From a5a5d30fce8045ab53dd6337e4b30a4c55ec7aeb Mon Sep 17 00:00:00 2001 From: Victor Vrantchan Date: Mon, 13 Mar 2017 17:14:38 -0400 Subject: [PATCH] remove legacy --- README.md | 27 +- cmd/squirrel/main.go | 165 - glide.lock | 137 - glide.yaml | 16 - munki/datastore/catalogs.go | 64 - munki/datastore/datastore.go | 57 - munki/datastore/manifest.go | 110 - munki/datastore/pkgsinfo.go | 123 - munki/munki/catalog.go | 9 - munki/munki/manifest.go | 81 - munki/munki/manifest_payload.go | 21 - munki/munki/pkgsinfo.go | 203 - munki/server/endpoint_manifest.go | 125 - munki/server/endpoint_pkgsinfo.go | 48 - munki/server/service.go | 20 - munki/server/service_manifest.go | 58 - munki/server/service_pkgsinfo.go | 27 - .../testdata/testrepo/manifests/site_default | 22 - munki/server/transport.go | 215 - munki/server/transport_manifest.go | 67 - munki/server/transport_manifest_test.go | 221 - munki/server/transport_pkgsinfo.go | 20 - munki/server/transport_pkgsinfo_test.go | 79 - munki/server/transport_test.go | 27 - .../yawning/chacha20.git/LICENSE | 122 - .../yawning/chacha20.git/README.md | 14 - .../yawning/chacha20.git/chacha20.go | 273 - .../yawning/chacha20.git/chacha20_amd64.go | 95 - .../yawning/chacha20.git/chacha20_amd64.py | 1303 -- .../yawning/chacha20.git/chacha20_amd64.s | 1187 -- .../yawning/chacha20.git/chacha20_ref.go | 392 - .../yawning/chacha20.git/chacha20_test.go | 523 - .../yawning/poly1305.git/.gitignore | 2 - .../yawning/poly1305.git/README.md | 17 - .../yawning/poly1305.git/poly1305.go | 207 - .../yawning/poly1305.git/poly1305_32.go | 236 - .../yawning/poly1305.git/poly1305_test.go | 585 - vendor/github.com/BurntSushi/toml/.gitignore | 5 - vendor/github.com/BurntSushi/toml/.travis.yml | 12 - vendor/github.com/BurntSushi/toml/COMPATIBLE | 3 - vendor/github.com/BurntSushi/toml/COPYING | 14 - vendor/github.com/BurntSushi/toml/Makefile | 19 - vendor/github.com/BurntSushi/toml/README.md | 220 - .../BurntSushi/toml/_examples/example.go | 61 - .../BurntSushi/toml/_examples/example.toml | 35 - .../BurntSushi/toml/_examples/hard.toml | 22 - .../BurntSushi/toml/_examples/implicit.toml | 4 - .../toml/_examples/invalid-apples.toml | 6 - .../BurntSushi/toml/_examples/invalid.toml | 35 - .../BurntSushi/toml/_examples/readme1.toml | 5 - .../BurntSushi/toml/_examples/readme2.toml | 1 - .../toml/cmd/toml-test-decoder/COPYING | 14 - .../toml/cmd/toml-test-decoder/README.md | 14 - .../toml/cmd/toml-test-decoder/main.go | 90 - .../toml/cmd/toml-test-encoder/COPYING | 14 - .../toml/cmd/toml-test-encoder/README.md | 14 - .../toml/cmd/toml-test-encoder/main.go | 131 - .../BurntSushi/toml/cmd/tomlv/COPYING | 14 - .../BurntSushi/toml/cmd/tomlv/README.md | 22 - .../BurntSushi/toml/cmd/tomlv/main.go | 61 - vendor/github.com/BurntSushi/toml/decode.go | 512 - .../github.com/BurntSushi/toml/decode_meta.go | 122 - .../github.com/BurntSushi/toml/decode_test.go | 1278 -- vendor/github.com/BurntSushi/toml/doc.go | 27 - vendor/github.com/BurntSushi/toml/encode.go | 569 - .../github.com/BurntSushi/toml/encode_test.go | 615 - .../BurntSushi/toml/encoding_types.go | 19 - .../BurntSushi/toml/encoding_types_1.1.go | 18 - vendor/github.com/BurntSushi/toml/lex.go | 866 - vendor/github.com/BurntSushi/toml/parse.go | 557 - vendor/github.com/BurntSushi/toml/session.vim | 1 - .../github.com/BurntSushi/toml/type_check.go | 91 - .../github.com/BurntSushi/toml/type_fields.go | 242 - .../github.com/abiosoft/caddy-git/.gitignore | 4 - .../github.com/abiosoft/caddy-git/.travis.yml | 7 - .../github.com/abiosoft/caddy-git/BUILDING.md | 43 - vendor/github.com/abiosoft/caddy-git/LICENSE | 21 - .../github.com/abiosoft/caddy-git/README.md | 116 - .../abiosoft/caddy-git/bitbucket_hook.go | 121 - .../abiosoft/caddy-git/bitbucket_hook_test.go | 98 - .../github.com/abiosoft/caddy-git/commands.go | 212 - .../github.com/abiosoft/caddy-git/config.json | 5 - .../abiosoft/caddy-git/generic_hook.go | 61 - .../abiosoft/caddy-git/generic_hook_test.go | 56 - vendor/github.com/abiosoft/caddy-git/git.go | 317 - .../github.com/abiosoft/caddy-git/git_test.go | 252 - .../abiosoft/caddy-git/github_hook.go | 147 - .../abiosoft/caddy-git/github_hook_test.go | 62 - .../abiosoft/caddy-git/gitlab_hook.go | 82 - .../abiosoft/caddy-git/gitlab_hook_test.go | 61 - .../abiosoft/caddy-git/gitos/gitos.go | 210 - .../abiosoft/caddy-git/gittest/gittest.go | 210 - .../abiosoft/caddy-git/gogs_hook.go | 87 - .../abiosoft/caddy-git/gogs_hook_test.go | 61 - .../github.com/abiosoft/caddy-git/logger.go | 38 - vendor/github.com/abiosoft/caddy-git/os.go | 12 - .../github.com/abiosoft/caddy-git/scripts.go | 116 - .../github.com/abiosoft/caddy-git/service.go | 90 - .../abiosoft/caddy-git/service_test.go | 67 - vendor/github.com/abiosoft/caddy-git/setup.go | 323 - .../abiosoft/caddy-git/setup_test.go | 285 - .../abiosoft/caddy-git/travis_hook.go | 95 - .../github.com/abiosoft/caddy-git/webhook.go | 124 - vendor/github.com/dgrijalva/jwt-go/.gitignore | 4 - .../github.com/dgrijalva/jwt-go/.travis.yml | 8 - vendor/github.com/dgrijalva/jwt-go/LICENSE | 8 - vendor/github.com/dgrijalva/jwt-go/README.md | 100 - .../dgrijalva/jwt-go/VERSION_HISTORY.md | 81 - .../dgrijalva/jwt-go/cmd/jwt/README.md | 13 - .../dgrijalva/jwt-go/cmd/jwt/app.go | 246 - vendor/github.com/dgrijalva/jwt-go/doc.go | 4 - vendor/github.com/dgrijalva/jwt-go/ecdsa.go | 147 - .../github.com/dgrijalva/jwt-go/ecdsa_test.go | 100 - .../dgrijalva/jwt-go/ecdsa_utils.go | 67 - vendor/github.com/dgrijalva/jwt-go/errors.go | 51 - .../dgrijalva/jwt-go/example_test.go | 52 - vendor/github.com/dgrijalva/jwt-go/hmac.go | 94 - .../github.com/dgrijalva/jwt-go/hmac_test.go | 91 - vendor/github.com/dgrijalva/jwt-go/none.go | 52 - .../github.com/dgrijalva/jwt-go/none_test.go | 72 - vendor/github.com/dgrijalva/jwt-go/parser.go | 140 - .../dgrijalva/jwt-go/parser_test.go | 275 - vendor/github.com/dgrijalva/jwt-go/rsa.go | 114 - vendor/github.com/dgrijalva/jwt-go/rsa_pss.go | 126 - .../dgrijalva/jwt-go/rsa_pss_test.go | 96 - .../github.com/dgrijalva/jwt-go/rsa_test.go | 174 - .../github.com/dgrijalva/jwt-go/rsa_utils.go | 69 - .../dgrijalva/jwt-go/signing_method.go | 24 - .../dgrijalva/jwt-go/test/ec256-private.pem | 5 - .../dgrijalva/jwt-go/test/ec256-public.pem | 4 - .../dgrijalva/jwt-go/test/ec384-private.pem | 6 - .../dgrijalva/jwt-go/test/ec384-public.pem | 5 - .../dgrijalva/jwt-go/test/ec512-private.pem | 7 - .../dgrijalva/jwt-go/test/ec512-public.pem | 6 - .../dgrijalva/jwt-go/test/hmacTestKey | 1 - .../dgrijalva/jwt-go/test/sample_key | 27 - .../dgrijalva/jwt-go/test/sample_key.pub | 9 - vendor/github.com/dgrijalva/jwt-go/token.go | 126 - .../github.com/dustin/go-humanize/.gitignore | 6 - .../github.com/dustin/go-humanize/.travis.yml | 18 - vendor/github.com/dustin/go-humanize/LICENSE | 21 - .../dustin/go-humanize/README.markdown | 92 - vendor/github.com/dustin/go-humanize/big.go | 31 - .../github.com/dustin/go-humanize/bigbytes.go | 164 - .../dustin/go-humanize/bigbytes_test.go | 219 - vendor/github.com/dustin/go-humanize/bytes.go | 134 - .../dustin/go-humanize/bytes_test.go | 144 - vendor/github.com/dustin/go-humanize/comma.go | 101 - .../dustin/go-humanize/comma_test.go | 134 - .../github.com/dustin/go-humanize/commaf.go | 40 - .../dustin/go-humanize/commaf_test.go | 44 - .../dustin/go-humanize/common_test.go | 18 - vendor/github.com/dustin/go-humanize/ftoa.go | 23 - .../dustin/go-humanize/ftoa_test.go | 55 - .../github.com/dustin/go-humanize/humanize.go | 8 - .../github.com/dustin/go-humanize/number.go | 192 - .../dustin/go-humanize/number_test.go | 78 - .../github.com/dustin/go-humanize/ordinals.go | 25 - .../dustin/go-humanize/ordinals_test.go | 22 - vendor/github.com/dustin/go-humanize/si.go | 113 - .../github.com/dustin/go-humanize/si_test.go | 101 - vendor/github.com/dustin/go-humanize/times.go | 90 - .../dustin/go-humanize/times_test.go | 71 - vendor/github.com/flynn/go-shlex/COPYING | 202 - vendor/github.com/flynn/go-shlex/Makefile | 21 - vendor/github.com/flynn/go-shlex/README.md | 2 - vendor/github.com/flynn/go-shlex/shlex.go | 457 - .../github.com/flynn/go-shlex/shlex_test.go | 162 - vendor/github.com/go-kit/kit/.gitignore | 45 - vendor/github.com/go-kit/kit/.travis.yml | 8 - vendor/github.com/go-kit/kit/CONTRIBUTING.md | 22 - vendor/github.com/go-kit/kit/LICENSE | 22 - vendor/github.com/go-kit/kit/README.md | 222 - .../go-kit/kit/circuitbreaker/gobreaker.go | 21 - .../kit/circuitbreaker/gobreaker_test.go | 19 - .../kit/circuitbreaker/handy_breaker.go | 38 - .../kit/circuitbreaker/handy_breaker_test.go | 20 - .../go-kit/kit/circuitbreaker/hystrix.go | 30 - .../go-kit/kit/circuitbreaker/hystrix_test.go | 40 - .../go-kit/kit/circuitbreaker/util_test.go | 76 - vendor/github.com/go-kit/kit/coverage.bash | 47 - .../go-kit/kit/endpoint/endpoint.go | 37 - .../kit/endpoint/endpoint_example_test.go | 50 - .../github.com/go-kit/kit/examples/README.md | 721 - .../kit/examples/addsvc/client/grpc/client.go | 75 - .../kit/examples/addsvc/client/http/client.go | 86 - .../examples/addsvc/client/thrift/client.go | 55 - .../kit/examples/addsvc/cmd/addcli/main.go | 178 - .../kit/examples/addsvc/cmd/addsvc/main.go | 257 - .../go-kit/kit/examples/addsvc/doc.go | 6 - .../go-kit/kit/examples/addsvc/endpoints.go | 136 - .../kit/examples/addsvc/pb/addsvc.pb.go | 215 - .../kit/examples/addsvc/pb/addsvc.proto | 36 - .../go-kit/kit/examples/addsvc/pb/compile.sh | 14 - .../go-kit/kit/examples/addsvc/service.go | 164 - .../kit/examples/addsvc/thrift/addsvc.thrift | 14 - .../kit/examples/addsvc/thrift/compile.sh | 5 - .../add_service-remote/add_service-remote.go | 157 - .../addsvc/thrift/gen-go/addsvc/addservice.go | 807 - .../addsvc/thrift/gen-go/addsvc/constants.go | 18 - .../addsvc/thrift/gen-go/addsvc/ttypes.go | 269 - .../kit/examples/addsvc/transport_grpc.go | 118 - .../kit/examples/addsvc/transport_http.go | 141 - .../kit/examples/addsvc/transport_thrift.go | 73 - .../go-kit/kit/examples/apigateway/main.go | 282 - .../go-kit/kit/examples/profilesvc/README.md | 4 - .../kit/examples/profilesvc/client/client.go | 120 - .../profilesvc/cmd/profilesvc/main.go | 59 - .../kit/examples/profilesvc/endpoints.go | 388 - .../kit/examples/profilesvc/middlewares.go | 89 - .../go-kit/kit/examples/profilesvc/service.go | 186 - .../kit/examples/profilesvc/transport.go | 410 - .../go-kit/kit/examples/shipping/README.md | 25 - .../kit/examples/shipping/booking/endpoint.go | 139 - .../shipping/booking/instrumenting.go | 95 - .../kit/examples/shipping/booking/logging.go | 101 - .../kit/examples/shipping/booking/service.go | 201 - .../examples/shipping/booking/transport.go | 201 - .../kit/examples/shipping/cargo/cargo.go | 137 - .../kit/examples/shipping/cargo/delivery.go | 174 - .../kit/examples/shipping/cargo/handling.go | 121 - .../kit/examples/shipping/cargo/itinerary.go | 91 - .../examples/shipping/handling/endpoint.go | 34 - .../shipping/handling/instrumenting.go | 38 - .../kit/examples/shipping/handling/logging.go | 37 - .../kit/examples/shipping/handling/service.go | 76 - .../examples/shipping/handling/transport.go | 100 - .../shipping/inspection/inspection.go | 51 - .../examples/shipping/location/location.go | 27 - .../shipping/location/sample_locations.go | 27 - .../go-kit/kit/examples/shipping/main.go | 203 - .../shipping/repository/repositories.go | 142 - .../kit/examples/shipping/routing/proxying.go | 117 - .../kit/examples/shipping/routing/routing.go | 13 - .../examples/shipping/tracking/endpoint.go | 26 - .../shipping/tracking/instrumenting.go | 32 - .../kit/examples/shipping/tracking/logging.go | 24 - .../kit/examples/shipping/tracking/service.go | 163 - .../examples/shipping/tracking/transport.go | 74 - .../shipping/voyage/sample_voyages.go | 40 - .../kit/examples/shipping/voyage/voyage.go | 44 - .../go-kit/kit/examples/stringsvc1/main.go | 115 - .../kit/examples/stringsvc2/instrumenting.go | 40 - .../go-kit/kit/examples/stringsvc2/logging.go | 41 - .../go-kit/kit/examples/stringsvc2/main.go | 65 - .../go-kit/kit/examples/stringsvc2/service.go | 28 - .../kit/examples/stringsvc2/transport.go | 66 - .../kit/examples/stringsvc3/instrumenting.go | 50 - .../go-kit/kit/examples/stringsvc3/logging.go | 47 - .../go-kit/kit/examples/stringsvc3/main.go | 75 - .../kit/examples/stringsvc3/proxying.go | 116 - .../go-kit/kit/examples/stringsvc3/service.go | 31 - .../kit/examples/stringsvc3/transport.go | 85 - vendor/github.com/go-kit/kit/lint | 26 - vendor/github.com/go-kit/kit/log/README.md | 147 - .../go-kit/kit/log/benchmark_test.go | 21 - .../go-kit/kit/log/concurrency_test.go | 28 - .../github.com/go-kit/kit/log/example_test.go | 23 - .../github.com/go-kit/kit/log/json_logger.go | 90 - .../go-kit/kit/log/json_logger_test.go | 156 - .../go-kit/kit/log/levels/levels.go | 127 - .../go-kit/kit/log/levels/levels_test.go | 65 - vendor/github.com/go-kit/kit/log/log.go | 181 - vendor/github.com/go-kit/kit/log/log_test.go | 255 - .../go-kit/kit/log/logfmt_logger.go | 61 - .../go-kit/kit/log/logfmt_logger_test.go | 55 - .../github.com/go-kit/kit/log/nop_logger.go | 8 - .../go-kit/kit/log/nop_logger_test.go | 17 - vendor/github.com/go-kit/kit/log/stdlib.go | 116 - .../github.com/go-kit/kit/log/stdlib_test.go | 205 - vendor/github.com/go-kit/kit/log/term/LICENSE | 21 - .../go-kit/kit/log/term/colorlogger.go | 144 - .../go-kit/kit/log/term/colorlogger_test.go | 88 - .../go-kit/kit/log/term/colorwriter_others.go | 12 - .../kit/log/term/colorwriter_windows.go | 190 - .../go-kit/kit/log/term/example_test.go | 57 - vendor/github.com/go-kit/kit/log/term/term.go | 22 - .../go-kit/kit/log/term/terminal_appengine.go | 15 - .../go-kit/kit/log/term/terminal_darwin.go | 10 - .../go-kit/kit/log/term/terminal_freebsd.go | 7 - .../go-kit/kit/log/term/terminal_linux.go | 12 - .../kit/log/term/terminal_notwindows.go | 25 - .../go-kit/kit/log/term/terminal_openbsd.go | 5 - .../go-kit/kit/log/term/terminal_windows.go | 31 - vendor/github.com/go-kit/kit/log/value.go | 62 - .../github.com/go-kit/kit/log/value_test.go | 109 - .../github.com/go-kit/kit/metrics/README.md | 83 - .../go-kit/kit/metrics/discard/discard.go | 43 - .../go-kit/kit/metrics/dogstatsd/dogstatsd.go | 248 - .../kit/metrics/dogstatsd/dogstatsd_test.go | 266 - .../go-kit/kit/metrics/dogstatsd/emitter.go | 159 - .../go-kit/kit/metrics/expvar/expvar.go | 172 - .../go-kit/kit/metrics/expvar/expvar_test.go | 69 - .../go-kit/kit/metrics/graphite/emitter.go | 159 - .../go-kit/kit/metrics/graphite/graphite.go | 186 - .../kit/metrics/graphite/graphite_test.go | 80 - .../go-kit/kit/metrics/influxdb/influxdb.go | 254 - .../kit/metrics/influxdb/influxdb_test.go | 348 - .../github.com/go-kit/kit/metrics/metrics.go | 55 - vendor/github.com/go-kit/kit/metrics/multi.go | 112 - .../go-kit/kit/metrics/multi_test.go | 233 - vendor/github.com/go-kit/kit/metrics/print.go | 42 - .../go-kit/kit/metrics/print_test.go | 40 - .../kit/metrics/prometheus/prometheus.go | 202 - .../kit/metrics/prometheus/prometheus_test.go | 130 - .../go-kit/kit/metrics/provider/providers.go | 259 - .../kit/metrics/provider/providers_test.go | 56 - .../go-kit/kit/metrics/scaled_histogram.go | 23 - .../kit/metrics/scaled_histogram_test.go | 26 - .../go-kit/kit/metrics/statsd/emitter.go | 159 - .../go-kit/kit/metrics/statsd/statsd.go | 215 - .../go-kit/kit/metrics/statsd/statsd_test.go | 259 - .../go-kit/kit/metrics/teststat/circonus.go | 55 - .../go-kit/kit/metrics/teststat/common.go | 73 - .../go-kit/kit/metrics/teststat/expvar.go | 26 - .../go-kit/kit/metrics/teststat/graphite.go | 63 - .../go-kit/kit/metrics/teststat/prometheus.go | 93 - .../go-kit/kit/metrics/time_histogram.go | 34 - .../go-kit/kit/metrics/time_histogram_test.go | 32 - .../go-kit/kit/ratelimit/token_bucket.go | 42 - .../go-kit/kit/ratelimit/token_bucket_test.go | 55 - .../go-kit/kit/sd/cache/benchmark_test.go | 29 - .../github.com/go-kit/kit/sd/cache/cache.go | 96 - .../go-kit/kit/sd/cache/cache_test.go | 91 - .../github.com/go-kit/kit/sd/consul/client.go | 37 - .../go-kit/kit/sd/consul/client_test.go | 156 - .../go-kit/kit/sd/consul/integration_test.go | 86 - .../go-kit/kit/sd/consul/registrar.go | 44 - .../go-kit/kit/sd/consul/registrar_test.go | 27 - .../go-kit/kit/sd/consul/subscriber.go | 166 - .../go-kit/kit/sd/consul/subscriber_test.go | 138 - .../github.com/go-kit/kit/sd/dnssrv/lookup.go | 7 - .../go-kit/kit/sd/dnssrv/subscriber.go | 100 - .../go-kit/kit/sd/dnssrv/subscriber_test.go | 85 - vendor/github.com/go-kit/kit/sd/doc.go | 5 - .../github.com/go-kit/kit/sd/etcd/client.go | 131 - .../go-kit/kit/sd/etcd/subscriber.go | 74 - .../go-kit/kit/sd/etcd/subscriber_test.go | 89 - vendor/github.com/go-kit/kit/sd/factory.go | 17 - .../go-kit/kit/sd/fixed_subscriber.go | 9 - .../github.com/go-kit/kit/sd/lb/balancer.go | 15 - vendor/github.com/go-kit/kit/sd/lb/doc.go | 5 - vendor/github.com/go-kit/kit/sd/lb/random.go | 32 - .../go-kit/kit/sd/lb/random_test.go | 52 - vendor/github.com/go-kit/kit/sd/lb/retry.go | 57 - .../github.com/go-kit/kit/sd/lb/retry_test.go | 90 - .../go-kit/kit/sd/lb/round_robin.go | 34 - .../go-kit/kit/sd/lb/round_robin_test.go | 96 - vendor/github.com/go-kit/kit/sd/registrar.go | 13 - vendor/github.com/go-kit/kit/sd/subscriber.go | 11 - vendor/github.com/go-kit/kit/sd/zk/client.go | 273 - .../go-kit/kit/sd/zk/client_test.go | 157 - .../go-kit/kit/sd/zk/integration_test.go | 212 - .../github.com/go-kit/kit/sd/zk/logwrapper.go | 27 - .../github.com/go-kit/kit/sd/zk/registrar.go | 51 - .../github.com/go-kit/kit/sd/zk/subscriber.go | 86 - .../go-kit/kit/sd/zk/subscriber_test.go | 117 - .../github.com/go-kit/kit/sd/zk/util_test.go | 134 - .../github.com/go-kit/kit/tracing/README.md | 60 - .../kit/tracing/opentracing/endpoint.go | 50 - .../kit/tracing/opentracing/endpoint_test.go | 96 - .../go-kit/kit/tracing/opentracing/grpc.go | 74 - .../kit/tracing/opentracing/grpc_test.go | 59 - .../go-kit/kit/tracing/opentracing/http.go | 73 - .../kit/tracing/opentracing/http_test.go | 59 - .../go-kit/kit/tracing/zipkin/README.md | 168 - .../tracing/zipkin/docker-compose-zipkin.yml | 76 - .../go-kit/kit/transport/grpc/README.md | 37 - .../go-kit/kit/transport/grpc/client.go | 102 - .../kit/transport/grpc/encode_decode.go | 27 - .../transport/grpc/request_response_funcs.go | 53 - .../go-kit/kit/transport/grpc/server.go | 129 - .../go-kit/kit/transport/http/client.go | 115 - .../go-kit/kit/transport/http/client_test.go | 149 - .../kit/transport/http/encode_decode.go | 31 - .../go-kit/kit/transport/http/err.go | 33 - .../go-kit/kit/transport/http/err_test.go | 56 - .../transport/http/request_response_funcs.go | 45 - .../http/request_response_funcs_test.go | 31 - .../go-kit/kit/transport/http/server.go | 134 - .../go-kit/kit/transport/http/server_test.go | 120 - .../go-kit/kit/transport/httprp/README.md | 48 - .../go-kit/kit/transport/httprp/server.go | 62 - .../kit/transport/httprp/server_test.go | 120 - .../go-kit/kit/transport/netrpc/README.md | 14 - .../go-kit/kit/transport/thrift/README.md | 32 - vendor/github.com/go-kit/kit/update_deps.bash | 28 - vendor/github.com/go-kit/kit/util/README.md | 5 - vendor/github.com/go-kit/kit/util/conn/doc.go | 2 - .../go-kit/kit/util/conn/manager.go | 124 - .../go-kit/kit/util/conn/manager_test.go | 159 - vendor/github.com/go-logfmt/logfmt/.gitignore | 4 - .../github.com/go-logfmt/logfmt/.travis.yml | 15 - vendor/github.com/go-logfmt/logfmt/LICENSE | 22 - vendor/github.com/go-logfmt/logfmt/README.md | 33 - .../go-logfmt/logfmt/decode-bench_test.go | 75 - vendor/github.com/go-logfmt/logfmt/decode.go | 222 - .../go-logfmt/logfmt/decode_test.go | 181 - vendor/github.com/go-logfmt/logfmt/doc.go | 6 - vendor/github.com/go-logfmt/logfmt/encode.go | 312 - .../go-logfmt/logfmt/encode_internal_test.go | 233 - .../go-logfmt/logfmt/encode_test.go | 199 - .../go-logfmt/logfmt/example_test.go | 60 - vendor/github.com/go-logfmt/logfmt/fuzz.go | 125 - .../github.com/go-logfmt/logfmt/jsonstring.go | 277 - vendor/github.com/go-stack/stack/.travis.yml | 16 - vendor/github.com/go-stack/stack/LICENSE.md | 13 - vendor/github.com/go-stack/stack/README.md | 38 - .../github.com/go-stack/stack/format_test.go | 21 - vendor/github.com/go-stack/stack/stack.go | 349 - .../github.com/go-stack/stack/stack_test.go | 398 - .../go-stack/stack/stackinternal_test.go | 65 - .../github.com/gorilla/websocket/.gitignore | 25 - .../github.com/gorilla/websocket/.travis.yml | 17 - vendor/github.com/gorilla/websocket/AUTHORS | 8 - vendor/github.com/gorilla/websocket/LICENSE | 22 - vendor/github.com/gorilla/websocket/README.md | 61 - .../gorilla/websocket/bench_test.go | 19 - vendor/github.com/gorilla/websocket/client.go | 375 - .../gorilla/websocket/client_server_test.go | 451 - .../gorilla/websocket/client_test.go | 72 - vendor/github.com/gorilla/websocket/conn.go | 951 - .../github.com/gorilla/websocket/conn_read.go | 18 - .../gorilla/websocket/conn_read_legacy.go | 21 - .../github.com/gorilla/websocket/conn_test.go | 402 - vendor/github.com/gorilla/websocket/doc.go | 152 - .../gorilla/websocket/example_test.go | 46 - .../websocket/examples/autobahn/README.md | 13 - .../examples/autobahn/fuzzingclient.json | 14 - .../websocket/examples/autobahn/server.go | 246 - .../gorilla/websocket/examples/chat/README.md | 20 - .../gorilla/websocket/examples/chat/conn.go | 129 - .../gorilla/websocket/examples/chat/home.html | 94 - .../gorilla/websocket/examples/chat/hub.go | 51 - .../gorilla/websocket/examples/chat/main.go | 39 - .../websocket/examples/command/README.md | 19 - .../websocket/examples/command/home.html | 96 - .../websocket/examples/command/main.go | 188 - .../gorilla/websocket/examples/echo/README.md | 17 - .../gorilla/websocket/examples/echo/client.go | 81 - .../gorilla/websocket/examples/echo/server.go | 132 - .../websocket/examples/filewatch/README.md | 9 - .../websocket/examples/filewatch/main.go | 193 - vendor/github.com/gorilla/websocket/json.go | 55 - .../github.com/gorilla/websocket/json_test.go | 119 - vendor/github.com/gorilla/websocket/server.go | 260 - .../gorilla/websocket/server_test.go | 51 - vendor/github.com/gorilla/websocket/util.go | 214 - .../github.com/gorilla/websocket/util_test.go | 74 - vendor/github.com/groob/plist/LICENSE | 91 - vendor/github.com/groob/plist/README.md | 4 - vendor/github.com/groob/plist/decode.go | 266 - vendor/github.com/groob/plist/decode_test.go | 217 - vendor/github.com/groob/plist/encode.go | 195 - vendor/github.com/groob/plist/encode_test.go | 240 - vendor/github.com/groob/plist/plist.go | 76 - vendor/github.com/groob/plist/tags.go | 304 - vendor/github.com/groob/plist/xml_parser.go | 187 - vendor/github.com/groob/plist/xml_writer.go | 231 - .../github.com/hashicorp/go-syslog/.gitignore | 22 - vendor/github.com/hashicorp/go-syslog/LICENSE | 20 - .../github.com/hashicorp/go-syslog/README.md | 11 - .../github.com/hashicorp/go-syslog/builtin.go | 214 - .../github.com/hashicorp/go-syslog/syslog.go | 27 - vendor/github.com/hashicorp/go-syslog/unix.go | 106 - .../hashicorp/go-syslog/unsupported.go | 12 - .../jimstudt/http-authentication/LICENSE | 21 - .../jimstudt/http-authentication/README.md | 13 - .../http-authentication/basic/README.md | 65 - .../http-authentication/basic/bcrypt.go | 15 - .../http-authentication/basic/bcrypt_test.go | 11 - .../http-authentication/basic/htpasswd.go | 208 - .../basic/htpasswd_test.go | 1079 -- .../jimstudt/http-authentication/basic/md5.go | 143 - .../http-authentication/basic/md5_test.go | 233 - .../http-authentication/basic/plain.go | 28 - .../http-authentication/basic/plain_test.go | 11 - .../jimstudt/http-authentication/basic/sha.go | 43 - .../http-authentication/basic/sha_test.go | 222 - .../http-authentication/basic/util.go | 18 - .../http-authentication/basic/util_test.go | 70 - .../http-authentication/digest/README.md | 83 - .../http-authentication/digest/digest.go | 339 - .../http-authentication/digest/digest_test.go | 172 - .../digest/htdigest-user-store.go | 97 - .../http-authentication/digest/parse.go | 154 - .../digest/simple-nonce-store.go | 79 - .../digest/simple-nonce.go | 71 - .../digest/simple-user-store.go | 25 - .../julienschmidt/httprouter/.travis.yml | 10 - .../julienschmidt/httprouter/LICENSE | 24 - .../julienschmidt/httprouter/README.md | 289 - .../julienschmidt/httprouter/path.go | 123 - .../julienschmidt/httprouter/path_test.go | 92 - .../julienschmidt/httprouter/router.go | 411 - .../julienschmidt/httprouter/router_test.go | 530 - .../julienschmidt/httprouter/tree.go | 649 - .../julienschmidt/httprouter/tree_test.go | 659 - vendor/github.com/kr/logfmt/.gitignore | 3 - vendor/github.com/kr/logfmt/Readme | 12 - vendor/github.com/kr/logfmt/bench_test.go | 59 - vendor/github.com/kr/logfmt/decode.go | 184 - vendor/github.com/kr/logfmt/decode_test.go | 110 - vendor/github.com/kr/logfmt/example_test.go | 59 - vendor/github.com/kr/logfmt/scanner.go | 149 - vendor/github.com/kr/logfmt/scanner_test.go | 67 - vendor/github.com/kr/logfmt/unquote.go | 149 - .../lucas-clemente/chacha20poly1305/LICENSE | 122 - .../lucas-clemente/chacha20poly1305/README.md | 5 - .../lucas-clemente/chacha20poly1305/aead.go | 217 - .../chacha20poly1305/aead_test.go | 160 - .../github.com/lucas-clemente/fnv128a/LICENSE | 21 - .../lucas-clemente/fnv128a/README.md | 3 - .../lucas-clemente/fnv128a/fnv128a.go | 87 - .../lucas-clemente/fnv128a/fnv128a_test.go | 24 - .../quic-go-certificates/README.md | 3 - .../quic-go-certificates/cert_set_1.go | 6615 ------- .../quic-go-certificates/cert_set_2.go | 5824 ------ .../quic-go-certificates/createCertSets.rb | 34 - .../lucas-clemente/quic-go/.editorconfig | 5 - .../lucas-clemente/quic-go/.gitignore | 3 - .../lucas-clemente/quic-go/.travis.yml | 34 - .../quic-go/.travis/after_success.sh | 9 - .../lucas-clemente/quic-go/.travis/script.sh | 12 - .../github.com/lucas-clemente/quic-go/LICENSE | 19 - .../lucas-clemente/quic-go/README.md | 67 - .../ackhandler/ackhandler_suite_test.go | 13 - .../quic-go/ackhandler/entropy_accumulator.go | 23 - .../ackhandler/entropy_accumulator_test.go | 41 - .../quic-go/ackhandler/interfaces.go | 41 - .../quic-go/ackhandler/packet.go | 51 - .../quic-go/ackhandler/packet_test.go | 97 - .../ackhandler/received_packet_handler.go | 154 - .../received_packet_handler_test.go | 369 - .../quic-go/ackhandler/sent_packet_handler.go | 339 - .../ackhandler/sent_packet_handler_test.go | 735 - .../ackhandler/stop_waiting_manager.go | 58 - .../ackhandler/stop_waiting_manager_test.go | 87 - .../lucas-clemente/quic-go/appveyor.yml | 34 - .../lucas-clemente/quic-go/blocked_manager.go | 49 - .../quic-go/blocked_manager_test.go | 54 - .../lucas-clemente/quic-go/codecov.yml | 3 - .../quic-go/congestion/bandwidth.go | 26 - .../quic-go/congestion/bandwidth_test.go | 14 - .../quic-go/congestion/clock.go | 18 - .../congestion/congestion_suite_test.go | 13 - .../quic-go/congestion/congestion_vector.go | 12 - .../quic-go/congestion/cubic.go | 218 - .../quic-go/congestion/cubic_sender.go | 309 - .../quic-go/congestion/cubic_sender_test.go | 821 - .../quic-go/congestion/cubic_test.go | 97 - .../quic-go/congestion/hybrid_slow_start.go | 111 - .../congestion/hybrid_slow_start_test.go | 75 - .../quic-go/congestion/interface.go | 35 - .../quic-go/congestion/prr_sender.go | 63 - .../quic-go/congestion/prr_sender_test.go | 108 - .../quic-go/congestion/rtt_stats.go | 182 - .../quic-go/congestion/rtt_stats_test.go | 214 - .../quic-go/congestion/stats.go | 8 - .../lucas-clemente/quic-go/crypto/AEAD.go | 9 - .../quic-go/crypto/cert_compression.go | 156 - .../quic-go/crypto/cert_compression_test.go | 164 - .../quic-go/crypto/cert_dict.go | 128 - .../quic-go/crypto/cert_sets.go | 24 - .../quic-go/crypto/chacha20poly1305_aead.go | 58 - .../crypto/chacha20poly1305_aead_test.go | 64 - .../quic-go/crypto/crypto_suite_test.go | 13 - .../quic-go/crypto/curve_25519.go | 46 - .../quic-go/crypto/curve_25519_test.go | 27 - .../quic-go/crypto/key_derivation.go | 71 - .../quic-go/crypto/key_derivation_test.go | 86 - .../quic-go/crypto/key_exchange.go | 7 - .../quic-go/crypto/null_aead.go | 49 - .../quic-go/crypto/null_aead_test.go | 41 - .../quic-go/crypto/proof_source.go | 97 - .../quic-go/crypto/proof_source_test.go | 190 - .../lucas-clemente/quic-go/crypto/signer.go | 8 - .../quic-go/crypto/source_address_token.go | 128 - .../crypto/source_address_token_test.go | 118 - .../lucas-clemente/quic-go/docs/quic.png | Bin 17299 -> 0 bytes .../lucas-clemente/quic-go/docs/quic.sketch | Bin 90112 -> 0 bytes .../lucas-clemente/quic-go/docs/quic.svg | 65 - .../lucas-clemente/quic-go/example/Dockerfile | 9 - .../lucas-clemente/quic-go/example/cert.der | Bin 1288 -> 0 bytes .../lucas-clemente/quic-go/example/chain.der | Bin 1174 -> 0 bytes .../quic-go/example/fullchain.der | Bin 1288 -> 0 bytes .../quic-go/example/fullchain.pem | 56 - .../lucas-clemente/quic-go/example/key.der | Bin 1193 -> 0 bytes .../lucas-clemente/quic-go/example/main.go | 141 - .../quic-go/example/privkey.pem | 28 - .../flowcontrol/flow_control_manager.go | 128 - .../flowcontrol/flow_control_manager_test.go | 107 - .../quic-go/flowcontrol/flow_controller.go | 163 - .../flowcontrol/flow_controller_test.go | 217 - .../flowcontrol/flowcontrol_suite_test.go | 13 - .../quic-go/flowcontrol/interface.go | 25 - .../quic-go/frames/ack_frame.go | 317 - .../quic-go/frames/ack_frame_test.go | 587 - .../quic-go/frames/blocked_frame.go | 44 - .../quic-go/frames/blocked_frame_test.go | 41 - .../quic-go/frames/connection_close_frame.go | 73 - .../frames/connection_close_frame_test.go | 103 - .../lucas-clemente/quic-go/frames/frame.go | 13 - .../quic-go/frames/frames_suite_test.go | 13 - .../quic-go/frames/goaway_frame.go | 73 - .../quic-go/frames/goaway_frame_test.go | 70 - .../lucas-clemente/quic-go/frames/log.go | 19 - .../lucas-clemente/quic-go/frames/log_test.go | 49 - .../quic-go/frames/nack_range.go | 22 - .../quic-go/frames/nack_range_test.go | 39 - .../quic-go/frames/ping_frame.go | 33 - .../quic-go/frames/ping_frame_test.go | 34 - .../quic-go/frames/rst_stream_frame.go | 59 - .../quic-go/frames/rst_stream_frame_test.go | 44 - .../quic-go/frames/stop_waiting_frame.go | 95 - .../quic-go/frames/stop_waiting_frame_test.go | 166 - .../quic-go/frames/stream_frame.go | 210 - .../quic-go/frames/stream_frame_test.go | 402 - .../quic-go/frames/window_update_frame.go | 54 - .../frames/window_update_frame_test.go | 42 - .../quic-go/h2quic/h2quic_suite_test.go | 13 - .../lucas-clemente/quic-go/h2quic/request.go | 51 - .../quic-go/h2quic/request_test.go | 75 - .../quic-go/h2quic/response_writer.go | 70 - .../quic-go/h2quic/response_writer_test.go | 81 - .../lucas-clemente/quic-go/h2quic/server.go | 229 - .../quic-go/h2quic/server_test.go | 327 - .../connection_parameters_manager.go | 206 - .../connection_parameters_manager_test.go | 228 - .../quic-go/handshake/crypto_setup.go | 335 - .../quic-go/handshake/crypto_setup_test.go | 403 - .../quic-go/handshake/data_test.go | 24 - .../quic-go/handshake/handshake_message.go | 116 - .../handshake/handshake_message_test.go | 45 - .../quic-go/handshake/handshake_suite_test.go | 13 - .../quic-go/handshake/server_config.go | 67 - .../quic-go/handshake/server_config_test.go | 34 - .../lucas-clemente/quic-go/handshake/tags.go | 83 - .../quic-go/integrationtests/chrome_test.go | 72 - .../quic-go/integrationtests/drop.go | 1 - .../quic-go/integrationtests/drop_test.go | 79 - .../quic-go/integrationtests/integration.go | 1 - .../integrationtests/integration_test.go | 104 - .../integrationtests_suite_test.go | 156 - .../quic-go/integrationtests/udp_proxy.go | 150 - .../integrationtests/udp_proxy_test.go | 232 - .../lucas-clemente/quic-go/packet_packer.go | 258 - .../quic-go/packet_packer_test.go | 480 - .../lucas-clemente/quic-go/packet_unpacker.go | 123 - .../quic-go/packet_unpacker_test.go | 203 - .../quic-go/protocol/packet_number.go | 58 - .../quic-go/protocol/packet_number_test.go | 225 - .../quic-go/protocol/protocol.go | 66 - .../quic-go/protocol/protocol_suite_test.go | 13 - .../quic-go/protocol/server_parameters.go | 75 - .../quic-go/protocol/version.go | 68 - .../quic-go/protocol/version_test.go | 31 - .../lucas-clemente/quic-go/public_header.go | 181 - .../quic-go/public_header_test.go | 303 - .../lucas-clemente/quic-go/public_reset.go | 24 - .../quic-go/public_reset_test.go | 25 - .../quic-go/qerr/error_codes.go | 190 - .../quic-go/qerr/errorcode_string.go | 43 - .../quic-go/qerr/errorcodes_test.go | 33 - .../quic-go/qerr/errors_suite_test.go | 13 - .../lucas-clemente/quic-go/qerr/quic_error.go | 45 - .../quic-go/qerr/quic_error_test.go | 40 - .../lucas-clemente/quic-go/quic_suite_test.go | 13 - .../lucas-clemente/quic-go/server.go | 200 - .../lucas-clemente/quic-go/server_test.go | 165 - .../lucas-clemente/quic-go/session.go | 698 - .../lucas-clemente/quic-go/session_test.go | 768 - .../lucas-clemente/quic-go/stream.go | 336 - .../quic-go/stream_frame_queue.go | 227 - .../quic-go/stream_frame_queue_test.go | 473 - .../quic-go/stream_frame_sorter.go | 120 - .../quic-go/stream_frame_sorter_test.go | 420 - .../lucas-clemente/quic-go/stream_test.go | 704 - .../lucas-clemente/quic-go/testdata/cert.go | 31 - .../lucas-clemente/quic-go/udp_conn.go | 29 - .../lucas-clemente/quic-go/utils/_gen.go | 7 - .../quic-go/utils/byteinterval_linkedlist.go | 214 - .../quic-go/utils/caching_reader.go | 35 - .../quic-go/utils/caching_reader_test.go | 36 - .../lucas-clemente/quic-go/utils/float16.go | 86 - .../quic-go/utils/float16_test.go | 150 - .../lucas-clemente/quic-go/utils/log.go | 70 - .../lucas-clemente/quic-go/utils/log_test.go | 63 - .../lucas-clemente/quic-go/utils/minmax.go | 123 - .../quic-go/utils/minmax_test.go | 87 - .../quic-go/utils/ringbuffer.go | 95 - .../quic-go/utils/ringbuffer_test.go | 188 - .../quic-go/utils/streamframe_interval.go | 10 - .../lucas-clemente/quic-go/utils/utils.go | 178 - .../quic-go/utils/utils_suite_test.go | 13 - .../quic-go/utils/utils_test.go | 221 - .../quic-go/window_update_manager.go | 74 - .../quic-go/window_update_manager_test.go | 86 - vendor/github.com/mholt/caddy/.gitattributes | 14 - vendor/github.com/mholt/caddy/.gitignore | 16 - vendor/github.com/mholt/caddy/.travis.yml | 30 - vendor/github.com/mholt/caddy/CONTRIBUTING.md | 105 - vendor/github.com/mholt/caddy/ISSUE_TEMPLATE | 24 - vendor/github.com/mholt/caddy/LICENSE.txt | 201 - vendor/github.com/mholt/caddy/README.md | 172 - vendor/github.com/mholt/caddy/appveyor.yml | 32 - vendor/github.com/mholt/caddy/assets.go | 34 - vendor/github.com/mholt/caddy/assets_test.go | 19 - vendor/github.com/mholt/caddy/caddy.go | 743 - .../github.com/mholt/caddy/caddy/build.bash | 56 - .../mholt/caddy/caddy/caddymain/run.go | 279 - vendor/github.com/mholt/caddy/caddy/main.go | 7 - vendor/github.com/mholt/caddy/caddy_test.go | 58 - .../caddy/caddyhttp/basicauth/basicauth.go | 148 - .../caddyhttp/basicauth/basicauth_test.go | 146 - .../mholt/caddy/caddyhttp/basicauth/setup.go | 82 - .../caddy/caddyhttp/basicauth/setup_test.go | 131 - .../mholt/caddy/caddyhttp/bind/bind.go | 24 - .../mholt/caddy/caddyhttp/bind/bind_test.go | 23 - .../mholt/caddy/caddyhttp/browse/browse.go | 432 - .../caddy/caddyhttp/browse/browse_test.go | 355 - .../mholt/caddy/caddyhttp/browse/setup.go | 427 - .../caddy/caddyhttp/browse/setup_test.go | 68 - .../caddyhttp/browse/testdata/header.html | 1 - .../caddyhttp/browse/testdata/photos.tpl | 13 - .../browse/testdata/photos/test.html | 8 - .../browse/testdata/photos/test2.html | 8 - .../browse/testdata/photos/test3.html | 3 - .../mholt/caddy/caddyhttp/caddyhttp.go | 29 - .../mholt/caddy/caddyhttp/errors/errors.go | 140 - .../caddy/caddyhttp/errors/errors_test.go | 168 - .../mholt/caddy/caddyhttp/errors/setup.go | 152 - .../caddy/caddyhttp/errors/setup_test.go | 154 - .../mholt/caddy/caddyhttp/expvar/expvar.go | 45 - .../caddy/caddyhttp/expvar/expvar_test.go | 46 - .../mholt/caddy/caddyhttp/expvar/setup.go | 69 - .../caddy/caddyhttp/expvar/setup_test.go | 40 - .../mholt/caddy/caddyhttp/extensions/ext.go | 52 - .../mholt/caddy/caddyhttp/extensions/setup.go | 53 - .../caddy/caddyhttp/extensions/setup_test.go | 74 - .../mholt/caddy/caddyhttp/fastcgi/fastcgi.go | 336 - .../caddy/caddyhttp/fastcgi/fastcgi_test.go | 160 - .../caddy/caddyhttp/fastcgi/fcgi_test.php | 79 - .../caddy/caddyhttp/fastcgi/fcgiclient.go | 560 - .../caddyhttp/fastcgi/fcgiclient_test.go | 275 - .../mholt/caddy/caddyhttp/fastcgi/setup.go | 126 - .../caddy/caddyhttp/fastcgi/setup_test.go | 121 - .../mholt/caddy/caddyhttp/gzip/gzip.go | 167 - .../mholt/caddy/caddyhttp/gzip/gzip_test.go | 122 - .../caddy/caddyhttp/gzip/requestfilter.go | 91 - .../caddyhttp/gzip/requestfilter_test.go | 113 - .../caddy/caddyhttp/gzip/responsefilter.go | 79 - .../caddyhttp/gzip/responsefilter_test.go | 89 - .../mholt/caddy/caddyhttp/gzip/setup.go | 119 - .../mholt/caddy/caddyhttp/gzip/setup_test.go | 100 - .../caddy/caddyhttp/gzip/testdata/test.txt | 199 - .../mholt/caddy/caddyhttp/header/header.go | 51 - .../caddy/caddyhttp/header/header_test.go | 57 - .../mholt/caddy/caddyhttp/header/setup.go | 93 - .../caddy/caddyhttp/header/setup_test.go | 85 - .../caddy/caddyhttp/httpserver/context.go | 263 - .../caddyhttp/httpserver/context_test.go | 650 - .../caddy/caddyhttp/httpserver/graceful.go | 80 - .../mholt/caddy/caddyhttp/httpserver/https.go | 154 - .../caddy/caddyhttp/httpserver/https_test.go | 178 - .../caddy/caddyhttp/httpserver/middleware.go | 156 - .../caddyhttp/httpserver/middleware_test.go | 58 - .../caddy/caddyhttp/httpserver/plugin.go | 400 - .../caddy/caddyhttp/httpserver/plugin_test.go | 114 - .../caddy/caddyhttp/httpserver/recorder.go | 98 - .../caddyhttp/httpserver/recorder_test.go | 40 - .../caddy/caddyhttp/httpserver/replacer.go | 178 - .../caddyhttp/httpserver/replacer_test.go | 140 - .../caddy/caddyhttp/httpserver/roller.go | 64 - .../caddy/caddyhttp/httpserver/server.go | 389 - .../caddy/caddyhttp/httpserver/server_test.go | 15 - .../caddy/caddyhttp/httpserver/siteconfig.go | 53 - .../caddy/caddyhttp/httpserver/vhosttrie.go | 139 - .../caddyhttp/httpserver/vhosttrie_test.go | 141 - .../caddy/caddyhttp/internalsrv/internal.go | 93 - .../caddyhttp/internalsrv/internal_test.go | 64 - .../caddy/caddyhttp/internalsrv/setup.go | 40 - .../caddy/caddyhttp/internalsrv/setup_test.go | 69 - .../mholt/caddy/caddyhttp/log/log.go | 83 - .../mholt/caddy/caddyhttp/log/log_test.go | 62 - .../mholt/caddy/caddyhttp/log/setup.go | 131 - .../mholt/caddy/caddyhttp/log/setup_test.go | 174 - .../caddy/caddyhttp/markdown/markdown.go | 171 - .../caddy/caddyhttp/markdown/markdown_test.go | 230 - .../caddyhttp/markdown/metadata/metadata.go | 158 - .../markdown/metadata/metadata_json.go | 53 - .../markdown/metadata/metadata_none.go | 39 - .../markdown/metadata/metadata_test.go | 261 - .../markdown/metadata/metadata_toml.go | 44 - .../markdown/metadata/metadata_yaml.go | 43 - .../mholt/caddy/caddyhttp/markdown/process.go | 74 - .../mholt/caddy/caddyhttp/markdown/setup.go | 140 - .../caddy/caddyhttp/markdown/setup_test.go | 152 - .../caddyhttp/markdown/summary/render.go | 153 - .../caddyhttp/markdown/summary/summary.go | 17 - .../caddy/caddyhttp/markdown/template.go | 88 - .../mholt/caddy/caddyhttp/mime/mime.go | 31 - .../mholt/caddy/caddyhttp/mime/mime_test.go | 69 - .../mholt/caddy/caddyhttp/mime/setup.go | 74 - .../mholt/caddy/caddyhttp/mime/setup_test.go | 62 - .../mholt/caddy/caddyhttp/pprof/pprof.go | 41 - .../mholt/caddy/caddyhttp/pprof/pprof_test.go | 55 - .../mholt/caddy/caddyhttp/pprof/setup.go | 37 - .../mholt/caddy/caddyhttp/pprof/setup_test.go | 31 - .../mholt/caddy/caddyhttp/proxy/policy.go | 103 - .../caddy/caddyhttp/proxy/policy_test.go | 105 - .../mholt/caddy/caddyhttp/proxy/proxy.go | 242 - .../mholt/caddy/caddyhttp/proxy/proxy_test.go | 583 - .../caddy/caddyhttp/proxy/reverseproxy.go | 269 - .../mholt/caddy/caddyhttp/proxy/setup.go | 25 - .../mholt/caddy/caddyhttp/proxy/setup_test.go | 140 - .../mholt/caddy/caddyhttp/proxy/upstream.go | 349 - .../caddy/caddyhttp/proxy/upstream_test.go | 175 - .../caddy/caddyhttp/redirect/redirect.go | 58 - .../caddy/caddyhttp/redirect/redirect_test.go | 154 - .../mholt/caddy/caddyhttp/redirect/setup.go | 184 - .../caddy/caddyhttp/redirect/setup_test.go | 69 - .../caddy/caddyhttp/rewrite/condition.go | 130 - .../caddy/caddyhttp/rewrite/condition_test.go | 106 - .../mholt/caddy/caddyhttp/rewrite/rewrite.go | 236 - .../caddy/caddyhttp/rewrite/rewrite_test.go | 163 - .../mholt/caddy/caddyhttp/rewrite/setup.go | 120 - .../caddy/caddyhttp/rewrite/setup_test.go | 239 - .../caddyhttp/rewrite/testdata/testdir/empty | 0 .../caddy/caddyhttp/rewrite/testdata/testfile | 1 - .../mholt/caddy/caddyhttp/rewrite/to.go | 94 - .../mholt/caddy/caddyhttp/rewrite/to_test.go | 45 - .../mholt/caddy/caddyhttp/root/root.go | 41 - .../mholt/caddy/caddyhttp/root/root_test.go | 104 - .../caddy/caddyhttp/staticfiles/fileserver.go | 171 - .../caddyhttp/staticfiles/fileserver_test.go | 389 - .../mholt/caddy/caddyhttp/templates/setup.go | 101 - .../caddy/caddyhttp/templates/setup_test.go | 107 - .../caddy/caddyhttp/templates/templates.go | 96 - .../caddyhttp/templates/templates_test.go | 138 - .../caddyhttp/templates/testdata/header.html | 1 - .../templates/testdata/images/header.html | 1 - .../templates/testdata/images/img.htm | 1 - .../templates/testdata/images/img2.htm | 1 - .../templates/testdata/photos/test.html | 1 - .../caddyhttp/templates/testdata/root.html | 1 - .../mholt/caddy/caddyhttp/websocket/setup.go | 96 - .../caddy/caddyhttp/websocket/setup_test.go | 102 - .../caddy/caddyhttp/websocket/websocket.go | 259 - .../caddyhttp/websocket/websocket_test.go | 22 - .../mholt/caddy/caddytls/certificates.go | 240 - .../mholt/caddy/caddytls/certificates_test.go | 59 - .../github.com/mholt/caddy/caddytls/client.go | 294 - .../mholt/caddy/caddytls/client_test.go | 3 - .../github.com/mholt/caddy/caddytls/config.go | 437 - .../github.com/mholt/caddy/caddytls/crypto.go | 258 - .../mholt/caddy/caddytls/crypto_test.go | 166 - .../mholt/caddy/caddytls/handshake.go | 312 - .../mholt/caddy/caddytls/handshake_test.go | 56 - .../mholt/caddy/caddytls/httphandler.go | 42 - .../mholt/caddy/caddytls/httphandler_test.go | 63 - .../mholt/caddy/caddytls/maintain.go | 228 - .../github.com/mholt/caddy/caddytls/setup.go | 275 - .../mholt/caddy/caddytls/setup_test.go | 298 - .../mholt/caddy/caddytls/storage.go | 134 - .../mholt/caddy/caddytls/storage_test.go | 135 - vendor/github.com/mholt/caddy/caddytls/tls.go | 202 - .../mholt/caddy/caddytls/tls_test.go | 165 - .../github.com/mholt/caddy/caddytls/user.go | 200 - .../mholt/caddy/caddytls/user_test.go | 184 - vendor/github.com/mholt/caddy/commands.go | 119 - .../github.com/mholt/caddy/commands_test.go | 291 - vendor/github.com/mholt/caddy/controller.go | 86 - .../github.com/mholt/caddy/dist/CHANGES.txt | 229 - .../github.com/mholt/caddy/dist/LICENSES.txt | 539 - vendor/github.com/mholt/caddy/dist/README.txt | 39 - .../github.com/mholt/caddy/dist/automate.go | 161 - .../mholt/caddy/dist/gitcookie.sh.enc | 3 - .../mholt/caddy/dist/init/README.md | 12 - .../mholt/caddy/dist/init/freebsd/caddy | 73 - .../caddy/dist/init/linux-systemd/README.md | 85 - .../dist/init/linux-systemd/caddy.service | 50 - .../caddy/dist/init/linux-upstart/README.md | 14 - .../caddy/dist/init/linux-upstart/caddy.conf | 23 - vendor/github.com/mholt/caddy/plugins.go | 302 - vendor/github.com/mholt/caddy/sigtrap.go | 83 - .../github.com/mholt/caddy/sigtrap_posix.go | 84 - .../github.com/mholt/caddy/sigtrap_windows.go | 3 - .../caddy/startupshutdown/startupshutdown.go | 70 - .../startupshutdown/startupshutdown_test.go | 66 - vendor/github.com/micromdm/scep/.gitignore | 4 - vendor/github.com/micromdm/scep/Dockerfile | 9 - vendor/github.com/micromdm/scep/LICENSE | 21 - vendor/github.com/micromdm/scep/README.md | 151 - .../micromdm/scep/caddy/config.json | 3 - vendor/github.com/micromdm/scep/caddy/scep.go | 152 - .../micromdm/scep/caddy/scep_test.go | 20 - .../github.com/micromdm/scep/client/scep.go | 100 - .../micromdm/scep/cmd/scepclient/cert.go | 100 - .../micromdm/scep/cmd/scepclient/csr.go | 86 - .../micromdm/scep/cmd/scepclient/key.go | 70 - .../micromdm/scep/cmd/scepclient/release.sh | 18 - .../scep/cmd/scepclient/scepclient.go | 232 - .../micromdm/scep/cmd/scepserver/release.sh | 18 - .../scep/cmd/scepserver/scepserver.go | 328 - .../scep/scep/internal/pkcs7/.gitignore | 24 - .../micromdm/scep/scep/internal/pkcs7/LICENSE | 22 - .../scep/scep/internal/pkcs7/README.md | 10 - .../micromdm/scep/scep/internal/pkcs7/ber.go | 228 - .../scep/scep/internal/pkcs7/ber_test.go | 61 - .../scep/scep/internal/pkcs7/pkcs7.go | 788 - .../scep/scep/internal/pkcs7/pkcs7_test.go | 439 - vendor/github.com/micromdm/scep/scep/scep.go | 618 - .../micromdm/scep/scep/scep_test.go | 266 - .../micromdm/scep/scep/testdata/CertRep.der | Bin 4621 -> 0 bytes .../micromdm/scep/scep/testdata/PKCSReq.der | Bin 2461 -> 0 bytes .../micromdm/scep/scep/testdata/testca/ca.crt | 30 - .../scep/scep/testdata/testca/ca.crt.info | 1 - .../micromdm/scep/scep/testdata/testca/ca.key | 54 - .../micromdm/scep/scep/testdata/testca/ca.pem | 30 - .../testdata/testca/sceptest.mobileconfig | 115 - .../scep/scep/testdata/testclient/client.key | 19 - .../scep/scep/testdata/testclient/client.pem | 28 - .../github.com/micromdm/scep/server/depot.go | 213 - .../micromdm/scep/server/endpoint.go | 17 - .../micromdm/scep/server/service.go | 211 - .../micromdm/scep/server/service_logging.go | 54 - .../micromdm/scep/server/transport.go | 181 - .../micromdm/scep/server/transport_test.go | 177 - vendor/github.com/miekg/dns/.gitignore | 4 - vendor/github.com/miekg/dns/.travis.yml | 7 - vendor/github.com/miekg/dns/AUTHORS | 1 - vendor/github.com/miekg/dns/CONTRIBUTORS | 9 - vendor/github.com/miekg/dns/COPYRIGHT | 9 - vendor/github.com/miekg/dns/LICENSE | 32 - vendor/github.com/miekg/dns/README.md | 151 - vendor/github.com/miekg/dns/client.go | 455 - vendor/github.com/miekg/dns/client_test.go | 452 - vendor/github.com/miekg/dns/clientconfig.go | 99 - .../github.com/miekg/dns/clientconfig_test.go | 50 - vendor/github.com/miekg/dns/defaults.go | 282 - vendor/github.com/miekg/dns/dns.go | 104 - vendor/github.com/miekg/dns/dns_bench_test.go | 211 - vendor/github.com/miekg/dns/dns_test.go | 433 - vendor/github.com/miekg/dns/dnssec.go | 721 - vendor/github.com/miekg/dns/dnssec_keygen.go | 156 - vendor/github.com/miekg/dns/dnssec_keyscan.go | 249 - vendor/github.com/miekg/dns/dnssec_privkey.go | 85 - vendor/github.com/miekg/dns/dnssec_test.go | 733 - vendor/github.com/miekg/dns/dnsutil/util.go | 79 - .../github.com/miekg/dns/dnsutil/util_test.go | 130 - vendor/github.com/miekg/dns/doc.go | 251 - vendor/github.com/miekg/dns/dyn_test.go | 3 - vendor/github.com/miekg/dns/edns.go | 532 - vendor/github.com/miekg/dns/edns_test.go | 32 - vendor/github.com/miekg/dns/example_test.go | 146 - vendor/github.com/miekg/dns/format.go | 87 - vendor/github.com/miekg/dns/fuzz_test.go | 25 - vendor/github.com/miekg/dns/generate.go | 159 - .../github.com/miekg/dns/idn/code_points.go | 2346 --- .../github.com/miekg/dns/idn/example_test.go | 18 - vendor/github.com/miekg/dns/idn/punycode.go | 373 - .../github.com/miekg/dns/idn/punycode_test.go | 116 - vendor/github.com/miekg/dns/issue_test.go | 23 - vendor/github.com/miekg/dns/labels.go | 168 - vendor/github.com/miekg/dns/labels_test.go | 200 - vendor/github.com/miekg/dns/msg.go | 1231 -- vendor/github.com/miekg/dns/msg_generate.go | 337 - vendor/github.com/miekg/dns/msg_helpers.go | 630 - vendor/github.com/miekg/dns/nsecx.go | 119 - vendor/github.com/miekg/dns/nsecx_test.go | 29 - vendor/github.com/miekg/dns/parse_test.go | 1492 -- vendor/github.com/miekg/dns/privaterr.go | 149 - vendor/github.com/miekg/dns/privaterr_test.go | 171 - vendor/github.com/miekg/dns/rawmsg.go | 49 - vendor/github.com/miekg/dns/remote_test.go | 19 - vendor/github.com/miekg/dns/reverse.go | 38 - vendor/github.com/miekg/dns/sanitize.go | 84 - vendor/github.com/miekg/dns/sanitize_test.go | 84 - vendor/github.com/miekg/dns/scan.go | 974 - vendor/github.com/miekg/dns/scan_rr.go | 2143 --- vendor/github.com/miekg/dns/scanner.go | 43 - vendor/github.com/miekg/dns/server.go | 732 - vendor/github.com/miekg/dns/server_test.go | 679 - vendor/github.com/miekg/dns/sig0.go | 219 - vendor/github.com/miekg/dns/sig0_test.go | 89 - vendor/github.com/miekg/dns/singleinflight.go | 57 - vendor/github.com/miekg/dns/tlsa.go | 86 - vendor/github.com/miekg/dns/tsig.go | 384 - vendor/github.com/miekg/dns/tsig_test.go | 37 - vendor/github.com/miekg/dns/types.go | 1250 -- vendor/github.com/miekg/dns/types_generate.go | 271 - vendor/github.com/miekg/dns/types_test.go | 42 - vendor/github.com/miekg/dns/udp.go | 58 - vendor/github.com/miekg/dns/udp_linux.go | 73 - vendor/github.com/miekg/dns/udp_other.go | 17 - vendor/github.com/miekg/dns/udp_plan9.go | 34 - vendor/github.com/miekg/dns/udp_windows.go | 34 - vendor/github.com/miekg/dns/update.go | 106 - vendor/github.com/miekg/dns/update_test.go | 145 - vendor/github.com/miekg/dns/xfr.go | 244 - vendor/github.com/miekg/dns/xfr_test.go | 161 - vendor/github.com/miekg/dns/zmsg.go | 3462 ---- vendor/github.com/miekg/dns/ztypes.go | 828 - .../russross/blackfriday/.gitignore | 8 - .../russross/blackfriday/.travis.yml | 30 - .../russross/blackfriday/LICENSE.txt | 29 - .../github.com/russross/blackfriday/README.md | 267 - .../github.com/russross/blackfriday/block.go | 1420 -- .../russross/blackfriday/block_test.go | 1638 -- .../github.com/russross/blackfriday/html.go | 949 - .../github.com/russross/blackfriday/inline.go | 1148 -- .../russross/blackfriday/inline_test.go | 1198 -- .../github.com/russross/blackfriday/latex.go | 332 - .../russross/blackfriday/markdown.go | 926 - .../russross/blackfriday/ref_test.go | 128 - .../russross/blackfriday/smartypants.go | 400 - .../testdata/Amps and angle encoding.html | 17 - .../testdata/Amps and angle encoding.text | 21 - .../blackfriday/testdata/Auto links.html | 18 - .../blackfriday/testdata/Auto links.text | 13 - .../testdata/Backslash escapes.html | 123 - .../testdata/Backslash escapes.text | 126 - .../Blockquotes with code blocks.html | 15 - .../Blockquotes with code blocks.text | 11 - .../blackfriday/testdata/Code Blocks.html | 18 - .../blackfriday/testdata/Code Blocks.text | 14 - .../blackfriday/testdata/Code Spans.html | 5 - .../blackfriday/testdata/Code Spans.text | 6 - ...like lines no empty line before block.html | 14 - ...like lines no empty line before block.text | 8 - ...apped paragraphs with list-like lines.html | 8 - ...apped paragraphs with list-like lines.text | 8 - .../testdata/Horizontal rules.html | 71 - .../testdata/Horizontal rules.text | 67 - .../testdata/Inline HTML (Advanced).html | 15 - .../testdata/Inline HTML (Advanced).text | 15 - .../testdata/Inline HTML (Simple).html | 72 - .../testdata/Inline HTML (Simple).text | 69 - .../testdata/Inline HTML comments.html | 13 - .../testdata/Inline HTML comments.text | 13 - .../testdata/Links, inline style.html | 11 - .../testdata/Links, inline style.text | 12 - .../testdata/Links, reference style.html | 52 - .../testdata/Links, reference style.text | 71 - .../testdata/Links, shortcut references.html | 9 - .../testdata/Links, shortcut references.text | 20 - .../testdata/Literal quotes in titles.html | 3 - .../testdata/Literal quotes in titles.text | 7 - .../Markdown Documentation - Basics.html | 314 - .../Markdown Documentation - Basics.text | 306 - .../Markdown Documentation - Syntax.html | 946 - .../Markdown Documentation - Syntax.text | 888 - .../testdata/Nested blockquotes.html | 9 - .../testdata/Nested blockquotes.text | 5 - .../testdata/Ordered and unordered lists.html | 166 - .../testdata/Ordered and unordered lists.text | 131 - .../testdata/Strong and em together.html | 7 - .../testdata/Strong and em together.text | 7 - .../russross/blackfriday/testdata/Tabs.html | 26 - .../russross/blackfriday/testdata/Tabs.text | 21 - .../blackfriday/testdata/Tidyness.html | 9 - .../blackfriday/testdata/Tidyness.text | 5 - .../sanitized_anchor_name/.travis.yml | 10 - .../shurcooL/sanitized_anchor_name/LICENSE | 19 - .../shurcooL/sanitized_anchor_name/README.md | 31 - .../shurcooL/sanitized_anchor_name/main.go | 29 - .../sanitized_anchor_name/main_test.go | 35 - vendor/github.com/xenolf/lego/.gitcookies.enc | Bin 480 -> 0 bytes vendor/github.com/xenolf/lego/.gitignore | 3 - vendor/github.com/xenolf/lego/.travis.yml | 12 - vendor/github.com/xenolf/lego/CHANGELOG.md | 94 - vendor/github.com/xenolf/lego/CONTRIBUTING.md | 32 - vendor/github.com/xenolf/lego/Dockerfile | 14 - vendor/github.com/xenolf/lego/LICENSE | 21 - vendor/github.com/xenolf/lego/README.md | 257 - vendor/github.com/xenolf/lego/account.go | 109 - .../github.com/xenolf/lego/acme/challenges.go | 16 - vendor/github.com/xenolf/lego/acme/client.go | 798 - .../xenolf/lego/acme/client_test.go | 198 - vendor/github.com/xenolf/lego/acme/crypto.go | 339 - .../xenolf/lego/acme/crypto_test.go | 93 - .../xenolf/lego/acme/dns_challenge.go | 279 - .../xenolf/lego/acme/dns_challenge_manual.go | 53 - .../xenolf/lego/acme/dns_challenge_test.go | 165 - vendor/github.com/xenolf/lego/acme/error.go | 86 - vendor/github.com/xenolf/lego/acme/http.go | 120 - .../xenolf/lego/acme/http_challenge.go | 41 - .../xenolf/lego/acme/http_challenge_server.go | 79 - .../xenolf/lego/acme/http_challenge_test.go | 57 - .../github.com/xenolf/lego/acme/http_test.go | 100 - vendor/github.com/xenolf/lego/acme/jws.go | 109 - .../github.com/xenolf/lego/acme/messages.go | 117 - .../xenolf/lego/acme/pop_challenge.go | 1 - .../github.com/xenolf/lego/acme/provider.go | 28 - .../xenolf/lego/acme/tls_sni_challenge.go | 67 - .../lego/acme/tls_sni_challenge_server.go | 62 - .../lego/acme/tls_sni_challenge_test.go | 65 - vendor/github.com/xenolf/lego/acme/utils.go | 29 - .../github.com/xenolf/lego/acme/utils_test.go | 26 - vendor/github.com/xenolf/lego/cli.go | 202 - vendor/github.com/xenolf/lego/cli_handlers.go | 407 - .../github.com/xenolf/lego/configuration.go | 76 - vendor/github.com/xenolf/lego/crypto.go | 56 - .../providers/dns/cloudflare/cloudflare.go | 219 - .../dns/cloudflare/cloudflare_test.go | 80 - .../dns/digitalocean/digitalocean.go | 166 - .../dns/digitalocean/digitalocean_test.go | 117 - .../lego/providers/dns/dnsimple/dnsimple.go | 141 - .../providers/dns/dnsimple/dnsimple_test.go | 79 - .../xenolf/lego/providers/dns/dyn/dyn.go | 274 - .../xenolf/lego/providers/dns/dyn/dyn_test.go | 53 - .../xenolf/lego/providers/dns/gandi/gandi.go | 472 - .../lego/providers/dns/gandi/gandi_test.go | 939 - .../providers/dns/googlecloud/googlecloud.go | 155 - .../dns/googlecloud/googlecloud_test.go | 85 - .../lego/providers/dns/namecheap/namecheap.go | 416 - .../providers/dns/namecheap/namecheap_test.go | 402 - .../lego/providers/dns/rfc2136/rfc2136.go | 129 - .../providers/dns/rfc2136/rfc2136_test.go | 244 - .../providers/dns/route53/fixtures_test.go | 39 - .../lego/providers/dns/route53/route53.go | 170 - .../providers/dns/route53/route53_test.go | 87 - .../providers/dns/route53/testutil_test.go | 38 - .../xenolf/lego/providers/dns/vultr/vultr.go | 127 - .../lego/providers/dns/vultr/vultr_test.go | 65 - .../lego/providers/http/webroot/webroot.go | 58 - .../providers/http/webroot/webroot_test.go | 46 - vendor/golang.org/x/crypto/.gitattributes | 10 - vendor/golang.org/x/crypto/.gitignore | 2 - vendor/golang.org/x/crypto/AUTHORS | 3 - vendor/golang.org/x/crypto/CONTRIBUTING.md | 31 - vendor/golang.org/x/crypto/CONTRIBUTORS | 3 - vendor/golang.org/x/crypto/LICENSE | 27 - vendor/golang.org/x/crypto/PATENTS | 22 - vendor/golang.org/x/crypto/README | 3 - .../x/crypto/acme/internal/acme/acme.go | 473 - .../x/crypto/acme/internal/acme/acme_test.go | 759 - .../x/crypto/acme/internal/acme/jws.go | 67 - .../x/crypto/acme/internal/acme/jws_test.go | 139 - .../x/crypto/acme/internal/acme/types.go | 181 - vendor/golang.org/x/crypto/bcrypt/base64.go | 35 - vendor/golang.org/x/crypto/bcrypt/bcrypt.go | 294 - .../golang.org/x/crypto/bcrypt/bcrypt_test.go | 226 - vendor/golang.org/x/crypto/blowfish/block.go | 159 - .../x/crypto/blowfish/blowfish_test.go | 274 - vendor/golang.org/x/crypto/blowfish/cipher.go | 91 - vendor/golang.org/x/crypto/blowfish/const.go | 199 - vendor/golang.org/x/crypto/bn256/bn256.go | 404 - .../golang.org/x/crypto/bn256/bn256_test.go | 304 - vendor/golang.org/x/crypto/bn256/constants.go | 44 - vendor/golang.org/x/crypto/bn256/curve.go | 278 - .../golang.org/x/crypto/bn256/example_test.go | 43 - vendor/golang.org/x/crypto/bn256/gfp12.go | 200 - vendor/golang.org/x/crypto/bn256/gfp2.go | 219 - vendor/golang.org/x/crypto/bn256/gfp6.go | 296 - vendor/golang.org/x/crypto/bn256/optate.go | 395 - vendor/golang.org/x/crypto/bn256/twist.go | 249 - vendor/golang.org/x/crypto/cast5/cast5.go | 526 - .../golang.org/x/crypto/cast5/cast5_test.go | 106 - vendor/golang.org/x/crypto/codereview.cfg | 1 - .../x/crypto/curve25519/const_amd64.s | 20 - .../x/crypto/curve25519/cswap_amd64.s | 88 - .../x/crypto/curve25519/curve25519.go | 841 - .../x/crypto/curve25519/curve25519_test.go | 29 - vendor/golang.org/x/crypto/curve25519/doc.go | 23 - .../x/crypto/curve25519/freeze_amd64.s | 94 - .../x/crypto/curve25519/ladderstep_amd64.s | 1398 -- .../x/crypto/curve25519/mont25519_amd64.go | 240 - .../x/crypto/curve25519/mul_amd64.s | 191 - .../x/crypto/curve25519/square_amd64.s | 153 - vendor/golang.org/x/crypto/ed25519/ed25519.go | 181 - .../x/crypto/ed25519/ed25519_test.go | 183 - .../ed25519/internal/edwards25519/const.go | 1422 -- .../internal/edwards25519/edwards25519.go | 1771 -- .../x/crypto/ed25519/testdata/sign.input.gz | Bin 50330 -> 0 bytes .../golang.org/x/crypto/hkdf/example_test.go | 61 - vendor/golang.org/x/crypto/hkdf/hkdf.go | 75 - vendor/golang.org/x/crypto/hkdf/hkdf_test.go | 370 - vendor/golang.org/x/crypto/md4/md4.go | 118 - vendor/golang.org/x/crypto/md4/md4_test.go | 71 - vendor/golang.org/x/crypto/md4/md4block.go | 89 - vendor/golang.org/x/crypto/nacl/box/box.go | 85 - .../golang.org/x/crypto/nacl/box/box_test.go | 78 - .../x/crypto/nacl/secretbox/secretbox.go | 149 - .../x/crypto/nacl/secretbox/secretbox_test.go | 91 - vendor/golang.org/x/crypto/ocsp/ocsp.go | 673 - vendor/golang.org/x/crypto/ocsp/ocsp_test.go | 584 - .../x/crypto/openpgp/armor/armor.go | 219 - .../x/crypto/openpgp/armor/armor_test.go | 95 - .../x/crypto/openpgp/armor/encode.go | 160 - .../x/crypto/openpgp/canonical_text.go | 59 - .../x/crypto/openpgp/canonical_text_test.go | 52 - .../x/crypto/openpgp/clearsign/clearsign.go | 376 - .../openpgp/clearsign/clearsign_test.go | 210 - .../x/crypto/openpgp/elgamal/elgamal.go | 122 - .../x/crypto/openpgp/elgamal/elgamal_test.go | 49 - .../x/crypto/openpgp/errors/errors.go | 72 - vendor/golang.org/x/crypto/openpgp/keys.go | 633 - .../golang.org/x/crypto/openpgp/keys_test.go | 370 - .../x/crypto/openpgp/packet/compressed.go | 123 - .../crypto/openpgp/packet/compressed_test.go | 41 - .../x/crypto/openpgp/packet/config.go | 91 - .../x/crypto/openpgp/packet/encrypted_key.go | 199 - .../openpgp/packet/encrypted_key_test.go | 146 - .../x/crypto/openpgp/packet/literal.go | 89 - .../x/crypto/openpgp/packet/ocfb.go | 143 - .../x/crypto/openpgp/packet/ocfb_test.go | 46 - .../openpgp/packet/one_pass_signature.go | 73 - .../x/crypto/openpgp/packet/opaque.go | 162 - .../x/crypto/openpgp/packet/opaque_test.go | 67 - .../x/crypto/openpgp/packet/packet.go | 539 - .../x/crypto/openpgp/packet/packet_test.go | 255 - .../x/crypto/openpgp/packet/private_key.go | 362 - .../crypto/openpgp/packet/private_key_test.go | 126 - .../x/crypto/openpgp/packet/public_key.go | 750 - .../crypto/openpgp/packet/public_key_test.go | 202 - .../x/crypto/openpgp/packet/public_key_v3.go | 280 - .../openpgp/packet/public_key_v3_test.go | 82 - .../x/crypto/openpgp/packet/reader.go | 76 - .../x/crypto/openpgp/packet/signature.go | 706 - .../x/crypto/openpgp/packet/signature_test.go | 42 - .../x/crypto/openpgp/packet/signature_v3.go | 146 - .../openpgp/packet/signature_v3_test.go | 92 - .../openpgp/packet/symmetric_key_encrypted.go | 155 - .../packet/symmetric_key_encrypted_test.go | 103 - .../openpgp/packet/symmetrically_encrypted.go | 290 - .../packet/symmetrically_encrypted_test.go | 123 - .../x/crypto/openpgp/packet/userattribute.go | 91 - .../openpgp/packet/userattribute_test.go | 109 - .../x/crypto/openpgp/packet/userid.go | 160 - .../x/crypto/openpgp/packet/userid_test.go | 87 - vendor/golang.org/x/crypto/openpgp/read.go | 442 - .../golang.org/x/crypto/openpgp/read_test.go | 613 - vendor/golang.org/x/crypto/openpgp/s2k/s2k.go | 273 - .../x/crypto/openpgp/s2k/s2k_test.go | 137 - vendor/golang.org/x/crypto/openpgp/write.go | 378 - .../golang.org/x/crypto/openpgp/write_test.go | 273 - .../x/crypto/otr/libotr_test_helper.c | 197 - vendor/golang.org/x/crypto/otr/otr.go | 1408 -- vendor/golang.org/x/crypto/otr/otr_test.go | 470 - vendor/golang.org/x/crypto/otr/smp.go | 572 - vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go | 77 - .../golang.org/x/crypto/pbkdf2/pbkdf2_test.go | 157 - .../golang.org/x/crypto/pkcs12/bmp-string.go | 50 - .../x/crypto/pkcs12/bmp-string_test.go | 63 - vendor/golang.org/x/crypto/pkcs12/crypto.go | 131 - .../golang.org/x/crypto/pkcs12/crypto_test.go | 125 - vendor/golang.org/x/crypto/pkcs12/errors.go | 23 - .../crypto/pkcs12/internal/rc2/bench_test.go | 27 - .../x/crypto/pkcs12/internal/rc2/rc2.go | 274 - .../x/crypto/pkcs12/internal/rc2/rc2_test.go | 93 - vendor/golang.org/x/crypto/pkcs12/mac.go | 45 - vendor/golang.org/x/crypto/pkcs12/mac_test.go | 42 - vendor/golang.org/x/crypto/pkcs12/pbkdf.go | 170 - .../golang.org/x/crypto/pkcs12/pbkdf_test.go | 34 - vendor/golang.org/x/crypto/pkcs12/pkcs12.go | 342 - .../golang.org/x/crypto/pkcs12/pkcs12_test.go | 138 - vendor/golang.org/x/crypto/pkcs12/safebags.go | 57 - .../x/crypto/poly1305/const_amd64.s | 45 - .../golang.org/x/crypto/poly1305/poly1305.go | 32 - .../x/crypto/poly1305/poly1305_amd64.s | 497 - .../x/crypto/poly1305/poly1305_arm.s | 379 - .../x/crypto/poly1305/poly1305_test.go | 86 - .../golang.org/x/crypto/poly1305/sum_amd64.go | 24 - .../golang.org/x/crypto/poly1305/sum_arm.go | 24 - .../golang.org/x/crypto/poly1305/sum_ref.go | 1531 -- .../x/crypto/ripemd160/ripemd160.go | 120 - .../x/crypto/ripemd160/ripemd160_test.go | 64 - .../x/crypto/ripemd160/ripemd160block.go | 161 - .../x/crypto/salsa20/salsa/hsalsa20.go | 144 - .../x/crypto/salsa20/salsa/salsa2020_amd64.s | 902 - .../x/crypto/salsa20/salsa/salsa208.go | 199 - .../x/crypto/salsa20/salsa/salsa20_amd64.go | 23 - .../x/crypto/salsa20/salsa/salsa20_ref.go | 234 - .../x/crypto/salsa20/salsa/salsa_test.go | 35 - vendor/golang.org/x/crypto/salsa20/salsa20.go | 54 - .../x/crypto/salsa20/salsa20_test.go | 139 - vendor/golang.org/x/crypto/scrypt/scrypt.go | 243 - .../golang.org/x/crypto/scrypt/scrypt_test.go | 160 - vendor/golang.org/x/crypto/sha3/doc.go | 66 - vendor/golang.org/x/crypto/sha3/hashes.go | 65 - vendor/golang.org/x/crypto/sha3/keccakf.go | 410 - vendor/golang.org/x/crypto/sha3/register.go | 18 - vendor/golang.org/x/crypto/sha3/sha3.go | 193 - vendor/golang.org/x/crypto/sha3/sha3_test.go | 306 - vendor/golang.org/x/crypto/sha3/shake.go | 60 - .../sha3/testdata/keccakKats.json.deflate | Bin 521342 -> 0 bytes vendor/golang.org/x/crypto/sha3/xor.go | 16 - .../golang.org/x/crypto/sha3/xor_generic.go | 28 - .../golang.org/x/crypto/sha3/xor_unaligned.go | 58 - .../golang.org/x/crypto/ssh/agent/client.go | 659 - .../x/crypto/ssh/agent/client_test.go | 327 - .../x/crypto/ssh/agent/example_test.go | 40 - .../golang.org/x/crypto/ssh/agent/forward.go | 103 - .../golang.org/x/crypto/ssh/agent/keyring.go | 184 - .../x/crypto/ssh/agent/keyring_test.go | 78 - .../golang.org/x/crypto/ssh/agent/server.go | 420 - .../x/crypto/ssh/agent/server_test.go | 186 - .../x/crypto/ssh/agent/testdata_test.go | 64 - .../golang.org/x/crypto/ssh/benchmark_test.go | 122 - vendor/golang.org/x/crypto/ssh/buffer.go | 98 - vendor/golang.org/x/crypto/ssh/buffer_test.go | 87 - vendor/golang.org/x/crypto/ssh/certs.go | 503 - vendor/golang.org/x/crypto/ssh/certs_test.go | 216 - vendor/golang.org/x/crypto/ssh/channel.go | 631 - vendor/golang.org/x/crypto/ssh/cipher.go | 579 - vendor/golang.org/x/crypto/ssh/cipher_test.go | 127 - vendor/golang.org/x/crypto/ssh/client.go | 213 - vendor/golang.org/x/crypto/ssh/client_auth.go | 439 - .../x/crypto/ssh/client_auth_test.go | 393 - vendor/golang.org/x/crypto/ssh/client_test.go | 39 - vendor/golang.org/x/crypto/ssh/common.go | 356 - vendor/golang.org/x/crypto/ssh/connection.go | 144 - vendor/golang.org/x/crypto/ssh/doc.go | 18 - .../golang.org/x/crypto/ssh/example_test.go | 243 - vendor/golang.org/x/crypto/ssh/handshake.go | 451 - .../golang.org/x/crypto/ssh/handshake_test.go | 486 - vendor/golang.org/x/crypto/ssh/kex.go | 526 - vendor/golang.org/x/crypto/ssh/kex_test.go | 50 - vendor/golang.org/x/crypto/ssh/keys.go | 846 - vendor/golang.org/x/crypto/ssh/keys_test.go | 440 - vendor/golang.org/x/crypto/ssh/mac.go | 57 - .../golang.org/x/crypto/ssh/mempipe_test.go | 110 - vendor/golang.org/x/crypto/ssh/messages.go | 758 - .../golang.org/x/crypto/ssh/messages_test.go | 288 - vendor/golang.org/x/crypto/ssh/mux.go | 330 - vendor/golang.org/x/crypto/ssh/mux_test.go | 502 - vendor/golang.org/x/crypto/ssh/server.go | 489 - vendor/golang.org/x/crypto/ssh/session.go | 612 - .../golang.org/x/crypto/ssh/session_test.go | 774 - vendor/golang.org/x/crypto/ssh/tcpip.go | 407 - vendor/golang.org/x/crypto/ssh/tcpip_test.go | 20 - .../x/crypto/ssh/terminal/terminal.go | 892 - .../x/crypto/ssh/terminal/terminal_test.go | 291 - .../golang.org/x/crypto/ssh/terminal/util.go | 128 - .../x/crypto/ssh/terminal/util_bsd.go | 12 - .../x/crypto/ssh/terminal/util_linux.go | 11 - .../x/crypto/ssh/terminal/util_plan9.go | 58 - .../x/crypto/ssh/terminal/util_windows.go | 174 - .../x/crypto/ssh/test/agent_unix_test.go | 59 - .../golang.org/x/crypto/ssh/test/cert_test.go | 47 - vendor/golang.org/x/crypto/ssh/test/doc.go | 7 - .../x/crypto/ssh/test/forward_unix_test.go | 160 - .../x/crypto/ssh/test/session_test.go | 365 - .../x/crypto/ssh/test/tcpip_test.go | 46 - .../x/crypto/ssh/test/test_unix_test.go | 268 - .../x/crypto/ssh/test/testdata_test.go | 64 - .../golang.org/x/crypto/ssh/testdata/doc.go | 8 - .../golang.org/x/crypto/ssh/testdata/keys.go | 57 - .../golang.org/x/crypto/ssh/testdata_test.go | 63 - vendor/golang.org/x/crypto/ssh/transport.go | 333 - .../golang.org/x/crypto/ssh/transport_test.go | 109 - vendor/golang.org/x/crypto/tea/cipher.go | 109 - vendor/golang.org/x/crypto/tea/tea_test.go | 93 - vendor/golang.org/x/crypto/twofish/twofish.go | 342 - .../x/crypto/twofish/twofish_test.go | 129 - vendor/golang.org/x/crypto/xtea/block.go | 66 - vendor/golang.org/x/crypto/xtea/cipher.go | 82 - vendor/golang.org/x/crypto/xtea/xtea_test.go | 229 - vendor/golang.org/x/crypto/xts/xts.go | 138 - vendor/golang.org/x/crypto/xts/xts_test.go | 85 - vendor/golang.org/x/net/.gitattributes | 10 - vendor/golang.org/x/net/.gitignore | 2 - vendor/golang.org/x/net/AUTHORS | 3 - vendor/golang.org/x/net/CONTRIBUTING.md | 31 - vendor/golang.org/x/net/CONTRIBUTORS | 3 - vendor/golang.org/x/net/LICENSE | 27 - vendor/golang.org/x/net/PATENTS | 22 - vendor/golang.org/x/net/README | 3 - vendor/golang.org/x/net/bpf/asm.go | 41 - vendor/golang.org/x/net/bpf/constants.go | 215 - vendor/golang.org/x/net/bpf/doc.go | 81 - vendor/golang.org/x/net/bpf/instructions.go | 434 - .../golang.org/x/net/bpf/instructions_test.go | 184 - .../x/net/bpf/testdata/all_instructions.bpf | 1 - .../x/net/bpf/testdata/all_instructions.txt | 79 - vendor/golang.org/x/net/codereview.cfg | 1 - vendor/golang.org/x/net/context/context.go | 156 - .../golang.org/x/net/context/context_test.go | 577 - .../x/net/context/ctxhttp/ctxhttp.go | 146 - .../x/net/context/ctxhttp/ctxhttp_test.go | 176 - vendor/golang.org/x/net/context/go17.go | 72 - vendor/golang.org/x/net/context/pre_go17.go | 300 - .../x/net/context/withtimeout_test.go | 26 - vendor/golang.org/x/net/dict/dict.go | 210 - vendor/golang.org/x/net/html/atom/atom.go | 78 - .../golang.org/x/net/html/atom/atom_test.go | 109 - vendor/golang.org/x/net/html/atom/gen.go | 648 - vendor/golang.org/x/net/html/atom/table.go | 713 - .../golang.org/x/net/html/atom/table_test.go | 351 - .../golang.org/x/net/html/charset/charset.go | 257 - .../x/net/html/charset/charset_test.go | 237 - .../html/charset/testdata/HTTP-charset.html | 48 - .../charset/testdata/HTTP-vs-UTF-8-BOM.html | 48 - .../testdata/HTTP-vs-meta-charset.html | 49 - .../testdata/HTTP-vs-meta-content.html | 49 - .../testdata/No-encoding-declaration.html | 47 - .../x/net/html/charset/testdata/README | 9 - .../html/charset/testdata/UTF-16BE-BOM.html | Bin 2670 -> 0 bytes .../html/charset/testdata/UTF-16LE-BOM.html | Bin 2682 -> 0 bytes .../testdata/UTF-8-BOM-vs-meta-charset.html | 49 - .../testdata/UTF-8-BOM-vs-meta-content.html | 48 - .../testdata/meta-charset-attribute.html | 48 - .../testdata/meta-content-attribute.html | 48 - vendor/golang.org/x/net/html/const.go | 102 - vendor/golang.org/x/net/html/doc.go | 106 - vendor/golang.org/x/net/html/doctype.go | 156 - vendor/golang.org/x/net/html/entity.go | 2253 --- vendor/golang.org/x/net/html/entity_test.go | 29 - vendor/golang.org/x/net/html/escape.go | 258 - vendor/golang.org/x/net/html/escape_test.go | 97 - vendor/golang.org/x/net/html/example_test.go | 40 - vendor/golang.org/x/net/html/foreign.go | 226 - vendor/golang.org/x/net/html/node.go | 193 - vendor/golang.org/x/net/html/node_test.go | 146 - vendor/golang.org/x/net/html/parse.go | 2094 -- vendor/golang.org/x/net/html/parse_test.go | 388 - vendor/golang.org/x/net/html/render.go | 271 - vendor/golang.org/x/net/html/render_test.go | 156 - .../golang.org/x/net/html/testdata/go1.html | 2237 --- .../x/net/html/testdata/webkit/README | 28 - .../x/net/html/testdata/webkit/adoption01.dat | 194 - .../x/net/html/testdata/webkit/adoption02.dat | 31 - .../x/net/html/testdata/webkit/comments01.dat | 135 - .../x/net/html/testdata/webkit/doctype01.dat | 370 - .../x/net/html/testdata/webkit/entities01.dat | 603 - .../x/net/html/testdata/webkit/entities02.dat | 249 - .../html/testdata/webkit/html5test-com.dat | 246 - .../x/net/html/testdata/webkit/inbody01.dat | 43 - .../x/net/html/testdata/webkit/isindex.dat | 40 - ...pending-spec-changes-plain-text-unsafe.dat | Bin 115 -> 0 bytes .../testdata/webkit/pending-spec-changes.dat | 52 - .../testdata/webkit/plain-text-unsafe.dat | Bin 4166 -> 0 bytes .../net/html/testdata/webkit/scriptdata01.dat | 308 - .../testdata/webkit/scripted/adoption01.dat | 15 - .../testdata/webkit/scripted/webkit01.dat | 28 - .../x/net/html/testdata/webkit/tables01.dat | 212 - .../x/net/html/testdata/webkit/tests1.dat | 1952 -- .../x/net/html/testdata/webkit/tests10.dat | 799 - .../x/net/html/testdata/webkit/tests11.dat | 482 - .../x/net/html/testdata/webkit/tests12.dat | 62 - .../x/net/html/testdata/webkit/tests14.dat | 74 - .../x/net/html/testdata/webkit/tests15.dat | 208 - .../x/net/html/testdata/webkit/tests16.dat | 2299 --- .../x/net/html/testdata/webkit/tests17.dat | 153 - .../x/net/html/testdata/webkit/tests18.dat | 269 - .../x/net/html/testdata/webkit/tests19.dat | 1237 -- .../x/net/html/testdata/webkit/tests2.dat | 763 - .../x/net/html/testdata/webkit/tests20.dat | 455 - .../x/net/html/testdata/webkit/tests21.dat | 221 - .../x/net/html/testdata/webkit/tests22.dat | 157 - .../x/net/html/testdata/webkit/tests23.dat | 155 - .../x/net/html/testdata/webkit/tests24.dat | 79 - .../x/net/html/testdata/webkit/tests25.dat | 219 - .../x/net/html/testdata/webkit/tests26.dat | 313 - .../x/net/html/testdata/webkit/tests3.dat | 305 - .../x/net/html/testdata/webkit/tests4.dat | 59 - .../x/net/html/testdata/webkit/tests5.dat | 191 - .../x/net/html/testdata/webkit/tests6.dat | 663 - .../x/net/html/testdata/webkit/tests7.dat | 390 - .../x/net/html/testdata/webkit/tests8.dat | 148 - .../x/net/html/testdata/webkit/tests9.dat | 457 - .../testdata/webkit/tests_innerHTML_1.dat | 741 - .../x/net/html/testdata/webkit/tricky01.dat | 261 - .../x/net/html/testdata/webkit/webkit01.dat | 610 - .../x/net/html/testdata/webkit/webkit02.dat | 159 - vendor/golang.org/x/net/html/token.go | 1219 -- vendor/golang.org/x/net/html/token_test.go | 748 - vendor/golang.org/x/net/http2/.gitignore | 2 - vendor/golang.org/x/net/http2/Dockerfile | 51 - vendor/golang.org/x/net/http2/Makefile | 3 - vendor/golang.org/x/net/http2/README | 20 - .../x/net/http2/client_conn_pool.go | 246 - .../x/net/http2/configure_transport.go | 80 - vendor/golang.org/x/net/http2/errors.go | 122 - vendor/golang.org/x/net/http2/errors_test.go | 24 - vendor/golang.org/x/net/http2/fixed_buffer.go | 60 - .../x/net/http2/fixed_buffer_test.go | 128 - vendor/golang.org/x/net/http2/flow.go | 50 - vendor/golang.org/x/net/http2/flow_test.go | 53 - vendor/golang.org/x/net/http2/frame.go | 1507 -- vendor/golang.org/x/net/http2/frame_test.go | 1024 - vendor/golang.org/x/net/http2/go16.go | 16 - vendor/golang.org/x/net/http2/go17.go | 94 - vendor/golang.org/x/net/http2/gotrack.go | 170 - vendor/golang.org/x/net/http2/gotrack_test.go | 33 - .../golang.org/x/net/http2/h2demo/.gitignore | 5 - vendor/golang.org/x/net/http2/h2demo/Makefile | 8 - vendor/golang.org/x/net/http2/h2demo/README | 16 - .../golang.org/x/net/http2/h2demo/h2demo.go | 504 - .../golang.org/x/net/http2/h2demo/launch.go | 302 - .../golang.org/x/net/http2/h2demo/rootCA.key | 27 - .../golang.org/x/net/http2/h2demo/rootCA.pem | 26 - .../golang.org/x/net/http2/h2demo/rootCA.srl | 1 - .../golang.org/x/net/http2/h2demo/server.crt | 20 - .../golang.org/x/net/http2/h2demo/server.key | 27 - vendor/golang.org/x/net/http2/h2i/README.md | 97 - vendor/golang.org/x/net/http2/h2i/h2i.go | 501 - vendor/golang.org/x/net/http2/headermap.go | 78 - vendor/golang.org/x/net/http2/hpack/encode.go | 251 - .../x/net/http2/hpack/encode_test.go | 330 - vendor/golang.org/x/net/http2/hpack/hpack.go | 542 - .../x/net/http2/hpack/hpack_test.go | 854 - .../golang.org/x/net/http2/hpack/huffman.go | 212 - vendor/golang.org/x/net/http2/hpack/tables.go | 352 - vendor/golang.org/x/net/http2/http2.go | 351 - vendor/golang.org/x/net/http2/http2_test.go | 198 - vendor/golang.org/x/net/http2/not_go16.go | 20 - vendor/golang.org/x/net/http2/not_go17.go | 51 - vendor/golang.org/x/net/http2/pipe.go | 153 - vendor/golang.org/x/net/http2/pipe_test.go | 109 - .../golang.org/x/net/http2/priority_test.go | 118 - vendor/golang.org/x/net/http2/server.go | 2287 --- vendor/golang.org/x/net/http2/server_test.go | 3301 ---- .../testdata/draft-ietf-httpbis-http2.xml | 5021 ----- vendor/golang.org/x/net/http2/transport.go | 1832 -- .../golang.org/x/net/http2/transport_test.go | 2013 -- vendor/golang.org/x/net/http2/write.go | 264 - vendor/golang.org/x/net/http2/writesched.go | 283 - vendor/golang.org/x/net/http2/z_spec_test.go | 356 - vendor/golang.org/x/net/icmp/dstunreach.go | 41 - vendor/golang.org/x/net/icmp/echo.go | 45 - vendor/golang.org/x/net/icmp/endpoint.go | 113 - vendor/golang.org/x/net/icmp/example_test.go | 63 - vendor/golang.org/x/net/icmp/extension.go | 89 - .../golang.org/x/net/icmp/extension_test.go | 259 - vendor/golang.org/x/net/icmp/helper.go | 27 - vendor/golang.org/x/net/icmp/helper_posix.go | 75 - vendor/golang.org/x/net/icmp/interface.go | 236 - vendor/golang.org/x/net/icmp/ipv4.go | 56 - vendor/golang.org/x/net/icmp/ipv4_test.go | 82 - vendor/golang.org/x/net/icmp/ipv6.go | 23 - vendor/golang.org/x/net/icmp/listen_posix.go | 98 - vendor/golang.org/x/net/icmp/listen_stub.go | 33 - vendor/golang.org/x/net/icmp/message.go | 150 - vendor/golang.org/x/net/icmp/message_test.go | 134 - vendor/golang.org/x/net/icmp/messagebody.go | 41 - vendor/golang.org/x/net/icmp/mpls.go | 77 - vendor/golang.org/x/net/icmp/multipart.go | 109 - .../golang.org/x/net/icmp/multipart_test.go | 442 - vendor/golang.org/x/net/icmp/packettoobig.go | 43 - vendor/golang.org/x/net/icmp/paramprob.go | 63 - vendor/golang.org/x/net/icmp/ping_test.go | 166 - vendor/golang.org/x/net/icmp/sys_freebsd.go | 11 - vendor/golang.org/x/net/icmp/timeexceeded.go | 39 - vendor/golang.org/x/net/idna/idna.go | 68 - vendor/golang.org/x/net/idna/idna_test.go | 43 - vendor/golang.org/x/net/idna/punycode.go | 200 - vendor/golang.org/x/net/idna/punycode_test.go | 198 - .../golang.org/x/net/internal/iana/const.go | 180 - vendor/golang.org/x/net/internal/iana/gen.go | 293 - .../x/net/internal/nettest/error_posix.go | 31 - .../x/net/internal/nettest/error_stub.go | 11 - .../x/net/internal/nettest/interface.go | 94 - .../x/net/internal/nettest/rlimit.go | 11 - .../x/net/internal/nettest/rlimit_stub.go | 9 - .../x/net/internal/nettest/rlimit_unix.go | 17 - .../x/net/internal/nettest/rlimit_windows.go | 7 - .../x/net/internal/nettest/stack.go | 36 - .../x/net/internal/nettest/stack_stub.go | 18 - .../x/net/internal/nettest/stack_unix.go | 22 - .../x/net/internal/nettest/stack_windows.go | 32 - .../x/net/internal/timeseries/timeseries.go | 525 - .../internal/timeseries/timeseries_test.go | 170 - vendor/golang.org/x/net/ipv4/bpf_test.go | 93 - vendor/golang.org/x/net/ipv4/bpfopt_linux.go | 27 - vendor/golang.org/x/net/ipv4/bpfopt_stub.go | 16 - vendor/golang.org/x/net/ipv4/control.go | 70 - vendor/golang.org/x/net/ipv4/control_bsd.go | 40 - .../golang.org/x/net/ipv4/control_pktinfo.go | 37 - vendor/golang.org/x/net/ipv4/control_stub.go | 23 - vendor/golang.org/x/net/ipv4/control_unix.go | 164 - .../golang.org/x/net/ipv4/control_windows.go | 27 - vendor/golang.org/x/net/ipv4/defs_darwin.go | 77 - .../golang.org/x/net/ipv4/defs_dragonfly.go | 38 - vendor/golang.org/x/net/ipv4/defs_freebsd.go | 75 - vendor/golang.org/x/net/ipv4/defs_linux.go | 120 - vendor/golang.org/x/net/ipv4/defs_netbsd.go | 37 - vendor/golang.org/x/net/ipv4/defs_openbsd.go | 37 - vendor/golang.org/x/net/ipv4/defs_solaris.go | 57 - .../golang.org/x/net/ipv4/dgramopt_posix.go | 251 - vendor/golang.org/x/net/ipv4/dgramopt_stub.go | 106 - vendor/golang.org/x/net/ipv4/doc.go | 242 - vendor/golang.org/x/net/ipv4/endpoint.go | 187 - vendor/golang.org/x/net/ipv4/example_test.go | 224 - vendor/golang.org/x/net/ipv4/gen.go | 208 - .../golang.org/x/net/ipv4/genericopt_posix.go | 59 - .../golang.org/x/net/ipv4/genericopt_stub.go | 29 - vendor/golang.org/x/net/ipv4/header.go | 132 - vendor/golang.org/x/net/ipv4/header_test.go | 138 - vendor/golang.org/x/net/ipv4/helper.go | 59 - vendor/golang.org/x/net/ipv4/helper_stub.go | 23 - vendor/golang.org/x/net/ipv4/helper_unix.go | 50 - .../golang.org/x/net/ipv4/helper_windows.go | 49 - vendor/golang.org/x/net/ipv4/iana.go | 34 - vendor/golang.org/x/net/ipv4/icmp.go | 57 - vendor/golang.org/x/net/ipv4/icmp_linux.go | 25 - vendor/golang.org/x/net/ipv4/icmp_stub.go | 25 - vendor/golang.org/x/net/ipv4/icmp_test.go | 95 - .../x/net/ipv4/mocktransponder_test.go | 21 - .../golang.org/x/net/ipv4/multicast_test.go | 330 - .../x/net/ipv4/multicastlistener_test.go | 249 - .../x/net/ipv4/multicastsockopt_test.go | 195 - vendor/golang.org/x/net/ipv4/packet.go | 97 - vendor/golang.org/x/net/ipv4/payload.go | 15 - vendor/golang.org/x/net/ipv4/payload_cmsg.go | 81 - .../golang.org/x/net/ipv4/payload_nocmsg.go | 42 - .../golang.org/x/net/ipv4/readwrite_test.go | 174 - vendor/golang.org/x/net/ipv4/sockopt.go | 46 - .../golang.org/x/net/ipv4/sockopt_asmreq.go | 83 - .../x/net/ipv4/sockopt_asmreq_stub.go | 21 - .../x/net/ipv4/sockopt_asmreq_unix.go | 46 - .../x/net/ipv4/sockopt_asmreq_windows.go | 45 - .../x/net/ipv4/sockopt_asmreqn_stub.go | 17 - .../x/net/ipv4/sockopt_asmreqn_unix.go | 42 - .../x/net/ipv4/sockopt_ssmreq_stub.go | 17 - .../x/net/ipv4/sockopt_ssmreq_unix.go | 61 - vendor/golang.org/x/net/ipv4/sockopt_stub.go | 11 - vendor/golang.org/x/net/ipv4/sockopt_unix.go | 122 - .../golang.org/x/net/ipv4/sockopt_windows.go | 68 - vendor/golang.org/x/net/ipv4/sys_bsd.go | 34 - vendor/golang.org/x/net/ipv4/sys_darwin.go | 96 - vendor/golang.org/x/net/ipv4/sys_freebsd.go | 73 - vendor/golang.org/x/net/ipv4/sys_linux.go | 55 - vendor/golang.org/x/net/ipv4/sys_openbsd.go | 32 - vendor/golang.org/x/net/ipv4/sys_stub.go | 13 - vendor/golang.org/x/net/ipv4/sys_windows.go | 61 - .../x/net/ipv4/syscall_linux_386.go | 31 - vendor/golang.org/x/net/ipv4/syscall_unix.go | 26 - .../golang.org/x/net/ipv4/thunk_linux_386.s | 8 - vendor/golang.org/x/net/ipv4/unicast_test.go | 246 - .../x/net/ipv4/unicastsockopt_test.go | 139 - vendor/golang.org/x/net/ipv4/zsys_darwin.go | 99 - .../golang.org/x/net/ipv4/zsys_dragonfly.go | 33 - .../golang.org/x/net/ipv4/zsys_freebsd_386.go | 93 - .../x/net/ipv4/zsys_freebsd_amd64.go | 95 - .../golang.org/x/net/ipv4/zsys_freebsd_arm.go | 95 - .../golang.org/x/net/ipv4/zsys_linux_386.go | 146 - .../golang.org/x/net/ipv4/zsys_linux_amd64.go | 148 - .../golang.org/x/net/ipv4/zsys_linux_arm.go | 146 - .../golang.org/x/net/ipv4/zsys_linux_arm64.go | 150 - .../x/net/ipv4/zsys_linux_mips64.go | 150 - .../x/net/ipv4/zsys_linux_mips64le.go | 150 - .../golang.org/x/net/ipv4/zsys_linux_ppc64.go | 150 - .../x/net/ipv4/zsys_linux_ppc64le.go | 150 - .../golang.org/x/net/ipv4/zsys_linux_s390x.go | 150 - vendor/golang.org/x/net/ipv4/zsys_netbsd.go | 30 - vendor/golang.org/x/net/ipv4/zsys_openbsd.go | 30 - vendor/golang.org/x/net/ipv4/zsys_solaris.go | 60 - vendor/golang.org/x/net/ipv6/bpf_test.go | 93 - vendor/golang.org/x/net/ipv6/bpfopt_linux.go | 27 - vendor/golang.org/x/net/ipv6/bpfopt_stub.go | 16 - vendor/golang.org/x/net/ipv6/control.go | 85 - .../x/net/ipv6/control_rfc2292_unix.go | 55 - .../x/net/ipv6/control_rfc3542_unix.go | 99 - vendor/golang.org/x/net/ipv6/control_stub.go | 23 - vendor/golang.org/x/net/ipv6/control_unix.go | 166 - .../golang.org/x/net/ipv6/control_windows.go | 27 - vendor/golang.org/x/net/ipv6/defs_darwin.go | 112 - .../golang.org/x/net/ipv6/defs_dragonfly.go | 84 - vendor/golang.org/x/net/ipv6/defs_freebsd.go | 105 - vendor/golang.org/x/net/ipv6/defs_linux.go | 145 - vendor/golang.org/x/net/ipv6/defs_netbsd.go | 80 - vendor/golang.org/x/net/ipv6/defs_openbsd.go | 89 - vendor/golang.org/x/net/ipv6/defs_solaris.go | 96 - .../golang.org/x/net/ipv6/dgramopt_posix.go | 288 - vendor/golang.org/x/net/ipv6/dgramopt_stub.go | 119 - vendor/golang.org/x/net/ipv6/doc.go | 240 - vendor/golang.org/x/net/ipv6/endpoint.go | 123 - vendor/golang.org/x/net/ipv6/example_test.go | 216 - vendor/golang.org/x/net/ipv6/gen.go | 208 - .../golang.org/x/net/ipv6/genericopt_posix.go | 60 - .../golang.org/x/net/ipv6/genericopt_stub.go | 30 - vendor/golang.org/x/net/ipv6/header.go | 55 - vendor/golang.org/x/net/ipv6/header_test.go | 55 - vendor/golang.org/x/net/ipv6/helper.go | 53 - vendor/golang.org/x/net/ipv6/helper_stub.go | 19 - vendor/golang.org/x/net/ipv6/helper_unix.go | 46 - .../golang.org/x/net/ipv6/helper_windows.go | 45 - vendor/golang.org/x/net/ipv6/iana.go | 82 - vendor/golang.org/x/net/ipv6/icmp.go | 57 - vendor/golang.org/x/net/ipv6/icmp_bsd.go | 29 - vendor/golang.org/x/net/ipv6/icmp_linux.go | 27 - vendor/golang.org/x/net/ipv6/icmp_solaris.go | 24 - vendor/golang.org/x/net/ipv6/icmp_stub.go | 23 - vendor/golang.org/x/net/ipv6/icmp_test.go | 96 - vendor/golang.org/x/net/ipv6/icmp_windows.go | 26 - .../x/net/ipv6/mocktransponder_test.go | 32 - .../golang.org/x/net/ipv6/multicast_test.go | 260 - .../x/net/ipv6/multicastlistener_test.go | 246 - .../x/net/ipv6/multicastsockopt_test.go | 157 - vendor/golang.org/x/net/ipv6/payload.go | 15 - vendor/golang.org/x/net/ipv6/payload_cmsg.go | 70 - .../golang.org/x/net/ipv6/payload_nocmsg.go | 41 - .../golang.org/x/net/ipv6/readwrite_test.go | 189 - vendor/golang.org/x/net/ipv6/sockopt.go | 46 - .../x/net/ipv6/sockopt_asmreq_unix.go | 22 - .../x/net/ipv6/sockopt_asmreq_windows.go | 21 - .../x/net/ipv6/sockopt_ssmreq_stub.go | 17 - .../x/net/ipv6/sockopt_ssmreq_unix.go | 59 - vendor/golang.org/x/net/ipv6/sockopt_stub.go | 13 - vendor/golang.org/x/net/ipv6/sockopt_test.go | 133 - vendor/golang.org/x/net/ipv6/sockopt_unix.go | 122 - .../golang.org/x/net/ipv6/sockopt_windows.go | 86 - vendor/golang.org/x/net/ipv6/sys_bsd.go | 56 - vendor/golang.org/x/net/ipv6/sys_darwin.go | 133 - vendor/golang.org/x/net/ipv6/sys_freebsd.go | 91 - vendor/golang.org/x/net/ipv6/sys_linux.go | 72 - vendor/golang.org/x/net/ipv6/sys_stub.go | 13 - vendor/golang.org/x/net/ipv6/sys_windows.go | 63 - .../x/net/ipv6/syscall_linux_386.go | 31 - vendor/golang.org/x/net/ipv6/syscall_unix.go | 26 - .../golang.org/x/net/ipv6/thunk_linux_386.s | 8 - vendor/golang.org/x/net/ipv6/unicast_test.go | 182 - .../x/net/ipv6/unicastsockopt_test.go | 111 - vendor/golang.org/x/net/ipv6/zsys_darwin.go | 131 - .../golang.org/x/net/ipv6/zsys_dragonfly.go | 90 - .../golang.org/x/net/ipv6/zsys_freebsd_386.go | 122 - .../x/net/ipv6/zsys_freebsd_amd64.go | 124 - .../golang.org/x/net/ipv6/zsys_freebsd_arm.go | 124 - .../golang.org/x/net/ipv6/zsys_linux_386.go | 168 - .../golang.org/x/net/ipv6/zsys_linux_amd64.go | 170 - .../golang.org/x/net/ipv6/zsys_linux_arm.go | 168 - .../golang.org/x/net/ipv6/zsys_linux_arm64.go | 172 - .../x/net/ipv6/zsys_linux_mips64.go | 172 - .../x/net/ipv6/zsys_linux_mips64le.go | 172 - .../golang.org/x/net/ipv6/zsys_linux_ppc64.go | 172 - .../x/net/ipv6/zsys_linux_ppc64le.go | 172 - .../golang.org/x/net/ipv6/zsys_linux_s390x.go | 172 - vendor/golang.org/x/net/ipv6/zsys_netbsd.go | 84 - vendor/golang.org/x/net/ipv6/zsys_openbsd.go | 93 - vendor/golang.org/x/net/ipv6/zsys_solaris.go | 105 - .../golang.org/x/net/lex/httplex/httplex.go | 312 - .../x/net/lex/httplex/httplex_test.go | 101 - vendor/golang.org/x/net/netutil/listen.go | 48 - .../golang.org/x/net/netutil/listen_test.go | 101 - vendor/golang.org/x/net/proxy/direct.go | 18 - vendor/golang.org/x/net/proxy/per_host.go | 140 - .../golang.org/x/net/proxy/per_host_test.go | 55 - vendor/golang.org/x/net/proxy/proxy.go | 94 - vendor/golang.org/x/net/proxy/proxy_test.go | 142 - vendor/golang.org/x/net/proxy/socks5.go | 210 - vendor/golang.org/x/net/publicsuffix/gen.go | 713 - vendor/golang.org/x/net/publicsuffix/list.go | 135 - .../x/net/publicsuffix/list_test.go | 416 - vendor/golang.org/x/net/publicsuffix/table.go | 8947 --------- .../x/net/publicsuffix/table_test.go | 16035 ---------------- vendor/golang.org/x/net/route/address.go | 269 - .../x/net/route/address_darwin_test.go | 63 - vendor/golang.org/x/net/route/address_test.go | 103 - vendor/golang.org/x/net/route/binary.go | 90 - vendor/golang.org/x/net/route/defs_darwin.go | 106 - .../golang.org/x/net/route/defs_dragonfly.go | 105 - vendor/golang.org/x/net/route/defs_freebsd.go | 329 - vendor/golang.org/x/net/route/defs_netbsd.go | 104 - vendor/golang.org/x/net/route/defs_openbsd.go | 93 - vendor/golang.org/x/net/route/interface.go | 64 - .../x/net/route/interface_announce.go | 32 - .../x/net/route/interface_classic.go | 66 - .../x/net/route/interface_freebsd.go | 78 - .../x/net/route/interface_multicast.go | 30 - .../x/net/route/interface_openbsd.go | 83 - vendor/golang.org/x/net/route/message.go | 70 - .../x/net/route/message_darwin_test.go | 27 - .../x/net/route/message_freebsd_test.go | 106 - vendor/golang.org/x/net/route/message_test.go | 95 - vendor/golang.org/x/net/route/route.go | 74 - .../golang.org/x/net/route/route_classic.go | 31 - .../golang.org/x/net/route/route_openbsd.go | 28 - vendor/golang.org/x/net/route/route_test.go | 385 - vendor/golang.org/x/net/route/sys.go | 40 - vendor/golang.org/x/net/route/sys_darwin.go | 80 - .../golang.org/x/net/route/sys_dragonfly.go | 71 - vendor/golang.org/x/net/route/sys_freebsd.go | 150 - vendor/golang.org/x/net/route/sys_netbsd.go | 67 - vendor/golang.org/x/net/route/sys_openbsd.go | 72 - vendor/golang.org/x/net/route/syscall.go | 33 - vendor/golang.org/x/net/route/syscall.s | 8 - vendor/golang.org/x/net/route/zsys_darwin.go | 93 - .../golang.org/x/net/route/zsys_dragonfly.go | 92 - .../x/net/route/zsys_freebsd_386.go | 120 - .../x/net/route/zsys_freebsd_amd64.go | 117 - .../x/net/route/zsys_freebsd_arm.go | 117 - vendor/golang.org/x/net/route/zsys_netbsd.go | 91 - vendor/golang.org/x/net/route/zsys_openbsd.go | 80 - vendor/golang.org/x/net/trace/events.go | 524 - vendor/golang.org/x/net/trace/histogram.go | 356 - .../golang.org/x/net/trace/histogram_test.go | 325 - vendor/golang.org/x/net/trace/trace.go | 1063 - vendor/golang.org/x/net/trace/trace_test.go | 71 - vendor/golang.org/x/net/webdav/file.go | 794 - vendor/golang.org/x/net/webdav/file_test.go | 1166 -- vendor/golang.org/x/net/webdav/if.go | 173 - vendor/golang.org/x/net/webdav/if_test.go | 322 - .../x/net/webdav/internal/xml/README | 11 - .../x/net/webdav/internal/xml/atom_test.go | 56 - .../x/net/webdav/internal/xml/example_test.go | 151 - .../x/net/webdav/internal/xml/marshal.go | 1223 -- .../x/net/webdav/internal/xml/marshal_test.go | 1939 -- .../x/net/webdav/internal/xml/read.go | 692 - .../x/net/webdav/internal/xml/read_test.go | 744 - .../x/net/webdav/internal/xml/typeinfo.go | 371 - .../x/net/webdav/internal/xml/xml.go | 1998 -- .../x/net/webdav/internal/xml/xml_test.go | 752 - .../x/net/webdav/litmus_test_server.go | 94 - vendor/golang.org/x/net/webdav/lock.go | 445 - vendor/golang.org/x/net/webdav/lock_test.go | 731 - vendor/golang.org/x/net/webdav/prop.go | 395 - vendor/golang.org/x/net/webdav/prop_test.go | 610 - vendor/golang.org/x/net/webdav/webdav.go | 689 - vendor/golang.org/x/net/webdav/webdav_test.go | 285 - vendor/golang.org/x/net/webdav/xml.go | 519 - vendor/golang.org/x/net/webdav/xml_test.go | 906 - vendor/golang.org/x/net/websocket/client.go | 113 - .../x/net/websocket/exampledial_test.go | 31 - .../x/net/websocket/examplehandler_test.go | 26 - vendor/golang.org/x/net/websocket/hybi.go | 583 - .../golang.org/x/net/websocket/hybi_test.go | 608 - vendor/golang.org/x/net/websocket/server.go | 113 - .../golang.org/x/net/websocket/websocket.go | 411 - .../x/net/websocket/websocket_test.go | 587 - vendor/golang.org/x/net/xsrftoken/xsrf.go | 88 - .../golang.org/x/net/xsrftoken/xsrf_test.go | 83 - .../natefinch/lumberjack.v2/.gitignore | 23 - .../gopkg.in/natefinch/lumberjack.v2/LICENSE | 21 - .../natefinch/lumberjack.v2/README.md | 166 - .../gopkg.in/natefinch/lumberjack.v2/chown.go | 11 - .../natefinch/lumberjack.v2/chown_linux.go | 19 - .../natefinch/lumberjack.v2/example_test.go | 18 - .../natefinch/lumberjack.v2/linux_test.go | 104 - .../natefinch/lumberjack.v2/lumberjack.go | 417 - .../lumberjack.v2/lumberjack_test.go | 690 - .../natefinch/lumberjack.v2/rotate_test.go | 27 - .../natefinch/lumberjack.v2/testing_test.go | 91 - .../square/go-jose.v1/.gitcookies.sh.enc | 1 - vendor/gopkg.in/square/go-jose.v1/.gitignore | 7 - vendor/gopkg.in/square/go-jose.v1/.travis.yml | 45 - .../gopkg.in/square/go-jose.v1/BUG-BOUNTY.md | 10 - .../square/go-jose.v1/CONTRIBUTING.md | 14 - vendor/gopkg.in/square/go-jose.v1/LICENSE | 202 - vendor/gopkg.in/square/go-jose.v1/README.md | 209 - .../gopkg.in/square/go-jose.v1/asymmetric.go | 498 - .../square/go-jose.v1/asymmetric_test.go | 431 - .../square/go-jose.v1/cipher/cbc_hmac.go | 196 - .../square/go-jose.v1/cipher/cbc_hmac_test.go | 498 - .../square/go-jose.v1/cipher/concat_kdf.go | 75 - .../go-jose.v1/cipher/concat_kdf_test.go | 150 - .../square/go-jose.v1/cipher/ecdh_es.go | 51 - .../square/go-jose.v1/cipher/ecdh_es_test.go | 98 - .../square/go-jose.v1/cipher/key_wrap.go | 109 - .../square/go-jose.v1/cipher/key_wrap_test.go | 133 - vendor/gopkg.in/square/go-jose.v1/crypter.go | 349 - .../square/go-jose.v1/crypter_test.go | 784 - vendor/gopkg.in/square/go-jose.v1/doc.go | 26 - vendor/gopkg.in/square/go-jose.v1/doc_test.go | 226 - vendor/gopkg.in/square/go-jose.v1/encoding.go | 191 - .../square/go-jose.v1/encoding_test.go | 173 - .../square/go-jose.v1/jose-util/README.md | 59 - .../square/go-jose.v1/jose-util/jose-util.t | 88 - .../square/go-jose.v1/jose-util/main.go | 184 - .../gopkg.in/square/go-jose.v1/json/LICENSE | 27 - .../gopkg.in/square/go-jose.v1/json/README.md | 13 - .../square/go-jose.v1/json/bench_test.go | 223 - .../gopkg.in/square/go-jose.v1/json/decode.go | 1183 -- .../square/go-jose.v1/json/decode_test.go | 1474 -- .../gopkg.in/square/go-jose.v1/json/encode.go | 1197 -- .../square/go-jose.v1/json/encode_test.go | 538 - .../gopkg.in/square/go-jose.v1/json/indent.go | 141 - .../square/go-jose.v1/json/number_test.go | 133 - .../square/go-jose.v1/json/scanner.go | 623 - .../square/go-jose.v1/json/scanner_test.go | 316 - .../gopkg.in/square/go-jose.v1/json/stream.go | 480 - .../square/go-jose.v1/json/stream_test.go | 354 - .../square/go-jose.v1/json/tagkey_test.go | 115 - .../gopkg.in/square/go-jose.v1/json/tags.go | 44 - .../square/go-jose.v1/json/tags_test.go | 28 - .../go-jose.v1/json/testdata/code.json.gz | Bin 120432 -> 0 bytes .../gopkg.in/square/go-jose.v1/json_fork.go | 31 - .../square/go-jose.v1/json_fork_test.go | 105 - vendor/gopkg.in/square/go-jose.v1/json_std.go | 31 - .../square/go-jose.v1/json_std_test.go | 124 - vendor/gopkg.in/square/go-jose.v1/jwe.go | 278 - vendor/gopkg.in/square/go-jose.v1/jwe_test.go | 537 - vendor/gopkg.in/square/go-jose.v1/jwk.go | 408 - vendor/gopkg.in/square/go-jose.v1/jwk_test.go | 552 - vendor/gopkg.in/square/go-jose.v1/jws.go | 252 - vendor/gopkg.in/square/go-jose.v1/jws_test.go | 302 - vendor/gopkg.in/square/go-jose.v1/shared.go | 224 - vendor/gopkg.in/square/go-jose.v1/signing.go | 218 - .../square/go-jose.v1/signing_test.go | 447 - .../gopkg.in/square/go-jose.v1/symmetric.go | 349 - .../square/go-jose.v1/symmetric_test.go | 131 - vendor/gopkg.in/square/go-jose.v1/utils.go | 74 - .../gopkg.in/square/go-jose.v1/utils_test.go | 225 - vendor/gopkg.in/yaml.v2/.travis.yml | 9 - vendor/gopkg.in/yaml.v2/LICENSE | 188 - vendor/gopkg.in/yaml.v2/LICENSE.libyaml | 31 - vendor/gopkg.in/yaml.v2/README.md | 131 - vendor/gopkg.in/yaml.v2/apic.go | 742 - vendor/gopkg.in/yaml.v2/decode.go | 683 - vendor/gopkg.in/yaml.v2/decode_test.go | 988 - vendor/gopkg.in/yaml.v2/emitterc.go | 1685 -- vendor/gopkg.in/yaml.v2/encode.go | 306 - vendor/gopkg.in/yaml.v2/encode_test.go | 501 - vendor/gopkg.in/yaml.v2/parserc.go | 1096 -- vendor/gopkg.in/yaml.v2/readerc.go | 394 - vendor/gopkg.in/yaml.v2/resolve.go | 203 - vendor/gopkg.in/yaml.v2/scannerc.go | 2710 --- vendor/gopkg.in/yaml.v2/sorter.go | 104 - vendor/gopkg.in/yaml.v2/suite_test.go | 12 - vendor/gopkg.in/yaml.v2/writerc.go | 89 - vendor/gopkg.in/yaml.v2/yaml.go | 346 - vendor/gopkg.in/yaml.v2/yamlh.go | 716 - vendor/gopkg.in/yaml.v2/yamlprivateh.go | 173 - 1915 files changed, 1 insertion(+), 380696 deletions(-) delete mode 100644 cmd/squirrel/main.go delete mode 100644 glide.lock delete mode 100644 glide.yaml delete mode 100644 munki/datastore/catalogs.go delete mode 100644 munki/datastore/datastore.go delete mode 100644 munki/datastore/manifest.go delete mode 100644 munki/datastore/pkgsinfo.go delete mode 100644 munki/munki/catalog.go delete mode 100644 munki/munki/manifest.go delete mode 100644 munki/munki/manifest_payload.go delete mode 100644 munki/munki/pkgsinfo.go delete mode 100644 munki/server/endpoint_manifest.go delete mode 100644 munki/server/endpoint_pkgsinfo.go delete mode 100644 munki/server/service.go delete mode 100644 munki/server/service_manifest.go delete mode 100644 munki/server/service_pkgsinfo.go delete mode 100644 munki/server/testdata/testrepo/manifests/site_default delete mode 100644 munki/server/transport.go delete mode 100644 munki/server/transport_manifest.go delete mode 100644 munki/server/transport_manifest_test.go delete mode 100644 munki/server/transport_pkgsinfo.go delete mode 100644 munki/server/transport_pkgsinfo_test.go delete mode 100644 munki/server/transport_test.go delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/LICENSE delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/README.md delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20.go delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.go delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.py delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.s delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_ref.go delete mode 100644 vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_test.go delete mode 100644 vendor/git.schwanenlied.me/yawning/poly1305.git/.gitignore delete mode 100644 vendor/git.schwanenlied.me/yawning/poly1305.git/README.md delete mode 100644 vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305.go delete mode 100644 vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_32.go delete mode 100644 vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_test.go delete mode 100644 vendor/github.com/BurntSushi/toml/.gitignore delete mode 100644 vendor/github.com/BurntSushi/toml/.travis.yml delete mode 100644 vendor/github.com/BurntSushi/toml/COMPATIBLE delete mode 100644 vendor/github.com/BurntSushi/toml/COPYING delete mode 100644 vendor/github.com/BurntSushi/toml/Makefile delete mode 100644 vendor/github.com/BurntSushi/toml/README.md delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/example.go delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/example.toml delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/hard.toml delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/implicit.toml delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/invalid-apples.toml delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/invalid.toml delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/readme1.toml delete mode 100644 vendor/github.com/BurntSushi/toml/_examples/readme2.toml delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/tomlv/COPYING delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/tomlv/README.md delete mode 100644 vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go delete mode 100644 vendor/github.com/BurntSushi/toml/decode.go delete mode 100644 vendor/github.com/BurntSushi/toml/decode_meta.go delete mode 100644 vendor/github.com/BurntSushi/toml/decode_test.go delete mode 100644 vendor/github.com/BurntSushi/toml/doc.go delete mode 100644 vendor/github.com/BurntSushi/toml/encode.go delete mode 100644 vendor/github.com/BurntSushi/toml/encode_test.go delete mode 100644 vendor/github.com/BurntSushi/toml/encoding_types.go delete mode 100644 vendor/github.com/BurntSushi/toml/encoding_types_1.1.go delete mode 100644 vendor/github.com/BurntSushi/toml/lex.go delete mode 100644 vendor/github.com/BurntSushi/toml/parse.go delete mode 100644 vendor/github.com/BurntSushi/toml/session.vim delete mode 100644 vendor/github.com/BurntSushi/toml/type_check.go delete mode 100644 vendor/github.com/BurntSushi/toml/type_fields.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/.gitignore delete mode 100644 vendor/github.com/abiosoft/caddy-git/.travis.yml delete mode 100644 vendor/github.com/abiosoft/caddy-git/BUILDING.md delete mode 100644 vendor/github.com/abiosoft/caddy-git/LICENSE delete mode 100644 vendor/github.com/abiosoft/caddy-git/README.md delete mode 100644 vendor/github.com/abiosoft/caddy-git/bitbucket_hook.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/bitbucket_hook_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/commands.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/config.json delete mode 100644 vendor/github.com/abiosoft/caddy-git/generic_hook.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/generic_hook_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/git.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/git_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/github_hook.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/github_hook_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/gitlab_hook.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/gitlab_hook_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/gitos/gitos.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/gittest/gittest.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/gogs_hook.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/gogs_hook_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/logger.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/os.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/scripts.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/service.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/service_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/setup.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/setup_test.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/travis_hook.go delete mode 100644 vendor/github.com/abiosoft/caddy-git/webhook.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/.gitignore delete mode 100644 vendor/github.com/dgrijalva/jwt-go/.travis.yml delete mode 100644 vendor/github.com/dgrijalva/jwt-go/LICENSE delete mode 100644 vendor/github.com/dgrijalva/jwt-go/README.md delete mode 100644 vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md delete mode 100644 vendor/github.com/dgrijalva/jwt-go/cmd/jwt/README.md delete mode 100644 vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/doc.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/ecdsa.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/ecdsa_test.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/errors.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/example_test.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/hmac.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/hmac_test.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/none.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/none_test.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/parser.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/parser_test.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/rsa.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/rsa_pss.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/rsa_pss_test.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/rsa_test.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/rsa_utils.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/signing_method.go delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/ec256-private.pem delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/ec256-public.pem delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/ec384-private.pem delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/ec384-public.pem delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/ec512-private.pem delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/ec512-public.pem delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/hmacTestKey delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/sample_key delete mode 100644 vendor/github.com/dgrijalva/jwt-go/test/sample_key.pub delete mode 100644 vendor/github.com/dgrijalva/jwt-go/token.go delete mode 100644 vendor/github.com/dustin/go-humanize/.gitignore delete mode 100644 vendor/github.com/dustin/go-humanize/.travis.yml delete mode 100644 vendor/github.com/dustin/go-humanize/LICENSE delete mode 100644 vendor/github.com/dustin/go-humanize/README.markdown delete mode 100644 vendor/github.com/dustin/go-humanize/big.go delete mode 100644 vendor/github.com/dustin/go-humanize/bigbytes.go delete mode 100644 vendor/github.com/dustin/go-humanize/bigbytes_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/bytes.go delete mode 100644 vendor/github.com/dustin/go-humanize/bytes_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/comma.go delete mode 100644 vendor/github.com/dustin/go-humanize/comma_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/commaf.go delete mode 100644 vendor/github.com/dustin/go-humanize/commaf_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/common_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/ftoa.go delete mode 100644 vendor/github.com/dustin/go-humanize/ftoa_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/humanize.go delete mode 100644 vendor/github.com/dustin/go-humanize/number.go delete mode 100644 vendor/github.com/dustin/go-humanize/number_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/ordinals.go delete mode 100644 vendor/github.com/dustin/go-humanize/ordinals_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/si.go delete mode 100644 vendor/github.com/dustin/go-humanize/si_test.go delete mode 100644 vendor/github.com/dustin/go-humanize/times.go delete mode 100644 vendor/github.com/dustin/go-humanize/times_test.go delete mode 100644 vendor/github.com/flynn/go-shlex/COPYING delete mode 100644 vendor/github.com/flynn/go-shlex/Makefile delete mode 100644 vendor/github.com/flynn/go-shlex/README.md delete mode 100644 vendor/github.com/flynn/go-shlex/shlex.go delete mode 100644 vendor/github.com/flynn/go-shlex/shlex_test.go delete mode 100644 vendor/github.com/go-kit/kit/.gitignore delete mode 100644 vendor/github.com/go-kit/kit/.travis.yml delete mode 100644 vendor/github.com/go-kit/kit/CONTRIBUTING.md delete mode 100644 vendor/github.com/go-kit/kit/LICENSE delete mode 100644 vendor/github.com/go-kit/kit/README.md delete mode 100644 vendor/github.com/go-kit/kit/circuitbreaker/gobreaker.go delete mode 100644 vendor/github.com/go-kit/kit/circuitbreaker/gobreaker_test.go delete mode 100644 vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker.go delete mode 100644 vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker_test.go delete mode 100644 vendor/github.com/go-kit/kit/circuitbreaker/hystrix.go delete mode 100644 vendor/github.com/go-kit/kit/circuitbreaker/hystrix_test.go delete mode 100644 vendor/github.com/go-kit/kit/circuitbreaker/util_test.go delete mode 100755 vendor/github.com/go-kit/kit/coverage.bash delete mode 100644 vendor/github.com/go-kit/kit/endpoint/endpoint.go delete mode 100644 vendor/github.com/go-kit/kit/endpoint/endpoint_example_test.go delete mode 100644 vendor/github.com/go-kit/kit/examples/README.md delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/client/grpc/client.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/client/http/client.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/client/thrift/client.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/cmd/addcli/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/cmd/addsvc/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/doc.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/endpoints.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.proto delete mode 100755 vendor/github.com/go-kit/kit/examples/addsvc/pb/compile.sh delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/service.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/thrift/addsvc.thrift delete mode 100755 vendor/github.com/go-kit/kit/examples/addsvc/thrift/compile.sh delete mode 100755 vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/add_service-remote/add_service-remote.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/addservice.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/constants.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/ttypes.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/transport_grpc.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/transport_http.go delete mode 100644 vendor/github.com/go-kit/kit/examples/addsvc/transport_thrift.go delete mode 100644 vendor/github.com/go-kit/kit/examples/apigateway/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/profilesvc/README.md delete mode 100644 vendor/github.com/go-kit/kit/examples/profilesvc/client/client.go delete mode 100644 vendor/github.com/go-kit/kit/examples/profilesvc/cmd/profilesvc/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/profilesvc/endpoints.go delete mode 100644 vendor/github.com/go-kit/kit/examples/profilesvc/middlewares.go delete mode 100644 vendor/github.com/go-kit/kit/examples/profilesvc/service.go delete mode 100644 vendor/github.com/go-kit/kit/examples/profilesvc/transport.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/README.md delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/booking/service.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/cargo/delivery.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/cargo/itinerary.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/handling/service.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/location/location.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/repository/repositories.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/routing/routing.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/tracking/endpoint.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/tracking/logging.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go delete mode 100644 vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc1/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc2/instrumenting.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc2/logging.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc2/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc2/service.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc2/transport.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc3/instrumenting.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc3/logging.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc3/main.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc3/proxying.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc3/service.go delete mode 100644 vendor/github.com/go-kit/kit/examples/stringsvc3/transport.go delete mode 100755 vendor/github.com/go-kit/kit/lint delete mode 100644 vendor/github.com/go-kit/kit/log/README.md delete mode 100644 vendor/github.com/go-kit/kit/log/benchmark_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/concurrency_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/example_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/json_logger.go delete mode 100644 vendor/github.com/go-kit/kit/log/json_logger_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/levels/levels.go delete mode 100644 vendor/github.com/go-kit/kit/log/levels/levels_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/log.go delete mode 100644 vendor/github.com/go-kit/kit/log/log_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/logfmt_logger.go delete mode 100644 vendor/github.com/go-kit/kit/log/logfmt_logger_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/nop_logger.go delete mode 100644 vendor/github.com/go-kit/kit/log/nop_logger_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/stdlib.go delete mode 100644 vendor/github.com/go-kit/kit/log/stdlib_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/LICENSE delete mode 100644 vendor/github.com/go-kit/kit/log/term/colorlogger.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/colorlogger_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/colorwriter_others.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/colorwriter_windows.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/example_test.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/term.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/terminal_appengine.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/terminal_darwin.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/terminal_freebsd.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/terminal_linux.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/terminal_notwindows.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/terminal_openbsd.go delete mode 100644 vendor/github.com/go-kit/kit/log/term/terminal_windows.go delete mode 100644 vendor/github.com/go-kit/kit/log/value.go delete mode 100644 vendor/github.com/go-kit/kit/log/value_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/README.md delete mode 100644 vendor/github.com/go-kit/kit/metrics/discard/discard.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/dogstatsd/dogstatsd.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/dogstatsd/dogstatsd_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/dogstatsd/emitter.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/expvar/expvar.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/expvar/expvar_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/graphite/emitter.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/graphite/graphite.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/graphite/graphite_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/influxdb/influxdb.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/influxdb/influxdb_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/metrics.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/multi.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/multi_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/print.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/print_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/prometheus/prometheus.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/prometheus/prometheus_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/provider/providers.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/provider/providers_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/scaled_histogram.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/scaled_histogram_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/statsd/emitter.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/statsd/statsd.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/statsd/statsd_test.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/teststat/circonus.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/teststat/common.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/teststat/expvar.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/teststat/graphite.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/teststat/prometheus.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/time_histogram.go delete mode 100644 vendor/github.com/go-kit/kit/metrics/time_histogram_test.go delete mode 100644 vendor/github.com/go-kit/kit/ratelimit/token_bucket.go delete mode 100644 vendor/github.com/go-kit/kit/ratelimit/token_bucket_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/cache/benchmark_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/cache/cache.go delete mode 100644 vendor/github.com/go-kit/kit/sd/cache/cache_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/consul/client.go delete mode 100644 vendor/github.com/go-kit/kit/sd/consul/client_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/consul/integration_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/consul/registrar.go delete mode 100644 vendor/github.com/go-kit/kit/sd/consul/registrar_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/consul/subscriber.go delete mode 100644 vendor/github.com/go-kit/kit/sd/consul/subscriber_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/dnssrv/lookup.go delete mode 100644 vendor/github.com/go-kit/kit/sd/dnssrv/subscriber.go delete mode 100644 vendor/github.com/go-kit/kit/sd/dnssrv/subscriber_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/doc.go delete mode 100644 vendor/github.com/go-kit/kit/sd/etcd/client.go delete mode 100644 vendor/github.com/go-kit/kit/sd/etcd/subscriber.go delete mode 100644 vendor/github.com/go-kit/kit/sd/etcd/subscriber_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/factory.go delete mode 100644 vendor/github.com/go-kit/kit/sd/fixed_subscriber.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/balancer.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/doc.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/random.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/random_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/retry.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/retry_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/round_robin.go delete mode 100644 vendor/github.com/go-kit/kit/sd/lb/round_robin_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/registrar.go delete mode 100644 vendor/github.com/go-kit/kit/sd/subscriber.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/client.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/client_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/integration_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/logwrapper.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/registrar.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/subscriber.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/subscriber_test.go delete mode 100644 vendor/github.com/go-kit/kit/sd/zk/util_test.go delete mode 100644 vendor/github.com/go-kit/kit/tracing/README.md delete mode 100644 vendor/github.com/go-kit/kit/tracing/opentracing/endpoint.go delete mode 100644 vendor/github.com/go-kit/kit/tracing/opentracing/endpoint_test.go delete mode 100644 vendor/github.com/go-kit/kit/tracing/opentracing/grpc.go delete mode 100644 vendor/github.com/go-kit/kit/tracing/opentracing/grpc_test.go delete mode 100644 vendor/github.com/go-kit/kit/tracing/opentracing/http.go delete mode 100644 vendor/github.com/go-kit/kit/tracing/opentracing/http_test.go delete mode 100644 vendor/github.com/go-kit/kit/tracing/zipkin/README.md delete mode 100644 vendor/github.com/go-kit/kit/tracing/zipkin/docker-compose-zipkin.yml delete mode 100644 vendor/github.com/go-kit/kit/transport/grpc/README.md delete mode 100644 vendor/github.com/go-kit/kit/transport/grpc/client.go delete mode 100644 vendor/github.com/go-kit/kit/transport/grpc/encode_decode.go delete mode 100644 vendor/github.com/go-kit/kit/transport/grpc/request_response_funcs.go delete mode 100644 vendor/github.com/go-kit/kit/transport/grpc/server.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/client.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/client_test.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/encode_decode.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/err.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/err_test.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/request_response_funcs.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/request_response_funcs_test.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/server.go delete mode 100644 vendor/github.com/go-kit/kit/transport/http/server_test.go delete mode 100644 vendor/github.com/go-kit/kit/transport/httprp/README.md delete mode 100644 vendor/github.com/go-kit/kit/transport/httprp/server.go delete mode 100644 vendor/github.com/go-kit/kit/transport/httprp/server_test.go delete mode 100644 vendor/github.com/go-kit/kit/transport/netrpc/README.md delete mode 100644 vendor/github.com/go-kit/kit/transport/thrift/README.md delete mode 100755 vendor/github.com/go-kit/kit/update_deps.bash delete mode 100644 vendor/github.com/go-kit/kit/util/README.md delete mode 100644 vendor/github.com/go-kit/kit/util/conn/doc.go delete mode 100644 vendor/github.com/go-kit/kit/util/conn/manager.go delete mode 100644 vendor/github.com/go-kit/kit/util/conn/manager_test.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/.gitignore delete mode 100644 vendor/github.com/go-logfmt/logfmt/.travis.yml delete mode 100644 vendor/github.com/go-logfmt/logfmt/LICENSE delete mode 100644 vendor/github.com/go-logfmt/logfmt/README.md delete mode 100644 vendor/github.com/go-logfmt/logfmt/decode-bench_test.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/decode.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/decode_test.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/doc.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/encode.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/encode_internal_test.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/encode_test.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/example_test.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/fuzz.go delete mode 100644 vendor/github.com/go-logfmt/logfmt/jsonstring.go delete mode 100644 vendor/github.com/go-stack/stack/.travis.yml delete mode 100644 vendor/github.com/go-stack/stack/LICENSE.md delete mode 100644 vendor/github.com/go-stack/stack/README.md delete mode 100644 vendor/github.com/go-stack/stack/format_test.go delete mode 100644 vendor/github.com/go-stack/stack/stack.go delete mode 100644 vendor/github.com/go-stack/stack/stack_test.go delete mode 100644 vendor/github.com/go-stack/stack/stackinternal_test.go delete mode 100644 vendor/github.com/gorilla/websocket/.gitignore delete mode 100644 vendor/github.com/gorilla/websocket/.travis.yml delete mode 100644 vendor/github.com/gorilla/websocket/AUTHORS delete mode 100644 vendor/github.com/gorilla/websocket/LICENSE delete mode 100644 vendor/github.com/gorilla/websocket/README.md delete mode 100644 vendor/github.com/gorilla/websocket/bench_test.go delete mode 100644 vendor/github.com/gorilla/websocket/client.go delete mode 100644 vendor/github.com/gorilla/websocket/client_server_test.go delete mode 100644 vendor/github.com/gorilla/websocket/client_test.go delete mode 100644 vendor/github.com/gorilla/websocket/conn.go delete mode 100644 vendor/github.com/gorilla/websocket/conn_read.go delete mode 100644 vendor/github.com/gorilla/websocket/conn_read_legacy.go delete mode 100644 vendor/github.com/gorilla/websocket/conn_test.go delete mode 100644 vendor/github.com/gorilla/websocket/doc.go delete mode 100644 vendor/github.com/gorilla/websocket/example_test.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/autobahn/README.md delete mode 100644 vendor/github.com/gorilla/websocket/examples/autobahn/fuzzingclient.json delete mode 100644 vendor/github.com/gorilla/websocket/examples/autobahn/server.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/README.md delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/conn.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/home.html delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/hub.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/chat/main.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/command/README.md delete mode 100644 vendor/github.com/gorilla/websocket/examples/command/home.html delete mode 100644 vendor/github.com/gorilla/websocket/examples/command/main.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/echo/README.md delete mode 100644 vendor/github.com/gorilla/websocket/examples/echo/client.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/echo/server.go delete mode 100644 vendor/github.com/gorilla/websocket/examples/filewatch/README.md delete mode 100644 vendor/github.com/gorilla/websocket/examples/filewatch/main.go delete mode 100644 vendor/github.com/gorilla/websocket/json.go delete mode 100644 vendor/github.com/gorilla/websocket/json_test.go delete mode 100644 vendor/github.com/gorilla/websocket/server.go delete mode 100644 vendor/github.com/gorilla/websocket/server_test.go delete mode 100644 vendor/github.com/gorilla/websocket/util.go delete mode 100644 vendor/github.com/gorilla/websocket/util_test.go delete mode 100644 vendor/github.com/groob/plist/LICENSE delete mode 100644 vendor/github.com/groob/plist/README.md delete mode 100644 vendor/github.com/groob/plist/decode.go delete mode 100644 vendor/github.com/groob/plist/decode_test.go delete mode 100644 vendor/github.com/groob/plist/encode.go delete mode 100644 vendor/github.com/groob/plist/encode_test.go delete mode 100644 vendor/github.com/groob/plist/plist.go delete mode 100644 vendor/github.com/groob/plist/tags.go delete mode 100644 vendor/github.com/groob/plist/xml_parser.go delete mode 100644 vendor/github.com/groob/plist/xml_writer.go delete mode 100644 vendor/github.com/hashicorp/go-syslog/.gitignore delete mode 100644 vendor/github.com/hashicorp/go-syslog/LICENSE delete mode 100644 vendor/github.com/hashicorp/go-syslog/README.md delete mode 100644 vendor/github.com/hashicorp/go-syslog/builtin.go delete mode 100644 vendor/github.com/hashicorp/go-syslog/syslog.go delete mode 100644 vendor/github.com/hashicorp/go-syslog/unix.go delete mode 100644 vendor/github.com/hashicorp/go-syslog/unsupported.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/LICENSE delete mode 100644 vendor/github.com/jimstudt/http-authentication/README.md delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/README.md delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/bcrypt.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/bcrypt_test.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/htpasswd.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/htpasswd_test.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/md5.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/md5_test.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/plain.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/plain_test.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/sha.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/sha_test.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/util.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/basic/util_test.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/README.md delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/digest.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/digest_test.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/htdigest-user-store.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/parse.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/simple-nonce-store.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/simple-nonce.go delete mode 100644 vendor/github.com/jimstudt/http-authentication/digest/simple-user-store.go delete mode 100644 vendor/github.com/julienschmidt/httprouter/.travis.yml delete mode 100644 vendor/github.com/julienschmidt/httprouter/LICENSE delete mode 100644 vendor/github.com/julienschmidt/httprouter/README.md delete mode 100644 vendor/github.com/julienschmidt/httprouter/path.go delete mode 100644 vendor/github.com/julienschmidt/httprouter/path_test.go delete mode 100644 vendor/github.com/julienschmidt/httprouter/router.go delete mode 100644 vendor/github.com/julienschmidt/httprouter/router_test.go delete mode 100644 vendor/github.com/julienschmidt/httprouter/tree.go delete mode 100644 vendor/github.com/julienschmidt/httprouter/tree_test.go delete mode 100644 vendor/github.com/kr/logfmt/.gitignore delete mode 100644 vendor/github.com/kr/logfmt/Readme delete mode 100644 vendor/github.com/kr/logfmt/bench_test.go delete mode 100644 vendor/github.com/kr/logfmt/decode.go delete mode 100644 vendor/github.com/kr/logfmt/decode_test.go delete mode 100644 vendor/github.com/kr/logfmt/example_test.go delete mode 100644 vendor/github.com/kr/logfmt/scanner.go delete mode 100644 vendor/github.com/kr/logfmt/scanner_test.go delete mode 100644 vendor/github.com/kr/logfmt/unquote.go delete mode 100644 vendor/github.com/lucas-clemente/chacha20poly1305/LICENSE delete mode 100644 vendor/github.com/lucas-clemente/chacha20poly1305/README.md delete mode 100644 vendor/github.com/lucas-clemente/chacha20poly1305/aead.go delete mode 100644 vendor/github.com/lucas-clemente/chacha20poly1305/aead_test.go delete mode 100644 vendor/github.com/lucas-clemente/fnv128a/LICENSE delete mode 100644 vendor/github.com/lucas-clemente/fnv128a/README.md delete mode 100644 vendor/github.com/lucas-clemente/fnv128a/fnv128a.go delete mode 100644 vendor/github.com/lucas-clemente/fnv128a/fnv128a_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go-certificates/README.md delete mode 100644 vendor/github.com/lucas-clemente/quic-go-certificates/cert_set_1.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go-certificates/cert_set_2.go delete mode 100755 vendor/github.com/lucas-clemente/quic-go-certificates/createCertSets.rb delete mode 100644 vendor/github.com/lucas-clemente/quic-go/.editorconfig delete mode 100644 vendor/github.com/lucas-clemente/quic-go/.gitignore delete mode 100644 vendor/github.com/lucas-clemente/quic-go/.travis.yml delete mode 100755 vendor/github.com/lucas-clemente/quic-go/.travis/after_success.sh delete mode 100755 vendor/github.com/lucas-clemente/quic-go/.travis/script.sh delete mode 100644 vendor/github.com/lucas-clemente/quic-go/LICENSE delete mode 100644 vendor/github.com/lucas-clemente/quic-go/README.md delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/ackhandler_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/entropy_accumulator.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/entropy_accumulator_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/interfaces.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/packet.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/packet_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/received_packet_handler.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/received_packet_handler_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/sent_packet_handler.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/sent_packet_handler_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/stop_waiting_manager.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/ackhandler/stop_waiting_manager_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/appveyor.yml delete mode 100644 vendor/github.com/lucas-clemente/quic-go/blocked_manager.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/blocked_manager_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/codecov.yml delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/bandwidth.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/bandwidth_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/clock.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/congestion_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/congestion_vector.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/cubic.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/cubic_sender.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/cubic_sender_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/cubic_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/hybrid_slow_start.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/hybrid_slow_start_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/interface.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/prr_sender.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/prr_sender_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/rtt_stats.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/rtt_stats_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/congestion/stats.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/AEAD.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/cert_compression.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/cert_compression_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/cert_dict.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/cert_sets.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/chacha20poly1305_aead.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/chacha20poly1305_aead_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/crypto_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/curve_25519.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/curve_25519_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/key_derivation.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/key_derivation_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/key_exchange.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/null_aead.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/null_aead_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/proof_source.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/proof_source_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/signer.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/source_address_token.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/crypto/source_address_token_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/docs/quic.png delete mode 100644 vendor/github.com/lucas-clemente/quic-go/docs/quic.sketch delete mode 100644 vendor/github.com/lucas-clemente/quic-go/docs/quic.svg delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/Dockerfile delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/cert.der delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/chain.der delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/fullchain.der delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/fullchain.pem delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/key.der delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/main.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/example/privkey.pem delete mode 100644 vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/flowcontrol/flowcontrol_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/flowcontrol/interface.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/ack_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/ack_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/frames_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/log.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/log_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/nack_range.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/nack_range_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/ping_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/ping_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/stream_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/stream_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/h2quic/h2quic_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/h2quic/request.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/h2quic/request_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/h2quic/server.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/h2quic/server_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/data_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/handshake_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/server_config.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/server_config_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/handshake/tags.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/chrome_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/drop.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/drop_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/integration.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/integration_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/integrationtests_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/packet_packer.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/packet_packer_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/packet_unpacker.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/packet_unpacker_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/protocol/packet_number.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/protocol/packet_number_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/protocol/protocol.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/protocol/protocol_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/protocol/server_parameters.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/protocol/version.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/protocol/version_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/public_header.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/public_header_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/public_reset.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/public_reset_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/qerr/error_codes.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/qerr/errorcode_string.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/qerr/errorcodes_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/qerr/errors_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/qerr/quic_error.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/qerr/quic_error_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/quic_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/server.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/server_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/session.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/session_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/stream.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/stream_frame_queue.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/stream_frame_queue_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/stream_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/testdata/cert.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/udp_conn.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/_gen.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/byteinterval_linkedlist.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/caching_reader.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/caching_reader_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/float16.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/float16_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/log.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/log_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/minmax.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/minmax_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/streamframe_interval.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/utils.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/utils_suite_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/utils/utils_test.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/window_update_manager.go delete mode 100644 vendor/github.com/lucas-clemente/quic-go/window_update_manager_test.go delete mode 100644 vendor/github.com/mholt/caddy/.gitattributes delete mode 100644 vendor/github.com/mholt/caddy/.gitignore delete mode 100644 vendor/github.com/mholt/caddy/.travis.yml delete mode 100644 vendor/github.com/mholt/caddy/CONTRIBUTING.md delete mode 100644 vendor/github.com/mholt/caddy/ISSUE_TEMPLATE delete mode 100644 vendor/github.com/mholt/caddy/LICENSE.txt delete mode 100644 vendor/github.com/mholt/caddy/README.md delete mode 100644 vendor/github.com/mholt/caddy/appveyor.yml delete mode 100644 vendor/github.com/mholt/caddy/assets.go delete mode 100644 vendor/github.com/mholt/caddy/assets_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddy.go delete mode 100755 vendor/github.com/mholt/caddy/caddy/build.bash delete mode 100644 vendor/github.com/mholt/caddy/caddy/caddymain/run.go delete mode 100644 vendor/github.com/mholt/caddy/caddy/main.go delete mode 100644 vendor/github.com/mholt/caddy/caddy_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/bind/bind.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/bind/bind_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/browse.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/browse_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/header.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos.tpl delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test2.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test3.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/caddyhttp.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/errors/errors.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/errors/errors_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/errors/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/errors/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/expvar/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/expvar/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/extensions/ext.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/extensions/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/extensions/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgi_test.php delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/gzip/testdata/test.txt delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/header/header.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/header/header_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/header/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/header/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/context.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/context_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/graceful.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/https.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/https_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/middleware.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/middleware_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/plugin.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/plugin_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/roller.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/server.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/server_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/siteconfig.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/log/log.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/log/log_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/log/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/log/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_json.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_none.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_toml.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_yaml.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/process.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/render.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/summary.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/markdown/template.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/mime/mime.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/mime/mime_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/mime/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/mime/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/pprof/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/pprof/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/policy.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/policy_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/redirect/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/redirect/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/testdata/testdir/empty delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/testdata/testfile delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/to.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/rewrite/to_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/root/root.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/root/root_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/templates.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/templates_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/header.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/header.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img.htm delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img2.htm delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/photos/test.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/root.html delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/websocket/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/websocket/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket.go delete mode 100644 vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/certificates.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/certificates_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/client.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/client_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/config.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/crypto.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/crypto_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/handshake.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/handshake_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/httphandler.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/httphandler_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/maintain.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/setup.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/setup_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/storage.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/storage_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/tls.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/tls_test.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/user.go delete mode 100644 vendor/github.com/mholt/caddy/caddytls/user_test.go delete mode 100644 vendor/github.com/mholt/caddy/commands.go delete mode 100644 vendor/github.com/mholt/caddy/commands_test.go delete mode 100644 vendor/github.com/mholt/caddy/controller.go delete mode 100644 vendor/github.com/mholt/caddy/dist/CHANGES.txt delete mode 100644 vendor/github.com/mholt/caddy/dist/LICENSES.txt delete mode 100644 vendor/github.com/mholt/caddy/dist/README.txt delete mode 100644 vendor/github.com/mholt/caddy/dist/automate.go delete mode 100644 vendor/github.com/mholt/caddy/dist/gitcookie.sh.enc delete mode 100644 vendor/github.com/mholt/caddy/dist/init/README.md delete mode 100755 vendor/github.com/mholt/caddy/dist/init/freebsd/caddy delete mode 100644 vendor/github.com/mholt/caddy/dist/init/linux-systemd/README.md delete mode 100644 vendor/github.com/mholt/caddy/dist/init/linux-systemd/caddy.service delete mode 100644 vendor/github.com/mholt/caddy/dist/init/linux-upstart/README.md delete mode 100644 vendor/github.com/mholt/caddy/dist/init/linux-upstart/caddy.conf delete mode 100644 vendor/github.com/mholt/caddy/plugins.go delete mode 100644 vendor/github.com/mholt/caddy/sigtrap.go delete mode 100644 vendor/github.com/mholt/caddy/sigtrap_posix.go delete mode 100644 vendor/github.com/mholt/caddy/sigtrap_windows.go delete mode 100644 vendor/github.com/mholt/caddy/startupshutdown/startupshutdown.go delete mode 100644 vendor/github.com/mholt/caddy/startupshutdown/startupshutdown_test.go delete mode 100644 vendor/github.com/micromdm/scep/.gitignore delete mode 100644 vendor/github.com/micromdm/scep/Dockerfile delete mode 100644 vendor/github.com/micromdm/scep/LICENSE delete mode 100644 vendor/github.com/micromdm/scep/README.md delete mode 100644 vendor/github.com/micromdm/scep/caddy/config.json delete mode 100644 vendor/github.com/micromdm/scep/caddy/scep.go delete mode 100644 vendor/github.com/micromdm/scep/caddy/scep_test.go delete mode 100644 vendor/github.com/micromdm/scep/client/scep.go delete mode 100644 vendor/github.com/micromdm/scep/cmd/scepclient/cert.go delete mode 100644 vendor/github.com/micromdm/scep/cmd/scepclient/csr.go delete mode 100644 vendor/github.com/micromdm/scep/cmd/scepclient/key.go delete mode 100755 vendor/github.com/micromdm/scep/cmd/scepclient/release.sh delete mode 100644 vendor/github.com/micromdm/scep/cmd/scepclient/scepclient.go delete mode 100755 vendor/github.com/micromdm/scep/cmd/scepserver/release.sh delete mode 100644 vendor/github.com/micromdm/scep/cmd/scepserver/scepserver.go delete mode 100644 vendor/github.com/micromdm/scep/scep/internal/pkcs7/.gitignore delete mode 100644 vendor/github.com/micromdm/scep/scep/internal/pkcs7/LICENSE delete mode 100644 vendor/github.com/micromdm/scep/scep/internal/pkcs7/README.md delete mode 100644 vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber.go delete mode 100644 vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber_test.go delete mode 100644 vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7.go delete mode 100644 vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7_test.go delete mode 100644 vendor/github.com/micromdm/scep/scep/scep.go delete mode 100644 vendor/github.com/micromdm/scep/scep/scep_test.go delete mode 100755 vendor/github.com/micromdm/scep/scep/testdata/CertRep.der delete mode 100755 vendor/github.com/micromdm/scep/scep/testdata/PKCSReq.der delete mode 100644 vendor/github.com/micromdm/scep/scep/testdata/testca/ca.crt delete mode 100644 vendor/github.com/micromdm/scep/scep/testdata/testca/ca.crt.info delete mode 100644 vendor/github.com/micromdm/scep/scep/testdata/testca/ca.key delete mode 100644 vendor/github.com/micromdm/scep/scep/testdata/testca/ca.pem delete mode 100644 vendor/github.com/micromdm/scep/scep/testdata/testca/sceptest.mobileconfig delete mode 100644 vendor/github.com/micromdm/scep/scep/testdata/testclient/client.key delete mode 100644 vendor/github.com/micromdm/scep/scep/testdata/testclient/client.pem delete mode 100644 vendor/github.com/micromdm/scep/server/depot.go delete mode 100644 vendor/github.com/micromdm/scep/server/endpoint.go delete mode 100644 vendor/github.com/micromdm/scep/server/service.go delete mode 100644 vendor/github.com/micromdm/scep/server/service_logging.go delete mode 100644 vendor/github.com/micromdm/scep/server/transport.go delete mode 100644 vendor/github.com/micromdm/scep/server/transport_test.go delete mode 100644 vendor/github.com/miekg/dns/.gitignore delete mode 100644 vendor/github.com/miekg/dns/.travis.yml delete mode 100644 vendor/github.com/miekg/dns/AUTHORS delete mode 100644 vendor/github.com/miekg/dns/CONTRIBUTORS delete mode 100644 vendor/github.com/miekg/dns/COPYRIGHT delete mode 100644 vendor/github.com/miekg/dns/LICENSE delete mode 100644 vendor/github.com/miekg/dns/README.md delete mode 100644 vendor/github.com/miekg/dns/client.go delete mode 100644 vendor/github.com/miekg/dns/client_test.go delete mode 100644 vendor/github.com/miekg/dns/clientconfig.go delete mode 100644 vendor/github.com/miekg/dns/clientconfig_test.go delete mode 100644 vendor/github.com/miekg/dns/defaults.go delete mode 100644 vendor/github.com/miekg/dns/dns.go delete mode 100644 vendor/github.com/miekg/dns/dns_bench_test.go delete mode 100644 vendor/github.com/miekg/dns/dns_test.go delete mode 100644 vendor/github.com/miekg/dns/dnssec.go delete mode 100644 vendor/github.com/miekg/dns/dnssec_keygen.go delete mode 100644 vendor/github.com/miekg/dns/dnssec_keyscan.go delete mode 100644 vendor/github.com/miekg/dns/dnssec_privkey.go delete mode 100644 vendor/github.com/miekg/dns/dnssec_test.go delete mode 100644 vendor/github.com/miekg/dns/dnsutil/util.go delete mode 100644 vendor/github.com/miekg/dns/dnsutil/util_test.go delete mode 100644 vendor/github.com/miekg/dns/doc.go delete mode 100644 vendor/github.com/miekg/dns/dyn_test.go delete mode 100644 vendor/github.com/miekg/dns/edns.go delete mode 100644 vendor/github.com/miekg/dns/edns_test.go delete mode 100644 vendor/github.com/miekg/dns/example_test.go delete mode 100644 vendor/github.com/miekg/dns/format.go delete mode 100644 vendor/github.com/miekg/dns/fuzz_test.go delete mode 100644 vendor/github.com/miekg/dns/generate.go delete mode 100644 vendor/github.com/miekg/dns/idn/code_points.go delete mode 100644 vendor/github.com/miekg/dns/idn/example_test.go delete mode 100644 vendor/github.com/miekg/dns/idn/punycode.go delete mode 100644 vendor/github.com/miekg/dns/idn/punycode_test.go delete mode 100644 vendor/github.com/miekg/dns/issue_test.go delete mode 100644 vendor/github.com/miekg/dns/labels.go delete mode 100644 vendor/github.com/miekg/dns/labels_test.go delete mode 100644 vendor/github.com/miekg/dns/msg.go delete mode 100644 vendor/github.com/miekg/dns/msg_generate.go delete mode 100644 vendor/github.com/miekg/dns/msg_helpers.go delete mode 100644 vendor/github.com/miekg/dns/nsecx.go delete mode 100644 vendor/github.com/miekg/dns/nsecx_test.go delete mode 100644 vendor/github.com/miekg/dns/parse_test.go delete mode 100644 vendor/github.com/miekg/dns/privaterr.go delete mode 100644 vendor/github.com/miekg/dns/privaterr_test.go delete mode 100644 vendor/github.com/miekg/dns/rawmsg.go delete mode 100644 vendor/github.com/miekg/dns/remote_test.go delete mode 100644 vendor/github.com/miekg/dns/reverse.go delete mode 100644 vendor/github.com/miekg/dns/sanitize.go delete mode 100644 vendor/github.com/miekg/dns/sanitize_test.go delete mode 100644 vendor/github.com/miekg/dns/scan.go delete mode 100644 vendor/github.com/miekg/dns/scan_rr.go delete mode 100644 vendor/github.com/miekg/dns/scanner.go delete mode 100644 vendor/github.com/miekg/dns/server.go delete mode 100644 vendor/github.com/miekg/dns/server_test.go delete mode 100644 vendor/github.com/miekg/dns/sig0.go delete mode 100644 vendor/github.com/miekg/dns/sig0_test.go delete mode 100644 vendor/github.com/miekg/dns/singleinflight.go delete mode 100644 vendor/github.com/miekg/dns/tlsa.go delete mode 100644 vendor/github.com/miekg/dns/tsig.go delete mode 100644 vendor/github.com/miekg/dns/tsig_test.go delete mode 100644 vendor/github.com/miekg/dns/types.go delete mode 100644 vendor/github.com/miekg/dns/types_generate.go delete mode 100644 vendor/github.com/miekg/dns/types_test.go delete mode 100644 vendor/github.com/miekg/dns/udp.go delete mode 100644 vendor/github.com/miekg/dns/udp_linux.go delete mode 100644 vendor/github.com/miekg/dns/udp_other.go delete mode 100644 vendor/github.com/miekg/dns/udp_plan9.go delete mode 100644 vendor/github.com/miekg/dns/udp_windows.go delete mode 100644 vendor/github.com/miekg/dns/update.go delete mode 100644 vendor/github.com/miekg/dns/update_test.go delete mode 100644 vendor/github.com/miekg/dns/xfr.go delete mode 100644 vendor/github.com/miekg/dns/xfr_test.go delete mode 100644 vendor/github.com/miekg/dns/zmsg.go delete mode 100644 vendor/github.com/miekg/dns/ztypes.go delete mode 100644 vendor/github.com/russross/blackfriday/.gitignore delete mode 100644 vendor/github.com/russross/blackfriday/.travis.yml delete mode 100644 vendor/github.com/russross/blackfriday/LICENSE.txt delete mode 100644 vendor/github.com/russross/blackfriday/README.md delete mode 100644 vendor/github.com/russross/blackfriday/block.go delete mode 100644 vendor/github.com/russross/blackfriday/block_test.go delete mode 100644 vendor/github.com/russross/blackfriday/html.go delete mode 100644 vendor/github.com/russross/blackfriday/inline.go delete mode 100644 vendor/github.com/russross/blackfriday/inline_test.go delete mode 100644 vendor/github.com/russross/blackfriday/latex.go delete mode 100644 vendor/github.com/russross/blackfriday/markdown.go delete mode 100644 vendor/github.com/russross/blackfriday/ref_test.go delete mode 100644 vendor/github.com/russross/blackfriday/smartypants.go delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Amps and angle encoding.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Amps and angle encoding.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Auto links.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Auto links.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Backslash escapes.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Backslash escapes.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Blockquotes with code blocks.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Blockquotes with code blocks.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Code Blocks.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Code Blocks.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Code Spans.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Code Spans.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines no empty line before block.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines no empty line before block.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Hard-wrapped paragraphs with list-like lines.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Horizontal rules.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Horizontal rules.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Inline HTML (Advanced).html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Inline HTML (Advanced).text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Inline HTML (Simple).html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Inline HTML (Simple).text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Inline HTML comments.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Inline HTML comments.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Links, inline style.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Links, inline style.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Links, reference style.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Links, reference style.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Links, shortcut references.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Links, shortcut references.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Literal quotes in titles.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Literal quotes in titles.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Markdown Documentation - Basics.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Markdown Documentation - Basics.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Markdown Documentation - Syntax.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Markdown Documentation - Syntax.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Nested blockquotes.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Nested blockquotes.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Ordered and unordered lists.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Ordered and unordered lists.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Strong and em together.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Strong and em together.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Tabs.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Tabs.text delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Tidyness.html delete mode 100644 vendor/github.com/russross/blackfriday/testdata/Tidyness.text delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/.travis.yml delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/LICENSE delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/README.md delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/main.go delete mode 100644 vendor/github.com/shurcooL/sanitized_anchor_name/main_test.go delete mode 100644 vendor/github.com/xenolf/lego/.gitcookies.enc delete mode 100644 vendor/github.com/xenolf/lego/.gitignore delete mode 100644 vendor/github.com/xenolf/lego/.travis.yml delete mode 100644 vendor/github.com/xenolf/lego/CHANGELOG.md delete mode 100644 vendor/github.com/xenolf/lego/CONTRIBUTING.md delete mode 100644 vendor/github.com/xenolf/lego/Dockerfile delete mode 100644 vendor/github.com/xenolf/lego/LICENSE delete mode 100644 vendor/github.com/xenolf/lego/README.md delete mode 100644 vendor/github.com/xenolf/lego/account.go delete mode 100644 vendor/github.com/xenolf/lego/acme/challenges.go delete mode 100644 vendor/github.com/xenolf/lego/acme/client.go delete mode 100644 vendor/github.com/xenolf/lego/acme/client_test.go delete mode 100644 vendor/github.com/xenolf/lego/acme/crypto.go delete mode 100644 vendor/github.com/xenolf/lego/acme/crypto_test.go delete mode 100644 vendor/github.com/xenolf/lego/acme/dns_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/dns_challenge_manual.go delete mode 100644 vendor/github.com/xenolf/lego/acme/dns_challenge_test.go delete mode 100644 vendor/github.com/xenolf/lego/acme/error.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http_challenge_server.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http_challenge_test.go delete mode 100644 vendor/github.com/xenolf/lego/acme/http_test.go delete mode 100644 vendor/github.com/xenolf/lego/acme/jws.go delete mode 100644 vendor/github.com/xenolf/lego/acme/messages.go delete mode 100644 vendor/github.com/xenolf/lego/acme/pop_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/provider.go delete mode 100644 vendor/github.com/xenolf/lego/acme/tls_sni_challenge.go delete mode 100644 vendor/github.com/xenolf/lego/acme/tls_sni_challenge_server.go delete mode 100644 vendor/github.com/xenolf/lego/acme/tls_sni_challenge_test.go delete mode 100644 vendor/github.com/xenolf/lego/acme/utils.go delete mode 100644 vendor/github.com/xenolf/lego/acme/utils_test.go delete mode 100644 vendor/github.com/xenolf/lego/cli.go delete mode 100644 vendor/github.com/xenolf/lego/cli_handlers.go delete mode 100644 vendor/github.com/xenolf/lego/configuration.go delete mode 100644 vendor/github.com/xenolf/lego/crypto.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/cloudflare/cloudflare.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/cloudflare/cloudflare_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/digitalocean/digitalocean.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/digitalocean/digitalocean_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/dnsimple/dnsimple_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/dyn/dyn.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/dyn/dyn_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/gandi/gandi.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/gandi/gandi_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/googlecloud/googlecloud.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/googlecloud/googlecloud_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/namecheap/namecheap.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/namecheap/namecheap_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/rfc2136/rfc2136.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/rfc2136/rfc2136_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/route53/fixtures_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/route53/route53.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/route53/route53_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/route53/testutil_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/vultr/vultr.go delete mode 100644 vendor/github.com/xenolf/lego/providers/dns/vultr/vultr_test.go delete mode 100644 vendor/github.com/xenolf/lego/providers/http/webroot/webroot.go delete mode 100644 vendor/github.com/xenolf/lego/providers/http/webroot/webroot_test.go delete mode 100644 vendor/golang.org/x/crypto/.gitattributes delete mode 100644 vendor/golang.org/x/crypto/.gitignore delete mode 100644 vendor/golang.org/x/crypto/AUTHORS delete mode 100644 vendor/golang.org/x/crypto/CONTRIBUTING.md delete mode 100644 vendor/golang.org/x/crypto/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/crypto/LICENSE delete mode 100644 vendor/golang.org/x/crypto/PATENTS delete mode 100644 vendor/golang.org/x/crypto/README delete mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/acme.go delete mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/acme_test.go delete mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/jws.go delete mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/jws_test.go delete mode 100644 vendor/golang.org/x/crypto/acme/internal/acme/types.go delete mode 100644 vendor/golang.org/x/crypto/bcrypt/base64.go delete mode 100644 vendor/golang.org/x/crypto/bcrypt/bcrypt.go delete mode 100644 vendor/golang.org/x/crypto/bcrypt/bcrypt_test.go delete mode 100644 vendor/golang.org/x/crypto/blowfish/block.go delete mode 100644 vendor/golang.org/x/crypto/blowfish/blowfish_test.go delete mode 100644 vendor/golang.org/x/crypto/blowfish/cipher.go delete mode 100644 vendor/golang.org/x/crypto/blowfish/const.go delete mode 100644 vendor/golang.org/x/crypto/bn256/bn256.go delete mode 100644 vendor/golang.org/x/crypto/bn256/bn256_test.go delete mode 100644 vendor/golang.org/x/crypto/bn256/constants.go delete mode 100644 vendor/golang.org/x/crypto/bn256/curve.go delete mode 100644 vendor/golang.org/x/crypto/bn256/example_test.go delete mode 100644 vendor/golang.org/x/crypto/bn256/gfp12.go delete mode 100644 vendor/golang.org/x/crypto/bn256/gfp2.go delete mode 100644 vendor/golang.org/x/crypto/bn256/gfp6.go delete mode 100644 vendor/golang.org/x/crypto/bn256/optate.go delete mode 100644 vendor/golang.org/x/crypto/bn256/twist.go delete mode 100644 vendor/golang.org/x/crypto/cast5/cast5.go delete mode 100644 vendor/golang.org/x/crypto/cast5/cast5_test.go delete mode 100644 vendor/golang.org/x/crypto/codereview.cfg delete mode 100644 vendor/golang.org/x/crypto/curve25519/const_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/cswap_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/curve25519.go delete mode 100644 vendor/golang.org/x/crypto/curve25519/curve25519_test.go delete mode 100644 vendor/golang.org/x/crypto/curve25519/doc.go delete mode 100644 vendor/golang.org/x/crypto/curve25519/freeze_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/ladderstep_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/mont25519_amd64.go delete mode 100644 vendor/golang.org/x/crypto/curve25519/mul_amd64.s delete mode 100644 vendor/golang.org/x/crypto/curve25519/square_amd64.s delete mode 100644 vendor/golang.org/x/crypto/ed25519/ed25519.go delete mode 100644 vendor/golang.org/x/crypto/ed25519/ed25519_test.go delete mode 100644 vendor/golang.org/x/crypto/ed25519/internal/edwards25519/const.go delete mode 100644 vendor/golang.org/x/crypto/ed25519/internal/edwards25519/edwards25519.go delete mode 100644 vendor/golang.org/x/crypto/ed25519/testdata/sign.input.gz delete mode 100644 vendor/golang.org/x/crypto/hkdf/example_test.go delete mode 100644 vendor/golang.org/x/crypto/hkdf/hkdf.go delete mode 100644 vendor/golang.org/x/crypto/hkdf/hkdf_test.go delete mode 100644 vendor/golang.org/x/crypto/md4/md4.go delete mode 100644 vendor/golang.org/x/crypto/md4/md4_test.go delete mode 100644 vendor/golang.org/x/crypto/md4/md4block.go delete mode 100644 vendor/golang.org/x/crypto/nacl/box/box.go delete mode 100644 vendor/golang.org/x/crypto/nacl/box/box_test.go delete mode 100644 vendor/golang.org/x/crypto/nacl/secretbox/secretbox.go delete mode 100644 vendor/golang.org/x/crypto/nacl/secretbox/secretbox_test.go delete mode 100644 vendor/golang.org/x/crypto/ocsp/ocsp.go delete mode 100644 vendor/golang.org/x/crypto/ocsp/ocsp_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/armor/armor.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/armor/armor_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/armor/encode.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/canonical_text.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/canonical_text_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/clearsign/clearsign.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/clearsign/clearsign_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/elgamal/elgamal.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/elgamal/elgamal_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/errors/errors.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/keys.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/keys_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/compressed.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/compressed_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/config.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/encrypted_key.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/encrypted_key_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/literal.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/ocfb.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/ocfb_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/one_pass_signature.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/opaque.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/opaque_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/packet.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/packet_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/private_key.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/private_key_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/public_key.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/public_key_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/public_key_v3.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/public_key_v3_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/reader.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/signature.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/signature_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/signature_v3.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/signature_v3_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/symmetric_key_encrypted.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/symmetric_key_encrypted_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/symmetrically_encrypted_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/userattribute.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/userattribute_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/userid.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/packet/userid_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/read.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/read_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/s2k/s2k.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/s2k/s2k_test.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/write.go delete mode 100644 vendor/golang.org/x/crypto/openpgp/write_test.go delete mode 100644 vendor/golang.org/x/crypto/otr/libotr_test_helper.c delete mode 100644 vendor/golang.org/x/crypto/otr/otr.go delete mode 100644 vendor/golang.org/x/crypto/otr/otr_test.go delete mode 100644 vendor/golang.org/x/crypto/otr/smp.go delete mode 100644 vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go delete mode 100644 vendor/golang.org/x/crypto/pbkdf2/pbkdf2_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/bmp-string.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/bmp-string_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/crypto.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/crypto_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/errors.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/internal/rc2/bench_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/internal/rc2/rc2.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/internal/rc2/rc2_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/mac.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/mac_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/pbkdf.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/pbkdf_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/pkcs12.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/pkcs12_test.go delete mode 100644 vendor/golang.org/x/crypto/pkcs12/safebags.go delete mode 100644 vendor/golang.org/x/crypto/poly1305/const_amd64.s delete mode 100644 vendor/golang.org/x/crypto/poly1305/poly1305.go delete mode 100644 vendor/golang.org/x/crypto/poly1305/poly1305_amd64.s delete mode 100644 vendor/golang.org/x/crypto/poly1305/poly1305_arm.s delete mode 100644 vendor/golang.org/x/crypto/poly1305/poly1305_test.go delete mode 100644 vendor/golang.org/x/crypto/poly1305/sum_amd64.go delete mode 100644 vendor/golang.org/x/crypto/poly1305/sum_arm.go delete mode 100644 vendor/golang.org/x/crypto/poly1305/sum_ref.go delete mode 100644 vendor/golang.org/x/crypto/ripemd160/ripemd160.go delete mode 100644 vendor/golang.org/x/crypto/ripemd160/ripemd160_test.go delete mode 100644 vendor/golang.org/x/crypto/ripemd160/ripemd160block.go delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa/hsalsa20.go delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa/salsa2020_amd64.s delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa/salsa208.go delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa/salsa20_amd64.go delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa/salsa20_ref.go delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa/salsa_test.go delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa20.go delete mode 100644 vendor/golang.org/x/crypto/salsa20/salsa20_test.go delete mode 100644 vendor/golang.org/x/crypto/scrypt/scrypt.go delete mode 100644 vendor/golang.org/x/crypto/scrypt/scrypt_test.go delete mode 100644 vendor/golang.org/x/crypto/sha3/doc.go delete mode 100644 vendor/golang.org/x/crypto/sha3/hashes.go delete mode 100644 vendor/golang.org/x/crypto/sha3/keccakf.go delete mode 100644 vendor/golang.org/x/crypto/sha3/register.go delete mode 100644 vendor/golang.org/x/crypto/sha3/sha3.go delete mode 100644 vendor/golang.org/x/crypto/sha3/sha3_test.go delete mode 100644 vendor/golang.org/x/crypto/sha3/shake.go delete mode 100644 vendor/golang.org/x/crypto/sha3/testdata/keccakKats.json.deflate delete mode 100644 vendor/golang.org/x/crypto/sha3/xor.go delete mode 100644 vendor/golang.org/x/crypto/sha3/xor_generic.go delete mode 100644 vendor/golang.org/x/crypto/sha3/xor_unaligned.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/client.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/client_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/example_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/forward.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/keyring.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/keyring_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/server.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/server_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/agent/testdata_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/benchmark_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/buffer.go delete mode 100644 vendor/golang.org/x/crypto/ssh/buffer_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/certs.go delete mode 100644 vendor/golang.org/x/crypto/ssh/certs_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/channel.go delete mode 100644 vendor/golang.org/x/crypto/ssh/cipher.go delete mode 100644 vendor/golang.org/x/crypto/ssh/cipher_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/client.go delete mode 100644 vendor/golang.org/x/crypto/ssh/client_auth.go delete mode 100644 vendor/golang.org/x/crypto/ssh/client_auth_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/client_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/common.go delete mode 100644 vendor/golang.org/x/crypto/ssh/connection.go delete mode 100644 vendor/golang.org/x/crypto/ssh/doc.go delete mode 100644 vendor/golang.org/x/crypto/ssh/example_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/handshake.go delete mode 100644 vendor/golang.org/x/crypto/ssh/handshake_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/kex.go delete mode 100644 vendor/golang.org/x/crypto/ssh/kex_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/keys.go delete mode 100644 vendor/golang.org/x/crypto/ssh/keys_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/mac.go delete mode 100644 vendor/golang.org/x/crypto/ssh/mempipe_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/messages.go delete mode 100644 vendor/golang.org/x/crypto/ssh/messages_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/mux.go delete mode 100644 vendor/golang.org/x/crypto/ssh/mux_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/server.go delete mode 100644 vendor/golang.org/x/crypto/ssh/session.go delete mode 100644 vendor/golang.org/x/crypto/ssh/session_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/tcpip.go delete mode 100644 vendor/golang.org/x/crypto/ssh/tcpip_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/terminal.go delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/terminal_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util.go delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_linux.go delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_plan9.go delete mode 100644 vendor/golang.org/x/crypto/ssh/terminal/util_windows.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/agent_unix_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/cert_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/doc.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/forward_unix_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/session_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/tcpip_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/test_unix_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/test/testdata_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/testdata/doc.go delete mode 100644 vendor/golang.org/x/crypto/ssh/testdata/keys.go delete mode 100644 vendor/golang.org/x/crypto/ssh/testdata_test.go delete mode 100644 vendor/golang.org/x/crypto/ssh/transport.go delete mode 100644 vendor/golang.org/x/crypto/ssh/transport_test.go delete mode 100644 vendor/golang.org/x/crypto/tea/cipher.go delete mode 100644 vendor/golang.org/x/crypto/tea/tea_test.go delete mode 100644 vendor/golang.org/x/crypto/twofish/twofish.go delete mode 100644 vendor/golang.org/x/crypto/twofish/twofish_test.go delete mode 100644 vendor/golang.org/x/crypto/xtea/block.go delete mode 100644 vendor/golang.org/x/crypto/xtea/cipher.go delete mode 100644 vendor/golang.org/x/crypto/xtea/xtea_test.go delete mode 100644 vendor/golang.org/x/crypto/xts/xts.go delete mode 100644 vendor/golang.org/x/crypto/xts/xts_test.go delete mode 100644 vendor/golang.org/x/net/.gitattributes delete mode 100644 vendor/golang.org/x/net/.gitignore delete mode 100644 vendor/golang.org/x/net/AUTHORS delete mode 100644 vendor/golang.org/x/net/CONTRIBUTING.md delete mode 100644 vendor/golang.org/x/net/CONTRIBUTORS delete mode 100644 vendor/golang.org/x/net/LICENSE delete mode 100644 vendor/golang.org/x/net/PATENTS delete mode 100644 vendor/golang.org/x/net/README delete mode 100644 vendor/golang.org/x/net/bpf/asm.go delete mode 100644 vendor/golang.org/x/net/bpf/constants.go delete mode 100644 vendor/golang.org/x/net/bpf/doc.go delete mode 100644 vendor/golang.org/x/net/bpf/instructions.go delete mode 100644 vendor/golang.org/x/net/bpf/instructions_test.go delete mode 100644 vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf delete mode 100644 vendor/golang.org/x/net/bpf/testdata/all_instructions.txt delete mode 100644 vendor/golang.org/x/net/codereview.cfg delete mode 100644 vendor/golang.org/x/net/context/context.go delete mode 100644 vendor/golang.org/x/net/context/context_test.go delete mode 100644 vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go delete mode 100644 vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.go delete mode 100644 vendor/golang.org/x/net/context/go17.go delete mode 100644 vendor/golang.org/x/net/context/pre_go17.go delete mode 100644 vendor/golang.org/x/net/context/withtimeout_test.go delete mode 100644 vendor/golang.org/x/net/dict/dict.go delete mode 100644 vendor/golang.org/x/net/html/atom/atom.go delete mode 100644 vendor/golang.org/x/net/html/atom/atom_test.go delete mode 100644 vendor/golang.org/x/net/html/atom/gen.go delete mode 100644 vendor/golang.org/x/net/html/atom/table.go delete mode 100644 vendor/golang.org/x/net/html/atom/table_test.go delete mode 100644 vendor/golang.org/x/net/html/charset/charset.go delete mode 100644 vendor/golang.org/x/net/html/charset/charset_test.go delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/HTTP-charset.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/README delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/UTF-16LE-BOM.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html delete mode 100644 vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html delete mode 100644 vendor/golang.org/x/net/html/const.go delete mode 100644 vendor/golang.org/x/net/html/doc.go delete mode 100644 vendor/golang.org/x/net/html/doctype.go delete mode 100644 vendor/golang.org/x/net/html/entity.go delete mode 100644 vendor/golang.org/x/net/html/entity_test.go delete mode 100644 vendor/golang.org/x/net/html/escape.go delete mode 100644 vendor/golang.org/x/net/html/escape_test.go delete mode 100644 vendor/golang.org/x/net/html/example_test.go delete mode 100644 vendor/golang.org/x/net/html/foreign.go delete mode 100644 vendor/golang.org/x/net/html/node.go delete mode 100644 vendor/golang.org/x/net/html/node_test.go delete mode 100644 vendor/golang.org/x/net/html/parse.go delete mode 100644 vendor/golang.org/x/net/html/parse_test.go delete mode 100644 vendor/golang.org/x/net/html/render.go delete mode 100644 vendor/golang.org/x/net/html/render_test.go delete mode 100644 vendor/golang.org/x/net/html/testdata/go1.html delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/README delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/adoption01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/adoption02.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/comments01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/doctype01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/entities01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/entities02.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/html5test-com.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/inbody01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/isindex.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/plain-text-unsafe.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/scriptdata01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/scripted/adoption01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/scripted/webkit01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tables01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests1.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests10.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests11.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests12.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests14.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests15.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests16.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests17.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests18.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests19.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests2.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests20.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests21.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests22.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests23.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests24.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests25.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests26.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests3.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests4.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests5.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests6.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests7.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests8.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests9.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tests_innerHTML_1.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/tricky01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/webkit01.dat delete mode 100644 vendor/golang.org/x/net/html/testdata/webkit/webkit02.dat delete mode 100644 vendor/golang.org/x/net/html/token.go delete mode 100644 vendor/golang.org/x/net/html/token_test.go delete mode 100644 vendor/golang.org/x/net/http2/.gitignore delete mode 100644 vendor/golang.org/x/net/http2/Dockerfile delete mode 100644 vendor/golang.org/x/net/http2/Makefile delete mode 100644 vendor/golang.org/x/net/http2/README delete mode 100644 vendor/golang.org/x/net/http2/client_conn_pool.go delete mode 100644 vendor/golang.org/x/net/http2/configure_transport.go delete mode 100644 vendor/golang.org/x/net/http2/errors.go delete mode 100644 vendor/golang.org/x/net/http2/errors_test.go delete mode 100644 vendor/golang.org/x/net/http2/fixed_buffer.go delete mode 100644 vendor/golang.org/x/net/http2/fixed_buffer_test.go delete mode 100644 vendor/golang.org/x/net/http2/flow.go delete mode 100644 vendor/golang.org/x/net/http2/flow_test.go delete mode 100644 vendor/golang.org/x/net/http2/frame.go delete mode 100644 vendor/golang.org/x/net/http2/frame_test.go delete mode 100644 vendor/golang.org/x/net/http2/go16.go delete mode 100644 vendor/golang.org/x/net/http2/go17.go delete mode 100644 vendor/golang.org/x/net/http2/gotrack.go delete mode 100644 vendor/golang.org/x/net/http2/gotrack_test.go delete mode 100644 vendor/golang.org/x/net/http2/h2demo/.gitignore delete mode 100644 vendor/golang.org/x/net/http2/h2demo/Makefile delete mode 100644 vendor/golang.org/x/net/http2/h2demo/README delete mode 100644 vendor/golang.org/x/net/http2/h2demo/h2demo.go delete mode 100644 vendor/golang.org/x/net/http2/h2demo/launch.go delete mode 100644 vendor/golang.org/x/net/http2/h2demo/rootCA.key delete mode 100644 vendor/golang.org/x/net/http2/h2demo/rootCA.pem delete mode 100644 vendor/golang.org/x/net/http2/h2demo/rootCA.srl delete mode 100644 vendor/golang.org/x/net/http2/h2demo/server.crt delete mode 100644 vendor/golang.org/x/net/http2/h2demo/server.key delete mode 100644 vendor/golang.org/x/net/http2/h2i/README.md delete mode 100644 vendor/golang.org/x/net/http2/h2i/h2i.go delete mode 100644 vendor/golang.org/x/net/http2/headermap.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/encode.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/encode_test.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/hpack.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/hpack_test.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/huffman.go delete mode 100644 vendor/golang.org/x/net/http2/hpack/tables.go delete mode 100644 vendor/golang.org/x/net/http2/http2.go delete mode 100644 vendor/golang.org/x/net/http2/http2_test.go delete mode 100644 vendor/golang.org/x/net/http2/not_go16.go delete mode 100644 vendor/golang.org/x/net/http2/not_go17.go delete mode 100644 vendor/golang.org/x/net/http2/pipe.go delete mode 100644 vendor/golang.org/x/net/http2/pipe_test.go delete mode 100644 vendor/golang.org/x/net/http2/priority_test.go delete mode 100644 vendor/golang.org/x/net/http2/server.go delete mode 100644 vendor/golang.org/x/net/http2/server_test.go delete mode 100644 vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml delete mode 100644 vendor/golang.org/x/net/http2/transport.go delete mode 100644 vendor/golang.org/x/net/http2/transport_test.go delete mode 100644 vendor/golang.org/x/net/http2/write.go delete mode 100644 vendor/golang.org/x/net/http2/writesched.go delete mode 100644 vendor/golang.org/x/net/http2/z_spec_test.go delete mode 100644 vendor/golang.org/x/net/icmp/dstunreach.go delete mode 100644 vendor/golang.org/x/net/icmp/echo.go delete mode 100644 vendor/golang.org/x/net/icmp/endpoint.go delete mode 100644 vendor/golang.org/x/net/icmp/example_test.go delete mode 100644 vendor/golang.org/x/net/icmp/extension.go delete mode 100644 vendor/golang.org/x/net/icmp/extension_test.go delete mode 100644 vendor/golang.org/x/net/icmp/helper.go delete mode 100644 vendor/golang.org/x/net/icmp/helper_posix.go delete mode 100644 vendor/golang.org/x/net/icmp/interface.go delete mode 100644 vendor/golang.org/x/net/icmp/ipv4.go delete mode 100644 vendor/golang.org/x/net/icmp/ipv4_test.go delete mode 100644 vendor/golang.org/x/net/icmp/ipv6.go delete mode 100644 vendor/golang.org/x/net/icmp/listen_posix.go delete mode 100644 vendor/golang.org/x/net/icmp/listen_stub.go delete mode 100644 vendor/golang.org/x/net/icmp/message.go delete mode 100644 vendor/golang.org/x/net/icmp/message_test.go delete mode 100644 vendor/golang.org/x/net/icmp/messagebody.go delete mode 100644 vendor/golang.org/x/net/icmp/mpls.go delete mode 100644 vendor/golang.org/x/net/icmp/multipart.go delete mode 100644 vendor/golang.org/x/net/icmp/multipart_test.go delete mode 100644 vendor/golang.org/x/net/icmp/packettoobig.go delete mode 100644 vendor/golang.org/x/net/icmp/paramprob.go delete mode 100644 vendor/golang.org/x/net/icmp/ping_test.go delete mode 100644 vendor/golang.org/x/net/icmp/sys_freebsd.go delete mode 100644 vendor/golang.org/x/net/icmp/timeexceeded.go delete mode 100644 vendor/golang.org/x/net/idna/idna.go delete mode 100644 vendor/golang.org/x/net/idna/idna_test.go delete mode 100644 vendor/golang.org/x/net/idna/punycode.go delete mode 100644 vendor/golang.org/x/net/idna/punycode_test.go delete mode 100644 vendor/golang.org/x/net/internal/iana/const.go delete mode 100644 vendor/golang.org/x/net/internal/iana/gen.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/error_posix.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/error_stub.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/interface.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/rlimit.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/rlimit_stub.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/rlimit_unix.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/rlimit_windows.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/stack.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/stack_stub.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/stack_unix.go delete mode 100644 vendor/golang.org/x/net/internal/nettest/stack_windows.go delete mode 100644 vendor/golang.org/x/net/internal/timeseries/timeseries.go delete mode 100644 vendor/golang.org/x/net/internal/timeseries/timeseries_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/bpf_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/bpfopt_linux.go delete mode 100644 vendor/golang.org/x/net/ipv4/bpfopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/control.go delete mode 100644 vendor/golang.org/x/net/ipv4/control_bsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/control_pktinfo.go delete mode 100644 vendor/golang.org/x/net/ipv4/control_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/control_unix.go delete mode 100644 vendor/golang.org/x/net/ipv4/control_windows.go delete mode 100644 vendor/golang.org/x/net/ipv4/defs_darwin.go delete mode 100644 vendor/golang.org/x/net/ipv4/defs_dragonfly.go delete mode 100644 vendor/golang.org/x/net/ipv4/defs_freebsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/defs_linux.go delete mode 100644 vendor/golang.org/x/net/ipv4/defs_netbsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/defs_openbsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/defs_solaris.go delete mode 100644 vendor/golang.org/x/net/ipv4/dgramopt_posix.go delete mode 100644 vendor/golang.org/x/net/ipv4/dgramopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/doc.go delete mode 100644 vendor/golang.org/x/net/ipv4/endpoint.go delete mode 100644 vendor/golang.org/x/net/ipv4/example_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/gen.go delete mode 100644 vendor/golang.org/x/net/ipv4/genericopt_posix.go delete mode 100644 vendor/golang.org/x/net/ipv4/genericopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/header.go delete mode 100644 vendor/golang.org/x/net/ipv4/header_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/helper.go delete mode 100644 vendor/golang.org/x/net/ipv4/helper_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/helper_unix.go delete mode 100644 vendor/golang.org/x/net/ipv4/helper_windows.go delete mode 100644 vendor/golang.org/x/net/ipv4/iana.go delete mode 100644 vendor/golang.org/x/net/ipv4/icmp.go delete mode 100644 vendor/golang.org/x/net/ipv4/icmp_linux.go delete mode 100644 vendor/golang.org/x/net/ipv4/icmp_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/icmp_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/mocktransponder_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/multicast_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/multicastlistener_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/multicastsockopt_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/packet.go delete mode 100644 vendor/golang.org/x/net/ipv4/payload.go delete mode 100644 vendor/golang.org/x/net/ipv4/payload_cmsg.go delete mode 100644 vendor/golang.org/x/net/ipv4/payload_nocmsg.go delete mode 100644 vendor/golang.org/x/net/ipv4/readwrite_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_asmreq.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_asmreq_unix.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_asmreq_windows.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_unix.go delete mode 100644 vendor/golang.org/x/net/ipv4/sockopt_windows.go delete mode 100644 vendor/golang.org/x/net/ipv4/sys_bsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/sys_darwin.go delete mode 100644 vendor/golang.org/x/net/ipv4/sys_freebsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/sys_linux.go delete mode 100644 vendor/golang.org/x/net/ipv4/sys_openbsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/sys_stub.go delete mode 100644 vendor/golang.org/x/net/ipv4/sys_windows.go delete mode 100644 vendor/golang.org/x/net/ipv4/syscall_linux_386.go delete mode 100644 vendor/golang.org/x/net/ipv4/syscall_unix.go delete mode 100644 vendor/golang.org/x/net/ipv4/thunk_linux_386.s delete mode 100644 vendor/golang.org/x/net/ipv4/unicast_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/unicastsockopt_test.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_darwin.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_dragonfly.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_386.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_arm.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_netbsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_openbsd.go delete mode 100644 vendor/golang.org/x/net/ipv4/zsys_solaris.go delete mode 100644 vendor/golang.org/x/net/ipv6/bpf_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/bpfopt_linux.go delete mode 100644 vendor/golang.org/x/net/ipv6/bpfopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/control.go delete mode 100644 vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/control_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/control_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/control_windows.go delete mode 100644 vendor/golang.org/x/net/ipv6/defs_darwin.go delete mode 100644 vendor/golang.org/x/net/ipv6/defs_dragonfly.go delete mode 100644 vendor/golang.org/x/net/ipv6/defs_freebsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/defs_linux.go delete mode 100644 vendor/golang.org/x/net/ipv6/defs_netbsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/defs_openbsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/defs_solaris.go delete mode 100644 vendor/golang.org/x/net/ipv6/dgramopt_posix.go delete mode 100644 vendor/golang.org/x/net/ipv6/dgramopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/doc.go delete mode 100644 vendor/golang.org/x/net/ipv6/endpoint.go delete mode 100644 vendor/golang.org/x/net/ipv6/example_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/gen.go delete mode 100644 vendor/golang.org/x/net/ipv6/genericopt_posix.go delete mode 100644 vendor/golang.org/x/net/ipv6/genericopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/header.go delete mode 100644 vendor/golang.org/x/net/ipv6/header_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/helper.go delete mode 100644 vendor/golang.org/x/net/ipv6/helper_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/helper_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/helper_windows.go delete mode 100644 vendor/golang.org/x/net/ipv6/iana.go delete mode 100644 vendor/golang.org/x/net/ipv6/icmp.go delete mode 100644 vendor/golang.org/x/net/ipv6/icmp_bsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/icmp_linux.go delete mode 100644 vendor/golang.org/x/net/ipv6/icmp_solaris.go delete mode 100644 vendor/golang.org/x/net/ipv6/icmp_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/icmp_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/icmp_windows.go delete mode 100644 vendor/golang.org/x/net/ipv6/mocktransponder_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/multicast_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/multicastlistener_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/multicastsockopt_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/payload.go delete mode 100644 vendor/golang.org/x/net/ipv6/payload_cmsg.go delete mode 100644 vendor/golang.org/x/net/ipv6/payload_nocmsg.go delete mode 100644 vendor/golang.org/x/net/ipv6/readwrite_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_asmreq_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_asmreq_windows.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/sockopt_windows.go delete mode 100644 vendor/golang.org/x/net/ipv6/sys_bsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/sys_darwin.go delete mode 100644 vendor/golang.org/x/net/ipv6/sys_freebsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/sys_linux.go delete mode 100644 vendor/golang.org/x/net/ipv6/sys_stub.go delete mode 100644 vendor/golang.org/x/net/ipv6/sys_windows.go delete mode 100644 vendor/golang.org/x/net/ipv6/syscall_linux_386.go delete mode 100644 vendor/golang.org/x/net/ipv6/syscall_unix.go delete mode 100644 vendor/golang.org/x/net/ipv6/thunk_linux_386.s delete mode 100644 vendor/golang.org/x/net/ipv6/unicast_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/unicastsockopt_test.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_darwin.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_dragonfly.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_386.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_arm.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_netbsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_openbsd.go delete mode 100644 vendor/golang.org/x/net/ipv6/zsys_solaris.go delete mode 100644 vendor/golang.org/x/net/lex/httplex/httplex.go delete mode 100644 vendor/golang.org/x/net/lex/httplex/httplex_test.go delete mode 100644 vendor/golang.org/x/net/netutil/listen.go delete mode 100644 vendor/golang.org/x/net/netutil/listen_test.go delete mode 100644 vendor/golang.org/x/net/proxy/direct.go delete mode 100644 vendor/golang.org/x/net/proxy/per_host.go delete mode 100644 vendor/golang.org/x/net/proxy/per_host_test.go delete mode 100644 vendor/golang.org/x/net/proxy/proxy.go delete mode 100644 vendor/golang.org/x/net/proxy/proxy_test.go delete mode 100644 vendor/golang.org/x/net/proxy/socks5.go delete mode 100644 vendor/golang.org/x/net/publicsuffix/gen.go delete mode 100644 vendor/golang.org/x/net/publicsuffix/list.go delete mode 100644 vendor/golang.org/x/net/publicsuffix/list_test.go delete mode 100644 vendor/golang.org/x/net/publicsuffix/table.go delete mode 100644 vendor/golang.org/x/net/publicsuffix/table_test.go delete mode 100644 vendor/golang.org/x/net/route/address.go delete mode 100644 vendor/golang.org/x/net/route/address_darwin_test.go delete mode 100644 vendor/golang.org/x/net/route/address_test.go delete mode 100644 vendor/golang.org/x/net/route/binary.go delete mode 100644 vendor/golang.org/x/net/route/defs_darwin.go delete mode 100644 vendor/golang.org/x/net/route/defs_dragonfly.go delete mode 100644 vendor/golang.org/x/net/route/defs_freebsd.go delete mode 100644 vendor/golang.org/x/net/route/defs_netbsd.go delete mode 100644 vendor/golang.org/x/net/route/defs_openbsd.go delete mode 100644 vendor/golang.org/x/net/route/interface.go delete mode 100644 vendor/golang.org/x/net/route/interface_announce.go delete mode 100644 vendor/golang.org/x/net/route/interface_classic.go delete mode 100644 vendor/golang.org/x/net/route/interface_freebsd.go delete mode 100644 vendor/golang.org/x/net/route/interface_multicast.go delete mode 100644 vendor/golang.org/x/net/route/interface_openbsd.go delete mode 100644 vendor/golang.org/x/net/route/message.go delete mode 100644 vendor/golang.org/x/net/route/message_darwin_test.go delete mode 100644 vendor/golang.org/x/net/route/message_freebsd_test.go delete mode 100644 vendor/golang.org/x/net/route/message_test.go delete mode 100644 vendor/golang.org/x/net/route/route.go delete mode 100644 vendor/golang.org/x/net/route/route_classic.go delete mode 100644 vendor/golang.org/x/net/route/route_openbsd.go delete mode 100644 vendor/golang.org/x/net/route/route_test.go delete mode 100644 vendor/golang.org/x/net/route/sys.go delete mode 100644 vendor/golang.org/x/net/route/sys_darwin.go delete mode 100644 vendor/golang.org/x/net/route/sys_dragonfly.go delete mode 100644 vendor/golang.org/x/net/route/sys_freebsd.go delete mode 100644 vendor/golang.org/x/net/route/sys_netbsd.go delete mode 100644 vendor/golang.org/x/net/route/sys_openbsd.go delete mode 100644 vendor/golang.org/x/net/route/syscall.go delete mode 100644 vendor/golang.org/x/net/route/syscall.s delete mode 100644 vendor/golang.org/x/net/route/zsys_darwin.go delete mode 100644 vendor/golang.org/x/net/route/zsys_dragonfly.go delete mode 100644 vendor/golang.org/x/net/route/zsys_freebsd_386.go delete mode 100644 vendor/golang.org/x/net/route/zsys_freebsd_amd64.go delete mode 100644 vendor/golang.org/x/net/route/zsys_freebsd_arm.go delete mode 100644 vendor/golang.org/x/net/route/zsys_netbsd.go delete mode 100644 vendor/golang.org/x/net/route/zsys_openbsd.go delete mode 100644 vendor/golang.org/x/net/trace/events.go delete mode 100644 vendor/golang.org/x/net/trace/histogram.go delete mode 100644 vendor/golang.org/x/net/trace/histogram_test.go delete mode 100644 vendor/golang.org/x/net/trace/trace.go delete mode 100644 vendor/golang.org/x/net/trace/trace_test.go delete mode 100644 vendor/golang.org/x/net/webdav/file.go delete mode 100644 vendor/golang.org/x/net/webdav/file_test.go delete mode 100644 vendor/golang.org/x/net/webdav/if.go delete mode 100644 vendor/golang.org/x/net/webdav/if_test.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/README delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/atom_test.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/example_test.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/marshal.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/read.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/read_test.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/xml.go delete mode 100644 vendor/golang.org/x/net/webdav/internal/xml/xml_test.go delete mode 100644 vendor/golang.org/x/net/webdav/litmus_test_server.go delete mode 100644 vendor/golang.org/x/net/webdav/lock.go delete mode 100644 vendor/golang.org/x/net/webdav/lock_test.go delete mode 100644 vendor/golang.org/x/net/webdav/prop.go delete mode 100644 vendor/golang.org/x/net/webdav/prop_test.go delete mode 100644 vendor/golang.org/x/net/webdav/webdav.go delete mode 100644 vendor/golang.org/x/net/webdav/webdav_test.go delete mode 100644 vendor/golang.org/x/net/webdav/xml.go delete mode 100644 vendor/golang.org/x/net/webdav/xml_test.go delete mode 100644 vendor/golang.org/x/net/websocket/client.go delete mode 100644 vendor/golang.org/x/net/websocket/exampledial_test.go delete mode 100644 vendor/golang.org/x/net/websocket/examplehandler_test.go delete mode 100644 vendor/golang.org/x/net/websocket/hybi.go delete mode 100644 vendor/golang.org/x/net/websocket/hybi_test.go delete mode 100644 vendor/golang.org/x/net/websocket/server.go delete mode 100644 vendor/golang.org/x/net/websocket/websocket.go delete mode 100644 vendor/golang.org/x/net/websocket/websocket_test.go delete mode 100644 vendor/golang.org/x/net/xsrftoken/xsrf.go delete mode 100644 vendor/golang.org/x/net/xsrftoken/xsrf_test.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/.gitignore delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/LICENSE delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/README.md delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/chown.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/example_test.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/linux_test.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack_test.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/rotate_test.go delete mode 100644 vendor/gopkg.in/natefinch/lumberjack.v2/testing_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/.gitcookies.sh.enc delete mode 100644 vendor/gopkg.in/square/go-jose.v1/.gitignore delete mode 100644 vendor/gopkg.in/square/go-jose.v1/.travis.yml delete mode 100644 vendor/gopkg.in/square/go-jose.v1/BUG-BOUNTY.md delete mode 100644 vendor/gopkg.in/square/go-jose.v1/CONTRIBUTING.md delete mode 100644 vendor/gopkg.in/square/go-jose.v1/LICENSE delete mode 100644 vendor/gopkg.in/square/go-jose.v1/README.md delete mode 100644 vendor/gopkg.in/square/go-jose.v1/asymmetric.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/asymmetric_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/crypter.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/crypter_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/doc.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/doc_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/encoding.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/encoding_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jose-util/README.md delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jose-util/jose-util.t delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jose-util/main.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/LICENSE delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/README.md delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/bench_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/decode.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/decode_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/encode.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/encode_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/indent.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/number_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/scanner.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/scanner_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/stream.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/stream_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/tagkey_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/tags.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/tags_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json/testdata/code.json.gz delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json_fork.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json_fork_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json_std.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/json_std_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jwe.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jwe_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jwk.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jwk_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jws.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/jws_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/shared.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/signing.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/signing_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/symmetric.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/symmetric_test.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/utils.go delete mode 100644 vendor/gopkg.in/square/go-jose.v1/utils_test.go delete mode 100644 vendor/gopkg.in/yaml.v2/.travis.yml delete mode 100644 vendor/gopkg.in/yaml.v2/LICENSE delete mode 100644 vendor/gopkg.in/yaml.v2/LICENSE.libyaml delete mode 100644 vendor/gopkg.in/yaml.v2/README.md delete mode 100644 vendor/gopkg.in/yaml.v2/apic.go delete mode 100644 vendor/gopkg.in/yaml.v2/decode.go delete mode 100644 vendor/gopkg.in/yaml.v2/decode_test.go delete mode 100644 vendor/gopkg.in/yaml.v2/emitterc.go delete mode 100644 vendor/gopkg.in/yaml.v2/encode.go delete mode 100644 vendor/gopkg.in/yaml.v2/encode_test.go delete mode 100644 vendor/gopkg.in/yaml.v2/parserc.go delete mode 100644 vendor/gopkg.in/yaml.v2/readerc.go delete mode 100644 vendor/gopkg.in/yaml.v2/resolve.go delete mode 100644 vendor/gopkg.in/yaml.v2/scannerc.go delete mode 100644 vendor/gopkg.in/yaml.v2/sorter.go delete mode 100644 vendor/gopkg.in/yaml.v2/suite_test.go delete mode 100644 vendor/gopkg.in/yaml.v2/writerc.go delete mode 100644 vendor/gopkg.in/yaml.v2/yaml.go delete mode 100644 vendor/gopkg.in/yaml.v2/yamlh.go delete mode 100644 vendor/gopkg.in/yaml.v2/yamlprivateh.go diff --git a/README.md b/README.md index d53a100..013addd 100644 --- a/README.md +++ b/README.md @@ -1,26 +1 @@ -Squirrel is a secure and easy to use webserver for [munki](https://github.com/munki/munki). -Squirrel is built on top of the [caddy](https://caddyserver.com/) webserver and adds munki specific features through plugins. - -Below is a list of features. Some are immediately usable, while others are in various stages of completion. - -# Features - -### Completed - -* [X] **Automatic HTTPS** - squirrel provides a built in Let's Encrypt Client(through caddy). You can also provide your own certs. -* [X] **Built in [SCEP](https://tools.ietf.org/html/draft-nourse-scep-23) server** - The `scepclient` can request client certificates in a munki preflight script. -* [X] **HTTP/2** - Automatically supported by the server and NSURLSession on OS X. -* [X] **git/git-fat/lfs sync** - syncing a repo on a time interval. provided by the caddy [addon](https://caddyserver.com/docs/git) - -### In Progress -* [ ] **API** - A REST API for managing a munki repo remotely. Mostly complete. Porting over from `https://github.com/groob/ape` -* [ ] **apiimport** - A custom `munkiimport` tool which allows importing packages using the API instead of mounting the repo. -* [ ] **Web UI** - A web interface for managing the munki repo. -* [ ] **dynamic catalogs** - currently possible to run `makecatalogs` after a git pull, but the server will also support this feature natively. -* [ ] **autopromotion/sharding** - part of having dynamic catalogs. The server will allow configuration of promotion between catalogs and [sharding](http://grahamgilbert.com/blog/2015/11/23/releasing-changes-with-sharding/) support. -* [ ] **monitoring** - structured logging and prometheus metrics. - -### Future -* [ ] DEP/MDM integration - as [micromdm](https://github.com/micromdm/micromdm) is developed, integrations will be added where they make sense. For example - ability to create manifests or validate SCEP requests based on DEP membership. -* [ ] rsync - another way to sync a repo at an interval for those who don't use git. -* [ ] [The Update Framework](https://theupdateframework.github.io/) - investigating TUF/[notary](https://github.com/docker/notary) as a way to validate catalogs and manifests. +Squirrel is a simple HTTP server for munki diff --git a/cmd/squirrel/main.go b/cmd/squirrel/main.go deleted file mode 100644 index 1787bdc..0000000 --- a/cmd/squirrel/main.go +++ /dev/null @@ -1,165 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "log" - "net/http" - "os" - "path/filepath" - - "golang.org/x/net/context" - - kitlog "github.com/go-kit/kit/log" - - "github.com/micromdm/squirrel/munki/datastore" - "github.com/micromdm/squirrel/munki/server" -) - -const usage = "usage: MUNKI_REPO_PATH= SQUIRREL_HTTP_LISTEN_PORT= ape -repo MUNKI_REPO_PATH -port SQUIRREL_HTTP_LISTEN_PORT" - -func main() { - var ( - flRepo = flag.String("repo", envString("SQUIRREL_MUNKI_REPO_PATH", ""), "path to munki repo") - flPort = flag.String("port", envString("SQUIRREL_HTTP_LISTEN_PORT", ""), "port to listen on") - flBasic = flag.Bool("basic", envBool("SQUIRREL_BASIC_AUTH"), "enable basic auth") - flJWT = flag.Bool("jwt", envBool("SQUIRREL_JWT_AUTH"), "enable jwt authentication for api calls") - flJWTSecret = flag.String("jwt-signing-key", envString("SQUIRREL_JWT_SIGNING_KEY", ""), "jwt signing key") - flTLS = flag.Bool("tls", envBool("SQUIRREL_USE_TLS"), "use https") - flTLSCert = flag.String("tls-cert", envString("SQUIRREL_TLS_CERT", ""), "path to TLS certificate") - flTLSKey = flag.String("tls-key", envString("SQUIRREL_TLS_KEY", ""), "path to TLS private key") - ) - *flTLS = true - flag.Parse() - if *flRepo == "" { - flag.Usage() - log.Fatal(usage) - } - - // create the folders if they don't yet exist - checkRepo(*flRepo) - - // validate port flag - if *flPort == "" { - port := defaultPort(*flTLS) - log.Printf("no port flag specified. Using %v by default", port) - *flPort = port - } - - if *flTLS { - checkTLSFlags(*flTLSKey, *flTLSCert) - } - - // validate JWT flags - if *flJWT { - checkJWTFlags(*flJWTSecret) - } - // validate basic auth - if *flBasic && !*flJWT { - log.Fatal("Basic Authentication is used to issue JWT Tokens. You must enable JWT as well") - } - - var repo datastore.Datastore - { - repo = &datastore.SimpleRepo{Path: *flRepo} - - } - - var err error - var svc munkiserver.Service - { - svc, err = munkiserver.NewService(repo) - if err != nil { - log.Fatal(err) - } - } - - var logger kitlog.Logger - { - logger = kitlog.NewLogfmtLogger(os.Stderr) - logger = kitlog.NewContext(logger).With("ts", kitlog.DefaultTimestampUTC) - logger = kitlog.NewContext(logger).With("caller", kitlog.DefaultCaller) - } - - ctx := context.Background() - var h http.Handler - { - h = munkiserver.ServiceHandler(ctx, svc, logger) - } - - mux := http.NewServeMux() - mux.Handle("/api/v1/", h) - mux.Handle("/repo/", http.StripPrefix("/repo/", http.FileServer(http.Dir(*flRepo)))) - - port := fmt.Sprintf(":%v", *flPort) - - if *flTLS { - log.Fatal(http.ListenAndServeTLS(port, *flTLSCert, *flTLSKey, mux)) - } else { - log.Fatal(http.ListenAndServe(port, mux)) - } -} - -func defaultPort(tls bool) string { - if tls { - return "443" - } - return "80" -} - -func checkJWTFlags(secret string) { - if secret == "" { - log.Fatal("You must provide a signing key to enable JWT authentication") - } -} - -func checkTLSFlags(keypath, certpath string) { - if keypath == "" || certpath == "" { - log.Fatal("You must provide a valid path to a TLS cert and key") - } -} - -func envString(key, def string) string { - if env := os.Getenv(key); env != "" { - return env - } - return def -} - -func envBool(key string) bool { - if env := os.Getenv(key); env == "true" { - return true - } - return false -} - -func createDir(path string) { - if !dirExists(path) { - dir := filepath.Dir(path) - if err := os.MkdirAll(dir, 0755); err != nil { - log.Fatalf("%v must exits", path) - } - } -} - -func dirExists(path string) bool { - _, err := os.Stat(path) - if os.IsNotExist(err) { - return false - } - return true -} - -func checkRepo(repoPath string) { - pkgsinfoPath := fmt.Sprintf("%v/pkgsinfo/", repoPath) - createDir(pkgsinfoPath) - - manifestPath := fmt.Sprintf("%v/manifests/", repoPath) - createDir(manifestPath) - - pkgsPath := fmt.Sprintf("%v/pkgs/", repoPath) - createDir(pkgsPath) - - catalogsPath := fmt.Sprintf("%v/catalogs/", repoPath) - createDir(catalogsPath) -} diff --git a/glide.lock b/glide.lock deleted file mode 100644 index 6b0e7cb..0000000 --- a/glide.lock +++ /dev/null @@ -1,137 +0,0 @@ -hash: 912c3e755581cb8bbabe09be289dd32f31d3cd40042d5cca0f88ee79de9aad13 -updated: 2016-06-16T10:45:40.430407388-04:00 -imports: -- name: git.schwanenlied.me/yawning/chacha20.git - version: c91e78db502ff629614837aacb7aa4efa61c651a -- name: git.schwanenlied.me/yawning/poly1305.git - version: dfc796fe731c2cfd3aa1e96115ab0aaa3cbb7849 -- name: github.com/abiosoft/caddy-git - version: bf8112054dfc2a0303412c102a17ba05732b345b - subpackages: - - gitos -- name: github.com/BurntSushi/toml - version: f0aeabca5a127c4078abb8c8d64298b147264b55 -- name: github.com/dgrijalva/jwt-go - version: c04502f106d7c5b3fae17c5da49a1bbdd3006b3c -- name: github.com/dustin/go-humanize - version: 499693e27ee0d14ffab67c31ad065fdb3d34ea75 -- name: github.com/flynn/go-shlex - version: 3f9db97f856818214da2e1057f8ad84803971cff -- name: github.com/go-kit/kit - version: 1078c87a1351dee509efd1ea7e7cb9f42840ac51 - subpackages: - - log - - endpoint - - transport/http -- name: github.com/go-logfmt/logfmt - version: d4327190ff838312623b09bfeb50d7c93c8d9c1d -- name: github.com/go-stack/stack - version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82 -- name: github.com/gorilla/websocket - version: a68708917c6a4f06314ab4e52493cc61359c9d42 -- name: github.com/groob/plist - version: e9ca5cd129407b401d850bc3248338865a7490ae -- name: github.com/hashicorp/go-syslog - version: 42a2b573b664dbf281bd48c3cc12c086b17a39ba -- name: github.com/jimstudt/http-authentication - version: 3eca13d6893afd7ecabe15f4445f5d2872a1b012 - subpackages: - - basic -- name: github.com/julienschmidt/httprouter - version: 77366a47451a56bb3ba682481eed85b64fea14e8 -- name: github.com/kr/logfmt - version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0 -- name: github.com/lucas-clemente/chacha20poly1305 - version: ecc9f245638b6ac6fec56f508a61afc99f353007 -- name: github.com/lucas-clemente/fnv128a - version: 393af48d391698c6ae4219566bfbdfef67269997 -- name: github.com/lucas-clemente/quic-go - version: c76d438808b909d6794a229f980021b5254356dc - subpackages: - - h2quic - - protocol - - utils - - ackhandler - - crypto - - flowcontrol - - frames - - handshake - - qerr - - congestion -- name: github.com/lucas-clemente/quic-go-certificates - version: 9bb36d3159787cca26dcfa15e23049615e307ef8 -- name: github.com/mholt/caddy - version: 6fe5c1a69fc3801dd2a20864777f66cc118ca19a - subpackages: - - caddyhttp - - caddytls - - caddyhttp/httpserver - - caddyfile - - caddyhttp/basicauth - - caddyhttp/bind - - caddyhttp/browse - - caddyhttp/errors - - caddyhttp/expvar - - caddyhttp/extensions - - caddyhttp/fastcgi - - caddyhttp/gzip - - caddyhttp/header - - caddyhttp/internalsrv - - caddyhttp/log - - caddyhttp/markdown - - caddyhttp/mime - - caddyhttp/pprof - - caddyhttp/proxy - - caddyhttp/redirect - - caddyhttp/rewrite - - caddyhttp/root - - caddyhttp/templates - - caddyhttp/websocket - - startupshutdown - - caddyhttp/staticfiles - - caddyhttp/markdown/metadata - - caddyhttp/markdown/summary -- name: github.com/micromdm/scep - version: b7516ce6fe521e14e2d9dbbf03004ad206135807 - subpackages: - - caddy - - server - - scep - - scep/internal/pkcs7 -- name: github.com/miekg/dns - version: 5d001d020961ae1c184f9f8152fdc73810481677 -- name: github.com/russross/blackfriday - version: 1d6b8e9301e720b08a8938b8c25c018285885438 -- name: github.com/shurcooL/sanitized_anchor_name - version: 10ef21a441db47d8b13ebcc5fd2310f636973c77 -- name: github.com/xenolf/lego - version: b2fad6198110326662e9e356a97199078a4a775c - subpackages: - - acme -- name: golang.org/x/crypto - version: f3241ce8505855877cc8a9717bd61a0f7c4ea83c - subpackages: - - bcrypt - - ocsp - - blowfish - - curve25519 - - hkdf -- name: golang.org/x/net - version: d7bf3545bb0dacf009c535b3d3fbf53ac0a339ab - subpackages: - - context - - publicsuffix - - http2 - - http2/hpack - - context/ctxhttp - - lex/httplex -- name: gopkg.in/natefinch/lumberjack.v2 - version: 514cbda263a734ae8caac038dadf05f8f3f9f738 -- name: gopkg.in/square/go-jose.v1 - version: e3f973b66b91445ec816dd7411ad1b6495a5a2fc - subpackages: - - cipher - - json -- name: gopkg.in/yaml.v2 - version: a83829b6f1293c91addabc89d0571c246397bbf4 -devImports: [] diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index c0f57e7..0000000 --- a/glide.yaml +++ /dev/null @@ -1,16 +0,0 @@ -package: github.com/micromdm/squirrel -import: -- package: github.com/abiosoft/caddy-git -- package: github.com/go-kit/kit - subpackages: - - log -- package: github.com/mholt/caddy - subpackages: - - caddyhttp - - caddytls -- package: github.com/micromdm/scep - subpackages: - - caddy -- package: github.com/xenolf/lego - subpackages: - - acme diff --git a/munki/datastore/catalogs.go b/munki/datastore/catalogs.go deleted file mode 100644 index 75091f8..0000000 --- a/munki/datastore/catalogs.go +++ /dev/null @@ -1,64 +0,0 @@ -package datastore - -import ( - "fmt" - "log" - "os" - - "github.com/groob/plist" - "github.com/micromdm/squirrel/munki/munki" -) - -var makecatalogs = make(chan bool, 1) - -func (r *SimpleRepo) makeCatalogs(done chan bool) { - catalogs := map[string]*munki.Catalogs{} - pkgsinfos, err := r.AllPkgsinfos() - if err != nil { - log.Println(err) - } - allCatalogs := pkgsinfos.Catalog("all") - catalogs["all"] = allCatalogs - for _, info := range *allCatalogs { - for _, catalogName := range info.Catalogs { - catalogs[catalogName] = pkgsinfos.Catalog(catalogName) - } - } - - for k, v := range catalogs { - err = r.saveCatalog(k, v) - if err != nil { - log.Println(err) - } - } - done <- true -} - -func (r *SimpleRepo) saveCatalog(name string, catalogs *munki.Catalogs) error { - catalogsPath := fmt.Sprintf("%v/catalogs/%v", r.Path, name) - var file *os.File - var err error - if _, err := os.Stat(catalogsPath); err != nil { - file, err = os.Create(catalogsPath) - } else { - file, err = os.OpenFile(catalogsPath, os.O_TRUNC|os.O_WRONLY, 0755) - } - if err != nil { - return err - } - defer file.Close() - enc := plist.NewEncoder(file) - enc.Indent(" ") - return enc.Encode(catalogs) - -} - -//WatchCatalogs creates catalogs from pkgsinfos -func (r *SimpleRepo) WatchCatalogs() { - done := make(chan bool, 1) - for { - <-makecatalogs - go r.makeCatalogs(done) - <-done - } -} diff --git a/munki/datastore/datastore.go b/munki/datastore/datastore.go deleted file mode 100644 index 0973d66..0000000 --- a/munki/datastore/datastore.go +++ /dev/null @@ -1,57 +0,0 @@ -package datastore - -import ( - "errors" - "os" - "path/filepath" - - "github.com/micromdm/squirrel/munki/munki" -) - -var ( - // ErrExists file already exists - ErrExists = errors.New("resource already exists") - - // ErrNotFound = resource not found - ErrNotFound = errors.New("resource not found") -) - -// Datastore is an interface around munki storage -type Datastore interface { - munki.PkgsinfoStore - munki.ManifestStore -} - -// SimpleRepo is a filesystem based backend -type SimpleRepo struct { - Path string - indexManifests map[string]*munki.Manifest - indexPkgsinfo map[string]*munki.PkgsInfo -} - -func deleteFile(path string) error { - if err := os.Remove(path); err != nil { - return ErrNotFound - } - return nil -} - -func createFile(path string) error { - // check if exists - if _, err := os.Stat(path); err == nil { - return ErrExists - } - // create the relative directory if it doesn't exist - dir := filepath.Dir(path) - if err := os.MkdirAll(dir, 0755); err != nil { - return err - } - - // create the file - file, err := os.Create(path) - if err != nil { - return err - } - defer file.Close() - return nil -} diff --git a/munki/datastore/manifest.go b/munki/datastore/manifest.go deleted file mode 100644 index cc796f0..0000000 --- a/munki/datastore/manifest.go +++ /dev/null @@ -1,110 +0,0 @@ -package datastore - -import ( - "errors" - "fmt" - "log" - "os" - "path/filepath" - - "github.com/groob/plist" - "github.com/micromdm/squirrel/munki/munki" -) - -// AllManifests returns an array of manifests -func (r *SimpleRepo) AllManifests() (*munki.ManifestCollection, error) { - manifests := &munki.ManifestCollection{} - err := loadManifests(r.Path, manifests) - if err != nil { - return nil, err - } - r.updateManifestIndex(manifests) - return manifests, nil -} - -// Manifest returns a single manifest from repo -func (r *SimpleRepo) Manifest(name string) (*munki.Manifest, error) { - manifests := &munki.ManifestCollection{} - err := loadManifests(r.Path, manifests) - if err != nil { - return nil, err - } - r.updateManifestIndex(manifests) - - manifest, ok := r.indexManifests[name] - if !ok { - return nil, ErrNotFound - } - return manifest, nil -} - -// NewManifest returns a single manifest from repo -func (r *SimpleRepo) NewManifest(name string) (*munki.Manifest, error) { - manifest := &munki.Manifest{} - manifestPath := fmt.Sprintf("%v/manifests/%v", r.Path, name) - err := createFile(manifestPath) - return manifest, err -} - -// SaveManifest saves a manifest to the datastore -func (r *SimpleRepo) SaveManifest(path string, manifest *munki.Manifest) error { - if path == "" { - return errors.New("must specify a manifest name") - } - manifestPath := fmt.Sprintf("%v/manifests/%v", r.Path, path) - file, err := os.OpenFile(manifestPath, os.O_WRONLY, 0755) - if err != nil { - return err - } - defer file.Close() - if err := plist.NewEncoder(file).Encode(manifest); err != nil { - return err - } - return nil -} - -// DeleteManifest removes a manifest file from the repository -func (r *SimpleRepo) DeleteManifest(name string) error { - manifestPath := fmt.Sprintf("%v/manifests/%v", r.Path, name) - return deleteFile(manifestPath) -} - -func (r *SimpleRepo) updateManifestIndex(manifests *munki.ManifestCollection) { - r.indexManifests = make(map[string]*munki.Manifest, len(*manifests)) - for _, manifest := range *manifests { - r.indexManifests[manifest.Filename] = manifest - } -} - -func walkManifests(manifests *munki.ManifestCollection) filepath.WalkFunc { - return func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - file, err := os.Open(path) - if err != nil { - return err - } - defer file.Close() - if !info.IsDir() { - // Decode manifest - manifest := &munki.Manifest{} - err := plist.NewDecoder(file).Decode(manifest) - if err != nil { - log.Printf("git-repo: failed to decode %v, skipping \n", info.Name()) - return nil - } - // set filename to relative path + filename - manifest.Filename = info.Name() - // add to ManifestCollection - *manifests = append(*manifests, manifest) - return nil - } - return nil - } -} - -func loadManifests(path string, manifests *munki.ManifestCollection) error { - manifestPath := fmt.Sprintf("%v/manifests", path) - return filepath.Walk(manifestPath, walkManifests(manifests)) -} diff --git a/munki/datastore/pkgsinfo.go b/munki/datastore/pkgsinfo.go deleted file mode 100644 index ee9388c..0000000 --- a/munki/datastore/pkgsinfo.go +++ /dev/null @@ -1,123 +0,0 @@ -package datastore - -import ( - "errors" - "fmt" - "log" - "os" - "path/filepath" - - "github.com/groob/plist" - "github.com/micromdm/squirrel/munki/munki" -) - -// AllPkgsinfos returns a pkgsinfo collection -func (r *SimpleRepo) AllPkgsinfos() (*munki.PkgsInfoCollection, error) { - pkgsinfos := &munki.PkgsInfoCollection{} - if err := loadPkgsinfos(r.Path, pkgsinfos); err != nil { - return nil, err - } - r.updatePkgsinfoIndex(pkgsinfos) - return pkgsinfos, nil -} - -// Pkgsinfo returns a single pkgsinfo from repo -func (r *SimpleRepo) Pkgsinfo(name string) (*munki.PkgsInfo, error) { - pkgsinfos := &munki.PkgsInfoCollection{} - if err := loadPkgsinfos(r.Path, pkgsinfos); err != nil { - return nil, err - } - r.updatePkgsinfoIndex(pkgsinfos) - pkgsinfo, ok := r.indexPkgsinfo[name] - if !ok { - return nil, ErrNotFound - } - return pkgsinfo, nil -} - -// NewPkgsinfo returns a single manifest from repo -func (r *SimpleRepo) NewPkgsinfo(name string) (*munki.PkgsInfo, error) { - pkgsinfo := &munki.PkgsInfo{} - pkgsinfoPath := fmt.Sprintf("%v/pkgsinfo/%v", r.Path, name) - err := createFile(pkgsinfoPath) - return pkgsinfo, err -} - -// SavePkgsinfo saves a pkgsinfo file to the datastore -func (r *SimpleRepo) SavePkgsinfo(path string, pkgsinfo *munki.PkgsInfo) error { - if path == "" { - return errors.New("must specify a pkgsinfo path") - } - pkgsinfoPath := fmt.Sprintf("%v/pkgsinfo/%v", r.Path, path) - file, err := os.OpenFile(pkgsinfoPath, os.O_WRONLY, 0755) - if err != nil { - return err - } - defer file.Close() - if err := plist.NewEncoder(file).Encode(pkgsinfo); err != nil { - return err - } - go func() { - makecatalogs <- true - }() - return nil -} - -// DeletePkgsinfo deletes a pkgsinfo file from the datastore and triggers makecatalogs if succesful -func (r *SimpleRepo) DeletePkgsinfo(name string) error { - pkgsinfoPath := fmt.Sprintf("%v/pkgsinfo/%v", r.Path, name) - if err := deleteFile(pkgsinfoPath); err != nil { - return err - } - go func() { - makecatalogs <- true - }() - return nil -} - -func (r *SimpleRepo) updatePkgsinfoIndex(pkgsinfos *munki.PkgsInfoCollection) { - r.indexPkgsinfo = make(map[string]*munki.PkgsInfo, len(*pkgsinfos)) - for _, pkgsinfo := range *pkgsinfos { - r.indexPkgsinfo[pkgsinfo.Filename] = pkgsinfo - } -} - -func walkPkgsinfo(pkgsinfos *munki.PkgsInfoCollection, pkgsinfoPath string) filepath.WalkFunc { - return func(path string, info os.FileInfo, err error) error { - if err != nil { - return err - } - file, err := os.Open(path) - if err != nil { - return err - } - defer file.Close() - if !info.IsDir() { - // Decode pkgsinfo - pkgsinfo := &munki.PkgsInfo{} - err := plist.NewDecoder(file).Decode(pkgsinfo) - if err != nil { - log.Printf("simple-repo: failed to decode %v, skipping \n", info.Name()) - return nil - } - // set filename to relative path - relpath, err := filepath.Rel(pkgsinfoPath, path) - if err != nil { - log.Printf("simple-repo: failed to get relative path %v, skipping \n", info.Name()) - return err - } - // use the relative path as the filename - pkgsinfo.Filename = relpath - // add to ManifestCollection - *pkgsinfos = append(*pkgsinfos, pkgsinfo) - return nil - } - return nil - } -} - -// load the pkgsinfos -func loadPkgsinfos(path string, pkgsinfos *munki.PkgsInfoCollection) error { - pkgsinfoPath := fmt.Sprintf("%v/pkgsinfo", path) - return filepath.Walk(pkgsinfoPath, walkPkgsinfo(pkgsinfos, pkgsinfoPath)) -} diff --git a/munki/munki/catalog.go b/munki/munki/catalog.go deleted file mode 100644 index 5db2c51..0000000 --- a/munki/munki/catalog.go +++ /dev/null @@ -1,9 +0,0 @@ -package munki - -// Catalog is a munki catalog -type Catalog struct { - pkgsinfo -} - -// Catalogs is an array of catalogs -type Catalogs []*Catalog diff --git a/munki/munki/manifest.go b/munki/munki/manifest.go deleted file mode 100644 index 92f70aa..0000000 --- a/munki/munki/manifest.go +++ /dev/null @@ -1,81 +0,0 @@ -package munki - -// ManifestStore is the interface for accessing manifests in a database or filesystem -type ManifestStore interface { - AllManifests() (*ManifestCollection, error) - Manifest(name string) (*Manifest, error) - NewManifest(name string) (*Manifest, error) - SaveManifest(path string, manifest *Manifest) error - DeleteManifest(name string) error -} - -// Manifest represents the structure of a munki manifest -// This is what would be serialized in a datastore -type Manifest struct { - Filename string `plist:"-" json:"-"` - Catalogs []string `plist:"catalogs,omitempty" json:"catalogs,omitempty"` - DisplayName string `plist:"display_name,omitempty" json:"display_name,omitempty"` - IncludedManifests []string `plist:"included_manifests,omitempty" json:"included_manifests,omitempty"` - Notes string `plist:"notes,omitempty" json:"notes,omitempty"` - User string `plist:"user,omitempty" json:"user,omitempty"` - ConditionalItems []condition `plist:"conditional_items,omitempty" json:"conditional_items,omitempty"` - manifestItems -} - -type manifestItems struct { - OptionalInstalls []string `plist:"optional_installs,omitempty" json:"optional_installs,omitempty"` - ManagedInstalls []string `plist:"managed_installs,omitempty" json:"managed_installs,omitempty"` - ManagedUninstalls []string `plist:"managed_uninstalls,omitempty" json:"managed_uninstalls,omitempty"` - ManagedUpdates []string `plist:"managed_updates,omitempty" json:"managed_updates,omitempty"` -} - -type condition struct { - Condition string `plist:"condition" json:"condition"` - manifestItems -} - -// ManifestCollection represents a list of manifests -type ManifestCollection []*Manifest - -// UpdateFromPayload updates a manifest from a ManifestPayload -func (m *Manifest) UpdateFromPayload(payload *ManifestPayload) { - if payload.Catalogs != nil { - m.Catalogs = *payload.Catalogs - } - - if payload.DisplayName != nil { - m.DisplayName = *payload.DisplayName - } - - if payload.IncludedManifests != nil { - m.IncludedManifests = *payload.IncludedManifests - } - - if payload.OptionalInstalls != nil { - m.OptionalInstalls = *payload.OptionalInstalls - } - - if payload.ManagedInstalls != nil { - m.ManagedInstalls = *payload.ManagedInstalls - } - - if payload.ManagedUninstalls != nil { - m.ManagedUninstalls = *payload.ManagedUninstalls - } - - if payload.ManagedUpdates != nil { - m.ManagedUpdates = *payload.ManagedUpdates - } - - if payload.Notes != nil { - m.Notes = *payload.Notes - } - - if payload.User != nil { - m.User = *payload.User - } - - if payload.ConditionalItems != nil { - m.ConditionalItems = *payload.ConditionalItems - } -} diff --git a/munki/munki/manifest_payload.go b/munki/munki/manifest_payload.go deleted file mode 100644 index eededa9..0000000 --- a/munki/munki/manifest_payload.go +++ /dev/null @@ -1,21 +0,0 @@ -package munki - -// ManifestPayload represents a payload type -// The payload type is what the client would send over the wire -type ManifestPayload struct { - Filename *string `plist:"filename,omitempty" json:"filename,omitempty"` - Catalogs *[]string `plist:"catalogs,omitempty" json:"catalogs,omitempty"` - DisplayName *string `plist:"display_name,omitempty" json:"display_name,omitempty"` - IncludedManifests *[]string `plist:"included_manifests,omitempty" json:"included_manifests,omitempty"` - Notes *string `plist:"notes,omitempty" json:"notes,omitempty"` - User *string `plist:"user,omitempty" json:"user,omitempty"` - ConditionalItems *[]condition `plist:"conditional_items,omitempty" json:"conditional_items,omitempty"` - manifestItemsPayload -} - -type manifestItemsPayload struct { - OptionalInstalls *[]string `plist:"optional_installs,omitempty" json:"optional_installs,omitempty"` - ManagedInstalls *[]string `plist:"managed_installs,omitempty" json:"managed_installs,omitempty"` - ManagedUninstalls *[]string `plist:"managed_uninstalls,omitempty" json:"managed_uninstalls,omitempty"` - ManagedUpdates *[]string `plist:"managed_updates,omitempty" json:"managed_updates,omitempty"` -} diff --git a/munki/munki/pkgsinfo.go b/munki/munki/pkgsinfo.go deleted file mode 100644 index 4359c4c..0000000 --- a/munki/munki/pkgsinfo.go +++ /dev/null @@ -1,203 +0,0 @@ -package munki - -import "time" - -// PkgsinfoStore is an interface for interacting with Pkgsinfo types -type PkgsinfoStore interface { - AllPkgsinfos() (*PkgsInfoCollection, error) - Pkgsinfo(name string) (*PkgsInfo, error) - NewPkgsinfo(name string) (*PkgsInfo, error) - SavePkgsinfo(path string, pkgsinfo *PkgsInfo) error - DeletePkgsinfo(name string) error -} - -// PkgsInfo represents the structure of a pkgsinfo file -type PkgsInfo struct { - pkgsinfo - Filename string `plist:"-" json:"-"` - Metadata metadata `plist:"_metadata,omitempty" json:"_metadata,omitempty"` - adobeRelatedItems -} - -type pkgsinfo struct { - Autoremove bool `plist:"autoremove,omitempty" json:"autoremove,omitempty"` - Catalogs []string `plist:"catalogs,omitempty" json:"catalogs,omitempty"` - Category string `plist:"category,omitempty" json:"category,omitempty"` - CopyLocal bool `plist:"copy_local,omitempty" json:"copy_local,omitempty"` - Description string `plist:"description,omitempty" json:"description,omitempty"` - Developer string `plist:"developer,omitempty" json:"developer,omitempty"` - DisplayName string `plist:"display_name,omitempty" json:"display_name,omitempty"` - ForceInstallAfterDate time.Time `plist:"force_install_after_date,omitempty" json:"force_install_after_date,omitempty"` - IconName string `plist:"icon_name,omitempty" json:"icon_name,omitempty"` - InstallableCondition string `plist:"installable_condition,omitempty" json:"installable_condition,omitempty"` - InstalledSize int `plist:"installed_size,omitempty" json:"installed_size,omitempty"` - InstallerItemHash string `plist:"installer_item_hash,omitempty" json:"installer_item_hash,omitempty"` - InstallerItemLocation string `plist:"installer_item_location,omitempty" json:"installer_item_location,omitempty"` - InstallerItemSize int `plist:"installer_item_size,omitempty" json:"installer_item_size,omitempty"` - InstallerType string `plist:"installer_type,omitempty" json:"installer_item_type,omitempty"` - Installs []install `plist:"installs,omitempty" json:"installs,omitempty"` - Receipts []receipt `plist:"receipts,omitempty" json:"receipts,omitempty"` - ItemsToCopy []itemsToCopy `plist:"items_to_copy,omitempty" json:"items_to_copy,omitempty"` - MinimumMunkiVersion string `plist:"minimum_munki_version,omitempty" json:"minimum_munki_version,omitempty"` - MinimumOSVersion string `plist:"minimum_os_version,omitempty" json:"minimum_os_version,omitempty"` - MaximumOSVersion string `plist:"maximum_os_version,omitempty" json:"maximum_os_version,omitempty"` - Name string `plist:"name,omitempty" json:"name,omitempty"` - Notes string `plist:"notes,omitempty" json:"notes,omitempty"` - PackageCompleteURL string `plist:"PackageCompleteURL,omitempty" json:"PackageCompleteURL,omitempty"` - PackageURL string `plist:"PackageURL,omitempty" json:"PackageURL,omitempty"` - PackagePath string `plist:"package_path,omitempty" json:"package_path,omitempty"` - InstallCheckScript string `plist:"installcheck_script,omitempty" json:"installcheck_script,omitempty"` - UninstallCheckScript string `plist:"uninstallcheck_script,omitempty" json:"uninstallcheck_script,omitempty"` - OnDemand bool `plist:"OnDemand,omitempty" json:"OnDemand,omitempty"` - PostInstallScript string `plist:"postinstall_script,omitempty" json:"postinstall_script,omitempty"` - PreInstallScript string `plist:"preinstall_script,omitempty" json:"preinstall_script,omitempty"` - PostUninstallScript string `plist:"postuninstall_script,omitempty" json:"postuninstall_script,omitempty"` - SuppressBundleRelocation bool `plist:"suppress_bundle_relocation,omitempty" json:"suppress_bundle_relocation,omitempty"` - UnattendedInstall bool `plist:"unattended_install,omitempty" json:"unattended_install,omitempty"` - UnattendedUninstall bool `plist:"unattended_uninstall,omitempty" json:"unattended_uninstall,omitempty"` - Requires []string `plist:"requires,omitempty" json:"requires,omitempty"` - RestartAction string `plist:"RestartAction,omitempty" json:"RestartAction,omitempty"` - Uninstallmethod string `plist:"uninstall_method,omitempty" json:"uninstall_method,omitempty"` - UninstallScript string `plist:"uninstall_script,omitempty" json:"uninstall_script,omitempty"` - UninstallerItemLocation string `plist:"uninstaller_item_location,omitempty" json:"uninstaller_item_location,omitempty"` - AppleItem bool `plist:"apple_item,omitempty" json:"apple_item,omitempty"` - Uninstallable bool `plist:"uninstallable,omitempty" json:"uninstallable,omitempty"` - BlockingApplications []string `plist:"blocking_applications,omitempty" json:"blocking_applications,omitempty"` - SupportedArchitectures []string `plist:"supported_architectures,omitempty" json:"supported_architectures,omitempty"` - UpdateFor []string `plist:"update_for,omitempty" json:"update_for,omitempty"` - Version string `plist:"version,omitempty" json:"version,omitempty"` - InstallerChoicesXML []installerChoicesXML `plist:"installer_choices_xml,omitempty" json:"installer_choices_xml,omitempty"` - InstallerEnvironment map[string]string `plist:"installer_environment,omitempty" json:"installer_environment,omitempty"` -} - -type metadata struct { - CreatedBy string `plist:"created_by,omitempty" json:"created_by,omitempty"` - CreatedDate time.Time `plist:"creation_date,omitempty" json:"created_date,omitempty"` - MunkiVersion string `plist:"munki_version,omitempty" json:"munki_version,omitempty"` - OSVersion string `plist:"os_version,omitempty" json:"os_version,omitempty"` -} - -type install struct { - CFBundleIdentifier string `plist:"CFBundleIdentifier,omitempty" json:"CFBundleIdentifier,omitempty"` - CFBundleName string `plist:"CFBundleName,omitempty" json:"CFBundleName,omitempty"` - CFBundleShortVersionString string `plist:"CFBundleShortVersionString,omitempty" json:"CFBundleShortVersionString,omitempty"` - CFBundleVersion string `plist:"CFBundleVersion,omitempty" json:"CFBundleVersion,omitempty"` - MD5Checksum string `plist:"md5checksum,omitempty" json:"md5checksum,omitempty"` - MinOSVersion string `plist:"minosversion,omitempty" json:"min_os_version,omitempty"` - Path string `plist:"path,omitempty" json:"path,omitempty"` - Type string `plist:"type,omitempty" json:"type,omitempty"` - VersionComparisonKey string `plist:"version_comparison_key,omitempty" json:"version_comparision_key,omitempty"` -} - -type receipt struct { - Filename string `plist:"filename,omitempty" json:"filename,omitempty"` - InstalledSize int `plist:"installed_size,omitempty" json:"installed_size,omitempty"` - Name string `plist:"name,omitempty" json:"name,omitempty"` - PackageID string `plist:"packageid,omitempty" json:"packageid,omitempty"` - Version string `plist:"version,omitempty" json:"version,omitempty"` - Optional bool `plist:"optional,omitempty" json:"optional,omitempty"` -} - -type itemsToCopy struct { - DestinationPath string `plist:"destination_path" json:"destination_path"` - Group string `plist:"group,omitempty" json:"group,omitempty"` - Mode string `plist:"mode,omitempty" json:"mode,omitempty"` - SourceItem string `plist:"source_item" json:"source_item"` - User string `plist:"user,omitempty" json:"user,omitempty"` -} - -type installerChoicesXML struct { - AttributeSetting int `plist:"attributeSetting,omitempty" json:"attributeSetting,omitempty"` - ChoiceAttribute string `plist:"choiceAttribute,omitempty" json:"choiceAttribute,omitempty"` - ChoiceIdentifier string `plist:"choiceIdentifier,omitempty" json:"choiceIdentifier,omitempty"` -} - -type adobeRelatedItems struct { - AdobeSetupType string `plist:"AdobeSetupType,omitempty" json:"AdobeSetupType,omitempty"` - Payloads []map[string]interface{} `plist:"payloads,omitempty" json:"payloads,omitempty"` - // Only available in CS, not CC - AdobeInstallInfo adobeInstallInfo `plist:"adobe_install_info,omitempty" json:"adobe_install_info,omitempty"` -} - -type adobeInstallInfo struct { - SerialNumber string `plist:"serialnumber,omitempty" json:"serialnumber,omitempty"` - InstallXML string `plist:"installxml,omitempty" json:"installxml,omitempty"` - UninstallXML string `plist:"uninstallxml,omitempty" json:"uninstallxml,omitempty"` - MediaSignature string `plist:"media_signature,omitempty" json:"media_signature,omitempty"` - MediaDigest string `plist:"media_digest,omitempty" json:"media_signature,omitempty"` - PayloadCount int `plist:"payload_count,omitempty" json:"payload_count,omitempty"` - SuppressRegistration bool `plist:"suppress_registration,omitempty" json:"suppress_registration,omitempty"` - SuppressUpdates bool `plist:"suppress_updates,omitempty" json:"suppress_updates,omitempty"` -} - -// Catalog converts a pkgsinfo to a catalog -func (p *PkgsInfo) catalog() *Catalog { - catalog := &Catalog{ - p.pkgsinfo, - } - return catalog -} - -type pkgsinfoView struct { - Filename string `plist:"filename,omitempty" json:"filename,omitempty"` - *PkgsInfo -} - -// PkgsInfoCollection is a collection of pkgsinfos -type PkgsInfoCollection []*PkgsInfo - -// Catalog return a specific catalog -func (p *PkgsInfoCollection) Catalog(name string) *Catalogs { - catalogs := Catalogs{} - var pkgsinfos *PkgsInfoCollection - if name != "all" { - filtered := p.ByCatalog(name) - pkgsinfos = filtered - } else { - pkgsinfos = p - } - for _, info := range *pkgsinfos { - catalog := info.catalog() - catalogs = append(catalogs, catalog) - } - return &catalogs -} - -// ByCatalog returns an array of items in catalog -func (p *PkgsInfoCollection) ByCatalog(catalogs ...string) *PkgsInfoCollection { - byCatalogIndex := map[string]*PkgsInfo{} - byCatalog := PkgsInfoCollection{} - for _, item := range *p { - for _, catalog := range catalogs { - if containsString(item.Catalogs, catalog) { - byCatalogIndex[item.Filename] = item - } - } - } - - for _, v := range byCatalogIndex { - byCatalog = append(byCatalog, v) - } - - return &byCatalog -} - -// ByName returns a list of pkgsinfos filtered by name -func (p *PkgsInfoCollection) ByName(name string) *PkgsInfoCollection { - byName := PkgsInfoCollection{} - for _, item := range *p { - if item.Name == name { - byName = append(byName, item) - } - } - return &byName -} - -func containsString(s []string, e string) bool { - for _, a := range s { - if a == e { - return true - } - } - return false -} diff --git a/munki/server/endpoint_manifest.go b/munki/server/endpoint_manifest.go deleted file mode 100644 index 63a5854..0000000 --- a/munki/server/endpoint_manifest.go +++ /dev/null @@ -1,125 +0,0 @@ -package munkiserver - -import ( - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/squirrel/munki/munki" - "golang.org/x/net/context" -) - -type listManifestsRequest struct { -} - -type listManifestsResponse struct { - manifests *munki.ManifestCollection - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r listManifestsResponse) subset() interface{} { - return r.manifests -} - -func (r listManifestsResponse) error() error { return r.Err } - -func makeListManifestsEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - manifests, err := svc.ListManifests(ctx) - return listManifestsResponse{manifests: manifests, Err: err}, nil - } -} - -type showManifestRequest struct { - Path string -} - -type showManifestResponse struct { - *munki.Manifest - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r showManifestResponse) error() error { return r.Err } - -func makeShowManifestEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(showManifestRequest) - manifest, err := svc.ShowManifest(ctx, req.Path) - return showManifestResponse{Manifest: manifest, Err: err}, nil - } -} - -type createManifestRequest struct { - Filename string `plist:"filename" json:"filename"` - *munki.Manifest -} - -type createManifestResponse struct { - *munki.Manifest - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r createManifestResponse) error() error { return r.Err } - -func makeCreateManifestEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(createManifestRequest) - manifest, err := svc.CreateManifest(ctx, req.Filename, req.Manifest) - return showManifestResponse{Manifest: manifest, Err: err}, nil - } -} - -type deleteManifestRequest struct { - Path string `plist:"filename" json:"filename"` -} - -type deleteManifestResponse struct { - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r deleteManifestResponse) error() error { return r.Err } - -func makeDeleteManifestEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(deleteManifestRequest) - err := svc.DeleteManifest(ctx, req.Path) - return deleteManifestResponse{Err: err}, nil - } -} - -type replaceManifestRequest struct { - Path string `plist:"filename" json:"filename"` - *munki.Manifest -} - -type replaceManifestResponse struct { - *munki.Manifest - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r replaceManifestResponse) error() error { return r.Err } - -func makeReplaceManifestEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(replaceManifestRequest) - manifest, err := svc.ReplaceManifest(ctx, req.Path, req.Manifest) - return replaceManifestResponse{Manifest: manifest, Err: err}, nil - } -} - -type updateManifestRequest struct { - Path string `plist:"filename" json:"filename"` - *munki.ManifestPayload -} - -type updateManifestResponse struct { - *munki.Manifest - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r updateManifestResponse) error() error { return r.Err } - -func makeUpdateManifestEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(updateManifestRequest) - manifest, err := svc.UpdateManifest(ctx, req.Path, req.ManifestPayload) - return updateManifestResponse{Manifest: manifest, Err: err}, nil - } -} diff --git a/munki/server/endpoint_pkgsinfo.go b/munki/server/endpoint_pkgsinfo.go deleted file mode 100644 index c0367ac..0000000 --- a/munki/server/endpoint_pkgsinfo.go +++ /dev/null @@ -1,48 +0,0 @@ -package munkiserver - -import ( - "github.com/go-kit/kit/endpoint" - "github.com/micromdm/squirrel/munki/munki" - "golang.org/x/net/context" -) - -type listPkgsinfosRequest struct { -} - -type listPkgsinfosResponse struct { - pkgsinfos *munki.PkgsInfoCollection - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r listPkgsinfosResponse) subset() interface{} { - return r.pkgsinfos -} - -func (r listPkgsinfosResponse) error() error { return r.Err } - -func makeListPkgsinfosEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - pkgsinfos, err := svc.ListPkgsinfos(ctx) - return listPkgsinfosResponse{pkgsinfos: pkgsinfos, Err: err}, nil - } -} - -type createPkgsinfoRequest struct { - Filename string `plist:"filename" json:"filename"` - *munki.PkgsInfo -} - -type createPkgsinfoResponse struct { - *munki.PkgsInfo - Err error `json:"error,omitempty" plist:"error,omitempty"` -} - -func (r createPkgsinfoResponse) error() error { return r.Err } - -func makeCreatePkgsinfoEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(createPkgsinfoRequest) - pkgsinfo, err := svc.CreatePkgsinfo(ctx, req.Filename, req.PkgsInfo) - return createPkgsinfoResponse{PkgsInfo: pkgsinfo, Err: err}, nil - } -} diff --git a/munki/server/service.go b/munki/server/service.go deleted file mode 100644 index b2b8ec0..0000000 --- a/munki/server/service.go +++ /dev/null @@ -1,20 +0,0 @@ -package munkiserver - -import "github.com/micromdm/squirrel/munki/datastore" - -// Service describes the actions of a munki server -type Service interface { - ManifestService - PkgsinfoService -} - -type service struct { - repo datastore.Datastore -} - -// NewService creates a new munki api service -func NewService(repo datastore.Datastore) (Service, error) { - return &service{ - repo: repo, - }, nil -} diff --git a/munki/server/service_manifest.go b/munki/server/service_manifest.go deleted file mode 100644 index 9a29319..0000000 --- a/munki/server/service_manifest.go +++ /dev/null @@ -1,58 +0,0 @@ -package munkiserver - -import ( - "github.com/micromdm/squirrel/munki/munki" - "golang.org/x/net/context" -) - -// ManifestService describes the actions of a munki server -type ManifestService interface { - ListManifests(ctx context.Context) (*munki.ManifestCollection, error) - ShowManifest(ctx context.Context, name string) (*munki.Manifest, error) - CreateManifest(ctx context.Context, name string, manifest *munki.Manifest) (*munki.Manifest, error) - ReplaceManifest(ctx context.Context, name string, manifest *munki.Manifest) (*munki.Manifest, error) - DeleteManifest(ctx context.Context, name string) error - UpdateManifest(ctx context.Context, name string, payload *munki.ManifestPayload) (*munki.Manifest, error) -} - -func (svc service) ListManifests(ctx context.Context) (*munki.ManifestCollection, error) { - return svc.repo.AllManifests() -} - -func (svc service) ShowManifest(ctx context.Context, name string) (*munki.Manifest, error) { - return svc.repo.Manifest(name) -} - -func (svc service) CreateManifest(ctx context.Context, name string, manifest *munki.Manifest) (*munki.Manifest, error) { - _, err := svc.repo.NewManifest(name) - if err != nil { - return nil, err - } - if err := svc.repo.SaveManifest(name, manifest); err != nil { - return nil, err - } - return manifest, nil -} - -func (svc service) DeleteManifest(ctx context.Context, name string) error { - return svc.repo.DeleteManifest(name) -} - -func (svc service) ReplaceManifest(ctx context.Context, name string, manifest *munki.Manifest) (*munki.Manifest, error) { - if err := svc.repo.DeleteManifest(name); err != nil { - return nil, err - } - return svc.CreateManifest(ctx, name, manifest) -} - -func (svc service) UpdateManifest(ctx context.Context, name string, payload *munki.ManifestPayload) (*munki.Manifest, error) { - manifest, err := svc.repo.Manifest(name) - if err != nil { - return nil, err - } - manifest.UpdateFromPayload(payload) - if err := svc.repo.SaveManifest(name, manifest); err != nil { - return nil, err - } - return manifest, nil -} diff --git a/munki/server/service_pkgsinfo.go b/munki/server/service_pkgsinfo.go deleted file mode 100644 index e2bbbce..0000000 --- a/munki/server/service_pkgsinfo.go +++ /dev/null @@ -1,27 +0,0 @@ -package munkiserver - -import ( - "github.com/micromdm/squirrel/munki/munki" - "golang.org/x/net/context" -) - -// PkgsinfoService describes the methods for managing Pkgsinfo files in a munki repository -type PkgsinfoService interface { - ListPkgsinfos(ctx context.Context) (*munki.PkgsInfoCollection, error) - CreatePkgsinfo(ctx context.Context, name string, pkgsinfo *munki.PkgsInfo) (*munki.PkgsInfo, error) -} - -func (svc service) ListPkgsinfos(ctx context.Context) (*munki.PkgsInfoCollection, error) { - return svc.repo.AllPkgsinfos() -} - -func (svc service) CreatePkgsinfo(ctx context.Context, name string, pkgsinfo *munki.PkgsInfo) (*munki.PkgsInfo, error) { - _, err := svc.repo.NewPkgsinfo(name) - if err != nil { - return nil, err - } - if err := svc.repo.SavePkgsinfo(name, pkgsinfo); err != nil { - return nil, err - } - return pkgsinfo, nil -} diff --git a/munki/server/testdata/testrepo/manifests/site_default b/munki/server/testdata/testrepo/manifests/site_default deleted file mode 100644 index 45a615b..0000000 --- a/munki/server/testdata/testrepo/manifests/site_default +++ /dev/null @@ -1,22 +0,0 @@ - - - - - catalogs - - production - - included_manifests - - managed_installs - - munkitools - munkitools_core - munkitools_launchd - - managed_uninstalls - - optional_installs - - - diff --git a/munki/server/transport.go b/munki/server/transport.go deleted file mode 100644 index 666ad11..0000000 --- a/munki/server/transport.go +++ /dev/null @@ -1,215 +0,0 @@ -package munkiserver - -import ( - "encoding/json" - "errors" - "net/http" - - kitlog "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" - kithttp "github.com/go-kit/kit/transport/http" - "github.com/gorilla/mux" - "github.com/groob/plist" - "github.com/micromdm/squirrel/munki/datastore" - - "golang.org/x/net/context" -) - -var ( - // ErrEmptyRequest is returned if the request body is empty - errEmptyRequest = errors.New("request must contain all required fields") - errBadRouting = errors.New("inconsistent mapping between route and handler (programmer error)") -) - -// ServiceHandler creates an HTTP handler for the munki Service -func ServiceHandler(ctx context.Context, svc Service, logger kitlog.Logger) http.Handler { - opts := []kithttp.ServerOption{ - kithttp.ServerErrorLogger(logger), - kithttp.ServerErrorEncoder(encodeError), - kithttp.ServerBefore(updateContext), - } - listManifestsHandler := kithttp.NewServer( - ctx, - makeListManifestsEndpoint(svc), - decodeListManifestsRequest, - encodeResponse, - opts..., - ) - showManifestHandler := kithttp.NewServer( - ctx, - makeShowManifestEndpoint(svc), - decodeShowManifestRequest, - encodeResponse, - opts..., - ) - createManifestHandler := kithttp.NewServer( - ctx, - makeCreateManifestEndpoint(svc), - decodeCreateManifestRequest, - encodeResponse, - opts..., - ) - deleteManifestHandler := kithttp.NewServer( - ctx, - makeDeleteManifestEndpoint(svc), - decodeDeleteManifestRequest, - encodeResponse, - opts..., - ) - replaceManifestHandler := kithttp.NewServer( - ctx, - makeReplaceManifestEndpoint(svc), - decodeReplaceManifestRequest, - encodeResponse, - opts..., - ) - updateManifestHandler := kithttp.NewServer( - ctx, - makeUpdateManifestEndpoint(svc), - decodeUpdateManifestRequest, - encodeResponse, - opts..., - ) - listPkgsinfosHandler := kithttp.NewServer( - ctx, - makeListPkgsinfosEndpoint(svc), - decodeListPkgsinfosRequest, - encodeResponse, - opts..., - ) - createPkgsinfoHandler := kithttp.NewServer( - ctx, - makeCreatePkgsinfoEndpoint(svc), - decodeCreatePkgsinfoRequest, - encodeResponse, - opts..., - ) - - r := mux.NewRouter() - - r.Handle("/api/v1/manifests/{path}", showManifestHandler).Methods("GET") - r.Handle("/api/v1/manifests", listManifestsHandler).Methods("GET") - r.Handle("/api/v1/manifests", createManifestHandler).Methods("POST") - r.Handle("/api/v1/manifests/{path}", deleteManifestHandler).Methods("DELETE") - r.Handle("/api/v1/manifests/{path}", replaceManifestHandler).Methods("PUT") - r.Handle("/api/v1/manifests/{path}", updateManifestHandler).Methods("PATCH") - - r.Handle("/api/v1/pkgsinfos", listPkgsinfosHandler).Methods("GET") - r.Handle("/api/v1/pkgsinfos", createPkgsinfoHandler).Methods("POST") - return r -} - -func updateContext(ctx context.Context, r *http.Request) context.Context { - return context.WithValue(ctx, "mediaType", acceptHeader(r)) -} - -// if header is not set to json or xml, return json header -func acceptHeader(r *http.Request) string { - accept := r.Header.Get("Accept") - switch accept { - case "application/xml", "application/xml; charset=utf-8": - return "application/xml" - default: - return "application/json" - } -} - -// set the Content-Type header -func setContentType(rw http.ResponseWriter, accept string) { - switch accept { - case "application/xml": - rw.Header().Set("Content-Type", "application/xml; charset=utf-8") - return - default: - rw.Header().Set("Content-Type", "application/json; charset=utf-8") - return - } -} - -type errorer interface { - error() error -} - -type statuser interface { - status() int -} - -type subsetEncoder interface { - subset() interface{} -} - -func encodeJSON(w http.ResponseWriter, from interface{}) error { - data, err := json.MarshalIndent(from, "", " ") - if err != nil { - return err - } - w.Write(data) - return nil -} - -func encodePLIST(w http.ResponseWriter, from interface{}) error { - enc := plist.NewEncoder(w) - enc.Indent(" ") - return enc.Encode(from) -} - -func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - if e, ok := response.(errorer); ok && e.error() != nil { - encodeError(ctx, e.error(), w) - return nil - } - mediaType := ctx.Value("mediaType").(string) - setContentType(w, mediaType) - // for success responses - if e, ok := response.(statuser); ok { - w.WriteHeader(e.status()) - if e.status() == http.StatusNoContent { - return nil - } - } - - // check if this is a collection - if e, ok := response.(subsetEncoder); ok { - response = e.subset() - } - if mediaType == "application/xml" { - return encodePLIST(w, response) - } - return encodeJSON(w, response) -} - -func encodeError(ctx context.Context, err error, w http.ResponseWriter) { - if err == nil { - panic("encodeError with nil error") - } - mediaType := ctx.Value("mediaType").(string) - setContentType(w, mediaType) - w.WriteHeader(codeFrom(err)) - errData := map[string]interface{}{ - "error": err.Error(), - } - if mediaType == "application/xml" { - encodePLIST(w, errData) - return - } - encodeJSON(w, errData) -} - -func codeFrom(err error) int { - switch err { - case datastore.ErrNotFound: - return http.StatusNotFound - default: - if e, ok := err.(httptransport.Error); ok { - switch e.Domain { - case httptransport.DomainDecode: - return http.StatusBadRequest - case httptransport.DomainDo: - return http.StatusServiceUnavailable - default: - return http.StatusInternalServerError - } - } - return http.StatusInternalServerError - } -} diff --git a/munki/server/transport_manifest.go b/munki/server/transport_manifest.go deleted file mode 100644 index 3e709c4..0000000 --- a/munki/server/transport_manifest.go +++ /dev/null @@ -1,67 +0,0 @@ -package munkiserver - -import ( - "encoding/json" - "net/http" - - "github.com/gorilla/mux" - "golang.org/x/net/context" -) - -func decodeListManifestsRequest(_ context.Context, r *http.Request) (interface{}, error) { - return listManifestsRequest{}, nil -} - -func decodeShowManifestRequest(_ context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - path, ok := vars["path"] - if !ok { - return nil, errBadRouting - } - return showManifestRequest{Path: path}, nil -} - -func decodeCreateManifestRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request createManifestRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func decodeDeleteManifestRequest(_ context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - path, ok := vars["path"] - if !ok { - return nil, errBadRouting - } - return deleteManifestRequest{Path: path}, nil -} - -func decodeReplaceManifestRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request replaceManifestRequest - if err := json.NewDecoder(r.Body).Decode(&request.Manifest); err != nil { - return nil, err - } - vars := mux.Vars(r) - path, ok := vars["path"] - if !ok { - return nil, errBadRouting - } - request.Path = path - return request, nil -} - -func decodeUpdateManifestRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request updateManifestRequest - if err := json.NewDecoder(r.Body).Decode(&request.ManifestPayload); err != nil { - return nil, err - } - vars := mux.Vars(r) - path, ok := vars["path"] - if !ok { - return nil, errBadRouting - } - request.Path = path - return request, nil -} diff --git a/munki/server/transport_manifest_test.go b/munki/server/transport_manifest_test.go deleted file mode 100644 index 0e636d4..0000000 --- a/munki/server/transport_manifest_test.go +++ /dev/null @@ -1,221 +0,0 @@ -package munkiserver_test - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/micromdm/squirrel/munki/munki" -) - -func TestListManifests(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - testListManifestsHTTP(t, server, http.StatusOK) -} - -func TestShowManifests(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - testShowManifestHTTP(t, server, "site_default", http.StatusOK) - testShowManifestHTTP(t, server, "site_none", http.StatusNotFound) -} - -func TestUpdateManifest(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - manifests := []*munki.Manifest{ - &munki.Manifest{ - Filename: "update-manifest", - Catalogs: []string{"production", "testing"}, - }, - } - - for _, m := range manifests { - os.Remove("testdata/testrepo/manifests/" + m.Filename) - testCreateManifestHTTP(t, server, m.Filename, m, http.StatusOK) - m1 := &munki.ManifestPayload{ - Catalogs: &[]string{"foo"}, - } - testUpdateManifestHTTP(t, server, m.Filename, m1, http.StatusOK) - os.Remove("testdata/testrepo/manifests/" + m.Filename) - } -} - -func TestReplaceManifest(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - manifests := []*munki.Manifest{ - &munki.Manifest{ - Filename: "replace-manifest", - Catalogs: []string{"production", "testing"}, - }, - } - - for _, m := range manifests { - os.Remove("testdata/testrepo/manifests/" + m.Filename) - testCreateManifestHTTP(t, server, m.Filename, m, http.StatusOK) - testReplaceManifestHTTP(t, server, m.Filename, m, http.StatusOK) - os.Remove("testdata/testrepo/manifests/" + m.Filename) - } -} - -func TestDeleteManifest(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - manifests := []*munki.Manifest{ - &munki.Manifest{ - Filename: "del-manifest", - Catalogs: []string{"production", "testing"}, - }, - } - for _, m := range manifests { - os.Remove("testdata/testrepo/manifests/" + m.Filename) - testCreateManifestHTTP(t, server, m.Filename, m, http.StatusOK) - testDeleteManifestHTTP(t, server, m.Filename, http.StatusOK) - } -} - -func TestCreateManifest(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - manifests := []*munki.Manifest{ - &munki.Manifest{ - Filename: "foo-manifest", - Catalogs: []string{"production", "testing"}, - }, - } - - for _, m := range manifests { - testCreateManifestHTTP(t, server, m.Filename, m, http.StatusOK) - os.Remove("testdata/testrepo/manifests/" + m.Filename) - } -} - -type createManifestRequest struct { - Filename string `plist:"filename" json:"filename"` - *munki.Manifest -} - -func testCreateManifestHTTP(t *testing.T, server *httptest.Server, filename string, manifest *munki.Manifest, expectedStatus int) *munki.Manifest { - client := http.DefaultClient - theURL := server.URL + "/api/v1/manifests" - var req = &createManifestRequest{ - Filename: filename, - Manifest: manifest, - } - data, err := json.Marshal(req) - if err != nil { - t.Fatal(err) - } - body := ioutil.NopCloser(bytes.NewBuffer(data)) - resp, err := client.Post(theURL, "application/json", body) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } - - return nil -} - -func testReplaceManifestHTTP(t *testing.T, server *httptest.Server, path string, m *munki.Manifest, expectedStatus int) { - client := http.DefaultClient - theURL := server.URL + "/api/v1/manifests/" + path - data, err := json.Marshal(m) - if err != nil { - t.Fatal(err) - } - body := ioutil.NopCloser(bytes.NewBuffer(data)) - req, err := http.NewRequest("PUT", theURL, body) - if err != nil { - t.Fatal(err) - } - resp, err := client.Do(req) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - fmt.Println(theURL) - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } -} - -func testUpdateManifestHTTP(t *testing.T, server *httptest.Server, path string, m *munki.ManifestPayload, expectedStatus int) { - client := http.DefaultClient - theURL := server.URL + "/api/v1/manifests/" + path - data, err := json.Marshal(m) - if err != nil { - t.Fatal(err) - } - body := ioutil.NopCloser(bytes.NewBuffer(data)) - req, err := http.NewRequest("PATCH", theURL, body) - if err != nil { - t.Fatal(err) - } - resp, err := client.Do(req) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - fmt.Println(theURL) - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } -} - -func testDeleteManifestHTTP(t *testing.T, server *httptest.Server, path string, expectedStatus int) { - client := http.DefaultClient - theURL := server.URL + "/api/v1/manifests/" + path - req, err := http.NewRequest("DELETE", theURL, nil) - if err != nil { - t.Fatal(err) - } - resp, err := client.Do(req) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - fmt.Println(theURL) - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } -} - -func testShowManifestHTTP(t *testing.T, server *httptest.Server, path string, expectedStatus int) *munki.Manifest { - client := http.DefaultClient - theURL := server.URL + "/api/v1/manifests/" + path - resp, err := client.Get(theURL) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - fmt.Println(theURL) - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } - return nil -} - -func testListManifestsHTTP(t *testing.T, server *httptest.Server, expectedStatus int) *munki.ManifestCollection { - client := http.DefaultClient - theURL := server.URL + "/api/v1/manifests" - resp, err := client.Get(theURL) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } - return nil -} diff --git a/munki/server/transport_pkgsinfo.go b/munki/server/transport_pkgsinfo.go deleted file mode 100644 index 68a2b16..0000000 --- a/munki/server/transport_pkgsinfo.go +++ /dev/null @@ -1,20 +0,0 @@ -package munkiserver - -import ( - "encoding/json" - "net/http" - - "golang.org/x/net/context" -) - -func decodeListPkgsinfosRequest(_ context.Context, r *http.Request) (interface{}, error) { - return listPkgsinfosRequest{}, nil -} - -func decodeCreatePkgsinfoRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request createPkgsinfoRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} diff --git a/munki/server/transport_pkgsinfo_test.go b/munki/server/transport_pkgsinfo_test.go deleted file mode 100644 index b9ba650..0000000 --- a/munki/server/transport_pkgsinfo_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package munkiserver_test - -import ( - "bytes" - "encoding/json" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/micromdm/squirrel/munki/munki" -) - -func TestListPkgsinfos(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - - testListPkgsinfosHTTP(t, server, http.StatusOK) -} - -func testListPkgsinfosHTTP(t *testing.T, server *httptest.Server, expectedStatus int) *munki.PkgsInfoCollection { - client := http.DefaultClient - theURL := server.URL + "/api/v1/pkgsinfos" - resp, err := client.Get(theURL) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } - return nil -} - -func TestCreatePkgsinfo(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - pkgsinfos := []*munki.PkgsInfo{ - &munki.PkgsInfo{ - Filename: "foo-pkgsinfo", - }, - } - - for _, p := range pkgsinfos { - testCreatePkgsinfoHTTP(t, server, p.Filename, p, http.StatusOK) - os.Remove("testdata/testrepo/pkgsinfo/" + p.Filename) - } -} - -type createPkgsinfoRequest struct { - Filename string `plist:"filename" json:"filename"` - *munki.PkgsInfo -} - -func testCreatePkgsinfoHTTP(t *testing.T, server *httptest.Server, filename string, pkgsinfo *munki.PkgsInfo, expectedStatus int) *munki.PkgsInfo { - client := http.DefaultClient - theURL := server.URL + "/api/v1/pkgsinfos" - var req = &createPkgsinfoRequest{ - Filename: filename, - PkgsInfo: pkgsinfo, - } - data, err := json.Marshal(req) - if err != nil { - t.Fatal(err) - } - body := ioutil.NopCloser(bytes.NewBuffer(data)) - resp, err := client.Post(theURL, "application/json", body) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != expectedStatus { - io.Copy(os.Stdout, resp.Body) - t.Fatal("expected", expectedStatus, "got", resp.StatusCode) - } - - return nil -} diff --git a/munki/server/transport_test.go b/munki/server/transport_test.go deleted file mode 100644 index bf296b1..0000000 --- a/munki/server/transport_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package munkiserver_test - -import ( - "net/http/httptest" - "os" - "testing" - - "github.com/go-kit/kit/log" - "github.com/micromdm/squirrel/munki/datastore" - "github.com/micromdm/squirrel/munki/server" - "golang.org/x/net/context" -) - -func newServer(t *testing.T) (*httptest.Server, munkiserver.Service) { - ctx := context.Background() - l := log.NewLogfmtLogger(os.Stderr) - logger := log.NewContext(l).With("source", "testing") - path := "testdata/testrepo" - repo := &datastore.SimpleRepo{Path: path} - svc, err := munkiserver.NewService(repo) - if err != nil { - t.Fatal(err) - } - handler := munkiserver.ServiceHandler(ctx, svc, logger) - server := httptest.NewServer(handler) - return server, svc -} diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/LICENSE b/vendor/git.schwanenlied.me/yawning/chacha20.git/LICENSE deleted file mode 100644 index 6ca207e..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/LICENSE +++ /dev/null @@ -1,122 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. - diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/README.md b/vendor/git.schwanenlied.me/yawning/chacha20.git/README.md deleted file mode 100644 index 9080a84..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/README.md +++ /dev/null @@ -1,14 +0,0 @@ -### chacha20 - ChaCha20 -#### Yawning Angel (yawning at schwanenlied dot me) - -Yet another Go ChaCha20 implementation. Everything else I found was slow, -didn't support all the variants I need to use, or relied on cgo to go fast. - -Features: - - * 20 round, 256 bit key only. Everything else is pointless and stupid. - * IETF 96 bit nonce variant. - * XChaCha 24 byte nonce variant. - * SSE2 and AVX2 support on amd64 targets. - * Incremental encrypt/decrypt support, unlike golang.org/x/crypto/salsa20. - diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20.go b/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20.go deleted file mode 100644 index 07d5e4b..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20.go +++ /dev/null @@ -1,273 +0,0 @@ -// chacha20.go - A ChaCha stream cipher implementation. -// -// To the extent possible under law, Yawning Angel has waived all copyright -// and related or neighboring rights to chacha20, using the Creative -// Commons "CC0" public domain dedication. See LICENSE or -// for full details. - -package chacha20 - -import ( - "crypto/cipher" - "encoding/binary" - "errors" - "math" - "runtime" -) - -const ( - // KeySize is the ChaCha20 key size in bytes. - KeySize = 32 - - // NonceSize is the ChaCha20 nonce size in bytes. - NonceSize = 8 - - // INonceSize is the IETF ChaCha20 nonce size in bytes. - INonceSize = 12 - - // XNonceSize is the XChaCha20 nonce size in bytes. - XNonceSize = 24 - - // HNonceSize is the HChaCha20 nonce size in bytes. - HNonceSize = 16 - - // BlockSize is the ChaCha20 block size in bytes. - BlockSize = 64 - - stateSize = 16 - chachaRounds = 20 - - // The constant "expand 32-byte k" as little endian uint32s. - sigma0 = uint32(0x61707865) - sigma1 = uint32(0x3320646e) - sigma2 = uint32(0x79622d32) - sigma3 = uint32(0x6b206574) -) - -var ( - // ErrInvalidKey is the error returned when the key is invalid. - ErrInvalidKey = errors.New("key length must be KeySize bytes") - - // ErrInvalidNonce is the error returned when the nonce is invalid. - ErrInvalidNonce = errors.New("nonce length must be NonceSize/INonceSize/XNonceSize bytes") - - // ErrInvalidCounter is the error returned when the counter is invalid. - ErrInvalidCounter = errors.New("block counter is invalid (out of range)") - - useUnsafe = false - usingVectors = false - blocksFn = blocksRef -) - -// A Cipher is an instance of ChaCha20/XChaCha20 using a particular key and -// nonce. -type Cipher struct { - state [stateSize]uint32 - - buf [BlockSize]byte - off int - ietf bool -} - -// Reset zeros the key data so that it will no longer appear in the process's -// memory. -func (c *Cipher) Reset() { - for i := range c.state { - c.state[i] = 0 - } - for i := range c.buf { - c.buf[i] = 0 - } -} - -// XORKeyStream sets dst to the result of XORing src with the key stream. Dst -// and src may be the same slice but otherwise should not overlap. -func (c *Cipher) XORKeyStream(dst, src []byte) { - if len(dst) < len(src) { - src = src[:len(dst)] - } - - for remaining := len(src); remaining > 0; { - // Process multiple blocks at once. - if c.off == BlockSize { - nrBlocks := remaining / BlockSize - directBytes := nrBlocks * BlockSize - if nrBlocks > 0 { - blocksFn(&c.state, src, dst, nrBlocks, c.ietf) - remaining -= directBytes - if remaining == 0 { - return - } - dst = dst[directBytes:] - src = src[directBytes:] - } - - // If there's a partial block, generate 1 block of keystream into - // the internal buffer. - blocksFn(&c.state, nil, c.buf[:], 1, c.ietf) - c.off = 0 - } - - // Process partial blocks from the buffered keystream. - toXor := BlockSize - c.off - if remaining < toXor { - toXor = remaining - } - if toXor > 0 { - for i, v := range src[:toXor] { - dst[i] = v ^ c.buf[c.off+i] - } - dst = dst[toXor:] - src = src[toXor:] - - remaining -= toXor - c.off += toXor - } - } -} - -// KeyStream sets dst to the raw keystream. -func (c *Cipher) KeyStream(dst []byte) { - for remaining := len(dst); remaining > 0; { - // Process multiple blocks at once. - if c.off == BlockSize { - nrBlocks := remaining / BlockSize - directBytes := nrBlocks * BlockSize - if nrBlocks > 0 { - blocksFn(&c.state, nil, dst, nrBlocks, c.ietf) - remaining -= directBytes - if remaining == 0 { - return - } - dst = dst[directBytes:] - } - - // If there's a partial block, generate 1 block of keystream into - // the internal buffer. - blocksFn(&c.state, nil, c.buf[:], 1, c.ietf) - c.off = 0 - } - - // Process partial blocks from the buffered keystream. - toCopy := BlockSize - c.off - if remaining < toCopy { - toCopy = remaining - } - if toCopy > 0 { - copy(dst[:toCopy], c.buf[c.off:c.off+toCopy]) - dst = dst[toCopy:] - remaining -= toCopy - c.off += toCopy - } - } -} - -// ReKey reinitializes the ChaCha20/XChaCha20 instance with the provided key -// and nonce. -func (c *Cipher) ReKey(key, nonce []byte) error { - if len(key) != KeySize { - return ErrInvalidKey - } - - switch len(nonce) { - case NonceSize: - case INonceSize: - case XNonceSize: - var subkey [KeySize]byte - var subnonce [HNonceSize]byte - copy(subnonce[:], nonce[0:16]) - HChaCha(key, &subnonce, &subkey) - key = subkey[:] - nonce = nonce[16:24] - defer func() { - for i := range subkey { - subkey[i] = 0 - } - }() - default: - return ErrInvalidNonce - } - - c.Reset() - c.state[0] = sigma0 - c.state[1] = sigma1 - c.state[2] = sigma2 - c.state[3] = sigma3 - c.state[4] = binary.LittleEndian.Uint32(key[0:4]) - c.state[5] = binary.LittleEndian.Uint32(key[4:8]) - c.state[6] = binary.LittleEndian.Uint32(key[8:12]) - c.state[7] = binary.LittleEndian.Uint32(key[12:16]) - c.state[8] = binary.LittleEndian.Uint32(key[16:20]) - c.state[9] = binary.LittleEndian.Uint32(key[20:24]) - c.state[10] = binary.LittleEndian.Uint32(key[24:28]) - c.state[11] = binary.LittleEndian.Uint32(key[28:32]) - c.state[12] = 0 - if len(nonce) == INonceSize { - c.state[13] = binary.LittleEndian.Uint32(nonce[0:4]) - c.state[14] = binary.LittleEndian.Uint32(nonce[4:8]) - c.state[15] = binary.LittleEndian.Uint32(nonce[8:12]) - c.ietf = true - } else { - c.state[13] = 0 - c.state[14] = binary.LittleEndian.Uint32(nonce[0:4]) - c.state[15] = binary.LittleEndian.Uint32(nonce[4:8]) - c.ietf = false - } - c.off = BlockSize - return nil - -} - -// Seek sets the block counter to a given offset. -func (c *Cipher) Seek(blockCounter uint64) error { - if c.ietf { - if blockCounter > math.MaxUint32 { - return ErrInvalidCounter - } - c.state[12] = uint32(blockCounter) - } else { - c.state[12] = uint32(blockCounter) - c.state[13] = uint32(blockCounter >> 32) - } - c.off = BlockSize - return nil -} - -// NewCipher returns a new ChaCha20/XChaCha20 instance. -func NewCipher(key, nonce []byte) (*Cipher, error) { - c := new(Cipher) - if err := c.ReKey(key, nonce); err != nil { - return nil, err - } - return c, nil -} - -// HChaCha is the HChaCha20 hash function used to make XChaCha. -func HChaCha(key []byte, nonce *[HNonceSize]byte, out *[32]byte) { - var x [stateSize]uint32 // Last 4 slots unused, sigma hardcoded. - x[0] = binary.LittleEndian.Uint32(key[0:4]) - x[1] = binary.LittleEndian.Uint32(key[4:8]) - x[2] = binary.LittleEndian.Uint32(key[8:12]) - x[3] = binary.LittleEndian.Uint32(key[12:16]) - x[4] = binary.LittleEndian.Uint32(key[16:20]) - x[5] = binary.LittleEndian.Uint32(key[20:24]) - x[6] = binary.LittleEndian.Uint32(key[24:28]) - x[7] = binary.LittleEndian.Uint32(key[28:32]) - x[8] = binary.LittleEndian.Uint32(nonce[0:4]) - x[9] = binary.LittleEndian.Uint32(nonce[4:8]) - x[10] = binary.LittleEndian.Uint32(nonce[8:12]) - x[11] = binary.LittleEndian.Uint32(nonce[12:16]) - hChaChaRef(&x, out) -} - -func init() { - switch runtime.GOARCH { - case "386", "amd64": - // Abuse unsafe to skip calling binary.LittleEndian.PutUint32 - // in the critical path. This is a big boost on systems that are - // little endian and not overly picky about alignment. - useUnsafe = true - } -} - -var _ cipher.Stream = (*Cipher)(nil) diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.go b/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.go deleted file mode 100644 index b2c8623..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.go +++ /dev/null @@ -1,95 +0,0 @@ -// chacha20_amd64.go - AMD64 optimized chacha20. -// -// To the extent possible under law, Yawning Angel has waived all copyright -// and related or neighboring rights to chacha20, using the Creative -// Commons "CC0" public domain dedication. See LICENSE or -// for full details. - -// +build amd64,!gccgo,!appengine - -package chacha20 - -import ( - "math" -) - -var usingAVX2 = false - -func blocksAmd64SSE2(x *uint32, inp, outp *byte, nrBlocks uint) - -func blocksAmd64AVX2(x *uint32, inp, outp *byte, nrBlocks uint) - -func cpuidAmd64(cpuidParams *uint32) - -func xgetbv0Amd64(xcrVec *uint32) - -func blocksAmd64(x *[stateSize]uint32, in []byte, out []byte, nrBlocks int, isIetf bool) { - // Probably unneeded, but stating this explicitly simplifies the assembly. - if nrBlocks == 0 { - return - } - - if isIetf { - var totalBlocks uint64 - totalBlocks = uint64(x[8]) + uint64(nrBlocks) - if totalBlocks > math.MaxUint32 { - panic("chacha20: Exceeded keystream per nonce limit") - } - } - - if in == nil { - for i := range out { - out[i] = 0 - } - in = out - } - - // Pointless to call the AVX2 code for just a single block, since half of - // the output gets discarded... - if usingAVX2 && nrBlocks > 1 { - blocksAmd64AVX2(&x[0], &in[0], &out[0], uint(nrBlocks)) - } else { - blocksAmd64SSE2(&x[0], &in[0], &out[0], uint(nrBlocks)) - } -} - -func supportsAVX2() bool { - // https://software.intel.com/en-us/articles/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family - const ( - osXsaveBit = 1 << 27 - avx2Bit = 1 << 5 - ) - - // Check to see if CPUID actually supports the leaf that indicates AVX2. - // CPUID.(EAX=0H, ECX=0H) >= 7 - regs := [4]uint32{0x00} - cpuidAmd64(®s[0]) - if regs[0] < 7 { - return false - } - - // Check to see if the OS knows how to save/restore XMM/YMM state. - // CPUID.(EAX=01H, ECX=0H):ECX.OSXSAVE[bit 27]==1 - regs = [4]uint32{0x01} - cpuidAmd64(®s[0]) - if regs[2]&osXsaveBit == 0 { - return false - } - xcrRegs := [2]uint32{} - xgetbv0Amd64(&xcrRegs[0]) - if xcrRegs[0]&6 != 6 { - return false - } - - // Check for AVX2 support. - // CPUID.(EAX=07H, ECX=0H):EBX.AVX2[bit 5]==1 - regs = [4]uint32{0x07} - cpuidAmd64(®s[0]) - return regs[1]&avx2Bit != 0 -} - -func init() { - blocksFn = blocksAmd64 - usingVectors = true - usingAVX2 = supportsAVX2() -} diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.py b/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.py deleted file mode 100644 index 5b689d1..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.py +++ /dev/null @@ -1,1303 +0,0 @@ -#!/usr/bin/env python3 -# -# To the extent possible under law, Yawning Angel has waived all copyright -# and related or neighboring rights to chacha20, using the Creative -# Commons "CC0" public domain dedication. See LICENSE or -# for full details. - -# -# cgo sucks. Plan 9 assembly sucks. Real languages have SIMD intrinsics. -# The least terrible/retarded option is to use a Python code generator, so -# that's what I did. -# -# Code based on Ted Krovetz's vec128 C implementation, with corrections -# to use a 64 bit counter instead of 32 bit, and to allow unaligned input and -# output pointers. -# -# Dependencies: https://github.com/Maratyszcza/PeachPy -# -# python3 -m peachpy.x86_64 -mabi=goasm -S -o chacha20_amd64.s chacha20_amd64.py -# - -from peachpy import * -from peachpy.x86_64 import * - -x = Argument(ptr(uint32_t)) -inp = Argument(ptr(const_uint8_t)) -outp = Argument(ptr(uint8_t)) -nrBlocks = Argument(ptr(size_t)) - -# -# SSE2 helper functions. A temporary register is explicitly passed in because -# the main fast loop uses every single register (and even spills) so manual -# control is needed. -# -# This used to also have a DQROUNDS helper that did 2 rounds of ChaCha like -# in the C code, but the C code has the luxury of an optimizer reordering -# everything, while this does not. -# - -def ROTW16_sse2(tmp, d): - MOVDQA(tmp, d) - PSLLD(tmp, 16) - PSRLD(d, 16) - PXOR(d, tmp) - -def ROTW12_sse2(tmp, b): - MOVDQA(tmp, b) - PSLLD(tmp, 12) - PSRLD(b, 20) - PXOR(b, tmp) - -def ROTW8_sse2(tmp, d): - MOVDQA(tmp, d) - PSLLD(tmp, 8) - PSRLD(d, 24) - PXOR(d, tmp) - -def ROTW7_sse2(tmp, b): - MOVDQA(tmp, b) - PSLLD(tmp, 7) - PSRLD(b, 25) - PXOR(b, tmp) - -def WriteXor_sse2(tmp, inp, outp, d, v0, v1, v2, v3): - MOVDQU(tmp, [inp+d]) - PXOR(tmp, v0) - MOVDQU([outp+d], tmp) - MOVDQU(tmp, [inp+d+16]) - PXOR(tmp, v1) - MOVDQU([outp+d+16], tmp) - MOVDQU(tmp, [inp+d+32]) - PXOR(tmp, v2) - MOVDQU([outp+d+32], tmp) - MOVDQU(tmp, [inp+d+48]) - PXOR(tmp, v3) - MOVDQU([outp+d+48], tmp) - -# SSE2 ChaCha20 (aka vec128). Does not handle partial blocks, and will -# process 4/2/1 blocks at a time. x (the ChaCha20 state) must be 16 byte -# aligned. -with Function("blocksAmd64SSE2", (x, inp, outp, nrBlocks)): - reg_x = GeneralPurposeRegister64() - reg_inp = GeneralPurposeRegister64() - reg_outp = GeneralPurposeRegister64() - reg_blocks = GeneralPurposeRegister64() - reg_sp_save = GeneralPurposeRegister64() - - LOAD.ARGUMENT(reg_x, x) - LOAD.ARGUMENT(reg_inp, inp) - LOAD.ARGUMENT(reg_outp, outp) - LOAD.ARGUMENT(reg_blocks, nrBlocks) - - # Align the stack to a 32 byte boundary. - reg_align = GeneralPurposeRegister64() - MOV(reg_sp_save, registers.rsp) - MOV(reg_align, 0x1f) - NOT(reg_align) - AND(registers.rsp, reg_align) - SUB(registers.rsp, 0x20) - - # Build the counter increment vector on the stack, and allocate the scratch - # space - xmm_v0 = XMMRegister() - PXOR(xmm_v0, xmm_v0) - SUB(registers.rsp, 16+16) - MOVDQA([registers.rsp], xmm_v0) - reg_tmp = GeneralPurposeRegister32() - MOV(reg_tmp, 0x00000001) - MOV([registers.rsp], reg_tmp) - mem_one = [registers.rsp] # (Stack) Counter increment vector - mem_tmp0 = [registers.rsp+16] # (Stack) Scratch space. - - mem_s0 = [reg_x] # (Memory) Cipher state [0..3] - mem_s1 = [reg_x+16] # (Memory) Cipher state [4..7] - mem_s2 = [reg_x+32] # (Memory) Cipher state [8..11] - mem_s3 = [reg_x+48] # (Memory) Cipher state [12..15] - - # xmm_v0 allocated above... - xmm_v1 = XMMRegister() - xmm_v2 = XMMRegister() - xmm_v3 = XMMRegister() - - xmm_v4 = XMMRegister() - xmm_v5 = XMMRegister() - xmm_v6 = XMMRegister() - xmm_v7 = XMMRegister() - - xmm_v8 = XMMRegister() - xmm_v9 = XMMRegister() - xmm_v10 = XMMRegister() - xmm_v11 = XMMRegister() - - xmm_v12 = XMMRegister() - xmm_v13 = XMMRegister() - xmm_v14 = XMMRegister() - xmm_v15 = XMMRegister() - - xmm_tmp = xmm_v12 - - # - # 4 blocks at a time. - # - - vector_loop4 = Loop() - SUB(reg_blocks, 4) - JB(vector_loop4.end) - with vector_loop4: - MOVDQA(xmm_v0, mem_s0) - MOVDQA(xmm_v1, mem_s1) - MOVDQA(xmm_v2, mem_s2) - MOVDQA(xmm_v3, mem_s3) - - MOVDQA(xmm_v4, xmm_v0) - MOVDQA(xmm_v5, xmm_v1) - MOVDQA(xmm_v6, xmm_v2) - MOVDQA(xmm_v7, xmm_v3) - PADDQ(xmm_v7, mem_one) - - MOVDQA(xmm_v8, xmm_v0) - MOVDQA(xmm_v9, xmm_v1) - MOVDQA(xmm_v10, xmm_v2) - MOVDQA(xmm_v11, xmm_v7) - PADDQ(xmm_v11, mem_one) - - MOVDQA(xmm_v12, xmm_v0) - MOVDQA(xmm_v13, xmm_v1) - MOVDQA(xmm_v14, xmm_v2) - MOVDQA(xmm_v15, xmm_v11) - PADDQ(xmm_v15, mem_one) - - reg_rounds = GeneralPurposeRegister64() - MOV(reg_rounds, 20) - rounds_loop4 = Loop() - with rounds_loop4: - # a += b; d ^= a; d = ROTW16(d); - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PADDD(xmm_v8, xmm_v9) - PADDD(xmm_v12, xmm_v13) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - PXOR(xmm_v11, xmm_v8) - PXOR(xmm_v15, xmm_v12) - - MOVDQA(mem_tmp0, xmm_tmp) # Save - - ROTW16_sse2(xmm_tmp, xmm_v3) - ROTW16_sse2(xmm_tmp, xmm_v7) - ROTW16_sse2(xmm_tmp, xmm_v11) - ROTW16_sse2(xmm_tmp, xmm_v15) - - # c += d; b ^= c; b = ROTW12(b); - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PADDD(xmm_v10, xmm_v11) - PADDD(xmm_v14, xmm_v15) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - PXOR(xmm_v9, xmm_v10) - PXOR(xmm_v13, xmm_v14) - ROTW12_sse2(xmm_tmp, xmm_v1) - ROTW12_sse2(xmm_tmp, xmm_v5) - ROTW12_sse2(xmm_tmp, xmm_v9) - ROTW12_sse2(xmm_tmp, xmm_v13) - - # a += b; d ^= a; d = ROTW8(d); - MOVDQA(xmm_tmp, mem_tmp0) # Restore - - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PADDD(xmm_v8, xmm_v9) - PADDD(xmm_v12, xmm_v13) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - PXOR(xmm_v11, xmm_v8) - PXOR(xmm_v15, xmm_v12) - - MOVDQA(mem_tmp0, xmm_tmp) # Save - - ROTW8_sse2(xmm_tmp, xmm_v3) - ROTW8_sse2(xmm_tmp, xmm_v7) - ROTW8_sse2(xmm_tmp, xmm_v11) - ROTW8_sse2(xmm_tmp, xmm_v15) - - # c += d; b ^= c; b = ROTW7(b) - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PADDD(xmm_v10, xmm_v11) - PADDD(xmm_v14, xmm_v15) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - PXOR(xmm_v9, xmm_v10) - PXOR(xmm_v13, xmm_v14) - ROTW7_sse2(xmm_tmp, xmm_v1) - ROTW7_sse2(xmm_tmp, xmm_v5) - ROTW7_sse2(xmm_tmp, xmm_v9) - ROTW7_sse2(xmm_tmp, xmm_v13) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - PSHUFD(xmm_v1, xmm_v1, 0x39) - PSHUFD(xmm_v5, xmm_v5, 0x39) - PSHUFD(xmm_v9, xmm_v9, 0x39) - PSHUFD(xmm_v13, xmm_v13, 0x39) - PSHUFD(xmm_v2, xmm_v2, 0x4e) - PSHUFD(xmm_v6, xmm_v6, 0x4e) - PSHUFD(xmm_v10, xmm_v10, 0x4e) - PSHUFD(xmm_v14, xmm_v14, 0x4e) - PSHUFD(xmm_v3, xmm_v3, 0x93) - PSHUFD(xmm_v7, xmm_v7, 0x93) - PSHUFD(xmm_v11, xmm_v11, 0x93) - PSHUFD(xmm_v15, xmm_v15, 0x93) - - MOVDQA(xmm_tmp, mem_tmp0) # Restore - - # a += b; d ^= a; d = ROTW16(d); - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PADDD(xmm_v8, xmm_v9) - PADDD(xmm_v12, xmm_v13) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - PXOR(xmm_v11, xmm_v8) - PXOR(xmm_v15, xmm_v12) - - MOVDQA(mem_tmp0, xmm_tmp) # Save - - ROTW16_sse2(xmm_tmp, xmm_v3) - ROTW16_sse2(xmm_tmp, xmm_v7) - ROTW16_sse2(xmm_tmp, xmm_v11) - ROTW16_sse2(xmm_tmp, xmm_v15) - - # c += d; b ^= c; b = ROTW12(b); - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PADDD(xmm_v10, xmm_v11) - PADDD(xmm_v14, xmm_v15) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - PXOR(xmm_v9, xmm_v10) - PXOR(xmm_v13, xmm_v14) - ROTW12_sse2(xmm_tmp, xmm_v1) - ROTW12_sse2(xmm_tmp, xmm_v5) - ROTW12_sse2(xmm_tmp, xmm_v9) - ROTW12_sse2(xmm_tmp, xmm_v13) - - # a += b; d ^= a; d = ROTW8(d); - MOVDQA(xmm_tmp, mem_tmp0) # Restore - - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PADDD(xmm_v8, xmm_v9) - PADDD(xmm_v12, xmm_v13) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - PXOR(xmm_v11, xmm_v8) - PXOR(xmm_v15, xmm_v12) - - MOVDQA(mem_tmp0, xmm_tmp) # Save - - ROTW8_sse2(xmm_tmp, xmm_v3) - ROTW8_sse2(xmm_tmp, xmm_v7) - ROTW8_sse2(xmm_tmp, xmm_v11) - ROTW8_sse2(xmm_tmp, xmm_v15) - - # c += d; b ^= c; b = ROTW7(b) - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PADDD(xmm_v10, xmm_v11) - PADDD(xmm_v14, xmm_v15) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - PXOR(xmm_v9, xmm_v10) - PXOR(xmm_v13, xmm_v14) - ROTW7_sse2(xmm_tmp, xmm_v1) - ROTW7_sse2(xmm_tmp, xmm_v5) - ROTW7_sse2(xmm_tmp, xmm_v9) - ROTW7_sse2(xmm_tmp, xmm_v13) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - PSHUFD(xmm_v1, xmm_v1, 0x93) - PSHUFD(xmm_v5, xmm_v5, 0x93) - PSHUFD(xmm_v9, xmm_v9, 0x93) - PSHUFD(xmm_v13, xmm_v13, 0x93) - PSHUFD(xmm_v2, xmm_v2, 0x4e) - PSHUFD(xmm_v6, xmm_v6, 0x4e) - PSHUFD(xmm_v10, xmm_v10, 0x4e) - PSHUFD(xmm_v14, xmm_v14, 0x4e) - PSHUFD(xmm_v3, xmm_v3, 0x39) - PSHUFD(xmm_v7, xmm_v7, 0x39) - PSHUFD(xmm_v11, xmm_v11, 0x39) - PSHUFD(xmm_v15, xmm_v15, 0x39) - - MOVDQA(xmm_tmp, mem_tmp0) # Restore - - SUB(reg_rounds, 2) - JNZ(rounds_loop4.begin) - - MOVDQA(mem_tmp0, xmm_tmp) - - PADDD(xmm_v0, mem_s0) - PADDD(xmm_v1, mem_s1) - PADDD(xmm_v2, mem_s2) - PADDD(xmm_v3, mem_s3) - WriteXor_sse2(xmm_tmp, reg_inp, reg_outp, 0, xmm_v0, xmm_v1, xmm_v2, xmm_v3) - MOVDQA(xmm_v3, mem_s3) - PADDQ(xmm_v3, mem_one) - - PADDD(xmm_v4, mem_s0) - PADDD(xmm_v5, mem_s1) - PADDD(xmm_v6, mem_s2) - PADDD(xmm_v7, xmm_v3) - WriteXor_sse2(xmm_tmp, reg_inp, reg_outp, 64, xmm_v4, xmm_v5, xmm_v6, xmm_v7) - PADDQ(xmm_v3, mem_one) - - PADDD(xmm_v8, mem_s0) - PADDD(xmm_v9, mem_s1) - PADDD(xmm_v10, mem_s2) - PADDD(xmm_v11, xmm_v3) - WriteXor_sse2(xmm_tmp, reg_inp, reg_outp, 128, xmm_v8, xmm_v9, xmm_v10, xmm_v11) - PADDQ(xmm_v3, mem_one) - - MOVDQA(xmm_tmp, mem_tmp0) - - PADDD(xmm_v12, mem_s0) - PADDD(xmm_v13, mem_s1) - PADDD(xmm_v14, mem_s2) - PADDD(xmm_v15, xmm_v3) - WriteXor_sse2(xmm_v0, reg_inp, reg_outp, 192, xmm_v12, xmm_v13, xmm_v14, xmm_v15) - PADDQ(xmm_v3, mem_one) - - MOVDQA(mem_s3, xmm_v3) - - ADD(reg_inp, 4 * 64) - ADD(reg_outp, 4 * 64) - - SUB(reg_blocks, 4) - JAE(vector_loop4.begin) - - ADD(reg_blocks, 4) - out = Label() - JZ(out) - - # Past this point, we no longer need to use every single register to hold - # the in progress state. - - xmm_s0 = xmm_v8 - xmm_s1 = xmm_v9 - xmm_s2 = xmm_v10 - xmm_s3 = xmm_v11 - xmm_one = xmm_v13 - MOVDQA(xmm_s0, mem_s0) - MOVDQA(xmm_s1, mem_s1) - MOVDQA(xmm_s2, mem_s2) - MOVDQA(xmm_s3, mem_s3) - MOVDQA(xmm_one, mem_one) - - # - # 2 blocks at a time. - # - - SUB(reg_blocks, 2) - vector_loop2 = Loop() - JB(vector_loop2.end) - with vector_loop2: - MOVDQA(xmm_v0, xmm_s0) - MOVDQA(xmm_v1, xmm_s1) - MOVDQA(xmm_v2, xmm_s2) - MOVDQA(xmm_v3, xmm_s3) - - MOVDQA(xmm_v4, xmm_v0) - MOVDQA(xmm_v5, xmm_v1) - MOVDQA(xmm_v6, xmm_v2) - MOVDQA(xmm_v7, xmm_v3) - PADDQ(xmm_v7, xmm_one) - - reg_rounds = GeneralPurposeRegister64() - MOV(reg_rounds, 20) - rounds_loop2 = Loop() - with rounds_loop2: - # a += b; d ^= a; d = ROTW16(d); - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - ROTW16_sse2(xmm_tmp, xmm_v3) - ROTW16_sse2(xmm_tmp, xmm_v7) - - # c += d; b ^= c; b = ROTW12(b); - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - ROTW12_sse2(xmm_tmp, xmm_v1) - ROTW12_sse2(xmm_tmp, xmm_v5) - - # a += b; d ^= a; d = ROTW8(d); - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - ROTW8_sse2(xmm_tmp, xmm_v3) - ROTW8_sse2(xmm_tmp, xmm_v7) - - # c += d; b ^= c; b = ROTW7(b) - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - ROTW7_sse2(xmm_tmp, xmm_v1) - ROTW7_sse2(xmm_tmp, xmm_v5) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - PSHUFD(xmm_v1, xmm_v1, 0x39) - PSHUFD(xmm_v5, xmm_v5, 0x39) - PSHUFD(xmm_v2, xmm_v2, 0x4e) - PSHUFD(xmm_v6, xmm_v6, 0x4e) - PSHUFD(xmm_v3, xmm_v3, 0x93) - PSHUFD(xmm_v7, xmm_v7, 0x93) - - # a += b; d ^= a; d = ROTW16(d); - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - ROTW16_sse2(xmm_tmp, xmm_v3) - ROTW16_sse2(xmm_tmp, xmm_v7) - - # c += d; b ^= c; b = ROTW12(b); - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - ROTW12_sse2(xmm_tmp, xmm_v1) - ROTW12_sse2(xmm_tmp, xmm_v5) - - # a += b; d ^= a; d = ROTW8(d); - PADDD(xmm_v0, xmm_v1) - PADDD(xmm_v4, xmm_v5) - PXOR(xmm_v3, xmm_v0) - PXOR(xmm_v7, xmm_v4) - ROTW8_sse2(xmm_tmp, xmm_v3) - ROTW8_sse2(xmm_tmp, xmm_v7) - - # c += d; b ^= c; b = ROTW7(b) - PADDD(xmm_v2, xmm_v3) - PADDD(xmm_v6, xmm_v7) - PXOR(xmm_v1, xmm_v2) - PXOR(xmm_v5, xmm_v6) - ROTW7_sse2(xmm_tmp, xmm_v1) - ROTW7_sse2(xmm_tmp, xmm_v5) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - PSHUFD(xmm_v1, xmm_v1, 0x93) - PSHUFD(xmm_v5, xmm_v5, 0x93) - PSHUFD(xmm_v2, xmm_v2, 0x4e) - PSHUFD(xmm_v6, xmm_v6, 0x4e) - PSHUFD(xmm_v3, xmm_v3, 0x39) - PSHUFD(xmm_v7, xmm_v7, 0x39) - - SUB(reg_rounds, 2) - JNZ(rounds_loop2.begin) - - PADDD(xmm_v0, xmm_s0) - PADDD(xmm_v1, xmm_s1) - PADDD(xmm_v2, xmm_s2) - PADDD(xmm_v3, xmm_s3) - WriteXor_sse2(xmm_tmp, reg_inp, reg_outp, 0, xmm_v0, xmm_v1, xmm_v2, xmm_v3) - PADDQ(xmm_s3, xmm_one) - - PADDD(xmm_v4, xmm_s0) - PADDD(xmm_v5, xmm_s1) - PADDD(xmm_v6, xmm_s2) - PADDD(xmm_v7, xmm_s3) - WriteXor_sse2(xmm_tmp, reg_inp, reg_outp, 64, xmm_v4, xmm_v5, xmm_v6, xmm_v7) - PADDQ(xmm_s3, xmm_one) - - ADD(reg_inp, 2 * 64) - ADD(reg_outp, 2 * 64) - - SUB(reg_blocks, 2) - JAE(vector_loop2.begin) - - ADD(reg_blocks, 2) - out_serial = Label() - JZ(out_serial) - - # - # 1 block at a time. Only executed once, because if there was > 1, - # the parallel code would have processed it already. - # - - MOVDQA(xmm_v0, xmm_s0) - MOVDQA(xmm_v1, xmm_s1) - MOVDQA(xmm_v2, xmm_s2) - MOVDQA(xmm_v3, xmm_s3) - - reg_rounds = GeneralPurposeRegister64() - MOV(reg_rounds, 20) - rounds_loop1 = Loop() - with rounds_loop1: - # a += b; d ^= a; d = ROTW16(d); - PADDD(xmm_v0, xmm_v1) - PXOR(xmm_v3, xmm_v0) - ROTW16_sse2(xmm_tmp, xmm_v3) - - # c += d; b ^= c; b = ROTW12(b); - PADDD(xmm_v2, xmm_v3) - PXOR(xmm_v1, xmm_v2) - ROTW12_sse2(xmm_tmp, xmm_v1) - - # a += b; d ^= a; d = ROTW8(d); - PADDD(xmm_v0, xmm_v1) - PXOR(xmm_v3, xmm_v0) - ROTW8_sse2(xmm_tmp, xmm_v3) - - # c += d; b ^= c; b = ROTW7(b) - PADDD(xmm_v2, xmm_v3) - PXOR(xmm_v1, xmm_v2) - ROTW7_sse2(xmm_tmp, xmm_v1) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - PSHUFD(xmm_v1, xmm_v1, 0x39) - PSHUFD(xmm_v2, xmm_v2, 0x4e) - PSHUFD(xmm_v3, xmm_v3, 0x93) - - # a += b; d ^= a; d = ROTW16(d); - PADDD(xmm_v0, xmm_v1) - PXOR(xmm_v3, xmm_v0) - ROTW16_sse2(xmm_tmp, xmm_v3) - - # c += d; b ^= c; b = ROTW12(b); - PADDD(xmm_v2, xmm_v3) - PXOR(xmm_v1, xmm_v2) - ROTW12_sse2(xmm_tmp, xmm_v1) - - # a += b; d ^= a; d = ROTW8(d); - PADDD(xmm_v0, xmm_v1) - PXOR(xmm_v3, xmm_v0) - ROTW8_sse2(xmm_tmp, xmm_v3) - - # c += d; b ^= c; b = ROTW7(b) - PADDD(xmm_v2, xmm_v3) - PXOR(xmm_v1, xmm_v2) - ROTW7_sse2(xmm_tmp, xmm_v1) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - PSHUFD(xmm_v1, xmm_v1, 0x93) - PSHUFD(xmm_v2, xmm_v2, 0x4e) - PSHUFD(xmm_v3, xmm_v3, 0x39) - - SUB(reg_rounds, 2) - JNZ(rounds_loop1.begin) - - PADDD(xmm_v0, xmm_s0) - PADDD(xmm_v1, xmm_s1) - PADDD(xmm_v2, xmm_s2) - PADDD(xmm_v3, xmm_s3) - WriteXor_sse2(xmm_tmp, reg_inp, reg_outp, 0, xmm_v0, xmm_v1, xmm_v2, xmm_v3) - PADDQ(xmm_s3, xmm_one) - - LABEL(out_serial) - - # Write back the updated counter. Stoping at 2^70 bytes is the user's - # problem, not mine. (Skipped if there's exactly a multiple of 4 blocks - # because the counter is incremented in memory while looping.) - MOVDQA(mem_s3, xmm_s3) - - LABEL(out) - - # Paranoia, cleanse the scratch space. - PXOR(xmm_v0, xmm_v0) - MOVDQA(mem_tmp0, xmm_v0) - - # Remove our stack allocation. - MOV(registers.rsp, reg_sp_save) - - RETURN() - -# -# AVX2 helpers. Like the SSE2 equivalents, the scratch register is explicit, -# and more helpers are used to increase readability for destructive operations. -# -# XXX/Performance: ROTW16_avx2/ROTW8_avx2 both can use VPSHUFFB. -# - -def ADD_avx2(dst, src): - VPADDD(dst, dst, src) - -def XOR_avx2(dst, src): - VPXOR(dst, dst, src) - -def ROTW16_avx2(tmp, d): - VPSLLD(tmp, d, 16) - VPSRLD(d, d, 16) - XOR_avx2(d, tmp) - -def ROTW12_avx2(tmp, b): - VPSLLD(tmp, b, 12) - VPSRLD(b, b, 20) - XOR_avx2(b, tmp) - -def ROTW8_avx2(tmp, d): - VPSLLD(tmp, d, 8) - VPSRLD(d, d, 24) - XOR_avx2(d, tmp) - -def ROTW7_avx2(tmp, b): - VPSLLD(tmp, b, 7) - VPSRLD(b, b, 25) - XOR_avx2(b, tmp) - -def WriteXor_avx2(tmp, inp, outp, d, v0, v1, v2, v3): - # XOR_WRITE(out+ 0, in+ 0, _mm256_permute2x128_si256(v0,v1,0x20)); - VPERM2I128(tmp, v0, v1, 0x20) - VPXOR(tmp, tmp, [inp+d]) - VMOVDQU([outp+d], tmp) - - # XOR_WRITE(out+32, in+32, _mm256_permute2x128_si256(v2,v3,0x20)); - VPERM2I128(tmp, v2, v3, 0x20) - VPXOR(tmp, tmp, [inp+d+32]) - VMOVDQU([outp+d+32], tmp) - - # XOR_WRITE(out+64, in+64, _mm256_permute2x128_si256(v0,v1,0x31)); - VPERM2I128(tmp, v0, v1, 0x31) - VPXOR(tmp, tmp, [inp+d+64]) - VMOVDQU([outp+d+64], tmp) - - # XOR_WRITE(out+96, in+96, _mm256_permute2x128_si256(v2,v3,0x31)); - VPERM2I128(tmp, v2, v3, 0x31) - VPXOR(tmp, tmp, [inp+d+96]) - VMOVDQU([outp+d+96], tmp) - -# AVX2 ChaCha20 (aka avx2). Does not handle partial blocks, will process -# 8/4/2 blocks at a time. Alignment blah blah blah fuck you. -with Function("blocksAmd64AVX2", (x, inp, outp, nrBlocks), target=uarch.broadwell): - reg_x = GeneralPurposeRegister64() - reg_inp = GeneralPurposeRegister64() - reg_outp = GeneralPurposeRegister64() - reg_blocks = GeneralPurposeRegister64() - reg_sp_save = GeneralPurposeRegister64() - - LOAD.ARGUMENT(reg_x, x) - LOAD.ARGUMENT(reg_inp, inp) - LOAD.ARGUMENT(reg_outp, outp) - LOAD.ARGUMENT(reg_blocks, nrBlocks) - - # Align the stack to a 32 byte boundary. - reg_align = GeneralPurposeRegister64() - MOV(reg_sp_save, registers.rsp) - MOV(reg_align, 0x1f) - NOT(reg_align) - AND(registers.rsp, reg_align) - SUB(registers.rsp, 0x20) - - x_s0 = [reg_x] # (Memory) Cipher state [0..3] - x_s1 = [reg_x+16] # (Memory) Cipher state [4..7] - x_s2 = [reg_x+32] # (Memory) Cipher state [8..11] - x_s3 = [reg_x+48] # (Memory) Cipher state [12..15] - - ymm_v0 = YMMRegister() - ymm_v1 = YMMRegister() - ymm_v2 = YMMRegister() - ymm_v3 = YMMRegister() - - ymm_v4 = YMMRegister() - ymm_v5 = YMMRegister() - ymm_v6 = YMMRegister() - ymm_v7 = YMMRegister() - - ymm_v8 = YMMRegister() - ymm_v9 = YMMRegister() - ymm_v10 = YMMRegister() - ymm_v11 = YMMRegister() - - ymm_v12 = YMMRegister() - ymm_v13 = YMMRegister() - ymm_v14 = YMMRegister() - ymm_v15 = YMMRegister() - - ymm_tmp0 = ymm_v12 - - # Allocate the neccecary stack space for the counter vector and two ymm - # registers that we will spill. - SUB(registers.rsp, 96) - mem_tmp0 = [registers.rsp+64] # (Stack) Scratch space. - mem_s3 = [registers.rsp+32] # (Stack) Working copy of s3. (8x) - mem_inc = [registers.rsp] # (Stack) Counter increment vector. - - # Increment the counter for one side of the state vector. - VPXOR(ymm_tmp0, ymm_tmp0, ymm_tmp0) - VMOVDQU(mem_inc, ymm_tmp0) - reg_tmp = GeneralPurposeRegister32() - MOV(reg_tmp, 0x00000001) - MOV([registers.rsp+16], reg_tmp) - VBROADCASTI128(ymm_v3, x_s3) - VPADDQ(ymm_v3, ymm_v3, [registers.rsp]) - VMOVDQA(mem_s3, ymm_v3) - - # As we process 2xN blocks at a time, so the counter increment for both - # sides of the state vector is 2. - MOV(reg_tmp, 0x00000002) - MOV([registers.rsp], reg_tmp) - MOV([registers.rsp+16], reg_tmp) - - out_write_even = Label() - out_write_odd = Label() - - # - # 8 blocks at a time. Ted Krovetz's avx2 code does not do this, but it's - # a decent gain despite all the pain... - # - - vector_loop8 = Loop() - SUB(reg_blocks, 8) - JB(vector_loop8.end) - with vector_loop8: - VBROADCASTI128(ymm_v0, x_s0) - VBROADCASTI128(ymm_v1, x_s1) - VBROADCASTI128(ymm_v2, x_s2) - VMOVDQA(ymm_v3, mem_s3) - - VMOVDQA(ymm_v4, ymm_v0) - VMOVDQA(ymm_v5, ymm_v1) - VMOVDQA(ymm_v6, ymm_v2) - VPADDQ(ymm_v7, ymm_v3, mem_inc) - - VMOVDQA(ymm_v8, ymm_v0) - VMOVDQA(ymm_v9, ymm_v1) - VMOVDQA(ymm_v10, ymm_v2) - VPADDQ(ymm_v11, ymm_v7, mem_inc) - - VMOVDQA(ymm_v12, ymm_v0) - VMOVDQA(ymm_v13, ymm_v1) - VMOVDQA(ymm_v14, ymm_v2) - VPADDQ(ymm_v15, ymm_v11, mem_inc) - - reg_rounds = GeneralPurposeRegister64() - MOV(reg_rounds, 20) - rounds_loop8 = Loop() - with rounds_loop8: - # a += b; d ^= a; d = ROTW16(d); - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - ADD_avx2(ymm_v8, ymm_v9) - ADD_avx2(ymm_v12, ymm_v13) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - XOR_avx2(ymm_v11, ymm_v8) - XOR_avx2(ymm_v15, ymm_v12) - - VMOVDQA(mem_tmp0, ymm_tmp0) # Save - - ROTW16_avx2(ymm_tmp0, ymm_v3) - ROTW16_avx2(ymm_tmp0, ymm_v7) - ROTW16_avx2(ymm_tmp0, ymm_v11) - ROTW16_avx2(ymm_tmp0, ymm_v15) - - # c += d; b ^= c; b = ROTW12(b); - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - ADD_avx2(ymm_v10, ymm_v11) - ADD_avx2(ymm_v14, ymm_v15) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - XOR_avx2(ymm_v9, ymm_v10) - XOR_avx2(ymm_v13, ymm_v14) - ROTW12_avx2(ymm_tmp0, ymm_v1) - ROTW12_avx2(ymm_tmp0, ymm_v5) - ROTW12_avx2(ymm_tmp0, ymm_v9) - ROTW12_avx2(ymm_tmp0, ymm_v13) - - # a += b; d ^= a; d = ROTW8(d); - VMOVDQA(ymm_tmp0, mem_tmp0) # Restore - - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - ADD_avx2(ymm_v8, ymm_v9) - ADD_avx2(ymm_v12, ymm_v13) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - XOR_avx2(ymm_v11, ymm_v8) - XOR_avx2(ymm_v15, ymm_v12) - - VMOVDQA(mem_tmp0, ymm_tmp0) # Save - - ROTW8_avx2(ymm_tmp0, ymm_v3) - ROTW8_avx2(ymm_tmp0, ymm_v7) - ROTW8_avx2(ymm_tmp0, ymm_v11) - ROTW8_avx2(ymm_tmp0, ymm_v15) - - # c += d; b ^= c; b = ROTW7(b) - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - ADD_avx2(ymm_v10, ymm_v11) - ADD_avx2(ymm_v14, ymm_v15) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - XOR_avx2(ymm_v9, ymm_v10) - XOR_avx2(ymm_v13, ymm_v14) - ROTW7_avx2(ymm_tmp0, ymm_v1) - ROTW7_avx2(ymm_tmp0, ymm_v5) - ROTW7_avx2(ymm_tmp0, ymm_v9) - ROTW7_avx2(ymm_tmp0, ymm_v13) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - VPSHUFD(ymm_v1, ymm_v1, 0x39) - VPSHUFD(ymm_v5, ymm_v5, 0x39) - VPSHUFD(ymm_v9, ymm_v9, 0x39) - VPSHUFD(ymm_v13, ymm_v13, 0x39) - VPSHUFD(ymm_v2, ymm_v2, 0x4e) - VPSHUFD(ymm_v6, ymm_v6, 0x4e) - VPSHUFD(ymm_v10, ymm_v10, 0x4e) - VPSHUFD(ymm_v14, ymm_v14, 0x4e) - VPSHUFD(ymm_v3, ymm_v3, 0x93) - VPSHUFD(ymm_v7, ymm_v7, 0x93) - VPSHUFD(ymm_v11, ymm_v11, 0x93) - VPSHUFD(ymm_v15, ymm_v15, 0x93) - - # a += b; d ^= a; d = ROTW16(d); - VMOVDQA(ymm_tmp0, mem_tmp0) # Restore - - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - ADD_avx2(ymm_v8, ymm_v9) - ADD_avx2(ymm_v12, ymm_v13) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - XOR_avx2(ymm_v11, ymm_v8) - XOR_avx2(ymm_v15, ymm_v12) - - VMOVDQA(mem_tmp0, ymm_tmp0) # Save - - ROTW16_avx2(ymm_tmp0, ymm_v3) - ROTW16_avx2(ymm_tmp0, ymm_v7) - ROTW16_avx2(ymm_tmp0, ymm_v11) - ROTW16_avx2(ymm_tmp0, ymm_v15) - - # c += d; b ^= c; b = ROTW12(b); - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - ADD_avx2(ymm_v10, ymm_v11) - ADD_avx2(ymm_v14, ymm_v15) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - XOR_avx2(ymm_v9, ymm_v10) - XOR_avx2(ymm_v13, ymm_v14) - ROTW12_avx2(ymm_tmp0, ymm_v1) - ROTW12_avx2(ymm_tmp0, ymm_v5) - ROTW12_avx2(ymm_tmp0, ymm_v9) - ROTW12_avx2(ymm_tmp0, ymm_v13) - - # a += b; d ^= a; d = ROTW8(d); - VMOVDQA(ymm_tmp0, mem_tmp0) # Restore - - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - ADD_avx2(ymm_v8, ymm_v9) - ADD_avx2(ymm_v12, ymm_v13) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - XOR_avx2(ymm_v11, ymm_v8) - XOR_avx2(ymm_v15, ymm_v12) - - VMOVDQA(mem_tmp0, ymm_tmp0) # Save - - ROTW8_avx2(ymm_tmp0, ymm_v3) - ROTW8_avx2(ymm_tmp0, ymm_v7) - ROTW8_avx2(ymm_tmp0, ymm_v11) - ROTW8_avx2(ymm_tmp0, ymm_v15) - - # c += d; b ^= c; b = ROTW7(b) - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - ADD_avx2(ymm_v10, ymm_v11) - ADD_avx2(ymm_v14, ymm_v15) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - XOR_avx2(ymm_v9, ymm_v10) - XOR_avx2(ymm_v13, ymm_v14) - ROTW7_avx2(ymm_tmp0, ymm_v1) - ROTW7_avx2(ymm_tmp0, ymm_v5) - ROTW7_avx2(ymm_tmp0, ymm_v9) - ROTW7_avx2(ymm_tmp0, ymm_v13) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - VPSHUFD(ymm_v1, ymm_v1, 0x93) - VPSHUFD(ymm_v5, ymm_v5, 0x93) - VPSHUFD(ymm_v9, ymm_v9, 0x93) - VPSHUFD(ymm_v13, ymm_v13, 0x93) - VPSHUFD(ymm_v2, ymm_v2, 0x4e) - VPSHUFD(ymm_v6, ymm_v6, 0x4e) - VPSHUFD(ymm_v10, ymm_v10, 0x4e) - VPSHUFD(ymm_v14, ymm_v14, 0x4e) - VPSHUFD(ymm_v3, ymm_v3, 0x39) - VPSHUFD(ymm_v7, ymm_v7, 0x39) - VPSHUFD(ymm_v11, ymm_v11, 0x39) - VPSHUFD(ymm_v15, ymm_v15, 0x39) - - VMOVDQA(ymm_tmp0, mem_tmp0) # Restore - - SUB(reg_rounds, 2) - JNZ(rounds_loop8.begin) - - # ymm_v12 is in mem_tmp0 and is current.... - - # XXX: I assume VBROADCASTI128 is about as fast as VMOVDQA.... - VBROADCASTI128(ymm_tmp0, x_s0) - ADD_avx2(ymm_v0, ymm_tmp0) - ADD_avx2(ymm_v4, ymm_tmp0) - ADD_avx2(ymm_v8, ymm_tmp0) - ADD_avx2(ymm_tmp0, mem_tmp0) - VMOVDQA(mem_tmp0, ymm_tmp0) - - VBROADCASTI128(ymm_tmp0, x_s1) - ADD_avx2(ymm_v1, ymm_tmp0) - ADD_avx2(ymm_v5, ymm_tmp0) - ADD_avx2(ymm_v9, ymm_tmp0) - ADD_avx2(ymm_v13, ymm_tmp0) - - VBROADCASTI128(ymm_tmp0, x_s2) - ADD_avx2(ymm_v2, ymm_tmp0) - ADD_avx2(ymm_v6, ymm_tmp0) - ADD_avx2(ymm_v10, ymm_tmp0) - ADD_avx2(ymm_v14, ymm_tmp0) - - ADD_avx2(ymm_v3, mem_s3) - WriteXor_avx2(ymm_tmp0, reg_inp, reg_outp, 0, ymm_v0, ymm_v1, ymm_v2, ymm_v3) - VMOVDQA(ymm_v3, mem_s3) - ADD_avx2(ymm_v3, mem_inc) - - ADD_avx2(ymm_v7, ymm_v3) - WriteXor_avx2(ymm_tmp0, reg_inp, reg_outp, 128, ymm_v4, ymm_v5, ymm_v6, ymm_v7) - ADD_avx2(ymm_v3, mem_inc) - - ADD_avx2(ymm_v11, ymm_v3) - WriteXor_avx2(ymm_tmp0, reg_inp, reg_outp, 256, ymm_v8, ymm_v9, ymm_v10, ymm_v11) - ADD_avx2(ymm_v3, mem_inc) - - VMOVDQA(ymm_v12, mem_tmp0) - ADD_avx2(ymm_v15, ymm_v3) - WriteXor_avx2(ymm_v0, reg_inp, reg_outp, 384, ymm_v12, ymm_v13, ymm_v14, ymm_v15) - ADD_avx2(ymm_v3, mem_inc) - - VMOVDQA(mem_s3, ymm_v3) - - ADD(reg_inp, 8 * 64) - ADD(reg_outp, 8 * 64) - - SUB(reg_blocks, 8) - JAE(vector_loop8.begin) - - # ymm_v3 contains a current copy of mem_s3 either from when it was built, - # or because the loop updates it. Copy this before we mess with the block - # counter in case we need to write it back and return. - ymm_s3 = ymm_v11 - VMOVDQA(ymm_s3, ymm_v3) - - ADD(reg_blocks, 8) - JZ(out_write_even) - - # We now actually can do everything in registers. - ymm_s0 = ymm_v8 - VBROADCASTI128(ymm_s0, x_s0) - ymm_s1 = ymm_v9 - VBROADCASTI128(ymm_s1, x_s1) - ymm_s2 = ymm_v10 - VBROADCASTI128(ymm_s2, x_s2) - ymm_inc = ymm_v14 - VMOVDQA(ymm_inc, mem_inc) - - # - # 4 blocks at a time. - # - - SUB(reg_blocks, 4) - vector_loop4 = Loop() - JB(vector_loop4.end) - with vector_loop4: - VMOVDQA(ymm_v0, ymm_s0) - VMOVDQA(ymm_v1, ymm_s1) - VMOVDQA(ymm_v2, ymm_s2) - VMOVDQA(ymm_v3, ymm_s3) - - VMOVDQA(ymm_v4, ymm_v0) - VMOVDQA(ymm_v5, ymm_v1) - VMOVDQA(ymm_v6, ymm_v2) - VPADDQ(ymm_v7, ymm_v3, ymm_inc) - - reg_rounds = GeneralPurposeRegister64() - MOV(reg_rounds, 20) - rounds_loop4 = Loop() - with rounds_loop4: - # a += b; d ^= a; d = ROTW16(d); - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - ROTW16_avx2(ymm_tmp0, ymm_v3) - ROTW16_avx2(ymm_tmp0, ymm_v7) - - # c += d; b ^= c; b = ROTW12(b); - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - ROTW12_avx2(ymm_tmp0, ymm_v1) - ROTW12_avx2(ymm_tmp0, ymm_v5) - - # a += b; d ^= a; d = ROTW8(d); - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - ROTW8_avx2(ymm_tmp0, ymm_v3) - ROTW8_avx2(ymm_tmp0, ymm_v7) - - # c += d; b ^= c; b = ROTW7(b) - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - ROTW7_avx2(ymm_tmp0, ymm_v1) - ROTW7_avx2(ymm_tmp0, ymm_v5) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - VPSHUFD(ymm_v1, ymm_v1, 0x39) - VPSHUFD(ymm_v5, ymm_v5, 0x39) - VPSHUFD(ymm_v2, ymm_v2, 0x4e) - VPSHUFD(ymm_v6, ymm_v6, 0x4e) - VPSHUFD(ymm_v3, ymm_v3, 0x93) - VPSHUFD(ymm_v7, ymm_v7, 0x93) - - # a += b; d ^= a; d = ROTW16(d); - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - ROTW16_avx2(ymm_tmp0, ymm_v3) - ROTW16_avx2(ymm_tmp0, ymm_v7) - - # c += d; b ^= c; b = ROTW12(b); - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - ROTW12_avx2(ymm_tmp0, ymm_v1) - ROTW12_avx2(ymm_tmp0, ymm_v5) - - # a += b; d ^= a; d = ROTW8(d); - ADD_avx2(ymm_v0, ymm_v1) - ADD_avx2(ymm_v4, ymm_v5) - XOR_avx2(ymm_v3, ymm_v0) - XOR_avx2(ymm_v7, ymm_v4) - ROTW8_avx2(ymm_tmp0, ymm_v3) - ROTW8_avx2(ymm_tmp0, ymm_v7) - - # c += d; b ^= c; b = ROTW7(b) - ADD_avx2(ymm_v2, ymm_v3) - ADD_avx2(ymm_v6, ymm_v7) - XOR_avx2(ymm_v1, ymm_v2) - XOR_avx2(ymm_v5, ymm_v6) - ROTW7_avx2(ymm_tmp0, ymm_v1) - ROTW7_avx2(ymm_tmp0, ymm_v5) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - VPSHUFD(ymm_v1, ymm_v1, 0x93) - VPSHUFD(ymm_v5, ymm_v5, 0x93) - VPSHUFD(ymm_v2, ymm_v2, 0x4e) - VPSHUFD(ymm_v6, ymm_v6, 0x4e) - VPSHUFD(ymm_v3, ymm_v3, 0x39) - VPSHUFD(ymm_v7, ymm_v7, 0x39) - - SUB(reg_rounds, 2) - JNZ(rounds_loop4.begin) - - ADD_avx2(ymm_v0, ymm_s0) - ADD_avx2(ymm_v1, ymm_s1) - ADD_avx2(ymm_v2, ymm_s2) - ADD_avx2(ymm_v3, ymm_s3) - WriteXor_avx2(ymm_tmp0, reg_inp, reg_outp, 0, ymm_v0, ymm_v1, ymm_v2, ymm_v3) - ADD_avx2(ymm_s3, ymm_inc) - - ADD_avx2(ymm_v4, ymm_s0) - ADD_avx2(ymm_v5, ymm_s1) - ADD_avx2(ymm_v6, ymm_s2) - ADD_avx2(ymm_v7, ymm_s3) - WriteXor_avx2(ymm_tmp0, reg_inp, reg_outp, 128, ymm_v4, ymm_v5, ymm_v6, ymm_v7) - ADD_avx2(ymm_s3, ymm_inc) - - ADD(reg_inp, 4 * 64) - ADD(reg_outp, 4 * 64) - - SUB(reg_blocks, 4) - JAE(vector_loop4.begin) - - ADD(reg_blocks, 4) - JZ(out_write_even) - - # - # 2/1 blocks at a time. The two codepaths are unified because - # with AVX2 we do 2 blocks at a time anyway, and this only gets called - # if 3/2/1 blocks are remaining, so the extra branches don't hurt that - # much. - # - - vector_loop2 = Loop() - with vector_loop2: - VMOVDQA(ymm_v0, ymm_s0) - VMOVDQA(ymm_v1, ymm_s1) - VMOVDQA(ymm_v2, ymm_s2) - VMOVDQA(ymm_v3, ymm_s3) - - reg_rounds = GeneralPurposeRegister64() - MOV(reg_rounds, 20) - rounds_loop2 = Loop() - with rounds_loop2: - # a += b; d ^= a; d = ROTW16(d); - ADD_avx2(ymm_v0, ymm_v1) - XOR_avx2(ymm_v3, ymm_v0) - ROTW16_avx2(ymm_tmp0, ymm_v3) - - # c += d; b ^= c; b = ROTW12(b); - ADD_avx2(ymm_v2, ymm_v3) - XOR_avx2(ymm_v1, ymm_v2) - ROTW12_avx2(ymm_tmp0, ymm_v1) - - # a += b; d ^= a; d = ROTW8(d); - ADD_avx2(ymm_v0, ymm_v1) - XOR_avx2(ymm_v3, ymm_v0) - ROTW8_avx2(ymm_tmp0, ymm_v3) - - # c += d; b ^= c; b = ROTW7(b) - ADD_avx2(ymm_v2, ymm_v3) - XOR_avx2(ymm_v1, ymm_v2) - ROTW7_avx2(ymm_tmp0, ymm_v1) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - VPSHUFD(ymm_v1, ymm_v1, 0x39) - VPSHUFD(ymm_v2, ymm_v2, 0x4e) - VPSHUFD(ymm_v3, ymm_v3, 0x93) - - # a += b; d ^= a; d = ROTW16(d); - ADD_avx2(ymm_v0, ymm_v1) - XOR_avx2(ymm_v3, ymm_v0) - ROTW16_avx2(ymm_tmp0, ymm_v3) - - # c += d; b ^= c; b = ROTW12(b); - ADD_avx2(ymm_v2, ymm_v3) - XOR_avx2(ymm_v1, ymm_v2) - ROTW12_avx2(ymm_tmp0, ymm_v1) - - # a += b; d ^= a; d = ROTW8(d); - ADD_avx2(ymm_v0, ymm_v1) - XOR_avx2(ymm_v3, ymm_v0) - ROTW8_avx2(ymm_tmp0, ymm_v3) - - # c += d; b ^= c; b = ROTW7(b) - ADD_avx2(ymm_v2, ymm_v3) - XOR_avx2(ymm_v1, ymm_v2) - ROTW7_avx2(ymm_tmp0, ymm_v1) - - # b = ROTV1(b); c = ROTV2(c); d = ROTV3(d); - VPSHUFD(ymm_v1, ymm_v1, 0x93) - VPSHUFD(ymm_v2, ymm_v2, 0x4e) - VPSHUFD(ymm_v3, ymm_v3, 0x39) - - SUB(reg_rounds, 2) - JNZ(rounds_loop2.begin) - - ADD_avx2(ymm_v0, ymm_s0) - ADD_avx2(ymm_v1, ymm_s1) - ADD_avx2(ymm_v2, ymm_s2) - ADD_avx2(ymm_v3, ymm_s3) - - # XOR_WRITE(out+ 0, in+ 0, _mm256_permute2x128_si256(v0,v1,0x20)); - VPERM2I128(ymm_tmp0, ymm_v0, ymm_v1, 0x20) - VPXOR(ymm_tmp0, ymm_tmp0, [reg_inp]) - VMOVDQU([reg_outp], ymm_tmp0) - - # XOR_WRITE(out+32, in+32, _mm256_permute2x128_si256(v2,v3,0x20)); - VPERM2I128(ymm_tmp0, ymm_v2, ymm_v3, 0x20) - VPXOR(ymm_tmp0, ymm_tmp0, [reg_inp+32]) - VMOVDQU([reg_outp+32], ymm_tmp0) - - SUB(reg_blocks, 1) - JZ(out_write_odd) - - ADD_avx2(ymm_s3, ymm_inc) - - # XOR_WRITE(out+64, in+64, _mm256_permute2x128_si256(v0,v1,0x31)); - VPERM2I128(ymm_tmp0, ymm_v0, ymm_v1, 0x31) - VPXOR(ymm_tmp0, ymm_tmp0, [reg_inp+64]) - VMOVDQU([reg_outp+64], ymm_tmp0) - - # XOR_WRITE(out+96, in+96, _mm256_permute2x128_si256(v2,v3,0x31)); - VPERM2I128(ymm_tmp0, ymm_v2, ymm_v3, 0x31) - VPXOR(ymm_tmp0, ymm_tmp0, [reg_inp+96]) - VMOVDQU([reg_outp+96], ymm_tmp0) - - SUB(reg_blocks, 1) - JZ(out_write_even) - - ADD(reg_inp, 2 * 64) - ADD(reg_outp, 2 * 64) - JMP(vector_loop2.begin) - - LABEL(out_write_odd) - VPERM2I128(ymm_s3, ymm_s3, ymm_s3, 0x01) # Odd number of blocks. - - LABEL(out_write_even) - VMOVDQA(x_s3, ymm_s3.as_xmm) # Write back ymm_s3 to x_v3 - - # Paranoia, cleanse the scratch space. - VPXOR(ymm_v0, ymm_v0, ymm_v0) - VMOVDQA(mem_tmp0, ymm_v0) - VMOVDQA(mem_s3, ymm_v0) - - # Remove our stack allocation. - MOV(registers.rsp, reg_sp_save) - - RETURN() - -# -# CPUID -# - -cpuidParams = Argument(ptr(uint32_t)) - -with Function("cpuidAmd64", (cpuidParams,)): - reg_params = registers.r15 - LOAD.ARGUMENT(reg_params, cpuidParams) - - MOV(registers.eax, [reg_params]) - MOV(registers.ecx, [reg_params+4]) - - CPUID() - - MOV([reg_params], registers.eax) - MOV([reg_params+4], registers.ebx) - MOV([reg_params+8], registers.ecx) - MOV([reg_params+12], registers.edx) - - RETURN() - -# -# XGETBV (ECX = 0) -# - -xcrVec = Argument(ptr(uint32_t)) - -with Function("xgetbv0Amd64", (xcrVec,)): - reg_vec = GeneralPurposeRegister64() - - LOAD.ARGUMENT(reg_vec, xcrVec) - - XOR(registers.ecx, registers.ecx) - - XGETBV() - - MOV([reg_vec], registers.eax) - MOV([reg_vec+4], registers.edx) - - RETURN() diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.s b/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.s deleted file mode 100644 index 4970397..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_amd64.s +++ /dev/null @@ -1,1187 +0,0 @@ -// Generated by PeachPy 0.2.0 from chacha20_amd64.py - - -// func blocksAmd64SSE2(x *uint32, inp *uint8, outp *uint8, nrBlocks *uint) -TEXT ·blocksAmd64SSE2(SB),4,$0-32 - MOVQ x+0(FP), AX - MOVQ inp+8(FP), BX - MOVQ outp+16(FP), CX - MOVQ nrBlocks+24(FP), DX - MOVQ SP, DI - MOVQ $31, SI - NOTQ SI - ANDQ SI, SP - SUBQ $32, SP - PXOR X0, X0 - SUBQ $32, SP - MOVO X0, 0(SP) - MOVL $1, SI - MOVL SI, 0(SP) - SUBQ $4, DX - JCS vector_loop4_end -vector_loop4_begin: - MOVO 0(AX), X0 - MOVO 16(AX), X1 - MOVO 32(AX), X2 - MOVO 48(AX), X3 - MOVO X0, X4 - MOVO X1, X5 - MOVO X2, X6 - MOVO X3, X7 - PADDQ 0(SP), X7 - MOVO X0, X8 - MOVO X1, X9 - MOVO X2, X10 - MOVO X7, X11 - PADDQ 0(SP), X11 - MOVO X0, X12 - MOVO X1, X13 - MOVO X2, X14 - MOVO X11, X15 - PADDQ 0(SP), X15 - MOVQ $20, SI -rounds_loop4_begin: - PADDL X1, X0 - PADDL X5, X4 - PADDL X9, X8 - PADDL X13, X12 - PXOR X0, X3 - PXOR X4, X7 - PXOR X8, X11 - PXOR X12, X15 - MOVO X12, 16(SP) - MOVO X3, X12 - PSLLL $16, X12 - PSRLL $16, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $16, X12 - PSRLL $16, X7 - PXOR X12, X7 - MOVO X11, X12 - PSLLL $16, X12 - PSRLL $16, X11 - PXOR X12, X11 - MOVO X15, X12 - PSLLL $16, X12 - PSRLL $16, X15 - PXOR X12, X15 - PADDL X3, X2 - PADDL X7, X6 - PADDL X11, X10 - PADDL X15, X14 - PXOR X2, X1 - PXOR X6, X5 - PXOR X10, X9 - PXOR X14, X13 - MOVO X1, X12 - PSLLL $12, X12 - PSRLL $20, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $12, X12 - PSRLL $20, X5 - PXOR X12, X5 - MOVO X9, X12 - PSLLL $12, X12 - PSRLL $20, X9 - PXOR X12, X9 - MOVO X13, X12 - PSLLL $12, X12 - PSRLL $20, X13 - PXOR X12, X13 - MOVO 16(SP), X12 - PADDL X1, X0 - PADDL X5, X4 - PADDL X9, X8 - PADDL X13, X12 - PXOR X0, X3 - PXOR X4, X7 - PXOR X8, X11 - PXOR X12, X15 - MOVO X12, 16(SP) - MOVO X3, X12 - PSLLL $8, X12 - PSRLL $24, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $8, X12 - PSRLL $24, X7 - PXOR X12, X7 - MOVO X11, X12 - PSLLL $8, X12 - PSRLL $24, X11 - PXOR X12, X11 - MOVO X15, X12 - PSLLL $8, X12 - PSRLL $24, X15 - PXOR X12, X15 - PADDL X3, X2 - PADDL X7, X6 - PADDL X11, X10 - PADDL X15, X14 - PXOR X2, X1 - PXOR X6, X5 - PXOR X10, X9 - PXOR X14, X13 - MOVO X1, X12 - PSLLL $7, X12 - PSRLL $25, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $7, X12 - PSRLL $25, X5 - PXOR X12, X5 - MOVO X9, X12 - PSLLL $7, X12 - PSRLL $25, X9 - PXOR X12, X9 - MOVO X13, X12 - PSLLL $7, X12 - PSRLL $25, X13 - PXOR X12, X13 - PSHUFL $57, X1, X1 - PSHUFL $57, X5, X5 - PSHUFL $57, X9, X9 - PSHUFL $57, X13, X13 - PSHUFL $78, X2, X2 - PSHUFL $78, X6, X6 - PSHUFL $78, X10, X10 - PSHUFL $78, X14, X14 - PSHUFL $147, X3, X3 - PSHUFL $147, X7, X7 - PSHUFL $147, X11, X11 - PSHUFL $147, X15, X15 - MOVO 16(SP), X12 - PADDL X1, X0 - PADDL X5, X4 - PADDL X9, X8 - PADDL X13, X12 - PXOR X0, X3 - PXOR X4, X7 - PXOR X8, X11 - PXOR X12, X15 - MOVO X12, 16(SP) - MOVO X3, X12 - PSLLL $16, X12 - PSRLL $16, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $16, X12 - PSRLL $16, X7 - PXOR X12, X7 - MOVO X11, X12 - PSLLL $16, X12 - PSRLL $16, X11 - PXOR X12, X11 - MOVO X15, X12 - PSLLL $16, X12 - PSRLL $16, X15 - PXOR X12, X15 - PADDL X3, X2 - PADDL X7, X6 - PADDL X11, X10 - PADDL X15, X14 - PXOR X2, X1 - PXOR X6, X5 - PXOR X10, X9 - PXOR X14, X13 - MOVO X1, X12 - PSLLL $12, X12 - PSRLL $20, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $12, X12 - PSRLL $20, X5 - PXOR X12, X5 - MOVO X9, X12 - PSLLL $12, X12 - PSRLL $20, X9 - PXOR X12, X9 - MOVO X13, X12 - PSLLL $12, X12 - PSRLL $20, X13 - PXOR X12, X13 - MOVO 16(SP), X12 - PADDL X1, X0 - PADDL X5, X4 - PADDL X9, X8 - PADDL X13, X12 - PXOR X0, X3 - PXOR X4, X7 - PXOR X8, X11 - PXOR X12, X15 - MOVO X12, 16(SP) - MOVO X3, X12 - PSLLL $8, X12 - PSRLL $24, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $8, X12 - PSRLL $24, X7 - PXOR X12, X7 - MOVO X11, X12 - PSLLL $8, X12 - PSRLL $24, X11 - PXOR X12, X11 - MOVO X15, X12 - PSLLL $8, X12 - PSRLL $24, X15 - PXOR X12, X15 - PADDL X3, X2 - PADDL X7, X6 - PADDL X11, X10 - PADDL X15, X14 - PXOR X2, X1 - PXOR X6, X5 - PXOR X10, X9 - PXOR X14, X13 - MOVO X1, X12 - PSLLL $7, X12 - PSRLL $25, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $7, X12 - PSRLL $25, X5 - PXOR X12, X5 - MOVO X9, X12 - PSLLL $7, X12 - PSRLL $25, X9 - PXOR X12, X9 - MOVO X13, X12 - PSLLL $7, X12 - PSRLL $25, X13 - PXOR X12, X13 - PSHUFL $147, X1, X1 - PSHUFL $147, X5, X5 - PSHUFL $147, X9, X9 - PSHUFL $147, X13, X13 - PSHUFL $78, X2, X2 - PSHUFL $78, X6, X6 - PSHUFL $78, X10, X10 - PSHUFL $78, X14, X14 - PSHUFL $57, X3, X3 - PSHUFL $57, X7, X7 - PSHUFL $57, X11, X11 - PSHUFL $57, X15, X15 - MOVO 16(SP), X12 - SUBQ $2, SI - JNE rounds_loop4_begin - MOVO X12, 16(SP) - PADDL 0(AX), X0 - PADDL 16(AX), X1 - PADDL 32(AX), X2 - PADDL 48(AX), X3 - MOVOU 0(BX), X12 - PXOR X0, X12 - MOVOU X12, 0(CX) - MOVOU 16(BX), X12 - PXOR X1, X12 - MOVOU X12, 16(CX) - MOVOU 32(BX), X12 - PXOR X2, X12 - MOVOU X12, 32(CX) - MOVOU 48(BX), X12 - PXOR X3, X12 - MOVOU X12, 48(CX) - MOVO 48(AX), X3 - PADDQ 0(SP), X3 - PADDL 0(AX), X4 - PADDL 16(AX), X5 - PADDL 32(AX), X6 - PADDL X3, X7 - MOVOU 64(BX), X12 - PXOR X4, X12 - MOVOU X12, 64(CX) - MOVOU 80(BX), X12 - PXOR X5, X12 - MOVOU X12, 80(CX) - MOVOU 96(BX), X12 - PXOR X6, X12 - MOVOU X12, 96(CX) - MOVOU 112(BX), X12 - PXOR X7, X12 - MOVOU X12, 112(CX) - PADDQ 0(SP), X3 - PADDL 0(AX), X8 - PADDL 16(AX), X9 - PADDL 32(AX), X10 - PADDL X3, X11 - MOVOU 128(BX), X12 - PXOR X8, X12 - MOVOU X12, 128(CX) - MOVOU 144(BX), X12 - PXOR X9, X12 - MOVOU X12, 144(CX) - MOVOU 160(BX), X12 - PXOR X10, X12 - MOVOU X12, 160(CX) - MOVOU 176(BX), X12 - PXOR X11, X12 - MOVOU X12, 176(CX) - PADDQ 0(SP), X3 - MOVO 16(SP), X12 - PADDL 0(AX), X12 - PADDL 16(AX), X13 - PADDL 32(AX), X14 - PADDL X3, X15 - MOVOU 192(BX), X0 - PXOR X12, X0 - MOVOU X0, 192(CX) - MOVOU 208(BX), X0 - PXOR X13, X0 - MOVOU X0, 208(CX) - MOVOU 224(BX), X0 - PXOR X14, X0 - MOVOU X0, 224(CX) - MOVOU 240(BX), X0 - PXOR X15, X0 - MOVOU X0, 240(CX) - PADDQ 0(SP), X3 - MOVO X3, 48(AX) - ADDQ $256, BX - ADDQ $256, CX - SUBQ $4, DX - JCC vector_loop4_begin -vector_loop4_end: - ADDQ $4, DX - JEQ out - MOVO 0(AX), X8 - MOVO 16(AX), X9 - MOVO 32(AX), X10 - MOVO 48(AX), X11 - MOVO 0(SP), X13 - SUBQ $2, DX - JCS vector_loop2_end -vector_loop2_begin: - MOVO X8, X0 - MOVO X9, X1 - MOVO X10, X2 - MOVO X11, X3 - MOVO X0, X4 - MOVO X1, X5 - MOVO X2, X6 - MOVO X3, X7 - PADDQ X13, X7 - MOVQ $20, SI -rounds_loop2_begin: - PADDL X1, X0 - PADDL X5, X4 - PXOR X0, X3 - PXOR X4, X7 - MOVO X3, X12 - PSLLL $16, X12 - PSRLL $16, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $16, X12 - PSRLL $16, X7 - PXOR X12, X7 - PADDL X3, X2 - PADDL X7, X6 - PXOR X2, X1 - PXOR X6, X5 - MOVO X1, X12 - PSLLL $12, X12 - PSRLL $20, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $12, X12 - PSRLL $20, X5 - PXOR X12, X5 - PADDL X1, X0 - PADDL X5, X4 - PXOR X0, X3 - PXOR X4, X7 - MOVO X3, X12 - PSLLL $8, X12 - PSRLL $24, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $8, X12 - PSRLL $24, X7 - PXOR X12, X7 - PADDL X3, X2 - PADDL X7, X6 - PXOR X2, X1 - PXOR X6, X5 - MOVO X1, X12 - PSLLL $7, X12 - PSRLL $25, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $7, X12 - PSRLL $25, X5 - PXOR X12, X5 - PSHUFL $57, X1, X1 - PSHUFL $57, X5, X5 - PSHUFL $78, X2, X2 - PSHUFL $78, X6, X6 - PSHUFL $147, X3, X3 - PSHUFL $147, X7, X7 - PADDL X1, X0 - PADDL X5, X4 - PXOR X0, X3 - PXOR X4, X7 - MOVO X3, X12 - PSLLL $16, X12 - PSRLL $16, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $16, X12 - PSRLL $16, X7 - PXOR X12, X7 - PADDL X3, X2 - PADDL X7, X6 - PXOR X2, X1 - PXOR X6, X5 - MOVO X1, X12 - PSLLL $12, X12 - PSRLL $20, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $12, X12 - PSRLL $20, X5 - PXOR X12, X5 - PADDL X1, X0 - PADDL X5, X4 - PXOR X0, X3 - PXOR X4, X7 - MOVO X3, X12 - PSLLL $8, X12 - PSRLL $24, X3 - PXOR X12, X3 - MOVO X7, X12 - PSLLL $8, X12 - PSRLL $24, X7 - PXOR X12, X7 - PADDL X3, X2 - PADDL X7, X6 - PXOR X2, X1 - PXOR X6, X5 - MOVO X1, X12 - PSLLL $7, X12 - PSRLL $25, X1 - PXOR X12, X1 - MOVO X5, X12 - PSLLL $7, X12 - PSRLL $25, X5 - PXOR X12, X5 - PSHUFL $147, X1, X1 - PSHUFL $147, X5, X5 - PSHUFL $78, X2, X2 - PSHUFL $78, X6, X6 - PSHUFL $57, X3, X3 - PSHUFL $57, X7, X7 - SUBQ $2, SI - JNE rounds_loop2_begin - PADDL X8, X0 - PADDL X9, X1 - PADDL X10, X2 - PADDL X11, X3 - MOVOU 0(BX), X12 - PXOR X0, X12 - MOVOU X12, 0(CX) - MOVOU 16(BX), X12 - PXOR X1, X12 - MOVOU X12, 16(CX) - MOVOU 32(BX), X12 - PXOR X2, X12 - MOVOU X12, 32(CX) - MOVOU 48(BX), X12 - PXOR X3, X12 - MOVOU X12, 48(CX) - PADDQ X13, X11 - PADDL X8, X4 - PADDL X9, X5 - PADDL X10, X6 - PADDL X11, X7 - MOVOU 64(BX), X12 - PXOR X4, X12 - MOVOU X12, 64(CX) - MOVOU 80(BX), X12 - PXOR X5, X12 - MOVOU X12, 80(CX) - MOVOU 96(BX), X12 - PXOR X6, X12 - MOVOU X12, 96(CX) - MOVOU 112(BX), X12 - PXOR X7, X12 - MOVOU X12, 112(CX) - PADDQ X13, X11 - ADDQ $128, BX - ADDQ $128, CX - SUBQ $2, DX - JCC vector_loop2_begin -vector_loop2_end: - ADDQ $2, DX - JEQ out_serial - MOVO X8, X0 - MOVO X9, X1 - MOVO X10, X2 - MOVO X11, X3 - MOVQ $20, DX -rounds_loop1_begin: - PADDL X1, X0 - PXOR X0, X3 - MOVO X3, X12 - PSLLL $16, X12 - PSRLL $16, X3 - PXOR X12, X3 - PADDL X3, X2 - PXOR X2, X1 - MOVO X1, X12 - PSLLL $12, X12 - PSRLL $20, X1 - PXOR X12, X1 - PADDL X1, X0 - PXOR X0, X3 - MOVO X3, X12 - PSLLL $8, X12 - PSRLL $24, X3 - PXOR X12, X3 - PADDL X3, X2 - PXOR X2, X1 - MOVO X1, X12 - PSLLL $7, X12 - PSRLL $25, X1 - PXOR X12, X1 - PSHUFL $57, X1, X1 - PSHUFL $78, X2, X2 - PSHUFL $147, X3, X3 - PADDL X1, X0 - PXOR X0, X3 - MOVO X3, X12 - PSLLL $16, X12 - PSRLL $16, X3 - PXOR X12, X3 - PADDL X3, X2 - PXOR X2, X1 - MOVO X1, X12 - PSLLL $12, X12 - PSRLL $20, X1 - PXOR X12, X1 - PADDL X1, X0 - PXOR X0, X3 - MOVO X3, X12 - PSLLL $8, X12 - PSRLL $24, X3 - PXOR X12, X3 - PADDL X3, X2 - PXOR X2, X1 - MOVO X1, X12 - PSLLL $7, X12 - PSRLL $25, X1 - PXOR X12, X1 - PSHUFL $147, X1, X1 - PSHUFL $78, X2, X2 - PSHUFL $57, X3, X3 - SUBQ $2, DX - JNE rounds_loop1_begin - PADDL X8, X0 - PADDL X9, X1 - PADDL X10, X2 - PADDL X11, X3 - MOVOU 0(BX), X12 - PXOR X0, X12 - MOVOU X12, 0(CX) - MOVOU 16(BX), X12 - PXOR X1, X12 - MOVOU X12, 16(CX) - MOVOU 32(BX), X12 - PXOR X2, X12 - MOVOU X12, 32(CX) - MOVOU 48(BX), X12 - PXOR X3, X12 - MOVOU X12, 48(CX) - PADDQ X13, X11 -out_serial: - MOVO X11, 48(AX) -out: - PXOR X0, X0 - MOVO X0, 16(SP) - MOVQ DI, SP - RET - -// func blocksAmd64AVX2(x *uint32, inp *uint8, outp *uint8, nrBlocks *uint) -TEXT ·blocksAmd64AVX2(SB),4,$0-32 - MOVQ x+0(FP), AX - MOVQ inp+8(FP), BX - MOVQ outp+16(FP), CX - MOVQ nrBlocks+24(FP), DX - MOVQ SP, DI - MOVQ $31, SI - NOTQ SI - ANDQ SI, SP - SUBQ $32, SP - SUBQ $96, SP - BYTE $0xC4; BYTE $0x41; BYTE $0x1D; BYTE $0xEF; BYTE $0xE4 // VPXOR ymm12, ymm12, ymm12 - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x24; BYTE $0x24 // VMOVDQU [rsp], ymm12 - MOVL $1, SI - MOVL SI, 16(SP) - BYTE $0xC4; BYTE $0xE2; BYTE $0x7D; BYTE $0x5A; BYTE $0x58; BYTE $0x30 // VBROADCASTI128 ymm3, [rax + 48] - BYTE $0xC5; BYTE $0xE5; BYTE $0xD4; BYTE $0x1C; BYTE $0x24 // VPADDQ ymm3, ymm3, [rsp] - BYTE $0xC5; BYTE $0xFD; BYTE $0x7F; BYTE $0x5C; BYTE $0x24; BYTE $0x20 // VMOVDQA [rsp + 32], ymm3 - MOVL $2, SI - MOVL SI, 0(SP) - MOVL SI, 16(SP) - SUBQ $8, DX - JCS vector_loop8_end -vector_loop8_begin: - BYTE $0xC4; BYTE $0xE2; BYTE $0x7D; BYTE $0x5A; BYTE $0x00 // VBROADCASTI128 ymm0, [rax] - BYTE $0xC4; BYTE $0xE2; BYTE $0x7D; BYTE $0x5A; BYTE $0x48; BYTE $0x10 // VBROADCASTI128 ymm1, [rax + 16] - BYTE $0xC4; BYTE $0xE2; BYTE $0x7D; BYTE $0x5A; BYTE $0x50; BYTE $0x20 // VBROADCASTI128 ymm2, [rax + 32] - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0x5C; BYTE $0x24; BYTE $0x20 // VMOVDQA ymm3, [rsp + 32] - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0xE0 // VMOVDQA ymm4, ymm0 - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0xE9 // VMOVDQA ymm5, ymm1 - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0xF2 // VMOVDQA ymm6, ymm2 - BYTE $0xC5; BYTE $0xE5; BYTE $0xD4; BYTE $0x3C; BYTE $0x24 // VPADDQ ymm7, ymm3, [rsp] - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0xC0 // VMOVDQA ymm8, ymm0 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0xC9 // VMOVDQA ymm9, ymm1 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0xD2 // VMOVDQA ymm10, ymm2 - BYTE $0xC5; BYTE $0x45; BYTE $0xD4; BYTE $0x1C; BYTE $0x24 // VPADDQ ymm11, ymm7, [rsp] - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0xE0 // VMOVDQA ymm12, ymm0 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0xE9 // VMOVDQA ymm13, ymm1 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0xF2 // VMOVDQA ymm14, ymm2 - BYTE $0xC5; BYTE $0x25; BYTE $0xD4; BYTE $0x3C; BYTE $0x24 // VPADDQ ymm15, ymm11, [rsp] - MOVQ $20, SI -rounds_loop8_begin: - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC4; BYTE $0x41; BYTE $0x3D; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm8, ymm8, ymm9 - BYTE $0xC4; BYTE $0x41; BYTE $0x1D; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm12, ymm12, ymm13 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm11, ymm11, ymm8 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA [rsp + 64], ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm3, 16 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm3, ymm3, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x10 // VPSLLD ymm12, ymm7, 16 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x10 // VPSRLD ymm7, ymm7, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm11, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x25; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm11, ymm11, 16 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xDC // VPXOR ymm11, ymm11, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF7; BYTE $0x10 // VPSLLD ymm12, ymm15, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x05; BYTE $0x72; BYTE $0xD7; BYTE $0x10 // VPSRLD ymm15, ymm15, 16 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC4; BYTE $0x41; BYTE $0x2D; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm10, ymm10, ymm11 - BYTE $0xC4; BYTE $0x41; BYTE $0x0D; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm14, ymm14, ymm15 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCA // VPXOR ymm9, ymm9, ymm10 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEE // VPXOR ymm13, ymm13, ymm14 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm1, 12 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm1, ymm1, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x0C // VPSLLD ymm12, ymm5, 12 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x14 // VPSRLD ymm5, ymm5, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm9, 12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x35; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm9, ymm9, 20 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCC // VPXOR ymm9, ymm9, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF5; BYTE $0x0C // VPSLLD ymm12, ymm13, 12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x15; BYTE $0x72; BYTE $0xD5; BYTE $0x14 // VPSRLD ymm13, ymm13, 20 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEC // VPXOR ymm13, ymm13, ymm12 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA ymm12, [rsp + 64] - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC4; BYTE $0x41; BYTE $0x3D; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm8, ymm8, ymm9 - BYTE $0xC4; BYTE $0x41; BYTE $0x1D; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm12, ymm12, ymm13 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm11, ymm11, ymm8 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA [rsp + 64], ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm3, 8 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm3, ymm3, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x08 // VPSLLD ymm12, ymm7, 8 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x18 // VPSRLD ymm7, ymm7, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm11, 8 - BYTE $0xC4; BYTE $0xC1; BYTE $0x25; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm11, ymm11, 24 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xDC // VPXOR ymm11, ymm11, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF7; BYTE $0x08 // VPSLLD ymm12, ymm15, 8 - BYTE $0xC4; BYTE $0xC1; BYTE $0x05; BYTE $0x72; BYTE $0xD7; BYTE $0x18 // VPSRLD ymm15, ymm15, 24 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC4; BYTE $0x41; BYTE $0x2D; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm10, ymm10, ymm11 - BYTE $0xC4; BYTE $0x41; BYTE $0x0D; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm14, ymm14, ymm15 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCA // VPXOR ymm9, ymm9, ymm10 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEE // VPXOR ymm13, ymm13, ymm14 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm1, 7 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm1, ymm1, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x07 // VPSLLD ymm12, ymm5, 7 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x19 // VPSRLD ymm5, ymm5, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm9, 7 - BYTE $0xC4; BYTE $0xC1; BYTE $0x35; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm9, ymm9, 25 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCC // VPXOR ymm9, ymm9, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF5; BYTE $0x07 // VPSLLD ymm12, ymm13, 7 - BYTE $0xC4; BYTE $0xC1; BYTE $0x15; BYTE $0x72; BYTE $0xD5; BYTE $0x19 // VPSRLD ymm13, ymm13, 25 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEC // VPXOR ymm13, ymm13, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xC9; BYTE $0x39 // VPSHUFD ymm1, ymm1, 57 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xED; BYTE $0x39 // VPSHUFD ymm5, ymm5, 57 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xC9; BYTE $0x39 // VPSHUFD ymm9, ymm9, 57 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xED; BYTE $0x39 // VPSHUFD ymm13, ymm13, 57 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm2, ymm2, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xF6; BYTE $0x4E // VPSHUFD ymm6, ymm6, 78 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm10, ymm10, 78 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xF6; BYTE $0x4E // VPSHUFD ymm14, ymm14, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xDB; BYTE $0x93 // VPSHUFD ymm3, ymm3, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xFF; BYTE $0x93 // VPSHUFD ymm7, ymm7, 147 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xDB; BYTE $0x93 // VPSHUFD ymm11, ymm11, 147 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xFF; BYTE $0x93 // VPSHUFD ymm15, ymm15, 147 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA ymm12, [rsp + 64] - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC4; BYTE $0x41; BYTE $0x3D; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm8, ymm8, ymm9 - BYTE $0xC4; BYTE $0x41; BYTE $0x1D; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm12, ymm12, ymm13 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm11, ymm11, ymm8 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA [rsp + 64], ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm3, 16 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm3, ymm3, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x10 // VPSLLD ymm12, ymm7, 16 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x10 // VPSRLD ymm7, ymm7, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm11, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x25; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm11, ymm11, 16 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xDC // VPXOR ymm11, ymm11, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF7; BYTE $0x10 // VPSLLD ymm12, ymm15, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x05; BYTE $0x72; BYTE $0xD7; BYTE $0x10 // VPSRLD ymm15, ymm15, 16 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC4; BYTE $0x41; BYTE $0x2D; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm10, ymm10, ymm11 - BYTE $0xC4; BYTE $0x41; BYTE $0x0D; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm14, ymm14, ymm15 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCA // VPXOR ymm9, ymm9, ymm10 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEE // VPXOR ymm13, ymm13, ymm14 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm1, 12 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm1, ymm1, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x0C // VPSLLD ymm12, ymm5, 12 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x14 // VPSRLD ymm5, ymm5, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm9, 12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x35; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm9, ymm9, 20 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCC // VPXOR ymm9, ymm9, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF5; BYTE $0x0C // VPSLLD ymm12, ymm13, 12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x15; BYTE $0x72; BYTE $0xD5; BYTE $0x14 // VPSRLD ymm13, ymm13, 20 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEC // VPXOR ymm13, ymm13, ymm12 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA ymm12, [rsp + 64] - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC4; BYTE $0x41; BYTE $0x3D; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm8, ymm8, ymm9 - BYTE $0xC4; BYTE $0x41; BYTE $0x1D; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm12, ymm12, ymm13 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm11, ymm11, ymm8 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA [rsp + 64], ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm3, 8 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm3, ymm3, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x08 // VPSLLD ymm12, ymm7, 8 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x18 // VPSRLD ymm7, ymm7, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm11, 8 - BYTE $0xC4; BYTE $0xC1; BYTE $0x25; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm11, ymm11, 24 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xEF; BYTE $0xDC // VPXOR ymm11, ymm11, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF7; BYTE $0x08 // VPSLLD ymm12, ymm15, 8 - BYTE $0xC4; BYTE $0xC1; BYTE $0x05; BYTE $0x72; BYTE $0xD7; BYTE $0x18 // VPSRLD ymm15, ymm15, 24 - BYTE $0xC4; BYTE $0x41; BYTE $0x05; BYTE $0xEF; BYTE $0xFC // VPXOR ymm15, ymm15, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC4; BYTE $0x41; BYTE $0x2D; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm10, ymm10, ymm11 - BYTE $0xC4; BYTE $0x41; BYTE $0x0D; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm14, ymm14, ymm15 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCA // VPXOR ymm9, ymm9, ymm10 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEE // VPXOR ymm13, ymm13, ymm14 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm1, 7 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm1, ymm1, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x07 // VPSLLD ymm12, ymm5, 7 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x19 // VPSRLD ymm5, ymm5, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm9, 7 - BYTE $0xC4; BYTE $0xC1; BYTE $0x35; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm9, ymm9, 25 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xEF; BYTE $0xCC // VPXOR ymm9, ymm9, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x1D; BYTE $0x72; BYTE $0xF5; BYTE $0x07 // VPSLLD ymm12, ymm13, 7 - BYTE $0xC4; BYTE $0xC1; BYTE $0x15; BYTE $0x72; BYTE $0xD5; BYTE $0x19 // VPSRLD ymm13, ymm13, 25 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xEF; BYTE $0xEC // VPXOR ymm13, ymm13, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xC9; BYTE $0x93 // VPSHUFD ymm1, ymm1, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xED; BYTE $0x93 // VPSHUFD ymm5, ymm5, 147 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xC9; BYTE $0x93 // VPSHUFD ymm9, ymm9, 147 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xED; BYTE $0x93 // VPSHUFD ymm13, ymm13, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm2, ymm2, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xF6; BYTE $0x4E // VPSHUFD ymm6, ymm6, 78 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm10, ymm10, 78 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xF6; BYTE $0x4E // VPSHUFD ymm14, ymm14, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xDB; BYTE $0x39 // VPSHUFD ymm3, ymm3, 57 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xFF; BYTE $0x39 // VPSHUFD ymm7, ymm7, 57 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xDB; BYTE $0x39 // VPSHUFD ymm11, ymm11, 57 - BYTE $0xC4; BYTE $0x41; BYTE $0x7D; BYTE $0x70; BYTE $0xFF; BYTE $0x39 // VPSHUFD ymm15, ymm15, 57 - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA ymm12, [rsp + 64] - SUBQ $2, SI - JNE rounds_loop8_begin - BYTE $0xC4; BYTE $0x62; BYTE $0x7D; BYTE $0x5A; BYTE $0x20 // VBROADCASTI128 ymm12, [rax] - BYTE $0xC4; BYTE $0xC1; BYTE $0x7D; BYTE $0xFE; BYTE $0xC4 // VPADDD ymm0, ymm0, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x5D; BYTE $0xFE; BYTE $0xE4 // VPADDD ymm4, ymm4, ymm12 - BYTE $0xC4; BYTE $0x41; BYTE $0x3D; BYTE $0xFE; BYTE $0xC4 // VPADDD ymm8, ymm8, ymm12 - BYTE $0xC5; BYTE $0x1D; BYTE $0xFE; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VPADDD ymm12, ymm12, [rsp + 64] - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA [rsp + 64], ymm12 - BYTE $0xC4; BYTE $0x62; BYTE $0x7D; BYTE $0x5A; BYTE $0x60; BYTE $0x10 // VBROADCASTI128 ymm12, [rax + 16] - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xFE; BYTE $0xCC // VPADDD ymm1, ymm1, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xFE; BYTE $0xEC // VPADDD ymm5, ymm5, ymm12 - BYTE $0xC4; BYTE $0x41; BYTE $0x35; BYTE $0xFE; BYTE $0xCC // VPADDD ymm9, ymm9, ymm12 - BYTE $0xC4; BYTE $0x41; BYTE $0x15; BYTE $0xFE; BYTE $0xEC // VPADDD ymm13, ymm13, ymm12 - BYTE $0xC4; BYTE $0x62; BYTE $0x7D; BYTE $0x5A; BYTE $0x60; BYTE $0x20 // VBROADCASTI128 ymm12, [rax + 32] - BYTE $0xC4; BYTE $0xC1; BYTE $0x6D; BYTE $0xFE; BYTE $0xD4 // VPADDD ymm2, ymm2, ymm12 - BYTE $0xC4; BYTE $0xC1; BYTE $0x4D; BYTE $0xFE; BYTE $0xF4 // VPADDD ymm6, ymm6, ymm12 - BYTE $0xC4; BYTE $0x41; BYTE $0x2D; BYTE $0xFE; BYTE $0xD4 // VPADDD ymm10, ymm10, ymm12 - BYTE $0xC4; BYTE $0x41; BYTE $0x0D; BYTE $0xFE; BYTE $0xF4 // VPADDD ymm14, ymm14, ymm12 - BYTE $0xC5; BYTE $0xE5; BYTE $0xFE; BYTE $0x5C; BYTE $0x24; BYTE $0x20 // VPADDD ymm3, ymm3, [rsp + 32] - BYTE $0xC4; BYTE $0x63; BYTE $0x7D; BYTE $0x46; BYTE $0xE1; BYTE $0x20 // VPERM2I128 ymm12, ymm0, ymm1, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x23 // VPXOR ymm12, ymm12, [rbx] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x21 // VMOVDQU [rcx], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x6D; BYTE $0x46; BYTE $0xE3; BYTE $0x20 // VPERM2I128 ymm12, ymm2, ymm3, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x20 // VPXOR ymm12, ymm12, [rbx + 32] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x20 // VMOVDQU [rcx + 32], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x7D; BYTE $0x46; BYTE $0xE1; BYTE $0x31 // VPERM2I128 ymm12, ymm0, ymm1, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x40 // VPXOR ymm12, ymm12, [rbx + 64] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x40 // VMOVDQU [rcx + 64], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x6D; BYTE $0x46; BYTE $0xE3; BYTE $0x31 // VPERM2I128 ymm12, ymm2, ymm3, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x60 // VPXOR ymm12, ymm12, [rbx + 96] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x60 // VMOVDQU [rcx + 96], ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0x5C; BYTE $0x24; BYTE $0x20 // VMOVDQA ymm3, [rsp + 32] - BYTE $0xC5; BYTE $0xE5; BYTE $0xFE; BYTE $0x1C; BYTE $0x24 // VPADDD ymm3, ymm3, [rsp] - BYTE $0xC5; BYTE $0xC5; BYTE $0xFE; BYTE $0xFB // VPADDD ymm7, ymm7, ymm3 - BYTE $0xC4; BYTE $0x63; BYTE $0x5D; BYTE $0x46; BYTE $0xE5; BYTE $0x20 // VPERM2I128 ymm12, ymm4, ymm5, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0x80; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 128] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0x80; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 128], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x4D; BYTE $0x46; BYTE $0xE7; BYTE $0x20 // VPERM2I128 ymm12, ymm6, ymm7, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0xA0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 160] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0xA0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 160], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x5D; BYTE $0x46; BYTE $0xE5; BYTE $0x31 // VPERM2I128 ymm12, ymm4, ymm5, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0xC0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 192] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0xC0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 192], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x4D; BYTE $0x46; BYTE $0xE7; BYTE $0x31 // VPERM2I128 ymm12, ymm6, ymm7, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0xE0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 224] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0xE0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 224], ymm12 - BYTE $0xC5; BYTE $0xE5; BYTE $0xFE; BYTE $0x1C; BYTE $0x24 // VPADDD ymm3, ymm3, [rsp] - BYTE $0xC5; BYTE $0x25; BYTE $0xFE; BYTE $0xDB // VPADDD ymm11, ymm11, ymm3 - BYTE $0xC4; BYTE $0x43; BYTE $0x3D; BYTE $0x46; BYTE $0xE1; BYTE $0x20 // VPERM2I128 ymm12, ymm8, ymm9, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0x00; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 256] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0x00; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 256], ymm12 - BYTE $0xC4; BYTE $0x43; BYTE $0x2D; BYTE $0x46; BYTE $0xE3; BYTE $0x20 // VPERM2I128 ymm12, ymm10, ymm11, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0x20; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 288] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0x20; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 288], ymm12 - BYTE $0xC4; BYTE $0x43; BYTE $0x3D; BYTE $0x46; BYTE $0xE1; BYTE $0x31 // VPERM2I128 ymm12, ymm8, ymm9, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0x40; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 320] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0x40; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 320], ymm12 - BYTE $0xC4; BYTE $0x43; BYTE $0x2D; BYTE $0x46; BYTE $0xE3; BYTE $0x31 // VPERM2I128 ymm12, ymm10, ymm11, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0x60; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 352] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0x60; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 352], ymm12 - BYTE $0xC5; BYTE $0xE5; BYTE $0xFE; BYTE $0x1C; BYTE $0x24 // VPADDD ymm3, ymm3, [rsp] - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0x64; BYTE $0x24; BYTE $0x40 // VMOVDQA ymm12, [rsp + 64] - BYTE $0xC5; BYTE $0x05; BYTE $0xFE; BYTE $0xFB // VPADDD ymm15, ymm15, ymm3 - BYTE $0xC4; BYTE $0xC3; BYTE $0x1D; BYTE $0x46; BYTE $0xC5; BYTE $0x20 // VPERM2I128 ymm0, ymm12, ymm13, 32 - BYTE $0xC5; BYTE $0xFD; BYTE $0xEF; BYTE $0x83; BYTE $0x80; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm0, ymm0, [rbx + 384] - BYTE $0xC5; BYTE $0xFE; BYTE $0x7F; BYTE $0x81; BYTE $0x80; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 384], ymm0 - BYTE $0xC4; BYTE $0xC3; BYTE $0x0D; BYTE $0x46; BYTE $0xC7; BYTE $0x20 // VPERM2I128 ymm0, ymm14, ymm15, 32 - BYTE $0xC5; BYTE $0xFD; BYTE $0xEF; BYTE $0x83; BYTE $0xA0; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm0, ymm0, [rbx + 416] - BYTE $0xC5; BYTE $0xFE; BYTE $0x7F; BYTE $0x81; BYTE $0xA0; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 416], ymm0 - BYTE $0xC4; BYTE $0xC3; BYTE $0x1D; BYTE $0x46; BYTE $0xC5; BYTE $0x31 // VPERM2I128 ymm0, ymm12, ymm13, 49 - BYTE $0xC5; BYTE $0xFD; BYTE $0xEF; BYTE $0x83; BYTE $0xC0; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm0, ymm0, [rbx + 448] - BYTE $0xC5; BYTE $0xFE; BYTE $0x7F; BYTE $0x81; BYTE $0xC0; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 448], ymm0 - BYTE $0xC4; BYTE $0xC3; BYTE $0x0D; BYTE $0x46; BYTE $0xC7; BYTE $0x31 // VPERM2I128 ymm0, ymm14, ymm15, 49 - BYTE $0xC5; BYTE $0xFD; BYTE $0xEF; BYTE $0x83; BYTE $0xE0; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VPXOR ymm0, ymm0, [rbx + 480] - BYTE $0xC5; BYTE $0xFE; BYTE $0x7F; BYTE $0x81; BYTE $0xE0; BYTE $0x01; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 480], ymm0 - BYTE $0xC5; BYTE $0xE5; BYTE $0xFE; BYTE $0x1C; BYTE $0x24 // VPADDD ymm3, ymm3, [rsp] - BYTE $0xC5; BYTE $0xFD; BYTE $0x7F; BYTE $0x5C; BYTE $0x24; BYTE $0x20 // VMOVDQA [rsp + 32], ymm3 - ADDQ $512, BX - ADDQ $512, CX - SUBQ $8, DX - JCC vector_loop8_begin -vector_loop8_end: - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0xDB // VMOVDQA ymm11, ymm3 - ADDQ $8, DX - JEQ out_write_even - BYTE $0xC4; BYTE $0x62; BYTE $0x7D; BYTE $0x5A; BYTE $0x00 // VBROADCASTI128 ymm8, [rax] - BYTE $0xC4; BYTE $0x62; BYTE $0x7D; BYTE $0x5A; BYTE $0x48; BYTE $0x10 // VBROADCASTI128 ymm9, [rax + 16] - BYTE $0xC4; BYTE $0x62; BYTE $0x7D; BYTE $0x5A; BYTE $0x50; BYTE $0x20 // VBROADCASTI128 ymm10, [rax + 32] - BYTE $0xC5; BYTE $0x7D; BYTE $0x6F; BYTE $0x34; BYTE $0x24 // VMOVDQA ymm14, [rsp] - SUBQ $4, DX - JCS vector_loop4_end -vector_loop4_begin: - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xC0 // VMOVDQA ymm0, ymm8 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xC9 // VMOVDQA ymm1, ymm9 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xD2 // VMOVDQA ymm2, ymm10 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xDB // VMOVDQA ymm3, ymm11 - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0xE0 // VMOVDQA ymm4, ymm0 - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0xE9 // VMOVDQA ymm5, ymm1 - BYTE $0xC5; BYTE $0xFD; BYTE $0x6F; BYTE $0xF2 // VMOVDQA ymm6, ymm2 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xD4; BYTE $0xFE // VPADDQ ymm7, ymm3, ymm14 - MOVQ $20, SI -rounds_loop4_begin: - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm3, 16 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm3, ymm3, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x10 // VPSLLD ymm12, ymm7, 16 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x10 // VPSRLD ymm7, ymm7, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm1, 12 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm1, ymm1, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x0C // VPSLLD ymm12, ymm5, 12 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x14 // VPSRLD ymm5, ymm5, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm3, 8 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm3, ymm3, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x08 // VPSLLD ymm12, ymm7, 8 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x18 // VPSRLD ymm7, ymm7, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm1, 7 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm1, ymm1, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x07 // VPSLLD ymm12, ymm5, 7 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x19 // VPSRLD ymm5, ymm5, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xC9; BYTE $0x39 // VPSHUFD ymm1, ymm1, 57 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xED; BYTE $0x39 // VPSHUFD ymm5, ymm5, 57 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm2, ymm2, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xF6; BYTE $0x4E // VPSHUFD ymm6, ymm6, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xDB; BYTE $0x93 // VPSHUFD ymm3, ymm3, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xFF; BYTE $0x93 // VPSHUFD ymm7, ymm7, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm3, 16 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm3, ymm3, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x10 // VPSLLD ymm12, ymm7, 16 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x10 // VPSRLD ymm7, ymm7, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm1, 12 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm1, ymm1, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x0C // VPSLLD ymm12, ymm5, 12 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x14 // VPSRLD ymm5, ymm5, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xDD; BYTE $0xFE; BYTE $0xE5 // VPADDD ymm4, ymm4, ymm5 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0xC5; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm4 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm3, 8 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm3, ymm3, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF7; BYTE $0x08 // VPSLLD ymm12, ymm7, 8 - BYTE $0xC5; BYTE $0xC5; BYTE $0x72; BYTE $0xD7; BYTE $0x18 // VPSRLD ymm7, ymm7, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xEF; BYTE $0xFC // VPXOR ymm7, ymm7, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xCD; BYTE $0xFE; BYTE $0xF7 // VPADDD ymm6, ymm6, ymm7 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0xD5; BYTE $0xEF; BYTE $0xEE // VPXOR ymm5, ymm5, ymm6 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm1, 7 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm1, ymm1, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF5; BYTE $0x07 // VPSLLD ymm12, ymm5, 7 - BYTE $0xC5; BYTE $0xD5; BYTE $0x72; BYTE $0xD5; BYTE $0x19 // VPSRLD ymm5, ymm5, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xEF; BYTE $0xEC // VPXOR ymm5, ymm5, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xC9; BYTE $0x93 // VPSHUFD ymm1, ymm1, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xED; BYTE $0x93 // VPSHUFD ymm5, ymm5, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm2, ymm2, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xF6; BYTE $0x4E // VPSHUFD ymm6, ymm6, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xDB; BYTE $0x39 // VPSHUFD ymm3, ymm3, 57 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xFF; BYTE $0x39 // VPSHUFD ymm7, ymm7, 57 - SUBQ $2, SI - JNE rounds_loop4_begin - BYTE $0xC4; BYTE $0xC1; BYTE $0x7D; BYTE $0xFE; BYTE $0xC0 // VPADDD ymm0, ymm0, ymm8 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xFE; BYTE $0xC9 // VPADDD ymm1, ymm1, ymm9 - BYTE $0xC4; BYTE $0xC1; BYTE $0x6D; BYTE $0xFE; BYTE $0xD2 // VPADDD ymm2, ymm2, ymm10 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xFE; BYTE $0xDB // VPADDD ymm3, ymm3, ymm11 - BYTE $0xC4; BYTE $0x63; BYTE $0x7D; BYTE $0x46; BYTE $0xE1; BYTE $0x20 // VPERM2I128 ymm12, ymm0, ymm1, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x23 // VPXOR ymm12, ymm12, [rbx] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x21 // VMOVDQU [rcx], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x6D; BYTE $0x46; BYTE $0xE3; BYTE $0x20 // VPERM2I128 ymm12, ymm2, ymm3, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x20 // VPXOR ymm12, ymm12, [rbx + 32] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x20 // VMOVDQU [rcx + 32], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x7D; BYTE $0x46; BYTE $0xE1; BYTE $0x31 // VPERM2I128 ymm12, ymm0, ymm1, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x40 // VPXOR ymm12, ymm12, [rbx + 64] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x40 // VMOVDQU [rcx + 64], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x6D; BYTE $0x46; BYTE $0xE3; BYTE $0x31 // VPERM2I128 ymm12, ymm2, ymm3, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x60 // VPXOR ymm12, ymm12, [rbx + 96] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x60 // VMOVDQU [rcx + 96], ymm12 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xFE; BYTE $0xDE // VPADDD ymm11, ymm11, ymm14 - BYTE $0xC4; BYTE $0xC1; BYTE $0x5D; BYTE $0xFE; BYTE $0xE0 // VPADDD ymm4, ymm4, ymm8 - BYTE $0xC4; BYTE $0xC1; BYTE $0x55; BYTE $0xFE; BYTE $0xE9 // VPADDD ymm5, ymm5, ymm9 - BYTE $0xC4; BYTE $0xC1; BYTE $0x4D; BYTE $0xFE; BYTE $0xF2 // VPADDD ymm6, ymm6, ymm10 - BYTE $0xC4; BYTE $0xC1; BYTE $0x45; BYTE $0xFE; BYTE $0xFB // VPADDD ymm7, ymm7, ymm11 - BYTE $0xC4; BYTE $0x63; BYTE $0x5D; BYTE $0x46; BYTE $0xE5; BYTE $0x20 // VPERM2I128 ymm12, ymm4, ymm5, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0x80; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 128] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0x80; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 128], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x4D; BYTE $0x46; BYTE $0xE7; BYTE $0x20 // VPERM2I128 ymm12, ymm6, ymm7, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0xA0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 160] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0xA0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 160], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x5D; BYTE $0x46; BYTE $0xE5; BYTE $0x31 // VPERM2I128 ymm12, ymm4, ymm5, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0xC0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 192] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0xC0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 192], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x4D; BYTE $0x46; BYTE $0xE7; BYTE $0x31 // VPERM2I128 ymm12, ymm6, ymm7, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0xA3; BYTE $0xE0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VPXOR ymm12, ymm12, [rbx + 224] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0xA1; BYTE $0xE0; BYTE $0x00; BYTE $0x00; BYTE $0x00 // VMOVDQU [rcx + 224], ymm12 - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xFE; BYTE $0xDE // VPADDD ymm11, ymm11, ymm14 - ADDQ $256, BX - ADDQ $256, CX - SUBQ $4, DX - JCC vector_loop4_begin -vector_loop4_end: - ADDQ $4, DX - JEQ out_write_even -vector_loop2_begin: - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xC0 // VMOVDQA ymm0, ymm8 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xC9 // VMOVDQA ymm1, ymm9 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xD2 // VMOVDQA ymm2, ymm10 - BYTE $0xC5; BYTE $0x7D; BYTE $0x7F; BYTE $0xDB // VMOVDQA ymm3, ymm11 - MOVQ $20, SI -rounds_loop2_begin: - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm3, 16 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm3, ymm3, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm1, 12 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm1, ymm1, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm3, 8 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm3, ymm3, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm1, 7 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm1, ymm1, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xC9; BYTE $0x39 // VPSHUFD ymm1, ymm1, 57 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm2, ymm2, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xDB; BYTE $0x93 // VPSHUFD ymm3, ymm3, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x10 // VPSLLD ymm12, ymm3, 16 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x10 // VPSRLD ymm3, ymm3, 16 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x0C // VPSLLD ymm12, ymm1, 12 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x14 // VPSRLD ymm1, ymm1, 20 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0xFE; BYTE $0xC1 // VPADDD ymm0, ymm0, ymm1 - BYTE $0xC5; BYTE $0xE5; BYTE $0xEF; BYTE $0xD8 // VPXOR ymm3, ymm3, ymm0 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF3; BYTE $0x08 // VPSLLD ymm12, ymm3, 8 - BYTE $0xC5; BYTE $0xE5; BYTE $0x72; BYTE $0xD3; BYTE $0x18 // VPSRLD ymm3, ymm3, 24 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xEF; BYTE $0xDC // VPXOR ymm3, ymm3, ymm12 - BYTE $0xC5; BYTE $0xED; BYTE $0xFE; BYTE $0xD3 // VPADDD ymm2, ymm2, ymm3 - BYTE $0xC5; BYTE $0xF5; BYTE $0xEF; BYTE $0xCA // VPXOR ymm1, ymm1, ymm2 - BYTE $0xC5; BYTE $0x9D; BYTE $0x72; BYTE $0xF1; BYTE $0x07 // VPSLLD ymm12, ymm1, 7 - BYTE $0xC5; BYTE $0xF5; BYTE $0x72; BYTE $0xD1; BYTE $0x19 // VPSRLD ymm1, ymm1, 25 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xEF; BYTE $0xCC // VPXOR ymm1, ymm1, ymm12 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xC9; BYTE $0x93 // VPSHUFD ymm1, ymm1, 147 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xD2; BYTE $0x4E // VPSHUFD ymm2, ymm2, 78 - BYTE $0xC5; BYTE $0xFD; BYTE $0x70; BYTE $0xDB; BYTE $0x39 // VPSHUFD ymm3, ymm3, 57 - SUBQ $2, SI - JNE rounds_loop2_begin - BYTE $0xC4; BYTE $0xC1; BYTE $0x7D; BYTE $0xFE; BYTE $0xC0 // VPADDD ymm0, ymm0, ymm8 - BYTE $0xC4; BYTE $0xC1; BYTE $0x75; BYTE $0xFE; BYTE $0xC9 // VPADDD ymm1, ymm1, ymm9 - BYTE $0xC4; BYTE $0xC1; BYTE $0x6D; BYTE $0xFE; BYTE $0xD2 // VPADDD ymm2, ymm2, ymm10 - BYTE $0xC4; BYTE $0xC1; BYTE $0x65; BYTE $0xFE; BYTE $0xDB // VPADDD ymm3, ymm3, ymm11 - BYTE $0xC4; BYTE $0x63; BYTE $0x7D; BYTE $0x46; BYTE $0xE1; BYTE $0x20 // VPERM2I128 ymm12, ymm0, ymm1, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x23 // VPXOR ymm12, ymm12, [rbx] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x21 // VMOVDQU [rcx], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x6D; BYTE $0x46; BYTE $0xE3; BYTE $0x20 // VPERM2I128 ymm12, ymm2, ymm3, 32 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x20 // VPXOR ymm12, ymm12, [rbx + 32] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x20 // VMOVDQU [rcx + 32], ymm12 - SUBQ $1, DX - JEQ out_write_odd - BYTE $0xC4; BYTE $0x41; BYTE $0x25; BYTE $0xFE; BYTE $0xDE // VPADDD ymm11, ymm11, ymm14 - BYTE $0xC4; BYTE $0x63; BYTE $0x7D; BYTE $0x46; BYTE $0xE1; BYTE $0x31 // VPERM2I128 ymm12, ymm0, ymm1, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x40 // VPXOR ymm12, ymm12, [rbx + 64] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x40 // VMOVDQU [rcx + 64], ymm12 - BYTE $0xC4; BYTE $0x63; BYTE $0x6D; BYTE $0x46; BYTE $0xE3; BYTE $0x31 // VPERM2I128 ymm12, ymm2, ymm3, 49 - BYTE $0xC5; BYTE $0x1D; BYTE $0xEF; BYTE $0x63; BYTE $0x60 // VPXOR ymm12, ymm12, [rbx + 96] - BYTE $0xC5; BYTE $0x7E; BYTE $0x7F; BYTE $0x61; BYTE $0x60 // VMOVDQU [rcx + 96], ymm12 - SUBQ $1, DX - JEQ out_write_even - ADDQ $128, BX - ADDQ $128, CX - JMP vector_loop2_begin -out_write_odd: - BYTE $0xC4; BYTE $0x43; BYTE $0x25; BYTE $0x46; BYTE $0xDB; BYTE $0x01 // VPERM2I128 ymm11, ymm11, ymm11, 1 -out_write_even: - BYTE $0xC5; BYTE $0x79; BYTE $0x7F; BYTE $0x58; BYTE $0x30 // VMOVDQA [rax + 48], xmm11 - BYTE $0xC5; BYTE $0xFD; BYTE $0xEF; BYTE $0xC0 // VPXOR ymm0, ymm0, ymm0 - BYTE $0xC5; BYTE $0xFD; BYTE $0x7F; BYTE $0x44; BYTE $0x24; BYTE $0x40 // VMOVDQA [rsp + 64], ymm0 - BYTE $0xC5; BYTE $0xFD; BYTE $0x7F; BYTE $0x44; BYTE $0x24; BYTE $0x20 // VMOVDQA [rsp + 32], ymm0 - MOVQ DI, SP - BYTE $0xC5; BYTE $0xF8; BYTE $0x77 // VZEROUPPER - RET - -// func cpuidAmd64(cpuidParams *uint32) -TEXT ·cpuidAmd64(SB),4,$0-8 - MOVQ cpuidParams+0(FP), R15 - MOVL 0(R15), AX - MOVL 4(R15), CX - CPUID - MOVL AX, 0(R15) - MOVL BX, 4(R15) - MOVL CX, 8(R15) - MOVL DX, 12(R15) - RET - -// func xgetbv0Amd64(xcrVec *uint32) -TEXT ·xgetbv0Amd64(SB),4,$0-8 - MOVQ xcrVec+0(FP), BX - XORL CX, CX - BYTE $0x0F; BYTE $0x01; BYTE $0xD0 // XGETBV - MOVL AX, 0(BX) - MOVL DX, 4(BX) - RET diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_ref.go b/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_ref.go deleted file mode 100644 index 694c937..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_ref.go +++ /dev/null @@ -1,392 +0,0 @@ -// chacha20_ref.go - Reference ChaCha20. -// -// To the extent possible under law, Yawning Angel has waived all copyright -// and related or neighboring rights to chacha20, using the Creative -// Commons "CC0" public domain dedication. See LICENSE or -// for full details. - -package chacha20 - -import ( - "encoding/binary" - "math" - "unsafe" -) - -func blocksRef(x *[stateSize]uint32, in []byte, out []byte, nrBlocks int, isIetf bool) { - if isIetf { - var totalBlocks uint64 - totalBlocks = uint64(x[8]) + uint64(nrBlocks) - if totalBlocks > math.MaxUint32 { - panic("chacha20: Exceeded keystream per nonce limit") - } - } - - // This routine ignores x[0]...x[4] in favor the const values since it's - // ever so slightly faster. - - for n := 0; n < nrBlocks; n++ { - x0, x1, x2, x3 := sigma0, sigma1, sigma2, sigma3 - x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 := x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], x[13], x[14], x[15] - - for i := chachaRounds; i > 0; i -= 2 { - // quarterround(x, 0, 4, 8, 12) - x0 += x4 - x12 ^= x0 - x12 = (x12 << 16) | (x12 >> 16) - x8 += x12 - x4 ^= x8 - x4 = (x4 << 12) | (x4 >> 20) - x0 += x4 - x12 ^= x0 - x12 = (x12 << 8) | (x12 >> 24) - x8 += x12 - x4 ^= x8 - x4 = (x4 << 7) | (x4 >> 25) - - // quarterround(x, 1, 5, 9, 13) - x1 += x5 - x13 ^= x1 - x13 = (x13 << 16) | (x13 >> 16) - x9 += x13 - x5 ^= x9 - x5 = (x5 << 12) | (x5 >> 20) - x1 += x5 - x13 ^= x1 - x13 = (x13 << 8) | (x13 >> 24) - x9 += x13 - x5 ^= x9 - x5 = (x5 << 7) | (x5 >> 25) - - // quarterround(x, 2, 6, 10, 14) - x2 += x6 - x14 ^= x2 - x14 = (x14 << 16) | (x14 >> 16) - x10 += x14 - x6 ^= x10 - x6 = (x6 << 12) | (x6 >> 20) - x2 += x6 - x14 ^= x2 - x14 = (x14 << 8) | (x14 >> 24) - x10 += x14 - x6 ^= x10 - x6 = (x6 << 7) | (x6 >> 25) - - // quarterround(x, 3, 7, 11, 15) - x3 += x7 - x15 ^= x3 - x15 = (x15 << 16) | (x15 >> 16) - x11 += x15 - x7 ^= x11 - x7 = (x7 << 12) | (x7 >> 20) - x3 += x7 - x15 ^= x3 - x15 = (x15 << 8) | (x15 >> 24) - x11 += x15 - x7 ^= x11 - x7 = (x7 << 7) | (x7 >> 25) - - // quarterround(x, 0, 5, 10, 15) - x0 += x5 - x15 ^= x0 - x15 = (x15 << 16) | (x15 >> 16) - x10 += x15 - x5 ^= x10 - x5 = (x5 << 12) | (x5 >> 20) - x0 += x5 - x15 ^= x0 - x15 = (x15 << 8) | (x15 >> 24) - x10 += x15 - x5 ^= x10 - x5 = (x5 << 7) | (x5 >> 25) - - // quarterround(x, 1, 6, 11, 12) - x1 += x6 - x12 ^= x1 - x12 = (x12 << 16) | (x12 >> 16) - x11 += x12 - x6 ^= x11 - x6 = (x6 << 12) | (x6 >> 20) - x1 += x6 - x12 ^= x1 - x12 = (x12 << 8) | (x12 >> 24) - x11 += x12 - x6 ^= x11 - x6 = (x6 << 7) | (x6 >> 25) - - // quarterround(x, 2, 7, 8, 13) - x2 += x7 - x13 ^= x2 - x13 = (x13 << 16) | (x13 >> 16) - x8 += x13 - x7 ^= x8 - x7 = (x7 << 12) | (x7 >> 20) - x2 += x7 - x13 ^= x2 - x13 = (x13 << 8) | (x13 >> 24) - x8 += x13 - x7 ^= x8 - x7 = (x7 << 7) | (x7 >> 25) - - // quarterround(x, 3, 4, 9, 14) - x3 += x4 - x14 ^= x3 - x14 = (x14 << 16) | (x14 >> 16) - x9 += x14 - x4 ^= x9 - x4 = (x4 << 12) | (x4 >> 20) - x3 += x4 - x14 ^= x3 - x14 = (x14 << 8) | (x14 >> 24) - x9 += x14 - x4 ^= x9 - x4 = (x4 << 7) | (x4 >> 25) - } - - // On amd64 at least, this is a rather big boost. - if useUnsafe { - if in != nil { - inArr := (*[16]uint32)(unsafe.Pointer(&in[n*BlockSize])) - outArr := (*[16]uint32)(unsafe.Pointer(&out[n*BlockSize])) - outArr[0] = inArr[0] ^ (x0 + sigma0) - outArr[1] = inArr[1] ^ (x1 + sigma1) - outArr[2] = inArr[2] ^ (x2 + sigma2) - outArr[3] = inArr[3] ^ (x3 + sigma3) - outArr[4] = inArr[4] ^ (x4 + x[4]) - outArr[5] = inArr[5] ^ (x5 + x[5]) - outArr[6] = inArr[6] ^ (x6 + x[6]) - outArr[7] = inArr[7] ^ (x7 + x[7]) - outArr[8] = inArr[8] ^ (x8 + x[8]) - outArr[9] = inArr[9] ^ (x9 + x[9]) - outArr[10] = inArr[10] ^ (x10 + x[10]) - outArr[11] = inArr[11] ^ (x11 + x[11]) - outArr[12] = inArr[12] ^ (x12 + x[12]) - outArr[13] = inArr[13] ^ (x13 + x[13]) - outArr[14] = inArr[14] ^ (x14 + x[14]) - outArr[15] = inArr[15] ^ (x15 + x[15]) - } else { - outArr := (*[16]uint32)(unsafe.Pointer(&out[n*BlockSize])) - outArr[0] = x0 + sigma0 - outArr[1] = x1 + sigma1 - outArr[2] = x2 + sigma2 - outArr[3] = x3 + sigma3 - outArr[4] = x4 + x[4] - outArr[5] = x5 + x[5] - outArr[6] = x6 + x[6] - outArr[7] = x7 + x[7] - outArr[8] = x8 + x[8] - outArr[9] = x9 + x[9] - outArr[10] = x10 + x[10] - outArr[11] = x11 + x[11] - outArr[12] = x12 + x[12] - outArr[13] = x13 + x[13] - outArr[14] = x14 + x[14] - outArr[15] = x15 + x[15] - } - } else { - // Slow path, either the architecture cares about alignment, or is not little endian. - x0 += sigma0 - x1 += sigma1 - x2 += sigma2 - x3 += sigma3 - x4 += x[4] - x5 += x[5] - x6 += x[6] - x7 += x[7] - x8 += x[8] - x9 += x[9] - x10 += x[10] - x11 += x[11] - x12 += x[12] - x13 += x[13] - x14 += x[14] - x15 += x[15] - if in != nil { - binary.LittleEndian.PutUint32(out[0:4], binary.LittleEndian.Uint32(in[0:4])^x0) - binary.LittleEndian.PutUint32(out[4:8], binary.LittleEndian.Uint32(in[4:8])^x1) - binary.LittleEndian.PutUint32(out[8:12], binary.LittleEndian.Uint32(in[8:12])^x2) - binary.LittleEndian.PutUint32(out[12:16], binary.LittleEndian.Uint32(in[12:16])^x3) - binary.LittleEndian.PutUint32(out[16:20], binary.LittleEndian.Uint32(in[16:20])^x4) - binary.LittleEndian.PutUint32(out[20:24], binary.LittleEndian.Uint32(in[20:24])^x5) - binary.LittleEndian.PutUint32(out[24:28], binary.LittleEndian.Uint32(in[24:28])^x6) - binary.LittleEndian.PutUint32(out[28:32], binary.LittleEndian.Uint32(in[28:32])^x7) - binary.LittleEndian.PutUint32(out[32:36], binary.LittleEndian.Uint32(in[32:36])^x8) - binary.LittleEndian.PutUint32(out[36:40], binary.LittleEndian.Uint32(in[36:40])^x9) - binary.LittleEndian.PutUint32(out[40:44], binary.LittleEndian.Uint32(in[40:44])^x10) - binary.LittleEndian.PutUint32(out[44:48], binary.LittleEndian.Uint32(in[44:48])^x11) - binary.LittleEndian.PutUint32(out[48:52], binary.LittleEndian.Uint32(in[48:52])^x12) - binary.LittleEndian.PutUint32(out[52:56], binary.LittleEndian.Uint32(in[52:56])^x13) - binary.LittleEndian.PutUint32(out[56:60], binary.LittleEndian.Uint32(in[56:60])^x14) - binary.LittleEndian.PutUint32(out[60:64], binary.LittleEndian.Uint32(in[60:64])^x15) - in = in[BlockSize:] - } else { - binary.LittleEndian.PutUint32(out[0:4], x0) - binary.LittleEndian.PutUint32(out[4:8], x1) - binary.LittleEndian.PutUint32(out[8:12], x2) - binary.LittleEndian.PutUint32(out[12:16], x3) - binary.LittleEndian.PutUint32(out[16:20], x4) - binary.LittleEndian.PutUint32(out[20:24], x5) - binary.LittleEndian.PutUint32(out[24:28], x6) - binary.LittleEndian.PutUint32(out[28:32], x7) - binary.LittleEndian.PutUint32(out[32:36], x8) - binary.LittleEndian.PutUint32(out[36:40], x9) - binary.LittleEndian.PutUint32(out[40:44], x10) - binary.LittleEndian.PutUint32(out[44:48], x11) - binary.LittleEndian.PutUint32(out[48:52], x12) - binary.LittleEndian.PutUint32(out[52:56], x13) - binary.LittleEndian.PutUint32(out[56:60], x14) - binary.LittleEndian.PutUint32(out[60:64], x15) - } - out = out[BlockSize:] - } - - // Stoping at 2^70 bytes per nonce is the user's responsibility. - ctr := uint64(x[13])<<32 | uint64(x[12]) - ctr++ - x[12] = uint32(ctr) - x[13] = uint32(ctr >> 32) - } -} - -func hChaChaRef(x *[stateSize]uint32, out *[32]byte) { - x0, x1, x2, x3 := sigma0, sigma1, sigma2, sigma3 - x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15 := x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11] - - for i := chachaRounds; i > 0; i -= 2 { - // quarterround(x, 0, 4, 8, 12) - x0 += x4 - x12 ^= x0 - x12 = (x12 << 16) | (x12 >> 16) - x8 += x12 - x4 ^= x8 - x4 = (x4 << 12) | (x4 >> 20) - x0 += x4 - x12 ^= x0 - x12 = (x12 << 8) | (x12 >> 24) - x8 += x12 - x4 ^= x8 - x4 = (x4 << 7) | (x4 >> 25) - - // quarterround(x, 1, 5, 9, 13) - x1 += x5 - x13 ^= x1 - x13 = (x13 << 16) | (x13 >> 16) - x9 += x13 - x5 ^= x9 - x5 = (x5 << 12) | (x5 >> 20) - x1 += x5 - x13 ^= x1 - x13 = (x13 << 8) | (x13 >> 24) - x9 += x13 - x5 ^= x9 - x5 = (x5 << 7) | (x5 >> 25) - - // quarterround(x, 2, 6, 10, 14) - x2 += x6 - x14 ^= x2 - x14 = (x14 << 16) | (x14 >> 16) - x10 += x14 - x6 ^= x10 - x6 = (x6 << 12) | (x6 >> 20) - x2 += x6 - x14 ^= x2 - x14 = (x14 << 8) | (x14 >> 24) - x10 += x14 - x6 ^= x10 - x6 = (x6 << 7) | (x6 >> 25) - - // quarterround(x, 3, 7, 11, 15) - x3 += x7 - x15 ^= x3 - x15 = (x15 << 16) | (x15 >> 16) - x11 += x15 - x7 ^= x11 - x7 = (x7 << 12) | (x7 >> 20) - x3 += x7 - x15 ^= x3 - x15 = (x15 << 8) | (x15 >> 24) - x11 += x15 - x7 ^= x11 - x7 = (x7 << 7) | (x7 >> 25) - - // quarterround(x, 0, 5, 10, 15) - x0 += x5 - x15 ^= x0 - x15 = (x15 << 16) | (x15 >> 16) - x10 += x15 - x5 ^= x10 - x5 = (x5 << 12) | (x5 >> 20) - x0 += x5 - x15 ^= x0 - x15 = (x15 << 8) | (x15 >> 24) - x10 += x15 - x5 ^= x10 - x5 = (x5 << 7) | (x5 >> 25) - - // quarterround(x, 1, 6, 11, 12) - x1 += x6 - x12 ^= x1 - x12 = (x12 << 16) | (x12 >> 16) - x11 += x12 - x6 ^= x11 - x6 = (x6 << 12) | (x6 >> 20) - x1 += x6 - x12 ^= x1 - x12 = (x12 << 8) | (x12 >> 24) - x11 += x12 - x6 ^= x11 - x6 = (x6 << 7) | (x6 >> 25) - - // quarterround(x, 2, 7, 8, 13) - x2 += x7 - x13 ^= x2 - x13 = (x13 << 16) | (x13 >> 16) - x8 += x13 - x7 ^= x8 - x7 = (x7 << 12) | (x7 >> 20) - x2 += x7 - x13 ^= x2 - x13 = (x13 << 8) | (x13 >> 24) - x8 += x13 - x7 ^= x8 - x7 = (x7 << 7) | (x7 >> 25) - - // quarterround(x, 3, 4, 9, 14) - x3 += x4 - x14 ^= x3 - x14 = (x14 << 16) | (x14 >> 16) - x9 += x14 - x4 ^= x9 - x4 = (x4 << 12) | (x4 >> 20) - x3 += x4 - x14 ^= x3 - x14 = (x14 << 8) | (x14 >> 24) - x9 += x14 - x4 ^= x9 - x4 = (x4 << 7) | (x4 >> 25) - } - - // HChaCha returns x0...x3 | x12...x15, which corresponds to the - // indexes of the ChaCha constant and the indexes of the IV. - if useUnsafe { - outArr := (*[16]uint32)(unsafe.Pointer(&out[0])) - outArr[0] = x0 - outArr[1] = x1 - outArr[2] = x2 - outArr[3] = x3 - outArr[4] = x12 - outArr[5] = x13 - outArr[6] = x14 - outArr[7] = x15 - } else { - binary.LittleEndian.PutUint32(out[0:4], x0) - binary.LittleEndian.PutUint32(out[4:8], x1) - binary.LittleEndian.PutUint32(out[8:12], x2) - binary.LittleEndian.PutUint32(out[12:16], x3) - binary.LittleEndian.PutUint32(out[16:20], x12) - binary.LittleEndian.PutUint32(out[20:24], x13) - binary.LittleEndian.PutUint32(out[24:28], x14) - binary.LittleEndian.PutUint32(out[28:32], x15) - } - return -} diff --git a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_test.go b/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_test.go deleted file mode 100644 index 3ba9b11..0000000 --- a/vendor/git.schwanenlied.me/yawning/chacha20.git/chacha20_test.go +++ /dev/null @@ -1,523 +0,0 @@ -// chacha20_test.go - ChaCha stream cipher implementation tests. -// -// To the extent possible under law, Yawning Angel waived all copyright -// and related or neighboring rights to chacha20, using the Creative -// Commons "CC0" public domain dedication. See LICENSE or -// for full details. - -package chacha20 - -import ( - "bytes" - "crypto/aes" - "crypto/cipher" - "crypto/rand" - "encoding/hex" - "testing" -) - -// Test vectors taken from: -// https://tools.ietf.org/html/draft-strombergson-chacha-test-vectors-01 -var draftTestVectors = []struct { - name string - key []byte - iv []byte - stream []byte - seekOffset uint64 -}{ - { - name: "IETF Draft: TC1: All zero key and IV.", - key: []byte{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - iv: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - stream: []byte{ - 0x76, 0xb8, 0xe0, 0xad, 0xa0, 0xf1, 0x3d, 0x90, - 0x40, 0x5d, 0x6a, 0xe5, 0x53, 0x86, 0xbd, 0x28, - 0xbd, 0xd2, 0x19, 0xb8, 0xa0, 0x8d, 0xed, 0x1a, - 0xa8, 0x36, 0xef, 0xcc, 0x8b, 0x77, 0x0d, 0xc7, - 0xda, 0x41, 0x59, 0x7c, 0x51, 0x57, 0x48, 0x8d, - 0x77, 0x24, 0xe0, 0x3f, 0xb8, 0xd8, 0x4a, 0x37, - 0x6a, 0x43, 0xb8, 0xf4, 0x15, 0x18, 0xa1, 0x1c, - 0xc3, 0x87, 0xb6, 0x69, 0xb2, 0xee, 0x65, 0x86, - 0x9f, 0x07, 0xe7, 0xbe, 0x55, 0x51, 0x38, 0x7a, - 0x98, 0xba, 0x97, 0x7c, 0x73, 0x2d, 0x08, 0x0d, - 0xcb, 0x0f, 0x29, 0xa0, 0x48, 0xe3, 0x65, 0x69, - 0x12, 0xc6, 0x53, 0x3e, 0x32, 0xee, 0x7a, 0xed, - 0x29, 0xb7, 0x21, 0x76, 0x9c, 0xe6, 0x4e, 0x43, - 0xd5, 0x71, 0x33, 0xb0, 0x74, 0xd8, 0x39, 0xd5, - 0x31, 0xed, 0x1f, 0x28, 0x51, 0x0a, 0xfb, 0x45, - 0xac, 0xe1, 0x0a, 0x1f, 0x4b, 0x79, 0x4d, 0x6f, - }, - }, - { - name: "IETF Draft: TC2: Single bit in key set. All zero IV.", - key: []byte{ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - iv: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - stream: []byte{ - 0xc5, 0xd3, 0x0a, 0x7c, 0xe1, 0xec, 0x11, 0x93, - 0x78, 0xc8, 0x4f, 0x48, 0x7d, 0x77, 0x5a, 0x85, - 0x42, 0xf1, 0x3e, 0xce, 0x23, 0x8a, 0x94, 0x55, - 0xe8, 0x22, 0x9e, 0x88, 0x8d, 0xe8, 0x5b, 0xbd, - 0x29, 0xeb, 0x63, 0xd0, 0xa1, 0x7a, 0x5b, 0x99, - 0x9b, 0x52, 0xda, 0x22, 0xbe, 0x40, 0x23, 0xeb, - 0x07, 0x62, 0x0a, 0x54, 0xf6, 0xfa, 0x6a, 0xd8, - 0x73, 0x7b, 0x71, 0xeb, 0x04, 0x64, 0xda, 0xc0, - 0x10, 0xf6, 0x56, 0xe6, 0xd1, 0xfd, 0x55, 0x05, - 0x3e, 0x50, 0xc4, 0x87, 0x5c, 0x99, 0x30, 0xa3, - 0x3f, 0x6d, 0x02, 0x63, 0xbd, 0x14, 0xdf, 0xd6, - 0xab, 0x8c, 0x70, 0x52, 0x1c, 0x19, 0x33, 0x8b, - 0x23, 0x08, 0xb9, 0x5c, 0xf8, 0xd0, 0xbb, 0x7d, - 0x20, 0x2d, 0x21, 0x02, 0x78, 0x0e, 0xa3, 0x52, - 0x8f, 0x1c, 0xb4, 0x85, 0x60, 0xf7, 0x6b, 0x20, - 0xf3, 0x82, 0xb9, 0x42, 0x50, 0x0f, 0xce, 0xac, - }, - }, - { - name: "IETF Draft: TC3: Single bit in IV set. All zero key.", - key: []byte{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - iv: []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, - stream: []byte{ - 0xef, 0x3f, 0xdf, 0xd6, 0xc6, 0x15, 0x78, 0xfb, - 0xf5, 0xcf, 0x35, 0xbd, 0x3d, 0xd3, 0x3b, 0x80, - 0x09, 0x63, 0x16, 0x34, 0xd2, 0x1e, 0x42, 0xac, - 0x33, 0x96, 0x0b, 0xd1, 0x38, 0xe5, 0x0d, 0x32, - 0x11, 0x1e, 0x4c, 0xaf, 0x23, 0x7e, 0xe5, 0x3c, - 0xa8, 0xad, 0x64, 0x26, 0x19, 0x4a, 0x88, 0x54, - 0x5d, 0xdc, 0x49, 0x7a, 0x0b, 0x46, 0x6e, 0x7d, - 0x6b, 0xbd, 0xb0, 0x04, 0x1b, 0x2f, 0x58, 0x6b, - 0x53, 0x05, 0xe5, 0xe4, 0x4a, 0xff, 0x19, 0xb2, - 0x35, 0x93, 0x61, 0x44, 0x67, 0x5e, 0xfb, 0xe4, - 0x40, 0x9e, 0xb7, 0xe8, 0xe5, 0xf1, 0x43, 0x0f, - 0x5f, 0x58, 0x36, 0xae, 0xb4, 0x9b, 0xb5, 0x32, - 0x8b, 0x01, 0x7c, 0x4b, 0x9d, 0xc1, 0x1f, 0x8a, - 0x03, 0x86, 0x3f, 0xa8, 0x03, 0xdc, 0x71, 0xd5, - 0x72, 0x6b, 0x2b, 0x6b, 0x31, 0xaa, 0x32, 0x70, - 0x8a, 0xfe, 0x5a, 0xf1, 0xd6, 0xb6, 0x90, 0x58, - }, - }, - { - name: "IETF Draft: TC4: All bits in key and IV are set.", - key: []byte{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - }, - iv: []byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, - stream: []byte{ - 0xd9, 0xbf, 0x3f, 0x6b, 0xce, 0x6e, 0xd0, 0xb5, - 0x42, 0x54, 0x55, 0x77, 0x67, 0xfb, 0x57, 0x44, - 0x3d, 0xd4, 0x77, 0x89, 0x11, 0xb6, 0x06, 0x05, - 0x5c, 0x39, 0xcc, 0x25, 0xe6, 0x74, 0xb8, 0x36, - 0x3f, 0xea, 0xbc, 0x57, 0xfd, 0xe5, 0x4f, 0x79, - 0x0c, 0x52, 0xc8, 0xae, 0x43, 0x24, 0x0b, 0x79, - 0xd4, 0x90, 0x42, 0xb7, 0x77, 0xbf, 0xd6, 0xcb, - 0x80, 0xe9, 0x31, 0x27, 0x0b, 0x7f, 0x50, 0xeb, - 0x5b, 0xac, 0x2a, 0xcd, 0x86, 0xa8, 0x36, 0xc5, - 0xdc, 0x98, 0xc1, 0x16, 0xc1, 0x21, 0x7e, 0xc3, - 0x1d, 0x3a, 0x63, 0xa9, 0x45, 0x13, 0x19, 0xf0, - 0x97, 0xf3, 0xb4, 0xd6, 0xda, 0xb0, 0x77, 0x87, - 0x19, 0x47, 0x7d, 0x24, 0xd2, 0x4b, 0x40, 0x3a, - 0x12, 0x24, 0x1d, 0x7c, 0xca, 0x06, 0x4f, 0x79, - 0x0f, 0x1d, 0x51, 0xcc, 0xaf, 0xf6, 0xb1, 0x66, - 0x7d, 0x4b, 0xbc, 0xa1, 0x95, 0x8c, 0x43, 0x06, - }, - }, - { - name: "IETF Draft: TC5: Every even bit set in key and IV.", - key: []byte{ - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, - }, - iv: []byte{0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55}, - stream: []byte{ - 0xbe, 0xa9, 0x41, 0x1a, 0xa4, 0x53, 0xc5, 0x43, - 0x4a, 0x5a, 0xe8, 0xc9, 0x28, 0x62, 0xf5, 0x64, - 0x39, 0x68, 0x55, 0xa9, 0xea, 0x6e, 0x22, 0xd6, - 0xd3, 0xb5, 0x0a, 0xe1, 0xb3, 0x66, 0x33, 0x11, - 0xa4, 0xa3, 0x60, 0x6c, 0x67, 0x1d, 0x60, 0x5c, - 0xe1, 0x6c, 0x3a, 0xec, 0xe8, 0xe6, 0x1e, 0xa1, - 0x45, 0xc5, 0x97, 0x75, 0x01, 0x7b, 0xee, 0x2f, - 0xa6, 0xf8, 0x8a, 0xfc, 0x75, 0x80, 0x69, 0xf7, - 0xe0, 0xb8, 0xf6, 0x76, 0xe6, 0x44, 0x21, 0x6f, - 0x4d, 0x2a, 0x34, 0x22, 0xd7, 0xfa, 0x36, 0xc6, - 0xc4, 0x93, 0x1a, 0xca, 0x95, 0x0e, 0x9d, 0xa4, - 0x27, 0x88, 0xe6, 0xd0, 0xb6, 0xd1, 0xcd, 0x83, - 0x8e, 0xf6, 0x52, 0xe9, 0x7b, 0x14, 0x5b, 0x14, - 0x87, 0x1e, 0xae, 0x6c, 0x68, 0x04, 0xc7, 0x00, - 0x4d, 0xb5, 0xac, 0x2f, 0xce, 0x4c, 0x68, 0xc7, - 0x26, 0xd0, 0x04, 0xb1, 0x0f, 0xca, 0xba, 0x86, - }, - }, - { - name: "IETF Draft: TC6: Every odd bit set in key and IV.", - key: []byte{ - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, - }, - iv: []byte{0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa}, - stream: []byte{ - 0x9a, 0xa2, 0xa9, 0xf6, 0x56, 0xef, 0xde, 0x5a, - 0xa7, 0x59, 0x1c, 0x5f, 0xed, 0x4b, 0x35, 0xae, - 0xa2, 0x89, 0x5d, 0xec, 0x7c, 0xb4, 0x54, 0x3b, - 0x9e, 0x9f, 0x21, 0xf5, 0xe7, 0xbc, 0xbc, 0xf3, - 0xc4, 0x3c, 0x74, 0x8a, 0x97, 0x08, 0x88, 0xf8, - 0x24, 0x83, 0x93, 0xa0, 0x9d, 0x43, 0xe0, 0xb7, - 0xe1, 0x64, 0xbc, 0x4d, 0x0b, 0x0f, 0xb2, 0x40, - 0xa2, 0xd7, 0x21, 0x15, 0xc4, 0x80, 0x89, 0x06, - 0x72, 0x18, 0x44, 0x89, 0x44, 0x05, 0x45, 0xd0, - 0x21, 0xd9, 0x7e, 0xf6, 0xb6, 0x93, 0xdf, 0xe5, - 0xb2, 0xc1, 0x32, 0xd4, 0x7e, 0x6f, 0x04, 0x1c, - 0x90, 0x63, 0x65, 0x1f, 0x96, 0xb6, 0x23, 0xe6, - 0x2a, 0x11, 0x99, 0x9a, 0x23, 0xb6, 0xf7, 0xc4, - 0x61, 0xb2, 0x15, 0x30, 0x26, 0xad, 0x5e, 0x86, - 0x6a, 0x2e, 0x59, 0x7e, 0xd0, 0x7b, 0x84, 0x01, - 0xde, 0xc6, 0x3a, 0x09, 0x34, 0xc6, 0xb2, 0xa9, - }, - }, - { - name: "IETF Draft: TC7: Sequence patterns in key and IV.", - key: []byte{ - 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, - 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, - 0xff, 0xee, 0xdd, 0xcc, 0xbb, 0xaa, 0x99, 0x88, - 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11, 0x00, - }, - iv: []byte{0x0f, 0x1e, 0x2d, 0x3c, 0x4b, 0x5a, 0x69, 0x78}, - stream: []byte{ - 0x9f, 0xad, 0xf4, 0x09, 0xc0, 0x08, 0x11, 0xd0, - 0x04, 0x31, 0xd6, 0x7e, 0xfb, 0xd8, 0x8f, 0xba, - 0x59, 0x21, 0x8d, 0x5d, 0x67, 0x08, 0xb1, 0xd6, - 0x85, 0x86, 0x3f, 0xab, 0xbb, 0x0e, 0x96, 0x1e, - 0xea, 0x48, 0x0f, 0xd6, 0xfb, 0x53, 0x2b, 0xfd, - 0x49, 0x4b, 0x21, 0x51, 0x01, 0x50, 0x57, 0x42, - 0x3a, 0xb6, 0x0a, 0x63, 0xfe, 0x4f, 0x55, 0xf7, - 0xa2, 0x12, 0xe2, 0x16, 0x7c, 0xca, 0xb9, 0x31, - 0xfb, 0xfd, 0x29, 0xcf, 0x7b, 0xc1, 0xd2, 0x79, - 0xed, 0xdf, 0x25, 0xdd, 0x31, 0x6b, 0xb8, 0x84, - 0x3d, 0x6e, 0xde, 0xe0, 0xbd, 0x1e, 0xf1, 0x21, - 0xd1, 0x2f, 0xa1, 0x7c, 0xbc, 0x2c, 0x57, 0x4c, - 0xcc, 0xab, 0x5e, 0x27, 0x51, 0x67, 0xb0, 0x8b, - 0xd6, 0x86, 0xf8, 0xa0, 0x9d, 0xf8, 0x7e, 0xc3, - 0xff, 0xb3, 0x53, 0x61, 0xb9, 0x4e, 0xbf, 0xa1, - 0x3f, 0xec, 0x0e, 0x48, 0x89, 0xd1, 0x8d, 0xa5, - }, - }, - { - name: "IETF Draft: TC8: key: 'All your base are belong to us!, IV: 'IETF2013'", - key: []byte{ - 0xc4, 0x6e, 0xc1, 0xb1, 0x8c, 0xe8, 0xa8, 0x78, - 0x72, 0x5a, 0x37, 0xe7, 0x80, 0xdf, 0xb7, 0x35, - 0x1f, 0x68, 0xed, 0x2e, 0x19, 0x4c, 0x79, 0xfb, - 0xc6, 0xae, 0xbe, 0xe1, 0xa6, 0x67, 0x97, 0x5d, - }, - iv: []byte{0x1a, 0xda, 0x31, 0xd5, 0xcf, 0x68, 0x82, 0x21}, - stream: []byte{ - 0xf6, 0x3a, 0x89, 0xb7, 0x5c, 0x22, 0x71, 0xf9, - 0x36, 0x88, 0x16, 0x54, 0x2b, 0xa5, 0x2f, 0x06, - 0xed, 0x49, 0x24, 0x17, 0x92, 0x30, 0x2b, 0x00, - 0xb5, 0xe8, 0xf8, 0x0a, 0xe9, 0xa4, 0x73, 0xaf, - 0xc2, 0x5b, 0x21, 0x8f, 0x51, 0x9a, 0xf0, 0xfd, - 0xd4, 0x06, 0x36, 0x2e, 0x8d, 0x69, 0xde, 0x7f, - 0x54, 0xc6, 0x04, 0xa6, 0xe0, 0x0f, 0x35, 0x3f, - 0x11, 0x0f, 0x77, 0x1b, 0xdc, 0xa8, 0xab, 0x92, - 0xe5, 0xfb, 0xc3, 0x4e, 0x60, 0xa1, 0xd9, 0xa9, - 0xdb, 0x17, 0x34, 0x5b, 0x0a, 0x40, 0x27, 0x36, - 0x85, 0x3b, 0xf9, 0x10, 0xb0, 0x60, 0xbd, 0xf1, - 0xf8, 0x97, 0xb6, 0x29, 0x0f, 0x01, 0xd1, 0x38, - 0xae, 0x2c, 0x4c, 0x90, 0x22, 0x5b, 0xa9, 0xea, - 0x14, 0xd5, 0x18, 0xf5, 0x59, 0x29, 0xde, 0xa0, - 0x98, 0xca, 0x7a, 0x6c, 0xcf, 0xe6, 0x12, 0x27, - 0x05, 0x3c, 0x84, 0xe4, 0x9a, 0x4a, 0x33, 0x32, - }, - }, - { - name: "XChaCha20 Test", - key: []byte{ - 0x1b, 0x27, 0x55, 0x64, 0x73, 0xe9, 0x85, 0xd4, - 0x62, 0xcd, 0x51, 0x19, 0x7a, 0x9a, 0x46, 0xc7, - 0x60, 0x09, 0x54, 0x9e, 0xac, 0x64, 0x74, 0xf2, - 0x06, 0xc4, 0xee, 0x08, 0x44, 0xf6, 0x83, 0x89, - }, - iv: []byte{ - 0x69, 0x69, 0x6e, 0xe9, 0x55, 0xb6, 0x2b, 0x73, - 0xcd, 0x62, 0xbd, 0xa8, 0x75, 0xfc, 0x73, 0xd6, - 0x82, 0x19, 0xe0, 0x03, 0x6b, 0x7a, 0x0b, 0x37, - }, - stream: []byte{ - 0x4f, 0xeb, 0xf2, 0xfe, 0x4b, 0x35, 0x9c, 0x50, - 0x8d, 0xc5, 0xe8, 0xb5, 0x98, 0x0c, 0x88, 0xe3, - 0x89, 0x46, 0xd8, 0xf1, 0x8f, 0x31, 0x34, 0x65, - 0xc8, 0x62, 0xa0, 0x87, 0x82, 0x64, 0x82, 0x48, - 0x01, 0x8d, 0xac, 0xdc, 0xb9, 0x04, 0x17, 0x88, - 0x53, 0xa4, 0x6d, 0xca, 0x3a, 0x0e, 0xaa, 0xee, - 0x74, 0x7c, 0xba, 0x97, 0x43, 0x4e, 0xaf, 0xfa, - 0xd5, 0x8f, 0xea, 0x82, 0x22, 0x04, 0x7e, 0x0d, - 0xe6, 0xc3, 0xa6, 0x77, 0x51, 0x06, 0xe0, 0x33, - 0x1a, 0xd7, 0x14, 0xd2, 0xf2, 0x7a, 0x55, 0x64, - 0x13, 0x40, 0xa1, 0xf1, 0xdd, 0x9f, 0x94, 0x53, - 0x2e, 0x68, 0xcb, 0x24, 0x1c, 0xbd, 0xd1, 0x50, - 0x97, 0x0d, 0x14, 0xe0, 0x5c, 0x5b, 0x17, 0x31, - 0x93, 0xfb, 0x14, 0xf5, 0x1c, 0x41, 0xf3, 0x93, - 0x83, 0x5b, 0xf7, 0xf4, 0x16, 0xa7, 0xe0, 0xbb, - 0xa8, 0x1f, 0xfb, 0x8b, 0x13, 0xaf, 0x0e, 0x21, - 0x69, 0x1d, 0x7e, 0xce, 0xc9, 0x3b, 0x75, 0xe6, - 0xe4, 0x18, 0x3a, - }, - }, - { - name: "RFC 7539 Test Vector (96 bit nonce)", - key: []byte{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - }, - iv: []byte{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4a, - 0x00, 0x00, 0x00, 0x00, - }, - stream: []byte{ - 0x22, 0x4f, 0x51, 0xf3, 0x40, 0x1b, 0xd9, 0xe1, - 0x2f, 0xde, 0x27, 0x6f, 0xb8, 0x63, 0x1d, 0xed, - 0x8c, 0x13, 0x1f, 0x82, 0x3d, 0x2c, 0x06, 0xe2, - 0x7e, 0x4f, 0xca, 0xec, 0x9e, 0xf3, 0xcf, 0x78, - 0x8a, 0x3b, 0x0a, 0xa3, 0x72, 0x60, 0x0a, 0x92, - 0xb5, 0x79, 0x74, 0xcd, 0xed, 0x2b, 0x93, 0x34, - 0x79, 0x4c, 0xba, 0x40, 0xc6, 0x3e, 0x34, 0xcd, - 0xea, 0x21, 0x2c, 0x4c, 0xf0, 0x7d, 0x41, 0xb7, - 0x69, 0xa6, 0x74, 0x9f, 0x3f, 0x63, 0x0f, 0x41, - 0x22, 0xca, 0xfe, 0x28, 0xec, 0x4d, 0xc4, 0x7e, - 0x26, 0xd4, 0x34, 0x6d, 0x70, 0xb9, 0x8c, 0x73, - 0xf3, 0xe9, 0xc5, 0x3a, 0xc4, 0x0c, 0x59, 0x45, - 0x39, 0x8b, 0x6e, 0xda, 0x1a, 0x83, 0x2c, 0x89, - 0xc1, 0x67, 0xea, 0xcd, 0x90, 0x1d, 0x7e, 0x2b, - 0xf3, 0x63, - }, - seekOffset: 1, - }, -} - -func TestChaCha20(t *testing.T) { - for _, v := range draftTestVectors { - c, err := NewCipher(v.key, v.iv) - if err != nil { - t.Errorf("[%s]: New(k, iv) returned: %s", v.name, err) - continue - } - if v.seekOffset != 0 { - if err = c.Seek(v.seekOffset); err != nil { - t.Errorf("[%s]: Seek(seekOffset) returned: %s", v.name, err) - continue - } - } - out := make([]byte, len(v.stream)) - c.XORKeyStream(out, out) - if !bytes.Equal(out, v.stream) { - t.Errorf("[%s]: out != stream (%x != %x)", v.name, out, v.stream) - } - } -} - -func TestChaCha20Vectorized(t *testing.T) { - if !usingVectors { - t.Skip("vectorized ChaCha20 support not enabled") - } - - // Save the batch blocks processing routine so we can mess with it, and - // restore it when we're done. - oldBlocksFn := blocksFn - defer func() { - blocksFn = oldBlocksFn - }() - - const testSz = 1024 * 16 - - // Generate a random key, nonce and input. - var key [KeySize]byte - var nonce [NonceSize]byte - var input [testSz]byte - var vecOut [testSz]byte - var refOut [testSz]byte - rand.Read(key[:]) - rand.Read(nonce[:]) - rand.Read(input[:]) - - for i := 0; i < testSz; i++ { - // Encrypt with the vectorized implementation. - c, err := NewCipher(key[:], nonce[:]) - if err != nil { - t.Fatal(err) - } - c.XORKeyStream(vecOut[:], input[:i]) - - c, err = NewCipher(key[:], nonce[:]) - if err != nil { - t.Fatal(err) - } - blocksFn = blocksRef - c.XORKeyStream(refOut[:], input[:i]) - if !bytes.Equal(refOut[:i], vecOut[:i]) { - for j, v := range refOut { - if vecOut[j] != v { - t.Errorf("[%d] mismatch at offset: %d %x != %x", i, j, vecOut[j], v) - break - } - } - t.Errorf("ref: %s", hex.Dump(refOut[:i])) - t.Errorf("vec: %s", hex.Dump(vecOut[:i])) - t.Errorf("refOut != vecOut") - break - } - blocksFn = oldBlocksFn - } -} - -func TestChaCha20VectorizedIncremental(t *testing.T) { - if !usingVectors { - t.Skip("vectorized ChaCha20 support not enabled") - } - - // Save the batch blocks processing routine so we can mess with it, and - // restore it when we're done. - oldBlocksFn := blocksFn - defer func() { - blocksFn = oldBlocksFn - }() - - const ( - maxBlocks = 256 - testSz = (maxBlocks * (maxBlocks + 1) / 2) * BlockSize - ) - - // Generate a random key, nonce and input. - var key [KeySize]byte - var nonce [NonceSize]byte - var input [testSz]byte - var vecOut [testSz]byte - var refOut [testSz]byte - rand.Read(key[:]) - rand.Read(nonce[:]) - rand.Read(input[:]) - - // Using the vectorized version, encrypt an ever increasing number of - // blocks at a time. - c, err := NewCipher(key[:], nonce[:]) - if err != nil { - t.Fatal(err) - } - off := 0 - for nrBlocks := 0; nrBlocks <= maxBlocks; nrBlocks++ { - cnt := nrBlocks * BlockSize - c.XORKeyStream(vecOut[off:off+cnt], input[off:off+cnt]) - off += cnt - } - - // Encrypt an equivalent amount of data with a one shot call to the - // reference implementation. - c, err = NewCipher(key[:], nonce[:]) - if err != nil { - t.Fatal(err) - } - blocksFn = blocksRef - c.XORKeyStream(refOut[:], input[:]) - - // And compare the output. - if !bytes.Equal(refOut[:], vecOut[:]) { - for j, v := range refOut { - if vecOut[j] != v { - t.Errorf("incremental mismatch at offset: %d %x != %x", j, vecOut[j], v) - break - } - } - // t.Errorf("ref: %s", hex.Dump(refOut[:])) - // t.Errorf("vec: %s", hex.Dump(vecOut[:])) - t.Errorf("refOut != vecOut") - } -} - -func doBenchN(b *testing.B, n int) { - var key [KeySize]byte - var nonce [NonceSize]byte - s := make([]byte, n) - c, err := NewCipher(key[:], nonce[:]) - if err != nil { - b.Fatal(err) - } - b.SetBytes(int64(n)) - b.ResetTimer() - for i := 0; i < b.N; i++ { - c.XORKeyStream(s, s) - } -} - -func BenchmarkChaCha20_16(b *testing.B) { - doBenchN(b, 16) -} - -func BenchmarkChaCha20_64(b *testing.B) { - doBenchN(b, 64) -} - -func BenchmarkChaCha20_128(b *testing.B) { - doBenchN(b, 128) -} - -func BenchmarkChaCha20_192(b *testing.B) { - doBenchN(b, 192) -} - -func BenchmarkChaCha20_256(b *testing.B) { - doBenchN(b, 256) -} - -func BenchmarkChaCha20_384(b *testing.B) { - doBenchN(b, 384) -} - -func BenchmarkChaCha20_512(b *testing.B) { - doBenchN(b, 512) -} - -func BenchmarkChaCha20_1k(b *testing.B) { - doBenchN(b, 1024) -} - -func BenchmarkChaCha20_64k(b *testing.B) { - doBenchN(b, 65536) -} - -func BenchmarkCTRAES256_64k(b *testing.B) { - const sz = 64 * 1024 - var key [32]byte - var iv [16]byte - s := make([]byte, sz) - blk, err := aes.NewCipher(key[:]) - if err != nil { - b.Fatal(err) - } - c := cipher.NewCTR(blk, iv[:]) - b.SetBytes(sz) - b.ResetTimer() - for i := 0; i < b.N; i++ { - c.XORKeyStream(s, s) - } -} diff --git a/vendor/git.schwanenlied.me/yawning/poly1305.git/.gitignore b/vendor/git.schwanenlied.me/yawning/poly1305.git/.gitignore deleted file mode 100644 index d38c149..0000000 --- a/vendor/git.schwanenlied.me/yawning/poly1305.git/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.swp -*~ diff --git a/vendor/git.schwanenlied.me/yawning/poly1305.git/README.md b/vendor/git.schwanenlied.me/yawning/poly1305.git/README.md deleted file mode 100644 index 7b6de64..0000000 --- a/vendor/git.schwanenlied.me/yawning/poly1305.git/README.md +++ /dev/null @@ -1,17 +0,0 @@ -### poly1305: Go Poly1305 -#### Yawning Angel (yawning at schwanenlied dot me) - -Poly1305 implements the Poly1305 MAC algorithm, exposing a saner interface than -the one provided by golang.org/x/crypto/poly1305. In particular it exposes a -object that implements a hash.Hash interface. - -The implementation is based on the Public Domain poly1305-donna by Andrew -Moon. - -| Implementation | 64 byte | 1024 byte | -| -------------------- | ------------ | ----------- | -| go.crypto (ref) | 94.51 MB/s | 187.67 MB/s | -| go.crypto (amd64) | 540.68 MB/s | 909.97 MB/s | -| go poly1305-donna-32 | 425.40 MB/s | 715.23 MB/s | - -Note: All numbers on a i5-4250U, and to be taken with a huge grain of salt. diff --git a/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305.go b/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305.go deleted file mode 100644 index 21486ca..0000000 --- a/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305.go +++ /dev/null @@ -1,207 +0,0 @@ -// -// poly1305.go: Poly1305 MAC. -// -// To the extent possible under law, Yawning Angel waived all copyright -// and related or neighboring rights to poly1305, using the creative -// commons "CC0" public domain dedication. See LICENSE or -// for full details. - -// Package poly1305 is a Poly1305 MAC implementation. It is different from the -// golang.org/x/crypto implementation in that it exports a hash.Hash interface -// to support incremental updates. -// -// The implementation is based on Andrew Moon's poly1305-donna. -package poly1305 - -import ( - "crypto/subtle" - "errors" - "hash" - "runtime" - "unsafe" -) - -const ( - // KeySize is the Poly1305 key size in bytes. - KeySize = 32 - - // Size is the Poly1305 MAC size in bytes. - Size = 16 - - // BlockSize is the Poly1305 block size in bytes. - BlockSize = 16 -) - -var ( - // ErrInvalidKeySize is the error returned when an invalid sized key is - // encountered. - ErrInvalidKeySize = errors.New("poly1305: invalid key size") - - // ErrInvalidMacSize is the error returned when an invalid sized MAC is - // encountered. - ErrInvalidMacSize = errors.New("poly1305: invalid mac size") - - isLittleEndian = false -) - -type implInterface interface { - init(key []byte) - clear() - blocks(m []byte, bytes int, isFinal bool) - finish(mac *[Size]byte) -} - -// Poly1305 is an instance of the Poly1305 MAC algorithm. -type Poly1305 struct { - impl implState - leftover int - buffer [BlockSize]byte -} - -// Write adds more data to the running hash. It never returns an error. -func (st *Poly1305) Write(p []byte) (n int, err error) { - // - // poly1305-donna.c:poly1305_update() - // - - m := p - bytes := len(m) - - // handle leftover - if st.leftover > 0 { - want := BlockSize - st.leftover - if want > bytes { - want = bytes - } - for i := 0; i < want; i++ { - st.buffer[st.leftover+i] = m[i] - } - bytes -= want - m = m[want:] - st.leftover += want - if st.leftover < BlockSize { - return len(p), nil - } - st.impl.blocks(st.buffer[:], BlockSize, false) - st.leftover = 0 - } - - // process full blocks - if bytes >= BlockSize { - want := bytes & (^(BlockSize - 1)) - st.impl.blocks(m, want, false) - m = m[want:] - bytes -= want - } - - // store leftover - if bytes > 0 { - for i := 0; i < bytes; i++ { - st.buffer[st.leftover+i] = m[i] - } - st.leftover += bytes - } - - return len(p), nil -} - -// Sum appends the current hash to b and returns the resulting slice. It does -// not change the underlying hash state. -func (st *Poly1305) Sum(b []byte) []byte { - var mac [Size]byte - tmp := *st - tmp.finish(&mac) - return append(b, mac[:]...) -} - -// Reset clears the internal hash state and panic()s, because calling this is a -// sign that the user is doing something unadvisable. -func (st *Poly1305) Reset() { - st.Clear() // Obliterate the state before panic(). - - // Poly1305 keys are one time use only. - panic("poly1305: Reset() is not supported") -} - -// Size returns the number of bytes Sum will return. -func (st *Poly1305) Size() int { - return Size -} - -// BlockSize returns the hash's underlying block size. -func (st *Poly1305) BlockSize() int { - return BlockSize -} - -// Init (re-)initializes the hash instance with a given key. -func (st *Poly1305) Init(key []byte) { - if len(key) != KeySize { - panic(ErrInvalidKeySize) - } - - st.impl.init(key) - st.leftover = 0 -} - -// Clear purges the sensitive material in hash's internal state. -func (st *Poly1305) Clear() { - st.impl.clear() -} - -func (st *Poly1305) finish(mac *[Size]byte) { - // process the remaining block - if st.leftover > 0 { - st.buffer[st.leftover] = 1 - for i := st.leftover + 1; i < BlockSize; i++ { - st.buffer[i] = 0 - } - st.impl.blocks(st.buffer[:], BlockSize, true) - } - - st.impl.finish(mac) - st.impl.clear() -} - -// New returns a new Poly1305 instance keyed with the supplied key. -func New(key []byte) (*Poly1305, error) { - if len(key) != KeySize { - return nil, ErrInvalidKeySize - } - - h := &Poly1305{} - h.Init(key) - return h, nil -} - -// Sum does exactly what golang.org/x/crypto/poly1305.Sum() does. -func Sum(mac *[Size]byte, m []byte, key *[KeySize]byte) { - var h Poly1305 - h.Init(key[:]) - h.Write(m) - h.finish(mac) -} - -// Verify does exactly what golang.org/x/crypto/poly1305.Verify does. -func Verify(mac *[Size]byte, m []byte, key *[KeySize]byte) bool { - var m2 [Size]byte - Sum(&m2, m, key) - return subtle.ConstantTimeCompare(mac[:], m2[:]) == 1 -} - -func init() { - // Use the UTF-32 (UCS-4) Byte Order Mark to detect host byte order, - // which enables the further use of 'unsafe' for added performance. - const bomLE = 0x0000feff - bom := [4]byte{0xff, 0xfe, 0x00, 0x00} - - // ARM doesn't get the spiffy fast code since it's picky wrt alignment - // and I doubt Go does the right thing. - if runtime.GOARCH != "arm" { - bomHost := *(*uint32)(unsafe.Pointer(&bom[0])) - if bomHost == 0x0000feff { // Little endian, use unsafe. - isLittleEndian = true - } - } -} - -var _ hash.Hash = (*Poly1305)(nil) diff --git a/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_32.go b/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_32.go deleted file mode 100644 index 857de1f..0000000 --- a/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_32.go +++ /dev/null @@ -1,236 +0,0 @@ -// -// poly1305_32.go: 32->64 bit multiplies, 64 bit additions -// -// To the extent possible under law, Yawning Angel waived all copyright -// and related or neighboring rights to poly1305, using the creative -// commons "CC0" public domain dedication. See LICENSE or -// for full details. - -package poly1305 - -import ( - "encoding/binary" - "unsafe" -) - -type implState struct { - r [5]uint32 - h [5]uint32 - pad [4]uint32 -} - -func (impl *implState) init(key []byte) { - // - // poly1305-donna-32.h:poly1305_init() - // - - // r &= 0xffffffc0ffffffc0ffffffc0fffffff - if isLittleEndian { - impl.r[0] = *(*uint32)(unsafe.Pointer(&key[0])) & 0x3ffffff - impl.r[1] = (*(*uint32)(unsafe.Pointer(&key[3])) >> 2) & 0x3ffff03 - impl.r[2] = (*(*uint32)(unsafe.Pointer(&key[6])) >> 4) & 0x3ffc0ff - impl.r[3] = (*(*uint32)(unsafe.Pointer(&key[9])) >> 6) & 0x3f03fff - impl.r[4] = (*(*uint32)(unsafe.Pointer(&key[12])) >> 8) & 0x00fffff - } else { - impl.r[0] = binary.LittleEndian.Uint32(key[0:]) & 0x3ffffff - impl.r[1] = (binary.LittleEndian.Uint32(key[3:]) >> 2) & 0x3ffff03 - impl.r[2] = (binary.LittleEndian.Uint32(key[6:]) >> 4) & 0x3ffc0ff - impl.r[3] = (binary.LittleEndian.Uint32(key[9:]) >> 6) & 0x3f03fff - impl.r[4] = (binary.LittleEndian.Uint32(key[12:]) >> 8) & 0x00fffff - } - - // h = 0 - for i := range impl.h { - impl.h[i] = 0 - } - - // save pad for later - impl.pad[0] = binary.LittleEndian.Uint32(key[16:]) - impl.pad[1] = binary.LittleEndian.Uint32(key[20:]) - impl.pad[2] = binary.LittleEndian.Uint32(key[24:]) - impl.pad[3] = binary.LittleEndian.Uint32(key[28:]) -} - -func (impl *implState) clear() { - for i := range impl.h { - impl.h[i] = 0 - } - for i := range impl.r { - impl.r[i] = 0 - } - for i := range impl.pad { - impl.pad[i] = 0 - } -} - -func (impl *implState) blocks(m []byte, bytes int, isFinal bool) { - // - // poly1305-donna-32.h:poly1305_blocks() - // - - var hibit uint32 - var d0, d1, d2, d3, d4 uint64 - var c uint32 - if !isFinal { - hibit = 1 << 24 // 1 << 128 - } - r0, r1, r2, r3, r4 := impl.r[0], impl.r[1], impl.r[2], impl.r[3], impl.r[4] - s1, s2, s3, s4 := r1*5, r2*5, r3*5, r4*5 - h0, h1, h2, h3, h4 := impl.h[0], impl.h[1], impl.h[2], impl.h[3], impl.h[4] - - for bytes >= BlockSize { - // h += m[i] - if isLittleEndian { - h0 += *(*uint32)(unsafe.Pointer(&m[0])) & 0x3ffffff - h1 += (*(*uint32)(unsafe.Pointer(&m[3])) >> 2) & 0x3ffffff - h2 += (*(*uint32)(unsafe.Pointer(&m[6])) >> 4) & 0x3ffffff - h3 += (*(*uint32)(unsafe.Pointer(&m[9])) >> 6) & 0x3ffffff - h4 += (*(*uint32)(unsafe.Pointer(&m[12])) >> 8) | hibit - } else { - h0 += binary.LittleEndian.Uint32(m[0:]) & 0x3ffffff - h1 += (binary.LittleEndian.Uint32(m[3:]) >> 2) & 0x3ffffff - h2 += (binary.LittleEndian.Uint32(m[6:]) >> 4) & 0x3ffffff - h3 += (binary.LittleEndian.Uint32(m[9:]) >> 6) & 0x3ffffff - h4 += (binary.LittleEndian.Uint32(m[12:]) >> 8) | hibit - } - - // h *= r - d0 = (uint64(h0) * uint64(r0)) + (uint64(h1) * uint64(s4)) + (uint64(h2) * uint64(s3)) + (uint64(h3) * uint64(s2)) + (uint64(h4) * uint64(s1)) - d1 = (uint64(h0) * uint64(r1)) + (uint64(h1) * uint64(r0)) + (uint64(h2) * uint64(s4)) + (uint64(h3) * uint64(s3)) + (uint64(h4) * uint64(s2)) - d2 = (uint64(h0) * uint64(r2)) + (uint64(h1) * uint64(r1)) + (uint64(h2) * uint64(r0)) + (uint64(h3) * uint64(s4)) + (uint64(h4) * uint64(s3)) - d3 = (uint64(h0) * uint64(r3)) + (uint64(h1) * uint64(r2)) + (uint64(h2) * uint64(r1)) + (uint64(h3) * uint64(r0)) + (uint64(h4) * uint64(s4)) - d4 = (uint64(h0) * uint64(r4)) + (uint64(h1) * uint64(r3)) + (uint64(h2) * uint64(r2)) + (uint64(h3) * uint64(r1)) + (uint64(h4) * uint64(r0)) - - // (partial) h %= p - c = uint32(d0 >> 26) - h0 = uint32(d0) & 0x3ffffff - - d1 += uint64(c) - c = uint32(d1 >> 26) - h1 = uint32(d1) & 0x3ffffff - - d2 += uint64(c) - c = uint32(d2 >> 26) - h2 = uint32(d2) & 0x3ffffff - - d3 += uint64(c) - c = uint32(d3 >> 26) - h3 = uint32(d3) & 0x3ffffff - - d4 += uint64(c) - c = uint32(d4 >> 26) - h4 = uint32(d4) & 0x3ffffff - - h0 += c * 5 - c = h0 >> 26 - h0 = h0 & 0x3ffffff - - h1 += c - - m = m[BlockSize:] - bytes -= BlockSize - } - - impl.h[0], impl.h[1], impl.h[2], impl.h[3], impl.h[4] = h0, h1, h2, h3, h4 -} - -func (impl *implState) finish(mac *[Size]byte) { - // - // poly1305-donna-32.h:poly1305_finish() - // - - var c uint32 - var g0, g1, g2, g3, g4 uint32 - var f uint64 - var mask uint32 - - // fully carry h - h0, h1, h2, h3, h4 := impl.h[0], impl.h[1], impl.h[2], impl.h[3], impl.h[4] - c = h1 >> 26 - h1 &= 0x3ffffff - - h2 += c - c = h2 >> 26 - h2 &= 0x3ffffff - - h3 += c - c = h3 >> 26 - h3 &= 0x3ffffff - - h4 += c - c = h4 >> 26 - h4 &= 0x3ffffff - - h0 += c * 5 - c = h0 >> 26 - h0 &= 0x3ffffff - - h1 += c - - // compute h + -p - g0 = h0 + 5 - c = g0 >> 26 - g0 &= 0x3ffffff - - g1 = h1 + c - c = g1 >> 26 - g1 &= 0x3ffffff - - g2 = h2 + c - c = g2 >> 26 - g2 &= 0x3ffffff - - g3 = h3 + c - c = g3 >> 26 - g3 &= 0x3ffffff - - g4 = h4 + c - (1 << 26) - - // select h if h < p, or h + -p if h >= p - mask = (g4 >> ((4 * 8) - 1)) - 1 - g0 &= mask - g1 &= mask - g2 &= mask - g3 &= mask - g4 &= mask - mask = ^mask - h0 = (h0 & mask) | g0 - h1 = (h1 & mask) | g1 - h2 = (h2 & mask) | g2 - h3 = (h3 & mask) | g3 - h4 = (h4 & mask) | g4 - - // h = h % (2^128) - h0 = ((h0) | (h1 << 26)) & 0xffffffff - h1 = ((h1 >> 6) | (h2 << 20)) & 0xffffffff - h2 = ((h2 >> 12) | (h3 << 14)) & 0xffffffff - h3 = ((h3 >> 18) | (h4 << 8)) & 0xffffffff - - // mac = (h + pad) % (2^128) - f = uint64(h0) + uint64(impl.pad[0]) - h0 = uint32(f) - - f = uint64(h1) + uint64(impl.pad[1]) + (f >> 32) - h1 = uint32(f) - - f = uint64(h2) + uint64(impl.pad[2]) + (f >> 32) - h2 = uint32(f) - - f = uint64(h3) + uint64(impl.pad[3]) + (f >> 32) - h3 = uint32(f) - - if isLittleEndian { - macArr := (*[4]uint32)(unsafe.Pointer(&mac[0])) - macArr[0] = h0 - macArr[1] = h1 - macArr[2] = h2 - macArr[3] = h3 - } else { - binary.LittleEndian.PutUint32(mac[0:], h0) - binary.LittleEndian.PutUint32(mac[4:], h1) - binary.LittleEndian.PutUint32(mac[8:], h2) - binary.LittleEndian.PutUint32(mac[12:], h3) - } -} - -var _ implInterface = (*implState)(nil) diff --git a/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_test.go b/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_test.go deleted file mode 100644 index bed3da7..0000000 --- a/vendor/git.schwanenlied.me/yawning/poly1305.git/poly1305_test.go +++ /dev/null @@ -1,585 +0,0 @@ -// -// poly1305.go: Poly1305 MAC known answer tests. -// -// To the extent possible under law, Yawning Angel waived all copyright -// and related or neighboring rights to poly1305, using the creative -// commons "CC0" public domain dedication. See LICENSE or -// for full details. - -package poly1305 - -import ( - "bytes" - "testing" -) - -// Shamelessly stolen from poly1305-donna.c:poly1305_power_on_self_test() - -func TestNaCl(t *testing.T) { - var naclKey = []byte{ - 0xee, 0xa6, 0xa7, 0x25, 0x1c, 0x1e, 0x72, 0x91, - 0x6d, 0x11, 0xc2, 0xcb, 0x21, 0x4d, 0x3c, 0x25, - 0x25, 0x39, 0x12, 0x1d, 0x8e, 0x23, 0x4e, 0x65, - 0x2d, 0x65, 0x1f, 0xa4, 0xc8, 0xcf, 0xf8, 0x80, - } - - var naclMsg = []byte{ - 0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73, - 0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce, - 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4, - 0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a, - 0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b, - 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72, - 0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2, - 0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38, - 0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a, - 0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae, - 0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea, - 0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda, - 0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde, - 0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3, - 0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6, - 0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74, - 0xe3, 0x55, 0xa5, - } - - var naclMac = []byte{ - 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5, - 0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9, - } - - // Oneshot - h, err := New(naclKey[:]) - if err != nil { - t.Fatal(err) - } - - n, err := h.Write(naclMsg[:]) - if err != nil { - t.Fatal(err) - } else if n != len(naclMsg) { - t.Fatalf("h.Write() returned unexpected length: %d", n) - } - - mac := h.Sum(nil) - if !bytes.Equal(mac, naclMac[:]) { - t.Fatalf("mac != naclMac") - } - - // Incremental - h, err = New(naclKey[:]) - if err != nil { - t.Fatal(err) - } - - for i, s := range []struct{ off, sz int }{ - {0, 32}, - {32, 64}, - {96, 16}, - {112, 8}, - {120, 4}, - {124, 2}, - {126, 1}, - {127, 1}, - {128, 1}, - {129, 1}, - {130, 1}, - } { - n, err := h.Write(naclMsg[s.off : s.off+s.sz]) - if err != nil { - t.Fatalf("[%d]: h.Write(): %s", i, err) - } else if n != s.sz { - t.Fatalf("[%d]: h.Write(): %d (expected: %d)", i, n, s.sz) - } - } - - mac = h.Sum(nil) - if !bytes.Equal(mac, naclMac[:]) { - t.Fatalf("mac != naclMac") - } -} - -func TestWrap(t *testing.T) { - // generates a final value of (2^130 - 2) == 3 - wrapKey := [KeySize]byte{ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } - - wrapMsg := []byte{ - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - } - - wrapMac := [Size]byte{ - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } - - var mac [Size]byte - Sum(&mac, wrapMsg, &wrapKey) - if !bytes.Equal(mac[:], wrapMac[:]) { - t.Fatalf("mac != wrapMac") - } -} - -func TestTotal(t *testing.T) { - // mac of the macs of messages of length 0 to 256, where the key and messages - // have all their values set to the length - totalKey := []byte{ - 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0x00, 0x00, 0x00, 0x00, - } - - totalMac := []byte{ - 0x64, 0xaf, 0xe2, 0xe8, 0xd6, 0xad, 0x7b, 0xbd, - 0xd2, 0x87, 0xf9, 0x7c, 0x44, 0x62, 0x3d, 0x39, - } - - var allKey [KeySize]byte - allMsg := make([]byte, 256) - - totalCtx, err := New(totalKey[:]) - if err != nil { - t.Fatal(err) - } - - for i := 0; i < 256; i++ { - // set key and message to 'i,i,i..' - for j := range allKey { - allKey[j] = byte(i) - } - for j := 0; j < i; j++ { - allMsg[j] = byte(i) - } - - var mac [Size]byte - Sum(&mac, allMsg[:i], &allKey) - n, err := totalCtx.Write(mac[:]) - if err != nil { - t.Fatalf("[%d]: h.Write(): %s", i, err) - } else if n != len(mac) { - t.Fatalf("[%d]: h.Write(): %d (expected: %d)", i, n, len(mac)) - } - } - mac := totalCtx.Sum(nil) - if !bytes.Equal(mac, totalMac[:]) { - t.Fatalf("mac != totalMac") - } -} - -func TestIETFDraft(t *testing.T) { - // Test vectors taken from: - // https://www.ietf.org/id/draft-irtf-cfrg-chacha20-poly1305-07.txt - - vectors := []struct { - key [KeySize]byte - m []byte - tag [Size]byte - }{ - // Test Vector #1 - { - [KeySize]byte{}, - []byte{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - [Size]byte{}, - }, - - // Test Vector #2 - { - [KeySize]byte{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x36, 0xe5, 0xf6, 0xb5, 0xc5, 0xe0, 0x60, 0x70, - 0xf0, 0xef, 0xca, 0x96, 0x22, 0x7a, 0x86, 0x3e, - }, - []byte{ - 0x41, 0x6e, 0x79, 0x20, 0x73, 0x75, 0x62, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x74, - 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x49, 0x45, - 0x54, 0x46, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x6e, - 0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, - 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x20, 0x66, - 0x6f, 0x72, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, - 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x72, - 0x20, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6f, 0x66, - 0x20, 0x61, 0x6e, 0x20, 0x49, 0x45, 0x54, 0x46, - 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x20, - 0x6f, 0x72, 0x20, 0x52, 0x46, 0x43, 0x20, 0x61, - 0x6e, 0x64, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x20, 0x6d, 0x61, 0x64, 0x65, 0x20, 0x77, 0x69, - 0x74, 0x68, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, - 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, - 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x49, - 0x45, 0x54, 0x46, 0x20, 0x61, 0x63, 0x74, 0x69, - 0x76, 0x69, 0x74, 0x79, 0x20, 0x69, 0x73, 0x20, - 0x63, 0x6f, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72, - 0x65, 0x64, 0x20, 0x61, 0x6e, 0x20, 0x22, 0x49, - 0x45, 0x54, 0x46, 0x20, 0x43, 0x6f, 0x6e, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, - 0x22, 0x2e, 0x20, 0x53, 0x75, 0x63, 0x68, 0x20, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, - 0x64, 0x65, 0x20, 0x6f, 0x72, 0x61, 0x6c, 0x20, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x45, - 0x54, 0x46, 0x20, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x61, 0x73, 0x20, - 0x77, 0x65, 0x6c, 0x6c, 0x20, 0x61, 0x73, 0x20, - 0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, - 0x61, 0x6e, 0x64, 0x20, 0x65, 0x6c, 0x65, 0x63, - 0x74, 0x72, 0x6f, 0x6e, 0x69, 0x63, 0x20, 0x63, - 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6d, 0x61, - 0x64, 0x65, 0x20, 0x61, 0x74, 0x20, 0x61, 0x6e, - 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x6f, - 0x72, 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2c, - 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x61, - 0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6f, - }, - [Size]byte{ - 0x36, 0xe5, 0xf6, 0xb5, 0xc5, 0xe0, 0x60, 0x70, - 0xf0, 0xef, 0xca, 0x96, 0x22, 0x7a, 0x86, 0x3e, - }, - }, - - // Test Vector #3 - { - [KeySize]byte{ - 0x36, 0xe5, 0xf6, 0xb5, 0xc5, 0xe0, 0x60, 0x70, - 0xf0, 0xef, 0xca, 0x96, 0x22, 0x7a, 0x86, 0x3e, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - []byte{ - 0x41, 0x6e, 0x79, 0x20, 0x73, 0x75, 0x62, 0x6d, - 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x20, 0x74, - 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x49, 0x45, - 0x54, 0x46, 0x20, 0x69, 0x6e, 0x74, 0x65, 0x6e, - 0x64, 0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x74, - 0x68, 0x65, 0x20, 0x43, 0x6f, 0x6e, 0x74, 0x72, - 0x69, 0x62, 0x75, 0x74, 0x6f, 0x72, 0x20, 0x66, - 0x6f, 0x72, 0x20, 0x70, 0x75, 0x62, 0x6c, 0x69, - 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x61, - 0x73, 0x20, 0x61, 0x6c, 0x6c, 0x20, 0x6f, 0x72, - 0x20, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6f, 0x66, - 0x20, 0x61, 0x6e, 0x20, 0x49, 0x45, 0x54, 0x46, - 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x65, - 0x74, 0x2d, 0x44, 0x72, 0x61, 0x66, 0x74, 0x20, - 0x6f, 0x72, 0x20, 0x52, 0x46, 0x43, 0x20, 0x61, - 0x6e, 0x64, 0x20, 0x61, 0x6e, 0x79, 0x20, 0x73, - 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, - 0x20, 0x6d, 0x61, 0x64, 0x65, 0x20, 0x77, 0x69, - 0x74, 0x68, 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, - 0x20, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x74, - 0x20, 0x6f, 0x66, 0x20, 0x61, 0x6e, 0x20, 0x49, - 0x45, 0x54, 0x46, 0x20, 0x61, 0x63, 0x74, 0x69, - 0x76, 0x69, 0x74, 0x79, 0x20, 0x69, 0x73, 0x20, - 0x63, 0x6f, 0x6e, 0x73, 0x69, 0x64, 0x65, 0x72, - 0x65, 0x64, 0x20, 0x61, 0x6e, 0x20, 0x22, 0x49, - 0x45, 0x54, 0x46, 0x20, 0x43, 0x6f, 0x6e, 0x74, - 0x72, 0x69, 0x62, 0x75, 0x74, 0x69, 0x6f, 0x6e, - 0x22, 0x2e, 0x20, 0x53, 0x75, 0x63, 0x68, 0x20, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x20, 0x69, 0x6e, 0x63, 0x6c, 0x75, - 0x64, 0x65, 0x20, 0x6f, 0x72, 0x61, 0x6c, 0x20, - 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, - 0x74, 0x73, 0x20, 0x69, 0x6e, 0x20, 0x49, 0x45, - 0x54, 0x46, 0x20, 0x73, 0x65, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x61, 0x73, 0x20, - 0x77, 0x65, 0x6c, 0x6c, 0x20, 0x61, 0x73, 0x20, - 0x77, 0x72, 0x69, 0x74, 0x74, 0x65, 0x6e, 0x20, - 0x61, 0x6e, 0x64, 0x20, 0x65, 0x6c, 0x65, 0x63, - 0x74, 0x72, 0x6f, 0x6e, 0x69, 0x63, 0x20, 0x63, - 0x6f, 0x6d, 0x6d, 0x75, 0x6e, 0x69, 0x63, 0x61, - 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x6d, 0x61, - 0x64, 0x65, 0x20, 0x61, 0x74, 0x20, 0x61, 0x6e, - 0x79, 0x20, 0x74, 0x69, 0x6d, 0x65, 0x20, 0x6f, - 0x72, 0x20, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x2c, - 0x20, 0x77, 0x68, 0x69, 0x63, 0x68, 0x20, 0x61, - 0x72, 0x65, 0x20, 0x61, 0x64, 0x64, 0x72, 0x65, - 0x73, 0x73, 0x65, 0x64, 0x20, 0x74, 0x6f, - }, - [Size]byte{ - 0xf3, 0x47, 0x7e, 0x7c, 0xd9, 0x54, 0x17, 0xaf, - 0x89, 0xa6, 0xb8, 0x79, 0x4c, 0x31, 0x0c, 0xf0, - }, - }, - - // Test Vector #4 - { - [KeySize]byte{ - 0x1c, 0x92, 0x40, 0xa5, 0xeb, 0x55, 0xd3, 0x8a, - 0xf3, 0x33, 0x88, 0x86, 0x04, 0xf6, 0xb5, 0xf0, - 0x47, 0x39, 0x17, 0xc1, 0x40, 0x2b, 0x80, 0x09, - 0x9d, 0xca, 0x5c, 0xbc, 0x20, 0x70, 0x75, 0xc0, - }, - []byte{ - 0x27, 0x54, 0x77, 0x61, 0x73, 0x20, 0x62, 0x72, - 0x69, 0x6c, 0x6c, 0x69, 0x67, 0x2c, 0x20, 0x61, - 0x6e, 0x64, 0x20, 0x74, 0x68, 0x65, 0x20, 0x73, - 0x6c, 0x69, 0x74, 0x68, 0x79, 0x20, 0x74, 0x6f, - 0x76, 0x65, 0x73, 0x0a, 0x44, 0x69, 0x64, 0x20, - 0x67, 0x79, 0x72, 0x65, 0x20, 0x61, 0x6e, 0x64, - 0x20, 0x67, 0x69, 0x6d, 0x62, 0x6c, 0x65, 0x20, - 0x69, 0x6e, 0x20, 0x74, 0x68, 0x65, 0x20, 0x77, - 0x61, 0x62, 0x65, 0x3a, 0x0a, 0x41, 0x6c, 0x6c, - 0x20, 0x6d, 0x69, 0x6d, 0x73, 0x79, 0x20, 0x77, - 0x65, 0x72, 0x65, 0x20, 0x74, 0x68, 0x65, 0x20, - 0x62, 0x6f, 0x72, 0x6f, 0x67, 0x6f, 0x76, 0x65, - 0x73, 0x2c, 0x0a, 0x41, 0x6e, 0x64, 0x20, 0x74, - 0x68, 0x65, 0x20, 0x6d, 0x6f, 0x6d, 0x65, 0x20, - 0x72, 0x61, 0x74, 0x68, 0x73, 0x20, 0x6f, 0x75, - 0x74, 0x67, 0x72, 0x61, 0x62, 0x65, 0x2e, - }, - [Size]byte{ - 0x45, 0x41, 0x66, 0x9a, 0x7e, 0xaa, 0xee, 0x61, - 0xe7, 0x08, 0xdc, 0x7c, 0xbc, 0xc5, 0xeb, 0x62, - }, - }, - - // Test Vector #5 - // - // If one uses 130-bit partial reduction, does the code handle the case - // where partially reduced final result is not fully reduced? - { - [KeySize]byte{ - // R - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // S - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - []byte{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }, - [Size]byte{ - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - }, - - // Test Vector #6 - // - // What happens if addition of s overflows modulo 2^128? - { - [KeySize]byte{ - // R - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // S - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }, - []byte{ - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - [Size]byte{ - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - }, - - // Test Vector #7 - // - // What happens if data limb is all ones and there is carry from lower - // limb? - { - [KeySize]byte{ - // R - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // S - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - []byte{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xF0, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - [Size]byte{ - 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - }, - - // Test Vector #8 - // - // What happens if final result from polynomial part is exactly - // 2^130-5? - { - [KeySize]byte{ - // R - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // S - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - []byte{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFB, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, - 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - }, - [Size]byte{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - }, - - // Test Vector #9 - // - // What happens if final result from polynomial part is exactly - // 2^130-6? - { - [KeySize]byte{ - // R - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // S - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - []byte{ - 0xFD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }, - [Size]byte{ - 0xFA, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - }, - }, - - // Test Vector #10 - // - // What happens if 5*H+L-type reduction produces 131-bit intermediate - // result? - { - [KeySize]byte{ - // R - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // S - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - []byte{ - 0xE3, 0x35, 0x94, 0xD7, 0x50, 0x5E, 0x43, 0xB9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x33, 0x94, 0xD7, 0x50, 0x5E, 0x43, 0x79, 0xCD, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - [Size]byte{ - 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - }, - - // Test Vector #11 - // - // What happens if 5*H+L-type reduction produces 131-bit final result? - { - [KeySize]byte{ - // R - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - // S - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - []byte{ - 0xE3, 0x35, 0x94, 0xD7, 0x50, 0x5E, 0x43, 0xB9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x33, 0x94, 0xD7, 0x50, 0x5E, 0x43, 0x79, 0xCD, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - [Size]byte{ - 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - }, - }, - } - - for i, vec := range vectors { - var mac [Size]byte - Sum(&mac, vec.m, &vec.key) - if !bytes.Equal(mac[:], vec.tag[:]) { - t.Errorf("[%d]: mac != vec.tag", i) - } - if !Verify(&vec.tag, vec.m, &vec.key) { - t.Errorf("[%d]: Verify(tag, m, key) returned false", i) - } - } -} - -func TestIETFDraftForceByteswap(t *testing.T) { - if !isLittleEndian { - t.Skipf("not little endian, slow path already taken") - } else { - isLittleEndian = false - TestIETFDraft(t) - isLittleEndian = true - } -} - -// Swiped from golang.org/x/crypto/poly1305/poly1305_test.go. - -func Benchmark64(b *testing.B) { - b.StopTimer() - var mac [Size]byte - var key [KeySize]byte - m := make([]byte, 64) - b.SetBytes(int64(len(m))) - b.StartTimer() - - for i := 0; i < b.N; i++ { - Sum(&mac, m, &key) - } -} - -func Benchmark1k(b *testing.B) { - b.StopTimer() - var mac [Size]byte - var key [KeySize]byte - m := make([]byte, 1024) - b.SetBytes(int64(len(m))) - b.StartTimer() - - for i := 0; i < b.N; i++ { - Sum(&mac, m, &key) - } -} diff --git a/vendor/github.com/BurntSushi/toml/.gitignore b/vendor/github.com/BurntSushi/toml/.gitignore deleted file mode 100644 index 0cd3800..0000000 --- a/vendor/github.com/BurntSushi/toml/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -TAGS -tags -.*.swp -tomlcheck/tomlcheck -toml.test diff --git a/vendor/github.com/BurntSushi/toml/.travis.yml b/vendor/github.com/BurntSushi/toml/.travis.yml deleted file mode 100644 index 43caf6d..0000000 --- a/vendor/github.com/BurntSushi/toml/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: go -go: - - 1.1 - - 1.2 - - tip -install: - - go install ./... - - go get github.com/BurntSushi/toml-test -script: - - export PATH="$PATH:$HOME/gopath/bin" - - make test - diff --git a/vendor/github.com/BurntSushi/toml/COMPATIBLE b/vendor/github.com/BurntSushi/toml/COMPATIBLE deleted file mode 100644 index 21e0938..0000000 --- a/vendor/github.com/BurntSushi/toml/COMPATIBLE +++ /dev/null @@ -1,3 +0,0 @@ -Compatible with TOML version -[v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) - diff --git a/vendor/github.com/BurntSushi/toml/COPYING b/vendor/github.com/BurntSushi/toml/COPYING deleted file mode 100644 index 5a8e332..0000000 --- a/vendor/github.com/BurntSushi/toml/COPYING +++ /dev/null @@ -1,14 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - diff --git a/vendor/github.com/BurntSushi/toml/Makefile b/vendor/github.com/BurntSushi/toml/Makefile deleted file mode 100644 index 3600848..0000000 --- a/vendor/github.com/BurntSushi/toml/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -install: - go install ./... - -test: install - go test -v - toml-test toml-test-decoder - toml-test -encoder toml-test-encoder - -fmt: - gofmt -w *.go */*.go - colcheck *.go */*.go - -tags: - find ./ -name '*.go' -print0 | xargs -0 gotags > TAGS - -push: - git push origin master - git push github master - diff --git a/vendor/github.com/BurntSushi/toml/README.md b/vendor/github.com/BurntSushi/toml/README.md deleted file mode 100644 index 5a5df63..0000000 --- a/vendor/github.com/BurntSushi/toml/README.md +++ /dev/null @@ -1,220 +0,0 @@ -## TOML parser and encoder for Go with reflection - -TOML stands for Tom's Obvious, Minimal Language. This Go package provides a -reflection interface similar to Go's standard library `json` and `xml` -packages. This package also supports the `encoding.TextUnmarshaler` and -`encoding.TextMarshaler` interfaces so that you can define custom data -representations. (There is an example of this below.) - -Spec: https://github.com/mojombo/toml - -Compatible with TOML version -[v0.2.0](https://github.com/toml-lang/toml/blob/master/versions/en/toml-v0.2.0.md) - -Documentation: http://godoc.org/github.com/BurntSushi/toml - -Installation: - -```bash -go get github.com/BurntSushi/toml -``` - -Try the toml validator: - -```bash -go get github.com/BurntSushi/toml/cmd/tomlv -tomlv some-toml-file.toml -``` - -[![Build status](https://api.travis-ci.org/BurntSushi/toml.png)](https://travis-ci.org/BurntSushi/toml) - - -### Testing - -This package passes all tests in -[toml-test](https://github.com/BurntSushi/toml-test) for both the decoder -and the encoder. - -### Examples - -This package works similarly to how the Go standard library handles `XML` -and `JSON`. Namely, data is loaded into Go values via reflection. - -For the simplest example, consider some TOML file as just a list of keys -and values: - -```toml -Age = 25 -Cats = [ "Cauchy", "Plato" ] -Pi = 3.14 -Perfection = [ 6, 28, 496, 8128 ] -DOB = 1987-07-05T05:45:00Z -``` - -Which could be defined in Go as: - -```go -type Config struct { - Age int - Cats []string - Pi float64 - Perfection []int - DOB time.Time // requires `import time` -} -``` - -And then decoded with: - -```go -var conf Config -if _, err := toml.Decode(tomlData, &conf); err != nil { - // handle error -} -``` - -You can also use struct tags if your struct field name doesn't map to a TOML -key value directly: - -```toml -some_key_NAME = "wat" -``` - -```go -type TOML struct { - ObscureKey string `toml:"some_key_NAME"` -} -``` - -### Using the `encoding.TextUnmarshaler` interface - -Here's an example that automatically parses duration strings into -`time.Duration` values: - -```toml -[[song]] -name = "Thunder Road" -duration = "4m49s" - -[[song]] -name = "Stairway to Heaven" -duration = "8m03s" -``` - -Which can be decoded with: - -```go -type song struct { - Name string - Duration duration -} -type songs struct { - Song []song -} -var favorites songs -if _, err := toml.Decode(blob, &favorites); err != nil { - log.Fatal(err) -} - -for _, s := range favorites.Song { - fmt.Printf("%s (%s)\n", s.Name, s.Duration) -} -``` - -And you'll also need a `duration` type that satisfies the -`encoding.TextUnmarshaler` interface: - -```go -type duration struct { - time.Duration -} - -func (d *duration) UnmarshalText(text []byte) error { - var err error - d.Duration, err = time.ParseDuration(string(text)) - return err -} -``` - -### More complex usage - -Here's an example of how to load the example from the official spec page: - -```toml -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T07:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] -``` - -And the corresponding Go types are: - -```go -type tomlConfig struct { - Title string - Owner ownerInfo - DB database `toml:"database"` - Servers map[string]server - Clients clients -} - -type ownerInfo struct { - Name string - Org string `toml:"organization"` - Bio string - DOB time.Time -} - -type database struct { - Server string - Ports []int - ConnMax int `toml:"connection_max"` - Enabled bool -} - -type server struct { - IP string - DC string -} - -type clients struct { - Data [][]interface{} - Hosts []string -} -``` - -Note that a case insensitive match will be tried if an exact match can't be -found. - -A working example of the above can be found in `_examples/example.{go,toml}`. - diff --git a/vendor/github.com/BurntSushi/toml/_examples/example.go b/vendor/github.com/BurntSushi/toml/_examples/example.go deleted file mode 100644 index 79f31f2..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/example.go +++ /dev/null @@ -1,61 +0,0 @@ -package main - -import ( - "fmt" - "time" - - "github.com/BurntSushi/toml" -) - -type tomlConfig struct { - Title string - Owner ownerInfo - DB database `toml:"database"` - Servers map[string]server - Clients clients -} - -type ownerInfo struct { - Name string - Org string `toml:"organization"` - Bio string - DOB time.Time -} - -type database struct { - Server string - Ports []int - ConnMax int `toml:"connection_max"` - Enabled bool -} - -type server struct { - IP string - DC string -} - -type clients struct { - Data [][]interface{} - Hosts []string -} - -func main() { - var config tomlConfig - if _, err := toml.DecodeFile("example.toml", &config); err != nil { - fmt.Println(err) - return - } - - fmt.Printf("Title: %s\n", config.Title) - fmt.Printf("Owner: %s (%s, %s), Born: %s\n", - config.Owner.Name, config.Owner.Org, config.Owner.Bio, - config.Owner.DOB) - fmt.Printf("Database: %s %v (Max conn. %d), Enabled? %v\n", - config.DB.Server, config.DB.Ports, config.DB.ConnMax, - config.DB.Enabled) - for serverName, server := range config.Servers { - fmt.Printf("Server: %s (%s, %s)\n", serverName, server.IP, server.DC) - } - fmt.Printf("Client data: %v\n", config.Clients.Data) - fmt.Printf("Client hosts: %v\n", config.Clients.Hosts) -} diff --git a/vendor/github.com/BurntSushi/toml/_examples/example.toml b/vendor/github.com/BurntSushi/toml/_examples/example.toml deleted file mode 100644 index 32c7a4f..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/example.toml +++ /dev/null @@ -1,35 +0,0 @@ -# This is a TOML document. Boom. - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T07:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] diff --git a/vendor/github.com/BurntSushi/toml/_examples/hard.toml b/vendor/github.com/BurntSushi/toml/_examples/hard.toml deleted file mode 100644 index 26145d2..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/hard.toml +++ /dev/null @@ -1,22 +0,0 @@ -# Test file for TOML -# Only this one tries to emulate a TOML file written by a user of the kind of parser writers probably hate -# This part you'll really hate - -[the] -test_string = "You'll hate me after this - #" # " Annoying, isn't it? - - [the.hard] - test_array = [ "] ", " # "] # ] There you go, parse this! - test_array2 = [ "Test #11 ]proved that", "Experiment #9 was a success" ] - # You didn't think it'd as easy as chucking out the last #, did you? - another_test_string = " Same thing, but with a string #" - harder_test_string = " And when \"'s are in the string, along with # \"" # "and comments are there too" - # Things will get harder - - [the.hard.bit#] - what? = "You don't think some user won't do that?" - multi_line_array = [ - "]", - # ] Oh yes I did - ] - diff --git a/vendor/github.com/BurntSushi/toml/_examples/implicit.toml b/vendor/github.com/BurntSushi/toml/_examples/implicit.toml deleted file mode 100644 index 1dea5ce..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/implicit.toml +++ /dev/null @@ -1,4 +0,0 @@ -# [x] you -# [x.y] don't -# [x.y.z] need these -[x.y.z.w] # for this to work diff --git a/vendor/github.com/BurntSushi/toml/_examples/invalid-apples.toml b/vendor/github.com/BurntSushi/toml/_examples/invalid-apples.toml deleted file mode 100644 index 74e9e33..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/invalid-apples.toml +++ /dev/null @@ -1,6 +0,0 @@ -# DO NOT WANT -[fruit] -type = "apple" - -[fruit.type] -apple = "yes" diff --git a/vendor/github.com/BurntSushi/toml/_examples/invalid.toml b/vendor/github.com/BurntSushi/toml/_examples/invalid.toml deleted file mode 100644 index beb1dba..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/invalid.toml +++ /dev/null @@ -1,35 +0,0 @@ -# This is an INVALID TOML document. Boom. -# Can you spot the error without help? - -title = "TOML Example" - -[owner] -name = "Tom Preston-Werner" -organization = "GitHub" -bio = "GitHub Cofounder & CEO\nLikes tater tots and beer." -dob = 1979-05-27T7:32:00Z # First class dates? Why not? - -[database] -server = "192.168.1.1" -ports = [ 8001, 8001, 8002 ] -connection_max = 5000 -enabled = true - -[servers] - # You can indent as you please. Tabs or spaces. TOML don't care. - [servers.alpha] - ip = "10.0.0.1" - dc = "eqdc10" - - [servers.beta] - ip = "10.0.0.2" - dc = "eqdc10" - -[clients] -data = [ ["gamma", "delta"], [1, 2] ] # just an update to make sure parsers support it - -# Line breaks are OK when inside arrays -hosts = [ - "alpha", - "omega" -] diff --git a/vendor/github.com/BurntSushi/toml/_examples/readme1.toml b/vendor/github.com/BurntSushi/toml/_examples/readme1.toml deleted file mode 100644 index 3e1261d..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/readme1.toml +++ /dev/null @@ -1,5 +0,0 @@ -Age = 25 -Cats = [ "Cauchy", "Plato" ] -Pi = 3.14 -Perfection = [ 6, 28, 496, 8128 ] -DOB = 1987-07-05T05:45:00Z diff --git a/vendor/github.com/BurntSushi/toml/_examples/readme2.toml b/vendor/github.com/BurntSushi/toml/_examples/readme2.toml deleted file mode 100644 index b51cd93..0000000 --- a/vendor/github.com/BurntSushi/toml/_examples/readme2.toml +++ /dev/null @@ -1 +0,0 @@ -some_key_NAME = "wat" diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING b/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING deleted file mode 100644 index 5a8e332..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/COPYING +++ /dev/null @@ -1,14 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md b/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md deleted file mode 100644 index 24421eb..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Implements the TOML test suite interface - -This is an implementation of the interface expected by -[toml-test](https://github.com/BurntSushi/toml-test) for my -[toml parser written in Go](https://github.com/BurntSushi/toml). -In particular, it maps TOML data on `stdin` to a JSON format on `stdout`. - - -Compatible with TOML version -[v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) - -Compatible with `toml-test` version -[v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) - diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go b/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go deleted file mode 100644 index 14e7557..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-decoder/main.go +++ /dev/null @@ -1,90 +0,0 @@ -// Command toml-test-decoder satisfies the toml-test interface for testing -// TOML decoders. Namely, it accepts TOML on stdin and outputs JSON on stdout. -package main - -import ( - "encoding/json" - "flag" - "fmt" - "log" - "os" - "path" - "time" - - "github.com/BurntSushi/toml" -) - -func init() { - log.SetFlags(0) - - flag.Usage = usage - flag.Parse() -} - -func usage() { - log.Printf("Usage: %s < toml-file\n", path.Base(os.Args[0])) - flag.PrintDefaults() - - os.Exit(1) -} - -func main() { - if flag.NArg() != 0 { - flag.Usage() - } - - var tmp interface{} - if _, err := toml.DecodeReader(os.Stdin, &tmp); err != nil { - log.Fatalf("Error decoding TOML: %s", err) - } - - typedTmp := translate(tmp) - if err := json.NewEncoder(os.Stdout).Encode(typedTmp); err != nil { - log.Fatalf("Error encoding JSON: %s", err) - } -} - -func translate(tomlData interface{}) interface{} { - switch orig := tomlData.(type) { - case map[string]interface{}: - typed := make(map[string]interface{}, len(orig)) - for k, v := range orig { - typed[k] = translate(v) - } - return typed - case []map[string]interface{}: - typed := make([]map[string]interface{}, len(orig)) - for i, v := range orig { - typed[i] = translate(v).(map[string]interface{}) - } - return typed - case []interface{}: - typed := make([]interface{}, len(orig)) - for i, v := range orig { - typed[i] = translate(v) - } - - // We don't really need to tag arrays, but let's be future proof. - // (If TOML ever supports tuples, we'll need this.) - return tag("array", typed) - case time.Time: - return tag("datetime", orig.Format("2006-01-02T15:04:05Z")) - case bool: - return tag("bool", fmt.Sprintf("%v", orig)) - case int64: - return tag("integer", fmt.Sprintf("%d", orig)) - case float64: - return tag("float", fmt.Sprintf("%v", orig)) - case string: - return tag("string", orig) - } - - panic(fmt.Sprintf("Unknown type: %T", tomlData)) -} - -func tag(typeName string, data interface{}) map[string]interface{} { - return map[string]interface{}{ - "type": typeName, - "value": data, - } -} diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING b/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING deleted file mode 100644 index 5a8e332..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/COPYING +++ /dev/null @@ -1,14 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md b/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md deleted file mode 100644 index 45a603f..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# Implements the TOML test suite interface for TOML encoders - -This is an implementation of the interface expected by -[toml-test](https://github.com/BurntSushi/toml-test) for the -[TOML encoder](https://github.com/BurntSushi/toml). -In particular, it maps JSON data on `stdin` to a TOML format on `stdout`. - - -Compatible with TOML version -[v0.2.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.2.0.md) - -Compatible with `toml-test` version -[v0.2.0](https://github.com/BurntSushi/toml-test/tree/v0.2.0) - diff --git a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go b/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go deleted file mode 100644 index 092cc68..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/toml-test-encoder/main.go +++ /dev/null @@ -1,131 +0,0 @@ -// Command toml-test-encoder satisfies the toml-test interface for testing -// TOML encoders. Namely, it accepts JSON on stdin and outputs TOML on stdout. -package main - -import ( - "encoding/json" - "flag" - "log" - "os" - "path" - "strconv" - "time" - - "github.com/BurntSushi/toml" -) - -func init() { - log.SetFlags(0) - - flag.Usage = usage - flag.Parse() -} - -func usage() { - log.Printf("Usage: %s < json-file\n", path.Base(os.Args[0])) - flag.PrintDefaults() - - os.Exit(1) -} - -func main() { - if flag.NArg() != 0 { - flag.Usage() - } - - var tmp interface{} - if err := json.NewDecoder(os.Stdin).Decode(&tmp); err != nil { - log.Fatalf("Error decoding JSON: %s", err) - } - - tomlData := translate(tmp) - if err := toml.NewEncoder(os.Stdout).Encode(tomlData); err != nil { - log.Fatalf("Error encoding TOML: %s", err) - } -} - -func translate(typedJson interface{}) interface{} { - switch v := typedJson.(type) { - case map[string]interface{}: - if len(v) == 2 && in("type", v) && in("value", v) { - return untag(v) - } - m := make(map[string]interface{}, len(v)) - for k, v2 := range v { - m[k] = translate(v2) - } - return m - case []interface{}: - tabArray := make([]map[string]interface{}, len(v)) - for i := range v { - if m, ok := translate(v[i]).(map[string]interface{}); ok { - tabArray[i] = m - } else { - log.Fatalf("JSON arrays may only contain objects. This " + - "corresponds to only tables being allowed in " + - "TOML table arrays.") - } - } - return tabArray - } - log.Fatalf("Unrecognized JSON format '%T'.", typedJson) - panic("unreachable") -} - -func untag(typed map[string]interface{}) interface{} { - t := typed["type"].(string) - v := typed["value"] - switch t { - case "string": - return v.(string) - case "integer": - v := v.(string) - n, err := strconv.Atoi(v) - if err != nil { - log.Fatalf("Could not parse '%s' as integer: %s", v, err) - } - return n - case "float": - v := v.(string) - f, err := strconv.ParseFloat(v, 64) - if err != nil { - log.Fatalf("Could not parse '%s' as float64: %s", v, err) - } - return f - case "datetime": - v := v.(string) - t, err := time.Parse("2006-01-02T15:04:05Z", v) - if err != nil { - log.Fatalf("Could not parse '%s' as a datetime: %s", v, err) - } - return t - case "bool": - v := v.(string) - switch v { - case "true": - return true - case "false": - return false - } - log.Fatalf("Could not parse '%s' as a boolean.", v) - case "array": - v := v.([]interface{}) - array := make([]interface{}, len(v)) - for i := range v { - if m, ok := v[i].(map[string]interface{}); ok { - array[i] = untag(m) - } else { - log.Fatalf("Arrays may only contain other arrays or "+ - "primitive values, but found a '%T'.", m) - } - } - return array - } - log.Fatalf("Unrecognized tag type '%s'.", t) - panic("unreachable") -} - -func in(key string, m map[string]interface{}) bool { - _, ok := m[key] - return ok -} diff --git a/vendor/github.com/BurntSushi/toml/cmd/tomlv/COPYING b/vendor/github.com/BurntSushi/toml/cmd/tomlv/COPYING deleted file mode 100644 index 5a8e332..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/tomlv/COPYING +++ /dev/null @@ -1,14 +0,0 @@ - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. - diff --git a/vendor/github.com/BurntSushi/toml/cmd/tomlv/README.md b/vendor/github.com/BurntSushi/toml/cmd/tomlv/README.md deleted file mode 100644 index 5df0dc3..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/tomlv/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# TOML Validator - -If Go is installed, it's simple to try it out: - -```bash -go get github.com/BurntSushi/toml/cmd/tomlv -tomlv some-toml-file.toml -``` - -You can see the types of every key in a TOML file with: - -```bash -tomlv -types some-toml-file.toml -``` - -At the moment, only one error message is reported at a time. Error messages -include line numbers. No output means that the files given are valid TOML, or -there is a bug in `tomlv`. - -Compatible with TOML version -[v0.1.0](https://github.com/mojombo/toml/blob/master/versions/toml-v0.1.0.md) - diff --git a/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go b/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go deleted file mode 100644 index c7d689a..0000000 --- a/vendor/github.com/BurntSushi/toml/cmd/tomlv/main.go +++ /dev/null @@ -1,61 +0,0 @@ -// Command tomlv validates TOML documents and prints each key's type. -package main - -import ( - "flag" - "fmt" - "log" - "os" - "path" - "strings" - "text/tabwriter" - - "github.com/BurntSushi/toml" -) - -var ( - flagTypes = false -) - -func init() { - log.SetFlags(0) - - flag.BoolVar(&flagTypes, "types", flagTypes, - "When set, the types of every defined key will be shown.") - - flag.Usage = usage - flag.Parse() -} - -func usage() { - log.Printf("Usage: %s toml-file [ toml-file ... ]\n", - path.Base(os.Args[0])) - flag.PrintDefaults() - - os.Exit(1) -} - -func main() { - if flag.NArg() < 1 { - flag.Usage() - } - for _, f := range flag.Args() { - var tmp interface{} - md, err := toml.DecodeFile(f, &tmp) - if err != nil { - log.Fatalf("Error in '%s': %s", f, err) - } - if flagTypes { - printTypes(md) - } - } -} - -func printTypes(md toml.MetaData) { - tabw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) - for _, key := range md.Keys() { - fmt.Fprintf(tabw, "%s%s\t%s\n", - strings.Repeat(" ", len(key)-1), key, md.Type(key...)) - } - tabw.Flush() -} diff --git a/vendor/github.com/BurntSushi/toml/decode.go b/vendor/github.com/BurntSushi/toml/decode.go deleted file mode 100644 index 98c8aa6..0000000 --- a/vendor/github.com/BurntSushi/toml/decode.go +++ /dev/null @@ -1,512 +0,0 @@ -package toml - -import ( - "fmt" - "io" - "io/ioutil" - "math" - "reflect" - "strings" - "time" -) - -var e = fmt.Errorf - -// Unmarshaler is the interface implemented by objects that can unmarshal a -// TOML description of themselves. -type Unmarshaler interface { - UnmarshalTOML(interface{}) error -} - -// Unmarshal decodes the contents of `p` in TOML format into a pointer `v`. -func Unmarshal(p []byte, v interface{}) error { - _, err := Decode(string(p), v) - return err -} - -// Primitive is a TOML value that hasn't been decoded into a Go value. -// When using the various `Decode*` functions, the type `Primitive` may -// be given to any value, and its decoding will be delayed. -// -// A `Primitive` value can be decoded using the `PrimitiveDecode` function. -// -// The underlying representation of a `Primitive` value is subject to change. -// Do not rely on it. -// -// N.B. Primitive values are still parsed, so using them will only avoid -// the overhead of reflection. They can be useful when you don't know the -// exact type of TOML data until run time. -type Primitive struct { - undecoded interface{} - context Key -} - -// DEPRECATED! -// -// Use MetaData.PrimitiveDecode instead. -func PrimitiveDecode(primValue Primitive, v interface{}) error { - md := MetaData{decoded: make(map[string]bool)} - return md.unify(primValue.undecoded, rvalue(v)) -} - -// PrimitiveDecode is just like the other `Decode*` functions, except it -// decodes a TOML value that has already been parsed. Valid primitive values -// can *only* be obtained from values filled by the decoder functions, -// including this method. (i.e., `v` may contain more `Primitive` -// values.) -// -// Meta data for primitive values is included in the meta data returned by -// the `Decode*` functions with one exception: keys returned by the Undecoded -// method will only reflect keys that were decoded. Namely, any keys hidden -// behind a Primitive will be considered undecoded. Executing this method will -// update the undecoded keys in the meta data. (See the example.) -func (md *MetaData) PrimitiveDecode(primValue Primitive, v interface{}) error { - md.context = primValue.context - defer func() { md.context = nil }() - return md.unify(primValue.undecoded, rvalue(v)) -} - -// Decode will decode the contents of `data` in TOML format into a pointer -// `v`. -// -// TOML hashes correspond to Go structs or maps. (Dealer's choice. They can be -// used interchangeably.) -// -// TOML arrays of tables correspond to either a slice of structs or a slice -// of maps. -// -// TOML datetimes correspond to Go `time.Time` values. -// -// All other TOML types (float, string, int, bool and array) correspond -// to the obvious Go types. -// -// An exception to the above rules is if a type implements the -// encoding.TextUnmarshaler interface. In this case, any primitive TOML value -// (floats, strings, integers, booleans and datetimes) will be converted to -// a byte string and given to the value's UnmarshalText method. See the -// Unmarshaler example for a demonstration with time duration strings. -// -// Key mapping -// -// TOML keys can map to either keys in a Go map or field names in a Go -// struct. The special `toml` struct tag may be used to map TOML keys to -// struct fields that don't match the key name exactly. (See the example.) -// A case insensitive match to struct names will be tried if an exact match -// can't be found. -// -// The mapping between TOML values and Go values is loose. That is, there -// may exist TOML values that cannot be placed into your representation, and -// there may be parts of your representation that do not correspond to -// TOML values. This loose mapping can be made stricter by using the IsDefined -// and/or Undecoded methods on the MetaData returned. -// -// This decoder will not handle cyclic types. If a cyclic type is passed, -// `Decode` will not terminate. -func Decode(data string, v interface{}) (MetaData, error) { - rv := reflect.ValueOf(v) - if rv.Kind() != reflect.Ptr { - return MetaData{}, e("Decode of non-pointer type %s", reflect.TypeOf(v)) - } - if rv.IsNil() { - return MetaData{}, e("Decode of nil %s", reflect.TypeOf(v)) - } - p, err := parse(data) - if err != nil { - return MetaData{}, err - } - md := MetaData{ - p.mapping, p.types, p.ordered, - make(map[string]bool, len(p.ordered)), nil, - } - return md, md.unify(p.mapping, indirect(rv)) -} - -// DecodeFile is just like Decode, except it will automatically read the -// contents of the file at `fpath` and decode it for you. -func DecodeFile(fpath string, v interface{}) (MetaData, error) { - bs, err := ioutil.ReadFile(fpath) - if err != nil { - return MetaData{}, err - } - return Decode(string(bs), v) -} - -// DecodeReader is just like Decode, except it will consume all bytes -// from the reader and decode it for you. -func DecodeReader(r io.Reader, v interface{}) (MetaData, error) { - bs, err := ioutil.ReadAll(r) - if err != nil { - return MetaData{}, err - } - return Decode(string(bs), v) -} - -// unify performs a sort of type unification based on the structure of `rv`, -// which is the client representation. -// -// Any type mismatch produces an error. Finding a type that we don't know -// how to handle produces an unsupported type error. -func (md *MetaData) unify(data interface{}, rv reflect.Value) error { - - // Special case. Look for a `Primitive` value. - if rv.Type() == reflect.TypeOf((*Primitive)(nil)).Elem() { - // Save the undecoded data and the key context into the primitive - // value. - context := make(Key, len(md.context)) - copy(context, md.context) - rv.Set(reflect.ValueOf(Primitive{ - undecoded: data, - context: context, - })) - return nil - } - - // Special case. Unmarshaler Interface support. - if rv.CanAddr() { - if v, ok := rv.Addr().Interface().(Unmarshaler); ok { - return v.UnmarshalTOML(data) - } - } - - // Special case. Handle time.Time values specifically. - // TODO: Remove this code when we decide to drop support for Go 1.1. - // This isn't necessary in Go 1.2 because time.Time satisfies the encoding - // interfaces. - if rv.Type().AssignableTo(rvalue(time.Time{}).Type()) { - return md.unifyDatetime(data, rv) - } - - // Special case. Look for a value satisfying the TextUnmarshaler interface. - if v, ok := rv.Interface().(TextUnmarshaler); ok { - return md.unifyText(data, v) - } - // BUG(burntsushi) - // The behavior here is incorrect whenever a Go type satisfies the - // encoding.TextUnmarshaler interface but also corresponds to a TOML - // hash or array. In particular, the unmarshaler should only be applied - // to primitive TOML values. But at this point, it will be applied to - // all kinds of values and produce an incorrect error whenever those values - // are hashes or arrays (including arrays of tables). - - k := rv.Kind() - - // laziness - if k >= reflect.Int && k <= reflect.Uint64 { - return md.unifyInt(data, rv) - } - switch k { - case reflect.Ptr: - elem := reflect.New(rv.Type().Elem()) - err := md.unify(data, reflect.Indirect(elem)) - if err != nil { - return err - } - rv.Set(elem) - return nil - case reflect.Struct: - return md.unifyStruct(data, rv) - case reflect.Map: - return md.unifyMap(data, rv) - case reflect.Array: - return md.unifyArray(data, rv) - case reflect.Slice: - return md.unifySlice(data, rv) - case reflect.String: - return md.unifyString(data, rv) - case reflect.Bool: - return md.unifyBool(data, rv) - case reflect.Interface: - // we only support empty interfaces. - if rv.NumMethod() > 0 { - return e("Unsupported type '%s'.", rv.Kind()) - } - return md.unifyAnything(data, rv) - case reflect.Float32: - fallthrough - case reflect.Float64: - return md.unifyFloat64(data, rv) - } - return e("Unsupported type '%s'.", rv.Kind()) -} - -func (md *MetaData) unifyStruct(mapping interface{}, rv reflect.Value) error { - tmap, ok := mapping.(map[string]interface{}) - if !ok { - if mapping == nil { - return nil - } - return mismatch(rv, "map", mapping) - } - - for key, datum := range tmap { - var f *field - fields := cachedTypeFields(rv.Type()) - for i := range fields { - ff := &fields[i] - if ff.name == key { - f = ff - break - } - if f == nil && strings.EqualFold(ff.name, key) { - f = ff - } - } - if f != nil { - subv := rv - for _, i := range f.index { - subv = indirect(subv.Field(i)) - } - if isUnifiable(subv) { - md.decoded[md.context.add(key).String()] = true - md.context = append(md.context, key) - if err := md.unify(datum, subv); err != nil { - return e("Type mismatch for '%s.%s': %s", - rv.Type().String(), f.name, err) - } - md.context = md.context[0 : len(md.context)-1] - } else if f.name != "" { - // Bad user! No soup for you! - return e("Field '%s.%s' is unexported, and therefore cannot "+ - "be loaded with reflection.", rv.Type().String(), f.name) - } - } - } - return nil -} - -func (md *MetaData) unifyMap(mapping interface{}, rv reflect.Value) error { - tmap, ok := mapping.(map[string]interface{}) - if !ok { - if tmap == nil { - return nil - } - return badtype("map", mapping) - } - if rv.IsNil() { - rv.Set(reflect.MakeMap(rv.Type())) - } - for k, v := range tmap { - md.decoded[md.context.add(k).String()] = true - md.context = append(md.context, k) - - rvkey := indirect(reflect.New(rv.Type().Key())) - rvval := reflect.Indirect(reflect.New(rv.Type().Elem())) - if err := md.unify(v, rvval); err != nil { - return err - } - md.context = md.context[0 : len(md.context)-1] - - rvkey.SetString(k) - rv.SetMapIndex(rvkey, rvval) - } - return nil -} - -func (md *MetaData) unifyArray(data interface{}, rv reflect.Value) error { - datav := reflect.ValueOf(data) - if datav.Kind() != reflect.Slice { - if !datav.IsValid() { - return nil - } - return badtype("slice", data) - } - sliceLen := datav.Len() - if sliceLen != rv.Len() { - return e("expected array length %d; got TOML array of length %d", - rv.Len(), sliceLen) - } - return md.unifySliceArray(datav, rv) -} - -func (md *MetaData) unifySlice(data interface{}, rv reflect.Value) error { - datav := reflect.ValueOf(data) - if datav.Kind() != reflect.Slice { - if !datav.IsValid() { - return nil - } - return badtype("slice", data) - } - n := datav.Len() - if rv.IsNil() || rv.Cap() < n { - rv.Set(reflect.MakeSlice(rv.Type(), n, n)) - } - rv.SetLen(n) - return md.unifySliceArray(datav, rv) -} - -func (md *MetaData) unifySliceArray(data, rv reflect.Value) error { - sliceLen := data.Len() - for i := 0; i < sliceLen; i++ { - v := data.Index(i).Interface() - sliceval := indirect(rv.Index(i)) - if err := md.unify(v, sliceval); err != nil { - return err - } - } - return nil -} - -func (md *MetaData) unifyDatetime(data interface{}, rv reflect.Value) error { - if _, ok := data.(time.Time); ok { - rv.Set(reflect.ValueOf(data)) - return nil - } - return badtype("time.Time", data) -} - -func (md *MetaData) unifyString(data interface{}, rv reflect.Value) error { - if s, ok := data.(string); ok { - rv.SetString(s) - return nil - } - return badtype("string", data) -} - -func (md *MetaData) unifyFloat64(data interface{}, rv reflect.Value) error { - if num, ok := data.(float64); ok { - switch rv.Kind() { - case reflect.Float32: - fallthrough - case reflect.Float64: - rv.SetFloat(num) - default: - panic("bug") - } - return nil - } - return badtype("float", data) -} - -func (md *MetaData) unifyInt(data interface{}, rv reflect.Value) error { - if num, ok := data.(int64); ok { - if rv.Kind() >= reflect.Int && rv.Kind() <= reflect.Int64 { - switch rv.Kind() { - case reflect.Int, reflect.Int64: - // No bounds checking necessary. - case reflect.Int8: - if num < math.MinInt8 || num > math.MaxInt8 { - return e("Value '%d' is out of range for int8.", num) - } - case reflect.Int16: - if num < math.MinInt16 || num > math.MaxInt16 { - return e("Value '%d' is out of range for int16.", num) - } - case reflect.Int32: - if num < math.MinInt32 || num > math.MaxInt32 { - return e("Value '%d' is out of range for int32.", num) - } - } - rv.SetInt(num) - } else if rv.Kind() >= reflect.Uint && rv.Kind() <= reflect.Uint64 { - unum := uint64(num) - switch rv.Kind() { - case reflect.Uint, reflect.Uint64: - // No bounds checking necessary. - case reflect.Uint8: - if num < 0 || unum > math.MaxUint8 { - return e("Value '%d' is out of range for uint8.", num) - } - case reflect.Uint16: - if num < 0 || unum > math.MaxUint16 { - return e("Value '%d' is out of range for uint16.", num) - } - case reflect.Uint32: - if num < 0 || unum > math.MaxUint32 { - return e("Value '%d' is out of range for uint32.", num) - } - } - rv.SetUint(unum) - } else { - panic("unreachable") - } - return nil - } - return badtype("integer", data) -} - -func (md *MetaData) unifyBool(data interface{}, rv reflect.Value) error { - if b, ok := data.(bool); ok { - rv.SetBool(b) - return nil - } - return badtype("boolean", data) -} - -func (md *MetaData) unifyAnything(data interface{}, rv reflect.Value) error { - rv.Set(reflect.ValueOf(data)) - return nil -} - -func (md *MetaData) unifyText(data interface{}, v TextUnmarshaler) error { - var s string - switch sdata := data.(type) { - case TextMarshaler: - text, err := sdata.MarshalText() - if err != nil { - return err - } - s = string(text) - case fmt.Stringer: - s = sdata.String() - case string: - s = sdata - case bool: - s = fmt.Sprintf("%v", sdata) - case int64: - s = fmt.Sprintf("%d", sdata) - case float64: - s = fmt.Sprintf("%f", sdata) - default: - return badtype("primitive (string-like)", data) - } - if err := v.UnmarshalText([]byte(s)); err != nil { - return err - } - return nil -} - -// rvalue returns a reflect.Value of `v`. All pointers are resolved. -func rvalue(v interface{}) reflect.Value { - return indirect(reflect.ValueOf(v)) -} - -// indirect returns the value pointed to by a pointer. -// Pointers are followed until the value is not a pointer. -// New values are allocated for each nil pointer. -// -// An exception to this rule is if the value satisfies an interface of -// interest to us (like encoding.TextUnmarshaler). -func indirect(v reflect.Value) reflect.Value { - if v.Kind() != reflect.Ptr { - if v.CanAddr() { - pv := v.Addr() - if _, ok := pv.Interface().(TextUnmarshaler); ok { - return pv - } - } - return v - } - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - return indirect(reflect.Indirect(v)) -} - -func isUnifiable(rv reflect.Value) bool { - if rv.CanSet() { - return true - } - if _, ok := rv.Interface().(TextUnmarshaler); ok { - return true - } - return false -} - -func badtype(expected string, data interface{}) error { - return e("Expected %s but found '%T'.", expected, data) -} - -func mismatch(user reflect.Value, expected string, data interface{}) error { - return e("Type mismatch for %s. Expected %s but found '%T'.", - user.Type().String(), expected, data) -} diff --git a/vendor/github.com/BurntSushi/toml/decode_meta.go b/vendor/github.com/BurntSushi/toml/decode_meta.go deleted file mode 100644 index ef6f545..0000000 --- a/vendor/github.com/BurntSushi/toml/decode_meta.go +++ /dev/null @@ -1,122 +0,0 @@ -package toml - -import "strings" - -// MetaData allows access to meta information about TOML data that may not -// be inferrable via reflection. In particular, whether a key has been defined -// and the TOML type of a key. -type MetaData struct { - mapping map[string]interface{} - types map[string]tomlType - keys []Key - decoded map[string]bool - context Key // Used only during decoding. -} - -// IsDefined returns true if the key given exists in the TOML data. The key -// should be specified hierarchially. e.g., -// -// // access the TOML key 'a.b.c' -// IsDefined("a", "b", "c") -// -// IsDefined will return false if an empty key given. Keys are case sensitive. -func (md *MetaData) IsDefined(key ...string) bool { - if len(key) == 0 { - return false - } - - var hash map[string]interface{} - var ok bool - var hashOrVal interface{} = md.mapping - for _, k := range key { - if hash, ok = hashOrVal.(map[string]interface{}); !ok { - return false - } - if hashOrVal, ok = hash[k]; !ok { - return false - } - } - return true -} - -// Type returns a string representation of the type of the key specified. -// -// Type will return the empty string if given an empty key or a key that -// does not exist. Keys are case sensitive. -func (md *MetaData) Type(key ...string) string { - fullkey := strings.Join(key, ".") - if typ, ok := md.types[fullkey]; ok { - return typ.typeString() - } - return "" -} - -// Key is the type of any TOML key, including key groups. Use (MetaData).Keys -// to get values of this type. -type Key []string - -func (k Key) String() string { - return strings.Join(k, ".") -} - -func (k Key) maybeQuotedAll() string { - var ss []string - for i := range k { - ss = append(ss, k.maybeQuoted(i)) - } - return strings.Join(ss, ".") -} - -func (k Key) maybeQuoted(i int) string { - quote := false - for _, c := range k[i] { - if !isBareKeyChar(c) { - quote = true - break - } - } - if quote { - return "\"" + strings.Replace(k[i], "\"", "\\\"", -1) + "\"" - } else { - return k[i] - } -} - -func (k Key) add(piece string) Key { - newKey := make(Key, len(k)+1) - copy(newKey, k) - newKey[len(k)] = piece - return newKey -} - -// Keys returns a slice of every key in the TOML data, including key groups. -// Each key is itself a slice, where the first element is the top of the -// hierarchy and the last is the most specific. -// -// The list will have the same order as the keys appeared in the TOML data. -// -// All keys returned are non-empty. -func (md *MetaData) Keys() []Key { - return md.keys -} - -// Undecoded returns all keys that have not been decoded in the order in which -// they appear in the original TOML document. -// -// This includes keys that haven't been decoded because of a Primitive value. -// Once the Primitive value is decoded, the keys will be considered decoded. -// -// Also note that decoding into an empty interface will result in no decoding, -// and so no keys will be considered decoded. -// -// In this sense, the Undecoded keys correspond to keys in the TOML document -// that do not have a concrete type in your representation. -func (md *MetaData) Undecoded() []Key { - undecoded := make([]Key, 0, len(md.keys)) - for _, key := range md.keys { - if !md.decoded[key.String()] { - undecoded = append(undecoded, key) - } - } - return undecoded -} diff --git a/vendor/github.com/BurntSushi/toml/decode_test.go b/vendor/github.com/BurntSushi/toml/decode_test.go deleted file mode 100644 index d746527..0000000 --- a/vendor/github.com/BurntSushi/toml/decode_test.go +++ /dev/null @@ -1,1278 +0,0 @@ -package toml - -import ( - "fmt" - "log" - "math" - "reflect" - "strings" - "testing" - "time" -) - -func TestDecodeSimple(t *testing.T) { - var testSimple = ` -age = 250 -andrew = "gallant" -kait = "brady" -now = 1987-07-05T05:45:00Z -yesOrNo = true -pi = 3.14 -colors = [ - ["red", "green", "blue"], - ["cyan", "magenta", "yellow", "black"], -] - -[My.Cats] -plato = "cat 1" -cauchy = "cat 2" -` - - type cats struct { - Plato string - Cauchy string - } - type simple struct { - Age int - Colors [][]string - Pi float64 - YesOrNo bool - Now time.Time - Andrew string - Kait string - My map[string]cats - } - - var val simple - _, err := Decode(testSimple, &val) - if err != nil { - t.Fatal(err) - } - - now, err := time.Parse("2006-01-02T15:04:05", "1987-07-05T05:45:00") - if err != nil { - panic(err) - } - var answer = simple{ - Age: 250, - Andrew: "gallant", - Kait: "brady", - Now: now, - YesOrNo: true, - Pi: 3.14, - Colors: [][]string{ - {"red", "green", "blue"}, - {"cyan", "magenta", "yellow", "black"}, - }, - My: map[string]cats{ - "Cats": {Plato: "cat 1", Cauchy: "cat 2"}, - }, - } - if !reflect.DeepEqual(val, answer) { - t.Fatalf("Expected\n-----\n%#v\n-----\nbut got\n-----\n%#v\n", - answer, val) - } -} - -func TestDecodeEmbedded(t *testing.T) { - type Dog struct{ Name string } - type Age int - - tests := map[string]struct { - input string - decodeInto interface{} - wantDecoded interface{} - }{ - "embedded struct": { - input: `Name = "milton"`, - decodeInto: &struct{ Dog }{}, - wantDecoded: &struct{ Dog }{Dog{"milton"}}, - }, - "embedded non-nil pointer to struct": { - input: `Name = "milton"`, - decodeInto: &struct{ *Dog }{}, - wantDecoded: &struct{ *Dog }{&Dog{"milton"}}, - }, - "embedded nil pointer to struct": { - input: ``, - decodeInto: &struct{ *Dog }{}, - wantDecoded: &struct{ *Dog }{nil}, - }, - "embedded int": { - input: `Age = -5`, - decodeInto: &struct{ Age }{}, - wantDecoded: &struct{ Age }{-5}, - }, - } - - for label, test := range tests { - _, err := Decode(test.input, test.decodeInto) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(test.wantDecoded, test.decodeInto) { - t.Errorf("%s: want decoded == %+v, got %+v", - label, test.wantDecoded, test.decodeInto) - } - } -} - -func TestDecodeIgnoredFields(t *testing.T) { - type simple struct { - Number int `toml:"-"` - } - const input = ` -Number = 123 -- = 234 -` - var s simple - if _, err := Decode(input, &s); err != nil { - t.Fatal(err) - } - if s.Number != 0 { - t.Errorf("got: %d; want 0", s.Number) - } -} - -func TestTableArrays(t *testing.T) { - var tomlTableArrays = ` -[[albums]] -name = "Born to Run" - - [[albums.songs]] - name = "Jungleland" - - [[albums.songs]] - name = "Meeting Across the River" - -[[albums]] -name = "Born in the USA" - - [[albums.songs]] - name = "Glory Days" - - [[albums.songs]] - name = "Dancing in the Dark" -` - - type Song struct { - Name string - } - - type Album struct { - Name string - Songs []Song - } - - type Music struct { - Albums []Album - } - - expected := Music{[]Album{ - {"Born to Run", []Song{{"Jungleland"}, {"Meeting Across the River"}}}, - {"Born in the USA", []Song{{"Glory Days"}, {"Dancing in the Dark"}}}, - }} - var got Music - if _, err := Decode(tomlTableArrays, &got); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, got) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, got) - } -} - -func TestTableNesting(t *testing.T) { - for _, tt := range []struct { - t string - want []string - }{ - {"[a.b.c]", []string{"a", "b", "c"}}, - {`[a."b.c"]`, []string{"a", "b.c"}}, - {`[a.'b.c']`, []string{"a", "b.c"}}, - {`[a.' b ']`, []string{"a", " b "}}, - {"[ d.e.f ]", []string{"d", "e", "f"}}, - {"[ g . h . i ]", []string{"g", "h", "i"}}, - {`[ j . "Êž" . 'l' ]`, []string{"j", "Êž", "l"}}, - } { - var m map[string]interface{} - if _, err := Decode(tt.t, &m); err != nil { - t.Errorf("Decode(%q): got error: %s", tt.t, err) - continue - } - if keys := extractNestedKeys(m); !reflect.DeepEqual(keys, tt.want) { - t.Errorf("Decode(%q): got nested keys %#v; want %#v", - tt.t, keys, tt.want) - } - } -} - -func extractNestedKeys(v map[string]interface{}) []string { - var result []string - for { - if len(v) != 1 { - return result - } - for k, m := range v { - result = append(result, k) - var ok bool - v, ok = m.(map[string]interface{}) - if !ok { - return result - } - } - - } -} - -// Case insensitive matching tests. -// A bit more comprehensive than needed given the current implementation, -// but implementations change. -// Probably still missing demonstrations of some ugly corner cases regarding -// case insensitive matching and multiple fields. -func TestCase(t *testing.T) { - var caseToml = ` -tOpString = "string" -tOpInt = 1 -tOpFloat = 1.1 -tOpBool = true -tOpdate = 2006-01-02T15:04:05Z -tOparray = [ "array" ] -Match = "i should be in Match only" -MatcH = "i should be in MatcH only" -once = "just once" -[nEst.eD] -nEstedString = "another string" -` - - type InsensitiveEd struct { - NestedString string - } - - type InsensitiveNest struct { - Ed InsensitiveEd - } - - type Insensitive struct { - TopString string - TopInt int - TopFloat float64 - TopBool bool - TopDate time.Time - TopArray []string - Match string - MatcH string - Once string - OncE string - Nest InsensitiveNest - } - - tme, err := time.Parse(time.RFC3339, time.RFC3339[:len(time.RFC3339)-5]) - if err != nil { - panic(err) - } - expected := Insensitive{ - TopString: "string", - TopInt: 1, - TopFloat: 1.1, - TopBool: true, - TopDate: tme, - TopArray: []string{"array"}, - MatcH: "i should be in MatcH only", - Match: "i should be in Match only", - Once: "just once", - OncE: "", - Nest: InsensitiveNest{ - Ed: InsensitiveEd{NestedString: "another string"}, - }, - } - var got Insensitive - if _, err := Decode(caseToml, &got); err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(expected, got) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, got) - } -} - -func TestPointers(t *testing.T) { - type Object struct { - Type string - Description string - } - - type Dict struct { - NamedObject map[string]*Object - BaseObject *Object - Strptr *string - Strptrs []*string - } - s1, s2, s3 := "blah", "abc", "def" - expected := &Dict{ - Strptr: &s1, - Strptrs: []*string{&s2, &s3}, - NamedObject: map[string]*Object{ - "foo": {"FOO", "fooooo!!!"}, - "bar": {"BAR", "ba-ba-ba-ba-barrrr!!!"}, - }, - BaseObject: &Object{"BASE", "da base"}, - } - - ex1 := ` -Strptr = "blah" -Strptrs = ["abc", "def"] - -[NamedObject.foo] -Type = "FOO" -Description = "fooooo!!!" - -[NamedObject.bar] -Type = "BAR" -Description = "ba-ba-ba-ba-barrrr!!!" - -[BaseObject] -Type = "BASE" -Description = "da base" -` - dict := new(Dict) - _, err := Decode(ex1, dict) - if err != nil { - t.Errorf("Decode error: %v", err) - } - if !reflect.DeepEqual(expected, dict) { - t.Fatalf("\n%#v\n!=\n%#v\n", expected, dict) - } -} - -func TestDecodeDatetime(t *testing.T) { - const noTimestamp = "2006-01-02T15:04:05" - for _, tt := range []struct { - s string - t string - format string - }{ - {"1979-05-27T07:32:00Z", "1979-05-27T07:32:00Z", time.RFC3339}, - {"1979-05-27T00:32:00-07:00", "1979-05-27T00:32:00-07:00", time.RFC3339}, - { - "1979-05-27T00:32:00.999999-07:00", - "1979-05-27T00:32:00.999999-07:00", - time.RFC3339, - }, - {"1979-05-27T07:32:00", "1979-05-27T07:32:00", noTimestamp}, - { - "1979-05-27T00:32:00.999999", - "1979-05-27T00:32:00.999999", - noTimestamp, - }, - {"1979-05-27", "1979-05-27T00:00:00", noTimestamp}, - } { - var x struct{ D time.Time } - input := "d = " + tt.s - if _, err := Decode(input, &x); err != nil { - t.Errorf("Decode(%q): got error: %s", input, err) - continue - } - want, err := time.ParseInLocation(tt.format, tt.t, time.Local) - if err != nil { - panic(err) - } - if !x.D.Equal(want) { - t.Errorf("Decode(%q): got %s; want %s", input, x.D, want) - } - } -} - -func TestDecodeBadDatetime(t *testing.T) { - var x struct{ T time.Time } - for _, s := range []string{ - "123", - "2006-01-50T00:00:00Z", - "2006-01-30T00:00", - "2006-01-30T", - } { - input := "T = " + s - if _, err := Decode(input, &x); err == nil { - t.Errorf("Expected invalid DateTime error for %q", s) - } - } -} - -func TestDecodeMultilineStrings(t *testing.T) { - var x struct { - S string - } - const s0 = `s = """ -a b \n c -d e f -"""` - if _, err := Decode(s0, &x); err != nil { - t.Fatal(err) - } - if want := "a b \n c\nd e f\n"; x.S != want { - t.Errorf("got: %q; want: %q", x.S, want) - } - const s1 = `s = """a b c\ -"""` - if _, err := Decode(s1, &x); err != nil { - t.Fatal(err) - } - if want := "a b c"; x.S != want { - t.Errorf("got: %q; want: %q", x.S, want) - } -} - -type sphere struct { - Center [3]float64 - Radius float64 -} - -func TestDecodeSimpleArray(t *testing.T) { - var s1 sphere - if _, err := Decode(`center = [0.0, 1.5, 0.0]`, &s1); err != nil { - t.Fatal(err) - } -} - -func TestDecodeArrayWrongSize(t *testing.T) { - var s1 sphere - if _, err := Decode(`center = [0.1, 2.3]`, &s1); err == nil { - t.Fatal("Expected array type mismatch error") - } -} - -func TestDecodeLargeIntoSmallInt(t *testing.T) { - type table struct { - Value int8 - } - var tab table - if _, err := Decode(`value = 500`, &tab); err == nil { - t.Fatal("Expected integer out-of-bounds error.") - } -} - -func TestDecodeSizedInts(t *testing.T) { - type table struct { - U8 uint8 - U16 uint16 - U32 uint32 - U64 uint64 - U uint - I8 int8 - I16 int16 - I32 int32 - I64 int64 - I int - } - answer := table{1, 1, 1, 1, 1, -1, -1, -1, -1, -1} - toml := ` - u8 = 1 - u16 = 1 - u32 = 1 - u64 = 1 - u = 1 - i8 = -1 - i16 = -1 - i32 = -1 - i64 = -1 - i = -1 - ` - var tab table - if _, err := Decode(toml, &tab); err != nil { - t.Fatal(err.Error()) - } - if answer != tab { - t.Fatalf("Expected %#v but got %#v", answer, tab) - } -} - -func TestDecodeInts(t *testing.T) { - for _, tt := range []struct { - s string - want int64 - }{ - {"0", 0}, - {"+99", 99}, - {"-10", -10}, - {"1_234_567", 1234567}, - {"1_2_3_4", 1234}, - {"-9_223_372_036_854_775_808", math.MinInt64}, - {"9_223_372_036_854_775_807", math.MaxInt64}, - } { - var x struct{ N int64 } - input := "n = " + tt.s - if _, err := Decode(input, &x); err != nil { - t.Errorf("Decode(%q): got error: %s", input, err) - continue - } - if x.N != tt.want { - t.Errorf("Decode(%q): got %d; want %d", input, x.N, tt.want) - } - } -} - -func TestDecodeFloats(t *testing.T) { - for _, tt := range []struct { - s string - want float64 - }{ - {"+1.0", 1}, - {"3.1415", 3.1415}, - {"-0.01", -0.01}, - {"5e+22", 5e22}, - {"1e6", 1e6}, - {"-2E-2", -2e-2}, - {"6.626e-34", 6.626e-34}, - {"9_224_617.445_991_228_313", 9224617.445991228313}, - {"9_876.54_32e1_0", 9876.5432e10}, - } { - var x struct{ N float64 } - input := "n = " + tt.s - if _, err := Decode(input, &x); err != nil { - t.Errorf("Decode(%q): got error: %s", input, err) - continue - } - if x.N != tt.want { - t.Errorf("Decode(%q): got %d; want %d", input, x.N, tt.want) - } - } -} - -func TestDecodeMalformedNumbers(t *testing.T) { - for _, tt := range []struct { - s string - want string - }{ - {"++99", "Expected a digit"}, - {"0..1", "must be followed by one or more digits"}, - {"0.1.2", "Invalid float value"}, - {"1e2.3", "Invalid float value"}, - {"1e2e3", "Invalid float value"}, - {"_123", "Expected value"}, - {"123_", "surrounded by digits"}, - {"1._23", "surrounded by digits"}, - {"1e__23", "surrounded by digits"}, - {"123.", "must be followed by one or more digits"}, - {"1.e2", "must be followed by one or more digits"}, - } { - var x struct{ N interface{} } - input := "n = " + tt.s - _, err := Decode(input, &x) - if err == nil { - t.Errorf("Decode(%q): got nil, want error containing %q", - input, tt.want) - continue - } - if !strings.Contains(err.Error(), tt.want) { - t.Errorf("Decode(%q): got %q, want error containing %q", - input, err, tt.want) - } - } -} - -func TestDecodeBadValues(t *testing.T) { - for _, tt := range []struct { - v interface{} - want string - }{ - {3, "non-pointer type"}, - {(*int)(nil), "nil"}, - } { - _, err := Decode(`x = 3`, tt.v) - if err == nil { - t.Errorf("Decode(%v): got nil; want error containing %q", - tt.v, tt.want) - continue - } - if !strings.Contains(err.Error(), tt.want) { - t.Errorf("Decode(%v): got %q; want error containing %q", - tt.v, err, tt.want) - } - } -} - -func TestUnmarshaler(t *testing.T) { - - var tomlBlob = ` -[dishes.hamboogie] -name = "Hamboogie with fries" -price = 10.99 - -[[dishes.hamboogie.ingredients]] -name = "Bread Bun" - -[[dishes.hamboogie.ingredients]] -name = "Lettuce" - -[[dishes.hamboogie.ingredients]] -name = "Real Beef Patty" - -[[dishes.hamboogie.ingredients]] -name = "Tomato" - -[dishes.eggsalad] -name = "Egg Salad with rice" -price = 3.99 - -[[dishes.eggsalad.ingredients]] -name = "Egg" - -[[dishes.eggsalad.ingredients]] -name = "Mayo" - -[[dishes.eggsalad.ingredients]] -name = "Rice" -` - m := &menu{} - if _, err := Decode(tomlBlob, m); err != nil { - t.Fatal(err) - } - - if len(m.Dishes) != 2 { - t.Log("two dishes should be loaded with UnmarshalTOML()") - t.Errorf("expected %d but got %d", 2, len(m.Dishes)) - } - - eggSalad := m.Dishes["eggsalad"] - if _, ok := interface{}(eggSalad).(dish); !ok { - t.Errorf("expected a dish") - } - - if eggSalad.Name != "Egg Salad with rice" { - t.Errorf("expected the dish to be named 'Egg Salad with rice'") - } - - if len(eggSalad.Ingredients) != 3 { - t.Log("dish should be loaded with UnmarshalTOML()") - t.Errorf("expected %d but got %d", 3, len(eggSalad.Ingredients)) - } - - found := false - for _, i := range eggSalad.Ingredients { - if i.Name == "Rice" { - found = true - break - } - } - if !found { - t.Error("Rice was not loaded in UnmarshalTOML()") - } - - // test on a value - must be passed as * - o := menu{} - if _, err := Decode(tomlBlob, &o); err != nil { - t.Fatal(err) - } - -} - -type menu struct { - Dishes map[string]dish -} - -func (m *menu) UnmarshalTOML(p interface{}) error { - m.Dishes = make(map[string]dish) - data, _ := p.(map[string]interface{}) - dishes := data["dishes"].(map[string]interface{}) - for n, v := range dishes { - if d, ok := v.(map[string]interface{}); ok { - nd := dish{} - nd.UnmarshalTOML(d) - m.Dishes[n] = nd - } else { - return fmt.Errorf("not a dish") - } - } - return nil -} - -type dish struct { - Name string - Price float32 - Ingredients []ingredient -} - -func (d *dish) UnmarshalTOML(p interface{}) error { - data, _ := p.(map[string]interface{}) - d.Name, _ = data["name"].(string) - d.Price, _ = data["price"].(float32) - ingredients, _ := data["ingredients"].([]map[string]interface{}) - for _, e := range ingredients { - n, _ := interface{}(e).(map[string]interface{}) - name, _ := n["name"].(string) - i := ingredient{name} - d.Ingredients = append(d.Ingredients, i) - } - return nil -} - -type ingredient struct { - Name string -} - -func TestDecodeSlices(t *testing.T) { - type T struct { - S []string - } - for i, tt := range []struct { - v T - input string - want T - }{ - {T{}, "", T{}}, - {T{[]string{}}, "", T{[]string{}}}, - {T{[]string{"a", "b"}}, "", T{[]string{"a", "b"}}}, - {T{}, "S = []", T{[]string{}}}, - {T{[]string{}}, "S = []", T{[]string{}}}, - {T{[]string{"a", "b"}}, "S = []", T{[]string{}}}, - {T{}, `S = ["x"]`, T{[]string{"x"}}}, - {T{[]string{}}, `S = ["x"]`, T{[]string{"x"}}}, - {T{[]string{"a", "b"}}, `S = ["x"]`, T{[]string{"x"}}}, - } { - if _, err := Decode(tt.input, &tt.v); err != nil { - t.Errorf("[%d] %s", i, err) - continue - } - if !reflect.DeepEqual(tt.v, tt.want) { - t.Errorf("[%d] got %#v; want %#v", i, tt.v, tt.want) - } - } -} - -func TestDecodePrimitive(t *testing.T) { - type S struct { - P Primitive - } - type T struct { - S []int - } - slicep := func(s []int) *[]int { return &s } - arrayp := func(a [2]int) *[2]int { return &a } - mapp := func(m map[string]int) *map[string]int { return &m } - for i, tt := range []struct { - v interface{} - input string - want interface{} - }{ - // slices - {slicep(nil), "", slicep(nil)}, - {slicep([]int{}), "", slicep([]int{})}, - {slicep([]int{1, 2, 3}), "", slicep([]int{1, 2, 3})}, - {slicep(nil), "P = [1,2]", slicep([]int{1, 2})}, - {slicep([]int{}), "P = [1,2]", slicep([]int{1, 2})}, - {slicep([]int{1, 2, 3}), "P = [1,2]", slicep([]int{1, 2})}, - - // arrays - {arrayp([2]int{2, 3}), "", arrayp([2]int{2, 3})}, - {arrayp([2]int{2, 3}), "P = [3,4]", arrayp([2]int{3, 4})}, - - // maps - {mapp(nil), "", mapp(nil)}, - {mapp(map[string]int{}), "", mapp(map[string]int{})}, - {mapp(map[string]int{"a": 1}), "", mapp(map[string]int{"a": 1})}, - {mapp(nil), "[P]\na = 2", mapp(map[string]int{"a": 2})}, - {mapp(map[string]int{}), "[P]\na = 2", mapp(map[string]int{"a": 2})}, - {mapp(map[string]int{"a": 1, "b": 3}), "[P]\na = 2", mapp(map[string]int{"a": 2, "b": 3})}, - - // structs - {&T{nil}, "[P]", &T{nil}}, - {&T{[]int{}}, "[P]", &T{[]int{}}}, - {&T{[]int{1, 2, 3}}, "[P]", &T{[]int{1, 2, 3}}}, - {&T{nil}, "[P]\nS = [1,2]", &T{[]int{1, 2}}}, - {&T{[]int{}}, "[P]\nS = [1,2]", &T{[]int{1, 2}}}, - {&T{[]int{1, 2, 3}}, "[P]\nS = [1,2]", &T{[]int{1, 2}}}, - } { - var s S - md, err := Decode(tt.input, &s) - if err != nil { - t.Errorf("[%d] Decode error: %s", i, err) - continue - } - if err := md.PrimitiveDecode(s.P, tt.v); err != nil { - t.Errorf("[%d] PrimitiveDecode error: %s", i, err) - continue - } - if !reflect.DeepEqual(tt.v, tt.want) { - t.Errorf("[%d] got %#v; want %#v", i, tt.v, tt.want) - } - } -} - -func ExampleMetaData_PrimitiveDecode() { - var md MetaData - var err error - - var tomlBlob = ` -ranking = ["Springsteen", "J Geils"] - -[bands.Springsteen] -started = 1973 -albums = ["Greetings", "WIESS", "Born to Run", "Darkness"] - -[bands."J Geils"] -started = 1970 -albums = ["The J. Geils Band", "Full House", "Blow Your Face Out"] -` - - type band struct { - Started int - Albums []string - } - type classics struct { - Ranking []string - Bands map[string]Primitive - } - - // Do the initial decode. Reflection is delayed on Primitive values. - var music classics - if md, err = Decode(tomlBlob, &music); err != nil { - log.Fatal(err) - } - - // MetaData still includes information on Primitive values. - fmt.Printf("Is `bands.Springsteen` defined? %v\n", - md.IsDefined("bands", "Springsteen")) - - // Decode primitive data into Go values. - for _, artist := range music.Ranking { - // A band is a primitive value, so we need to decode it to get a - // real `band` value. - primValue := music.Bands[artist] - - var aBand band - if err = md.PrimitiveDecode(primValue, &aBand); err != nil { - log.Fatal(err) - } - fmt.Printf("%s started in %d.\n", artist, aBand.Started) - } - // Check to see if there were any fields left undecoded. - // Note that this won't be empty before decoding the Primitive value! - fmt.Printf("Undecoded: %q\n", md.Undecoded()) - - // Output: - // Is `bands.Springsteen` defined? true - // Springsteen started in 1973. - // J Geils started in 1970. - // Undecoded: [] -} - -func ExampleDecode() { - var tomlBlob = ` -# Some comments. -[alpha] -ip = "10.0.0.1" - - [alpha.config] - Ports = [ 8001, 8002 ] - Location = "Toronto" - Created = 1987-07-05T05:45:00Z - -[beta] -ip = "10.0.0.2" - - [beta.config] - Ports = [ 9001, 9002 ] - Location = "New Jersey" - Created = 1887-01-05T05:55:00Z -` - - type serverConfig struct { - Ports []int - Location string - Created time.Time - } - - type server struct { - IP string `toml:"ip,omitempty"` - Config serverConfig `toml:"config"` - } - - type servers map[string]server - - var config servers - if _, err := Decode(tomlBlob, &config); err != nil { - log.Fatal(err) - } - - for _, name := range []string{"alpha", "beta"} { - s := config[name] - fmt.Printf("Server: %s (ip: %s) in %s created on %s\n", - name, s.IP, s.Config.Location, - s.Config.Created.Format("2006-01-02")) - fmt.Printf("Ports: %v\n", s.Config.Ports) - } - - // Output: - // Server: alpha (ip: 10.0.0.1) in Toronto created on 1987-07-05 - // Ports: [8001 8002] - // Server: beta (ip: 10.0.0.2) in New Jersey created on 1887-01-05 - // Ports: [9001 9002] -} - -type duration struct { - time.Duration -} - -func (d *duration) UnmarshalText(text []byte) error { - var err error - d.Duration, err = time.ParseDuration(string(text)) - return err -} - -// Example Unmarshaler shows how to decode TOML strings into your own -// custom data type. -func Example_unmarshaler() { - blob := ` -[[song]] -name = "Thunder Road" -duration = "4m49s" - -[[song]] -name = "Stairway to Heaven" -duration = "8m03s" -` - type song struct { - Name string - Duration duration - } - type songs struct { - Song []song - } - var favorites songs - if _, err := Decode(blob, &favorites); err != nil { - log.Fatal(err) - } - - // Code to implement the TextUnmarshaler interface for `duration`: - // - // type duration struct { - // time.Duration - // } - // - // func (d *duration) UnmarshalText(text []byte) error { - // var err error - // d.Duration, err = time.ParseDuration(string(text)) - // return err - // } - - for _, s := range favorites.Song { - fmt.Printf("%s (%s)\n", s.Name, s.Duration) - } - // Output: - // Thunder Road (4m49s) - // Stairway to Heaven (8m3s) -} - -// Example StrictDecoding shows how to detect whether there are keys in the -// TOML document that weren't decoded into the value given. This is useful -// for returning an error to the user if they've included extraneous fields -// in their configuration. -func Example_strictDecoding() { - var blob = ` -key1 = "value1" -key2 = "value2" -key3 = "value3" -` - type config struct { - Key1 string - Key3 string - } - - var conf config - md, err := Decode(blob, &conf) - if err != nil { - log.Fatal(err) - } - fmt.Printf("Undecoded keys: %q\n", md.Undecoded()) - // Output: - // Undecoded keys: ["key2"] -} - -// Example UnmarshalTOML shows how to implement a struct type that knows how to -// unmarshal itself. The struct must take full responsibility for mapping the -// values passed into the struct. The method may be used with interfaces in a -// struct in cases where the actual type is not known until the data is -// examined. -func Example_unmarshalTOML() { - - var blob = ` -[[parts]] -type = "valve" -id = "valve-1" -size = 1.2 -rating = 4 - -[[parts]] -type = "valve" -id = "valve-2" -size = 2.1 -rating = 5 - -[[parts]] -type = "pipe" -id = "pipe-1" -length = 2.1 -diameter = 12 - -[[parts]] -type = "cable" -id = "cable-1" -length = 12 -rating = 3.1 -` - o := &order{} - err := Unmarshal([]byte(blob), o) - if err != nil { - log.Fatal(err) - } - - fmt.Println(len(o.parts)) - - for _, part := range o.parts { - fmt.Println(part.Name()) - } - - // Code to implement UmarshalJSON. - - // type order struct { - // // NOTE `order.parts` is a private slice of type `part` which is an - // // interface and may only be loaded from toml using the - // // UnmarshalTOML() method of the Umarshaler interface. - // parts parts - // } - - // func (o *order) UnmarshalTOML(data interface{}) error { - - // // NOTE the example below contains detailed type casting to show how - // // the 'data' is retrieved. In operational use, a type cast wrapper - // // may be prefered e.g. - // // - // // func AsMap(v interface{}) (map[string]interface{}, error) { - // // return v.(map[string]interface{}) - // // } - // // - // // resulting in: - // // d, _ := AsMap(data) - // // - - // d, _ := data.(map[string]interface{}) - // parts, _ := d["parts"].([]map[string]interface{}) - - // for _, p := range parts { - - // typ, _ := p["type"].(string) - // id, _ := p["id"].(string) - - // // detect the type of part and handle each case - // switch p["type"] { - // case "valve": - - // size := float32(p["size"].(float64)) - // rating := int(p["rating"].(int64)) - - // valve := &valve{ - // Type: typ, - // ID: id, - // Size: size, - // Rating: rating, - // } - - // o.parts = append(o.parts, valve) - - // case "pipe": - - // length := float32(p["length"].(float64)) - // diameter := int(p["diameter"].(int64)) - - // pipe := &pipe{ - // Type: typ, - // ID: id, - // Length: length, - // Diameter: diameter, - // } - - // o.parts = append(o.parts, pipe) - - // case "cable": - - // length := int(p["length"].(int64)) - // rating := float32(p["rating"].(float64)) - - // cable := &cable{ - // Type: typ, - // ID: id, - // Length: length, - // Rating: rating, - // } - - // o.parts = append(o.parts, cable) - - // } - // } - - // return nil - // } - - // type parts []part - - // type part interface { - // Name() string - // } - - // type valve struct { - // Type string - // ID string - // Size float32 - // Rating int - // } - - // func (v *valve) Name() string { - // return fmt.Sprintf("VALVE: %s", v.ID) - // } - - // type pipe struct { - // Type string - // ID string - // Length float32 - // Diameter int - // } - - // func (p *pipe) Name() string { - // return fmt.Sprintf("PIPE: %s", p.ID) - // } - - // type cable struct { - // Type string - // ID string - // Length int - // Rating float32 - // } - - // func (c *cable) Name() string { - // return fmt.Sprintf("CABLE: %s", c.ID) - // } - - // Output: - // 4 - // VALVE: valve-1 - // VALVE: valve-2 - // PIPE: pipe-1 - // CABLE: cable-1 - -} - -type order struct { - // NOTE `order.parts` is a private slice of type `part` which is an - // interface and may only be loaded from toml using the UnmarshalTOML() - // method of the Umarshaler interface. - parts parts -} - -func (o *order) UnmarshalTOML(data interface{}) error { - - // NOTE the example below contains detailed type casting to show how - // the 'data' is retrieved. In operational use, a type cast wrapper - // may be prefered e.g. - // - // func AsMap(v interface{}) (map[string]interface{}, error) { - // return v.(map[string]interface{}) - // } - // - // resulting in: - // d, _ := AsMap(data) - // - - d, _ := data.(map[string]interface{}) - parts, _ := d["parts"].([]map[string]interface{}) - - for _, p := range parts { - - typ, _ := p["type"].(string) - id, _ := p["id"].(string) - - // detect the type of part and handle each case - switch p["type"] { - case "valve": - - size := float32(p["size"].(float64)) - rating := int(p["rating"].(int64)) - - valve := &valve{ - Type: typ, - ID: id, - Size: size, - Rating: rating, - } - - o.parts = append(o.parts, valve) - - case "pipe": - - length := float32(p["length"].(float64)) - diameter := int(p["diameter"].(int64)) - - pipe := &pipe{ - Type: typ, - ID: id, - Length: length, - Diameter: diameter, - } - - o.parts = append(o.parts, pipe) - - case "cable": - - length := int(p["length"].(int64)) - rating := float32(p["rating"].(float64)) - - cable := &cable{ - Type: typ, - ID: id, - Length: length, - Rating: rating, - } - - o.parts = append(o.parts, cable) - - } - } - - return nil -} - -type parts []part - -type part interface { - Name() string -} - -type valve struct { - Type string - ID string - Size float32 - Rating int -} - -func (v *valve) Name() string { - return fmt.Sprintf("VALVE: %s", v.ID) -} - -type pipe struct { - Type string - ID string - Length float32 - Diameter int -} - -func (p *pipe) Name() string { - return fmt.Sprintf("PIPE: %s", p.ID) -} - -type cable struct { - Type string - ID string - Length int - Rating float32 -} - -func (c *cable) Name() string { - return fmt.Sprintf("CABLE: %s", c.ID) -} diff --git a/vendor/github.com/BurntSushi/toml/doc.go b/vendor/github.com/BurntSushi/toml/doc.go deleted file mode 100644 index fe26800..0000000 --- a/vendor/github.com/BurntSushi/toml/doc.go +++ /dev/null @@ -1,27 +0,0 @@ -/* -Package toml provides facilities for decoding and encoding TOML configuration -files via reflection. There is also support for delaying decoding with -the Primitive type, and querying the set of keys in a TOML document with the -MetaData type. - -The specification implemented: https://github.com/mojombo/toml - -The sub-command github.com/BurntSushi/toml/cmd/tomlv can be used to verify -whether a file is a valid TOML document. It can also be used to print the -type of each key in a TOML document. - -Testing - -There are two important types of tests used for this package. The first is -contained inside '*_test.go' files and uses the standard Go unit testing -framework. These tests are primarily devoted to holistically testing the -decoder and encoder. - -The second type of testing is used to verify the implementation's adherence -to the TOML specification. These tests have been factored into their own -project: https://github.com/BurntSushi/toml-test - -The reason the tests are in a separate project is so that they can be used by -any implementation of TOML. Namely, it is language agnostic. -*/ -package toml diff --git a/vendor/github.com/BurntSushi/toml/encode.go b/vendor/github.com/BurntSushi/toml/encode.go deleted file mode 100644 index f538261..0000000 --- a/vendor/github.com/BurntSushi/toml/encode.go +++ /dev/null @@ -1,569 +0,0 @@ -package toml - -import ( - "bufio" - "errors" - "fmt" - "io" - "reflect" - "sort" - "strconv" - "strings" - "time" -) - -type tomlEncodeError struct{ error } - -var ( - errArrayMixedElementTypes = errors.New( - "can't encode array with mixed element types") - errArrayNilElement = errors.New( - "can't encode array with nil element") - errNonString = errors.New( - "can't encode a map with non-string key type") - errAnonNonStruct = errors.New( - "can't encode an anonymous field that is not a struct") - errArrayNoTable = errors.New( - "TOML array element can't contain a table") - errNoKey = errors.New( - "top-level values must be a Go map or struct") - errAnything = errors.New("") // used in testing -) - -var quotedReplacer = strings.NewReplacer( - "\t", "\\t", - "\n", "\\n", - "\r", "\\r", - "\"", "\\\"", - "\\", "\\\\", -) - -// Encoder controls the encoding of Go values to a TOML document to some -// io.Writer. -// -// The indentation level can be controlled with the Indent field. -type Encoder struct { - // A single indentation level. By default it is two spaces. - Indent string - - // hasWritten is whether we have written any output to w yet. - hasWritten bool - w *bufio.Writer -} - -// NewEncoder returns a TOML encoder that encodes Go values to the io.Writer -// given. By default, a single indentation level is 2 spaces. -func NewEncoder(w io.Writer) *Encoder { - return &Encoder{ - w: bufio.NewWriter(w), - Indent: " ", - } -} - -// Encode writes a TOML representation of the Go value to the underlying -// io.Writer. If the value given cannot be encoded to a valid TOML document, -// then an error is returned. -// -// The mapping between Go values and TOML values should be precisely the same -// as for the Decode* functions. Similarly, the TextMarshaler interface is -// supported by encoding the resulting bytes as strings. (If you want to write -// arbitrary binary data then you will need to use something like base64 since -// TOML does not have any binary types.) -// -// When encoding TOML hashes (i.e., Go maps or structs), keys without any -// sub-hashes are encoded first. -// -// If a Go map is encoded, then its keys are sorted alphabetically for -// deterministic output. More control over this behavior may be provided if -// there is demand for it. -// -// Encoding Go values without a corresponding TOML representation---like map -// types with non-string keys---will cause an error to be returned. Similarly -// for mixed arrays/slices, arrays/slices with nil elements, embedded -// non-struct types and nested slices containing maps or structs. -// (e.g., [][]map[string]string is not allowed but []map[string]string is OK -// and so is []map[string][]string.) -func (enc *Encoder) Encode(v interface{}) error { - rv := eindirect(reflect.ValueOf(v)) - if err := enc.safeEncode(Key([]string{}), rv); err != nil { - return err - } - return enc.w.Flush() -} - -func (enc *Encoder) safeEncode(key Key, rv reflect.Value) (err error) { - defer func() { - if r := recover(); r != nil { - if terr, ok := r.(tomlEncodeError); ok { - err = terr.error - return - } - panic(r) - } - }() - enc.encode(key, rv) - return nil -} - -func (enc *Encoder) encode(key Key, rv reflect.Value) { - // Special case. Time needs to be in ISO8601 format. - // Special case. If we can marshal the type to text, then we used that. - // Basically, this prevents the encoder for handling these types as - // generic structs (or whatever the underlying type of a TextMarshaler is). - switch rv.Interface().(type) { - case time.Time, TextMarshaler: - enc.keyEqElement(key, rv) - return - } - - k := rv.Kind() - switch k { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, - reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, - reflect.Uint64, - reflect.Float32, reflect.Float64, reflect.String, reflect.Bool: - enc.keyEqElement(key, rv) - case reflect.Array, reflect.Slice: - if typeEqual(tomlArrayHash, tomlTypeOfGo(rv)) { - enc.eArrayOfTables(key, rv) - } else { - enc.keyEqElement(key, rv) - } - case reflect.Interface: - if rv.IsNil() { - return - } - enc.encode(key, rv.Elem()) - case reflect.Map: - if rv.IsNil() { - return - } - enc.eTable(key, rv) - case reflect.Ptr: - if rv.IsNil() { - return - } - enc.encode(key, rv.Elem()) - case reflect.Struct: - enc.eTable(key, rv) - default: - panic(e("Unsupported type for key '%s': %s", key, k)) - } -} - -// eElement encodes any value that can be an array element (primitives and -// arrays). -func (enc *Encoder) eElement(rv reflect.Value) { - switch v := rv.Interface().(type) { - case time.Time: - // Special case time.Time as a primitive. Has to come before - // TextMarshaler below because time.Time implements - // encoding.TextMarshaler, but we need to always use UTC. - enc.wf(v.In(time.FixedZone("UTC", 0)).Format("2006-01-02T15:04:05Z")) - return - case TextMarshaler: - // Special case. Use text marshaler if it's available for this value. - if s, err := v.MarshalText(); err != nil { - encPanic(err) - } else { - enc.writeQuoted(string(s)) - } - return - } - switch rv.Kind() { - case reflect.Bool: - enc.wf(strconv.FormatBool(rv.Bool())) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, - reflect.Int64: - enc.wf(strconv.FormatInt(rv.Int(), 10)) - case reflect.Uint, reflect.Uint8, reflect.Uint16, - reflect.Uint32, reflect.Uint64: - enc.wf(strconv.FormatUint(rv.Uint(), 10)) - case reflect.Float32: - enc.wf(floatAddDecimal(strconv.FormatFloat(rv.Float(), 'f', -1, 32))) - case reflect.Float64: - enc.wf(floatAddDecimal(strconv.FormatFloat(rv.Float(), 'f', -1, 64))) - case reflect.Array, reflect.Slice: - enc.eArrayOrSliceElement(rv) - case reflect.Interface: - enc.eElement(rv.Elem()) - case reflect.String: - enc.writeQuoted(rv.String()) - default: - panic(e("Unexpected primitive type: %s", rv.Kind())) - } -} - -// By the TOML spec, all floats must have a decimal with at least one -// number on either side. -func floatAddDecimal(fstr string) string { - if !strings.Contains(fstr, ".") { - return fstr + ".0" - } - return fstr -} - -func (enc *Encoder) writeQuoted(s string) { - enc.wf("\"%s\"", quotedReplacer.Replace(s)) -} - -func (enc *Encoder) eArrayOrSliceElement(rv reflect.Value) { - length := rv.Len() - enc.wf("[") - for i := 0; i < length; i++ { - elem := rv.Index(i) - enc.eElement(elem) - if i != length-1 { - enc.wf(", ") - } - } - enc.wf("]") -} - -func (enc *Encoder) eArrayOfTables(key Key, rv reflect.Value) { - if len(key) == 0 { - encPanic(errNoKey) - } - for i := 0; i < rv.Len(); i++ { - trv := rv.Index(i) - if isNil(trv) { - continue - } - panicIfInvalidKey(key) - enc.newline() - enc.wf("%s[[%s]]", enc.indentStr(key), key.maybeQuotedAll()) - enc.newline() - enc.eMapOrStruct(key, trv) - } -} - -func (enc *Encoder) eTable(key Key, rv reflect.Value) { - panicIfInvalidKey(key) - if len(key) == 1 { - // Output an extra new line between top-level tables. - // (The newline isn't written if nothing else has been written though.) - enc.newline() - } - if len(key) > 0 { - enc.wf("%s[%s]", enc.indentStr(key), key.maybeQuotedAll()) - enc.newline() - } - enc.eMapOrStruct(key, rv) -} - -func (enc *Encoder) eMapOrStruct(key Key, rv reflect.Value) { - switch rv := eindirect(rv); rv.Kind() { - case reflect.Map: - enc.eMap(key, rv) - case reflect.Struct: - enc.eStruct(key, rv) - default: - panic("eTable: unhandled reflect.Value Kind: " + rv.Kind().String()) - } -} - -func (enc *Encoder) eMap(key Key, rv reflect.Value) { - rt := rv.Type() - if rt.Key().Kind() != reflect.String { - encPanic(errNonString) - } - - // Sort keys so that we have deterministic output. And write keys directly - // underneath this key first, before writing sub-structs or sub-maps. - var mapKeysDirect, mapKeysSub []string - for _, mapKey := range rv.MapKeys() { - k := mapKey.String() - if typeIsHash(tomlTypeOfGo(rv.MapIndex(mapKey))) { - mapKeysSub = append(mapKeysSub, k) - } else { - mapKeysDirect = append(mapKeysDirect, k) - } - } - - var writeMapKeys = func(mapKeys []string) { - sort.Strings(mapKeys) - for _, mapKey := range mapKeys { - mrv := rv.MapIndex(reflect.ValueOf(mapKey)) - if isNil(mrv) { - // Don't write anything for nil fields. - continue - } - enc.encode(key.add(mapKey), mrv) - } - } - writeMapKeys(mapKeysDirect) - writeMapKeys(mapKeysSub) -} - -func (enc *Encoder) eStruct(key Key, rv reflect.Value) { - // Write keys for fields directly under this key first, because if we write - // a field that creates a new table, then all keys under it will be in that - // table (not the one we're writing here). - rt := rv.Type() - var fieldsDirect, fieldsSub [][]int - var addFields func(rt reflect.Type, rv reflect.Value, start []int) - addFields = func(rt reflect.Type, rv reflect.Value, start []int) { - for i := 0; i < rt.NumField(); i++ { - f := rt.Field(i) - // skip unexported fields - if f.PkgPath != "" && !f.Anonymous { - continue - } - frv := rv.Field(i) - if f.Anonymous { - t := f.Type - switch t.Kind() { - case reflect.Struct: - // Treat anonymous struct fields with - // tag names as though they are not - // anonymous, like encoding/json does. - if getOptions(f.Tag).name == "" { - addFields(t, frv, f.Index) - continue - } - case reflect.Ptr: - if t.Elem().Kind() == reflect.Struct && - getOptions(f.Tag).name == "" { - if !frv.IsNil() { - addFields(t.Elem(), frv.Elem(), f.Index) - } - continue - } - // Fall through to the normal field encoding logic below - // for non-struct anonymous fields. - } - } - - if typeIsHash(tomlTypeOfGo(frv)) { - fieldsSub = append(fieldsSub, append(start, f.Index...)) - } else { - fieldsDirect = append(fieldsDirect, append(start, f.Index...)) - } - } - } - addFields(rt, rv, nil) - - var writeFields = func(fields [][]int) { - for _, fieldIndex := range fields { - sft := rt.FieldByIndex(fieldIndex) - sf := rv.FieldByIndex(fieldIndex) - if isNil(sf) { - // Don't write anything for nil fields. - continue - } - - opts := getOptions(sft.Tag) - if opts.skip { - continue - } - keyName := sft.Name - if opts.name != "" { - keyName = opts.name - } - if opts.omitempty && isEmpty(sf) { - continue - } - if opts.omitzero && isZero(sf) { - continue - } - - enc.encode(key.add(keyName), sf) - } - } - writeFields(fieldsDirect) - writeFields(fieldsSub) -} - -// tomlTypeName returns the TOML type name of the Go value's type. It is -// used to determine whether the types of array elements are mixed (which is -// forbidden). If the Go value is nil, then it is illegal for it to be an array -// element, and valueIsNil is returned as true. - -// Returns the TOML type of a Go value. The type may be `nil`, which means -// no concrete TOML type could be found. -func tomlTypeOfGo(rv reflect.Value) tomlType { - if isNil(rv) || !rv.IsValid() { - return nil - } - switch rv.Kind() { - case reflect.Bool: - return tomlBool - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, - reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, - reflect.Uint64: - return tomlInteger - case reflect.Float32, reflect.Float64: - return tomlFloat - case reflect.Array, reflect.Slice: - if typeEqual(tomlHash, tomlArrayType(rv)) { - return tomlArrayHash - } else { - return tomlArray - } - case reflect.Ptr, reflect.Interface: - return tomlTypeOfGo(rv.Elem()) - case reflect.String: - return tomlString - case reflect.Map: - return tomlHash - case reflect.Struct: - switch rv.Interface().(type) { - case time.Time: - return tomlDatetime - case TextMarshaler: - return tomlString - default: - return tomlHash - } - default: - panic("unexpected reflect.Kind: " + rv.Kind().String()) - } -} - -// tomlArrayType returns the element type of a TOML array. The type returned -// may be nil if it cannot be determined (e.g., a nil slice or a zero length -// slize). This function may also panic if it finds a type that cannot be -// expressed in TOML (such as nil elements, heterogeneous arrays or directly -// nested arrays of tables). -func tomlArrayType(rv reflect.Value) tomlType { - if isNil(rv) || !rv.IsValid() || rv.Len() == 0 { - return nil - } - firstType := tomlTypeOfGo(rv.Index(0)) - if firstType == nil { - encPanic(errArrayNilElement) - } - - rvlen := rv.Len() - for i := 1; i < rvlen; i++ { - elem := rv.Index(i) - switch elemType := tomlTypeOfGo(elem); { - case elemType == nil: - encPanic(errArrayNilElement) - case !typeEqual(firstType, elemType): - encPanic(errArrayMixedElementTypes) - } - } - // If we have a nested array, then we must make sure that the nested - // array contains ONLY primitives. - // This checks arbitrarily nested arrays. - if typeEqual(firstType, tomlArray) || typeEqual(firstType, tomlArrayHash) { - nest := tomlArrayType(eindirect(rv.Index(0))) - if typeEqual(nest, tomlHash) || typeEqual(nest, tomlArrayHash) { - encPanic(errArrayNoTable) - } - } - return firstType -} - -type tagOptions struct { - skip bool // "-" - name string - omitempty bool - omitzero bool -} - -func getOptions(tag reflect.StructTag) tagOptions { - t := tag.Get("toml") - if t == "-" { - return tagOptions{skip: true} - } - var opts tagOptions - parts := strings.Split(t, ",") - opts.name = parts[0] - for _, s := range parts[1:] { - switch s { - case "omitempty": - opts.omitempty = true - case "omitzero": - opts.omitzero = true - } - } - return opts -} - -func isZero(rv reflect.Value) bool { - switch rv.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return rv.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return rv.Uint() == 0 - case reflect.Float32, reflect.Float64: - return rv.Float() == 0.0 - } - return false -} - -func isEmpty(rv reflect.Value) bool { - switch rv.Kind() { - case reflect.Array, reflect.Slice, reflect.Map, reflect.String: - return rv.Len() == 0 - case reflect.Bool: - return !rv.Bool() - } - return false -} - -func (enc *Encoder) newline() { - if enc.hasWritten { - enc.wf("\n") - } -} - -func (enc *Encoder) keyEqElement(key Key, val reflect.Value) { - if len(key) == 0 { - encPanic(errNoKey) - } - panicIfInvalidKey(key) - enc.wf("%s%s = ", enc.indentStr(key), key.maybeQuoted(len(key)-1)) - enc.eElement(val) - enc.newline() -} - -func (enc *Encoder) wf(format string, v ...interface{}) { - if _, err := fmt.Fprintf(enc.w, format, v...); err != nil { - encPanic(err) - } - enc.hasWritten = true -} - -func (enc *Encoder) indentStr(key Key) string { - return strings.Repeat(enc.Indent, len(key)-1) -} - -func encPanic(err error) { - panic(tomlEncodeError{err}) -} - -func eindirect(v reflect.Value) reflect.Value { - switch v.Kind() { - case reflect.Ptr, reflect.Interface: - return eindirect(v.Elem()) - default: - return v - } -} - -func isNil(rv reflect.Value) bool { - switch rv.Kind() { - case reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: - return rv.IsNil() - default: - return false - } -} - -func panicIfInvalidKey(key Key) { - for _, k := range key { - if len(k) == 0 { - encPanic(e("Key '%s' is not a valid table name. Key names "+ - "cannot be empty.", key.maybeQuotedAll())) - } - } -} - -func isValidKeyName(s string) bool { - return len(s) != 0 -} diff --git a/vendor/github.com/BurntSushi/toml/encode_test.go b/vendor/github.com/BurntSushi/toml/encode_test.go deleted file mode 100644 index 673b7b0..0000000 --- a/vendor/github.com/BurntSushi/toml/encode_test.go +++ /dev/null @@ -1,615 +0,0 @@ -package toml - -import ( - "bytes" - "fmt" - "log" - "net" - "testing" - "time" -) - -func TestEncodeRoundTrip(t *testing.T) { - type Config struct { - Age int - Cats []string - Pi float64 - Perfection []int - DOB time.Time - Ipaddress net.IP - } - - var inputs = Config{ - 13, - []string{"one", "two", "three"}, - 3.145, - []int{11, 2, 3, 4}, - time.Now(), - net.ParseIP("192.168.59.254"), - } - - var firstBuffer bytes.Buffer - e := NewEncoder(&firstBuffer) - err := e.Encode(inputs) - if err != nil { - t.Fatal(err) - } - var outputs Config - if _, err := Decode(firstBuffer.String(), &outputs); err != nil { - t.Logf("Could not decode:\n-----\n%s\n-----\n", - firstBuffer.String()) - t.Fatal(err) - } - - // could test each value individually, but I'm lazy - var secondBuffer bytes.Buffer - e2 := NewEncoder(&secondBuffer) - err = e2.Encode(outputs) - if err != nil { - t.Fatal(err) - } - if firstBuffer.String() != secondBuffer.String() { - t.Error( - firstBuffer.String(), - "\n\n is not identical to\n\n", - secondBuffer.String()) - } -} - -// XXX(burntsushi) -// I think these tests probably should be removed. They are good, but they -// ought to be obsolete by toml-test. -func TestEncode(t *testing.T) { - type Embedded struct { - Int int `toml:"_int"` - } - type NonStruct int - - date := time.Date(2014, 5, 11, 20, 30, 40, 0, time.FixedZone("IST", 3600)) - dateStr := "2014-05-11T19:30:40Z" - - tests := map[string]struct { - input interface{} - wantOutput string - wantError error - }{ - "bool field": { - input: struct { - BoolTrue bool - BoolFalse bool - }{true, false}, - wantOutput: "BoolTrue = true\nBoolFalse = false\n", - }, - "int fields": { - input: struct { - Int int - Int8 int8 - Int16 int16 - Int32 int32 - Int64 int64 - }{1, 2, 3, 4, 5}, - wantOutput: "Int = 1\nInt8 = 2\nInt16 = 3\nInt32 = 4\nInt64 = 5\n", - }, - "uint fields": { - input: struct { - Uint uint - Uint8 uint8 - Uint16 uint16 - Uint32 uint32 - Uint64 uint64 - }{1, 2, 3, 4, 5}, - wantOutput: "Uint = 1\nUint8 = 2\nUint16 = 3\nUint32 = 4" + - "\nUint64 = 5\n", - }, - "float fields": { - input: struct { - Float32 float32 - Float64 float64 - }{1.5, 2.5}, - wantOutput: "Float32 = 1.5\nFloat64 = 2.5\n", - }, - "string field": { - input: struct{ String string }{"foo"}, - wantOutput: "String = \"foo\"\n", - }, - "string field and unexported field": { - input: struct { - String string - unexported int - }{"foo", 0}, - wantOutput: "String = \"foo\"\n", - }, - "datetime field in UTC": { - input: struct{ Date time.Time }{date}, - wantOutput: fmt.Sprintf("Date = %s\n", dateStr), - }, - "datetime field as primitive": { - // Using a map here to fail if isStructOrMap() returns true for - // time.Time. - input: map[string]interface{}{ - "Date": date, - "Int": 1, - }, - wantOutput: fmt.Sprintf("Date = %s\nInt = 1\n", dateStr), - }, - "array fields": { - input: struct { - IntArray0 [0]int - IntArray3 [3]int - }{[0]int{}, [3]int{1, 2, 3}}, - wantOutput: "IntArray0 = []\nIntArray3 = [1, 2, 3]\n", - }, - "slice fields": { - input: struct{ IntSliceNil, IntSlice0, IntSlice3 []int }{ - nil, []int{}, []int{1, 2, 3}, - }, - wantOutput: "IntSlice0 = []\nIntSlice3 = [1, 2, 3]\n", - }, - "datetime slices": { - input: struct{ DatetimeSlice []time.Time }{ - []time.Time{date, date}, - }, - wantOutput: fmt.Sprintf("DatetimeSlice = [%s, %s]\n", - dateStr, dateStr), - }, - "nested arrays and slices": { - input: struct { - SliceOfArrays [][2]int - ArrayOfSlices [2][]int - SliceOfArraysOfSlices [][2][]int - ArrayOfSlicesOfArrays [2][][2]int - SliceOfMixedArrays [][2]interface{} - ArrayOfMixedSlices [2][]interface{} - }{ - [][2]int{{1, 2}, {3, 4}}, - [2][]int{{1, 2}, {3, 4}}, - [][2][]int{ - { - {1, 2}, {3, 4}, - }, - { - {5, 6}, {7, 8}, - }, - }, - [2][][2]int{ - { - {1, 2}, {3, 4}, - }, - { - {5, 6}, {7, 8}, - }, - }, - [][2]interface{}{ - {1, 2}, {"a", "b"}, - }, - [2][]interface{}{ - {1, 2}, {"a", "b"}, - }, - }, - wantOutput: `SliceOfArrays = [[1, 2], [3, 4]] -ArrayOfSlices = [[1, 2], [3, 4]] -SliceOfArraysOfSlices = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] -ArrayOfSlicesOfArrays = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]] -SliceOfMixedArrays = [[1, 2], ["a", "b"]] -ArrayOfMixedSlices = [[1, 2], ["a", "b"]] -`, - }, - "empty slice": { - input: struct{ Empty []interface{} }{[]interface{}{}}, - wantOutput: "Empty = []\n", - }, - "(error) slice with element type mismatch (string and integer)": { - input: struct{ Mixed []interface{} }{[]interface{}{1, "a"}}, - wantError: errArrayMixedElementTypes, - }, - "(error) slice with element type mismatch (integer and float)": { - input: struct{ Mixed []interface{} }{[]interface{}{1, 2.5}}, - wantError: errArrayMixedElementTypes, - }, - "slice with elems of differing Go types, same TOML types": { - input: struct { - MixedInts []interface{} - MixedFloats []interface{} - }{ - []interface{}{ - int(1), int8(2), int16(3), int32(4), int64(5), - uint(1), uint8(2), uint16(3), uint32(4), uint64(5), - }, - []interface{}{float32(1.5), float64(2.5)}, - }, - wantOutput: "MixedInts = [1, 2, 3, 4, 5, 1, 2, 3, 4, 5]\n" + - "MixedFloats = [1.5, 2.5]\n", - }, - "(error) slice w/ element type mismatch (one is nested array)": { - input: struct{ Mixed []interface{} }{ - []interface{}{1, []interface{}{2}}, - }, - wantError: errArrayMixedElementTypes, - }, - "(error) slice with 1 nil element": { - input: struct{ NilElement1 []interface{} }{[]interface{}{nil}}, - wantError: errArrayNilElement, - }, - "(error) slice with 1 nil element (and other non-nil elements)": { - input: struct{ NilElement []interface{} }{ - []interface{}{1, nil}, - }, - wantError: errArrayNilElement, - }, - "simple map": { - input: map[string]int{"a": 1, "b": 2}, - wantOutput: "a = 1\nb = 2\n", - }, - "map with interface{} value type": { - input: map[string]interface{}{"a": 1, "b": "c"}, - wantOutput: "a = 1\nb = \"c\"\n", - }, - "map with interface{} value type, some of which are structs": { - input: map[string]interface{}{ - "a": struct{ Int int }{2}, - "b": 1, - }, - wantOutput: "b = 1\n\n[a]\n Int = 2\n", - }, - "nested map": { - input: map[string]map[string]int{ - "a": {"b": 1}, - "c": {"d": 2}, - }, - wantOutput: "[a]\n b = 1\n\n[c]\n d = 2\n", - }, - "nested struct": { - input: struct{ Struct struct{ Int int } }{ - struct{ Int int }{1}, - }, - wantOutput: "[Struct]\n Int = 1\n", - }, - "nested struct and non-struct field": { - input: struct { - Struct struct{ Int int } - Bool bool - }{struct{ Int int }{1}, true}, - wantOutput: "Bool = true\n\n[Struct]\n Int = 1\n", - }, - "2 nested structs": { - input: struct{ Struct1, Struct2 struct{ Int int } }{ - struct{ Int int }{1}, struct{ Int int }{2}, - }, - wantOutput: "[Struct1]\n Int = 1\n\n[Struct2]\n Int = 2\n", - }, - "deeply nested structs": { - input: struct { - Struct1, Struct2 struct{ Struct3 *struct{ Int int } } - }{ - struct{ Struct3 *struct{ Int int } }{&struct{ Int int }{1}}, - struct{ Struct3 *struct{ Int int } }{nil}, - }, - wantOutput: "[Struct1]\n [Struct1.Struct3]\n Int = 1" + - "\n\n[Struct2]\n", - }, - "nested struct with nil struct elem": { - input: struct { - Struct struct{ Inner *struct{ Int int } } - }{ - struct{ Inner *struct{ Int int } }{nil}, - }, - wantOutput: "[Struct]\n", - }, - "nested struct with no fields": { - input: struct { - Struct struct{ Inner struct{} } - }{ - struct{ Inner struct{} }{struct{}{}}, - }, - wantOutput: "[Struct]\n [Struct.Inner]\n", - }, - "struct with tags": { - input: struct { - Struct struct { - Int int `toml:"_int"` - } `toml:"_struct"` - Bool bool `toml:"_bool"` - }{ - struct { - Int int `toml:"_int"` - }{1}, true, - }, - wantOutput: "_bool = true\n\n[_struct]\n _int = 1\n", - }, - "embedded struct": { - input: struct{ Embedded }{Embedded{1}}, - wantOutput: "_int = 1\n", - }, - "embedded *struct": { - input: struct{ *Embedded }{&Embedded{1}}, - wantOutput: "_int = 1\n", - }, - "nested embedded struct": { - input: struct { - Struct struct{ Embedded } `toml:"_struct"` - }{struct{ Embedded }{Embedded{1}}}, - wantOutput: "[_struct]\n _int = 1\n", - }, - "nested embedded *struct": { - input: struct { - Struct struct{ *Embedded } `toml:"_struct"` - }{struct{ *Embedded }{&Embedded{1}}}, - wantOutput: "[_struct]\n _int = 1\n", - }, - "embedded non-struct": { - input: struct{ NonStruct }{5}, - wantOutput: "NonStruct = 5\n", - }, - "array of tables": { - input: struct { - Structs []*struct{ Int int } `toml:"struct"` - }{ - []*struct{ Int int }{{1}, {3}}, - }, - wantOutput: "[[struct]]\n Int = 1\n\n[[struct]]\n Int = 3\n", - }, - "array of tables order": { - input: map[string]interface{}{ - "map": map[string]interface{}{ - "zero": 5, - "arr": []map[string]int{ - { - "friend": 5, - }, - }, - }, - }, - wantOutput: "[map]\n zero = 5\n\n [[map.arr]]\n friend = 5\n", - }, - "(error) top-level slice": { - input: []struct{ Int int }{{1}, {2}, {3}}, - wantError: errNoKey, - }, - "(error) slice of slice": { - input: struct { - Slices [][]struct{ Int int } - }{ - [][]struct{ Int int }{{{1}}, {{2}}, {{3}}}, - }, - wantError: errArrayNoTable, - }, - "(error) map no string key": { - input: map[int]string{1: ""}, - wantError: errNonString, - }, - "(error) empty key name": { - input: map[string]int{"": 1}, - wantError: errAnything, - }, - "(error) empty map name": { - input: map[string]interface{}{ - "": map[string]int{"v": 1}, - }, - wantError: errAnything, - }, - } - for label, test := range tests { - encodeExpected(t, label, test.input, test.wantOutput, test.wantError) - } -} - -func TestEncodeNestedTableArrays(t *testing.T) { - type song struct { - Name string `toml:"name"` - } - type album struct { - Name string `toml:"name"` - Songs []song `toml:"songs"` - } - type springsteen struct { - Albums []album `toml:"albums"` - } - value := springsteen{ - []album{ - {"Born to Run", - []song{{"Jungleland"}, {"Meeting Across the River"}}}, - {"Born in the USA", - []song{{"Glory Days"}, {"Dancing in the Dark"}}}, - }, - } - expected := `[[albums]] - name = "Born to Run" - - [[albums.songs]] - name = "Jungleland" - - [[albums.songs]] - name = "Meeting Across the River" - -[[albums]] - name = "Born in the USA" - - [[albums.songs]] - name = "Glory Days" - - [[albums.songs]] - name = "Dancing in the Dark" -` - encodeExpected(t, "nested table arrays", value, expected, nil) -} - -func TestEncodeArrayHashWithNormalHashOrder(t *testing.T) { - type Alpha struct { - V int - } - type Beta struct { - V int - } - type Conf struct { - V int - A Alpha - B []Beta - } - - val := Conf{ - V: 1, - A: Alpha{2}, - B: []Beta{{3}}, - } - expected := "V = 1\n\n[A]\n V = 2\n\n[[B]]\n V = 3\n" - encodeExpected(t, "array hash with normal hash order", val, expected, nil) -} - -func TestEncodeWithOmitEmpty(t *testing.T) { - type simple struct { - Bool bool `toml:"bool,omitempty"` - String string `toml:"string,omitempty"` - Array [0]byte `toml:"array,omitempty"` - Slice []int `toml:"slice,omitempty"` - Map map[string]string `toml:"map,omitempty"` - } - - var v simple - encodeExpected(t, "fields with omitempty are omitted when empty", v, "", nil) - v = simple{ - Bool: true, - String: " ", - Slice: []int{2, 3, 4}, - Map: map[string]string{"foo": "bar"}, - } - expected := `bool = true -string = " " -slice = [2, 3, 4] - -[map] - foo = "bar" -` - encodeExpected(t, "fields with omitempty are not omitted when non-empty", - v, expected, nil) -} - -func TestEncodeWithOmitZero(t *testing.T) { - type simple struct { - Number int `toml:"number,omitzero"` - Real float64 `toml:"real,omitzero"` - Unsigned uint `toml:"unsigned,omitzero"` - } - - value := simple{0, 0.0, uint(0)} - expected := "" - - encodeExpected(t, "simple with omitzero, all zero", value, expected, nil) - - value.Number = 10 - value.Real = 20 - value.Unsigned = 5 - expected = `number = 10 -real = 20.0 -unsigned = 5 -` - encodeExpected(t, "simple with omitzero, non-zero", value, expected, nil) -} - -func TestEncodeOmitemptyWithEmptyName(t *testing.T) { - type simple struct { - S []int `toml:",omitempty"` - } - v := simple{[]int{1, 2, 3}} - expected := "S = [1, 2, 3]\n" - encodeExpected(t, "simple with omitempty, no name, non-empty field", - v, expected, nil) -} - -func TestEncodeAnonymousStruct(t *testing.T) { - type Inner struct{ N int } - type Outer0 struct{ Inner } - type Outer1 struct { - Inner `toml:"inner"` - } - - v0 := Outer0{Inner{3}} - expected := "N = 3\n" - encodeExpected(t, "embedded anonymous untagged struct", v0, expected, nil) - - v1 := Outer1{Inner{3}} - expected = "[inner]\n N = 3\n" - encodeExpected(t, "embedded anonymous tagged struct", v1, expected, nil) -} - -func TestEncodeAnonymousStructPointerField(t *testing.T) { - type Inner struct{ N int } - type Outer0 struct{ *Inner } - type Outer1 struct { - *Inner `toml:"inner"` - } - - v0 := Outer0{} - expected := "" - encodeExpected(t, "nil anonymous untagged struct pointer field", v0, expected, nil) - - v0 = Outer0{&Inner{3}} - expected = "N = 3\n" - encodeExpected(t, "non-nil anonymous untagged struct pointer field", v0, expected, nil) - - v1 := Outer1{} - expected = "" - encodeExpected(t, "nil anonymous tagged struct pointer field", v1, expected, nil) - - v1 = Outer1{&Inner{3}} - expected = "[inner]\n N = 3\n" - encodeExpected(t, "non-nil anonymous tagged struct pointer field", v1, expected, nil) -} - -func TestEncodeIgnoredFields(t *testing.T) { - type simple struct { - Number int `toml:"-"` - } - value := simple{} - expected := "" - encodeExpected(t, "ignored field", value, expected, nil) -} - -func encodeExpected( - t *testing.T, label string, val interface{}, wantStr string, wantErr error, -) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - err := enc.Encode(val) - if err != wantErr { - if wantErr != nil { - if wantErr == errAnything && err != nil { - return - } - t.Errorf("%s: want Encode error %v, got %v", label, wantErr, err) - } else { - t.Errorf("%s: Encode failed: %s", label, err) - } - } - if err != nil { - return - } - if got := buf.String(); wantStr != got { - t.Errorf("%s: want\n-----\n%q\n-----\nbut got\n-----\n%q\n-----\n", - label, wantStr, got) - } -} - -func ExampleEncoder_Encode() { - date, _ := time.Parse(time.RFC822, "14 Mar 10 18:00 UTC") - var config = map[string]interface{}{ - "date": date, - "counts": []int{1, 1, 2, 3, 5, 8}, - "hash": map[string]string{ - "key1": "val1", - "key2": "val2", - }, - } - buf := new(bytes.Buffer) - if err := NewEncoder(buf).Encode(config); err != nil { - log.Fatal(err) - } - fmt.Println(buf.String()) - - // Output: - // counts = [1, 1, 2, 3, 5, 8] - // date = 2010-03-14T18:00:00Z - // - // [hash] - // key1 = "val1" - // key2 = "val2" -} diff --git a/vendor/github.com/BurntSushi/toml/encoding_types.go b/vendor/github.com/BurntSushi/toml/encoding_types.go deleted file mode 100644 index d36e1dd..0000000 --- a/vendor/github.com/BurntSushi/toml/encoding_types.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build go1.2 - -package toml - -// In order to support Go 1.1, we define our own TextMarshaler and -// TextUnmarshaler types. For Go 1.2+, we just alias them with the -// standard library interfaces. - -import ( - "encoding" -) - -// TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here -// so that Go 1.1 can be supported. -type TextMarshaler encoding.TextMarshaler - -// TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined -// here so that Go 1.1 can be supported. -type TextUnmarshaler encoding.TextUnmarshaler diff --git a/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go b/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go deleted file mode 100644 index e8d503d..0000000 --- a/vendor/github.com/BurntSushi/toml/encoding_types_1.1.go +++ /dev/null @@ -1,18 +0,0 @@ -// +build !go1.2 - -package toml - -// These interfaces were introduced in Go 1.2, so we add them manually when -// compiling for Go 1.1. - -// TextMarshaler is a synonym for encoding.TextMarshaler. It is defined here -// so that Go 1.1 can be supported. -type TextMarshaler interface { - MarshalText() (text []byte, err error) -} - -// TextUnmarshaler is a synonym for encoding.TextUnmarshaler. It is defined -// here so that Go 1.1 can be supported. -type TextUnmarshaler interface { - UnmarshalText(text []byte) error -} diff --git a/vendor/github.com/BurntSushi/toml/lex.go b/vendor/github.com/BurntSushi/toml/lex.go deleted file mode 100644 index a016dc2..0000000 --- a/vendor/github.com/BurntSushi/toml/lex.go +++ /dev/null @@ -1,866 +0,0 @@ -package toml - -import ( - "fmt" - "strings" - "unicode" - "unicode/utf8" -) - -type itemType int - -const ( - itemError itemType = iota - itemNIL // used in the parser to indicate no type - itemEOF - itemText - itemString - itemRawString - itemMultilineString - itemRawMultilineString - itemBool - itemInteger - itemFloat - itemDatetime - itemArray // the start of an array - itemArrayEnd - itemTableStart - itemTableEnd - itemArrayTableStart - itemArrayTableEnd - itemKeyStart - itemCommentStart -) - -const ( - eof = 0 - tableStart = '[' - tableEnd = ']' - arrayTableStart = '[' - arrayTableEnd = ']' - tableSep = '.' - keySep = '=' - arrayStart = '[' - arrayEnd = ']' - arrayValTerm = ',' - commentStart = '#' - stringStart = '"' - stringEnd = '"' - rawStringStart = '\'' - rawStringEnd = '\'' -) - -type stateFn func(lx *lexer) stateFn - -type lexer struct { - input string - start int - pos int - width int - line int - state stateFn - items chan item - - // A stack of state functions used to maintain context. - // The idea is to reuse parts of the state machine in various places. - // For example, values can appear at the top level or within arbitrarily - // nested arrays. The last state on the stack is used after a value has - // been lexed. Similarly for comments. - stack []stateFn -} - -type item struct { - typ itemType - val string - line int -} - -func (lx *lexer) nextItem() item { - for { - select { - case item := <-lx.items: - return item - default: - lx.state = lx.state(lx) - } - } -} - -func lex(input string) *lexer { - lx := &lexer{ - input: input + "\n", - state: lexTop, - line: 1, - items: make(chan item, 10), - stack: make([]stateFn, 0, 10), - } - return lx -} - -func (lx *lexer) push(state stateFn) { - lx.stack = append(lx.stack, state) -} - -func (lx *lexer) pop() stateFn { - if len(lx.stack) == 0 { - return lx.errorf("BUG in lexer: no states to pop.") - } - last := lx.stack[len(lx.stack)-1] - lx.stack = lx.stack[0 : len(lx.stack)-1] - return last -} - -func (lx *lexer) current() string { - return lx.input[lx.start:lx.pos] -} - -func (lx *lexer) emit(typ itemType) { - lx.items <- item{typ, lx.current(), lx.line} - lx.start = lx.pos -} - -func (lx *lexer) emitTrim(typ itemType) { - lx.items <- item{typ, strings.TrimSpace(lx.current()), lx.line} - lx.start = lx.pos -} - -func (lx *lexer) next() (r rune) { - if lx.pos >= len(lx.input) { - lx.width = 0 - return eof - } - - if lx.input[lx.pos] == '\n' { - lx.line++ - } - r, lx.width = utf8.DecodeRuneInString(lx.input[lx.pos:]) - lx.pos += lx.width - return r -} - -// ignore skips over the pending input before this point. -func (lx *lexer) ignore() { - lx.start = lx.pos -} - -// backup steps back one rune. Can be called only once per call of next. -func (lx *lexer) backup() { - lx.pos -= lx.width - if lx.pos < len(lx.input) && lx.input[lx.pos] == '\n' { - lx.line-- - } -} - -// accept consumes the next rune if it's equal to `valid`. -func (lx *lexer) accept(valid rune) bool { - if lx.next() == valid { - return true - } - lx.backup() - return false -} - -// peek returns but does not consume the next rune in the input. -func (lx *lexer) peek() rune { - r := lx.next() - lx.backup() - return r -} - -// skip ignores all input that matches the given predicate. -func (lx *lexer) skip(pred func(rune) bool) { - for { - r := lx.next() - if pred(r) { - continue - } - lx.backup() - lx.ignore() - return - } -} - -// errorf stops all lexing by emitting an error and returning `nil`. -// Note that any value that is a character is escaped if it's a special -// character (new lines, tabs, etc.). -func (lx *lexer) errorf(format string, values ...interface{}) stateFn { - lx.items <- item{ - itemError, - fmt.Sprintf(format, values...), - lx.line, - } - return nil -} - -// lexTop consumes elements at the top level of TOML data. -func lexTop(lx *lexer) stateFn { - r := lx.next() - if isWhitespace(r) || isNL(r) { - return lexSkip(lx, lexTop) - } - - switch r { - case commentStart: - lx.push(lexTop) - return lexCommentStart - case tableStart: - return lexTableStart - case eof: - if lx.pos > lx.start { - return lx.errorf("Unexpected EOF.") - } - lx.emit(itemEOF) - return nil - } - - // At this point, the only valid item can be a key, so we back up - // and let the key lexer do the rest. - lx.backup() - lx.push(lexTopEnd) - return lexKeyStart -} - -// lexTopEnd is entered whenever a top-level item has been consumed. (A value -// or a table.) It must see only whitespace, and will turn back to lexTop -// upon a new line. If it sees EOF, it will quit the lexer successfully. -func lexTopEnd(lx *lexer) stateFn { - r := lx.next() - switch { - case r == commentStart: - // a comment will read to a new line for us. - lx.push(lexTop) - return lexCommentStart - case isWhitespace(r): - return lexTopEnd - case isNL(r): - lx.ignore() - return lexTop - case r == eof: - lx.ignore() - return lexTop - } - return lx.errorf("Expected a top-level item to end with a new line, "+ - "comment or EOF, but got %q instead.", r) -} - -// lexTable lexes the beginning of a table. Namely, it makes sure that -// it starts with a character other than '.' and ']'. -// It assumes that '[' has already been consumed. -// It also handles the case that this is an item in an array of tables. -// e.g., '[[name]]'. -func lexTableStart(lx *lexer) stateFn { - if lx.peek() == arrayTableStart { - lx.next() - lx.emit(itemArrayTableStart) - lx.push(lexArrayTableEnd) - } else { - lx.emit(itemTableStart) - lx.push(lexTableEnd) - } - return lexTableNameStart -} - -func lexTableEnd(lx *lexer) stateFn { - lx.emit(itemTableEnd) - return lexTopEnd -} - -func lexArrayTableEnd(lx *lexer) stateFn { - if r := lx.next(); r != arrayTableEnd { - return lx.errorf("Expected end of table array name delimiter %q, "+ - "but got %q instead.", arrayTableEnd, r) - } - lx.emit(itemArrayTableEnd) - return lexTopEnd -} - -func lexTableNameStart(lx *lexer) stateFn { - lx.skip(isWhitespace) - switch r := lx.peek(); { - case r == tableEnd || r == eof: - return lx.errorf("Unexpected end of table name. (Table names cannot " + - "be empty.)") - case r == tableSep: - return lx.errorf("Unexpected table separator. (Table names cannot " + - "be empty.)") - case r == stringStart || r == rawStringStart: - lx.ignore() - lx.push(lexTableNameEnd) - return lexValue // reuse string lexing - default: - return lexBareTableName - } -} - -// lexBareTableName lexes the name of a table. It assumes that at least one -// valid character for the table has already been read. -func lexBareTableName(lx *lexer) stateFn { - r := lx.next() - if isBareKeyChar(r) { - return lexBareTableName - } - lx.backup() - lx.emit(itemText) - return lexTableNameEnd -} - -// lexTableNameEnd reads the end of a piece of a table name, optionally -// consuming whitespace. -func lexTableNameEnd(lx *lexer) stateFn { - lx.skip(isWhitespace) - switch r := lx.next(); { - case isWhitespace(r): - return lexTableNameEnd - case r == tableSep: - lx.ignore() - return lexTableNameStart - case r == tableEnd: - return lx.pop() - default: - return lx.errorf("Expected '.' or ']' to end table name, but got %q "+ - "instead.", r) - } -} - -// lexKeyStart consumes a key name up until the first non-whitespace character. -// lexKeyStart will ignore whitespace. -func lexKeyStart(lx *lexer) stateFn { - r := lx.peek() - switch { - case r == keySep: - return lx.errorf("Unexpected key separator %q.", keySep) - case isWhitespace(r) || isNL(r): - lx.next() - return lexSkip(lx, lexKeyStart) - case r == stringStart || r == rawStringStart: - lx.ignore() - lx.emit(itemKeyStart) - lx.push(lexKeyEnd) - return lexValue // reuse string lexing - default: - lx.ignore() - lx.emit(itemKeyStart) - return lexBareKey - } -} - -// lexBareKey consumes the text of a bare key. Assumes that the first character -// (which is not whitespace) has not yet been consumed. -func lexBareKey(lx *lexer) stateFn { - switch r := lx.next(); { - case isBareKeyChar(r): - return lexBareKey - case isWhitespace(r): - lx.backup() - lx.emit(itemText) - return lexKeyEnd - case r == keySep: - lx.backup() - lx.emit(itemText) - return lexKeyEnd - default: - return lx.errorf("Bare keys cannot contain %q.", r) - } -} - -// lexKeyEnd consumes the end of a key and trims whitespace (up to the key -// separator). -func lexKeyEnd(lx *lexer) stateFn { - switch r := lx.next(); { - case r == keySep: - return lexSkip(lx, lexValue) - case isWhitespace(r): - return lexSkip(lx, lexKeyEnd) - default: - return lx.errorf("Expected key separator %q, but got %q instead.", - keySep, r) - } -} - -// lexValue starts the consumption of a value anywhere a value is expected. -// lexValue will ignore whitespace. -// After a value is lexed, the last state on the next is popped and returned. -func lexValue(lx *lexer) stateFn { - // We allow whitespace to precede a value, but NOT new lines. - // In array syntax, the array states are responsible for ignoring new - // lines. - r := lx.next() - switch { - case isWhitespace(r): - return lexSkip(lx, lexValue) - case isDigit(r): - lx.backup() // avoid an extra state and use the same as above - return lexNumberOrDateStart - } - switch r { - case arrayStart: - lx.ignore() - lx.emit(itemArray) - return lexArrayValue - case stringStart: - if lx.accept(stringStart) { - if lx.accept(stringStart) { - lx.ignore() // Ignore """ - return lexMultilineString - } - lx.backup() - } - lx.ignore() // ignore the '"' - return lexString - case rawStringStart: - if lx.accept(rawStringStart) { - if lx.accept(rawStringStart) { - lx.ignore() // Ignore """ - return lexMultilineRawString - } - lx.backup() - } - lx.ignore() // ignore the "'" - return lexRawString - case '+', '-': - return lexNumberStart - case '.': // special error case, be kind to users - return lx.errorf("Floats must start with a digit, not '.'.") - } - if unicode.IsLetter(r) { - // Be permissive here; lexBool will give a nice error if the - // user wrote something like - // x = foo - // (i.e. not 'true' or 'false' but is something else word-like.) - lx.backup() - return lexBool - } - return lx.errorf("Expected value but found %q instead.", r) -} - -// lexArrayValue consumes one value in an array. It assumes that '[' or ',' -// have already been consumed. All whitespace and new lines are ignored. -func lexArrayValue(lx *lexer) stateFn { - r := lx.next() - switch { - case isWhitespace(r) || isNL(r): - return lexSkip(lx, lexArrayValue) - case r == commentStart: - lx.push(lexArrayValue) - return lexCommentStart - case r == arrayValTerm: - return lx.errorf("Unexpected array value terminator %q.", - arrayValTerm) - case r == arrayEnd: - return lexArrayEnd - } - - lx.backup() - lx.push(lexArrayValueEnd) - return lexValue -} - -// lexArrayValueEnd consumes the cruft between values of an array. Namely, -// it ignores whitespace and expects either a ',' or a ']'. -func lexArrayValueEnd(lx *lexer) stateFn { - r := lx.next() - switch { - case isWhitespace(r) || isNL(r): - return lexSkip(lx, lexArrayValueEnd) - case r == commentStart: - lx.push(lexArrayValueEnd) - return lexCommentStart - case r == arrayValTerm: - lx.ignore() - return lexArrayValue // move on to the next value - case r == arrayEnd: - return lexArrayEnd - } - return lx.errorf("Expected an array value terminator %q or an array "+ - "terminator %q, but got %q instead.", arrayValTerm, arrayEnd, r) -} - -// lexArrayEnd finishes the lexing of an array. It assumes that a ']' has -// just been consumed. -func lexArrayEnd(lx *lexer) stateFn { - lx.ignore() - lx.emit(itemArrayEnd) - return lx.pop() -} - -// lexString consumes the inner contents of a string. It assumes that the -// beginning '"' has already been consumed and ignored. -func lexString(lx *lexer) stateFn { - r := lx.next() - switch { - case isNL(r): - return lx.errorf("Strings cannot contain new lines.") - case r == '\\': - lx.push(lexString) - return lexStringEscape - case r == stringEnd: - lx.backup() - lx.emit(itemString) - lx.next() - lx.ignore() - return lx.pop() - } - return lexString -} - -// lexMultilineString consumes the inner contents of a string. It assumes that -// the beginning '"""' has already been consumed and ignored. -func lexMultilineString(lx *lexer) stateFn { - r := lx.next() - switch { - case r == '\\': - return lexMultilineStringEscape - case r == stringEnd: - if lx.accept(stringEnd) { - if lx.accept(stringEnd) { - lx.backup() - lx.backup() - lx.backup() - lx.emit(itemMultilineString) - lx.next() - lx.next() - lx.next() - lx.ignore() - return lx.pop() - } - lx.backup() - } - } - return lexMultilineString -} - -// lexRawString consumes a raw string. Nothing can be escaped in such a string. -// It assumes that the beginning "'" has already been consumed and ignored. -func lexRawString(lx *lexer) stateFn { - r := lx.next() - switch { - case isNL(r): - return lx.errorf("Strings cannot contain new lines.") - case r == rawStringEnd: - lx.backup() - lx.emit(itemRawString) - lx.next() - lx.ignore() - return lx.pop() - } - return lexRawString -} - -// lexMultilineRawString consumes a raw string. Nothing can be escaped in such -// a string. It assumes that the beginning "'" has already been consumed and -// ignored. -func lexMultilineRawString(lx *lexer) stateFn { - r := lx.next() - switch { - case r == rawStringEnd: - if lx.accept(rawStringEnd) { - if lx.accept(rawStringEnd) { - lx.backup() - lx.backup() - lx.backup() - lx.emit(itemRawMultilineString) - lx.next() - lx.next() - lx.next() - lx.ignore() - return lx.pop() - } - lx.backup() - } - } - return lexMultilineRawString -} - -// lexMultilineStringEscape consumes an escaped character. It assumes that the -// preceding '\\' has already been consumed. -func lexMultilineStringEscape(lx *lexer) stateFn { - // Handle the special case first: - if isNL(lx.next()) { - return lexMultilineString - } else { - lx.backup() - lx.push(lexMultilineString) - return lexStringEscape(lx) - } -} - -func lexStringEscape(lx *lexer) stateFn { - r := lx.next() - switch r { - case 'b': - fallthrough - case 't': - fallthrough - case 'n': - fallthrough - case 'f': - fallthrough - case 'r': - fallthrough - case '"': - fallthrough - case '\\': - return lx.pop() - case 'u': - return lexShortUnicodeEscape - case 'U': - return lexLongUnicodeEscape - } - return lx.errorf("Invalid escape character %q. Only the following "+ - "escape characters are allowed: "+ - "\\b, \\t, \\n, \\f, \\r, \\\", \\/, \\\\, "+ - "\\uXXXX and \\UXXXXXXXX.", r) -} - -func lexShortUnicodeEscape(lx *lexer) stateFn { - var r rune - for i := 0; i < 4; i++ { - r = lx.next() - if !isHexadecimal(r) { - return lx.errorf("Expected four hexadecimal digits after '\\u', "+ - "but got '%s' instead.", lx.current()) - } - } - return lx.pop() -} - -func lexLongUnicodeEscape(lx *lexer) stateFn { - var r rune - for i := 0; i < 8; i++ { - r = lx.next() - if !isHexadecimal(r) { - return lx.errorf("Expected eight hexadecimal digits after '\\U', "+ - "but got '%s' instead.", lx.current()) - } - } - return lx.pop() -} - -// lexNumberOrDateStart consumes either an integer, a float, or datetime. -func lexNumberOrDateStart(lx *lexer) stateFn { - r := lx.next() - if isDigit(r) { - return lexNumberOrDate - } - switch r { - case '_': - return lexNumber - case 'e', 'E': - return lexFloat - case '.': - return lx.errorf("Floats must start with a digit, not '.'.") - } - return lx.errorf("Expected a digit but got %q.", r) -} - -// lexNumberOrDate consumes either an integer, float or datetime. -func lexNumberOrDate(lx *lexer) stateFn { - r := lx.next() - if isDigit(r) { - return lexNumberOrDate - } - switch r { - case '-': - return lexDatetime - case '_': - return lexNumber - case '.', 'e', 'E': - return lexFloat - } - - lx.backup() - lx.emit(itemInteger) - return lx.pop() -} - -// lexDatetime consumes a Datetime, to a first approximation. -// The parser validates that it matches one of the accepted formats. -func lexDatetime(lx *lexer) stateFn { - r := lx.next() - if isDigit(r) { - return lexDatetime - } - switch r { - case '-', 'T', ':', '.', 'Z': - return lexDatetime - } - - lx.backup() - lx.emit(itemDatetime) - return lx.pop() -} - -// lexNumberStart consumes either an integer or a float. It assumes that a sign -// has already been read, but that *no* digits have been consumed. -// lexNumberStart will move to the appropriate integer or float states. -func lexNumberStart(lx *lexer) stateFn { - // We MUST see a digit. Even floats have to start with a digit. - r := lx.next() - if !isDigit(r) { - if r == '.' { - return lx.errorf("Floats must start with a digit, not '.'.") - } else { - return lx.errorf("Expected a digit but got %q.", r) - } - } - return lexNumber -} - -// lexNumber consumes an integer or a float after seeing the first digit. -func lexNumber(lx *lexer) stateFn { - r := lx.next() - if isDigit(r) { - return lexNumber - } - switch r { - case '_': - return lexNumber - case '.', 'e', 'E': - return lexFloat - } - - lx.backup() - lx.emit(itemInteger) - return lx.pop() -} - -// lexFloat consumes the elements of a float. It allows any sequence of -// float-like characters, so floats emitted by the lexer are only a first -// approximation and must be validated by the parser. -func lexFloat(lx *lexer) stateFn { - r := lx.next() - if isDigit(r) { - return lexFloat - } - switch r { - case '_', '.', '-', '+', 'e', 'E': - return lexFloat - } - - lx.backup() - lx.emit(itemFloat) - return lx.pop() -} - -// lexBool consumes a bool string: 'true' or 'false. -func lexBool(lx *lexer) stateFn { - var rs []rune - for { - r := lx.next() - if r == eof || isWhitespace(r) || isNL(r) { - lx.backup() - break - } - rs = append(rs, r) - } - s := string(rs) - switch s { - case "true", "false": - lx.emit(itemBool) - return lx.pop() - } - return lx.errorf("Expected value but found %q instead.", s) -} - -// lexCommentStart begins the lexing of a comment. It will emit -// itemCommentStart and consume no characters, passing control to lexComment. -func lexCommentStart(lx *lexer) stateFn { - lx.ignore() - lx.emit(itemCommentStart) - return lexComment -} - -// lexComment lexes an entire comment. It assumes that '#' has been consumed. -// It will consume *up to* the first new line character, and pass control -// back to the last state on the stack. -func lexComment(lx *lexer) stateFn { - r := lx.peek() - if isNL(r) || r == eof { - lx.emit(itemText) - return lx.pop() - } - lx.next() - return lexComment -} - -// lexSkip ignores all slurped input and moves on to the next state. -func lexSkip(lx *lexer, nextState stateFn) stateFn { - return func(lx *lexer) stateFn { - lx.ignore() - return nextState - } -} - -// isWhitespace returns true if `r` is a whitespace character according -// to the spec. -func isWhitespace(r rune) bool { - return r == '\t' || r == ' ' -} - -func isNL(r rune) bool { - return r == '\n' || r == '\r' -} - -func isDigit(r rune) bool { - return r >= '0' && r <= '9' -} - -func isHexadecimal(r rune) bool { - return (r >= '0' && r <= '9') || - (r >= 'a' && r <= 'f') || - (r >= 'A' && r <= 'F') -} - -func isBareKeyChar(r rune) bool { - return (r >= 'A' && r <= 'Z') || - (r >= 'a' && r <= 'z') || - (r >= '0' && r <= '9') || - r == '_' || - r == '-' -} - -func (itype itemType) String() string { - switch itype { - case itemError: - return "Error" - case itemNIL: - return "NIL" - case itemEOF: - return "EOF" - case itemText: - return "Text" - case itemString: - return "String" - case itemRawString: - return "String" - case itemMultilineString: - return "String" - case itemRawMultilineString: - return "String" - case itemBool: - return "Bool" - case itemInteger: - return "Integer" - case itemFloat: - return "Float" - case itemDatetime: - return "DateTime" - case itemTableStart: - return "TableStart" - case itemTableEnd: - return "TableEnd" - case itemKeyStart: - return "KeyStart" - case itemArray: - return "Array" - case itemArrayEnd: - return "ArrayEnd" - case itemCommentStart: - return "CommentStart" - } - panic(fmt.Sprintf("BUG: Unknown type '%d'.", int(itype))) -} - -func (item item) String() string { - return fmt.Sprintf("(%s, %s)", item.typ.String(), item.val) -} diff --git a/vendor/github.com/BurntSushi/toml/parse.go b/vendor/github.com/BurntSushi/toml/parse.go deleted file mode 100644 index a562555..0000000 --- a/vendor/github.com/BurntSushi/toml/parse.go +++ /dev/null @@ -1,557 +0,0 @@ -package toml - -import ( - "fmt" - "strconv" - "strings" - "time" - "unicode" - "unicode/utf8" -) - -type parser struct { - mapping map[string]interface{} - types map[string]tomlType - lx *lexer - - // A list of keys in the order that they appear in the TOML data. - ordered []Key - - // the full key for the current hash in scope - context Key - - // the base key name for everything except hashes - currentKey string - - // rough approximation of line number - approxLine int - - // A map of 'key.group.names' to whether they were created implicitly. - implicits map[string]bool -} - -type parseError string - -func (pe parseError) Error() string { - return string(pe) -} - -func parse(data string) (p *parser, err error) { - defer func() { - if r := recover(); r != nil { - var ok bool - if err, ok = r.(parseError); ok { - return - } - panic(r) - } - }() - - p = &parser{ - mapping: make(map[string]interface{}), - types: make(map[string]tomlType), - lx: lex(data), - ordered: make([]Key, 0), - implicits: make(map[string]bool), - } - for { - item := p.next() - if item.typ == itemEOF { - break - } - p.topLevel(item) - } - - return p, nil -} - -func (p *parser) panicf(format string, v ...interface{}) { - msg := fmt.Sprintf("Near line %d (last key parsed '%s'): %s", - p.approxLine, p.current(), fmt.Sprintf(format, v...)) - panic(parseError(msg)) -} - -func (p *parser) next() item { - it := p.lx.nextItem() - if it.typ == itemError { - p.panicf("%s", it.val) - } - return it -} - -func (p *parser) bug(format string, v ...interface{}) { - panic(fmt.Sprintf("BUG: "+format+"\n\n", v...)) -} - -func (p *parser) expect(typ itemType) item { - it := p.next() - p.assertEqual(typ, it.typ) - return it -} - -func (p *parser) assertEqual(expected, got itemType) { - if expected != got { - p.bug("Expected '%s' but got '%s'.", expected, got) - } -} - -func (p *parser) topLevel(item item) { - switch item.typ { - case itemCommentStart: - p.approxLine = item.line - p.expect(itemText) - case itemTableStart: - kg := p.next() - p.approxLine = kg.line - - var key Key - for ; kg.typ != itemTableEnd && kg.typ != itemEOF; kg = p.next() { - key = append(key, p.keyString(kg)) - } - p.assertEqual(itemTableEnd, kg.typ) - - p.establishContext(key, false) - p.setType("", tomlHash) - p.ordered = append(p.ordered, key) - case itemArrayTableStart: - kg := p.next() - p.approxLine = kg.line - - var key Key - for ; kg.typ != itemArrayTableEnd && kg.typ != itemEOF; kg = p.next() { - key = append(key, p.keyString(kg)) - } - p.assertEqual(itemArrayTableEnd, kg.typ) - - p.establishContext(key, true) - p.setType("", tomlArrayHash) - p.ordered = append(p.ordered, key) - case itemKeyStart: - kname := p.next() - p.approxLine = kname.line - p.currentKey = p.keyString(kname) - - val, typ := p.value(p.next()) - p.setValue(p.currentKey, val) - p.setType(p.currentKey, typ) - p.ordered = append(p.ordered, p.context.add(p.currentKey)) - p.currentKey = "" - default: - p.bug("Unexpected type at top level: %s", item.typ) - } -} - -// Gets a string for a key (or part of a key in a table name). -func (p *parser) keyString(it item) string { - switch it.typ { - case itemText: - return it.val - case itemString, itemMultilineString, - itemRawString, itemRawMultilineString: - s, _ := p.value(it) - return s.(string) - default: - p.bug("Unexpected key type: %s", it.typ) - panic("unreachable") - } -} - -// value translates an expected value from the lexer into a Go value wrapped -// as an empty interface. -func (p *parser) value(it item) (interface{}, tomlType) { - switch it.typ { - case itemString: - return p.replaceEscapes(it.val), p.typeOfPrimitive(it) - case itemMultilineString: - trimmed := stripFirstNewline(stripEscapedWhitespace(it.val)) - return p.replaceEscapes(trimmed), p.typeOfPrimitive(it) - case itemRawString: - return it.val, p.typeOfPrimitive(it) - case itemRawMultilineString: - return stripFirstNewline(it.val), p.typeOfPrimitive(it) - case itemBool: - switch it.val { - case "true": - return true, p.typeOfPrimitive(it) - case "false": - return false, p.typeOfPrimitive(it) - } - p.bug("Expected boolean value, but got '%s'.", it.val) - case itemInteger: - if !numUnderscoresOK(it.val) { - p.panicf("Invalid integer %q: underscores must be surrounded by digits", - it.val) - } - val := strings.Replace(it.val, "_", "", -1) - num, err := strconv.ParseInt(val, 10, 64) - if err != nil { - // Distinguish integer values. Normally, it'd be a bug if the lexer - // provides an invalid integer, but it's possible that the number is - // out of range of valid values (which the lexer cannot determine). - // So mark the former as a bug but the latter as a legitimate user - // error. - if e, ok := err.(*strconv.NumError); ok && - e.Err == strconv.ErrRange { - - p.panicf("Integer '%s' is out of the range of 64-bit "+ - "signed integers.", it.val) - } else { - p.bug("Expected integer value, but got '%s'.", it.val) - } - } - return num, p.typeOfPrimitive(it) - case itemFloat: - parts := strings.FieldsFunc(it.val, func(r rune) bool { - switch r { - case '.', 'e', 'E': - return true - } - return false - }) - for _, part := range parts { - if !numUnderscoresOK(part) { - p.panicf("Invalid float %q: underscores must be "+ - "surrounded by digits", it.val) - } - } - if !numPeriodsOK(it.val) { - // As a special case, numbers like '123.' or '1.e2', - // which are valid as far as Go/strconv are concerned, - // must be rejected because TOML says that a fractional - // part consists of '.' followed by 1+ digits. - p.panicf("Invalid float %q: '.' must be followed "+ - "by one or more digits", it.val) - } - val := strings.Replace(it.val, "_", "", -1) - num, err := strconv.ParseFloat(val, 64) - if err != nil { - if e, ok := err.(*strconv.NumError); ok && - e.Err == strconv.ErrRange { - - p.panicf("Float '%s' is out of the range of 64-bit "+ - "IEEE-754 floating-point numbers.", it.val) - } else { - p.panicf("Invalid float value: %q", it.val) - } - } - return num, p.typeOfPrimitive(it) - case itemDatetime: - var t time.Time - var ok bool - var err error - for _, format := range []string{ - "2006-01-02T15:04:05Z07:00", - "2006-01-02T15:04:05", - "2006-01-02", - } { - t, err = time.ParseInLocation(format, it.val, time.Local) - if err == nil { - ok = true - break - } - } - if !ok { - p.panicf("Invalid TOML Datetime: %q.", it.val) - } - return t, p.typeOfPrimitive(it) - case itemArray: - array := make([]interface{}, 0) - types := make([]tomlType, 0) - - for it = p.next(); it.typ != itemArrayEnd; it = p.next() { - if it.typ == itemCommentStart { - p.expect(itemText) - continue - } - - val, typ := p.value(it) - array = append(array, val) - types = append(types, typ) - } - return array, p.typeOfArray(types) - } - p.bug("Unexpected value type: %s", it.typ) - panic("unreachable") -} - -// numUnderscoresOK checks whether each underscore in s is surrounded by -// characters that are not underscores. -func numUnderscoresOK(s string) bool { - accept := false - for _, r := range s { - if r == '_' { - if !accept { - return false - } - accept = false - continue - } - accept = true - } - return accept -} - -// numPeriodsOK checks whether every period in s is followed by a digit. -func numPeriodsOK(s string) bool { - period := false - for _, r := range s { - if period && !isDigit(r) { - return false - } - period = r == '.' - } - return !period -} - -// establishContext sets the current context of the parser, -// where the context is either a hash or an array of hashes. Which one is -// set depends on the value of the `array` parameter. -// -// Establishing the context also makes sure that the key isn't a duplicate, and -// will create implicit hashes automatically. -func (p *parser) establishContext(key Key, array bool) { - var ok bool - - // Always start at the top level and drill down for our context. - hashContext := p.mapping - keyContext := make(Key, 0) - - // We only need implicit hashes for key[0:-1] - for _, k := range key[0 : len(key)-1] { - _, ok = hashContext[k] - keyContext = append(keyContext, k) - - // No key? Make an implicit hash and move on. - if !ok { - p.addImplicit(keyContext) - hashContext[k] = make(map[string]interface{}) - } - - // If the hash context is actually an array of tables, then set - // the hash context to the last element in that array. - // - // Otherwise, it better be a table, since this MUST be a key group (by - // virtue of it not being the last element in a key). - switch t := hashContext[k].(type) { - case []map[string]interface{}: - hashContext = t[len(t)-1] - case map[string]interface{}: - hashContext = t - default: - p.panicf("Key '%s' was already created as a hash.", keyContext) - } - } - - p.context = keyContext - if array { - // If this is the first element for this array, then allocate a new - // list of tables for it. - k := key[len(key)-1] - if _, ok := hashContext[k]; !ok { - hashContext[k] = make([]map[string]interface{}, 0, 5) - } - - // Add a new table. But make sure the key hasn't already been used - // for something else. - if hash, ok := hashContext[k].([]map[string]interface{}); ok { - hashContext[k] = append(hash, make(map[string]interface{})) - } else { - p.panicf("Key '%s' was already created and cannot be used as "+ - "an array.", keyContext) - } - } else { - p.setValue(key[len(key)-1], make(map[string]interface{})) - } - p.context = append(p.context, key[len(key)-1]) -} - -// setValue sets the given key to the given value in the current context. -// It will make sure that the key hasn't already been defined, account for -// implicit key groups. -func (p *parser) setValue(key string, value interface{}) { - var tmpHash interface{} - var ok bool - - hash := p.mapping - keyContext := make(Key, 0) - for _, k := range p.context { - keyContext = append(keyContext, k) - if tmpHash, ok = hash[k]; !ok { - p.bug("Context for key '%s' has not been established.", keyContext) - } - switch t := tmpHash.(type) { - case []map[string]interface{}: - // The context is a table of hashes. Pick the most recent table - // defined as the current hash. - hash = t[len(t)-1] - case map[string]interface{}: - hash = t - default: - p.bug("Expected hash to have type 'map[string]interface{}', but "+ - "it has '%T' instead.", tmpHash) - } - } - keyContext = append(keyContext, key) - - if _, ok := hash[key]; ok { - // Typically, if the given key has already been set, then we have - // to raise an error since duplicate keys are disallowed. However, - // it's possible that a key was previously defined implicitly. In this - // case, it is allowed to be redefined concretely. (See the - // `tests/valid/implicit-and-explicit-after.toml` test in `toml-test`.) - // - // But we have to make sure to stop marking it as an implicit. (So that - // another redefinition provokes an error.) - // - // Note that since it has already been defined (as a hash), we don't - // want to overwrite it. So our business is done. - if p.isImplicit(keyContext) { - p.removeImplicit(keyContext) - return - } - - // Otherwise, we have a concrete key trying to override a previous - // key, which is *always* wrong. - p.panicf("Key '%s' has already been defined.", keyContext) - } - hash[key] = value -} - -// setType sets the type of a particular value at a given key. -// It should be called immediately AFTER setValue. -// -// Note that if `key` is empty, then the type given will be applied to the -// current context (which is either a table or an array of tables). -func (p *parser) setType(key string, typ tomlType) { - keyContext := make(Key, 0, len(p.context)+1) - for _, k := range p.context { - keyContext = append(keyContext, k) - } - if len(key) > 0 { // allow type setting for hashes - keyContext = append(keyContext, key) - } - p.types[keyContext.String()] = typ -} - -// addImplicit sets the given Key as having been created implicitly. -func (p *parser) addImplicit(key Key) { - p.implicits[key.String()] = true -} - -// removeImplicit stops tagging the given key as having been implicitly -// created. -func (p *parser) removeImplicit(key Key) { - p.implicits[key.String()] = false -} - -// isImplicit returns true if the key group pointed to by the key was created -// implicitly. -func (p *parser) isImplicit(key Key) bool { - return p.implicits[key.String()] -} - -// current returns the full key name of the current context. -func (p *parser) current() string { - if len(p.currentKey) == 0 { - return p.context.String() - } - if len(p.context) == 0 { - return p.currentKey - } - return fmt.Sprintf("%s.%s", p.context, p.currentKey) -} - -func stripFirstNewline(s string) string { - if len(s) == 0 || s[0] != '\n' { - return s - } - return s[1:] -} - -func stripEscapedWhitespace(s string) string { - esc := strings.Split(s, "\\\n") - if len(esc) > 1 { - for i := 1; i < len(esc); i++ { - esc[i] = strings.TrimLeftFunc(esc[i], unicode.IsSpace) - } - } - return strings.Join(esc, "") -} - -func (p *parser) replaceEscapes(str string) string { - var replaced []rune - s := []byte(str) - r := 0 - for r < len(s) { - if s[r] != '\\' { - c, size := utf8.DecodeRune(s[r:]) - r += size - replaced = append(replaced, c) - continue - } - r += 1 - if r >= len(s) { - p.bug("Escape sequence at end of string.") - return "" - } - switch s[r] { - default: - p.bug("Expected valid escape code after \\, but got %q.", s[r]) - return "" - case 'b': - replaced = append(replaced, rune(0x0008)) - r += 1 - case 't': - replaced = append(replaced, rune(0x0009)) - r += 1 - case 'n': - replaced = append(replaced, rune(0x000A)) - r += 1 - case 'f': - replaced = append(replaced, rune(0x000C)) - r += 1 - case 'r': - replaced = append(replaced, rune(0x000D)) - r += 1 - case '"': - replaced = append(replaced, rune(0x0022)) - r += 1 - case '\\': - replaced = append(replaced, rune(0x005C)) - r += 1 - case 'u': - // At this point, we know we have a Unicode escape of the form - // `uXXXX` at [r, r+5). (Because the lexer guarantees this - // for us.) - escaped := p.asciiEscapeToUnicode(s[r+1 : r+5]) - replaced = append(replaced, escaped) - r += 5 - case 'U': - // At this point, we know we have a Unicode escape of the form - // `uXXXX` at [r, r+9). (Because the lexer guarantees this - // for us.) - escaped := p.asciiEscapeToUnicode(s[r+1 : r+9]) - replaced = append(replaced, escaped) - r += 9 - } - } - return string(replaced) -} - -func (p *parser) asciiEscapeToUnicode(bs []byte) rune { - s := string(bs) - hex, err := strconv.ParseUint(strings.ToLower(s), 16, 32) - if err != nil { - p.bug("Could not parse '%s' as a hexadecimal number, but the "+ - "lexer claims it's OK: %s", s, err) - } - if !utf8.ValidRune(rune(hex)) { - p.panicf("Escaped character '\\u%s' is not valid UTF-8.", s) - } - return rune(hex) -} - -func isStringType(ty itemType) bool { - return ty == itemString || ty == itemMultilineString || - ty == itemRawString || ty == itemRawMultilineString -} diff --git a/vendor/github.com/BurntSushi/toml/session.vim b/vendor/github.com/BurntSushi/toml/session.vim deleted file mode 100644 index 562164b..0000000 --- a/vendor/github.com/BurntSushi/toml/session.vim +++ /dev/null @@ -1 +0,0 @@ -au BufWritePost *.go silent!make tags > /dev/null 2>&1 diff --git a/vendor/github.com/BurntSushi/toml/type_check.go b/vendor/github.com/BurntSushi/toml/type_check.go deleted file mode 100644 index c73f8af..0000000 --- a/vendor/github.com/BurntSushi/toml/type_check.go +++ /dev/null @@ -1,91 +0,0 @@ -package toml - -// tomlType represents any Go type that corresponds to a TOML type. -// While the first draft of the TOML spec has a simplistic type system that -// probably doesn't need this level of sophistication, we seem to be militating -// toward adding real composite types. -type tomlType interface { - typeString() string -} - -// typeEqual accepts any two types and returns true if they are equal. -func typeEqual(t1, t2 tomlType) bool { - if t1 == nil || t2 == nil { - return false - } - return t1.typeString() == t2.typeString() -} - -func typeIsHash(t tomlType) bool { - return typeEqual(t, tomlHash) || typeEqual(t, tomlArrayHash) -} - -type tomlBaseType string - -func (btype tomlBaseType) typeString() string { - return string(btype) -} - -func (btype tomlBaseType) String() string { - return btype.typeString() -} - -var ( - tomlInteger tomlBaseType = "Integer" - tomlFloat tomlBaseType = "Float" - tomlDatetime tomlBaseType = "Datetime" - tomlString tomlBaseType = "String" - tomlBool tomlBaseType = "Bool" - tomlArray tomlBaseType = "Array" - tomlHash tomlBaseType = "Hash" - tomlArrayHash tomlBaseType = "ArrayHash" -) - -// typeOfPrimitive returns a tomlType of any primitive value in TOML. -// Primitive values are: Integer, Float, Datetime, String and Bool. -// -// Passing a lexer item other than the following will cause a BUG message -// to occur: itemString, itemBool, itemInteger, itemFloat, itemDatetime. -func (p *parser) typeOfPrimitive(lexItem item) tomlType { - switch lexItem.typ { - case itemInteger: - return tomlInteger - case itemFloat: - return tomlFloat - case itemDatetime: - return tomlDatetime - case itemString: - return tomlString - case itemMultilineString: - return tomlString - case itemRawString: - return tomlString - case itemRawMultilineString: - return tomlString - case itemBool: - return tomlBool - } - p.bug("Cannot infer primitive type of lex item '%s'.", lexItem) - panic("unreachable") -} - -// typeOfArray returns a tomlType for an array given a list of types of its -// values. -// -// In the current spec, if an array is homogeneous, then its type is always -// "Array". If the array is not homogeneous, an error is generated. -func (p *parser) typeOfArray(types []tomlType) tomlType { - // Empty arrays are cool. - if len(types) == 0 { - return tomlArray - } - - theType := types[0] - for _, t := range types[1:] { - if !typeEqual(theType, t) { - p.panicf("Array contains values of type '%s' and '%s', but "+ - "arrays must be homogeneous.", theType, t) - } - } - return tomlArray -} diff --git a/vendor/github.com/BurntSushi/toml/type_fields.go b/vendor/github.com/BurntSushi/toml/type_fields.go deleted file mode 100644 index 608997c..0000000 --- a/vendor/github.com/BurntSushi/toml/type_fields.go +++ /dev/null @@ -1,242 +0,0 @@ -package toml - -// Struct field handling is adapted from code in encoding/json: -// -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the Go distribution. - -import ( - "reflect" - "sort" - "sync" -) - -// A field represents a single field found in a struct. -type field struct { - name string // the name of the field (`toml` tag included) - tag bool // whether field has a `toml` tag - index []int // represents the depth of an anonymous field - typ reflect.Type // the type of the field -} - -// byName sorts field by name, breaking ties with depth, -// then breaking ties with "name came from toml tag", then -// breaking ties with index sequence. -type byName []field - -func (x byName) Len() int { return len(x) } - -func (x byName) Swap(i, j int) { x[i], x[j] = x[j], x[i] } - -func (x byName) Less(i, j int) bool { - if x[i].name != x[j].name { - return x[i].name < x[j].name - } - if len(x[i].index) != len(x[j].index) { - return len(x[i].index) < len(x[j].index) - } - if x[i].tag != x[j].tag { - return x[i].tag - } - return byIndex(x).Less(i, j) -} - -// byIndex sorts field by index sequence. -type byIndex []field - -func (x byIndex) Len() int { return len(x) } - -func (x byIndex) Swap(i, j int) { x[i], x[j] = x[j], x[i] } - -func (x byIndex) Less(i, j int) bool { - for k, xik := range x[i].index { - if k >= len(x[j].index) { - return false - } - if xik != x[j].index[k] { - return xik < x[j].index[k] - } - } - return len(x[i].index) < len(x[j].index) -} - -// typeFields returns a list of fields that TOML should recognize for the given -// type. The algorithm is breadth-first search over the set of structs to -// include - the top struct and then any reachable anonymous structs. -func typeFields(t reflect.Type) []field { - // Anonymous fields to explore at the current level and the next. - current := []field{} - next := []field{{typ: t}} - - // Count of queued names for current level and the next. - count := map[reflect.Type]int{} - nextCount := map[reflect.Type]int{} - - // Types already visited at an earlier level. - visited := map[reflect.Type]bool{} - - // Fields found. - var fields []field - - for len(next) > 0 { - current, next = next, current[:0] - count, nextCount = nextCount, map[reflect.Type]int{} - - for _, f := range current { - if visited[f.typ] { - continue - } - visited[f.typ] = true - - // Scan f.typ for fields to include. - for i := 0; i < f.typ.NumField(); i++ { - sf := f.typ.Field(i) - if sf.PkgPath != "" && !sf.Anonymous { // unexported - continue - } - opts := getOptions(sf.Tag) - if opts.skip { - continue - } - index := make([]int, len(f.index)+1) - copy(index, f.index) - index[len(f.index)] = i - - ft := sf.Type - if ft.Name() == "" && ft.Kind() == reflect.Ptr { - // Follow pointer. - ft = ft.Elem() - } - - // Record found field and index sequence. - if opts.name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct { - tagged := opts.name != "" - name := opts.name - if name == "" { - name = sf.Name - } - fields = append(fields, field{name, tagged, index, ft}) - if count[f.typ] > 1 { - // If there were multiple instances, add a second, - // so that the annihilation code will see a duplicate. - // It only cares about the distinction between 1 or 2, - // so don't bother generating any more copies. - fields = append(fields, fields[len(fields)-1]) - } - continue - } - - // Record new anonymous struct to explore in next round. - nextCount[ft]++ - if nextCount[ft] == 1 { - f := field{name: ft.Name(), index: index, typ: ft} - next = append(next, f) - } - } - } - } - - sort.Sort(byName(fields)) - - // Delete all fields that are hidden by the Go rules for embedded fields, - // except that fields with TOML tags are promoted. - - // The fields are sorted in primary order of name, secondary order - // of field index length. Loop over names; for each name, delete - // hidden fields by choosing the one dominant field that survives. - out := fields[:0] - for advance, i := 0, 0; i < len(fields); i += advance { - // One iteration per name. - // Find the sequence of fields with the name of this first field. - fi := fields[i] - name := fi.name - for advance = 1; i+advance < len(fields); advance++ { - fj := fields[i+advance] - if fj.name != name { - break - } - } - if advance == 1 { // Only one field with this name - out = append(out, fi) - continue - } - dominant, ok := dominantField(fields[i : i+advance]) - if ok { - out = append(out, dominant) - } - } - - fields = out - sort.Sort(byIndex(fields)) - - return fields -} - -// dominantField looks through the fields, all of which are known to -// have the same name, to find the single field that dominates the -// others using Go's embedding rules, modified by the presence of -// TOML tags. If there are multiple top-level fields, the boolean -// will be false: This condition is an error in Go and we skip all -// the fields. -func dominantField(fields []field) (field, bool) { - // The fields are sorted in increasing index-length order. The winner - // must therefore be one with the shortest index length. Drop all - // longer entries, which is easy: just truncate the slice. - length := len(fields[0].index) - tagged := -1 // Index of first tagged field. - for i, f := range fields { - if len(f.index) > length { - fields = fields[:i] - break - } - if f.tag { - if tagged >= 0 { - // Multiple tagged fields at the same level: conflict. - // Return no field. - return field{}, false - } - tagged = i - } - } - if tagged >= 0 { - return fields[tagged], true - } - // All remaining fields have the same length. If there's more than one, - // we have a conflict (two fields named "X" at the same level) and we - // return no field. - if len(fields) > 1 { - return field{}, false - } - return fields[0], true -} - -var fieldCache struct { - sync.RWMutex - m map[reflect.Type][]field -} - -// cachedTypeFields is like typeFields but uses a cache to avoid repeated work. -func cachedTypeFields(t reflect.Type) []field { - fieldCache.RLock() - f := fieldCache.m[t] - fieldCache.RUnlock() - if f != nil { - return f - } - - // Compute fields without lock. - // Might duplicate effort but won't hold other computations back. - f = typeFields(t) - if f == nil { - f = []field{} - } - - fieldCache.Lock() - if fieldCache.m == nil { - fieldCache.m = map[reflect.Type][]field{} - } - fieldCache.m[t] = f - fieldCache.Unlock() - return f -} diff --git a/vendor/github.com/abiosoft/caddy-git/.gitignore b/vendor/github.com/abiosoft/caddy-git/.gitignore deleted file mode 100644 index af449fe..0000000 --- a/vendor/github.com/abiosoft/caddy-git/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# IntelliJ project files -.idea/ -*.iml -Caddyfile diff --git a/vendor/github.com/abiosoft/caddy-git/.travis.yml b/vendor/github.com/abiosoft/caddy-git/.travis.yml deleted file mode 100644 index d31fde7..0000000 --- a/vendor/github.com/abiosoft/caddy-git/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: go - -go: - - 1.6 - -script: go test - diff --git a/vendor/github.com/abiosoft/caddy-git/BUILDING.md b/vendor/github.com/abiosoft/caddy-git/BUILDING.md deleted file mode 100644 index fb65b78..0000000 --- a/vendor/github.com/abiosoft/caddy-git/BUILDING.md +++ /dev/null @@ -1,43 +0,0 @@ -# Building from Source - -Follow the instructions below to build from source. [Go](http://golang.org/doc/install) must be installed. - -### 1. Install Caddydev - -``` -$ go get github.com/caddyserver/caddydev -``` - -### 2. Pull Git Add-on -``` -$ go get github.com/abiosoft/caddy-git -``` - -### 3. Execute -``` -$ cd $GOPATH/src/github.com/abiosoft/caddy-git -$ caddydev -``` -## Other options - -### Execute from another directory -Copy the bundled caddydev config over to the directory. -``` -$ cp $GOPATH/src/github.com/abiosoft/caddy-git/config.json config.json -$ caddydev -``` -Or pass path to `config.json` as flag to caddydev. -``` -$ caddydev --conf $GOPATH/src/github.com/abiosoft/caddy-git/config.json -``` - -### Generate Binary -Generate a Caddy binary that includes Git add-on. -``` -$ cd $GOPATH/src/github.com/abiosoft/caddy-git -$ caddydev -o caddy -$ ./caddy -``` - -### Note -Caddydev is more suited to development purpose. To add other add-ons to Caddy alongside Git, download from [Caddy's download page](https://caddyserver.com/download) or use [Caddyext](https://github.com/caddyserver/caddyext). \ No newline at end of file diff --git a/vendor/github.com/abiosoft/caddy-git/LICENSE b/vendor/github.com/abiosoft/caddy-git/LICENSE deleted file mode 100644 index 95678ba..0000000 --- a/vendor/github.com/abiosoft/caddy-git/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Abiola Ibrahim - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/vendor/github.com/abiosoft/caddy-git/README.md b/vendor/github.com/abiosoft/caddy-git/README.md deleted file mode 100644 index b507985..0000000 --- a/vendor/github.com/abiosoft/caddy-git/README.md +++ /dev/null @@ -1,116 +0,0 @@ -# git - -Middleware for [Caddy](https://caddyserver.com). - -[![Build Status](https://travis-ci.org/abiosoft/caddy-git.svg?branch=master)](https://travis-ci.org/abiosoft/caddy-git) - -git clones a git repository into the site. This makes it possible to deploy your site with a simple git push. - -The git directive does not chain in a handler. Instead, it starts a service routine that runs during the lifetime of the server. When the server starts, it clones the repository. While the server is still up, it pulls the latest every so often. In regular git fashion, a download only includes changes so it is very efficient. - -If a pull fails, the service will retry up to three times. If the pull was not successful by then, it won't try again until the next interval. - -**Requirements**: This directive requires git to be installed. Also, private repositories may only be accessed from Linux or Mac systems. (Contributions are welcome that make private repositories work on Windows.) - -### Syntax - -``` -git repo [path] -``` -* **repo** is the URL to the repository; SSH and HTTPS URLs are supported -* **path** is the path, relative to site root, to clone the repository into; default is site root - -This simplified syntax pulls from master every 3600 seconds (1 hour) and only works for public repositories. - -For more control or to use a private repository, use the following syntax: - -``` -git [repo path] { - repo repo - path path - branch branch - key key - interval interval - hook path secret - hook_type type - then command [args...] - then_long command [args...] -} -``` -* **repo** is the URL to the repository; SSH and HTTPS URLs are supported. -* **path** is the path, relative to site root, to clone the repository into; default is site root. -* **branch** is the branch or tag to pull; default is master branch. **`{latest}`** is a placeholder for latest tag which ensures the most recent tag is always pulled. -* **key** is the path to the SSH private key; only required for private repositories. -* **interval** is the number of seconds between pulls; default is 3600 (1 hour), minimum 5. -* **path** and **secret** are used to create a webhook which pulls the latest right after a push. This is limited to the [supported webhooks](#supported-webhooks). **secret** is currently supported for GitHub and Travis hooks only. -* **type** is webhook type to use. The webhook type is auto detected by default but it can be explicitly set to one of the [supported webhooks](#supported-webhooks). This is a requirement for generic webhook. -* **command** is a command to execute after successful pull; followed by **args** which are any arguments to pass to the command. You can have multiple lines of this for multiple commands. **then_long** is for long executing commands that should run in background. - -Each property in the block is optional. The path and repo may be specified on the first line, as in the first syntax, or they may be specified in the block with other values. - -#### Supported Webhooks -* [github](https://github.com) -* [gitlab](https://gitlab.com) -* [bitbucket](https://bitbucket.org) -* [travis](https://travis-ci.org) -* [gogs](https://gogs.io) -* generic - -### Examples - -Public repository pulled into site root every hour: -``` -git github.com/user/myproject -``` - -Public repository pulled into the "subfolder" directory in the site root: -``` -git github.com/user/myproject /subfolder -``` - -Private repository pulled into the "subfolder" directory with tag v1.0 once per day: -``` -git { - repo git@github.com:user/myproject - branch v1.0 - key /home/user/.ssh/id_rsa - path subfolder - interval 86400 -} -``` - -Generate a static site with [Hugo](http://gohugo.io) after each pull: -``` -git github.com/user/site { - path ../ - then hugo --destination=/home/user/hugosite/public -} -``` - -Part of a Caddyfile for a PHP site that gets changes from a private repo: -``` -git git@github.com:user/myphpsite { - key /home/user/.ssh/id_rsa -} -fastcgi / 127.0.0.1:9000 php -``` - -Specifying a webhook: -``` -git git@github.com:user/site { - hook /webhook secret-password -} -``` - -You might need quotes `"secret-password"` around your secret if it contains any special characters, or you get an error. - - -Generic webhook payload: `` is branch name e.g. `master`. -``` -{ - "ref" : "refs/heads/" -} -``` -### Build from source -Check instructions for building from source here [BUILDING.md](https://github.com/abiosoft/caddy-git/blob/master/BUILDING.md) - diff --git a/vendor/github.com/abiosoft/caddy-git/bitbucket_hook.go b/vendor/github.com/abiosoft/caddy-git/bitbucket_hook.go deleted file mode 100644 index 4209a89..0000000 --- a/vendor/github.com/abiosoft/caddy-git/bitbucket_hook.go +++ /dev/null @@ -1,121 +0,0 @@ -package git - -import ( - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "net" - "net/http" - "strings" -) - -// See: https://confluence.atlassian.com/bitbucket/manage-webhooks-735643732.html -var bitbucketIPBlocks = []string{ - "131.103.20.160/27", - "165.254.145.0/26", - "104.192.143.0/24", -} - -type BitbucketHook struct{} - -type bbPush struct { - Push struct { - Changes []struct { - New struct { - Name string `json:"name,omitempty"` - } `json:"new,omitempty"` - } `json:"changes,omitempty"` - } `json:"push,omitempty"` -} - -func (b BitbucketHook) DoesHandle(h http.Header) bool { - event := h.Get("X-Event-Key") - - // for Gitlab you can only use X-Gitlab-Event header to test if you could handle the request - if event != "" { - return true - } - return false -} - -func (b BitbucketHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) { - if !b.verifyBitbucketIP(r.RemoteAddr) { - return http.StatusForbidden, errors.New("the request doesn't come from a valid IP") - } - - if r.Method != "POST" { - return http.StatusMethodNotAllowed, errors.New("the request had an invalid method.") - } - - body, err := ioutil.ReadAll(r.Body) - if err != nil { - return http.StatusRequestTimeout, errors.New("could not read body from request") - } - - event := r.Header.Get("X-Event-Key") - if event == "" { - return http.StatusBadRequest, errors.New("the 'X-Event-Key' header is required but was missing.") - } - - switch event { - case "repo:push": - err = b.handlePush(body, repo) - if !hookIgnored(err) && err != nil { - return http.StatusBadRequest, err - } - default: - // return 400 if we do not handle the event type. - return http.StatusBadRequest, nil - } - - return http.StatusOK, err -} - -func (b BitbucketHook) handlePush(body []byte, repo *Repo) error { - var push bbPush - - err := json.Unmarshal(body, &push) - if err != nil { - return err - } - - if len(push.Push.Changes) == 0 { - return errors.New("the push was incomplete, missing change list") - } - - change := push.Push.Changes[0] - if len(change.New.Name) == 0 { - return errors.New("the push didn't contain a valid branch name") - } - - branch := change.New.Name - if branch != repo.Branch { - return hookIgnoredError{hookType: hookName(b), err: fmt.Errorf("found different branch %v", branch)} - } - Logger().Print("Received pull notification for the tracking branch, updating...\n") - repo.Pull() - - return nil -} - -func cleanRemoteIP(remoteIP string) string { - // *httpRequest.RemoteAddr comes in format IP:PORT, remove the port - return strings.Split(remoteIP, ":")[0] -} - -func (b BitbucketHook) verifyBitbucketIP(remoteIP string) bool { - ipAddress := net.ParseIP(cleanRemoteIP(remoteIP)) - for _, cidr := range bitbucketIPBlocks { - _, cidrnet, err := net.ParseCIDR(cidr) - if err != nil { - Logger().Printf("Error parsing CIDR block [%s]. Skipping...\n", cidr) - continue - } - - if cidrnet.Contains(ipAddress) { - return true - } - } - return false -} diff --git a/vendor/github.com/abiosoft/caddy-git/bitbucket_hook_test.go b/vendor/github.com/abiosoft/caddy-git/bitbucket_hook_test.go deleted file mode 100644 index 72ed03e..0000000 --- a/vendor/github.com/abiosoft/caddy-git/bitbucket_hook_test.go +++ /dev/null @@ -1,98 +0,0 @@ -package git - -import ( - "bytes" - "net/http" - "net/http/httptest" - "testing" -) - -func TestBitbucketDeployPush(t *testing.T) { - repo := &Repo{Branch: "master", Hook: HookConfig{Url: "/bitbucket_deploy"}} - bbHook := BitbucketHook{} - - for i, test := range []struct { - ip string - body string - event string - responseBody string - code int - }{ - {"131.103.20.192", "", "", "", 403}, - {"131.103.20.160", "", "", "", 400}, - {"131.103.20.160", "", "repo:push", "", 400}, - {"131.103.20.160", pushBBBodyValid, "repo:push", "", 200}, - {"131.103.20.165", pushBBBodyValid, "repo:push", "", 200}, - {"131.103.20.160", pushBBBodyEmptyBranch, "repo:push", "", 400}, - {"131.103.20.160", pushBBBodyDeleteBranch, "repo:push", "", 400}, - } { - - req, err := http.NewRequest("POST", "/bitbucket_deploy", bytes.NewBuffer([]byte(test.body))) - if err != nil { - t.Fatalf("Test %v: Could not create HTTP request: %v", i, err) - } - req.RemoteAddr = test.ip - - if test.event != "" { - req.Header.Add("X-Event-Key", test.event) - } - - rec := httptest.NewRecorder() - - code, err := bbHook.Handle(rec, req, repo) - - if code != test.code { - t.Errorf("Test %d: Expected response code to be %d but was %d", i, test.code, code) - } - - if rec.Body.String() != test.responseBody { - t.Errorf("Test %d: Expected response body to be '%v' but was '%v'", i, test.responseBody, rec.Body.String()) - } - } - -} - -var pushBBBodyEmptyBranch = ` -{ - "push": { - "changes": [ - { - "new": { - "type": "branch", - "name": "", - "target": { - "hash": "709d658dc5b6d6afcd46049c2f332ee3f515a67d" - } - } - } - ] - } -} -` - -var pushBBBodyValid = ` -{ - "push": { - "changes": [ - { - "new": { - "type": "branch", - "name": "master", - "target": { - "hash": "709d658dc5b6d6afcd46049c2f332ee3f515a67d" - } - } - } - ] - } -} -` - -var pushBBBodyDeleteBranch = ` -{ - "push": { - "changes": [ - ] - } -} -` diff --git a/vendor/github.com/abiosoft/caddy-git/commands.go b/vendor/github.com/abiosoft/caddy-git/commands.go deleted file mode 100644 index e73b6ee..0000000 --- a/vendor/github.com/abiosoft/caddy-git/commands.go +++ /dev/null @@ -1,212 +0,0 @@ -package git - -import ( - "bytes" - "os" - "strings" - "sync" - "time" -) - -// Then is the command executed after successful pull. -type Then interface { - Command() string - Exec(string) error -} - -// NewThen creates a new Then command. -func NewThen(command string, args ...string) Then { - return &gitCmd{command: command, args: args} -} - -// NewLongThen creates a new long running Then comand. -func NewLongThen(command string, args ...string) Then { - return &gitCmd{command: command, args: args, background: true, haltChan: make(chan struct{})} -} - -type gitCmd struct { - command string - args []string - dir string - background bool - process *os.Process - - haltChan chan struct{} - monitoring bool - sync.RWMutex -} - -// Command returns the full command as configured in Caddyfile -func (g *gitCmd) Command() string { - return g.command + " " + strings.Join(g.args, " ") -} - -// Exec executes the command initiated in GitCmd -func (g *gitCmd) Exec(dir string) error { - g.Lock() - g.dir = dir - g.Unlock() - - if g.background { - return g.execBackground(dir) - } - return g.exec(dir) -} - -func (g *gitCmd) restart() error { - err := g.Exec(g.dir) - if err == nil { - Logger().Printf("Restart successful for '%v'.\n", g.Command()) - } else { - Logger().Printf("Restart failed for '%v'.\n", g.Command()) - } - return err -} - -func (g *gitCmd) exec(dir string) error { - return runCmd(g.command, g.args, dir) -} - -func (g *gitCmd) execBackground(dir string) error { - // if existing process is running, kill it. - g.RLock() - if g.process != nil { - g.haltProcess() - } - g.RUnlock() - - process, err := runCmdBackground(g.command, g.args, dir) - if err == nil { - g.Lock() - g.process = process - g.Unlock() - g.monitorProcess() - } - return err -} - -func (g *gitCmd) monitorProcess() { - g.RLock() - if g.process == nil { - g.RUnlock() - return - } - monitoring := g.monitoring - g.RUnlock() - - if monitoring { - return - } - - type resp struct { - state *os.ProcessState - err error - } - - respChan := make(chan resp) - - go func() { - p, err := g.process.Wait() - respChan <- resp{p, err} - }() - - go func() { - g.Lock() - g.monitoring = true - g.Unlock() - - select { - case <-g.haltChan: - g.killProcess() - case r := <-respChan: - if r.err != nil || !r.state.Success() { - Logger().Printf("Command '%v' terminated with error", g.Command()) - - g.Lock() - g.process = nil - g.monitoring = false - g.Unlock() - - for i := 0; ; i++ { - if i >= numRetries { - Logger().Printf("Restart failed after 3 attempts for '%v'. Ignoring...\n", g.Command()) - break - } - Logger().Printf("Attempting restart %v of %v for '%v'\n", i+1, numRetries, g.Command()) - if g.restart() == nil { - break - } - time.Sleep(time.Second * 5) - } - } else { - g.Lock() - g.process = nil - g.monitoring = false - g.Unlock() - } - } - }() - -} - -func (g *gitCmd) killProcess() { - g.Lock() - if err := g.process.Kill(); err != nil { - Logger().Printf("Could not terminate running command '%v'\n", g.command) - } else { - Logger().Printf("Command '%v' terminated from within.\n", g.command) - } - g.process = nil - g.monitoring = false - g.Unlock() -} - -// haltProcess halts the running process -func (g *gitCmd) haltProcess() { - g.RLock() - monitoring := g.monitoring - g.RUnlock() - - if monitoring { - g.haltChan <- struct{}{} - } -} - -// runCmd is a helper function to run commands. -// It runs command with args from directory at dir. -// The executed process outputs to os.Stderr -func runCmd(command string, args []string, dir string) error { - cmd := gos.Command(command, args...) - cmd.Stdout(os.Stderr) - cmd.Stderr(os.Stderr) - cmd.Dir(dir) - if err := cmd.Start(); err != nil { - return err - } - return cmd.Wait() -} - -// runCmdBackground is a helper function to run commands in the background. -// It returns the resulting process and an error that occurs during while -// starting the process (if any). -func runCmdBackground(command string, args []string, dir string) (*os.Process, error) { - cmd := gos.Command(command, args...) - cmd.Dir(dir) - cmd.Stdout(os.Stderr) - cmd.Stderr(os.Stderr) - err := cmd.Start() - return cmd.Process(), err -} - -// runCmdOutput is a helper function to run commands and return output. -// It runs command with args from directory at dir. -// If successful, returns output and nil error -func runCmdOutput(command string, args []string, dir string) (string, error) { - cmd := gos.Command(command, args...) - cmd.Dir(dir) - var err error - if output, err := cmd.Output(); err == nil { - return string(bytes.TrimSpace(output)), nil - } - return "", err -} diff --git a/vendor/github.com/abiosoft/caddy-git/config.json b/vendor/github.com/abiosoft/caddy-git/config.json deleted file mode 100644 index af58b69..0000000 --- a/vendor/github.com/abiosoft/caddy-git/config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "directive": "git", - "after": "shutdown", - "source": "github.com/abiosoft/caddy-git" -} diff --git a/vendor/github.com/abiosoft/caddy-git/generic_hook.go b/vendor/github.com/abiosoft/caddy-git/generic_hook.go deleted file mode 100644 index 14b85a9..0000000 --- a/vendor/github.com/abiosoft/caddy-git/generic_hook.go +++ /dev/null @@ -1,61 +0,0 @@ -package git - -import ( - "encoding/json" - "errors" - "io/ioutil" - "net/http" - "strings" -) - -type GenericHook struct{} - -type gPush struct { - Ref string `json:"ref"` -} - -func (g GenericHook) DoesHandle(h http.Header) bool { - return true -} - -func (g GenericHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) { - if r.Method != "POST" { - return http.StatusMethodNotAllowed, errors.New("the request had an invalid method.") - } - - body, err := ioutil.ReadAll(r.Body) - if err != nil { - return http.StatusRequestTimeout, errors.New("could not read body from request") - } - - err = g.handlePush(body, repo) - if err != nil { - return http.StatusBadRequest, err - } - - return http.StatusOK, nil -} - -func (g GenericHook) handlePush(body []byte, repo *Repo) error { - var push gPush - - err := json.Unmarshal(body, &push) - if err != nil { - return err - } - - // extract the branch being pushed from the ref string - // and if it matches with our locally tracked one, pull. - refSlice := strings.Split(push.Ref, "/") - if len(refSlice) != 3 { - return errors.New("the push request contained an invalid reference string.") - } - - branch := refSlice[2] - if branch == repo.Branch { - Logger().Print("Received pull notification for the tracking branch, updating...\n") - repo.Pull() - } - - return nil -} diff --git a/vendor/github.com/abiosoft/caddy-git/generic_hook_test.go b/vendor/github.com/abiosoft/caddy-git/generic_hook_test.go deleted file mode 100644 index 7977eb4..0000000 --- a/vendor/github.com/abiosoft/caddy-git/generic_hook_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package git - -import ( - "bytes" - "net/http" - "net/http/httptest" - "testing" -) - -func TestGenericDeployPush(t *testing.T) { - repo := &Repo{Branch: "master", Hook: HookConfig{Url: "/generic_deploy"}} - gHook := GenericHook{} - - for i, test := range []struct { - body string - event string - responseBody string - code int - }{ - {"", "", "", 400}, - {pushGBodyOther, "", "", 200}, - {pushGBodyPartial, "", "", 400}, - {"", "Some Event", "", 400}, - } { - - req, err := http.NewRequest("POST", "/generic_deploy", bytes.NewBuffer([]byte(test.body))) - if err != nil { - t.Fatalf("Test %v: Could not create HTTP request: %v", i, err) - } - - rec := httptest.NewRecorder() - - code, err := gHook.Handle(rec, req, repo) - - if code != test.code { - t.Errorf("Test %d: Expected response code to be %d but was %d", i, test.code, code) - } - - if rec.Body.String() != test.responseBody { - t.Errorf("Test %d: Expected response body to be '%v' but was '%v'", i, test.responseBody, rec.Body.String()) - } - } - -} - -var pushGBodyPartial = ` -{ - "ref": "" -} -` - -var pushGBodyOther = ` -{ - "ref": "refs/heads/some-other-branch" -} -` diff --git a/vendor/github.com/abiosoft/caddy-git/git.go b/vendor/github.com/abiosoft/caddy-git/git.go deleted file mode 100644 index 58b6fba..0000000 --- a/vendor/github.com/abiosoft/caddy-git/git.go +++ /dev/null @@ -1,317 +0,0 @@ -package git - -import ( - "fmt" - "os" - "strings" - "sync" - "time" - - "github.com/abiosoft/caddy-git/gitos" - "github.com/mholt/caddy" -) - -const ( - // Number of retries if git pull fails - numRetries = 3 - - // variable for latest tag - latestTag = "{latest}" -) - -// Git represent multiple repositories. -type Git []*Repo - -// Repo retrieves repository at i or nil if not found. -func (g Git) Repo(i int) *Repo { - if i < len(g) { - return g[i] - } - return nil -} - -// Repo is the structure that holds required information -// of a git repository. -type Repo struct { - URL string // Repository URL - Path string // Directory to pull to - Host string // Git domain host e.g. github.com - Branch string // Git branch - KeyPath string // Path to private ssh key - Interval time.Duration // Interval between pulls - Then []Then // Commands to execute after successful git pull - pulled bool // true if there was a successful pull - lastPull time.Time // time of the last successful pull - lastCommit string // hash for the most recent commit - sync.Mutex - latestTag string // latest tag name - Hook HookConfig // Webhook configuration - -} - -// Pull attempts a git pull. -// It retries at most numRetries times if error occurs -func (r *Repo) Pull() error { - r.Lock() - defer r.Unlock() - - // prevent a pull if the last one was less than 5 seconds ago - if gos.TimeSince(r.lastPull) < 5*time.Second { - return nil - } - - // keep last commit hash for comparison later - lastCommit := r.lastCommit - - var err error - // Attempt to pull at most numRetries times - for i := 0; i < numRetries; i++ { - if err = r.pull(); err == nil { - break - } - Logger().Println(err) - } - - if err != nil { - return err - } - - // check if there are new changes, - // then execute post pull command - if r.lastCommit == lastCommit { - Logger().Println("No new changes.") - return nil - } - return r.execThen() -} - -// pull performs git pull, or git clone if repository does not exist. -func (r *Repo) pull() error { - - // if not pulled, perform clone - if !r.pulled { - return r.clone() - } - - // if latest tag config is set - if r.Branch == latestTag { - return r.checkoutLatestTag() - } - - params := []string{"pull", "origin", r.Branch} - var err error - if err = r.gitCmd(params, r.Path); err == nil { - r.pulled = true - r.lastPull = time.Now() - Logger().Printf("%v pulled.\n", r.URL) - r.lastCommit, err = r.mostRecentCommit() - } - return err -} - -// clone performs git clone. -func (r *Repo) clone() error { - params := []string{"clone", "-b", r.Branch, r.URL, r.Path} - - tagMode := r.Branch == latestTag - if tagMode { - params = []string{"clone", r.URL, r.Path} - } - - var err error - if err = r.gitCmd(params, ""); err == nil { - r.pulled = true - r.lastPull = time.Now() - Logger().Printf("%v pulled.\n", r.URL) - r.lastCommit, err = r.mostRecentCommit() - - // if latest tag config is set. - if tagMode { - return r.checkoutLatestTag() - } - } - - return err -} - -// checkoutLatestTag checks out the latest tag of the repository. -func (r *Repo) checkoutLatestTag() error { - tag, err := r.fetchLatestTag() - if err != nil { - Logger().Println("Error retrieving latest tag.") - return err - } - if tag == "" { - Logger().Println("No tags found for Repo: ", r.URL) - return fmt.Errorf("No tags found for Repo: %v.", r.URL) - } else if tag == r.latestTag { - Logger().Println("No new tags.") - return nil - } - - params := []string{"checkout", "tags/" + tag} - if err = r.gitCmd(params, r.Path); err == nil { - r.latestTag = tag - r.lastCommit, err = r.mostRecentCommit() - Logger().Printf("Tag %v checkout done.\n", tag) - } - return err -} - -// checkoutCommit checks out the specified commitHash. -func (r *Repo) checkoutCommit(commitHash string) error { - var err error - params := []string{"checkout", commitHash} - if err = r.gitCmd(params, r.Path); err == nil { - Logger().Printf("Commit %v checkout done.\n", commitHash) - } - return err -} - -// gitCmd performs a git command. -func (r *Repo) gitCmd(params []string, dir string) error { - // if key is specified, use ssh key - if r.KeyPath != "" { - return r.gitCmdWithKey(params, dir) - } - return runCmd(gitBinary, params, dir) -} - -// gitCmdWithKey is used for private repositories and requires an ssh key. -// Note: currently only limited to Linux and OSX. -func (r *Repo) gitCmdWithKey(params []string, dir string) error { - var gitSSH, script gitos.File - // ensure temporary files deleted after usage - defer func() { - if gitSSH != nil { - gos.Remove(gitSSH.Name()) - } - if script != nil { - gos.Remove(script.Name()) - } - }() - - var err error - // write git.sh script to temp file - gitSSH, err = writeScriptFile(gitWrapperScript()) - if err != nil { - return err - } - - // write git bash script to file - script, err = writeScriptFile(bashScript(gitSSH.Name(), r, params)) - if err != nil { - return err - } - - return runCmd(script.Name(), nil, dir) -} - -// Prepare prepares for a git pull -// and validates the configured directory -func (r *Repo) Prepare() error { - // check if directory exists or is empty - // if not, create directory - fs, err := gos.ReadDir(r.Path) - if err != nil || len(fs) == 0 { - return gos.MkdirAll(r.Path, os.FileMode(0755)) - } - - // validate git repo - isGit := false - for _, f := range fs { - if f.IsDir() && f.Name() == ".git" { - isGit = true - break - } - } - - if isGit { - // check if same repository - var repoURL string - if repoURL, err = r.originURL(); err == nil { - // add .git suffix if missing for adequate comparison. - if !strings.HasSuffix(repoURL, ".git") { - repoURL += ".git" - } - if repoURL == r.URL { - r.pulled = true - return nil - } - } - if err != nil { - return fmt.Errorf("cannot retrieve repo url for %v Error: %v", r.Path, err) - } - return fmt.Errorf("another git repo '%v' exists at %v", repoURL, r.Path) - } - return fmt.Errorf("cannot git clone into %v, directory not empty", r.Path) -} - -// getMostRecentCommit gets the hash of the most recent commit to the -// repository. Useful for checking if changes occur. -func (r *Repo) mostRecentCommit() (string, error) { - command := gitBinary + ` --no-pager log -n 1 --pretty=format:"%H"` - c, args, err := caddy.SplitCommandAndArgs(command) - if err != nil { - return "", err - } - return runCmdOutput(c, args, r.Path) -} - -// getLatestTag retrieves the most recent tag in the repository. -func (r *Repo) fetchLatestTag() (string, error) { - // fetch updates to get latest tag - params := []string{"fetch", "origin", "--tags"} - err := r.gitCmd(params, r.Path) - if err != nil { - return "", err - } - // retrieve latest tag - command := gitBinary + ` describe origin --abbrev=0 --tags` - c, args, err := caddy.SplitCommandAndArgs(command) - if err != nil { - return "", err - } - return runCmdOutput(c, args, r.Path) -} - -// getRepoURL retrieves remote origin url for the git repository at path -func (r *Repo) originURL() (string, error) { - _, err := gos.Stat(r.Path) - if err != nil { - return "", err - } - args := []string{"config", "--get", "remote.origin.url"} - return runCmdOutput(gitBinary, args, r.Path) -} - -// execThen executes r.Then. -// It is trigged after successful git pull -func (r *Repo) execThen() error { - var errs error - for _, command := range r.Then { - err := command.Exec(r.Path) - if err == nil { - Logger().Printf("Command '%v' successful.\n", command.Command()) - } - errs = mergeErrors(errs, err) - } - return errs -} - -func mergeErrors(errs ...error) error { - if len(errs) == 0 { - return nil - } - var err error - for _, e := range errs { - if err == nil { - err = e - continue - } - if e != nil { - err = fmt.Errorf("%v\n%v", err.Error(), e.Error()) - } - } - return err -} diff --git a/vendor/github.com/abiosoft/caddy-git/git_test.go b/vendor/github.com/abiosoft/caddy-git/git_test.go deleted file mode 100644 index 1bcc1ff..0000000 --- a/vendor/github.com/abiosoft/caddy-git/git_test.go +++ /dev/null @@ -1,252 +0,0 @@ -package git - -import ( - "io/ioutil" - "log" - "testing" - "time" - - "github.com/abiosoft/caddy-git/gittest" -) - -// init sets the OS used to fakeOS. -func init() { - SetOS(gittest.FakeOS) -} - -func check(t *testing.T, err error) { - if err != nil { - t.Errorf("Error not expected but found %v", err) - } -} - -func TestInit(t *testing.T) { - err := Init() - check(t, err) -} - -func TestHelpers(t *testing.T) { - f, err := writeScriptFile([]byte("script")) - check(t, err) - var b [6]byte - _, err = f.Read(b[:]) - check(t, err) - if string(b[:]) != "script" { - t.Errorf("Expected script found %v", string(b[:])) - } - - out, err := runCmdOutput(gitBinary, []string{"-version"}, "") - check(t, err) - if out != gittest.CmdOutput { - t.Errorf("Expected %v found %v", gittest.CmdOutput, out) - } - - err = runCmd(gitBinary, []string{"-version"}, "") - check(t, err) - - wScript := gitWrapperScript() - if string(wScript) != expectedWrapperScript { - t.Errorf("Expected %v found %v", expectedWrapperScript, string(wScript)) - } - - f, err = writeScriptFile(wScript) - check(t, err) - - repo := &Repo{Host: "github.com", KeyPath: "~/.key"} - script := string(bashScript(f.Name(), repo, []string{"clone", "git@github.com/repo/user"})) - if script != expectedBashScript { - t.Errorf("Expected %v found %v", expectedBashScript, script) - } -} - -func TestGit(t *testing.T) { - // prepare - repos := []*Repo{ - nil, - &Repo{Path: "gitdir", URL: "success.git"}, - } - for _, r := range repos { - repo := createRepo(r) - err := repo.Prepare() - check(t, err) - } - - // pull with success - logFile := gittest.Open("file") - SetLogger(log.New(logFile, "", 0)) - tests := []struct { - repo *Repo - output string - }{ - { - &Repo{Path: "gitdir", URL: "git@github.com:user/repo.git", KeyPath: "~/.key", Then: []Then{NewThen("echo", "Hello")}}, - `git@github.com:user/repo.git pulled. -Command 'echo Hello' successful. -`, - }, - { - &Repo{Path: "gitdir", URL: "https://github.com/user/repo.git", Then: []Then{NewThen("echo", "Hello")}}, - `https://github.com/user/repo.git pulled. -Command 'echo Hello' successful. -`, - }, - { - &Repo{URL: "git@github.com:user/repo"}, - `git@github.com:user/repo pulled. -`, - }, - } - - for i, test := range tests { - gittest.CmdOutput = test.repo.URL - - test.repo = createRepo(test.repo) - - err := test.repo.Prepare() - check(t, err) - - err = test.repo.Pull() - check(t, err) - - out, err := ioutil.ReadAll(logFile) - check(t, err) - if test.output != string(out) { - t.Errorf("Pull with Success %v: Expected %v found %v", i, test.output, string(out)) - } - } - - // pull with error - repos = []*Repo{ - &Repo{Path: "gitdir", URL: "http://github.com:u/repo.git"}, - &Repo{Path: "gitdir", URL: "https://github.com/user/repo.git", Then: []Then{NewThen("echo", "Hello")}}, - &Repo{Path: "gitdir"}, - &Repo{Path: "gitdir", KeyPath: ".key"}, - } - - gittest.CmdOutput = "git@github.com:u1/repo.git" - for i, repo := range repos { - repo = createRepo(repo) - - err := repo.Prepare() - if err == nil { - t.Errorf("Pull with Error %v: Error expected but not found %v", i, err) - continue - } - - expected := "another git repo 'git@github.com:u1/repo.git' exists at gitdir" - if expected != err.Error() { - t.Errorf("Pull with Error %v: Expected %v found %v", i, expected, err.Error()) - } - } - - // timeout checks - timeoutTests := []struct { - repo *Repo - shouldPull bool - }{ - {&Repo{Interval: time.Millisecond * 4900}, false}, - {&Repo{Interval: time.Millisecond * 1}, false}, - {&Repo{Interval: time.Second * 5}, true}, - {&Repo{Interval: time.Second * 10}, true}, - } - - for i, r := range timeoutTests { - r.repo = createRepo(r.repo) - - err := r.repo.Prepare() - check(t, err) - err = r.repo.Pull() - check(t, err) - - before := r.repo.lastPull - - gittest.Sleep(r.repo.Interval) - - err = r.repo.Pull() - after := r.repo.lastPull - check(t, err) - - expected := after.After(before) - if expected != r.shouldPull { - t.Errorf("Pull with Error %v: Expected %v found %v", i, expected, r.shouldPull) - } - } - -} - -func createRepo(r *Repo) *Repo { - repo := &Repo{ - URL: "git@github.com/user/test", - Path: ".", - Host: "github.com", - Branch: "master", - Interval: time.Second * 60, - } - if r == nil { - return repo - } - if r.Branch != "" { - repo.Branch = r.Branch - } - if r.Host != "" { - repo.Branch = r.Branch - } - if r.Interval != 0 { - repo.Interval = r.Interval - } - if r.KeyPath != "" { - repo.KeyPath = r.KeyPath - } - if r.Path != "" { - repo.Path = r.Path - } - if r.Then != nil { - repo.Then = r.Then - } - if r.URL != "" { - repo.URL = r.URL - } - - return repo -} - -var expectedBashScript = `#!/bin/bash - -mkdir -p ~/.ssh; -touch ~/.ssh/known_hosts; -ssh-keyscan -t rsa,dsa github.com 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts; -cat ~/.ssh/tmp_hosts >> ~/.ssh/known_hosts; -` + gittest.TempFileName + ` -i ~/.key clone git@github.com/repo/user; -` - -var expectedWrapperScript = `#!/bin/bash - -# The MIT License (MIT) -# Copyright (c) 2013 Alvin Abad - -if [ $# -eq 0 ]; then - echo "Git wrapper script that can specify an ssh-key file -Usage: - git.sh -i ssh-key-file git-command - " - exit 1 -fi - -# remove temporary file on exit -trap 'rm -f /tmp/.git_ssh.$$' 0 - -if [ "$1" = "-i" ]; then - SSH_KEY=$2; shift; shift - echo -e "#!/bin/bash \n \ - ssh -i $SSH_KEY \$@" > /tmp/.git_ssh.$$ - chmod +x /tmp/.git_ssh.$$ - export GIT_SSH=/tmp/.git_ssh.$$ -fi - -# in case the git command is repeated -[ "$1" = "git" ] && shift - -# Run the git command -/usr/bin/git "$@" - -` diff --git a/vendor/github.com/abiosoft/caddy-git/github_hook.go b/vendor/github.com/abiosoft/caddy-git/github_hook.go deleted file mode 100644 index cee2370..0000000 --- a/vendor/github.com/abiosoft/caddy-git/github_hook.go +++ /dev/null @@ -1,147 +0,0 @@ -package git - -import ( - "crypto/hmac" - "crypto/sha1" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "net/http" - "strings" -) - -type GithubHook struct{} - -type ghRelease struct { - Action string `json:"action"` - Release struct { - TagName string `json:"tag_name"` - Name interface{} `json:"name"` - } `json:"release"` -} - -type ghPush struct { - Ref string `json:"ref"` -} - -func (g GithubHook) DoesHandle(h http.Header) bool { - userAgent := h.Get("User-Agent") - - // GitHub always uses a user-agent like "GitHub-Hookshot/" - if userAgent != "" && strings.HasPrefix(userAgent, "GitHub-Hookshot") { - return true - } - return false -} - -func (g GithubHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) { - if r.Method != "POST" { - return http.StatusMethodNotAllowed, errors.New("the request had an invalid method.") - } - - // read full body - required for signature - body, err := ioutil.ReadAll(r.Body) - - err = g.handleSignature(r, body, repo.Hook.Secret) - if err != nil { - return http.StatusBadRequest, err - } - - event := r.Header.Get("X-Github-Event") - if event == "" { - return http.StatusBadRequest, errors.New("the 'X-Github-Event' header is required but was missing.") - } - - switch event { - case "ping": - w.Write([]byte("pong")) - case "push": - err = g.handlePush(body, repo) - if !hookIgnored(err) && err != nil { - return http.StatusBadRequest, err - } - case "release": - err = g.handleRelease(body, repo) - if err != nil { - return http.StatusBadRequest, err - } - - // return 400 if we do not handle the event type. - // This is to visually show the user a configuration error in the GH ui. - default: - return http.StatusBadRequest, nil - } - - return http.StatusOK, err -} - -// Check for an optional signature in the request -// if it is signed, verify the signature. -func (g GithubHook) handleSignature(r *http.Request, body []byte, secret string) error { - signature := r.Header.Get("X-Hub-Signature") - if signature != "" { - if secret == "" { - Logger().Print("Unable to verify request signature. Secret not set in caddyfile!\n") - } else { - mac := hmac.New(sha1.New, []byte(secret)) - mac.Write(body) - expectedMac := hex.EncodeToString(mac.Sum(nil)) - - if signature[5:] != expectedMac { - return errors.New("could not verify request signature. The signature is invalid!") - } - } - } - - return nil -} - -func (g GithubHook) handlePush(body []byte, repo *Repo) error { - var push ghPush - - err := json.Unmarshal(body, &push) - if err != nil { - return err - } - - // extract the branch being pushed from the ref string - // and if it matches with our locally tracked one, pull. - refSlice := strings.Split(push.Ref, "/") - if len(refSlice) != 3 { - return errors.New("the push request contained an invalid reference string.") - } - - branch := refSlice[2] - - if branch != repo.Branch { - return hookIgnoredError{hookType: hookName(g), err: fmt.Errorf("found different branch %v", branch)} - } - - Logger().Println("Received pull notification for the tracking branch, updating...") - repo.Pull() - return nil -} - -func (g GithubHook) handleRelease(body []byte, repo *Repo) error { - var release ghRelease - - err := json.Unmarshal(body, &release) - if err != nil { - return err - } - - if release.Release.TagName == "" { - return errors.New("the release request contained an invalid TagName.") - } - - Logger().Printf("Received new release '%s'. -> Updating local repository to this release.\n", release.Release.Name) - - // Update the local branch to the release tag name - // this will pull the release tag. - repo.Branch = release.Release.TagName - repo.Pull() - - return nil -} diff --git a/vendor/github.com/abiosoft/caddy-git/github_hook_test.go b/vendor/github.com/abiosoft/caddy-git/github_hook_test.go deleted file mode 100644 index 96813c3..0000000 --- a/vendor/github.com/abiosoft/caddy-git/github_hook_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package git - -import ( - "bytes" - "net/http" - "net/http/httptest" - "testing" -) - -func TestGithubDeployPush(t *testing.T) { - repo := &Repo{Branch: "master", Hook: HookConfig{ Url: "/github_deploy", Secret: "supersecret"} } - ghHook := GithubHook{} - - for i, test := range []struct { - body string - event string - responseBody string - code int - }{ - {"", "", "", 400}, - {"", "push", "", 400}, - {pushBodyOther, "push", "", 200}, - {pushBodyPartial, "push", "", 400}, - {"", "release", "", 400}, - {"", "ping", "pong", 200}, - } { - - req, err := http.NewRequest("POST", "/github_deploy", bytes.NewBuffer([]byte(test.body))) - if err != nil { - t.Fatalf("Test %v: Could not create HTTP request: %v", i, err) - } - - if test.event != "" { - req.Header.Add("X-Github-Event", test.event) - } - - rec := httptest.NewRecorder() - - code, err := ghHook.Handle(rec, req, repo) - - if code != test.code { - t.Errorf("Test %d: Expected response code to be %d but was %d", i, test.code, code) - } - - if rec.Body.String() != test.responseBody { - t.Errorf("Test %d: Expected response body to be '%v' but was '%v'", i, test.responseBody, rec.Body.String()) - } - } - -} - -var pushBodyPartial = ` -{ - "ref": "" -} -` - -var pushBodyOther = ` -{ - "ref": "refs/heads/some-other-branch" -} -` diff --git a/vendor/github.com/abiosoft/caddy-git/gitlab_hook.go b/vendor/github.com/abiosoft/caddy-git/gitlab_hook.go deleted file mode 100644 index 5b8ba33..0000000 --- a/vendor/github.com/abiosoft/caddy-git/gitlab_hook.go +++ /dev/null @@ -1,82 +0,0 @@ -package git - -import ( - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "net/http" - "strings" -) - -type GitlabHook struct{} - -type glPush struct { - Ref string `json:"ref"` -} - -func (g GitlabHook) DoesHandle(h http.Header) bool { - event := h.Get("X-Gitlab-Event") - - // for Gitlab you can only use X-Gitlab-Event header to test if you could handle the request - if event != "" { - return true - } - return false -} - -func (g GitlabHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) { - if r.Method != "POST" { - return http.StatusMethodNotAllowed, errors.New("the request had an invalid method.") - } - - body, err := ioutil.ReadAll(r.Body) - if err != nil { - return http.StatusRequestTimeout, errors.New("could not read body from request") - } - - event := r.Header.Get("X-Gitlab-Event") - if event == "" { - return http.StatusBadRequest, errors.New("the 'X-Gitlab-Event' header is required but was missing.") - } - - switch event { - case "Push Hook": - err = g.handlePush(body, repo) - if !hookIgnored(err) && err != nil { - return http.StatusBadRequest, err - } - - // return 400 if we do not handle the event type. - default: - return http.StatusBadRequest, nil - } - - return http.StatusOK, err -} - -func (g GitlabHook) handlePush(body []byte, repo *Repo) error { - var push glPush - - err := json.Unmarshal(body, &push) - if err != nil { - return err - } - - // extract the branch being pushed from the ref string - // and if it matches with our locally tracked one, pull. - refSlice := strings.Split(push.Ref, "/") - if len(refSlice) != 3 { - return errors.New("the push request contained an invalid reference string.") - } - - branch := refSlice[2] - if branch != repo.Branch { - return hookIgnoredError{hookType: hookName(g), err: fmt.Errorf("found different branch %v", branch)} - } - - Logger().Print("Received pull notification for the tracking branch, updating...\n") - repo.Pull() - - return nil -} diff --git a/vendor/github.com/abiosoft/caddy-git/gitlab_hook_test.go b/vendor/github.com/abiosoft/caddy-git/gitlab_hook_test.go deleted file mode 100644 index 5401829..0000000 --- a/vendor/github.com/abiosoft/caddy-git/gitlab_hook_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package git - -import ( - "bytes" - "net/http" - "net/http/httptest" - "testing" -) - -func TestGitlabDeployPush(t *testing.T) { - repo := &Repo{Branch: "master", Hook: HookConfig{Url: "/gitlab_deploy"}} - glHook := GitlabHook{} - - for i, test := range []struct { - body string - event string - responseBody string - code int - }{ - {"", "", "", 400}, - {"", "Push Hook", "", 400}, - {pushGLBodyOther, "Push Hook", "", 200}, - {pushGLBodyPartial, "Push Hook", "", 400}, - {"", "Some other Event", "", 400}, - } { - - req, err := http.NewRequest("POST", "/gitlab_deploy", bytes.NewBuffer([]byte(test.body))) - if err != nil { - t.Fatalf("Test %v: Could not create HTTP request: %v", i, err) - } - - if test.event != "" { - req.Header.Add("X-Gitlab-Event", test.event) - } - - rec := httptest.NewRecorder() - - code, err := glHook.Handle(rec, req, repo) - - if code != test.code { - t.Errorf("Test %d: Expected response code to be %d but was %d", i, test.code, code) - } - - if rec.Body.String() != test.responseBody { - t.Errorf("Test %d: Expected response body to be '%v' but was '%v'", i, test.responseBody, rec.Body.String()) - } - } - -} - -var pushGLBodyPartial = ` -{ - "ref": "" -} -` - -var pushGLBodyOther = ` -{ - "ref": "refs/heads/some-other-branch" -} -` diff --git a/vendor/github.com/abiosoft/caddy-git/gitos/gitos.go b/vendor/github.com/abiosoft/caddy-git/gitos/gitos.go deleted file mode 100644 index 158aff5..0000000 --- a/vendor/github.com/abiosoft/caddy-git/gitos/gitos.go +++ /dev/null @@ -1,210 +0,0 @@ -package gitos - -import ( - "io" - "io/ioutil" - "os" - "os/exec" - "time" -) - -// File is an abstraction for file (os.File). -type File interface { - // Name returns the name of the file - Name() string - - // Stat returns the FileInfo structure describing file. - Stat() (os.FileInfo, error) - - // Close closes the File, rendering it unusable for I/O. - Close() error - - // Chmod changes the mode of the file. - Chmod(os.FileMode) error - - // Read reads up to len(b) bytes from the File. It returns the number of - // bytes read and an error, if any. - Read([]byte) (int, error) - - // Write writes len(b) bytes to the File. It returns the number of bytes - // written and an error, if any. - Write([]byte) (int, error) -} - -// Cmd is an abstraction for external commands (os.Cmd). -type Cmd interface { - // Run starts the specified command and waits for it to complete. - Run() error - - // Start starts the specified command but does not wait for it to complete. - Start() error - - // Wait waits for the command to exit. It must have been started by Start. - Wait() error - - // Output runs the command and returns its standard output. - Output() ([]byte, error) - - // Dir sets the working directory of the command. - Dir(string) - - // Stdin sets the process's standard input. - Stdin(io.Reader) - - // Stdout sets the process's standard output. - Stdout(io.Writer) - - // Stderr sets the process's standard output. - Stderr(io.Writer) - - // Process is the underlying process, once started. - Process() *os.Process -} - -// gitCmd represents external commands executed by git. -type gitCmd struct { - *exec.Cmd -} - -// Dir sets the working directory of the command. -func (g *gitCmd) Dir(dir string) { - g.Cmd.Dir = dir -} - -// Stdin sets the process's standard input. -func (g *gitCmd) Stdin(stdin io.Reader) { - g.Cmd.Stdin = stdin -} - -// Stdout sets the process's standard output. -func (g *gitCmd) Stdout(stdout io.Writer) { - g.Cmd.Stdout = stdout -} - -// Stderr sets the process's standard output. -func (g *gitCmd) Stderr(stderr io.Writer) { - g.Cmd.Stderr = stderr -} - -func (g *gitCmd) Process() *os.Process { - return g.Cmd.Process -} - -// OS is an abstraction for required OS level functions. -type OS interface { - // Command returns the Cmd to execute the named program with the - // given arguments. - Command(string, ...string) Cmd - - // Mkdir creates a new directory with the specified name and permission - // bits. - Mkdir(string, os.FileMode) error - - // MkdirAll creates a directory named path, along with any necessary - // parents. - MkdirAll(string, os.FileMode) error - - // Stat returns a FileInfo describing the named file. - Stat(string) (os.FileInfo, error) - - // Remove removes the named file or directory. - Remove(string) error - - // ReadDir reads the directory named by dirname and returns a list of - // directory entries. - ReadDir(string) ([]os.FileInfo, error) - - // LookPath searches for an executable binary named file in the directories - // named by the PATH environment variable. - LookPath(string) (string, error) - - // TempFile creates a new temporary file in the directory dir with a name - // beginning with prefix, opens the file for reading and writing, and - // returns the resulting File. - TempFile(string, string) (File, error) - - // Sleep pauses the current goroutine for at least the duration d. A - // negative or zero duration causes Sleep to return immediately. - Sleep(time.Duration) - - // NewTicker returns a new Ticker containing a channel that will send the - // time with a period specified by the argument. - NewTicker(time.Duration) Ticker - - // TimeSince returns the time elapsed since the argument. - TimeSince(time.Time) time.Duration -} - -// Ticker is an abstraction for Ticker (time.Ticker) -type Ticker interface { - C() <-chan time.Time - Stop() -} - -// GitTicker is the implementation of Ticker for git. -type GitTicker struct { - *time.Ticker -} - -// C returns the channel on which the ticks are delivered.s -func (g *GitTicker) C() <-chan time.Time { - return g.Ticker.C -} - -// GitOS is the implementation of OS for git. -type GitOS struct{} - -// Mkdir calls os.Mkdir. -func (g GitOS) Mkdir(name string, perm os.FileMode) error { - return os.Mkdir(name, perm) -} - -// MkdirAll calls os.MkdirAll. -func (g GitOS) MkdirAll(path string, perm os.FileMode) error { - return os.MkdirAll(path, perm) -} - -// Stat calls os.Stat. -func (g GitOS) Stat(name string) (os.FileInfo, error) { - return os.Stat(name) -} - -// Remove calls os.Remove. -func (g GitOS) Remove(name string) error { - return os.Remove(name) -} - -// LookPath calls exec.LookPath. -func (g GitOS) LookPath(file string) (string, error) { - return exec.LookPath(file) -} - -// TempFile calls ioutil.TempFile. -func (g GitOS) TempFile(dir, prefix string) (File, error) { - return ioutil.TempFile(dir, prefix) -} - -// ReadDir calls ioutil.ReadDir. -func (g GitOS) ReadDir(dirname string) ([]os.FileInfo, error) { - return ioutil.ReadDir(dirname) -} - -// Command calls exec.Command. -func (g GitOS) Command(name string, args ...string) Cmd { - return &gitCmd{exec.Command(name, args...)} -} - -// Sleep calls time.Sleep. -func (g GitOS) Sleep(d time.Duration) { - time.Sleep(d) -} - -// New Ticker calls time.NewTicker. -func (g GitOS) NewTicker(d time.Duration) Ticker { - return &GitTicker{time.NewTicker(d)} -} - -// TimeSince calls time.Since -func (g GitOS) TimeSince(t time.Time) time.Duration { - return time.Since(t) -} diff --git a/vendor/github.com/abiosoft/caddy-git/gittest/gittest.go b/vendor/github.com/abiosoft/caddy-git/gittest/gittest.go deleted file mode 100644 index 9073c41..0000000 --- a/vendor/github.com/abiosoft/caddy-git/gittest/gittest.go +++ /dev/null @@ -1,210 +0,0 @@ -// Package gittest is a test package for the git middleware. -// It implements a mock gitos.OS, gitos.Cmd and gitos.File. -package gittest - -import ( - "io" - "log" - "os" - "sync" - "time" - - "github.com/abiosoft/caddy-git/gitos" -) - -// FakeOS implements a mock gitos.OS, gitos.Cmd and gitos.File. -var FakeOS = fakeOS{} - -// CmdOutput is the output of any call to the mocked gitos.Cmd's Output(). -var CmdOutput = "success" - -// TempFileName is the name of any file returned by mocked gitos.OS's TempFile(). -var TempFileName = "tempfile" - -// TimeSpeed is how faster the mocked gitos.Ticker and gitos.Sleep should run. -var TimeSpeed = 5 - -// dirs mocks a fake git dir if filename is "gitdir". -var dirs = map[string][]os.FileInfo{ - "gitdir": { - fakeInfo{name: ".git", dir: true}, - }, -} - -// Open creates a new mock gitos.File. -func Open(name string) gitos.File { - return &fakeFile{name: name} -} - -// Sleep calls fake time.Sleep -func Sleep(d time.Duration) { - FakeOS.Sleep(d) -} - -// NewLogger creates a logger that logs to f -func NewLogger(f gitos.File) *log.Logger { - return log.New(f, "", 0) -} - -// fakeFile is a mock gitos.File. -type fakeFile struct { - name string - dir bool - content []byte - info fakeInfo - sync.Mutex -} - -func (f fakeFile) Name() string { - return f.name -} - -func (f fakeFile) Stat() (os.FileInfo, error) { - return fakeInfo{name: f.name}, nil -} - -func (f fakeFile) Close() error { - return nil -} - -func (f fakeFile) Chmod(mode os.FileMode) error { - f.info.mode = mode - return nil -} - -func (f *fakeFile) Read(b []byte) (int, error) { - f.Lock() - defer f.Unlock() - if len(f.content) == 0 { - return 0, io.EOF - } - n := copy(b, f.content) - f.content = f.content[n:] - return n, nil -} - -func (f *fakeFile) Write(b []byte) (int, error) { - f.Lock() - defer f.Unlock() - f.content = append(f.content, b...) - return len(b), nil -} - -// fakeCmd is a mock gitos.Cmd. -type fakeCmd struct{} - -func (f fakeCmd) Run() error { - return nil -} - -func (f fakeCmd) Start() error { - return nil -} - -func (f fakeCmd) Wait() error { - return nil -} - -func (f fakeCmd) Output() ([]byte, error) { - return []byte(CmdOutput), nil -} - -func (f fakeCmd) Dir(dir string) {} - -func (f fakeCmd) Stdin(stdin io.Reader) {} - -func (f fakeCmd) Stdout(stdout io.Writer) {} - -func (f fakeCmd) Stderr(stderr io.Writer) {} - -func (f fakeCmd) Process() *os.Process { return nil } - -// fakeInfo is a mock os.FileInfo. -type fakeInfo struct { - name string - dir bool - mode os.FileMode -} - -func (f fakeInfo) Name() string { - return f.name -} - -func (f fakeInfo) Size() int64 { - return 1024 -} - -func (f fakeInfo) Mode() os.FileMode { - return f.mode -} - -func (f fakeInfo) ModTime() time.Time { - return time.Now().Truncate(time.Hour) -} - -func (f fakeInfo) IsDir() bool { - return f.dir -} - -func (f fakeInfo) Sys() interface{} { - return nil -} - -// fakeTicker is a mock gitos.Ticker -type fakeTicker struct { - *time.Ticker -} - -func (f fakeTicker) C() <-chan time.Time { - return f.Ticker.C -} - -// fakeOS is a mock gitos.OS. -type fakeOS struct{} - -func (f fakeOS) Mkdir(name string, perm os.FileMode) error { - return nil -} - -func (f fakeOS) MkdirAll(path string, perm os.FileMode) error { - return nil -} - -func (f fakeOS) Stat(name string) (os.FileInfo, error) { - return fakeInfo{name: name}, nil -} - -func (f fakeOS) Remove(name string) error { - return nil -} - -func (f fakeOS) LookPath(file string) (string, error) { - return "/usr/bin/" + file, nil -} - -func (f fakeOS) TempFile(dir, prefix string) (gitos.File, error) { - return &fakeFile{name: TempFileName, info: fakeInfo{name: TempFileName}}, nil -} - -func (f fakeOS) ReadDir(dirname string) ([]os.FileInfo, error) { - if f, ok := dirs[dirname]; ok { - return f, nil - } - return nil, nil -} - -func (f fakeOS) Command(name string, args ...string) gitos.Cmd { - return fakeCmd{} -} - -func (f fakeOS) Sleep(d time.Duration) { - time.Sleep(d / time.Duration(TimeSpeed)) -} - -func (f fakeOS) NewTicker(d time.Duration) gitos.Ticker { - return &fakeTicker{time.NewTicker(d / time.Duration(TimeSpeed))} -} - -func (f fakeOS) TimeSince(t time.Time) time.Duration { - return time.Since(t) * time.Duration(TimeSpeed) -} diff --git a/vendor/github.com/abiosoft/caddy-git/gogs_hook.go b/vendor/github.com/abiosoft/caddy-git/gogs_hook.go deleted file mode 100644 index 0d3452e..0000000 --- a/vendor/github.com/abiosoft/caddy-git/gogs_hook.go +++ /dev/null @@ -1,87 +0,0 @@ -package git - -import ( - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "net/http" - "strings" -) - -type GogsHook struct{} - -type gsPush struct { - Ref string `json:"ref"` -} - -func (g GogsHook) DoesHandle(h http.Header) bool { - event := h.Get("X-Gogs-Event") - - // for Gogs you can only use X-Gogs-Event header to test if you could handle the request - if event != "" { - return true - } - return false -} - -func (g GogsHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) { - if r.Method != "POST" { - return http.StatusMethodNotAllowed, errors.New("the request had an invalid method.") - } - - // read full body - required for signature - body, err := ioutil.ReadAll(r.Body) - - if err != nil { - return http.StatusBadRequest, err - } - - event := r.Header.Get("X-Gogs-Event") - if event == "" { - return http.StatusBadRequest, errors.New("the 'X-Gogs-Event' header is required but was missing.") - } - - switch event { - case "ping": - w.Write([]byte("pong")) - case "push": - err = g.handlePush(body, repo) - if !hookIgnored(err) && err != nil { - return http.StatusBadRequest, err - } - - // return 400 if we do not handle the event type. - // This is to visually show the user a configuration error in the Gogs ui. - default: - return http.StatusBadRequest, nil - } - - return http.StatusOK, err -} - -func (g GogsHook) handlePush(body []byte, repo *Repo) error { - var push gsPush - - err := json.Unmarshal(body, &push) - if err != nil { - return err - } - - // extract the branch being pushed from the ref string - // and if it matches with our locally tracked one, pull. - refSlice := strings.Split(push.Ref, "/") - if len(refSlice) != 3 { - return errors.New("the push request contained an invalid reference string.") - } - - branch := refSlice[2] - if branch != repo.Branch { - return hookIgnoredError{hookType: hookName(g), err: fmt.Errorf("found different branch %v", branch)} - } - - Logger().Print("Received pull notification for the tracking branch, updating...\n") - repo.Pull() - - return nil -} diff --git a/vendor/github.com/abiosoft/caddy-git/gogs_hook_test.go b/vendor/github.com/abiosoft/caddy-git/gogs_hook_test.go deleted file mode 100644 index 8c8c528..0000000 --- a/vendor/github.com/abiosoft/caddy-git/gogs_hook_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package git - -import ( - "bytes" - "net/http" - "net/http/httptest" - "testing" -) - -func TestGogsDeployPush(t *testing.T) { - repo := &Repo{Branch: "master", Hook: HookConfig{Url: "/gogs_deploy"}} - gsHook := GogsHook{} - - for i, test := range []struct { - body string - event string - responseBody string - code int - }{ - {"", "", "", 400}, - {"", "push", "", 400}, - {pushGSBodyOther, "push", "", 200}, - {pushGSBodyPartial, "push", "", 400}, - {"", "ping", "pong", 200}, - } { - - req, err := http.NewRequest("POST", "/gogs_deploy", bytes.NewBuffer([]byte(test.body))) - if err != nil { - t.Fatalf("Test %v: Could not create HTTP request: %v", i, err) - } - - if test.event != "" { - req.Header.Add("X-Gogs-Event", test.event) - } - - rec := httptest.NewRecorder() - - code, err := gsHook.Handle(rec, req, repo) - - if code != test.code { - t.Errorf("Test %d: Expected response code to be %d but was %d", i, test.code, code) - } - - if rec.Body.String() != test.responseBody { - t.Errorf("Test %d: Expected response body to be '%v' but was '%v'", i, test.responseBody, rec.Body.String()) - } - } - -} - -var pushGSBodyPartial = ` -{ - "ref": "" -} -` - -var pushGSBodyOther = ` -{ - "ref": "refs/heads/some-other-branch" -} -` diff --git a/vendor/github.com/abiosoft/caddy-git/logger.go b/vendor/github.com/abiosoft/caddy-git/logger.go deleted file mode 100644 index 2500239..0000000 --- a/vendor/github.com/abiosoft/caddy-git/logger.go +++ /dev/null @@ -1,38 +0,0 @@ -package git - -import ( - "log" - "os" - "sync" -) - -// logger is used to log errors -var logger = &gitLogger{l: log.New(os.Stderr, "", log.LstdFlags)} - -// gitLogger wraps log.Logger with mutex for thread safety. -type gitLogger struct { - l *log.Logger - sync.RWMutex -} - -func (g *gitLogger) logger() *log.Logger { - g.RLock() - defer g.RUnlock() - return g.l -} - -func (g *gitLogger) setLogger(l *log.Logger) { - g.Lock() - g.l = l - g.Unlock() -} - -// Logger gets the currently available logger -func Logger() *log.Logger { - return logger.logger() -} - -// SetLogger sets the current logger to l -func SetLogger(l *log.Logger) { - logger.setLogger(l) -} diff --git a/vendor/github.com/abiosoft/caddy-git/os.go b/vendor/github.com/abiosoft/caddy-git/os.go deleted file mode 100644 index 3b42dc7..0000000 --- a/vendor/github.com/abiosoft/caddy-git/os.go +++ /dev/null @@ -1,12 +0,0 @@ -package git - -import "github.com/abiosoft/caddy-git/gitos" - -// gos is the OS used by git. -var gos gitos.OS = gitos.GitOS{} - -// SetOS sets the OS to be used. Intended to be used for tests -// to abstract OS level git actions. -func SetOS(os gitos.OS) { - gos = os -} diff --git a/vendor/github.com/abiosoft/caddy-git/scripts.go b/vendor/github.com/abiosoft/caddy-git/scripts.go deleted file mode 100644 index 0016283..0000000 --- a/vendor/github.com/abiosoft/caddy-git/scripts.go +++ /dev/null @@ -1,116 +0,0 @@ -package git - -import ( - "fmt" - "os" - "strings" - "sync" - - "github.com/abiosoft/caddy-git/gitos" -) - -var ( - // gitBinary holds the absolute path to git executable - gitBinary string - - // shell holds the shell to be used. Either sh or bash. - shell string - - // initMutex prevents parallel attempt to validate - // git requirements. - initMutex = sync.Mutex{} -) - -// Init validates git installation, locates the git executable -// binary in PATH and check for available shell to use. -func Init() error { - // prevent concurrent call - initMutex.Lock() - defer initMutex.Unlock() - - // if validation has been done before and binary located in - // PATH, return. - if gitBinary != "" { - return nil - } - - // locate git binary in path - var err error - if gitBinary, err = gos.LookPath("git"); err != nil { - return fmt.Errorf("git middleware requires git installed. Cannot find git binary in PATH") - } - - // locate bash in PATH. If not found, fallback to sh. - // If neither is found, return error. - shell = "bash" - if _, err = gos.LookPath("bash"); err != nil { - shell = "sh" - if _, err = gos.LookPath("sh"); err != nil { - return fmt.Errorf("git middleware requires either bash or sh.") - } - } - return nil -} - -// writeScriptFile writes content to a temporary file. -// It changes the temporary file mode to executable and -// closes it to prepare it for execution. -func writeScriptFile(content []byte) (file gitos.File, err error) { - if file, err = gos.TempFile("", "caddy"); err != nil { - return nil, err - } - if _, err = file.Write(content); err != nil { - return nil, err - } - if err = file.Chmod(os.FileMode(0755)); err != nil { - return nil, err - } - return file, file.Close() -} - -// gitWrapperScript forms content for git.sh script -func gitWrapperScript() []byte { - return []byte(fmt.Sprintf(`#!/bin/%v - -# The MIT License (MIT) -# Copyright (c) 2013 Alvin Abad - -if [ $# -eq 0 ]; then - echo "Git wrapper script that can specify an ssh-key file -Usage: - git.sh -i ssh-key-file git-command - " - exit 1 -fi - -# remove temporary file on exit -trap 'rm -f /tmp/.git_ssh.$$' 0 - -if [ "$1" = "-i" ]; then - SSH_KEY=$2; shift; shift - echo -e "#!/bin/%v \n \ - ssh -i $SSH_KEY \$@" > /tmp/.git_ssh.$$ - chmod +x /tmp/.git_ssh.$$ - export GIT_SSH=/tmp/.git_ssh.$$ -fi - -# in case the git command is repeated -[ "$1" = "git" ] && shift - -# Run the git command -%v "$@" - -`, shell, shell, gitBinary)) -} - -// bashScript forms content of bash script to clone or update a repo using ssh -func bashScript(gitShPath string, repo *Repo, params []string) []byte { - return []byte(fmt.Sprintf(`#!/bin/%v - -mkdir -p ~/.ssh; -touch ~/.ssh/known_hosts; -ssh-keyscan -t rsa,dsa %v 2>&1 | sort -u - ~/.ssh/known_hosts > ~/.ssh/tmp_hosts; -cat ~/.ssh/tmp_hosts >> ~/.ssh/known_hosts; -%v -i %v %v; -`, shell, repo.Host, gitShPath, repo.KeyPath, strings.Join(params, " "))) -} diff --git a/vendor/github.com/abiosoft/caddy-git/service.go b/vendor/github.com/abiosoft/caddy-git/service.go deleted file mode 100644 index dd7b439..0000000 --- a/vendor/github.com/abiosoft/caddy-git/service.go +++ /dev/null @@ -1,90 +0,0 @@ -package git - -import ( - "sync" - - "github.com/abiosoft/caddy-git/gitos" -) - -var ( - // Services holds all git pulling services and provides the function to - // stop them. - Services = &services{} -) - -// repoService is the service that runs in background and periodically -// pull from the repository. -type repoService struct { - repo *Repo - ticker gitos.Ticker // ticker to tick at intervals - halt chan struct{} // channel to notify service to halt and stop pulling. -} - -// Start starts a new background service to pull periodically. -func Start(repo *Repo) { - service := &repoService{ - repo, - gos.NewTicker(repo.Interval), - make(chan struct{}), - } - go func(s *repoService) { - for { - select { - case <-s.ticker.C(): - err := repo.Pull() - if err != nil { - Logger().Println(err) - } - case <-s.halt: - s.ticker.Stop() - return - } - } - }(service) - - // add to services to make it stoppable - Services.add(service) -} - -// services stores all repoServices -type services struct { - services []*repoService - sync.Mutex -} - -// add adds a new service to list of services. -func (s *services) add(r *repoService) { - s.Lock() - defer s.Unlock() - - s.services = append(s.services, r) -} - -// Stop stops at most `limit` running services pulling from git repo at -// repoURL. It waits until the service is terminated before returning. -// If limit is less than zero, it is ignored. -// TODO find better ways to identify repos -func (s *services) Stop(repoURL string, limit int) { - s.Lock() - defer s.Unlock() - - // locate repos - for i, j := 0, 0; i < len(s.services) && ((limit >= 0 && j < limit) || limit < 0); i++ { - service := s.services[i] - if service.repo.URL == repoURL { - // send halt signal - service.halt <- struct{}{} - s.services[i] = nil - j++ - } - } - - // remove them from repos list - services := s.services[:0] - for _, s := range s.services { - if s != nil { - services = append(services, s) - } - } - s.services = services -} diff --git a/vendor/github.com/abiosoft/caddy-git/service_test.go b/vendor/github.com/abiosoft/caddy-git/service_test.go deleted file mode 100644 index 7b6f520..0000000 --- a/vendor/github.com/abiosoft/caddy-git/service_test.go +++ /dev/null @@ -1,67 +0,0 @@ -package git - -import ( - "fmt" - "testing" - "time" - - "github.com/abiosoft/caddy-git/gittest" -) - -func init() { - SetOS(gittest.FakeOS) -} - -func TestServices(t *testing.T) { - repo := &Repo{URL: "git@github.com", Interval: time.Second} - - Start(repo) - if len(Services.services) != 1 { - t.Errorf("Expected 1 service, found %v", len(Services.services)) - } - - Services.Stop(repo.URL, 1) - if len(Services.services) != 0 { - t.Errorf("Expected 1 service, found %v", len(Services.services)) - } - - repos := make([]*Repo, 5) - for i := 0; i < 5; i++ { - repos[i] = &Repo{URL: fmt.Sprintf("test%v", i), Interval: time.Second * 2} - Start(repos[i]) - if len(Services.services) != i+1 { - t.Errorf("Expected %v service(s), found %v", i+1, len(Services.services)) - } - } - - gos.Sleep(time.Second * 5) - Services.Stop(repos[0].URL, 1) - if len(Services.services) != 4 { - t.Errorf("Expected %v service(s), found %v", 4, len(Services.services)) - } - - repo = &Repo{URL: "git@github.com", Interval: time.Second} - Start(repo) - if len(Services.services) != 5 { - t.Errorf("Expected %v service(s), found %v", 5, len(Services.services)) - } - - repo = &Repo{URL: "git@github.com", Interval: time.Second * 2} - Start(repo) - if len(Services.services) != 6 { - t.Errorf("Expected %v service(s), found %v", 6, len(Services.services)) - } - - gos.Sleep(time.Second * 5) - Services.Stop(repo.URL, -1) - if len(Services.services) != 4 { - t.Errorf("Expected %v service(s), found %v", 4, len(Services.services)) - } - - for _, repo := range repos { - Services.Stop(repo.URL, -1) - } - if len(Services.services) != 0 { - t.Errorf("Expected %v service(s), found %v", 0, len(Services.services)) - } -} diff --git a/vendor/github.com/abiosoft/caddy-git/setup.go b/vendor/github.com/abiosoft/caddy-git/setup.go deleted file mode 100644 index f01a829..0000000 --- a/vendor/github.com/abiosoft/caddy-git/setup.go +++ /dev/null @@ -1,323 +0,0 @@ -package git - -import ( - "fmt" - "net/url" - "path" - "path/filepath" - "runtime" - "strconv" - "strings" - "time" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -const ( - // DefaultInterval is the minimum interval to delay before - // requesting another git pull - DefaultInterval time.Duration = time.Hour * 1 -) - -func init() { - caddy.RegisterPlugin("git", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Git service routine. -func setup(c *caddy.Controller) error { - git, err := parse(c) - if err != nil { - return err - } - - // repos configured with webhooks - var hookRepos []*Repo - - // functions to execute at startup - var startupFuncs []func() error - - // loop through all repos and and start monitoring - for i := range git { - repo := git.Repo(i) - - // If a HookUrl is set, we switch to event based pulling. - // Install the url handler - if repo.Hook.Url != "" { - - hookRepos = append(hookRepos, repo) - - startupFuncs = append(startupFuncs, func() error { - return repo.Pull() - }) - - } else { - startupFuncs = append(startupFuncs, func() error { - - // Start service routine in background - Start(repo) - - // Do a pull right away to return error - return repo.Pull() - }) - } - } - - // ensure the functions are executed once per server block - // for cases like server1.com, server2.com { ... } - c.OncePerServerBlock(func() error { - for i := range startupFuncs { - c.OnStartup(startupFuncs[i]) - } - return nil - }) - - // if there are repo(s) with webhook - // return handler - if len(hookRepos) > 0 { - webhook := &WebHook{Repos: hookRepos} - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - webhook.Next = next - return webhook - }) - } - - return nil -} - -func parse(c *caddy.Controller) (Git, error) { - var git Git - - config := httpserver.GetConfig(c.Key) - for c.Next() { - repo := &Repo{Branch: "master", Interval: DefaultInterval, Path: config.Root} - - args := c.RemainingArgs() - - switch len(args) { - case 2: - repo.Path = filepath.Clean(config.Root + string(filepath.Separator) + args[1]) - fallthrough - case 1: - u, err := validateURL(args[0]) - if err != nil { - return nil, err - } - repo.URL = u - } - - for c.NextBlock() { - switch c.Val() { - case "repo": - if !c.NextArg() { - return nil, c.ArgErr() - } - u, err := validateURL(c.Val()) - if err != nil { - return nil, err - } - repo.URL = u - case "path": - if !c.NextArg() { - return nil, c.ArgErr() - } - repo.Path = filepath.Clean(config.Root + string(filepath.Separator) + c.Val()) - case "branch": - if !c.NextArg() { - return nil, c.ArgErr() - } - repo.Branch = c.Val() - case "key": - if !c.NextArg() { - return nil, c.ArgErr() - } - repo.KeyPath = c.Val() - case "interval": - if !c.NextArg() { - return nil, c.ArgErr() - } - t, _ := strconv.Atoi(c.Val()) - if t > 0 { - repo.Interval = time.Duration(t) * time.Second - } - case "hook": - if !c.NextArg() { - return nil, c.ArgErr() - } - repo.Hook.Url = c.Val() - - // optional secret for validation - if c.NextArg() { - repo.Hook.Secret = c.Val() - } - case "hook_type": - if !c.NextArg() { - return nil, c.ArgErr() - } - t := c.Val() - if _, ok := handlers[t]; !ok { - return nil, c.Errf("invalid hook type %v", t) - } - repo.Hook.Type = t - case "then": - if !c.NextArg() { - return nil, c.ArgErr() - } - command := c.Val() - args := c.RemainingArgs() - repo.Then = append(repo.Then, NewThen(command, args...)) - case "then_long": - if !c.NextArg() { - return nil, c.ArgErr() - } - command := c.Val() - args := c.RemainingArgs() - repo.Then = append(repo.Then, NewLongThen(command, args...)) - default: - return nil, c.ArgErr() - } - } - - // if repo is not specified, return error - if repo.URL == "" { - return nil, c.ArgErr() - } - - // if private key is not specified, convert repository URL to https - // to avoid ssh authentication - // else validate git URL - // Note: private key support not yet available on Windows - var err error - if repo.KeyPath == "" { - repo.URL, repo.Host, err = sanitizeHTTP(repo.URL) - } else { - repo.URL, repo.Host, err = sanitizeSSH(repo.URL) - // TODO add Windows support for private repos - if runtime.GOOS == "windows" { - return nil, fmt.Errorf("private repository not yet supported on Windows") - } - } - - if err != nil { - return nil, err - } - - // validate git requirements - if err = Init(); err != nil { - return nil, err - } - - // prepare repo for use - if err = repo.Prepare(); err != nil { - return nil, err - } - - git = append(git, repo) - - } - - return git, nil -} - -// validateURL validates repoUrl is a valid git url and appends -// with .git if missing. -func validateURL(repoURL string) (string, error) { - u, err := url.Parse(repoURL) - if err != nil { - return "", err - } - if u.Scheme == "" { - u.Scheme = "https" - } - - switch u.Scheme { - case "https", "http", "ssh": - default: - return "", fmt.Errorf("Invalid url scheme %s. If url contains port, scheme is required.", u.Scheme) - } - - if !strings.HasSuffix(u.String(), ".git") { - return u.String() + ".git", nil - } - return u.String(), nil -} - -// sanitizeHTTP cleans up repository URL and converts to https format -// if currently in ssh format. -// Returns sanitized url, hostName (e.g. github.com, bitbucket.com) -// and possible error -func sanitizeHTTP(repoURL string) (string, string, error) { - u, err := url.Parse(repoURL) - if err != nil { - return "", "", err - } - - // ensure the url is not ssh - if u.Scheme == "ssh" { - u.Scheme = "https" - } - - // convert to http format if in ssh format - if strings.Contains(u.Host, ":") { - s := strings.SplitN(u.Host, ":", 2) - // alter path and host if we're sure its not a port - if _, err := strconv.Atoi(s[1]); err != nil { - u.Host = s[0] - u.Path = path.Join(s[1], u.Path) - } - } - - // Bitbucket require the user to be set into the HTTP URL - if u.Host == "bitbucket.org" && u.User == nil { - segments := strings.Split(u.Path, "/") - u.User = url.User(segments[1]) - } - - return u.String(), u.Host, nil -} - -// sanitizeSSH cleans up repository url and converts to ssh format for private -// repositories if required. -// Returns sanitized url, hostName (e.g. github.com, bitbucket.com) -// and possible error -func sanitizeSSH(repoURL string) (string, string, error) { - u, err := url.Parse(repoURL) - if err != nil { - return "", "", err - } - - u.Scheme = "" - host := u.Host - // convert to ssh format if not in ssh format - if !strings.Contains(u.Host, ":") { - if u.Path[0] == '/' { - u.Path = ":" + u.Path[1:] - } else if u.Path[0] != ':' { - u.Path = ":" + u.Path - } - } else { - s := strings.SplitN(u.Host, ":", 2) - host = s[0] - // if port is set, ssh scheme is required - if _, err := strconv.Atoi(s[1]); err == nil { - u.Scheme = "ssh" - } - } - - // ensure user is set - if u.User == nil { - u.User = url.User("git") - } - - // remove unintended `/` added by url.String and `//` if scheme is not ssh. - // TODO find a cleaner way - replacer := strings.NewReplacer("/:", ":", "//", "") - if u.Scheme == "ssh" { - replacer = strings.NewReplacer("/:", ":") - } - repoURL = replacer.Replace(u.String()) - return repoURL, host, nil -} diff --git a/vendor/github.com/abiosoft/caddy-git/setup_test.go b/vendor/github.com/abiosoft/caddy-git/setup_test.go deleted file mode 100644 index bffed73..0000000 --- a/vendor/github.com/abiosoft/caddy-git/setup_test.go +++ /dev/null @@ -1,285 +0,0 @@ -package git - -import ( - "fmt" - "io/ioutil" - "strings" - "testing" - "time" - - "github.com/abiosoft/caddy-git/gittest" - "github.com/mholt/caddy" -) - -// init sets the OS used to fakeOS -func init() { - SetOS(gittest.FakeOS) -} - -func TestGitSetup(t *testing.T) { - c := caddy.NewTestController(`git git@github.com:mholt/caddy.git`) - err := setup(c) - check(t, err) -} - -func TestGitParse(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expected *Repo - }{ - {`git git@github.com:user/repo`, false, &Repo{ - URL: "https://git@github.com/user/repo.git", - }}, - {`git github.com/user/repo`, false, &Repo{ - URL: "https://github.com/user/repo.git", - }}, - {`git git@github.com/user/repo`, false, &Repo{ - URL: "https://git@github.com/user/repo.git", - }}, - {`git http://github.com/user/repo`, false, &Repo{ - URL: "http://github.com/user/repo.git", - }}, - {`git http://github.com:8888/user/repo`, false, &Repo{ - URL: "http://github.com:8888/user/repo.git", - }}, - {`git https://github.com/user/repo`, false, &Repo{ - URL: "https://github.com/user/repo.git", - }}, - {`git http://github.com/user/repo { - key ~/.key - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "git@github.com:user/repo.git", - }}, - {`git git@github.com:user/repo { - key ~/.key - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "git@github.com:user/repo.git", - }}, - {`git `, true, nil}, - {`git { - }`, true, nil}, - {`git { - repo git@github.com:user/repo.git`, true, nil}, - {`git { - repo git@github.com:user/repo - key ~/.key - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "git@github.com:user/repo.git", - }}, - {`git { - repo git@github.com:user/repo - key ~/.key - interval 600 - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "git@github.com:user/repo.git", - Interval: time.Second * 600, - }}, - {`git { - repo git@github.com:user/repo - branch dev - }`, false, &Repo{ - Branch: "dev", - URL: "https://git@github.com/user/repo.git", - }}, - {`git { - key ~/.key - }`, true, nil}, - {`git { - repo git@github.com:user/repo - key ~/.key - then echo hello world - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "git@github.com:user/repo.git", - Then: []Then{NewThen("echo", "hello world")}, - }}, - {`git https://user@bitbucket.org/user/repo.git`, false, &Repo{ - URL: "https://user@bitbucket.org/user/repo.git", - }}, - {`git https://user@bitbucket.org/user/repo.git { - key ~/.key - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "user@bitbucket.org:user/repo.git", - }}, - {`git git@bitbucket.org:user/repo.git { - key ~/.key - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "git@bitbucket.org:user/repo.git", - }}, - {`git ssh://git@bitbucket.org:user/repo.git { - key ~/.key - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "git@bitbucket.org:user/repo.git", - }}, - {`git git@bitbucket.org:2222/user/repo.git { - key ~/.key - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "ssh://git@bitbucket.org:2222/user/repo.git", - }}, - {`git git@bitbucket.org:2222/user/repo.git { - key ~/.key - hook_type gogs - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "ssh://git@bitbucket.org:2222/user/repo.git", - Hook: HookConfig{ - Type: "gogs", - }, - }}, - {`git git@bitbucket.org:2222/user/repo.git { - key ~/.key - hook /webhook - hook_type gogs - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "ssh://git@bitbucket.org:2222/user/repo.git", - Hook: HookConfig{ - Url: "/webhook", - Type: "gogs", - }, - }}, - {`git git@bitbucket.org:2222/user/repo.git { - key ~/.key - hook /webhook some-secrets - hook_type gogs - }`, false, &Repo{ - KeyPath: "~/.key", - URL: "ssh://git@bitbucket.org:2222/user/repo.git", - Hook: HookConfig{ - Url: "/webhook", - Secret: "some-secrets", - Type: "gogs", - }, - }}, - } - - for i, test := range tests { - c := caddy.NewTestController(test.input) - git, err := parse(c) - if !test.shouldErr && err != nil { - t.Errorf("Test %v should not error but found %v", i, err) - continue - } - if test.shouldErr && err == nil { - t.Errorf("Test %v should error but found nil", i) - continue - } - repo := git.Repo(0) - if !reposEqual(test.expected, repo) { - t.Errorf("Test %v expects %v but found %v", i, test.expected, repo) - } - } -} - -func TestIntervals(t *testing.T) { - tests := []string{ - `git git@github.com:user/repo { interval 10 }`, - `git git@github.com:user/repo { interval 5 }`, - `git git@github.com:user/repo { interval 2 }`, - `git git@github.com:user/repo { interval 1 }`, - `git git@github.com:user/repo { interval 6 }`, - } - - for i, test := range tests { - SetLogger(gittest.NewLogger(gittest.Open("file"))) - c1 := caddy.NewTestController(test) - git, err := parse(c1) - check(t, err) - repo := git.Repo(0) - - c2 := caddy.NewTestController(test) - err = setup(c2) - check(t, err) - - // start startup services - err = func() error { - // Start service routine in background - Start(repo) - // Do a pull right away to return error - return repo.Pull() - }() - check(t, err) - - // wait for first background pull - gittest.Sleep(time.Millisecond * 100) - - // switch logger to test file - logFile := gittest.Open("file") - SetLogger(gittest.NewLogger(logFile)) - - // sleep for the interval - gittest.Sleep(repo.Interval) - - // get log output - out, err := ioutil.ReadAll(logFile) - check(t, err) - - // if greater than minimum interval - if repo.Interval >= time.Second*5 { - expected := `https://git@github.com/user/repo.git pulled. -No new changes.` - - // ensure pull is done by tracing the output - if expected != strings.TrimSpace(string(out)) { - t.Errorf("Test %v: Expected %v found %v", i, expected, string(out)) - } - } else { - // ensure pull is ignored by confirming no output - if string(out) != "" { - t.Errorf("Test %v: Expected no output but found %v", i, string(out)) - } - } - - // stop background thread monitor - Services.Stop(repo.URL, 1) - - } - -} - -func reposEqual(expected, repo *Repo) bool { - thenStr := func(then []Then) string { - var str []string - for _, t := range then { - str = append(str, t.Command()) - } - return fmt.Sprint(str) - } - if expected == nil { - return repo == nil - } - if expected.Branch != "" && expected.Branch != repo.Branch { - return false - } - if expected.Host != "" && expected.Host != repo.Host { - return false - } - if expected.Interval != 0 && expected.Interval != repo.Interval { - return false - } - if expected.KeyPath != "" && expected.KeyPath != repo.KeyPath { - return false - } - if expected.Path != "" && expected.Path != repo.Path { - return false - } - if expected.Then != nil && thenStr(expected.Then) != thenStr(repo.Then) { - return false - } - if expected.URL != "" && expected.URL != repo.URL { - return false - } - if fmt.Sprint(expected.Hook) != fmt.Sprint(repo.Hook) { - return false - } - return true -} diff --git a/vendor/github.com/abiosoft/caddy-git/travis_hook.go b/vendor/github.com/abiosoft/caddy-git/travis_hook.go deleted file mode 100644 index 66adeda..0000000 --- a/vendor/github.com/abiosoft/caddy-git/travis_hook.go +++ /dev/null @@ -1,95 +0,0 @@ -package git - -import ( - "crypto/sha256" - "encoding/hex" - "encoding/json" - "errors" - "fmt" - "net/http" - "time" -) - -type TravisHook struct{} - -func (t TravisHook) DoesHandle(h http.Header) bool { - return h.Get("Travis-Repo-Slug") != "" -} - -func (t TravisHook) Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) { - if r.Method != "POST" { - return http.StatusMethodNotAllowed, errors.New("the request had an invalid method") - } - if err := t.handleSignature(r, repo.Hook.Secret); err != nil { - return http.StatusBadRequest, err - } - if err := r.ParseForm(); err != nil { - return http.StatusBadRequest, err - } - payload := r.FormValue("payload") - if payload == "" { - return http.StatusBadRequest, fmt.Errorf("Payload required") - } - data := &travisPayload{} - if err := json.Unmarshal([]byte(payload), data); err != nil { - return http.StatusBadRequest, err - } - - // ignored webhooks - err := hookIgnoredError{hookType: hookName(t)} - if data.Type != "push" || data.StatusMessage != "Passed" { - err.err = fmt.Errorf("Ignoring payload with wrong status or type.") - return 200, err - } - if repo.Branch != "" && data.Branch != repo.Branch { - err.err = fmt.Errorf("Ignoring push for branch %s", data.Branch) - return 200, err - } - - // attempt pull - if err := repo.Pull(); err != nil { - return http.StatusInternalServerError, err - } - if err := repo.checkoutCommit(data.Commit); err != nil { - return http.StatusInternalServerError, err - } - return 200, nil -} - -type travisPayload struct { - ID int `json:"id"` - Number string `json:"number"` - Status int `json:"status"` - Result int `json:"result"` - StatusMessage string `json:"status_message"` - ResultMessage string `json:"result_message"` - StartedAt time.Time `json:"started_at"` - FinishedAt time.Time `json:"finished_at"` - Duration int `json:"duration"` - BuildURL string `json:"build_url"` - Branch string `json:"branch"` - Type string `json:"type"` - State string `json:"state"` - Commit string `json:"commit"` -} - -// Check for an authorization signature in the request. Reject if not present. If validation required, check the sha -func (t TravisHook) handleSignature(r *http.Request, secret string) error { - signature := r.Header.Get("Authorization") - if signature == "" { - return errors.New("request sent no authorization signature") - } - if secret == "" { - Logger().Print("Unable to verify request signature. Secret not set in caddyfile!\n") - return nil - } - - content := r.Header.Get("Travis-Repo-Slug") + secret - hash := sha256.Sum256([]byte(content)) - expectedMac := hex.EncodeToString(hash[:]) - if signature != expectedMac { - fmt.Println(signature, expectedMac) - return errors.New("Invalid authorization header") - } - return nil -} diff --git a/vendor/github.com/abiosoft/caddy-git/webhook.go b/vendor/github.com/abiosoft/caddy-git/webhook.go deleted file mode 100644 index a1ac78e..0000000 --- a/vendor/github.com/abiosoft/caddy-git/webhook.go +++ /dev/null @@ -1,124 +0,0 @@ -package git - -import ( - "errors" - "fmt" - "net/http" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// WebHook is middleware for handling web hooks of git providers -type WebHook struct { - Repos []*Repo - Next httpserver.Handler -} - -// HookConfig is a webhook handler configuration. -type HookConfig struct { - Url string // url to listen on for webhooks - Secret string // secret to validate hooks - Type string // type of Webhook -} - -// hookIgnoredError is returned when a webhook is ignored by the -// webhook handler. -type hookIgnoredError struct { - hookType string - err error -} - -// Error satisfies error interface -func (h hookIgnoredError) Error() string { - return fmt.Sprintf("%s webhook ignored. Error: %v", h.hookType, h.err) -} - -// hookIgnored checks if err is of type hookIgnoredError. -func hookIgnored(err error) bool { - _, ok := err.(hookIgnoredError) - return ok -} - -// hookName returns the name of the hookHanlder h. -func hookName(h hookHandler) string { - for name, handler := range handlers { - if handler == h { - return name - } - } - return "" -} - -// hookHandler is interface for specific providers to implement. -type hookHandler interface { - DoesHandle(http.Header) bool - Handle(w http.ResponseWriter, r *http.Request, repo *Repo) (int, error) -} - -// handlers stores all registered hookHandlers. -// map key corresponds to expected config name. -// -// register hook handlers here. -var handlers = map[string]hookHandler{ - "github": GithubHook{}, - "gitlab": GitlabHook{}, - "bitbucket": BitbucketHook{}, - "generic": GenericHook{}, - "travis": TravisHook{}, - "gogs": GogsHook{}, -} - -// defaultHandlers is the list of handlers to choose from -// if handler type is not specified in config. -var defaultHandlers = []string{ - "github", - "gitlab", - "bitbucket", - "travis", - "gogs", -} - -// ServeHTTP implements the middlware.Handler interface. -func (h WebHook) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - - for _, repo := range h.Repos { - - if r.URL.Path == repo.Hook.Url { - - // if handler type is specified. - if handler, ok := handlers[repo.Hook.Type]; ok { - if !handler.DoesHandle(r.Header) { - return http.StatusBadRequest, errors.New(http.StatusText(http.StatusBadRequest)) - } - status, err := handler.Handle(w, r, repo) - // if the webhook is ignored, log it and allow request to continue. - if hookIgnored(err) { - Logger().Println(err) - err = nil - } - return status, err - } - - // auto detect handler - for _, h := range defaultHandlers { - // if a handler indicates it does handle the request, - // we do not try other handlers. Only one handler ever - // handles a specific request. - if handlers[h].DoesHandle(r.Header) { - status, err := handlers[h].Handle(w, r, repo) - // if the webhook is ignored, log it and allow request to continue. - if hookIgnored(err) { - Logger().Println(err) - err = nil - } - return status, err - } - } - - // no compatible handler - Logger().Println("No compatible handler found. Consider enabling generic handler with 'hook_type generic'.") - } - } - - return h.Next.ServeHTTP(w, r) -} diff --git a/vendor/github.com/dgrijalva/jwt-go/.gitignore b/vendor/github.com/dgrijalva/jwt-go/.gitignore deleted file mode 100644 index 80bed65..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -bin - - diff --git a/vendor/github.com/dgrijalva/jwt-go/.travis.yml b/vendor/github.com/dgrijalva/jwt-go/.travis.yml deleted file mode 100644 index bde823d..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -go: - - 1.3 - - 1.4 - - 1.5 - - 1.6 - - tip diff --git a/vendor/github.com/dgrijalva/jwt-go/LICENSE b/vendor/github.com/dgrijalva/jwt-go/LICENSE deleted file mode 100644 index df83a9c..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/LICENSE +++ /dev/null @@ -1,8 +0,0 @@ -Copyright (c) 2012 Dave Grijalva - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/vendor/github.com/dgrijalva/jwt-go/README.md b/vendor/github.com/dgrijalva/jwt-go/README.md deleted file mode 100644 index 88448eb..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/README.md +++ /dev/null @@ -1,100 +0,0 @@ -A [go](http://www.golang.org) (or 'golang' for search engine friendliness) implementation of [JSON Web Tokens](http://self-issued.info/docs/draft-jones-json-web-token.html) - -[![Build Status](https://travis-ci.org/dgrijalva/jwt-go.svg?branch=master)](https://travis-ci.org/dgrijalva/jwt-go) - -**BREAKING CHANGES COMING:*** Version 3.0.0 is almost complete. It will include _a lot_ of changes including a few that break the API. We've tried to break as few things as possible, so there should just be a few type signature changes. A full list of breaking changes will be available before 3.0.0 lands. If you would like to have any input befor 3.0.0 is locked, now's the time to review and provide feedback. - -**NOTICE:** A vulnerability in JWT was [recently published](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/). As this library doesn't force users to validate the `alg` is what they expected, it's possible your usage is effected. There will be an update soon to remedy this, and it will likey require backwards-incompatible changes to the API. In the short term, please make sure your implementation verifies the `alg` is what you expect. - -## What the heck is a JWT? - -In short, it's a signed JSON object that does something useful (for example, authentication). It's commonly used for `Bearer` tokens in Oauth 2. A token is made of three parts, separated by `.`'s. The first two parts are JSON objects, that have been [base64url](http://tools.ietf.org/html/rfc4648) encoded. The last part is the signature, encoded the same way. - -The first part is called the header. It contains the necessary information for verifying the last part, the signature. For example, which encryption method was used for signing and what key was used. - -The part in the middle is the interesting bit. It's called the Claims and contains the actual stuff you care about. Refer to [the RFC](http://self-issued.info/docs/draft-jones-json-web-token.html) for information about reserved keys and the proper way to add your own. - -## What's in the box? - -This library supports the parsing and verification as well as the generation and signing of JWTs. Current supported signing algorithms are HMAC SHA, RSA, RSA-PSS, and ECDSA, though hooks are present for adding your own. - -## Parse and Verify - -Parsing and verifying tokens is pretty straight forward. You pass in the token and a function for looking up the key. This is done as a callback since you may need to parse the token to find out what signing method and key was used. - -```go - token, err := jwt.Parse(myToken, func(token *jwt.Token) (interface{}, error) { - // Don't forget to validate the alg is what you expect: - if _, ok := token.Method.(*jwt.SigningMethodRSA); !ok { - return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"]) - } - return myLookupKey(token.Header["kid"]), nil - }) - - if err == nil && token.Valid { - deliverGoodness("!") - } else { - deliverUtterRejection(":(") - } -``` - -## Create a token - -```go - // Create the token - token := jwt.New(jwt.SigningMethodHS256) - // Set some claims - token.Claims["foo"] = "bar" - token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix() - // Sign and get the complete encoded token as a string - tokenString, err := token.SignedString(mySigningKey) -``` - -## Extensions - -This library publishes all the necessary components for adding your own signing methods. Simply implement the `SigningMethod` interface and register a factory method using `RegisterSigningMethod`. - -Here's an example of an extension that integrates with the Google App Engine signing tools: https://github.com/someone1/gcp-jwt-go - -## Project Status & Versioning - -This library is considered production ready. Feedback and feature requests are appreciated. The API should be considered stable. There should be very few backwards-incompatible changes outside of major version updates (and only with good reason). - -This project uses [Semantic Versioning 2.0.0](http://semver.org). Accepted pull requests will land on `master`. Periodically, versions will be tagged from `master`. You can find all the releases on [the project releases page](https://github.com/dgrijalva/jwt-go/releases). - -While we try to make it obvious when we make breaking changes, there isn't a great mechanism for pushing announcements out to users. You may want to use this alternative package include: `gopkg.in/dgrijalva/jwt-go.v2`. It will do the right thing WRT semantic versioning. - -## Usage Tips - -### Signing vs Encryption - -A token is simply a JSON object that is signed by its author. this tells you exactly two things about the data: - -* The author of the token was in the possession of the signing secret -* The data has not been modified since it was signed - -It's important to know that JWT does not provide encryption, which means anyone who has access to the token can read its contents. If you need to protect (encrypt) the data, there is a companion spec, `JWE`, that provides this functionality. JWE is currently outside the scope of this library. - -### Choosing a Signing Method - -There are several signing methods available, and you should probably take the time to learn about the various options before choosing one. The principal design decision is most likely going to be symmetric vs asymmetric. - -Symmetric signing methods, such as HSA, use only a single secret. This is probably the simplest signing method to use since any `[]byte` can be used as a valid secret. They are also slightly computationally faster to use, though this rarely is enough to matter. Symmetric signing methods work the best when both producers and consumers of tokens are trusted, or even the same system. Since the same secret is used to both sign and validate tokens, you can't easily distribute the key for validation. - -Asymmetric signing methods, such as RSA, use different keys for signing and verifying tokens. This makes it possible to produce tokens with a private key, and allow any consumer to access the public key for verification. - -### JWT and OAuth - -It's worth mentioning that OAuth and JWT are not the same thing. A JWT token is simply a signed JSON object. It can be used anywhere such a thing is useful. There is some confusion, though, as JWT is the most common type of bearer token used in OAuth2 authentication. - -Without going too far down the rabbit hole, here's a description of the interaction of these technologies: - -* OAuth is a protocol for allowing an identity provider to be separate from the service a user is logging in to. For example, whenever you use Facebook to log into a different service (Yelp, Spotify, etc), you are using OAuth. -* OAuth defines several options for passing around authentication data. One popular method is called a "bearer token". A bearer token is simply a string that _should_ only be held by an authenticated user. Thus, simply presenting this token proves your identity. You can probably derive from here why a JWT might make a good bearer token. -* Because bearer tokens are used for authentication, it's important they're kept secret. This is why transactions that use bearer tokens typically happen over SSL. - -## More - -Documentation can be found [on godoc.org](http://godoc.org/github.com/dgrijalva/jwt-go). - -The command line utility included in this project (cmd/jwt) provides a straightforward example of token creation and parsing as well as a useful tool for debugging your own integration. For a more http centric example, see [this gist](https://gist.github.com/cryptix/45c33ecf0ae54828e63b). diff --git a/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md b/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md deleted file mode 100644 index 3918734..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/VERSION_HISTORY.md +++ /dev/null @@ -1,81 +0,0 @@ -## `jwt-go` Version History - -#### 2.6.0 - -This will likely be the last backwards compatible release before 3.0.0. - -* Exposed inner error within ValidationError -* Fixed validation errors when using UseJSONNumber flag -* Added several unit tests - -#### 2.5.0 - -* Added support for signing method none. You shouldn't use this. The API tries to make this clear. -* Updated/fixed some documentation -* Added more helpful error message when trying to parse tokens that begin with `BEARER ` - -#### 2.4.0 - -* Added new type, Parser, to allow for configuration of various parsing parameters - * You can now specify a list of valid signing methods. Anything outside this set will be rejected. - * You can now opt to use the `json.Number` type instead of `float64` when parsing token JSON -* Added support for [Travis CI](https://travis-ci.org/dgrijalva/jwt-go) -* Fixed some bugs with ECDSA parsing - -#### 2.3.0 - -* Added support for ECDSA signing methods -* Added support for RSA PSS signing methods (requires go v1.4) - -#### 2.2.0 - -* Gracefully handle a `nil` `Keyfunc` being passed to `Parse`. Result will now be the parsed token and an error, instead of a panic. - -#### 2.1.0 - -Backwards compatible API change that was missed in 2.0.0. - -* The `SignedString` method on `Token` now takes `interface{}` instead of `[]byte` - -#### 2.0.0 - -There were two major reasons for breaking backwards compatibility with this update. The first was a refactor required to expand the width of the RSA and HMAC-SHA signing implementations. There will likely be no required code changes to support this change. - -The second update, while unfortunately requiring a small change in integration, is required to open up this library to other signing methods. Not all keys used for all signing methods have a single standard on-disk representation. Requiring `[]byte` as the type for all keys proved too limiting. Additionally, this implementation allows for pre-parsed tokens to be reused, which might matter in an application that parses a high volume of tokens with a small set of keys. Backwards compatibilty has been maintained for passing `[]byte` to the RSA signing methods, but they will also accept `*rsa.PublicKey` and `*rsa.PrivateKey`. - -It is likely the only integration change required here will be to change `func(t *jwt.Token) ([]byte, error)` to `func(t *jwt.Token) (interface{}, error)` when calling `Parse`. - -* **Compatibility Breaking Changes** - * `SigningMethodHS256` is now `*SigningMethodHMAC` instead of `type struct` - * `SigningMethodRS256` is now `*SigningMethodRSA` instead of `type struct` - * `KeyFunc` now returns `interface{}` instead of `[]byte` - * `SigningMethod.Sign` now takes `interface{}` instead of `[]byte` for the key - * `SigningMethod.Verify` now takes `interface{}` instead of `[]byte` for the key -* Renamed type `SigningMethodHS256` to `SigningMethodHMAC`. Specific sizes are now just instances of this type. - * Added public package global `SigningMethodHS256` - * Added public package global `SigningMethodHS384` - * Added public package global `SigningMethodHS512` -* Renamed type `SigningMethodRS256` to `SigningMethodRSA`. Specific sizes are now just instances of this type. - * Added public package global `SigningMethodRS256` - * Added public package global `SigningMethodRS384` - * Added public package global `SigningMethodRS512` -* Moved sample private key for HMAC tests from an inline value to a file on disk. Value is unchanged. -* Refactored the RSA implementation to be easier to read -* Exposed helper methods `ParseRSAPrivateKeyFromPEM` and `ParseRSAPublicKeyFromPEM` - -#### 1.0.2 - -* Fixed bug in parsing public keys from certificates -* Added more tests around the parsing of keys for RS256 -* Code refactoring in RS256 implementation. No functional changes - -#### 1.0.1 - -* Fixed panic if RS256 signing method was passed an invalid key - -#### 1.0.0 - -* First versioned release -* API stabilized -* Supports creating, signing, parsing, and validating JWT tokens -* Supports RS256 and HS256 signing methods \ No newline at end of file diff --git a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/README.md b/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/README.md deleted file mode 100644 index 4a68ba4..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/README.md +++ /dev/null @@ -1,13 +0,0 @@ -`jwt` command-line tool -======================= - -This is a simple tool to sign, verify and show JSON Web Tokens from -the command line. - -The following will create and sign a token, then verify it and output the original claims: - - echo {\"foo\":\"bar\"} | bin/jwt -key test/sample_key -alg RS256 -sign - | bin/jwt -key test/sample_key.pub -verify - - -To simply display a token, use: - - echo $JWT | jwt -show - diff --git a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go b/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go deleted file mode 100644 index e8bc336..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/cmd/jwt/app.go +++ /dev/null @@ -1,246 +0,0 @@ -// A useful example app. You can use this to debug your tokens on the command line. -// This is also a great place to look at how you might use this library. -// -// Example usage: -// The following will create and sign a token, then verify it and output the original claims. -// echo {\"foo\":\"bar\"} | bin/jwt -key test/sample_key -alg RS256 -sign - | bin/jwt -key test/sample_key.pub -verify - -package main - -import ( - "encoding/json" - "flag" - "fmt" - "io" - "io/ioutil" - "os" - "regexp" - "strings" - - jwt "github.com/dgrijalva/jwt-go" -) - -var ( - // Options - flagAlg = flag.String("alg", "", "signing algorithm identifier") - flagKey = flag.String("key", "", "path to key file or '-' to read from stdin") - flagCompact = flag.Bool("compact", false, "output compact JSON") - flagDebug = flag.Bool("debug", false, "print out all kinds of debug data") - - // Modes - exactly one of these is required - flagSign = flag.String("sign", "", "path to claims object to sign or '-' to read from stdin") - flagVerify = flag.String("verify", "", "path to JWT token to verify or '-' to read from stdin") - flagShow = flag.String("show", "", "path to JWT file or '-' to read from stdin") -) - -func main() { - // Usage message if you ask for -help or if you mess up inputs. - flag.Usage = func() { - fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0]) - fmt.Fprintf(os.Stderr, " One of the following flags is required: sign, verify\n") - flag.PrintDefaults() - } - - // Parse command line options - flag.Parse() - - // Do the thing. If something goes wrong, print error to stderr - // and exit with a non-zero status code - if err := start(); err != nil { - fmt.Fprintf(os.Stderr, "Error: %v\n", err) - os.Exit(1) - } -} - -// Figure out which thing to do and then do that -func start() error { - if *flagSign != "" { - return signToken() - } else if *flagVerify != "" { - return verifyToken() - } else if *flagShow != "" { - return showToken() - } else { - flag.Usage() - return fmt.Errorf("None of the required flags are present. What do you want me to do?") - } -} - -// Helper func: Read input from specified file or stdin -func loadData(p string) ([]byte, error) { - if p == "" { - return nil, fmt.Errorf("No path specified") - } - - var rdr io.Reader - if p == "-" { - rdr = os.Stdin - } else { - if f, err := os.Open(p); err == nil { - rdr = f - defer f.Close() - } else { - return nil, err - } - } - return ioutil.ReadAll(rdr) -} - -// Print a json object in accordance with the prophecy (or the command line options) -func printJSON(j interface{}) error { - var out []byte - var err error - - if *flagCompact == false { - out, err = json.MarshalIndent(j, "", " ") - } else { - out, err = json.Marshal(j) - } - - if err == nil { - fmt.Println(string(out)) - } - - return err -} - -// Verify a token and output the claims. This is a great example -// of how to verify and view a token. -func verifyToken() error { - // get the token - tokData, err := loadData(*flagVerify) - if err != nil { - return fmt.Errorf("Couldn't read token: %v", err) - } - - // trim possible whitespace from token - tokData = regexp.MustCompile(`\s*$`).ReplaceAll(tokData, []byte{}) - if *flagDebug { - fmt.Fprintf(os.Stderr, "Token len: %v bytes\n", len(tokData)) - } - - // Parse the token. Load the key from command line option - token, err := jwt.Parse(string(tokData), func(t *jwt.Token) (interface{}, error) { - data, err := loadData(*flagKey) - if err != nil { - return nil, err - } - if isEs() { - return jwt.ParseECPublicKeyFromPEM(data) - } - return data, nil - }) - - // Print some debug data - if *flagDebug && token != nil { - fmt.Fprintf(os.Stderr, "Header:\n%v\n", token.Header) - fmt.Fprintf(os.Stderr, "Claims:\n%v\n", token.Claims) - } - - // Print an error if we can't parse for some reason - if err != nil { - return fmt.Errorf("Couldn't parse token: %v", err) - } - - // Is token invalid? - if !token.Valid { - return fmt.Errorf("Token is invalid") - } - - // Print the token details - if err := printJSON(token.Claims); err != nil { - return fmt.Errorf("Failed to output claims: %v", err) - } - - return nil -} - -// Create, sign, and output a token. This is a great, simple example of -// how to use this library to create and sign a token. -func signToken() error { - // get the token data from command line arguments - tokData, err := loadData(*flagSign) - if err != nil { - return fmt.Errorf("Couldn't read token: %v", err) - } else if *flagDebug { - fmt.Fprintf(os.Stderr, "Token: %v bytes", len(tokData)) - } - - // parse the JSON of the claims - var claims map[string]interface{} - if err := json.Unmarshal(tokData, &claims); err != nil { - return fmt.Errorf("Couldn't parse claims JSON: %v", err) - } - - // get the key - var key interface{} - key, err = loadData(*flagKey) - if err != nil { - return fmt.Errorf("Couldn't read key: %v", err) - } - - // get the signing alg - alg := jwt.GetSigningMethod(*flagAlg) - if alg == nil { - return fmt.Errorf("Couldn't find signing method: %v", *flagAlg) - } - - // create a new token - token := jwt.New(alg) - token.Claims = claims - - if isEs() { - if k, ok := key.([]byte); !ok { - return fmt.Errorf("Couldn't convert key data to key") - } else { - key, err = jwt.ParseECPrivateKeyFromPEM(k) - if err != nil { - return err - } - } - } - - if out, err := token.SignedString(key); err == nil { - fmt.Println(out) - } else { - return fmt.Errorf("Error signing token: %v", err) - } - - return nil -} - -// showToken pretty-prints the token on the command line. -func showToken() error { - // get the token - tokData, err := loadData(*flagShow) - if err != nil { - return fmt.Errorf("Couldn't read token: %v", err) - } - - // trim possible whitespace from token - tokData = regexp.MustCompile(`\s*$`).ReplaceAll(tokData, []byte{}) - if *flagDebug { - fmt.Fprintf(os.Stderr, "Token len: %v bytes\n", len(tokData)) - } - - token, err := jwt.Parse(string(tokData), nil) - if token == nil { - return fmt.Errorf("malformed token: %v", err) - } - - // Print the token details - fmt.Println("Header:") - if err := printJSON(token.Header); err != nil { - return fmt.Errorf("Failed to output header: %v", err) - } - - fmt.Println("Claims:") - if err := printJSON(token.Claims); err != nil { - return fmt.Errorf("Failed to output claims: %v", err) - } - - return nil -} - -func isEs() bool { - return strings.HasPrefix(*flagAlg, "ES") -} diff --git a/vendor/github.com/dgrijalva/jwt-go/doc.go b/vendor/github.com/dgrijalva/jwt-go/doc.go deleted file mode 100644 index a86dc1a..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/doc.go +++ /dev/null @@ -1,4 +0,0 @@ -// Package jwt is a Go implementation of JSON Web Tokens: http://self-issued.info/docs/draft-jones-json-web-token.html -// -// See README.md for more info. -package jwt diff --git a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go b/vendor/github.com/dgrijalva/jwt-go/ecdsa.go deleted file mode 100644 index 0518ed1..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/ecdsa.go +++ /dev/null @@ -1,147 +0,0 @@ -package jwt - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rand" - "errors" - "math/big" -) - -var ( - // Sadly this is missing from crypto/ecdsa compared to crypto/rsa - ErrECDSAVerification = errors.New("crypto/ecdsa: verification error") -) - -// Implements the ECDSA family of signing methods signing methods -type SigningMethodECDSA struct { - Name string - Hash crypto.Hash - KeySize int - CurveBits int -} - -// Specific instances for EC256 and company -var ( - SigningMethodES256 *SigningMethodECDSA - SigningMethodES384 *SigningMethodECDSA - SigningMethodES512 *SigningMethodECDSA -) - -func init() { - // ES256 - SigningMethodES256 = &SigningMethodECDSA{"ES256", crypto.SHA256, 32, 256} - RegisterSigningMethod(SigningMethodES256.Alg(), func() SigningMethod { - return SigningMethodES256 - }) - - // ES384 - SigningMethodES384 = &SigningMethodECDSA{"ES384", crypto.SHA384, 48, 384} - RegisterSigningMethod(SigningMethodES384.Alg(), func() SigningMethod { - return SigningMethodES384 - }) - - // ES512 - SigningMethodES512 = &SigningMethodECDSA{"ES512", crypto.SHA512, 66, 521} - RegisterSigningMethod(SigningMethodES512.Alg(), func() SigningMethod { - return SigningMethodES512 - }) -} - -func (m *SigningMethodECDSA) Alg() string { - return m.Name -} - -// Implements the Verify method from SigningMethod -// For this verify method, key must be an ecdsa.PublicKey struct -func (m *SigningMethodECDSA) Verify(signingString, signature string, key interface{}) error { - var err error - - // Decode the signature - var sig []byte - if sig, err = DecodeSegment(signature); err != nil { - return err - } - - // Get the key - var ecdsaKey *ecdsa.PublicKey - switch k := key.(type) { - case *ecdsa.PublicKey: - ecdsaKey = k - default: - return ErrInvalidKey - } - - if len(sig) != 2*m.KeySize { - return ErrECDSAVerification - } - - r := big.NewInt(0).SetBytes(sig[:m.KeySize]) - s := big.NewInt(0).SetBytes(sig[m.KeySize:]) - - // Create hasher - if !m.Hash.Available() { - return ErrHashUnavailable - } - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Verify the signature - if verifystatus := ecdsa.Verify(ecdsaKey, hasher.Sum(nil), r, s); verifystatus == true { - return nil - } else { - return ErrECDSAVerification - } -} - -// Implements the Sign method from SigningMethod -// For this signing method, key must be an ecdsa.PrivateKey struct -func (m *SigningMethodECDSA) Sign(signingString string, key interface{}) (string, error) { - // Get the key - var ecdsaKey *ecdsa.PrivateKey - switch k := key.(type) { - case *ecdsa.PrivateKey: - ecdsaKey = k - default: - return "", ErrInvalidKey - } - - // Create the hasher - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Sign the string and return r, s - if r, s, err := ecdsa.Sign(rand.Reader, ecdsaKey, hasher.Sum(nil)); err == nil { - curveBits := ecdsaKey.Curve.Params().BitSize - - if m.CurveBits != curveBits { - return "", ErrInvalidKey - } - - keyBytes := curveBits / 8 - if curveBits%8 > 0 { - keyBytes += 1 - } - - // We serialize the outpus (r and s) into big-endian byte arrays and pad - // them with zeros on the left to make sure the sizes work out. Both arrays - // must be keyBytes long, and the output must be 2*keyBytes long. - rBytes := r.Bytes() - rBytesPadded := make([]byte, keyBytes) - copy(rBytesPadded[keyBytes-len(rBytes):], rBytes) - - sBytes := s.Bytes() - sBytesPadded := make([]byte, keyBytes) - copy(sBytesPadded[keyBytes-len(sBytes):], sBytes) - - out := append(rBytesPadded, sBytesPadded...) - - return EncodeSegment(out), nil - } else { - return "", err - } -} diff --git a/vendor/github.com/dgrijalva/jwt-go/ecdsa_test.go b/vendor/github.com/dgrijalva/jwt-go/ecdsa_test.go deleted file mode 100644 index 753047b..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/ecdsa_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package jwt_test - -import ( - "crypto/ecdsa" - "io/ioutil" - "strings" - "testing" - - "github.com/dgrijalva/jwt-go" -) - -var ecdsaTestData = []struct { - name string - keys map[string]string - tokenString string - alg string - claims map[string]interface{} - valid bool -}{ - { - "Basic ES256", - map[string]string{"private": "test/ec256-private.pem", "public": "test/ec256-public.pem"}, - "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJmb28iOiJiYXIifQ.feG39E-bn8HXAKhzDZq7yEAPWYDhZlwTn3sePJnU9VrGMmwdXAIEyoOnrjreYlVM_Z4N13eK9-TmMTWyfKJtHQ", - "ES256", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic ES384", - map[string]string{"private": "test/ec384-private.pem", "public": "test/ec384-public.pem"}, - "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzM4NCJ9.eyJmb28iOiJiYXIifQ.ngAfKMbJUh0WWubSIYe5GMsA-aHNKwFbJk_wq3lq23aPp8H2anb1rRILIzVR0gUf4a8WzDtrzmiikuPWyCS6CN4-PwdgTk-5nehC7JXqlaBZU05p3toM3nWCwm_LXcld", - "ES384", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic ES512", - map[string]string{"private": "test/ec512-private.pem", "public": "test/ec512-public.pem"}, - "eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzUxMiJ9.eyJmb28iOiJiYXIifQ.AAU0TvGQOcdg2OvrwY73NHKgfk26UDekh9Prz-L_iWuTBIBqOFCWwwLsRiHB1JOddfKAls5do1W0jR_F30JpVd-6AJeTjGKA4C1A1H6gIKwRY0o_tFDIydZCl_lMBMeG5VNFAjO86-WCSKwc3hqaGkq1MugPRq_qrF9AVbuEB4JPLyL5", - "ES512", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "basic ES256 invalid: foo => bar", - map[string]string{"private": "test/ec256-private.pem", "public": "test/ec256-public.pem"}, - "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.MEQCIHoSJnmGlPaVQDqacx_2XlXEhhqtWceVopjomc2PJLtdAiAUTeGPoNYxZw0z8mgOnnIcjoxRuNDVZvybRZF3wR1l8W", - "ES256", - map[string]interface{}{"foo": "bar"}, - false, - }, -} - -func TestECDSAVerify(t *testing.T) { - for _, data := range ecdsaTestData { - var err error - - key, _ := ioutil.ReadFile(data.keys["public"]) - - var ecdsaKey *ecdsa.PublicKey - if ecdsaKey, err = jwt.ParseECPublicKeyFromPEM(key); err != nil { - t.Errorf("Unable to parse ECDSA public key: %v", err) - } - - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - err = method.Verify(strings.Join(parts[0:2], "."), parts[2], ecdsaKey) - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying key: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid key passed validation", data.name) - } - } -} - -func TestECDSASign(t *testing.T) { - for _, data := range ecdsaTestData { - var err error - key, _ := ioutil.ReadFile(data.keys["private"]) - - var ecdsaKey *ecdsa.PrivateKey - if ecdsaKey, err = jwt.ParseECPrivateKeyFromPEM(key); err != nil { - t.Errorf("Unable to parse ECDSA private key: %v", err) - } - - if data.valid { - parts := strings.Split(data.tokenString, ".") - method := jwt.GetSigningMethod(data.alg) - sig, err := method.Sign(strings.Join(parts[0:2], "."), ecdsaKey) - if err != nil { - t.Errorf("[%v] Error signing token: %v", data.name, err) - } - if sig == parts[2] { - t.Errorf("[%v] Identical signatures\nbefore:\n%v\nafter:\n%v", data.name, parts[2], sig) - } - } - } -} diff --git a/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go b/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go deleted file mode 100644 index d19624b..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/ecdsa_utils.go +++ /dev/null @@ -1,67 +0,0 @@ -package jwt - -import ( - "crypto/ecdsa" - "crypto/x509" - "encoding/pem" - "errors" -) - -var ( - ErrNotECPublicKey = errors.New("Key is not a valid ECDSA public key") - ErrNotECPrivateKey = errors.New("Key is not a valid ECDSA private key") -) - -// Parse PEM encoded Elliptic Curve Private Key Structure -func ParseECPrivateKeyFromPEM(key []byte) (*ecdsa.PrivateKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParseECPrivateKey(block.Bytes); err != nil { - return nil, err - } - - var pkey *ecdsa.PrivateKey - var ok bool - if pkey, ok = parsedKey.(*ecdsa.PrivateKey); !ok { - return nil, ErrNotECPrivateKey - } - - return pkey, nil -} - -// Parse PEM encoded PKCS1 or PKCS8 public key -func ParseECPublicKeyFromPEM(key []byte) (*ecdsa.PublicKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { - if cert, err := x509.ParseCertificate(block.Bytes); err == nil { - parsedKey = cert.PublicKey - } else { - return nil, err - } - } - - var pkey *ecdsa.PublicKey - var ok bool - if pkey, ok = parsedKey.(*ecdsa.PublicKey); !ok { - return nil, ErrNotECPublicKey - } - - return pkey, nil -} diff --git a/vendor/github.com/dgrijalva/jwt-go/errors.go b/vendor/github.com/dgrijalva/jwt-go/errors.go deleted file mode 100644 index a6b60a3..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/errors.go +++ /dev/null @@ -1,51 +0,0 @@ -package jwt - -import ( - "errors" -) - -// Error constants -var ( - ErrInvalidKey = errors.New("key is invalid or of invalid type") - ErrHashUnavailable = errors.New("the requested hash function is unavailable") - ErrNoTokenInRequest = errors.New("no token present in request") -) - -// The errors that might occur when parsing and validating a token -const ( - ValidationErrorMalformed uint32 = 1 << iota // Token is malformed - ValidationErrorUnverifiable // Token could not be verified because of signing problems - ValidationErrorSignatureInvalid // Signature validation failed - ValidationErrorExpired // Exp validation failed - ValidationErrorNotValidYet // NBF validation failed -) - -// Helper for constructing a ValidationError with a string error message -func NewValidationError(errorText string, errorFlags uint32) *ValidationError { - return &ValidationError{ - Inner: errors.New(errorText), - Errors: errorFlags, - } -} - -// The error from Parse if token is not valid -type ValidationError struct { - Inner error // stores the error returned by external dependencies, i.e.: KeyFunc - Errors uint32 // bitfield. see ValidationError... constants -} - -// Validation error is an error type -func (e ValidationError) Error() string { - if e.Inner == nil { - return "token is invalid" - } - return e.Inner.Error() -} - -// No errors -func (e *ValidationError) valid() bool { - if e.Errors > 0 { - return false - } - return true -} diff --git a/vendor/github.com/dgrijalva/jwt-go/example_test.go b/vendor/github.com/dgrijalva/jwt-go/example_test.go deleted file mode 100644 index edb48e4..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/example_test.go +++ /dev/null @@ -1,52 +0,0 @@ -package jwt_test - -import ( - "fmt" - "github.com/dgrijalva/jwt-go" - "time" -) - -func ExampleParse(myToken string, myLookupKey func(interface{}) (interface{}, error)) { - token, err := jwt.Parse(myToken, func(token *jwt.Token) (interface{}, error) { - return myLookupKey(token.Header["kid"]) - }) - - if err == nil && token.Valid { - fmt.Println("Your token is valid. I like your style.") - } else { - fmt.Println("This token is terrible! I cannot accept this.") - } -} - -func ExampleNew(mySigningKey []byte) (string, error) { - // Create the token - token := jwt.New(jwt.SigningMethodHS256) - // Set some claims - token.Claims["foo"] = "bar" - token.Claims["exp"] = time.Now().Add(time.Hour * 72).Unix() - // Sign and get the complete encoded token as a string - tokenString, err := token.SignedString(mySigningKey) - return tokenString, err -} - -func ExampleParse_errorChecking(myToken string, myLookupKey func(interface{}) (interface{}, error)) { - token, err := jwt.Parse(myToken, func(token *jwt.Token) (interface{}, error) { - return myLookupKey(token.Header["kid"]) - }) - - if token.Valid { - fmt.Println("You look nice today") - } else if ve, ok := err.(*jwt.ValidationError); ok { - if ve.Errors&jwt.ValidationErrorMalformed != 0 { - fmt.Println("That's not even a token") - } else if ve.Errors&(jwt.ValidationErrorExpired|jwt.ValidationErrorNotValidYet) != 0 { - // Token is either expired or not active yet - fmt.Println("Timing is everything") - } else { - fmt.Println("Couldn't handle this token:", err) - } - } else { - fmt.Println("Couldn't handle this token:", err) - } - -} diff --git a/vendor/github.com/dgrijalva/jwt-go/hmac.go b/vendor/github.com/dgrijalva/jwt-go/hmac.go deleted file mode 100644 index 192e625..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/hmac.go +++ /dev/null @@ -1,94 +0,0 @@ -package jwt - -import ( - "crypto" - "crypto/hmac" - "errors" -) - -// Implements the HMAC-SHA family of signing methods signing methods -type SigningMethodHMAC struct { - Name string - Hash crypto.Hash -} - -// Specific instances for HS256 and company -var ( - SigningMethodHS256 *SigningMethodHMAC - SigningMethodHS384 *SigningMethodHMAC - SigningMethodHS512 *SigningMethodHMAC - ErrSignatureInvalid = errors.New("signature is invalid") -) - -func init() { - // HS256 - SigningMethodHS256 = &SigningMethodHMAC{"HS256", crypto.SHA256} - RegisterSigningMethod(SigningMethodHS256.Alg(), func() SigningMethod { - return SigningMethodHS256 - }) - - // HS384 - SigningMethodHS384 = &SigningMethodHMAC{"HS384", crypto.SHA384} - RegisterSigningMethod(SigningMethodHS384.Alg(), func() SigningMethod { - return SigningMethodHS384 - }) - - // HS512 - SigningMethodHS512 = &SigningMethodHMAC{"HS512", crypto.SHA512} - RegisterSigningMethod(SigningMethodHS512.Alg(), func() SigningMethod { - return SigningMethodHS512 - }) -} - -func (m *SigningMethodHMAC) Alg() string { - return m.Name -} - -// Verify the signature of HSXXX tokens. Returns nil if the signature is valid. -func (m *SigningMethodHMAC) Verify(signingString, signature string, key interface{}) error { - // Verify the key is the right type - keyBytes, ok := key.([]byte) - if !ok { - return ErrInvalidKey - } - - // Decode signature, for comparison - sig, err := DecodeSegment(signature) - if err != nil { - return err - } - - // Can we use the specified hashing method? - if !m.Hash.Available() { - return ErrHashUnavailable - } - - // This signing method is symmetric, so we validate the signature - // by reproducing the signature from the signing string and key, then - // comparing that against the provided signature. - hasher := hmac.New(m.Hash.New, keyBytes) - hasher.Write([]byte(signingString)) - if !hmac.Equal(sig, hasher.Sum(nil)) { - return ErrSignatureInvalid - } - - // No validation errors. Signature is good. - return nil -} - -// Implements the Sign method from SigningMethod for this signing method. -// Key must be []byte -func (m *SigningMethodHMAC) Sign(signingString string, key interface{}) (string, error) { - if keyBytes, ok := key.([]byte); ok { - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := hmac.New(m.Hash.New, keyBytes) - hasher.Write([]byte(signingString)) - - return EncodeSegment(hasher.Sum(nil)), nil - } - - return "", ErrInvalidKey -} diff --git a/vendor/github.com/dgrijalva/jwt-go/hmac_test.go b/vendor/github.com/dgrijalva/jwt-go/hmac_test.go deleted file mode 100644 index c7e114f..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/hmac_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package jwt_test - -import ( - "github.com/dgrijalva/jwt-go" - "io/ioutil" - "strings" - "testing" -) - -var hmacTestData = []struct { - name string - tokenString string - alg string - claims map[string]interface{} - valid bool -}{ - { - "web sample", - "eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk", - "HS256", - map[string]interface{}{"iss": "joe", "exp": 1300819380, "http://example.com/is_root": true}, - true, - }, - { - "HS384", - "eyJhbGciOiJIUzM4NCIsInR5cCI6IkpXVCJ9.eyJleHAiOjEuMzAwODE5MzhlKzA5LCJodHRwOi8vZXhhbXBsZS5jb20vaXNfcm9vdCI6dHJ1ZSwiaXNzIjoiam9lIn0.KWZEuOD5lbBxZ34g7F-SlVLAQ_r5KApWNWlZIIMyQVz5Zs58a7XdNzj5_0EcNoOy", - "HS384", - map[string]interface{}{"iss": "joe", "exp": 1300819380, "http://example.com/is_root": true}, - true, - }, - { - "HS512", - "eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJleHAiOjEuMzAwODE5MzhlKzA5LCJodHRwOi8vZXhhbXBsZS5jb20vaXNfcm9vdCI6dHJ1ZSwiaXNzIjoiam9lIn0.CN7YijRX6Aw1n2jyI2Id1w90ja-DEMYiWixhYCyHnrZ1VfJRaFQz1bEbjjA5Fn4CLYaUG432dEYmSbS4Saokmw", - "HS512", - map[string]interface{}{"iss": "joe", "exp": 1300819380, "http://example.com/is_root": true}, - true, - }, - { - "web sample: invalid", - "eyJ0eXAiOiJKV1QiLA0KICJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJqb2UiLA0KICJleHAiOjEzMDA4MTkzODAsDQogImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlfQ.dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXo", - "HS256", - map[string]interface{}{"iss": "joe", "exp": 1300819380, "http://example.com/is_root": true}, - false, - }, -} - -// Sample data from http://tools.ietf.org/html/draft-jones-json-web-signature-04#appendix-A.1 -var hmacTestKey, _ = ioutil.ReadFile("test/hmacTestKey") - -func TestHMACVerify(t *testing.T) { - for _, data := range hmacTestData { - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - err := method.Verify(strings.Join(parts[0:2], "."), parts[2], hmacTestKey) - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying key: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid key passed validation", data.name) - } - } -} - -func TestHMACSign(t *testing.T) { - for _, data := range hmacTestData { - if data.valid { - parts := strings.Split(data.tokenString, ".") - method := jwt.GetSigningMethod(data.alg) - sig, err := method.Sign(strings.Join(parts[0:2], "."), hmacTestKey) - if err != nil { - t.Errorf("[%v] Error signing token: %v", data.name, err) - } - if sig != parts[2] { - t.Errorf("[%v] Incorrect signature.\nwas:\n%v\nexpecting:\n%v", data.name, sig, parts[2]) - } - } - } -} - -func BenchmarkHS256Signing(b *testing.B) { - benchmarkSigning(b, jwt.SigningMethodHS256, hmacTestKey) -} - -func BenchmarkHS384Signing(b *testing.B) { - benchmarkSigning(b, jwt.SigningMethodHS384, hmacTestKey) -} - -func BenchmarkHS512Signing(b *testing.B) { - benchmarkSigning(b, jwt.SigningMethodHS512, hmacTestKey) -} diff --git a/vendor/github.com/dgrijalva/jwt-go/none.go b/vendor/github.com/dgrijalva/jwt-go/none.go deleted file mode 100644 index f04d189..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/none.go +++ /dev/null @@ -1,52 +0,0 @@ -package jwt - -// Implements the none signing method. This is required by the spec -// but you probably should never use it. -var SigningMethodNone *signingMethodNone - -const UnsafeAllowNoneSignatureType unsafeNoneMagicConstant = "none signing method allowed" - -var NoneSignatureTypeDisallowedError error - -type signingMethodNone struct{} -type unsafeNoneMagicConstant string - -func init() { - SigningMethodNone = &signingMethodNone{} - NoneSignatureTypeDisallowedError = NewValidationError("'none' signature type is not allowed", ValidationErrorSignatureInvalid) - - RegisterSigningMethod(SigningMethodNone.Alg(), func() SigningMethod { - return SigningMethodNone - }) -} - -func (m *signingMethodNone) Alg() string { - return "none" -} - -// Only allow 'none' alg type if UnsafeAllowNoneSignatureType is specified as the key -func (m *signingMethodNone) Verify(signingString, signature string, key interface{}) (err error) { - // Key must be UnsafeAllowNoneSignatureType to prevent accidentally - // accepting 'none' signing method - if _, ok := key.(unsafeNoneMagicConstant); !ok { - return NoneSignatureTypeDisallowedError - } - // If signing method is none, signature must be an empty string - if signature != "" { - return NewValidationError( - "'none' signing method with non-empty signature", - ValidationErrorSignatureInvalid, - ) - } - - // Accept 'none' signing method. - return nil -} - -// Only allow 'none' signing if UnsafeAllowNoneSignatureType is specified as the key -func (m *signingMethodNone) Sign(signingString string, key interface{}) (string, error) { - if _, ok := key.(unsafeNoneMagicConstant); ok { - return "", nil - } - return "", NoneSignatureTypeDisallowedError -} diff --git a/vendor/github.com/dgrijalva/jwt-go/none_test.go b/vendor/github.com/dgrijalva/jwt-go/none_test.go deleted file mode 100644 index 29a69ef..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/none_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package jwt_test - -import ( - "github.com/dgrijalva/jwt-go" - "strings" - "testing" -) - -var noneTestData = []struct { - name string - tokenString string - alg string - key interface{} - claims map[string]interface{} - valid bool -}{ - { - "Basic", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.", - "none", - jwt.UnsafeAllowNoneSignatureType, - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic - no key", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.", - "none", - nil, - map[string]interface{}{"foo": "bar"}, - false, - }, - { - "Signed", - "eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.W-jEzRfBigtCWsinvVVuldiuilzVdU5ty0MvpLaSaqK9PlAWWlDQ1VIQ_qSKzwL5IXaZkvZFJXT3yL3n7OUVu7zCNJzdwznbC8Z-b0z2lYvcklJYi2VOFRcGbJtXUqgjk2oGsiqUMUMOLP70TTefkpsgqDxbRh9CDUfpOJgW-dU7cmgaoswe3wjUAUi6B6G2YEaiuXC0XScQYSYVKIzgKXJV8Zw-7AN_DBUI4GkTpsvQ9fVVjZM9csQiEXhYekyrKu1nu_POpQonGd8yqkIyXPECNmmqH5jH4sFiF67XhD7_JpkvLziBpI-uh86evBUadmHhb9Otqw3uV3NTaXLzJw", - "none", - jwt.UnsafeAllowNoneSignatureType, - map[string]interface{}{"foo": "bar"}, - false, - }, -} - -func TestNoneVerify(t *testing.T) { - for _, data := range noneTestData { - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - err := method.Verify(strings.Join(parts[0:2], "."), parts[2], data.key) - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying key: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid key passed validation", data.name) - } - } -} - -func TestNoneSign(t *testing.T) { - for _, data := range noneTestData { - if data.valid { - parts := strings.Split(data.tokenString, ".") - method := jwt.GetSigningMethod(data.alg) - sig, err := method.Sign(strings.Join(parts[0:2], "."), data.key) - if err != nil { - t.Errorf("[%v] Error signing token: %v", data.name, err) - } - if sig != parts[2] { - t.Errorf("[%v] Incorrect signature.\nwas:\n%v\nexpecting:\n%v", data.name, sig, parts[2]) - } - } - } -} diff --git a/vendor/github.com/dgrijalva/jwt-go/parser.go b/vendor/github.com/dgrijalva/jwt-go/parser.go deleted file mode 100644 index fbde9cb..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/parser.go +++ /dev/null @@ -1,140 +0,0 @@ -package jwt - -import ( - "bytes" - "encoding/json" - "fmt" - "strings" - "time" -) - -type Parser struct { - ValidMethods []string // If populated, only these methods will be considered valid - UseJSONNumber bool // Use JSON Number format in JSON decoder -} - -// Parse, validate, and return a token. -// keyFunc will receive the parsed token and should return the key for validating. -// If everything is kosher, err will be nil -func (p *Parser) Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { - parts := strings.Split(tokenString, ".") - if len(parts) != 3 { - return nil, NewValidationError("token contains an invalid number of segments", ValidationErrorMalformed) - } - - var err error - token := &Token{Raw: tokenString} - // parse Header - var headerBytes []byte - if headerBytes, err = DecodeSegment(parts[0]); err != nil { - if strings.HasPrefix(strings.ToLower(tokenString), "bearer ") { - return token, NewValidationError("tokenstring should not contain 'bearer '", ValidationErrorMalformed) - } - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - if err = json.Unmarshal(headerBytes, &token.Header); err != nil { - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // parse Claims - var claimBytes []byte - if claimBytes, err = DecodeSegment(parts[1]); err != nil { - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - dec := json.NewDecoder(bytes.NewBuffer(claimBytes)) - if p.UseJSONNumber { - dec.UseNumber() - } - if err = dec.Decode(&token.Claims); err != nil { - return token, &ValidationError{Inner: err, Errors: ValidationErrorMalformed} - } - - // Lookup signature method - if method, ok := token.Header["alg"].(string); ok { - if token.Method = GetSigningMethod(method); token.Method == nil { - return token, NewValidationError("signing method (alg) is unavailable.", ValidationErrorUnverifiable) - } - } else { - return token, NewValidationError("signing method (alg) is unspecified.", ValidationErrorUnverifiable) - } - - // Verify signing method is in the required set - if p.ValidMethods != nil { - var signingMethodValid = false - var alg = token.Method.Alg() - for _, m := range p.ValidMethods { - if m == alg { - signingMethodValid = true - break - } - } - if !signingMethodValid { - // signing method is not in the listed set - return token, NewValidationError(fmt.Sprintf("signing method %v is invalid", alg), ValidationErrorSignatureInvalid) - } - } - - // Lookup key - var key interface{} - if keyFunc == nil { - // keyFunc was not provided. short circuiting validation - return token, NewValidationError("no Keyfunc was provided.", ValidationErrorUnverifiable) - } - if key, err = keyFunc(token); err != nil { - // keyFunc returned an error - return token, &ValidationError{Inner: err, Errors: ValidationErrorUnverifiable} - } - - // Check expiration times - vErr := &ValidationError{} - now := TimeFunc().Unix() - var exp, nbf int64 - var vexp, vnbf bool - - // Parse 'exp' claim - switch num := token.Claims["exp"].(type) { - case json.Number: - if exp, err = num.Int64(); err == nil { - vexp = true - } - case float64: - vexp = true - exp = int64(num) - } - - // Parse 'nbf' claim - switch num := token.Claims["nbf"].(type) { - case json.Number: - if nbf, err = num.Int64(); err == nil { - vnbf = true - } - case float64: - vnbf = true - nbf = int64(num) - } - - if vexp && now > exp { - delta := time.Unix(now, 0).Sub(time.Unix(exp, 0)) - vErr.Inner = fmt.Errorf("token is expired by %v", delta) - vErr.Errors |= ValidationErrorExpired - } - - if vnbf && now < nbf { - vErr.Inner = fmt.Errorf("token is not valid yet") - vErr.Errors |= ValidationErrorNotValidYet - } - - // Perform validation - token.Signature = parts[2] - if err = token.Method.Verify(strings.Join(parts[0:2], "."), token.Signature, key); err != nil { - vErr.Inner = err - vErr.Errors |= ValidationErrorSignatureInvalid - } - - if vErr.valid() { - token.Valid = true - return token, nil - } - - return token, vErr -} diff --git a/vendor/github.com/dgrijalva/jwt-go/parser_test.go b/vendor/github.com/dgrijalva/jwt-go/parser_test.go deleted file mode 100644 index f1b7d2a..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/parser_test.go +++ /dev/null @@ -1,275 +0,0 @@ -package jwt_test - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "reflect" - "testing" - "time" - - "github.com/dgrijalva/jwt-go" -) - -var keyFuncError error = fmt.Errorf("error loading key") - -var ( - jwtTestDefaultKey []byte - defaultKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) { return jwtTestDefaultKey, nil } - emptyKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) { return nil, nil } - errorKeyFunc jwt.Keyfunc = func(t *jwt.Token) (interface{}, error) { return nil, keyFuncError } - nilKeyFunc jwt.Keyfunc = nil -) - -var jwtTestData = []struct { - name string - tokenString string - keyfunc jwt.Keyfunc - claims map[string]interface{} - valid bool - errors uint32 - parser *jwt.Parser -}{ - { - "basic", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.FhkiHkoESI_cG3NPigFrxEk9Z60_oXrOT2vGm9Pn6RDgYNovYORQmmA0zs1AoAOf09ly2Nx2YAg6ABqAYga1AcMFkJljwxTT5fYphTuqpWdy4BELeSYJx5Ty2gmr8e7RonuUztrdD5WfPqLKMm1Ozp_T6zALpRmwTIW0QPnaBXaQD90FplAg46Iy1UlDKr-Eupy0i5SLch5Q-p2ZpaL_5fnTIUDlxC3pWhJTyx_71qDI-mAA_5lE_VdroOeflG56sSmDxopPEG3bFlSu1eowyBfxtu0_CuVd-M42RU75Zc4Gsj6uV77MBtbMrf4_7M_NUTSgoIF3fRqxrj0NzihIBg", - defaultKeyFunc, - map[string]interface{}{"foo": "bar"}, - true, - 0, - nil, - }, - { - "basic expired", - "", // autogen - defaultKeyFunc, - map[string]interface{}{"foo": "bar", "exp": float64(time.Now().Unix() - 100)}, - false, - jwt.ValidationErrorExpired, - nil, - }, - { - "basic nbf", - "", // autogen - defaultKeyFunc, - map[string]interface{}{"foo": "bar", "nbf": float64(time.Now().Unix() + 100)}, - false, - jwt.ValidationErrorNotValidYet, - nil, - }, - { - "expired and nbf", - "", // autogen - defaultKeyFunc, - map[string]interface{}{"foo": "bar", "nbf": float64(time.Now().Unix() + 100), "exp": float64(time.Now().Unix() - 100)}, - false, - jwt.ValidationErrorNotValidYet | jwt.ValidationErrorExpired, - nil, - }, - { - "basic invalid", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.EhkiHkoESI_cG3NPigFrxEk9Z60_oXrOT2vGm9Pn6RDgYNovYORQmmA0zs1AoAOf09ly2Nx2YAg6ABqAYga1AcMFkJljwxTT5fYphTuqpWdy4BELeSYJx5Ty2gmr8e7RonuUztrdD5WfPqLKMm1Ozp_T6zALpRmwTIW0QPnaBXaQD90FplAg46Iy1UlDKr-Eupy0i5SLch5Q-p2ZpaL_5fnTIUDlxC3pWhJTyx_71qDI-mAA_5lE_VdroOeflG56sSmDxopPEG3bFlSu1eowyBfxtu0_CuVd-M42RU75Zc4Gsj6uV77MBtbMrf4_7M_NUTSgoIF3fRqxrj0NzihIBg", - defaultKeyFunc, - map[string]interface{}{"foo": "bar"}, - false, - jwt.ValidationErrorSignatureInvalid, - nil, - }, - { - "basic nokeyfunc", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.FhkiHkoESI_cG3NPigFrxEk9Z60_oXrOT2vGm9Pn6RDgYNovYORQmmA0zs1AoAOf09ly2Nx2YAg6ABqAYga1AcMFkJljwxTT5fYphTuqpWdy4BELeSYJx5Ty2gmr8e7RonuUztrdD5WfPqLKMm1Ozp_T6zALpRmwTIW0QPnaBXaQD90FplAg46Iy1UlDKr-Eupy0i5SLch5Q-p2ZpaL_5fnTIUDlxC3pWhJTyx_71qDI-mAA_5lE_VdroOeflG56sSmDxopPEG3bFlSu1eowyBfxtu0_CuVd-M42RU75Zc4Gsj6uV77MBtbMrf4_7M_NUTSgoIF3fRqxrj0NzihIBg", - nilKeyFunc, - map[string]interface{}{"foo": "bar"}, - false, - jwt.ValidationErrorUnverifiable, - nil, - }, - { - "basic nokey", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.FhkiHkoESI_cG3NPigFrxEk9Z60_oXrOT2vGm9Pn6RDgYNovYORQmmA0zs1AoAOf09ly2Nx2YAg6ABqAYga1AcMFkJljwxTT5fYphTuqpWdy4BELeSYJx5Ty2gmr8e7RonuUztrdD5WfPqLKMm1Ozp_T6zALpRmwTIW0QPnaBXaQD90FplAg46Iy1UlDKr-Eupy0i5SLch5Q-p2ZpaL_5fnTIUDlxC3pWhJTyx_71qDI-mAA_5lE_VdroOeflG56sSmDxopPEG3bFlSu1eowyBfxtu0_CuVd-M42RU75Zc4Gsj6uV77MBtbMrf4_7M_NUTSgoIF3fRqxrj0NzihIBg", - emptyKeyFunc, - map[string]interface{}{"foo": "bar"}, - false, - jwt.ValidationErrorSignatureInvalid, - nil, - }, - { - "basic errorkey", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.FhkiHkoESI_cG3NPigFrxEk9Z60_oXrOT2vGm9Pn6RDgYNovYORQmmA0zs1AoAOf09ly2Nx2YAg6ABqAYga1AcMFkJljwxTT5fYphTuqpWdy4BELeSYJx5Ty2gmr8e7RonuUztrdD5WfPqLKMm1Ozp_T6zALpRmwTIW0QPnaBXaQD90FplAg46Iy1UlDKr-Eupy0i5SLch5Q-p2ZpaL_5fnTIUDlxC3pWhJTyx_71qDI-mAA_5lE_VdroOeflG56sSmDxopPEG3bFlSu1eowyBfxtu0_CuVd-M42RU75Zc4Gsj6uV77MBtbMrf4_7M_NUTSgoIF3fRqxrj0NzihIBg", - errorKeyFunc, - map[string]interface{}{"foo": "bar"}, - false, - jwt.ValidationErrorUnverifiable, - nil, - }, - { - "invalid signing method", - "", - defaultKeyFunc, - map[string]interface{}{"foo": "bar"}, - false, - jwt.ValidationErrorSignatureInvalid, - &jwt.Parser{ValidMethods: []string{"HS256"}}, - }, - { - "valid signing method", - "", - defaultKeyFunc, - map[string]interface{}{"foo": "bar"}, - true, - 0, - &jwt.Parser{ValidMethods: []string{"RS256", "HS256"}}, - }, - { - "JSON Number", - "", - defaultKeyFunc, - map[string]interface{}{"foo": json.Number("123.4")}, - true, - 0, - &jwt.Parser{UseJSONNumber: true}, - }, - { - "JSON Number - basic expired", - "", // autogen - defaultKeyFunc, - map[string]interface{}{"foo": "bar", "exp": json.Number(fmt.Sprintf("%v", time.Now().Unix()-100))}, - false, - jwt.ValidationErrorExpired, - &jwt.Parser{UseJSONNumber: true}, - }, - { - "JSON Number - basic nbf", - "", // autogen - defaultKeyFunc, - map[string]interface{}{"foo": "bar", "nbf": json.Number(fmt.Sprintf("%v", time.Now().Unix()+100))}, - false, - jwt.ValidationErrorNotValidYet, - &jwt.Parser{UseJSONNumber: true}, - }, - { - "JSON Number - expired and nbf", - "", // autogen - defaultKeyFunc, - map[string]interface{}{"foo": "bar", "nbf": json.Number(fmt.Sprintf("%v", time.Now().Unix()+100)), "exp": json.Number(fmt.Sprintf("%v", time.Now().Unix()-100))}, - false, - jwt.ValidationErrorNotValidYet | jwt.ValidationErrorExpired, - &jwt.Parser{UseJSONNumber: true}, - }, -} - -func init() { - var e error - if jwtTestDefaultKey, e = ioutil.ReadFile("test/sample_key.pub"); e != nil { - panic(e) - } -} - -func makeSample(c map[string]interface{}) string { - key, e := ioutil.ReadFile("test/sample_key") - if e != nil { - panic(e.Error()) - } - - token := jwt.New(jwt.SigningMethodRS256) - token.Claims = c - s, e := token.SignedString(key) - - if e != nil { - panic(e.Error()) - } - - return s -} - -func TestParser_Parse(t *testing.T) { - for _, data := range jwtTestData { - if data.tokenString == "" { - data.tokenString = makeSample(data.claims) - } - - var token *jwt.Token - var err error - if data.parser != nil { - token, err = data.parser.Parse(data.tokenString, data.keyfunc) - } else { - token, err = jwt.Parse(data.tokenString, data.keyfunc) - } - - if !reflect.DeepEqual(data.claims, token.Claims) { - t.Errorf("[%v] Claims mismatch. Expecting: %v Got: %v", data.name, data.claims, token.Claims) - } - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying token: %T:%v", data.name, err, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid token passed validation", data.name) - } - if data.errors != 0 { - if err == nil { - t.Errorf("[%v] Expecting error. Didn't get one.", data.name) - } else { - - ve := err.(*jwt.ValidationError) - // compare the bitfield part of the error - if e := ve.Errors; e != data.errors { - t.Errorf("[%v] Errors don't match expectation. %v != %v", data.name, e, data.errors) - } - - if err.Error() == keyFuncError.Error() && ve.Inner != keyFuncError { - t.Errorf("[%v] Inner error does not match expectation. %v != %v", data.name, ve.Inner, keyFuncError) - } - } - } - if data.valid && token.Signature == "" { - t.Errorf("[%v] Signature is left unpopulated after parsing", data.name) - } - } -} - -func TestParseRequest(t *testing.T) { - // Bearer token request - for _, data := range jwtTestData { - // FIXME: custom parsers are not supported by this helper. skip tests that require them - if data.parser != nil { - t.Logf("Skipping [%v]. Custom parsers are not supported by ParseRequest", data.name) - continue - } - - if data.tokenString == "" { - data.tokenString = makeSample(data.claims) - } - - r, _ := http.NewRequest("GET", "/", nil) - r.Header.Set("Authorization", fmt.Sprintf("Bearer %v", data.tokenString)) - token, err := jwt.ParseFromRequest(r, data.keyfunc) - - if token == nil { - t.Errorf("[%v] Token was not found: %v", data.name, err) - continue - } - if !reflect.DeepEqual(data.claims, token.Claims) { - t.Errorf("[%v] Claims mismatch. Expecting: %v Got: %v", data.name, data.claims, token.Claims) - } - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying token: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid token passed validation", data.name) - } - } -} - -// Helper method for benchmarking various methods -func benchmarkSigning(b *testing.B, method jwt.SigningMethod, key interface{}) { - t := jwt.New(method) - b.RunParallel(func(pb *testing.PB) { - for pb.Next() { - if _, err := t.SignedString(key); err != nil { - b.Fatal(err) - } - } - }) - -} diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa.go b/vendor/github.com/dgrijalva/jwt-go/rsa.go deleted file mode 100644 index cddffce..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/rsa.go +++ /dev/null @@ -1,114 +0,0 @@ -package jwt - -import ( - "crypto" - "crypto/rand" - "crypto/rsa" -) - -// Implements the RSA family of signing methods signing methods -type SigningMethodRSA struct { - Name string - Hash crypto.Hash -} - -// Specific instances for RS256 and company -var ( - SigningMethodRS256 *SigningMethodRSA - SigningMethodRS384 *SigningMethodRSA - SigningMethodRS512 *SigningMethodRSA -) - -func init() { - // RS256 - SigningMethodRS256 = &SigningMethodRSA{"RS256", crypto.SHA256} - RegisterSigningMethod(SigningMethodRS256.Alg(), func() SigningMethod { - return SigningMethodRS256 - }) - - // RS384 - SigningMethodRS384 = &SigningMethodRSA{"RS384", crypto.SHA384} - RegisterSigningMethod(SigningMethodRS384.Alg(), func() SigningMethod { - return SigningMethodRS384 - }) - - // RS512 - SigningMethodRS512 = &SigningMethodRSA{"RS512", crypto.SHA512} - RegisterSigningMethod(SigningMethodRS512.Alg(), func() SigningMethod { - return SigningMethodRS512 - }) -} - -func (m *SigningMethodRSA) Alg() string { - return m.Name -} - -// Implements the Verify method from SigningMethod -// For this signing method, must be either a PEM encoded PKCS1 or PKCS8 RSA public key as -// []byte, or an rsa.PublicKey structure. -func (m *SigningMethodRSA) Verify(signingString, signature string, key interface{}) error { - var err error - - // Decode the signature - var sig []byte - if sig, err = DecodeSegment(signature); err != nil { - return err - } - - var rsaKey *rsa.PublicKey - - switch k := key.(type) { - case []byte: - if rsaKey, err = ParseRSAPublicKeyFromPEM(k); err != nil { - return err - } - case *rsa.PublicKey: - rsaKey = k - default: - return ErrInvalidKey - } - - // Create hasher - if !m.Hash.Available() { - return ErrHashUnavailable - } - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Verify the signature - return rsa.VerifyPKCS1v15(rsaKey, m.Hash, hasher.Sum(nil), sig) -} - -// Implements the Sign method from SigningMethod -// For this signing method, must be either a PEM encoded PKCS1 or PKCS8 RSA private key as -// []byte, or an rsa.PrivateKey structure. -func (m *SigningMethodRSA) Sign(signingString string, key interface{}) (string, error) { - var err error - var rsaKey *rsa.PrivateKey - - switch k := key.(type) { - case []byte: - if rsaKey, err = ParseRSAPrivateKeyFromPEM(k); err != nil { - return "", err - } - case *rsa.PrivateKey: - rsaKey = k - default: - return "", ErrInvalidKey - } - - // Create the hasher - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Sign the string and return the encoded bytes - if sigBytes, err := rsa.SignPKCS1v15(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil)); err == nil { - return EncodeSegment(sigBytes), nil - } else { - return "", err - } -} diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go b/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go deleted file mode 100644 index b5b7073..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_pss.go +++ /dev/null @@ -1,126 +0,0 @@ -// +build go1.4 - -package jwt - -import ( - "crypto" - "crypto/rand" - "crypto/rsa" -) - -// Implements the RSAPSS family of signing methods signing methods -type SigningMethodRSAPSS struct { - *SigningMethodRSA - Options *rsa.PSSOptions -} - -// Specific instances for RS/PS and company -var ( - SigningMethodPS256 *SigningMethodRSAPSS - SigningMethodPS384 *SigningMethodRSAPSS - SigningMethodPS512 *SigningMethodRSAPSS -) - -func init() { - // PS256 - SigningMethodPS256 = &SigningMethodRSAPSS{ - &SigningMethodRSA{ - Name: "PS256", - Hash: crypto.SHA256, - }, - &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - Hash: crypto.SHA256, - }, - } - RegisterSigningMethod(SigningMethodPS256.Alg(), func() SigningMethod { - return SigningMethodPS256 - }) - - // PS384 - SigningMethodPS384 = &SigningMethodRSAPSS{ - &SigningMethodRSA{ - Name: "PS384", - Hash: crypto.SHA384, - }, - &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - Hash: crypto.SHA384, - }, - } - RegisterSigningMethod(SigningMethodPS384.Alg(), func() SigningMethod { - return SigningMethodPS384 - }) - - // PS512 - SigningMethodPS512 = &SigningMethodRSAPSS{ - &SigningMethodRSA{ - Name: "PS512", - Hash: crypto.SHA512, - }, - &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - Hash: crypto.SHA512, - }, - } - RegisterSigningMethod(SigningMethodPS512.Alg(), func() SigningMethod { - return SigningMethodPS512 - }) -} - -// Implements the Verify method from SigningMethod -// For this verify method, key must be an rsa.PublicKey struct -func (m *SigningMethodRSAPSS) Verify(signingString, signature string, key interface{}) error { - var err error - - // Decode the signature - var sig []byte - if sig, err = DecodeSegment(signature); err != nil { - return err - } - - var rsaKey *rsa.PublicKey - switch k := key.(type) { - case *rsa.PublicKey: - rsaKey = k - default: - return ErrInvalidKey - } - - // Create hasher - if !m.Hash.Available() { - return ErrHashUnavailable - } - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - return rsa.VerifyPSS(rsaKey, m.Hash, hasher.Sum(nil), sig, m.Options) -} - -// Implements the Sign method from SigningMethod -// For this signing method, key must be an rsa.PrivateKey struct -func (m *SigningMethodRSAPSS) Sign(signingString string, key interface{}) (string, error) { - var rsaKey *rsa.PrivateKey - - switch k := key.(type) { - case *rsa.PrivateKey: - rsaKey = k - default: - return "", ErrInvalidKey - } - - // Create the hasher - if !m.Hash.Available() { - return "", ErrHashUnavailable - } - - hasher := m.Hash.New() - hasher.Write([]byte(signingString)) - - // Sign the string and return the encoded bytes - if sigBytes, err := rsa.SignPSS(rand.Reader, rsaKey, m.Hash, hasher.Sum(nil), m.Options); err == nil { - return EncodeSegment(sigBytes), nil - } else { - return "", err - } -} diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_pss_test.go b/vendor/github.com/dgrijalva/jwt-go/rsa_pss_test.go deleted file mode 100644 index 9045aaf..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_pss_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// +build go1.4 - -package jwt_test - -import ( - "crypto/rsa" - "io/ioutil" - "strings" - "testing" - - "github.com/dgrijalva/jwt-go" -) - -var rsaPSSTestData = []struct { - name string - tokenString string - alg string - claims map[string]interface{} - valid bool -}{ - { - "Basic PS256", - "eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.PPG4xyDVY8ffp4CcxofNmsTDXsrVG2npdQuibLhJbv4ClyPTUtR5giNSvuxo03kB6I8VXVr0Y9X7UxhJVEoJOmULAwRWaUsDnIewQa101cVhMa6iR8X37kfFoiZ6NkS-c7henVkkQWu2HtotkEtQvN5hFlk8IevXXPmvZlhQhwzB1sGzGYnoi1zOfuL98d3BIjUjtlwii5w6gYG2AEEzp7HnHCsb3jIwUPdq86Oe6hIFjtBwduIK90ca4UqzARpcfwxHwVLMpatKask00AgGVI0ysdk0BLMjmLutquD03XbThHScC2C2_Pp4cHWgMzvbgLU2RYYZcZRKr46QeNgz9w", - "PS256", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic PS384", - "eyJhbGciOiJQUzM4NCIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.w7-qqgj97gK4fJsq_DCqdYQiylJjzWONvD0qWWWhqEOFk2P1eDULPnqHRnjgTXoO4HAw4YIWCsZPet7nR3Xxq4ZhMqvKW8b7KlfRTb9cH8zqFvzMmybQ4jv2hKc3bXYqVow3AoR7hN_CWXI3Dv6Kd2X5xhtxRHI6IL39oTVDUQ74LACe-9t4c3QRPuj6Pq1H4FAT2E2kW_0KOc6EQhCLWEhm2Z2__OZskDC8AiPpP8Kv4k2vB7l0IKQu8Pr4RcNBlqJdq8dA5D3hk5TLxP8V5nG1Ib80MOMMqoS3FQvSLyolFX-R_jZ3-zfq6Ebsqr0yEb0AH2CfsECF7935Pa0FKQ", - "PS384", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic PS512", - "eyJhbGciOiJQUzUxMiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.GX1HWGzFaJevuSLavqqFYaW8_TpvcjQ8KfC5fXiSDzSiT9UD9nB_ikSmDNyDILNdtjZLSvVKfXxZJqCfefxAtiozEDDdJthZ-F0uO4SPFHlGiXszvKeodh7BuTWRI2wL9-ZO4mFa8nq3GMeQAfo9cx11i7nfN8n2YNQ9SHGovG7_T_AvaMZB_jT6jkDHpwGR9mz7x1sycckEo6teLdHRnH_ZdlHlxqknmyTu8Odr5Xh0sJFOL8BepWbbvIIn-P161rRHHiDWFv6nhlHwZnVzjx7HQrWSGb6-s2cdLie9QL_8XaMcUpjLkfOMKkDOfHo6AvpL7Jbwi83Z2ZTHjJWB-A", - "PS512", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "basic PS256 invalid: foo => bar", - "eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.PPG4xyDVY8ffp4CcxofNmsTDXsrVG2npdQuibLhJbv4ClyPTUtR5giNSvuxo03kB6I8VXVr0Y9X7UxhJVEoJOmULAwRWaUsDnIewQa101cVhMa6iR8X37kfFoiZ6NkS-c7henVkkQWu2HtotkEtQvN5hFlk8IevXXPmvZlhQhwzB1sGzGYnoi1zOfuL98d3BIjUjtlwii5w6gYG2AEEzp7HnHCsb3jIwUPdq86Oe6hIFjtBwduIK90ca4UqzARpcfwxHwVLMpatKask00AgGVI0ysdk0BLMjmLutquD03XbThHScC2C2_Pp4cHWgMzvbgLU2RYYZcZRKr46QeNgz9W", - "PS256", - map[string]interface{}{"foo": "bar"}, - false, - }, -} - -func TestRSAPSSVerify(t *testing.T) { - var err error - - key, _ := ioutil.ReadFile("test/sample_key.pub") - var rsaPSSKey *rsa.PublicKey - if rsaPSSKey, err = jwt.ParseRSAPublicKeyFromPEM(key); err != nil { - t.Errorf("Unable to parse RSA public key: %v", err) - } - - for _, data := range rsaPSSTestData { - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - err := method.Verify(strings.Join(parts[0:2], "."), parts[2], rsaPSSKey) - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying key: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid key passed validation", data.name) - } - } -} - -func TestRSAPSSSign(t *testing.T) { - var err error - - key, _ := ioutil.ReadFile("test/sample_key") - var rsaPSSKey *rsa.PrivateKey - if rsaPSSKey, err = jwt.ParseRSAPrivateKeyFromPEM(key); err != nil { - t.Errorf("Unable to parse RSA private key: %v", err) - } - - for _, data := range rsaPSSTestData { - if data.valid { - parts := strings.Split(data.tokenString, ".") - method := jwt.GetSigningMethod(data.alg) - sig, err := method.Sign(strings.Join(parts[0:2], "."), rsaPSSKey) - if err != nil { - t.Errorf("[%v] Error signing token: %v", data.name, err) - } - if sig == parts[2] { - t.Errorf("[%v] Signatures shouldn't match\nnew:\n%v\noriginal:\n%v", data.name, sig, parts[2]) - } - } - } -} diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_test.go b/vendor/github.com/dgrijalva/jwt-go/rsa_test.go deleted file mode 100644 index 13ba1fc..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_test.go +++ /dev/null @@ -1,174 +0,0 @@ -package jwt_test - -import ( - "github.com/dgrijalva/jwt-go" - "io/ioutil" - "strings" - "testing" -) - -var rsaTestData = []struct { - name string - tokenString string - alg string - claims map[string]interface{} - valid bool -}{ - { - "Basic RS256", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.FhkiHkoESI_cG3NPigFrxEk9Z60_oXrOT2vGm9Pn6RDgYNovYORQmmA0zs1AoAOf09ly2Nx2YAg6ABqAYga1AcMFkJljwxTT5fYphTuqpWdy4BELeSYJx5Ty2gmr8e7RonuUztrdD5WfPqLKMm1Ozp_T6zALpRmwTIW0QPnaBXaQD90FplAg46Iy1UlDKr-Eupy0i5SLch5Q-p2ZpaL_5fnTIUDlxC3pWhJTyx_71qDI-mAA_5lE_VdroOeflG56sSmDxopPEG3bFlSu1eowyBfxtu0_CuVd-M42RU75Zc4Gsj6uV77MBtbMrf4_7M_NUTSgoIF3fRqxrj0NzihIBg", - "RS256", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic RS384", - "eyJhbGciOiJSUzM4NCIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.W-jEzRfBigtCWsinvVVuldiuilzVdU5ty0MvpLaSaqK9PlAWWlDQ1VIQ_qSKzwL5IXaZkvZFJXT3yL3n7OUVu7zCNJzdwznbC8Z-b0z2lYvcklJYi2VOFRcGbJtXUqgjk2oGsiqUMUMOLP70TTefkpsgqDxbRh9CDUfpOJgW-dU7cmgaoswe3wjUAUi6B6G2YEaiuXC0XScQYSYVKIzgKXJV8Zw-7AN_DBUI4GkTpsvQ9fVVjZM9csQiEXhYekyrKu1nu_POpQonGd8yqkIyXPECNmmqH5jH4sFiF67XhD7_JpkvLziBpI-uh86evBUadmHhb9Otqw3uV3NTaXLzJw", - "RS384", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "Basic RS512", - "eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJmb28iOiJiYXIifQ.zBlLlmRrUxx4SJPUbV37Q1joRcI9EW13grnKduK3wtYKmDXbgDpF1cZ6B-2Jsm5RB8REmMiLpGms-EjXhgnyh2TSHE-9W2gA_jvshegLWtwRVDX40ODSkTb7OVuaWgiy9y7llvcknFBTIg-FnVPVpXMmeV_pvwQyhaz1SSwSPrDyxEmksz1hq7YONXhXPpGaNbMMeDTNP_1oj8DZaqTIL9TwV8_1wb2Odt_Fy58Ke2RVFijsOLdnyEAjt2n9Mxihu9i3PhNBkkxa2GbnXBfq3kzvZ_xxGGopLdHhJjcGWXO-NiwI9_tiu14NRv4L2xC0ItD9Yz68v2ZIZEp_DuzwRQ", - "RS512", - map[string]interface{}{"foo": "bar"}, - true, - }, - { - "basic invalid: foo => bar", - "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJmb28iOiJiYXIifQ.EhkiHkoESI_cG3NPigFrxEk9Z60_oXrOT2vGm9Pn6RDgYNovYORQmmA0zs1AoAOf09ly2Nx2YAg6ABqAYga1AcMFkJljwxTT5fYphTuqpWdy4BELeSYJx5Ty2gmr8e7RonuUztrdD5WfPqLKMm1Ozp_T6zALpRmwTIW0QPnaBXaQD90FplAg46Iy1UlDKr-Eupy0i5SLch5Q-p2ZpaL_5fnTIUDlxC3pWhJTyx_71qDI-mAA_5lE_VdroOeflG56sSmDxopPEG3bFlSu1eowyBfxtu0_CuVd-M42RU75Zc4Gsj6uV77MBtbMrf4_7M_NUTSgoIF3fRqxrj0NzihIBg", - "RS256", - map[string]interface{}{"foo": "bar"}, - false, - }, -} - -func TestRSAVerify(t *testing.T) { - key, _ := ioutil.ReadFile("test/sample_key.pub") - - for _, data := range rsaTestData { - parts := strings.Split(data.tokenString, ".") - - method := jwt.GetSigningMethod(data.alg) - err := method.Verify(strings.Join(parts[0:2], "."), parts[2], key) - if data.valid && err != nil { - t.Errorf("[%v] Error while verifying key: %v", data.name, err) - } - if !data.valid && err == nil { - t.Errorf("[%v] Invalid key passed validation", data.name) - } - } -} - -func TestRSASign(t *testing.T) { - key, _ := ioutil.ReadFile("test/sample_key") - - for _, data := range rsaTestData { - if data.valid { - parts := strings.Split(data.tokenString, ".") - method := jwt.GetSigningMethod(data.alg) - sig, err := method.Sign(strings.Join(parts[0:2], "."), key) - if err != nil { - t.Errorf("[%v] Error signing token: %v", data.name, err) - } - if sig != parts[2] { - t.Errorf("[%v] Incorrect signature.\nwas:\n%v\nexpecting:\n%v", data.name, sig, parts[2]) - } - } - } -} - -func TestRSAVerifyWithPreParsedPrivateKey(t *testing.T) { - key, _ := ioutil.ReadFile("test/sample_key.pub") - parsedKey, err := jwt.ParseRSAPublicKeyFromPEM(key) - if err != nil { - t.Fatal(err) - } - testData := rsaTestData[0] - parts := strings.Split(testData.tokenString, ".") - err = jwt.SigningMethodRS256.Verify(strings.Join(parts[0:2], "."), parts[2], parsedKey) - if err != nil { - t.Errorf("[%v] Error while verifying key: %v", testData.name, err) - } -} - -func TestRSAWithPreParsedPrivateKey(t *testing.T) { - key, _ := ioutil.ReadFile("test/sample_key") - parsedKey, err := jwt.ParseRSAPrivateKeyFromPEM(key) - if err != nil { - t.Fatal(err) - } - testData := rsaTestData[0] - parts := strings.Split(testData.tokenString, ".") - sig, err := jwt.SigningMethodRS256.Sign(strings.Join(parts[0:2], "."), parsedKey) - if err != nil { - t.Errorf("[%v] Error signing token: %v", testData.name, err) - } - if sig != parts[2] { - t.Errorf("[%v] Incorrect signature.\nwas:\n%v\nexpecting:\n%v", testData.name, sig, parts[2]) - } -} - -func TestRSAKeyParsing(t *testing.T) { - key, _ := ioutil.ReadFile("test/sample_key") - pubKey, _ := ioutil.ReadFile("test/sample_key.pub") - badKey := []byte("All your base are belong to key") - - // Test parsePrivateKey - if _, e := jwt.ParseRSAPrivateKeyFromPEM(key); e != nil { - t.Errorf("Failed to parse valid private key: %v", e) - } - - if k, e := jwt.ParseRSAPrivateKeyFromPEM(pubKey); e == nil { - t.Errorf("Parsed public key as valid private key: %v", k) - } - - if k, e := jwt.ParseRSAPrivateKeyFromPEM(badKey); e == nil { - t.Errorf("Parsed invalid key as valid private key: %v", k) - } - - // Test parsePublicKey - if _, e := jwt.ParseRSAPublicKeyFromPEM(pubKey); e != nil { - t.Errorf("Failed to parse valid public key: %v", e) - } - - if k, e := jwt.ParseRSAPublicKeyFromPEM(key); e == nil { - t.Errorf("Parsed private key as valid public key: %v", k) - } - - if k, e := jwt.ParseRSAPublicKeyFromPEM(badKey); e == nil { - t.Errorf("Parsed invalid key as valid private key: %v", k) - } - -} - -func BenchmarkRS256Signing(b *testing.B) { - key, _ := ioutil.ReadFile("test/sample_key") - parsedKey, err := jwt.ParseRSAPrivateKeyFromPEM(key) - if err != nil { - b.Fatal(err) - } - - benchmarkSigning(b, jwt.SigningMethodRS256, parsedKey) -} - -func BenchmarkRS384Signing(b *testing.B) { - key, _ := ioutil.ReadFile("test/sample_key") - parsedKey, err := jwt.ParseRSAPrivateKeyFromPEM(key) - if err != nil { - b.Fatal(err) - } - - benchmarkSigning(b, jwt.SigningMethodRS384, parsedKey) -} - -func BenchmarkRS512Signing(b *testing.B) { - key, _ := ioutil.ReadFile("test/sample_key") - parsedKey, err := jwt.ParseRSAPrivateKeyFromPEM(key) - if err != nil { - b.Fatal(err) - } - - benchmarkSigning(b, jwt.SigningMethodRS512, parsedKey) -} diff --git a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go b/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go deleted file mode 100644 index 213a90d..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/rsa_utils.go +++ /dev/null @@ -1,69 +0,0 @@ -package jwt - -import ( - "crypto/rsa" - "crypto/x509" - "encoding/pem" - "errors" -) - -var ( - ErrKeyMustBePEMEncoded = errors.New("Invalid Key: Key must be PEM encoded PKCS1 or PKCS8 private key") - ErrNotRSAPrivateKey = errors.New("Key is not a valid RSA private key") - ErrNotRSAPublicKey = errors.New("Key is not a valid RSA public key") -) - -// Parse PEM encoded PKCS1 or PKCS8 private key -func ParseRSAPrivateKeyFromPEM(key []byte) (*rsa.PrivateKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - var parsedKey interface{} - if parsedKey, err = x509.ParsePKCS1PrivateKey(block.Bytes); err != nil { - if parsedKey, err = x509.ParsePKCS8PrivateKey(block.Bytes); err != nil { - return nil, err - } - } - - var pkey *rsa.PrivateKey - var ok bool - if pkey, ok = parsedKey.(*rsa.PrivateKey); !ok { - return nil, ErrNotRSAPrivateKey - } - - return pkey, nil -} - -// Parse PEM encoded PKCS1 or PKCS8 public key -func ParseRSAPublicKeyFromPEM(key []byte) (*rsa.PublicKey, error) { - var err error - - // Parse PEM block - var block *pem.Block - if block, _ = pem.Decode(key); block == nil { - return nil, ErrKeyMustBePEMEncoded - } - - // Parse the key - var parsedKey interface{} - if parsedKey, err = x509.ParsePKIXPublicKey(block.Bytes); err != nil { - if cert, err := x509.ParseCertificate(block.Bytes); err == nil { - parsedKey = cert.PublicKey - } else { - return nil, err - } - } - - var pkey *rsa.PublicKey - var ok bool - if pkey, ok = parsedKey.(*rsa.PublicKey); !ok { - return nil, ErrNotRSAPublicKey - } - - return pkey, nil -} diff --git a/vendor/github.com/dgrijalva/jwt-go/signing_method.go b/vendor/github.com/dgrijalva/jwt-go/signing_method.go deleted file mode 100644 index 12cf0f3..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/signing_method.go +++ /dev/null @@ -1,24 +0,0 @@ -package jwt - -var signingMethods = map[string]func() SigningMethod{} - -// Implement SigningMethod to add new methods for signing or verifying tokens. -type SigningMethod interface { - Verify(signingString, signature string, key interface{}) error // Returns nil if signature is valid - Sign(signingString string, key interface{}) (string, error) // Returns encoded signature or error - Alg() string // returns the alg identifier for this method (example: 'HS256') -} - -// Register the "alg" name and a factory function for signing method. -// This is typically done during init() in the method's implementation -func RegisterSigningMethod(alg string, f func() SigningMethod) { - signingMethods[alg] = f -} - -// Get a signing method from an "alg" string -func GetSigningMethod(alg string) (method SigningMethod) { - if methodF, ok := signingMethods[alg]; ok { - method = methodF() - } - return -} diff --git a/vendor/github.com/dgrijalva/jwt-go/test/ec256-private.pem b/vendor/github.com/dgrijalva/jwt-go/test/ec256-private.pem deleted file mode 100644 index a6882b3..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/ec256-private.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MHcCAQEEIAh5qA3rmqQQuu0vbKV/+zouz/y/Iy2pLpIcWUSyImSwoAoGCCqGSM49 -AwEHoUQDQgAEYD54V/vp+54P9DXarYqx4MPcm+HKRIQzNasYSoRQHQ/6S6Ps8tpM -cT+KvIIC8W/e9k0W7Cm72M1P9jU7SLf/vg== ------END EC PRIVATE KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/test/ec256-public.pem b/vendor/github.com/dgrijalva/jwt-go/test/ec256-public.pem deleted file mode 100644 index 7191361..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/ec256-public.pem +++ /dev/null @@ -1,4 +0,0 @@ ------BEGIN PUBLIC KEY----- -MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEYD54V/vp+54P9DXarYqx4MPcm+HK -RIQzNasYSoRQHQ/6S6Ps8tpMcT+KvIIC8W/e9k0W7Cm72M1P9jU7SLf/vg== ------END PUBLIC KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/test/ec384-private.pem b/vendor/github.com/dgrijalva/jwt-go/test/ec384-private.pem deleted file mode 100644 index a86c823..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/ec384-private.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MIGkAgEBBDCaCvMHKhcG/qT7xsNLYnDT7sE/D+TtWIol1ROdaK1a564vx5pHbsRy -SEKcIxISi1igBwYFK4EEACKhZANiAATYa7rJaU7feLMqrAx6adZFNQOpaUH/Uylb -ZLriOLON5YFVwtVUpO1FfEXZUIQpptRPtc5ixIPY658yhBSb6irfIJUSP9aYTflJ -GKk/mDkK4t8mWBzhiD5B6jg9cEGhGgA= ------END EC PRIVATE KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/test/ec384-public.pem b/vendor/github.com/dgrijalva/jwt-go/test/ec384-public.pem deleted file mode 100644 index e80d005..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/ec384-public.pem +++ /dev/null @@ -1,5 +0,0 @@ ------BEGIN PUBLIC KEY----- -MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE2Gu6yWlO33izKqwMemnWRTUDqWlB/1Mp -W2S64jizjeWBVcLVVKTtRXxF2VCEKabUT7XOYsSD2OufMoQUm+oq3yCVEj/WmE35 -SRipP5g5CuLfJlgc4Yg+Qeo4PXBBoRoA ------END PUBLIC KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/test/ec512-private.pem b/vendor/github.com/dgrijalva/jwt-go/test/ec512-private.pem deleted file mode 100644 index 213afaf..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/ec512-private.pem +++ /dev/null @@ -1,7 +0,0 @@ ------BEGIN EC PRIVATE KEY----- -MIHcAgEBBEIB0pE4uFaWRx7t03BsYlYvF1YvKaBGyvoakxnodm9ou0R9wC+sJAjH -QZZJikOg4SwNqgQ/hyrOuDK2oAVHhgVGcYmgBwYFK4EEACOhgYkDgYYABAAJXIuw -12MUzpHggia9POBFYXSxaOGKGbMjIyDI+6q7wi7LMw3HgbaOmgIqFG72o8JBQwYN -4IbXHf+f86CRY1AA2wHzbHvt6IhkCXTNxBEffa1yMUgu8n9cKKF2iLgyQKcKqW33 -8fGOw/n3Rm2Yd/EB56u2rnD29qS+nOM9eGS+gy39OQ== ------END EC PRIVATE KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/test/ec512-public.pem b/vendor/github.com/dgrijalva/jwt-go/test/ec512-public.pem deleted file mode 100644 index 02ea022..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/ec512-public.pem +++ /dev/null @@ -1,6 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQACVyLsNdjFM6R4IImvTzgRWF0sWjh -ihmzIyMgyPuqu8IuyzMNx4G2jpoCKhRu9qPCQUMGDeCG1x3/n/OgkWNQANsB82x7 -7eiIZAl0zcQRH32tcjFILvJ/XCihdoi4MkCnCqlt9/HxjsP590ZtmHfxAeertq5w -9vakvpzjPXhkvoMt/Tk= ------END PUBLIC KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/test/hmacTestKey b/vendor/github.com/dgrijalva/jwt-go/test/hmacTestKey deleted file mode 100644 index 435b8dd..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/hmacTestKey +++ /dev/null @@ -1 +0,0 @@ -#5K+¥¼ƒ~ew{¦Z³(æðTÉ(©„²ÒP.¿ÓûZ’ÒGï–Š´Ãwb="=.!r.OÀÍšõgЀ£ \ No newline at end of file diff --git a/vendor/github.com/dgrijalva/jwt-go/test/sample_key b/vendor/github.com/dgrijalva/jwt-go/test/sample_key deleted file mode 100644 index abdbade..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/sample_key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEA4f5wg5l2hKsTeNem/V41fGnJm6gOdrj8ym3rFkEU/wT8RDtn -SgFEZOQpHEgQ7JL38xUfU0Y3g6aYw9QT0hJ7mCpz9Er5qLaMXJwZxzHzAahlfA0i -cqabvJOMvQtzD6uQv6wPEyZtDTWiQi9AXwBpHssPnpYGIn20ZZuNlX2BrClciHhC -PUIIZOQn/MmqTD31jSyjoQoV7MhhMTATKJx2XrHhR+1DcKJzQBSTAGnpYVaqpsAR -ap+nwRipr3nUTuxyGohBTSmjJ2usSeQXHI3bODIRe1AuTyHceAbewn8b462yEWKA -Rdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy7wIDAQABAoIBAQCwia1k7+2oZ2d3 -n6agCAbqIE1QXfCmh41ZqJHbOY3oRQG3X1wpcGH4Gk+O+zDVTV2JszdcOt7E5dAy -MaomETAhRxB7hlIOnEN7WKm+dGNrKRvV0wDU5ReFMRHg31/Lnu8c+5BvGjZX+ky9 -POIhFFYJqwCRlopGSUIxmVj5rSgtzk3iWOQXr+ah1bjEXvlxDOWkHN6YfpV5ThdE -KdBIPGEVqa63r9n2h+qazKrtiRqJqGnOrHzOECYbRFYhexsNFz7YT02xdfSHn7gM -IvabDDP/Qp0PjE1jdouiMaFHYnLBbgvlnZW9yuVf/rpXTUq/njxIXMmvmEyyvSDn -FcFikB8pAoGBAPF77hK4m3/rdGT7X8a/gwvZ2R121aBcdPwEaUhvj/36dx596zvY -mEOjrWfZhF083/nYWE2kVquj2wjs+otCLfifEEgXcVPTnEOPO9Zg3uNSL0nNQghj -FuD3iGLTUBCtM66oTe0jLSslHe8gLGEQqyMzHOzYxNqibxcOZIe8Qt0NAoGBAO+U -I5+XWjWEgDmvyC3TrOSf/KCGjtu0TSv30ipv27bDLMrpvPmD/5lpptTFwcxvVhCs -2b+chCjlghFSWFbBULBrfci2FtliClOVMYrlNBdUSJhf3aYSG2Doe6Bgt1n2CpNn -/iu37Y3NfemZBJA7hNl4dYe+f+uzM87cdQ214+jrAoGAXA0XxX8ll2+ToOLJsaNT -OvNB9h9Uc5qK5X5w+7G7O998BN2PC/MWp8H+2fVqpXgNENpNXttkRm1hk1dych86 -EunfdPuqsX+as44oCyJGFHVBnWpm33eWQw9YqANRI+pCJzP08I5WK3osnPiwshd+ -hR54yjgfYhBFNI7B95PmEQkCgYBzFSz7h1+s34Ycr8SvxsOBWxymG5zaCsUbPsL0 -4aCgLScCHb9J+E86aVbbVFdglYa5Id7DPTL61ixhl7WZjujspeXZGSbmq0Kcnckb -mDgqkLECiOJW2NHP/j0McAkDLL4tysF8TLDO8gvuvzNC+WQ6drO2ThrypLVZQ+ry -eBIPmwKBgEZxhqa0gVvHQG/7Od69KWj4eJP28kq13RhKay8JOoN0vPmspXJo1HY3 -CKuHRG+AP579dncdUnOMvfXOtkdM4vk0+hWASBQzM9xzVcztCa+koAugjVaLS9A+ -9uQoqEeVNTckxx0S2bYevRy7hGQmUJTyQm3j1zEUR5jpdbL83Fbq ------END RSA PRIVATE KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/test/sample_key.pub b/vendor/github.com/dgrijalva/jwt-go/test/sample_key.pub deleted file mode 100644 index 03dc982..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/test/sample_key.pub +++ /dev/null @@ -1,9 +0,0 @@ ------BEGIN PUBLIC KEY----- -MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4f5wg5l2hKsTeNem/V41 -fGnJm6gOdrj8ym3rFkEU/wT8RDtnSgFEZOQpHEgQ7JL38xUfU0Y3g6aYw9QT0hJ7 -mCpz9Er5qLaMXJwZxzHzAahlfA0icqabvJOMvQtzD6uQv6wPEyZtDTWiQi9AXwBp -HssPnpYGIn20ZZuNlX2BrClciHhCPUIIZOQn/MmqTD31jSyjoQoV7MhhMTATKJx2 -XrHhR+1DcKJzQBSTAGnpYVaqpsARap+nwRipr3nUTuxyGohBTSmjJ2usSeQXHI3b -ODIRe1AuTyHceAbewn8b462yEWKARdpd9AjQW5SIVPfdsz5B6GlYQ5LdYKtznTuy -7wIDAQAB ------END PUBLIC KEY----- diff --git a/vendor/github.com/dgrijalva/jwt-go/token.go b/vendor/github.com/dgrijalva/jwt-go/token.go deleted file mode 100644 index c275333..0000000 --- a/vendor/github.com/dgrijalva/jwt-go/token.go +++ /dev/null @@ -1,126 +0,0 @@ -package jwt - -import ( - "encoding/base64" - "encoding/json" - "net/http" - "strings" - "time" -) - -// TimeFunc provides the current time when parsing token to validate "exp" claim (expiration time). -// You can override it to use another time value. This is useful for testing or if your -// server uses a different time zone than your tokens. -var TimeFunc = time.Now - -// Parse methods use this callback function to supply -// the key for verification. The function receives the parsed, -// but unverified Token. This allows you to use properties in the -// Header of the token (such as `kid`) to identify which key to use. -type Keyfunc func(*Token) (interface{}, error) - -// A JWT Token. Different fields will be used depending on whether you're -// creating or parsing/verifying a token. -type Token struct { - Raw string // The raw token. Populated when you Parse a token - Method SigningMethod // The signing method used or to be used - Header map[string]interface{} // The first segment of the token - Claims map[string]interface{} // The second segment of the token - Signature string // The third segment of the token. Populated when you Parse a token - Valid bool // Is the token valid? Populated when you Parse/Verify a token -} - -// Create a new Token. Takes a signing method -func New(method SigningMethod) *Token { - return &Token{ - Header: map[string]interface{}{ - "typ": "JWT", - "alg": method.Alg(), - }, - Claims: make(map[string]interface{}), - Method: method, - } -} - -// Get the complete, signed token -func (t *Token) SignedString(key interface{}) (string, error) { - var sig, sstr string - var err error - if sstr, err = t.SigningString(); err != nil { - return "", err - } - if sig, err = t.Method.Sign(sstr, key); err != nil { - return "", err - } - return strings.Join([]string{sstr, sig}, "."), nil -} - -// Generate the signing string. This is the -// most expensive part of the whole deal. Unless you -// need this for something special, just go straight for -// the SignedString. -func (t *Token) SigningString() (string, error) { - var err error - parts := make([]string, 2) - for i, _ := range parts { - var source map[string]interface{} - if i == 0 { - source = t.Header - } else { - source = t.Claims - } - - var jsonValue []byte - if jsonValue, err = json.Marshal(source); err != nil { - return "", err - } - - parts[i] = EncodeSegment(jsonValue) - } - return strings.Join(parts, "."), nil -} - -// Parse, validate, and return a token. -// keyFunc will receive the parsed token and should return the key for validating. -// If everything is kosher, err will be nil -func Parse(tokenString string, keyFunc Keyfunc) (*Token, error) { - return new(Parser).Parse(tokenString, keyFunc) -} - -// Try to find the token in an http.Request. -// This method will call ParseMultipartForm if there's no token in the header. -// Currently, it looks in the Authorization header as well as -// looking for an 'access_token' request parameter in req.Form. -func ParseFromRequest(req *http.Request, keyFunc Keyfunc) (token *Token, err error) { - - // Look for an Authorization header - if ah := req.Header.Get("Authorization"); ah != "" { - // Should be a bearer token - if len(ah) > 6 && strings.ToUpper(ah[0:7]) == "BEARER " { - return Parse(ah[7:], keyFunc) - } - } - - // Look for "access_token" parameter - req.ParseMultipartForm(10e6) - if tokStr := req.Form.Get("access_token"); tokStr != "" { - return Parse(tokStr, keyFunc) - } - - return nil, ErrNoTokenInRequest - -} - -// Encode JWT specific base64url encoding with padding stripped -func EncodeSegment(seg []byte) string { - return strings.TrimRight(base64.URLEncoding.EncodeToString(seg), "=") -} - -// Decode JWT specific base64url encoding with padding stripped -func DecodeSegment(seg string) ([]byte, error) { - if l := len(seg) % 4; l > 0 { - seg += strings.Repeat("=", 4-l) - } - - return base64.URLEncoding.DecodeString(seg) -} diff --git a/vendor/github.com/dustin/go-humanize/.gitignore b/vendor/github.com/dustin/go-humanize/.gitignore deleted file mode 100644 index 05b4051..0000000 --- a/vendor/github.com/dustin/go-humanize/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -#* -*.[568] -*.a -*~ -[568].out -_* diff --git a/vendor/github.com/dustin/go-humanize/.travis.yml b/vendor/github.com/dustin/go-humanize/.travis.yml deleted file mode 100644 index ffa8740..0000000 --- a/vendor/github.com/dustin/go-humanize/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -sudo: false -language: go -go: - - 1.3.3 - - 1.5.4 - - 1.6.2 - - tip -matrix: - allow_failures: - - go: tip - fast_finish: true -install: - - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). -script: - - go get -t -v ./... - - diff -u <(echo -n) <(gofmt -d -s .) - - go tool vet . - - go test -v -race ./... diff --git a/vendor/github.com/dustin/go-humanize/LICENSE b/vendor/github.com/dustin/go-humanize/LICENSE deleted file mode 100644 index 8d9a94a..0000000 --- a/vendor/github.com/dustin/go-humanize/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -Copyright (c) 2005-2008 Dustin Sallings - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - diff --git a/vendor/github.com/dustin/go-humanize/README.markdown b/vendor/github.com/dustin/go-humanize/README.markdown deleted file mode 100644 index 23dfee0..0000000 --- a/vendor/github.com/dustin/go-humanize/README.markdown +++ /dev/null @@ -1,92 +0,0 @@ -# Humane Units [![Build Status](https://travis-ci.org/dustin/go-humanize.svg?branch=master)](https://travis-ci.org/dustin/go-humanize) [![GoDoc](https://godoc.org/github.com/dustin/go-humanize?status.svg)](https://godoc.org/github.com/dustin/go-humanize) - -Just a few functions for helping humanize times and sizes. - -`go get` it as `github.com/dustin/go-humanize`, import it as -`"github.com/dustin/go-humanize"`, use it as `humanize` - -See [godoc](https://godoc.org/github.com/dustin/go-humanize) for -complete documentation. - -## Sizes - -This lets you take numbers like `82854982` and convert them to useful -strings like, `83MB` or `79MiB` (whichever you prefer). - -Example: - -```go -fmt.Printf("That file is %s.", humanize.Bytes(82854982)) -``` - -## Times - -This lets you take a `time.Time` and spit it out in relative terms. -For example, `12 seconds ago` or `3 days from now`. - -Example: - -```go -fmt.Printf("This was touched %s", humanize.Time(someTimeInstance)) -``` - -Thanks to Kyle Lemons for the time implementation from an IRC -conversation one day. It's pretty neat. - -## Ordinals - -From a [mailing list discussion][odisc] where a user wanted to be able -to label ordinals. - - 0 -> 0th - 1 -> 1st - 2 -> 2nd - 3 -> 3rd - 4 -> 4th - [...] - -Example: - -```go -fmt.Printf("You're my %s best friend.", humanize.Ordinal(193)) -``` - -## Commas - -Want to shove commas into numbers? Be my guest. - - 0 -> 0 - 100 -> 100 - 1000 -> 1,000 - 1000000000 -> 1,000,000,000 - -100000 -> -100,000 - -Example: - -```go -fmt.Printf("You owe $%s.\n", humanize.Comma(6582491)) -``` - -## Ftoa - -Nicer float64 formatter that removes trailing zeros. - -```go -fmt.Printf("%f", 2.24) // 2.240000 -fmt.Printf("%s", humanize.Ftoa(2.24)) // 2.24 -fmt.Printf("%f", 2.0) // 2.000000 -fmt.Printf("%s", humanize.Ftoa(2.0)) // 2 -``` - -## SI notation - -Format numbers with [SI notation][sinotation]. - -Example: - -```go -humanize.SI(0.00000000223, "M") // 2.23nM -``` - -[odisc]: https://groups.google.com/d/topic/golang-nuts/l8NhI74jl-4/discussion -[sinotation]: http://en.wikipedia.org/wiki/Metric_prefix diff --git a/vendor/github.com/dustin/go-humanize/big.go b/vendor/github.com/dustin/go-humanize/big.go deleted file mode 100644 index f49dc33..0000000 --- a/vendor/github.com/dustin/go-humanize/big.go +++ /dev/null @@ -1,31 +0,0 @@ -package humanize - -import ( - "math/big" -) - -// order of magnitude (to a max order) -func oomm(n, b *big.Int, maxmag int) (float64, int) { - mag := 0 - m := &big.Int{} - for n.Cmp(b) >= 0 { - n.DivMod(n, b, m) - mag++ - if mag == maxmag && maxmag >= 0 { - break - } - } - return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag -} - -// total order of magnitude -// (same as above, but with no upper limit) -func oom(n, b *big.Int) (float64, int) { - mag := 0 - m := &big.Int{} - for n.Cmp(b) >= 0 { - n.DivMod(n, b, m) - mag++ - } - return float64(n.Int64()) + (float64(m.Int64()) / float64(b.Int64())), mag -} diff --git a/vendor/github.com/dustin/go-humanize/bigbytes.go b/vendor/github.com/dustin/go-humanize/bigbytes.go deleted file mode 100644 index 67ea5c8..0000000 --- a/vendor/github.com/dustin/go-humanize/bigbytes.go +++ /dev/null @@ -1,164 +0,0 @@ -package humanize - -import ( - "fmt" - "math/big" - "strings" - "unicode" -) - -var ( - bigIECExp = big.NewInt(1024) - - // BigByte is one byte in bit.Ints - BigByte = big.NewInt(1) - // BigKiByte is 1,024 bytes in bit.Ints - BigKiByte = (&big.Int{}).Mul(BigByte, bigIECExp) - // BigMiByte is 1,024 k bytes in bit.Ints - BigMiByte = (&big.Int{}).Mul(BigKiByte, bigIECExp) - // BigGiByte is 1,024 m bytes in bit.Ints - BigGiByte = (&big.Int{}).Mul(BigMiByte, bigIECExp) - // BigTiByte is 1,024 g bytes in bit.Ints - BigTiByte = (&big.Int{}).Mul(BigGiByte, bigIECExp) - // BigPiByte is 1,024 t bytes in bit.Ints - BigPiByte = (&big.Int{}).Mul(BigTiByte, bigIECExp) - // BigEiByte is 1,024 p bytes in bit.Ints - BigEiByte = (&big.Int{}).Mul(BigPiByte, bigIECExp) - // BigZiByte is 1,024 e bytes in bit.Ints - BigZiByte = (&big.Int{}).Mul(BigEiByte, bigIECExp) - // BigYiByte is 1,024 z bytes in bit.Ints - BigYiByte = (&big.Int{}).Mul(BigZiByte, bigIECExp) -) - -var ( - bigSIExp = big.NewInt(1000) - - // BigSIByte is one SI byte in big.Ints - BigSIByte = big.NewInt(1) - // BigKByte is 1,000 SI bytes in big.Ints - BigKByte = (&big.Int{}).Mul(BigSIByte, bigSIExp) - // BigMByte is 1,000 SI k bytes in big.Ints - BigMByte = (&big.Int{}).Mul(BigKByte, bigSIExp) - // BigGByte is 1,000 SI m bytes in big.Ints - BigGByte = (&big.Int{}).Mul(BigMByte, bigSIExp) - // BigTByte is 1,000 SI g bytes in big.Ints - BigTByte = (&big.Int{}).Mul(BigGByte, bigSIExp) - // BigPByte is 1,000 SI t bytes in big.Ints - BigPByte = (&big.Int{}).Mul(BigTByte, bigSIExp) - // BigEByte is 1,000 SI p bytes in big.Ints - BigEByte = (&big.Int{}).Mul(BigPByte, bigSIExp) - // BigZByte is 1,000 SI e bytes in big.Ints - BigZByte = (&big.Int{}).Mul(BigEByte, bigSIExp) - // BigYByte is 1,000 SI z bytes in big.Ints - BigYByte = (&big.Int{}).Mul(BigZByte, bigSIExp) -) - -var bigBytesSizeTable = map[string]*big.Int{ - "b": BigByte, - "kib": BigKiByte, - "kb": BigKByte, - "mib": BigMiByte, - "mb": BigMByte, - "gib": BigGiByte, - "gb": BigGByte, - "tib": BigTiByte, - "tb": BigTByte, - "pib": BigPiByte, - "pb": BigPByte, - "eib": BigEiByte, - "eb": BigEByte, - "zib": BigZiByte, - "zb": BigZByte, - "yib": BigYiByte, - "yb": BigYByte, - // Without suffix - "": BigByte, - "ki": BigKiByte, - "k": BigKByte, - "mi": BigMiByte, - "m": BigMByte, - "gi": BigGiByte, - "g": BigGByte, - "ti": BigTiByte, - "t": BigTByte, - "pi": BigPiByte, - "p": BigPByte, - "ei": BigEiByte, - "e": BigEByte, - "z": BigZByte, - "zi": BigZiByte, - "y": BigYByte, - "yi": BigYiByte, -} - -var ten = big.NewInt(10) - -func humanateBigBytes(s, base *big.Int, sizes []string) string { - if s.Cmp(ten) < 0 { - return fmt.Sprintf("%d B", s) - } - c := (&big.Int{}).Set(s) - val, mag := oomm(c, base, len(sizes)-1) - suffix := sizes[mag] - f := "%.0f %s" - if val < 10 { - f = "%.1f %s" - } - - return fmt.Sprintf(f, val, suffix) - -} - -// BigBytes produces a human readable representation of an SI size. -// -// See also: ParseBigBytes. -// -// BigBytes(82854982) -> 83MB -func BigBytes(s *big.Int) string { - sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"} - return humanateBigBytes(s, bigSIExp, sizes) -} - -// BigIBytes produces a human readable representation of an IEC size. -// -// See also: ParseBigBytes. -// -// BigIBytes(82854982) -> 79MiB -func BigIBytes(s *big.Int) string { - sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"} - return humanateBigBytes(s, bigIECExp, sizes) -} - -// ParseBigBytes parses a string representation of bytes into the number -// of bytes it represents. -// -// See also: BigBytes, BigIBytes. -// -// ParseBigBytes("42MB") -> 42000000, nil -// ParseBigBytes("42mib") -> 44040192, nil -func ParseBigBytes(s string) (*big.Int, error) { - lastDigit := 0 - for _, r := range s { - if !(unicode.IsDigit(r) || r == '.') { - break - } - lastDigit++ - } - - val := &big.Rat{} - _, err := fmt.Sscanf(s[:lastDigit], "%f", val) - if err != nil { - return nil, err - } - - extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) - if m, ok := bigBytesSizeTable[extra]; ok { - mv := (&big.Rat{}).SetInt(m) - val.Mul(val, mv) - rv := &big.Int{} - rv.Div(val.Num(), val.Denom()) - return rv, nil - } - - return nil, fmt.Errorf("unhandled size name: %v", extra) -} diff --git a/vendor/github.com/dustin/go-humanize/bigbytes_test.go b/vendor/github.com/dustin/go-humanize/bigbytes_test.go deleted file mode 100644 index 88eed45..0000000 --- a/vendor/github.com/dustin/go-humanize/bigbytes_test.go +++ /dev/null @@ -1,219 +0,0 @@ -package humanize - -import ( - "math/big" - "testing" -) - -func TestBigByteParsing(t *testing.T) { - tests := []struct { - in string - exp uint64 - }{ - {"42", 42}, - {"42MB", 42000000}, - {"42MiB", 44040192}, - {"42mb", 42000000}, - {"42mib", 44040192}, - {"42MIB", 44040192}, - {"42 MB", 42000000}, - {"42 MiB", 44040192}, - {"42 mb", 42000000}, - {"42 mib", 44040192}, - {"42 MIB", 44040192}, - {"42.5MB", 42500000}, - {"42.5MiB", 44564480}, - {"42.5 MB", 42500000}, - {"42.5 MiB", 44564480}, - // No need to say B - {"42M", 42000000}, - {"42Mi", 44040192}, - {"42m", 42000000}, - {"42mi", 44040192}, - {"42MI", 44040192}, - {"42 M", 42000000}, - {"42 Mi", 44040192}, - {"42 m", 42000000}, - {"42 mi", 44040192}, - {"42 MI", 44040192}, - {"42.5M", 42500000}, - {"42.5Mi", 44564480}, - {"42.5 M", 42500000}, - {"42.5 Mi", 44564480}, - // Large testing, breaks when too much larger than - // this. - {"12.5 EB", uint64(12.5 * float64(EByte))}, - {"12.5 E", uint64(12.5 * float64(EByte))}, - {"12.5 EiB", uint64(12.5 * float64(EiByte))}, - } - - for _, p := range tests { - got, err := ParseBigBytes(p.in) - if err != nil { - t.Errorf("Couldn't parse %v: %v", p.in, err) - } else { - if got.Uint64() != p.exp { - t.Errorf("Expected %v for %v, got %v", - p.exp, p.in, got) - } - } - } -} - -func TestBigByteErrors(t *testing.T) { - got, err := ParseBigBytes("84 JB") - if err == nil { - t.Errorf("Expected error, got %v", got) - } - got, err = ParseBigBytes("") - if err == nil { - t.Errorf("Expected error parsing nothing") - } -} - -func bbyte(in uint64) string { - return BigBytes((&big.Int{}).SetUint64(in)) -} - -func bibyte(in uint64) string { - return BigIBytes((&big.Int{}).SetUint64(in)) -} - -func TestBigBytes(t *testing.T) { - testList{ - {"bytes(0)", bbyte(0), "0 B"}, - {"bytes(1)", bbyte(1), "1 B"}, - {"bytes(803)", bbyte(803), "803 B"}, - {"bytes(999)", bbyte(999), "999 B"}, - - {"bytes(1024)", bbyte(1024), "1.0 kB"}, - {"bytes(1MB - 1)", bbyte(MByte - Byte), "1000 kB"}, - - {"bytes(1MB)", bbyte(1024 * 1024), "1.0 MB"}, - {"bytes(1GB - 1K)", bbyte(GByte - KByte), "1000 MB"}, - - {"bytes(1GB)", bbyte(GByte), "1.0 GB"}, - {"bytes(1TB - 1M)", bbyte(TByte - MByte), "1000 GB"}, - - {"bytes(1TB)", bbyte(TByte), "1.0 TB"}, - {"bytes(1PB - 1T)", bbyte(PByte - TByte), "999 TB"}, - - {"bytes(1PB)", bbyte(PByte), "1.0 PB"}, - {"bytes(1PB - 1T)", bbyte(EByte - PByte), "999 PB"}, - - {"bytes(1EB)", bbyte(EByte), "1.0 EB"}, - // Overflows. - // {"bytes(1EB - 1P)", Bytes((KByte*EByte)-PByte), "1023EB"}, - - {"bytes(0)", bibyte(0), "0 B"}, - {"bytes(1)", bibyte(1), "1 B"}, - {"bytes(803)", bibyte(803), "803 B"}, - {"bytes(1023)", bibyte(1023), "1023 B"}, - - {"bytes(1024)", bibyte(1024), "1.0 KiB"}, - {"bytes(1MB - 1)", bibyte(MiByte - IByte), "1024 KiB"}, - - {"bytes(1MB)", bibyte(1024 * 1024), "1.0 MiB"}, - {"bytes(1GB - 1K)", bibyte(GiByte - KiByte), "1024 MiB"}, - - {"bytes(1GB)", bibyte(GiByte), "1.0 GiB"}, - {"bytes(1TB - 1M)", bibyte(TiByte - MiByte), "1024 GiB"}, - - {"bytes(1TB)", bibyte(TiByte), "1.0 TiB"}, - {"bytes(1PB - 1T)", bibyte(PiByte - TiByte), "1023 TiB"}, - - {"bytes(1PB)", bibyte(PiByte), "1.0 PiB"}, - {"bytes(1PB - 1T)", bibyte(EiByte - PiByte), "1023 PiB"}, - - {"bytes(1EiB)", bibyte(EiByte), "1.0 EiB"}, - // Overflows. - // {"bytes(1EB - 1P)", bibyte((KIByte*EIByte)-PiByte), "1023EB"}, - - {"bytes(5.5GiB)", bibyte(5.5 * GiByte), "5.5 GiB"}, - - {"bytes(5.5GB)", bbyte(5.5 * GByte), "5.5 GB"}, - }.validate(t) -} - -func TestVeryBigBytes(t *testing.T) { - b, _ := (&big.Int{}).SetString("15347691069326346944512", 10) - s := BigBytes(b) - if s != "15 ZB" { - t.Errorf("Expected 15 ZB, got %v", s) - } - s = BigIBytes(b) - if s != "13 ZiB" { - t.Errorf("Expected 13 ZiB, got %v", s) - } - - b, _ = (&big.Int{}).SetString("15716035654990179271180288", 10) - s = BigBytes(b) - if s != "16 YB" { - t.Errorf("Expected 16 YB, got %v", s) - } - s = BigIBytes(b) - if s != "13 YiB" { - t.Errorf("Expected 13 YiB, got %v", s) - } -} - -func TestVeryVeryBigBytes(t *testing.T) { - b, _ := (&big.Int{}).SetString("16093220510709943573688614912", 10) - s := BigBytes(b) - if s != "16093 YB" { - t.Errorf("Expected 16093 YB, got %v", s) - } - s = BigIBytes(b) - if s != "13312 YiB" { - t.Errorf("Expected 13312 YiB, got %v", s) - } -} - -func TestParseVeryBig(t *testing.T) { - tests := []struct { - in string - out string - }{ - {"16 ZB", "16000000000000000000000"}, - {"16 ZiB", "18889465931478580854784"}, - {"16.5 ZB", "16500000000000000000000"}, - {"16.5 ZiB", "19479761741837286506496"}, - {"16 Z", "16000000000000000000000"}, - {"16 Zi", "18889465931478580854784"}, - {"16.5 Z", "16500000000000000000000"}, - {"16.5 Zi", "19479761741837286506496"}, - - {"16 YB", "16000000000000000000000000"}, - {"16 YiB", "19342813113834066795298816"}, - {"16.5 YB", "16500000000000000000000000"}, - {"16.5 YiB", "19947276023641381382651904"}, - {"16 Y", "16000000000000000000000000"}, - {"16 Yi", "19342813113834066795298816"}, - {"16.5 Y", "16500000000000000000000000"}, - {"16.5 Yi", "19947276023641381382651904"}, - } - - for _, test := range tests { - x, err := ParseBigBytes(test.in) - if err != nil { - t.Errorf("Error parsing %q: %v", test.in, err) - continue - } - - if x.String() != test.out { - t.Errorf("Expected %q for %q, got %v", test.out, test.in, x) - } - } -} - -func BenchmarkParseBigBytes(b *testing.B) { - for i := 0; i < b.N; i++ { - ParseBigBytes("16.5 Z") - } -} - -func BenchmarkBigBytes(b *testing.B) { - for i := 0; i < b.N; i++ { - bibyte(16.5 * GByte) - } -} diff --git a/vendor/github.com/dustin/go-humanize/bytes.go b/vendor/github.com/dustin/go-humanize/bytes.go deleted file mode 100644 index dacbb9c..0000000 --- a/vendor/github.com/dustin/go-humanize/bytes.go +++ /dev/null @@ -1,134 +0,0 @@ -package humanize - -import ( - "fmt" - "math" - "strconv" - "strings" - "unicode" -) - -// IEC Sizes. -// kibis of bits -const ( - Byte = 1 << (iota * 10) - KiByte - MiByte - GiByte - TiByte - PiByte - EiByte -) - -// SI Sizes. -const ( - IByte = 1 - KByte = IByte * 1000 - MByte = KByte * 1000 - GByte = MByte * 1000 - TByte = GByte * 1000 - PByte = TByte * 1000 - EByte = PByte * 1000 -) - -var bytesSizeTable = map[string]uint64{ - "b": Byte, - "kib": KiByte, - "kb": KByte, - "mib": MiByte, - "mb": MByte, - "gib": GiByte, - "gb": GByte, - "tib": TiByte, - "tb": TByte, - "pib": PiByte, - "pb": PByte, - "eib": EiByte, - "eb": EByte, - // Without suffix - "": Byte, - "ki": KiByte, - "k": KByte, - "mi": MiByte, - "m": MByte, - "gi": GiByte, - "g": GByte, - "ti": TiByte, - "t": TByte, - "pi": PiByte, - "p": PByte, - "ei": EiByte, - "e": EByte, -} - -func logn(n, b float64) float64 { - return math.Log(n) / math.Log(b) -} - -func humanateBytes(s uint64, base float64, sizes []string) string { - if s < 10 { - return fmt.Sprintf("%d B", s) - } - e := math.Floor(logn(float64(s), base)) - suffix := sizes[int(e)] - val := math.Floor(float64(s)/math.Pow(base, e)*10+0.5) / 10 - f := "%.0f %s" - if val < 10 { - f = "%.1f %s" - } - - return fmt.Sprintf(f, val, suffix) -} - -// Bytes produces a human readable representation of an SI size. -// -// See also: ParseBytes. -// -// Bytes(82854982) -> 83MB -func Bytes(s uint64) string { - sizes := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB"} - return humanateBytes(s, 1000, sizes) -} - -// IBytes produces a human readable representation of an IEC size. -// -// See also: ParseBytes. -// -// IBytes(82854982) -> 79MiB -func IBytes(s uint64) string { - sizes := []string{"B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB"} - return humanateBytes(s, 1024, sizes) -} - -// ParseBytes parses a string representation of bytes into the number -// of bytes it represents. -// -// See Also: Bytes, IBytes. -// -// ParseBytes("42MB") -> 42000000, nil -// ParseBytes("42mib") -> 44040192, nil -func ParseBytes(s string) (uint64, error) { - lastDigit := 0 - for _, r := range s { - if !(unicode.IsDigit(r) || r == '.') { - break - } - lastDigit++ - } - - f, err := strconv.ParseFloat(s[:lastDigit], 64) - if err != nil { - return 0, err - } - - extra := strings.ToLower(strings.TrimSpace(s[lastDigit:])) - if m, ok := bytesSizeTable[extra]; ok { - f *= float64(m) - if f >= math.MaxUint64 { - return 0, fmt.Errorf("too large: %v", s) - } - return uint64(f), nil - } - - return 0, fmt.Errorf("unhandled size name: %v", extra) -} diff --git a/vendor/github.com/dustin/go-humanize/bytes_test.go b/vendor/github.com/dustin/go-humanize/bytes_test.go deleted file mode 100644 index 99cad92..0000000 --- a/vendor/github.com/dustin/go-humanize/bytes_test.go +++ /dev/null @@ -1,144 +0,0 @@ -package humanize - -import ( - "testing" -) - -func TestByteParsing(t *testing.T) { - tests := []struct { - in string - exp uint64 - }{ - {"42", 42}, - {"42MB", 42000000}, - {"42MiB", 44040192}, - {"42mb", 42000000}, - {"42mib", 44040192}, - {"42MIB", 44040192}, - {"42 MB", 42000000}, - {"42 MiB", 44040192}, - {"42 mb", 42000000}, - {"42 mib", 44040192}, - {"42 MIB", 44040192}, - {"42.5MB", 42500000}, - {"42.5MiB", 44564480}, - {"42.5 MB", 42500000}, - {"42.5 MiB", 44564480}, - // No need to say B - {"42M", 42000000}, - {"42Mi", 44040192}, - {"42m", 42000000}, - {"42mi", 44040192}, - {"42MI", 44040192}, - {"42 M", 42000000}, - {"42 Mi", 44040192}, - {"42 m", 42000000}, - {"42 mi", 44040192}, - {"42 MI", 44040192}, - {"42.5M", 42500000}, - {"42.5Mi", 44564480}, - {"42.5 M", 42500000}, - {"42.5 Mi", 44564480}, - // Large testing, breaks when too much larger than - // this. - {"12.5 EB", uint64(12.5 * float64(EByte))}, - {"12.5 E", uint64(12.5 * float64(EByte))}, - {"12.5 EiB", uint64(12.5 * float64(EiByte))}, - } - - for _, p := range tests { - got, err := ParseBytes(p.in) - if err != nil { - t.Errorf("Couldn't parse %v: %v", p.in, err) - } - if got != p.exp { - t.Errorf("Expected %v for %v, got %v", - p.exp, p.in, got) - } - } -} - -func TestByteErrors(t *testing.T) { - got, err := ParseBytes("84 JB") - if err == nil { - t.Errorf("Expected error, got %v", got) - } - got, err = ParseBytes("") - if err == nil { - t.Errorf("Expected error parsing nothing") - } - got, err = ParseBytes("16 EiB") - if err == nil { - t.Errorf("Expected error, got %v", got) - } -} - -func TestBytes(t *testing.T) { - testList{ - {"bytes(0)", Bytes(0), "0 B"}, - {"bytes(1)", Bytes(1), "1 B"}, - {"bytes(803)", Bytes(803), "803 B"}, - {"bytes(999)", Bytes(999), "999 B"}, - - {"bytes(1024)", Bytes(1024), "1.0 kB"}, - {"bytes(9999)", Bytes(9999), "10 kB"}, - {"bytes(1MB - 1)", Bytes(MByte - Byte), "1000 kB"}, - - {"bytes(1MB)", Bytes(1024 * 1024), "1.0 MB"}, - {"bytes(1GB - 1K)", Bytes(GByte - KByte), "1000 MB"}, - - {"bytes(1GB)", Bytes(GByte), "1.0 GB"}, - {"bytes(1TB - 1M)", Bytes(TByte - MByte), "1000 GB"}, - {"bytes(10MB)", Bytes(9999 * 1000), "10 MB"}, - - {"bytes(1TB)", Bytes(TByte), "1.0 TB"}, - {"bytes(1PB - 1T)", Bytes(PByte - TByte), "999 TB"}, - - {"bytes(1PB)", Bytes(PByte), "1.0 PB"}, - {"bytes(1PB - 1T)", Bytes(EByte - PByte), "999 PB"}, - - {"bytes(1EB)", Bytes(EByte), "1.0 EB"}, - // Overflows. - // {"bytes(1EB - 1P)", Bytes((KByte*EByte)-PByte), "1023EB"}, - - {"bytes(0)", IBytes(0), "0 B"}, - {"bytes(1)", IBytes(1), "1 B"}, - {"bytes(803)", IBytes(803), "803 B"}, - {"bytes(1023)", IBytes(1023), "1023 B"}, - - {"bytes(1024)", IBytes(1024), "1.0 KiB"}, - {"bytes(1MB - 1)", IBytes(MiByte - IByte), "1024 KiB"}, - - {"bytes(1MB)", IBytes(1024 * 1024), "1.0 MiB"}, - {"bytes(1GB - 1K)", IBytes(GiByte - KiByte), "1024 MiB"}, - - {"bytes(1GB)", IBytes(GiByte), "1.0 GiB"}, - {"bytes(1TB - 1M)", IBytes(TiByte - MiByte), "1024 GiB"}, - - {"bytes(1TB)", IBytes(TiByte), "1.0 TiB"}, - {"bytes(1PB - 1T)", IBytes(PiByte - TiByte), "1023 TiB"}, - - {"bytes(1PB)", IBytes(PiByte), "1.0 PiB"}, - {"bytes(1PB - 1T)", IBytes(EiByte - PiByte), "1023 PiB"}, - - {"bytes(1EiB)", IBytes(EiByte), "1.0 EiB"}, - // Overflows. - // {"bytes(1EB - 1P)", IBytes((KIByte*EIByte)-PiByte), "1023EB"}, - - {"bytes(5.5GiB)", IBytes(5.5 * GiByte), "5.5 GiB"}, - - {"bytes(5.5GB)", Bytes(5.5 * GByte), "5.5 GB"}, - }.validate(t) -} - -func BenchmarkParseBytes(b *testing.B) { - for i := 0; i < b.N; i++ { - ParseBytes("16.5 GB") - } -} - -func BenchmarkBytes(b *testing.B) { - for i := 0; i < b.N; i++ { - Bytes(16.5 * GByte) - } -} diff --git a/vendor/github.com/dustin/go-humanize/comma.go b/vendor/github.com/dustin/go-humanize/comma.go deleted file mode 100644 index b65ea6f..0000000 --- a/vendor/github.com/dustin/go-humanize/comma.go +++ /dev/null @@ -1,101 +0,0 @@ -package humanize - -import ( - "bytes" - "math/big" - "strconv" - "strings" -) - -// Comma produces a string form of the given number in base 10 with -// commas after every three orders of magnitude. -// -// e.g. Comma(834142) -> 834,142 -func Comma(v int64) string { - sign := "" - if v < 0 { - sign = "-" - v = 0 - v - } - - parts := []string{"", "", "", "", "", "", ""} - j := len(parts) - 1 - - for v > 999 { - parts[j] = strconv.FormatInt(v%1000, 10) - switch len(parts[j]) { - case 2: - parts[j] = "0" + parts[j] - case 1: - parts[j] = "00" + parts[j] - } - v = v / 1000 - j-- - } - parts[j] = strconv.Itoa(int(v)) - return sign + strings.Join(parts[j:], ",") -} - -// Commaf produces a string form of the given number in base 10 with -// commas after every three orders of magnitude. -// -// e.g. Comma(834142.32) -> 834,142.32 -func Commaf(v float64) string { - buf := &bytes.Buffer{} - if v < 0 { - buf.Write([]byte{'-'}) - v = 0 - v - } - - comma := []byte{','} - - parts := strings.Split(strconv.FormatFloat(v, 'f', -1, 64), ".") - pos := 0 - if len(parts[0])%3 != 0 { - pos += len(parts[0]) % 3 - buf.WriteString(parts[0][:pos]) - buf.Write(comma) - } - for ; pos < len(parts[0]); pos += 3 { - buf.WriteString(parts[0][pos : pos+3]) - buf.Write(comma) - } - buf.Truncate(buf.Len() - 1) - - if len(parts) > 1 { - buf.Write([]byte{'.'}) - buf.WriteString(parts[1]) - } - return buf.String() -} - -// BigComma produces a string form of the given big.Int in base 10 -// with commas after every three orders of magnitude. -func BigComma(b *big.Int) string { - sign := "" - if b.Sign() < 0 { - sign = "-" - b.Abs(b) - } - - athousand := big.NewInt(1000) - c := (&big.Int{}).Set(b) - _, m := oom(c, athousand) - parts := make([]string, m+1) - j := len(parts) - 1 - - mod := &big.Int{} - for b.Cmp(athousand) >= 0 { - b.DivMod(b, athousand, mod) - parts[j] = strconv.FormatInt(mod.Int64(), 10) - switch len(parts[j]) { - case 2: - parts[j] = "0" + parts[j] - case 1: - parts[j] = "00" + parts[j] - } - j-- - } - parts[j] = strconv.Itoa(int(b.Int64())) - return sign + strings.Join(parts[j:], ",") -} diff --git a/vendor/github.com/dustin/go-humanize/comma_test.go b/vendor/github.com/dustin/go-humanize/comma_test.go deleted file mode 100644 index 49040fb..0000000 --- a/vendor/github.com/dustin/go-humanize/comma_test.go +++ /dev/null @@ -1,134 +0,0 @@ -package humanize - -import ( - "math" - "math/big" - "testing" -) - -func TestCommas(t *testing.T) { - testList{ - {"0", Comma(0), "0"}, - {"10", Comma(10), "10"}, - {"100", Comma(100), "100"}, - {"1,000", Comma(1000), "1,000"}, - {"10,000", Comma(10000), "10,000"}, - {"100,000", Comma(100000), "100,000"}, - {"10,000,000", Comma(10000000), "10,000,000"}, - {"10,100,000", Comma(10100000), "10,100,000"}, - {"10,010,000", Comma(10010000), "10,010,000"}, - {"10,001,000", Comma(10001000), "10,001,000"}, - {"123,456,789", Comma(123456789), "123,456,789"}, - {"maxint", Comma(9.223372e+18), "9,223,372,000,000,000,000"}, - {"minint", Comma(-9.223372e+18), "-9,223,372,000,000,000,000"}, - {"-123,456,789", Comma(-123456789), "-123,456,789"}, - {"-10,100,000", Comma(-10100000), "-10,100,000"}, - {"-10,010,000", Comma(-10010000), "-10,010,000"}, - {"-10,001,000", Comma(-10001000), "-10,001,000"}, - {"-10,000,000", Comma(-10000000), "-10,000,000"}, - {"-100,000", Comma(-100000), "-100,000"}, - {"-10,000", Comma(-10000), "-10,000"}, - {"-1,000", Comma(-1000), "-1,000"}, - {"-100", Comma(-100), "-100"}, - {"-10", Comma(-10), "-10"}, - }.validate(t) -} - -func TestCommafs(t *testing.T) { - testList{ - {"0", Commaf(0), "0"}, - {"10.11", Commaf(10.11), "10.11"}, - {"100", Commaf(100), "100"}, - {"1,000", Commaf(1000), "1,000"}, - {"10,000", Commaf(10000), "10,000"}, - {"100,000", Commaf(100000), "100,000"}, - {"834,142.32", Commaf(834142.32), "834,142.32"}, - {"10,000,000", Commaf(10000000), "10,000,000"}, - {"10,100,000", Commaf(10100000), "10,100,000"}, - {"10,010,000", Commaf(10010000), "10,010,000"}, - {"10,001,000", Commaf(10001000), "10,001,000"}, - {"123,456,789", Commaf(123456789), "123,456,789"}, - {"maxf64", Commaf(math.MaxFloat64), "179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000"}, - {"minf64", Commaf(math.SmallestNonzeroFloat64), "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005"}, - {"-123,456,789", Commaf(-123456789), "-123,456,789"}, - {"-10,100,000", Commaf(-10100000), "-10,100,000"}, - {"-10,010,000", Commaf(-10010000), "-10,010,000"}, - {"-10,001,000", Commaf(-10001000), "-10,001,000"}, - {"-10,000,000", Commaf(-10000000), "-10,000,000"}, - {"-100,000", Commaf(-100000), "-100,000"}, - {"-10,000", Commaf(-10000), "-10,000"}, - {"-1,000", Commaf(-1000), "-1,000"}, - {"-100.11", Commaf(-100.11), "-100.11"}, - {"-10", Commaf(-10), "-10"}, - }.validate(t) -} - -func BenchmarkCommas(b *testing.B) { - for i := 0; i < b.N; i++ { - Comma(1234567890) - } -} - -func BenchmarkCommaf(b *testing.B) { - for i := 0; i < b.N; i++ { - Commaf(1234567890.83584) - } -} - -func BenchmarkBigCommas(b *testing.B) { - for i := 0; i < b.N; i++ { - BigComma(big.NewInt(1234567890)) - } -} - -func bigComma(i int64) string { - return BigComma(big.NewInt(i)) -} - -func TestBigCommas(t *testing.T) { - testList{ - {"0", bigComma(0), "0"}, - {"10", bigComma(10), "10"}, - {"100", bigComma(100), "100"}, - {"1,000", bigComma(1000), "1,000"}, - {"10,000", bigComma(10000), "10,000"}, - {"100,000", bigComma(100000), "100,000"}, - {"10,000,000", bigComma(10000000), "10,000,000"}, - {"10,100,000", bigComma(10100000), "10,100,000"}, - {"10,010,000", bigComma(10010000), "10,010,000"}, - {"10,001,000", bigComma(10001000), "10,001,000"}, - {"123,456,789", bigComma(123456789), "123,456,789"}, - {"maxint", bigComma(9.223372e+18), "9,223,372,000,000,000,000"}, - {"minint", bigComma(-9.223372e+18), "-9,223,372,000,000,000,000"}, - {"-123,456,789", bigComma(-123456789), "-123,456,789"}, - {"-10,100,000", bigComma(-10100000), "-10,100,000"}, - {"-10,010,000", bigComma(-10010000), "-10,010,000"}, - {"-10,001,000", bigComma(-10001000), "-10,001,000"}, - {"-10,000,000", bigComma(-10000000), "-10,000,000"}, - {"-100,000", bigComma(-100000), "-100,000"}, - {"-10,000", bigComma(-10000), "-10,000"}, - {"-1,000", bigComma(-1000), "-1,000"}, - {"-100", bigComma(-100), "-100"}, - {"-10", bigComma(-10), "-10"}, - }.validate(t) -} - -func TestVeryBigCommas(t *testing.T) { - tests := []struct{ in, exp string }{ - { - "84889279597249724975972597249849757294578485", - "84,889,279,597,249,724,975,972,597,249,849,757,294,578,485", - }, - { - "-84889279597249724975972597249849757294578485", - "-84,889,279,597,249,724,975,972,597,249,849,757,294,578,485", - }, - } - for _, test := range tests { - n, _ := (&big.Int{}).SetString(test.in, 10) - got := BigComma(n) - if test.exp != got { - t.Errorf("Expected %q, got %q", test.exp, got) - } - } -} diff --git a/vendor/github.com/dustin/go-humanize/commaf.go b/vendor/github.com/dustin/go-humanize/commaf.go deleted file mode 100644 index 620690d..0000000 --- a/vendor/github.com/dustin/go-humanize/commaf.go +++ /dev/null @@ -1,40 +0,0 @@ -// +build go1.6 - -package humanize - -import ( - "bytes" - "math/big" - "strings" -) - -// BigCommaf produces a string form of the given big.Float in base 10 -// with commas after every three orders of magnitude. -func BigCommaf(v *big.Float) string { - buf := &bytes.Buffer{} - if v.Sign() < 0 { - buf.Write([]byte{'-'}) - v.Abs(v) - } - - comma := []byte{','} - - parts := strings.Split(v.Text('f', -1), ".") - pos := 0 - if len(parts[0])%3 != 0 { - pos += len(parts[0]) % 3 - buf.WriteString(parts[0][:pos]) - buf.Write(comma) - } - for ; pos < len(parts[0]); pos += 3 { - buf.WriteString(parts[0][pos : pos+3]) - buf.Write(comma) - } - buf.Truncate(buf.Len() - 1) - - if len(parts) > 1 { - buf.Write([]byte{'.'}) - buf.WriteString(parts[1]) - } - return buf.String() -} diff --git a/vendor/github.com/dustin/go-humanize/commaf_test.go b/vendor/github.com/dustin/go-humanize/commaf_test.go deleted file mode 100644 index 21f7f9e..0000000 --- a/vendor/github.com/dustin/go-humanize/commaf_test.go +++ /dev/null @@ -1,44 +0,0 @@ -// +build go1.6 - -package humanize - -import ( - "math" - "math/big" - "testing" -) - -func BenchmarkBigCommaf(b *testing.B) { - for i := 0; i < b.N; i++ { - Commaf(1234567890.83584) - } -} - -func TestBigCommafs(t *testing.T) { - testList{ - {"0", BigCommaf(big.NewFloat(0)), "0"}, - {"10.11", BigCommaf(big.NewFloat(10.11)), "10.11"}, - {"100", BigCommaf(big.NewFloat(100)), "100"}, - {"1,000", BigCommaf(big.NewFloat(1000)), "1,000"}, - {"10,000", BigCommaf(big.NewFloat(10000)), "10,000"}, - {"100,000", BigCommaf(big.NewFloat(100000)), "100,000"}, - {"834,142.32", BigCommaf(big.NewFloat(834142.32)), "834,142.32"}, - {"10,000,000", BigCommaf(big.NewFloat(10000000)), "10,000,000"}, - {"10,100,000", BigCommaf(big.NewFloat(10100000)), "10,100,000"}, - {"10,010,000", BigCommaf(big.NewFloat(10010000)), "10,010,000"}, - {"10,001,000", BigCommaf(big.NewFloat(10001000)), "10,001,000"}, - {"123,456,789", BigCommaf(big.NewFloat(123456789)), "123,456,789"}, - {"maxf64", BigCommaf(big.NewFloat(math.MaxFloat64)), "179,769,313,486,231,570,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000"}, - {"minf64", BigCommaf(big.NewFloat(math.SmallestNonzeroFloat64)), "0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004940656458412465"}, - {"-123,456,789", BigCommaf(big.NewFloat(-123456789)), "-123,456,789"}, - {"-10,100,000", BigCommaf(big.NewFloat(-10100000)), "-10,100,000"}, - {"-10,010,000", BigCommaf(big.NewFloat(-10010000)), "-10,010,000"}, - {"-10,001,000", BigCommaf(big.NewFloat(-10001000)), "-10,001,000"}, - {"-10,000,000", BigCommaf(big.NewFloat(-10000000)), "-10,000,000"}, - {"-100,000", BigCommaf(big.NewFloat(-100000)), "-100,000"}, - {"-10,000", BigCommaf(big.NewFloat(-10000)), "-10,000"}, - {"-1,000", BigCommaf(big.NewFloat(-1000)), "-1,000"}, - {"-100.11", BigCommaf(big.NewFloat(-100.11)), "-100.11"}, - {"-10", BigCommaf(big.NewFloat(-10)), "-10"}, - }.validate(t) -} diff --git a/vendor/github.com/dustin/go-humanize/common_test.go b/vendor/github.com/dustin/go-humanize/common_test.go deleted file mode 100644 index fc7db15..0000000 --- a/vendor/github.com/dustin/go-humanize/common_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package humanize - -import ( - "testing" -) - -type testList []struct { - name, got, exp string -} - -func (tl testList) validate(t *testing.T) { - for _, test := range tl { - if test.got != test.exp { - t.Errorf("On %v, expected '%v', but got '%v'", - test.name, test.exp, test.got) - } - } -} diff --git a/vendor/github.com/dustin/go-humanize/ftoa.go b/vendor/github.com/dustin/go-humanize/ftoa.go deleted file mode 100644 index c76190b..0000000 --- a/vendor/github.com/dustin/go-humanize/ftoa.go +++ /dev/null @@ -1,23 +0,0 @@ -package humanize - -import "strconv" - -func stripTrailingZeros(s string) string { - offset := len(s) - 1 - for offset > 0 { - if s[offset] == '.' { - offset-- - break - } - if s[offset] != '0' { - break - } - offset-- - } - return s[:offset+1] -} - -// Ftoa converts a float to a string with no trailing zeros. -func Ftoa(num float64) string { - return stripTrailingZeros(strconv.FormatFloat(num, 'f', 6, 64)) -} diff --git a/vendor/github.com/dustin/go-humanize/ftoa_test.go b/vendor/github.com/dustin/go-humanize/ftoa_test.go deleted file mode 100644 index 276d411..0000000 --- a/vendor/github.com/dustin/go-humanize/ftoa_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package humanize - -import ( - "fmt" - "regexp" - "strconv" - "testing" -) - -func TestFtoa(t *testing.T) { - testList{ - {"200", Ftoa(200), "200"}, - {"2", Ftoa(2), "2"}, - {"2.2", Ftoa(2.2), "2.2"}, - {"2.02", Ftoa(2.02), "2.02"}, - {"200.02", Ftoa(200.02), "200.02"}, - }.validate(t) -} - -func BenchmarkFtoaRegexTrailing(b *testing.B) { - trailingZerosRegex := regexp.MustCompile(`\.?0+$`) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - trailingZerosRegex.ReplaceAllString("2.00000", "") - trailingZerosRegex.ReplaceAllString("2.0000", "") - trailingZerosRegex.ReplaceAllString("2.000", "") - trailingZerosRegex.ReplaceAllString("2.00", "") - trailingZerosRegex.ReplaceAllString("2.0", "") - trailingZerosRegex.ReplaceAllString("2", "") - } -} - -func BenchmarkFtoaFunc(b *testing.B) { - for i := 0; i < b.N; i++ { - stripTrailingZeros("2.00000") - stripTrailingZeros("2.0000") - stripTrailingZeros("2.000") - stripTrailingZeros("2.00") - stripTrailingZeros("2.0") - stripTrailingZeros("2") - } -} - -func BenchmarkFmtF(b *testing.B) { - for i := 0; i < b.N; i++ { - _ = fmt.Sprintf("%f", 2.03584) - } -} - -func BenchmarkStrconvF(b *testing.B) { - for i := 0; i < b.N; i++ { - strconv.FormatFloat(2.03584, 'f', 6, 64) - } -} diff --git a/vendor/github.com/dustin/go-humanize/humanize.go b/vendor/github.com/dustin/go-humanize/humanize.go deleted file mode 100644 index a69540a..0000000 --- a/vendor/github.com/dustin/go-humanize/humanize.go +++ /dev/null @@ -1,8 +0,0 @@ -/* -Package humanize converts boring ugly numbers to human-friendly strings and back. - -Durations can be turned into strings such as "3 days ago", numbers -representing sizes like 82854982 into useful strings like, "83MB" or -"79MiB" (whichever you prefer). -*/ -package humanize diff --git a/vendor/github.com/dustin/go-humanize/number.go b/vendor/github.com/dustin/go-humanize/number.go deleted file mode 100644 index 3214134..0000000 --- a/vendor/github.com/dustin/go-humanize/number.go +++ /dev/null @@ -1,192 +0,0 @@ -package humanize - -/* -Slightly adapted from the source to fit go-humanize. - -Author: https://github.com/gorhill -Source: https://gist.github.com/gorhill/5285193 - -*/ - -import ( - "math" - "strconv" -) - -var ( - renderFloatPrecisionMultipliers = [...]float64{ - 1, - 10, - 100, - 1000, - 10000, - 100000, - 1000000, - 10000000, - 100000000, - 1000000000, - } - - renderFloatPrecisionRounders = [...]float64{ - 0.5, - 0.05, - 0.005, - 0.0005, - 0.00005, - 0.000005, - 0.0000005, - 0.00000005, - 0.000000005, - 0.0000000005, - } -) - -// FormatFloat produces a formatted number as string based on the following user-specified criteria: -// * thousands separator -// * decimal separator -// * decimal precision -// -// Usage: s := RenderFloat(format, n) -// The format parameter tells how to render the number n. -// -// See examples: http://play.golang.org/p/LXc1Ddm1lJ -// -// Examples of format strings, given n = 12345.6789: -// "#,###.##" => "12,345.67" -// "#,###." => "12,345" -// "#,###" => "12345,678" -// "#\u202F###,##" => "12 345,68" -// "#.###,###### => 12.345,678900 -// "" (aka default format) => 12,345.67 -// -// The highest precision allowed is 9 digits after the decimal symbol. -// There is also a version for integer number, FormatInteger(), -// which is convenient for calls within template. -func FormatFloat(format string, n float64) string { - // Special cases: - // NaN = "NaN" - // +Inf = "+Infinity" - // -Inf = "-Infinity" - if math.IsNaN(n) { - return "NaN" - } - if n > math.MaxFloat64 { - return "Infinity" - } - if n < -math.MaxFloat64 { - return "-Infinity" - } - - // default format - precision := 2 - decimalStr := "." - thousandStr := "," - positiveStr := "" - negativeStr := "-" - - if len(format) > 0 { - format := []rune(format) - - // If there is an explicit format directive, - // then default values are these: - precision = 9 - thousandStr = "" - - // collect indices of meaningful formatting directives - formatIndx := []int{} - for i, char := range format { - if char != '#' && char != '0' { - formatIndx = append(formatIndx, i) - } - } - - if len(formatIndx) > 0 { - // Directive at index 0: - // Must be a '+' - // Raise an error if not the case - // index: 0123456789 - // +0.000,000 - // +000,000.0 - // +0000.00 - // +0000 - if formatIndx[0] == 0 { - if format[formatIndx[0]] != '+' { - panic("RenderFloat(): invalid positive sign directive") - } - positiveStr = "+" - formatIndx = formatIndx[1:] - } - - // Two directives: - // First is thousands separator - // Raise an error if not followed by 3-digit - // 0123456789 - // 0.000,000 - // 000,000.00 - if len(formatIndx) == 2 { - if (formatIndx[1] - formatIndx[0]) != 4 { - panic("RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers") - } - thousandStr = string(format[formatIndx[0]]) - formatIndx = formatIndx[1:] - } - - // One directive: - // Directive is decimal separator - // The number of digit-specifier following the separator indicates wanted precision - // 0123456789 - // 0.00 - // 000,0000 - if len(formatIndx) == 1 { - decimalStr = string(format[formatIndx[0]]) - precision = len(format) - formatIndx[0] - 1 - } - } - } - - // generate sign part - var signStr string - if n >= 0.000000001 { - signStr = positiveStr - } else if n <= -0.000000001 { - signStr = negativeStr - n = -n - } else { - signStr = "" - n = 0.0 - } - - // split number into integer and fractional parts - intf, fracf := math.Modf(n + renderFloatPrecisionRounders[precision]) - - // generate integer part string - intStr := strconv.Itoa(int(intf)) - - // add thousand separator if required - if len(thousandStr) > 0 { - for i := len(intStr); i > 3; { - i -= 3 - intStr = intStr[:i] + thousandStr + intStr[i:] - } - } - - // no fractional part, we can leave now - if precision == 0 { - return signStr + intStr - } - - // generate fractional part - fracStr := strconv.Itoa(int(fracf * renderFloatPrecisionMultipliers[precision])) - // may need padding - if len(fracStr) < precision { - fracStr = "000000000000000"[:precision-len(fracStr)] + fracStr - } - - return signStr + intStr + decimalStr + fracStr -} - -// FormatInteger produces a formatted number as string. -// See FormatFloat. -func FormatInteger(format string, n int) string { - return FormatFloat(format, float64(n)) -} diff --git a/vendor/github.com/dustin/go-humanize/number_test.go b/vendor/github.com/dustin/go-humanize/number_test.go deleted file mode 100644 index dd38a5b..0000000 --- a/vendor/github.com/dustin/go-humanize/number_test.go +++ /dev/null @@ -1,78 +0,0 @@ -package humanize - -import ( - "math" - "testing" -) - -type TestStruct struct { - name string - format string - num float64 - formatted string -} - -func TestFormatFloat(t *testing.T) { - tests := []TestStruct{ - {"default", "", 12345.6789, "12,345.68"}, - {"#", "#", 12345.6789, "12345.678900000"}, - {"#.", "#.", 12345.6789, "12346"}, - {"#,#", "#,#", 12345.6789, "12345,7"}, - {"#,##", "#,##", 12345.6789, "12345,68"}, - {"#,###", "#,###", 12345.6789, "12345,679"}, - {"#,###.", "#,###.", 12345.6789, "12,346"}, - {"#,###.##", "#,###.##", 12345.6789, "12,345.68"}, - {"#,###.###", "#,###.###", 12345.6789, "12,345.679"}, - {"#,###.####", "#,###.####", 12345.6789, "12,345.6789"}, - {"#.###,######", "#.###,######", 12345.6789, "12.345,678900"}, - {"#\u202f###,##", "#\u202f###,##", 12345.6789, "12 345,68"}, - - // special cases - {"NaN", "#", math.NaN(), "NaN"}, - {"+Inf", "#", math.Inf(1), "Infinity"}, - {"-Inf", "#", math.Inf(-1), "-Infinity"}, - {"signStr <= -0.000000001", "", -0.000000002, "-0.00"}, - {"signStr = 0", "", 0, "0.00"}, - {"Format directive must start with +", "+000", 12345.6789, "+12345.678900000"}, - } - - for _, test := range tests { - got := FormatFloat(test.format, test.num) - if got != test.formatted { - t.Errorf("On %v (%v, %v), got %v, wanted %v", - test.name, test.format, test.num, got, test.formatted) - } - } - // Test a single integer - got := FormatInteger("#", 12345) - if got != "12345.000000000" { - t.Errorf("On %v (%v, %v), got %v, wanted %v", - "integerTest", "#", 12345, got, "12345.000000000") - } - // Test the things that could panic - panictests := []TestStruct{ - {"RenderFloat(): invalid positive sign directive", "-", 12345.6789, "12,345.68"}, - {"RenderFloat(): thousands separator directive must be followed by 3 digit-specifiers", "0.01", 12345.6789, "12,345.68"}, - } - for _, test := range panictests { - didPanic := false - var message interface{} - func() { - - defer func() { - if message = recover(); message != nil { - didPanic = true - } - }() - - // call the target function - _ = FormatFloat(test.format, test.num) - - }() - if didPanic != true { - t.Errorf("On %v, should have panic and did not.", - test.name) - } - } - -} diff --git a/vendor/github.com/dustin/go-humanize/ordinals.go b/vendor/github.com/dustin/go-humanize/ordinals.go deleted file mode 100644 index 43d88a8..0000000 --- a/vendor/github.com/dustin/go-humanize/ordinals.go +++ /dev/null @@ -1,25 +0,0 @@ -package humanize - -import "strconv" - -// Ordinal gives you the input number in a rank/ordinal format. -// -// Ordinal(3) -> 3rd -func Ordinal(x int) string { - suffix := "th" - switch x % 10 { - case 1: - if x%100 != 11 { - suffix = "st" - } - case 2: - if x%100 != 12 { - suffix = "nd" - } - case 3: - if x%100 != 13 { - suffix = "rd" - } - } - return strconv.Itoa(x) + suffix -} diff --git a/vendor/github.com/dustin/go-humanize/ordinals_test.go b/vendor/github.com/dustin/go-humanize/ordinals_test.go deleted file mode 100644 index 51d85ee..0000000 --- a/vendor/github.com/dustin/go-humanize/ordinals_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package humanize - -import ( - "testing" -) - -func TestOrdinals(t *testing.T) { - testList{ - {"0", Ordinal(0), "0th"}, - {"1", Ordinal(1), "1st"}, - {"2", Ordinal(2), "2nd"}, - {"3", Ordinal(3), "3rd"}, - {"4", Ordinal(4), "4th"}, - {"10", Ordinal(10), "10th"}, - {"11", Ordinal(11), "11th"}, - {"12", Ordinal(12), "12th"}, - {"13", Ordinal(13), "13th"}, - {"101", Ordinal(101), "101st"}, - {"102", Ordinal(102), "102nd"}, - {"103", Ordinal(103), "103rd"}, - }.validate(t) -} diff --git a/vendor/github.com/dustin/go-humanize/si.go b/vendor/github.com/dustin/go-humanize/si.go deleted file mode 100644 index 9cce4e8..0000000 --- a/vendor/github.com/dustin/go-humanize/si.go +++ /dev/null @@ -1,113 +0,0 @@ -package humanize - -import ( - "errors" - "math" - "regexp" - "strconv" -) - -var siPrefixTable = map[float64]string{ - -24: "y", // yocto - -21: "z", // zepto - -18: "a", // atto - -15: "f", // femto - -12: "p", // pico - -9: "n", // nano - -6: "µ", // micro - -3: "m", // milli - 0: "", - 3: "k", // kilo - 6: "M", // mega - 9: "G", // giga - 12: "T", // tera - 15: "P", // peta - 18: "E", // exa - 21: "Z", // zetta - 24: "Y", // yotta -} - -var revSIPrefixTable = revfmap(siPrefixTable) - -// revfmap reverses the map and precomputes the power multiplier -func revfmap(in map[float64]string) map[string]float64 { - rv := map[string]float64{} - for k, v := range in { - rv[v] = math.Pow(10, k) - } - return rv -} - -var riParseRegex *regexp.Regexp - -func init() { - ri := `^([\-0-9.]+)\s?([` - for _, v := range siPrefixTable { - ri += v - } - ri += `]?)(.*)` - - riParseRegex = regexp.MustCompile(ri) -} - -// ComputeSI finds the most appropriate SI prefix for the given number -// and returns the prefix along with the value adjusted to be within -// that prefix. -// -// See also: SI, ParseSI. -// -// e.g. ComputeSI(2.2345e-12) -> (2.2345, "p") -func ComputeSI(input float64) (float64, string) { - if input == 0 { - return 0, "" - } - mag := math.Abs(input) - exponent := math.Floor(logn(mag, 10)) - exponent = math.Floor(exponent/3) * 3 - - value := mag / math.Pow(10, exponent) - - // Handle special case where value is exactly 1000.0 - // Should return 1M instead of 1000k - if value == 1000.0 { - exponent += 3 - value = mag / math.Pow(10, exponent) - } - - value = math.Copysign(value, input) - - prefix := siPrefixTable[exponent] - return value, prefix -} - -// SI returns a string with default formatting. -// -// SI uses Ftoa to format float value, removing trailing zeros. -// -// See also: ComputeSI, ParseSI. -// -// e.g. SI(1000000, B) -> 1MB -// e.g. SI(2.2345e-12, "F") -> 2.2345pF -func SI(input float64, unit string) string { - value, prefix := ComputeSI(input) - return Ftoa(value) + " " + prefix + unit -} - -var errInvalid = errors.New("invalid input") - -// ParseSI parses an SI string back into the number and unit. -// -// See also: SI, ComputeSI. -// -// e.g. ParseSI(2.2345pF) -> (2.2345e-12, "F", nil) -func ParseSI(input string) (float64, string, error) { - found := riParseRegex.FindStringSubmatch(input) - if len(found) != 4 { - return 0, "", errInvalid - } - mag := revSIPrefixTable[found[2]] - unit := found[3] - - base, err := strconv.ParseFloat(found[1], 64) - return base * mag, unit, err -} diff --git a/vendor/github.com/dustin/go-humanize/si_test.go b/vendor/github.com/dustin/go-humanize/si_test.go deleted file mode 100644 index bc5bac6..0000000 --- a/vendor/github.com/dustin/go-humanize/si_test.go +++ /dev/null @@ -1,101 +0,0 @@ -package humanize - -import ( - "math" - "testing" -) - -func TestSI(t *testing.T) { - tests := []struct { - name string - num float64 - formatted string - }{ - {"e-24", 1e-24, "1 yF"}, - {"e-21", 1e-21, "1 zF"}, - {"e-18", 1e-18, "1 aF"}, - {"e-15", 1e-15, "1 fF"}, - {"e-12", 1e-12, "1 pF"}, - {"e-12", 2.2345e-12, "2.2345 pF"}, - {"e-12", 2.23e-12, "2.23 pF"}, - {"e-11", 2.23e-11, "22.3 pF"}, - {"e-10", 2.2e-10, "220 pF"}, - {"e-9", 2.2e-9, "2.2 nF"}, - {"e-8", 2.2e-8, "22 nF"}, - {"e-7", 2.2e-7, "220 nF"}, - {"e-6", 2.2e-6, "2.2 µF"}, - {"e-6", 1e-6, "1 µF"}, - {"e-5", 2.2e-5, "22 µF"}, - {"e-4", 2.2e-4, "220 µF"}, - {"e-3", 2.2e-3, "2.2 mF"}, - {"e-2", 2.2e-2, "22 mF"}, - {"e-1", 2.2e-1, "220 mF"}, - {"e+0", 2.2e-0, "2.2 F"}, - {"e+0", 2.2, "2.2 F"}, - {"e+1", 2.2e+1, "22 F"}, - {"0", 0, "0 F"}, - {"e+1", 22, "22 F"}, - {"e+2", 2.2e+2, "220 F"}, - {"e+2", 220, "220 F"}, - {"e+3", 2.2e+3, "2.2 kF"}, - {"e+3", 2200, "2.2 kF"}, - {"e+4", 2.2e+4, "22 kF"}, - {"e+4", 22000, "22 kF"}, - {"e+5", 2.2e+5, "220 kF"}, - {"e+6", 2.2e+6, "2.2 MF"}, - {"e+6", 1e+6, "1 MF"}, - {"e+7", 2.2e+7, "22 MF"}, - {"e+8", 2.2e+8, "220 MF"}, - {"e+9", 2.2e+9, "2.2 GF"}, - {"e+10", 2.2e+10, "22 GF"}, - {"e+11", 2.2e+11, "220 GF"}, - {"e+12", 2.2e+12, "2.2 TF"}, - {"e+15", 2.2e+15, "2.2 PF"}, - {"e+18", 2.2e+18, "2.2 EF"}, - {"e+21", 2.2e+21, "2.2 ZF"}, - {"e+24", 2.2e+24, "2.2 YF"}, - - // special case - {"1F", 1000 * 1000, "1 MF"}, - {"1F", 1e6, "1 MF"}, - - // negative number - {"-100 F", -100, "-100 F"}, - } - - for _, test := range tests { - got := SI(test.num, "F") - if got != test.formatted { - t.Errorf("On %v (%v), got %v, wanted %v", - test.name, test.num, got, test.formatted) - } - - gotf, gotu, err := ParseSI(test.formatted) - if err != nil { - t.Errorf("Error parsing %v (%v): %v", test.name, test.formatted, err) - continue - } - - if math.Abs(1-(gotf/test.num)) > 0.01 { - t.Errorf("On %v (%v), got %v, wanted %v (±%v)", - test.name, test.formatted, gotf, test.num, - math.Abs(1-(gotf/test.num))) - } - if gotu != "F" { - t.Errorf("On %v (%v), expected unit F, got %v", - test.name, test.formatted, gotu) - } - } - - // Parse error - gotf, gotu, err := ParseSI("x1.21JW") // 1.21 jigga whats - if err == nil { - t.Errorf("Expected error on x1.21JW, got %v %v", gotf, gotu) - } -} - -func BenchmarkParseSI(b *testing.B) { - for i := 0; i < b.N; i++ { - ParseSI("2.2346ZB") - } -} diff --git a/vendor/github.com/dustin/go-humanize/times.go b/vendor/github.com/dustin/go-humanize/times.go deleted file mode 100644 index 49906b3..0000000 --- a/vendor/github.com/dustin/go-humanize/times.go +++ /dev/null @@ -1,90 +0,0 @@ -package humanize - -import ( - "fmt" - "math" - "sort" - "time" -) - -// Seconds-based time units -const ( - Minute = 60 - Hour = 60 * Minute - Day = 24 * Hour - Week = 7 * Day - Month = 30 * Day - Year = 12 * Month - LongTime = 37 * Year -) - -// Time formats a time into a relative string. -// -// Time(someT) -> "3 weeks ago" -func Time(then time.Time) string { - return RelTime(then, time.Now(), "ago", "from now") -} - -var magnitudes = []struct { - d int64 - format string - divby int64 -}{ - {1, "now", 1}, - {2, "1 second %s", 1}, - {Minute, "%d seconds %s", 1}, - {2 * Minute, "1 minute %s", 1}, - {Hour, "%d minutes %s", Minute}, - {2 * Hour, "1 hour %s", 1}, - {Day, "%d hours %s", Hour}, - {2 * Day, "1 day %s", 1}, - {Week, "%d days %s", Day}, - {2 * Week, "1 week %s", 1}, - {Month, "%d weeks %s", Week}, - {2 * Month, "1 month %s", 1}, - {Year, "%d months %s", Month}, - {18 * Month, "1 year %s", 1}, - {2 * Year, "2 years %s", 1}, - {LongTime, "%d years %s", Year}, - {math.MaxInt64, "a long while %s", 1}, -} - -// RelTime formats a time into a relative string. -// -// It takes two times and two labels. In addition to the generic time -// delta string (e.g. 5 minutes), the labels are used applied so that -// the label corresponding to the smaller time is applied. -// -// RelTime(timeInPast, timeInFuture, "earlier", "later") -> "3 weeks earlier" -func RelTime(a, b time.Time, albl, blbl string) string { - lbl := albl - diff := b.Unix() - a.Unix() - - after := a.After(b) - if after { - lbl = blbl - diff = a.Unix() - b.Unix() - } - - n := sort.Search(len(magnitudes), func(i int) bool { - return magnitudes[i].d > diff - }) - - mag := magnitudes[n] - args := []interface{}{} - escaped := false - for _, ch := range mag.format { - if escaped { - switch ch { - case 's': - args = append(args, lbl) - case 'd': - args = append(args, diff/mag.divby) - } - escaped = false - } else { - escaped = ch == '%' - } - } - return fmt.Sprintf(mag.format, args...) -} diff --git a/vendor/github.com/dustin/go-humanize/times_test.go b/vendor/github.com/dustin/go-humanize/times_test.go deleted file mode 100644 index 528daa4..0000000 --- a/vendor/github.com/dustin/go-humanize/times_test.go +++ /dev/null @@ -1,71 +0,0 @@ -package humanize - -import ( - "math" - "testing" - "time" -) - -func TestPast(t *testing.T) { - now := time.Now().Unix() - testList{ - {"now", Time(time.Unix(now, 0)), "now"}, - {"1 second ago", Time(time.Unix(now-1, 0)), "1 second ago"}, - {"12 seconds ago", Time(time.Unix(now-12, 0)), "12 seconds ago"}, - {"30 seconds ago", Time(time.Unix(now-30, 0)), "30 seconds ago"}, - {"45 seconds ago", Time(time.Unix(now-45, 0)), "45 seconds ago"}, - {"1 minute ago", Time(time.Unix(now-63, 0)), "1 minute ago"}, - {"15 minutes ago", Time(time.Unix(now-15*Minute, 0)), "15 minutes ago"}, - {"1 hour ago", Time(time.Unix(now-63*Minute, 0)), "1 hour ago"}, - {"2 hours ago", Time(time.Unix(now-2*Hour, 0)), "2 hours ago"}, - {"21 hours ago", Time(time.Unix(now-21*Hour, 0)), "21 hours ago"}, - {"1 day ago", Time(time.Unix(now-26*Hour, 0)), "1 day ago"}, - {"2 days ago", Time(time.Unix(now-49*Hour, 0)), "2 days ago"}, - {"3 days ago", Time(time.Unix(now-3*Day, 0)), "3 days ago"}, - {"1 week ago (1)", Time(time.Unix(now-7*Day, 0)), "1 week ago"}, - {"1 week ago (2)", Time(time.Unix(now-12*Day, 0)), "1 week ago"}, - {"2 weeks ago", Time(time.Unix(now-15*Day, 0)), "2 weeks ago"}, - {"1 month ago", Time(time.Unix(now-39*Day, 0)), "1 month ago"}, - {"3 months ago", Time(time.Unix(now-99*Day, 0)), "3 months ago"}, - {"1 year ago (1)", Time(time.Unix(now-365*Day, 0)), "1 year ago"}, - {"1 year ago (1)", Time(time.Unix(now-400*Day, 0)), "1 year ago"}, - {"2 years ago (1)", Time(time.Unix(now-548*Day, 0)), "2 years ago"}, - {"2 years ago (2)", Time(time.Unix(now-725*Day, 0)), "2 years ago"}, - {"2 years ago (3)", Time(time.Unix(now-800*Day, 0)), "2 years ago"}, - {"3 years ago", Time(time.Unix(now-3*Year, 0)), "3 years ago"}, - {"long ago", Time(time.Unix(now-LongTime, 0)), "a long while ago"}, - }.validate(t) -} - -func TestFuture(t *testing.T) { - now := time.Now().Unix() - testList{ - {"now", Time(time.Unix(now, 0)), "now"}, - {"1 second from now", Time(time.Unix(now+1, 0)), "1 second from now"}, - {"12 seconds from now", Time(time.Unix(now+12, 0)), "12 seconds from now"}, - {"30 seconds from now", Time(time.Unix(now+30, 0)), "30 seconds from now"}, - {"45 seconds from now", Time(time.Unix(now+45, 0)), "45 seconds from now"}, - {"15 minutes from now", Time(time.Unix(now+15*Minute, 0)), "15 minutes from now"}, - {"2 hours from now", Time(time.Unix(now+2*Hour, 0)), "2 hours from now"}, - {"21 hours from now", Time(time.Unix(now+21*Hour, 0)), "21 hours from now"}, - {"1 day from now", Time(time.Unix(now+26*Hour, 0)), "1 day from now"}, - {"2 days from now", Time(time.Unix(now+49*Hour, 0)), "2 days from now"}, - {"3 days from now", Time(time.Unix(now+3*Day, 0)), "3 days from now"}, - {"1 week from now (1)", Time(time.Unix(now+7*Day, 0)), "1 week from now"}, - {"1 week from now (2)", Time(time.Unix(now+12*Day, 0)), "1 week from now"}, - {"2 weeks from now", Time(time.Unix(now+15*Day, 0)), "2 weeks from now"}, - {"1 month from now", Time(time.Unix(now+30*Day, 0)), "1 month from now"}, - {"1 year from now", Time(time.Unix(now+365*Day, 0)), "1 year from now"}, - {"2 years from now", Time(time.Unix(now+2*Year, 0)), "2 years from now"}, - {"a while from now", Time(time.Unix(now+LongTime, 0)), "a long while from now"}, - }.validate(t) -} - -func TestRange(t *testing.T) { - start := time.Time{} - end := time.Unix(math.MaxInt64, math.MaxInt64) - x := RelTime(start, end, "ago", "from now") - if x != "a long while from now" { - t.Errorf("Expected a long while from now, got %q", x) - } -} diff --git a/vendor/github.com/flynn/go-shlex/COPYING b/vendor/github.com/flynn/go-shlex/COPYING deleted file mode 100644 index d645695..0000000 --- a/vendor/github.com/flynn/go-shlex/COPYING +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/flynn/go-shlex/Makefile b/vendor/github.com/flynn/go-shlex/Makefile deleted file mode 100644 index 038d9a4..0000000 --- a/vendor/github.com/flynn/go-shlex/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2011 Google Inc. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -include $(GOROOT)/src/Make.inc - -TARG=shlex -GOFILES=\ - shlex.go\ - -include $(GOROOT)/src/Make.pkg diff --git a/vendor/github.com/flynn/go-shlex/README.md b/vendor/github.com/flynn/go-shlex/README.md deleted file mode 100644 index c86bcc0..0000000 --- a/vendor/github.com/flynn/go-shlex/README.md +++ /dev/null @@ -1,2 +0,0 @@ -go-shlex is a simple lexer for go that supports shell-style quoting, -commenting, and escaping. diff --git a/vendor/github.com/flynn/go-shlex/shlex.go b/vendor/github.com/flynn/go-shlex/shlex.go deleted file mode 100644 index 7aeace8..0000000 --- a/vendor/github.com/flynn/go-shlex/shlex.go +++ /dev/null @@ -1,457 +0,0 @@ -/* -Copyright 2012 Google Inc. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package shlex - -/* -Package shlex implements a simple lexer which splits input in to tokens using -shell-style rules for quoting and commenting. -*/ -import ( - "bufio" - "errors" - "fmt" - "io" - "strings" -) - -/* -A TokenType is a top-level token; a word, space, comment, unknown. -*/ -type TokenType int - -/* -A RuneTokenType is the type of a UTF-8 character; a character, quote, space, escape. -*/ -type RuneTokenType int - -type lexerState int - -type Token struct { - tokenType TokenType - value string -} - -/* -Two tokens are equal if both their types and values are equal. A nil token can -never equal another token. -*/ -func (a *Token) Equal(b *Token) bool { - if a == nil || b == nil { - return false - } - if a.tokenType != b.tokenType { - return false - } - return a.value == b.value -} - -const ( - RUNE_CHAR string = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789._-,/@$*()+=><:;&^%~|!?[]{}" - RUNE_SPACE string = " \t\r\n" - RUNE_ESCAPING_QUOTE string = "\"" - RUNE_NONESCAPING_QUOTE string = "'" - RUNE_ESCAPE = "\\" - RUNE_COMMENT = "#" - - RUNETOKEN_UNKNOWN RuneTokenType = 0 - RUNETOKEN_CHAR RuneTokenType = 1 - RUNETOKEN_SPACE RuneTokenType = 2 - RUNETOKEN_ESCAPING_QUOTE RuneTokenType = 3 - RUNETOKEN_NONESCAPING_QUOTE RuneTokenType = 4 - RUNETOKEN_ESCAPE RuneTokenType = 5 - RUNETOKEN_COMMENT RuneTokenType = 6 - RUNETOKEN_EOF RuneTokenType = 7 - - TOKEN_UNKNOWN TokenType = 0 - TOKEN_WORD TokenType = 1 - TOKEN_SPACE TokenType = 2 - TOKEN_COMMENT TokenType = 3 - - STATE_START lexerState = 0 - STATE_INWORD lexerState = 1 - STATE_ESCAPING lexerState = 2 - STATE_ESCAPING_QUOTED lexerState = 3 - STATE_QUOTED_ESCAPING lexerState = 4 - STATE_QUOTED lexerState = 5 - STATE_COMMENT lexerState = 6 - - INITIAL_TOKEN_CAPACITY int = 100 -) - -/* -A type for classifying characters. This allows for different sorts of -classifiers - those accepting extended non-ascii chars, or strict posix -compatibility, for example. -*/ -type TokenClassifier struct { - typeMap map[int32]RuneTokenType -} - -func addRuneClass(typeMap *map[int32]RuneTokenType, runes string, tokenType RuneTokenType) { - for _, rune := range runes { - (*typeMap)[int32(rune)] = tokenType - } -} - -/* -Create a new classifier for basic ASCII characters. -*/ -func NewDefaultClassifier() *TokenClassifier { - typeMap := map[int32]RuneTokenType{} - addRuneClass(&typeMap, RUNE_CHAR, RUNETOKEN_CHAR) - addRuneClass(&typeMap, RUNE_SPACE, RUNETOKEN_SPACE) - addRuneClass(&typeMap, RUNE_ESCAPING_QUOTE, RUNETOKEN_ESCAPING_QUOTE) - addRuneClass(&typeMap, RUNE_NONESCAPING_QUOTE, RUNETOKEN_NONESCAPING_QUOTE) - addRuneClass(&typeMap, RUNE_ESCAPE, RUNETOKEN_ESCAPE) - addRuneClass(&typeMap, RUNE_COMMENT, RUNETOKEN_COMMENT) - return &TokenClassifier{ - typeMap: typeMap} -} - -func (classifier *TokenClassifier) ClassifyRune(rune int32) RuneTokenType { - return classifier.typeMap[rune] -} - -/* -A type for turning an input stream in to a sequence of strings. Whitespace and -comments are skipped. -*/ -type Lexer struct { - tokenizer *Tokenizer -} - -/* -Create a new lexer. -*/ -func NewLexer(r io.Reader) (*Lexer, error) { - - tokenizer, err := NewTokenizer(r) - if err != nil { - return nil, err - } - lexer := &Lexer{tokenizer: tokenizer} - return lexer, nil -} - -/* -Return the next word, and an error value. If there are no more words, the error -will be io.EOF. -*/ -func (l *Lexer) NextWord() (string, error) { - var token *Token - var err error - for { - token, err = l.tokenizer.NextToken() - if err != nil { - return "", err - } - switch token.tokenType { - case TOKEN_WORD: - { - return token.value, nil - } - case TOKEN_COMMENT: - { - // skip comments - } - default: - { - panic(fmt.Sprintf("Unknown token type: %v", token.tokenType)) - } - } - } - return "", io.EOF -} - -/* -A type for turning an input stream in to a sequence of typed tokens. -*/ -type Tokenizer struct { - input *bufio.Reader - classifier *TokenClassifier -} - -/* -Create a new tokenizer. -*/ -func NewTokenizer(r io.Reader) (*Tokenizer, error) { - input := bufio.NewReader(r) - classifier := NewDefaultClassifier() - tokenizer := &Tokenizer{ - input: input, - classifier: classifier} - return tokenizer, nil -} - -/* -Scan the stream for the next token. - -This uses an internal state machine. It will panic if it encounters a character -which it does not know how to handle. -*/ -func (t *Tokenizer) scanStream() (*Token, error) { - state := STATE_START - var tokenType TokenType - value := make([]int32, 0, INITIAL_TOKEN_CAPACITY) - var ( - nextRune int32 - nextRuneType RuneTokenType - err error - ) -SCAN: - for { - nextRune, _, err = t.input.ReadRune() - nextRuneType = t.classifier.ClassifyRune(nextRune) - if err != nil { - if err == io.EOF { - nextRuneType = RUNETOKEN_EOF - err = nil - } else { - return nil, err - } - } - switch state { - case STATE_START: // no runes read yet - { - switch nextRuneType { - case RUNETOKEN_EOF: - { - return nil, io.EOF - } - case RUNETOKEN_CHAR: - { - tokenType = TOKEN_WORD - value = append(value, nextRune) - state = STATE_INWORD - } - case RUNETOKEN_SPACE: - { - } - case RUNETOKEN_ESCAPING_QUOTE: - { - tokenType = TOKEN_WORD - state = STATE_QUOTED_ESCAPING - } - case RUNETOKEN_NONESCAPING_QUOTE: - { - tokenType = TOKEN_WORD - state = STATE_QUOTED - } - case RUNETOKEN_ESCAPE: - { - tokenType = TOKEN_WORD - state = STATE_ESCAPING - } - case RUNETOKEN_COMMENT: - { - tokenType = TOKEN_COMMENT - state = STATE_COMMENT - } - default: - { - return nil, errors.New(fmt.Sprintf("Unknown rune: %v", nextRune)) - } - } - } - case STATE_INWORD: // in a regular word - { - switch nextRuneType { - case RUNETOKEN_EOF: - { - break SCAN - } - case RUNETOKEN_CHAR, RUNETOKEN_COMMENT: - { - value = append(value, nextRune) - } - case RUNETOKEN_SPACE: - { - t.input.UnreadRune() - break SCAN - } - case RUNETOKEN_ESCAPING_QUOTE: - { - state = STATE_QUOTED_ESCAPING - } - case RUNETOKEN_NONESCAPING_QUOTE: - { - state = STATE_QUOTED - } - case RUNETOKEN_ESCAPE: - { - state = STATE_ESCAPING - } - default: - { - return nil, errors.New(fmt.Sprintf("Uknown rune: %v", nextRune)) - } - } - } - case STATE_ESCAPING: // the next rune after an escape character - { - switch nextRuneType { - case RUNETOKEN_EOF: - { - err = errors.New("EOF found after escape character") - break SCAN - } - case RUNETOKEN_CHAR, RUNETOKEN_SPACE, RUNETOKEN_ESCAPING_QUOTE, RUNETOKEN_NONESCAPING_QUOTE, RUNETOKEN_ESCAPE, RUNETOKEN_COMMENT: - { - state = STATE_INWORD - value = append(value, nextRune) - } - default: - { - return nil, errors.New(fmt.Sprintf("Uknown rune: %v", nextRune)) - } - } - } - case STATE_ESCAPING_QUOTED: // the next rune after an escape character, in double quotes - { - switch nextRuneType { - case RUNETOKEN_EOF: - { - err = errors.New("EOF found after escape character") - break SCAN - } - case RUNETOKEN_CHAR, RUNETOKEN_SPACE, RUNETOKEN_ESCAPING_QUOTE, RUNETOKEN_NONESCAPING_QUOTE, RUNETOKEN_ESCAPE, RUNETOKEN_COMMENT: - { - state = STATE_QUOTED_ESCAPING - value = append(value, nextRune) - } - default: - { - return nil, errors.New(fmt.Sprintf("Uknown rune: %v", nextRune)) - } - } - } - case STATE_QUOTED_ESCAPING: // in escaping double quotes - { - switch nextRuneType { - case RUNETOKEN_EOF: - { - err = errors.New("EOF found when expecting closing quote.") - break SCAN - } - case RUNETOKEN_CHAR, RUNETOKEN_UNKNOWN, RUNETOKEN_SPACE, RUNETOKEN_NONESCAPING_QUOTE, RUNETOKEN_COMMENT: - { - value = append(value, nextRune) - } - case RUNETOKEN_ESCAPING_QUOTE: - { - state = STATE_INWORD - } - case RUNETOKEN_ESCAPE: - { - state = STATE_ESCAPING_QUOTED - } - default: - { - return nil, errors.New(fmt.Sprintf("Uknown rune: %v", nextRune)) - } - } - } - case STATE_QUOTED: // in non-escaping single quotes - { - switch nextRuneType { - case RUNETOKEN_EOF: - { - err = errors.New("EOF found when expecting closing quote.") - break SCAN - } - case RUNETOKEN_CHAR, RUNETOKEN_UNKNOWN, RUNETOKEN_SPACE, RUNETOKEN_ESCAPING_QUOTE, RUNETOKEN_ESCAPE, RUNETOKEN_COMMENT: - { - value = append(value, nextRune) - } - case RUNETOKEN_NONESCAPING_QUOTE: - { - state = STATE_INWORD - } - default: - { - return nil, errors.New(fmt.Sprintf("Uknown rune: %v", nextRune)) - } - } - } - case STATE_COMMENT: - { - switch nextRuneType { - case RUNETOKEN_EOF: - { - break SCAN - } - case RUNETOKEN_CHAR, RUNETOKEN_UNKNOWN, RUNETOKEN_ESCAPING_QUOTE, RUNETOKEN_ESCAPE, RUNETOKEN_COMMENT, RUNETOKEN_NONESCAPING_QUOTE: - { - value = append(value, nextRune) - } - case RUNETOKEN_SPACE: - { - if nextRune == '\n' { - state = STATE_START - break SCAN - } else { - value = append(value, nextRune) - } - } - default: - { - return nil, errors.New(fmt.Sprintf("Uknown rune: %v", nextRune)) - } - } - } - default: - { - panic(fmt.Sprintf("Unexpected state: %v", state)) - } - } - } - token := &Token{ - tokenType: tokenType, - value: string(value)} - return token, err -} - -/* -Return the next token in the stream, and an error value. If there are no more -tokens available, the error value will be io.EOF. -*/ -func (t *Tokenizer) NextToken() (*Token, error) { - return t.scanStream() -} - -/* -Split a string in to a slice of strings, based upon shell-style rules for -quoting, escaping, and spaces. -*/ -func Split(s string) ([]string, error) { - l, err := NewLexer(strings.NewReader(s)) - if err != nil { - return nil, err - } - subStrings := []string{} - for { - word, err := l.NextWord() - if err != nil { - if err == io.EOF { - return subStrings, nil - } - return subStrings, err - } - subStrings = append(subStrings, word) - } - return subStrings, nil -} diff --git a/vendor/github.com/flynn/go-shlex/shlex_test.go b/vendor/github.com/flynn/go-shlex/shlex_test.go deleted file mode 100644 index 7551f7c..0000000 --- a/vendor/github.com/flynn/go-shlex/shlex_test.go +++ /dev/null @@ -1,162 +0,0 @@ -/* -Copyright 2012 Google Inc. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package shlex - -import ( - "strings" - "testing" -) - -func checkError(err error, t *testing.T) { - if err != nil { - t.Error(err) - } -} - -func TestClassifier(t *testing.T) { - classifier := NewDefaultClassifier() - runeTests := map[int32]RuneTokenType{ - 'a': RUNETOKEN_CHAR, - ' ': RUNETOKEN_SPACE, - '"': RUNETOKEN_ESCAPING_QUOTE, - '\'': RUNETOKEN_NONESCAPING_QUOTE, - '#': RUNETOKEN_COMMENT} - for rune, expectedType := range runeTests { - foundType := classifier.ClassifyRune(rune) - if foundType != expectedType { - t.Logf("Expected type: %v for rune '%c'(%v). Found type: %v.", expectedType, rune, rune, foundType) - t.Fail() - } - } -} - -func TestTokenizer(t *testing.T) { - testInput := strings.NewReader("one two \"three four\" \"five \\\"six\\\"\" seven#eight # nine # ten\n eleven") - expectedTokens := []*Token{ - &Token{ - tokenType: TOKEN_WORD, - value: "one"}, - &Token{ - tokenType: TOKEN_WORD, - value: "two"}, - &Token{ - tokenType: TOKEN_WORD, - value: "three four"}, - &Token{ - tokenType: TOKEN_WORD, - value: "five \"six\""}, - &Token{ - tokenType: TOKEN_WORD, - value: "seven#eight"}, - &Token{ - tokenType: TOKEN_COMMENT, - value: " nine # ten"}, - &Token{ - tokenType: TOKEN_WORD, - value: "eleven"}} - - tokenizer, err := NewTokenizer(testInput) - checkError(err, t) - for _, expectedToken := range expectedTokens { - foundToken, err := tokenizer.NextToken() - checkError(err, t) - if !foundToken.Equal(expectedToken) { - t.Error("Expected token:", expectedToken, ". Found:", foundToken) - } - } -} - -func TestLexer(t *testing.T) { - testInput := strings.NewReader("one") - expectedWord := "one" - lexer, err := NewLexer(testInput) - checkError(err, t) - foundWord, err := lexer.NextWord() - checkError(err, t) - if expectedWord != foundWord { - t.Error("Expected word:", expectedWord, ". Found:", foundWord) - } -} - -func TestSplitSimple(t *testing.T) { - testInput := "one two three" - expectedOutput := []string{"one", "two", "three"} - foundOutput, err := Split(testInput) - if err != nil { - t.Error("Split returned error:", err) - } - if len(expectedOutput) != len(foundOutput) { - t.Error("Split expected:", len(expectedOutput), "results. Found:", len(foundOutput), "results") - } - for i := range foundOutput { - if foundOutput[i] != expectedOutput[i] { - t.Error("Item:", i, "(", foundOutput[i], ") differs from the expected value:", expectedOutput[i]) - } - } -} - -func TestSplitEscapingQuotes(t *testing.T) { - testInput := "one \"два ${three}\" four" - expectedOutput := []string{"one", "два ${three}", "four"} - foundOutput, err := Split(testInput) - if err != nil { - t.Error("Split returned error:", err) - } - if len(expectedOutput) != len(foundOutput) { - t.Error("Split expected:", len(expectedOutput), "results. Found:", len(foundOutput), "results") - } - for i := range foundOutput { - if foundOutput[i] != expectedOutput[i] { - t.Error("Item:", i, "(", foundOutput[i], ") differs from the expected value:", expectedOutput[i]) - } - } -} - -func TestGlobbingExpressions(t *testing.T) { - testInput := "onefile *file one?ile onefil[de]" - expectedOutput := []string{"onefile", "*file", "one?ile", "onefil[de]"} - foundOutput, err := Split(testInput) - if err != nil { - t.Error("Split returned error", err) - } - if len(expectedOutput) != len(foundOutput) { - t.Error("Split expected:", len(expectedOutput), "results. Found:", len(foundOutput), "results") - } - for i := range foundOutput { - if foundOutput[i] != expectedOutput[i] { - t.Error("Item:", i, "(", foundOutput[i], ") differs from the expected value:", expectedOutput[i]) - } - } - -} - -func TestSplitNonEscapingQuotes(t *testing.T) { - testInput := "one 'два ${three}' four" - expectedOutput := []string{"one", "два ${three}", "four"} - foundOutput, err := Split(testInput) - if err != nil { - t.Error("Split returned error:", err) - } - if len(expectedOutput) != len(foundOutput) { - t.Error("Split expected:", len(expectedOutput), "results. Found:", len(foundOutput), "results") - } - for i := range foundOutput { - if foundOutput[i] != expectedOutput[i] { - t.Error("Item:", i, "(", foundOutput[i], ") differs from the expected value:", expectedOutput[i]) - } - } -} diff --git a/vendor/github.com/go-kit/kit/.gitignore b/vendor/github.com/go-kit/kit/.gitignore deleted file mode 100644 index 716bfff..0000000 --- a/vendor/github.com/go-kit/kit/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -examples/addsvc/addsvc -examples/addsvc/client/client -examples/apigateway/apigateway -examples/profilesvc/profilesvc -examples/stringsvc1/stringsvc1 -examples/stringsvc2/stringsvc2 -examples/stringsvc3/stringsvc3 -gover.coverprofile - -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test -_old* - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe - -# https://github.com/github/gitignore/blob/master/Global/Vim.gitignore -# swap -[._]*.s[a-w][a-z] -[._]s[a-w][a-z] -# session -Session.vim -# temporary -.netrwhist -*~ -# auto-generated tag files -tags - diff --git a/vendor/github.com/go-kit/kit/.travis.yml b/vendor/github.com/go-kit/kit/.travis.yml deleted file mode 100644 index 413f1db..0000000 --- a/vendor/github.com/go-kit/kit/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -script: go test -race -v ./... - -go: - - 1.5.3 - - 1.6 - #- tip diff --git a/vendor/github.com/go-kit/kit/CONTRIBUTING.md b/vendor/github.com/go-kit/kit/CONTRIBUTING.md deleted file mode 100644 index 5cb85a3..0000000 --- a/vendor/github.com/go-kit/kit/CONTRIBUTING.md +++ /dev/null @@ -1,22 +0,0 @@ -# Contributing - -First, thank you for contributing! We love and encourage pull requests from everyone. - -At this stage, we're still developing the initial drafts of all of the packages, using an -[RFC workflow](https://github.com/go-kit/kit/tree/master/rfc). - -Before submitting major changes, here are a few guidelines to follow: - -1. Check the [open issues][issues] and [pull requests][prs] for existing discussions. -1. Open an [issue][issues] to discuss a new feature. -1. Write tests. -1. Make sure the entire test suite passes locally and on Travis CI. -1. Open a Pull Request. -1. [Squash your commits][squash] after receiving feedback and add a [great commit message][message]. -1. Have fun! - -[issues]: https://github.com/go-kit/kit/issues -[prs]: https://github.com/go-kit/kit/pulls -[squash]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html -[message]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html - diff --git a/vendor/github.com/go-kit/kit/LICENSE b/vendor/github.com/go-kit/kit/LICENSE deleted file mode 100644 index 9d83342..0000000 --- a/vendor/github.com/go-kit/kit/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Peter Bourgon - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/vendor/github.com/go-kit/kit/README.md b/vendor/github.com/go-kit/kit/README.md deleted file mode 100644 index daf208d..0000000 --- a/vendor/github.com/go-kit/kit/README.md +++ /dev/null @@ -1,222 +0,0 @@ -# Go kit [![Circle CI](https://circleci.com/gh/go-kit/kit.svg?style=svg)](https://circleci.com/gh/go-kit/kit) [![Drone.io](https://drone.io/github.com/go-kit/kit/status.png)](https://drone.io/github.com/go-kit/kit/latest) [![Travis CI](https://travis-ci.org/go-kit/kit.svg?branch=master)](https://travis-ci.org/go-kit/kit) [![GoDoc](https://godoc.org/github.com/go-kit/kit?status.svg)](https://godoc.org/github.com/go-kit/kit) [![Coverage Status](https://coveralls.io/repos/go-kit/kit/badge.svg?branch=master&service=github)](https://coveralls.io/github/go-kit/kit?branch=master) [![Go Report Card](https://goreportcard.com/badge/go-kit/kit)](https://goreportcard.com/report/go-kit/kit) - -**Go kit** is a **distributed programming toolkit** for building microservices -in large organizations. We solve common problems in distributed systems, so -you can focus on your business logic. - -- Mailing list: [go-kit](https://groups.google.com/forum/#!forum/go-kit) -- Slack: [gophers.slack.com](https://gophers.slack.com) **#go-kit** ([invite](https://gophersinvite.herokuapp.com/)) - -## Documentation - -### Examples - -Perhaps the best way to understand Go kit is to follow along as we build an -[example service][examples] from first principles. This can serve as a -blueprint for your own new service, or demonstrate how to adapt your existing -service to use Go kit components. - -[examples]: https://github.com/go-kit/kit/tree/master/examples - -### Endpoint - -Go kit primarily deals in the RPC messaging pattern. We use an abstraction -called an **[endpoint][]** to model individual RPCs. An endpoint can be -implemented by a server, and called by a client. It's the fundamental building -block of many Go kit components. - -[endpoint]: https://github.com/go-kit/kit/tree/master/endpoint/endpoint.go - -#### Circuit breaker - -The [circuitbreaker package][circuitbreaker] provides endpoint adapters to -several popular circuit breaker libraries. Circuit breakers prevent thundering -herds, and improve resiliency against intermittent errors. Every client-side -endpoint should be wrapped in a circuit breaker. - -[circuitbreaker]: https://github.com/go-kit/kit/tree/master/circuitbreaker - -#### Rate limiter - -The [ratelimit package][ratelimit] provides endpoint adapters to rate limiting -packages. Rate limiters are equally applicable to both server- and client-side -endpoints. Use rate limiters to enforce upper thresholds on incoming or -outgoing request throughput. - -[ratelimit]: https://github.com/go-kit/kit/tree/master/ratelimit - -### Transport - -The [transport package][transport] provides helpers to bind endpoints to -specific serialization mechanisms. At the moment, Go kit just provides helpers -for simple JSON over HTTP. If your organization uses a fully-featured -transport, bindings are typically provided by the Go library for the -transport, and there's not much for Go kit to do. In those cases, see the -examples to understand how to write adapters for your endpoints. For now, see -the [addsvc][addsvc] to understand how transport bindings work. We have -specific examples for Thrift, gRPC, net/rpc, and JSON over HTTP. JSON/RPC and -Swagger support is planned. - -[transport]: https://github.com/go-kit/kit/tree/master/transport -[addsvc]: https://github.com/go-kit/kit/tree/master/examples/addsvc - -### Logging - -Services produce logs to be consumed later, either by humans or machines. -Humans might be interested in debugging errors, or tracing specific requests. -Machines might be interested in counting interesting events, or aggregating -information for offline processing. In both cases, it's important that the log -messages be structured and actionable. Go kit's [log package][log] is designed -to encourage both of these best practices. - -[log]: https://github.com/go-kit/kit/tree/master/log - -### Metrics (Instrumentation) - -Services can't be considered production-ready until they're thoroughly -instrumented with metrics that track counts, latency, health, and other -periodic or per-request information. Go kit's [metrics package][metrics] -provides a robust common set of interfaces for instrumenting your service. -Bindings exist for common backends, from [expvar][] to [statsd][] to -[Prometheus][]. - -[metrics]: https://github.com/go-kit/kit/tree/master/metrics -[expvar]: https://golang.org/pkg/expvar/ -[statsd]: https://github.com/etsy/statsd -[Prometheus]: http://prometheus.io - -### Request tracing - -As your infrastructure grows, it becomes important to be able to trace a -request, as it travels through multiple services and back to the user. Go -kit's [tracing package][tracing] provides enhancements for your endpoints and -transport bindings to capture information about requests and emit them to -request tracing systems. (Currently, [Zipkin][] is supported; [Appdash][] -support is planned.) - -[tracing]: https://github.com/go-kit/kit/tree/master/tracing -[Zipkin]: https://github.com/openzipkin/zipkin -[Appdash]: https://github.com/sourcegraph/appdash - -### Service discovery and load balancing - -If your service calls another service, it needs to know how to find it, and -should intelligently spread its load among those discovered instances. Go -kit's [loadbalancer package][loadbalancer] provides client-side endpoint -middleware to solve that problem, whether your organization uses static hosts -or IPs, [DNS SRV records][dnssrv], Consul, etcd, or Zookeeper. And if you use -a custom system, it's very easy to write your own [Publisher][] and use Go -kit's load balancing strategies. (Currently, static hosts, DNS SRV, etcd, Consul -and ZooKeeper are supported) - -[loadbalancer]: https://github.com/go-kit/kit/tree/master/loadbalancer -[dnssrv]: https://github.com/go-kit/kit/tree/master/loadbalancer/dnssrv -[Publisher]: https://github.com/go-kit/kit/tree/master/loadbalancer/publisher.go - -## Motivation - -Go has emerged as the language of the server, but it remains underrepresented -in large, consumer-focused tech companies like Facebook, Twitter, Netflix, and -SoundCloud. These organizations have largely adopted JVM-based stacks for -their business logic, owing in large part to libraries and ecosystems that -directly support their microservice architectures. - -To reach its next level of success, Go needs more than simple primitives and -idioms. It needs a comprehensive toolkit, for coherent distributed programming -in the large. Go kit is a set of packages and best practices, leveraging years -of production experience, and providing a comprehensive, robust, and trustable -platform for organizations of any size. - -In short, Go kit makes Go a viable choice for business-domain microservices. - -For more details, see - [the motivating blog post](http://peter.bourgon.org/go-kit/) and - [the video of the talk](https://www.youtube.com/watch?v=iFR_7AKkJFU). -See also the - [Go kit talk at GopherCon 2015](https://www.youtube.com/watch?v=1AjaZi4QuGo). - -## Goals - -- Operate in a heterogeneous SOA — expect to interact with mostly non-Go-kit services -- RPC as the primary messaging pattern -- Pluggable serialization and transport — not just JSON over HTTP -- Operate within existing infrastructures — no mandates for specific tools or technologies - -## Non-goals - -- Supporting messaging patterns other than RPC (for now) — e.g. MPI, pub/sub, CQRS, etc. -- Re-implementing functionality that can be provided by adapting existing software -- Having opinions on operational concerns: deployment, configuration, process supervision, orchestration, etc. - -## Contributing - -Please see [CONTRIBUTING.md][]. Thank you, [contributors][]! - -[CONTRIBUTING.md]: /CONTRIBUTING.md -[contributors]: https://github.com/go-kit/kit/graphs/contributors - -## Dependency management - -Go kit is a library, designed to be imported into a binary package. -Vendoring is currently the best way for binary package authors to ensure reliable, reproducible builds. -Therefore, we strongly recommend our users use vendoring for all of their dependencies, including Go kit. -To avoid compatibility and availability issues, Go kit doesn't vendor its own dependencies, and doesn't recommend use of third-party import proxies. - -There are several tools which make vendoring easier, including [gb][], [glide][], [gvt][], [govendor][], and [vendetta][]. -In addition, Go kit uses a variety of continuous integration providers to find and fix compatibility problems as soon as they occur. - -[gb]: http://getgb.io -[glide]: https://github.com/Masterminds/glide -[gvt]: https://github.com/FiloSottile/gvt -[govendor]: https://github.com/kardianos/govendor -[vendetta]: https://github.com/dpw/vendetta - -## Related projects - -Projects with a ★ have had particular influence on Go kit's design (or vice-versa). - -### Service frameworks - -- [gizmo](https://github.com/nytimes/gizmo), a microservice toolkit from The New York Times ★ -- [go-micro](https://github.com/myodc/go-micro), a microservices client/server library ★ -- [gocircuit](https://github.com/gocircuit/circuit), dynamic cloud orchestration -- [gotalk](https://github.com/rsms/gotalk), async peer communication protocol & library -- [h2](https://github.com/hailocab/h2), a microservices framework ★ -- [Kite](https://github.com/koding/kite), a micro-service framework - -### Individual components - -- [afex/hystrix-go](https://github.com/afex/hystrix-go), client-side latency and fault tolerance library -- [armon/go-metrics](https://github.com/armon/go-metrics), library for exporting performance and runtime metrics to external metrics systems -- [codahale/lunk](https://github.com/codahale/lunk), structured logging in the style of Google's Dapper or Twitter's Zipkin -- [eapache/go-resiliency](https://github.com/eapache/go-resiliency), resiliency patterns -- [sasbury/logging](https://github.com/sasbury/logging), a tagged style of logging -- [grpc/grpc-go](https://github.com/grpc/grpc-go), HTTP/2 based RPC -- [inconshreveable/log15](https://github.com/inconshreveable/log15), simple, powerful logging for Go ★ -- [mailgun/vulcand](https://github.com/vulcand/vulcand), programmatic load balancer backed by etcd -- [mattheath/phosphor](https://github.com/mondough/phosphor), distributed system tracing -- [pivotal-golang/lager](https://github.com/pivotal-golang/lager), an opinionated logging library -- [rubyist/circuitbreaker](https://github.com/rubyist/circuitbreaker), circuit breaker library -- [Sirupsen/logrus](https://github.com/Sirupsen/logrus), structured, pluggable logging for Go ★ -- [sourcegraph/appdash](https://github.com/sourcegraph/appdash), application tracing system based on Google's Dapper -- [spacemonkeygo/monitor](https://github.com/spacemonkeygo/monitor), data collection, monitoring, instrumentation, and Zipkin client library -- [streadway/handy](https://github.com/streadway/handy), net/http handler filters -- [vitess/rpcplus](https://godoc.org/github.com/youtube/vitess/go/rpcplus), package rpc + context.Context -- [gdamore/mangos](https://github.com/gdamore/mangos), nanomsg implementation in pure Go - -### Web frameworks - -- [Beego](http://beego.me/) -- [Gin](https://gin-gonic.github.io/gin/) -- [Goji](https://github.com/zenazn/goji) -- [Gorilla](http://www.gorillatoolkit.org) -- [Martini](https://github.com/go-martini/martini) -- [Negroni](https://github.com/codegangsta/negroni) -- [Revel](https://revel.github.io/) (considered harmful) - -## Additional reading - -- [Architecting for the Cloud](http://fr.slideshare.net/stonse/architecting-for-the-cloud-using-netflixoss-codemash-workshop-29852233) — Netflix -- [Dapper, a Large-Scale Distributed Systems Tracing Infrastructure](http://research.google.com/pubs/pub36356.html) — Google -- [Your Server as a Function](http://monkey.org/~marius/funsrv.pdf) (PDF) — Twitter - diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/gobreaker.go b/vendor/github.com/go-kit/kit/circuitbreaker/gobreaker.go deleted file mode 100644 index b00de95..0000000 --- a/vendor/github.com/go-kit/kit/circuitbreaker/gobreaker.go +++ /dev/null @@ -1,21 +0,0 @@ -package circuitbreaker - -import ( - "github.com/sony/gobreaker" - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -// Gobreaker returns an endpoint.Middleware that implements the circuit -// breaker pattern using the sony/gobreaker package. Only errors returned by -// the wrapped endpoint count against the circuit breaker's error count. -// -// See http://godoc.org/github.com/sony/gobreaker for more information. -func Gobreaker(cb *gobreaker.CircuitBreaker) endpoint.Middleware { - return func(next endpoint.Endpoint) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - return cb.Execute(func() (interface{}, error) { return next(ctx, request) }) - } - } -} diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/gobreaker_test.go b/vendor/github.com/go-kit/kit/circuitbreaker/gobreaker_test.go deleted file mode 100644 index b581cfe..0000000 --- a/vendor/github.com/go-kit/kit/circuitbreaker/gobreaker_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package circuitbreaker_test - -import ( - "testing" - - "github.com/sony/gobreaker" - - "github.com/go-kit/kit/circuitbreaker" -) - -func TestGobreaker(t *testing.T) { - var ( - breaker = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{})) - primeWith = 100 - shouldPass = func(n int) bool { return n <= 5 } // https://github.com/sony/gobreaker/blob/bfa846d/gobreaker.go#L76 - circuitOpenError = "circuit breaker is open" - ) - testFailingEndpoint(t, breaker, primeWith, shouldPass, 0, circuitOpenError) -} diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker.go b/vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker.go deleted file mode 100644 index 5875d4f..0000000 --- a/vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker.go +++ /dev/null @@ -1,38 +0,0 @@ -package circuitbreaker - -import ( - "time" - - "github.com/streadway/handy/breaker" - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -// HandyBreaker returns an endpoint.Middleware that implements the circuit -// breaker pattern using the streadway/handy/breaker package. Only errors -// returned by the wrapped endpoint count against the circuit breaker's error -// count. -// -// See http://godoc.org/github.com/streadway/handy/breaker for more -// information. -func HandyBreaker(cb breaker.Breaker) endpoint.Middleware { - return func(next endpoint.Endpoint) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - if !cb.Allow() { - return nil, breaker.ErrCircuitOpen - } - - defer func(begin time.Time) { - if err == nil { - cb.Success(time.Since(begin)) - } else { - cb.Failure(time.Since(begin)) - } - }(time.Now()) - - response, err = next(ctx, request) - return - } - } -} diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker_test.go b/vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker_test.go deleted file mode 100644 index f3642a1..0000000 --- a/vendor/github.com/go-kit/kit/circuitbreaker/handy_breaker_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package circuitbreaker_test - -import ( - "testing" - - handybreaker "github.com/streadway/handy/breaker" - - "github.com/go-kit/kit/circuitbreaker" -) - -func TestHandyBreaker(t *testing.T) { - var ( - failureRatio = 0.05 - breaker = circuitbreaker.HandyBreaker(handybreaker.NewBreaker(failureRatio)) - primeWith = handybreaker.DefaultMinObservations * 10 - shouldPass = func(n int) bool { return (float64(n) / float64(primeWith+n)) <= failureRatio } - openCircuitError = handybreaker.ErrCircuitOpen.Error() - ) - testFailingEndpoint(t, breaker, primeWith, shouldPass, 0, openCircuitError) -} diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/hystrix.go b/vendor/github.com/go-kit/kit/circuitbreaker/hystrix.go deleted file mode 100644 index 5e7b144..0000000 --- a/vendor/github.com/go-kit/kit/circuitbreaker/hystrix.go +++ /dev/null @@ -1,30 +0,0 @@ -package circuitbreaker - -import ( - "github.com/afex/hystrix-go/hystrix" - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -// Hystrix returns an endpoint.Middleware that implements the circuit -// breaker pattern using the afex/hystrix-go package. -// -// When using this circuit breaker, please configure your commands separately. -// -// See https://godoc.org/github.com/afex/hystrix-go/hystrix for more -// information. -func Hystrix(commandName string) endpoint.Middleware { - return func(next endpoint.Endpoint) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - var resp interface{} - if err := hystrix.Do(commandName, func() (err error) { - resp, err = next(ctx, request) - return err - }, nil); err != nil { - return nil, err - } - return resp, nil - } - } -} diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/hystrix_test.go b/vendor/github.com/go-kit/kit/circuitbreaker/hystrix_test.go deleted file mode 100644 index da52757..0000000 --- a/vendor/github.com/go-kit/kit/circuitbreaker/hystrix_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package circuitbreaker_test - -import ( - "io/ioutil" - stdlog "log" - "testing" - "time" - - "github.com/afex/hystrix-go/hystrix" - - "github.com/go-kit/kit/circuitbreaker" -) - -func TestHystrix(t *testing.T) { - stdlog.SetOutput(ioutil.Discard) - - const ( - commandName = "my-endpoint" - errorPercent = 5 - maxConcurrent = 1000 - ) - hystrix.ConfigureCommand(commandName, hystrix.CommandConfig{ - ErrorPercentThreshold: errorPercent, - MaxConcurrentRequests: maxConcurrent, - }) - - var ( - breaker = circuitbreaker.Hystrix(commandName) - primeWith = hystrix.DefaultVolumeThreshold * 2 - shouldPass = func(n int) bool { return (float64(n) / float64(primeWith+n)) <= (float64(errorPercent-1) / 100.0) } - openCircuitError = hystrix.ErrCircuitOpen.Error() - ) - - // hystrix-go uses buffered channels to receive reports on request success/failure, - // and so is basically impossible to test deterministically. We have to make sure - // the report buffer is emptied, by injecting a sleep between each invocation. - requestDelay := 5 * time.Millisecond - - testFailingEndpoint(t, breaker, primeWith, shouldPass, requestDelay, openCircuitError) -} diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/util_test.go b/vendor/github.com/go-kit/kit/circuitbreaker/util_test.go deleted file mode 100644 index 0039b6d..0000000 --- a/vendor/github.com/go-kit/kit/circuitbreaker/util_test.go +++ /dev/null @@ -1,76 +0,0 @@ -package circuitbreaker_test - -import ( - "errors" - "fmt" - "path/filepath" - "runtime" - "testing" - "time" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -func testFailingEndpoint( - t *testing.T, - breaker endpoint.Middleware, - primeWith int, - shouldPass func(int) bool, - requestDelay time.Duration, - openCircuitError string, -) { - _, file, line, _ := runtime.Caller(1) - caller := fmt.Sprintf("%s:%d", filepath.Base(file), line) - - // Create a mock endpoint and wrap it with the breaker. - m := mock{} - var e endpoint.Endpoint - e = m.endpoint - e = breaker(e) - - // Prime the endpoint with successful requests. - for i := 0; i < primeWith; i++ { - if _, err := e(context.Background(), struct{}{}); err != nil { - t.Fatalf("%s: during priming, got error: %v", caller, err) - } - time.Sleep(requestDelay) - } - - // Switch the endpoint to start throwing errors. - m.err = errors.New("tragedy+disaster") - m.thru = 0 - - // The first several should be allowed through and yield our error. - for i := 0; shouldPass(i); i++ { - if _, err := e(context.Background(), struct{}{}); err != m.err { - t.Fatalf("%s: want %v, have %v", caller, m.err, err) - } - time.Sleep(requestDelay) - } - thru := m.thru - - // But the rest should be blocked by an open circuit. - for i := 0; i < 10; i++ { - if _, err := e(context.Background(), struct{}{}); err.Error() != openCircuitError { - t.Fatalf("%s: want %q, have %q", caller, openCircuitError, err.Error()) - } - time.Sleep(requestDelay) - } - - // Make sure none of those got through. - if want, have := thru, m.thru; want != have { - t.Errorf("%s: want %d, have %d", caller, want, have) - } -} - -type mock struct { - thru int - err error -} - -func (m *mock) endpoint(context.Context, interface{}) (interface{}, error) { - m.thru++ - return struct{}{}, m.err -} diff --git a/vendor/github.com/go-kit/kit/coverage.bash b/vendor/github.com/go-kit/kit/coverage.bash deleted file mode 100755 index f4b0524..0000000 --- a/vendor/github.com/go-kit/kit/coverage.bash +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -# This script runs the cover tool on all packages with test files. If you set a -# WEB environment variable, it will additionally open the web-based coverage -# visualizer for each package. - -set -e - -function go_files { find . -name '*_test.go' ; } -function filter { grep -v '/_' ; } -function remove_relative_prefix { sed -e 's/^\.\///g' ; } - -function directories { - go_files | filter | remove_relative_prefix | while read f - do - dirname $f - done -} - -function unique_directories { directories | sort | uniq ; } - -PATHS=${1:-$(unique_directories)} - -function report { - for path in $PATHS - do - go test -coverprofile=$path/cover.coverprofile ./$path - done -} - -function combine { - gover -} - -function clean { - find . -name cover.coverprofile | xargs rm -} - -report -combine -clean - -if [ -n "${WEB+x}" ] -then - go tool cover -html=gover.coverprofile -fi - diff --git a/vendor/github.com/go-kit/kit/endpoint/endpoint.go b/vendor/github.com/go-kit/kit/endpoint/endpoint.go deleted file mode 100644 index 2702ef2..0000000 --- a/vendor/github.com/go-kit/kit/endpoint/endpoint.go +++ /dev/null @@ -1,37 +0,0 @@ -package endpoint - -import ( - "errors" - - "golang.org/x/net/context" -) - -// Endpoint is the fundamental building block of servers and clients. -// It represents a single RPC method. -type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error) - -// Nop is an endpoint that does nothing and returns a nil error. -// Useful for tests. -func Nop(context.Context, interface{}) (interface{}, error) { return struct{}{}, nil } - -// Middleware is a chainable behavior modifier for endpoints. -type Middleware func(Endpoint) Endpoint - -// ErrBadCast indicates an unexpected concrete request or response struct was -// received from an endpoint. -var ErrBadCast = errors.New("bad cast") - -// ErrContextCanceled indicates the request context was canceled. -var ErrContextCanceled = errors.New("context canceled") - -// Chain is a helper function for composing middlewares. Requests will -// traverse them in the order they're declared. That is, the first middleware -// is treated as the outermost middleware. -func Chain(outer Middleware, others ...Middleware) Middleware { - return func(next Endpoint) Endpoint { - for i := len(others) - 1; i >= 0; i-- { // reverse - next = others[i](next) - } - return outer(next) - } -} diff --git a/vendor/github.com/go-kit/kit/endpoint/endpoint_example_test.go b/vendor/github.com/go-kit/kit/endpoint/endpoint_example_test.go deleted file mode 100644 index dd25ec7..0000000 --- a/vendor/github.com/go-kit/kit/endpoint/endpoint_example_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package endpoint_test - -import ( - "fmt" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -func ExampleChain() { - e := endpoint.Chain( - annotate("first"), - annotate("second"), - annotate("third"), - )(myEndpoint) - - if _, err := e(ctx, req); err != nil { - panic(err) - } - - // Output: - // first pre - // second pre - // third pre - // my endpoint! - // third post - // second post - // first post -} - -var ( - ctx = context.Background() - req = struct{}{} -) - -func annotate(s string) endpoint.Middleware { - return func(next endpoint.Endpoint) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - fmt.Println(s, "pre") - defer fmt.Println(s, "post") - return next(ctx, request) - } - } -} - -func myEndpoint(context.Context, interface{}) (interface{}, error) { - fmt.Println("my endpoint!") - return struct{}{}, nil -} diff --git a/vendor/github.com/go-kit/kit/examples/README.md b/vendor/github.com/go-kit/kit/examples/README.md deleted file mode 100644 index 0b11c21..0000000 --- a/vendor/github.com/go-kit/kit/examples/README.md +++ /dev/null @@ -1,721 +0,0 @@ -# Examples - -1. [A minimal example](#a-minimal-example) - 1. [Your business logic](#your-business-logic) - 1. [Requests and responses](#requests-and-responses) - 1. [Endpoints](#endpoints) - 1. [Transports](#transports) - 1. [stringsvc1](#stringsvc1) -1. [Logging and instrumentation](#logging-and-instrumentation) - 1. [Transport logging](#transport-logging) - 1. [Application logging](#application-logging) - 1. [Instrumentation](#instrumentation) - 1. [stringsvc2](#stringsvc2) -1. [Calling other services](#calling-other-services) - 1. [Client-side endpoints](#client-side-endpoints) - 1. [Service discovery and load balancing](#service-discovery-and-load-balancing) - 1. [stringsvc3](#stringsvc3) -1. [Advanced topics](#advanced-topics) - 1. [Creating a client package](#creating-a-client-package) - 1. [Request tracing](#request-tracing) - 1. [Threading a context](#threading-a-context) -1. [Other examples](#other-examples) - 1. [addsvc](#addsvc) - 1. [profilesvc](#profilesvc) - 1. [apigateway](#apigateway) - 1. [shipping](#shipping) - -## A minimal example - -Let's create a minimal Go kit service. - -### Your business logic - -Your service starts with your business logic. -In Go kit, we model a service as an **interface**. - -```go -// StringService provides operations on strings. -type StringService interface { - Uppercase(string) (string, error) - Count(string) int -} -``` - -That interface will have an implementation. - -```go -type stringService struct{} - -func (stringService) Uppercase(s string) (string, error) { - if s == "" { - return "", ErrEmpty - } - return strings.ToUpper(s), nil -} - -func (stringService) Count(s string) int { - return len(s) -} - -// ErrEmpty is returned when input string is empty -var ErrEmpty = errors.New("Empty string") -``` - -### Requests and responses - -In Go kit, the primary messaging pattern is RPC. -So, every method in our interface will be modeled as a remote procedure call. -For each method, we define **request and response** structs, - capturing all of the input and output parameters respectively. - -```go -type uppercaseRequest struct { - S string `json:"s"` -} - -type uppercaseResponse struct { - V string `json:"v"` - Err string `json:"err,omitempty"` // errors don't JSON-marshal, so we use a string -} - -type countRequest struct { - S string `json:"s"` -} - -type countResponse struct { - V int `json:"v"` -} -``` - -### Endpoints - -Go kit provides much of its functionality through an abstraction called an **endpoint**. - -```go -type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error) -``` - -An endpoint represents a single RPC. -That is, a single method in our service interface. -We'll write simple adapters to convert each of our service's methods into an endpoint. -Each adapter takes a StringService, and returns an endpoint that corresponds to one of the methods. - -```go -import ( - "golang.org/x/net/context" - "github.com/go-kit/kit/endpoint" -) - -func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(uppercaseRequest) - v, err := svc.Uppercase(req.S) - if err != nil { - return uppercaseResponse{v, err.Error()}, nil - } - return uppercaseResponse{v, ""}, nil - } -} - -func makeCountEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(countRequest) - v := svc.Count(req.S) - return countResponse{v}, nil - } -} -``` - -### Transports - -Now we need to expose your service to the outside world, so it can be called. -Your organization probably already has opinions about how services should talk to each other. -Maybe you use Thrift, or custom JSON over HTTP. -Go kit supports many **transports** out of the box. -(Adding support for new ones is easy—just [file an issue](https://github.com/go-kit/kit/issues).) - -For this minimal example service, let's use JSON over HTTP. -Go kit provides a helper struct, in package transport/http. - -```go -import ( - "encoding/json" - "log" - "net/http" - - "golang.org/x/net/context" - - httptransport "github.com/go-kit/kit/transport/http" -) - -func main() { - ctx := context.Background() - svc := stringService{} - - uppercaseHandler := httptransport.NewServer( - ctx, - makeUppercaseEndpoint(svc), - decodeUppercaseRequest, - encodeResponse, - ) - - countHandler := httptransport.NewServer( - ctx, - makeCountEndpoint(svc), - decodeCountRequest, - encodeResponse, - ) - - http.Handle("/uppercase", uppercaseHandler) - http.Handle("/count", countHandler) - log.Fatal(http.ListenAndServe(":8080", nil)) -} - -func decodeUppercaseRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request uppercaseRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func decodeCountRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request countRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func encodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error { - return json.NewEncoder(w).Encode(response) -} -``` - -### stringsvc1 - -The complete service so far is [stringsvc1][]. - -[stringsvc1]: https://github.com/go-kit/kit/blob/master/examples/stringsvc1 - -``` -$ go get github.com/go-kit/kit/examples/stringsvc1 -$ stringsvc1 -``` - -``` -$ curl -XPOST -d'{"s":"hello, world"}' localhost:8080/uppercase -{"v":"HELLO, WORLD","err":null} -$ curl -XPOST -d'{"s":"hello, world"}' localhost:8080/count -{"v":12} -``` - -## Logging and instrumentation - -No service can be considered production-ready without thorough logging and instrumentation. - -### Transport logging - -Any component that needs to log should treat the logger like a dependency, same as a database connection. -So, we construct our logger in our `func main`, and pass it to components that need it. -We never use a globally-scoped logger. - -We could pass a logger directly into our stringService implementation, but there's a better way. -Let's use a **middleware**, also known as a decorator. -A middleware is a function that takes an endpoint and returns an endpoint. - -```go -type Middleware func(Endpoint) Endpoint -``` - -In between, it can do anything. -Let's create a basic logging middleware. - -```go -func loggingMiddleware(logger log.Logger) Middleware { - return func(next endpoint.Endpoint) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - logger.Log("msg", "calling endpoint") - defer logger.Log("msg", "called endpoint") - return next(ctx, request) - } - } -} -``` - -And wire it into each of our handlers. - -```go -logger := log.NewLogfmtLogger(os.Stderr) - -svc := stringService{} - -var uppercase endpoint.Endpoint -uppercase = makeUppercaseEndpoint(svc) -uppercase = loggingMiddleware(log.NewContext(logger).With("method", "uppercase"))(uppercase) - -var count endpoint.Endpoint -count = makeCountEndpoint(svc) -count = loggingMiddleware(log.NewContext(logger).With("method", "count"))(count) - -uppercaseHandler := httptransport.Server( - // ... - uppercase, - // ... -) - -countHandler := httptransport.Server( - // ... - count, - // ... -) -``` - -It turns out that this technique is useful for a lot more than just logging. -Many Go kit components are implemented as endpoint middlewares. - -### Application logging - -But what if we want to log in our application domain, like the parameters that are passed in? -It turns out that we can define a middleware for our service, and get the same nice and composable effects. -Since our StringService is defined as an interface, we just need to make a new type - which wraps an existing StringService, and performs the extra logging duties. - -```go -type loggingMiddleware struct { - logger log.Logger - next StringService -} - -func (mw loggingMiddleware) Uppercase(s string) (output string, err error) { - defer func(begin time.Time) { - mw.logger.Log( - "method", "uppercase", - "input", s, - "output", output, - "err", err, - "took", time.Since(begin), - ) - }(time.Now()) - - output, err = mw.next.Uppercase(s) - return -} - -func (mw loggingMiddleware) Count(s string) (n int) { - defer func(begin time.Time) { - mw.logger.Log( - "method", "count", - "input", s, - "n", n, - "took", time.Since(begin), - ) - }(time.Now()) - - n = mw.next.Count(s) - return -} -``` - -And wire it in. - -```go -import ( - "os" - - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" -) - -func main() { - logger := log.NewLogfmtLogger(os.Stderr) - - var svc StringService - svc = stringsvc{} - svc = loggingMiddleware{logger, svc} - - // ... - - uppercaseHandler := httptransport.NewServer( - // ... - makeUppercaseEndpoint(svc), - // ... - ) - - countHandler := httptransport.NewServer( - // ... - makeCountEndpoint(svc), - // ... - ) -} -``` - -Use endpoint middlewares for transport-domain concerns, like circuit breaking and rate limiting. -Use service middlewares for business-domain concerns, like logging and instrumentation. -Speaking of instrumentation... - -### Instrumentation - -In Go kit, instrumentation means using **package metrics** to record statistics about your service's runtime behavior. -Counting the number of jobs processed, - recording the duration of requests after they've finished, - and tracking the number of in-flight operations would all be considered instrumentation. - -We can use the same middleware pattern that we used for logging. - -```go -type instrumentingMiddleware struct { - requestCount metrics.Counter - requestLatency metrics.TimeHistogram - countResult metrics.Histogram - next StringService -} - -func (mw instrumentingMiddleware) Uppercase(s string) (output string, err error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "uppercase"} - errorField := metrics.Field{Key: "error", Value: fmt.Sprintf("%v", err)} - mw.requestCount.With(methodField).With(errorField).Add(1) - mw.requestLatency.With(methodField).With(errorField).Observe(time.Since(begin)) - }(time.Now()) - - output, err = mw.next.Uppercase(s) - return -} - -func (mw instrumentingMiddleware) Count(s string) (n int) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "count"} - errorField := metrics.Field{Key: "error", Value: fmt.Sprintf("%v", error(nil))} - mw.requestCount.With(methodField).With(errorField).Add(1) - mw.requestLatency.With(methodField).With(errorField).Observe(time.Since(begin)) - mw.countResult.Observe(int64(n)) - }(time.Now()) - - n = mw.next.Count(s) - return -} -``` - -And wire it into our service. - -```go -import ( - stdprometheus "github.com/prometheus/client_golang/prometheus" - kitprometheus "github.com/go-kit/kit/metrics/prometheus" - "github.com/go-kit/kit/metrics" -) - -func main() { - logger := log.NewLogfmtLogger(os.Stderr) - - fieldKeys := []string{"method", "error"} - requestCount := kitprometheus.NewCounter(stdprometheus.CounterOpts{ - // ... - }, fieldKeys) - requestLatency := metrics.NewTimeHistogram(time.Microsecond, kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - // ... - }, fieldKeys)) - countResult := kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - // ... - }, []string{})) - - var svc StringService - svc = stringService{} - svc = loggingMiddleware{logger, svc} - svc = instrumentingMiddleware{requestCount, requestLatency, countResult, svc} - - // ... - - http.Handle("/metrics", stdprometheus.Handler()) -} -``` - -### stringsvc2 - -The complete service so far is [stringsvc2][]. - -[stringsvc2]: https://github.com/go-kit/kit/blob/master/examples/stringsvc2 - -``` -$ go get github.com/go-kit/kit/examples/stringsvc2 -$ stringsvc2 -msg=HTTP addr=:8080 -``` - -``` -$ curl -XPOST -d'{"s":"hello, world"}' localhost:8080/uppercase -{"v":"HELLO, WORLD","err":null} -$ curl -XPOST -d'{"s":"hello, world"}' localhost:8080/count -{"v":12} -``` - -``` -method=uppercase input="hello, world" output="HELLO, WORLD" err=null took=2.455µs -method=count input="hello, world" n=12 took=743ns -``` - -## Calling other services - -It's rare that a service exists in a vacuum. -Often, you need to call other services. -**This is where Go kit shines**. -We provide transport middlewares to solve many of the problems that come up. - -Let's say that we want to have our string service call out to a _different_ string service - to satisfy the Uppercase method. -In effect, proxying the request to another service. -Let's implement the proxying middleware as a ServiceMiddleware, same as a logging or instrumenting middleware. - -```go -// proxymw implements StringService, forwarding Uppercase requests to the -// provided endpoint, and serving all other (i.e. Count) requests via the -// next StringService. -type proxymw struct { - ctx context.Context - next StringService // Serve most requests via this service... - uppercase endpoint.Endpoint // ...except Uppercase, which gets served by this endpoint -} -``` - -### Client-side endpoints - -We've got exactly the same endpoint we already know about, but we'll use it to invoke, rather than serve, a request. -When used this way, we call it a _client_ endpoint. -And to invoke the client endpoint, we just do some simple conversions. - -```go -func (mw proxymw) Uppercase(s string) (string, error) { - response, err := mw.uppercase(mw.Context, uppercaseRequest{S: s}) - if err != nil { - return "", err - } - resp := response.(uppercaseResponse) - if resp.Err != "" { - return resp.V, errors.New(resp.Err) - } - return resp.V, nil -} -``` - -Now, to construct one of these proxying middlewares, we convert a proxy URL string to an endpoint. -If we assume JSON over HTTP, we can use a helper in the transport/http package. - -```go -import ( - httptransport "github.com/go-kit/kit/transport/http" -) - -func proxyingMiddleware(proxyURL string, ctx context.Context) ServiceMiddleware { - return func(next StringService) StringService { - return proxymw{ctx, next, makeUppercaseEndpoint(ctx, proxyURL)} - } -} - -func makeUppercaseEndpoint(ctx context.Context, proxyURL string) endpoint.Endpoint { - return httptransport.NewClient( - "GET", - mustParseURL(proxyURL), - encodeUppercaseRequest, - decodeUppercaseResponse, - ).Endpoint() -} -``` - -### Service discovery and load balancing - -That's fine if we only have a single remote service. -But in reality, we'll probably have many service instances available to us. -We want to discover them through some service discovery mechanism, and spread our load across all of them. -And if any of those instances start to behave badly, we want to deal with that, without affecting our own service's reliability. - -Go kit offers adapters to different service discovery systems, to get up-to-date sets of instances, exposed as individual endpoints. -Those adapters are called subscribers. - -```go -type Subscriber interface { - Endpoints() ([]endpoint.Endpoint, error) -} -``` - -Internally, subscribers use a provided factory function to convert each discovered instance string (typically host:port) to a usable endpoint. - -```go -type Factory func(instance string) (endpoint.Endpoint, error) -``` - -So far, our factory function, makeUppercaseEndpoint, just calls the URL directly. -But it's important to put some safety middleware, like circuit breakers and rate limiters, into your factory, too. - -```go -var e endpoint.Endpoint -e = makeUppercaseProxy(ctx, instance) -e = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))(e) -e = kitratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(float64(maxQPS), int64(maxQPS)))(e) -} -``` - -Now that we've got a set of endpoints, we need to choose one. -Load balancers wrap subscribers, and select one endpoint from many. -Go kit provides a couple of basic load balancers, and it's easy to write your own if you want more advanced heuristics. - -```go -type Balancer interface { - Endpoint() (endpoint.Endpoint, error) -} -``` - -Now we have the ability to choose endpoints according to some heuristic. -We can use that to provide a single, logical, robust endpoint to consumers. -A retry strategy wraps a load balancer, and returns a usable endpoint. -The retry strategy will retry failed requests until either the max attempts or timeout has been reached. - -```go -func Retry(max int, timeout time.Duration, lb Balancer) endpoint.Endpoint -``` - -Let's wire up our final proxying middleware. -For simplicity, we'll assume the user will specify multiple comma-separate instance endpoints with a flag. - -```go -func proxyingMiddleware(instances string, ctx context.Context, logger log.Logger) ServiceMiddleware { - // If instances is empty, don't proxy. - if instances == "" { - logger.Log("proxy_to", "none") - return func(next StringService) StringService { return next } - } - - // Set some parameters for our client. - var ( - qps = 100 // beyond which we will return an error - maxAttempts = 3 // per request, before giving up - maxTime = 250 * time.Millisecond // wallclock time, before giving up - ) - - // Otherwise, construct an endpoint for each instance in the list, and add - // it to a fixed set of endpoints. In a real service, rather than doing this - // by hand, you'd probably use package sd's support for your service - // discovery system. - var ( - instanceList = split(instances) - subscriber sd.FixedSubscriber - ) - logger.Log("proxy_to", fmt.Sprint(instanceList)) - for _, instance := range instanceList { - var e endpoint.Endpoint - e = makeUppercaseProxy(ctx, instance) - e = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))(e) - e = kitratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(float64(qps), int64(qps)))(e) - subscriber = append(subscriber, e) - } - - // Now, build a single, retrying, load-balancing endpoint out of all of - // those individual endpoints. - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(maxAttempts, maxTime, balancer) - - // And finally, return the ServiceMiddleware, implemented by proxymw. - return func(next StringService) StringService { - return proxymw{ctx, next, retry} - } -} -``` - -### stringsvc3 - -The complete service so far is [stringsvc3][]. - -[stringsvc3]: https://github.com/go-kit/kit/blob/master/examples/stringsvc3 - -``` -$ go get github.com/go-kit/kit/examples/stringsvc3 -$ stringsvc3 -listen=:8001 & -listen=:8001 caller=proxying.go:25 proxy_to=none -listen=:8001 caller=main.go:72 msg=HTTP addr=:8001 -$ stringsvc3 -listen=:8002 & -listen=:8002 caller=proxying.go:25 proxy_to=none -listen=:8002 caller=main.go:72 msg=HTTP addr=:8002 -$ stringsvc3 -listen=:8003 & -listen=:8003 caller=proxying.go:25 proxy_to=none -listen=:8003 caller=main.go:72 msg=HTTP addr=:8003 -$ stringsvc3 -listen=:8080 -proxy=localhost:8001,localhost:8002,localhost:8003 -listen=:8080 caller=proxying.go:29 proxy_to="[localhost:8001 localhost:8002 localhost:8003]" -listen=:8080 caller=main.go:72 msg=HTTP addr=:8080 -``` - -``` -$ for s in foo bar baz ; do curl -d"{\"s\":\"$s\"}" localhost:8080/uppercase ; done -{"v":"FOO","err":null} -{"v":"BAR","err":null} -{"v":"BAZ","err":null} -``` - -``` -listen=:8001 caller=logging.go:28 method=uppercase input=foo output=FOO err=null took=5.168µs -listen=:8080 caller=logging.go:28 method=uppercase input=foo output=FOO err=null took=4.39012ms -listen=:8002 caller=logging.go:28 method=uppercase input=bar output=BAR err=null took=5.445µs -listen=:8080 caller=logging.go:28 method=uppercase input=bar output=BAR err=null took=2.04831ms -listen=:8003 caller=logging.go:28 method=uppercase input=baz output=BAZ err=null took=3.285µs -listen=:8080 caller=logging.go:28 method=uppercase input=baz output=BAZ err=null took=1.388155ms -``` - -## Advanced topics - -### Threading a context - -The context object is used to carry information across conceptual boundaries in the scope of a single request. -In our example, we haven't yet threaded the context through our business logic. -But that's almost always a good idea. -It allows you to pass request-scoped information between business logic and middlewares, - and is necessary for more sophisticated tasks like granular distributed tracing annotations. - -Concretely, this means your business logic interfaces will look like - -```go -type MyService interface { - Foo(context.Context, string, int) (string, error) - Bar(context.Context, string) error - Baz(context.Context) (int, error) -} -``` - -### Request tracing - -Once your infrastructure grows beyond a certain size, it becomes important to trace requests through multiple services, so you can identify and troubleshoot hotspots. -See [package tracing](https://github.com/go-kit/kit/blob/master/tracing) for more information. - -### Creating a client package - -It's possible to use Go kit to create a client package to your service, to make consuming your service easier from other Go programs. -Effectively, your client package will provide an implementation of your service interface, which invokes a remote service instance using a specific transport. -See [package addsvc/client](https://github.com/go-kit/kit/tree/master/examples/addsvc/client) - or [package profilesvc/client](https://github.com/go-kit/kit/tree/master/examples/profilesvc/client) - for examples. - -## Other examples - -### addsvc - -[addsvc](https://github.com/go-kit/kit/blob/master/examples/addsvc) is the original example service. -It exposes a set of operations over **all supported transports**. -It's fully logged, instrumented, and uses Zipkin request tracing. -It also demonstrates how to create and use client packages. -It's a good example of a fully-featured Go kit service. - -### profilesvc - -[profilesvc](https://github.com/go-kit/kit/blob/master/examples/profilesvc) - demonstrates how to use Go kit to build a REST-ish microservice. - -### apigateway - -[apigateway](https://github.com/go-kit/kit/blob/master/examples/apigateway/main.go) - demonstrates how to implement the API gateway pattern, - backed by a Consul service discovery system. - -### shipping - -[shipping](https://github.com/go-kit/kit/tree/master/examples/shipping) - is a complete, "real-world" application composed of multiple microservices, - based on Domain Driven Design principles. diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/client/grpc/client.go b/vendor/github.com/go-kit/kit/examples/addsvc/client/grpc/client.go deleted file mode 100644 index f21a9f5..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/client/grpc/client.go +++ /dev/null @@ -1,75 +0,0 @@ -// Package grpc provides a gRPC client for the add service. -package grpc - -import ( - "time" - - jujuratelimit "github.com/juju/ratelimit" - stdopentracing "github.com/opentracing/opentracing-go" - "github.com/sony/gobreaker" - "google.golang.org/grpc" - - "github.com/go-kit/kit/circuitbreaker" - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/addsvc" - "github.com/go-kit/kit/examples/addsvc/pb" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/ratelimit" - "github.com/go-kit/kit/tracing/opentracing" - grpctransport "github.com/go-kit/kit/transport/grpc" -) - -// New returns an AddService backed by a gRPC client connection. It is the -// responsibility of the caller to dial, and later close, the connection. -func New(conn *grpc.ClientConn, tracer stdopentracing.Tracer, logger log.Logger) addsvc.Service { - // We construct a single ratelimiter middleware, to limit the total outgoing - // QPS from this client to all methods on the remote instance. We also - // construct per-endpoint circuitbreaker middlewares to demonstrate how - // that's done, although they could easily be combined into a single breaker - // for the entire remote instance, too. - - limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100)) - - var sumEndpoint endpoint.Endpoint - { - sumEndpoint = grpctransport.NewClient( - conn, - "Add", - "Sum", - addsvc.EncodeGRPCSumRequest, - addsvc.DecodeGRPCSumResponse, - pb.SumReply{}, - grpctransport.ClientBefore(opentracing.FromGRPCRequest(tracer, "Sum", logger)), - ).Endpoint() - sumEndpoint = opentracing.TraceClient(tracer, "Sum")(sumEndpoint) - sumEndpoint = limiter(sumEndpoint) - sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{ - Name: "Sum", - Timeout: 30 * time.Second, - }))(sumEndpoint) - } - - var concatEndpoint endpoint.Endpoint - { - concatEndpoint = grpctransport.NewClient( - conn, - "Add", - "Concat", - addsvc.EncodeGRPCConcatRequest, - addsvc.DecodeGRPCConcatResponse, - pb.ConcatReply{}, - grpctransport.ClientBefore(opentracing.FromGRPCRequest(tracer, "Concat", logger)), - ).Endpoint() - concatEndpoint = opentracing.TraceClient(tracer, "Concat")(concatEndpoint) - concatEndpoint = limiter(concatEndpoint) - sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{ - Name: "Concat", - Timeout: 30 * time.Second, - }))(sumEndpoint) - } - - return addsvc.Endpoints{ - SumEndpoint: sumEndpoint, - ConcatEndpoint: concatEndpoint, - } -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/client/http/client.go b/vendor/github.com/go-kit/kit/examples/addsvc/client/http/client.go deleted file mode 100644 index cb349fb..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/client/http/client.go +++ /dev/null @@ -1,86 +0,0 @@ -// Package http provides an HTTP client for the add service. -package http - -import ( - "net/url" - "strings" - "time" - - jujuratelimit "github.com/juju/ratelimit" - stdopentracing "github.com/opentracing/opentracing-go" - "github.com/sony/gobreaker" - - "github.com/go-kit/kit/circuitbreaker" - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/addsvc" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/ratelimit" - "github.com/go-kit/kit/tracing/opentracing" - httptransport "github.com/go-kit/kit/transport/http" -) - -// New returns an AddService backed by an HTTP server living at the remote -// instance. We expect instance to come from a service discovery system, so -// likely of the form "host:port". -func New(instance string, tracer stdopentracing.Tracer, logger log.Logger) (addsvc.Service, error) { - if !strings.HasPrefix(instance, "http") { - instance = "http://" + instance - } - u, err := url.Parse(instance) - if err != nil { - return nil, err - } - - // We construct a single ratelimiter middleware, to limit the total outgoing - // QPS from this client to all methods on the remote instance. We also - // construct per-endpoint circuitbreaker middlewares to demonstrate how - // that's done, although they could easily be combined into a single breaker - // for the entire remote instance, too. - - limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100)) - - var sumEndpoint endpoint.Endpoint - { - sumEndpoint = httptransport.NewClient( - "POST", - copyURL(u, "/sum"), - addsvc.EncodeHTTPGenericRequest, - addsvc.DecodeHTTPSumResponse, - httptransport.ClientBefore(opentracing.FromHTTPRequest(tracer, "Sum", logger)), - ).Endpoint() - sumEndpoint = opentracing.TraceClient(tracer, "Sum")(sumEndpoint) - sumEndpoint = limiter(sumEndpoint) - sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{ - Name: "Sum", - Timeout: 30 * time.Second, - }))(sumEndpoint) - } - - var concatEndpoint endpoint.Endpoint - { - concatEndpoint = httptransport.NewClient( - "POST", - copyURL(u, "/concat"), - addsvc.EncodeHTTPGenericRequest, - addsvc.DecodeHTTPConcatResponse, - httptransport.ClientBefore(opentracing.FromHTTPRequest(tracer, "Concat", logger)), - ).Endpoint() - concatEndpoint = opentracing.TraceClient(tracer, "Concat")(concatEndpoint) - concatEndpoint = limiter(concatEndpoint) - sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{ - Name: "Concat", - Timeout: 30 * time.Second, - }))(sumEndpoint) - } - - return addsvc.Endpoints{ - SumEndpoint: sumEndpoint, - ConcatEndpoint: concatEndpoint, - }, nil -} - -func copyURL(base *url.URL, path string) *url.URL { - next := *base - next.Path = path - return &next -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/client/thrift/client.go b/vendor/github.com/go-kit/kit/examples/addsvc/client/thrift/client.go deleted file mode 100644 index a943c7b..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/client/thrift/client.go +++ /dev/null @@ -1,55 +0,0 @@ -// Package thrift provides a Thrift client for the add service. -package thrift - -import ( - "time" - - jujuratelimit "github.com/juju/ratelimit" - "github.com/sony/gobreaker" - - "github.com/go-kit/kit/circuitbreaker" - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/addsvc" - thriftadd "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc" - "github.com/go-kit/kit/ratelimit" -) - -// New returns an AddService backed by a Thrift server described by the provided -// client. The caller is responsible for constructing the client, and eventually -// closing the underlying transport. -func New(client *thriftadd.AddServiceClient) addsvc.Service { - // We construct a single ratelimiter middleware, to limit the total outgoing - // QPS from this client to all methods on the remote instance. We also - // construct per-endpoint circuitbreaker middlewares to demonstrate how - // that's done, although they could easily be combined into a single breaker - // for the entire remote instance, too. - - limiter := ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(100, 100)) - - // Thrift does not currently have tracer bindings, so we skip tracing. - - var sumEndpoint endpoint.Endpoint - { - sumEndpoint = addsvc.MakeThriftSumEndpoint(client) - sumEndpoint = limiter(sumEndpoint) - sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{ - Name: "Sum", - Timeout: 30 * time.Second, - }))(sumEndpoint) - } - - var concatEndpoint endpoint.Endpoint - { - concatEndpoint = addsvc.MakeThriftConcatEndpoint(client) - concatEndpoint = limiter(concatEndpoint) - sumEndpoint = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{ - Name: "Concat", - Timeout: 30 * time.Second, - }))(sumEndpoint) - } - - return addsvc.Endpoints{ - SumEndpoint: addsvc.MakeThriftSumEndpoint(client), - ConcatEndpoint: addsvc.MakeThriftConcatEndpoint(client), - } -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/cmd/addcli/main.go b/vendor/github.com/go-kit/kit/examples/addsvc/cmd/addcli/main.go deleted file mode 100644 index 870bfa8..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/cmd/addcli/main.go +++ /dev/null @@ -1,178 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "os" - "strconv" - "strings" - "time" - - "github.com/apache/thrift/lib/go/thrift" - "github.com/lightstep/lightstep-tracer-go" - stdopentracing "github.com/opentracing/opentracing-go" - zipkin "github.com/openzipkin/zipkin-go-opentracing" - appdashot "github.com/sourcegraph/appdash/opentracing" - "golang.org/x/net/context" - "google.golang.org/grpc" - "sourcegraph.com/sourcegraph/appdash" - - "github.com/go-kit/kit/examples/addsvc" - grpcclient "github.com/go-kit/kit/examples/addsvc/client/grpc" - httpclient "github.com/go-kit/kit/examples/addsvc/client/http" - thriftclient "github.com/go-kit/kit/examples/addsvc/client/thrift" - thriftadd "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc" - "github.com/go-kit/kit/log" -) - -func main() { - // The addcli presumes no service discovery system, and expects users to - // provide the direct address of an addsvc. This presumption is reflected in - // the addcli binary and the the client packages: the -transport.addr flags - // and various client constructors both expect host:port strings. For an - // example service with a client built on top of a service discovery system, - // see profilesvc. - - var ( - httpAddr = flag.String("http.addr", "", "HTTP address of addsvc") - grpcAddr = flag.String("grpc.addr", "", "gRPC (HTTP) address of addsvc") - thriftAddr = flag.String("thrift.addr", "", "Thrift address of addsvc") - thriftProtocol = flag.String("thrift.protocol", "binary", "binary, compact, json, simplejson") - thriftBufferSize = flag.Int("thrift.buffer.size", 0, "0 for unbuffered") - thriftFramed = flag.Bool("thrift.framed", false, "true to enable framing") - zipkinAddr = flag.String("zipkin.addr", "", "Enable Zipkin tracing via a Kafka Collector host:port") - appdashAddr = flag.String("appdash.addr", "", "Enable Appdash tracing via an Appdash server host:port") - lightstepToken = flag.String("lightstep.token", "", "Enable LightStep tracing via a LightStep access token") - method = flag.String("method", "sum", "sum, concat") - ) - flag.Parse() - - if len(flag.Args()) != 2 { - fmt.Fprintf(os.Stderr, "usage: addcli [flags] \n") - os.Exit(1) - } - - // This is a demonstration client, which supports multiple tracers. - // Your clients will probably just use one tracer. - var tracer stdopentracing.Tracer - { - if *zipkinAddr != "" { - collector, err := zipkin.NewKafkaCollector( - strings.Split(*zipkinAddr, ","), - zipkin.KafkaLogger(log.NewNopLogger()), - ) - if err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } - tracer, err = zipkin.NewTracer( - zipkin.NewRecorder(collector, false, "localhost:8000", "addcli"), - ) - if err != nil { - fmt.Fprintf(os.Stderr, "%v\n", err) - os.Exit(1) - } - } else if *appdashAddr != "" { - tracer = appdashot.NewTracer(appdash.NewRemoteCollector(*appdashAddr)) - } else if *lightstepToken != "" { - tracer = lightstep.NewTracer(lightstep.Options{ - AccessToken: *lightstepToken, - }) - defer lightstep.FlushLightStepTracer(tracer) - } else { - tracer = stdopentracing.GlobalTracer() // no-op - } - } - - // This is a demonstration client, which supports multiple transports. - // Your clients will probably just define and stick with 1 transport. - - var ( - service addsvc.Service - err error - ) - if *httpAddr != "" { - service, err = httpclient.New(*httpAddr, tracer, log.NewNopLogger()) - } else if *grpcAddr != "" { - conn, err := grpc.Dial(*grpcAddr, grpc.WithInsecure(), grpc.WithTimeout(time.Second)) - if err != nil { - fmt.Fprintf(os.Stderr, "error: %v", err) - os.Exit(1) - } - defer conn.Close() - service = grpcclient.New(conn, tracer, log.NewNopLogger()) - } else if *thriftAddr != "" { - // It's necessary to do all of this construction in the func main, - // because (among other reasons) we need to control the lifecycle of the - // Thrift transport, i.e. close it eventually. - var protocolFactory thrift.TProtocolFactory - switch *thriftProtocol { - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - case "binary", "": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - default: - fmt.Fprintf(os.Stderr, "error: invalid protocol %q\n", *thriftProtocol) - os.Exit(1) - } - var transportFactory thrift.TTransportFactory - if *thriftBufferSize > 0 { - transportFactory = thrift.NewTBufferedTransportFactory(*thriftBufferSize) - } else { - transportFactory = thrift.NewTTransportFactory() - } - if *thriftFramed { - transportFactory = thrift.NewTFramedTransportFactory(transportFactory) - } - transportSocket, err := thrift.NewTSocket(*thriftAddr) - if err != nil { - fmt.Fprintf(os.Stderr, "error: %v\n", err) - os.Exit(1) - } - transport := transportFactory.GetTransport(transportSocket) - if err := transport.Open(); err != nil { - fmt.Fprintf(os.Stderr, "error: %v\n", err) - os.Exit(1) - } - defer transport.Close() - client := thriftadd.NewAddServiceClientFactory(transport, protocolFactory) - service = thriftclient.New(client) - } else { - fmt.Fprintf(os.Stderr, "error: no remote address specified\n") - os.Exit(1) - } - if err != nil { - fmt.Fprintf(os.Stderr, "error: %v\n", err) - os.Exit(1) - } - - switch *method { - case "sum": - a, _ := strconv.ParseInt(flag.Args()[0], 10, 64) - b, _ := strconv.ParseInt(flag.Args()[1], 10, 64) - v, err := service.Sum(context.Background(), int(a), int(b)) - if err != nil { - fmt.Fprintf(os.Stderr, "error: %v\n", err) - os.Exit(1) - } - fmt.Fprintf(os.Stdout, "%d + %d = %d\n", a, b, v) - - case "concat": - a := flag.Args()[0] - b := flag.Args()[1] - v, err := service.Concat(context.Background(), a, b) - if err != nil { - fmt.Fprintf(os.Stderr, "error: %v\n", err) - os.Exit(1) - } - fmt.Fprintf(os.Stdout, "%q + %q = %q\n", a, b, v) - - default: - fmt.Fprintf(os.Stderr, "error: invalid method %q\n", method) - os.Exit(1) - } -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/cmd/addsvc/main.go b/vendor/github.com/go-kit/kit/examples/addsvc/cmd/addsvc/main.go deleted file mode 100644 index 2273a4c..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/cmd/addsvc/main.go +++ /dev/null @@ -1,257 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "net" - "net/http" - "net/http/pprof" - "os" - "os/signal" - "strings" - "syscall" - "time" - - "github.com/apache/thrift/lib/go/thrift" - lightstep "github.com/lightstep/lightstep-tracer-go" - stdopentracing "github.com/opentracing/opentracing-go" - zipkin "github.com/openzipkin/zipkin-go-opentracing" - stdprometheus "github.com/prometheus/client_golang/prometheus" - appdashot "github.com/sourcegraph/appdash/opentracing" - "golang.org/x/net/context" - "google.golang.org/grpc" - "sourcegraph.com/sourcegraph/appdash" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/addsvc" - "github.com/go-kit/kit/examples/addsvc/pb" - thriftadd "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics" - "github.com/go-kit/kit/metrics/prometheus" - "github.com/go-kit/kit/tracing/opentracing" -) - -func main() { - var ( - debugAddr = flag.String("debug.addr", ":8080", "Debug and metrics listen address") - httpAddr = flag.String("http.addr", ":8081", "HTTP listen address") - grpcAddr = flag.String("grpc.addr", ":8082", "gRPC (HTTP) listen address") - thriftAddr = flag.String("thrift.addr", ":8083", "Thrift listen address") - thriftProtocol = flag.String("thrift.protocol", "binary", "binary, compact, json, simplejson") - thriftBufferSize = flag.Int("thrift.buffer.size", 0, "0 for unbuffered") - thriftFramed = flag.Bool("thrift.framed", false, "true to enable framing") - zipkinAddr = flag.String("zipkin.addr", "", "Enable Zipkin tracing via a Kafka server host:port") - appdashAddr = flag.String("appdash.addr", "", "Enable Appdash tracing via an Appdash server host:port") - lightstepToken = flag.String("lightstep.token", "", "Enable LightStep tracing via a LightStep access token") - ) - flag.Parse() - - // Logging domain. - var logger log.Logger - { - logger = log.NewLogfmtLogger(os.Stdout) - logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) - logger = log.NewContext(logger).With("caller", log.DefaultCaller) - } - logger.Log("msg", "hello") - defer logger.Log("msg", "goodbye") - - // Metrics domain. - var ints, chars metrics.Counter - { - // Business level metrics. - ints = prometheus.NewCounter(stdprometheus.CounterOpts{ - Namespace: "addsvc", - Name: "integers_summed", - Help: "Total count of integers summed via the Sum method.", - }, []string{}) - chars = prometheus.NewCounter(stdprometheus.CounterOpts{ - Namespace: "addsvc", - Name: "characters_concatenated", - Help: "Total count of characters concatenated via the Concat method.", - }, []string{}) - } - var duration metrics.TimeHistogram - { - // Transport level metrics. - duration = metrics.NewTimeHistogram(time.Nanosecond, prometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "addsvc", - Name: "request_duration_ns", - Help: "Request duration in nanoseconds.", - }, []string{"method", "success"})) - } - - // Tracing domain. - var tracer stdopentracing.Tracer - { - if *zipkinAddr != "" { - logger := log.NewContext(logger).With("tracer", "Zipkin") - logger.Log("addr", *zipkinAddr) - collector, err := zipkin.NewKafkaCollector( - strings.Split(*zipkinAddr, ","), - zipkin.KafkaLogger(logger), - ) - if err != nil { - logger.Log("err", err) - os.Exit(1) - } - tracer, err = zipkin.NewTracer( - zipkin.NewRecorder(collector, false, "localhost:80", "addsvc"), - ) - if err != nil { - logger.Log("err", err) - os.Exit(1) - } - } else if *appdashAddr != "" { - logger := log.NewContext(logger).With("tracer", "Appdash") - logger.Log("addr", *appdashAddr) - tracer = appdashot.NewTracer(appdash.NewRemoteCollector(*appdashAddr)) - } else if *lightstepToken != "" { - logger := log.NewContext(logger).With("tracer", "LightStep") - logger.Log() // probably don't want to print out the token :) - tracer = lightstep.NewTracer(lightstep.Options{ - AccessToken: *lightstepToken, - }) - defer lightstep.FlushLightStepTracer(tracer) - } else { - logger := log.NewContext(logger).With("tracer", "none") - logger.Log() - tracer = stdopentracing.GlobalTracer() // no-op - } - } - - // Business domain. - var service addsvc.Service - { - service = addsvc.NewBasicService() - service = addsvc.ServiceLoggingMiddleware(logger)(service) - service = addsvc.ServiceInstrumentingMiddleware(ints, chars)(service) - } - - // Endpoint domain. - var sumEndpoint endpoint.Endpoint - { - sumDuration := duration.With(metrics.Field{Key: "method", Value: "Sum"}) - sumLogger := log.NewContext(logger).With("method", "Sum") - - sumEndpoint = addsvc.MakeSumEndpoint(service) - sumEndpoint = opentracing.TraceServer(tracer, "Sum")(sumEndpoint) - sumEndpoint = addsvc.EndpointInstrumentingMiddleware(sumDuration)(sumEndpoint) - sumEndpoint = addsvc.EndpointLoggingMiddleware(sumLogger)(sumEndpoint) - } - var concatEndpoint endpoint.Endpoint - { - concatDuration := duration.With(metrics.Field{Key: "method", Value: "Concat"}) - concatLogger := log.NewContext(logger).With("method", "Concat") - - concatEndpoint = addsvc.MakeConcatEndpoint(service) - concatEndpoint = opentracing.TraceServer(tracer, "Concat")(concatEndpoint) - concatEndpoint = addsvc.EndpointInstrumentingMiddleware(concatDuration)(concatEndpoint) - concatEndpoint = addsvc.EndpointLoggingMiddleware(concatLogger)(concatEndpoint) - } - endpoints := addsvc.Endpoints{ - SumEndpoint: sumEndpoint, - ConcatEndpoint: concatEndpoint, - } - - // Mechanical domain. - errc := make(chan error) - ctx := context.Background() - - // Interrupt handler. - go func() { - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - errc <- fmt.Errorf("%s", <-c) - }() - - // Debug listener. - go func() { - logger := log.NewContext(logger).With("transport", "debug") - - m := http.NewServeMux() - m.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index)) - m.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline)) - m.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile)) - m.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol)) - m.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace)) - m.Handle("/metrics", stdprometheus.Handler()) - - logger.Log("addr", *debugAddr) - errc <- http.ListenAndServe(*debugAddr, m) - }() - - // HTTP transport. - go func() { - logger := log.NewContext(logger).With("transport", "HTTP") - h := addsvc.MakeHTTPHandler(ctx, endpoints, tracer, logger) - logger.Log("addr", *httpAddr) - errc <- http.ListenAndServe(*httpAddr, h) - }() - - // gRPC transport. - go func() { - logger := log.NewContext(logger).With("transport", "gRPC") - - ln, err := net.Listen("tcp", *grpcAddr) - if err != nil { - errc <- err - return - } - - srv := addsvc.MakeGRPCServer(ctx, endpoints, tracer, logger) - s := grpc.NewServer() - pb.RegisterAddServer(s, srv) - - logger.Log("addr", *grpcAddr) - errc <- s.Serve(ln) - }() - - // Thrift transport. - go func() { - logger := log.NewContext(logger).With("transport", "Thrift") - - var protocolFactory thrift.TProtocolFactory - switch *thriftProtocol { - case "binary": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - default: - errc <- fmt.Errorf("invalid Thrift protocol %q", *thriftProtocol) - return - } - - var transportFactory thrift.TTransportFactory - if *thriftBufferSize > 0 { - transportFactory = thrift.NewTBufferedTransportFactory(*thriftBufferSize) - } else { - transportFactory = thrift.NewTTransportFactory() - } - if *thriftFramed { - transportFactory = thrift.NewTFramedTransportFactory(transportFactory) - } - - transport, err := thrift.NewTServerSocket(*thriftAddr) - if err != nil { - errc <- err - return - } - - logger.Log("addr", *thriftAddr) - errc <- thrift.NewTSimpleServer4( - thriftadd.NewAddServiceProcessor(addsvc.MakeThriftHandler(ctx, endpoints)), - transport, - transportFactory, - protocolFactory, - ).Serve() - }() - - // Run! - logger.Log("exit", <-errc) -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/doc.go b/vendor/github.com/go-kit/kit/examples/addsvc/doc.go deleted file mode 100644 index 8865046..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// Package addsvc implements the business and transport logic for an example -// service that can sum integers and concatenate strings. -// -// A client library is available in the client subdirectory. A server binary is -// available in cmd/addsrv. An example client binary is available in cmd/addcli. -package addsvc diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/endpoints.go b/vendor/github.com/go-kit/kit/examples/addsvc/endpoints.go deleted file mode 100644 index 8fb7cbd..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/endpoints.go +++ /dev/null @@ -1,136 +0,0 @@ -package addsvc - -// This file contains methods to make individual endpoints from services, -// request and response types to serve those endpoints, as well as encoders and -// decoders for those types, for all of our supported transport serialization -// formats. It also includes endpoint middlewares. - -import ( - "fmt" - "time" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics" -) - -// Endpoints collects all of the endpoints that compose an add service. It's -// meant to be used as a helper struct, to collect all of the endpoints into a -// single parameter. -// -// In a server, it's useful for functions that need to operate on a per-endpoint -// basis. For example, you might pass an Endpoints to a function that produces -// an http.Handler, with each method (endpoint) wired up to a specific path. (It -// is probably a mistake in design to invoke the Service methods on the -// Endpoints struct in a server.) -// -// In a client, it's useful to collect individually constructed endpoints into a -// single type that implements the Service interface. For example, you might -// construct individual endpoints using transport/http.NewClient, combine them -// into an Endpoints, and return it to the caller as a Service. -type Endpoints struct { - SumEndpoint endpoint.Endpoint - ConcatEndpoint endpoint.Endpoint -} - -// Sum implements Service. Primarily useful in a client. -func (e Endpoints) Sum(ctx context.Context, a, b int) (int, error) { - request := sumRequest{A: a, B: b} - response, err := e.SumEndpoint(ctx, request) - if err != nil { - return 0, err - } - return response.(sumResponse).V, response.(sumResponse).Err -} - -// Concat implements Service. Primarily useful in a client. -func (e Endpoints) Concat(ctx context.Context, a, b string) (string, error) { - request := concatRequest{A: a, B: b} - response, err := e.ConcatEndpoint(ctx, request) - if err != nil { - return "", err - } - return response.(concatResponse).V, response.(concatResponse).Err -} - -// MakeSumEndpoint returns an endpoint that invokes Sum on the service. -// Primarily useful in a server. -func MakeSumEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - sumReq := request.(sumRequest) - v, err := s.Sum(ctx, sumReq.A, sumReq.B) - if err == ErrIntOverflow { - return nil, err // special case; see comment on ErrIntOverflow - } - return sumResponse{ - V: v, - Err: err, - }, nil - } -} - -// MakeConcatEndpoint returns an endpoint that invokes Concat on the service. -// Primarily useful in a server. -func MakeConcatEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - concatReq := request.(concatRequest) - v, err := s.Concat(ctx, concatReq.A, concatReq.B) - return concatResponse{ - V: v, - Err: err, - }, nil - } -} - -// EndpointInstrumentingMiddleware returns an endpoint middleware that records -// the duration of each invocation to the passed histogram. The middleware adds -// a single field: "success", which is "true" if no error is returned, and -// "false" otherwise. -func EndpointInstrumentingMiddleware(duration metrics.TimeHistogram) endpoint.Middleware { - return func(next endpoint.Endpoint) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - - defer func(begin time.Time) { - f := metrics.Field{Key: "success", Value: fmt.Sprint(err == nil)} - duration.With(f).Observe(time.Since(begin)) - }(time.Now()) - return next(ctx, request) - - } - } -} - -// EndpointLoggingMiddleware returns an endpoint middleware that logs the -// duration of each invocation, and the resulting error, if any. -func EndpointLoggingMiddleware(logger log.Logger) endpoint.Middleware { - return func(next endpoint.Endpoint) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - - defer func(begin time.Time) { - logger.Log("error", err, "took", time.Since(begin)) - }(time.Now()) - return next(ctx, request) - - } - } -} - -// These types are unexported because they only exist to serve the endpoint -// domain, which is totally encapsulated in this package. They are otherwise -// opaque to all callers. - -type sumRequest struct{ A, B int } - -type sumResponse struct { - V int - Err error -} - -type concatRequest struct{ A, B string } - -type concatResponse struct { - V string - Err error -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go b/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go deleted file mode 100644 index 0e8cff5..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go +++ /dev/null @@ -1,215 +0,0 @@ -// Code generated by protoc-gen-go. -// source: addsvc.proto -// DO NOT EDIT! - -/* -Package pb is a generated protocol buffer package. - -It is generated from these files: - addsvc.proto - -It has these top-level messages: - SumRequest - SumReply - ConcatRequest - ConcatReply -*/ -package pb - -import proto "github.com/golang/protobuf/proto" -import fmt "fmt" -import math "math" - -import ( - context "golang.org/x/net/context" - grpc "google.golang.org/grpc" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package - -// The sum request contains two parameters. -type SumRequest struct { - A int64 `protobuf:"varint,1,opt,name=a" json:"a,omitempty"` - B int64 `protobuf:"varint,2,opt,name=b" json:"b,omitempty"` -} - -func (m *SumRequest) Reset() { *m = SumRequest{} } -func (m *SumRequest) String() string { return proto.CompactTextString(m) } -func (*SumRequest) ProtoMessage() {} -func (*SumRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } - -// The sum response contains the result of the calculation. -type SumReply struct { - V int64 `protobuf:"varint,1,opt,name=v" json:"v,omitempty"` - Err string `protobuf:"bytes,2,opt,name=err" json:"err,omitempty"` -} - -func (m *SumReply) Reset() { *m = SumReply{} } -func (m *SumReply) String() string { return proto.CompactTextString(m) } -func (*SumReply) ProtoMessage() {} -func (*SumReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } - -// The Concat request contains two parameters. -type ConcatRequest struct { - A string `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` - B string `protobuf:"bytes,2,opt,name=b" json:"b,omitempty"` -} - -func (m *ConcatRequest) Reset() { *m = ConcatRequest{} } -func (m *ConcatRequest) String() string { return proto.CompactTextString(m) } -func (*ConcatRequest) ProtoMessage() {} -func (*ConcatRequest) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } - -// The Concat response contains the result of the concatenation. -type ConcatReply struct { - V string `protobuf:"bytes,1,opt,name=v" json:"v,omitempty"` - Err string `protobuf:"bytes,2,opt,name=err" json:"err,omitempty"` -} - -func (m *ConcatReply) Reset() { *m = ConcatReply{} } -func (m *ConcatReply) String() string { return proto.CompactTextString(m) } -func (*ConcatReply) ProtoMessage() {} -func (*ConcatReply) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } - -func init() { - proto.RegisterType((*SumRequest)(nil), "pb.SumRequest") - proto.RegisterType((*SumReply)(nil), "pb.SumReply") - proto.RegisterType((*ConcatRequest)(nil), "pb.ConcatRequest") - proto.RegisterType((*ConcatReply)(nil), "pb.ConcatReply") -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion3 - -// Client API for Add service - -type AddClient interface { - // Sums two integers. - Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumReply, error) - // Concatenates two strings - Concat(ctx context.Context, in *ConcatRequest, opts ...grpc.CallOption) (*ConcatReply, error) -} - -type addClient struct { - cc *grpc.ClientConn -} - -func NewAddClient(cc *grpc.ClientConn) AddClient { - return &addClient{cc} -} - -func (c *addClient) Sum(ctx context.Context, in *SumRequest, opts ...grpc.CallOption) (*SumReply, error) { - out := new(SumReply) - err := grpc.Invoke(ctx, "/pb.Add/Sum", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *addClient) Concat(ctx context.Context, in *ConcatRequest, opts ...grpc.CallOption) (*ConcatReply, error) { - out := new(ConcatReply) - err := grpc.Invoke(ctx, "/pb.Add/Concat", in, out, c.cc, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// Server API for Add service - -type AddServer interface { - // Sums two integers. - Sum(context.Context, *SumRequest) (*SumReply, error) - // Concatenates two strings - Concat(context.Context, *ConcatRequest) (*ConcatReply, error) -} - -func RegisterAddServer(s *grpc.Server, srv AddServer) { - s.RegisterService(&_Add_serviceDesc, srv) -} - -func _Add_Sum_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(SumRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AddServer).Sum(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/pb.Add/Sum", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AddServer).Sum(ctx, req.(*SumRequest)) - } - return interceptor(ctx, in, info, handler) -} - -func _Add_Concat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(ConcatRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(AddServer).Concat(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/pb.Add/Concat", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AddServer).Concat(ctx, req.(*ConcatRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Add_serviceDesc = grpc.ServiceDesc{ - ServiceName: "pb.Add", - HandlerType: (*AddServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Sum", - Handler: _Add_Sum_Handler, - }, - { - MethodName: "Concat", - Handler: _Add_Concat_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: fileDescriptor0, -} - -func init() { proto.RegisterFile("addsvc.proto", fileDescriptor0) } - -var fileDescriptor0 = []byte{ - // 188 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0x4c, 0x49, 0x29, - 0x2e, 0x4b, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2a, 0x48, 0x52, 0xd2, 0xe0, 0xe2, - 0x0a, 0x2e, 0xcd, 0x0d, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0xe2, 0xe1, 0x62, 0x4c, 0x94, - 0x60, 0x54, 0x60, 0xd4, 0x60, 0x0e, 0x62, 0x4c, 0x04, 0xf1, 0x92, 0x24, 0x98, 0x20, 0xbc, 0x24, - 0x25, 0x2d, 0x2e, 0x0e, 0xb0, 0xca, 0x82, 0x9c, 0x4a, 0x90, 0x4c, 0x19, 0x4c, 0x5d, 0x99, 0x90, - 0x00, 0x17, 0x73, 0x6a, 0x51, 0x11, 0x58, 0x25, 0x67, 0x10, 0x88, 0xa9, 0xa4, 0xcd, 0xc5, 0xeb, - 0x9c, 0x9f, 0x97, 0x9c, 0x58, 0x82, 0x61, 0x30, 0x27, 0x8a, 0xc1, 0x9c, 0x20, 0x83, 0x75, 0xb9, - 0xb8, 0x61, 0x8a, 0x51, 0xcc, 0xe6, 0xc4, 0x6a, 0xb6, 0x51, 0x0c, 0x17, 0xb3, 0x63, 0x4a, 0x8a, - 0x90, 0x2a, 0x17, 0x33, 0xd0, 0x39, 0x42, 0x7c, 0x7a, 0x05, 0x49, 0x7a, 0x08, 0x1f, 0x48, 0xf1, - 0xc0, 0xf9, 0x40, 0xb3, 0x94, 0x18, 0x84, 0xf4, 0xb8, 0xd8, 0x20, 0x86, 0x0b, 0x09, 0x82, 0x64, - 0x50, 0x5c, 0x25, 0xc5, 0x8f, 0x2c, 0x04, 0x56, 0x9f, 0xc4, 0x06, 0x0e, 0x1a, 0x63, 0x40, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xdc, 0x37, 0x81, 0x99, 0x2a, 0x01, 0x00, 0x00, -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.proto b/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.proto deleted file mode 100644 index cf61532..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.proto +++ /dev/null @@ -1,36 +0,0 @@ -syntax = "proto3"; - -package pb; - -// The Add service definition. -service Add { - // Sums two integers. - rpc Sum (SumRequest) returns (SumReply) {} - - // Concatenates two strings - rpc Concat (ConcatRequest) returns (ConcatReply) {} -} - -// The sum request contains two parameters. -message SumRequest { - int64 a = 1; - int64 b = 2; -} - -// The sum response contains the result of the calculation. -message SumReply { - int64 v = 1; - string err = 2; -} - -// The Concat request contains two parameters. -message ConcatRequest { - string a = 1; - string b = 2; -} - -// The Concat response contains the result of the concatenation. -message ConcatReply { - string v = 1; - string err = 2; -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/pb/compile.sh b/vendor/github.com/go-kit/kit/examples/addsvc/pb/compile.sh deleted file mode 100755 index c026844..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/pb/compile.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env sh - -# Install proto3 from source -# brew install autoconf automake libtool -# git clone https://github.com/google/protobuf -# ./autogen.sh ; ./configure ; make ; make install -# -# Update protoc Go bindings via -# go get -u github.com/golang/protobuf/{proto,protoc-gen-go} -# -# See also -# https://github.com/grpc/grpc-go/tree/master/examples - -protoc addsvc.proto --go_out=plugins=grpc:. diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/service.go b/vendor/github.com/go-kit/kit/examples/addsvc/service.go deleted file mode 100644 index c60b676..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/service.go +++ /dev/null @@ -1,164 +0,0 @@ -package addsvc - -// This file contains the Service definition, and a basic service -// implementation. It also includes service middlewares. - -import ( - "errors" - "time" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics" -) - -// Service describes a service that adds things together. -type Service interface { - Sum(ctx context.Context, a, b int) (int, error) - Concat(ctx context.Context, a, b string) (string, error) -} - -// Business-domain errors like these may be served in two ways: returned -// directly by endpoints, or bundled into the response struct. Both methods can -// be made to work, but errors returned directly by endpoints are counted by -// middlewares that check errors, like circuit breakers. -// -// If you don't want that behavior -- and you probably don't -- then it's better -// to bundle errors into the response struct. - -var ( - // ErrTwoZeroes is an arbitrary business rule for the Add method. - ErrTwoZeroes = errors.New("can't sum two zeroes") - - // ErrIntOverflow protects the Add method. We've decided that this error - // indicates a misbehaving service and should count against e.g. circuit - // breakers. So, we return it directly in endpoints, to illustrate the - // difference. In a real service, this probably wouldn't be the case. - ErrIntOverflow = errors.New("integer overflow") - - // ErrMaxSizeExceeded protects the Concat method. - ErrMaxSizeExceeded = errors.New("result exceeds maximum size") -) - -// These annoying helper functions are required to translate Go error types to -// and from strings, which is the type we use in our IDLs to represent errors. -// There is special casing to treat empty strings as nil errors. - -func str2err(s string) error { - if s == "" { - return nil - } - return errors.New(s) -} - -func err2str(err error) string { - if err == nil { - return "" - } - return err.Error() -} - -// NewBasicService returns a naïve, stateless implementation of Service. -func NewBasicService() Service { - return basicService{} -} - -type basicService struct{} - -const ( - intMax = 1<<31 - 1 - intMin = -(intMax + 1) - maxLen = 102400 -) - -// Sum implements Service. -func (s basicService) Sum(_ context.Context, a, b int) (int, error) { - if a == 0 && b == 0 { - return 0, ErrTwoZeroes - } - if (b > 0 && a > (intMax-b)) || (b < 0 && a < (intMin-b)) { - return 0, ErrIntOverflow - } - return a + b, nil -} - -// Concat implements Service. -func (s basicService) Concat(_ context.Context, a, b string) (string, error) { - if len(a)+len(b) > maxLen { - return "", ErrMaxSizeExceeded - } - return a + b, nil -} - -// Middleware describes a service (as opposed to endpoint) middleware. -type Middleware func(Service) Service - -// ServiceLoggingMiddleware returns a service middleware that logs the -// parameters and result of each method invocation. -func ServiceLoggingMiddleware(logger log.Logger) Middleware { - return func(next Service) Service { - return serviceLoggingMiddleware{ - logger: logger, - next: next, - } - } -} - -type serviceLoggingMiddleware struct { - logger log.Logger - next Service -} - -func (mw serviceLoggingMiddleware) Sum(ctx context.Context, a, b int) (v int, err error) { - defer func(begin time.Time) { - mw.logger.Log( - "method", "Sum", - "a", a, "b", b, "result", v, "error", err, - "took", time.Since(begin), - ) - }(time.Now()) - return mw.next.Sum(ctx, a, b) -} - -func (mw serviceLoggingMiddleware) Concat(ctx context.Context, a, b string) (v string, err error) { - defer func(begin time.Time) { - mw.logger.Log( - "method", "Concat", - "a", a, "b", b, "result", v, "error", err, - "took", time.Since(begin), - ) - }(time.Now()) - return mw.next.Concat(ctx, a, b) -} - -// ServiceInstrumentingMiddleware returns a service middleware that instruments -// the number of integers summed and characters concatenated over the lifetime of -// the service. -func ServiceInstrumentingMiddleware(ints, chars metrics.Counter) Middleware { - return func(next Service) Service { - return serviceInstrumentingMiddleware{ - ints: ints, - chars: chars, - next: next, - } - } -} - -type serviceInstrumentingMiddleware struct { - ints metrics.Counter - chars metrics.Counter - next Service -} - -func (mw serviceInstrumentingMiddleware) Sum(ctx context.Context, a, b int) (int, error) { - v, err := mw.next.Sum(ctx, a, b) - mw.ints.Add(uint64(v)) - return v, err -} - -func (mw serviceInstrumentingMiddleware) Concat(ctx context.Context, a, b string) (string, error) { - v, err := mw.next.Concat(ctx, a, b) - mw.chars.Add(uint64(len(v))) - return v, err -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/addsvc.thrift b/vendor/github.com/go-kit/kit/examples/addsvc/thrift/addsvc.thrift deleted file mode 100644 index e67ce1b..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/addsvc.thrift +++ /dev/null @@ -1,14 +0,0 @@ -struct SumReply { - 1: i64 value - 2: string err -} - -struct ConcatReply { - 1: string value - 2: string err -} - -service AddService { - SumReply Sum(1: i64 a, 2: i64 b) - ConcatReply Concat(1: string a, 2: string b) -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/compile.sh b/vendor/github.com/go-kit/kit/examples/addsvc/thrift/compile.sh deleted file mode 100755 index 2ecce5b..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/compile.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh - -# See also https://thrift.apache.org/tutorial/go - -thrift -r --gen "go:package_prefix=github.com/go-kit/kit/examples/addsvc/thrift/gen-go/,thrift_import=github.com/apache/thrift/lib/go/thrift" addsvc.thrift diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/add_service-remote/add_service-remote.go b/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/add_service-remote/add_service-remote.go deleted file mode 100755 index b8ce67c..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/add_service-remote/add_service-remote.go +++ /dev/null @@ -1,157 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package main - -import ( - "flag" - "fmt" - "github.com/apache/thrift/lib/go/thrift" - "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc" - "math" - "net" - "net/url" - "os" - "strconv" - "strings" -) - -func Usage() { - fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, "\nFunctions:") - fmt.Fprintln(os.Stderr, " SumReply Sum(i64 a, i64 b)") - fmt.Fprintln(os.Stderr, " ConcatReply Concat(string a, string b)") - fmt.Fprintln(os.Stderr) - os.Exit(0) -} - -func main() { - flag.Usage = Usage - var host string - var port int - var protocol string - var urlString string - var framed bool - var useHttp bool - var parsedUrl url.URL - var trans thrift.TTransport - _ = strconv.Atoi - _ = math.Abs - flag.Usage = Usage - flag.StringVar(&host, "h", "localhost", "Specify host and port") - flag.IntVar(&port, "p", 9090, "Specify port") - flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") - flag.StringVar(&urlString, "u", "", "Specify the url") - flag.BoolVar(&framed, "framed", false, "Use framed transport") - flag.BoolVar(&useHttp, "http", false, "Use http") - flag.Parse() - - if len(urlString) > 0 { - parsedUrl, err := url.Parse(urlString) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - host = parsedUrl.Host - useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" - } else if useHttp { - _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - } - - cmd := flag.Arg(0) - var err error - if useHttp { - trans, err = thrift.NewTHttpClient(parsedUrl.String()) - } else { - portStr := fmt.Sprint(port) - if strings.Contains(host, ":") { - host, portStr, err = net.SplitHostPort(host) - if err != nil { - fmt.Fprintln(os.Stderr, "error with host:", err) - os.Exit(1) - } - } - trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) - if err != nil { - fmt.Fprintln(os.Stderr, "error resolving address:", err) - os.Exit(1) - } - if framed { - trans = thrift.NewTFramedTransport(trans) - } - } - if err != nil { - fmt.Fprintln(os.Stderr, "Error creating transport", err) - os.Exit(1) - } - defer trans.Close() - var protocolFactory thrift.TProtocolFactory - switch protocol { - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - break - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - break - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - break - case "binary", "": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - break - default: - fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) - Usage() - os.Exit(1) - } - client := addsvc.NewAddServiceClientFactory(trans, protocolFactory) - if err := trans.Open(); err != nil { - fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) - os.Exit(1) - } - - switch cmd { - case "Sum": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "Sum requires 2 args") - flag.Usage() - } - argvalue0, err6 := (strconv.ParseInt(flag.Arg(1), 10, 64)) - if err6 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1, err7 := (strconv.ParseInt(flag.Arg(2), 10, 64)) - if err7 != nil { - Usage() - return - } - value1 := argvalue1 - fmt.Print(client.Sum(value0, value1)) - fmt.Print("\n") - break - case "Concat": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "Concat requires 2 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.Concat(value0, value1)) - fmt.Print("\n") - break - case "": - Usage() - break - default: - fmt.Fprintln(os.Stderr, "Invalid function ", cmd) - } -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/addservice.go b/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/addservice.go deleted file mode 100644 index 3f3aeeb..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/addservice.go +++ /dev/null @@ -1,807 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package addsvc - -import ( - "bytes" - "fmt" - "github.com/apache/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -type AddService interface { - // Parameters: - // - A - // - B - Sum(a int64, b int64) (r *SumReply, err error) - // Parameters: - // - A - // - B - Concat(a string, b string) (r *ConcatReply, err error) -} - -type AddServiceClient struct { - Transport thrift.TTransport - ProtocolFactory thrift.TProtocolFactory - InputProtocol thrift.TProtocol - OutputProtocol thrift.TProtocol - SeqId int32 -} - -func NewAddServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AddServiceClient { - return &AddServiceClient{Transport: t, - ProtocolFactory: f, - InputProtocol: f.GetProtocol(t), - OutputProtocol: f.GetProtocol(t), - SeqId: 0, - } -} - -func NewAddServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AddServiceClient { - return &AddServiceClient{Transport: t, - ProtocolFactory: nil, - InputProtocol: iprot, - OutputProtocol: oprot, - SeqId: 0, - } -} - -// Parameters: -// - A -// - B -func (p *AddServiceClient) Sum(a int64, b int64) (r *SumReply, err error) { - if err = p.sendSum(a, b); err != nil { - return - } - return p.recvSum() -} - -func (p *AddServiceClient) sendSum(a int64, b int64) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("Sum", thrift.CALL, p.SeqId); err != nil { - return - } - args := AddServiceSumArgs{ - A: a, - B: b, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AddServiceClient) recvSum() (value *SumReply, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "Sum" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Sum failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Sum failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error0 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error1 error - error1, err = error0.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error1 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Sum failed: invalid message type") - return - } - result := AddServiceSumResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Parameters: -// - A -// - B -func (p *AddServiceClient) Concat(a string, b string) (r *ConcatReply, err error) { - if err = p.sendConcat(a, b); err != nil { - return - } - return p.recvConcat() -} - -func (p *AddServiceClient) sendConcat(a string, b string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("Concat", thrift.CALL, p.SeqId); err != nil { - return - } - args := AddServiceConcatArgs{ - A: a, - B: b, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AddServiceClient) recvConcat() (value *ConcatReply, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "Concat" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "Concat failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "Concat failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error2 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error3 error - error3, err = error2.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error3 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "Concat failed: invalid message type") - return - } - result := AddServiceConcatResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -type AddServiceProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler AddService -} - -func (p *AddServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *AddServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *AddServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewAddServiceProcessor(handler AddService) *AddServiceProcessor { - - self4 := &AddServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self4.processorMap["Sum"] = &addServiceProcessorSum{handler: handler} - self4.processorMap["Concat"] = &addServiceProcessorConcat{handler: handler} - return self4 -} - -func (p *AddServiceProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x5 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x5.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, x5 - -} - -type addServiceProcessorSum struct { - handler AddService -} - -func (p *addServiceProcessorSum) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AddServiceSumArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Sum", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AddServiceSumResult{} - var retval *SumReply - var err2 error - if retval, err2 = p.handler.Sum(args.A, args.B); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Sum: "+err2.Error()) - oprot.WriteMessageBegin("Sum", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Sum", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type addServiceProcessorConcat struct { - handler AddService -} - -func (p *addServiceProcessorConcat) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AddServiceConcatArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("Concat", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AddServiceConcatResult{} - var retval *ConcatReply - var err2 error - if retval, err2 = p.handler.Concat(args.A, args.B); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Concat: "+err2.Error()) - oprot.WriteMessageBegin("Concat", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("Concat", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - A -// - B -type AddServiceSumArgs struct { - A int64 `thrift:"a,1" json:"a"` - B int64 `thrift:"b,2" json:"b"` -} - -func NewAddServiceSumArgs() *AddServiceSumArgs { - return &AddServiceSumArgs{} -} - -func (p *AddServiceSumArgs) GetA() int64 { - return p.A -} - -func (p *AddServiceSumArgs) GetB() int64 { - return p.B -} -func (p *AddServiceSumArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AddServiceSumArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *AddServiceSumArgs) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.B = v - } - return nil -} - -func (p *AddServiceSumArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Sum_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AddServiceSumArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) - } - if err := oprot.WriteI64(int64(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) - } - return err -} - -func (p *AddServiceSumArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) - } - if err := oprot.WriteI64(int64(p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) - } - return err -} - -func (p *AddServiceSumArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AddServiceSumArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AddServiceSumResult struct { - Success *SumReply `thrift:"success,0" json:"success,omitempty"` -} - -func NewAddServiceSumResult() *AddServiceSumResult { - return &AddServiceSumResult{} -} - -var AddServiceSumResult_Success_DEFAULT *SumReply - -func (p *AddServiceSumResult) GetSuccess() *SumReply { - if !p.IsSetSuccess() { - return AddServiceSumResult_Success_DEFAULT - } - return p.Success -} -func (p *AddServiceSumResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AddServiceSumResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AddServiceSumResult) readField0(iprot thrift.TProtocol) error { - p.Success = &SumReply{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AddServiceSumResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Sum_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AddServiceSumResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AddServiceSumResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AddServiceSumResult(%+v)", *p) -} - -// Attributes: -// - A -// - B -type AddServiceConcatArgs struct { - A string `thrift:"a,1" json:"a"` - B string `thrift:"b,2" json:"b"` -} - -func NewAddServiceConcatArgs() *AddServiceConcatArgs { - return &AddServiceConcatArgs{} -} - -func (p *AddServiceConcatArgs) GetA() string { - return p.A -} - -func (p *AddServiceConcatArgs) GetB() string { - return p.B -} -func (p *AddServiceConcatArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AddServiceConcatArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.A = v - } - return nil -} - -func (p *AddServiceConcatArgs) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.B = v - } - return nil -} - -func (p *AddServiceConcatArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Concat_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AddServiceConcatArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("a", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err) - } - if err := oprot.WriteString(string(p.A)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err) - } - return err -} - -func (p *AddServiceConcatArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("b", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) - } - if err := oprot.WriteString(string(p.B)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) - } - return err -} - -func (p *AddServiceConcatArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AddServiceConcatArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AddServiceConcatResult struct { - Success *ConcatReply `thrift:"success,0" json:"success,omitempty"` -} - -func NewAddServiceConcatResult() *AddServiceConcatResult { - return &AddServiceConcatResult{} -} - -var AddServiceConcatResult_Success_DEFAULT *ConcatReply - -func (p *AddServiceConcatResult) GetSuccess() *ConcatReply { - if !p.IsSetSuccess() { - return AddServiceConcatResult_Success_DEFAULT - } - return p.Success -} -func (p *AddServiceConcatResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AddServiceConcatResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AddServiceConcatResult) readField0(iprot thrift.TProtocol) error { - p.Success = &ConcatReply{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AddServiceConcatResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Concat_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AddServiceConcatResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AddServiceConcatResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AddServiceConcatResult(%+v)", *p) -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/constants.go b/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/constants.go deleted file mode 100644 index 2f0079a..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/constants.go +++ /dev/null @@ -1,18 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package addsvc - -import ( - "bytes" - "fmt" - "github.com/apache/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -func init() { -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/ttypes.go b/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/ttypes.go deleted file mode 100644 index 2fcbd55..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc/ttypes.go +++ /dev/null @@ -1,269 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package addsvc - -import ( - "bytes" - "fmt" - "github.com/apache/thrift/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -var GoUnusedProtection__ int - -// Attributes: -// - Value -// - Err -type SumReply struct { - Value int64 `thrift:"value,1" json:"value"` - Err string `thrift:"err,2" json:"err"` -} - -func NewSumReply() *SumReply { - return &SumReply{} -} - -func (p *SumReply) GetValue() int64 { - return p.Value -} - -func (p *SumReply) GetErr() string { - return p.Err -} -func (p *SumReply) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *SumReply) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *SumReply) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Err = v - } - return nil -} - -func (p *SumReply) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("SumReply"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *SumReply) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) - } - if err := oprot.WriteI64(int64(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) - } - return err -} - -func (p *SumReply) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("err", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:err: ", p), err) - } - if err := oprot.WriteString(string(p.Err)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.err (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:err: ", p), err) - } - return err -} - -func (p *SumReply) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("SumReply(%+v)", *p) -} - -// Attributes: -// - Value -// - Err -type ConcatReply struct { - Value string `thrift:"value,1" json:"value"` - Err string `thrift:"err,2" json:"err"` -} - -func NewConcatReply() *ConcatReply { - return &ConcatReply{} -} - -func (p *ConcatReply) GetValue() string { - return p.Value -} - -func (p *ConcatReply) GetErr() string { - return p.Err -} -func (p *ConcatReply) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ConcatReply) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *ConcatReply) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Err = v - } - return nil -} - -func (p *ConcatReply) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ConcatReply"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ConcatReply) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) - } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) - } - return err -} - -func (p *ConcatReply) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("err", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:err: ", p), err) - } - if err := oprot.WriteString(string(p.Err)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.err (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:err: ", p), err) - } - return err -} - -func (p *ConcatReply) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ConcatReply(%+v)", *p) -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/transport_grpc.go b/vendor/github.com/go-kit/kit/examples/addsvc/transport_grpc.go deleted file mode 100644 index 6ad30cb..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/transport_grpc.go +++ /dev/null @@ -1,118 +0,0 @@ -package addsvc - -// This file provides server-side bindings for the gRPC transport. -// It utilizes the transport/grpc.Server. - -import ( - stdopentracing "github.com/opentracing/opentracing-go" - "golang.org/x/net/context" - - "github.com/go-kit/kit/examples/addsvc/pb" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/tracing/opentracing" - grpctransport "github.com/go-kit/kit/transport/grpc" -) - -// MakeGRPCServer makes a set of endpoints available as a gRPC AddServer. -func MakeGRPCServer(ctx context.Context, endpoints Endpoints, tracer stdopentracing.Tracer, logger log.Logger) pb.AddServer { - options := []grpctransport.ServerOption{ - grpctransport.ServerErrorLogger(logger), - } - return &grpcServer{ - sum: grpctransport.NewServer( - ctx, - endpoints.SumEndpoint, - DecodeGRPCSumRequest, - EncodeGRPCSumResponse, - append(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, "Sum", logger)))..., - ), - concat: grpctransport.NewServer( - ctx, - endpoints.ConcatEndpoint, - DecodeGRPCConcatRequest, - EncodeGRPCConcatResponse, - append(options, grpctransport.ServerBefore(opentracing.FromGRPCRequest(tracer, "Concat", logger)))..., - ), - } -} - -type grpcServer struct { - sum grpctransport.Handler - concat grpctransport.Handler -} - -func (s *grpcServer) Sum(ctx context.Context, req *pb.SumRequest) (*pb.SumReply, error) { - _, rep, err := s.sum.ServeGRPC(ctx, req) - if err != nil { - return nil, err - } - return rep.(*pb.SumReply), nil -} - -func (s *grpcServer) Concat(ctx context.Context, req *pb.ConcatRequest) (*pb.ConcatReply, error) { - _, rep, err := s.concat.ServeGRPC(ctx, req) - if err != nil { - return nil, err - } - return rep.(*pb.ConcatReply), nil -} - -// DecodeGRPCSumRequest is a transport/grpc.DecodeRequestFunc that converts a -// gRPC sum request to a user-domain sum request. Primarily useful in a server. -func DecodeGRPCSumRequest(_ context.Context, grpcReq interface{}) (interface{}, error) { - req := grpcReq.(*pb.SumRequest) - return sumRequest{A: int(req.A), B: int(req.B)}, nil -} - -// DecodeGRPCConcatRequest is a transport/grpc.DecodeRequestFunc that converts a -// gRPC concat request to a user-domain concat request. Primarily useful in a -// server. -func DecodeGRPCConcatRequest(_ context.Context, grpcReq interface{}) (interface{}, error) { - req := grpcReq.(*pb.ConcatRequest) - return concatRequest{A: req.A, B: req.B}, nil -} - -// DecodeGRPCSumResponse is a transport/grpc.DecodeResponseFunc that converts a -// gRPC sum reply to a user-domain sum response. Primarily useful in a client. -func DecodeGRPCSumResponse(_ context.Context, grpcReply interface{}) (interface{}, error) { - reply := grpcReply.(*pb.SumReply) - return sumResponse{V: int(reply.V), Err: str2err(reply.Err)}, nil -} - -// DecodeGRPCConcatResponse is a transport/grpc.DecodeResponseFunc that converts -// a gRPC concat reply to a user-domain concat response. Primarily useful in a -// client. -func DecodeGRPCConcatResponse(_ context.Context, grpcReply interface{}) (interface{}, error) { - reply := grpcReply.(*pb.ConcatReply) - return concatResponse{V: reply.V, Err: str2err(reply.Err)}, nil -} - -// EncodeGRPCSumResponse is a transport/grpc.EncodeResponseFunc that converts a -// user-domain sum response to a gRPC sum reply. Primarily useful in a server. -func EncodeGRPCSumResponse(_ context.Context, response interface{}) (interface{}, error) { - resp := response.(sumResponse) - return &pb.SumReply{V: int64(resp.V), Err: err2str(resp.Err)}, nil -} - -// EncodeGRPCConcatResponse is a transport/grpc.EncodeResponseFunc that converts -// a user-domain concat response to a gRPC concat reply. Primarily useful in a -// server. -func EncodeGRPCConcatResponse(_ context.Context, response interface{}) (interface{}, error) { - resp := response.(concatResponse) - return &pb.ConcatReply{V: resp.V, Err: err2str(resp.Err)}, nil -} - -// EncodeGRPCSumRequest is a transport/grpc.EncodeRequestFunc that converts a -// user-domain sum request to a gRPC sum request. Primarily useful in a client. -func EncodeGRPCSumRequest(_ context.Context, request interface{}) (interface{}, error) { - req := request.(sumRequest) - return &pb.SumRequest{A: int64(req.A), B: int64(req.B)}, nil -} - -// EncodeGRPCConcatRequest is a transport/grpc.EncodeRequestFunc that converts a -// user-domain concat request to a gRPC concat request. Primarily useful in a -// client. -func EncodeGRPCConcatRequest(_ context.Context, request interface{}) (interface{}, error) { - req := request.(concatRequest) - return &pb.ConcatRequest{A: req.A, B: req.B}, nil -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/transport_http.go b/vendor/github.com/go-kit/kit/examples/addsvc/transport_http.go deleted file mode 100644 index e2d8f6d..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/transport_http.go +++ /dev/null @@ -1,141 +0,0 @@ -package addsvc - -// This file provides server-side bindings for the HTTP transport. -// It utilizes the transport/http.Server. - -import ( - "bytes" - "encoding/json" - "errors" - "io/ioutil" - "net/http" - - stdopentracing "github.com/opentracing/opentracing-go" - "golang.org/x/net/context" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/tracing/opentracing" - httptransport "github.com/go-kit/kit/transport/http" -) - -// MakeHTTPHandler returns a handler that makes a set of endpoints available -// on predefined paths. -func MakeHTTPHandler(ctx context.Context, endpoints Endpoints, tracer stdopentracing.Tracer, logger log.Logger) http.Handler { - options := []httptransport.ServerOption{ - httptransport.ServerErrorEncoder(errorEncoder), - httptransport.ServerErrorLogger(logger), - } - m := http.NewServeMux() - m.Handle("/sum", httptransport.NewServer( - ctx, - endpoints.SumEndpoint, - DecodeHTTPSumRequest, - EncodeHTTPGenericResponse, - append(options, httptransport.ServerBefore(opentracing.FromHTTPRequest(tracer, "Sum", logger)))..., - )) - m.Handle("/concat", httptransport.NewServer( - ctx, - endpoints.ConcatEndpoint, - DecodeHTTPConcatRequest, - EncodeHTTPGenericResponse, - append(options, httptransport.ServerBefore(opentracing.FromHTTPRequest(tracer, "Concat", logger)))..., - )) - return m -} - -func errorEncoder(_ context.Context, err error, w http.ResponseWriter) { - code := http.StatusInternalServerError - msg := err.Error() - - if e, ok := err.(httptransport.Error); ok { - msg = e.Err.Error() - switch e.Domain { - case httptransport.DomainDecode: - code = http.StatusBadRequest - - case httptransport.DomainDo: - switch e.Err { - case ErrTwoZeroes, ErrMaxSizeExceeded, ErrIntOverflow: - code = http.StatusBadRequest - } - } - } - - w.WriteHeader(code) - json.NewEncoder(w).Encode(errorWrapper{Error: msg}) -} - -func errorDecoder(r *http.Response) error { - var w errorWrapper - if err := json.NewDecoder(r.Body).Decode(&w); err != nil { - return err - } - return errors.New(w.Error) -} - -type errorWrapper struct { - Error string `json:"error"` -} - -// DecodeHTTPSumRequest is a transport/http.DecodeRequestFunc that decodes a -// JSON-encoded sum request from the HTTP request body. Primarily useful in a -// server. -func DecodeHTTPSumRequest(_ context.Context, r *http.Request) (interface{}, error) { - var req sumRequest - err := json.NewDecoder(r.Body).Decode(&req) - return req, err -} - -// DecodeHTTPConcatRequest is a transport/http.DecodeRequestFunc that decodes a -// JSON-encoded concat request from the HTTP request body. Primarily useful in a -// server. -func DecodeHTTPConcatRequest(_ context.Context, r *http.Request) (interface{}, error) { - var req concatRequest - err := json.NewDecoder(r.Body).Decode(&req) - return req, err -} - -// DecodeHTTPSumResponse is a transport/http.DecodeResponseFunc that decodes a -// JSON-encoded sum response from the HTTP response body. If the response has a -// non-200 status code, we will interpret that as an error and attempt to decode -// the specific error message from the response body. Primarily useful in a -// client. -func DecodeHTTPSumResponse(_ context.Context, r *http.Response) (interface{}, error) { - if r.StatusCode != http.StatusOK { - return nil, errorDecoder(r) - } - var resp sumResponse - err := json.NewDecoder(r.Body).Decode(&resp) - return resp, err -} - -// DecodeHTTPConcatResponse is a transport/http.DecodeResponseFunc that decodes -// a JSON-encoded concat response from the HTTP response body. If the response -// has a non-200 status code, we will interpret that as an error and attempt to -// decode the specific error message from the response body. Primarily useful in -// a client. -func DecodeHTTPConcatResponse(_ context.Context, r *http.Response) (interface{}, error) { - if r.StatusCode != http.StatusOK { - return nil, errorDecoder(r) - } - var resp concatResponse - err := json.NewDecoder(r.Body).Decode(&resp) - return resp, err -} - -// EncodeHTTPGenericRequest is a transport/http.EncodeRequestFunc that -// JSON-encodes any request to the request body. Primarily useful in a client. -func EncodeHTTPGenericRequest(_ context.Context, r *http.Request, request interface{}) error { - var buf bytes.Buffer - if err := json.NewEncoder(&buf).Encode(request); err != nil { - return err - } - r.Body = ioutil.NopCloser(&buf) - return nil -} - -// EncodeHTTPGenericResponse is a transport/http.EncodeResponseFunc that encodes -// the response as JSON to the response writer. Primarily useful in a server. -func EncodeHTTPGenericResponse(_ context.Context, w http.ResponseWriter, response interface{}) error { - return json.NewEncoder(w).Encode(response) -} diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/transport_thrift.go b/vendor/github.com/go-kit/kit/examples/addsvc/transport_thrift.go deleted file mode 100644 index 23b1f1c..0000000 --- a/vendor/github.com/go-kit/kit/examples/addsvc/transport_thrift.go +++ /dev/null @@ -1,73 +0,0 @@ -package addsvc - -// This file provides server-side bindings for the Thrift transport. -// -// This file also provides endpoint constructors that utilize a Thrift client, -// for use in client packages, because package transport/thrift doesn't exist -// yet. See https://github.com/go-kit/kit/issues/184. - -import ( - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" - thriftadd "github.com/go-kit/kit/examples/addsvc/thrift/gen-go/addsvc" -) - -// MakeThriftHandler makes a set of endpoints available as a Thrift service. -func MakeThriftHandler(ctx context.Context, e Endpoints) thriftadd.AddService { - return &thriftServer{ - ctx: ctx, - sum: e.SumEndpoint, - concat: e.ConcatEndpoint, - } -} - -type thriftServer struct { - ctx context.Context - sum endpoint.Endpoint - concat endpoint.Endpoint -} - -func (s *thriftServer) Sum(a int64, b int64) (*thriftadd.SumReply, error) { - request := sumRequest{A: int(a), B: int(b)} - response, err := s.sum(s.ctx, request) - if err != nil { - return nil, err - } - resp := response.(sumResponse) - return &thriftadd.SumReply{Value: int64(resp.V), Err: err2str(resp.Err)}, nil -} - -func (s *thriftServer) Concat(a string, b string) (*thriftadd.ConcatReply, error) { - request := concatRequest{A: a, B: b} - response, err := s.concat(s.ctx, request) - if err != nil { - return nil, err - } - resp := response.(concatResponse) - return &thriftadd.ConcatReply{Value: resp.V, Err: err2str(resp.Err)}, nil -} - -// MakeThriftSumEndpoint returns an endpoint that invokes the passed Thrift client. -// Useful only in clients, and only until a proper transport/thrift.Client exists. -func MakeThriftSumEndpoint(client *thriftadd.AddServiceClient) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(sumRequest) - reply, err := client.Sum(int64(req.A), int64(req.B)) - if err == ErrIntOverflow { - return nil, err // special case; see comment on ErrIntOverflow - } - return sumResponse{V: int(reply.Value), Err: err}, nil - } -} - -// MakeThriftConcatEndpoint returns an endpoint that invokes the passed Thrift -// client. Useful only in clients, and only until a proper -// transport/thrift.Client exists. -func MakeThriftConcatEndpoint(client *thriftadd.AddServiceClient) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(concatRequest) - reply, err := client.Concat(req.A, req.B) - return concatResponse{V: reply.Value, Err: err}, nil - } -} diff --git a/vendor/github.com/go-kit/kit/examples/apigateway/main.go b/vendor/github.com/go-kit/kit/examples/apigateway/main.go deleted file mode 100644 index 01367ec..0000000 --- a/vendor/github.com/go-kit/kit/examples/apigateway/main.go +++ /dev/null @@ -1,282 +0,0 @@ -package main - -import ( - "bytes" - "encoding/json" - "flag" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "os" - "os/signal" - "strings" - "syscall" - "time" - - "github.com/gorilla/mux" - "github.com/hashicorp/consul/api" - stdopentracing "github.com/opentracing/opentracing-go" - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/addsvc" - addsvcgrpcclient "github.com/go-kit/kit/examples/addsvc/client/grpc" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/sd" - consulsd "github.com/go-kit/kit/sd/consul" - "github.com/go-kit/kit/sd/lb" - httptransport "github.com/go-kit/kit/transport/http" - "google.golang.org/grpc" -) - -func main() { - var ( - httpAddr = flag.String("http.addr", ":8000", "Address for HTTP (JSON) server") - consulAddr = flag.String("consul.addr", "", "Consul agent address") - retryMax = flag.Int("retry.max", 3, "per-request retries to different instances") - retryTimeout = flag.Duration("retry.timeout", 500*time.Millisecond, "per-request timeout, including retries") - ) - flag.Parse() - - // Logging domain. - var logger log.Logger - { - logger = log.NewLogfmtLogger(os.Stderr) - logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) - logger = log.NewContext(logger).With("caller", log.DefaultCaller) - } - - // Service discovery domain. In this example we use Consul. - var client consulsd.Client - { - consulConfig := api.DefaultConfig() - if len(*consulAddr) > 0 { - consulConfig.Address = *consulAddr - } - consulClient, err := api.NewClient(consulConfig) - if err != nil { - logger.Log("err", err) - os.Exit(1) - } - client = consulsd.NewClient(consulClient) - } - - // Transport domain. - tracer := stdopentracing.GlobalTracer() // no-op - ctx := context.Background() - r := mux.NewRouter() - - // Now we begin installing the routes. Each route corresponds to a single - // method: sum, concat, uppercase, and count. - - // addsvc routes. - { - // Each method gets constructed with a factory. Factories take an - // instance string, and return a specific endpoint. In the factory we - // dial the instance string we get from Consul, and then leverage an - // addsvc client package to construct a complete service. We can then - // leverage the addsvc.Make{Sum,Concat}Endpoint constructors to convert - // the complete service to specific endpoint. - - var ( - tags = []string{} - passingOnly = true - endpoints = addsvc.Endpoints{} - ) - { - factory := addsvcFactory(addsvc.MakeSumEndpoint, tracer, logger) - subscriber := consulsd.NewSubscriber(client, factory, logger, "addsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(*retryMax, *retryTimeout, balancer) - endpoints.SumEndpoint = retry - } - { - factory := addsvcFactory(addsvc.MakeConcatEndpoint, tracer, logger) - subscriber := consulsd.NewSubscriber(client, factory, logger, "addsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(*retryMax, *retryTimeout, balancer) - endpoints.ConcatEndpoint = retry - } - - // Here we leverage the fact that addsvc comes with a constructor for an - // HTTP handler, and just install it under a particular path prefix in - // our router. - - r.PathPrefix("addsvc/").Handler(addsvc.MakeHTTPHandler(ctx, endpoints, tracer, logger)) - } - - // stringsvc routes. - { - // addsvc had lots of nice importable Go packages we could leverage. - // With stringsvc we are not so fortunate, it just has some endpoints - // that we assume will exist. So we have to write that logic here. This - // is by design, so you can see two totally different methods of - // proxying to a remote service. - - var ( - tags = []string{} - passingOnly = true - uppercase endpoint.Endpoint - count endpoint.Endpoint - ) - { - factory := stringsvcFactory(ctx, "GET", "/uppercase") - subscriber := consulsd.NewSubscriber(client, factory, logger, "stringsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(*retryMax, *retryTimeout, balancer) - uppercase = retry - } - { - factory := stringsvcFactory(ctx, "GET", "/count") - subscriber := consulsd.NewSubscriber(client, factory, logger, "stringsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(*retryMax, *retryTimeout, balancer) - count = retry - } - - // We can use the transport/http.Server to act as our handler, all we - // have to do provide it with the encode and decode functions for our - // stringsvc methods. - - r.Handle("/stringsvc/uppercase", httptransport.NewServer(ctx, uppercase, decodeUppercaseRequest, encodeJSONResponse)) - r.Handle("/stringsvc/count", httptransport.NewServer(ctx, count, decodeCountRequest, encodeJSONResponse)) - } - - // Interrupt handler. - errc := make(chan error) - go func() { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - errc <- fmt.Errorf("%s", <-c) - }() - - // HTTP transport. - go func() { - logger.Log("transport", "HTTP", "addr", *httpAddr) - errc <- http.ListenAndServe(*httpAddr, r) - }() - - // Run! - logger.Log("exit", <-errc) -} - -func addsvcFactory(makeEndpoint func(addsvc.Service) endpoint.Endpoint, tracer stdopentracing.Tracer, logger log.Logger) sd.Factory { - return func(instance string) (endpoint.Endpoint, io.Closer, error) { - // We could just as easily use the HTTP or Thrift client package to make - // the connection to addsvc. We've chosen gRPC arbitrarily. Note that - // the transport is an implementation detail: it doesn't leak out of - // this function. Nice! - - conn, err := grpc.Dial(instance, grpc.WithInsecure()) - if err != nil { - return nil, nil, err - } - service := addsvcgrpcclient.New(conn, tracer, logger) - endpoint := makeEndpoint(service) - - // Notice that the addsvc gRPC client converts the connection to a - // complete addsvc, and we just throw away everything except the method - // we're interested in. A smarter factory would mux multiple methods - // over the same connection. But that would require more work to manage - // the returned io.Closer, e.g. reference counting. Since this is for - // the purposes of demonstration, we'll just keep it simple. - - return endpoint, conn, nil - } -} - -func stringsvcFactory(ctx context.Context, method, path string) sd.Factory { - return func(instance string) (endpoint.Endpoint, io.Closer, error) { - if !strings.HasPrefix(instance, "http") { - instance = "http://" + instance - } - tgt, err := url.Parse(instance) - if err != nil { - return nil, nil, err - } - tgt.Path = path - - // Since stringsvc doesn't have any kind of package we can import, or - // any formal spec, we are forced to just assert where the endpoints - // live, and write our own code to encode and decode requests and - // responses. Ideally, if you write the service, you will want to - // provide stronger guarantees to your clients. - - var ( - enc httptransport.EncodeRequestFunc - dec httptransport.DecodeResponseFunc - ) - switch path { - case "/uppercase": - enc, dec = encodeJSONRequest, decodeUppercaseResponse - case "/count": - enc, dec = encodeJSONRequest, decodeCountResponse - default: - return nil, nil, fmt.Errorf("unknown stringsvc path %q", path) - } - - return httptransport.NewClient(method, tgt, enc, dec).Endpoint(), nil, nil - } -} - -func encodeJSONRequest(_ context.Context, req *http.Request, request interface{}) error { - // Both uppercase and count requests are encoded in the same way: - // simple JSON serialization to the request body. - var buf bytes.Buffer - if err := json.NewEncoder(&buf).Encode(request); err != nil { - return err - } - req.Body = ioutil.NopCloser(&buf) - return nil -} - -func encodeJSONResponse(_ context.Context, w http.ResponseWriter, response interface{}) error { - w.Header().Set("Content-Type", "application/json; charset=utf-8") - return json.NewEncoder(w).Encode(response) -} - -// I've just copied these functions from stringsvc3/transport.go, inlining the -// struct definitions. - -func decodeUppercaseResponse(ctx context.Context, resp *http.Response) (interface{}, error) { - var response struct { - V string `json:"v"` - Err string `json:"err,omitempty"` - } - if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { - return nil, err - } - return response, nil -} - -func decodeCountResponse(ctx context.Context, resp *http.Response) (interface{}, error) { - var response struct { - V int `json:"v"` - } - if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { - return nil, err - } - return response, nil -} - -func decodeUppercaseRequest(ctx context.Context, req *http.Request) (interface{}, error) { - var request struct { - S string `json:"s"` - } - if err := json.NewDecoder(req.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func decodeCountRequest(ctx context.Context, req *http.Request) (interface{}, error) { - var request struct { - S string `json:"s"` - } - if err := json.NewDecoder(req.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} diff --git a/vendor/github.com/go-kit/kit/examples/profilesvc/README.md b/vendor/github.com/go-kit/kit/examples/profilesvc/README.md deleted file mode 100644 index 68c4125..0000000 --- a/vendor/github.com/go-kit/kit/examples/profilesvc/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# profilesvc - -This example demonstrates how to use Go kit to implement a REST-y HTTP service. -It leverages the excellent [gorilla mux package](https://github.com/gorilla/mux) for routing. diff --git a/vendor/github.com/go-kit/kit/examples/profilesvc/client/client.go b/vendor/github.com/go-kit/kit/examples/profilesvc/client/client.go deleted file mode 100644 index 6b1dff0..0000000 --- a/vendor/github.com/go-kit/kit/examples/profilesvc/client/client.go +++ /dev/null @@ -1,120 +0,0 @@ -// Package client provides a profilesvc client based on a predefined Consul -// service name and relevant tags. Users must only provide the address of a -// Consul server. -package client - -import ( - "io" - "time" - - consulapi "github.com/hashicorp/consul/api" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/profilesvc" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/sd" - "github.com/go-kit/kit/sd/consul" - "github.com/go-kit/kit/sd/lb" -) - -// New returns a service that's load-balanced over instances of profilesvc found -// in the provided Consul server. The mechanism of looking up profilesvc -// instances in Consul is hard-coded into the client. -func New(consulAddr string, logger log.Logger) (profilesvc.Service, error) { - apiclient, err := consulapi.NewClient(&consulapi.Config{ - Address: consulAddr, - }) - if err != nil { - return nil, err - } - - // As the implementer of profilesvc, we declare and enforce these - // parameters for all of the profilesvc consumers. - var ( - consulService = "profilesvc" - consulTags = []string{"prod"} - passingOnly = true - retryMax = 3 - retryTimeout = 500 * time.Millisecond - ) - - var ( - sdclient = consul.NewClient(apiclient) - endpoints profilesvc.Endpoints - ) - { - factory := factoryFor(profilesvc.MakePostProfileEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.PostProfileEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakeGetProfileEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.GetProfileEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakePutProfileEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.PutProfileEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakePatchProfileEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.PatchProfileEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakeDeleteProfileEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.DeleteProfileEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakeGetAddressesEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.GetAddressesEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakeGetAddressEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.GetAddressEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakePostAddressEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.PostAddressEndpoint = retry - } - { - factory := factoryFor(profilesvc.MakeDeleteAddressEndpoint) - subscriber := consul.NewSubscriber(sdclient, factory, logger, consulService, consulTags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(retryMax, retryTimeout, balancer) - endpoints.DeleteAddressEndpoint = retry - } - - return endpoints, nil -} - -func factoryFor(makeEndpoint func(profilesvc.Service) endpoint.Endpoint) sd.Factory { - return func(instance string) (endpoint.Endpoint, io.Closer, error) { - service, err := profilesvc.MakeClientEndpoints(instance) - if err != nil { - return nil, nil, err - } - return makeEndpoint(service), nil, nil - } -} diff --git a/vendor/github.com/go-kit/kit/examples/profilesvc/cmd/profilesvc/main.go b/vendor/github.com/go-kit/kit/examples/profilesvc/cmd/profilesvc/main.go deleted file mode 100644 index a340e69..0000000 --- a/vendor/github.com/go-kit/kit/examples/profilesvc/cmd/profilesvc/main.go +++ /dev/null @@ -1,59 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "net/http" - "os" - "os/signal" - "syscall" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/examples/profilesvc" - "github.com/go-kit/kit/log" -) - -func main() { - var ( - httpAddr = flag.String("http.addr", ":8080", "HTTP listen address") - ) - flag.Parse() - - var logger log.Logger - { - logger = log.NewLogfmtLogger(os.Stderr) - logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) - logger = log.NewContext(logger).With("caller", log.DefaultCaller) - } - - var ctx context.Context - { - ctx = context.Background() - } - - var s profilesvc.Service - { - s = profilesvc.NewInmemService() - s = profilesvc.LoggingMiddleware(logger)(s) - } - - var h http.Handler - { - h = profilesvc.MakeHTTPHandler(ctx, s, log.NewContext(logger).With("component", "HTTP")) - } - - errs := make(chan error) - go func() { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGINT, syscall.SIGTERM) - errs <- fmt.Errorf("%s", <-c) - }() - - go func() { - logger.Log("transport", "HTTP", "addr", *httpAddr) - errs <- http.ListenAndServe(*httpAddr, h) - }() - - logger.Log("exit", <-errs) -} diff --git a/vendor/github.com/go-kit/kit/examples/profilesvc/endpoints.go b/vendor/github.com/go-kit/kit/examples/profilesvc/endpoints.go deleted file mode 100644 index 6dd129f..0000000 --- a/vendor/github.com/go-kit/kit/examples/profilesvc/endpoints.go +++ /dev/null @@ -1,388 +0,0 @@ -package profilesvc - -import ( - "net/url" - "strings" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" -) - -// Endpoints collects all of the endpoints that compose a profile service. It's -// meant to be used as a helper struct, to collect all of the endpoints into a -// single parameter. -// -// In a server, it's useful for functions that need to operate on a per-endpoint -// basis. For example, you might pass an Endpoints to a function that produces -// an http.Handler, with each method (endpoint) wired up to a specific path. (It -// is probably a mistake in design to invoke the Service methods on the -// Endpoints struct in a server.) -// -// In a client, it's useful to collect individually constructed endpoints into a -// single type that implements the Service interface. For example, you might -// construct individual endpoints using transport/http.NewClient, combine them -// into an Endpoints, and return it to the caller as a Service. -type Endpoints struct { - PostProfileEndpoint endpoint.Endpoint - GetProfileEndpoint endpoint.Endpoint - PutProfileEndpoint endpoint.Endpoint - PatchProfileEndpoint endpoint.Endpoint - DeleteProfileEndpoint endpoint.Endpoint - GetAddressesEndpoint endpoint.Endpoint - GetAddressEndpoint endpoint.Endpoint - PostAddressEndpoint endpoint.Endpoint - DeleteAddressEndpoint endpoint.Endpoint -} - -// MakeServerEndpoints returns an Endpoints struct where each endpoint invokes -// the corresponding method on the provided service. Useful in a profilesvc -// server. -func MakeServerEndpoints(s Service) Endpoints { - return Endpoints{ - PostProfileEndpoint: MakePostProfileEndpoint(s), - GetProfileEndpoint: MakeGetProfileEndpoint(s), - PutProfileEndpoint: MakePutProfileEndpoint(s), - PatchProfileEndpoint: MakePatchProfileEndpoint(s), - DeleteProfileEndpoint: MakeDeleteProfileEndpoint(s), - GetAddressesEndpoint: MakeGetAddressesEndpoint(s), - GetAddressEndpoint: MakeGetAddressEndpoint(s), - PostAddressEndpoint: MakePostAddressEndpoint(s), - DeleteAddressEndpoint: MakeDeleteAddressEndpoint(s), - } -} - -// MakeClientEndpoints returns an Endpoints struct where each endpoint invokes -// the corresponding method on the remote instance, via a transport/http.Client. -// Useful in a profilesvc client. -func MakeClientEndpoints(instance string) (Endpoints, error) { - if !strings.HasPrefix(instance, "http") { - instance = "http://" + instance - } - tgt, err := url.Parse(instance) - if err != nil { - return Endpoints{}, err - } - tgt.Path = "" - - options := []httptransport.ClientOption{} - - // Note that the request encoders need to modify the request URL, changing - // the path and method. That's fine: we simply need to provide specific - // encoders for each endpoint. - - return Endpoints{ - PostProfileEndpoint: httptransport.NewClient("POST", tgt, encodePostProfileRequest, decodePostProfileResponse, options...).Endpoint(), - GetProfileEndpoint: httptransport.NewClient("GET", tgt, encodeGetProfileRequest, decodeGetProfileResponse, options...).Endpoint(), - PutProfileEndpoint: httptransport.NewClient("PUT", tgt, encodePutProfileRequest, decodePutProfileResponse, options...).Endpoint(), - PatchProfileEndpoint: httptransport.NewClient("PATCH", tgt, encodePatchProfileRequest, decodePatchProfileResponse, options...).Endpoint(), - DeleteProfileEndpoint: httptransport.NewClient("DELETE", tgt, encodeDeleteProfileRequest, decodeDeleteProfileResponse, options...).Endpoint(), - GetAddressesEndpoint: httptransport.NewClient("GET", tgt, encodeGetAddressesRequest, decodeGetAddressesResponse, options...).Endpoint(), - GetAddressEndpoint: httptransport.NewClient("GET", tgt, encodeGetAddressRequest, decodeGetAddressResponse, options...).Endpoint(), - PostAddressEndpoint: httptransport.NewClient("POST", tgt, encodePostAddressRequest, decodePostAddressResponse, options...).Endpoint(), - DeleteAddressEndpoint: httptransport.NewClient("DELETE", tgt, encodeDeleteAddressRequest, decodeDeleteAddressResponse, options...).Endpoint(), - }, nil -} - -// PostProfile implements Service. Primarily useful in a client. -func (e Endpoints) PostProfile(ctx context.Context, p Profile) error { - request := postProfileRequest{Profile: p} - response, err := e.PostProfileEndpoint(ctx, request) - if err != nil { - return err - } - resp := response.(postProfileResponse) - return resp.Err -} - -// GetProfile implements Service. Primarily useful in a client. -func (e Endpoints) GetProfile(ctx context.Context, id string) (Profile, error) { - request := getProfileRequest{ID: id} - response, err := e.GetProfileEndpoint(ctx, request) - if err != nil { - return Profile{}, err - } - resp := response.(getProfileResponse) - return resp.Profile, resp.Err -} - -// PutProfile implements Service. Primarily useful in a client. -func (e Endpoints) PutProfile(ctx context.Context, id string, p Profile) error { - request := putProfileRequest{ID: id, Profile: p} - response, err := e.PutProfileEndpoint(ctx, request) - if err != nil { - return err - } - resp := response.(putProfileResponse) - return resp.Err -} - -// PatchProfile implements Service. Primarily useful in a client. -func (e Endpoints) PatchProfile(ctx context.Context, id string, p Profile) error { - request := patchProfileRequest{ID: id, Profile: p} - response, err := e.PatchProfileEndpoint(ctx, request) - if err != nil { - return err - } - resp := response.(patchProfileResponse) - return resp.Err -} - -// DeleteProfile implements Service. Primarily useful in a client. -func (e Endpoints) DeleteProfile(ctx context.Context, id string) error { - request := deleteProfileRequest{ID: id} - response, err := e.DeleteProfileEndpoint(ctx, request) - if err != nil { - return err - } - resp := response.(deleteProfileResponse) - return resp.Err -} - -// GetAddresses implements Service. Primarily useful in a client. -func (e Endpoints) GetAddresses(ctx context.Context, profileID string) ([]Address, error) { - request := getAddressesRequest{ProfileID: profileID} - response, err := e.GetAddressesEndpoint(ctx, request) - if err != nil { - return nil, err - } - resp := response.(getAddressesResponse) - return resp.Addresses, resp.Err -} - -// GetAddress implements Service. Primarily useful in a client. -func (e Endpoints) GetAddress(ctx context.Context, profileID string, addressID string) (Address, error) { - request := getAddressRequest{ProfileID: profileID, AddressID: addressID} - response, err := e.GetAddressEndpoint(ctx, request) - if err != nil { - return Address{}, err - } - resp := response.(getAddressResponse) - return resp.Address, resp.Err -} - -// PostAddress implements Service. Primarily useful in a client. -func (e Endpoints) PostAddress(ctx context.Context, profileID string, a Address) error { - request := postAddressRequest{ProfileID: profileID, Address: a} - response, err := e.PostAddressEndpoint(ctx, request) - if err != nil { - return err - } - resp := response.(postAddressResponse) - return resp.Err -} - -// DeleteAddress implements Service. Primarily useful in a client. -func (e Endpoints) DeleteAddress(ctx context.Context, profileID string, addressID string) error { - request := deleteAddressRequest{ProfileID: profileID, AddressID: addressID} - response, err := e.DeleteAddressEndpoint(ctx, request) - if err != nil { - return err - } - resp := response.(deleteAddressResponse) - return resp.Err -} - -// MakePostProfileEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakePostProfileEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(postProfileRequest) - e := s.PostProfile(ctx, req.Profile) - return postProfileResponse{Err: e}, nil - } -} - -// MakeGetProfileEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakeGetProfileEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(getProfileRequest) - p, e := s.GetProfile(ctx, req.ID) - return getProfileResponse{Profile: p, Err: e}, nil - } -} - -// MakePutProfileEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakePutProfileEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(putProfileRequest) - e := s.PutProfile(ctx, req.ID, req.Profile) - return putProfileResponse{Err: e}, nil - } -} - -// MakePatchProfileEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakePatchProfileEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(patchProfileRequest) - e := s.PatchProfile(ctx, req.ID, req.Profile) - return patchProfileResponse{Err: e}, nil - } -} - -// MakeDeleteProfileEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakeDeleteProfileEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(deleteProfileRequest) - e := s.DeleteProfile(ctx, req.ID) - return deleteProfileResponse{Err: e}, nil - } -} - -// MakeGetAddressesEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakeGetAddressesEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(getAddressesRequest) - a, e := s.GetAddresses(ctx, req.ProfileID) - return getAddressesResponse{Addresses: a, Err: e}, nil - } -} - -// MakeGetAddressEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakeGetAddressEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(getAddressRequest) - a, e := s.GetAddress(ctx, req.ProfileID, req.AddressID) - return getAddressResponse{Address: a, Err: e}, nil - } -} - -// MakePostAddressEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakePostAddressEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(postAddressRequest) - e := s.PostAddress(ctx, req.ProfileID, req.Address) - return postAddressResponse{Err: e}, nil - } -} - -// MakeDeleteAddressEndpoint returns an endpoint via the passed service. -// Primarily useful in a server. -func MakeDeleteAddressEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (response interface{}, err error) { - req := request.(deleteAddressRequest) - e := s.DeleteAddress(ctx, req.ProfileID, req.AddressID) - return deleteAddressResponse{Err: e}, nil - } -} - -// We have two options to return errors from the business logic. -// -// We could return the error via the endpoint itself. That makes certain things -// a little bit easier, like providing non-200 HTTP responses to the client. But -// Go kit assumes that endpoint errors are (or may be treated as) -// transport-domain errors. For example, an endpoint error will count against a -// circuit breaker error count. -// -// Therefore, it's often better to return service (business logic) errors in the -// response object. This means we have to do a bit more work in the HTTP -// response encoder to detect e.g. a not-found error and provide a proper HTTP -// status code. That work is done with the errorer interface, in transport.go. -// Response types that may contain business-logic errors implement that -// interface. - -type postProfileRequest struct { - Profile Profile -} - -type postProfileResponse struct { - Err error `json:"err,omitempty"` -} - -func (r postProfileResponse) error() error { return r.Err } - -type getProfileRequest struct { - ID string -} - -type getProfileResponse struct { - Profile Profile `json:"profile,omitempty"` - Err error `json:"err,omitempty"` -} - -func (r getProfileResponse) error() error { return r.Err } - -type putProfileRequest struct { - ID string - Profile Profile -} - -type putProfileResponse struct { - Err error `json:"err,omitempty"` -} - -func (r putProfileResponse) error() error { return nil } - -type patchProfileRequest struct { - ID string - Profile Profile -} - -type patchProfileResponse struct { - Err error `json:"err,omitempty"` -} - -func (r patchProfileResponse) error() error { return r.Err } - -type deleteProfileRequest struct { - ID string -} - -type deleteProfileResponse struct { - Err error `json:"err,omitempty"` -} - -func (r deleteProfileResponse) error() error { return r.Err } - -type getAddressesRequest struct { - ProfileID string -} - -type getAddressesResponse struct { - Addresses []Address `json:"addresses,omitempty"` - Err error `json:"err,omitempty"` -} - -func (r getAddressesResponse) error() error { return r.Err } - -type getAddressRequest struct { - ProfileID string - AddressID string -} - -type getAddressResponse struct { - Address Address `json:"address,omitempty"` - Err error `json:"err,omitempty"` -} - -func (r getAddressResponse) error() error { return r.Err } - -type postAddressRequest struct { - ProfileID string - Address Address -} - -type postAddressResponse struct { - Err error `json:"err,omitempty"` -} - -func (r postAddressResponse) error() error { return r.Err } - -type deleteAddressRequest struct { - ProfileID string - AddressID string -} - -type deleteAddressResponse struct { - Err error `json:"err,omitempty"` -} - -func (r deleteAddressResponse) error() error { return r.Err } diff --git a/vendor/github.com/go-kit/kit/examples/profilesvc/middlewares.go b/vendor/github.com/go-kit/kit/examples/profilesvc/middlewares.go deleted file mode 100644 index 76708e5..0000000 --- a/vendor/github.com/go-kit/kit/examples/profilesvc/middlewares.go +++ /dev/null @@ -1,89 +0,0 @@ -package profilesvc - -import ( - "time" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/log" -) - -// Middleware describes a service (as opposed to endpoint) middleware. -type Middleware func(Service) Service - -func LoggingMiddleware(logger log.Logger) Middleware { - return func(next Service) Service { - return &loggingMiddleware{ - next: next, - logger: logger, - } - } -} - -type loggingMiddleware struct { - next Service - logger log.Logger -} - -func (mw loggingMiddleware) PostProfile(ctx context.Context, p Profile) (err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "PostProfile", "id", p.ID, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.PostProfile(ctx, p) -} - -func (mw loggingMiddleware) GetProfile(ctx context.Context, id string) (p Profile, err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "GetProfile", "id", id, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.GetProfile(ctx, id) -} - -func (mw loggingMiddleware) PutProfile(ctx context.Context, id string, p Profile) (err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "PutProfile", "id", id, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.PutProfile(ctx, id, p) -} - -func (mw loggingMiddleware) PatchProfile(ctx context.Context, id string, p Profile) (err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "PatchProfile", "id", id, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.PatchProfile(ctx, id, p) -} - -func (mw loggingMiddleware) DeleteProfile(ctx context.Context, id string) (err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "DeleteProfile", "id", id, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.DeleteProfile(ctx, id) -} - -func (mw loggingMiddleware) GetAddresses(ctx context.Context, profileID string) (addresses []Address, err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "GetAddresses", "profileID", profileID, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.GetAddresses(ctx, profileID) -} - -func (mw loggingMiddleware) GetAddress(ctx context.Context, profileID string, addressID string) (a Address, err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "GetAddress", "profileID", profileID, "addressID", addressID, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.GetAddress(ctx, profileID, addressID) -} - -func (mw loggingMiddleware) PostAddress(ctx context.Context, profileID string, a Address) (err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "PostAddress", "profileID", profileID, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.PostAddress(ctx, profileID, a) -} - -func (mw loggingMiddleware) DeleteAddress(ctx context.Context, profileID string, addressID string) (err error) { - defer func(begin time.Time) { - mw.logger.Log("method", "DeleteAddress", "profileID", profileID, "addressID", addressID, "took", time.Since(begin), "err", err) - }(time.Now()) - return mw.next.DeleteAddress(ctx, profileID, addressID) -} diff --git a/vendor/github.com/go-kit/kit/examples/profilesvc/service.go b/vendor/github.com/go-kit/kit/examples/profilesvc/service.go deleted file mode 100644 index 4ae6756..0000000 --- a/vendor/github.com/go-kit/kit/examples/profilesvc/service.go +++ /dev/null @@ -1,186 +0,0 @@ -package profilesvc - -import ( - "errors" - "sync" - - "golang.org/x/net/context" -) - -// Service is a simple CRUD interface for user profiles. -type Service interface { - PostProfile(ctx context.Context, p Profile) error - GetProfile(ctx context.Context, id string) (Profile, error) - PutProfile(ctx context.Context, id string, p Profile) error - PatchProfile(ctx context.Context, id string, p Profile) error - DeleteProfile(ctx context.Context, id string) error - GetAddresses(ctx context.Context, profileID string) ([]Address, error) - GetAddress(ctx context.Context, profileID string, addressID string) (Address, error) - PostAddress(ctx context.Context, profileID string, a Address) error - DeleteAddress(ctx context.Context, profileID string, addressID string) error -} - -// Profile represents a single user profile. -// ID should be globally unique. -type Profile struct { - ID string `json:"id"` - Name string `json:"name,omitempty"` - Addresses []Address `json:"addresses,omitempty"` -} - -// Address is a field of a user profile. -// ID should be unique within the profile (at a minimum). -type Address struct { - ID string `json:"id"` - Location string `json:"location,omitempty"` -} - -var ( - ErrInconsistentIDs = errors.New("inconsistent IDs") - ErrAlreadyExists = errors.New("already exists") - ErrNotFound = errors.New("not found") -) - -type inmemService struct { - mtx sync.RWMutex - m map[string]Profile -} - -func NewInmemService() Service { - return &inmemService{ - m: map[string]Profile{}, - } -} - -func (s *inmemService) PostProfile(ctx context.Context, p Profile) error { - s.mtx.Lock() - defer s.mtx.Unlock() - if _, ok := s.m[p.ID]; ok { - return ErrAlreadyExists // POST = create, don't overwrite - } - s.m[p.ID] = p - return nil -} - -func (s *inmemService) GetProfile(ctx context.Context, id string) (Profile, error) { - s.mtx.RLock() - defer s.mtx.RUnlock() - p, ok := s.m[id] - if !ok { - return Profile{}, ErrNotFound - } - return p, nil -} - -func (s *inmemService) PutProfile(ctx context.Context, id string, p Profile) error { - if id != p.ID { - return ErrInconsistentIDs - } - s.mtx.Lock() - defer s.mtx.Unlock() - s.m[id] = p // PUT = create or update - return nil -} - -func (s *inmemService) PatchProfile(ctx context.Context, id string, p Profile) error { - if p.ID != "" && id != p.ID { - return ErrInconsistentIDs - } - - s.mtx.Lock() - defer s.mtx.Unlock() - - existing, ok := s.m[id] - if !ok { - return ErrNotFound // PATCH = update existing, don't create - } - - // We assume that it's not possible to PATCH the ID, and that it's not - // possible to PATCH any field to its zero value. That is, the zero value - // means not specified. The way around this is to use e.g. Name *string in - // the Profile definition. But since this is just a demonstrative example, - // I'm leaving that out. - - if p.Name != "" { - existing.Name = p.Name - } - if len(p.Addresses) > 0 { - existing.Addresses = p.Addresses - } - s.m[id] = existing - return nil -} - -func (s *inmemService) DeleteProfile(ctx context.Context, id string) error { - s.mtx.Lock() - defer s.mtx.Unlock() - if _, ok := s.m[id]; !ok { - return ErrNotFound - } - delete(s.m, id) - return nil -} - -func (s *inmemService) GetAddresses(ctx context.Context, profileID string) ([]Address, error) { - s.mtx.RLock() - defer s.mtx.RUnlock() - p, ok := s.m[profileID] - if !ok { - return []Address{}, ErrNotFound - } - return p.Addresses, nil -} - -func (s *inmemService) GetAddress(ctx context.Context, profileID string, addressID string) (Address, error) { - s.mtx.RLock() - defer s.mtx.RUnlock() - p, ok := s.m[profileID] - if !ok { - return Address{}, ErrNotFound - } - for _, address := range p.Addresses { - if address.ID == addressID { - return address, nil - } - } - return Address{}, ErrNotFound -} - -func (s *inmemService) PostAddress(ctx context.Context, profileID string, a Address) error { - s.mtx.Lock() - defer s.mtx.Unlock() - p, ok := s.m[profileID] - if !ok { - return ErrNotFound - } - for _, address := range p.Addresses { - if address.ID == a.ID { - return ErrAlreadyExists - } - } - p.Addresses = append(p.Addresses, a) - s.m[profileID] = p - return nil -} - -func (s *inmemService) DeleteAddress(ctx context.Context, profileID string, addressID string) error { - s.mtx.Lock() - defer s.mtx.Unlock() - p, ok := s.m[profileID] - if !ok { - return ErrNotFound - } - newAddresses := make([]Address, 0, len(p.Addresses)) - for _, address := range p.Addresses { - if address.ID == addressID { - continue // delete - } - newAddresses = append(newAddresses, address) - } - if len(newAddresses) == len(p.Addresses) { - return ErrNotFound - } - p.Addresses = newAddresses - s.m[profileID] = p - return nil -} diff --git a/vendor/github.com/go-kit/kit/examples/profilesvc/transport.go b/vendor/github.com/go-kit/kit/examples/profilesvc/transport.go deleted file mode 100644 index 02d807c..0000000 --- a/vendor/github.com/go-kit/kit/examples/profilesvc/transport.go +++ /dev/null @@ -1,410 +0,0 @@ -package profilesvc - -// The profilesvc is just over HTTP, so we just have a single transport.go. - -import ( - "bytes" - "encoding/json" - "errors" - "io/ioutil" - "net/http" - - "github.com/gorilla/mux" - "golang.org/x/net/context" - - "net/url" - - "github.com/go-kit/kit/log" - httptransport "github.com/go-kit/kit/transport/http" -) - -var ( - // ErrBadRouting is returned when an expected path variable is missing. - // It always indicates programmer error. - ErrBadRouting = errors.New("inconsistent mapping between route and handler (programmer error)") -) - -// MakeHTTPHandler mounts all of the service endpoints into an http.Handler. -// Useful in a profilesvc server. -func MakeHTTPHandler(ctx context.Context, s Service, logger log.Logger) http.Handler { - r := mux.NewRouter() - e := MakeServerEndpoints(s) - options := []httptransport.ServerOption{ - httptransport.ServerErrorLogger(logger), - httptransport.ServerErrorEncoder(encodeError), - } - - // POST /profiles adds another profile - // GET /profiles/:id retrieves the given profile by id - // PUT /profiles/:id post updated profile information about the profile - // PATCH /profiles/:id partial updated profile information - // DELETE /profiles/:id remove the given profile - // GET /profiles/:id/addresses retrieve addresses associated with the profile - // GET /profiles/:id/addresses/:addressID retrieve a particular profile address - // POST /profiles/:id/addresses add a new address - // DELETE /profiles/:id/addresses/:addressID remove an address - - r.Methods("POST").Path("/profiles/").Handler(httptransport.NewServer( - ctx, - e.PostProfileEndpoint, - decodePostProfileRequest, - encodeResponse, - options..., - )) - r.Methods("GET").Path("/profiles/{id}").Handler(httptransport.NewServer( - ctx, - e.GetProfileEndpoint, - decodeGetProfileRequest, - encodeResponse, - options..., - )) - r.Methods("PUT").Path("/profiles/{id}").Handler(httptransport.NewServer( - ctx, - e.PutProfileEndpoint, - decodePutProfileRequest, - encodeResponse, - options..., - )) - r.Methods("PATCH").Path("/profiles/{id}").Handler(httptransport.NewServer( - ctx, - e.PatchProfileEndpoint, - decodePatchProfileRequest, - encodeResponse, - options..., - )) - r.Methods("DELETE").Path("/profiles/{id}").Handler(httptransport.NewServer( - ctx, - e.DeleteProfileEndpoint, - decodeDeleteProfileRequest, - encodeResponse, - options..., - )) - r.Methods("GET").Path("/profiles/{id}/addresses/").Handler(httptransport.NewServer( - ctx, - e.GetAddressesEndpoint, - decodeGetAddressesRequest, - encodeResponse, - options..., - )) - r.Methods("GET").Path("/profiles/{id}/addresses/{addressID}").Handler(httptransport.NewServer( - ctx, - e.GetAddressEndpoint, - decodeGetAddressRequest, - encodeResponse, - options..., - )) - r.Methods("POST").Path("/profiles/{id}/addresses/").Handler(httptransport.NewServer( - ctx, - e.PostAddressEndpoint, - decodePostAddressRequest, - encodeResponse, - options..., - )) - r.Methods("DELETE").Path("/profiles/{id}/addresses/{addressID}").Handler(httptransport.NewServer( - ctx, - e.DeleteAddressEndpoint, - decodeDeleteAddressRequest, - encodeResponse, - options..., - )) - return r -} - -func decodePostProfileRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - var req postProfileRequest - if e := json.NewDecoder(r.Body).Decode(&req.Profile); e != nil { - return nil, e - } - return req, nil -} - -func decodeGetProfileRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - return getProfileRequest{ID: id}, nil -} - -func decodePutProfileRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - var profile Profile - if err := json.NewDecoder(r.Body).Decode(&profile); err != nil { - return nil, err - } - return putProfileRequest{ - ID: id, - Profile: profile, - }, nil -} - -func decodePatchProfileRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - var profile Profile - if err := json.NewDecoder(r.Body).Decode(&profile); err != nil { - return nil, err - } - return patchProfileRequest{ - ID: id, - Profile: profile, - }, nil -} - -func decodeDeleteProfileRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - return deleteProfileRequest{ID: id}, nil -} - -func decodeGetAddressesRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - return getAddressesRequest{ProfileID: id}, nil -} - -func decodeGetAddressRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - addressID, ok := vars["addressID"] - if !ok { - return nil, ErrBadRouting - } - return getAddressRequest{ - ProfileID: id, - AddressID: addressID, - }, nil -} - -func decodePostAddressRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - var address Address - if err := json.NewDecoder(r.Body).Decode(&address); err != nil { - return nil, err - } - return postAddressRequest{ - ProfileID: id, - Address: address, - }, nil -} - -func decodeDeleteAddressRequest(_ context.Context, r *http.Request) (request interface{}, err error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, ErrBadRouting - } - addressID, ok := vars["addressID"] - if !ok { - return nil, ErrBadRouting - } - return deleteAddressRequest{ - ProfileID: id, - AddressID: addressID, - }, nil -} - -func encodePostProfileRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("POST").Path("/profiles/") - req.Method, req.URL.Path = "POST", url.QueryEscape("/profiles/") - return encodeRequest(ctx, req, request) -} - -func encodeGetProfileRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("GET").Path("/profiles/{id}") - r := request.(getProfileRequest) - req.Method, req.URL.Path = "GET", url.QueryEscape("/profiles/"+r.ID) - return encodeRequest(ctx, req, request) -} - -func encodePutProfileRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("PUT").Path("/profiles/{id}") - r := request.(putProfileRequest) - req.Method, req.URL.Path = "PUT", url.QueryEscape("/profiles/"+r.ID) - return encodeRequest(ctx, req, request) -} - -func encodePatchProfileRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("PATCH").Path("/profiles/{id}") - r := request.(patchProfileRequest) - req.Method, req.URL.Path = "PATCH", url.QueryEscape("/profiles/"+r.ID) - return encodeRequest(ctx, req, request) -} - -func encodeDeleteProfileRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("DELETE").Path("/profiles/{id}") - r := request.(deleteProfileRequest) - req.Method, req.URL.Path = "DELETE", url.QueryEscape("/profiles/"+r.ID) - return encodeRequest(ctx, req, request) -} - -func encodeGetAddressesRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("GET").Path("/profiles/{id}/addresses/") - r := request.(getAddressesRequest) - req.Method, req.URL.Path = "GET", url.QueryEscape("/profiles/"+r.ProfileID+"/addresses/") - return encodeRequest(ctx, req, request) -} - -func encodeGetAddressRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("GET").Path("/profiles/{id}/addresses/{addressID}") - r := request.(getAddressRequest) - req.Method, req.URL.Path = "GET", url.QueryEscape("/profiles/"+r.ProfileID+"/addresses/"+r.AddressID) - return encodeRequest(ctx, req, request) -} - -func encodePostAddressRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("POST").Path("/profiles/{id}/addresses/") - r := request.(postAddressRequest) - req.Method, req.URL.Path = "POST", url.QueryEscape("/profiles/"+r.ProfileID+"/addresses/") - return encodeRequest(ctx, req, request) -} - -func encodeDeleteAddressRequest(ctx context.Context, req *http.Request, request interface{}) error { - // r.Methods("DELETE").Path("/profiles/{id}/addresses/{addressID}") - r := request.(deleteAddressRequest) - req.Method, req.URL.Path = "DELETE", url.QueryEscape("/profiles/"+r.ProfileID+"/addresses/"+r.AddressID) - return encodeRequest(ctx, req, request) -} - -func decodePostProfileResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response postProfileResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodeGetProfileResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response getProfileResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodePutProfileResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response putProfileResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodePatchProfileResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response patchProfileResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodeDeleteProfileResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response deleteProfileResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodeGetAddressesResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response getAddressesResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodeGetAddressResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response getAddressResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodePostAddressResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response postAddressResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -func decodeDeleteAddressResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response deleteAddressResponse - err := json.NewDecoder(resp.Body).Decode(&response) - return response, err -} - -// errorer is implemented by all concrete response types that may contain -// errors. It allows us to change the HTTP response code without needing to -// trigger an endpoint (transport-level) error. For more information, read the -// big comment in endpoints.go. -type errorer interface { - error() error -} - -// encodeResponse is the common method to encode all response types to the -// client. I chose to do it this way because, since we're using JSON, there's no -// reason to provide anything more specific. It's certainly possible to -// specialize on a per-response (per-method) basis. -func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - if e, ok := response.(errorer); ok && e.error() != nil { - // Not a Go kit transport error, but a business-logic error. - // Provide those as HTTP errors. - encodeError(ctx, e.error(), w) - return nil - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - return json.NewEncoder(w).Encode(response) -} - -// encodeRequest likewise JSON-encodes the request to the HTTP request body. -// Don't use it directly as a transport/http.Client EncodeRequestFunc: -// profilesvc endpoints require mutating the HTTP method and request path. -func encodeRequest(_ context.Context, req *http.Request, request interface{}) error { - var buf bytes.Buffer - err := json.NewEncoder(&buf).Encode(request) - if err != nil { - return err - } - req.Body = ioutil.NopCloser(&buf) - return nil -} - -func encodeError(_ context.Context, err error, w http.ResponseWriter) { - if err == nil { - panic("encodeError with nil error") - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - w.WriteHeader(codeFrom(err)) - json.NewEncoder(w).Encode(map[string]interface{}{ - "error": err.Error(), - }) -} - -func codeFrom(err error) int { - switch err { - case ErrNotFound: - return http.StatusNotFound - case ErrAlreadyExists, ErrInconsistentIDs: - return http.StatusBadRequest - default: - if e, ok := err.(httptransport.Error); ok { - switch e.Domain { - case httptransport.DomainDecode: - return http.StatusBadRequest - case httptransport.DomainDo: - return http.StatusServiceUnavailable - default: - return http.StatusInternalServerError - } - } - return http.StatusInternalServerError - } -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/README.md b/vendor/github.com/go-kit/kit/examples/shipping/README.md deleted file mode 100644 index cbcc4df..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# shipping - -This example demonstrates a more real-world application consisting of multiple services. - -## Description - -The implementation is based on the container shipping domain from the [Domain Driven Design](http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215) book by Eric Evans, which was [originally](http://dddsample.sourceforge.net/) implemented in Java but has since been ported to Go. This example is a somewhat stripped down version to demonstrate the use of Go kit. The [original Go application](https://github.com/marcusolsson/goddd) is maintained separately and accompanied by an [AngularJS application](https://github.com/marcusolsson/dddelivery-angularjs) as well as a mock [routing service](https://github.com/marcusolsson/pathfinder). - -### Organization - -The application consists of three application services, `booking`, `handling` and `tracking`. Each of these is an individual Go kit service as seen in previous examples. - -- __booking__ - used by the shipping company to book and route cargos. -- __handling__ - used by our staff around the world to register whenever the cargo has been received, loaded etc. -- __tracking__ - used by the customer to track the cargo along the route - -There are also a few pure domain packages that contain some intricate business-logic. They provide domain objects and services that are used by each application service to provide interesting use-cases for the user. - -`repository` contains in-memory implementations for the repositories found in the domain packages. - -The `routing` package provides a _domain service_ that is used to query an external application for possible routes. - -## Contributing - -As with all Go kit examples you are more than welcome to contribute. If you do however, please consider contributing back to the original project as well. diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go deleted file mode 100644 index b9864d2..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go +++ /dev/null @@ -1,139 +0,0 @@ -package booking - -import ( - "time" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" -) - -type bookCargoRequest struct { - Origin location.UNLocode - Destination location.UNLocode - ArrivalDeadline time.Time -} - -type bookCargoResponse struct { - ID cargo.TrackingID `json:"tracking_id,omitempty"` - Err error `json:"error,omitempty"` -} - -func (r bookCargoResponse) error() error { return r.Err } - -func makeBookCargoEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(bookCargoRequest) - id, err := s.BookNewCargo(req.Origin, req.Destination, req.ArrivalDeadline) - return bookCargoResponse{ID: id, Err: err}, nil - } -} - -type loadCargoRequest struct { - ID cargo.TrackingID -} - -type loadCargoResponse struct { - Cargo *Cargo `json:"cargo,omitempty"` - Err error `json:"error,omitempty"` -} - -func (r loadCargoResponse) error() error { return r.Err } - -func makeLoadCargoEndpoint(bs Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(loadCargoRequest) - c, err := bs.LoadCargo(req.ID) - return loadCargoResponse{Cargo: &c, Err: err}, nil - } -} - -type requestRoutesRequest struct { - ID cargo.TrackingID -} - -type requestRoutesResponse struct { - Routes []cargo.Itinerary `json:"routes,omitempty"` - Err error `json:"error,omitempty"` -} - -func (r requestRoutesResponse) error() error { return r.Err } - -func makeRequestRoutesEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(requestRoutesRequest) - itin := s.RequestPossibleRoutesForCargo(req.ID) - return requestRoutesResponse{Routes: itin, Err: nil}, nil - } -} - -type assignToRouteRequest struct { - ID cargo.TrackingID - Itinerary cargo.Itinerary -} - -type assignToRouteResponse struct { - Err error `json:"error,omitempty"` -} - -func (r assignToRouteResponse) error() error { return r.Err } - -func makeAssignToRouteEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(assignToRouteRequest) - err := s.AssignCargoToRoute(req.ID, req.Itinerary) - return assignToRouteResponse{Err: err}, nil - } -} - -type changeDestinationRequest struct { - ID cargo.TrackingID - Destination location.UNLocode -} - -type changeDestinationResponse struct { - Err error `json:"error,omitempty"` -} - -func (r changeDestinationResponse) error() error { return r.Err } - -func makeChangeDestinationEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(changeDestinationRequest) - err := s.ChangeDestination(req.ID, req.Destination) - return changeDestinationResponse{Err: err}, nil - } -} - -type listCargosRequest struct{} - -type listCargosResponse struct { - Cargos []Cargo `json:"cargos,omitempty"` - Err error `json:"error,omitempty"` -} - -func (r listCargosResponse) error() error { return r.Err } - -func makeListCargosEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - _ = request.(listCargosRequest) - return listCargosResponse{Cargos: s.Cargos(), Err: nil}, nil - } -} - -type listLocationsRequest struct { -} - -type listLocationsResponse struct { - Locations []Location `json:"locations,omitempty"` - Err error `json:"error,omitempty"` -} - -func makeListLocationsEndpoint(s Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - _ = request.(listLocationsRequest) - return listLocationsResponse{Locations: s.Locations(), Err: nil}, nil - } -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go deleted file mode 100644 index 71feb59..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go +++ /dev/null @@ -1,95 +0,0 @@ -package booking - -import ( - "time" - - "github.com/go-kit/kit/metrics" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" -) - -type instrumentingService struct { - requestCount metrics.Counter - requestLatency metrics.TimeHistogram - Service -} - -// NewInstrumentingService returns an instance of an instrumenting Service. -func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.TimeHistogram, s Service) Service { - return &instrumentingService{ - requestCount: requestCount, - requestLatency: requestLatency, - Service: s, - } -} - -func (s *instrumentingService) BookNewCargo(origin, destination location.UNLocode, arrivalDeadline time.Time) (cargo.TrackingID, error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "book"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.BookNewCargo(origin, destination, arrivalDeadline) -} - -func (s *instrumentingService) LoadCargo(id cargo.TrackingID) (c Cargo, err error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "load"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.LoadCargo(id) -} - -func (s *instrumentingService) RequestPossibleRoutesForCargo(id cargo.TrackingID) []cargo.Itinerary { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "request_routes"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.RequestPossibleRoutesForCargo(id) -} - -func (s *instrumentingService) AssignCargoToRoute(id cargo.TrackingID, itinerary cargo.Itinerary) (err error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "assign_to_route"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.AssignCargoToRoute(id, itinerary) -} - -func (s *instrumentingService) ChangeDestination(id cargo.TrackingID, l location.UNLocode) (err error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "change_destination"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.ChangeDestination(id, l) -} - -func (s *instrumentingService) Cargos() []Cargo { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "list_cargos"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.Cargos() -} - -func (s *instrumentingService) Locations() []Location { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "list_locations"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.Locations() -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go deleted file mode 100644 index 3a04576..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go +++ /dev/null @@ -1,101 +0,0 @@ -package booking - -import ( - "time" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/log" -) - -type loggingService struct { - logger log.Logger - Service -} - -// NewLoggingService returns a new instance of a logging Service. -func NewLoggingService(logger log.Logger, s Service) Service { - return &loggingService{logger, s} -} - -func (s *loggingService) BookNewCargo(origin location.UNLocode, destination location.UNLocode, arrivalDeadline time.Time) (id cargo.TrackingID, err error) { - defer func(begin time.Time) { - s.logger.Log( - "method", "book", - "origin", origin, - "destination", destination, - "arrival_deadline", arrivalDeadline, - "took", time.Since(begin), - "err", err, - ) - }(time.Now()) - return s.Service.BookNewCargo(origin, destination, arrivalDeadline) -} - -func (s *loggingService) LoadCargo(id cargo.TrackingID) (c Cargo, err error) { - defer func(begin time.Time) { - s.logger.Log( - "method", "load", - "tracking_id", id, - "took", time.Since(begin), - "err", err, - ) - }(time.Now()) - return s.Service.LoadCargo(id) -} - -func (s *loggingService) RequestPossibleRoutesForCargo(id cargo.TrackingID) []cargo.Itinerary { - defer func(begin time.Time) { - s.logger.Log( - "method", "request_routes", - "tracking_id", id, - "took", time.Since(begin), - ) - }(time.Now()) - return s.Service.RequestPossibleRoutesForCargo(id) -} - -func (s *loggingService) AssignCargoToRoute(id cargo.TrackingID, itinerary cargo.Itinerary) (err error) { - defer func(begin time.Time) { - s.logger.Log( - "method", "assign_to_route", - "tracking_id", id, - "took", time.Since(begin), - "err", err, - ) - }(time.Now()) - return s.Service.AssignCargoToRoute(id, itinerary) -} - -func (s *loggingService) ChangeDestination(id cargo.TrackingID, l location.UNLocode) (err error) { - defer func(begin time.Time) { - s.logger.Log( - "method", "change_destination", - "tracking_id", id, - "destination", l, - "took", time.Since(begin), - "err", err, - ) - }(time.Now()) - return s.Service.ChangeDestination(id, l) -} - -func (s *loggingService) Cargos() []Cargo { - defer func(begin time.Time) { - s.logger.Log( - "method", "list_cargos", - "took", time.Since(begin), - ) - }(time.Now()) - return s.Service.Cargos() -} - -func (s *loggingService) Locations() []Location { - defer func(begin time.Time) { - s.logger.Log( - "method", "list_locations", - "took", time.Since(begin), - ) - }(time.Now()) - return s.Service.Locations() -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/service.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/service.go deleted file mode 100644 index 47605f8..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/service.go +++ /dev/null @@ -1,201 +0,0 @@ -// Package booking provides the use-case of booking a cargo. Used by views -// facing an administrator. -package booking - -import ( - "errors" - "time" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/routing" -) - -// ErrInvalidArgument is returned when one or more arguments are invalid. -var ErrInvalidArgument = errors.New("invalid argument") - -// Service is the interface that provides booking methods. -type Service interface { - // BookNewCargo registers a new cargo in the tracking system, not yet - // routed. - BookNewCargo(origin location.UNLocode, destination location.UNLocode, arrivalDeadline time.Time) (cargo.TrackingID, error) - - // LoadCargo returns a read model of a cargo. - LoadCargo(trackingID cargo.TrackingID) (Cargo, error) - - // RequestPossibleRoutesForCargo requests a list of itineraries describing - // possible routes for this cargo. - RequestPossibleRoutesForCargo(trackingID cargo.TrackingID) []cargo.Itinerary - - // AssignCargoToRoute assigns a cargo to the route specified by the - // itinerary. - AssignCargoToRoute(trackingID cargo.TrackingID, itinerary cargo.Itinerary) error - - // ChangeDestination changes the destination of a cargo. - ChangeDestination(trackingID cargo.TrackingID, unLocode location.UNLocode) error - - // Cargos returns a list of all cargos that have been booked. - Cargos() []Cargo - - // Locations returns a list of registered locations. - Locations() []Location -} - -type service struct { - cargoRepository cargo.Repository - locationRepository location.Repository - routingService routing.Service - handlingEventRepository cargo.HandlingEventRepository -} - -func (s *service) AssignCargoToRoute(id cargo.TrackingID, itinerary cargo.Itinerary) error { - if id == "" || len(itinerary.Legs) == 0 { - return ErrInvalidArgument - } - - c, err := s.cargoRepository.Find(id) - if err != nil { - return err - } - - c.AssignToRoute(itinerary) - - if err := s.cargoRepository.Store(c); err != nil { - return err - } - - return nil -} - -func (s *service) BookNewCargo(origin, destination location.UNLocode, arrivalDeadline time.Time) (cargo.TrackingID, error) { - if origin == "" || destination == "" || arrivalDeadline.IsZero() { - return "", ErrInvalidArgument - } - - id := cargo.NextTrackingID() - rs := cargo.RouteSpecification{ - Origin: origin, - Destination: destination, - ArrivalDeadline: arrivalDeadline, - } - - c := cargo.New(id, rs) - - if err := s.cargoRepository.Store(c); err != nil { - return "", err - } - - return c.TrackingID, nil -} - -func (s *service) LoadCargo(trackingID cargo.TrackingID) (Cargo, error) { - if trackingID == "" { - return Cargo{}, ErrInvalidArgument - } - - c, err := s.cargoRepository.Find(trackingID) - if err != nil { - return Cargo{}, err - } - - return assemble(c, s.handlingEventRepository), nil -} - -func (s *service) ChangeDestination(id cargo.TrackingID, destination location.UNLocode) error { - if id == "" || destination == "" { - return ErrInvalidArgument - } - - c, err := s.cargoRepository.Find(id) - if err != nil { - return err - } - - l, err := s.locationRepository.Find(destination) - if err != nil { - return err - } - - c.SpecifyNewRoute(cargo.RouteSpecification{ - Origin: c.Origin, - Destination: l.UNLocode, - ArrivalDeadline: c.RouteSpecification.ArrivalDeadline, - }) - - if err := s.cargoRepository.Store(c); err != nil { - return err - } - - return nil -} - -func (s *service) RequestPossibleRoutesForCargo(id cargo.TrackingID) []cargo.Itinerary { - if id == "" { - return nil - } - - c, err := s.cargoRepository.Find(id) - if err != nil { - return []cargo.Itinerary{} - } - - return s.routingService.FetchRoutesForSpecification(c.RouteSpecification) -} - -func (s *service) Cargos() []Cargo { - var result []Cargo - for _, c := range s.cargoRepository.FindAll() { - result = append(result, assemble(c, s.handlingEventRepository)) - } - return result -} - -func (s *service) Locations() []Location { - var result []Location - for _, v := range s.locationRepository.FindAll() { - result = append(result, Location{ - UNLocode: string(v.UNLocode), - Name: v.Name, - }) - } - return result -} - -// NewService creates a booking service with necessary dependencies. -func NewService(cr cargo.Repository, lr location.Repository, her cargo.HandlingEventRepository, rs routing.Service) Service { - return &service{ - cargoRepository: cr, - locationRepository: lr, - handlingEventRepository: her, - routingService: rs, - } -} - -// Location is a read model for booking views. -type Location struct { - UNLocode string `json:"locode"` - Name string `json:"name"` -} - -// Cargo is a read model for booking views. -type Cargo struct { - ArrivalDeadline time.Time `json:"arrival_deadline"` - Destination string `json:"destination"` - Legs []cargo.Leg `json:"legs,omitempty"` - Misrouted bool `json:"misrouted"` - Origin string `json:"origin"` - Routed bool `json:"routed"` - TrackingID string `json:"tracking_id"` -} - -func assemble(c *cargo.Cargo, her cargo.HandlingEventRepository) Cargo { - return Cargo{ - TrackingID: string(c.TrackingID), - Origin: string(c.Origin), - Destination: string(c.RouteSpecification.Destination), - Misrouted: c.Delivery.RoutingStatus == cargo.Misrouted, - Routed: !c.Itinerary.IsEmpty(), - ArrivalDeadline: c.RouteSpecification.ArrivalDeadline, - Legs: c.Itinerary.Legs, - } -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go deleted file mode 100644 index 7cf5994..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go +++ /dev/null @@ -1,201 +0,0 @@ -package booking - -import ( - "encoding/json" - "errors" - "net/http" - "time" - - "github.com/gorilla/mux" - "golang.org/x/net/context" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - kitlog "github.com/go-kit/kit/log" - kithttp "github.com/go-kit/kit/transport/http" -) - -// MakeHandler returns a handler for the booking service. -func MakeHandler(ctx context.Context, bs Service, logger kitlog.Logger) http.Handler { - opts := []kithttp.ServerOption{ - kithttp.ServerErrorLogger(logger), - kithttp.ServerErrorEncoder(encodeError), - } - - bookCargoHandler := kithttp.NewServer( - ctx, - makeBookCargoEndpoint(bs), - decodeBookCargoRequest, - encodeResponse, - opts..., - ) - loadCargoHandler := kithttp.NewServer( - ctx, - makeLoadCargoEndpoint(bs), - decodeLoadCargoRequest, - encodeResponse, - opts..., - ) - requestRoutesHandler := kithttp.NewServer( - ctx, - makeRequestRoutesEndpoint(bs), - decodeRequestRoutesRequest, - encodeResponse, - opts..., - ) - assignToRouteHandler := kithttp.NewServer( - ctx, - makeAssignToRouteEndpoint(bs), - decodeAssignToRouteRequest, - encodeResponse, - opts..., - ) - changeDestinationHandler := kithttp.NewServer( - ctx, - makeChangeDestinationEndpoint(bs), - decodeChangeDestinationRequest, - encodeResponse, - opts..., - ) - listCargosHandler := kithttp.NewServer( - ctx, - makeListCargosEndpoint(bs), - decodeListCargosRequest, - encodeResponse, - opts..., - ) - listLocationsHandler := kithttp.NewServer( - ctx, - makeListLocationsEndpoint(bs), - decodeListLocationsRequest, - encodeResponse, - opts..., - ) - - r := mux.NewRouter() - - r.Handle("/booking/v1/cargos", bookCargoHandler).Methods("POST") - r.Handle("/booking/v1/cargos", listCargosHandler).Methods("GET") - r.Handle("/booking/v1/cargos/{id}", loadCargoHandler).Methods("GET") - r.Handle("/booking/v1/cargos/{id}/request_routes", requestRoutesHandler).Methods("GET") - r.Handle("/booking/v1/cargos/{id}/assign_to_route", assignToRouteHandler).Methods("POST") - r.Handle("/booking/v1/cargos/{id}/change_destination", changeDestinationHandler).Methods("POST") - r.Handle("/booking/v1/locations", listLocationsHandler).Methods("GET") - r.Handle("/booking/v1/docs", http.StripPrefix("/booking/v1/docs", http.FileServer(http.Dir("booking/docs")))) - - return r -} - -var errBadRoute = errors.New("bad route") - -func decodeBookCargoRequest(_ context.Context, r *http.Request) (interface{}, error) { - var body struct { - Origin string `json:"origin"` - Destination string `json:"destination"` - ArrivalDeadline time.Time `json:"arrival_deadline"` - } - - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { - return nil, err - } - - return bookCargoRequest{ - Origin: location.UNLocode(body.Origin), - Destination: location.UNLocode(body.Destination), - ArrivalDeadline: body.ArrivalDeadline, - }, nil -} - -func decodeLoadCargoRequest(_ context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, errBadRoute - } - return loadCargoRequest{ID: cargo.TrackingID(id)}, nil -} - -func decodeRequestRoutesRequest(_ context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, errBadRoute - } - return requestRoutesRequest{ID: cargo.TrackingID(id)}, nil -} - -func decodeAssignToRouteRequest(_ context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, errBadRoute - } - - var itinerary cargo.Itinerary - if err := json.NewDecoder(r.Body).Decode(&itinerary); err != nil { - return nil, err - } - - return assignToRouteRequest{ - ID: cargo.TrackingID(id), - Itinerary: itinerary, - }, nil -} - -func decodeChangeDestinationRequest(_ context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, errBadRoute - } - - var body struct { - Destination string `json:"destination"` - } - - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { - return nil, err - } - - return changeDestinationRequest{ - ID: cargo.TrackingID(id), - Destination: location.UNLocode(body.Destination), - }, nil -} - -func decodeListCargosRequest(_ context.Context, r *http.Request) (interface{}, error) { - return listCargosRequest{}, nil -} - -func decodeListLocationsRequest(_ context.Context, r *http.Request) (interface{}, error) { - return listLocationsRequest{}, nil -} - -func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - if e, ok := response.(errorer); ok && e.error() != nil { - encodeError(ctx, e.error(), w) - return nil - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - return json.NewEncoder(w).Encode(response) -} - -type errorer interface { - error() error -} - -// encode errors from business-logic -func encodeError(_ context.Context, err error, w http.ResponseWriter) { - switch err { - case cargo.ErrUnknown: - w.WriteHeader(http.StatusNotFound) - case ErrInvalidArgument: - w.WriteHeader(http.StatusBadRequest) - default: - w.WriteHeader(http.StatusInternalServerError) - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - json.NewEncoder(w).Encode(map[string]interface{}{ - "error": err.Error(), - }) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go b/vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go deleted file mode 100644 index d4bb5f4..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go +++ /dev/null @@ -1,137 +0,0 @@ -// Package cargo contains the heart of the domain model. -package cargo - -import ( - "errors" - "strings" - "time" - - "github.com/pborman/uuid" - - "github.com/go-kit/kit/examples/shipping/location" -) - -// TrackingID uniquely identifies a particular cargo. -type TrackingID string - -// Cargo is the central class in the domain model. -type Cargo struct { - TrackingID TrackingID - Origin location.UNLocode - RouteSpecification RouteSpecification - Itinerary Itinerary - Delivery Delivery -} - -// SpecifyNewRoute specifies a new route for this cargo. -func (c *Cargo) SpecifyNewRoute(rs RouteSpecification) { - c.RouteSpecification = rs - c.Delivery = c.Delivery.UpdateOnRouting(c.RouteSpecification, c.Itinerary) -} - -// AssignToRoute attaches a new itinerary to this cargo. -func (c *Cargo) AssignToRoute(itinerary Itinerary) { - c.Itinerary = itinerary - c.Delivery = c.Delivery.UpdateOnRouting(c.RouteSpecification, c.Itinerary) -} - -// DeriveDeliveryProgress updates all aspects of the cargo aggregate status -// based on the current route specification, itinerary and handling of the cargo. -func (c *Cargo) DeriveDeliveryProgress(history HandlingHistory) { - c.Delivery = DeriveDeliveryFrom(c.RouteSpecification, c.Itinerary, history) -} - -// New creates a new, unrouted cargo. -func New(id TrackingID, rs RouteSpecification) *Cargo { - itinerary := Itinerary{} - history := HandlingHistory{make([]HandlingEvent, 0)} - - return &Cargo{ - TrackingID: id, - Origin: rs.Origin, - RouteSpecification: rs, - Delivery: DeriveDeliveryFrom(rs, itinerary, history), - } -} - -// Repository provides access a cargo store. -type Repository interface { - Store(cargo *Cargo) error - Find(trackingID TrackingID) (*Cargo, error) - FindAll() []*Cargo -} - -// ErrUnknown is used when a cargo could not be found. -var ErrUnknown = errors.New("unknown cargo") - -// NextTrackingID generates a new tracking ID. -// TODO: Move to infrastructure(?) -func NextTrackingID() TrackingID { - return TrackingID(strings.Split(strings.ToUpper(uuid.New()), "-")[0]) -} - -// RouteSpecification Contains information about a route: its origin, -// destination and arrival deadline. -type RouteSpecification struct { - Origin location.UNLocode - Destination location.UNLocode - ArrivalDeadline time.Time -} - -// IsSatisfiedBy checks whether provided itinerary satisfies this -// specification. -func (s RouteSpecification) IsSatisfiedBy(itinerary Itinerary) bool { - return itinerary.Legs != nil && - s.Origin == itinerary.InitialDepartureLocation() && - s.Destination == itinerary.FinalArrivalLocation() -} - -// RoutingStatus describes status of cargo routing. -type RoutingStatus int - -// Valid routing statuses. -const ( - NotRouted RoutingStatus = iota - Misrouted - Routed -) - -func (s RoutingStatus) String() string { - switch s { - case NotRouted: - return "Not routed" - case Misrouted: - return "Misrouted" - case Routed: - return "Routed" - } - return "" -} - -// TransportStatus describes status of cargo transportation. -type TransportStatus int - -// Valid transport statuses. -const ( - NotReceived TransportStatus = iota - InPort - OnboardCarrier - Claimed - Unknown -) - -func (s TransportStatus) String() string { - switch s { - case NotReceived: - return "Not received" - case InPort: - return "In port" - case OnboardCarrier: - return "Onboard carrier" - case Claimed: - return "Claimed" - case Unknown: - return "Unknown" - } - return "" -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/cargo/delivery.go b/vendor/github.com/go-kit/kit/examples/shipping/cargo/delivery.go deleted file mode 100644 index 34f079d..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/cargo/delivery.go +++ /dev/null @@ -1,174 +0,0 @@ -package cargo - -import ( - "time" - - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" -) - -// Delivery is the actual transportation of the cargo, as opposed to the -// customer requirement (RouteSpecification) and the plan (Itinerary). -type Delivery struct { - Itinerary Itinerary - RouteSpecification RouteSpecification - RoutingStatus RoutingStatus - TransportStatus TransportStatus - NextExpectedActivity HandlingActivity - LastEvent HandlingEvent - LastKnownLocation location.UNLocode - CurrentVoyage voyage.Number - ETA time.Time - IsMisdirected bool - IsUnloadedAtDestination bool -} - -// UpdateOnRouting creates a new delivery snapshot to reflect changes in -// routing, i.e. when the route specification or the itinerary has changed but -// no additional handling of the cargo has been performed. -func (d Delivery) UpdateOnRouting(rs RouteSpecification, itinerary Itinerary) Delivery { - return newDelivery(d.LastEvent, itinerary, rs) -} - -// IsOnTrack checks if the delivery is on track. -func (d Delivery) IsOnTrack() bool { - return d.RoutingStatus == Routed && !d.IsMisdirected -} - -// DeriveDeliveryFrom creates a new delivery snapshot based on the complete -// handling history of a cargo, as well as its route specification and -// itinerary. -func DeriveDeliveryFrom(rs RouteSpecification, itinerary Itinerary, history HandlingHistory) Delivery { - lastEvent, _ := history.MostRecentlyCompletedEvent() - return newDelivery(lastEvent, itinerary, rs) -} - -// newDelivery creates a up-to-date delivery based on an handling event, -// itinerary and a route specification. -func newDelivery(lastEvent HandlingEvent, itinerary Itinerary, rs RouteSpecification) Delivery { - var ( - routingStatus = calculateRoutingStatus(itinerary, rs) - transportStatus = calculateTransportStatus(lastEvent) - lastKnownLocation = calculateLastKnownLocation(lastEvent) - isMisdirected = calculateMisdirectedStatus(lastEvent, itinerary) - isUnloadedAtDestination = calculateUnloadedAtDestination(lastEvent, rs) - currentVoyage = calculateCurrentVoyage(transportStatus, lastEvent) - ) - - d := Delivery{ - LastEvent: lastEvent, - Itinerary: itinerary, - RouteSpecification: rs, - RoutingStatus: routingStatus, - TransportStatus: transportStatus, - LastKnownLocation: lastKnownLocation, - IsMisdirected: isMisdirected, - IsUnloadedAtDestination: isUnloadedAtDestination, - CurrentVoyage: currentVoyage, - } - - d.NextExpectedActivity = calculateNextExpectedActivity(d) - d.ETA = calculateETA(d) - - return d -} - -// Below are internal functions used when creating a new delivery. - -func calculateRoutingStatus(itinerary Itinerary, rs RouteSpecification) RoutingStatus { - if itinerary.Legs == nil { - return NotRouted - } - - if rs.IsSatisfiedBy(itinerary) { - return Routed - } - - return Misrouted -} - -func calculateMisdirectedStatus(event HandlingEvent, itinerary Itinerary) bool { - if event.Activity.Type == NotHandled { - return false - } - - return !itinerary.IsExpected(event) -} - -func calculateUnloadedAtDestination(event HandlingEvent, rs RouteSpecification) bool { - if event.Activity.Type == NotHandled { - return false - } - - return event.Activity.Type == Unload && rs.Destination == event.Activity.Location -} - -func calculateTransportStatus(event HandlingEvent) TransportStatus { - switch event.Activity.Type { - case NotHandled: - return NotReceived - case Load: - return OnboardCarrier - case Unload: - return InPort - case Receive: - return InPort - case Customs: - return InPort - case Claim: - return Claimed - } - return Unknown -} - -func calculateLastKnownLocation(event HandlingEvent) location.UNLocode { - return event.Activity.Location -} - -func calculateNextExpectedActivity(d Delivery) HandlingActivity { - if !d.IsOnTrack() { - return HandlingActivity{} - } - - switch d.LastEvent.Activity.Type { - case NotHandled: - return HandlingActivity{Type: Receive, Location: d.RouteSpecification.Origin} - case Receive: - l := d.Itinerary.Legs[0] - return HandlingActivity{Type: Load, Location: l.LoadLocation, VoyageNumber: l.VoyageNumber} - case Load: - for _, l := range d.Itinerary.Legs { - if l.LoadLocation == d.LastEvent.Activity.Location { - return HandlingActivity{Type: Unload, Location: l.UnloadLocation, VoyageNumber: l.VoyageNumber} - } - } - case Unload: - for i, l := range d.Itinerary.Legs { - if l.UnloadLocation == d.LastEvent.Activity.Location { - if i < len(d.Itinerary.Legs)-1 { - return HandlingActivity{Type: Load, Location: d.Itinerary.Legs[i+1].LoadLocation, VoyageNumber: d.Itinerary.Legs[i+1].VoyageNumber} - } - - return HandlingActivity{Type: Claim, Location: l.UnloadLocation} - } - } - } - - return HandlingActivity{} -} - -func calculateCurrentVoyage(transportStatus TransportStatus, event HandlingEvent) voyage.Number { - if transportStatus == OnboardCarrier && event.Activity.Type != NotHandled { - return event.Activity.VoyageNumber - } - - return voyage.Number("") -} - -func calculateETA(d Delivery) time.Time { - if !d.IsOnTrack() { - return time.Time{} - } - - return d.Itinerary.FinalArrivalTime() -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go b/vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go deleted file mode 100644 index 5f77bc4..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go +++ /dev/null @@ -1,121 +0,0 @@ -package cargo - -// TODO: It would make sense to have this in its own package. Unfortunately, -// then there would be a circular dependency between the cargo and handling -// packages since cargo.Delivery would use handling.HandlingEvent and -// handling.HandlingEvent would use cargo.TrackingID. Also, -// HandlingEventFactory depends on the cargo repository. -// -// It would make sense not having the cargo package depend on handling. - -import ( - "errors" - "time" - - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" -) - -// HandlingActivity represents how and where a cargo can be handled, and can -// be used to express predictions about what is expected to happen to a cargo -// in the future. -type HandlingActivity struct { - Type HandlingEventType - Location location.UNLocode - VoyageNumber voyage.Number -} - -// HandlingEvent is used to register the event when, for instance, a cargo is -// unloaded from a carrier at a some location at a given time. -type HandlingEvent struct { - TrackingID TrackingID - Activity HandlingActivity -} - -// HandlingEventType describes type of a handling event. -type HandlingEventType int - -// Valid handling event types. -const ( - NotHandled HandlingEventType = iota - Load - Unload - Receive - Claim - Customs -) - -func (t HandlingEventType) String() string { - switch t { - case NotHandled: - return "Not Handled" - case Load: - return "Load" - case Unload: - return "Unload" - case Receive: - return "Receive" - case Claim: - return "Claim" - case Customs: - return "Customs" - } - - return "" -} - -// HandlingHistory is the handling history of a cargo. -type HandlingHistory struct { - HandlingEvents []HandlingEvent -} - -// MostRecentlyCompletedEvent returns most recently completed handling event. -func (h HandlingHistory) MostRecentlyCompletedEvent() (HandlingEvent, error) { - if len(h.HandlingEvents) == 0 { - return HandlingEvent{}, errors.New("delivery history is empty") - } - - return h.HandlingEvents[len(h.HandlingEvents)-1], nil -} - -// HandlingEventRepository provides access a handling event store. -type HandlingEventRepository interface { - Store(e HandlingEvent) - QueryHandlingHistory(TrackingID) HandlingHistory -} - -// HandlingEventFactory creates handling events. -type HandlingEventFactory struct { - CargoRepository Repository - VoyageRepository voyage.Repository - LocationRepository location.Repository -} - -// CreateHandlingEvent creates a validated handling event. -func (f *HandlingEventFactory) CreateHandlingEvent(registrationTime time.Time, completionTime time.Time, trackingID TrackingID, - voyageNumber voyage.Number, unLocode location.UNLocode, eventType HandlingEventType) (HandlingEvent, error) { - - if _, err := f.CargoRepository.Find(trackingID); err != nil { - return HandlingEvent{}, err - } - - if _, err := f.VoyageRepository.Find(voyageNumber); err != nil { - // TODO: This is pretty ugly, but when creating a Receive event, the voyage number is not known. - if len(voyageNumber) > 0 { - return HandlingEvent{}, err - } - } - - if _, err := f.LocationRepository.Find(unLocode); err != nil { - return HandlingEvent{}, err - } - - return HandlingEvent{ - TrackingID: trackingID, - Activity: HandlingActivity{ - Type: eventType, - Location: unLocode, - VoyageNumber: voyageNumber, - }, - }, nil -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/cargo/itinerary.go b/vendor/github.com/go-kit/kit/examples/shipping/cargo/itinerary.go deleted file mode 100644 index 6b5088e..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/cargo/itinerary.go +++ /dev/null @@ -1,91 +0,0 @@ -package cargo - -import ( - "time" - - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" -) - -// Leg describes the transportation between two locations on a voyage. -type Leg struct { - VoyageNumber voyage.Number `json:"voyage_number"` - LoadLocation location.UNLocode `json:"from"` - UnloadLocation location.UNLocode `json:"to"` - LoadTime time.Time `json:"load_time"` - UnloadTime time.Time `json:"unload_time"` -} - -// NewLeg creates a new itinerary leg. -func NewLeg(voyageNumber voyage.Number, loadLocation, unloadLocation location.UNLocode, loadTime, unloadTime time.Time) Leg { - return Leg{ - VoyageNumber: voyageNumber, - LoadLocation: loadLocation, - UnloadLocation: unloadLocation, - LoadTime: loadTime, - UnloadTime: unloadTime, - } -} - -// Itinerary specifies steps required to transport a cargo from its origin to -// destination. -type Itinerary struct { - Legs []Leg `json:"legs"` -} - -// InitialDepartureLocation returns the start of the itinerary. -func (i Itinerary) InitialDepartureLocation() location.UNLocode { - if i.IsEmpty() { - return location.UNLocode("") - } - return i.Legs[0].LoadLocation -} - -// FinalArrivalLocation returns the end of the itinerary. -func (i Itinerary) FinalArrivalLocation() location.UNLocode { - if i.IsEmpty() { - return location.UNLocode("") - } - return i.Legs[len(i.Legs)-1].UnloadLocation -} - -// FinalArrivalTime returns the expected arrival time at final destination. -func (i Itinerary) FinalArrivalTime() time.Time { - return i.Legs[len(i.Legs)-1].UnloadTime -} - -// IsEmpty checks if the itinerary contains at least one leg. -func (i Itinerary) IsEmpty() bool { - return i.Legs == nil || len(i.Legs) == 0 -} - -// IsExpected checks if the given handling event is expected when executing -// this itinerary. -func (i Itinerary) IsExpected(event HandlingEvent) bool { - if i.IsEmpty() { - return true - } - - switch event.Activity.Type { - case Receive: - return i.InitialDepartureLocation() == event.Activity.Location - case Load: - for _, l := range i.Legs { - if l.LoadLocation == event.Activity.Location && l.VoyageNumber == event.Activity.VoyageNumber { - return true - } - } - return false - case Unload: - for _, l := range i.Legs { - if l.UnloadLocation == event.Activity.Location && l.VoyageNumber == event.Activity.VoyageNumber { - return true - } - } - return false - case Claim: - return i.FinalArrivalLocation() == event.Activity.Location - } - - return true -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go deleted file mode 100644 index e10bdda..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go +++ /dev/null @@ -1,34 +0,0 @@ -package handling - -import ( - "time" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" -) - -type registerIncidentRequest struct { - ID cargo.TrackingID - Location location.UNLocode - Voyage voyage.Number - EventType cargo.HandlingEventType - CompletionTime time.Time -} - -type registerIncidentResponse struct { - Err error `json:"error,omitempty"` -} - -func (r registerIncidentResponse) error() error { return r.Err } - -func makeRegisterIncidentEndpoint(hs Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(registerIncidentRequest) - err := hs.RegisterHandlingEvent(req.CompletionTime, req.ID, req.Voyage, req.Location, req.EventType) - return registerIncidentResponse{Err: err}, nil - } -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go deleted file mode 100644 index 1d1d6da..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go +++ /dev/null @@ -1,38 +0,0 @@ -package handling - -import ( - "time" - - "github.com/go-kit/kit/metrics" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" -) - -type instrumentingService struct { - requestCount metrics.Counter - requestLatency metrics.TimeHistogram - Service -} - -// NewInstrumentingService returns an instance of an instrumenting Service. -func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.TimeHistogram, s Service) Service { - return &instrumentingService{ - requestCount: requestCount, - requestLatency: requestLatency, - Service: s, - } -} - -func (s *instrumentingService) RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyage voyage.Number, - loc location.UNLocode, eventType cargo.HandlingEventType) error { - - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "register_incident"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.RegisterHandlingEvent(completionTime, trackingID, voyage, loc, eventType) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go deleted file mode 100644 index 26457ac..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go +++ /dev/null @@ -1,37 +0,0 @@ -package handling - -import ( - "time" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" - "github.com/go-kit/kit/log" -) - -type loggingService struct { - logger log.Logger - Service -} - -// NewLoggingService returns a new instance of a logging Service. -func NewLoggingService(logger log.Logger, s Service) Service { - return &loggingService{logger, s} -} - -func (s *loggingService) RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyageNumber voyage.Number, - unLocode location.UNLocode, eventType cargo.HandlingEventType) (err error) { - defer func(begin time.Time) { - s.logger.Log( - "method", "register_incident", - "tracking_id", trackingID, - "location", unLocode, - "voyage", voyageNumber, - "event_type", eventType, - "completion_time", completionTime, - "took", time.Since(begin), - "err", err, - ) - }(time.Now()) - return s.Service.RegisterHandlingEvent(completionTime, trackingID, voyageNumber, unLocode, eventType) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/service.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/service.go deleted file mode 100644 index f548f4c..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/service.go +++ /dev/null @@ -1,76 +0,0 @@ -// Package handling provides the use-case for registering incidents. Used by -// views facing the people handling the cargo along its route. -package handling - -import ( - "errors" - "time" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/inspection" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" -) - -// ErrInvalidArgument is returned when one or more arguments are invalid. -var ErrInvalidArgument = errors.New("invalid argument") - -// EventHandler provides a means of subscribing to registered handling events. -type EventHandler interface { - CargoWasHandled(cargo.HandlingEvent) -} - -// Service provides handling operations. -type Service interface { - // RegisterHandlingEvent registers a handling event in the system, and - // notifies interested parties that a cargo has been handled. - RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyageNumber voyage.Number, - unLocode location.UNLocode, eventType cargo.HandlingEventType) error -} - -type service struct { - handlingEventRepository cargo.HandlingEventRepository - handlingEventFactory cargo.HandlingEventFactory - handlingEventHandler EventHandler -} - -func (s *service) RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyage voyage.Number, - loc location.UNLocode, eventType cargo.HandlingEventType) error { - if completionTime.IsZero() || trackingID == "" || loc == "" || eventType == cargo.NotHandled { - return ErrInvalidArgument - } - - e, err := s.handlingEventFactory.CreateHandlingEvent(time.Now(), completionTime, trackingID, voyage, loc, eventType) - if err != nil { - return err - } - - s.handlingEventRepository.Store(e) - s.handlingEventHandler.CargoWasHandled(e) - - return nil -} - -// NewService creates a handling event service with necessary dependencies. -func NewService(r cargo.HandlingEventRepository, f cargo.HandlingEventFactory, h EventHandler) Service { - return &service{ - handlingEventRepository: r, - handlingEventFactory: f, - handlingEventHandler: h, - } -} - -type handlingEventHandler struct { - InspectionService inspection.Service -} - -func (h *handlingEventHandler) CargoWasHandled(event cargo.HandlingEvent) { - h.InspectionService.InspectCargo(event.TrackingID) -} - -// NewEventHandler returns a new instance of a EventHandler. -func NewEventHandler(s inspection.Service) EventHandler { - return &handlingEventHandler{ - InspectionService: s, - } -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go deleted file mode 100644 index 1777ad6..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go +++ /dev/null @@ -1,100 +0,0 @@ -package handling - -import ( - "encoding/json" - "net/http" - "time" - - "github.com/gorilla/mux" - "golang.org/x/net/context" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" - kitlog "github.com/go-kit/kit/log" - kithttp "github.com/go-kit/kit/transport/http" -) - -// MakeHandler returns a handler for the handling service. -func MakeHandler(ctx context.Context, hs Service, logger kitlog.Logger) http.Handler { - r := mux.NewRouter() - - opts := []kithttp.ServerOption{ - kithttp.ServerErrorLogger(logger), - kithttp.ServerErrorEncoder(encodeError), - } - - registerIncidentHandler := kithttp.NewServer( - ctx, - makeRegisterIncidentEndpoint(hs), - decodeRegisterIncidentRequest, - encodeResponse, - opts..., - ) - - r.Handle("/handling/v1/incidents", registerIncidentHandler).Methods("POST") - - return r -} - -func decodeRegisterIncidentRequest(_ context.Context, r *http.Request) (interface{}, error) { - var body struct { - CompletionTime time.Time `json:"completion_time"` - TrackingID string `json:"tracking_id"` - VoyageNumber string `json:"voyage"` - Location string `json:"location"` - EventType string `json:"event_type"` - } - - if err := json.NewDecoder(r.Body).Decode(&body); err != nil { - return nil, err - } - - return registerIncidentRequest{ - CompletionTime: body.CompletionTime, - ID: cargo.TrackingID(body.TrackingID), - Voyage: voyage.Number(body.VoyageNumber), - Location: location.UNLocode(body.Location), - EventType: stringToEventType(body.EventType), - }, nil -} - -func stringToEventType(s string) cargo.HandlingEventType { - types := map[string]cargo.HandlingEventType{ - cargo.Receive.String(): cargo.Receive, - cargo.Load.String(): cargo.Load, - cargo.Unload.String(): cargo.Unload, - cargo.Customs.String(): cargo.Customs, - cargo.Claim.String(): cargo.Claim, - } - return types[s] -} - -func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - if e, ok := response.(errorer); ok && e.error() != nil { - encodeError(ctx, e.error(), w) - return nil - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - return json.NewEncoder(w).Encode(response) -} - -type errorer interface { - error() error -} - -// encode errors from business-logic -func encodeError(_ context.Context, err error, w http.ResponseWriter) { - switch err { - case cargo.ErrUnknown: - w.WriteHeader(http.StatusNotFound) - case ErrInvalidArgument: - w.WriteHeader(http.StatusBadRequest) - default: - w.WriteHeader(http.StatusInternalServerError) - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - json.NewEncoder(w).Encode(map[string]interface{}{ - "error": err.Error(), - }) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go b/vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go deleted file mode 100644 index a3f7147..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go +++ /dev/null @@ -1,51 +0,0 @@ -// Package inspection provides means to inspect cargos. -package inspection - -import "github.com/go-kit/kit/examples/shipping/cargo" - -// EventHandler provides means of subscribing to inspection events. -type EventHandler interface { - CargoWasMisdirected(*cargo.Cargo) - CargoHasArrived(*cargo.Cargo) -} - -// Service provides cargo inspection operations. -type Service interface { - // InspectCargo inspects cargo and send relevant notifications to - // interested parties, for example if a cargo has been misdirected, or - // unloaded at the final destination. - InspectCargo(trackingID cargo.TrackingID) -} - -type service struct { - cargoRepository cargo.Repository - handlingEventRepository cargo.HandlingEventRepository - cargoEventHandler EventHandler -} - -// TODO: Should be transactional -func (s *service) InspectCargo(trackingID cargo.TrackingID) { - c, err := s.cargoRepository.Find(trackingID) - if err != nil { - return - } - - h := s.handlingEventRepository.QueryHandlingHistory(trackingID) - - c.DeriveDeliveryProgress(h) - - if c.Delivery.IsMisdirected { - s.cargoEventHandler.CargoWasMisdirected(c) - } - - if c.Delivery.IsUnloadedAtDestination { - s.cargoEventHandler.CargoHasArrived(c) - } - - s.cargoRepository.Store(c) -} - -// NewService creates a inspection service with necessary dependencies. -func NewService(cargoRepository cargo.Repository, handlingEventRepository cargo.HandlingEventRepository, eventHandler EventHandler) Service { - return &service{cargoRepository, handlingEventRepository, eventHandler} -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/location/location.go b/vendor/github.com/go-kit/kit/examples/shipping/location/location.go deleted file mode 100644 index 5129380..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/location/location.go +++ /dev/null @@ -1,27 +0,0 @@ -// Package location provides the Location aggregate. -package location - -import "errors" - -// UNLocode is the United Nations location code that uniquely identifies a -// particular location. -// -// http://www.unece.org/cefact/locode/ -// http://www.unece.org/cefact/locode/DocColumnDescription.htm#LOCODE -type UNLocode string - -// Location is a location is our model is stops on a journey, such as cargo -// origin or destination, or carrier movement endpoints. -type Location struct { - UNLocode UNLocode - Name string -} - -// ErrUnknown is used when a location could not be found. -var ErrUnknown = errors.New("unknown location") - -// Repository provides access a location store. -type Repository interface { - Find(locode UNLocode) (Location, error) - FindAll() []Location -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go b/vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go deleted file mode 100644 index de0d4c1..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go +++ /dev/null @@ -1,27 +0,0 @@ -package location - -// Sample UN locodes. -var ( - SESTO UNLocode = "SESTO" - AUMEL UNLocode = "AUMEL" - CNHKG UNLocode = "CNHKG" - USNYC UNLocode = "USNYC" - USCHI UNLocode = "USCHI" - JNTKO UNLocode = "JNTKO" - DEHAM UNLocode = "DEHAM" - NLRTM UNLocode = "NLRTM" - FIHEL UNLocode = "FIHEL" -) - -// Sample locations. -var ( - Stockholm = Location{SESTO, "Stockholm"} - Melbourne = Location{AUMEL, "Melbourne"} - Hongkong = Location{CNHKG, "Hongkong"} - NewYork = Location{USNYC, "New York"} - Chicago = Location{USCHI, "Chicago"} - Tokyo = Location{JNTKO, "Tokyo"} - Hamburg = Location{DEHAM, "Hamburg"} - Rotterdam = Location{NLRTM, "Rotterdam"} - Helsinki = Location{FIHEL, "Helsinki"} -) diff --git a/vendor/github.com/go-kit/kit/examples/shipping/main.go b/vendor/github.com/go-kit/kit/examples/shipping/main.go deleted file mode 100644 index 98a081c..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/main.go +++ /dev/null @@ -1,203 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "net/http" - "os" - "os/signal" - "sync" - "syscall" - "time" - - stdprometheus "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics" - kitprometheus "github.com/go-kit/kit/metrics/prometheus" - - "github.com/go-kit/kit/examples/shipping/booking" - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/handling" - "github.com/go-kit/kit/examples/shipping/inspection" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/repository" - "github.com/go-kit/kit/examples/shipping/routing" - "github.com/go-kit/kit/examples/shipping/tracking" -) - -const ( - defaultPort = "8080" - defaultRoutingServiceURL = "http://localhost:7878" -) - -func main() { - var ( - addr = envString("PORT", defaultPort) - rsurl = envString("ROUTINGSERVICE_URL", defaultRoutingServiceURL) - - httpAddr = flag.String("http.addr", ":"+addr, "HTTP listen address") - routingServiceURL = flag.String("service.routing", rsurl, "routing service URL") - - ctx = context.Background() - ) - - flag.Parse() - - var logger log.Logger - logger = log.NewLogfmtLogger(os.Stderr) - logger = &serializedLogger{Logger: logger} - logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) - - var ( - cargos = repository.NewCargo() - locations = repository.NewLocation() - voyages = repository.NewVoyage() - handlingEvents = repository.NewHandlingEvent() - ) - - // Configure some questionable dependencies. - var ( - handlingEventFactory = cargo.HandlingEventFactory{ - CargoRepository: cargos, - VoyageRepository: voyages, - LocationRepository: locations, - } - handlingEventHandler = handling.NewEventHandler( - inspection.NewService(cargos, handlingEvents, nil), - ) - ) - - // Facilitate testing by adding some cargos. - storeTestData(cargos) - - fieldKeys := []string{"method"} - - var rs routing.Service - rs = routing.NewProxyingMiddleware(*routingServiceURL, ctx)(rs) - - var bs booking.Service - bs = booking.NewService(cargos, locations, handlingEvents, rs) - bs = booking.NewLoggingService(log.NewContext(logger).With("component", "booking"), bs) - bs = booking.NewInstrumentingService( - kitprometheus.NewCounter(stdprometheus.CounterOpts{ - Namespace: "api", - Subsystem: "booking_service", - Name: "request_count", - Help: "Number of requests received.", - }, fieldKeys), - metrics.NewTimeHistogram(time.Microsecond, kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "api", - Subsystem: "booking_service", - Name: "request_latency_microseconds", - Help: "Total duration of requests in microseconds.", - }, fieldKeys)), bs) - - var ts tracking.Service - ts = tracking.NewService(cargos, handlingEvents) - ts = tracking.NewLoggingService(log.NewContext(logger).With("component", "tracking"), ts) - ts = tracking.NewInstrumentingService( - kitprometheus.NewCounter(stdprometheus.CounterOpts{ - Namespace: "api", - Subsystem: "tracking_service", - Name: "request_count", - Help: "Number of requests received.", - }, fieldKeys), - metrics.NewTimeHistogram(time.Microsecond, kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "api", - Subsystem: "tracking_service", - Name: "request_latency_microseconds", - Help: "Total duration of requests in microseconds.", - }, fieldKeys)), ts) - - var hs handling.Service - hs = handling.NewService(handlingEvents, handlingEventFactory, handlingEventHandler) - hs = handling.NewLoggingService(log.NewContext(logger).With("component", "handling"), hs) - hs = handling.NewInstrumentingService( - kitprometheus.NewCounter(stdprometheus.CounterOpts{ - Namespace: "api", - Subsystem: "handling_service", - Name: "request_count", - Help: "Number of requests received.", - }, fieldKeys), - metrics.NewTimeHistogram(time.Microsecond, kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "api", - Subsystem: "handling_service", - Name: "request_latency_microseconds", - Help: "Total duration of requests in microseconds.", - }, fieldKeys)), hs) - - httpLogger := log.NewContext(logger).With("component", "http") - - mux := http.NewServeMux() - - mux.Handle("/booking/v1/", booking.MakeHandler(ctx, bs, httpLogger)) - mux.Handle("/tracking/v1/", tracking.MakeHandler(ctx, ts, httpLogger)) - mux.Handle("/handling/v1/", handling.MakeHandler(ctx, hs, httpLogger)) - - http.Handle("/", accessControl(mux)) - http.Handle("/metrics", stdprometheus.Handler()) - - errs := make(chan error, 2) - go func() { - logger.Log("transport", "http", "address", *httpAddr, "msg", "listening") - errs <- http.ListenAndServe(*httpAddr, nil) - }() - go func() { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGINT) - errs <- fmt.Errorf("%s", <-c) - }() - - logger.Log("terminated", <-errs) -} - -func accessControl(h http.Handler) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Access-Control-Allow-Origin", "*") - w.Header().Set("Access-Control-Allow-Methods", "GET, POST, OPTIONS") - w.Header().Set("Access-Control-Allow-Headers", "Origin, Content-Type") - - if r.Method == "OPTIONS" { - return - } - - h.ServeHTTP(w, r) - }) -} - -func envString(env, fallback string) string { - e := os.Getenv(env) - if e == "" { - return fallback - } - return e -} - -func storeTestData(r cargo.Repository) { - test1 := cargo.New("FTL456", cargo.RouteSpecification{ - Origin: location.AUMEL, - Destination: location.SESTO, - ArrivalDeadline: time.Now().AddDate(0, 0, 7), - }) - _ = r.Store(test1) - - test2 := cargo.New("ABC123", cargo.RouteSpecification{ - Origin: location.SESTO, - Destination: location.CNHKG, - ArrivalDeadline: time.Now().AddDate(0, 0, 14), - }) - _ = r.Store(test2) -} - -type serializedLogger struct { - mtx sync.Mutex - log.Logger -} - -func (l *serializedLogger) Log(keyvals ...interface{}) error { - l.mtx.Lock() - defer l.mtx.Unlock() - return l.Logger.Log(keyvals...) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/repository/repositories.go b/vendor/github.com/go-kit/kit/examples/shipping/repository/repositories.go deleted file mode 100644 index 714d0a8..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/repository/repositories.go +++ /dev/null @@ -1,142 +0,0 @@ -// Package repository provides implementations of all the domain repositories. -package repository - -import ( - "sync" - - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" -) - -type cargoRepository struct { - mtx sync.RWMutex - cargos map[cargo.TrackingID]*cargo.Cargo -} - -func (r *cargoRepository) Store(c *cargo.Cargo) error { - r.mtx.Lock() - defer r.mtx.Unlock() - r.cargos[c.TrackingID] = c - return nil -} - -func (r *cargoRepository) Find(trackingID cargo.TrackingID) (*cargo.Cargo, error) { - r.mtx.RLock() - defer r.mtx.RUnlock() - if val, ok := r.cargos[trackingID]; ok { - return val, nil - } - return nil, cargo.ErrUnknown -} - -func (r *cargoRepository) FindAll() []*cargo.Cargo { - r.mtx.RLock() - defer r.mtx.RUnlock() - c := make([]*cargo.Cargo, 0, len(r.cargos)) - for _, val := range r.cargos { - c = append(c, val) - } - return c -} - -// NewCargo returns a new instance of a in-memory cargo repository. -func NewCargo() cargo.Repository { - return &cargoRepository{ - cargos: make(map[cargo.TrackingID]*cargo.Cargo), - } -} - -type locationRepository struct { - locations map[location.UNLocode]location.Location -} - -func (r *locationRepository) Find(locode location.UNLocode) (location.Location, error) { - if l, ok := r.locations[locode]; ok { - return l, nil - } - return location.Location{}, location.ErrUnknown -} - -func (r *locationRepository) FindAll() []location.Location { - l := make([]location.Location, 0, len(r.locations)) - for _, val := range r.locations { - l = append(l, val) - } - return l -} - -// NewLocation returns a new instance of a in-memory location repository. -func NewLocation() location.Repository { - r := &locationRepository{ - locations: make(map[location.UNLocode]location.Location), - } - - r.locations[location.SESTO] = location.Stockholm - r.locations[location.AUMEL] = location.Melbourne - r.locations[location.CNHKG] = location.Hongkong - r.locations[location.JNTKO] = location.Tokyo - r.locations[location.NLRTM] = location.Rotterdam - r.locations[location.DEHAM] = location.Hamburg - - return r -} - -type voyageRepository struct { - voyages map[voyage.Number]*voyage.Voyage -} - -func (r *voyageRepository) Find(voyageNumber voyage.Number) (*voyage.Voyage, error) { - if v, ok := r.voyages[voyageNumber]; ok { - return v, nil - } - - return nil, voyage.ErrUnknown -} - -// NewVoyage returns a new instance of a in-memory voyage repository. -func NewVoyage() voyage.Repository { - r := &voyageRepository{ - voyages: make(map[voyage.Number]*voyage.Voyage), - } - - r.voyages[voyage.V100.Number] = voyage.V100 - r.voyages[voyage.V300.Number] = voyage.V300 - r.voyages[voyage.V400.Number] = voyage.V400 - - r.voyages[voyage.V0100S.Number] = voyage.V0100S - r.voyages[voyage.V0200T.Number] = voyage.V0200T - r.voyages[voyage.V0300A.Number] = voyage.V0300A - r.voyages[voyage.V0301S.Number] = voyage.V0301S - r.voyages[voyage.V0400S.Number] = voyage.V0400S - - return r -} - -type handlingEventRepository struct { - mtx sync.RWMutex - events map[cargo.TrackingID][]cargo.HandlingEvent -} - -func (r *handlingEventRepository) Store(e cargo.HandlingEvent) { - r.mtx.Lock() - defer r.mtx.Unlock() - // Make array if it's the first event with this tracking ID. - if _, ok := r.events[e.TrackingID]; !ok { - r.events[e.TrackingID] = make([]cargo.HandlingEvent, 0) - } - r.events[e.TrackingID] = append(r.events[e.TrackingID], e) -} - -func (r *handlingEventRepository) QueryHandlingHistory(trackingID cargo.TrackingID) cargo.HandlingHistory { - r.mtx.RLock() - defer r.mtx.RUnlock() - return cargo.HandlingHistory{HandlingEvents: r.events[trackingID]} -} - -// NewHandlingEvent returns a new instance of a in-memory handling event repository. -func NewHandlingEvent() cargo.HandlingEventRepository { - return &handlingEventRepository{ - events: make(map[cargo.TrackingID][]cargo.HandlingEvent), - } -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go b/vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go deleted file mode 100644 index 3051caf..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go +++ /dev/null @@ -1,117 +0,0 @@ -package routing - -import ( - "encoding/json" - "net/http" - "net/url" - "time" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/circuitbreaker" - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/voyage" - kithttp "github.com/go-kit/kit/transport/http" -) - -type proxyService struct { - context.Context - FetchRoutesEndpoint endpoint.Endpoint - Service -} - -func (s proxyService) FetchRoutesForSpecification(rs cargo.RouteSpecification) []cargo.Itinerary { - response, err := s.FetchRoutesEndpoint(s.Context, fetchRoutesRequest{ - From: string(rs.Origin), - To: string(rs.Destination), - }) - if err != nil { - return []cargo.Itinerary{} - } - - resp := response.(fetchRoutesResponse) - - var itineraries []cargo.Itinerary - for _, r := range resp.Paths { - var legs []cargo.Leg - for _, e := range r.Edges { - legs = append(legs, cargo.Leg{ - VoyageNumber: voyage.Number(e.Voyage), - LoadLocation: location.UNLocode(e.Origin), - UnloadLocation: location.UNLocode(e.Destination), - LoadTime: e.Departure, - UnloadTime: e.Arrival, - }) - } - - itineraries = append(itineraries, cargo.Itinerary{Legs: legs}) - } - - return itineraries -} - -// ServiceMiddleware defines a middleware for a routing service. -type ServiceMiddleware func(Service) Service - -// NewProxyingMiddleware returns a new instance of a proxying middleware. -func NewProxyingMiddleware(proxyURL string, ctx context.Context) ServiceMiddleware { - return func(next Service) Service { - var e endpoint.Endpoint - e = makeFetchRoutesEndpoint(ctx, proxyURL) - e = circuitbreaker.Hystrix("fetch-routes")(e) - return proxyService{ctx, e, next} - } -} - -type fetchRoutesRequest struct { - From string - To string -} - -type fetchRoutesResponse struct { - Paths []struct { - Edges []struct { - Origin string `json:"origin"` - Destination string `json:"destination"` - Voyage string `json:"voyage"` - Departure time.Time `json:"departure"` - Arrival time.Time `json:"arrival"` - } `json:"edges"` - } `json:"paths"` -} - -func makeFetchRoutesEndpoint(ctx context.Context, instance string) endpoint.Endpoint { - u, err := url.Parse(instance) - if err != nil { - panic(err) - } - if u.Path == "" { - u.Path = "/paths" - } - return kithttp.NewClient( - "GET", u, - encodeFetchRoutesRequest, - decodeFetchRoutesResponse, - ).Endpoint() -} - -func decodeFetchRoutesResponse(_ context.Context, resp *http.Response) (interface{}, error) { - var response fetchRoutesResponse - if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { - return nil, err - } - return response, nil -} - -func encodeFetchRoutesRequest(_ context.Context, r *http.Request, request interface{}) error { - req := request.(fetchRoutesRequest) - - vals := r.URL.Query() - vals.Add("from", req.From) - vals.Add("to", req.To) - r.URL.RawQuery = vals.Encode() - - return nil -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/routing/routing.go b/vendor/github.com/go-kit/kit/examples/shipping/routing/routing.go deleted file mode 100644 index dac3690..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/routing/routing.go +++ /dev/null @@ -1,13 +0,0 @@ -// Package routing provides the routing domain service. It does not actually -// implement the routing service but merely acts as a proxy for a separate -// bounded context. -package routing - -import "github.com/go-kit/kit/examples/shipping/cargo" - -// Service provides access to an external routing service. -type Service interface { - // FetchRoutesForSpecification finds all possible routes that satisfy a - // given specification. - FetchRoutesForSpecification(rs cargo.RouteSpecification) []cargo.Itinerary -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/endpoint.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/endpoint.go deleted file mode 100644 index ea105d5..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/endpoint.go +++ /dev/null @@ -1,26 +0,0 @@ -package tracking - -import ( - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -type trackCargoRequest struct { - ID string -} - -type trackCargoResponse struct { - Cargo *Cargo `json:"cargo,omitempty"` - Err error `json:"error,omitempty"` -} - -func (r trackCargoResponse) error() error { return r.Err } - -func makeTrackCargoEndpoint(ts Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(trackCargoRequest) - c, err := ts.Track(req.ID) - return trackCargoResponse{Cargo: &c, Err: err}, nil - } -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go deleted file mode 100644 index 629ab27..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go +++ /dev/null @@ -1,32 +0,0 @@ -package tracking - -import ( - "time" - - "github.com/go-kit/kit/metrics" -) - -type instrumentingService struct { - requestCount metrics.Counter - requestLatency metrics.TimeHistogram - Service -} - -// NewInstrumentingService returns an instance of an instrumenting Service. -func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.TimeHistogram, s Service) Service { - return &instrumentingService{ - requestCount: requestCount, - requestLatency: requestLatency, - Service: s, - } -} - -func (s *instrumentingService) Track(id string) (Cargo, error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "track"} - s.requestCount.With(methodField).Add(1) - s.requestLatency.With(methodField).Observe(time.Since(begin)) - }(time.Now()) - - return s.Service.Track(id) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/logging.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/logging.go deleted file mode 100644 index 584aeaa..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/logging.go +++ /dev/null @@ -1,24 +0,0 @@ -package tracking - -import ( - "time" - - "github.com/go-kit/kit/log" -) - -type loggingService struct { - logger log.Logger - Service -} - -// NewLoggingService returns a new instance of a logging Service. -func NewLoggingService(logger log.Logger, s Service) Service { - return &loggingService{logger, s} -} - -func (s *loggingService) Track(id string) (c Cargo, err error) { - defer func(begin time.Time) { - s.logger.Log("method", "track", "tracking_id", id, "took", time.Since(begin), "err", err) - }(time.Now()) - return s.Service.Track(id) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go deleted file mode 100644 index d5b9273..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go +++ /dev/null @@ -1,163 +0,0 @@ -// Package tracking provides the use-case of tracking a cargo. Used by views -// facing the end-user. -package tracking - -import ( - "errors" - "fmt" - "strings" - "time" - - "github.com/go-kit/kit/examples/shipping/cargo" -) - -// ErrInvalidArgument is returned when one or more arguments are invalid. -var ErrInvalidArgument = errors.New("invalid argument") - -// Service is the interface that provides the basic Track method. -type Service interface { - // Track returns a cargo matching a tracking ID. - Track(id string) (Cargo, error) -} - -type service struct { - cargos cargo.Repository - handlingEvents cargo.HandlingEventRepository -} - -func (s *service) Track(id string) (Cargo, error) { - if id == "" { - return Cargo{}, ErrInvalidArgument - } - c, err := s.cargos.Find(cargo.TrackingID(id)) - if err != nil { - return Cargo{}, err - } - return assemble(c, s.handlingEvents), nil -} - -// NewService returns a new instance of the default Service. -func NewService(cargos cargo.Repository, handlingEvents cargo.HandlingEventRepository) Service { - return &service{ - cargos: cargos, - handlingEvents: handlingEvents, - } -} - -// Cargo is a read model for tracking views. -type Cargo struct { - TrackingID string `json:"tracking_id"` - StatusText string `json:"status_text"` - Origin string `json:"origin"` - Destination string `json:"destination"` - ETA time.Time `json:"eta"` - NextExpectedActivity string `json:"next_expected_activity"` - ArrivalDeadline time.Time `json:"arrival_deadline"` - Events []Event `json:"events"` -} - -// Leg is a read model for booking views. -type Leg struct { - VoyageNumber string `json:"voyage_number"` - From string `json:"from"` - To string `json:"to"` - LoadTime time.Time `json:"load_time"` - UnloadTime time.Time `json:"unload_time"` -} - -// Event is a read model for tracking views. -type Event struct { - Description string `json:"description"` - Expected bool `json:"expected"` -} - -func assemble(c *cargo.Cargo, her cargo.HandlingEventRepository) Cargo { - return Cargo{ - TrackingID: string(c.TrackingID), - Origin: string(c.Origin), - Destination: string(c.RouteSpecification.Destination), - ETA: c.Delivery.ETA, - NextExpectedActivity: nextExpectedActivity(c), - ArrivalDeadline: c.RouteSpecification.ArrivalDeadline, - StatusText: assembleStatusText(c), - Events: assembleEvents(c, her), - } -} - -func assembleLegs(c cargo.Cargo) []Leg { - var legs []Leg - for _, l := range c.Itinerary.Legs { - legs = append(legs, Leg{ - VoyageNumber: string(l.VoyageNumber), - From: string(l.LoadLocation), - To: string(l.UnloadLocation), - LoadTime: l.LoadTime, - UnloadTime: l.UnloadTime, - }) - } - return legs -} - -func nextExpectedActivity(c *cargo.Cargo) string { - a := c.Delivery.NextExpectedActivity - prefix := "Next expected activity is to" - - switch a.Type { - case cargo.Load: - return fmt.Sprintf("%s %s cargo onto voyage %s in %s.", prefix, strings.ToLower(a.Type.String()), a.VoyageNumber, a.Location) - case cargo.Unload: - return fmt.Sprintf("%s %s cargo off of voyage %s in %s.", prefix, strings.ToLower(a.Type.String()), a.VoyageNumber, a.Location) - case cargo.NotHandled: - return "There are currently no expected activities for this cargo." - } - - return fmt.Sprintf("%s %s cargo in %s.", prefix, strings.ToLower(a.Type.String()), a.Location) -} - -func assembleStatusText(c *cargo.Cargo) string { - switch c.Delivery.TransportStatus { - case cargo.NotReceived: - return "Not received" - case cargo.InPort: - return fmt.Sprintf("In port %s", c.Delivery.LastKnownLocation) - case cargo.OnboardCarrier: - return fmt.Sprintf("Onboard voyage %s", c.Delivery.CurrentVoyage) - case cargo.Claimed: - return "Claimed" - default: - return "Unknown" - } -} - -func assembleEvents(c *cargo.Cargo, r cargo.HandlingEventRepository) []Event { - h := r.QueryHandlingHistory(c.TrackingID) - - var events []Event - for _, e := range h.HandlingEvents { - var description string - - switch e.Activity.Type { - case cargo.NotHandled: - description = "Cargo has not yet been received." - case cargo.Receive: - description = fmt.Sprintf("Received in %s, at %s", e.Activity.Location, time.Now().Format(time.RFC3339)) - case cargo.Load: - description = fmt.Sprintf("Loaded onto voyage %s in %s, at %s.", e.Activity.VoyageNumber, e.Activity.Location, time.Now().Format(time.RFC3339)) - case cargo.Unload: - description = fmt.Sprintf("Unloaded off voyage %s in %s, at %s.", e.Activity.VoyageNumber, e.Activity.Location, time.Now().Format(time.RFC3339)) - case cargo.Claim: - description = fmt.Sprintf("Claimed in %s, at %s.", e.Activity.Location, time.Now().Format(time.RFC3339)) - case cargo.Customs: - description = fmt.Sprintf("Cleared customs in %s, at %s.", e.Activity.Location, time.Now().Format(time.RFC3339)) - default: - description = "[Unknown status]" - } - - events = append(events, Event{ - Description: description, - Expected: c.Itinerary.IsExpected(e), - }) - } - - return events -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go deleted file mode 100644 index 9cac1ec..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go +++ /dev/null @@ -1,74 +0,0 @@ -package tracking - -import ( - "encoding/json" - "errors" - "net/http" - - "github.com/gorilla/mux" - "golang.org/x/net/context" - - "github.com/go-kit/kit/examples/shipping/cargo" - kitlog "github.com/go-kit/kit/log" - kithttp "github.com/go-kit/kit/transport/http" -) - -// MakeHandler returns a handler for the tracking service. -func MakeHandler(ctx context.Context, ts Service, logger kitlog.Logger) http.Handler { - r := mux.NewRouter() - - opts := []kithttp.ServerOption{ - kithttp.ServerErrorLogger(logger), - kithttp.ServerErrorEncoder(encodeError), - } - - trackCargoHandler := kithttp.NewServer( - ctx, - makeTrackCargoEndpoint(ts), - decodeTrackCargoRequest, - encodeResponse, - opts..., - ) - - r.Handle("/tracking/v1/cargos/{id}", trackCargoHandler).Methods("GET") - - return r -} - -func decodeTrackCargoRequest(_ context.Context, r *http.Request) (interface{}, error) { - vars := mux.Vars(r) - id, ok := vars["id"] - if !ok { - return nil, errors.New("bad route") - } - return trackCargoRequest{ID: id}, nil -} - -func encodeResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - if e, ok := response.(errorer); ok && e.error() != nil { - encodeError(ctx, e.error(), w) - return nil - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - return json.NewEncoder(w).Encode(response) -} - -type errorer interface { - error() error -} - -// encode errors from business-logic -func encodeError(_ context.Context, err error, w http.ResponseWriter) { - switch err { - case cargo.ErrUnknown: - w.WriteHeader(http.StatusNotFound) - case ErrInvalidArgument: - w.WriteHeader(http.StatusBadRequest) - default: - w.WriteHeader(http.StatusInternalServerError) - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - json.NewEncoder(w).Encode(map[string]interface{}{ - "error": err.Error(), - }) -} diff --git a/vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go b/vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go deleted file mode 100644 index 51b7a05..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go +++ /dev/null @@ -1,40 +0,0 @@ -package voyage - -import "github.com/go-kit/kit/examples/shipping/location" - -// A set of sample voyages. -var ( - V100 = New("V100", Schedule{ - []CarrierMovement{ - {DepartureLocation: location.Hongkong, ArrivalLocation: location.Tokyo}, - {DepartureLocation: location.Tokyo, ArrivalLocation: location.NewYork}, - }, - }) - - V300 = New("V300", Schedule{ - []CarrierMovement{ - {DepartureLocation: location.Tokyo, ArrivalLocation: location.Rotterdam}, - {DepartureLocation: location.Rotterdam, ArrivalLocation: location.Hamburg}, - {DepartureLocation: location.Hamburg, ArrivalLocation: location.Melbourne}, - {DepartureLocation: location.Melbourne, ArrivalLocation: location.Tokyo}, - }, - }) - - V400 = New("V400", Schedule{ - []CarrierMovement{ - {DepartureLocation: location.Hamburg, ArrivalLocation: location.Stockholm}, - {DepartureLocation: location.Stockholm, ArrivalLocation: location.Helsinki}, - {DepartureLocation: location.Helsinki, ArrivalLocation: location.Hamburg}, - }, - }) -) - -// These voyages are hard-coded into the current pathfinder. Make sure -// they exist. -var ( - V0100S = New("0100S", Schedule{[]CarrierMovement{}}) - V0200T = New("0200T", Schedule{[]CarrierMovement{}}) - V0300A = New("0300A", Schedule{[]CarrierMovement{}}) - V0301S = New("0301S", Schedule{[]CarrierMovement{}}) - V0400S = New("0400S", Schedule{[]CarrierMovement{}}) -) diff --git a/vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go b/vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go deleted file mode 100644 index 57a70b0..0000000 --- a/vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go +++ /dev/null @@ -1,44 +0,0 @@ -// Package voyage provides the Voyage aggregate. -package voyage - -import ( - "errors" - "time" - - "github.com/go-kit/kit/examples/shipping/location" -) - -// Number uniquely identifies a particular Voyage. -type Number string - -// Voyage is a uniquely identifiable series of carrier movements. -type Voyage struct { - Number Number - Schedule Schedule -} - -// New creates a voyage with a voyage number and a provided schedule. -func New(n Number, s Schedule) *Voyage { - return &Voyage{Number: n, Schedule: s} -} - -// Schedule describes a voyage schedule. -type Schedule struct { - CarrierMovements []CarrierMovement -} - -// CarrierMovement is a vessel voyage from one location to another. -type CarrierMovement struct { - DepartureLocation location.Location - ArrivalLocation location.Location - DepartureTime time.Time - ArrivalTime time.Time -} - -// ErrUnknown is used when a voyage could not be found. -var ErrUnknown = errors.New("unknown voyage") - -// Repository provides access a voyage store. -type Repository interface { - Find(Number) (*Voyage, error) -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc1/main.go b/vendor/github.com/go-kit/kit/examples/stringsvc1/main.go deleted file mode 100644 index 876eb9c..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc1/main.go +++ /dev/null @@ -1,115 +0,0 @@ -package main - -import ( - "encoding/json" - "errors" - "log" - "net/http" - "strings" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" -) - -// StringService provides operations on strings. -type StringService interface { - Uppercase(string) (string, error) - Count(string) int -} - -type stringService struct{} - -func (stringService) Uppercase(s string) (string, error) { - if s == "" { - return "", ErrEmpty - } - return strings.ToUpper(s), nil -} - -func (stringService) Count(s string) int { - return len(s) -} - -func main() { - ctx := context.Background() - svc := stringService{} - - uppercaseHandler := httptransport.NewServer( - ctx, - makeUppercaseEndpoint(svc), - decodeUppercaseRequest, - encodeResponse, - ) - - countHandler := httptransport.NewServer( - ctx, - makeCountEndpoint(svc), - decodeCountRequest, - encodeResponse, - ) - - http.Handle("/uppercase", uppercaseHandler) - http.Handle("/count", countHandler) - log.Fatal(http.ListenAndServe(":8080", nil)) -} - -func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(uppercaseRequest) - v, err := svc.Uppercase(req.S) - if err != nil { - return uppercaseResponse{v, err.Error()}, nil - } - return uppercaseResponse{v, ""}, nil - } -} - -func makeCountEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(countRequest) - v := svc.Count(req.S) - return countResponse{v}, nil - } -} - -func decodeUppercaseRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request uppercaseRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func decodeCountRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request countRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func encodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error { - return json.NewEncoder(w).Encode(response) -} - -type uppercaseRequest struct { - S string `json:"s"` -} - -type uppercaseResponse struct { - V string `json:"v"` - Err string `json:"err,omitempty"` // errors don't define JSON marshaling -} - -type countRequest struct { - S string `json:"s"` -} - -type countResponse struct { - V int `json:"v"` -} - -// ErrEmpty is returned when an input string is empty. -var ErrEmpty = errors.New("empty string") diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc2/instrumenting.go b/vendor/github.com/go-kit/kit/examples/stringsvc2/instrumenting.go deleted file mode 100644 index f461845..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc2/instrumenting.go +++ /dev/null @@ -1,40 +0,0 @@ -package main - -import ( - "fmt" - "time" - - "github.com/go-kit/kit/metrics" -) - -type instrumentingMiddleware struct { - requestCount metrics.Counter - requestLatency metrics.TimeHistogram - countResult metrics.Histogram - next StringService -} - -func (mw instrumentingMiddleware) Uppercase(s string) (output string, err error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "uppercase"} - errorField := metrics.Field{Key: "error", Value: fmt.Sprintf("%v", err)} - mw.requestCount.With(methodField).With(errorField).Add(1) - mw.requestLatency.With(methodField).With(errorField).Observe(time.Since(begin)) - }(time.Now()) - - output, err = mw.next.Uppercase(s) - return -} - -func (mw instrumentingMiddleware) Count(s string) (n int) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "count"} - errorField := metrics.Field{Key: "error", Value: fmt.Sprintf("%v", error(nil))} - mw.requestCount.With(methodField).With(errorField).Add(1) - mw.requestLatency.With(methodField).With(errorField).Observe(time.Since(begin)) - mw.countResult.Observe(int64(n)) - }(time.Now()) - - n = mw.next.Count(s) - return -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc2/logging.go b/vendor/github.com/go-kit/kit/examples/stringsvc2/logging.go deleted file mode 100644 index b958f3b..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc2/logging.go +++ /dev/null @@ -1,41 +0,0 @@ -package main - -import ( - "time" - - "github.com/go-kit/kit/log" -) - -type loggingMiddleware struct { - logger log.Logger - next StringService -} - -func (mw loggingMiddleware) Uppercase(s string) (output string, err error) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "uppercase", - "input", s, - "output", output, - "err", err, - "took", time.Since(begin), - ) - }(time.Now()) - - output, err = mw.next.Uppercase(s) - return -} - -func (mw loggingMiddleware) Count(s string) (n int) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "count", - "input", s, - "n", n, - "took", time.Since(begin), - ) - }(time.Now()) - - n = mw.next.Count(s) - return -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc2/main.go b/vendor/github.com/go-kit/kit/examples/stringsvc2/main.go deleted file mode 100644 index dbe4788..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc2/main.go +++ /dev/null @@ -1,65 +0,0 @@ -package main - -import ( - "net/http" - "os" - "time" - - stdprometheus "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics" - kitprometheus "github.com/go-kit/kit/metrics/prometheus" - httptransport "github.com/go-kit/kit/transport/http" -) - -func main() { - ctx := context.Background() - logger := log.NewLogfmtLogger(os.Stderr) - - fieldKeys := []string{"method", "error"} - requestCount := kitprometheus.NewCounter(stdprometheus.CounterOpts{ - Namespace: "my_group", - Subsystem: "string_service", - Name: "request_count", - Help: "Number of requests received.", - }, fieldKeys) - requestLatency := metrics.NewTimeHistogram(time.Microsecond, kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "my_group", - Subsystem: "string_service", - Name: "request_latency_microseconds", - Help: "Total duration of requests in microseconds.", - }, fieldKeys)) - countResult := kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "my_group", - Subsystem: "string_service", - Name: "count_result", - Help: "The result of each count method.", - }, []string{}) // no fields here - - var svc StringService - svc = stringService{} - svc = loggingMiddleware{logger, svc} - svc = instrumentingMiddleware{requestCount, requestLatency, countResult, svc} - - uppercaseHandler := httptransport.NewServer( - ctx, - makeUppercaseEndpoint(svc), - decodeUppercaseRequest, - encodeResponse, - ) - - countHandler := httptransport.NewServer( - ctx, - makeCountEndpoint(svc), - decodeCountRequest, - encodeResponse, - ) - - http.Handle("/uppercase", uppercaseHandler) - http.Handle("/count", countHandler) - http.Handle("/metrics", stdprometheus.Handler()) - logger.Log("msg", "HTTP", "addr", ":8080") - logger.Log("err", http.ListenAndServe(":8080", nil)) -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc2/service.go b/vendor/github.com/go-kit/kit/examples/stringsvc2/service.go deleted file mode 100644 index 1da2f3e..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc2/service.go +++ /dev/null @@ -1,28 +0,0 @@ -package main - -import ( - "errors" - "strings" -) - -// StringService provides operations on strings. -type StringService interface { - Uppercase(string) (string, error) - Count(string) int -} - -type stringService struct{} - -func (stringService) Uppercase(s string) (string, error) { - if s == "" { - return "", ErrEmpty - } - return strings.ToUpper(s), nil -} - -func (stringService) Count(s string) int { - return len(s) -} - -// ErrEmpty is returned when an input string is empty. -var ErrEmpty = errors.New("empty string") diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc2/transport.go b/vendor/github.com/go-kit/kit/examples/stringsvc2/transport.go deleted file mode 100644 index a70ad3f..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc2/transport.go +++ /dev/null @@ -1,66 +0,0 @@ -package main - -import ( - "encoding/json" - "net/http" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(uppercaseRequest) - v, err := svc.Uppercase(req.S) - if err != nil { - return uppercaseResponse{v, err.Error()}, nil - } - return uppercaseResponse{v, ""}, nil - } -} - -func makeCountEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(countRequest) - v := svc.Count(req.S) - return countResponse{v}, nil - } -} - -func decodeUppercaseRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request uppercaseRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func decodeCountRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request countRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func encodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error { - return json.NewEncoder(w).Encode(response) -} - -type uppercaseRequest struct { - S string `json:"s"` -} - -type uppercaseResponse struct { - V string `json:"v"` - Err string `json:"err,omitempty"` -} - -type countRequest struct { - S string `json:"s"` -} - -type countResponse struct { - V int `json:"v"` -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc3/instrumenting.go b/vendor/github.com/go-kit/kit/examples/stringsvc3/instrumenting.go deleted file mode 100644 index 1b27b61..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc3/instrumenting.go +++ /dev/null @@ -1,50 +0,0 @@ -package main - -import ( - "fmt" - "time" - - "github.com/go-kit/kit/metrics" -) - -func instrumentingMiddleware( - requestCount metrics.Counter, - requestLatency metrics.TimeHistogram, - countResult metrics.Histogram, -) ServiceMiddleware { - return func(next StringService) StringService { - return instrmw{requestCount, requestLatency, countResult, next} - } -} - -type instrmw struct { - requestCount metrics.Counter - requestLatency metrics.TimeHistogram - countResult metrics.Histogram - StringService -} - -func (mw instrmw) Uppercase(s string) (output string, err error) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "uppercase"} - errorField := metrics.Field{Key: "error", Value: fmt.Sprintf("%v", err)} - mw.requestCount.With(methodField).With(errorField).Add(1) - mw.requestLatency.With(methodField).With(errorField).Observe(time.Since(begin)) - }(time.Now()) - - output, err = mw.StringService.Uppercase(s) - return -} - -func (mw instrmw) Count(s string) (n int) { - defer func(begin time.Time) { - methodField := metrics.Field{Key: "method", Value: "count"} - errorField := metrics.Field{Key: "error", Value: fmt.Sprintf("%v", error(nil))} - mw.requestCount.With(methodField).With(errorField).Add(1) - mw.requestLatency.With(methodField).With(errorField).Observe(time.Since(begin)) - mw.countResult.Observe(int64(n)) - }(time.Now()) - - n = mw.StringService.Count(s) - return -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc3/logging.go b/vendor/github.com/go-kit/kit/examples/stringsvc3/logging.go deleted file mode 100644 index 72a2709..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc3/logging.go +++ /dev/null @@ -1,47 +0,0 @@ -package main - -import ( - "time" - - "github.com/go-kit/kit/log" -) - -func loggingMiddleware(logger log.Logger) ServiceMiddleware { - return func(next StringService) StringService { - return logmw{logger, next} - } -} - -type logmw struct { - logger log.Logger - StringService -} - -func (mw logmw) Uppercase(s string) (output string, err error) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "uppercase", - "input", s, - "output", output, - "err", err, - "took", time.Since(begin), - ) - }(time.Now()) - - output, err = mw.StringService.Uppercase(s) - return -} - -func (mw logmw) Count(s string) (n int) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "count", - "input", s, - "n", n, - "took", time.Since(begin), - ) - }(time.Now()) - - n = mw.StringService.Count(s) - return -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc3/main.go b/vendor/github.com/go-kit/kit/examples/stringsvc3/main.go deleted file mode 100644 index b62952a..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc3/main.go +++ /dev/null @@ -1,75 +0,0 @@ -package main - -import ( - "flag" - "net/http" - "os" - "time" - - stdprometheus "github.com/prometheus/client_golang/prometheus" - "golang.org/x/net/context" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics" - kitprometheus "github.com/go-kit/kit/metrics/prometheus" - httptransport "github.com/go-kit/kit/transport/http" -) - -func main() { - var ( - listen = flag.String("listen", ":8080", "HTTP listen address") - proxy = flag.String("proxy", "", "Optional comma-separated list of URLs to proxy uppercase requests") - ) - flag.Parse() - - var logger log.Logger - logger = log.NewLogfmtLogger(os.Stderr) - logger = log.NewContext(logger).With("listen", *listen).With("caller", log.DefaultCaller) - - ctx := context.Background() - - fieldKeys := []string{"method", "error"} - requestCount := kitprometheus.NewCounter(stdprometheus.CounterOpts{ - Namespace: "my_group", - Subsystem: "string_service", - Name: "request_count", - Help: "Number of requests received.", - }, fieldKeys) - requestLatency := metrics.NewTimeHistogram(time.Microsecond, kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "my_group", - Subsystem: "string_service", - Name: "request_latency_microseconds", - Help: "Total duration of requests in microseconds.", - }, fieldKeys)) - countResult := kitprometheus.NewSummary(stdprometheus.SummaryOpts{ - Namespace: "my_group", - Subsystem: "string_service", - Name: "count_result", - Help: "The result of each count method.", - }, []string{}) - - var svc StringService - svc = stringService{} - svc = proxyingMiddleware(*proxy, ctx, logger)(svc) - svc = loggingMiddleware(logger)(svc) - svc = instrumentingMiddleware(requestCount, requestLatency, countResult)(svc) - - uppercaseHandler := httptransport.NewServer( - ctx, - makeUppercaseEndpoint(svc), - decodeUppercaseRequest, - encodeResponse, - ) - countHandler := httptransport.NewServer( - ctx, - makeCountEndpoint(svc), - decodeCountRequest, - encodeResponse, - ) - - http.Handle("/uppercase", uppercaseHandler) - http.Handle("/count", countHandler) - http.Handle("/metrics", stdprometheus.Handler()) - logger.Log("msg", "HTTP", "addr", *listen) - logger.Log("err", http.ListenAndServe(*listen, nil)) -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc3/proxying.go b/vendor/github.com/go-kit/kit/examples/stringsvc3/proxying.go deleted file mode 100644 index 33bc156..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc3/proxying.go +++ /dev/null @@ -1,116 +0,0 @@ -package main - -import ( - "errors" - "fmt" - "net/url" - "strings" - "time" - - jujuratelimit "github.com/juju/ratelimit" - "github.com/sony/gobreaker" - "golang.org/x/net/context" - - "github.com/go-kit/kit/circuitbreaker" - "github.com/go-kit/kit/endpoint" - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/ratelimit" - "github.com/go-kit/kit/sd" - "github.com/go-kit/kit/sd/lb" - httptransport "github.com/go-kit/kit/transport/http" -) - -func proxyingMiddleware(instances string, ctx context.Context, logger log.Logger) ServiceMiddleware { - // If instances is empty, don't proxy. - if instances == "" { - logger.Log("proxy_to", "none") - return func(next StringService) StringService { return next } - } - - // Set some parameters for our client. - var ( - qps = 100 // beyond which we will return an error - maxAttempts = 3 // per request, before giving up - maxTime = 250 * time.Millisecond // wallclock time, before giving up - ) - - // Otherwise, construct an endpoint for each instance in the list, and add - // it to a fixed set of endpoints. In a real service, rather than doing this - // by hand, you'd probably use package sd's support for your service - // discovery system. - var ( - instanceList = split(instances) - subscriber sd.FixedSubscriber - ) - logger.Log("proxy_to", fmt.Sprint(instanceList)) - for _, instance := range instanceList { - var e endpoint.Endpoint - e = makeUppercaseProxy(ctx, instance) - e = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))(e) - e = ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(float64(qps), int64(qps)))(e) - subscriber = append(subscriber, e) - } - - // Now, build a single, retrying, load-balancing endpoint out of all of - // those individual endpoints. - balancer := lb.NewRoundRobin(subscriber) - retry := lb.Retry(maxAttempts, maxTime, balancer) - - // And finally, return the ServiceMiddleware, implemented by proxymw. - return func(next StringService) StringService { - return proxymw{ctx, next, retry} - } -} - -// proxymw implements StringService, forwarding Uppercase requests to the -// provided endpoint, and serving all other (i.e. Count) requests via the -// next StringService. -type proxymw struct { - ctx context.Context - next StringService // Serve most requests via this service... - uppercase endpoint.Endpoint // ...except Uppercase, which gets served by this endpoint -} - -func (mw proxymw) Count(s string) int { - return mw.next.Count(s) -} - -func (mw proxymw) Uppercase(s string) (string, error) { - response, err := mw.uppercase(mw.ctx, uppercaseRequest{S: s}) - if err != nil { - return "", err - } - - resp := response.(uppercaseResponse) - if resp.Err != "" { - return resp.V, errors.New(resp.Err) - } - return resp.V, nil -} - -func makeUppercaseProxy(ctx context.Context, instance string) endpoint.Endpoint { - if !strings.HasPrefix(instance, "http") { - instance = "http://" + instance - } - u, err := url.Parse(instance) - if err != nil { - panic(err) - } - if u.Path == "" { - u.Path = "/uppercase" - } - return httptransport.NewClient( - "GET", - u, - encodeRequest, - decodeUppercaseResponse, - ).Endpoint() -} - -func split(s string) []string { - a := strings.Split(s, ",") - for i := range a { - a[i] = strings.TrimSpace(a[i]) - } - return a -} diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc3/service.go b/vendor/github.com/go-kit/kit/examples/stringsvc3/service.go deleted file mode 100644 index 7e1773a..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc3/service.go +++ /dev/null @@ -1,31 +0,0 @@ -package main - -import ( - "errors" - "strings" -) - -// StringService provides operations on strings. -type StringService interface { - Uppercase(string) (string, error) - Count(string) int -} - -type stringService struct{} - -func (stringService) Uppercase(s string) (string, error) { - if s == "" { - return "", ErrEmpty - } - return strings.ToUpper(s), nil -} - -func (stringService) Count(s string) int { - return len(s) -} - -// ErrEmpty is returned when an input string is empty. -var ErrEmpty = errors.New("empty string") - -// ServiceMiddleware is a chainable behavior modifier for StringService. -type ServiceMiddleware func(StringService) StringService diff --git a/vendor/github.com/go-kit/kit/examples/stringsvc3/transport.go b/vendor/github.com/go-kit/kit/examples/stringsvc3/transport.go deleted file mode 100644 index c6341c1..0000000 --- a/vendor/github.com/go-kit/kit/examples/stringsvc3/transport.go +++ /dev/null @@ -1,85 +0,0 @@ -package main - -import ( - "bytes" - "encoding/json" - "io/ioutil" - "net/http" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/endpoint" -) - -func makeUppercaseEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(uppercaseRequest) - v, err := svc.Uppercase(req.S) - if err != nil { - return uppercaseResponse{v, err.Error()}, nil - } - return uppercaseResponse{v, ""}, nil - } -} - -func makeCountEndpoint(svc StringService) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - req := request.(countRequest) - v := svc.Count(req.S) - return countResponse{v}, nil - } -} - -func decodeUppercaseRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request uppercaseRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func decodeCountRequest(_ context.Context, r *http.Request) (interface{}, error) { - var request countRequest - if err := json.NewDecoder(r.Body).Decode(&request); err != nil { - return nil, err - } - return request, nil -} - -func decodeUppercaseResponse(_ context.Context, r *http.Response) (interface{}, error) { - var response uppercaseResponse - if err := json.NewDecoder(r.Body).Decode(&response); err != nil { - return nil, err - } - return response, nil -} - -func encodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error { - return json.NewEncoder(w).Encode(response) -} - -func encodeRequest(_ context.Context, r *http.Request, request interface{}) error { - var buf bytes.Buffer - if err := json.NewEncoder(&buf).Encode(request); err != nil { - return err - } - r.Body = ioutil.NopCloser(&buf) - return nil -} - -type uppercaseRequest struct { - S string `json:"s"` -} - -type uppercaseResponse struct { - V string `json:"v"` - Err string `json:"err,omitempty"` -} - -type countRequest struct { - S string `json:"s"` -} - -type countResponse struct { - V int `json:"v"` -} diff --git a/vendor/github.com/go-kit/kit/lint b/vendor/github.com/go-kit/kit/lint deleted file mode 100755 index 12e3072..0000000 --- a/vendor/github.com/go-kit/kit/lint +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o pipefail - -if [ ! $(command -v gometalinter) ] -then - go get github.com/alecthomas/gometalinter - gometalinter --update --install -fi - -time gometalinter \ - --exclude='error return value not checked.*(Close|Log|Print).*\(errcheck\)$' \ - --exclude='.*_test\.go:.*error return value not checked.*\(errcheck\)$' \ - --exclude='/thrift/' \ - --exclude='/pb/' \ - --exclude='no args in Log call \(vet\)' \ - --disable=dupl \ - --disable=aligncheck \ - --disable=gotype \ - --cyclo-over=20 \ - --tests \ - --concurrency=2 \ - --deadline=300s \ - ./... diff --git a/vendor/github.com/go-kit/kit/log/README.md b/vendor/github.com/go-kit/kit/log/README.md deleted file mode 100644 index 452157d..0000000 --- a/vendor/github.com/go-kit/kit/log/README.md +++ /dev/null @@ -1,147 +0,0 @@ -# package log - -`package log` provides a minimal interface for structured logging in services. -It may be wrapped to encode conventions, enforce type-safety, provide leveled logging, and so on. -It can be used for both typical application log events, and log-structured data streams. - -## Structured logging - -Structured logging is, basically, conceding to the reality that logs are _data_, - and warrant some level of schematic rigor. -Using a stricter, key/value-oriented message format for our logs, - containing contextual and semantic information, - makes it much easier to get insight into the operational activity of the systems we build. -Consequently, `package log` is of the strong belief that - "[the benefits of structured logging outweigh the minimal effort involved](https://www.thoughtworks.com/radar/techniques/structured-logging)". - -Migrating from unstructured to structured logging is probably a lot easier than you'd expect. - -```go -// Unstructured -log.Printf("HTTP server listening on %s", addr) - -// Structured -logger.Log("transport", "HTTP", "addr", addr, "msg", "listening") -``` - -## Usage - -### Typical application logging - -```go -logger := log.NewLogfmtLogger(os.Stderr) -logger.Log("question", "what is the meaning of life?", "answer", 42) - -// Output: -// question="what is the meaning of life?" answer=42 -``` - -### Log contexts - -```go -func main() { - var logger log.Logger - logger = log.NewLogfmtLogger(os.Stderr) - logger = log.NewContext(logger).With("instance_id", 123) - - logger.Log("msg", "starting") - NewWorker(log.NewContext(logger).With("component", "worker")).Run() - NewSlacker(log.NewContext(logger).With("component", "slacker")).Run() -} - -// Output: -// instance_id=123 msg=starting -// instance_id=123 component=worker msg=running -// instance_id=123 component=slacker msg=running -``` - -### Interact with stdlib logger - -Redirect stdlib logger to Go kit logger. - -```go -import ( - "os" - stdlog "log" - kitlog "github.com/go-kit/kit/log" -) - -func main() { - logger := kitlog.NewJSONLogger(os.Stdout) - stdlog.SetOutput(kitlog.NewStdlibAdapter(logger)) - stdlog.Print("I sure like pie") -} - -// Output: -// {"msg":"I sure like pie","ts":"2016/01/01 12:34:56"} -``` - -Or, if, for legacy reasons, - you need to pipe all of your logging through the stdlib log package, - you can redirect Go kit logger to the stdlib logger. - -```go -logger := kitlog.NewLogfmtLogger(kitlog.StdlibWriter{}) -logger.Log("legacy", true, "msg", "at least it's something") - -// Output: -// 2016/01/01 12:34:56 legacy=true msg="at least it's something" -``` - -### Timestamps and callers - -```go -var logger log.Logger -logger = log.NewLogfmtLogger(os.Stderr) -logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC, "caller", log.DefaultCaller) - -logger.Log("msg", "hello") - -// Output: -// ts=2016-01-01T12:34:56Z caller=main.go:15 msg=hello -``` - -## Supported output formats - -- [Logfmt](https://brandur.org/logfmt) -- JSON - -## Enhancements - -`package log` is centered on the one-method Logger interface. - -```go -type Logger interface { - Log(keyvals ...interface{}) error -} -``` - -This interface, and its supporting code like [log.Context](https://godoc.org/github.com/go-kit/kit/log#Context), - is the product of much iteration and evaluation. -For more details on the evolution of the Logger interface, - see [The Hunt for a Logger Interface](http://go-talks.appspot.com/github.com/ChrisHines/talks/structured-logging/structured-logging.slide#1), - a talk by [Chris Hines](https://github.com/ChrisHines). -Also, please see - [#63](https://github.com/go-kit/kit/issues/63), - [#76](https://github.com/go-kit/kit/pull/76), - [#131](https://github.com/go-kit/kit/issues/131), - [#157](https://github.com/go-kit/kit/pull/157), - [#164](https://github.com/go-kit/kit/issues/164), and - [#252](https://github.com/go-kit/kit/pull/252) - to review historical conversations about package log and the Logger interface. - -Value-add packages and suggestions, - like improvements to [the leveled logger](https://godoc.org/github.com/go-kit/kit/log/levels), - are of course welcome. -Good proposals should - -- Be composable with [log.Context](https://godoc.org/github.com/go-kit/kit/log#Context), -- Not break the behavior of [log.Caller](https://godoc.org/github.com/go-kit/kit/log#Caller) in any wrapped context, and -- Be friendly to packages that accept only an unadorned log.Logger. - -## Benchmarks & comparisons - -There are a few Go logging benchmarks and comparisons that include Go kit's package log. - -- [imkira/go-loggers-bench](https://github.com/imkira/go-loggers-bench) includes kit/log -- [uber-common/zap](https://github.com/uber-common/zap), a zero-alloc logging library, includes a comparison with kit/log diff --git a/vendor/github.com/go-kit/kit/log/benchmark_test.go b/vendor/github.com/go-kit/kit/log/benchmark_test.go deleted file mode 100644 index d3695b8..0000000 --- a/vendor/github.com/go-kit/kit/log/benchmark_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package log_test - -import ( - "testing" - - "github.com/go-kit/kit/log" -) - -func benchmarkRunner(b *testing.B, logger log.Logger, f func(log.Logger)) { - lc := log.NewContext(logger).With("common_key", "common_value") - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - f(lc) - } -} - -var ( - baseMessage = func(logger log.Logger) { logger.Log("foo_key", "foo_value") } - withMessage = func(logger log.Logger) { log.NewContext(logger).With("a", "b").Log("c", "d") } -) diff --git a/vendor/github.com/go-kit/kit/log/concurrency_test.go b/vendor/github.com/go-kit/kit/log/concurrency_test.go deleted file mode 100644 index e68d16a..0000000 --- a/vendor/github.com/go-kit/kit/log/concurrency_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package log_test - -import ( - "strconv" - "sync" - "testing" - - "github.com/go-kit/kit/log" -) - -// These test are designed to be run with the race detector. - -func testConcurrency(t *testing.T, logger log.Logger) { - for _, n := range []int{10, 100, 500} { - wg := sync.WaitGroup{} - wg.Add(n) - for i := 0; i < n; i++ { - go func() { spam(logger); wg.Done() }() - } - wg.Wait() - } -} - -func spam(logger log.Logger) { - for i := 0; i < 100; i++ { - logger.Log("key", strconv.FormatInt(int64(i), 10)) - } -} diff --git a/vendor/github.com/go-kit/kit/log/example_test.go b/vendor/github.com/go-kit/kit/log/example_test.go deleted file mode 100644 index 1741615..0000000 --- a/vendor/github.com/go-kit/kit/log/example_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package log_test - -import ( - "os" - - "github.com/go-kit/kit/log" -) - -func ExampleContext() { - logger := log.NewLogfmtLogger(os.Stdout) - logger.Log("foo", 123) - ctx := log.NewContext(logger).With("level", "info") - ctx.Log() - ctx = ctx.With("msg", "hello") - ctx.Log() - ctx.With("a", 1).Log("b", 2) - - // Output: - // foo=123 - // level=info - // level=info msg=hello - // level=info msg=hello a=1 b=2 -} diff --git a/vendor/github.com/go-kit/kit/log/json_logger.go b/vendor/github.com/go-kit/kit/log/json_logger.go deleted file mode 100644 index cef0d19..0000000 --- a/vendor/github.com/go-kit/kit/log/json_logger.go +++ /dev/null @@ -1,90 +0,0 @@ -package log - -import ( - "encoding" - "encoding/json" - "fmt" - "io" - "reflect" -) - -type jsonLogger struct { - io.Writer -} - -// NewJSONLogger returns a Logger that encodes keyvals to the Writer as a -// single JSON object. -func NewJSONLogger(w io.Writer) Logger { - return &jsonLogger{w} -} - -func (l *jsonLogger) Log(keyvals ...interface{}) error { - n := (len(keyvals) + 1) / 2 // +1 to handle case when len is odd - m := make(map[string]interface{}, n) - for i := 0; i < len(keyvals); i += 2 { - k := keyvals[i] - var v interface{} = ErrMissingValue - if i+1 < len(keyvals) { - v = keyvals[i+1] - } - merge(m, k, v) - } - return json.NewEncoder(l.Writer).Encode(m) -} - -func merge(dst map[string]interface{}, k, v interface{}) { - var key string - switch x := k.(type) { - case string: - key = x - case fmt.Stringer: - key = safeString(x) - default: - key = fmt.Sprint(x) - } - if x, ok := v.(error); ok { - v = safeError(x) - } - - // We want json.Marshaler and encoding.TextMarshaller to take priority over - // err.Error() and v.String(). But json.Marshall (called later) does that by - // default so we force a no-op if it's one of those 2 case. - switch x := v.(type) { - case json.Marshaler: - case encoding.TextMarshaler: - case error: - v = safeError(x) - case fmt.Stringer: - v = safeString(x) - } - - dst[key] = v -} - -func safeString(str fmt.Stringer) (s string) { - defer func() { - if panicVal := recover(); panicVal != nil { - if v := reflect.ValueOf(str); v.Kind() == reflect.Ptr && v.IsNil() { - s = "NULL" - } else { - panic(panicVal) - } - } - }() - s = str.String() - return -} - -func safeError(err error) (s interface{}) { - defer func() { - if panicVal := recover(); panicVal != nil { - if v := reflect.ValueOf(err); v.Kind() == reflect.Ptr && v.IsNil() { - s = nil - } else { - panic(panicVal) - } - } - }() - s = err.Error() - return -} diff --git a/vendor/github.com/go-kit/kit/log/json_logger_test.go b/vendor/github.com/go-kit/kit/log/json_logger_test.go deleted file mode 100644 index 2911577..0000000 --- a/vendor/github.com/go-kit/kit/log/json_logger_test.go +++ /dev/null @@ -1,156 +0,0 @@ -package log_test - -import ( - "bytes" - "errors" - "io/ioutil" - "testing" - - "github.com/go-kit/kit/log" -) - -func TestJSONLoggerCaller(t *testing.T) { - t.Parallel() - buf := &bytes.Buffer{} - logger := log.NewJSONLogger(buf) - logger = log.NewContext(logger).With("caller", log.DefaultCaller) - - if err := logger.Log(); err != nil { - t.Fatal(err) - } - if want, have := `{"caller":"json_logger_test.go:18"}`+"\n", buf.String(); want != have { - t.Errorf("\nwant %#v\nhave %#v", want, have) - } -} - -func TestJSONLogger(t *testing.T) { - t.Parallel() - buf := &bytes.Buffer{} - logger := log.NewJSONLogger(buf) - if err := logger.Log("err", errors.New("err"), "m", map[string]int{"0": 0}, "a", []int{1, 2, 3}); err != nil { - t.Fatal(err) - } - if want, have := `{"a":[1,2,3],"err":"err","m":{"0":0}}`+"\n", buf.String(); want != have { - t.Errorf("\nwant %#v\nhave %#v", want, have) - } -} - -func TestJSONLoggerMissingValue(t *testing.T) { - t.Parallel() - buf := &bytes.Buffer{} - logger := log.NewJSONLogger(buf) - if err := logger.Log("k"); err != nil { - t.Fatal(err) - } - if want, have := `{"k":"(MISSING)"}`+"\n", buf.String(); want != have { - t.Errorf("\nwant %#v\nhave %#v", want, have) - } -} - -func TestJSONLoggerNilStringerKey(t *testing.T) { - t.Parallel() - - buf := &bytes.Buffer{} - logger := log.NewJSONLogger(buf) - if err := logger.Log((*stringer)(nil), "v"); err != nil { - t.Fatal(err) - } - if want, have := `{"NULL":"v"}`+"\n", buf.String(); want != have { - t.Errorf("\nwant %#v\nhave %#v", want, have) - } -} - -func TestJSONLoggerNilErrorValue(t *testing.T) { - t.Parallel() - - buf := &bytes.Buffer{} - logger := log.NewJSONLogger(buf) - if err := logger.Log("err", (*stringError)(nil)); err != nil { - t.Fatal(err) - } - if want, have := `{"err":null}`+"\n", buf.String(); want != have { - t.Errorf("\nwant %#v\nhave %#v", want, have) - } -} - -// aller implements json.Marshaler, encoding.TextMarshaler, and fmt.Stringer. -type aller struct{} - -func (aller) MarshalJSON() ([]byte, error) { - return []byte("\"json\""), nil -} - -func (aller) MarshalText() ([]byte, error) { - return []byte("text"), nil -} - -func (aller) String() string { - return "string" -} - -// textstringer implements encoding.TextMarshaler and fmt.Stringer. -type textstringer struct{} - -func (textstringer) MarshalText() ([]byte, error) { - return []byte("text"), nil -} - -func (textstringer) String() string { - return "string" -} - -func TestJSONLoggerStringValue(t *testing.T) { - tests := []struct { - v interface{} - expected string - }{ - { - v: aller{}, - expected: `{"v":"json"}`, - }, - { - v: textstringer{}, - expected: `{"v":"text"}`, - }, - { - v: stringer("string"), - expected: `{"v":"string"}`, - }, - } - - for _, test := range tests { - buf := &bytes.Buffer{} - logger := log.NewJSONLogger(buf) - if err := logger.Log("v", test.v); err != nil { - t.Fatal(err) - } - - if want, have := test.expected+"\n", buf.String(); want != have { - t.Errorf("\nwant %#v\nhave %#v", want, have) - } - } -} - -type stringer string - -func (s stringer) String() string { - return string(s) -} - -type stringError string - -func (s stringError) Error() string { - return string(s) -} - -func BenchmarkJSONLoggerSimple(b *testing.B) { - benchmarkRunner(b, log.NewJSONLogger(ioutil.Discard), baseMessage) -} - -func BenchmarkJSONLoggerContextual(b *testing.B) { - benchmarkRunner(b, log.NewJSONLogger(ioutil.Discard), withMessage) -} - -func TestJSONLoggerConcurrency(t *testing.T) { - testConcurrency(t, log.NewJSONLogger(ioutil.Discard)) -} diff --git a/vendor/github.com/go-kit/kit/log/levels/levels.go b/vendor/github.com/go-kit/kit/log/levels/levels.go deleted file mode 100644 index da6b681..0000000 --- a/vendor/github.com/go-kit/kit/log/levels/levels.go +++ /dev/null @@ -1,127 +0,0 @@ -package levels - -import "github.com/go-kit/kit/log" - -// Levels provides a leveled logging wrapper around a logger. It has five -// levels: debug, info, warning (warn), error, and critical (crit). If you -// want a different set of levels, you can create your own levels type very -// easily, and you can elide the configuration. -type Levels struct { - ctx *log.Context - levelKey string - - // We have a choice between storing level values in string fields or - // making a separate context for each level. When using string fields the - // Log method must combine the base context, the level data, and the - // logged keyvals; but the With method only requires updating one context. - // If we instead keep a separate context for each level the Log method - // must only append the new keyvals; but the With method would have to - // update all five contexts. - - // Roughly speaking, storing multiple contexts breaks even if the ratio of - // Log/With calls is more than the number of levels. We have chosen to - // make the With method cheap and the Log method a bit more costly because - // we do not expect most applications to Log more than five times for each - // call to With. - - debugValue string - infoValue string - warnValue string - errorValue string - critValue string -} - -// New creates a new leveled logger, wrapping the passed logger. -func New(logger log.Logger, options ...Option) Levels { - l := Levels{ - ctx: log.NewContext(logger), - levelKey: "level", - - debugValue: "debug", - infoValue: "info", - warnValue: "warn", - errorValue: "error", - critValue: "crit", - } - for _, option := range options { - option(&l) - } - return l -} - -// With returns a new leveled logger that includes keyvals in all log events. -func (l Levels) With(keyvals ...interface{}) Levels { - return Levels{ - ctx: l.ctx.With(keyvals...), - levelKey: l.levelKey, - debugValue: l.debugValue, - infoValue: l.infoValue, - warnValue: l.warnValue, - errorValue: l.errorValue, - critValue: l.critValue, - } -} - -// Debug returns a debug level logger. -func (l Levels) Debug() log.Logger { - return l.ctx.WithPrefix(l.levelKey, l.debugValue) -} - -// Info returns an info level logger. -func (l Levels) Info() log.Logger { - return l.ctx.WithPrefix(l.levelKey, l.infoValue) -} - -// Warn returns a warning level logger. -func (l Levels) Warn() log.Logger { - return l.ctx.WithPrefix(l.levelKey, l.warnValue) -} - -// Error returns an error level logger. -func (l Levels) Error() log.Logger { - return l.ctx.WithPrefix(l.levelKey, l.errorValue) -} - -// Crit returns a critical level logger. -func (l Levels) Crit() log.Logger { - return l.ctx.WithPrefix(l.levelKey, l.critValue) -} - -// Option sets a parameter for leveled loggers. -type Option func(*Levels) - -// Key sets the key for the field used to indicate log level. By default, -// the key is "level". -func Key(key string) Option { - return func(l *Levels) { l.levelKey = key } -} - -// DebugValue sets the value for the field used to indicate the debug log -// level. By default, the value is "debug". -func DebugValue(value string) Option { - return func(l *Levels) { l.debugValue = value } -} - -// InfoValue sets the value for the field used to indicate the info log level. -// By default, the value is "info". -func InfoValue(value string) Option { - return func(l *Levels) { l.infoValue = value } -} - -// WarnValue sets the value for the field used to indicate the warning log -// level. By default, the value is "warn". -func WarnValue(value string) Option { - return func(l *Levels) { l.warnValue = value } -} - -// ErrorValue sets the value for the field used to indicate the error log -// level. By default, the value is "error". -func ErrorValue(value string) Option { - return func(l *Levels) { l.errorValue = value } -} - -// CritValue sets the value for the field used to indicate the critical log -// level. By default, the value is "crit". -func CritValue(value string) Option { - return func(l *Levels) { l.critValue = value } -} diff --git a/vendor/github.com/go-kit/kit/log/levels/levels_test.go b/vendor/github.com/go-kit/kit/log/levels/levels_test.go deleted file mode 100644 index 270963c..0000000 --- a/vendor/github.com/go-kit/kit/log/levels/levels_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package levels_test - -import ( - "bytes" - "os" - "testing" - - "github.com/go-kit/kit/log" - "github.com/go-kit/kit/log/levels" -) - -func TestDefaultLevels(t *testing.T) { - buf := bytes.Buffer{} - logger := levels.New(log.NewLogfmtLogger(&buf)) - - logger.Debug().Log("msg", "résumé") // of course you'd want to do this - if want, have := "level=debug msg=résumé\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } - - buf.Reset() - logger.Info().Log("msg", "Åhus") - if want, have := "level=info msg=Åhus\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } - - buf.Reset() - logger.Error().Log("msg", "© violation") - if want, have := "level=error msg=\"© violation\"\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } - - buf.Reset() - logger.Crit().Log("msg", " ") - if want, have := "level=crit msg=\"\\t\"\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } -} - -func TestModifiedLevels(t *testing.T) { - buf := bytes.Buffer{} - logger := levels.New( - log.NewJSONLogger(&buf), - levels.Key("l"), - levels.DebugValue("dbg"), - levels.InfoValue("nfo"), - levels.WarnValue("wrn"), - levels.ErrorValue("err"), - levels.CritValue("crt"), - ) - logger.With("easter_island", "176°").Debug().Log("msg", "moai") - if want, have := `{"easter_island":"176°","l":"dbg","msg":"moai"}`+"\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } -} - -func ExampleLevels() { - logger := levels.New(log.NewLogfmtLogger(os.Stdout)) - logger.Debug().Log("msg", "hello") - logger.With("context", "foo").Warn().Log("err", "error") - - // Output: - // level=debug msg=hello - // level=warn context=foo err=error -} diff --git a/vendor/github.com/go-kit/kit/log/log.go b/vendor/github.com/go-kit/kit/log/log.go deleted file mode 100644 index 25e76cb..0000000 --- a/vendor/github.com/go-kit/kit/log/log.go +++ /dev/null @@ -1,181 +0,0 @@ -// Package log provides basic interfaces for structured logging. -// -// The fundamental interface is Logger. Loggers create log events from -// key/value data. -package log - -import ( - "errors" - "sync/atomic" -) - -// Logger is the fundamental interface for all log operations. Log creates a -// log event from keyvals, a variadic sequence of alternating keys and values. -// Implementations must be safe for concurrent use by multiple goroutines. In -// particular, any implementation of Logger that appends to keyvals or -// modifies any of its elements must make a copy first. -type Logger interface { - Log(keyvals ...interface{}) error -} - -// ErrMissingValue is appended to keyvals slices with odd length to substitute -// the missing value. -var ErrMissingValue = errors.New("(MISSING)") - -// NewContext returns a new Context that logs to logger. -func NewContext(logger Logger) *Context { - if c, ok := logger.(*Context); ok { - return c - } - return &Context{logger: logger} -} - -// Context must always have the same number of stack frames between calls to -// its Log method and the eventual binding of Valuers to their value. This -// requirement comes from the functional requirement to allow a context to -// resolve application call site information for a log.Caller stored in the -// context. To do this we must be able to predict the number of logging -// functions on the stack when bindValues is called. -// -// Three implementation details provide the needed stack depth consistency. -// The first two of these details also result in better amortized performance, -// and thus make sense even without the requirements regarding stack depth. -// The third detail, however, is subtle and tied to the implementation of the -// Go compiler. -// -// 1. NewContext avoids introducing an additional layer when asked to -// wrap another Context. -// 2. With avoids introducing an additional layer by returning a newly -// constructed Context with a merged keyvals rather than simply -// wrapping the existing Context. -// 3. All of Context's methods take pointer receivers even though they -// do not mutate the Context. -// -// Before explaining the last detail, first some background. The Go compiler -// generates wrapper methods to implement the auto dereferencing behavior when -// calling a value method through a pointer variable. These wrapper methods -// are also used when calling a value method through an interface variable -// because interfaces store a pointer to the underlying concrete value. -// Calling a pointer receiver through an interface does not require generating -// an additional function. -// -// If Context had value methods then calling Context.Log through a variable -// with type Logger would have an extra stack frame compared to calling -// Context.Log through a variable with type Context. Using pointer receivers -// avoids this problem. - -// A Context wraps a Logger and holds keyvals that it includes in all log -// events. When logging, a Context replaces all value elements (odd indexes) -// containing a Valuer with their generated value for each call to its Log -// method. -type Context struct { - logger Logger - keyvals []interface{} - hasValuer bool -} - -// Log replaces all value elements (odd indexes) containing a Valuer in the -// stored context with their generated value, appends keyvals, and passes the -// result to the wrapped Logger. -func (l *Context) Log(keyvals ...interface{}) error { - kvs := append(l.keyvals, keyvals...) - if len(kvs)%2 != 0 { - kvs = append(kvs, ErrMissingValue) - } - if l.hasValuer { - // If no keyvals were appended above then we must copy l.keyvals so - // that future log events will reevaluate the stored Valuers. - if len(keyvals) == 0 { - kvs = append([]interface{}{}, l.keyvals...) - } - bindValues(kvs[:len(l.keyvals)]) - } - return l.logger.Log(kvs...) -} - -// With returns a new Context with keyvals appended to those of the receiver. -func (l *Context) With(keyvals ...interface{}) *Context { - if len(keyvals) == 0 { - return l - } - kvs := append(l.keyvals, keyvals...) - if len(kvs)%2 != 0 { - kvs = append(kvs, ErrMissingValue) - } - return &Context{ - logger: l.logger, - // Limiting the capacity of the stored keyvals ensures that a new - // backing array is created if the slice must grow in Log or With. - // Using the extra capacity without copying risks a data race that - // would violate the Logger interface contract. - keyvals: kvs[:len(kvs):len(kvs)], - hasValuer: l.hasValuer || containsValuer(keyvals), - } -} - -// WithPrefix returns a new Context with keyvals prepended to those of the -// receiver. -func (l *Context) WithPrefix(keyvals ...interface{}) *Context { - if len(keyvals) == 0 { - return l - } - // Limiting the capacity of the stored keyvals ensures that a new - // backing array is created if the slice must grow in Log or With. - // Using the extra capacity without copying risks a data race that - // would violate the Logger interface contract. - n := len(l.keyvals) + len(keyvals) - if len(keyvals)%2 != 0 { - n++ - } - kvs := make([]interface{}, 0, n) - kvs = append(kvs, keyvals...) - if len(kvs)%2 != 0 { - kvs = append(kvs, ErrMissingValue) - } - kvs = append(kvs, l.keyvals...) - return &Context{ - logger: l.logger, - keyvals: kvs, - hasValuer: l.hasValuer || containsValuer(keyvals), - } -} - -// LoggerFunc is an adapter to allow use of ordinary functions as Loggers. If -// f is a function with the appropriate signature, LoggerFunc(f) is a Logger -// object that calls f. -type LoggerFunc func(...interface{}) error - -// Log implements Logger by calling f(keyvals...). -func (f LoggerFunc) Log(keyvals ...interface{}) error { - return f(keyvals...) -} - -// SwapLogger wraps another logger that may be safely replaced while other -// goroutines use the SwapLogger concurrently. The zero value for a SwapLogger -// will discard all log events without error. -// -// SwapLogger serves well as a package global logger that can be changed by -// importers. -type SwapLogger struct { - logger atomic.Value -} - -type loggerStruct struct { - Logger -} - -// Log implements the Logger interface by forwarding keyvals to the currently -// wrapped logger. It does not log anything if the wrapped logger is nil. -func (l *SwapLogger) Log(keyvals ...interface{}) error { - s, ok := l.logger.Load().(loggerStruct) - if !ok || s.Logger == nil { - return nil - } - return s.Log(keyvals...) -} - -// Swap replaces the currently wrapped logger with logger. Swap may be called -// concurrently with calls to Log from other goroutines. -func (l *SwapLogger) Swap(logger Logger) { - l.logger.Store(loggerStruct{logger}) -} diff --git a/vendor/github.com/go-kit/kit/log/log_test.go b/vendor/github.com/go-kit/kit/log/log_test.go deleted file mode 100644 index 7cd0844..0000000 --- a/vendor/github.com/go-kit/kit/log/log_test.go +++ /dev/null @@ -1,255 +0,0 @@ -package log_test - -import ( - "bytes" - "fmt" - "sync" - "testing" - - "github.com/go-kit/kit/log" - "github.com/go-stack/stack" -) - -func TestContext(t *testing.T) { - t.Parallel() - buf := &bytes.Buffer{} - logger := log.NewLogfmtLogger(buf) - - kvs := []interface{}{"a", 123} - lc := log.NewContext(logger).With(kvs...) - kvs[1] = 0 // With should copy its key values - - lc = lc.With("b", "c") // With should stack - if err := lc.Log("msg", "message"); err != nil { - t.Fatal(err) - } - if want, have := "a=123 b=c msg=message\n", buf.String(); want != have { - t.Errorf("\nwant: %shave: %s", want, have) - } - - buf.Reset() - lc = lc.WithPrefix("p", "first") - if err := lc.Log("msg", "message"); err != nil { - t.Fatal(err) - } - if want, have := "p=first a=123 b=c msg=message\n", buf.String(); want != have { - t.Errorf("\nwant: %shave: %s", want, have) - } -} - -func TestContextMissingValue(t *testing.T) { - t.Parallel() - var output []interface{} - logger := log.Logger(log.LoggerFunc(func(keyvals ...interface{}) error { - output = keyvals - return nil - })) - - lc := log.NewContext(logger) - - lc.Log("k") - if want, have := 2, len(output); want != have { - t.Errorf("want len(output) == %v, have %v", want, have) - } - if want, have := log.ErrMissingValue, output[1]; want != have { - t.Errorf("want %#v, have %#v", want, have) - } - - lc.With("k1").WithPrefix("k0").Log("k2") - if want, have := 6, len(output); want != have { - t.Errorf("want len(output) == %v, have %v", want, have) - } - for i := 1; i < 6; i += 2 { - if want, have := log.ErrMissingValue, output[i]; want != have { - t.Errorf("want output[%d] == %#v, have %#v", i, want, have) - } - } -} - -// Test that Context.Log has a consistent function stack depth when binding -// log.Valuers, regardless of how many times Context.With has been called or -// whether Context.Log is called via an interface typed variable or a concrete -// typed variable. -func TestContextStackDepth(t *testing.T) { - fn := fmt.Sprintf("%n", stack.Caller(0)) - - var output []interface{} - - logger := log.Logger(log.LoggerFunc(func(keyvals ...interface{}) error { - output = keyvals - return nil - })) - - stackValuer := log.Valuer(func() interface{} { - for i, c := range stack.Trace() { - if fmt.Sprintf("%n", c) == fn { - return i - } - } - t.Fatal("Test function not found in stack trace.") - return nil - }) - - concrete := log.NewContext(logger).With("stack", stackValuer) - var iface log.Logger = concrete - - // Call through interface to get baseline. - iface.Log("k", "v") - want := output[1].(int) - - for len(output) < 10 { - concrete.Log("k", "v") - if have := output[1]; have != want { - t.Errorf("%d Withs: have %v, want %v", len(output)/2-1, have, want) - } - - iface.Log("k", "v") - if have := output[1]; have != want { - t.Errorf("%d Withs: have %v, want %v", len(output)/2-1, have, want) - } - - wrapped := log.NewContext(concrete) - wrapped.Log("k", "v") - if have := output[1]; have != want { - t.Errorf("%d Withs: have %v, want %v", len(output)/2-1, have, want) - } - - concrete = concrete.With("k", "v") - iface = concrete - } -} - -// Test that With returns a Logger safe for concurrent use. This test -// validates that the stored logging context does not get corrupted when -// multiple clients concurrently log additional keyvals. -// -// This test must be run with go test -cpu 2 (or more) to achieve its goal. -func TestWithConcurrent(t *testing.T) { - // Create some buckets to count how many events each goroutine logs. - const goroutines = 8 - counts := [goroutines]int{} - - // This logger extracts a goroutine id from the last value field and - // increments the referenced bucket. - logger := log.LoggerFunc(func(kv ...interface{}) error { - goroutine := kv[len(kv)-1].(int) - counts[goroutine]++ - return nil - }) - - // With must be careful about handling slices that can grow without - // copying the underlying array, so give it a challenge. - l := log.NewContext(logger).With(make([]interface{}, 0, 2)...) - - // Start logging concurrently. Each goroutine logs its id so the logger - // can bucket the event counts. - var wg sync.WaitGroup - wg.Add(goroutines) - const n = 10000 - for i := 0; i < goroutines; i++ { - go func(idx int) { - defer wg.Done() - for j := 0; j < n; j++ { - l.Log("goroutineIdx", idx) - } - }(i) - } - wg.Wait() - - for bucket, have := range counts { - if want := n; want != have { - t.Errorf("bucket %d: want %d, have %d", bucket, want, have) // note Errorf - } - } -} - -func BenchmarkDiscard(b *testing.B) { - logger := log.NewNopLogger() - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - logger.Log("k", "v") - } -} - -func BenchmarkOneWith(b *testing.B) { - logger := log.NewNopLogger() - lc := log.NewContext(logger).With("k", "v") - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - lc.Log("k", "v") - } -} - -func BenchmarkTwoWith(b *testing.B) { - logger := log.NewNopLogger() - lc := log.NewContext(logger).With("k", "v") - for i := 1; i < 2; i++ { - lc = lc.With("k", "v") - } - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - lc.Log("k", "v") - } -} - -func BenchmarkTenWith(b *testing.B) { - logger := log.NewNopLogger() - lc := log.NewContext(logger).With("k", "v") - for i := 1; i < 10; i++ { - lc = lc.With("k", "v") - } - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - lc.Log("k", "v") - } -} - -func TestSwapLogger(t *testing.T) { - var logger log.SwapLogger - - // Zero value does not panic or error. - err := logger.Log("k", "v") - if got, want := err, error(nil); got != want { - t.Errorf("got %v, want %v", got, want) - } - - buf := &bytes.Buffer{} - json := log.NewJSONLogger(buf) - logger.Swap(json) - - if err := logger.Log("k", "v"); err != nil { - t.Error(err) - } - if got, want := buf.String(), `{"k":"v"}`+"\n"; got != want { - t.Errorf("got %v, want %v", got, want) - } - - buf.Reset() - prefix := log.NewLogfmtLogger(buf) - logger.Swap(prefix) - - if err := logger.Log("k", "v"); err != nil { - t.Error(err) - } - if got, want := buf.String(), "k=v\n"; got != want { - t.Errorf("got %v, want %v", got, want) - } - - buf.Reset() - logger.Swap(nil) - - if err := logger.Log("k", "v"); err != nil { - t.Error(err) - } - if got, want := buf.String(), ""; got != want { - t.Errorf("got %v, want %v", got, want) - } -} - -func TestSwapLoggerConcurrency(t *testing.T) { - testConcurrency(t, &log.SwapLogger{}) -} diff --git a/vendor/github.com/go-kit/kit/log/logfmt_logger.go b/vendor/github.com/go-kit/kit/log/logfmt_logger.go deleted file mode 100644 index 4ff5555..0000000 --- a/vendor/github.com/go-kit/kit/log/logfmt_logger.go +++ /dev/null @@ -1,61 +0,0 @@ -package log - -import ( - "bytes" - "io" - "sync" - - "github.com/go-logfmt/logfmt" -) - -type logfmtEncoder struct { - *logfmt.Encoder - buf bytes.Buffer -} - -func (l *logfmtEncoder) Reset() { - l.Encoder.Reset() - l.buf.Reset() -} - -var logfmtEncoderPool = sync.Pool{ - New: func() interface{} { - var enc logfmtEncoder - enc.Encoder = logfmt.NewEncoder(&enc.buf) - return &enc - }, -} - -type logfmtLogger struct { - w io.Writer -} - -// NewLogfmtLogger returns a logger that encodes keyvals to the Writer in -// logfmt format. The passed Writer must be safe for concurrent use by -// multiple goroutines if the returned Logger will be used concurrently. -func NewLogfmtLogger(w io.Writer) Logger { - return &logfmtLogger{w} -} - -func (l logfmtLogger) Log(keyvals ...interface{}) error { - enc := logfmtEncoderPool.Get().(*logfmtEncoder) - enc.Reset() - defer logfmtEncoderPool.Put(enc) - - if err := enc.EncodeKeyvals(keyvals...); err != nil { - return err - } - - // Add newline to the end of the buffer - if err := enc.EndRecord(); err != nil { - return err - } - - // The Logger interface requires implementations to be safe for concurrent - // use by multiple goroutines. For this implementation that means making - // only one call to l.w.Write() for each call to Log. - if _, err := l.w.Write(enc.buf.Bytes()); err != nil { - return err - } - return nil -} diff --git a/vendor/github.com/go-kit/kit/log/logfmt_logger_test.go b/vendor/github.com/go-kit/kit/log/logfmt_logger_test.go deleted file mode 100644 index 185e948..0000000 --- a/vendor/github.com/go-kit/kit/log/logfmt_logger_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package log_test - -import ( - "bytes" - "errors" - "io/ioutil" - "testing" - - "github.com/go-kit/kit/log" - "github.com/go-logfmt/logfmt" -) - -func TestLogfmtLogger(t *testing.T) { - buf := &bytes.Buffer{} - logger := log.NewLogfmtLogger(buf) - - if err := logger.Log("hello", "world"); err != nil { - t.Fatal(err) - } - if want, have := "hello=world\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } - - buf.Reset() - if err := logger.Log("a", 1, "err", errors.New("error")); err != nil { - t.Fatal(err) - } - if want, have := "a=1 err=error\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } - - buf.Reset() - if err := logger.Log("std_map", map[int]int{1: 2}, "my_map", mymap{0: 0}); err != nil { - t.Fatal(err) - } - if want, have := "std_map=\""+logfmt.ErrUnsupportedValueType.Error()+"\" my_map=special_behavior\n", buf.String(); want != have { - t.Errorf("want %#v, have %#v", want, have) - } -} - -func BenchmarkLogfmtLoggerSimple(b *testing.B) { - benchmarkRunner(b, log.NewLogfmtLogger(ioutil.Discard), baseMessage) -} - -func BenchmarkLogfmtLoggerContextual(b *testing.B) { - benchmarkRunner(b, log.NewLogfmtLogger(ioutil.Discard), withMessage) -} - -func TestLogfmtLoggerConcurrency(t *testing.T) { - testConcurrency(t, log.NewLogfmtLogger(ioutil.Discard)) -} - -type mymap map[int]int - -func (m mymap) String() string { return "special_behavior" } diff --git a/vendor/github.com/go-kit/kit/log/nop_logger.go b/vendor/github.com/go-kit/kit/log/nop_logger.go deleted file mode 100644 index 1047d62..0000000 --- a/vendor/github.com/go-kit/kit/log/nop_logger.go +++ /dev/null @@ -1,8 +0,0 @@ -package log - -type nopLogger struct{} - -// NewNopLogger returns a logger that doesn't do anything. -func NewNopLogger() Logger { return nopLogger{} } - -func (nopLogger) Log(...interface{}) error { return nil } diff --git a/vendor/github.com/go-kit/kit/log/nop_logger_test.go b/vendor/github.com/go-kit/kit/log/nop_logger_test.go deleted file mode 100644 index 043553e..0000000 --- a/vendor/github.com/go-kit/kit/log/nop_logger_test.go +++ /dev/null @@ -1,17 +0,0 @@ -package log_test - -import ( - "testing" - - "github.com/go-kit/kit/log" -) - -func TestNopLogger(t *testing.T) { - logger := log.NewNopLogger() - if err := logger.Log("abc", 123); err != nil { - t.Error(err) - } - if err := log.NewContext(logger).With("def", "ghi").Log(); err != nil { - t.Error(err) - } -} diff --git a/vendor/github.com/go-kit/kit/log/stdlib.go b/vendor/github.com/go-kit/kit/log/stdlib.go deleted file mode 100644 index 7ffd1ca..0000000 --- a/vendor/github.com/go-kit/kit/log/stdlib.go +++ /dev/null @@ -1,116 +0,0 @@ -package log - -import ( - "io" - "log" - "regexp" - "strings" -) - -// StdlibWriter implements io.Writer by invoking the stdlib log.Print. It's -// designed to be passed to a Go kit logger as the writer, for cases where -// it's necessary to redirect all Go kit log output to the stdlib logger. -// -// If you have any choice in the matter, you shouldn't use this. Prefer to -// redirect the stdlib log to the Go kit logger via NewStdlibAdapter. -type StdlibWriter struct{} - -// Write implements io.Writer. -func (w StdlibWriter) Write(p []byte) (int, error) { - log.Print(strings.TrimSpace(string(p))) - return len(p), nil -} - -// StdlibAdapter wraps a Logger and allows it to be passed to the stdlib -// logger's SetOutput. It will extract date/timestamps, filenames, and -// messages, and place them under relevant keys. -type StdlibAdapter struct { - Logger - timestampKey string - fileKey string - messageKey string -} - -// StdlibAdapterOption sets a parameter for the StdlibAdapter. -type StdlibAdapterOption func(*StdlibAdapter) - -// TimestampKey sets the key for the timestamp field. By default, it's "ts". -func TimestampKey(key string) StdlibAdapterOption { - return func(a *StdlibAdapter) { a.timestampKey = key } -} - -// FileKey sets the key for the file and line field. By default, it's "file". -func FileKey(key string) StdlibAdapterOption { - return func(a *StdlibAdapter) { a.fileKey = key } -} - -// MessageKey sets the key for the actual log message. By default, it's "msg". -func MessageKey(key string) StdlibAdapterOption { - return func(a *StdlibAdapter) { a.messageKey = key } -} - -// NewStdlibAdapter returns a new StdlibAdapter wrapper around the passed -// logger. It's designed to be passed to log.SetOutput. -func NewStdlibAdapter(logger Logger, options ...StdlibAdapterOption) io.Writer { - a := StdlibAdapter{ - Logger: logger, - timestampKey: "ts", - fileKey: "file", - messageKey: "msg", - } - for _, option := range options { - option(&a) - } - return a -} - -func (a StdlibAdapter) Write(p []byte) (int, error) { - result := subexps(p) - keyvals := []interface{}{} - var timestamp string - if date, ok := result["date"]; ok && date != "" { - timestamp = date - } - if time, ok := result["time"]; ok && time != "" { - if timestamp != "" { - timestamp += " " - } - timestamp += time - } - if timestamp != "" { - keyvals = append(keyvals, a.timestampKey, timestamp) - } - if file, ok := result["file"]; ok && file != "" { - keyvals = append(keyvals, a.fileKey, file) - } - if msg, ok := result["msg"]; ok { - keyvals = append(keyvals, a.messageKey, msg) - } - if err := a.Logger.Log(keyvals...); err != nil { - return 0, err - } - return len(p), nil -} - -const ( - logRegexpDate = `(?P[0-9]{4}/[0-9]{2}/[0-9]{2})?[ ]?` - logRegexpTime = `(?P&=f)W6atGKd5>xRY1k;yd-osfNHk%w(pSIkSJR}s%CbIzpCBDtYY=*J;YmCpK(!$ z{=%!xyRup!?c$mDDtrr%Z2fUP=Uuzb8~ky_>D8=L-bllblEU&kHXxlVPRqAwPf#W>>HMkH9Nqr#_OFUZj*(t_Oa(X zvqSLvdt*ZIx7*fJLZhgh=@B1$a1uMBCYd}ugBBKaoA6AN+8*pE$%~{G*$MIRo%pKe z@Zu2i~7jb_H9ysQ;wzitkUj>^GU_|t?ZN6`X$&J|EP;N!`M;Y$> zR2Rz*ss{F>NkCvtT~Pn9M4ghAm>s?+lSsotK%%&`OZj89o~ik~%{}ts%p43#E>7EI zHdg8R>a>53NcMAM(B*7vW3cs%mTA!pd2D~I=(qvgnR^yWH zH#e`?6ifM3Z4ni%da}sI#Y{0%x=u3K)n6^i>~sLO)Q%{$utkGp{3s;TLS~{~$1+)* zvb@SG_lQITT9qXQXLMzV`n~loAx=L}a-9?+HP}(c!-Y)70&K?HQU^SYH~+EXqWqpW zQ1tv%?UgXX$4$Fde5*sdNft2tNifPrX&nb@n2}h#jh#+P_sXG}O@a7D6W-8#jretL z*@>F7+VZfeSSK7Z=iW7i?59=+PZKDKaMmxKNJP8XG-GL5b0yUx=%ra-x{6V{M+;Sw zjY_BrC=>Vw31k`kmZtLV?s08@m#=<5cOva;-&YfWK@6m%axO=b>l6QHkGL_-xwlxW zl(7-+EYZ!26$jR-W{d(hE(td&+|D#P2E1Xp)yBV*9<5Tiv;DJwXjISZG)(Qsq_ApI zvn~~_X;_XTdFEs2 zaTgGAU|H0|dZW92VwP938&+FaMsl|q1Sd?$D(%bPDf?log!g?7W|zfg{KsOdd?HOY z+Y_uH7v4ek^Ynr7?^3%THBv=F2R|MLnh!Clm)!mKX5-3?k7z4;j((hSWPR7ahC5s3 z<$*dizBZ>AzRFKw=*Q$N4*9_@1Y^JW6tSgp@%UFhdj$pJTAIz}(*H5H1Te??1RF8C zBvt7*YhJk5b8#+wNGn}8^Wbf=sQdP_9klcy-66cRuYjWq!h3qw5K^}S_RmHb!H(fR zBTCR;3Vm-q_bQ|#w3Stf8QBzln}ceo7vRNAEqZCAcmm@7^Sh!c?Br0G-*jLpT?~5< zHkK0m+}Y(?>01}V`wEAKPQ);^>kq0QE@x`vW}!$t+>4a24kx}{pfPPe?dP?Q3P}Lu z#P*LR_`n<_9l#(&A(u|07~ib)QTsCcu$J{D=~F4Ur|Rv8V!v)q5VjiVmGsOu2r+SG z%&)2-IIS>tmZ)Ij5$OVraeq;1`g%G}CvFLetCwznedZs@A_}>?H(Wv=2A?yvFW2O4 za(B6Jx15btl~#j&BKp<7bJ=%@63Sxx+tt|)4eG&+W<06odP0w?9YzSBW>A2~l58$* z|4*vUlyY}8TtcbT4#!QI^T)?J7maInU0DlTr~A@_bLhy_2d*H^Aev2tA)@oo!$Sl~iDW_7O(jD^?Bc;ZeU zg^$NeB#!j>GApE|g!$I_VNt?@QVj{(|Id_?SzIR?!pKc^QfMEbFkqPy9>8AuMAaiC zqU3(*cR#pqf6;l+n@jSxpB*ySa^Fs!mfPu0J2KSIYA(wK!UCe?-6*R5=n+?XlIvr( z`pV?&l41=trjryFo%3Qw6+r~md34uur9Pe#`rAZtu_Z+!;vZ=LVCyU-kY{xF( z81ru~DSEH9l}mnBxq)k%AhY@fqL1p4$e2@smS& zOhqfSDzym?JMr$bg?(?{>9t!Rt#$|Gajp5Bb|TD2+}po@f4QTi*JwiNak7w9Avyf> zIV1Z03TlA@PU9z=OU~f`Bx4SkHk<05>D|N3{oJRO1M`0GYuklH%9JLSm~4mT=CNO0 zM{Au~Ts1~*@w=TaPDOJ_2H%A!4od@H(M7M zb}w_FSGLqtzRAq{*5kmU)sdS9tXw!&i}as@6yM2Wv*J8Yc*`ocI4p{<-JN_nH8}YW z9GZU10Z_AA!1%;?Zyb=8;KWUNgwO*MDCKk&(_^9&v$e}qgF4QEv&Jt5+d#AbD{-gK z?OfixVLHa5qvQ$lfAmMUfq4G<0F24XDu4X=@f$I4-gQaX zp`7!!q}#bPG>=2B@N$Ly(wUyye$Kay+lZf^|K~Vx%2h5J1ii$6YZA%+nj?{hIc?%U ztHr^P>qF{WpLA54ZM4<6kd~GXpWrqEPHj^cI+g`vllFjm#R!!U3rlQ`K*+mM!J5zi ziLZ?l=&t_u(`6i0;FiVy^mX^Y09ph#UP7~H}a3N z7j$x{EmZ(JLh^KRG0jv#%_A~0^7}S6z$oZEr>3W`cSpmXG>ha)7g)vKM|XD8b8>2| z%6c3xH618lJ2@x5F5TSRv_o*Id8q(eSI^ngKax-V&9_U52>&4bbX_3FFLY47}*T>6g$oQ;PFE2P@#+2O&IK#H?`;P3a!kH+vKJjxquvD>(knzAvao5WqqmN zKN4=Q{AT0>z7W1#cRdMo7V+rZv-FN%<6(9n8WF4>-7DFVN=UEHBnTU5E@zf;9;`fH z9fpry)rR{{$oZ1I0T+zl zi$XMhbZ=3dQB+!W^Wey$8;5AvFHVoh0G92#Y#{cnZR(XIs1L-v$5@D0|;5&UDI&i@!QaK7=A z&*)JKevNE-Q^s*AglHrrdPW7_)ND9KK|(wwirIZrFuL}}stc>P65-EQj%;uISfDmJ zK5RJhuM=|`|6^#5^RcTzal=1vH|#Uf=u=O6+<%GG`A6f5g~2c=Y?J z5j{t(n>c0{HWiDE*UHZYDrEj~1jow$d_(H2Z`10u1>3~m(z{^<(U`cws3oxX5NN4h zHiH3Sn4&e@mLen06UOX%q@qc4iO^f=xK&$qK%7%wGcRpn{KV{Fw;cHx*ON4~buUz* zVHv!L>|OZ$e#rho%d79r(CCo12WH0)!t0pH$6DCXxX~C-aV=7PIp6Xf{ZX*t>IjbZ zrY&nQ{#Ehf%cKqI4hR0kMaA2$MPJ=9-n_PFcrBy4W{%ndzzSb?*OB6Q$6B%GN@&ux zPNbiE!L2C;5d4B8CcZq-Y{KlQi(7o@hYeMU9dwHrfj-_*{w`2<4`ErA4qX`GvqFVs z%RM<}5Tc?muxHM7E?m-tPak;-OqUqrEx%tH(l)C5=z63%3v8!j@x@3@VoLbPiZx$O z6JB@S_q_)@_j>EjQkJ+^@AHrZk(T6H-{B4_9>l}N*~Li1GEgIKQMkY%R=vH5*F`U< z;X!p4n8C1viVpE0V614V2ghp=ZZMcPzh)rrPbW91tYltrzgN=2=|%aT#R*mw1&`|r zVwCT(r+bm@>WxT85I(f%7@g_nGS$)UOHKBT zHTCu&dlsz%kRTbyZe8T79<&8%7P?o9lymXdi{4ZbLPNfHP2=x!Y7PLy2Dzad;P?I9 z+2U8G|7;zbv1Sl_tmuS0a)J1}>ko+?p4~GkO@!nAh@mYnE&7Vd!uGg~6NBK_A-TXL zlqKmuliCaYP4toQ$GPw)z~WfdI>|zxZ+@n{OzF;~&tg~b1min#S-Zkl_rKrSTGXU3 z{2u$ROQY}+MMh(;E`+0WU(*qm&B1YeOJSU2P*trPuq&bho418sZ>+pNe{PAqFK7z< z9NxgM(@=|Ov@$oDRZ48wx~j{!4!8;OovM-eV%C&zwLX(Qc!tlrLTOg!tdC_!aJ<-K zVa`BM0a@yOEJuHy+ftgNuG?5n1#5M=V5HW+_CPKOtf#gW`? zbEUY-B)!Zzj_{gsL!)dW^U%?W8-4jn%EJwT5?nI?RqH*5bL(BOTa=-BMAmJfiV@SxG&=HLw}xS}N1^ znnx`M{q)nrv@*36VjiXH*(d1U!}WA6Pw_iF9h-ML88JI!;l@Yl9F&M`1!lyH_mC28 zgi0)S@XW6Ci^$R8H(UzvW=H78HR&!zOAR5m`Xj3yjiAZ+CShuS>dxaMot+Kk?3~pL zhWdKoMwpsC)Ciif=Vc1@tv7#^pC&i7wn8g-*Ewhm!4q5EU8>Vsc#JRT0S@pnova}J zWt5d4Ip3W+u3p?4UUX8A!e?&BZtt-~43ew9hj78NaYdc6X8^uTJY4I=8 znr=E!;x83CDYc&a`lfz=MmluR=V#ZQ(YKnIe}!mNcf(j!)b)#b*dT!HH(8Uekq=9! zDQjk45uMK5UFL&H>I7JA6)9ke%<#G|2kOqdc@Vzx=SVm%b*8 zeC{UZ{`96 zYtqOOaWjf1k|X@`*0k3bm%IE2Zx*dlY^AGRUtUx058i&s&deY4)PNnUqvBrc!Su~L zs!1R+EEUCbKE6oKWqBqLT)S@J5EUT>w2X>$?fmT7V<>!}@&EF+^UTvxZJzGxDkA*p z6GAXPB<7(FYV)w5Z1ZPNzM2lrO@O_nL(+f?`U7w>?pY09LJsOSpC0$M)gFv&6!%y zewx~+xz+R=aq@djGzMl9N9BuO&i{SOXu>oQe2&QPRp!Jn5PU2fO74R?Pl@LX&2~#K zIh-c(;sq@$W|*!ry;;%}PLLSwj5XA)>@(fNu+}DvA@eCh9lZo5`L8&xDL| zS(_`W*`!rUD0y@~^*~{@EQV4*)!(3--^Zj@V+OFhd~u%ul-7Pk}TN-ECo5ABEyH zBc)>0NQ@4|vbo%`EUBIrYB6Ed&q>A4^jfxG4FrDr0dPCX6#R@ClKcayZ8IVmOgKyl z&+OK3$#@JbGDPg+vxw@SSd)+Uq=#uv8D1rc1}^B>3wsp_Ww@!BiOzPc5NW#mg9HoQ z^q}i_7imh@y&?q%(oiFDI&vam2S-;?J{d_@1rj6&pL~Vm#q0Cov%dRI2fO=6Otln9 zW(!Uo2}fu0xE!cvKR}_I6>Fl=y%HszNr=4eD4#@8`NQlerY=m`2J)wEq8wZ#Oaov4U!WL{Ob6viXj`B|uJyM3#7V#UbcecWF?7@2% zF$BAOW(MQAQHCFjLpKH(zSDY!I-oHqqb<4ZM(E@D)2LwY>h8ND5q zF;TbdWf2|O;BI>KbRvC5tfGs|+YUeuxOHS(ff~AjPGF3ddHq=hW(yYA$F@KXAv+vB@NHG^L?03JEH<@dTrFCh=hEaT$QAk)`=1$1s9K zTltj>@u}$v1|xTAPQ^U_2R0;YK{P{0z3(+C~ZDZ#z=Z*@TdJi02J`Ene(3gX3(WW`DD zk0%Y-)N|~&X4rF^uLcS=NrvrWhuOgJzc7O#wwW4XYD5@?r0^!Rtm3Gxk-zprc3RQG z^4nU2`HFRlrJNw@ z@31yseG;SezihWI^|{HesIAiPg1~?RIfxcYg&CkgKcIHGTt1o=Yhr;w4JGOgh8hSU zkV^m~x3|Ex5(uQ(XvN5_F8~DsDu^p5;4Uv(8VFQolcs6+LA(MH6xcgmiPpg`?EL5Y zmwNf)rET3GQu6?*-x^XNkYZ++LW%Tx>AgDeh9p~lOju>Q1o#mK0>;i9`LQ)692yXa zQCBDx-kTvV6QH~itx2?(#HIK^4g#TONtbM7`J}{GA)0;7s?%G0+?l%kwG^D@= znHo5eyM%OuKqe_ys*Fk}?Tz9@%ut}Sh=S?3a(8j#;)bcIa$};OP@pS?-IA#&zf5H% zg<`C!o;SLB9Ai0p&>+!TcSS~+a^9&_+wMm7OulP}DL#mN7NlW%x4d{;T>%QTK%2^H zC+f|&n!+kq3MrZvw*AuRs>faZiAPqygmemPf9lHSVaxa>%RvkTVk)`S*q8pD2(Q9| z05S=6*JE5QYg7LY4br9W%$Dc1S)Q2!fx=}YAmkdh+pMx6kfUk%l`NyDslHQisn1nvui2NMX? zUpzR~wLf>|!DzT}yC2jTa4-h~JwV<~Hv`OxG3G4j?-w>YW^$r^f`11BeT4j)p4(4! zS8nI*Okb1Bd+zW3T|2G6f9`JI&X<#jE-z4=I;~p{{FsJ!31z#*?4RG+`2R0|sNH#~ U#>d~UT>jjXlTwzf5jP3`e>LfjkN^Mx diff --git a/vendor/github.com/lucas-clemente/quic-go/docs/quic.sketch b/vendor/github.com/lucas-clemente/quic-go/docs/quic.sketch deleted file mode 100644 index 535e9a3d8d0bd276d69c693de69cc4667d5a0a1f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 90112 zcmeFa2Ygf2-#>m=lAC=qnjk~aIzR|!4?t+9qAb}Uh@~x1DJ`@G0U0@ph+9#ds3^lN zZUtPp6}N(0+=?6L*ZqH=dz0HHX%&1Pe_x;ft5r%kNzOgze9n1)_UDW`dPr?^O^;~} zjk7A7djyys49hYVJ$f(N{4O4p!X0`5a-Pq}JKeNzXb!9U? zsQk?p^ptOHuPf@CH+GrNbicIw=_ZohSXvg^XGjxG4_4p^qtJzD=T$b=R@OHQ#-`@Rn#x(t3uf0;lTY|%Y{jx=%fw-$Mm0Cq)=y{U z*TbhCUsKi0oU)AVZ5%dySbW5YQKN^COfMg95V{koa&B`&Q{}vx>UR4YHh0$4nnq^X zGTpFIW2r9@FY$<$ZVy?ujIFweSze4YxJ##dn-o7-Cj z)38yg+Nx$eud=ap+}hG{^Odt_FJHOr!izdrHO%TewP8lhEYPc}p&C@_+cdMLxoSp0 zeqW3CXVo^#uX}m}(`sUsQ>((>=+r>FbwY>T>%@{zt(kp>xpX)*A1w zzVwRAMlN4osTJI0z_fHPk!lozRV8Tzurz*>zBByxx~tju$jqmwWsHIl*}R0S&T_)imLN%Eqc0 zwP+rFKy$-vJHswtvsNcs#~e^Ux32Cby}@WQTgD9=)pusif~JZ1JNLb@2UOKnHZ`qT zljUBNY<9;)<=-@jbG-7hrfG`g7&dC?Tsd^JMHyLZca}|Rt(}a|Yi3g<>#$Kr)hwu~ zj_1boLZ^L3H#RghXIatKx!mKA^p77g;+Uyb)zfCqTe|9!4I8&U@}xpJlyXvjIu}uL z+p-%fSxwoBR|d?gtgTm91SOp~hDVVn4WsR3?Ii8l%51c0jf{>FnR4a;rZ3}Xf=quV z&ZL+OGnhGw8P1GlCNRe^Q<-T@Ei;p8W=>!hGK-i~m=(+!%vsFE%w^1#%nQtm%p1(x z%sb5c%!kb9%=gT%%x|ogHM0`C9~)qUY(KU?JCKdDN3ut;L)fA0Xm%VsfvsexvQ=y? zJDXj=p2?oYu4GrS7qOSJtJ!tzdUgYQJ$n;-EBgfdB>OD;0{arXgMF3V$-cvW!hXhn z$^M7^nbUA)PU0L~H*SByN!E*dy#vIdzE{Gdy9LAdym`2eaY?SzTDFmc{ksg@5*=Q_u~)dd-Hwy5I=xFj33Ak;t%JK;0NpWn(q%s<6H&%ea);9uw8 zjAp!MvSzBLMl(Y*U$a27L_;(uYnE$P zXwK4{r@26LiDr%FD$UiJwVLZSH)w9u+@!ffbEoDm&E1-(G}|=KYhKc9*SxBEUGuKy zBh4<&=bGJ`Z#6$?e$wi-2CY?V*E+Rs?LOM>+H&ndT8}oU4Qa#Lh<2cMkhVe_*B+rA ztUXeDly;Awzg3_S9^kXsWz)6+EcVEv}bCs)UMI4*Iui=UVD>v zqxLTCz1jz~4{0CMKB3*FeOCLD_Eqg0+PAe|YQNHcr~Og;llE8b?>dc6uQTavx=y-% zbe(lwbo=YdbqDAU)b-JMbbWP)>Jqx7?g-scx}mxex{fx@ujmZlu%KDq`O(SQFoW_Zrwe)O}YnlTXhfV9@agj+opS3 z_l$0*?j7BSx=(bU>b}r@rTbC$AKg#7-$X_ z5N{N35+4+|ijRp;ird6z#plIW#J9wE#P`Kd#81U9#IMEg#UI6=#ozR1y+!ZPyY!v( zUG&}b2k3k1d+WXWh(4;1>HF#9`h-5IPw9`+577_R57Srbr|PHckJs1f8}xJZ^Yu&g zM88bGLVvpcEd9CqRr-tcm+CLq-=x1;f4lxJ{XP0E`up?`=^xWSsef7jhW<_cTl%;4 zAL>8Sf2{vR|CRo0{cim?`k(Ya>wnSzYTylmL1WMw%m$0WYLE>38_Eqm4ZRH>gV*3U z#0>omgA55n+Hj;{h+(*4lwq1-x}na{V3=cQHq0|DHY_omY*=nM&2YBiT*LW>3k@3# z*BEXzY&6_zxWjOl;a`(@fJ%GfcIn*`_(BMpKh%q3J}^BGY2ixu)|> z7n&|HU1qw%w8nIe=|ou&^=pO`)~ePjB` z^t0&~)30XUESNQBt=Vk0n5|~X>^65Y?_=(4_L%#c1Lm+fYVL17%$zbGX&!1GVIFNB zYo1`9WUe$n%50ZnE5L*=V`Ta<}Ck%O=Z%maUeDEDu|rvTU zj^$m;N0wcd&n#bBzP9{m`PK4=m9y%sdaKE5wRX4mupVgbX+6a1u^ws-TBFwf)`WGi z^+@Yc)*;qW*3s56*0I*f)?=+xtjAfWTW45nt;bszSr=PRvYui+)q1-1OzZj93#_ZG zmsnR@ue083z0dlP^-=5N)~BpbTVJxiW_{DT)B1t+BkL~f=hofUZ>>LAf0Fc)L9$AA z$tk&|eWdPExpa`!Tk=Z*DJX@c0n%a8KxvSakq(!RkOoVWq{-4$sYaSE9WT{MP0|8s zk+f7=CM}mvlg^aRlg^helrE93ldhLGO1DXONOwz{qz9!(q{pSFrI)0arR~xV=`HDP zX{Yp#^s)4bv`hL_`c3-X#@n`&OY z*`Kw)ZQp7C!2Yp)m;H15m-cV%KiYqGuny6ocNiQ-huz_DI2~nzLT-?ciTc#^Bm08PdWzI5JS(mcz zW&4-)D)W~4%KT-4vVLX#%LbGkR+cJDmklW!S~jd~cv)rH)UxSi$CuTWHI&UMn_srL zEL(PR*^08$%g!o0uWVh}`m*cGZYtYYc3asUWn0R&mOWDTc-gkH=gVFy+fnvL**j(L zmwioU5mF1xFn>j2k*u7g|$yZX8gb$MMrSJV}A^>g)iC0t2Y z%9VBvaSe41a}9Tmb&Ye4cTI5Bxn{Wz?AC z=04tC@1E_Rv68ChHa6DOH;=$S2iI5E%+Kj#$5hod%&i{N zRMR*(1$9d9c{FnBl-|{DhtMas>UNU+wNW!F8*2uqj;U^#qG)-8Q1AP8a)E^4OJc(F5=n2M>UQayci+BRb zWHROt2V$XQa65A#a}aYd(-SMzi#dep&GcbB6Q(y-R@Y);O=GJX>KYm`Rcq}mOfuO} zR|lUU{8?k=e>Y{ttdKQiEm`SB=1_FuWqji+sgrI>bwgH@)xChWKvw%A6Jo+lgo(DL zpdPELr?Pu*Ej|}x`a#>3|EcPwN*@E5!?5l{M-84eOHpa%53OScGJ}{3re7QHO_7|f zK0XxQqPj$7Q_bX|qvY4aWer>zeS-02^{oa?7v*r~h^#SdrV}|bYf=U=gc;h7R?Q4y zhB5sL6l>)xBbcM7NS#{^WN_hnu4hIvqnOdm7&?bP`P>w#%arze*^9Z3!(6Sc=1K`P ziJ4sZ@HjmOEks|>9Lr2$j$J0g)HGhh)H4mtY-SGA$TZO@{M8qxNIhCFc3XYoBPCB& zwv_tVDbjwWy_9@rkJn@_GcW7Pc2d@2KGworv=)n*C52QRB?E^#o@RYHaN5&1$pVcS@a^ zHOy7a)y!IE9kZUt5c4qe2;SMmJkC5J^J4nBXXH9Hu1w~&LtwE@&!1fhrd~Z7K{5c=+WM-xxz*tF zNtwCNrn&SJ7B)1@l4Dz@NH$n+n`^5o>(s8%rjB-O?#*MUZFX=|rglC$rmx4!&uf}c z+cdVesTRV<__02zv_9emJ?s&S-NAf;;eE+`#eB`|#;*SctMVQG+j8^*e7_1Ct+^3|Lf8r&8{K$g zPN=PJo-uYt4UJ+sdVaR2SYFZipiDGHfcSy=5nH;|yhcJ0ThIK5`HA_N`GroW_)RQ& z>sipx@6q7LQgOD2ZwF@ZJ5KH&EN*CEIncB#E8t{y#yM(gu54^h)l@Y!$|sJVkco&! zs%acji@zo`=Ve`-fSUU1!VhM9XBi2ysyr=L$BKnAo6NG;vwGIR8d(#aS8HiceiyyA zo>;DJj~FO+4Qs)!@nm(cu{PF@e>zwvTgJMW)vTNC#O}ic*e+~Wwi~-I+nw#v3jX}9 zUPoHJ4z_yjYxO$Z>UE&i>rnP4qInF)Ty}OgPWWdDYsvN{>@N^we^cH3f zyFXhF8e9bwr3g!L^;YboE$o5pLHHY*3wsE&iS2{eo0!h*p-d;%#{f00Q!A@xP6y=G zS3`7bXq+P1frN>|MltKn_7~}4A1G!kaP$w=XAhIlyEhsL2Qt2pCz1~Mpfv=%ohY=oY9HYR3$*%%J3A6zmJizP$;c*v8A##5f4HwxfD z5Sqv9i^d|cXfzSagypl%4gf_0D$`*rz-WRy*aRM7VQyxVYzos$vl;eq_6T+`HpDyy zDMtZpYvjE*t+uX40gW+Dv@sjXMzfJ@xO~vp@)4pq7EJhqLBHSYNyd{g3?~`#B$BCs z#~%x&Lf)V^kn|=-&90w5LfM$Z*x^$ocdPTJpn&p}_3Q}tXm%t!itf+$J_LYiy-izx ze~-?gvNmI|HvLqLdj%`}E9li11F22}scH19=Qr?9rYEU_vuVm zF?&>bMZX-uhh&r4Bj|w!*UsLE1Dz1FN6H5}l}?2MA#cdz3kIT|U@{f;#NytFCliUJ z{9$h}6!xbJ7&v>5e3;J@vl$%al(G-c$39G}`%r1S7;T5EZKZqj3ie8N4aRykyO!?F z!}^p`3=o{tX!H(5&ty)``_# z&E5>4za@JTpk~-k$yFfJUJK$l*xT^28`;}|yO3ttJ7n~|Jtxa{V($hH--D@bX1B2S z;`euKyRl?kzvs;KCSe^OD6S|3y)Rc*~O`s}#u7*S%g zBeKJ@1ca>Ci`lWDt0ImC(t$w08x4B`i44TCSUTc~1rt$^FB1<(V_|CL@fT8an@r7T z#Ox?g^Jrx;p2K2{R4J#ly^OZeYFmK_!@fpE81_x}E%xp5L3i2D+rH8`MV3)w8-F`F z#Oz;QG2o5CtM>7HR6c0s4c#|Lw>OW0wmiG$RrXyfL?AA}!oG*#fIryxF&YRFEXRIC z1&VP~8yc$-Ts#I4Ue}Zz4|?^^9-F7xF80&xgzV&;Ho|@ZYE9h1e#L%`?sl`^u-~%Z zp{wt)=AGFeCp6E1uwP%()HI%UMi~R7>a=XZs~$hQp{Z8Z4yq_mEUyrA=Vp>VdrSew zfv|%ivTe!3*)Qy`0EgDtLbZ*AJnZY(-`L;TKRAYCIgaBwfdWiBp9P~RK$wh%}&Wy<#r2a$8I_9HSCmc zIVbxySH`(GH`j^X&F#aQ)Hcax-g;~m2nR-+ zB~Z$>jE1}+OCJ++-+}EnJ2hL0(_65YxbEy=t_QbYc2N1C*DsZS$_IUZFa5c%e9)&q z)1O~tuE~{i2NX_KUTga3>$n5CgSdmao?I{P5Uw}Zhi%G&)rwczIclE!yxxzrl8dXN+`eAcT+bP)#MRslgcNjMi zBD+zb?{#@19rrK%o{ zJvT$l&dAQ9+}-gqrrqH8u9tP z;bbZpPsIut12>W~25z*Noe9QJD>DIZET(z9$^?|QW6)NowiPf2?l{UAxGJuit0^C_ zd-4rGzINQrtr&wj<WbzxOluX<0J%ozWvOpO?59TrFeaj>lTmjh)?43tt0F9Wbpl z)l_F^>$6LhN7v)gbF#XZaf+Q_+BPP@HF8Z{GgkkEY-9GsSGjrI3Fv1&w}4y7oyaXh ze@nQfT$Uru7Vacw(I+8v z_~rNd{7~{R#om~`9~xgYQl5iN*T#zybz>!Du8Fi2A}|uOE#8c|qFgsEy&U zn?dNyxYZcW<;*5JoF&;s*~OsG-&yfL`IbVAwcNTQ*rfsv-OTH`_1p&T8t&Q>V9tM{ z7?@ky_ka@0qi+uMd9F{DpWYA{&0HsG%>p@d$O!O zoKv7ZgriBoQzQwS3|0I6>8K~3fe|E>iuqE(WH6KP!6n?vn9FUKnZzq%_Ea#5QxsHw z4XC_aWe7^!+h|*%wiPmo_hlyW5%)3oNqI%NYv7_6tf$IMV*f2)Z2kI*9px1V4m3Wq zCa|r%V&A8=&$!2!sV*t&4LPkrHa~(}eol1;S*trErz3D*LFzlRMe6$&tl_M-rM@4i z;?W}YL0~((SYT@{{6lHve#NZLRk=RTp!4(gg6s1 z6NbM^C5qD44Q&^xZ3ToNqn$asxV&JzuUqQO8Q%rz3A%sA);%k{$e z7;MFN+j^^w(eQC@DWBw17!4#hy~JZYYqM8nuLj@iLzx>M84U%4u}~-m=H`vc%*`8# z1~86jAd2G_2uCAyM6%rA3xvbSNcKiTK_A2hFPNdXZx|nqMIyeiFC2tC;iGZ`<(%jS zZ$)A-$@wE*zb`0D88oOP?DNL_QEwz1_4>n$OUEs9Yknv{4C5ZIaO-Qb>$4kLachV# z7(oPG_+!41-=BMCI7qvVMZ$O-RxbvQ3~r6(_6Ng3uy9NX_9R8JQMh$UM{Nv;a%+AZ zKOV!Gpm6IOve#v=&vWaxh>>H-d-;~kb@(a#afMu`1^ln$EBUE>6<^KQ@YDF|{ET9b z)AG@OF9X?QLn1$uuj6O&^?ZW@MEI>568ZVeCVn9`B;H;AU@T`4xhK0Zdq-}|A zE?L9y`NQd8AQJTi!ZGRzOv6H#3?w~}d4usl0RJbVg_yKd#v~$UZv!UXqTtWTfQVaF z{88FgpzU_Gt;CSXpUt1cp9|)=loingLRah^BeeUTG%;%Ln%9dD7#h6-kaSbv-52Q?A#Yj#9$GH6+iBeV18ai zc!j-jk2jV8IHVFjUo=rjk-KDy+#_Zm07dRoR(~^QcE7s%O4|cydr)mF;1c{Jl%4aB z^H1^P>x49HWXq-+M{ zpOsnq!?NM;@f=gI-69{??{{?juC~eex`jXmKurUh@079>SxyiR5)Njz2t5@!;f?HT+1J5R zDC-1Y3woi0Lq-UO!@f{hQ98q3I5?qrMj%8)!1xqFLDpU&ScD?sh~F28Mq|N1_|M)d z9gfU!1+U=4aQq6x-I;wW`?kz*VJ?7aAOhYQjRk!0uu?`&Edaev^z{u!;1>lihuVyo z%y57XCgKl=qG1RTUcWzvX+)I4wB1b`gQ4tJ=qL2YUKa|05cOm#C6KQWa6ZC}RaEAo_8J{PS z@p(OgOvVei2OVRD1}|ZpyvHYq*^pXi*t`_boH$;uDpW#vc9D-PaRxwF@C54NMr2=%Hi^FtdWL0zqL3X7!BCs;b7Vq^JfaUlyIR;sEftye?X`o6rxc6 z`=d$}rR_?z{iL=P5^9}HsB464nJszC>q?>a2TmV6NSnW zg=G+qcP{`!5%JqoXhMEi%Y2bgjJic*(O4@(Vw-QZF&?VW2#*MlVmyyQp~=o8tcI{W zVTGJV6Y=|f&@`Z70YC#VaJH|}Q1~iRXk?Y3Eq#X0HAcZzR%W2m#G*bK>-Jck5uO#E z!>FH^(Uq`z!s-YsV$|*vy*YGht@79Dnbvy@(qS-o=346W$j-C>8gGFMwQMLEI;7C&KPS zSc$M@tt5TITJe@!mi4Jhmx)E_QeAwc|q z9vs<&2y0VL=zka=VeRS>RT_VzjZU?(4S8R~YhXBG7iqNFo`iLkS5#KWGCzchCBKi~ zcwu-8`dE-j2s)4hbz5%vJW?vKUmM%b>D*%8)L!0jU5 zU<^?Z0Z-hQLNrx00}xGN#{P65?oS3GxTN9*1koHq38LwPo_bJ%>?^OmrZ1gicXjQR z#sF>HPi-tAh$g1#r|HjZ(j2B4NENW0d{5Z&oB|MKRB^9YPU;^|gRWvJif%EVC+fclKov2^NZYl95C(8AX&YQicjQ)`{}QT8vJDbYuCIJ+zcg15tcx$`2GE z%`(~;QX306w4yF(&d{9sC+Y%J1v+mEn` zQplDWv1YaAavaJla*X&e!uBWZfd8h-pxL0g1|zyQ$JFA49YolQ|DM*MxkYm;#&cVa zsig^?pGQ61I`BClu%ub8zw&$T~&b?}Y^*19?40Mc6HZziYSnzFXJopX=;y` z&u$%hm`l%YlX6V!={agvkEznwL>uR+jU^(ic7b-G_CySJv35yIF!CD0&WCbwTwb|Q zqmfVUBsWnJHj#l03#rHlzZ^`d0r+I$bMplJ5#(2=L$IfMb6Q4lPqYl}ayrsQs+OTW z4Ipp^VXvV;y7+Hs8QOC|9_k(0tX-)+zlAGmFKUA;ojQ~`X=qcKD7*^EFaoj@Y0NiOz!kMu%OqNdK2M?~$|}^@K<7wQYAB6}z$Wa; zYGWb1-Xg>6?bQH=nbdmn4|VSsyCdf>J8eh zbj??^qc>k0lwcFXj+8x?g{#tL) zA_{}B=ct@m`xbrlxqHEhweM)(ZN-T{QaSObDkok^*o$(U7}hwdHy|q@7jKvd`Mlw1 z!V`)_5St&5WjwJ|BISvsGHE0XM*Y5I(N@_lZ4&R2HD_jDQ;sJlXG{Fydh zs5TaEl|SfK(Q!InC*&=AZN?mat;QVYOnf@6!jdn^vt*rtKIhT`O+shUS#=U!%PR?c z8DZD9!+&*7T^X}Q=gRTlD+s%qu$Rl4#6KM!SUMuv`JmfZ*Bv8*+<{;?!d^{Sz}r=_ zCecn*-9H_kr|YTfg%Kf5O&-w(!mcCi`W!Rc+nC5)I6zyGlz#&?b$$#iKv7c{(uG@4 zQ`fHz)Z9qeo3U-LBkZ*bYTi+Rn#n{m0fQ4*1UMT_Q-QH8lb|m0WZ0MS$C8Oip|?$! zrbj_{IQqPi9);`WU9THVcjFD}u2&j|(Z-w9#)6}u8zmowvAS`(@%hNA<*jrHHL~i- zzlyBVO={64Zpp!=ZVCmrTUBt=Rnb#%Tbtmfn^p>Lw-sFx_Gm!R{gKeK`cXUqP_D^9UA*WoT7=zb6%k7b)nA$6;K{ zq&#VV(w|DeP7R}c0khLBlgYLmWZOc?wn?E7q8A9eS*4KDcouEES8XgHn_~IUU7%Z~ zyRa3t)Hth`isP(w7c0Q^fC^lzY4>o@=OV3iS5jR!=dkP%!ahXUhjY5beZcbo2Z4Cs!WF7X6mA0zDJIbGu49C4+) zS9c!A7K1eWV*Qt={=;Ok0I zQaX_ch9R*=!-z);CPMI0gb?!(^QJPHbSx4|MGLbVb??cC_yhE?gC63SmGk-$Jy6@# z^Qts{MjH{8kh5u)C>6Thx^HyfVzA%qexORlh?~a$*7Xax(r}ck*5s9naWnoHYN)=j zydqnXS1SB5j1HDpk2eleD-7g5C>4Q_2S%qb;}e4u)gdKi3kCDV~qG?7U~lRj?&bc^Mb>f(Xu^LbU0i@<9(>YJYR- z$IT^riWtRMWIaXfujnZsD|*UjImRmvq<|{S<2JDEavI?lyI6Z35<o-W?kDo+|Kxc3PYO@}CePEoh-mdkfoJ2%i zI^&5WX&6TfhTTwMdaO8G-WZM87(dXB@trb_W;%`U)jgmzE})GqF$jelV~M;mhNZ%Xk%QTQ%1yPm=ElGKa06!CsCFoeko8!#52XS#IxxEWC;5!;e>V=xVTb0 zAE)br90Nym!Ec299U$KePIsi`Ah-zHT1bvOj?kEazE}re5D`Y9kS~IW0vh~FqnW)} zz)-;F3wfh4AN;5hpB$e|LleTtc7n_vjfBHN8oIPsA8%vaG!8*rEy5imUZL=Ljwc*T zI1cQRMsP*tNa$G5ABrJhDiFm;pjr6?z8LbK5oisce$W@AUjCkP7y>P67lTy>NpLYA zjr2zNv@aHjAk-RR))41tu$LT#5DkT*_+~VSi=jeLC}{8ijl4jd03yGl=sxK4wHH(^ zZV=(H5pxb3PDeNm;j}r~WG~jQFU=zJ29OShU~3;u-o|)nW*BXz0Th0p7am|A|^mcSh;}|$4jzRCF(G#){=gmg9w%Qn;{KjyU z-}}>h=lyubcl~ontv^skYVLqMQtNxs=Nwpo)OwG;ul`WFmWL1y!|dAz;?V?3eLx>% zw&+6&QggiscQE04=8-z&4*@L z^DrHwKp*hO5bTDq*^oRzWT1or(e&HEbfnm}2h;k)^+#aHgB4AT1Hld@oHsXQ?;bB+ zABxgGcpVY9izx-bN-zU?hA@AEM1VPP805xy>A3fXGJgZ2^+#h$BPm4dN9)J5K(u~B z8xY-(a50>kAmIWEL?;U%It>W`QA1G==;Vd@1F7SP3r~3v`GxHVI%NDsC$U;SiPO+$ zgr3BZjD`9c^e}`~G*%jC(Z;CSSa=c}<&!v9KTm%GK)Bxjzzy#yCvkuMZ(j^t_(^%i zp=W)*Y{HM>@`}X1zj%Hb_IL?I>lfr9TE9qv=>7^s56VHbekq0M0V+i6Po`({umXr~ zsUD&~RYvB4e}>HZGbl1wsK~58hxQn66PfiZOOZM87s#x?n66n$MP~hK+JAa4kXe7F z9_4oO<}m$w6`8M7k@;}K4ap(%Pz9MYd1Q_wnH`yGK2I7l9$0oL4xJP=gQ050Bi^Jp zj1yO&Q|WJ!_rq=24@c7daD+noJLoh9tE5*NH_^tU)W(ASpqRt-59+t(0)dLQ!BKe} zept4Gal`UfFug1t4A1JIn6ozhQ>;_JjajXKnhEHi)jy|yUjKsrMg2?dXuO3r*|5^% z33nXfMiXul;YJXyx(z6l0sIyHt2l(Ozl@1t(0RFH~PEN%6 zqWOwQs)KzPIHAP-BN!HfA58=dAfpaabr2Z}fSM4^9E|yZZBYOu#S|*T@7ZVD8}hsQ z_b}x5bLc&eaAOEJ7EnlgMrtDbm;s;~@(kqMd^`=1CX3gRAOzx&oXAf@eUSu+AW$kZ zV{RdDF4Q-O0_#k0IOy!cD}8srU{oj=hWmLU<%n6H$*L5~d5+6CcKa zu*O(*ya*tA1k8!9CPLi6mgpPNP`(mF2>1>oOb8@E-X*XRys6y*ey{%l1N<>JKo~|Q z6Yf}K)ss*K0gN2u0m$rgbifV39MZ=;xMq^)7gE+YLO28P*UU~^2d zig1;Ln~GuYgMpySD8e!kl?|ST*zyqFy*X;q^v^H|3APIX0~(3Ej`%cW4V1q?Y%mx& zKHGjjrF#=xj9Y5Z8w?ncQ87<)(+O8YxM?|gXwP>2-kgxV`RtxrG@&vX?3jbY;53ve z_>14vnhCoW)7h{u-tQsH#d8QZk8sBmu0geC>VclM_%mC!W`9rwCr>ZjJP&MmL#J^qGCiIY*$Wt26(U-~M~7&)}Mo!B(PVU#OV z3nk$ib1d0VK^bV1%0LY%%HW#YWT1w_OBv|gVg_2|PcjUp6FfnUtT2pV0)~-NqNG873Gewn$rsV<}|~l^7zez1fu(%;gAyIfHNu3AaFzww6=UX4S%N z@l+hfT|W%f3Dm^I5l(pGX+I*@;)!r7?9F6CvBHRYL#<5OndoIPCGCj{6=lf^;Ulf% zYz>Wc=1bJZ0`_V+K_=}&!-@rH(lUpdef-d>8wkdl?DP>RjE6Scn=Xa_q8W~p6 z{#WdUXk@t9a0y7IcnUWe5dUkSqEctW)p)f|KAfi$?i~4867D>#IYL^v)9~k9`CuZR zA%Rr+AVg#&MFdf9fX2imQIEk(Yn-MczC>XTli@mP^fnkoyeIgp_Ink zXye&xVv-H7 zIhK1F;VvQErSijMmRZuN{4n{glA+*X@*APH_`5u}_YEK5VISrmb|v91C)^denUy?A z;gju5+MA!5x7~+*VfYdc`zrUawS>EhaJ0SzdZdCw>G0LJN`^uoCJP&j6;rHV5Md~Mu$``e2{})sl`Wv`z0N9*KaGtb$=omOQ%ucI0Y#VYEu**hd>C)j=^{wwb#<9 zn_L)?Y%HV5V05F?>nSo^D}#Vhwq0GPf`HPvFFmj=5g`T0U@WJ|U_8ipuo14u&h>^9 zqVqP$$e{D|seC3oth~Z#y>;}*A6$Uok0(MEPp>_&9Y{C!X@T^cbC7O4ltTJO71E6| zCfw2{q#MJfkbY}1q!&4gj05P@Q1l^Zhcu$jua}RusaE}n~(SHcRjb|8A_sstk!S_M|F|{bX+;6? zqwqH^QV7>6?sy2sB59ymfW~NN(#cRLoQlN@{Wiv1yvf^>DjzxWs z<)$p^OZ-t-R0d9fh3|$(}g;tDL_x7DTE%rp@jQd zS*Qq|$nHWGWs({2w`ya-X*9)U!lg`UQzox<^lL@98}fv6l^>>iZGz_WBj@LsmgxwE zY5kCATBafN;fR{ZF)h<@%Ct;Jn?{;OnMM~gEyOtdhwuX7nRb|#X}oCyv&A$qhqS*C z?kB?ioP+feLHU2Ea+s!?s_?Mt+{6AL+;4>YU4GdAzRF>$GtI)o>XnD_JmFcw(^v?q zSCq*4|3j6-G|zMb9yUMsFdgAFgr`9a|09*-ZvdSsi(wE7bf%L{%UXcWw4xN~c!}@` zI^YcicODYt$n#}|Ko?9zlE^5JdjM%Ddz8u0Ky1pw5G>|{V>uE`7Y1UR&X>>2Ds)Ao z4tOQ%z;qF|EMF9LV4@+nd^=GGrmN)hvd*;Lv>`8xUoW2*?Nj$n-Z3bdm+e-US9I^( zsox>*ywD!dU9SQikEjFX{N4nhI#gxzA#@M-kHFGN%`3<|qJ<}- zDb$)kg#+-c!a`=aiID=`%OG4=O1RF-Lea!qzV)4O2uU-&K^wcZ4RneuZhFu3eohuw z=#|LR>$*Iw!4d#l3g1J8wOzDV#2Vyb?Q@Yj=u(I64K%qkkPo4h%k72Eoxf_N7!#}&(+{3(I3#^$Bq_9>P?8^5eJRJ3W zknoD5o-cINhkXc+N#oL@RDjl9OyJ57IB3G24BUeVB95hEfx^RK_R_;)_M=bgsOJ?& zy*WsCY>}hh9HWixIO@#diCFbt+tTGSA67>dkZW zj(YxZ!si_IyyB?mRY!d+=?kXg2pP{HPzVJJG7t!9Fcr3l&zpi(6(;He!-aW~ydRce zKTtSvrj(N4@zJ+W4oAdh?m)vvOdmYy)F{8yuJeOY=DjSgMYCGj0zeJRJ2o zuryyt!P0!O`4aP`=F5t~ax~#b5dIj#k8cAksSDnGrFjjG7gSvtzeW-MXu?w$yi#Bn z(XI&KL@*~@@o>b;o=TMB_XVi09f3b^n}(t=4$HARv^a1SrGjWE5p^od;jV~`MGagZ z4ZMOU8P3kV{B(QczRr9-#*G@E^0>zlehlHMA6^bhg|i$%UT}^_VyO0;cNs^+{%{Zh zUhpKtU{1qysdL?rvRrV{()*pG7$zOHuWtas1yp-SY%JyxRKuvkD6<0>ase7#?i|5&IEu z3opCulg3owN=Gm*3L4Xz#*sFx-+)I@^IkJjX3Y019$@}h!cQXnWSN@qN&h4C**n_r zg&D?-s%qxP%#WLqZUdmF{z26YgFB>iW*B}t;UP;@5`J21GYo$mha)U z2jfUOk0bLOv02dAW8rWD#z|zR6$-Lu`O;1E>p0@o^oUQDDe4B!-`KMB3o>?r&7MWqpf6%GTQq3?H zjtN-6a@Ntu)c+0b#3C|VEQo7mH(QJrQwtlnNX2X%3lC9hF8-QL_y$EgSy~WphwS-y zFqleslBlc)mX5$MfKTvNM zw8YuLmV_lqbKkd~M}Jn94|-6Nf650v&|UsfrkkewXpy>)EQ9I87Pq;NEJI57(URhQ zWH}m-9%&gxAN}Rq^k--JpbtjNKe(uAqWq&g8W%DWKC9|VmI?IHWG{3j%OndfY^3Nw zlU6NL^UU8eO=bQk6Mh9n21q)m$x(XzN%<(fNE!;Q7r_JmIK7?|u{bDzdkGYX&RjdR*#@I z$`TR8i}1Z*j0z1Qnt73z5fICVm{=?@xGpki=p_R9G>T*5DjUS;LCnB6Bl+_Ad-~}% z22LZbEmv5s#K70&WQ6kxe;(miLPnr$AD8MN6dI9*K?IATo-lQ(<8~c-uMR|km=8SO zM_dy2wA7& zfQ*LVX+%{k*9FNzcvP0a^(2U&L~I+v^8yGgSK`|c6pqMtpmAK1fYh1xmijgeL>o&k$(X;4@Rtyt1{BDljz}efkrgYB zICEs@&@tn2h-jc?r7;gAE93(?As}M;v7;~o1j5k>K9og89H^Jh2Dv;K9u35oWhI3A zVQ9E-7B@uEdCH3sLG&efyVnQd$%nk8Hij(6?^*7(KvuHk(u?^k34b}^^I-|HJcrf5 z#z4hg2u|oa_f%|mBs^h9gy051ZdX3kG=L|f3F0PpFVJvWqRb z>|%Z`;jbe6)j8p9PmhAK1OJ&%{~e}}s1^%^H8A~`EHAfW`meUZ^lv0QVtn`wgkP^P z{aXu|eu`E{@#Erj;00h0|aa+aT41i72?-2OMpfNxeAu$84;aATVc*eaAV;9H6raFHNq zrG;7e+f*)Vwb1@=-wQ5lwOQ>gT-NH&b6IN_mCN2q_{}*kyG7x$cjUROKMXF5L+MG! zX&ny~Xh&8#y)zf5KbA^HaIgtGb24kd`N7LKy3H9!V&+3E#w$Ua3(HPRe|A^89G5yV-8(^BMv&W(-`6AjQo@P)r6herLzpMJWH z;nVOf>u~D`4FBjHJ9?Dx4-@_oKs(J81;0kjGGdq!enwdeMQbktY;mDZAOU+tUr(KFnBi0|QAJlG=; z?T<>UuspOeX3F`k6RZ<4=3{bWevfj3%Ltf<3XiALD~)8vf#nC*BeNAh z$Q%pNWLU~&!0u_H6bu;1n?jI0z5Ren3Xpkd$h)kQ$69j3{_a}KJjq&Rt;V=(au$MT z2)~W+Ph;FlF4Ug&{ZD>+FZ6e79cD7iT5m19Ek};yw$5iZSr^h!QT|oJzef1y3BSES ze@AUl{uMb~l$NH>gaI8fFTHG@78XsQswi$-5BmIZ+)INh+6Az0m9NUN67=vA#g7*h zsK8}8gnv~Q_y%i#1iIM(&!oLUVAgJR_h0%Xr!03@)9!1$8+|cHymmGxf z3+jHrlgy+;G{PHzSr}tseL&_IThZq`l;UqI#C@19+fJ3ZO5+o>@m;mCfYDo@p^V=8 zy!8d^i)~e;sM~{z6xNq97FoNuzM^RNA1K=WCpms^eVuCeAFA5D^=-;UJ}S`et?%R$ zo~`c}RHWcPE>QD}Sv{>-%kOFtC1}N3{?oQaiPDO-xQD0c(&ZxOru93zcwe-L60~A1 z|K;9@62DkmRjifRyeJ{j)Mq*2ng5#b-{(Y$9~4pItGp-?j(dFx$k-m5&x88fNz{)F z!7+_;m(gGn*YiXZg`$KcSFDv#v6laqZj9aX9*}6oTK*e#4=9baVlDrj+E}nLB)MX( z)J>ulYul(up>B+PMGC10<^#LrkNG@jNwzBery$Q+>M8Y-4xvl<8{vN<0^0^RqY9za zS2~p0B6)KH#IJ<^nee|rfROdre{V$!DJtROK?zmhsNf?og#VrJf8@B?zqBHSl#r4b zb4uaBfXiXQ*EiWJfiObg+>>}F}WG@=EdrO~ATEtrX55{aNAf>s7- z!Bqgz0Yo+iyzwXsMd8{6lw3lc`zRs~{K&`4q~mEMDii{=G=&1RREa(fIER9$964I9 zU(l;ZPHCh$(1KBIEIfy^C_qcIr8!b#TNNpK<_iy~6)7GlF~3U9d4QHqkO5kNnGIJW z2=*L6OA7(ef>i}*X$g*~AQb?#l+6RQbaFvO3c>bg04<#gfEFAoKuc%PuAOZHv~+ff zt|y>qhQ6TxB7l}Ipo`~L0a~JE{Dn??0npNA(&`pnPl8`isYoHw3}_jkh0a9it^l;q zLk4JJpFBYO!*SeQm_$w%vNG`tdGHCj%5NITos4^f-gIFFG3iEmW1u3W(2Z`4F3KLb zg-)ZZx(Ad-8V4)vt2P#HjLq`KxKFxYdZ4X}6fo8+rAkUFQb=26q!#v5k@`{koc#-t z`bp_2X&YV3gNaa1gx>8T^>Y#o9uf>5GU8!E2N2=FJW~H#D^f_WNyrA0a@jz_Aw=j& zgkCwE{&!ZSklvS&QzU(ugXz9R=tBgLswnMgIgfu=MGEN)OzBG*qQ91Qw}NO|o2)3% zMTig~j8lWH>Qx}Rq5z^1*MJHlL6jUoJ|wiJAd>9Ds11`w_^U7MPh`S@!X!HzLr_UWtT#+J}uSoGk z2}IjyT8}J4+u+(kpo8Y!*0KlgtANiv5FM7^|lQd(KSjul2A>AsYIyC$wU8VDpJ^P#vC@tu2`Xt?{HpBBes%Br2^&JmGK}waw#cFU%K#j3uw&TFEy-NA9T#G`e&okpUDC=x!VVyfEYn$CR>wK@2b}K0{w(ncyEZa|1&N39#q7W7l;Y6%I z>=$ztIg1qLNd$bzS@z>T=pc9~%I79gVFWjs(Cb)2s6U(v#FK^LWp;rQ)viUS3n)=f zkm+X^=_Kc?^ivwmv~i)@SU^;}of6evW_Q`$`Gm06wJ1=$&(P4sd*CcIHi-wa)E>#hlHF;#*xVfqkS6j z61ej?iLlYa&|iB}CR`eXTR{o8T%pn7bRsQ*K1w4^)Dli>hj2&Bgd1%i({>q(ae2a7 za-xxaoFW>XnHP=hxM`UPXQ>WK`?1tPX+O?hX`gDZY9$g;2c@u*2xk-FQX*W~hR{Pj zeD>+~8O#=YZI0cYM}%{Ta4z_U9KrCvTzbMj$KHsCHRT?*iU{Wu;R5+#vKy`>J4=qF zkl!jvN&Cyv6ZRABi}0|;xrbdsgo}u9ac*WMPf}t$+L`oUm!7bnVqcDjotk^t2{4MbRv9leGKS1R~+ zLm|G!;z4gRNGma*@)**I5=bZVAxs`6)xzmCN|%Kag|aOEHc17}k#_KHZU^5$jpQwS11`q{ zB$Y5p-8RP6Z(|%dP1{a-l?9RRpsu?tr<@#k*W(9~7@X1|TmU%MK*>f>dsqk@l>D^g zpjz9+xD6n@8iMeuw&Zk=@G#Xoa@uNqL};wtY5YleTW@_-FR1?5e(T%fWjOmyX5V-j zs9tSBTf+{t5fY4-ZIFd=2WELhFhDj!V+JX-Oh1lAH^9soUcRa`f=L7t+z=J3RHfn2zXPdq2Q*A1fky9l3zIC zAs2S!x78R$XasB&e-&YdxU?zMctips@!J;sM^1*F)c$|U$$&`tF4Wa;LQN+Kb?v)Q zvk0@j{?|gy{j*Rv{+UpV36FMf$3!8@2=~ALFPJDqC8FxPi9*zWGf@aY<+r^B{|zR2 zvTdH8ZkwkEJLU<*g%e0KM1Z7tfFBVMHFApZ0-9Vt9zq@mNX_9D{y7^H(X}bK9w4~i z34(jLC8IvVgFM=i(N^Q80e-yG__H>SZwl@vVhS<+SDXyx-?rd?;$%R~ZW*j+-wYN= z9S5C*DjnMf3$aKrScqlB3St$p_N&2q4U@cpNj}3Q@BhwV-9y|5s_|eOXEH7%Vg}P&u0>D<2rDVqmrq#5KTNl@ZqhQ&mY+MO?ROuxf!}YXmCU zj3foaAR_=Bk^)Kj9q5p#KLZ`KABF%E1GF24c5MP3MD{b#31hKf*9~Z;PZ3g90Rb=; zr1pcoxGX3=0^IQ;{4#Ps(`+Fb2>OC#1UKCS^aUc>R1G8{76pQKRAa001fg;7PUBDd zg5)CT3z7%Pi{$&Z7yrkc4AXyOy^umXKnESz20ElD06OU44$vXb03d=6{Uy*LrTzqT z5Xip$`K;lWy*QF!m?82VphGGV?oaVA03A{lsrDV{klNpX4ypeQ=pZT>!fXK@MBrio zuRjpw4$uLnds!JdDLw#nAbuUxGL!*aw7h`w5~L*ZfI4|{f>J++t|K=CCXgUt0zwf4 zhuD%4!6gDAcVx8HNC=pK0OQ18S*WdjIMNyEvb_)g8%_qK+a|0*G~ZwiNyuM*G-vIs!v<{~=gI#vnmf zH8O6yGe#I@ zQEg-s)y9z%NRWE>XHJIw-;(huzHu_V{gbO2Ngz+zbX9{=G~kp0hWIyK)e!JlZ;jwK za8*MBJFaTvA_05^|Hf5~TqU@wA@EZELo(+tn{nh_0$hrGhs)mxcNG0=xcvRka0y5w z{xMv>Ak3Ngces2_xc`}d1uowq-|xUBHS)_hS2b$aH&-L9p@3}HP;ZB9Ij zaCi<$?}&b@k&4g=_$K}yEKxKlaMrV#-m}HYaOm4IVBS8DMIG4!OZjhLiDDq!6*$1R z!4kzp0811LiWPMn#r7*$s=$x}3~9lT#$SLXA>I?kf#M`;MS)jc!mB-`3`2@Aqy)TX z|K*$vC_$7E7`N~?I;q2uDh#OsblP;D|2K0oprp4mE;czCAkA-M28o*gJ{be*EJ^`P zhvJs=6VintZ5Yzo6e9>F{r?vk0}2$&L2072P+;prIFbba?zlivAO(Bt`~@p~oV7~b2KoYfC zCqr(3T$(FxD@-L8&iY7c7Zs+_36$jwu zG7J&Q+CbL-#`y~>5y&%%V82nxsFd&a8U(lr27V*yhfsA3`jIL9_?E&MFgqD{Om0r#{g$n^Y{_z2Db$Zkh`TaAQB zP{?7Y@n@OV6YMvt3Dt~hVcI5RQ2l|7VJDwn=kLiFP;KArH>z{Xemig3Z})Ga?IGB2 zmmT|!8X(NM>)+UK)bOVLcKgYGqsE98P~)hHe@@1Lx=C0^`0wjzme85UU#}zJiU(u= z(JKLY{<@A(OQ7pz)XG06V?Yt8Od#NZ-X@Vo-6M4E^DkI^)NiPV->p6h1Tt=g4x@mO zwnB#?KNt$$w)*gv)%X2o^+iAxLsXR;grS#eolTqDQR9|KwKvx{WCu& z>iy;_`UqB0AYm2xZ!H)Chbk1XvtTwG(YpwZK|75{qH7YK=Y#oz_10khkXf#Vqqw5d)WV_WDMvtXbCW8$?Y*Gz|a*K+Ty(+WbFPo zk};sqqQPDXt+=%fgOXt=35Is6Ul7Q({*TER(3)s1Fd(qq*+T_8%7^(1fB?N)`(lsrf9S8Mjs7Gd4GOs2bh`7 z#mf(9Vgb7^pk(+(bQPPTs{*2{B8aYHOG<=NJ5c2>qH82HevcIRNp#zmwgcU{ZE3d% z8D8&5?3<FZ@d(xLykDbl5ZN(D%^5rG?&hX+hmE)CogfV9fvJWDMwMXy6?~1Mk?T3FwERUKk<}U;OuwF;IVZ zN1@+txuekU(C^V7&>zvC2yUs(_=zeIK~anTOw@q>LU?n>5EHdxc42lC(PBt2AnzKy zy^j%)3P4K>|jbkZi_o_V~baCmvK1n;)1gRm69CJJK?lk%q`D5*+}DT%{|XMd${SjxZym{ zP7r~E5`+#CIOG^uaTIpCo z#2_dQ3iJvA@?TJM3}lW=ost7=B2rj6sh>T~7&HO%Fu;`qjS?_#XcO}=v;-g;-hpq- zQ3BwM%o0n3$*v%lA;yBVP&s0G;~+jO{%?LZ~LApJx$fjNm`$ACfx z7%mKVFi2wc%m&y_LCPf%j>SE7APlA&FjzcNV%ZZ(1D5|k0Z3h>LxaAE;j42a1C zsh8m0TZB_e034ZucylRXS**5(j)Ke_=<*A2Nq!|JA|@u@1s)C@R$~N+Xg6cIAy8_B z3?qaQ#)z0wP~w~{ovm01VdODq^;NaF>~TI^yx)G|`S#1HA94CyBXA9@z|b-b{RTseFth|iGca@)hGt=C z!<2$vMQdje+si@@tiYW%!l0Ef$`}<>3R+by!X+%u-O}y63*Omn=R;uh3otY{yESg2 z4DcN_j5E6DqYVP>`GWe1f zSl5;~88Bz+ZqA&_1U1+!7=|&x7=o4k>&S93=LqG&{?x9ks-=W;b7Jb^-|A0KRZGU% z!P#vFV}>!uSb%X`61QNiFgP7mElqi8qwUKC4a1pIP=P-^+=0SuerK~$?i2&~AFQHP z7+Rmg*nm6OV$N%;YAIkTh+$}LYmoLBho5ehi*Y0p{i$W^b0!$)T#U)~$kol=%x&Dv zU2L`RJ`T7Uj2p%sg9l6O$bm78C&tTARZH94LJRNgLMWvq<#67{$r0y-2Y1ybsJ(-; zr9C)bfuVaa^Z=a1V|-xf{$?*kA{f71A`v3dtv+2a0l65L?Z1drF+sURs^6}`n2?{V zu@P>)Ih+DaC?*UOj*0lS3fs;neyPItLpxGMOTp3618;8OfKveyb&xi9#~G_=ZT_xi zVTZE>vL(Y@#6)7EfZNU7&C>R~=MTEFy-Z=~3k>}}gNeb!V&cH(4`D82u3+N9vj2u| zTM}* zLtx%MfH@>Ag#pYU<^}=JEPU`dAh}Q2-2h^@*6%Q8#8_2JWotQM&GF`Wm|@H)kti4n z;jgU^jbkP@)ptky+iNHnGf7y$K(T+lvh}?w%rvi40p~`LT><7P<{9QW=Ebj*vGa*vCgX?p|G|*Y z`2o%-z`+R!$pgL*{}tvQyl3yuklzx9yziGGf5LnQyRjeUPTkxFcOCNu^Oc&2nwWYQ z^=@hsYKVFd^pcF{s%`L&QkLP9#7iN+fZ};E?H|#6#JKiVk%h8aOn6X!X$JLtjWSq|BtJ zNX1E&NL5JHNYzO-NwrD!NDWBOks6VjkeZQNkXn&OlV+2al2()Uk`9xOl8%#3l1`D% zkS>wlC;bgjjz1%PLHdCVA|oTCBVz`H)dFN^$TY|d$sEbT$l}S;$uh~Z$nwbw$tuaJ z$!f`($XdvH$>zyc$)1qCAxDrOB|i-~^jydT$uE#cl1GzYCXXjiCvPI}C0`}~LV==S zqTrz5rw{}TKT;Gj6tWbG6v`Aj6kZe&6vY%H6i-3&{|QPVN=Zs-N-U)cr5dFMr7opD zr8#9FWh`YW2qe@XXQTI_V&?IO|G(9+RXGAljS<&2R9yA|X7%hsHLCd1$(aLC5v>w_G9e_?j z*MXymdGsIXSD1qsN(?oI7IOqchhfEVgZ;5G#suREb_`d6Wp2QX0-#;PyvDr6yvKaR zd&1kwc4z%(H=VKfmm7ic1BqG+ONVrk-NF4M%*G}BDcOw-KL+@hJM zS)koTdytltmYkNFmX`JitpM#=S}j@w+H%)ArFW)4o4U zaro%rM6>;rYXl z55GNf;K{~NHRkJGc!pP*-_=cMPN=cebO*Qa-+ccOQpccaJC2ha!6 z!}JmK7wNCiC(tL+r_pE7*VA{}EK~K*@k$Krvt#Xc!JNFf*_+ zurcs3@G%H5s50m?m^0Wj;2C@wLK(stA{Z_*WHMwi6f<-)%rHDTw)Ys*G09_k$DEHv z97{Zwd93T$*sRHBFZn4a>++o>ZdCc;fk(EK*5j-vSVdXISkJIZvP!dBvbwPPvIet8u_m)-v6ix4XDw%~WUXecWvypz zV7<%w^*HTursJoN%N;j4?sYuwc*gPe;~mGlj`tkzJ3erH@c23#1sgk?GMfsU8k+{2 z7Ml*6E}JV`3|kRf726=&6x+iS#3!gvu%6&Pp>)FVgy)Hb6NM*QPTV}Pa^km>L?k?awv1?aOiOua0GG$bA)h&afEZEab$25a1?QraMWs?nvWDQhf|N!fb$%u6{j_)EvF-= zGp9GFFQ-2z%o)m=!Fi1{i?f)snzMy-kaLK0m~)hKmh%?pJm*u+51gMkzi<(8?cyTg zV&P)tV&gi=#lgkJ#m!~J<;4}xRm)Y!)xg!n)xy=r)xp)t^_2Svw<5Paw*$8mw+pu$ zH=f&r`!aV2_dNFp?vLD`xxbzwKDGN4$tn6%qNj9DnVj-G6?rP>RLiO9Q%`t^c#u5o zfI0OdPb5z?Pa@A%o)n%mo^+lJo@+c=JUKjhJo!8YJViXkJf%EkJkvbC@jT@Do#zS9 zGoE)mA9z0T67%lnJ;Y1KOTmlc#Q-OdAg=_k6t5z$60bI|AMZup9Ns+M0^TCtD&892 zI^J&HUfzD*K|V%4WSF<3jB)v%KYa1mi!L(pe3LqpeGP0 zkRXsKa8)2hAWa}opg^EVpiH1bpi!V%pjDttphsXqU`b$E;DNw%fzJY81&IWA2_6(A z6(kpA5M&f&7GxD<6I2jX6jT;e6;v106x0%g1v3O21#b(^3oZyQ39bmP39bu%7CIq> z6~YNw3)u?U2{{Nk2{{Wz2^9!+2_F`w6Fw@;Aj~MtB+MdwT=<0WNnv)t=f)+>4eIv* zetu97M@ZO2*j*Se>?!Om>?<5994>r8I7T>5I9WJVI9)hfI9Iq;xKDUMcu;s!cwTs2 z_^Sx9$ZioxWUmN?2$cv@gieHBTm7H^pbf=fvm5*TwINKM;Q`{#5*}_y_S%XNb@2KErT^@eIou zt~10-(Gsx|@e+v= z)e^N5Z4#XlHzbB6rX&_5cS!<=izJ)mNl8vgZb@Ou(~{zna*}5yl_aesttD+F?IeRF zVaX`TSjkJ0DUxZDnUXz{eUgKcLz2UiE0SxHk0f78ev*Qu_DLO(LP(*csHH5WtfXwD z?4<0a9HgA2oTc2P+@(CEJf(c3e5L%Q0;LM1TBKT~I;6U!dZk9CCZujk%}L#sT9djf zbzkatsVCBVr1wehm!^_FEX^j(F3lm$B`qW^DlI0hBCRH^DXk-|FYP1kEA1~GBpo6h zE*&9VCp{tkNamo-AsI3mN*SaKMuu93PsUWnS0-I1L*|-Hj!eExkxa2nugtQ{d#pBA z7psRg#2RBwu;y4RtTomKYm2qVI$#~K&RAEh8`d4`fz7~HV{5SW*hXv%wii2qy@4IW zPGE0i7qCm%b?ja2XW2cn`(*daQpp~cWd zxqEU?AXOquXpItfoUV&EOumYU|g94KRtHN;wX$4~i zZ-qgH8ww)|;|ezwW)x-><`ix#%quJ?EGaB2tSGE2Y$)7U_)U>qky(*NkxlWWBB!FD zqKM*YMM*_zMI}X5MRi3TMLk8lqNiezVu)h2VvJ&v;x)y7#WBVEioYp7QhcoVTJfFY z2c^AA2b2yekt^9LIVd?QxhT0S;g!6Ue3kr_0+a%kV5JbHP^ECC3rZK2B9)?*YLo_* zZYYf?jVVnk%_}V`Eh}v(-BWt1^g`*S(mSOO$_V8n%14#ymD!Yeltq=#DVr#pDO)Jx zlx>tjgDd#FTDmN?lDEBK5Do-j;DbFf@Q2wO+RfSk(mkLIO zMuky@U4>soTt!kvT181kMMYgDT_r;$OC?t&PbFWaP^CzvROPx#xk`mfwMvajol1ks zlFA<{FIC>Cyi@t8N}{?~b-yZ^DupVI>JinWs!XaZs%KQ?RTWefRkc)&RB@_qsvfGI zs@|%wYM5$-YO-poYKCf-YOZRpYM<(W>X7QF>V)c~>K8Q{HGVZ6HC;7*wR37FYUXMd zY5{83)dtiasQsq)NbQN*bG4UhuhhxaPpZqRXRGI`=cyN}m#CMjm#bH)*QnR3*QqzE zH>o$Px2m_Rcc^!&cdP%V{#pHt2C>F&jXfIV8dMrc4H}KZ8q6BUHBM-7X`Iqf(9qNX zo&yaN4I2#?jaZFK8do$DHLhx8Y2<3;Ym{qLYSd`l(wNs+)L7P7(RiitM&qmIE=>|m zQcZGADotZe6HRkXD@~lHwWh7+c})jRM@?r<7fp9fyr!q7w`P`Roo2melV*!%yXJuA zkmiWyq~?_7g66X3s^&e-2U#|9nwN+9o1sj;?m;Q;?WY-64#Q@($+H5ve3e5 z*=pHqIcZ(ex~vtim86xTm9CYcHKcV{>#H_{_AzZHZC33Q+8o-P+D6(@+D+Q?+IO@U zwO6#)weM-)*CE#7)=|{4*KyEs(s9+n>v-vS>m=w@=nUyn>(b~R(WTdA)Me3S)jh6z zLieODhc1^cx9%xjK3#rYAzcw&GhGi|PhB5fKixpx3%XIdF}hcD6Ld3lvvhNG3w4Wi z`*jC(Cv~TF7j>6(@9RF(L+c&Y6VemWJFO?KC#R>Nr=;hg=dBl}cUdn(FH0{+FJG@n zuT-yGuS&00pG==ZpHd&GkI|>rKdgULpF#haKBGR1KCAw5{S*4^`W*V4`rP`u`u6$` z`pyJ5fxfFgUOzxTSU*Jnf_|iaynd2?vVMmCHT_2YF8v<;Uj0%1S^Z`GuLipeNDTHE z>^C@QfHc4u&=@cpFdG~gtQf2tavE|O@)+_P3K$9+3LArIaMEzzaKUiV@SfpQ!;gkv48NWuK6l_8 z={fRq4Cffnv7BQ&$9_)voXR=1bDHOL&gq{sI2V4d?%akEi4kP9*XV!|sS$+{rICb@ zol&w;lTou#t5Jthw^5%_ztJmW7GrJWO5c>yrt_wEOqWcTO;=6V zOz)cBGkswC(2T;2#f;VLgc-XTmzj{6sF|3Vl$nf~vYDEhhMBIJzL~3;ubIDDfLVmu zC9@Q>0<&VX60_@Ob!Lrb&1S=9qh=FkQ)aVfZ_M7By*K-0_SJls`EGM=b7S*p^D^^t z^Gfp?^Lq0p^Jeo07L*oeEKDuTEG#T=7Pc1l77i9^7DEjXwv^Y8(a5Uo_aLzavoGZ>9 zhsSy0ym7ubKU^R#2nXXraizFUToEhq&Ky&vAcPAG9X5 zCbPy^Ggxz4pR(q$=Cc;FmavwxHnFy|_OuSM4zs>s9c3MBec3v}`l@xKb(3|Ab-Q(! zb+2`w^$Qz18wDFX8+#i^8y6dQ8&4ZAn>?Edn~%0fZ0T(2Z5eG@Y}ss2*y`HCwi&kV zwjH)zw!O9kwnMhVw(rifoYy*!Kksqg>%8yzfb+rU;q#g2htA)#+he!aZol0jJ90ZJ zJA|EtoxNSM-F>?Uc8~0y*gdy7Z?m7bU$9@YU$tMi z|K0wn{d4>G_8;xPI50V|IIuaKbYORobdYvXa!_?pcQAG^a{wMNhc1U6hhB#Pharby zhcSmqhbf0?hZ%=k4!0fV9Tpvy9abDx9o8N9J05kUcVu*Ac0BHQ%8}1ez){pu%u&|y ztfQi%nxlrJouj*>hoh%skmE(iD~?wkYaQzy8y#C5+Z_8HZ#WJ+PCL#z-gf-#_|<8b z6NwY#MC)|KiN%S{>7)~%lYo=3Q>asz(*>s}r)Z}br#PoePVr6&PFJ0hozk4rovt}$ zI}JK5IxRV^I;}h1b9(CZ!s(^cJEsrMyPfwq?{g+~CU<6Y=5gk8=64o%mUC8jHg-01 zHg~oJu2pAeSLX=lc;`gtWal*JOy_LpZs#87KIZ}FA?H!&3Fk@Y-(B{&kh`36;c?+} z5p)r85pxlD(RXoo@ps8|x#p7XlIK$BQsPqT((khB^3e5w>p@piR|;2zE7}#~%Im7) zs_Sa%>ggKkn(f-;I^+7njl_-GjoVG!EyXR(E#2*!TaH_q~5w??-nw-&cGw>NHY-9ET|a{KDO&;6h~sXLWB(w)wo!JX0lxcdorX?G=e6?av4 zJ$Ezr^X?Ju7u}=WW8E*gr?{uPXSx@<7rS3~pLCycpLM_Ge%t+t`!n}F%@5cAx2k;~K zG5j2U9>0KJ#joQ(;y>fRc)q(x?A_zt?>*=}<9*9} z-h0tU$VbFS)JNP$(nrb%>m%=@;G^iH!asm;1leV__4U z`R()D?{~lfq)`=$Bi`4#vT z`c?Wh`E~n^``z@L@|*En@>}&=_j~KV+aL1Z=YP z5C1^_EdOl(T>k?9V*l&@W&VTy>;At7910)}AP=AlKm||-&;;-Ys0HW;_yqU{_y+_9 zgam{KLvVOzzczw0}}$10@DIB0t*6*14{!d1FHjv1E&LL1Lp!)0)Gp95kwY55kwV) z3c>_21Th7%1aSqO3gQdW4>Alg4l)fg3-So^3JMMi4GIs63%VSX5VRb$60{z4FX(>I zgP?~&kAj{AJq>yh^heO^pf^G9gFXf`g4iA5;M2k4!IHrW!OFp^!CJvO!6v~V#V6P{ z*e*CUI6OEa_)>66a6xc!a7pm>;JV<(;O5}*;5)&K!7IV*!S{lHgZIM+;6pGuOa-H0 zG|U4l!#c1h>;?P4{%{Z+0*Aua;AXf7-hl7I_u+@|WB3{TJmg>qYY2CUdWc4dR)}th zL5NX^afo+FLP$o)+mQDmA3{Ed5`_|nl7#LJ-5+`&^k67iD0wJFC{-vj6cvgNr4E${ z)ehAO)ekicH4e27Js)Zx>JsV}>K7Uq8XOuPdLcABv?TO;Xjy1|Xh-N^=x?FFhdv2? z7Wzl%tI*G3L}9za4u+A2QG}fcV-Mp9;|{}y$%UzfX@+Ts8HbsMS%h5(iwuhiiwnCH zmLFCaRvA_kRu|SD)*03lP8v=YP8p62M}?!qsl#c)kA%~O(}y#JGlesUvxc*UtA$&I z65ke6n5n>S%5z-Md5v~zg5n~ZgBc4UPhg{d-1?U(u))qDKAP~bi9~;@zKTKFFw8a z;^M1|Z!f;P`2OO@i=Qrji6n|7j@%UqMed2*A9*m6H&Q{EK>R1$0 z6l)Y))QPAwQIb&#QOZ%OQRkveqRgT!qdKCxqPnB{q6VXGM2$p^M@>fEjGBs?jhc(P z6*V8V5VaV!6txn)C;D*ok!bqpW6{jfoYAMEd837*MWUsnWuxVzm7`UoZK7SG-J;#2 z{iDO9U4c z#+Juc##Y5P$M(cd#7@Od$Iiws$F9Y0#1X|EildHWj$@5G5yuh79mg9d5GNdG5N8-? z6lWS|5r>Pjj!TN`jeBv4>Js7->Js&(!I%;lzAJ)PM6QTk5x=5;CHzYEmF_D& zSNg6DUKzeJc4hp^r}&fc`th~#_3;hy&GBvV?eSglz486=1M!3L!|@~Wqw(YMlkqp> zr{ZVgKPFHlP$nP~&iKs+OB10l$B1@u6qH7{P z(JRqA(I?R_(LXULF*q?KF*GqE@j_x`Vsv6n;$Y&9#F50Y#L2|@#Kpwr#EryziBA(> zB)&|1m-rzGk%US@C($RdB?%-6Cy6ATPQoV1Cn+SEB-tf7BsnL!C3z%yC#5E(C1oUK zCFLd+Bo!vzx(Z$8yQ+Ov=c?XS!>h(u&90hXjk(%#^+EE!$BvNYN>*0d98>}gzSJZb!CLTRFD;%O;qX=&+c z*V1y*a?=XZiqlHduBVlyRi;&?Rj1Xa)u%P2HKsMEt){(Bdz1D)?PJ=P^u6f^(hsFm zrX$jiq|>J#OJ_}IOP5MlOjk}^Yr)WpVGf%?9JGpaVUc)gD*ocLpVbuLp4J^!yv;b!z9Bd<9vog zMq@@(Mr%e#MrTG>Mo&g>#z4kk#!$v^##qL9#$?7+#`{dNO!7>sOk^e|lOdBSlO^+H zCP$_~rf{ZcrbMPxreUUKCN9%D(>c>SGd%NRW@Kh`W@2V?W@=_>W?5!sW=&>&=3M5j z%=yg4%$3ab%#Ca0*UnsXycT!u(zPqs60ap+OS_hSZRpyotYcZySu$C&S!c79vQ)Fw zvI4UzvzD_(vQKA=WlLmBXUk;EWh-PWWh-Z^WUFUuWNT(?XX|F`W$R}fX2aQ6vy-#a zvNN)?vWv5?XP0N!WY=Z4XLn`yWDjN!Wv^%dp8X{IY4+P3qMZFXCv!M+xN~@N_;Unv zByyy4usJF@YB`!Y_Br?*&m6BD-<(T1S8~#FGIO$WigQYH%5$c2W^!)j%;((6d6x4c z=R?ltoUgh2au4K^=IZAfQSS(mBSSeU9xL0t$;9LDix|0su$`M>J^$5S{C98?Ft+`j^`+}yu752fE+Z-1TXvxAVA=69tup7b%Vk%}63VWYrIuxsWtI(bQ`AYeE z`Q7q|<-eD|Dt}x4zWhrCQ3Xu}V+C^sO9fYjP=#cLafNAxd4*Mlb%k?na;7n=3miyDEn&M=QrGrz>YGpH{xD zd|&yYYIoJ4DpVD36@Qgrl}Od;Dr}W}l|q$fm3Eb0m48)W6iyLRst;C^R+CjzR#R1@s?pUn)wI=g)%4YJ)#s{>s!glStF5XX zt6i$ys=caxsza*7t1nc?RL4~pRaaHlRM%FwRrgmRo|{&tG-)(zxrd%-kSY2 zhib@csA^C(f;B=lA~j+)5;f8_GBqYOJ~bgVc{TYpg*7ELWi^#GRW&0u_iLWjQq)q` zB5KjKG_^-+>1u^*wQ7xO18M_ngKI-;BWfdSqiPFkyK0B(nCn>Uj@O;6SL;7hRWFmt2=xcdahFuB5K4uA;8C zuD))(?pED=-JQCPy2o{|>#6FI_2_z<`os0i^~dW^)brN!*9+Af)tl6t*IU+G)%(=@ z)rZwzsE@3VuTQK`u3xX;sJ~zTu>Mi~@AXgWpVq&q|D*nO{hRvt^&jd#*MDtbZ8+T^ z)*#U!)qrhKX;5#_Y|v{kXs~F&HP|#bG&nU}XozfxYDj3vXeenYYbbB1Y-nm|ZD?

EaU*FXStCUwq7mIl(@5JW(5T*M(CFLf*BHp!r}kSu;hmP_uHgO0#;iX0uMSNwaygWwULwU9)?$ zXR~*6Kyy%YN^?$gUUPnPd2>T^XY*q7a`S5QM)SSqr_C>#Up9Yg{?bC+!rH>t!rsE! z!qp22w68E6@58EqMBnQWPEnQfVCxz%!~WuaxUWu;}U zWxZvi z+KJmq+V`{{Y$t7JZRc+1Y3FS}-HvTnX*X;)ZZ~N+Yd_!a(C*Y8+J341N_%2^a(h~P zW_w3_XM1;hU;AMDaQjI6{SM-e10C!g935O8JRSTULLI^#S{+UuUL7eNsU7JZ*E(`K z@;eGTx;hp*?sh_*dph@Z9_%FRr0k^X1SUyH0nBcj|y8^n>x-z=1b>(#Bb(M8hc2#$^bhUMLcHQl|-}SKT_pZm?#NE5Q4|S7w zQ+CsKAL*v=w(GX?e_89h9_t^H> z_c-;q_TYPxdam}Q^rZJ(>&fZK?P>41-Luxat9N%V)Vr_uU@uuOdGEsl#ondfmEQHUj07(e*J;{!Tpi_G5vA<$^EJQ8U6MBjr~pit^Jez zQ~eA5%l)hU5Bq=be>#8|Kn+k2&<-3PI5ogKaC+d(faHL}fYN~KKk3%K=DAy!1aN$fy#lZftrE3frWwR11|<%4ZIn6Ke%fU8r(a0Xpn3WGe|plWboJ^ z)1cVknL&xcvx6FgCWGdK7K2uUj)N|PZi5#F69$t8QwGxquMOr5_6+t8_7C0|92p!R zoEZFkgZ+lV4c{AnHv(=1-w3@CapS^`x*MxQq(fXo+(SG={6j)RqC=;LY=KpoFm|@s?*k#y#*mKxt*nc=+IB+<47#Z4ktI-|OydZUJ;=SGc2O-9W|%||Uptwy6qvqy7A^G6FuOGax(>qi?$+eSM^ z2SB6$>S;GY2)eR*T%EPbH;PW3&sn_i^ogHZ;sy|e=z=N{PFm+ z@pt1N$3IW(njo1VouHVYn!rrZOz=+dPY6t$nUJ5*p3s}npD>)ToUop-od}<}GLbn^ zGI4#PVxoGYZlZCbWukpzd17T^ZQ}04gNa8IzfaOmo}KiZOrA`cOq@!Get9{Gi5W?Gqp2qGo3TtGXpa> zX4YmN%{-oYGV^BU>+HT+mf7R8CuTWjxn_lCMQ6okWoPAQ6=$7iU1#yLp0i%FF|%>A z$+Ky*8M6hmMYE-|uV>%PzMuUx`+4@u9MK%{9LXFsw|8#e+`+j+b7XTAb3${-epcx7cqP-HN)^bZh?Bom-2yR&K4|x_9gTZOYpc zw;gWB-j2I{`F6tXtG82cr`;a9{brtdUUpt?{_MQcyz0EhyykrHe8v3Y9f>B6&ci#8?>xKn{LYIzFYmm$^Y+fWJ0I_Sy7T4E*M(gR zyBA0n*cT)hq!zFXatjIznhQD$dJAR?77Mrq-v$4Lz=hz2$c31NxP^p;q=lM=x`pS-QSdv(&oO zyELO+H%Hn)^hH0 z(Q@f>?Q+v{_wvB<#PZDY((&1B7H z&1KDf&3g@AyR>$7Epx4Kt#z$yZFX&W?d96Lb<%a_b(bPxqeVJ->Sq_oDAz X-bw@9Mac69|4}2het!G+Ui|+9fQCUF diff --git a/vendor/github.com/lucas-clemente/quic-go/docs/quic.svg b/vendor/github.com/lucas-clemente/quic-go/docs/quic.svg deleted file mode 100644 index a37e0af..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/docs/quic.svg +++ /dev/null @@ -1,65 +0,0 @@ - - - - quic - Created with Sketch. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - QUI - C - - - \ No newline at end of file diff --git a/vendor/github.com/lucas-clemente/quic-go/example/Dockerfile b/vendor/github.com/lucas-clemente/quic-go/example/Dockerfile deleted file mode 100644 index d0723ee..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/example/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM scratch - -VOLUME /certs -VOLUME /www -EXPOSE 6121 - -ADD main /main - -CMD ["/main", "-bind=0.0.0.0", "-certpath=/certs/", "-www=/www"] diff --git a/vendor/github.com/lucas-clemente/quic-go/example/cert.der b/vendor/github.com/lucas-clemente/quic-go/example/cert.der deleted file mode 100644 index ef02fe3ff202e9173e1b5d48a779232eb1b42ceb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1288 zcmXqLVr4OCVt%uLnTe5!Nr?HLChsx7zk*s(S3jTo+GFK5-GG;kQ>)FR?K>|cBR4C9 zftMk-0Vf-CC<~h~Q)sZEn1Kk0!zIk?lUkx)tl*lLTvS<5VyJAO2oh%&mO>F%a4ap! z$S=w)sZ@wCHjoqNH8e9YF*F5|76t}UV6M5L36yIfZ769V4lzccurxDSFF7YQH#M&$ zRWCE&povil*=>xh49rc8{0u;GE~X|%MuzP!f+>!X224t&8XjrRA={6+&f8zrz#_8v zf5OJ<(;eKa|18#j9=9QRANRK%Z&|Z9esIml?=|6f3hx7>G59tnkW8W~sfq>)A!i?aN$K-+x~5W}!g= z%w$GJmK1{|1AQ3ZfU!+Eqokz3N?$)exwt?tGp|Iq!dNdSwWK%|l92TBi_-OxG%&$6 zB&QaY;M5=ua*`m6h=EWOX3A;&2a;7_Y5Zo;_}PGijV-;AhmncVpz#?SH!v(%7@O_` zy$}+LHN>3>{W%={6pOrdM7k?Z%zKZVR0bq%^%BWg`Q}d_UFx+xHAs}Ze;yS z|FU}e^RgN8b^$U05eK5)v%07KZ@gJJ?U4|V@1{@6vhS{cKanQ*cG{kDjpmaEyLU-B z^72ZrJSkbSGRf05rR%=r(J67;rzXZfVp#R-V@USzOKyvDKJCrA{j5-S?ztHE$+qhD zolAw@ME-cWw9{t7-oqbv>{q*}cv$t=WK-i{bI+fFn}aGNH)l0|<1MR?oOMKG;in5P zdA^0me&|}u^ft3Fr{cs_iOj{6Uk9qBar;z~8IT31y7Oi6s;oISRp<>3NAIrA4Uh&j1wXVrpV! zWSDcA=R?#}J@@TJvF6R2Gm;HnT{l&eRDHO2pXtYfN&4G&cssJLUOCT{BjU|Qts@!j z+>0NVK6&l0_q|9qh$z3@aP-_(ic|2>=eGQq~-^kmKfP`JhC5R4vw5eA)gIAakh*Cmi&<$y_8PCx(i1!@^cPL@*HTc` zWI0xH;DX`VenX3?V!Kut?{NOOQU0(&{h~@kVOw3ZACLchGS1p*X?S$~kzQWe6fxsf zzgjf6UEw}(qxSG*CT2zk#>GvHwZIUmG!Oy?sH`v}<9`+o12!PV#K>U42NL54iLn6F zN1H)C8;3R2P#h-gA@BM&1Jqk%meH_+KEj7|4} z{$n&SFwld!fr(K}3F?Mqpc6oL=~fu(<)oGrr$UmNUVc%!fepx1c@|RxV*|ql`U`a1 zv|*Zxa?sojOz%Pd{vpne5ys9zK6=STIR>&I-Fz%!EFvqsvXWV9@9uhb(Q^AT*VOl) zSG-w>oJ4_H446b28SWZi7yO(YVR2VN^fzbdzOt~L1s+Q?-PNlPsc=mC7$xr|q-m~F z5-5|DvE%I2g7l}~m+bM=2s}Ic#k%&nuWsy$TF5x-&WF2MvROCm!j@;Oxdt4HR-{@kf)2a)+!u%`E2){6W_KTHd;L6O!Z+>x=&G>hD&N+uyM)Tw+#W)@;$%&5TiZ?#vJAaME2mNZDq`5a2Ps~@9)}OFZ z(#`f;o%FJ*_MMBXawUGLE}hse`rwn8e#8bgeVq)oW8O2)-kQ(zvwp%`XD=Zazx?7V bjaN%nhllF4Ox`})Hs(OaAVarCE7 diff --git a/vendor/github.com/lucas-clemente/quic-go/example/fullchain.der b/vendor/github.com/lucas-clemente/quic-go/example/fullchain.der deleted file mode 100644 index ef02fe3ff202e9173e1b5d48a779232eb1b42ceb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1288 zcmXqLVr4OCVt%uLnTe5!Nr?HLChsx7zk*s(S3jTo+GFK5-GG;kQ>)FR?K>|cBR4C9 zftMk-0Vf-CC<~h~Q)sZEn1Kk0!zIk?lUkx)tl*lLTvS<5VyJAO2oh%&mO>F%a4ap! z$S=w)sZ@wCHjoqNH8e9YF*F5|76t}UV6M5L36yIfZ769V4lzccurxDSFF7YQH#M&$ zRWCE&povil*=>xh49rc8{0u;GE~X|%MuzP!f+>!X224t&8XjrRA={6+&f8zrz#_8v zf5OJ<(;eKa|18#j9=9QRANRK%Z&|Z9esIml?=|6f3hx7>G59tnkW8W~sfq>)A!i?aN$K-+x~5W}!g= z%w$GJmK1{|1AQ3ZfU!+Eqokz3N?$)exwt?tGp|Iq!dNdSwWK%|l92TBi_-OxG%&$6 zB&QaY;M5=ua*`m6h=EWOX3A;&2a;7_Y5Zo;_}PGijV-;AhmncVpz#?SH!v(%7@O_` zy$}+LHN>3>{W%={6pOrdM7k?Z%zKZVR0bq%^%BWg`Q}d_UFx+xHAs}Ze;yS z|FU}e^RgN8b^$U05eK5)v%07KZ@gJJ?U4|V@1{@6vhS{cKanQ*cG{kDjpmaEyLU-B z^72ZrJSkbSGRf05rR%=r(J67;rzXZfVp#R-V@USzOKyvDKJCrA{j5-S?ztHE$+qhD zolAw@ME-cWw9{t7-oqbv>{q*}cv$t=WK-i{bI+fFn}aGNH)l0|<1MR?oOMKG;in5P zdA^0me&|}u^ft3Fr{cs_iOj{6Uk9qBar;z~8IT31y7OiqIJTp4ux{^HDjF;s)sfxjyy;gpF#A}z2F2aq| zo9zN$s z`fd4T34m_&d2*|IByYb00|5X50)hbn0Ez|s%QNIf;q|Se&lDxKl1l@45#i#rFb`{R znR^h(zj2~&4A21`nwUXB4G`x;c}Ukrr{V=LXwBYknA=ITU_o!S>3t;# z$Vf;>v0F@dAN?0PHyOhcT@c3e7wH+}4>MH2QeUqf>wsN!ENZ z+aR;I+Y*{DWooQJm_IlwyrFfwvAf!=Gx%8I5+7)4NyFGWtz8VoG^?r1CKoU_SXK(2 z^4O6Ve&Kt_4ck9yxkmyg%S3d-mUx3va0SmRyT+Uwgd%+?1-BdQ6Xg3t=mTGSM2 zgcBGej=r*jHl*V7J=8kVg9h~<151bl~l zyZL7lQ%2whQg+2)y$jro{g-C^RmfRb%-DQ+>@`P*o(Upus796ZV80$Y;GqEUx;bQz z0)c@5u7&paq(&&$V3q*wAw{&rS|#v|N-?4oL10xF8!Hp`FdW-9(3;!T0{@CM zkdqb~e&Aq~l)zX(3`}*8p5(z{Bk8amS#(zw0)c@5iy_wiLB6f_S1UH*ggRJQx_3i) zrF8-b4SBZapdLzkGe") - for i := 0; i < 200; i++ { - fmt.Fprintf(w, ``, i) - } - io.WriteString(w, "") - }) - - http.HandleFunc("/demo/echo", func(w http.ResponseWriter, r *http.Request) { - body, err := ioutil.ReadAll(r.Body) - if err != nil { - fmt.Printf("error reading body while handling /echo: %s\n", err.Error()) - } - w.Write(body) - }) -} - -func main() { - go func() { - log.Println(http.ListenAndServe("localhost:6060", nil)) - }() - // runtime.SetBlockProfileRate(1) - - verbose := flag.Bool("v", false, "verbose") - bs := binds{} - flag.Var(&bs, "bind", "bind to") - certPath := flag.String("certpath", "", "certificate directory") - www := flag.String("www", "/var/www", "www data") - flag.Parse() - - if *verbose { - utils.SetLogLevel(utils.LogLevelDebug) - } else { - utils.SetLogLevel(utils.LogLevelInfo) - } - - var tlsConfig *tls.Config - if *certPath == "" { - tlsConfig = testdata.GetTLSConfig() - } else { - var err error - tlsConfig, err = tlsConfigFromCertpath(*certPath) - if err != nil { - panic(err) - } - } - - http.Handle("/", http.FileServer(http.Dir(*www))) - - if len(bs) == 0 { - bs = binds{"localhost:6121"} - } - - var wg sync.WaitGroup - wg.Add(len(bs)) - for _, b := range bs { - bCap := b - go func() { - server := h2quic.Server{ - // CloseAfterFirstRequest: true, - Server: &http.Server{ - Addr: bCap, - TLSConfig: tlsConfig, - }, - } - err := server.ListenAndServe() - if err != nil { - fmt.Println(err) - } - wg.Done() - }() - } - wg.Wait() -} - -func tlsConfigFromCertpath(certpath string) (*tls.Config, error) { - keyDer, err := ioutil.ReadFile(certpath + "/key.der") - if err != nil { - return nil, err - } - certDer, err := ioutil.ReadFile(certpath + "/cert.der") - if err != nil { - return nil, err - } - key, err := x509.ParsePKCS1PrivateKey(keyDer) - if err != nil { - return nil, err - } - return &tls.Config{ - Certificates: []tls.Certificate{{ - Certificate: [][]byte{certDer}, - PrivateKey: key, - }}, - }, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/example/privkey.pem b/vendor/github.com/lucas-clemente/quic-go/example/privkey.pem deleted file mode 100644 index 71d9af8..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/example/privkey.pem +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC3RBFkQVkwAiJ1 -KEhmQ1S3xkWev3qABBSj/2Cxe8uIC6v8oy/nV7Fj9JFlve7S3kJD/SJm7QFTF42v -MkPVBG2xP4gmiwgC0dweP4BVPfOP6ghMpz2iwE5oWaRJX8hUVgSGhS4OGjgShnYL -ztsldnvz0/vkAo7W9+CYmUVdV77OZBD6SmN4H6V0D6BdjbelluZUVI6jcCG9BJxS -hEmuiCpbBDwzOuO6kjzYjJflOqmKwZu9Vn58xGuXjy7CjdOb7QJf44+Gx4SsvV+b -isX8bricSLBVZ6VSwmnCgnitPrRcy2x/5GgwvR6HitfUeWaVHTmf+m35ZQmAbvR5 -cqt6JG+/AgMBAAECggEBAIoF+8sz5EXh9a2izxQltZJLA3gR4eK0MA9rcJl7EMi/ -caJuDNABHZqYQUENEOdDeUjXRqeZ7Bt2a8D87FVsZmjN3m6Y20m0YEFvtel9JQjI -S8PfWO5QQz0X9kFEoA3UUsg1WYBJgt2A4zr1adsHJ0d16gnJW2bPfRmwpastQIkT -ULBjqL/pWIcmLlx5aV7AdWpMQYUKFJmzT/fQbQUpimtsUcWisUFR86hs+XPTfRtR -3Gqw0/nZw7tL+Zu2JkGXr+irV3R/tVeEUM+O1M073rKfFkK/NAbjJRCnzhv0Himj -PcsRdtdQRKLzU6m8Q0cODZQwIYxaI6bgU3h84spp9/ECgYEA7DjyhzGtFQrNO/3c -1pkeNPp4y6NTgBRJ1nwx2yCzt9sSmi9laqxBmD84Kryhdbuxu9qsM/hY4hIfaGpJ -w9g6rV0MxTSrqcwmFzA3WFYKnvLYkRd+4XvIDds/ablHAifLRHTClniDUXAFzyu7 -xpwbhCJ9KAW3G+wT5PtD6ANfqDMCgYEAxpwUtXinPKUj3cc6GLM2Bf4JYkt5o67Z -p8+zrRtD82xVr70rVmjN8jA+/vsTdLr+x+j8hBMYI47A1ipgSYYR3IOllvFyA/rb -jrq5YnJTEVxbHJufmU8n2ycALbCk9X0jjX3fs3JV+ZjPsmaKFetekQRNBL5U6mkR -iJXXkfohfkUCgYAE9MDp4zntaheaPZ5Hhlji5appI1kaI9LUxDBLl6kNn3QJdhsb -nNeXeSQViXWdwb1d4p2gTYKX46dzCl/X0w6QGpatAIjlfBoEfId8u/lnElNG4AZS -dsVgvQvcjP2XZvxVyFlYzNh8eew1R4aeCSJuqEaV82C/HjngoQDwujlkjwKBgQCu -hfb4pEYo12CWAPx/OfON/nZWhsYj3IDsompcAiqK3DbLj+pmKwBWAqlIvG6TU8KQ -/p3unSzICihPybsEwKgvYwt+gTpUXvrSCCjhZl6yUbrKf8IWIOWAAVx5ydCa29UC -/4o0kJMWGn7gYJSUwFhADEx1j57kwWEj6bAdWXRXFQKBgQCLIdb9Qb6t9lcrNuGE -OlhYundDeaV1AggNebbmoB5KejNHPyalnjK0MNLf4KwHfCrDFY/54HGGslVdQSMd -Kl3l1L9H4eK8C6qP7Koh9J5Uey8kaIR12L3Afw8Gx7w+S48zo9LzrPoj8GwzOfH3 -D3Iz0NBdmZDK/BDSq2B9ByYIRg== ------END PRIVATE KEY----- diff --git a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager.go b/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager.go deleted file mode 100644 index 91ccd34..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager.go +++ /dev/null @@ -1,128 +0,0 @@ -package flowcontrol - -import ( - "errors" - "sync" - - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" -) - -type flowControlManager struct { - connectionParametersManager *handshake.ConnectionParametersManager - streamFlowController map[protocol.StreamID]*flowController - contributesToConnectionFlowControl map[protocol.StreamID]bool - mutex sync.Mutex -} - -var ( - // ErrStreamFlowControlViolation is a stream flow control violation - ErrStreamFlowControlViolation = errors.New("Stream level flow control violation") - // ErrConnectionFlowControlViolation is a connection level flow control violation - ErrConnectionFlowControlViolation = errors.New("Connection level flow control violation") -) - -var errMapAccess = errors.New("Error accessing the flowController map.") - -// NewFlowControlManager creates a new flow control manager -func NewFlowControlManager(connectionParametersManager *handshake.ConnectionParametersManager) FlowControlManager { - fcm := flowControlManager{ - connectionParametersManager: connectionParametersManager, - streamFlowController: make(map[protocol.StreamID]*flowController), - contributesToConnectionFlowControl: make(map[protocol.StreamID]bool), - } - // initialize connection level flow controller - fcm.streamFlowController[0] = NewFlowController(0, connectionParametersManager) - fcm.contributesToConnectionFlowControl[0] = false - return &fcm -} - -// NewStream creates new flow controllers for a stream -func (f *flowControlManager) NewStream(streamID protocol.StreamID, contributesToConnectionFlow bool) { - f.mutex.Lock() - defer f.mutex.Unlock() - - if _, ok := f.streamFlowController[streamID]; ok { - return - } - - f.streamFlowController[streamID] = NewFlowController(streamID, f.connectionParametersManager) - f.contributesToConnectionFlowControl[streamID] = contributesToConnectionFlow -} - -// UpdateHighestReceived updates the highest received byte offset for a stream -// it adds the number of additional bytes to connection level flow control -func (f *flowControlManager) UpdateHighestReceived(streamID protocol.StreamID, byteOffset protocol.ByteCount) error { - if streamID == 0 { - return errors.New("UpdateHightestReceived requires an actual StreamID.") - } - - f.mutex.Lock() - defer f.mutex.Unlock() - - streamFlowController, err := f.getFlowController(streamID) - if err != nil { - return err - } - increment := streamFlowController.UpdateHighestReceived(byteOffset) - - if streamFlowController.CheckFlowControlViolation() { - return ErrStreamFlowControlViolation - } - - if f.contributesToConnectionFlowControl[streamID] { - connectionFlowController := f.streamFlowController[0] - connectionFlowController.IncrementHighestReceived(increment) - if connectionFlowController.CheckFlowControlViolation() { - return ErrConnectionFlowControlViolation - } - } - - return nil -} - -func (f *flowControlManager) AddBytesRead(streamID protocol.StreamID, n protocol.ByteCount) error { - f.mutex.Lock() - defer f.mutex.Unlock() - - streamFlowController, err := f.getFlowController(streamID) - if err != nil { - return err - } - - streamFlowController.AddBytesRead(n) - - if f.contributesToConnectionFlowControl[streamID] { - f.streamFlowController[0].AddBytesRead(n) - } - - return nil -} - -func (f *flowControlManager) MaybeTriggerStreamWindowUpdate(streamID protocol.StreamID) (bool, protocol.ByteCount, error) { - f.mutex.Lock() - defer f.mutex.Unlock() - - streamFlowController, err := f.getFlowController(streamID) - if err != nil { - return false, 0, err - } - - doIt, offset := streamFlowController.MaybeTriggerWindowUpdate() - return doIt, offset, nil -} - -func (f *flowControlManager) MaybeTriggerConnectionWindowUpdate() (bool, protocol.ByteCount) { - f.mutex.Lock() - defer f.mutex.Unlock() - - return f.streamFlowController[0].MaybeTriggerWindowUpdate() -} - -func (f *flowControlManager) getFlowController(streamID protocol.StreamID) (FlowController, error) { - streamFlowController, ok := f.streamFlowController[streamID] - if !ok { - return nil, errMapAccess - } - return streamFlowController, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager_test.go b/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager_test.go deleted file mode 100644 index c86adc7..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_control_manager_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package flowcontrol - -import ( - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Flow Control Manager", func() { - var fcm *flowControlManager - var cpm *handshake.ConnectionParametersManager - - BeforeEach(func() { - cpm = &handshake.ConnectionParametersManager{} - setConnectionParametersManagerWindow(cpm, "receiveStreamFlowControlWindow", 0x100) - setConnectionParametersManagerWindow(cpm, "receiveConnectionFlowControlWindow", 0x200) - fcm = NewFlowControlManager(cpm).(*flowControlManager) - }) - - It("creates a connection level flow controller", func() { - Expect(fcm.streamFlowController).To(HaveKey(protocol.StreamID(0))) - Expect(fcm.contributesToConnectionFlowControl).To(HaveKey(protocol.StreamID(0))) - }) - - Context("creating new streams", func() { - It("creates a new stream", func() { - fcm.NewStream(5, true) - Expect(fcm.streamFlowController).To(HaveKey(protocol.StreamID(5))) - Expect(fcm.streamFlowController[5]).ToNot(BeNil()) - Expect(fcm.contributesToConnectionFlowControl).To(HaveKey(protocol.StreamID(5))) - Expect(fcm.contributesToConnectionFlowControl[5]).To(BeTrue()) - }) - }) - - Context("receiving data", func() { - BeforeEach(func() { - fcm.NewStream(1, false) - fcm.NewStream(4, true) - fcm.NewStream(6, true) - }) - - It("updates the connection level flow controller if the stream does not contribute", func() { - err := fcm.UpdateHighestReceived(4, 0x100) - Expect(err).ToNot(HaveOccurred()) - Expect(fcm.streamFlowController[0].highestReceived).To(Equal(protocol.ByteCount(0x100))) - Expect(fcm.streamFlowController[4].highestReceived).To(Equal(protocol.ByteCount(0x100))) - }) - - It("adds the offsets of multiple streams for the connection flow control window", func() { - err := fcm.UpdateHighestReceived(4, 0x100) - Expect(err).ToNot(HaveOccurred()) - err = fcm.UpdateHighestReceived(6, 0x50) - Expect(err).ToNot(HaveOccurred()) - Expect(fcm.streamFlowController[0].highestReceived).To(Equal(protocol.ByteCount(0x100 + 0x50))) - }) - - It("does not update the connection level flow controller if the stream does not contribute", func() { - err := fcm.UpdateHighestReceived(1, 0x100) - // fcm.streamFlowController[4].receiveFlowControlWindow = 0x1000 - Expect(err).ToNot(HaveOccurred()) - Expect(fcm.streamFlowController[0].highestReceived).To(Equal(protocol.ByteCount(0))) - Expect(fcm.streamFlowController[1].highestReceived).To(Equal(protocol.ByteCount(0x100))) - }) - - Context("flow control violations", func() { - It("errors when encountering a stream level flow control violation", func() { - err := fcm.UpdateHighestReceived(4, 0x101) - Expect(err).To(MatchError(ErrStreamFlowControlViolation)) - }) - - It("errors when encountering a connection-level flow control violation", func() { - fcm.streamFlowController[4].receiveFlowControlWindow = 0x300 - err := fcm.UpdateHighestReceived(4, 0x201) - Expect(err).To(MatchError(ErrConnectionFlowControlViolation)) - }) - }) - - Context("window updates", func() { - It("gets stream level window updates", func() { - err := fcm.UpdateHighestReceived(4, 0x100) - Expect(err).ToNot(HaveOccurred()) - err = fcm.AddBytesRead(4, 0x100-0x10) - Expect(err).ToNot(HaveOccurred()) - doIt, offset, err := fcm.MaybeTriggerStreamWindowUpdate(4) - Expect(err).ToNot(HaveOccurred()) - Expect(doIt).To(BeTrue()) - Expect(offset).ToNot(Equal(protocol.ByteCount(0x100))) - }) - - It("gets connection level window updates", func() { - err := fcm.UpdateHighestReceived(4, 0x100) - Expect(err).ToNot(HaveOccurred()) - err = fcm.UpdateHighestReceived(6, 0x100) - Expect(err).ToNot(HaveOccurred()) - err = fcm.AddBytesRead(4, 0x100-0x10) - Expect(err).ToNot(HaveOccurred()) - err = fcm.AddBytesRead(6, 0x100-0x10) - Expect(err).ToNot(HaveOccurred()) - doIt, offset := fcm.MaybeTriggerConnectionWindowUpdate() - Expect(err).ToNot(HaveOccurred()) - Expect(doIt).To(BeTrue()) - Expect(offset).ToNot(Equal(protocol.ByteCount(0x200))) - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller.go b/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller.go deleted file mode 100644 index d5de2b4..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller.go +++ /dev/null @@ -1,163 +0,0 @@ -package flowcontrol - -import ( - "sync" - - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" -) - -type flowController struct { - streamID protocol.StreamID - - connectionParametersManager *handshake.ConnectionParametersManager - - bytesSent protocol.ByteCount - sendFlowControlWindow protocol.ByteCount - lastBlockedSentForOffset protocol.ByteCount - - bytesRead protocol.ByteCount - highestReceived protocol.ByteCount - receiveFlowControlWindow protocol.ByteCount - receiveFlowControlWindowIncrement protocol.ByteCount - - mutex sync.RWMutex -} - -// NewFlowController gets a new flow controller -// TODO: make private -func NewFlowController(streamID protocol.StreamID, connectionParametersManager *handshake.ConnectionParametersManager) *flowController { - fc := flowController{ - streamID: streamID, - connectionParametersManager: connectionParametersManager, - } - - if streamID == 0 { - fc.receiveFlowControlWindow = connectionParametersManager.GetReceiveConnectionFlowControlWindow() - fc.receiveFlowControlWindowIncrement = fc.receiveFlowControlWindow - } else { - fc.receiveFlowControlWindow = connectionParametersManager.GetReceiveStreamFlowControlWindow() - fc.receiveFlowControlWindowIncrement = fc.receiveFlowControlWindow - } - - return &fc -} - -func (c *flowController) getSendFlowControlWindow() protocol.ByteCount { - if c.sendFlowControlWindow == 0 { - if c.streamID == 0 { - return c.connectionParametersManager.GetSendConnectionFlowControlWindow() - } - return c.connectionParametersManager.GetSendStreamFlowControlWindow() - } - return c.sendFlowControlWindow -} - -func (c *flowController) AddBytesSent(n protocol.ByteCount) { - c.mutex.Lock() - defer c.mutex.Unlock() - - c.bytesSent += n -} - -// UpdateSendWindow should be called after receiving a WindowUpdateFrame -// it returns true if the window was actually updated -func (c *flowController) UpdateSendWindow(newOffset protocol.ByteCount) bool { - c.mutex.Lock() - defer c.mutex.Unlock() - - if newOffset > c.sendFlowControlWindow { - c.sendFlowControlWindow = newOffset - return true - } - return false -} - -func (c *flowController) SendWindowSize() protocol.ByteCount { - c.mutex.RLock() - defer c.mutex.RUnlock() - - sendFlowControlWindow := c.getSendFlowControlWindow() - - if c.bytesSent > sendFlowControlWindow { // should never happen, but make sure we don't do an underflow here - return 0 - } - return sendFlowControlWindow - c.bytesSent -} - -// UpdateHighestReceived updates the highestReceived value, if the byteOffset is higher -// Should **only** be used for the stream-level FlowController -func (c *flowController) UpdateHighestReceived(byteOffset protocol.ByteCount) protocol.ByteCount { - c.mutex.Lock() - defer c.mutex.Unlock() - - if byteOffset > c.highestReceived { - increment := byteOffset - c.highestReceived - c.highestReceived = byteOffset - return increment - } - return 0 -} - -// IncrementHighestReceived adds an increment to the highestReceived value -// Should **only** be used for the connection-level FlowController -func (c *flowController) IncrementHighestReceived(increment protocol.ByteCount) { - c.mutex.Lock() - defer c.mutex.Unlock() - - c.highestReceived += increment -} - -func (c *flowController) AddBytesRead(n protocol.ByteCount) { - c.mutex.Lock() - defer c.mutex.Unlock() - - c.bytesRead += n -} - -// MaybeTriggerBlocked determines if it is necessary to send a Blocked for this stream -// it makes sure that only one Blocked is sent for each offset -func (c *flowController) MaybeTriggerBlocked() bool { - if c.SendWindowSize() != 0 { - return false - } - - c.mutex.RLock() - sendFlowControlWindow := c.getSendFlowControlWindow() - c.mutex.RUnlock() - - c.mutex.Lock() - defer c.mutex.Unlock() - - if c.lastBlockedSentForOffset == sendFlowControlWindow { - return false - } - - c.lastBlockedSentForOffset = sendFlowControlWindow - return true -} - -// MaybeTriggerWindowUpdate determines if it is necessary to send a WindowUpdate -// if so, it returns true and the offset of the window -func (c *flowController) MaybeTriggerWindowUpdate() (bool, protocol.ByteCount) { - c.mutex.Lock() - defer c.mutex.Unlock() - - diff := c.receiveFlowControlWindow - c.bytesRead - // Chromium implements the same threshold - if diff < (c.receiveFlowControlWindowIncrement / 2) { - c.receiveFlowControlWindow += c.receiveFlowControlWindowIncrement - return true, c.bytesRead + c.receiveFlowControlWindowIncrement - } - return false, 0 -} - -func (c *flowController) CheckFlowControlViolation() bool { - c.mutex.Lock() - defer c.mutex.Unlock() - - if c.highestReceived > c.receiveFlowControlWindow { - return true - } - return false -} diff --git a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller_test.go b/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller_test.go deleted file mode 100644 index f99b302..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flow_controller_test.go +++ /dev/null @@ -1,217 +0,0 @@ -package flowcontrol - -import ( - "reflect" - "unsafe" - - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -// set private variables of the ConnectionParametersManager -// those are normally read from the server parameter constants in the constructor of the ConnectionParametersManager -func setConnectionParametersManagerWindow(cpm *handshake.ConnectionParametersManager, name string, value protocol.ByteCount) { - *(*protocol.ByteCount)(unsafe.Pointer(reflect.ValueOf(cpm).Elem().FieldByName(name).UnsafeAddr())) = value -} - -var _ = Describe("Flow controller", func() { - var controller *flowController - - BeforeEach(func() { - controller = &flowController{} - }) - - Context("Constructor", func() { - var cpm *handshake.ConnectionParametersManager - - BeforeEach(func() { - cpm = &handshake.ConnectionParametersManager{} - setConnectionParametersManagerWindow(cpm, "sendStreamFlowControlWindow", 1000) - setConnectionParametersManagerWindow(cpm, "receiveStreamFlowControlWindow", 2000) - setConnectionParametersManagerWindow(cpm, "sendConnectionFlowControlWindow", 3000) - setConnectionParametersManagerWindow(cpm, "receiveConnectionFlowControlWindow", 4000) - }) - - It("reads the stream send and receive windows when acting as stream-level flow controller", func() { - fc := NewFlowController(5, cpm) - Expect(fc.streamID).To(Equal(protocol.StreamID(5))) - Expect(fc.receiveFlowControlWindow).To(Equal(protocol.ByteCount(2000))) - }) - - It("reads the stream send and receive windows when acting as stream-level flow controller", func() { - fc := NewFlowController(0, cpm) - Expect(fc.streamID).To(Equal(protocol.StreamID(0))) - Expect(fc.receiveFlowControlWindow).To(Equal(protocol.ByteCount(4000))) - }) - - It("does not set the stream flow control windows for sending", func() { - fc := NewFlowController(5, cpm) - Expect(fc.sendFlowControlWindow).To(BeZero()) - }) - - It("does not set the connection flow control windows for sending", func() { - fc := NewFlowController(0, cpm) - Expect(fc.sendFlowControlWindow).To(BeZero()) - }) - }) - - Context("send flow control", func() { - var cpm *handshake.ConnectionParametersManager - - BeforeEach(func() { - cpm = &handshake.ConnectionParametersManager{} - setConnectionParametersManagerWindow(cpm, "sendStreamFlowControlWindow", 1000) - setConnectionParametersManagerWindow(cpm, "sendConnectionFlowControlWindow", 3000) - controller.connectionParametersManager = cpm - }) - - It("adds bytes sent", func() { - controller.bytesSent = 5 - controller.AddBytesSent(6) - Expect(controller.bytesSent).To(Equal(protocol.ByteCount(5 + 6))) - }) - - It("gets the size of the remaining flow control window", func() { - controller.bytesSent = 5 - controller.sendFlowControlWindow = 12 - Expect(controller.SendWindowSize()).To(Equal(protocol.ByteCount(12 - 5))) - }) - - It("updates the size of the flow control window", func() { - controller.bytesSent = 5 - updateSuccessful := controller.UpdateSendWindow(15) - Expect(updateSuccessful).To(BeTrue()) - Expect(controller.SendWindowSize()).To(Equal(protocol.ByteCount(15 - 5))) - }) - - It("does not decrease the flow control window", func() { - updateSuccessful := controller.UpdateSendWindow(20) - Expect(updateSuccessful).To(BeTrue()) - Expect(controller.SendWindowSize()).To(Equal(protocol.ByteCount(20))) - updateSuccessful = controller.UpdateSendWindow(10) - Expect(updateSuccessful).To(BeFalse()) - Expect(controller.SendWindowSize()).To(Equal(protocol.ByteCount(20))) - }) - - It("asks the ConnectionParametersManager for the stream flow control window size", func() { - controller.streamID = 5 - Expect(controller.getSendFlowControlWindow()).To(Equal(protocol.ByteCount(1000))) - // make sure the value is not cached - setConnectionParametersManagerWindow(cpm, "sendStreamFlowControlWindow", 2000) - Expect(controller.getSendFlowControlWindow()).To(Equal(protocol.ByteCount(2000))) - }) - - It("stops asking the ConnectionParametersManager for the flow control stream window size once a window update has arrived", func() { - controller.streamID = 5 - Expect(controller.UpdateSendWindow(8000)) - setConnectionParametersManagerWindow(cpm, "sendStreamFlowControlWindow", 9000) - Expect(controller.getSendFlowControlWindow()).To(Equal(protocol.ByteCount(8000))) - }) - - It("asks the ConnectionParametersManager for the connection flow control window size", func() { - controller.streamID = 0 - Expect(controller.getSendFlowControlWindow()).To(Equal(protocol.ByteCount(3000))) - // make sure the value is not cached - setConnectionParametersManagerWindow(cpm, "sendConnectionFlowControlWindow", 5000) - Expect(controller.getSendFlowControlWindow()).To(Equal(protocol.ByteCount(5000))) - }) - - It("stops asking the ConnectionParametersManager for the connection flow control window size once a window update has arrived", func() { - controller.streamID = 0 - Expect(controller.UpdateSendWindow(7000)) - setConnectionParametersManagerWindow(cpm, "sendConnectionFlowControlWindow", 9000) - Expect(controller.getSendFlowControlWindow()).To(Equal(protocol.ByteCount(7000))) - }) - - Context("Blocked", func() { - var sendFlowControlWindow protocol.ByteCount = 20 - - BeforeEach(func() { - controller.sendFlowControlWindow = sendFlowControlWindow - }) - - It("sends a Blocked when there's no space left in the window", func() { - controller.bytesSent = sendFlowControlWindow - Expect(controller.MaybeTriggerBlocked()).To(BeTrue()) - }) - - It("does not send a Blocked when there's still space in the window", func() { - controller.bytesSent = sendFlowControlWindow - 1 - Expect(controller.MaybeTriggerBlocked()).To(BeFalse()) - }) - - It("only sends one Blocked for one offset", func() { - controller.bytesSent = sendFlowControlWindow - Expect(controller.MaybeTriggerBlocked()).To(BeTrue()) - Expect(controller.MaybeTriggerBlocked()).To(BeFalse()) - updateSuccessfull := controller.UpdateSendWindow(sendFlowControlWindow + 1) - Expect(updateSuccessfull).To(BeTrue()) - controller.bytesSent = sendFlowControlWindow + 1 - Expect(controller.MaybeTriggerBlocked()).To(BeTrue()) - }) - }) - }) - - Context("receive flow control", func() { - var receiveFlowControlWindow protocol.ByteCount = 10000 - var receiveFlowControlWindowIncrement protocol.ByteCount = 600 - - BeforeEach(func() { - controller.receiveFlowControlWindow = receiveFlowControlWindow - controller.receiveFlowControlWindowIncrement = receiveFlowControlWindowIncrement - }) - - It("adds bytes read", func() { - controller.bytesRead = 5 - controller.AddBytesRead(6) - Expect(controller.bytesRead).To(Equal(protocol.ByteCount(5 + 6))) - }) - - It("triggers a window update when necessary", func() { - readPosition := receiveFlowControlWindow - receiveFlowControlWindowIncrement/2 + 1 - controller.bytesRead = readPosition - updateNecessary, offset := controller.MaybeTriggerWindowUpdate() - Expect(updateNecessary).To(BeTrue()) - Expect(offset).To(Equal(readPosition + receiveFlowControlWindowIncrement)) - }) - - It("triggers a window update when not necessary", func() { - readPosition := receiveFlowControlWindow - receiveFlowControlWindow/2 - 1 - controller.bytesRead = readPosition - updateNecessary, _ := controller.MaybeTriggerWindowUpdate() - Expect(updateNecessary).To(BeFalse()) - }) - - It("updates the highestReceived", func() { - controller.highestReceived = 1337 - increment := controller.UpdateHighestReceived(1338) - Expect(increment).To(Equal(protocol.ByteCount(1338 - 1337))) - Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1338))) - }) - - It("does not decrease the highestReceived", func() { - controller.highestReceived = 1337 - increment := controller.UpdateHighestReceived(1000) - Expect(increment).To(Equal(protocol.ByteCount(0))) - Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1337))) - }) - - It("increases the highestReceived by a given increment", func() { - controller.highestReceived = 1337 - controller.IncrementHighestReceived(123) - Expect(controller.highestReceived).To(Equal(protocol.ByteCount(1337 + 123))) - }) - - It("detects a flow control violation", func() { - controller.UpdateHighestReceived(receiveFlowControlWindow + 1) - Expect(controller.CheckFlowControlViolation()).To(BeTrue()) - }) - - It("does not give a flow control violation when using the window completely", func() { - controller.UpdateHighestReceived(receiveFlowControlWindow) - Expect(controller.CheckFlowControlViolation()).To(BeFalse()) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flowcontrol_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flowcontrol_suite_test.go deleted file mode 100644 index 17920ab..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/flowcontrol_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package flowcontrol - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestCrypto(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "FlowControl Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/interface.go b/vendor/github.com/lucas-clemente/quic-go/flowcontrol/interface.go deleted file mode 100644 index 2591e00..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/flowcontrol/interface.go +++ /dev/null @@ -1,25 +0,0 @@ -package flowcontrol - -import "github.com/lucas-clemente/quic-go/protocol" - -// A FlowController handles the flow control -type FlowController interface { - AddBytesSent(n protocol.ByteCount) - UpdateSendWindow(newOffset protocol.ByteCount) bool - SendWindowSize() protocol.ByteCount - UpdateHighestReceived(byteOffset protocol.ByteCount) protocol.ByteCount - IncrementHighestReceived(increment protocol.ByteCount) - AddBytesRead(n protocol.ByteCount) - MaybeTriggerBlocked() bool - MaybeTriggerWindowUpdate() (bool, protocol.ByteCount) - CheckFlowControlViolation() bool -} - -// A FlowControlManager manages the flow control -type FlowControlManager interface { - NewStream(streamID protocol.StreamID, contributesToConnectionFlow bool) - UpdateHighestReceived(streamID protocol.StreamID, byteOffset protocol.ByteCount) error - AddBytesRead(streamID protocol.StreamID, n protocol.ByteCount) error - MaybeTriggerStreamWindowUpdate(streamID protocol.StreamID) (bool, protocol.ByteCount, error) - MaybeTriggerConnectionWindowUpdate() (bool, protocol.ByteCount) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/ack_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/ack_frame.go deleted file mode 100644 index ad19601..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/ack_frame.go +++ /dev/null @@ -1,317 +0,0 @@ -package frames - -import ( - "bytes" - "errors" - "time" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" -) - -var errInvalidNackRanges = errors.New("AckFrame: ACK frame contains invalid NACK ranges") - -// An AckFrame in QUIC -type AckFrame struct { - LargestObserved protocol.PacketNumber - Entropy byte - NackRanges []NackRange // has to be ordered. The NACK range with the highest FirstPacketNumber goes first, the NACK range with the lowest FirstPacketNumber goes last - Truncated bool - - DelayTime time.Duration - PacketReceivedTime time.Time // only for received packets. Will not be modified for received ACKs frames -} - -// Write writes an ACK frame. -func (f *AckFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - largestObservedLen := protocol.GetPacketNumberLength(f.LargestObserved) - - typeByte := uint8(0x40) - - if largestObservedLen != protocol.PacketNumberLen1 { - typeByte ^= (uint8(largestObservedLen / 2)) << 2 - } - - if f.HasNACK() { - typeByte |= (0x20 | 0x03) - } - - f.DelayTime = time.Now().Sub(f.PacketReceivedTime) - - b.WriteByte(typeByte) - b.WriteByte(f.Entropy) - - switch largestObservedLen { - case protocol.PacketNumberLen1: - b.WriteByte(uint8(f.LargestObserved)) - case protocol.PacketNumberLen2: - utils.WriteUint16(b, uint16(f.LargestObserved)) - case protocol.PacketNumberLen4: - utils.WriteUint32(b, uint32(f.LargestObserved)) - case protocol.PacketNumberLen6: - utils.WriteUint48(b, uint64(f.LargestObserved)) - } - - utils.WriteUfloat16(b, uint64(f.DelayTime/time.Microsecond)) - b.WriteByte(0x01) // Just one timestamp - b.WriteByte(0x00) // Delta Largest observed - utils.WriteUint32(b, 0) // First timestamp - - if f.HasNACK() { - numRanges := uint64(0) - // calculate the number of NackRanges that are about to be written - // this number is different from len(f.NackRanges) for the case of contiguous NACK ranges - for _, nackRange := range f.NackRanges { - rangeLength := nackRange.Len() - numRanges += rangeLength/0xFF + 1 - if rangeLength > 0 && rangeLength%0xFF == 0 { - numRanges-- - } - } - if numRanges > 0xFF { - panic("Too many NACK ranges. Truncating not yet implemented.") - } - - b.WriteByte(uint8(numRanges)) - - rangeCounter := uint8(0) - for i, nackRange := range f.NackRanges { - var missingPacketSequenceNumberDelta uint64 - if i == 0 { - if nackRange.LastPacketNumber > f.LargestObserved { - return errors.New("AckFrame: Invalid NACK ranges") - } - missingPacketSequenceNumberDelta = uint64(f.LargestObserved) - uint64(nackRange.LastPacketNumber) - } else { - lastNackRange := f.NackRanges[i-1] - missingPacketSequenceNumberDelta = uint64(lastNackRange.FirstPacketNumber) - uint64(nackRange.LastPacketNumber) - 1 - } - rangeLength := nackRange.Len() - - utils.WriteUint48(b, missingPacketSequenceNumberDelta) - b.WriteByte(uint8(rangeLength % 0x100)) - rangeCounter++ - - rangeLength = rangeLength - (rangeLength % 0x100) - for rangeLength > 0 { - rangeCounter++ - utils.WriteUint48(b, 0) - b.WriteByte(uint8(0xFF)) - rangeLength -= 0x100 - } - } - - if rangeCounter != uint8(numRanges) { - return errors.New("BUG: Inconsistent number of NACK ranges written") - } - - // TODO: Remove once we drop support for <32 - if version < protocol.Version32 { - b.WriteByte(0) - } - } - - return nil -} - -// MinLength of a written frame -func (f *AckFrame) MinLength() (protocol.ByteCount, error) { - l := 1 + 1 + 2 + 1 + 1 + 4 // 1 TypeByte, 1 Entropy, 2 ACK delay time, 1 Num Timestamp, 1 Delta Largest Observed, 4 FirstTimestamp - l += int(protocol.GetPacketNumberLength(f.LargestObserved)) - l += (1 + 2) * 0 /* TODO: num_timestamps */ - if f.HasNACK() { - l += 1 + (6+1)*len(f.NackRanges) - l++ // TODO: Remove once we drop support for <32 - } - return protocol.ByteCount(l), nil -} - -// HasNACK returns if the frame has NACK ranges -func (f *AckFrame) HasNACK() bool { - if len(f.NackRanges) > 0 { - return true - } - return false -} - -// GetHighestInOrderPacketNumber gets the highest in order packet number that is confirmed by this ACK -func (f *AckFrame) GetHighestInOrderPacketNumber() protocol.PacketNumber { - if f.HasNACK() { - return (f.NackRanges[len(f.NackRanges)-1].FirstPacketNumber - 1) - } - return f.LargestObserved -} - -// ParseAckFrame reads an ACK frame -func ParseAckFrame(r *bytes.Reader, version protocol.VersionNumber) (*AckFrame, error) { - frame := &AckFrame{} - - typeByte, err := r.ReadByte() - if err != nil { - return nil, err - } - - hasNACK := false - if typeByte&0x20 == 0x20 { - hasNACK = true - } - frame.Truncated = typeByte&0x10 > 0 - - largestObservedLen := 2 * ((typeByte & 0x0C) >> 2) - if largestObservedLen == 0 { - largestObservedLen = 1 - } - - missingSequenceNumberDeltaLen := 2 * (typeByte & 0x03) - if missingSequenceNumberDeltaLen == 0 { - missingSequenceNumberDeltaLen = 1 - } - - frame.Entropy, err = r.ReadByte() - if err != nil { - return nil, err - } - - largestObserved, err := utils.ReadUintN(r, largestObservedLen) - if err != nil { - return nil, err - } - frame.LargestObserved = protocol.PacketNumber(largestObserved) - - delay, err := utils.ReadUfloat16(r) - if err != nil { - return nil, err - } - frame.DelayTime = time.Duration(delay) * time.Microsecond - - if !frame.Truncated { - var numTimestampByte byte - numTimestampByte, err = r.ReadByte() - if err != nil { - return nil, err - } - numTimestamp := uint8(numTimestampByte) - - // Delta Largest observed - _, err = r.ReadByte() - if err != nil { - return nil, err - } - // First Timestamp - _, err = utils.ReadUint32(r) - if err != nil { - return nil, err - } - - for i := 0; i < int(numTimestamp)-1; i++ { - // Delta Largest observed - _, err = r.ReadByte() - if err != nil { - return nil, err - } - // Time Since Previous Timestamp - _, err = utils.ReadUint16(r) - if err != nil { - return nil, err - } - } - } - - // Invalid NACK Handling: - // NACKs contain a lot of offsets that require subtractions of PacketNumbers. If an ACK contains invalid data, it is possible to underflow the uint64 used to store the PacketNumber - // TODO: handle uint64 overflows - if hasNACK { - var numRanges uint8 - numRanges, err = r.ReadByte() - if err != nil { - return nil, err - } - - for i := uint8(0); i < numRanges; i++ { - missingPacketSequenceNumberDelta, err := utils.ReadUintN(r, missingSequenceNumberDeltaLen) - if err != nil { - return nil, err - } - - rangeLengthByte, err := r.ReadByte() - if err != nil { - return nil, err - } - rangeLength := uint8(rangeLengthByte) - - // contiguous NACK range - if i > 0 && missingPacketSequenceNumberDelta == 0 { - nackRange := &frame.NackRanges[len(frame.NackRanges)-1] - if uint64(nackRange.FirstPacketNumber) <= uint64(rangeLength)+1 { - return nil, errInvalidNackRanges - } - nackRange.FirstPacketNumber = protocol.PacketNumber(uint64(nackRange.FirstPacketNumber) - uint64(rangeLength) - 1) - } else { - nackRange := NackRange{} - if i == 0 { - if uint64(frame.LargestObserved) < missingPacketSequenceNumberDelta+uint64(rangeLength) { - return nil, errInvalidNackRanges - } - nackRange.FirstPacketNumber = frame.LargestObserved - protocol.PacketNumber(missingPacketSequenceNumberDelta+uint64(rangeLength)) - } else { - lastNackRange := frame.NackRanges[len(frame.NackRanges)-1] - if uint64(lastNackRange.FirstPacketNumber) <= missingPacketSequenceNumberDelta+uint64(rangeLength) { - return nil, errInvalidNackRanges - } - nackRange.FirstPacketNumber = lastNackRange.FirstPacketNumber - protocol.PacketNumber(missingPacketSequenceNumberDelta+uint64(rangeLength)) - 1 - } - nackRange.LastPacketNumber = protocol.PacketNumber(uint64(nackRange.FirstPacketNumber) + uint64(rangeLength)) - frame.NackRanges = append(frame.NackRanges, nackRange) - } - } - - // TODO: Remove once we drop support for versions <32 - if version < protocol.Version32 { - numRevived, err := r.ReadByte() - if err != nil { - return nil, err - } - - for i := uint8(0); i < numRevived; i++ { - _, err := utils.ReadUintN(r, largestObservedLen) - if err != nil { - return nil, err - } - } - } - } - - if !frame.validateNackRanges() { - return nil, errInvalidNackRanges - } - - return frame, nil -} - -func (f *AckFrame) validateNackRanges() bool { - // check the validity of every single NACK range - for _, nackRange := range f.NackRanges { - if nackRange.FirstPacketNumber > nackRange.LastPacketNumber { - return false - } - if nackRange.LastPacketNumber > f.LargestObserved { - return false - } - } - - // check the consistency for ACK with multiple NACK ranges - for i, nackRange := range f.NackRanges { - if i == 0 { - continue - } - lastNackRange := f.NackRanges[i-1] - if lastNackRange.FirstPacketNumber <= nackRange.FirstPacketNumber { - return false - } - if lastNackRange.FirstPacketNumber <= nackRange.LastPacketNumber { - return false - } - } - - return true -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/ack_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/ack_frame_test.go deleted file mode 100644 index 09e8885..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/ack_frame_test.go +++ /dev/null @@ -1,587 +0,0 @@ -package frames - -import ( - "bytes" - "time" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("AckFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.Entropy).To(Equal(byte(0xA4))) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0x03))) - Expect(frame.DelayTime).To(Equal(430464 * time.Microsecond)) - Expect(frame.HasNACK()).To(Equal(false)) - Expect(b.Len()).To(Equal(0)) - }) - - It("parses a frame with a 48 bit packet number", func() { - b := bytes.NewReader([]byte{0x4C, 0xA4, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x23, 0x45, 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337))) - Expect(b.Len()).To(Equal(0)) - }) - - It("completely parses a frame with multiple timestamps", func() { - b := bytes.NewReader([]byte{0x40, 0xA4, 0x03, 0x23, 0x45, 0x03, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0x12, 0x34, 0x56, 0x78, 0x90, 0xA0}) - _, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Len()).To(Equal(0)) - }) - - It("parses a frame containing one NACK range", func() { - b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.HasNACK()).To(Equal(true)) - Expect(frame.NackRanges).To(HaveLen(1)) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(3))) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 1, LastPacketNumber: 2})) - Expect(b.Len()).To(Equal(0)) - }) - - It("parses a frame containing one NACK range with a 48 bit LargestObserved and missingPacketSequenceNumberDelta", func() { - var rangeLength uint64 = 3 - b := bytes.NewReader([]byte{(0x4C | 0x20 | 0x03), 0x08, 0x37, 0x13, 0xAD, 0xFB, 0xCA, 0xDE, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, byte(rangeLength)}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(0xDECAFBAD1337))) - Expect(frame.HasNACK()).To(Equal(true)) - Expect(frame.NackRanges).To(HaveLen(1)) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: protocol.PacketNumber(0xDECAFBAD1337 - 0xDEADBEEFCAFE - rangeLength), LastPacketNumber: 0xDECAFBAD1337 - 0xDEADBEEFCAFE})) - Expect(b.Len()).To(Equal(0)) - }) - - It("parses a frame containing multiple NACK ranges", func() { - // sent packets 1, 3, 7, 15 - b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x3, 0x1, 0x6, 0x1, 0x2, 0x1, 0x0}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.HasNACK()).To(Equal(true)) - Expect(frame.NackRanges).To(HaveLen(3)) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 8, LastPacketNumber: 14})) - Expect(frame.NackRanges[1]).To(Equal(NackRange{FirstPacketNumber: 4, LastPacketNumber: 6})) - Expect(frame.NackRanges[2]).To(Equal(NackRange{FirstPacketNumber: 2, LastPacketNumber: 2})) - Expect(b.Len()).To(Equal(0)) - }) - - It("rejects a packet with an invalid NACK range", func() { - // LargestObserved: 8, NackRange: (8-7-3) to (8-7) - b := bytes.NewReader([]byte{0x60, 0x8, 0x7, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x7, 0x3}) - _, err := ParseAckFrame(b, protocol.Version32) - Expect(err).To(MatchError(errInvalidNackRanges)) - }) - - It("accepts truncated acks", func() { - b := bytes.NewReader([]byte{0x50, 0xA4, 0x03, 0x23, 0x45}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.Truncated).To(BeTrue()) - Expect(b.Len()).To(BeZero()) - }) - - It("parses a frame with the largest observed missing", func() { - b := bytes.NewReader([]byte{0x60, 0x2, 0xf, 0xb8, 0x1, 0x1, 0x0, 0xe5, 0x58, 0x4, 0x0, 0x1, 0x0, 0x0}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.HasNACK()).To(Equal(true)) - Expect(frame.NackRanges).To(HaveLen(1)) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 15, LastPacketNumber: 15})) - Expect(b.Len()).To(Equal(0)) - }) - - Context("support for version 31", func() { - It("support a simple ACK with one NACK range, version 31", func() { - b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1, 0x0}) - frame, err := ParseAckFrame(b, protocol.Version31) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.HasNACK()).To(Equal(true)) - Expect(frame.NackRanges).To(HaveLen(1)) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(3))) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 1, LastPacketNumber: 2})) - Expect(b.Len()).To(Equal(0)) - }) - - It("support a simple ACK with multiple NACK ranges, version 31", func() { - b := bytes.NewReader([]byte{0x60, 0x8, 0x9, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x1, 0x2, 0x0, 0x0}) - frame, err := ParseAckFrame(b, protocol.Version31) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.HasNACK()).To(Equal(true)) - Expect(frame.NackRanges).To(HaveLen(2)) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(9))) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 7, LastPacketNumber: 8})) - Expect(frame.NackRanges[1]).To(Equal(NackRange{FirstPacketNumber: 4, LastPacketNumber: 4})) - Expect(b.Len()).To(Equal(0)) - }) - - It("reads the complete ACK frame if it contains revived packet numbers", func() { - b := bytes.NewReader([]byte{0x60, 0x8, 0x3, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x1, 0x1, 0x1, 0x3, 0x5, 0x6, 0x7}) - _, err := ParseAckFrame(b, protocol.Version31) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Len()).To(Equal(0)) - }) - }) - - Context("contiguous NACK ranges", func() { - It("parses a frame with a contiguous NACK range spanning two fields", func() { - b := bytes.NewReader([]byte{0x64, 0x8, 0x2E, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(302))) - Expect(frame.NackRanges).To(HaveLen(1)) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 2, LastPacketNumber: 301})) - }) - - It("parses a frame with a contiguous NACK range spanning more than two fields", func() { - b := bytes.NewReader([]byte{0x64, 0x8, 0x16, 0x05, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x6, 0x1, 0x13, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(1302))) - Expect(frame.NackRanges).To(HaveLen(1)) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 2, LastPacketNumber: 1301})) - }) - - It("parses a frame with two contiguous NACK ranges", func() { - b := bytes.NewReader([]byte{0x64, 0x8, 0x23, 0x03, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x4, 0x1, 0x8f, 0x0, 0xff, 0x1, 0x8f, 0x0, 0xff}) - frame, err := ParseAckFrame(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.LargestObserved).To(Equal(protocol.PacketNumber(803))) - Expect(frame.NackRanges).To(HaveLen(2)) - Expect(frame.NackRanges[0]).To(Equal(NackRange{FirstPacketNumber: 403, LastPacketNumber: 802})) - Expect(frame.NackRanges[1]).To(Equal(NackRange{FirstPacketNumber: 2, LastPacketNumber: 401})) - }) - - It("rejects a frame with an invalid NACK range", func() { - // LargestObserved: 280, but NACK range is 301 packets long - b := bytes.NewReader([]byte{0x64, 0x8, 0x18, 0x01, 0x72, 0x1, 0x1, 0x0, 0xc0, 0x15, 0x0, 0x0, 0x2, 0x1, 0x2b, 0x0, 0xff}) - _, err := ParseAckFrame(b, protocol.Version32) - Expect(err).To(MatchError(errInvalidNackRanges)) - }) - }) - }) - - Context("GetHighestInOrderPacket", func() { - It("gets the highest in order packet number for an ACK without NACK ranges", func() { - frame := AckFrame{LargestObserved: 5} - Expect(frame.GetHighestInOrderPacketNumber()).To(Equal(protocol.PacketNumber(5))) - }) - - It("gets the highest in order packet number for an ACK with one NACK ranges", func() { - nackRange := NackRange{FirstPacketNumber: 3, LastPacketNumber: 4} - frame := AckFrame{ - LargestObserved: 6, - NackRanges: []NackRange{nackRange}, - } - Expect(frame.GetHighestInOrderPacketNumber()).To(Equal(protocol.PacketNumber(2))) - }) - - It("gets the highest in order packet number for an ACK with one NACK ranges", func() { - nackRanges := []NackRange{ - {FirstPacketNumber: 9, LastPacketNumber: 11}, - {FirstPacketNumber: 7, LastPacketNumber: 7}, - {FirstPacketNumber: 4, LastPacketNumber: 5}, - } - frame := &AckFrame{ - LargestObserved: 15, - NackRanges: nackRanges, - } - Expect(frame.GetHighestInOrderPacketNumber()).To(Equal(protocol.PacketNumber(3))) - }) - }) - - Context("NACK range validator", func() { - It("rejects NACKs with FirstPacketNumber greater than LastPacketNumber", func() { - nackRange := NackRange{FirstPacketNumber: 7, LastPacketNumber: 6} - ack := AckFrame{ - LargestObserved: 10, - NackRanges: []NackRange{nackRange}, - } - Expect(ack.validateNackRanges()).To(BeFalse()) - }) - - It("rejects NACKs with FirstPacketNumber greater than LargestObserved", func() { - nackRange := NackRange{FirstPacketNumber: 6, LastPacketNumber: 6} - ack := AckFrame{ - LargestObserved: 5, - NackRanges: []NackRange{nackRange}, - } - Expect(ack.validateNackRanges()).To(BeFalse()) - }) - - It("does not reject NACKs with LasterPacketNumber equal to LargestObserved", func() { - nackRange := NackRange{FirstPacketNumber: 7, LastPacketNumber: 7} - ack := AckFrame{ - LargestObserved: 7, - NackRanges: []NackRange{nackRange}, - } - Expect(ack.validateNackRanges()).To(BeTrue()) - }) - - It("rejects NACKs with NackRanges in the wrong order", func() { - nackRanges := []NackRange{ - {FirstPacketNumber: 2, LastPacketNumber: 2}, - {FirstPacketNumber: 6, LastPacketNumber: 6}, - } - ack := AckFrame{ - LargestObserved: 7, - NackRanges: nackRanges, - } - Expect(ack.validateNackRanges()).To(BeFalse()) - }) - - It("rejects NACKs with overlapping NackRanges", func() { - nackRanges := []NackRange{ - {FirstPacketNumber: 5, LastPacketNumber: 6}, - {FirstPacketNumber: 2, LastPacketNumber: 5}, - } - ack := AckFrame{ - LargestObserved: 7, - NackRanges: nackRanges, - } - Expect(ack.validateNackRanges()).To(BeFalse()) - }) - - It("accepts an ACK without NACK Ranges", func() { - ack := AckFrame{LargestObserved: 7} - Expect(ack.validateNackRanges()).To(BeTrue()) - }) - - It("accepts an ACK with one NACK Ranges", func() { - nackRange := NackRange{FirstPacketNumber: 6, LastPacketNumber: 8} - ack := AckFrame{ - LargestObserved: 10, - NackRanges: []NackRange{nackRange}, - } - Expect(ack.validateNackRanges()).To(BeTrue()) - }) - - It("accepts an ACK with multiple NACK Ranges", func() { - nackRanges := []NackRange{ - {FirstPacketNumber: 6, LastPacketNumber: 7}, - {FirstPacketNumber: 2, LastPacketNumber: 4}, - } - ack := AckFrame{ - LargestObserved: 10, - NackRanges: nackRanges, - } - Expect(ack.validateNackRanges()).To(BeTrue()) - }) - }) - - Context("when writing", func() { - var b *bytes.Buffer - BeforeEach(func() { - b = &bytes.Buffer{} - }) - - It("writes simple frames without NACK ranges", func() { - frame := AckFrame{ - Entropy: 2, - LargestObserved: 1, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - // check all values except the DelayTime - Expect(b.Bytes()[0:3]).To(Equal([]byte{0x40, 0x02, 0x01})) - Expect(b.Bytes()[5:]).To(Equal([]byte{1, 0, 0, 0, 0, 0})) - }) - - It("calculates the DelayTime", func() { - frame := AckFrame{ - LargestObserved: 5, - PacketReceivedTime: time.Now().Add(-750 * time.Millisecond), - } - frame.Write(b, protocol.Version32) - Expect(frame.DelayTime).To(BeNumerically("~", 750*time.Millisecond, 10*time.Millisecond)) - delayTime := frame.DelayTime - var b2 bytes.Buffer - utils.WriteUfloat16(&b2, uint64(delayTime/time.Microsecond)) - Expect(b.Bytes()[3:5]).To(Equal(b2.Bytes())) - }) - - It("writes a frame with one NACK range", func() { - frame := AckFrame{ - Entropy: 2, - LargestObserved: 4, - NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}}, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-8:] - Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges - Expect(missingPacketBytes[7]).To(Equal(uint8(0))) // rangeLength - packetNumber := make([]byte, 6) - copy(packetNumber, missingPacketBytes[1:6]) - Expect(packetNumber).To(BeEquivalentTo([]byte{2, 0, 0, 0, 0, 0})) - }) - - It("supports version 31", func() { - frame := AckFrame{ - Entropy: 2, - LargestObserved: 4, - NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}}, - } - err := frame.Write(b, protocol.Version31) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-9:] - Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges - Expect(missingPacketBytes[7]).To(Equal(uint8(0))) // rangeLength - packetNumber := make([]byte, 6) - copy(packetNumber, missingPacketBytes[1:6]) - Expect(packetNumber).To(BeEquivalentTo([]byte{2, 0, 0, 0, 0, 0})) - Expect(b.Bytes()[b.Len()-1]).To(BeZero()) - }) - - It("writes a frame with multiple NACK ranges", func() { - nackRange1 := NackRange{FirstPacketNumber: 4, LastPacketNumber: 6} - nackRange2 := NackRange{FirstPacketNumber: 2, LastPacketNumber: 2} - frame := AckFrame{ - Entropy: 2, - LargestObserved: 7, - NackRanges: []NackRange{nackRange1, nackRange2}, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):] - Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges - Expect(missingPacketBytes[7]).To(Equal(uint8(3 - 1))) // rangeLength #1 - Expect(missingPacketBytes[14]).To(Equal(uint8(1 - 1))) // rangeLength #2 - packetNumber1 := make([]byte, 6) - packetNumber2 := make([]byte, 6) - copy(packetNumber1, missingPacketBytes[1:6]) - copy(packetNumber2, missingPacketBytes[8:13]) - Expect(packetNumber1).To(BeEquivalentTo([]byte{1, 0, 0, 0, 0, 0})) - Expect(packetNumber2).To(BeEquivalentTo([]byte{1, 0, 0, 0, 0, 0})) - }) - - Context("contiguous NACK ranges", func() { - It("writes the largest possible NACK range that does not require to be written in contiguous form", func() { - frame := AckFrame{ - Entropy: 2, - LargestObserved: 258, - NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 257}}, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-(1+7):] - Expect(missingPacketBytes[0]).To(Equal(uint8(1))) // numRanges - Expect(missingPacketBytes[1:7]).To(Equal([]byte{1, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta - Expect(missingPacketBytes[7]).To(Equal(uint8(0xFF))) // rangeLength - }) - - It("writes a frame with a contiguous NACK range", func() { - frame := AckFrame{ - Entropy: 2, - LargestObserved: 302, - NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 301}}, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):] - Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges - Expect(missingPacketBytes[1:7]).To(Equal([]byte{1, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #1 - Expect(missingPacketBytes[7]).To(Equal(uint8(43))) // rangeLength #1 - Expect(missingPacketBytes[8:14]).To(Equal([]byte{0, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #2 - Expect(missingPacketBytes[14]).To(Equal(uint8(0xFF))) // rangeLength #2 - }) - - It("writes a frame with the smallest NACK ranges that requires a contiguous NACK range", func() { - frame := AckFrame{ - Entropy: 2, - LargestObserved: 259, - NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 258}}, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-(1+2*7):] - Expect(missingPacketBytes[0]).To(Equal(uint8(2))) // numRanges - Expect(missingPacketBytes[1:7]).To(Equal([]byte{1, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #1 - Expect(missingPacketBytes[7]).To(Equal(uint8(0))) // rangeLength #1 - Expect(missingPacketBytes[8:14]).To(Equal([]byte{0, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #2 - Expect(missingPacketBytes[14]).To(Equal(uint8(0xFF))) // rangeLength #2 - }) - - It("writes a frame with a long contiguous NACK range", func() { - frame := AckFrame{ - Entropy: 2, - LargestObserved: 603, - NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 601}}, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-(1+3*7):] - Expect(missingPacketBytes[0]).To(Equal(uint8(3))) // numRanges - Expect(missingPacketBytes[1:7]).To(Equal([]byte{2, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #1 - Expect(missingPacketBytes[7]).To(Equal(uint8(87))) // rangeLength #1 - Expect(missingPacketBytes[8:14]).To(Equal([]byte{0, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #2 - Expect(missingPacketBytes[14]).To(Equal(uint8(0xFF))) // rangeLength #2 - Expect(missingPacketBytes[15:21]).To(Equal([]byte{0, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #3 - Expect(missingPacketBytes[21]).To(Equal(uint8(0xFF))) // rangeLength #3 - }) - - It("writes a frame with two contiguous NACK range", func() { - nackRange1 := NackRange{FirstPacketNumber: 2, LastPacketNumber: 351} - nackRange2 := NackRange{FirstPacketNumber: 355, LastPacketNumber: 654} - frame := AckFrame{ - Entropy: 2, - LargestObserved: 655, - NackRanges: []NackRange{nackRange2, nackRange1}, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - missingPacketBytes := b.Bytes()[b.Len()-(1+4*7):] - Expect(missingPacketBytes[0]).To(Equal(uint8(4))) // numRanges - Expect(missingPacketBytes[1:7]).To(Equal([]byte{1, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #1 - Expect(missingPacketBytes[7]).To(Equal(uint8(43))) // rangeLength #1 - Expect(missingPacketBytes[8:14]).To(Equal([]byte{0, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #2 - Expect(missingPacketBytes[14]).To(Equal(uint8(0xFF))) // rangeLength #2 - Expect(missingPacketBytes[15:21]).To(Equal([]byte{3, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #3 - Expect(missingPacketBytes[21]).To(Equal(uint8(93))) // rangeLength #3 - Expect(missingPacketBytes[22:28]).To(Equal([]byte{0, 0, 0, 0, 0, 0})) // missingPacketSequenceNumberDelta #4 - Expect(missingPacketBytes[28]).To(Equal(uint8(0xFF))) // rangeLength #4 - }) - - Context("LargestObserved length", func() { - It("writes a 1 byte LargestObserved value", func() { - frame := AckFrame{ - LargestObserved: 7, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x40))) - Expect(b.Bytes()[2]).To(Equal(uint8(7))) - }) - - It("writes a 2 byte LargestObserved value", func() { - frame := AckFrame{ - LargestObserved: 0x1337, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x44))) - Expect(b.Bytes()[2:4]).To(Equal([]byte{0x37, 0x13})) - }) - - It("writes a 4 byte LargestObserved value", func() { - frame := AckFrame{ - LargestObserved: 0xDECAFBAD, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x48))) - Expect(b.Bytes()[2:6]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE})) - }) - - It("writes a 6 byte LargestObserved value", func() { - frame := AckFrame{ - LargestObserved: 0xDEADBEEFCAFE, - } - err := frame.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x4C).To(Equal(uint8(0x4C))) - Expect(b.Bytes()[2:8]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE})) - }) - }) - }) - - Context("min length", func() { - It("has proper min length", func() { - f := &AckFrame{ - Entropy: 2, - LargestObserved: 1, - } - f.Write(b, 2) - Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len()))) - }) - - It("has proper min length with a large LargestObserved", func() { - f := &AckFrame{ - Entropy: 2, - LargestObserved: 0xDEADBEEFCAFE, - } - f.Write(b, 2) - Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len()))) - }) - - It("has proper min length with nack ranges", func() { - f := &AckFrame{ - Entropy: 2, - LargestObserved: 4, - NackRanges: []NackRange{{FirstPacketNumber: 2, LastPacketNumber: 2}}, - } - err := f.Write(b, protocol.Version31) - Expect(err).ToNot(HaveOccurred()) - Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len()))) - }) - }) - }) - - Context("self-consistency checks", func() { - var b *bytes.Buffer - BeforeEach(func() { - b = &bytes.Buffer{} - }) - - It("is self-consistent for ACK frames without NACK ranges", func() { - frameOrig := &AckFrame{ - Entropy: 0xDE, - LargestObserved: 6789, - } - err := frameOrig.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - frame, err := ParseAckFrame(bytes.NewReader(b.Bytes()), protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.Entropy).To(Equal(frameOrig.Entropy)) - Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved)) - }) - - It("is self-consistent for ACK frames with NACK ranges", func() { - nackRanges := []NackRange{ - {FirstPacketNumber: 9, LastPacketNumber: 11}, - {FirstPacketNumber: 7, LastPacketNumber: 7}, - {FirstPacketNumber: 2, LastPacketNumber: 3}, - } - frameOrig := &AckFrame{ - LargestObserved: 15, - NackRanges: nackRanges, - } - err := frameOrig.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - r := bytes.NewReader(b.Bytes()) - frame, err := ParseAckFrame(r, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved)) - Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges))) - Expect(frame.NackRanges).To(Equal(frameOrig.NackRanges)) - }) - - It("is self-consistent for ACK frames with contiguous NACK ranges", func() { - nackRanges := []NackRange{ - {FirstPacketNumber: 500, LastPacketNumber: 1500}, - {FirstPacketNumber: 350, LastPacketNumber: 351}, - {FirstPacketNumber: 2, LastPacketNumber: 306}, - } - frameOrig := &AckFrame{ - LargestObserved: 1600, - NackRanges: nackRanges, - } - err := frameOrig.Write(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - r := bytes.NewReader(b.Bytes()) - frame, err := ParseAckFrame(r, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.LargestObserved).To(Equal(frameOrig.LargestObserved)) - Expect(frame.NackRanges).To(HaveLen(len(frameOrig.NackRanges))) - Expect(frame.NackRanges).To(Equal(frameOrig.NackRanges)) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame.go deleted file mode 100644 index 81c1ba8..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame.go +++ /dev/null @@ -1,44 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" -) - -// A BlockedFrame in QUIC -type BlockedFrame struct { - StreamID protocol.StreamID -} - -//Write writes a BlockedFrame frame -func (f *BlockedFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - b.WriteByte(0x05) - utils.WriteUint32(b, uint32(f.StreamID)) - return nil -} - -// MinLength of a written frame -func (f *BlockedFrame) MinLength() (protocol.ByteCount, error) { - return 1 + 4, nil -} - -// ParseBlockedFrame parses a BLOCKED frame -func ParseBlockedFrame(r *bytes.Reader) (*BlockedFrame, error) { - frame := &BlockedFrame{} - - // read the TypeByte - _, err := r.ReadByte() - if err != nil { - return nil, err - } - - sid, err := utils.ReadUint32(r) - if err != nil { - return nil, err - } - frame.StreamID = protocol.StreamID(sid) - - return frame, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame_test.go deleted file mode 100644 index 927b7ec..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/blocked_frame_test.go +++ /dev/null @@ -1,41 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("BlockedFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0x05, 0xEF, 0xBE, 0xAD, 0xDE}) - frame, err := ParseBlockedFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.StreamID).To(Equal(protocol.StreamID(0xDEADBEEF))) - }) - }) - - Context("when writing", func() { - It("writes a sample frame", func() { - b := &bytes.Buffer{} - frame := BlockedFrame{StreamID: 0x1337} - frame.Write(b, 0) - Expect(b.Bytes()).To(Equal([]byte{0x05, 0x37, 0x13, 0x0, 0x0})) - }) - - It("writes a connection-level Blocked", func() { - b := &bytes.Buffer{} - frame := BlockedFrame{StreamID: 0} - frame.Write(b, 0) - Expect(b.Bytes()).To(Equal([]byte{0x05, 0, 0, 0, 0})) - }) - - It("has the correct min length", func() { - frame := BlockedFrame{StreamID: 3} - Expect(frame.MinLength()).To(Equal(protocol.ByteCount(5))) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame.go deleted file mode 100644 index 1c98858..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame.go +++ /dev/null @@ -1,73 +0,0 @@ -package frames - -import ( - "bytes" - "errors" - "io" - "math" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// A ConnectionCloseFrame in QUIC -type ConnectionCloseFrame struct { - ErrorCode qerr.ErrorCode - ReasonPhrase string -} - -// ParseConnectionCloseFrame reads a CONNECTION_CLOSE frame -func ParseConnectionCloseFrame(r *bytes.Reader) (*ConnectionCloseFrame, error) { - frame := &ConnectionCloseFrame{} - - // read the TypeByte - _, err := r.ReadByte() - if err != nil { - return nil, err - } - - errorCode, err := utils.ReadUint32(r) - if err != nil { - return nil, err - } - frame.ErrorCode = qerr.ErrorCode(errorCode) - - reasonPhraseLen, err := utils.ReadUint16(r) - if err != nil { - return nil, err - } - - if reasonPhraseLen > uint16(protocol.MaxPacketSize) { - return nil, qerr.Error(qerr.InvalidConnectionCloseData, "reason phrase too long") - } - - reasonPhrase := make([]byte, reasonPhraseLen) - if _, err := io.ReadFull(r, reasonPhrase); err != nil { - return nil, err - } - frame.ReasonPhrase = string(reasonPhrase) - - return frame, nil -} - -// MinLength of a written frame -func (f *ConnectionCloseFrame) MinLength() (protocol.ByteCount, error) { - return 1 + 4 + 2 + protocol.ByteCount(len(f.ReasonPhrase)), nil -} - -// Write writes an CONNECTION_CLOSE frame. -func (f *ConnectionCloseFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - b.WriteByte(0x02) - utils.WriteUint32(b, uint32(f.ErrorCode)) - - if len(f.ReasonPhrase) > math.MaxUint16 { - return errors.New("ConnectionFrame: ReasonPhrase too long") - } - - reasonPhraseLen := uint16(len(f.ReasonPhrase)) - utils.WriteUint16(b, reasonPhraseLen) - b.WriteString(f.ReasonPhrase) - - return nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame_test.go deleted file mode 100644 index 0aee892..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/connection_close_frame_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package frames - -import ( - "bytes" - "strings" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("ConnectionCloseFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0x40, 0x19, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x4e, 0x6f, 0x20, 0x72, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x20, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x20, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x2e}) - frame, err := ParseConnectionCloseFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.ErrorCode).To(Equal(qerr.ErrorCode(0x19))) - Expect(frame.ReasonPhrase).To(Equal("No recent network activity.")) - Expect(b.Len()).To(Equal(0)) - }) - - It("parses a frame without a reason phrase", func() { - b := bytes.NewReader([]byte{0x02, 0xAD, 0xFB, 0xCA, 0xDE, 0x00, 0x00}) - frame, err := ParseConnectionCloseFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.ErrorCode).To(Equal(qerr.ErrorCode(0xDECAFBAD))) - Expect(frame.ReasonPhrase).To(BeEmpty()) - Expect(b.Len()).To(Equal(0)) - }) - - It("rejects long reason phrases", func() { - b := bytes.NewReader([]byte{0x02, 0xAD, 0xFB, 0xCA, 0xDE, 0xff, 0xf}) - _, err := ParseConnectionCloseFrame(b) - Expect(err).To(MatchError(qerr.Error(qerr.InvalidConnectionCloseData, "reason phrase too long"))) - }) - }) - - Context("when writing", func() { - It("writes a frame without a ReasonPhrase", func() { - b := &bytes.Buffer{} - frame := &ConnectionCloseFrame{ - ErrorCode: 0xDEADBEEF, - } - err := frame.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Len()).To(Equal(1 + 2 + 4)) - Expect(b.Bytes()).To(Equal([]byte{0x02, 0xEF, 0xBE, 0xAD, 0xDE, 0x00, 0x00})) - }) - - It("writes a frame with a ReasonPhrase", func() { - b := &bytes.Buffer{} - frame := &ConnectionCloseFrame{ - ErrorCode: 0xDEADBEEF, - ReasonPhrase: "foobar", - } - err := frame.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Len()).To(Equal(1 + 2 + 4 + len(frame.ReasonPhrase))) - Expect(b.Bytes()[:5]).To(Equal([]byte{0x02, 0xEF, 0xBE, 0xAD, 0xDE})) - Expect(b.Bytes()[5:7]).To(Equal([]byte{0x06, 0x00})) - Expect(b.Bytes()[7:]).To(Equal([]byte{'f', 'o', 'o', 'b', 'a', 'r'})) - }) - - It("rejects ReasonPhrases that are too long", func() { - b := &bytes.Buffer{} - - reasonPhrase := strings.Repeat("a", 0xFFFF+0x11) - - frame := &ConnectionCloseFrame{ - ErrorCode: 0xDEADBEEF, - ReasonPhrase: reasonPhrase, - } - err := frame.Write(b, 0) - Expect(err).To(HaveOccurred()) - }) - - It("has proper min length", func() { - b := &bytes.Buffer{} - f := &ConnectionCloseFrame{ - ErrorCode: 0xDEADBEEF, - ReasonPhrase: "foobar", - } - f.Write(b, 0) - Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len()))) - }) - }) - - It("is self-consistent", func() { - b := &bytes.Buffer{} - frame := &ConnectionCloseFrame{ - ErrorCode: 0xDEADBEEF, - ReasonPhrase: "Lorem ipsum dolor sit amet.", - } - err := frame.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - readframe, err := ParseConnectionCloseFrame(bytes.NewReader(b.Bytes())) - Expect(err).ToNot(HaveOccurred()) - Expect(readframe.ErrorCode).To(Equal(frame.ErrorCode)) - Expect(readframe.ReasonPhrase).To(Equal(frame.ReasonPhrase)) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/frame.go deleted file mode 100644 index 0bed565..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/frame.go +++ /dev/null @@ -1,13 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" -) - -// A Frame in QUIC -type Frame interface { - Write(b *bytes.Buffer, version protocol.VersionNumber) error - MinLength() (protocol.ByteCount, error) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/frames_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/frames_suite_test.go deleted file mode 100644 index 0cf2be1..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/frames_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package frames - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestCrypto(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Frames Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame.go deleted file mode 100644 index b890ba2..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame.go +++ /dev/null @@ -1,73 +0,0 @@ -package frames - -import ( - "bytes" - "io" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// A GoawayFrame is a GOAWAY frame -type GoawayFrame struct { - ErrorCode qerr.ErrorCode - LastGoodStream protocol.StreamID - ReasonPhrase string -} - -// ParseGoawayFrame parses a GOAWAY frame -func ParseGoawayFrame(r *bytes.Reader) (*GoawayFrame, error) { - frame := &GoawayFrame{} - - _, err := r.ReadByte() - if err != nil { - return nil, err - } - - errorCode, err := utils.ReadUint32(r) - if err != nil { - return nil, err - } - frame.ErrorCode = qerr.ErrorCode(errorCode) - - lastGoodStream, err := utils.ReadUint32(r) - if err != nil { - return nil, err - } - frame.LastGoodStream = protocol.StreamID(lastGoodStream) - - reasonPhraseLen, err := utils.ReadUint16(r) - if err != nil { - return nil, err - } - - if reasonPhraseLen > uint16(protocol.MaxPacketSize) { - return nil, qerr.Error(qerr.InvalidGoawayData, "reason phrase too long") - } - - reasonPhrase := make([]byte, reasonPhraseLen) - if _, err := io.ReadFull(r, reasonPhrase); err != nil { - return nil, err - } - frame.ReasonPhrase = string(reasonPhrase) - - return frame, nil -} - -func (f *GoawayFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - typeByte := uint8(0x03) - b.WriteByte(typeByte) - - utils.WriteUint32(b, uint32(f.ErrorCode)) - utils.WriteUint32(b, uint32(f.LastGoodStream)) - utils.WriteUint16(b, uint16(len(f.ReasonPhrase))) - b.WriteString(f.ReasonPhrase) - - return nil -} - -// MinLength of a written frame -func (f *GoawayFrame) MinLength() (protocol.ByteCount, error) { - return protocol.ByteCount(1 + 4 + 4 + 2 + len(f.ReasonPhrase)), nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame_test.go deleted file mode 100644 index e25b96e..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/goaway_frame_test.go +++ /dev/null @@ -1,70 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("GoawayFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{ - 0x03, - 0x01, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, - 0x03, 0x00, - 'f', 'o', 'o', - }) - frame, err := ParseGoawayFrame(b) - Expect(frame).To(Equal(&GoawayFrame{ - ErrorCode: 1, - LastGoodStream: 2, - ReasonPhrase: "foo", - })) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Len()).To(Equal(0)) - }) - - It("rejects long reason phrases", func() { - b := bytes.NewReader([]byte{ - 0x03, - 0x01, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, - 0xff, 0xff, - }) - _, err := ParseGoawayFrame(b) - Expect(err).To(MatchError(qerr.Error(qerr.InvalidGoawayData, "reason phrase too long"))) - }) - }) - - Context("when writing", func() { - It("writes a sample frame", func() { - b := &bytes.Buffer{} - frame := GoawayFrame{ - ErrorCode: 1, - LastGoodStream: 2, - ReasonPhrase: "foo", - } - frame.Write(b, 0) - Expect(b.Bytes()).To(Equal([]byte{ - 0x03, - 0x01, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, - 0x03, 0x00, - 'f', 'o', 'o', - })) - }) - - It("has the correct min length", func() { - frame := GoawayFrame{ - ReasonPhrase: "foo", - } - Expect(frame.MinLength()).To(Equal(protocol.ByteCount(14))) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/log.go b/vendor/github.com/lucas-clemente/quic-go/frames/log.go deleted file mode 100644 index f4e9074..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/log.go +++ /dev/null @@ -1,19 +0,0 @@ -package frames - -import "github.com/lucas-clemente/quic-go/utils" - -// LogFrame logs a frame, either sent or received -func LogFrame(frame Frame, sent bool) { - if !utils.Debug() { - return - } - dir := "<-" - if sent { - dir = "->" - } - if sf, ok := frame.(*StreamFrame); ok { - utils.Debugf("\t%s &frames.StreamFrame{StreamID: %d, FinBit: %t, Offset: 0x%x, Data length: 0x%x, Offset + Data length: 0x%x}", dir, sf.StreamID, sf.FinBit, sf.Offset, sf.DataLen(), sf.Offset+sf.DataLen()) - } else { - utils.Debugf("\t%s %#v", dir, frame) - } -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/log_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/log_test.go deleted file mode 100644 index c88168a..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/log_test.go +++ /dev/null @@ -1,49 +0,0 @@ -package frames - -import ( - "bytes" - "os" - - "github.com/lucas-clemente/quic-go/utils" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Frame logging", func() { - var ( - buf bytes.Buffer - ) - - BeforeEach(func() { - buf.Reset() - utils.SetLogLevel(utils.LogLevelDebug) - utils.SetLogWriter(&buf) - }) - - AfterSuite(func() { - utils.SetLogLevel(utils.LogLevelNothing) - utils.SetLogWriter(os.Stdout) - }) - - It("doesn't log when debug is disabled", func() { - utils.SetLogLevel(utils.LogLevelInfo) - LogFrame(&RstStreamFrame{}, true) - Expect(buf.Len()).To(BeZero()) - }) - - It("logs sent frames", func() { - LogFrame(&RstStreamFrame{}, true) - Expect(string(buf.Bytes())).To(Equal("\t-> &frames.RstStreamFrame{StreamID:0x0, ByteOffset:0x0, ErrorCode:0x0}\n")) - }) - - It("logs received frames", func() { - LogFrame(&RstStreamFrame{}, false) - Expect(string(buf.Bytes())).To(Equal("\t<- &frames.RstStreamFrame{StreamID:0x0, ByteOffset:0x0, ErrorCode:0x0}\n")) - }) - - It("logs stream frames", func() { - LogFrame(&StreamFrame{}, false) - Expect(string(buf.Bytes())).To(Equal("\t<- &frames.StreamFrame{StreamID: 0, FinBit: false, Offset: 0x0, Data length: 0x0, Offset + Data length: 0x0}\n")) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/nack_range.go b/vendor/github.com/lucas-clemente/quic-go/frames/nack_range.go deleted file mode 100644 index ebb1a29..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/nack_range.go +++ /dev/null @@ -1,22 +0,0 @@ -package frames - -import "github.com/lucas-clemente/quic-go/protocol" - -// NackRange is a NACK range -type NackRange struct { - FirstPacketNumber protocol.PacketNumber - LastPacketNumber protocol.PacketNumber -} - -// Len gets the lengths of a NackRange -func (n *NackRange) Len() uint64 { - return uint64(n.LastPacketNumber) - uint64(n.FirstPacketNumber) -} - -// ContainsPacketNumber checks if a packetNumber is contained in a NACK range -func (n *NackRange) ContainsPacketNumber(packetNumber protocol.PacketNumber) bool { - if packetNumber >= n.FirstPacketNumber && packetNumber <= n.LastPacketNumber { - return true - } - return false -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/nack_range_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/nack_range_test.go deleted file mode 100644 index 5a5d09b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/nack_range_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package frames - -import ( - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("NackRange", func() { - Context("Length", func() { - It("calculates the length for a NACK range with only one packet", func() { - nackRange := NackRange{FirstPacketNumber: 2, LastPacketNumber: 2} - Expect(nackRange.Len()).To(Equal(uint64(0))) - }) - - It("calculates the length for a NACK range with more than one packet", func() { - nackRange := NackRange{FirstPacketNumber: 10, LastPacketNumber: 20} - Expect(nackRange.Len()).To(Equal(uint64(10))) - }) - }) - - Context("ContainsPacketNumber", func() { - It("determines if a packet is in a NACK range with only one packet", func() { - nackRange := NackRange{FirstPacketNumber: 2, LastPacketNumber: 2} - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(1))).To(BeFalse()) - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(3))).To(BeFalse()) - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(2))).To(BeTrue()) - }) - - It("determines if a packet is in a NACK range with more than one packet", func() { - nackRange := NackRange{FirstPacketNumber: 10, LastPacketNumber: 20} - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(1))).To(BeFalse()) - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(10))).To(BeTrue()) - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(15))).To(BeTrue()) - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(20))).To(BeTrue()) - Expect(nackRange.ContainsPacketNumber(protocol.PacketNumber(21))).To(BeFalse()) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/ping_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/ping_frame.go deleted file mode 100644 index a2867f0..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/ping_frame.go +++ /dev/null @@ -1,33 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" -) - -// A PingFrame is a ping frame -type PingFrame struct{} - -// ParsePingFrame parses a Ping frame -func ParsePingFrame(r *bytes.Reader) (*PingFrame, error) { - frame := &PingFrame{} - - _, err := r.ReadByte() - if err != nil { - return nil, err - } - - return frame, nil -} - -func (f *PingFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - typeByte := uint8(0x07) - b.WriteByte(typeByte) - return nil -} - -// MinLength of a written frame -func (f *PingFrame) MinLength() (protocol.ByteCount, error) { - return 1, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/ping_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/ping_frame_test.go deleted file mode 100644 index 2348ca3..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/ping_frame_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("PingFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0x07}) - _, err := ParsePingFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Len()).To(Equal(0)) - }) - }) - - Context("when writing", func() { - It("writes a sample frame", func() { - b := &bytes.Buffer{} - frame := PingFrame{} - frame.Write(b, 0) - Expect(b.Bytes()).To(Equal([]byte{0x07})) - }) - - It("has the correct min length", func() { - frame := PingFrame{} - Expect(frame.MinLength()).To(Equal(protocol.ByteCount(1))) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame.go deleted file mode 100644 index 55a2f19..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame.go +++ /dev/null @@ -1,59 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" -) - -// A RstStreamFrame in QUIC -type RstStreamFrame struct { - StreamID protocol.StreamID - ByteOffset protocol.ByteCount - ErrorCode uint32 -} - -//Write writes a RST_STREAM frame -func (f *RstStreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - b.WriteByte(0x01) - utils.WriteUint32(b, uint32(f.StreamID)) - utils.WriteUint64(b, uint64(f.ByteOffset)) - utils.WriteUint32(b, f.ErrorCode) - return nil -} - -// MinLength of a written frame -func (f *RstStreamFrame) MinLength() (protocol.ByteCount, error) { - return 1 + 4 + 8 + 4, nil -} - -// ParseRstStreamFrame parses a RST_STREAM frame -func ParseRstStreamFrame(r *bytes.Reader) (*RstStreamFrame, error) { - frame := &RstStreamFrame{} - - // read the TypeByte - _, err := r.ReadByte() - if err != nil { - return nil, err - } - - sid, err := utils.ReadUint32(r) - if err != nil { - return nil, err - } - frame.StreamID = protocol.StreamID(sid) - - byteOffset, err := utils.ReadUint64(r) - if err != nil { - return nil, err - } - frame.ByteOffset = protocol.ByteCount(byteOffset) - - frame.ErrorCode, err = utils.ReadUint32(r) - if err != nil { - return nil, err - } - - return frame, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame_test.go deleted file mode 100644 index 0a2e5ab..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/rst_stream_frame_test.go +++ /dev/null @@ -1,44 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("RstStreamFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0x01, 0xEF, 0xBE, 0xAD, 0xDE, 0x44, 0x33, 0x22, 0x11, 0xAD, 0xFB, 0xCA, 0xDE, 0x34, 0x12, 0x37, 0x13}) - frame, err := ParseRstStreamFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.StreamID).To(Equal(protocol.StreamID(0xDEADBEEF))) - Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0xDECAFBAD11223344))) - Expect(frame.ErrorCode).To(Equal(uint32(0x13371234))) - }) - }) - - Context("when writing", func() { - It("writes a sample RstStreamFrame", func() { - frame := RstStreamFrame{ - StreamID: 0x1337, - ByteOffset: 0x11223344DECAFBAD, - ErrorCode: 0xDEADBEEF, - } - b := &bytes.Buffer{} - frame.Write(b, 0) - Expect(b.Bytes()).To(Equal([]byte{0x01, 0x37, 0x13, 0, 0, 0xAD, 0xFB, 0xCA, 0xDE, 0x44, 0x33, 0x22, 0x11, 0xEF, 0xBE, 0xAD, 0xDE})) - }) - - It("has the correct min length", func() { - rst := RstStreamFrame{ - StreamID: 0x1337, - ByteOffset: 0x1000, - ErrorCode: 0xDE, - } - Expect(rst.MinLength()).To(Equal(protocol.ByteCount(17))) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame.go deleted file mode 100644 index bbd6f39..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame.go +++ /dev/null @@ -1,95 +0,0 @@ -package frames - -import ( - "bytes" - "errors" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// A StopWaitingFrame in QUIC -type StopWaitingFrame struct { - LeastUnacked protocol.PacketNumber - Entropy byte - PacketNumberLen protocol.PacketNumberLen - PacketNumber protocol.PacketNumber -} - -var ( - errLeastUnackedHigherThanPacketNumber = errors.New("StopWaitingFrame: LeastUnacked can't be greater than the packet number") - errPacketNumberNotSet = errors.New("StopWaitingFrame: PacketNumber not set") - errPacketNumberLenNotSet = errors.New("StopWaitingFrame: PacketNumberLen not set") -) - -func (f *StopWaitingFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - // packetNumber is the packet number of the packet that this StopWaitingFrame will be sent with - typeByte := uint8(0x06) - b.WriteByte(typeByte) - - b.WriteByte(f.Entropy) - - // make sure the PacketNumber was set - if f.PacketNumber == protocol.PacketNumber(0) { - return errPacketNumberNotSet - } - - if f.LeastUnacked > f.PacketNumber { - return errLeastUnackedHigherThanPacketNumber - } - - leastUnackedDelta := uint64(f.PacketNumber - f.LeastUnacked) - - switch f.PacketNumberLen { - case protocol.PacketNumberLen1: - b.WriteByte(uint8(leastUnackedDelta)) - case protocol.PacketNumberLen2: - utils.WriteUint16(b, uint16(leastUnackedDelta)) - case protocol.PacketNumberLen4: - utils.WriteUint32(b, uint32(leastUnackedDelta)) - case protocol.PacketNumberLen6: - utils.WriteUint48(b, leastUnackedDelta) - default: - return errPacketNumberLenNotSet - } - - return nil -} - -// MinLength of a written frame -func (f *StopWaitingFrame) MinLength() (protocol.ByteCount, error) { - if f.PacketNumberLen == protocol.PacketNumberLenInvalid { - return 0, errPacketNumberLenNotSet - } - return protocol.ByteCount(1 + 1 + f.PacketNumberLen), nil -} - -// ParseStopWaitingFrame parses a StopWaiting frame -func ParseStopWaitingFrame(r *bytes.Reader, packetNumber protocol.PacketNumber, packetNumberLen protocol.PacketNumberLen) (*StopWaitingFrame, error) { - frame := &StopWaitingFrame{} - - // read the TypeByte - _, err := r.ReadByte() - if err != nil { - return nil, err - } - - frame.Entropy, err = r.ReadByte() - if err != nil { - return nil, err - } - - leastUnackedDelta, err := utils.ReadUintN(r, uint8(packetNumberLen)) - if err != nil { - return nil, err - } - - if leastUnackedDelta > uint64(packetNumber) { - return nil, qerr.Error(qerr.InvalidStopWaitingData, "invalid LeastUnackedDelta") - } - - frame.LeastUnacked = protocol.PacketNumber(uint64(packetNumber) - leastUnackedDelta) - - return frame, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame_test.go deleted file mode 100644 index bf3d7d6..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/stop_waiting_frame_test.go +++ /dev/null @@ -1,166 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("StopWaitingFrame", func() { - Context("stop waiting frames", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0x06, 0xA4, 0x03}) - frame, err := ParseStopWaitingFrame(b, 5, 1) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.Entropy).To(Equal(byte(0xA4))) - Expect(frame.LeastUnacked).To(Equal(protocol.PacketNumber(2))) - }) - - It("rejects frames with an invalid LeastUnackedDelta", func() { - b := bytes.NewReader([]byte{0x06, 0xA4, 0xD}) - _, err := ParseStopWaitingFrame(b, 10, 1) - Expect(err).To(HaveOccurred()) - }) - }) - - Context("when writing", func() { - It("writes a sample frame", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 10, - PacketNumber: 13, - Entropy: 0xAD, - PacketNumberLen: protocol.PacketNumberLen6, - } - frame.Write(b, 0) - Expect(b.Bytes()[0]).To(Equal(uint8(0x06))) - Expect(b.Bytes()[1]).To(Equal(uint8(frame.Entropy))) - Expect(b.Bytes()[2:8]).To(Equal([]byte{3, 0, 0, 0, 0, 0})) - }) - - It("errors when PacketNumber was not set", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 10, - PacketNumberLen: protocol.PacketNumberLen1, - Entropy: 0xAD, - } - err := frame.Write(b, 0) - Expect(err).To(MatchError(errPacketNumberNotSet)) - }) - - It("errors when PacketNumberLen was not set", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 10, - PacketNumber: 13, - Entropy: 0xAD, - } - err := frame.Write(b, 0) - Expect(err).To(MatchError(errPacketNumberLenNotSet)) - }) - - It("errors when the LeastUnackedDelta would be negative", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 10, - PacketNumber: 5, - PacketNumberLen: protocol.PacketNumberLen1, - } - err := frame.Write(b, 0) - Expect(err).To(MatchError(errLeastUnackedHigherThanPacketNumber)) - }) - - Context("LeastUnackedDelta length", func() { - It("writes a 1-byte LeastUnackedDelta", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 10, - PacketNumber: 13, - PacketNumberLen: protocol.PacketNumberLen1, - } - frame.Write(b, 0) - Expect(b.Len()).To(Equal(3)) - Expect(b.Bytes()[2]).To(Equal(uint8(3))) - }) - - It("writes a 2-byte LeastUnackedDelta", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 0x10, - PacketNumber: 0x1300, - PacketNumberLen: protocol.PacketNumberLen2, - } - frame.Write(b, 0) - Expect(b.Len()).To(Equal(4)) - Expect(b.Bytes()[2:4]).To(Equal([]byte{0xF0, 0x12})) - }) - - It("writes a 4-byte LeastUnackedDelta", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 0x1000, - PacketNumber: 0x12345678, - PacketNumberLen: protocol.PacketNumberLen4, - } - frame.Write(b, 0) - Expect(b.Len()).To(Equal(6)) - Expect(b.Bytes()[2:6]).To(Equal([]byte{0x78, 0x46, 0x34, 0x12})) - }) - - It("writes a 6-byte LeastUnackedDelta", func() { - b := &bytes.Buffer{} - frame := &StopWaitingFrame{ - LeastUnacked: 0x10, - PacketNumber: 0x123456789ABC, - PacketNumberLen: protocol.PacketNumberLen6, - } - frame.Write(b, 0) - Expect(b.Len()).To(Equal(8)) - Expect(b.Bytes()[2:8]).To(Equal([]byte{0xAC, 0x9A, 0x78, 0x56, 0x34, 0x12})) - }) - }) - }) - - Context("minLength", func() { - It("calculates the right minLength", func() { - for _, length := range []protocol.PacketNumberLen{protocol.PacketNumberLen1, protocol.PacketNumberLen2, protocol.PacketNumberLen4, protocol.PacketNumberLen6} { - frame := &StopWaitingFrame{ - LeastUnacked: 10, - PacketNumberLen: length, - } - Expect(frame.MinLength()).To(Equal(protocol.ByteCount(length + 2))) - } - }) - - It("errors when packetNumberLen is not set", func() { - frame := &StopWaitingFrame{ - LeastUnacked: 10, - } - _, err := frame.MinLength() - Expect(err).To(MatchError(errPacketNumberLenNotSet)) - }) - }) - - Context("self consistency", func() { - It("reads a stop waiting frame that it wrote", func() { - packetNumber := protocol.PacketNumber(13) - frame := &StopWaitingFrame{ - LeastUnacked: 10, - PacketNumber: packetNumber, - Entropy: 0xAC, - PacketNumberLen: protocol.PacketNumberLen4, - } - b := &bytes.Buffer{} - frame.Write(b, 0) - readframe, err := ParseStopWaitingFrame(bytes.NewReader(b.Bytes()), packetNumber, protocol.PacketNumberLen4) - Expect(err).ToNot(HaveOccurred()) - Expect(readframe.Entropy).To(Equal(frame.Entropy)) - Expect(readframe.LeastUnacked).To(Equal(frame.LeastUnacked)) - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/stream_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/stream_frame.go deleted file mode 100644 index b66b516..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/stream_frame.go +++ /dev/null @@ -1,210 +0,0 @@ -package frames - -import ( - "bytes" - "errors" - "io/ioutil" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// A StreamFrame of QUIC -type StreamFrame struct { - FinBit bool - StreamID protocol.StreamID - streamIDLen protocol.ByteCount - Offset protocol.ByteCount - Data []byte - DataLenPresent bool -} - -var ( - errInvalidStreamIDLen = errors.New("StreamFrame: Invalid StreamID length") - errInvalidOffsetLen = errors.New("StreamFrame: Invalid offset length") -) - -// ParseStreamFrame reads a stream frame. The type byte must not have been read yet. -func ParseStreamFrame(r *bytes.Reader) (*StreamFrame, error) { - frame := &StreamFrame{} - - typeByte, err := r.ReadByte() - if err != nil { - return nil, err - } - - frame.FinBit = typeByte&0x40 > 0 - frame.DataLenPresent = typeByte&0x20 > 0 - offsetLen := typeByte & 0x1C >> 2 - if offsetLen != 0 { - offsetLen++ - } - frame.streamIDLen = protocol.ByteCount(typeByte&0x03 + 1) - - sid, err := utils.ReadUintN(r, uint8(frame.streamIDLen)) - if err != nil { - return nil, err - } - frame.StreamID = protocol.StreamID(sid) - - offset, err := utils.ReadUintN(r, offsetLen) - if err != nil { - return nil, err - } - frame.Offset = protocol.ByteCount(offset) - - var dataLen uint16 - if frame.DataLenPresent { - dataLen, err = utils.ReadUint16(r) - if err != nil { - return nil, err - } - } - - if dataLen > uint16(protocol.MaxPacketSize) { - return nil, qerr.Error(qerr.InvalidStreamData, "data len too large") - } - - if dataLen == 0 { - // The rest of the packet is data - frame.Data, err = ioutil.ReadAll(r) - if err != nil { - return nil, err - } - } else { - frame.Data = make([]byte, dataLen) - if _, err := r.Read(frame.Data); err != nil { - return nil, err - } - } - - if !frame.FinBit && len(frame.Data) == 0 { - return nil, qerr.EmptyStreamFrameNoFin - } - - return frame, nil -} - -// WriteStreamFrame writes a stream frame. -func (f *StreamFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - typeByte := uint8(0x80) // sets the leftmost bit to 1 - - if f.FinBit { - typeByte ^= 0x40 - } - - if f.DataLenPresent { - typeByte ^= 0x20 - } - - offsetLength := f.getOffsetLength() - - if offsetLength > 0 { - typeByte ^= (uint8(offsetLength) - 1) << 2 - } - - if f.streamIDLen == 0 { - f.calculateStreamIDLength() - } - typeByte ^= uint8(f.streamIDLen) - 1 - - b.WriteByte(typeByte) - - switch f.streamIDLen { - case 1: - b.WriteByte(uint8(f.StreamID)) - case 2: - utils.WriteUint16(b, uint16(f.StreamID)) - case 3: - utils.WriteUint24(b, uint32(f.StreamID)) - case 4: - utils.WriteUint32(b, uint32(f.StreamID)) - default: - return errInvalidStreamIDLen - } - - switch offsetLength { - case 0: - case 2: - utils.WriteUint16(b, uint16(f.Offset)) - case 3: - utils.WriteUint24(b, uint32(f.Offset)) - case 4: - utils.WriteUint32(b, uint32(f.Offset)) - case 5: - utils.WriteUint40(b, uint64(f.Offset)) - case 6: - utils.WriteUint48(b, uint64(f.Offset)) - case 7: - utils.WriteUint56(b, uint64(f.Offset)) - case 8: - utils.WriteUint64(b, uint64(f.Offset)) - default: - return errInvalidOffsetLen - } - - if f.DataLenPresent { - utils.WriteUint16(b, uint16(len(f.Data))) - } - - b.Write(f.Data) - - return nil -} - -func (f *StreamFrame) calculateStreamIDLength() { - if f.StreamID < (1 << 8) { - f.streamIDLen = 1 - } else if f.StreamID < (1 << 16) { - f.streamIDLen = 2 - } else if f.StreamID < (1 << 24) { - f.streamIDLen = 3 - } else { - f.streamIDLen = 4 - } -} - -func (f *StreamFrame) getOffsetLength() protocol.ByteCount { - if f.Offset == 0 { - return 0 - } - if f.Offset < (1 << 16) { - return 2 - } - if f.Offset < (1 << 24) { - return 3 - } - if f.Offset < (1 << 32) { - return 4 - } - if f.Offset < (1 << 40) { - return 5 - } - if f.Offset < (1 << 48) { - return 6 - } - if f.Offset < (1 << 56) { - return 7 - } - return 8 -} - -// MinLength of a written frame -func (f *StreamFrame) MinLength() (protocol.ByteCount, error) { - if f.streamIDLen == 0 { - f.calculateStreamIDLength() - } - - length := protocol.ByteCount(1) + f.streamIDLen + f.getOffsetLength() - if f.DataLenPresent { - length += 2 - } - - return length + 1, nil -} - -// DataLen gives the length of data in bytes -func (f *StreamFrame) DataLen() protocol.ByteCount { - return protocol.ByteCount(len(f.Data)) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/stream_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/stream_frame_test.go deleted file mode 100644 index eec2e56..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/stream_frame_test.go +++ /dev/null @@ -1,402 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("StreamFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0xa0, 0x1, 0x06, 0x00, 'f', 'o', 'o', 'b', 'a', 'r'}) - frame, err := ParseStreamFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.FinBit).To(BeFalse()) - Expect(frame.StreamID).To(Equal(protocol.StreamID(1))) - Expect(frame.Offset).To(BeZero()) - Expect(frame.DataLenPresent).To(BeTrue()) - Expect(frame.Data).To(Equal([]byte("foobar"))) - }) - - It("accepts frame without data length", func() { - b := bytes.NewReader([]byte{0x80, 0x1, 'f', 'o', 'o', 'b', 'a', 'r'}) - frame, err := ParseStreamFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.FinBit).To(BeFalse()) - Expect(frame.StreamID).To(Equal(protocol.StreamID(1))) - Expect(frame.Offset).To(BeZero()) - Expect(frame.DataLenPresent).To(BeFalse()) - Expect(frame.Data).To(Equal([]byte("foobar"))) - }) - - It("accepts empty frame with finbit set", func() { - b := bytes.NewReader([]byte{0x80 ^ 0x40 ^ 0x20, 0x1, 0, 0}) - frame, err := ParseStreamFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.FinBit).To(BeTrue()) - Expect(frame.DataLenPresent).To(BeTrue()) - Expect(frame.Data).To(HaveLen(0)) - }) - - It("errors on empty stream frames that don't have the FinBit set", func() { - b := bytes.NewReader([]byte{0x80 ^ 0x20, 0x1, 0, 0}) - _, err := ParseStreamFrame(b) - Expect(err).To(MatchError(qerr.EmptyStreamFrameNoFin)) - }) - - It("rejects frames to too large dataLen", func() { - b := bytes.NewReader([]byte{0xa0, 0x1, 0xff, 0xf}) - _, err := ParseStreamFrame(b) - Expect(err).To(MatchError(qerr.Error(qerr.InvalidStreamData, "data len too large"))) - }) - }) - - Context("when writing", func() { - It("writes sample frame", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - DataLenPresent: true, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{0xa0, 0x1, 0x06, 0x00, 'f', 'o', 'o', 'b', 'a', 'r'})) - }) - - It("sets the FinBit", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - FinBit: true, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x40).To(Equal(byte(0x40))) - }) - - It("has proper min length for a short StreamID and a short offset", func() { - b := &bytes.Buffer{} - f := &StreamFrame{ - StreamID: 1, - Data: []byte("f"), - Offset: 0, - } - err := f.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len()))) - }) - - It("has proper min length for a long StreamID and a big offset", func() { - b := &bytes.Buffer{} - f := &StreamFrame{ - StreamID: 0xDECAFBAD, - Data: []byte("f"), - Offset: 0xDEADBEEFCAFE, - } - err := f.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(f.MinLength()).To(Equal(protocol.ByteCount(b.Len()))) - }) - - Context("data length field", func() { - It("writes the data length", func() { - dataLen := 0x1337 - b := &bytes.Buffer{} - f := &StreamFrame{ - StreamID: 1, - Data: bytes.Repeat([]byte{'f'}, dataLen), - DataLenPresent: true, - Offset: 0, - } - err := f.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - minLength, _ := f.MinLength() - headerLength := minLength - 1 - Expect(b.Bytes()[0] & 0x20).To(Equal(uint8(0x20))) - Expect(b.Bytes()[headerLength-2 : headerLength]).To(Equal([]byte{0x37, 0x13})) - }) - - It("omits the data length field", func() { - dataLen := 0x1337 - b := &bytes.Buffer{} - f := &StreamFrame{ - StreamID: 1, - Data: bytes.Repeat([]byte{'f'}, dataLen), - DataLenPresent: false, - Offset: 0, - } - err := f.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x20).To(Equal(uint8(0))) - Expect(b.Bytes()[1 : b.Len()-dataLen]).ToNot(ContainSubstring(string([]byte{0x37, 0x13}))) - minLength, _ := f.MinLength() - f.DataLenPresent = true - minLengthWithoutDataLen, _ := f.MinLength() - Expect(minLength).To(Equal(minLengthWithoutDataLen - 2)) - }) - - It("calculates the correcct min-length", func() { - f := &StreamFrame{ - StreamID: 0xCAFE, - Data: []byte("foobar"), - DataLenPresent: false, - Offset: 0xDEADBEEF, - } - minLengthWithoutDataLen, _ := f.MinLength() - f.DataLenPresent = true - Expect(f.MinLength()).To(Equal(minLengthWithoutDataLen + 2)) - }) - }) - - Context("offset lengths", func() { - It("does not write an offset if the offset is 0", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x0))) - }) - - It("writes a 2-byte offset if the offset is larger than 0", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0x1337, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x1 << 2))) - Expect(b.Bytes()[2:4]).To(Equal([]byte{0x37, 0x13})) - }) - - It("writes a 3-byte offset if the offset", func() { - b := &bytes.Buffer{} - (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0x13CAFE, - }).Write(b, 0) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x2 << 2))) - Expect(b.Bytes()[2:5]).To(Equal([]byte{0xFE, 0xCA, 0x13})) - }) - - It("writes a 4-byte offset if the offset", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0xDEADBEEF, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x3 << 2))) - Expect(b.Bytes()[2:6]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE})) - }) - - It("writes a 5-byte offset if the offset", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0x13DEADBEEF, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x4 << 2))) - Expect(b.Bytes()[2:7]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE, 0x13})) - }) - - It("writes a 6-byte offset if the offset", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0xDEADBEEFCAFE, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x5 << 2))) - Expect(b.Bytes()[2:8]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE})) - }) - - It("writes a 7-byte offset if the offset", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0x13DEADBEEFCAFE, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x6 << 2))) - Expect(b.Bytes()[2:9]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, 0x13})) - }) - - It("writes a 8-byte offset if the offset", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - Offset: 0x1337DEADBEEFCAFE, - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x1c).To(Equal(uint8(0x7 << 2))) - Expect(b.Bytes()[2:10]).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE, 0x37, 0x13})) - }) - }) - - Context("lengths of StreamIDs", func() { - It("returns an error for a non-valid StreamID length", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 1, - streamIDLen: 13, - Data: []byte("foobar"), - }).Write(b, 0) - Expect(err).To(MatchError(errInvalidStreamIDLen)) - }) - - It("writes a 1 byte StreamID", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 13, - Data: []byte("foobar"), - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x0))) - Expect(b.Bytes()[1]).To(Equal(uint8(13))) - }) - - It("writes a 2 byte StreamID", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 0xCAFE, - Data: []byte("foobar"), - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x1))) - Expect(b.Bytes()[1:3]).To(Equal([]byte{0xFE, 0xCA})) - }) - - It("writes a 3 byte StreamID", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 0x13BEEF, - Data: []byte("foobar"), - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x2))) - Expect(b.Bytes()[1:4]).To(Equal([]byte{0xEF, 0xBE, 0x13})) - }) - - It("writes a 4 byte StreamID", func() { - b := &bytes.Buffer{} - err := (&StreamFrame{ - StreamID: 0xDECAFBAD, - Data: []byte("foobar"), - }).Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x3))) - Expect(b.Bytes()[1:5]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE})) - }) - - It("writes a multiple byte StreamID, after the Stream length was already determined by MinLenght()", func() { - b := &bytes.Buffer{} - frame := &StreamFrame{ - StreamID: 0xDECAFBAD, - Data: []byte("foobar"), - } - frame.MinLength() - err := frame.Write(b, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()[0] & 0x3).To(Equal(uint8(0x3))) - Expect(b.Bytes()[1:5]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE})) - }) - }) - }) - - Context("shortening of StreamIDs", func() { - It("determines the length of a 1 byte StreamID", func() { - f := &StreamFrame{StreamID: 0xFF} - f.calculateStreamIDLength() - Expect(f.streamIDLen).To(Equal(protocol.ByteCount(1))) - }) - - It("determines the length of a 2 byte StreamID", func() { - f := &StreamFrame{StreamID: 0xFFFF} - f.calculateStreamIDLength() - Expect(f.streamIDLen).To(Equal(protocol.ByteCount(2))) - }) - - It("determines the length of a 3 byte StreamID", func() { - f := &StreamFrame{StreamID: 0xFFFFFF} - f.calculateStreamIDLength() - Expect(f.streamIDLen).To(Equal(protocol.ByteCount(3))) - }) - - It("determines the length of a 4 byte StreamID", func() { - f := &StreamFrame{StreamID: 0xFFFFFFFF} - f.calculateStreamIDLength() - Expect(f.streamIDLen).To(Equal(protocol.ByteCount(4))) - }) - }) - - Context("shortening of Offsets", func() { - It("determines length 0 of offset 0", func() { - f := &StreamFrame{Offset: 0} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(0))) - }) - - It("determines the length of a 2 byte offset", func() { - f := &StreamFrame{Offset: 0xFFFF} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(2))) - }) - - It("determines the length of a 2 byte offset, even if it would fit into 1 byte", func() { - f := &StreamFrame{Offset: 0x1} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(2))) - }) - - It("determines the length of a 3 byte offset", func() { - f := &StreamFrame{Offset: 0xFFFFFF} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(3))) - }) - - It("determines the length of a 4 byte offset", func() { - f := &StreamFrame{Offset: 0xFFFFFFFF} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(4))) - }) - - It("determines the length of a 5 byte offset", func() { - f := &StreamFrame{Offset: 0xFFFFFFFFFF} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(5))) - }) - - It("determines the length of a 6 byte offset", func() { - f := &StreamFrame{Offset: 0xFFFFFFFFFFFF} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(6))) - }) - - It("determines the length of a 7 byte offset", func() { - f := &StreamFrame{Offset: 0xFFFFFFFFFFFFFF} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(7))) - }) - - It("determines the length of an 8 byte offset", func() { - f := &StreamFrame{Offset: 0xFFFFFFFFFFFFFFFF} - Expect(f.getOffsetLength()).To(Equal(protocol.ByteCount(8))) - }) - }) - - Context("DataLen", func() { - It("determines the length of the data", func() { - frame := StreamFrame{ - Data: []byte("foobar"), - } - Expect(frame.DataLen()).To(Equal(protocol.ByteCount(6))) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame.go b/vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame.go deleted file mode 100644 index 01bed55..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame.go +++ /dev/null @@ -1,54 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" -) - -// A WindowUpdateFrame in QUIC -type WindowUpdateFrame struct { - StreamID protocol.StreamID - ByteOffset protocol.ByteCount -} - -//Write writes a RST_STREAM frame -func (f *WindowUpdateFrame) Write(b *bytes.Buffer, version protocol.VersionNumber) error { - typeByte := uint8(0x04) - b.WriteByte(typeByte) - - utils.WriteUint32(b, uint32(f.StreamID)) - utils.WriteUint64(b, uint64(f.ByteOffset)) - return nil -} - -// MinLength of a written frame -func (f *WindowUpdateFrame) MinLength() (protocol.ByteCount, error) { - return 1 + 4 + 8, nil -} - -// ParseWindowUpdateFrame parses a RST_STREAM frame -func ParseWindowUpdateFrame(r *bytes.Reader) (*WindowUpdateFrame, error) { - frame := &WindowUpdateFrame{} - - // read the TypeByte - _, err := r.ReadByte() - if err != nil { - return nil, err - } - - sid, err := utils.ReadUint32(r) - if err != nil { - return nil, err - } - frame.StreamID = protocol.StreamID(sid) - - byteOffset, err := utils.ReadUint64(r) - if err != nil { - return nil, err - } - frame.ByteOffset = protocol.ByteCount(byteOffset) - - return frame, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame_test.go b/vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame_test.go deleted file mode 100644 index bb7925e..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/frames/window_update_frame_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package frames - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("WindowUpdateFrame", func() { - Context("when parsing", func() { - It("accepts sample frame", func() { - b := bytes.NewReader([]byte{0x04, 0xEF, 0xBE, 0xAD, 0xDE, 0x44, 0x33, 0x22, 0x11, 0xAD, 0xFB, 0xCA, 0xDE}) - frame, err := ParseWindowUpdateFrame(b) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.StreamID).To(Equal(protocol.StreamID(0xDEADBEEF))) - Expect(frame.ByteOffset).To(Equal(protocol.ByteCount(0xDECAFBAD11223344))) - Expect(b.Len()).To(Equal(0)) - }) - }) - - Context("when writing", func() { - It("has proper min length", func() { - f := &WindowUpdateFrame{ - StreamID: 0x1337, - ByteOffset: 0xDEADBEEF, - } - Expect(f.MinLength()).To(Equal(protocol.ByteCount(13))) - }) - - It("writes a sample frame", func() { - b := &bytes.Buffer{} - f := &WindowUpdateFrame{ - StreamID: 0xDECAFBAD, - ByteOffset: 0xDEADBEEFCAFE1337, - } - f.Write(b, 0) - Expect(b.Bytes()).To(Equal([]byte{0x04, 0xAD, 0xFB, 0xCA, 0xDE, 0x37, 0x13, 0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE})) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/h2quic/h2quic_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/h2quic/h2quic_suite_test.go deleted file mode 100644 index f0b2655..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/h2quic/h2quic_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package h2quic - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestH2quic(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "H2quic Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/h2quic/request.go b/vendor/github.com/lucas-clemente/quic-go/h2quic/request.go deleted file mode 100644 index f2e0fa5..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/h2quic/request.go +++ /dev/null @@ -1,51 +0,0 @@ -package h2quic - -import ( - "errors" - "net/http" - "net/url" - - "golang.org/x/net/http2/hpack" -) - -func requestFromHeaders(headers []hpack.HeaderField) (*http.Request, error) { - var path, authority, method string - httpHeaders := http.Header{} - - for _, h := range headers { - switch h.Name { - case ":path": - path = h.Value - case ":method": - method = h.Value - case ":authority": - authority = h.Value - default: - if !h.IsPseudo() { - httpHeaders.Add(h.Name, h.Value) - } - } - } - - if len(path) == 0 || len(authority) == 0 || len(method) == 0 { - return nil, errors.New(":path, :authority and :method must not be empty") - } - - u, err := url.Parse(path) - if err != nil { - return nil, err - } - - return &http.Request{ - Method: method, - URL: u, - Proto: "HTTP/2.0", - ProtoMajor: 2, - ProtoMinor: 0, - Header: httpHeaders, - Body: nil, - // ContentLength: -1, - Host: authority, - RequestURI: path, - }, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/h2quic/request_test.go b/vendor/github.com/lucas-clemente/quic-go/h2quic/request_test.go deleted file mode 100644 index 08f42b0..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/h2quic/request_test.go +++ /dev/null @@ -1,75 +0,0 @@ -package h2quic - -import ( - "net/http" - - "golang.org/x/net/http2/hpack" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Request", func() { - It("populates request", func() { - headers := []hpack.HeaderField{ - {":path", "/foo", false}, - {":authority", "quic.clemente.io", false}, - {":method", "GET", false}, - } - req, err := requestFromHeaders(headers) - Expect(err).NotTo(HaveOccurred()) - Expect(req.Method).To(Equal("GET")) - Expect(req.URL.Path).To(Equal("/foo")) - Expect(req.Proto).To(Equal("HTTP/2.0")) - Expect(req.ProtoMajor).To(Equal(2)) - Expect(req.ProtoMinor).To(Equal(0)) - Expect(req.Header).To(BeEmpty()) - Expect(req.Body).To(BeNil()) - Expect(req.Host).To(Equal("quic.clemente.io")) - Expect(req.RequestURI).To(Equal("/foo")) - }) - - It("handles other headers", func() { - headers := []hpack.HeaderField{ - {":path", "/foo", false}, - {":authority", "quic.clemente.io", false}, - {":method", "GET", false}, - {"content-length", "42", false}, - {"duplicate-header", "1", false}, - {"duplicate-header", "2", false}, - } - req, err := requestFromHeaders(headers) - Expect(err).NotTo(HaveOccurred()) - Expect(req.Header).To(Equal(http.Header{ - "Content-Length": []string{"42"}, - "Duplicate-Header": []string{"1", "2"}, - })) - }) - - It("errors with missing path", func() { - headers := []hpack.HeaderField{ - {":authority", "quic.clemente.io", false}, - {":method", "GET", false}, - } - _, err := requestFromHeaders(headers) - Expect(err).To(MatchError(":path, :authority and :method must not be empty")) - }) - - It("errors with missing method", func() { - headers := []hpack.HeaderField{ - {":path", "/foo", false}, - {":authority", "quic.clemente.io", false}, - } - _, err := requestFromHeaders(headers) - Expect(err).To(MatchError(":path, :authority and :method must not be empty")) - }) - - It("errors with missing authority", func() { - headers := []hpack.HeaderField{ - {":path", "/foo", false}, - {":method", "GET", false}, - } - _, err := requestFromHeaders(headers) - Expect(err).To(MatchError(":path, :authority and :method must not be empty")) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer.go b/vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer.go deleted file mode 100644 index a730e34..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer.go +++ /dev/null @@ -1,70 +0,0 @@ -package h2quic - -import ( - "bytes" - "net/http" - "strconv" - "sync" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" -) - -type responseWriter struct { - dataStreamID protocol.StreamID - dataStream utils.Stream - - headerStream utils.Stream - headerStreamMutex *sync.Mutex - - header http.Header - headerWritten bool -} - -func newResponseWriter(headerStream utils.Stream, headerStreamMutex *sync.Mutex, dataStream utils.Stream, dataStreamID protocol.StreamID) *responseWriter { - return &responseWriter{ - header: http.Header{}, - headerStream: headerStream, - headerStreamMutex: headerStreamMutex, - dataStream: dataStream, - dataStreamID: dataStreamID, - } -} - -func (w *responseWriter) Header() http.Header { - return w.header -} - -func (w *responseWriter) WriteHeader(status int) { - w.headerWritten = true - - var headers bytes.Buffer - enc := hpack.NewEncoder(&headers) - enc.WriteField(hpack.HeaderField{Name: ":status", Value: strconv.Itoa(status)}) - - for k, v := range w.header { - enc.WriteField(hpack.HeaderField{Name: k, Value: v[0]}) - } - - utils.Infof("Responding with %d", status) - w.headerStreamMutex.Lock() - defer w.headerStreamMutex.Unlock() - h2framer := http2.NewFramer(w.headerStream, nil) - err := h2framer.WriteHeaders(http2.HeadersFrameParam{ - StreamID: uint32(w.dataStreamID), - EndHeaders: true, - BlockFragment: headers.Bytes(), - }) - if err != nil { - utils.Errorf("could not write h2 header: %s", err.Error()) - } -} - -func (w *responseWriter) Write(p []byte) (int, error) { - if !w.headerWritten { - w.WriteHeader(200) - } - return w.dataStream.Write(p) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer_test.go b/vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer_test.go deleted file mode 100644 index 0448c01..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/h2quic/response_writer_test.go +++ /dev/null @@ -1,81 +0,0 @@ -package h2quic - -import ( - "bytes" - "net/http" - "sync" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type mockStream struct { - id protocol.StreamID - bytes.Buffer - remoteClosed bool -} - -func (mockStream) Close() error { return nil } -func (s *mockStream) CloseRemote(offset protocol.ByteCount) { s.remoteClosed = true } -func (s mockStream) StreamID() protocol.StreamID { return s.id } - -var _ = Describe("Response Writer", func() { - var ( - w *responseWriter - headerStream *mockStream - dataStream *mockStream - ) - - BeforeEach(func() { - headerStream = &mockStream{} - dataStream = &mockStream{} - w = newResponseWriter(headerStream, &sync.Mutex{}, dataStream, 5) - }) - - It("writes status", func() { - w.WriteHeader(http.StatusTeapot) - Expect(headerStream.Bytes()).To(Equal([]byte{ - 0x0, 0x0, 0x5, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, 'H', 0x3, '4', '1', '8', - })) - }) - - It("writes headers", func() { - w.Header().Add("content-length", "42") - w.WriteHeader(http.StatusTeapot) - Expect(headerStream.Bytes()).To(Equal([]byte{ - 0x0, 0x0, 0x14, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, 0x48, 0x3, 0x34, 0x31, 0x38, - 0x40, 0x8a, 0xbc, 0x7a, 0x92, 0x5a, 0x92, 0xb6, 0x72, 0xd5, 0x32, 0x67, - 0x2, 0x34, 0x32, - })) - }) - - It("writes data", func() { - n, err := w.Write([]byte("foobar")) - Expect(n).To(Equal(6)) - Expect(err).ToNot(HaveOccurred()) - // Should have written 200 on the header stream - Expect(headerStream.Bytes()).To(Equal([]byte{ - 0x0, 0x0, 0x1, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, 0x88, - })) - // And foobar on the data stream - Expect(dataStream.Bytes()).To(Equal([]byte{ - 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72, - })) - }) - - It("writes data after WriteHeader is called", func() { - w.WriteHeader(http.StatusTeapot) - n, err := w.Write([]byte("foobar")) - Expect(n).To(Equal(6)) - Expect(err).ToNot(HaveOccurred()) - // Should have written 418 on the header stream - Expect(headerStream.Bytes()).To(Equal([]byte{ - 0x0, 0x0, 0x5, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, 'H', 0x3, '4', '1', '8', - })) - // And foobar on the data stream - Expect(dataStream.Bytes()).To(Equal([]byte{ - 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72, - })) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/h2quic/server.go b/vendor/github.com/lucas-clemente/quic-go/h2quic/server.go deleted file mode 100644 index ec35179..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/h2quic/server.go +++ /dev/null @@ -1,229 +0,0 @@ -package h2quic - -import ( - "crypto/tls" - "errors" - "fmt" - "io/ioutil" - "net" - "net/http" - "sync" - "sync/atomic" - "time" - - "github.com/lucas-clemente/quic-go" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" -) - -type streamCreator interface { - GetOrOpenStream(protocol.StreamID) (utils.Stream, error) - Close(error) error -} - -// Server is a HTTP2 server listening for QUIC connections. -type Server struct { - *http.Server - - // Private flag for demo, do not use - CloseAfterFirstRequest bool - - port uint32 // used atomically - - server *quic.Server - serverMutex sync.Mutex -} - -// ListenAndServe listens on the UDP address s.Addr and calls s.Handler to handle HTTP/2 requests on incoming connections. -func (s *Server) ListenAndServe() error { - if s.Server == nil { - return errors.New("use of h2quic.Server without http.Server") - } - return s.serveImpl(s.TLSConfig, nil) -} - -// ListenAndServeTLS listens on the UDP address s.Addr and calls s.Handler to handle HTTP/2 requests on incoming connections. -func (s *Server) ListenAndServeTLS(certFile, keyFile string) error { - var err error - certs := make([]tls.Certificate, 1) - certs[0], err = tls.LoadX509KeyPair(certFile, keyFile) - if err != nil { - return err - } - // We currently only use the cert-related stuff from tls.Config, - // so we don't need to make a full copy. - config := &tls.Config{ - Certificates: certs, - } - return s.serveImpl(config, nil) -} - -// Serve an existing UDP connection. -func (s *Server) Serve(conn *net.UDPConn) error { - return s.serveImpl(s.TLSConfig, conn) -} - -func (s *Server) serveImpl(tlsConfig *tls.Config, conn *net.UDPConn) error { - if s.Server == nil { - return errors.New("use of h2quic.Server without http.Server") - } - s.serverMutex.Lock() - if s.server != nil { - s.serverMutex.Unlock() - return errors.New("ListenAndServe may only be called once") - } - var err error - server, err := quic.NewServer(s.Addr, s.TLSConfig, s.handleStreamCb) - if err != nil { - s.serverMutex.Unlock() - return err - } - s.server = server - s.serverMutex.Unlock() - if conn == nil { - return server.ListenAndServe() - } - return server.Serve(conn) -} - -func (s *Server) handleStreamCb(session *quic.Session, stream utils.Stream) { - s.handleStream(session, stream) -} - -func (s *Server) handleStream(session streamCreator, stream utils.Stream) { - if stream.StreamID() != 3 { - return - } - - hpackDecoder := hpack.NewDecoder(4096, nil) - h2framer := http2.NewFramer(nil, stream) - - go func() { - var headerStreamMutex sync.Mutex // Protects concurrent calls to Write() - for { - if err := s.handleRequest(session, stream, &headerStreamMutex, hpackDecoder, h2framer); err != nil { - utils.Errorf("error handling h2 request: %s", err.Error()) - return - } - } - }() -} - -func (s *Server) handleRequest(session streamCreator, headerStream utils.Stream, headerStreamMutex *sync.Mutex, hpackDecoder *hpack.Decoder, h2framer *http2.Framer) error { - h2frame, err := h2framer.ReadFrame() - if err != nil { - return err - } - h2headersFrame := h2frame.(*http2.HeadersFrame) - if !h2headersFrame.HeadersEnded() { - return errors.New("http2 header continuation not implemented") - } - headers, err := hpackDecoder.DecodeFull(h2headersFrame.HeaderBlockFragment()) - if err != nil { - utils.Errorf("invalid http2 headers encoding: %s", err.Error()) - return err - } - - req, err := requestFromHeaders(headers) - if err != nil { - return err - } - - if utils.Debug() { - utils.Infof("%s %s%s, on data stream %d", req.Method, req.Host, req.RequestURI, h2headersFrame.StreamID) - } else { - utils.Infof("%s %s%s", req.Method, req.Host, req.RequestURI) - } - - dataStream, err := session.GetOrOpenStream(protocol.StreamID(h2headersFrame.StreamID)) - if err != nil { - return err - } - - if h2headersFrame.StreamEnded() { - dataStream.CloseRemote(0) - _, _ = dataStream.Read([]byte{0}) // read the eof - } - - // stream's Close() closes the write side, not the read side - req.Body = ioutil.NopCloser(dataStream) - - responseWriter := newResponseWriter(headerStream, headerStreamMutex, dataStream, protocol.StreamID(h2headersFrame.StreamID)) - - go func() { - handler := s.Handler - if handler == nil { - handler = http.DefaultServeMux - } - handler.ServeHTTP(responseWriter, req) - if responseWriter.dataStream != nil { - responseWriter.dataStream.Close() - } - if s.CloseAfterFirstRequest { - time.Sleep(100 * time.Millisecond) - session.Close(nil) - } - }() - - return nil -} - -// Close the server immediately, aborting requests and sending CONNECTION_CLOSE frames to connected clients -func (s *Server) Close() error { - s.serverMutex.Lock() - defer s.serverMutex.Unlock() - if s.server != nil { - err := s.server.Close() - s.server = nil - return err - } - return nil -} - -// CloseGracefully shuts down the server gracefully. The server sends a GOAWAY frame first, then waits for either timeout to trigger, or for all running requests to complete. -func (s *Server) CloseGracefully(timeout time.Duration) error { - // TODO: implement - return nil -} - -// SetQuicHeaders can be used to set the proper headers that announce that this server supports QUIC. -// The values that are set depend on the port information from s.Server.Addr, and currently look like this (if Addr has port 443): -// Alternate-Protocol: 443:quic -// Alt-Svc: quic=":443"; ma=2592000; v="33,32,31,30" -func (s *Server) SetQuicHeaders(hdr http.Header) error { - port := atomic.LoadUint32(&s.port) - - if port == 0 { - // Extract port from s.Server.Addr - _, portStr, err := net.SplitHostPort(s.Server.Addr) - if err != nil { - return err - } - portInt, err := net.LookupPort("tcp", portStr) - if err != nil { - return err - } - port = uint32(portInt) - atomic.StoreUint32(&s.port, port) - } - - hdr.Add("Alternate-Protocol", fmt.Sprintf("%d:quic", port)) - hdr.Add("Alt-Svc", fmt.Sprintf(`quic=":%d"; ma=2592000; v="%s"`, port, protocol.SupportedVersionsAsString)) - - return nil -} - -// ListenAndServeQUIC listens on the UDP network address addr and calls the -// handler for HTTP/2 requests on incoming connections. http.DefaultServeMux is -// used when handler is nil. -func ListenAndServeQUIC(addr, certFile, keyFile string, handler http.Handler) error { - server := &Server{ - Server: &http.Server{ - Addr: addr, - Handler: handler, - }, - } - return server.ListenAndServeTLS(certFile, keyFile) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/h2quic/server_test.go b/vendor/github.com/lucas-clemente/quic-go/h2quic/server_test.go deleted file mode 100644 index af399dc..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/h2quic/server_test.go +++ /dev/null @@ -1,327 +0,0 @@ -package h2quic - -import ( - "net" - "net/http" - "os" - "runtime" - "sync" - "syscall" - "time" - - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/testdata" - "github.com/lucas-clemente/quic-go/utils" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type mockSession struct { - closed bool - dataStream *mockStream -} - -func (s *mockSession) GetOrOpenStream(id protocol.StreamID) (utils.Stream, error) { - return s.dataStream, nil -} - -func (s *mockSession) Close(error) error { s.closed = true; return nil } - -var _ = Describe("H2 server", func() { - certPath := os.Getenv("GOPATH") - certPath += "/src/github.com/lucas-clemente/quic-go/example/" - - var ( - s *Server - session *mockSession - dataStream *mockStream - ) - - BeforeEach(func() { - s = &Server{ - Server: &http.Server{ - TLSConfig: testdata.GetTLSConfig(), - }, - } - dataStream = &mockStream{} - session = &mockSession{dataStream: dataStream} - }) - - Context("handling requests", func() { - var ( - h2framer *http2.Framer - hpackDecoder *hpack.Decoder - headerStream *mockStream - ) - - BeforeEach(func() { - headerStream = &mockStream{} - hpackDecoder = hpack.NewDecoder(4096, nil) - h2framer = http2.NewFramer(nil, headerStream) - }) - - It("handles a sample GET request", func() { - var handlerCalled bool - s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - Expect(r.Host).To(Equal("www.example.com")) - handlerCalled = true - }) - headerStream.Write([]byte{ - 0x0, 0x0, 0x11, 0x1, 0x5, 0x0, 0x0, 0x0, 0x5, - // Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding - 0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff, - }) - err := s.handleRequest(session, headerStream, &sync.Mutex{}, hpackDecoder, h2framer) - Expect(err).NotTo(HaveOccurred()) - Eventually(func() bool { return handlerCalled }).Should(BeTrue()) - Expect(dataStream.remoteClosed).To(BeTrue()) - }) - - It("does not close the dataStream when end of stream is not set", func() { - var handlerCalled bool - s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - Expect(r.Host).To(Equal("www.example.com")) - handlerCalled = true - }) - headerStream.Write([]byte{ - 0x0, 0x0, 0x11, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, - // Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding - 0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff, - }) - err := s.handleRequest(session, headerStream, &sync.Mutex{}, hpackDecoder, h2framer) - Expect(err).NotTo(HaveOccurred()) - Eventually(func() bool { return handlerCalled }).Should(BeTrue()) - Expect(dataStream.remoteClosed).To(BeFalse()) - }) - }) - - It("handles the header stream", func() { - var handlerCalled bool - s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - Expect(r.Host).To(Equal("www.example.com")) - handlerCalled = true - }) - headerStream := &mockStream{id: 3} - headerStream.Write([]byte{ - 0x0, 0x0, 0x11, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, - // Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding - 0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff, - }) - s.handleStream(session, headerStream) - Eventually(func() bool { return handlerCalled }).Should(BeTrue()) - }) - - It("ignores other streams", func() { - var handlerCalled bool - s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - Expect(r.Host).To(Equal("www.example.com")) - handlerCalled = true - }) - headerStream := &mockStream{id: 5} - headerStream.Write([]byte{ - 0x0, 0x0, 0x11, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, - // Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding - 0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff, - }) - s.handleStream(session, headerStream) - Consistently(func() bool { return handlerCalled }).Should(BeFalse()) - }) - - It("supports closing after first request", func() { - s.CloseAfterFirstRequest = true - s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}) - headerStream := &mockStream{id: 3} - headerStream.Write([]byte{ - 0x0, 0x0, 0x11, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, - // Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding - 0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff, - }) - Expect(session.closed).To(BeFalse()) - s.handleStream(session, headerStream) - Eventually(func() bool { return session.closed }).Should(BeTrue()) - }) - - It("uses the default handler as fallback", func() { - var handlerCalled bool - http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - Expect(r.Host).To(Equal("www.example.com")) - handlerCalled = true - })) - headerStream := &mockStream{id: 3} - headerStream.Write([]byte{ - 0x0, 0x0, 0x11, 0x1, 0x4, 0x0, 0x0, 0x0, 0x5, - // Taken from https://http2.github.io/http2-spec/compression.html#request.examples.with.huffman.coding - 0x82, 0x86, 0x84, 0x41, 0x8c, 0xf1, 0xe3, 0xc2, 0xe5, 0xf2, 0x3a, 0x6b, 0xa0, 0xab, 0x90, 0xf4, 0xff, - }) - s.handleStream(session, headerStream) - Eventually(func() bool { return handlerCalled }).Should(BeTrue()) - }) - - Context("setting http headers", func() { - expected := http.Header{ - "Alt-Svc": {`quic=":443"; ma=2592000; v="33,32,31,30"`}, - "Alternate-Protocol": {`443:quic`}, - } - - It("sets proper headers with numeric port", func() { - s.Server.Addr = ":443" - hdr := http.Header{} - err := s.SetQuicHeaders(hdr) - Expect(err).NotTo(HaveOccurred()) - Expect(hdr).To(Equal(expected)) - }) - - It("sets proper headers with full addr", func() { - s.Server.Addr = "127.0.0.1:443" - hdr := http.Header{} - err := s.SetQuicHeaders(hdr) - Expect(err).NotTo(HaveOccurred()) - Expect(hdr).To(Equal(expected)) - }) - - It("sets proper headers with string port", func() { - s.Server.Addr = ":https" - hdr := http.Header{} - err := s.SetQuicHeaders(hdr) - Expect(err).NotTo(HaveOccurred()) - Expect(hdr).To(Equal(expected)) - }) - - It("works multiple times", func() { - s.Server.Addr = ":https" - hdr := http.Header{} - err := s.SetQuicHeaders(hdr) - Expect(err).NotTo(HaveOccurred()) - Expect(hdr).To(Equal(expected)) - hdr = http.Header{} - err = s.SetQuicHeaders(hdr) - Expect(err).NotTo(HaveOccurred()) - Expect(hdr).To(Equal(expected)) - }) - }) - - It("should error when ListenAndServe is called with s.Server nil", func() { - err := (&Server{}).ListenAndServe() - Expect(err).To(MatchError("use of h2quic.Server without http.Server")) - }) - - It("should error when ListenAndServeTLS is called with s.Server nil", func() { - err := (&Server{}).ListenAndServeTLS(certPath+"fullchain.pem", certPath+"privkey.pem") - Expect(err).To(MatchError("use of h2quic.Server without http.Server")) - }) - - It("should nop-Close() when s.server is nil", func() { - err := (&Server{}).Close() - Expect(err).NotTo(HaveOccurred()) - }) - - Context("ListenAndServe", func() { - BeforeEach(func() { - s.Server.Addr = "localhost:0" - }) - - AfterEach(func() { - err := s.Close() - Expect(err).NotTo(HaveOccurred()) - }) - - It("works", func(done Done) { - go func() { - defer GinkgoRecover() - err := s.ListenAndServe() - Expect(err).NotTo(HaveOccurred()) - close(done) - }() - time.Sleep(50 * time.Millisecond) - err := s.Close() - Expect(err).NotTo(HaveOccurred()) - }, 0.5) - - It("may only be called once", func(done Done) { - go func() { - defer GinkgoRecover() - err := s.ListenAndServe() - Expect(err).NotTo(HaveOccurred()) - close(done) - }() - time.Sleep(10 * time.Millisecond) - err := s.ListenAndServe() - Expect(err).To(MatchError("ListenAndServe may only be called once")) - err = s.Close() - Expect(err).NotTo(HaveOccurred()) - }, 0.5) - }) - - Context("ListenAndServeTLS", func() { - BeforeEach(func() { - s.Server.Addr = "localhost:0" - }) - - AfterEach(func() { - err := s.Close() - Expect(err).NotTo(HaveOccurred()) - }) - - It("works", func(done Done) { - go func() { - defer GinkgoRecover() - err := s.ListenAndServeTLS(certPath+"fullchain.pem", certPath+"privkey.pem") - Expect(err).NotTo(HaveOccurred()) - close(done) - }() - time.Sleep(50 * time.Millisecond) - err := s.Close() - Expect(err).NotTo(HaveOccurred()) - }, 0.5) - - It("may only be called once", func(done Done) { - go func() { - defer GinkgoRecover() - err := s.ListenAndServeTLS(certPath+"fullchain.pem", certPath+"privkey.pem") - Expect(err).NotTo(HaveOccurred()) - close(done) - }() - time.Sleep(10 * time.Millisecond) - err := s.ListenAndServeTLS(certPath+"fullchain.pem", certPath+"privkey.pem") - Expect(err).To(MatchError("ListenAndServe may only be called once")) - err = s.Close() - Expect(err).NotTo(HaveOccurred()) - }, 0.5) - }) - - It("closes gracefully", func() { - err := s.CloseGracefully(0) - Expect(err).NotTo(HaveOccurred()) - }) - - It("at least errors in global ListenAndServeQUIC", func() { - // It's quite hard to test this, since we cannot properly shutdown the server - // once it's started. So, we open a socket on the same port before the test, - // so that ListenAndServeQUIC definitely fails. This way we know it at least - // created a socket on the proper address :) - const addr = "127.0.0.1:4826" - udpAddr, err := net.ResolveUDPAddr("udp", addr) - Expect(err).NotTo(HaveOccurred()) - c, err := net.ListenUDP("udp", udpAddr) - Expect(err).NotTo(HaveOccurred()) - defer c.Close() - err = ListenAndServeQUIC(addr, certPath+"fullchain.pem", certPath+"privkey.pem", nil) - // Check that it's an EADDRINUSE - Expect(err).ToNot(BeNil()) - opErr, ok := err.(*net.OpError) - Expect(ok).To(BeTrue()) - syscallErr, ok := opErr.Err.(*os.SyscallError) - Expect(ok).To(BeTrue()) - if runtime.GOOS == "windows" { - // for some reason, Windows return a different error number, corresponding to an WSAEADDRINUSE error - // see https://msdn.microsoft.com/en-us/library/windows/desktop/ms681391(v=vs.85).aspx - Expect(syscallErr.Err).To(Equal(syscall.Errno(0x2740))) - } else { - Expect(syscallErr.Err).To(MatchError(syscall.EADDRINUSE)) - } - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager.go b/vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager.go deleted file mode 100644 index 820c126..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager.go +++ /dev/null @@ -1,206 +0,0 @@ -package handshake - -import ( - "bytes" - "encoding/binary" - "errors" - "sync" - "time" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// ConnectionParametersManager stores the connection parameters -// Warning: Writes may only be done from the crypto stream, see the comment -// in GetSHLOMap(). -type ConnectionParametersManager struct { - params map[Tag][]byte - mutex sync.RWMutex - - flowControlNegotiated bool // have the flow control parameters for sending already been negotiated - - maxStreamsPerConnection uint32 - idleConnectionStateLifetime time.Duration - sendStreamFlowControlWindow protocol.ByteCount - sendConnectionFlowControlWindow protocol.ByteCount - receiveStreamFlowControlWindow protocol.ByteCount - receiveConnectionFlowControlWindow protocol.ByteCount -} - -var errTagNotInConnectionParameterMap = errors.New("ConnectionParametersManager: Tag not found in ConnectionsParameter map") - -// ErrMalformedTag is returned when the tag value cannot be read -var ( - ErrMalformedTag = qerr.Error(qerr.InvalidCryptoMessageParameter, "malformed Tag value") - ErrFlowControlRenegotiationNotSupported = qerr.Error(qerr.InvalidCryptoMessageParameter, "renegotiation of flow control parameters not supported") -) - -// NewConnectionParamatersManager creates a new connection parameters manager -func NewConnectionParamatersManager() *ConnectionParametersManager { - return &ConnectionParametersManager{ - params: make(map[Tag][]byte), - idleConnectionStateLifetime: protocol.InitialIdleConnectionStateLifetime, - sendStreamFlowControlWindow: protocol.InitialStreamFlowControlWindow, // can only be changed by the client - sendConnectionFlowControlWindow: protocol.InitialConnectionFlowControlWindow, // can only be changed by the client - receiveStreamFlowControlWindow: protocol.ReceiveStreamFlowControlWindow, - receiveConnectionFlowControlWindow: protocol.ReceiveConnectionFlowControlWindow, - maxStreamsPerConnection: protocol.MaxStreamsPerConnection, - } -} - -// SetFromMap reads all params -func (h *ConnectionParametersManager) SetFromMap(params map[Tag][]byte) error { - h.mutex.Lock() - defer h.mutex.Unlock() - - for key, value := range params { - switch key { - case TagTCID: - h.params[key] = value - case TagMSPC: - clientValue, err := utils.ReadUint32(bytes.NewBuffer(value)) - if err != nil { - return ErrMalformedTag - } - h.maxStreamsPerConnection = h.negotiateMaxStreamsPerConnection(clientValue) - case TagICSL: - clientValue, err := utils.ReadUint32(bytes.NewBuffer(value)) - if err != nil { - return ErrMalformedTag - } - h.idleConnectionStateLifetime = h.negotiateIdleConnectionStateLifetime(time.Duration(clientValue) * time.Second) - case TagSFCW: - if h.flowControlNegotiated { - return ErrFlowControlRenegotiationNotSupported - } - sendStreamFlowControlWindow, err := utils.ReadUint32(bytes.NewBuffer(value)) - if err != nil { - return ErrMalformedTag - } - h.sendStreamFlowControlWindow = protocol.ByteCount(sendStreamFlowControlWindow) - case TagCFCW: - if h.flowControlNegotiated { - return ErrFlowControlRenegotiationNotSupported - } - sendConnectionFlowControlWindow, err := utils.ReadUint32(bytes.NewBuffer(value)) - if err != nil { - return ErrMalformedTag - } - h.sendConnectionFlowControlWindow = protocol.ByteCount(sendConnectionFlowControlWindow) - } - } - - _, containsSFCW := params[TagSFCW] - _, containsCFCW := params[TagCFCW] - if containsCFCW || containsSFCW { - h.flowControlNegotiated = true - } - - return nil -} - -func (h *ConnectionParametersManager) negotiateMaxStreamsPerConnection(clientValue uint32) uint32 { - return utils.MinUint32(clientValue, protocol.MaxStreamsPerConnection) -} - -func (h *ConnectionParametersManager) negotiateIdleConnectionStateLifetime(clientValue time.Duration) time.Duration { - // TODO: what happens if the clients sets 0 seconds? - return utils.MinDuration(clientValue, protocol.MaxIdleConnectionStateLifetime) -} - -// getRawValue gets the byte-slice for a tag -func (h *ConnectionParametersManager) getRawValue(tag Tag) ([]byte, error) { - h.mutex.RLock() - rawValue, ok := h.params[tag] - h.mutex.RUnlock() - - if !ok { - return nil, errTagNotInConnectionParameterMap - } - return rawValue, nil -} - -// GetSHLOMap gets all values (except crypto values) needed for the SHLO -func (h *ConnectionParametersManager) GetSHLOMap() map[Tag][]byte { - sfcw := bytes.NewBuffer([]byte{}) - utils.WriteUint32(sfcw, uint32(h.GetReceiveStreamFlowControlWindow())) - cfcw := bytes.NewBuffer([]byte{}) - utils.WriteUint32(cfcw, uint32(h.GetReceiveConnectionFlowControlWindow())) - mspc := bytes.NewBuffer([]byte{}) - utils.WriteUint32(mspc, uint32(h.GetMaxStreamsPerConnection())) - icsl := bytes.NewBuffer([]byte{}) - utils.WriteUint32(icsl, uint32(h.GetIdleConnectionStateLifetime()/time.Second)) - - return map[Tag][]byte{ - TagICSL: icsl.Bytes(), - TagMSPC: mspc.Bytes(), - TagCFCW: cfcw.Bytes(), - TagSFCW: sfcw.Bytes(), - } -} - -// GetSendStreamFlowControlWindow gets the size of the stream-level flow control window for sending data -func (h *ConnectionParametersManager) GetSendStreamFlowControlWindow() protocol.ByteCount { - h.mutex.RLock() - defer h.mutex.RUnlock() - - return h.sendStreamFlowControlWindow -} - -// GetSendConnectionFlowControlWindow gets the size of the stream-level flow control window for sending data -func (h *ConnectionParametersManager) GetSendConnectionFlowControlWindow() protocol.ByteCount { - h.mutex.RLock() - defer h.mutex.RUnlock() - - return h.sendConnectionFlowControlWindow -} - -// GetReceiveStreamFlowControlWindow gets the size of the stream-level flow control window for receiving data -func (h *ConnectionParametersManager) GetReceiveStreamFlowControlWindow() protocol.ByteCount { - h.mutex.RLock() - defer h.mutex.RUnlock() - - return h.receiveStreamFlowControlWindow -} - -// GetReceiveConnectionFlowControlWindow gets the size of the stream-level flow control window for receiving data -func (h *ConnectionParametersManager) GetReceiveConnectionFlowControlWindow() protocol.ByteCount { - h.mutex.RLock() - defer h.mutex.RUnlock() - - return h.receiveConnectionFlowControlWindow -} - -// GetMaxStreamsPerConnection gets the maximum number of streams per connection -func (h *ConnectionParametersManager) GetMaxStreamsPerConnection() uint32 { - h.mutex.RLock() - defer h.mutex.RUnlock() - - return h.maxStreamsPerConnection -} - -// GetIdleConnectionStateLifetime gets the idle timeout -func (h *ConnectionParametersManager) GetIdleConnectionStateLifetime() time.Duration { - h.mutex.RLock() - defer h.mutex.RUnlock() - - return h.idleConnectionStateLifetime -} - -// TruncateConnectionID determines if the client requests truncated ConnectionIDs -func (h *ConnectionParametersManager) TruncateConnectionID() bool { - rawValue, err := h.getRawValue(TagTCID) - if err != nil { - return false - } - if len(rawValue) != 4 { - return false - } - value := binary.LittleEndian.Uint32(rawValue) - if value == 0 { - return true - } - return false -} diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager_test.go b/vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager_test.go deleted file mode 100644 index d3f8ec8..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/connection_parameters_manager_test.go +++ /dev/null @@ -1,228 +0,0 @@ -package handshake - -import ( - "time" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("ConnectionsParameterManager", func() { - var cpm *ConnectionParametersManager - BeforeEach(func() { - cpm = NewConnectionParamatersManager() - }) - - It("stores and retrieves a value", func() { - tcid := []byte{0x13, 0x37} - values := map[Tag][]byte{ - TagTCID: tcid, - } - - cpm.SetFromMap(values) - - val, err := cpm.getRawValue(TagTCID) - Expect(err).ToNot(HaveOccurred()) - Expect(val).To(Equal(tcid)) - }) - - It("returns an error for a tag that is not set", func() { - _, err := cpm.getRawValue(TagKEXS) - Expect(err).To(MatchError(errTagNotInConnectionParameterMap)) - }) - - Context("SHLO", func() { - It("returns all parameters necessary for the SHLO", func() { - entryMap := cpm.GetSHLOMap() - Expect(entryMap).To(HaveKey(TagICSL)) - Expect(entryMap).To(HaveKey(TagMSPC)) - }) - - It("sets the stream-level flow control windows in SHLO", func() { - cpm.receiveStreamFlowControlWindow = 0xDEADBEEF - entryMap := cpm.GetSHLOMap() - Expect(entryMap).To(HaveKey(TagSFCW)) - Expect(entryMap[TagSFCW]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE})) - }) - - It("sets the connection-level flow control windows in SHLO", func() { - cpm.receiveConnectionFlowControlWindow = 0xDECAFBAD - entryMap := cpm.GetSHLOMap() - Expect(entryMap).To(HaveKey(TagCFCW)) - Expect(entryMap[TagCFCW]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE})) - }) - - It("sets the connection-level flow control windows in SHLO", func() { - cpm.idleConnectionStateLifetime = 0xDECAFBAD * time.Second - entryMap := cpm.GetSHLOMap() - Expect(entryMap).To(HaveKey(TagICSL)) - Expect(entryMap[TagICSL]).To(Equal([]byte{0xAD, 0xFB, 0xCA, 0xDE})) - }) - - It("sets the maximum streams per connection in SHLO", func() { - cpm.maxStreamsPerConnection = 0xDEADBEEF - entryMap := cpm.GetSHLOMap() - Expect(entryMap).To(HaveKey(TagMSPC)) - Expect(entryMap[TagMSPC]).To(Equal([]byte{0xEF, 0xBE, 0xAD, 0xDE})) - }) - }) - - Context("Truncated connection IDs", func() { - It("does not send truncated connection IDs if the TCID tag is missing", func() { - Expect(cpm.TruncateConnectionID()).To(BeFalse()) - }) - - It("reads the tag for truncated connection IDs", func() { - values := map[Tag][]byte{ - TagTCID: {0, 0, 0, 0}, - } - cpm.SetFromMap(values) - Expect(cpm.TruncateConnectionID()).To(BeTrue()) - }) - }) - - Context("flow control", func() { - It("has the correct default stream-level flow control window for sending", func() { - Expect(cpm.GetSendStreamFlowControlWindow()).To(Equal(protocol.InitialStreamFlowControlWindow)) - }) - - It("has the correct default connection-level flow control window for sending", func() { - Expect(cpm.GetSendConnectionFlowControlWindow()).To(Equal(protocol.InitialConnectionFlowControlWindow)) - }) - - It("has the correct default stream-level flow control window for receiving", func() { - Expect(cpm.GetReceiveStreamFlowControlWindow()).To(Equal(protocol.ReceiveStreamFlowControlWindow)) - }) - - It("has the correct default connection-level flow control window for receiving", func() { - Expect(cpm.GetReceiveConnectionFlowControlWindow()).To(Equal(protocol.ReceiveConnectionFlowControlWindow)) - }) - - It("sets a new stream-level flow control window for sending", func() { - values := map[Tag][]byte{ - TagSFCW: {0xDE, 0xAD, 0xBE, 0xEF}, - } - err := cpm.SetFromMap(values) - Expect(err).ToNot(HaveOccurred()) - Expect(cpm.GetSendStreamFlowControlWindow()).To(Equal(protocol.ByteCount(0xEFBEADDE))) - }) - - It("does not change the stream-level flow control window when given an invalid value", func() { - values := map[Tag][]byte{ - TagSFCW: {0xDE, 0xAD, 0xBE}, // 1 byte too short - } - err := cpm.SetFromMap(values) - Expect(err).To(MatchError(ErrMalformedTag)) - Expect(cpm.GetSendStreamFlowControlWindow()).To(Equal(protocol.InitialStreamFlowControlWindow)) - }) - - It("sets a new connection-level flow control window for sending", func() { - values := map[Tag][]byte{ - TagCFCW: {0xDE, 0xAD, 0xBE, 0xEF}, - } - err := cpm.SetFromMap(values) - Expect(err).ToNot(HaveOccurred()) - Expect(cpm.GetSendConnectionFlowControlWindow()).To(Equal(protocol.ByteCount(0xEFBEADDE))) - }) - - It("does not change the connection-level flow control window when given an invalid value", func() { - values := map[Tag][]byte{ - TagSFCW: {0xDE, 0xAD, 0xBE}, // 1 byte too short - } - err := cpm.SetFromMap(values) - Expect(err).To(MatchError(ErrMalformedTag)) - Expect(cpm.GetSendStreamFlowControlWindow()).To(Equal(protocol.InitialConnectionFlowControlWindow)) - }) - - It("does not allow renegotiation of flow control parameters", func() { - values := map[Tag][]byte{ - TagCFCW: {0xDE, 0xAD, 0xBE, 0xEF}, - TagSFCW: {0xDE, 0xAD, 0xBE, 0xEF}, - } - err := cpm.SetFromMap(values) - Expect(err).ToNot(HaveOccurred()) - values = map[Tag][]byte{ - TagCFCW: {0x13, 0x37, 0x13, 0x37}, - TagSFCW: {0x13, 0x37, 0x13, 0x37}, - } - err = cpm.SetFromMap(values) - Expect(err).To(MatchError(ErrFlowControlRenegotiationNotSupported)) - Expect(cpm.GetSendStreamFlowControlWindow()).To(Equal(protocol.ByteCount(0xEFBEADDE))) - Expect(cpm.GetSendConnectionFlowControlWindow()).To(Equal(protocol.ByteCount(0xEFBEADDE))) - }) - }) - - Context("idle connection state lifetime", func() { - It("has initial idle conneciton state lifetime", func() { - Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.InitialIdleConnectionStateLifetime)) - }) - - It("negotiates correctly when the client wants a longer lifetime", func() { - Expect(cpm.negotiateIdleConnectionStateLifetime(protocol.MaxIdleConnectionStateLifetime + 10*time.Second)).To(Equal(protocol.MaxIdleConnectionStateLifetime)) - }) - - It("negotiates correctly when the client wants a shorter lifetime", func() { - Expect(cpm.negotiateIdleConnectionStateLifetime(protocol.MaxIdleConnectionStateLifetime - 1*time.Second)).To(Equal(protocol.MaxIdleConnectionStateLifetime - 1*time.Second)) - }) - - It("sets the negotiated lifetime", func() { - // this test only works if the value given here is smaller than protocol.MaxIdleConnectionStateLifetime - values := map[Tag][]byte{ - TagICSL: {10, 0, 0, 0}, - } - err := cpm.SetFromMap(values) - Expect(err).ToNot(HaveOccurred()) - Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(10 * time.Second)) - }) - - It("does not change the idle connection state lifetime when given an invalid value", func() { - values := map[Tag][]byte{ - TagSFCW: {0xDE, 0xAD, 0xBE}, // 1 byte too short - } - err := cpm.SetFromMap(values) - Expect(err).To(MatchError(ErrMalformedTag)) - Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(protocol.InitialIdleConnectionStateLifetime)) - }) - - It("gets idle connection state lifetime", func() { - value := 0xDECAFBAD * time.Second - cpm.idleConnectionStateLifetime = value - Expect(cpm.GetIdleConnectionStateLifetime()).To(Equal(value)) - }) - }) - - Context("max streams per connection", func() { - It("negotiates correctly when the client wants a larger number", func() { - Expect(cpm.negotiateMaxStreamsPerConnection(protocol.MaxStreamsPerConnection + 10)).To(Equal(protocol.MaxStreamsPerConnection)) - }) - - It("negotiates correctly when the client wants a smaller number", func() { - Expect(cpm.negotiateMaxStreamsPerConnection(protocol.MaxStreamsPerConnection - 1)).To(Equal(protocol.MaxStreamsPerConnection - 1)) - }) - - It("sets the negotiated max streams per connection value", func() { - // this test only works if the value given here is smaller than protocol.MaxStreamsPerConnection - values := map[Tag][]byte{ - TagMSPC: {2, 0, 0, 0}, - } - err := cpm.SetFromMap(values) - Expect(err).ToNot(HaveOccurred()) - Expect(cpm.GetMaxStreamsPerConnection()).To(Equal(uint32(2))) - }) - - It("errors when given an invalid max streams per connection value", func() { - values := map[Tag][]byte{ - TagMSPC: {2, 0, 0}, // 1 byte too short - } - err := cpm.SetFromMap(values) - Expect(err).To(MatchError(ErrMalformedTag)) - }) - - It("gets the max streams per connection value", func() { - var value uint32 = 0xDECAFBAD - cpm.maxStreamsPerConnection = value - Expect(cpm.GetMaxStreamsPerConnection()).To(Equal(value)) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup.go b/vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup.go deleted file mode 100644 index be7f67e..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup.go +++ /dev/null @@ -1,335 +0,0 @@ -package handshake - -import ( - "bytes" - "crypto/rand" - "io" - "net" - "sync" - - "github.com/lucas-clemente/quic-go/crypto" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// KeyDerivationFunction is used for key derivation -type KeyDerivationFunction func(version protocol.VersionNumber, forwardSecure bool, sharedSecret, nonces []byte, connID protocol.ConnectionID, chlo []byte, scfg []byte, cert []byte, divNonce []byte) (crypto.AEAD, error) - -// KeyExchangeFunction is used to make a new KEX -type KeyExchangeFunction func() (crypto.KeyExchange, error) - -// The CryptoSetup handles all things crypto for the Session -type CryptoSetup struct { - connID protocol.ConnectionID - ip net.IP - version protocol.VersionNumber - scfg *ServerConfig - nonce []byte - diversificationNonce []byte - - secureAEAD crypto.AEAD - forwardSecureAEAD crypto.AEAD - receivedForwardSecurePacket bool - receivedSecurePacket bool - aeadChanged chan struct{} - - keyDerivation KeyDerivationFunction - keyExchange KeyExchangeFunction - - cryptoStream utils.Stream - - connectionParametersManager *ConnectionParametersManager - - mutex sync.RWMutex -} - -var _ crypto.AEAD = &CryptoSetup{} - -// NewCryptoSetup creates a new CryptoSetup instance -func NewCryptoSetup( - connID protocol.ConnectionID, - ip net.IP, - version protocol.VersionNumber, - scfg *ServerConfig, - cryptoStream utils.Stream, - connectionParametersManager *ConnectionParametersManager, - aeadChanged chan struct{}, -) (*CryptoSetup, error) { - nonce := make([]byte, 32) - if _, err := io.ReadFull(rand.Reader, nonce); err != nil { - return nil, err - } - diversificationNonce := make([]byte, 32) - if _, err := io.ReadFull(rand.Reader, diversificationNonce); err != nil { - return nil, err - } - return &CryptoSetup{ - connID: connID, - ip: ip, - version: version, - scfg: scfg, - nonce: nonce, - diversificationNonce: diversificationNonce, - keyDerivation: crypto.DeriveKeysChacha20, - keyExchange: crypto.NewCurve25519KEX, - cryptoStream: cryptoStream, - connectionParametersManager: connectionParametersManager, - aeadChanged: aeadChanged, - }, nil -} - -// HandleCryptoStream reads and writes messages on the crypto stream -func (h *CryptoSetup) HandleCryptoStream() error { - for { - cachingReader := utils.NewCachingReader(h.cryptoStream) - messageTag, cryptoData, err := ParseHandshakeMessage(cachingReader) - if err != nil { - return err - } - if messageTag != TagCHLO { - return qerr.InvalidCryptoMessageType - } - chloData := cachingReader.Get() - - utils.Debugf("Got CHLO:\n%s", printHandshakeMessage(cryptoData)) - - done, err := h.handleMessage(chloData, cryptoData) - if err != nil { - return err - } - if done { - return nil - } - } -} - -func (h *CryptoSetup) handleMessage(chloData []byte, cryptoData map[Tag][]byte) (bool, error) { - sniSlice, ok := cryptoData[TagSNI] - if !ok { - return false, qerr.Error(qerr.CryptoMessageParameterNotFound, "SNI required") - } - sni := string(sniSlice) - if sni == "" { - return false, qerr.Error(qerr.CryptoMessageParameterNotFound, "SNI required") - } - - var reply []byte - var err error - if !h.isInchoateCHLO(cryptoData) { - // We have a CHLO with a proper server config ID, do a 0-RTT handshake - reply, err = h.handleCHLO(sni, chloData, cryptoData) - if err != nil { - return false, err - } - _, err = h.cryptoStream.Write(reply) - if err != nil { - return false, err - } - return true, nil - } - - // We have an inchoate or non-matching CHLO, we now send a rejection - reply, err = h.handleInchoateCHLO(sni, chloData, cryptoData) - if err != nil { - return false, err - } - _, err = h.cryptoStream.Write(reply) - if err != nil { - return false, err - } - return false, nil -} - -// Open a message -func (h *CryptoSetup) Open(packetNumber protocol.PacketNumber, associatedData []byte, ciphertext []byte) ([]byte, error) { - h.mutex.RLock() - defer h.mutex.RUnlock() - - if h.forwardSecureAEAD != nil { - res, err := h.forwardSecureAEAD.Open(packetNumber, associatedData, ciphertext) - if err == nil { - h.receivedForwardSecurePacket = true - return res, nil - } - if h.receivedForwardSecurePacket { - return nil, err - } - } - if h.secureAEAD != nil { - res, err := h.secureAEAD.Open(packetNumber, associatedData, ciphertext) - if err == nil { - h.receivedSecurePacket = true - return res, nil - } - if h.receivedSecurePacket { - return nil, err - } - } - return (&crypto.NullAEAD{}).Open(packetNumber, associatedData, ciphertext) -} - -// Seal a message, call LockForSealing() before! -func (h *CryptoSetup) Seal(packetNumber protocol.PacketNumber, associatedData []byte, plaintext []byte) []byte { - if h.receivedForwardSecurePacket { - return h.forwardSecureAEAD.Seal(packetNumber, associatedData, plaintext) - } else if h.secureAEAD != nil { - return h.secureAEAD.Seal(packetNumber, associatedData, plaintext) - } else { - return (&crypto.NullAEAD{}).Seal(packetNumber, associatedData, plaintext) - } -} - -func (h *CryptoSetup) isInchoateCHLO(cryptoData map[Tag][]byte) bool { - scid, ok := cryptoData[TagSCID] - if !ok || !bytes.Equal(h.scfg.ID, scid) { - return true - } - if err := h.scfg.stkSource.VerifyToken(h.ip, cryptoData[TagSTK]); err != nil { - utils.Infof("STK invalid: %s", err.Error()) - return false - } - return false -} - -func (h *CryptoSetup) handleInchoateCHLO(sni string, data []byte, cryptoData map[Tag][]byte) ([]byte, error) { - if len(data) < protocol.ClientHelloMinimumSize { - return nil, qerr.Error(qerr.CryptoInvalidValueLength, "CHLO too small") - } - - var chloOrNil []byte - if h.version > protocol.Version30 { - chloOrNil = data - } - - proof, err := h.scfg.Sign(sni, chloOrNil) - if err != nil { - return nil, err - } - - commonSetHashes := cryptoData[TagCCS] - cachedCertsHashes := cryptoData[TagCCRT] - - certCompressed, err := h.scfg.GetCertsCompressed(sni, commonSetHashes, cachedCertsHashes) - if err != nil { - return nil, err - } - - token, err := h.scfg.stkSource.NewToken(h.ip) - if err != nil { - return nil, err - } - - var serverReply bytes.Buffer - WriteHandshakeMessage(&serverReply, TagREJ, map[Tag][]byte{ - TagSCFG: h.scfg.Get(), - TagCERT: certCompressed, - TagPROF: proof, - TagSTK: token, - }) - return serverReply.Bytes(), nil -} - -func (h *CryptoSetup) handleCHLO(sni string, data []byte, cryptoData map[Tag][]byte) ([]byte, error) { - // We have a CHLO matching our server config, we can continue with the 0-RTT handshake - sharedSecret, err := h.scfg.kex.CalculateSharedKey(cryptoData[TagPUBS]) - if err != nil { - return nil, err - } - - h.mutex.Lock() - defer h.mutex.Unlock() - - certUncompressed, err := h.scfg.signer.GetLeafCert(sni) - if err != nil { - return nil, err - } - - h.secureAEAD, err = h.keyDerivation( - h.version, - false, - sharedSecret, - cryptoData[TagNONC], - h.connID, - data, - h.scfg.Get(), - certUncompressed, - h.diversificationNonce, - ) - if err != nil { - return nil, err - } - - // Generate a new curve instance to derive the forward secure key - var fsNonce bytes.Buffer - fsNonce.Write(cryptoData[TagNONC]) - fsNonce.Write(h.nonce) - ephermalKex, err := h.keyExchange() - if err != nil { - return nil, err - } - ephermalSharedSecret, err := ephermalKex.CalculateSharedKey(cryptoData[TagPUBS]) - if err != nil { - return nil, err - } - h.forwardSecureAEAD, err = h.keyDerivation(h.version, - true, - ephermalSharedSecret, - fsNonce.Bytes(), - h.connID, - data, - h.scfg.Get(), - certUncompressed, - nil, - ) - if err != nil { - return nil, err - } - - err = h.connectionParametersManager.SetFromMap(cryptoData) - if err != nil { - return nil, err - } - - replyMap := h.connectionParametersManager.GetSHLOMap() - // add crypto parameters - replyMap[TagPUBS] = ephermalKex.PublicKey() - replyMap[TagSNO] = h.nonce - replyMap[TagVER] = protocol.SupportedVersionsAsTags - - var reply bytes.Buffer - WriteHandshakeMessage(&reply, TagSHLO, replyMap) - - h.aeadChanged <- struct{}{} - - return reply.Bytes(), nil -} - -// DiversificationNonce returns a diversification nonce if required in the next packet to be Seal'ed. See LockForSealing()! -func (h *CryptoSetup) DiversificationNonce() []byte { - if h.version < protocol.Version33 { - return nil - } - if h.receivedForwardSecurePacket || h.secureAEAD == nil { - return nil - } - return h.diversificationNonce -} - -// LockForSealing should be called before Seal(). It is needed so that diversification nonces can be obtained before packets are sealed, and the AEADs are not changed in the meantime. -func (h *CryptoSetup) LockForSealing() { - h.mutex.RLock() -} - -// UnlockForSealing should be called after Seal() is complete, see LockForSealing(). -func (h *CryptoSetup) UnlockForSealing() { - h.mutex.RUnlock() -} - -func (h *CryptoSetup) verifyOrCreateSTK(token []byte) ([]byte, error) { - err := h.scfg.stkSource.VerifyToken(h.ip, token) - if err != nil { - return h.scfg.stkSource.NewToken(h.ip) - } - return token, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup_test.go b/vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup_test.go deleted file mode 100644 index 9090bf9..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/crypto_setup_test.go +++ /dev/null @@ -1,403 +0,0 @@ -package handshake - -import ( - "bytes" - "errors" - "net" - - "github.com/lucas-clemente/quic-go/crypto" - "github.com/lucas-clemente/quic-go/protocol" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type mockKEX struct { - ephermal bool -} - -func (m *mockKEX) PublicKey() []byte { - if m.ephermal { - return []byte("ephermal pub") - } - return []byte("initial public") -} - -func (m *mockKEX) CalculateSharedKey(otherPublic []byte) ([]byte, error) { - if m.ephermal { - return []byte("shared ephermal"), nil - } - return []byte("shared key"), nil -} - -type mockSigner struct { - gotCHLO bool -} - -func (s *mockSigner) SignServerProof(sni string, chlo []byte, serverConfigData []byte) ([]byte, error) { - if len(chlo) > 0 { - s.gotCHLO = true - } - return []byte("proof"), nil -} -func (*mockSigner) GetCertsCompressed(sni string, common, cached []byte) ([]byte, error) { - return []byte("certcompressed"), nil -} -func (*mockSigner) GetLeafCert(sni string) ([]byte, error) { - return []byte("certuncompressed"), nil -} - -type mockAEAD struct { - forwardSecure bool - sharedSecret []byte -} - -func (m *mockAEAD) Seal(packetNumber protocol.PacketNumber, associatedData []byte, plaintext []byte) []byte { - if m.forwardSecure { - return []byte("forward secure encrypted") - } - return []byte("encrypted") -} - -func (m *mockAEAD) Open(packetNumber protocol.PacketNumber, associatedData []byte, ciphertext []byte) ([]byte, error) { - if m.forwardSecure && string(ciphertext) == "forward secure encrypted" { - return []byte("decrypted"), nil - } else if !m.forwardSecure && string(ciphertext) == "encrypted" { - return []byte("decrypted"), nil - } - return nil, errors.New("authentication failed") -} - -func (mockAEAD) DiversificationNonce() []byte { return nil } - -var expectedInitialNonceLen int -var expectedFSNonceLen int - -func mockKeyDerivation(v protocol.VersionNumber, forwardSecure bool, sharedSecret, nonces []byte, connID protocol.ConnectionID, chlo []byte, scfg []byte, cert []byte, divNonce []byte) (crypto.AEAD, error) { - if forwardSecure { - Expect(nonces).To(HaveLen(expectedFSNonceLen)) - } else { - Expect(nonces).To(HaveLen(expectedInitialNonceLen)) - } - return &mockAEAD{forwardSecure: forwardSecure, sharedSecret: sharedSecret}, nil -} - -type mockStream struct { - dataToRead bytes.Buffer - dataWritten bytes.Buffer -} - -func (s *mockStream) Read(p []byte) (int, error) { - return s.dataToRead.Read(p) -} - -func (s *mockStream) ReadByte() (byte, error) { - return s.dataToRead.ReadByte() -} - -func (s *mockStream) Write(p []byte) (int, error) { - return s.dataWritten.Write(p) -} - -func (s *mockStream) Close() error { panic("not implemented") } -func (mockStream) CloseRemote(offset protocol.ByteCount) { panic("not implemented") } -func (s mockStream) StreamID() protocol.StreamID { panic("not implemented") } - -type mockStkSource struct{} - -func (mockStkSource) NewToken(ip net.IP) ([]byte, error) { - return append([]byte("token "), ip...), nil -} - -func (mockStkSource) VerifyToken(ip net.IP, token []byte) error { - split := bytes.Split(token, []byte(" ")) - if len(split) != 2 { - return errors.New("stk required") - } - if !bytes.Equal(split[0], []byte("token")) { - return errors.New("no prefix match") - } - if !bytes.Equal(split[1], ip) { - return errors.New("ip wrong") - } - return nil -} - -var _ = Describe("Crypto setup", func() { - var ( - kex *mockKEX - signer *mockSigner - scfg *ServerConfig - cs *CryptoSetup - stream *mockStream - cpm *ConnectionParametersManager - aeadChanged chan struct{} - nonce32 []byte - ip net.IP - validSTK []byte - ) - - BeforeEach(func() { - var err error - ip = net.ParseIP("1.2.3.4") - validSTK, err = mockStkSource{}.NewToken(ip) - Expect(err).NotTo(HaveOccurred()) - nonce32 = make([]byte, 32) - expectedInitialNonceLen = 32 - expectedFSNonceLen = 64 - aeadChanged = make(chan struct{}, 1) - stream = &mockStream{} - kex = &mockKEX{} - signer = &mockSigner{} - scfg, err = NewServerConfig(kex, signer) - Expect(err).NotTo(HaveOccurred()) - scfg.stkSource = &mockStkSource{} - v := protocol.SupportedVersions[len(protocol.SupportedVersions)-1] - cpm = NewConnectionParamatersManager() - cs, err = NewCryptoSetup(protocol.ConnectionID(42), ip, v, scfg, stream, cpm, aeadChanged) - Expect(err).NotTo(HaveOccurred()) - cs.keyDerivation = mockKeyDerivation - cs.keyExchange = func() (crypto.KeyExchange, error) { return &mockKEX{ephermal: true}, nil } - }) - - It("has a nonce", func() { - Expect(cs.nonce).To(HaveLen(32)) - s := 0 - for _, b := range cs.nonce { - s += int(b) - } - Expect(s).ToNot(BeZero()) - }) - - Context("diversification nonce", func() { - BeforeEach(func() { - cs.version = protocol.Version33 - cs.secureAEAD = &mockAEAD{} - cs.receivedForwardSecurePacket = false - }) - - It("returns diversification nonces", func() { - Expect(cs.DiversificationNonce()).To(HaveLen(32)) - }) - - It("does not return nonce for version < 33", func() { - cs.version = protocol.Version32 - Expect(cs.DiversificationNonce()).To(BeEmpty()) - }) - - It("does not return nonce for FS packets", func() { - cs.receivedForwardSecurePacket = true - Expect(cs.DiversificationNonce()).To(BeEmpty()) - }) - - It("does not return nonce for unencrypted packets", func() { - cs.secureAEAD = nil - Expect(cs.DiversificationNonce()).To(BeEmpty()) - }) - }) - - Context("when responding to client messages", func() { - It("generates REJ messages", func() { - response, err := cs.handleInchoateCHLO("", bytes.Repeat([]byte{'a'}, protocol.ClientHelloMinimumSize), nil) - Expect(err).ToNot(HaveOccurred()) - Expect(response).To(HavePrefix("REJ")) - Expect(response).To(ContainSubstring("certcompressed")) - Expect(response).To(ContainSubstring("initial public")) - Expect(signer.gotCHLO).To(BeTrue()) - }) - - It("generates REJ messages for version 30", func() { - cs.version = protocol.Version30 - _, err := cs.handleInchoateCHLO("", sampleCHLO, nil) - Expect(err).ToNot(HaveOccurred()) - Expect(signer.gotCHLO).To(BeFalse()) - }) - - It("generates SHLO messages", func() { - response, err := cs.handleCHLO("", []byte("chlo-data"), map[Tag][]byte{ - TagPUBS: []byte("pubs-c"), - TagNONC: nonce32, - }) - Expect(err).ToNot(HaveOccurred()) - Expect(response).To(HavePrefix("SHLO")) - Expect(response).To(ContainSubstring("ephermal pub")) - Expect(response).To(ContainSubstring(string(cs.nonce))) - Expect(response).To(ContainSubstring(string(protocol.SupportedVersionsAsTags))) - Expect(cs.secureAEAD).ToNot(BeNil()) - Expect(cs.secureAEAD.(*mockAEAD).forwardSecure).To(BeFalse()) - Expect(cs.secureAEAD.(*mockAEAD).sharedSecret).To(Equal([]byte("shared key"))) - Expect(cs.forwardSecureAEAD).ToNot(BeNil()) - Expect(cs.forwardSecureAEAD.(*mockAEAD).sharedSecret).To(Equal([]byte("shared ephermal"))) - Expect(cs.forwardSecureAEAD.(*mockAEAD).forwardSecure).To(BeTrue()) - }) - - It("handles long handshake", func() { - WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{ - TagSNI: []byte("quic.clemente.io"), - TagSTK: validSTK, - TagPAD: bytes.Repeat([]byte{'a'}, protocol.ClientHelloMinimumSize), - }) - WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{ - TagSCID: scfg.ID, - TagSNI: []byte("quic.clemente.io"), - TagNONC: nonce32, - TagSTK: validSTK, - }) - err := cs.HandleCryptoStream() - Expect(err).NotTo(HaveOccurred()) - Expect(stream.dataWritten.Bytes()).To(HavePrefix("REJ")) - Expect(stream.dataWritten.Bytes()).To(ContainSubstring("SHLO")) - Expect(aeadChanged).To(Receive()) - }) - - It("handles 0-RTT handshake", func() { - WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{ - TagSCID: scfg.ID, - TagSNI: []byte("quic.clemente.io"), - TagNONC: nonce32, - TagSTK: validSTK, - }) - err := cs.HandleCryptoStream() - Expect(err).NotTo(HaveOccurred()) - Expect(stream.dataWritten.Bytes()).To(HavePrefix("SHLO")) - Expect(stream.dataWritten.Bytes()).ToNot(ContainSubstring("REJ")) - Expect(aeadChanged).To(Receive()) - }) - - It("recognizes inchoate CHLOs missing SCID", func() { - Expect(cs.isInchoateCHLO(map[Tag][]byte{})).To(BeTrue()) - }) - - It("recognizes proper CHLOs", func() { - Expect(cs.isInchoateCHLO(map[Tag][]byte{TagSCID: scfg.ID})).To(BeFalse()) - }) - - It("errors on too short inchoate CHLOs", func() { - _, err := cs.handleInchoateCHLO("", bytes.Repeat([]byte{'a'}, protocol.ClientHelloMinimumSize-1), nil) - Expect(err).To(MatchError("CryptoInvalidValueLength: CHLO too small")) - }) - }) - - It("errors without SNI", func() { - WriteHandshakeMessage(&stream.dataToRead, TagCHLO, map[Tag][]byte{ - TagSTK: validSTK, - }) - err := cs.HandleCryptoStream() - Expect(err).To(MatchError("CryptoMessageParameterNotFound: SNI required")) - }) - - Context("escalating crypto", func() { - foobarFNVSigned := []byte{0x18, 0x6f, 0x44, 0xba, 0x97, 0x35, 0xd, 0x6f, 0xbf, 0x64, 0x3c, 0x79, 0x66, 0x6f, 0x6f, 0x62, 0x61, 0x72} - - doCHLO := func() { - _, err := cs.handleCHLO("", []byte("chlo-data"), map[Tag][]byte{TagPUBS: []byte("pubs-c"), TagNONC: nonce32}) - Expect(err).ToNot(HaveOccurred()) - } - - Context("null encryption", func() { - It("is used initially", func() { - Expect(cs.Seal(0, []byte{}, []byte("foobar"))).To(Equal(foobarFNVSigned)) - }) - - It("is accepted initially", func() { - d, err := cs.Open(0, []byte{}, foobarFNVSigned) - Expect(err).ToNot(HaveOccurred()) - Expect(d).To(Equal([]byte("foobar"))) - }) - - It("is still accepted after CHLO", func() { - doCHLO() - Expect(cs.secureAEAD).ToNot(BeNil()) - _, err := cs.Open(0, []byte{}, foobarFNVSigned) - Expect(err).ToNot(HaveOccurred()) - }) - - It("is not accepted after receiving secure packet", func() { - doCHLO() - Expect(cs.secureAEAD).ToNot(BeNil()) - d, err := cs.Open(0, []byte{}, []byte("encrypted")) - Expect(err).ToNot(HaveOccurred()) - Expect(d).To(Equal([]byte("decrypted"))) - _, err = cs.Open(0, []byte{}, foobarFNVSigned) - Expect(err).To(MatchError("authentication failed")) - }) - - It("is not used after CHLO", func() { - doCHLO() - d := cs.Seal(0, []byte{}, []byte("foobar")) - Expect(d).ToNot(Equal(foobarFNVSigned)) - }) - }) - - Context("initial encryption", func() { - It("is used after CHLO", func() { - doCHLO() - d := cs.Seal(0, []byte{}, []byte("foobar")) - Expect(d).To(Equal([]byte("encrypted"))) - }) - - It("is accepted after CHLO", func() { - doCHLO() - d, err := cs.Open(0, []byte{}, []byte("encrypted")) - Expect(err).ToNot(HaveOccurred()) - Expect(d).To(Equal([]byte("decrypted"))) - }) - - It("is not used after receiving forward secure packet", func() { - doCHLO() - _, err := cs.Open(0, []byte{}, []byte("forward secure encrypted")) - Expect(err).ToNot(HaveOccurred()) - d := cs.Seal(0, []byte{}, []byte("foobar")) - Expect(d).To(Equal([]byte("forward secure encrypted"))) - }) - - It("is not accepted after receiving forward secure packet", func() { - doCHLO() - _, err := cs.Open(0, []byte{}, []byte("forward secure encrypted")) - Expect(err).ToNot(HaveOccurred()) - _, err = cs.Open(0, []byte{}, []byte("encrypted")) - Expect(err).To(MatchError("authentication failed")) - }) - }) - - Context("forward secure encryption", func() { - It("is used after receiving forward secure packet", func() { - doCHLO() - _, err := cs.Open(0, []byte{}, []byte("forward secure encrypted")) - Expect(err).ToNot(HaveOccurred()) - d := cs.Seal(0, []byte{}, []byte("foobar")) - Expect(d).To(Equal([]byte("forward secure encrypted"))) - }) - }) - }) - - Context("STK verification and creation", func() { - It("requires STK", func() { - done, err := cs.handleMessage(bytes.Repeat([]byte{'a'}, protocol.ClientHelloMinimumSize), map[Tag][]byte{ - TagSNI: []byte("foo"), - }) - Expect(done).To(BeFalse()) - Expect(err).To(BeNil()) - Expect(stream.dataWritten.Bytes()).To(ContainSubstring(string(validSTK))) - }) - - It("works with proper STK", func() { - done, err := cs.handleMessage(bytes.Repeat([]byte{'a'}, protocol.ClientHelloMinimumSize), map[Tag][]byte{ - TagSTK: validSTK, - TagSNI: []byte("foo"), - }) - Expect(done).To(BeFalse()) - Expect(err).To(BeNil()) - }) - - It("errors if IP does not match", func() { - done, err := cs.handleMessage(bytes.Repeat([]byte{'a'}, protocol.ClientHelloMinimumSize), map[Tag][]byte{ - TagSNI: []byte("foo"), - TagSTK: []byte("token \x04\x03\x03\x01"), - }) - Expect(done).To(BeFalse()) - Expect(err).To(BeNil()) - Expect(stream.dataWritten.Bytes()).To(ContainSubstring(string(validSTK))) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/data_test.go b/vendor/github.com/lucas-clemente/quic-go/handshake/data_test.go deleted file mode 100644 index 238f703..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/data_test.go +++ /dev/null @@ -1,24 +0,0 @@ -package handshake - -import "strings" - -var sampleCHLO = []byte{0x43, 0x48, 0x4c, 0x4f, 0x10, 0x0, 0x0, 0x0, 0x50, 0x41, 0x44, 0x0, 0xf8, 0x3, 0x0, 0x0, 0x53, 0x4e, 0x49, 0x0, 0x7, 0x4, 0x0, 0x0, 0x56, 0x45, 0x52, 0x0, 0xb, 0x4, 0x0, 0x0, 0x43, 0x43, 0x53, 0x0, 0x1b, 0x4, 0x0, 0x0, 0x4d, 0x53, 0x50, 0x43, 0x1f, 0x4, 0x0, 0x0, 0x55, 0x41, 0x49, 0x44, 0x4c, 0x4, 0x0, 0x0, 0x54, 0x43, 0x49, 0x44, 0x50, 0x4, 0x0, 0x0, 0x50, 0x44, 0x4d, 0x44, 0x54, 0x4, 0x0, 0x0, 0x53, 0x52, 0x42, 0x46, 0x58, 0x4, 0x0, 0x0, 0x49, 0x43, 0x53, 0x4c, 0x5c, 0x4, 0x0, 0x0, 0x4e, 0x4f, 0x4e, 0x50, 0x7c, 0x4, 0x0, 0x0, 0x53, 0x43, 0x4c, 0x53, 0x80, 0x4, 0x0, 0x0, 0x43, 0x53, 0x43, 0x54, 0x80, 0x4, 0x0, 0x0, 0x43, 0x4f, 0x50, 0x54, 0x84, 0x4, 0x0, 0x0, 0x43, 0x46, 0x43, 0x57, 0x88, 0x4, 0x0, 0x0, 0x53, 0x46, 0x43, 0x57, 0x8c, 0x4, 0x0, 0x0, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x2d, 0x77, 0x77, 0x77, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x6f, 0x72, 0x67, 0x51, 0x30, 0x33, 0x30, 0x7b, 0x26, 0xe9, 0xe7, 0xe4, 0x5c, 0x71, 0xff, 0x1, 0xe8, 0x81, 0x60, 0x92, 0x92, 0x1a, 0xe8, 0x64, 0x0, 0x0, 0x0, 0x64, 0x65, 0x76, 0x20, 0x43, 0x68, 0x72, 0x6f, 0x6d, 0x65, 0x2f, 0x35, 0x31, 0x2e, 0x30, 0x2e, 0x32, 0x37, 0x30, 0x30, 0x2e, 0x30, 0x20, 0x49, 0x6e, 0x74, 0x65, 0x6c, 0x20, 0x4d, 0x61, 0x63, 0x20, 0x4f, 0x53, 0x20, 0x58, 0x20, 0x31, 0x30, 0x5f, 0x31, 0x31, 0x5f, 0x34, 0x0, 0x0, 0x0, 0x0, 0x58, 0x35, 0x30, 0x39, 0x0, 0x0, 0x10, 0x0, 0x1e, 0x0, 0x0, 0x0, 0xe1, 0x84, 0x54, 0x1b, 0xe3, 0xd6, 0x7c, 0x1f, 0x69, 0xb2, 0x4e, 0x9e, 0x46, 0xf4, 0x46, 0xdd, 0xab, 0xe5, 0xde, 0x66, 0x94, 0xf6, 0xb2, 0xee, 0x1, 0xc4, 0xa5, 0x77, 0xfe, 0xc9, 0xb, 0xa3, 0x1, 0x0, 0x0, 0x0, 0x46, 0x49, 0x58, 0x44, 0x0, 0x0, 0xf0, 0x0, 0x0, 0x0, 0x60, 0x0} - -var sampleCHLOMap = map[Tag][]byte{ - TagPAD: []byte(strings.Repeat("-", 1016)), - TagSNI: []byte("www.example.org"), - TagVER: []byte("Q030"), - TagCCS: []byte("{&\xe9\xe7\xe4\\q\xff\x01\xe8\x81`\x92\x92\x1a\xe8"), - TagMSPC: []byte("d\x00\x00\x00"), - TagUAID: []byte("dev Chrome/51.0.2700.0 Intel Mac OS X 10_11_4"), - TagTCID: []byte("\x00\x00\x00\x00"), - TagSRBF: []byte("\x00\x00\x10\x00"), - TagICSL: []byte("\x1e\x00\x00\x00"), - TagNONP: []byte("\xe1\x84T\x1b\xe3\xd6|\x1fi\xb2N\x9eF\xf4Fݫ\xe5\xdef\x94\xf6\xb2\xee\x01ĥw\xfe\xc9\v\xa3"), - TagSCLS: []byte("\x01\x00\x00\x00"), - TagCSCT: {}, - TagCOPT: []byte("FIXD"), - TagSFCW: []byte("\x00\x00`\x00"), - TagCFCW: []byte("\x00\x00\xf0\x00"), - TagPDMD: []byte("X509"), -} diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message.go b/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message.go deleted file mode 100644 index e43db23..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message.go +++ /dev/null @@ -1,116 +0,0 @@ -package handshake - -import ( - "bytes" - "encoding/binary" - "fmt" - "io" - "sort" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// ParseHandshakeMessage reads a crypto message -func ParseHandshakeMessage(r utils.ReadStream) (Tag, map[Tag][]byte, error) { - messageTag, err := utils.ReadUint32(r) - if err != nil { - return 0, nil, err - } - - nPairs, err := utils.ReadUint32(r) - if err != nil { - return 0, nil, err - } - - if nPairs > protocol.CryptoMaxParams { - return 0, nil, qerr.CryptoTooManyEntries - } - - index := make([]byte, nPairs*8) - _, err = io.ReadFull(r, index) - if err != nil { - return 0, nil, err - } - - resultMap := map[Tag][]byte{} - - var dataStart uint32 - for indexPos := 0; indexPos < int(nPairs)*8; indexPos += 8 { - tag := Tag(binary.LittleEndian.Uint32(index[indexPos : indexPos+4])) - dataEnd := uint32(binary.LittleEndian.Uint32(index[indexPos+4 : indexPos+8])) - - dataLen := dataEnd - dataStart - if dataLen > protocol.CryptoParameterMaxLength { - return 0, nil, qerr.Error(qerr.CryptoInvalidValueLength, "value too long") - } - - data := make([]byte, dataLen) - _, err = io.ReadFull(r, data) - if err != nil { - return 0, nil, err - } - - resultMap[tag] = data - dataStart = dataEnd - } - - return Tag(messageTag), resultMap, nil -} - -// WriteHandshakeMessage writes a crypto message -func WriteHandshakeMessage(b *bytes.Buffer, messageTag Tag, data map[Tag][]byte) { - utils.WriteUint32(b, uint32(messageTag)) - utils.WriteUint16(b, uint16(len(data))) - utils.WriteUint16(b, 0) - - // Save current position in the buffer, so that we can update the index in-place later - indexStart := b.Len() - - indexData := make([]byte, 8*len(data)) - b.Write(indexData) // Will be updated later - - // Sort the tags - tags := make([]uint32, len(data)) - i := 0 - for t := range data { - tags[i] = uint32(t) - i++ - } - sort.Sort(utils.Uint32Slice(tags)) - - offset := uint32(0) - for i, t := range tags { - v := data[Tag(t)] - b.Write(v) - offset += uint32(len(v)) - binary.LittleEndian.PutUint32(indexData[i*8:], t) - binary.LittleEndian.PutUint32(indexData[i*8+4:], offset) - } - - // Now we write the index data for real - copy(b.Bytes()[indexStart:], indexData) -} - -func printHandshakeMessage(data map[Tag][]byte) string { - var res string - for k, v := range data { - if k == TagPAD { - continue - } - res += fmt.Sprintf("\t%s: %#v\n", tagToString(k), string(v)) - } - return res -} - -func tagToString(tag Tag) string { - b := make([]byte, 4) - binary.LittleEndian.PutUint32(b, uint32(tag)) - for i := range b { - if b[i] == 0 { - b[i] = ' ' - } - } - return string(b) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message_test.go b/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message_test.go deleted file mode 100644 index 81eac31..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_message_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package handshake - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/qerr" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Handshake Message", func() { - Context("when parsing", func() { - It("parses sample CHLO message", func() { - tag, msg, err := ParseHandshakeMessage(bytes.NewReader(sampleCHLO)) - Expect(err).ToNot(HaveOccurred()) - Expect(tag).To(Equal(TagCHLO)) - Expect(msg).To(Equal(sampleCHLOMap)) - }) - - It("rejects large numbers of pairs", func() { - r := bytes.NewReader([]byte("CHLO\xff\xff\xff\xff")) - _, _, err := ParseHandshakeMessage(r) - Expect(err).To(MatchError(qerr.CryptoTooManyEntries)) - }) - - It("rejects too long values", func() { - r := bytes.NewReader([]byte{ - 'C', 'H', 'L', 'O', - 1, 0, 0, 0, - 0, 0, 0, 0, - 0xff, 0xff, 0xff, 0xff, - }) - _, _, err := ParseHandshakeMessage(r) - Expect(err).To(MatchError(qerr.Error(qerr.CryptoInvalidValueLength, "value too long"))) - }) - }) - - Context("when writing", func() { - It("writes sample message", func() { - b := &bytes.Buffer{} - WriteHandshakeMessage(b, TagCHLO, sampleCHLOMap) - Expect(b.Bytes()).To(Equal(sampleCHLO)) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_suite_test.go deleted file mode 100644 index 74d9e7b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/handshake_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package handshake - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestQuicGo(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Handshake Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/server_config.go b/vendor/github.com/lucas-clemente/quic-go/handshake/server_config.go deleted file mode 100644 index c3de7bd..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/server_config.go +++ /dev/null @@ -1,67 +0,0 @@ -package handshake - -import ( - "bytes" - "crypto/rand" - "io" - - "github.com/lucas-clemente/quic-go/crypto" -) - -// ServerConfig is a server config -type ServerConfig struct { - kex crypto.KeyExchange - signer crypto.Signer - ID []byte - stkSource crypto.StkSource -} - -// NewServerConfig creates a new server config -func NewServerConfig(kex crypto.KeyExchange, signer crypto.Signer) (*ServerConfig, error) { - id := make([]byte, 16) - _, err := io.ReadFull(rand.Reader, id) - if err != nil { - return nil, err - } - - stkSecret := make([]byte, 32) - if _, err = io.ReadFull(rand.Reader, stkSecret); err != nil { - return nil, err - } - stkSource, err := crypto.NewStkSource(stkSecret) - if err != nil { - return nil, err - } - - return &ServerConfig{ - kex: kex, - signer: signer, - ID: id, - stkSource: stkSource, - }, nil -} - -// Get the server config binary representation -func (s *ServerConfig) Get() []byte { - var serverConfig bytes.Buffer - WriteHandshakeMessage(&serverConfig, TagSCFG, map[Tag][]byte{ - TagSCID: s.ID, - TagKEXS: []byte("C255"), - TagAEAD: []byte("CC20"), - TagPUBS: append([]byte{0x20, 0x00, 0x00}, s.kex.PublicKey()...), - TagOBIT: {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7}, - TagEXPY: {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, - TagVER: []byte("Q032"), - }) - return serverConfig.Bytes() -} - -// Sign the server config and CHLO with the server's keyData -func (s *ServerConfig) Sign(sni string, chlo []byte) ([]byte, error) { - return s.signer.SignServerProof(sni, chlo, s.Get()) -} - -// GetCertsCompressed returns the certificate data -func (s *ServerConfig) GetCertsCompressed(sni string, commonSetHashes, compressedHashes []byte) ([]byte, error) { - return s.signer.GetCertsCompressed(sni, commonSetHashes, compressedHashes) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/server_config_test.go b/vendor/github.com/lucas-clemente/quic-go/handshake/server_config_test.go deleted file mode 100644 index 0e4c100..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/server_config_test.go +++ /dev/null @@ -1,34 +0,0 @@ -package handshake - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/crypto" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("ServerConfig", func() { - var ( - kex crypto.KeyExchange - scfg *ServerConfig - ) - - BeforeEach(func() { - var err error - kex, err = crypto.NewCurve25519KEX() - Expect(err).NotTo(HaveOccurred()) - scfg, err = NewServerConfig(kex, nil) - Expect(err).NotTo(HaveOccurred()) - }) - - It("gets the proper binary representation", func() { - expected := bytes.NewBuffer([]byte{0x53, 0x43, 0x46, 0x47, 0x7, 0x0, 0x0, 0x0, 0x56, 0x45, 0x52, 0x0, 0x4, 0x0, 0x0, 0x0, 0x41, 0x45, 0x41, 0x44, 0x8, 0x0, 0x0, 0x0, 0x53, 0x43, 0x49, 0x44, 0x18, 0x0, 0x0, 0x0, 0x50, 0x55, 0x42, 0x53, 0x3b, 0x0, 0x0, 0x0, 0x4b, 0x45, 0x58, 0x53, 0x3f, 0x0, 0x0, 0x0, 0x4f, 0x42, 0x49, 0x54, 0x47, 0x0, 0x0, 0x0, 0x45, 0x58, 0x50, 0x59, 0x4f, 0x0, 0x0, 0x0, 0x51, 0x30, 0x33, 0x32, 0x43, 0x43, 0x32, 0x30}) - expected.Write(scfg.ID) - expected.Write([]byte{0x20, 0x0, 0x0}) - expected.Write(kex.PublicKey()) - expected.Write([]byte{0x43, 0x32, 0x35, 0x35, 0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}) - Expect(scfg.Get()).To(Equal(expected.Bytes())) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/handshake/tags.go b/vendor/github.com/lucas-clemente/quic-go/handshake/tags.go deleted file mode 100644 index ed96c40..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/handshake/tags.go +++ /dev/null @@ -1,83 +0,0 @@ -package handshake - -// A Tag in the QUIC crypto -type Tag uint32 - -const ( - // TagCHLO is a client hello - TagCHLO Tag = 'C' + 'H'<<8 + 'L'<<16 + 'O'<<24 - // TagREJ is a server hello rejection - TagREJ Tag = 'R' + 'E'<<8 + 'J'<<16 - // TagSCFG is a server config - TagSCFG Tag = 'S' + 'C'<<8 + 'F'<<16 + 'G'<<24 - - // TagPAD is padding - TagPAD Tag = 'P' + 'A'<<8 + 'D'<<16 - // TagSNI is the server name indication - TagSNI Tag = 'S' + 'N'<<8 + 'I'<<16 - // TagVER is the QUIC version - TagVER Tag = 'V' + 'E'<<8 + 'R'<<16 - // TagCCS are the hashes of the common certificate sets - TagCCS Tag = 'C' + 'C'<<8 + 'S'<<16 - // TagCCRT are the hashes of the cached certificates - TagCCRT Tag = 'C' + 'C'<<8 + 'R'<<16 + 'T'<<24 - // TagMSPC is max streams per connection - TagMSPC Tag = 'M' + 'S'<<8 + 'P'<<16 + 'C'<<24 - // TagUAID is the user agent ID - TagUAID Tag = 'U' + 'A'<<8 + 'I'<<16 + 'D'<<24 - // TagTCID is truncation of the connection ID - TagTCID Tag = 'T' + 'C'<<8 + 'I'<<16 + 'D'<<24 - // TagPDMD is the proof demand - TagPDMD Tag = 'P' + 'D'<<8 + 'M'<<16 + 'D'<<24 - // TagSRBF is the socket receive buffer - TagSRBF Tag = 'S' + 'R'<<8 + 'B'<<16 + 'F'<<24 - // TagICSL is the idle connection state lifetime - TagICSL Tag = 'I' + 'C'<<8 + 'S'<<16 + 'L'<<24 - // TagNONP is the client proof nonce - TagNONP Tag = 'N' + 'O'<<8 + 'N'<<16 + 'P'<<24 - // TagSCLS is the silently close timeout - TagSCLS Tag = 'S' + 'C'<<8 + 'L'<<16 + 'S'<<24 - // TagCSCT is the signed cert timestamp (RFC6962) of leaf cert - TagCSCT Tag = 'C' + 'S'<<8 + 'C'<<16 + 'T'<<24 - // TagCOPT are the connection options - TagCOPT Tag = 'C' + 'O'<<8 + 'P'<<16 + 'T'<<24 - // TagCFCW is the initial session/connection flow control receive window - TagCFCW Tag = 'C' + 'F'<<8 + 'C'<<16 + 'W'<<24 - // TagSFCW is the initial stream flow control receive window. - TagSFCW Tag = 'S' + 'F'<<8 + 'C'<<16 + 'W'<<24 - - // TagSTK is the source-address token - TagSTK Tag = 'S' + 'T'<<8 + 'K'<<16 - // TagSNO is the server nonce - TagSNO Tag = 'S' + 'N'<<8 + 'O'<<16 - // TagPROF is the server proof - TagPROF Tag = 'P' + 'R'<<8 + 'O'<<16 + 'F'<<24 - - // TagNONC is the client nonce - TagNONC Tag = 'N' + 'O'<<8 + 'N'<<16 + 'C'<<24 - - // TagSCID is the server config ID - TagSCID Tag = 'S' + 'C'<<8 + 'I'<<16 + 'D'<<24 - // TagKEXS is the list of key exchange algos - TagKEXS Tag = 'K' + 'E'<<8 + 'X'<<16 + 'S'<<24 - // TagAEAD is the list of AEAD algos - TagAEAD Tag = 'A' + 'E'<<8 + 'A'<<16 + 'D'<<24 - // TagPUBS is the public value for the KEX - TagPUBS Tag = 'P' + 'U'<<8 + 'B'<<16 + 'S'<<24 - // TagOBIT is the client orbit - TagOBIT Tag = 'O' + 'B'<<8 + 'I'<<16 + 'T'<<24 - // TagEXPY is the server config expiry - TagEXPY Tag = 'E' + 'X'<<8 + 'P'<<16 + 'Y'<<24 - // TagCERT is the CERT data - TagCERT Tag = 0xff545243 - - // TagSHLO is the server hello - TagSHLO Tag = 'S' + 'H'<<8 + 'L'<<16 + 'O'<<24 - - // TagPRST is the public reset tag - TagPRST Tag = 'P' + 'R'<<8 + 'S'<<16 + 'T'<<24 - // TagRSEQ is the public reset rejected packet number - TagRSEQ Tag = 'R' + 'S'<<8 + 'E'<<16 + 'Q'<<24 - // TagRNON is the public reset nonce - TagRNON Tag = 'R' + 'N'<<8 + 'O'<<16 + 'N'<<24 -) diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/chrome_test.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/chrome_test.go deleted file mode 100644 index 55fae52..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/chrome_test.go +++ /dev/null @@ -1,72 +0,0 @@ -package integrationtests - -import ( - "fmt" - "io" - "net/http" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -const nImgs = 200 -const imgSize = 40 - -func init() { - http.HandleFunc("/tile", func(w http.ResponseWriter, r *http.Request) { - // Small 40x40 png - w.Write([]byte{ - 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, - 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, - 0x01, 0x03, 0x00, 0x00, 0x00, 0xb6, 0x30, 0x2a, 0x2e, 0x00, 0x00, 0x00, - 0x03, 0x50, 0x4c, 0x54, 0x45, 0x5a, 0xc3, 0x5a, 0xad, 0x38, 0xaa, 0xdb, - 0x00, 0x00, 0x00, 0x0b, 0x49, 0x44, 0x41, 0x54, 0x78, 0x01, 0x63, 0x18, - 0x61, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x01, 0xe2, 0xb8, 0x75, 0x22, 0x00, - 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82, - }) - }) - - http.HandleFunc("/tiles", func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, "") - for i := 0; i < nImgs; i++ { - fmt.Fprintf(w, ``, i) - } - io.WriteString(w, "") - }) -} - -var _ = Describe("Chrome tests", func() { - It("loads a simple hello world page using quic", func(done Done) { - err := wd.Get("https://quic.clemente.io/hello") - Expect(err).NotTo(HaveOccurred()) - source, err := wd.PageSource() - Expect(err).NotTo(HaveOccurred()) - Expect(source).To(ContainSubstring("Hello, World!\n")) - close(done) - }, 5) - - It("loads a large number of files", func(done Done) { - err := wd.Get("https://quic.clemente.io/tiles") - Expect(err).NotTo(HaveOccurred()) - Eventually(func() error { - imgs, err := wd.FindElements("tag name", "img") - if err != nil { - return err - } - if len(imgs) != nImgs { - return fmt.Errorf("expected number of images to be %d, got %d", nImgs, len(imgs)) - } - for i, img := range imgs { - size, err := img.Size() - if err != nil { - return err - } - if size.Height != imgSize || size.Width != imgSize { - return fmt.Errorf("image %d did not have expected size", i) - } - } - return nil - }).ShouldNot(HaveOccurred()) - close(done) - }, 10) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/drop.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/drop.go deleted file mode 100644 index c94303b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/drop.go +++ /dev/null @@ -1 +0,0 @@ -package integrationtests diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/drop_test.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/drop_test.go deleted file mode 100644 index e8b6f93..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/drop_test.go +++ /dev/null @@ -1,79 +0,0 @@ -package integrationtests - -import ( - "bytes" - "fmt" - "os" - "os/exec" - "runtime" - "strconv" - "time" - - _ "github.com/lucas-clemente/quic-clients" // download clients - "github.com/lucas-clemente/quic-go/protocol" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gexec" -) - -var proxy *UDPProxy - -func runDropTest(incomingPacketDropper, outgoingPacketDropper dropCallback, version protocol.VersionNumber) { - proxyPort := 12345 - - clientPath := fmt.Sprintf( - "%s/src/github.com/lucas-clemente/quic-clients/client-%s-debug", - os.Getenv("GOPATH"), - runtime.GOOS, - ) - - iPort, _ := strconv.Atoi(port) - var err error - proxy, err = NewUDPProxy(proxyPort, "localhost", iPort, incomingPacketDropper, outgoingPacketDropper) - Expect(err).ToNot(HaveOccurred()) - - command := exec.Command( - clientPath, - "--quic-version="+strconv.Itoa(int(version)), - "--host=127.0.0.1", - "--port="+strconv.Itoa(proxyPort), - "https://quic.clemente.io/data", - ) - - session, err := Start(command, nil, GinkgoWriter) - Expect(err).NotTo(HaveOccurred()) - defer session.Kill() - Eventually(session, 4).Should(Exit(0)) - Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue()) -} - -var _ = Describe("Drop Proxy", func() { - AfterEach(func() { - proxy.Stop() - time.Sleep(time.Millisecond) - }) - - for i := range protocol.SupportedVersions { - version := protocol.SupportedVersions[i] - - Context(fmt.Sprintf("with quic version %d", version), func() { - Context("dropping every 4th packet after the crypto handshake", func() { - dropper := func(p PacketNumber) bool { - if p <= 5 { // don't interfere with the crypto handshake - return false - } - return p%4 == 0 - } - - It("gets a file when many outgoing packets are dropped", func() { - runDropTest(nil, dropper, version) - }) - - It("gets a file when many incoming packets are dropped", func() { - runDropTest(dropper, nil, version) - }) - }) - }) - } -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/integration.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/integration.go deleted file mode 100644 index c94303b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/integration.go +++ /dev/null @@ -1 +0,0 @@ -package integrationtests diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/integration_test.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/integration_test.go deleted file mode 100644 index 6a8c1d7..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/integration_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package integrationtests - -import ( - "bytes" - "fmt" - "os" - "os/exec" - "runtime" - "strconv" - "sync" - - "github.com/lucas-clemente/quic-go/protocol" - - _ "github.com/lucas-clemente/quic-clients" // download clients - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - . "github.com/onsi/gomega/gbytes" - . "github.com/onsi/gomega/gexec" -) - -var _ = Describe("Integration tests", func() { - clientPath := fmt.Sprintf( - "%s/src/github.com/lucas-clemente/quic-clients/client-%s-debug", - os.Getenv("GOPATH"), - runtime.GOOS, - ) - - for i := range protocol.SupportedVersions { - version := protocol.SupportedVersions[i] - - Context(fmt.Sprintf("with quic version %d", version), func() { - It("gets a simple file", func() { - command := exec.Command( - clientPath, - "--quic-version="+strconv.Itoa(int(version)), - "--host=127.0.0.1", - "--port="+port, - "https://quic.clemente.io/hello", - ) - session, err := Start(command, GinkgoWriter, GinkgoWriter) - Expect(err).NotTo(HaveOccurred()) - defer session.Kill() - Eventually(session).Should(Exit(0)) - Expect(session.Out).To(Say("Response:\nheaders: HTTP/1.1 200\nstatus: 200\n\nbody: Hello, World!\n")) - }) - - It("posts and reads a body", func() { - command := exec.Command( - clientPath, - "--quic-version="+strconv.Itoa(int(version)), - "--host=127.0.0.1", - "--port="+port, - "--body=foo", - "https://quic.clemente.io/echo", - ) - session, err := Start(command, GinkgoWriter, GinkgoWriter) - Expect(err).NotTo(HaveOccurred()) - defer session.Kill() - Eventually(session).Should(Exit(0)) - Expect(session.Out).To(Say("Response:\nheaders: HTTP/1.1 200\nstatus: 200\n\nbody: foo\n")) - }) - - It("gets a large file", func() { - command := exec.Command( - clientPath, - "--quic-version="+strconv.Itoa(int(version)), - "--host=127.0.0.1", - "--port="+port, - "https://quic.clemente.io/data", - ) - session, err := Start(command, nil, GinkgoWriter) - Expect(err).NotTo(HaveOccurred()) - defer session.Kill() - Eventually(session, 2).Should(Exit(0)) - Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue()) - }) - - It("gets many large files in parallel", func() { - wg := sync.WaitGroup{} - for i := 0; i < 10; i++ { - wg.Add(1) - go func() { - defer wg.Done() - defer GinkgoRecover() - command := exec.Command( - clientPath, - "--quic-version="+strconv.Itoa(int(version)), - "--host=127.0.0.1", - "--port="+port, - "https://quic.clemente.io/data", - ) - session, err := Start(command, nil, GinkgoWriter) - Expect(err).NotTo(HaveOccurred()) - defer session.Kill() - Eventually(session, 3).Should(Exit(0)) - Expect(bytes.Contains(session.Out.Contents(), data)).To(BeTrue()) - }() - } - wg.Wait() - }) - }) - } -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/integrationtests_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/integrationtests_suite_test.go deleted file mode 100644 index 0f36542..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/integrationtests_suite_test.go +++ /dev/null @@ -1,156 +0,0 @@ -package integrationtests - -import ( - "crypto/rand" - "fmt" - "io" - "net" - "net/http" - "os/exec" - "strconv" - "time" - - "github.com/lucas-clemente/quic-go/h2quic" - "github.com/lucas-clemente/quic-go/testdata" - "github.com/tebeka/selenium" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - "github.com/onsi/gomega/gbytes" - "github.com/onsi/gomega/gexec" - - "testing" -) - -const ( - dataLen = 50 * 1024 -) - -var ( - server *h2quic.Server - data []byte - port string - - docker *gexec.Session - wd selenium.WebDriver -) - -func TestIntegration(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Integration Tests Suite") -} - -var _ = BeforeSuite(func() { - setupHTTPHandlers() - setupQuicServer() - setupSelenium() -}) - -var _ = AfterSuite(func() { - err := server.Close() - Expect(err).NotTo(HaveOccurred()) - - stopSelenium() -}) - -func setupHTTPHandlers() { - defer GinkgoRecover() - data = make([]byte, dataLen) - _, err := rand.Read(data) - Expect(err).NotTo(HaveOccurred()) - - http.HandleFunc("/hello", func(w http.ResponseWriter, r *http.Request) { - _, err := io.WriteString(w, "Hello, World!\n") - Expect(err).NotTo(HaveOccurred()) - }) - - http.HandleFunc("/data", func(w http.ResponseWriter, r *http.Request) { - _, err := w.Write(data) - Expect(err).NotTo(HaveOccurred()) - }) - - http.HandleFunc("/echo", func(w http.ResponseWriter, r *http.Request) { - _, err := io.Copy(w, r.Body) - Expect(err).NotTo(HaveOccurred()) - }) -} - -func setupQuicServer() { - server = &h2quic.Server{ - Server: &http.Server{ - TLSConfig: testdata.GetTLSConfig(), - }, - } - - addr, err := net.ResolveUDPAddr("udp", "0.0.0.0:0") - Expect(err).NotTo(HaveOccurred()) - conn, err := net.ListenUDP("udp", addr) - Expect(err).NotTo(HaveOccurred()) - port = strconv.Itoa(conn.LocalAddr().(*net.UDPAddr).Port) - - go func() { - defer GinkgoRecover() - server.Serve(conn) - }() -} - -func setupSelenium() { - var err error - pullCmd := exec.Command("docker", "pull", "selenium/standalone-chrome:latest") - pull, err := gexec.Start(pullCmd, GinkgoWriter, GinkgoWriter) - Expect(err).NotTo(HaveOccurred()) - // Assuming a download at 10 Mbit/s - Eventually(pull, 10*time.Minute).Should(gexec.Exit(0)) - - dockerCmd := exec.Command( - "docker", - "run", - "-i", - "--rm", - "-p=4444:4444", - "selenium/standalone-chrome:latest", - ) - docker, err = gexec.Start(dockerCmd, GinkgoWriter, GinkgoWriter) - Expect(err).NotTo(HaveOccurred()) - Eventually(docker.Out, 5).Should(gbytes.Say("Selenium Server is up and running")) - - caps := selenium.Capabilities{ - "browserName": "chrome", - "chromeOptions": map[string]interface{}{ - "args": []string{ - "--enable-quic", - "--no-proxy-server", - "--origin-to-force-quic-on=quic.clemente.io:443", - fmt.Sprintf(`--host-resolver-rules=MAP quic.clemente.io:443 %s:%s`, GetLocalIP(), port), - }, - }, - } - wd, err = selenium.NewRemote(caps, "http://localhost:4444/wd/hub") - Expect(err).NotTo(HaveOccurred()) -} - -func stopSelenium() { - docker.Interrupt().Wait(1) -} - -func GetLocalIP() string { - // First, try finding interface docker0 - i, err := net.InterfaceByName("docker0") - if err == nil { - var addrs []net.Addr - addrs, err = i.Addrs() - Expect(err).NotTo(HaveOccurred()) - return addrs[0].(*net.IPNet).IP.String() - } - - addrs, err := net.InterfaceAddrs() - Expect(err).NotTo(HaveOccurred()) - for _, address := range addrs { - if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() { - if ipnet.IP.To4() != nil { - return ipnet.IP.String() - } - } - } - panic("no addr") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy.go deleted file mode 100644 index 9322ea1..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy.go +++ /dev/null @@ -1,150 +0,0 @@ -package integrationtests - -import ( - "net" - "strconv" - "sync" -) - -// Connection is a UDP connection -type connection struct { - ClientAddr *net.UDPAddr // Address of the client - ServerConn *net.UDPConn // UDP connection to server - - incomingPacketCounter PacketNumber - outgoingPacketCounter PacketNumber -} - -type PacketNumber uint64 -type dropCallback func(PacketNumber) bool - -// UDPProxy is a UDP proxy -type UDPProxy struct { - serverAddr *net.UDPAddr - mutex sync.Mutex - - proxyConn *net.UDPConn - dropIncomingPacket dropCallback - dropOutgoingPacket dropCallback - - // Mapping from client addresses (as host:port) to connection - clientDict map[string]*connection -} - -// NewUDPProxy creates a new UDP proxy -func NewUDPProxy(proxyPort int, serverAddress string, serverPort int, dropIncomingPacket, dropOutgoingPacket dropCallback) (*UDPProxy, error) { - dontDrop := func(p PacketNumber) bool { - return false - } - - if dropIncomingPacket == nil { - dropIncomingPacket = dontDrop - } - if dropOutgoingPacket == nil { - dropOutgoingPacket = dontDrop - } - - p := UDPProxy{ - clientDict: make(map[string]*connection), - dropIncomingPacket: dropIncomingPacket, - dropOutgoingPacket: dropOutgoingPacket, - } - - saddr, err := net.ResolveUDPAddr("udp", ":"+strconv.Itoa(proxyPort)) - if err != nil { - return nil, err - } - pudp, err := net.ListenUDP("udp", saddr) - if err != nil { - return nil, err - } - p.proxyConn = pudp - - srvaddr, err := net.ResolveUDPAddr("udp", serverAddress+":"+strconv.Itoa(serverPort)) - if err != nil { - return nil, err - } - p.serverAddr = srvaddr - - go p.runProxy() - - return &p, nil -} - -// Stop stops the UDP Proxy -func (p *UDPProxy) Stop() { - p.proxyConn.Close() -} - -func (p *UDPProxy) newConnection(cliAddr *net.UDPAddr) (*connection, error) { - var conn connection - conn.ClientAddr = cliAddr - srvudp, err := net.DialUDP("udp", nil, p.serverAddr) - if err != nil { - return nil, err - } - conn.ServerConn = srvudp - return &conn, nil -} - -// runProxy handles inputs to Proxy port -func (p *UDPProxy) runProxy() error { - buffer := make([]byte, 1500) - - for { - n, cliaddr, err := p.proxyConn.ReadFromUDP(buffer[0:]) - if err != nil { - return err - } - - saddr := cliaddr.String() - - p.mutex.Lock() - conn, ok := p.clientDict[saddr] - - if !ok { - conn, err = p.newConnection(cliaddr) - if err != nil { - p.mutex.Unlock() - return err - } - p.clientDict[saddr] = conn - p.mutex.Unlock() - go p.runConnection(conn) - } else { - p.mutex.Unlock() - } - - conn.incomingPacketCounter++ - - if !p.dropIncomingPacket(conn.incomingPacketCounter) { - // Relay to server - _, err = conn.ServerConn.Write(buffer[0:n]) - if err != nil { - return err - } - } - } -} - -// runConnection handles packets from server to a single client -func (p *UDPProxy) runConnection(conn *connection) error { - buffer := make([]byte, 1500) - - for { - n, err := conn.ServerConn.Read(buffer[0:]) - if err != nil { - return err - } - - conn.outgoingPacketCounter++ - - if !p.dropOutgoingPacket(conn.outgoingPacketCounter) { - // Relay it to client - _, err = p.proxyConn.WriteToUDP(buffer[0:n], conn.ClientAddr) - if err != nil { - return err - } - } - } -} diff --git a/vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy_test.go b/vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy_test.go deleted file mode 100644 index 0464536..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/integrationtests/udp_proxy_test.go +++ /dev/null @@ -1,232 +0,0 @@ -package integrationtests - -import ( - "net" - "strconv" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type packetData []byte - -var _ = Describe("Integrationtests", func() { - var serverPort int - - BeforeEach(func() { - serverPort = 7331 - }) - - It("sets up the UDPProxy", func() { - proxy, err := NewUDPProxy(13370, "localhost", serverPort, nil, nil) - Expect(err).ToNot(HaveOccurred()) - Expect(proxy.clientDict).To(HaveLen(0)) - - // check that port 13370 is in use - addr, err := net.ResolveUDPAddr("udp", ":13370") - Expect(err).ToNot(HaveOccurred()) - _, err = net.ListenUDP("udp", addr) - Expect(err).To(HaveOccurred()) - Expect(err).To(MatchError("listen udp :13370: bind: address already in use")) - - proxy.Stop() // stopping is tested in the next test - }) - - It("stops the UDPProxy", func() { - proxy, err := NewUDPProxy(13371, "localhost", serverPort, nil, nil) - Expect(err).ToNot(HaveOccurred()) - proxy.Stop() - - // check that port 13370 is not in use anymore - addr, err := net.ResolveUDPAddr("udp", ":13371") - Expect(err).ToNot(HaveOccurred()) - ln, err := net.ListenUDP("udp", addr) - Expect(err).ToNot(HaveOccurred()) - ln.Close() - }) - - Context("Proxy tests", func() { - var serverConn *net.UDPConn - var serverReceivedPackets []packetData - var serverNumPacketsSent int - var clientConn *net.UDPConn - var proxy *UDPProxy - - BeforeEach(func() { - var err error - serverReceivedPackets = serverReceivedPackets[:0] - serverNumPacketsSent = 0 - - // setup a UDP server on port 7331 - serverAddr, err := net.ResolveUDPAddr("udp", ":"+strconv.Itoa(serverPort)) - Expect(err).ToNot(HaveOccurred()) - serverConn, err = net.ListenUDP("udp", serverAddr) - Expect(err).ToNot(HaveOccurred()) - - proxyAddr, err := net.ResolveUDPAddr("udp", ":10001") - Expect(err).ToNot(HaveOccurred()) - - go func() { - defer GinkgoRecover() - - for { - buf := make([]byte, 1500) - n, addr, err2 := serverConn.ReadFromUDP(buf) - if err2 != nil { - return - } - data := buf[0:n] - serverReceivedPackets = append(serverReceivedPackets, packetData(data)) - - // echo each packet received back to the client - serverConn.WriteToUDP(data, addr) - serverNumPacketsSent++ - } - }() - - // setup the client - localAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0") - Expect(err).ToNot(HaveOccurred()) - clientConn, err = net.DialUDP("udp", localAddr, proxyAddr) - Expect(err).ToNot(HaveOccurred()) - }) - - AfterEach(func() { - proxy.Stop() - serverConn.Close() - time.Sleep(time.Millisecond) - }) - - Context("no packet drop", func() { - BeforeEach(func() { - // setup the proxy - var err error - proxy, err = NewUDPProxy(10001, "localhost", serverPort, nil, nil) - Expect(err).ToNot(HaveOccurred()) - }) - - It("relays packets from the client to the server", func() { - _, err := clientConn.Write([]byte("foobar")) - Expect(err).ToNot(HaveOccurred()) - time.Sleep(time.Millisecond) - Expect(proxy.clientDict).To(HaveLen(1)) - var key string - var conn *connection - for key, conn = range proxy.clientDict { - Expect(conn.incomingPacketCounter).To(Equal(PacketNumber(1))) - } - _, err = clientConn.Write([]byte("decafbad")) - Expect(err).ToNot(HaveOccurred()) - time.Sleep(time.Millisecond) - Expect(proxy.clientDict).To(HaveLen(1)) - Expect(proxy.clientDict[key].incomingPacketCounter).To(Equal(PacketNumber(2))) - Expect(serverReceivedPackets).To(HaveLen(2)) - Expect(serverReceivedPackets[0]).To(Equal(packetData("foobar"))) - Expect(serverReceivedPackets[1]).To(Equal(packetData("decafbad"))) - }) - - It("relays packets from the server to the client", func() { - _, err := clientConn.Write([]byte("foobar")) - Expect(err).ToNot(HaveOccurred()) - time.Sleep(time.Millisecond) - Expect(proxy.clientDict).To(HaveLen(1)) - var key string - var conn *connection - for key, conn = range proxy.clientDict { - Expect(conn.outgoingPacketCounter).To(Equal(PacketNumber(1))) - } - _, err = clientConn.Write([]byte("decafbad")) - Expect(err).ToNot(HaveOccurred()) - time.Sleep(time.Millisecond) - Expect(proxy.clientDict).To(HaveLen(1)) - Expect(proxy.clientDict[key].outgoingPacketCounter).To(Equal(PacketNumber(2))) - - var clientReceivedPackets []packetData - - // receive the packets echoed by the server on client side - go func() { - defer GinkgoRecover() - - for { - buf := make([]byte, 1500) - n, _, err2 := clientConn.ReadFromUDP(buf) - if err2 != nil { - return - } - data := buf[0:n] - clientReceivedPackets = append(clientReceivedPackets, packetData(data)) - } - }() - - time.Sleep(time.Millisecond) - Expect(serverReceivedPackets).To(HaveLen(2)) - Expect(serverNumPacketsSent).To(Equal(2)) - Expect(clientReceivedPackets).To(HaveLen(2)) - Expect(clientReceivedPackets[0]).To(Equal(packetData("foobar"))) - Expect(clientReceivedPackets[1]).To(Equal(packetData("decafbad"))) - }) - }) - - Context("Drop Callbacks", func() { - It("drops incoming packets", func() { - dropper := func(p PacketNumber) bool { - return p%2 == 0 - } - - var err error - proxy, err = NewUDPProxy(10001, "localhost", serverPort, dropper, nil) - Expect(err).ToNot(HaveOccurred()) - - for i := 1; i <= 6; i++ { - _, err := clientConn.Write([]byte("foobar" + strconv.Itoa(i))) - Expect(err).ToNot(HaveOccurred()) - time.Sleep(time.Millisecond) - } - Expect(serverReceivedPackets).To(HaveLen(3)) - Expect(serverReceivedPackets[0]).To(Equal(packetData("foobar1"))) - Expect(serverReceivedPackets[1]).To(Equal(packetData("foobar3"))) - Expect(serverReceivedPackets[2]).To(Equal(packetData("foobar5"))) - }) - - It("drops outgoing packets", func() { - dropper := func(p PacketNumber) bool { - return p%2 == 0 - } - - var err error - proxy, err = NewUDPProxy(10001, "localhost", serverPort, nil, dropper) - Expect(err).ToNot(HaveOccurred()) - - for i := 1; i <= 6; i++ { - _, err := clientConn.Write([]byte("foobar" + strconv.Itoa(i))) - Expect(err).ToNot(HaveOccurred()) - time.Sleep(time.Millisecond) - } - - var clientReceivedPackets []packetData - - // receive the packets echoed by the server on client side - go func() { - defer GinkgoRecover() - - for { - buf := make([]byte, 1500) - n, _, err2 := clientConn.ReadFromUDP(buf) - if err2 != nil { - return - } - data := buf[0:n] - clientReceivedPackets = append(clientReceivedPackets, packetData(data)) - } - }() - - time.Sleep(time.Millisecond) - Expect(clientReceivedPackets).To(HaveLen(3)) - Expect(clientReceivedPackets[0]).To(Equal(packetData("foobar1"))) - Expect(clientReceivedPackets[1]).To(Equal(packetData("foobar3"))) - Expect(clientReceivedPackets[2]).To(Equal(packetData("foobar5"))) - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/packet_packer.go b/vendor/github.com/lucas-clemente/quic-go/packet_packer.go deleted file mode 100644 index f521889..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/packet_packer.go +++ /dev/null @@ -1,258 +0,0 @@ -package quic - -import ( - "bytes" - "errors" - "sync/atomic" - - "github.com/lucas-clemente/quic-go/ackhandler" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" -) - -type packedPacket struct { - number protocol.PacketNumber - entropyBit bool - raw []byte - frames []frames.Frame -} - -type packetPacker struct { - connectionID protocol.ConnectionID - version protocol.VersionNumber - cryptoSetup *handshake.CryptoSetup - - sentPacketHandler ackhandler.SentPacketHandler - connectionParametersManager *handshake.ConnectionParametersManager - - streamFrameQueue *streamFrameQueue - controlFrames []frames.Frame - blockedManager *blockedManager - - lastPacketNumber protocol.PacketNumber -} - -func newPacketPacker(connectionID protocol.ConnectionID, cryptoSetup *handshake.CryptoSetup, sentPacketHandler ackhandler.SentPacketHandler, connectionParametersHandler *handshake.ConnectionParametersManager, blockedManager *blockedManager, streamFrameQueue *streamFrameQueue, version protocol.VersionNumber) *packetPacker { - return &packetPacker{ - cryptoSetup: cryptoSetup, - connectionID: connectionID, - connectionParametersManager: connectionParametersHandler, - version: version, - sentPacketHandler: sentPacketHandler, - blockedManager: blockedManager, - streamFrameQueue: streamFrameQueue, - } -} - -func (p *packetPacker) AddStreamFrame(f frames.StreamFrame) { - p.streamFrameQueue.Push(&f, false) -} - -func (p *packetPacker) AddHighPrioStreamFrame(f frames.StreamFrame) { - p.streamFrameQueue.Push(&f, true) -} - -func (p *packetPacker) AddBlocked(streamID protocol.StreamID, byteOffset protocol.ByteCount) { - return - // TODO: send out connection-level BlockedFrames at the right time - // see https://github.com/lucas-clemente/quic-go/issues/113 - // TODO: remove this function completely once #113 is resolved - if streamID == 0 { - p.controlFrames = append(p.controlFrames, &frames.BlockedFrame{StreamID: 0}) - } - - p.blockedManager.AddBlockedStream(streamID, byteOffset) -} - -func (p *packetPacker) PackConnectionClose(frame *frames.ConnectionCloseFrame) (*packedPacket, error) { - return p.packPacket(nil, []frames.Frame{frame}, true) -} - -func (p *packetPacker) PackPacket(stopWaitingFrame *frames.StopWaitingFrame, controlFrames []frames.Frame) (*packedPacket, error) { - return p.packPacket(stopWaitingFrame, controlFrames, false) -} - -func (p *packetPacker) packPacket(stopWaitingFrame *frames.StopWaitingFrame, controlFrames []frames.Frame, onlySendOneControlFrame bool) (*packedPacket, error) { - // don't send out packets that only contain a StopWaitingFrame - if len(p.controlFrames) == 0 && len(controlFrames) == 0 && p.streamFrameQueue.Len() == 0 { - return nil, nil - } - - if len(controlFrames) > 0 { - p.controlFrames = append(p.controlFrames, controlFrames...) - } - - currentPacketNumber := protocol.PacketNumber(atomic.AddUint64( - (*uint64)(&p.lastPacketNumber), - 1, - )) - - // cryptoSetup needs to be locked here, so that the AEADs are not changed between - // calling DiversificationNonce() and Seal(). - p.cryptoSetup.LockForSealing() - defer p.cryptoSetup.UnlockForSealing() - - packetNumberLen := protocol.GetPacketNumberLengthForPublicHeader(currentPacketNumber, p.sentPacketHandler.GetLargestObserved()) - responsePublicHeader := &publicHeader{ - ConnectionID: p.connectionID, - PacketNumber: currentPacketNumber, - PacketNumberLen: packetNumberLen, - TruncateConnectionID: p.connectionParametersManager.TruncateConnectionID(), - DiversificationNonce: p.cryptoSetup.DiversificationNonce(), - } - - publicHeaderLength, err := responsePublicHeader.GetLength() - if err != nil { - return nil, err - } - - if stopWaitingFrame != nil { - stopWaitingFrame.PacketNumber = currentPacketNumber - stopWaitingFrame.PacketNumberLen = packetNumberLen - } - - var payloadFrames []frames.Frame - if onlySendOneControlFrame { - payloadFrames = []frames.Frame{controlFrames[0]} - } else { - payloadFrames, err = p.composeNextPacket(stopWaitingFrame, publicHeaderLength) - if err != nil { - return nil, err - } - } - - payload, err := p.getPayload(payloadFrames, currentPacketNumber) - if err != nil { - return nil, err - } - - // set entropy bit in Private Header, for QUIC version < 34 - var entropyBit bool - if p.version < protocol.Version34 { - entropyBit, err = utils.RandomBit() - if err != nil { - return nil, err - } - if entropyBit { - payload[0] = 1 - } - } - - var raw bytes.Buffer - if err := responsePublicHeader.WritePublicHeader(&raw, p.version); err != nil { - return nil, err - } - - ciphertext := p.cryptoSetup.Seal(currentPacketNumber, raw.Bytes(), payload) - raw.Write(ciphertext) - - if protocol.ByteCount(raw.Len()) > protocol.MaxPacketSize { - return nil, errors.New("PacketPacker BUG: packet too large") - } - - return &packedPacket{ - number: currentPacketNumber, - entropyBit: entropyBit, - raw: raw.Bytes(), - frames: payloadFrames, - }, nil -} - -func (p *packetPacker) getPayload(frames []frames.Frame, currentPacketNumber protocol.PacketNumber) ([]byte, error) { - var payload bytes.Buffer - - // reserve 1 byte for the Private Header, for QUIC Version < 34 - // the entropy bit is set in sendPayload - if p.version < protocol.Version34 { - payload.WriteByte(0) - } - - for _, frame := range frames { - frame.Write(&payload, p.version) - } - return payload.Bytes(), nil -} - -func (p *packetPacker) composeNextPacket(stopWaitingFrame *frames.StopWaitingFrame, publicHeaderLength protocol.ByteCount) ([]frames.Frame, error) { - var payloadLength protocol.ByteCount - var payloadFrames []frames.Frame - - maxFrameSize := protocol.MaxFrameAndPublicHeaderSize - publicHeaderLength - - if stopWaitingFrame != nil { - payloadFrames = append(payloadFrames, stopWaitingFrame) - minLength, err := stopWaitingFrame.MinLength() - if err != nil { - return nil, err - } - payloadLength += minLength - } - - for len(p.controlFrames) > 0 { - frame := p.controlFrames[0] - minLength, _ := frame.MinLength() // controlFrames does not contain any StopWaitingFrames. So it will *never* return an error - if payloadLength+minLength > maxFrameSize { - break - } - payloadFrames = append(payloadFrames, frame) - payloadLength += minLength - p.controlFrames = p.controlFrames[1:] - } - - if payloadLength > maxFrameSize { - return nil, errors.New("PacketPacker BUG: packet payload too large") - } - - hasStreamFrames := false - - // temporarily increase the maxFrameSize by 2 bytes - // this leads to a properly sized packet in all cases, since we do all the packet length calculations with StreamFrames that have the DataLen set - // however, for the last StreamFrame in the packet, we can omit the DataLen, thus saving 2 bytes and yielding a packet of exactly the correct size - maxFrameSize += 2 - - for p.streamFrameQueue.Len() > 0 { - if payloadLength > maxFrameSize { - return nil, errors.New("PacketPacker BUG: packet payload too large") - } - - frame, err := p.streamFrameQueue.Pop(maxFrameSize - payloadLength) - if err != nil { - return nil, err - } - if frame == nil { - break - } - frame.DataLenPresent = true // set the dataLen by default. Remove them later if applicable - - frameMinLength, _ := frame.MinLength() // StreamFrame.MinLength *never* returns an error - payloadLength += frameMinLength - 1 + frame.DataLen() - - blockedFrame := p.blockedManager.GetBlockedFrame(frame.StreamID, frame.Offset+frame.DataLen()) - if blockedFrame != nil { - blockedLength, _ := blockedFrame.MinLength() // BlockedFrame.MinLength *never* returns an error - if payloadLength+blockedLength <= maxFrameSize { - payloadFrames = append(payloadFrames, blockedFrame) - payloadLength += blockedLength - } else { - p.controlFrames = append(p.controlFrames, blockedFrame) - } - } - - payloadFrames = append(payloadFrames, frame) - hasStreamFrames = true - } - - // remove the dataLen for the last StreamFrame in the packet - if hasStreamFrames { - lastStreamFrame, ok := payloadFrames[len(payloadFrames)-1].(*frames.StreamFrame) - if !ok { - return nil, errors.New("PacketPacker BUG: StreamFrame type assertion failed") - } - lastStreamFrame.DataLenPresent = false - // payloadLength -= 2 - } - - return payloadFrames, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/packet_packer_test.go b/vendor/github.com/lucas-clemente/quic-go/packet_packer_test.go deleted file mode 100644 index f1e9e83..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/packet_packer_test.go +++ /dev/null @@ -1,480 +0,0 @@ -package quic - -import ( - "bytes" - "time" - - "github.com/lucas-clemente/quic-go/ackhandler" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type mockSentPacketHandler struct { - retransmissionQueue []*ackhandler.Packet -} - -func (h *mockSentPacketHandler) SentPacket(packet *ackhandler.Packet) error { return nil } -func (h *mockSentPacketHandler) ReceivedAck(ackFrame *frames.AckFrame) error { return nil } -func (h *mockSentPacketHandler) BytesInFlight() protocol.ByteCount { return 0 } -func (h *mockSentPacketHandler) GetLargestObserved() protocol.PacketNumber { return 1 } -func (h *mockSentPacketHandler) CongestionAllowsSending() bool { return true } -func (h *mockSentPacketHandler) CheckForError() error { return nil } -func (h *mockSentPacketHandler) TimeOfFirstRTO() time.Time { panic("not implemented") } - -func (h *mockSentPacketHandler) ProbablyHasPacketForRetransmission() bool { - return len(h.retransmissionQueue) > 0 -} - -func (h *mockSentPacketHandler) DequeuePacketForRetransmission() *ackhandler.Packet { - if len(h.retransmissionQueue) > 0 { - packet := h.retransmissionQueue[0] - h.retransmissionQueue = h.retransmissionQueue[1:] - return packet - } - return nil -} - -func newMockSentPacketHandler() ackhandler.SentPacketHandler { - return &mockSentPacketHandler{} -} - -var _ = Describe("Packet packer", func() { - var ( - packer *packetPacker - publicHeaderLen protocol.ByteCount - ) - - BeforeEach(func() { - packer = &packetPacker{ - cryptoSetup: &handshake.CryptoSetup{}, - connectionParametersManager: handshake.NewConnectionParamatersManager(), - sentPacketHandler: newMockSentPacketHandler(), - blockedManager: newBlockedManager(), - streamFrameQueue: newStreamFrameQueue(), - } - publicHeaderLen = 1 + 8 + 1 // 1 flag byte, 8 connection ID, 1 packet number - }) - - AfterEach(func() { - packer.lastPacketNumber = 0 - }) - - It("returns nil when no packet is queued", func() { - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(p).To(BeNil()) - Expect(err).ToNot(HaveOccurred()) - }) - - It("doesn't set a private header for QUIC version >= 34", func() { - // This is not trivial to test, since PackPacket() already encrypts the packet - // So pack the packet for QUIC 33, then for QUIC 34. The packet for QUIC 33 should be 1 byte longer, since it contains the Private Header - f := frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar"), - } - // pack the packet for QUIC version 33 - packer.version = protocol.Version33 - packer.AddStreamFrame(f) - p33, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p33).ToNot(BeNil()) - // pack the packet for QUIC version 34 - packer.version = protocol.Version34 - packer.AddStreamFrame(f) - p34, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p34).ToNot(BeNil()) - Expect(p34.entropyBit).To(BeFalse()) - Expect(p34.raw).To(HaveLen(len(p33.raw) - 1)) - }) - - It("packs single packets", func() { - f := frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xDE, 0xCA, 0xFB, 0xAD}, - } - packer.AddStreamFrame(f) - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p).ToNot(BeNil()) - b := &bytes.Buffer{} - f.Write(b, 0) - Expect(p.frames).To(HaveLen(1)) - Expect(p.raw).To(ContainSubstring(string(b.Bytes()))) - }) - - It("packs a ConnectionCloseFrame", func() { - ccf := frames.ConnectionCloseFrame{ - ErrorCode: 0x1337, - ReasonPhrase: "foobar", - } - p, err := packer.PackConnectionClose(&ccf) - Expect(err).ToNot(HaveOccurred()) - Expect(p.frames).To(HaveLen(1)) - Expect(p.frames[0]).To(Equal(&ccf)) - }) - - It("ignores all other frames when called with onlySendOneControlFrame=true", func() { - ccf := frames.ConnectionCloseFrame{ - ErrorCode: 0x1337, - ReasonPhrase: "foobar", - } - p, err := packer.packPacket(&frames.StopWaitingFrame{LeastUnacked: 13}, []frames.Frame{&ccf, &frames.WindowUpdateFrame{StreamID: 37}}, true) - Expect(err).ToNot(HaveOccurred()) - Expect(p.frames).To(HaveLen(1)) - Expect(p.frames[0]).To(Equal(&ccf)) - }) - - It("packs only control frames", func() { - p, err := packer.PackPacket(nil, []frames.Frame{&frames.ConnectionCloseFrame{}}) - Expect(p).ToNot(BeNil()) - Expect(err).ToNot(HaveOccurred()) - Expect(p.frames).To(HaveLen(1)) - Expect(p.raw).NotTo(BeEmpty()) - }) - - It("packs a StopWaitingFrame first", func() { - swf := &frames.StopWaitingFrame{LeastUnacked: 10} - p, err := packer.PackPacket(swf, []frames.Frame{&frames.ConnectionCloseFrame{}}) - Expect(err).ToNot(HaveOccurred()) - Expect(p).ToNot(BeNil()) - Expect(p.frames).To(HaveLen(2)) - Expect(p.frames[0]).To(Equal(swf)) - }) - - It("sets the LeastUnackedDelta length of a StopWaitingFrame", func() { - packetNumber := protocol.PacketNumber(0xDECAFB) // will result in a 4 byte packet number - packer.lastPacketNumber = packetNumber - 1 - swf := &frames.StopWaitingFrame{LeastUnacked: packetNumber - 0x100} - p, err := packer.PackPacket(swf, []frames.Frame{&frames.ConnectionCloseFrame{}}) - Expect(err).ToNot(HaveOccurred()) - Expect(p.frames[0].(*frames.StopWaitingFrame).PacketNumberLen).To(Equal(protocol.PacketNumberLen4)) - }) - - It("does not pack a packet containing only a StopWaitingFrame", func() { - swf := &frames.StopWaitingFrame{LeastUnacked: 10} - p, err := packer.PackPacket(swf, []frames.Frame{}) - Expect(p).To(BeNil()) - Expect(err).ToNot(HaveOccurred()) - }) - - It("packs a packet if it has queued control frames, but no new control frames", func() { - packer.controlFrames = []frames.Frame{&frames.BlockedFrame{StreamID: 0}} - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p).ToNot(BeNil()) - }) - - It("packs many control frames into 1 packets", func() { - f := &frames.AckFrame{LargestObserved: 1} - b := &bytes.Buffer{} - f.Write(b, protocol.Version32) - maxFramesPerPacket := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) / b.Len() - var controlFrames []frames.Frame - for i := 0; i < maxFramesPerPacket; i++ { - controlFrames = append(controlFrames, f) - } - packer.controlFrames = controlFrames - payloadFrames, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(maxFramesPerPacket)) - payloadFrames, err = packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(BeEmpty()) - }) - - It("packs a lot of control frames into 2 packets if they don't fit into one", func() { - blockedFrame := &frames.BlockedFrame{ - StreamID: 0x1337, - } - minLength, _ := blockedFrame.MinLength() - maxFramesPerPacket := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) / int(minLength) - var controlFrames []frames.Frame - for i := 0; i < maxFramesPerPacket+10; i++ { - controlFrames = append(controlFrames, blockedFrame) - } - packer.controlFrames = controlFrames - payloadFrames, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(maxFramesPerPacket)) - payloadFrames, err = packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(10)) - }) - - It("only increases the packet number when there is an actual packet to send", func() { - f := frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xDE, 0xCA, 0xFB, 0xAD}, - } - packer.AddStreamFrame(f) - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(p).ToNot(BeNil()) - Expect(err).ToNot(HaveOccurred()) - Expect(packer.lastPacketNumber).To(Equal(protocol.PacketNumber(1))) - p, err = packer.PackPacket(nil, []frames.Frame{}) - Expect(p).To(BeNil()) - Expect(err).ToNot(HaveOccurred()) - Expect(packer.lastPacketNumber).To(Equal(protocol.PacketNumber(1))) - packer.AddStreamFrame(f) - p, err = packer.PackPacket(nil, []frames.Frame{}) - Expect(p).ToNot(BeNil()) - Expect(err).ToNot(HaveOccurred()) - Expect(packer.lastPacketNumber).To(Equal(protocol.PacketNumber(2))) - }) - - Context("Stream Frame handling", func() { - It("does not splits a stream frame with maximum size", func() { - f := frames.StreamFrame{ - Offset: 1, - StreamID: 13, - DataLenPresent: false, - } - minLength, _ := f.MinLength() - maxStreamFrameDataLen := protocol.MaxFrameAndPublicHeaderSize - publicHeaderLen - minLength - f.Data = bytes.Repeat([]byte{'f'}, int(maxStreamFrameDataLen)) - packer.AddStreamFrame(f) - payloadFrames, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(1)) - Expect(payloadFrames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - payloadFrames, err = packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(BeEmpty()) - }) - - It("correctly handles a stream frame with one byte less than maximum size", func() { - maxStreamFrameDataLen := protocol.MaxFrameAndPublicHeaderSize - publicHeaderLen - (1 + 1 + 2) - 1 - f1 := frames.StreamFrame{ - StreamID: 5, - Offset: 1, - Data: bytes.Repeat([]byte{'f'}, int(maxStreamFrameDataLen)), - } - f2 := frames.StreamFrame{ - StreamID: 5, - Offset: 1, - Data: []byte("foobar"), - } - packer.AddStreamFrame(f1) - packer.AddStreamFrame(f2) - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p.raw).To(HaveLen(int(protocol.MaxPacketSize - 1))) - Expect(p.frames).To(HaveLen(1)) - Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - p, err = packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - }) - - It("packs multiple small stream frames into single packet", func() { - f1 := frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xDE, 0xCA, 0xFB, 0xAD}, - } - f2 := frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xBE, 0xEF, 0x13, 0x37}, - } - f3 := frames.StreamFrame{ - StreamID: 3, - Data: []byte{0xCA, 0xFE}, - } - packer.AddStreamFrame(f1) - packer.AddStreamFrame(f2) - packer.AddStreamFrame(f3) - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(p).ToNot(BeNil()) - Expect(err).ToNot(HaveOccurred()) - b := &bytes.Buffer{} - f1.Write(b, 0) - f2.Write(b, 0) - f3.Write(b, 0) - Expect(p.frames).To(HaveLen(3)) - Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeTrue()) - Expect(p.frames[1].(*frames.StreamFrame).DataLenPresent).To(BeTrue()) - Expect(p.frames[2].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - Expect(p.raw).To(ContainSubstring(string(f1.Data))) - Expect(p.raw).To(ContainSubstring(string(f2.Data))) - Expect(p.raw).To(ContainSubstring(string(f3.Data))) - }) - - It("splits one stream frame larger than maximum size", func() { - f := frames.StreamFrame{ - StreamID: 7, - Offset: 1, - } - minLength, _ := f.MinLength() - maxStreamFrameDataLen := protocol.MaxFrameAndPublicHeaderSize - publicHeaderLen - minLength + 1 // + 1 since MinceLength is 1 bigger than the actual StreamFrame header - f.Data = bytes.Repeat([]byte{'f'}, int(maxStreamFrameDataLen)+200) - packer.AddStreamFrame(f) - payloadFrames, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(1)) - Expect(payloadFrames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - Expect(payloadFrames[0].(*frames.StreamFrame).Data).To(HaveLen(int(maxStreamFrameDataLen))) - payloadFrames, err = packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(1)) - Expect(payloadFrames[0].(*frames.StreamFrame).Data).To(HaveLen(200)) - Expect(payloadFrames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - payloadFrames, err = packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(BeEmpty()) - }) - - It("packs 2 stream frames that are too big for one packet correctly", func() { - maxStreamFrameDataLen := protocol.MaxFrameAndPublicHeaderSize - publicHeaderLen - (1 + 1 + 2) - f1 := frames.StreamFrame{ - StreamID: 5, - Data: bytes.Repeat([]byte{'f'}, int(maxStreamFrameDataLen)+100), - Offset: 1, - } - f2 := frames.StreamFrame{ - StreamID: 5, - Data: bytes.Repeat([]byte{'f'}, int(maxStreamFrameDataLen)+100), - Offset: 1, - } - packer.AddStreamFrame(f1) - packer.AddStreamFrame(f2) - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p.frames).To(HaveLen(1)) - Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - Expect(p.raw).To(HaveLen(int(protocol.MaxPacketSize))) - p, err = packer.PackPacket(nil, []frames.Frame{}) - Expect(p.frames).To(HaveLen(2)) - Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeTrue()) - Expect(p.frames[1].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - Expect(err).ToNot(HaveOccurred()) - Expect(p.raw).To(HaveLen(int(protocol.MaxPacketSize))) - p, err = packer.PackPacket(nil, []frames.Frame{}) - Expect(p.frames).To(HaveLen(1)) - Expect(p.frames[0].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - Expect(err).ToNot(HaveOccurred()) - Expect(p).ToNot(BeNil()) - p, err = packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(BeNil()) - }) - - It("packs a packet that has the maximum packet size when given a large enough stream frame", func() { - f := frames.StreamFrame{ - StreamID: 5, - Offset: 1, - } - minLength, _ := f.MinLength() - f.Data = bytes.Repeat([]byte{'f'}, int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen-minLength+1)) // + 1 since MinceLength is 1 bigger than the actual StreamFrame header - packer.AddStreamFrame(f) - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p).ToNot(BeNil()) - Expect(p.raw).To(HaveLen(int(protocol.MaxPacketSize))) - }) - - It("splits a stream frame larger than the maximum size", func() { - f := frames.StreamFrame{ - StreamID: 5, - Offset: 1, - } - minLength, _ := f.MinLength() - f.Data = bytes.Repeat([]byte{'f'}, int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen-minLength+2)) // + 2 since MinceLength is 1 bigger than the actual StreamFrame header - - packer.AddStreamFrame(f) - payloadFrames, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(1)) - payloadFrames, err = packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(payloadFrames).To(HaveLen(1)) - }) - }) - - PContext("Blocked frames", func() { - It("adds a blocked frame to a packet if there is enough space", func() { - length := 100 - packer.AddBlocked(5, protocol.ByteCount(length)) - f := frames.StreamFrame{ - StreamID: 5, - Data: bytes.Repeat([]byte{'f'}, length), - } - packer.AddStreamFrame(f) - p, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(HaveLen(2)) - Expect(p[0]).To(Equal(&frames.BlockedFrame{StreamID: 5})) - }) - - It("removes the dataLen attribute from the last StreamFrame, even if it inserted a BlockedFrame before", func() { - length := 100 - packer.AddBlocked(5, protocol.ByteCount(length)) - f := frames.StreamFrame{ - StreamID: 5, - Data: bytes.Repeat([]byte{'f'}, length), - } - packer.AddStreamFrame(f) - p, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(HaveLen(2)) - Expect(p[1].(*frames.StreamFrame).DataLenPresent).To(BeFalse()) - }) - - It("packs a BlockedFrame in the next packet if the current packet doesn't have enough space", func() { - dataLen := int(protocol.MaxFrameAndPublicHeaderSize-publicHeaderLen) - (1 + 1 + 2) + 1 - packer.AddBlocked(5, protocol.ByteCount(dataLen)) - f := frames.StreamFrame{ - StreamID: 5, - Data: bytes.Repeat([]byte{'f'}, dataLen), - } - packer.AddStreamFrame(f) - p, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(HaveLen(1)) - p, err = packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(HaveLen(1)) - Expect(p[0]).To(Equal(&frames.BlockedFrame{StreamID: 5})) - }) - - It("packs a packet with the maximum size with a BlocedFrame", func() { - blockedFrame := &frames.BlockedFrame{StreamID: 0x1337} - blockedFrameLen, _ := blockedFrame.MinLength() - f1 := frames.StreamFrame{ - StreamID: 5, - Offset: 1, - } - streamFrameHeaderLen, _ := f1.MinLength() - streamFrameHeaderLen-- // - 1 since MinceLength is 1 bigger than the actual StreamFrame header - // this is the maximum dataLen of a StreamFrames that fits into one packet - dataLen := int(protocol.MaxFrameAndPublicHeaderSize - publicHeaderLen - streamFrameHeaderLen - blockedFrameLen) - packer.AddBlocked(5, protocol.ByteCount(dataLen)) - f1.Data = bytes.Repeat([]byte{'f'}, dataLen) - packer.AddStreamFrame(f1) - p, err := packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p).ToNot(BeNil()) - Expect(p.raw).To(HaveLen(int(protocol.MaxPacketSize))) - p, err = packer.PackPacket(nil, []frames.Frame{}) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(BeNil()) - }) - - // TODO: fix this once connection-level BlockedFrames are sent out at the right time - // see https://github.com/lucas-clemente/quic-go/issues/113 - It("packs a connection-level BlockedFrame", func() { - packer.AddBlocked(0, 0x1337) - f := frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar"), - } - packer.AddStreamFrame(f) - p, err := packer.composeNextPacket(nil, publicHeaderLen) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(HaveLen(2)) - Expect(p[0]).To(Equal(&frames.BlockedFrame{StreamID: 0})) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/packet_unpacker.go b/vendor/github.com/lucas-clemente/quic-go/packet_unpacker.go deleted file mode 100644 index 9b91350..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/packet_unpacker.go +++ /dev/null @@ -1,123 +0,0 @@ -package quic - -import ( - "bytes" - "errors" - "fmt" - "io/ioutil" - - "github.com/lucas-clemente/quic-go/crypto" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" -) - -type unpackedPacket struct { - entropyBit bool - frames []frames.Frame -} - -type packetUnpacker struct { - version protocol.VersionNumber - aead crypto.AEAD -} - -func (u *packetUnpacker) Unpack(publicHeaderBinary []byte, hdr *publicHeader, r *bytes.Reader) (*unpackedPacket, error) { - ciphertext, _ := ioutil.ReadAll(r) - plaintext, err := u.aead.Open(hdr.PacketNumber, publicHeaderBinary, ciphertext) - if err != nil { - // Wrap err in quicError so that public reset is sent by session - return nil, qerr.Error(qerr.DecryptionFailure, err.Error()) - } - r = bytes.NewReader(plaintext) - - // read private flag byte, for QUIC Version < 34 - var entropyBit bool - if u.version < protocol.Version34 { - var privateFlag uint8 - privateFlag, err = r.ReadByte() - if err != nil { - return nil, qerr.MissingPayload - } - entropyBit = privateFlag&0x01 > 0 - } - - if r.Len() == 0 { - return nil, qerr.MissingPayload - } - - fs := make([]frames.Frame, 0, 1) - - // Read all frames in the packet -ReadLoop: - for r.Len() > 0 { - typeByte, _ := r.ReadByte() - r.UnreadByte() - - var frame frames.Frame - if typeByte&0x80 == 0x80 { - frame, err = frames.ParseStreamFrame(r) - if err != nil { - err = qerr.Error(qerr.InvalidStreamData, err.Error()) - } - } else if typeByte&0xc0 == 0x40 { - frame, err = frames.ParseAckFrame(r, u.version) - if err != nil { - err = qerr.Error(qerr.InvalidAckData, err.Error()) - } - } else if typeByte&0xe0 == 0x20 { - err = errors.New("unimplemented: CONGESTION_FEEDBACK") - } else { - switch typeByte { - case 0x0: // PAD, end of frames - break ReadLoop - case 0x01: - frame, err = frames.ParseRstStreamFrame(r) - if err != nil { - err = qerr.Error(qerr.InvalidRstStreamData, err.Error()) - } - case 0x02: - frame, err = frames.ParseConnectionCloseFrame(r) - if err != nil { - err = qerr.Error(qerr.InvalidConnectionCloseData, err.Error()) - } - case 0x03: - frame, err = frames.ParseGoawayFrame(r) - if err != nil { - err = qerr.Error(qerr.InvalidGoawayData, err.Error()) - } - case 0x04: - frame, err = frames.ParseWindowUpdateFrame(r) - if err != nil { - err = qerr.Error(qerr.InvalidWindowUpdateData, err.Error()) - } - case 0x05: - frame, err = frames.ParseBlockedFrame(r) - if err != nil { - err = qerr.Error(qerr.InvalidBlockedData, err.Error()) - } - case 0x06: - frame, err = frames.ParseStopWaitingFrame(r, hdr.PacketNumber, hdr.PacketNumberLen) - if err != nil { - err = qerr.Error(qerr.InvalidStopWaitingData, err.Error()) - } - case 0x07: - frame, err = frames.ParsePingFrame(r) - default: - err = qerr.Error(qerr.InvalidFrameData, fmt.Sprintf("unknown type byte 0x%x", typeByte)) - } - } - if err != nil { - return nil, err - } - // TODO: Remove once all frames are implemented - if frame != nil { - fs = append(fs, frame) - } - } - - return &unpackedPacket{ - entropyBit: entropyBit, - frames: fs, - }, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/packet_unpacker_test.go b/vendor/github.com/lucas-clemente/quic-go/packet_unpacker_test.go deleted file mode 100644 index c73669c..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/packet_unpacker_test.go +++ /dev/null @@ -1,203 +0,0 @@ -package quic - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/crypto" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Packet unpacker", func() { - var ( - unpacker *packetUnpacker - hdr *publicHeader - hdrBin []byte - aead crypto.AEAD - r *bytes.Reader - buf *bytes.Buffer - ) - - BeforeEach(func() { - aead = &crypto.NullAEAD{} - hdr = &publicHeader{ - PacketNumber: 10, - PacketNumberLen: 1, - } - hdrBin = []byte{0x04, 0x4c, 0x01} - unpacker = &packetUnpacker{aead: aead} - r = nil - buf = &bytes.Buffer{} - }) - - setReader := func(data []byte) { - if unpacker.version < protocol.Version34 { // add private flag - data = append([]byte{0x01}, data...) - } - r = bytes.NewReader(aead.Seal(0, hdrBin, data)) - } - - It("returns an error for empty packets that don't have a private flag, for QUIC Version < 34", func() { - // don't use setReader here, since it adds a private flag - unpacker.version = protocol.Version33 - r = bytes.NewReader(aead.Seal(0, hdrBin, []byte{})) - _, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).To(MatchError(qerr.MissingPayload)) - }) - - It("returns an error for empty packets that have a private flag, for QUIC Version < 34", func() { - unpacker.version = protocol.Version33 - setReader(nil) - _, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).To(MatchError(qerr.MissingPayload)) - }) - - It("does not read read a private flag for QUIC Version >= 34", func() { - unpacker.version = protocol.Version34 - f := &frames.ConnectionCloseFrame{ReasonPhrase: "foo"} - err := f.Write(buf, 0) - Expect(err).ToNot(HaveOccurred()) - setReader(buf.Bytes()) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{f})) - }) - - It("unpacks stream frames", func() { - f := &frames.StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - } - err := f.Write(buf, 0) - Expect(err).ToNot(HaveOccurred()) - setReader(buf.Bytes()) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{f})) - }) - - It("unpacks ack frames", func() { - f := &frames.AckFrame{ - LargestObserved: 0x13, - Entropy: 0x37, - } - err := f.Write(buf, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - setReader(buf.Bytes()) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(HaveLen(1)) - readFrame := packet.frames[0].(*frames.AckFrame) - Expect(readFrame.LargestObserved).To(Equal(protocol.PacketNumber(0x13))) - Expect(readFrame.Entropy).To(Equal(byte(0x37))) - }) - - It("errors on CONGESTION_FEEDBACK frames", func() { - setReader([]byte{0x20}) - _, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).To(MatchError("unimplemented: CONGESTION_FEEDBACK")) - }) - - It("handles pad frames", func() { - setReader([]byte{0, 0, 0}) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(BeEmpty()) - }) - - It("unpacks RST_STREAM frames", func() { - setReader([]byte{0x01, 0xEF, 0xBE, 0xAD, 0xDE, 0x44, 0x33, 0x22, 0x11, 0xAD, 0xFB, 0xCA, 0xDE, 0x34, 0x12, 0x37, 0x13}) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{ - &frames.RstStreamFrame{ - StreamID: 0xDEADBEEF, - ByteOffset: 0xDECAFBAD11223344, - ErrorCode: 0x13371234, - }, - })) - }) - - It("unpacks CONNECTION_CLOSE frames", func() { - f := &frames.ConnectionCloseFrame{ReasonPhrase: "foo"} - err := f.Write(buf, 0) - Expect(err).ToNot(HaveOccurred()) - setReader(buf.Bytes()) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{f})) - }) - - It("accepts GOAWAY frames", func() { - setReader([]byte{ - 0x03, - 0x01, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, - 0x03, 0x00, - 'f', 'o', 'o', - }) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{ - &frames.GoawayFrame{ - ErrorCode: 1, - LastGoodStream: 2, - ReasonPhrase: "foo", - }, - })) - }) - - It("accepts WINDOW_UPDATE frames", func() { - setReader([]byte{0x04, 0xEF, 0xBE, 0xAD, 0xDE, 0x37, 0x13, 0, 0, 0, 0, 0xFE, 0xCA}) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{ - &frames.WindowUpdateFrame{ - StreamID: 0xDEADBEEF, - ByteOffset: 0xCAFE000000001337, - }, - })) - }) - - It("accepts BLOCKED frames", func() { - setReader([]byte{0x05, 0xEF, 0xBE, 0xAD, 0xDE}) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{ - &frames.BlockedFrame{ - StreamID: 0xDEADBEEF, - }, - })) - }) - - It("unpacks STOP_WAITING frames", func() { - setReader([]byte{0x06, 0xA4, 0x03}) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{ - &frames.StopWaitingFrame{ - Entropy: 0xA4, - LeastUnacked: 7, - }, - })) - }) - - It("accepts PING frames", func() { - setReader([]byte{0x07}) - packet, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).ToNot(HaveOccurred()) - Expect(packet.frames).To(Equal([]frames.Frame{ - &frames.PingFrame{}, - })) - }) - - It("errors on invalid type", func() { - setReader([]byte{0x08}) - _, err := unpacker.Unpack(hdrBin, hdr, r) - Expect(err).To(MatchError("InvalidFrameData: unknown type byte 0x8")) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/protocol/packet_number.go b/vendor/github.com/lucas-clemente/quic-go/protocol/packet_number.go deleted file mode 100644 index fb9e558..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/protocol/packet_number.go +++ /dev/null @@ -1,58 +0,0 @@ -package protocol - -// InferPacketNumber calculates the packet number based on the received packet number, its length and the last seen packet number -func InferPacketNumber(packetNumberLength PacketNumberLen, lastPacketNumber PacketNumber, wirePacketNumber PacketNumber) PacketNumber { - epochDelta := PacketNumber(1) << (uint8(packetNumberLength) * 8) - epoch := lastPacketNumber & ^(epochDelta - 1) - prevEpochBegin := epoch - epochDelta - nextEpochBegin := epoch + epochDelta - return closestTo( - lastPacketNumber+1, - epoch+wirePacketNumber, - closestTo(lastPacketNumber+1, prevEpochBegin+wirePacketNumber, nextEpochBegin+wirePacketNumber), - ) -} - -func closestTo(target, a, b PacketNumber) PacketNumber { - if delta(target, a) < delta(target, b) { - return a - } - return b -} - -func delta(a, b PacketNumber) PacketNumber { - if a < b { - return b - a - } - return a - b -} - -// GetPacketNumberLengthForPublicHeader gets the length of the packet number for the public header -func GetPacketNumberLengthForPublicHeader(packetNumber PacketNumber, highestAckedPacketNumber PacketNumber) PacketNumberLen { - diff := uint64(packetNumber - highestAckedPacketNumber) - if diff < (2 << (uint8(PacketNumberLen1)*8 - 2)) { - return PacketNumberLen1 - } - if diff < (2 << (uint8(PacketNumberLen2)*8 - 2)) { - return PacketNumberLen2 - } - if diff < (2 << (uint8(PacketNumberLen4)*8 - 2)) { - return PacketNumberLen4 - } - // we do not check if there are less than 2^46 packets in flight, since flow control and congestion control will limit this number *a lot* sooner - return PacketNumberLen6 -} - -// GetPacketNumberLength gets the minimum length needed to fully represent the packet number -func GetPacketNumberLength(packetNumber PacketNumber) PacketNumberLen { - if packetNumber < (1 << (uint8(PacketNumberLen1) * 8)) { - return PacketNumberLen1 - } - if packetNumber < (1 << (uint8(PacketNumberLen2) * 8)) { - return PacketNumberLen2 - } - if packetNumber < (1 << (uint8(PacketNumberLen4) * 8)) { - return PacketNumberLen4 - } - return PacketNumberLen6 -} diff --git a/vendor/github.com/lucas-clemente/quic-go/protocol/packet_number_test.go b/vendor/github.com/lucas-clemente/quic-go/protocol/packet_number_test.go deleted file mode 100644 index 88539b9..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/protocol/packet_number_test.go +++ /dev/null @@ -1,225 +0,0 @@ -package protocol - -import ( - "fmt" - "math" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -// Tests taken and extended from chrome -var _ = Describe("packet number calculation", func() { - Context("infering a packet number", func() { - check := func(length PacketNumberLen, expected, last uint64) { - epoch := uint64(1) << (length * 8) - epochMask := epoch - 1 - wirePacketNumber := expected & epochMask - Expect(InferPacketNumber(length, PacketNumber(last), PacketNumber(wirePacketNumber))).To(Equal(PacketNumber(expected))) - } - for _, length := range []PacketNumberLen{PacketNumberLen1, PacketNumberLen2, PacketNumberLen4, PacketNumberLen6} { - Context(fmt.Sprintf("with %d bytes", length), func() { - epoch := uint64(1) << (length * 8) - epochMask := epoch - 1 - - It("works near epoch start", func() { - // A few quick manual sanity check - check(length, 1, 0) - check(length, epoch+1, epochMask) - check(length, epoch, epochMask) - - // Cases where the last number was close to the start of the range. - for last := uint64(0); last < 10; last++ { - // Small numbers should not wrap (even if they're out of order). - for j := uint64(0); j < 10; j++ { - check(length, j, last) - } - - // Large numbers should not wrap either (because we're near 0 already). - for j := uint64(0); j < 10; j++ { - check(length, epoch-1-j, last) - } - } - }) - - It("works near epoch end", func() { - // Cases where the last number was close to the end of the range - for i := uint64(0); i < 10; i++ { - last := epoch - i - - // Small numbers should wrap. - for j := uint64(0); j < 10; j++ { - check(length, epoch+j, last) - } - - // Large numbers should not (even if they're out of order). - for j := uint64(0); j < 10; j++ { - check(length, epoch-1-j, last) - } - } - }) - - // Next check where we're in a non-zero epoch to verify we handle - // reverse wrapping, too. - It("works near previous epoch", func() { - prevEpoch := 1 * epoch - curEpoch := 2 * epoch - // Cases where the last number was close to the start of the range - for i := uint64(0); i < 10; i++ { - last := curEpoch + i - // Small number should not wrap (even if they're out of order). - for j := uint64(0); j < 10; j++ { - check(length, curEpoch+j, last) - } - - // But large numbers should reverse wrap. - for j := uint64(0); j < 10; j++ { - num := epoch - 1 - j - check(length, prevEpoch+num, last) - } - } - }) - - It("works near next epoch", func() { - curEpoch := 2 * epoch - nextEpoch := 3 * epoch - // Cases where the last number was close to the end of the range - for i := uint64(0); i < 10; i++ { - last := nextEpoch - 1 - i - - // Small numbers should wrap. - for j := uint64(0); j < 10; j++ { - check(length, nextEpoch+j, last) - } - - // but large numbers should not (even if they're out of order). - for j := uint64(0); j < 10; j++ { - num := epoch - 1 - j - check(length, curEpoch+num, last) - } - } - }) - - It("works near next max", func() { - maxNumber := uint64(math.MaxUint64) - maxEpoch := maxNumber & ^epochMask - - // Cases where the last number was close to the end of the range - for i := uint64(0); i < 10; i++ { - // Subtract 1, because the expected next packet number is 1 more than the - // last packet number. - last := maxNumber - i - 1 - - // Small numbers should not wrap, because they have nowhere to go. - for j := uint64(0); j < 10; j++ { - check(length, maxEpoch+j, last) - } - - // Large numbers should not wrap either. - for j := uint64(0); j < 10; j++ { - num := epoch - 1 - j - check(length, maxEpoch+num, last) - } - } - }) - }) - } - }) - - Context("shortening a packet number for the publicHeader", func() { - Context("shortening", func() { - It("sends out low packet numbers as 1 byte", func() { - length := GetPacketNumberLengthForPublicHeader(4, 2) - Expect(length).To(Equal(PacketNumberLen1)) - }) - - It("sends out high packet numbers as 1 byte, if all ACKs are received", func() { - length := GetPacketNumberLengthForPublicHeader(0xDEADBEEF, 0xDEADBEEF-1) - Expect(length).To(Equal(PacketNumberLen1)) - }) - - It("sends out higher packet numbers as 2 bytes, if a lot of ACKs are missing", func() { - length := GetPacketNumberLengthForPublicHeader(200, 2) - Expect(length).To(Equal(PacketNumberLen2)) - }) - }) - - Context("self-consistency", func() { - It("works for small packet numbers", func() { - for i := uint64(1); i < 10000; i++ { - packetNumber := PacketNumber(i) - highestAcked := PacketNumber(1) - length := GetPacketNumberLengthForPublicHeader(packetNumber, highestAcked) - wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8) - - inferedPacketNumber := InferPacketNumber(length, highestAcked, PacketNumber(wirePacketNumber)) - Expect(inferedPacketNumber).To(Equal(packetNumber)) - } - }) - - It("works for small packet numbers and increasing ACKed packets", func() { - for i := uint64(1); i < 10000; i++ { - packetNumber := PacketNumber(i) - highestAcked := PacketNumber(i / 2) - length := GetPacketNumberLengthForPublicHeader(packetNumber, highestAcked) - wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8) - - inferedPacketNumber := InferPacketNumber(length, highestAcked, PacketNumber(wirePacketNumber)) - Expect(inferedPacketNumber).To(Equal(packetNumber)) - } - }) - - It("also works for larger packet numbers", func() { - increment := uint64(1 << (8 - 3)) - for i := uint64(1); i < (2 << 46); i += increment { - packetNumber := PacketNumber(i) - highestAcked := PacketNumber(1) - length := GetPacketNumberLengthForPublicHeader(packetNumber, highestAcked) - wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8) - - inferedPacketNumber := InferPacketNumber(length, highestAcked, PacketNumber(wirePacketNumber)) - Expect(inferedPacketNumber).To(Equal(packetNumber)) - - switch length { - case PacketNumberLen2: - increment = 1 << (2*8 - 3) - case PacketNumberLen4: - increment = 1 << (4*8 - 3) - case PacketNumberLen6: - increment = 1 << (6*8 - 3) - } - } - }) - - It("works for packet numbers larger than 2^48", func() { - for i := (uint64(1) << 48); i < ((uint64(1) << 63) - 1); i += (uint64(1) << 48) { - packetNumber := PacketNumber(i) - highestAcked := PacketNumber(i - 1000) - length := GetPacketNumberLengthForPublicHeader(packetNumber, highestAcked) - wirePacketNumber := (uint64(packetNumber) << (64 - length*8)) >> (64 - length*8) - - inferedPacketNumber := InferPacketNumber(length, highestAcked, PacketNumber(wirePacketNumber)) - Expect(inferedPacketNumber).To(Equal(packetNumber)) - } - }) - }) - }) - - Context("determining the minimum length of a packet number", func() { - It("1 byte", func() { - Expect(GetPacketNumberLength(0xFF)).To(Equal(PacketNumberLen1)) - }) - - It("2 byte", func() { - Expect(GetPacketNumberLength(0xFFFF)).To(Equal(PacketNumberLen2)) - }) - - It("4 byte", func() { - Expect(GetPacketNumberLength(0xFFFFFFFF)).To(Equal(PacketNumberLen4)) - }) - - It("6 byte", func() { - Expect(GetPacketNumberLength(0xFFFFFFFFFFFF)).To(Equal(PacketNumberLen6)) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/protocol/protocol.go b/vendor/github.com/lucas-clemente/quic-go/protocol/protocol.go deleted file mode 100644 index eeafb24..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/protocol/protocol.go +++ /dev/null @@ -1,66 +0,0 @@ -package protocol - -import ( - "math" - "time" -) - -// A PacketNumber in QUIC -type PacketNumber uint64 - -// PacketNumberLen is the length of the packet number in bytes -type PacketNumberLen uint8 - -const ( - // PacketNumberLenInvalid is the default value and not a valid length for a packet number - PacketNumberLenInvalid PacketNumberLen = 0 - // PacketNumberLen1 is a packet number length of 1 byte - PacketNumberLen1 PacketNumberLen = 1 - // PacketNumberLen2 is a packet number length of 2 bytes - PacketNumberLen2 PacketNumberLen = 2 - // PacketNumberLen4 is a packet number length of 4 bytes - PacketNumberLen4 PacketNumberLen = 4 - // PacketNumberLen6 is a packet number length of 6 bytes - PacketNumberLen6 PacketNumberLen = 6 -) - -// A ConnectionID in QUIC -type ConnectionID uint64 - -// A StreamID in QUIC -type StreamID uint32 - -// A ByteCount in QUIC -type ByteCount uint64 - -// MaxByteCount is the maximum value of a ByteCount -const MaxByteCount = math.MaxUint64 - -// MaxPacketSize is the maximum packet size, including the public header -// This is the value used by Chromium for a QUIC packet sent using IPv6 (for IPv4 it would be 1370) -const MaxPacketSize ByteCount = 1350 - -// MaxFrameAndPublicHeaderSize is the maximum size of a QUIC frame plus PublicHeader -const MaxFrameAndPublicHeaderSize = MaxPacketSize - 1 /*private header*/ - 12 /*crypto signature*/ - -// DefaultTCPMSS is the default maximum packet size used in the Linux TCP implementation. -// Used in QUIC for congestion window computations in bytes. -const DefaultTCPMSS ByteCount = 1460 - -// InitialStreamFlowControlWindow is the initial stream-level flow control window for sending -const InitialStreamFlowControlWindow ByteCount = (1 << 14) // 16 kB - -// InitialConnectionFlowControlWindow is the initial connection-level flow control window for sending -const InitialConnectionFlowControlWindow ByteCount = (1 << 14) // 16 kB - -// InitialIdleConnectionStateLifetime is the initial idle connection state lifetime -const InitialIdleConnectionStateLifetime = 30 * time.Second - -// DefaultRetransmissionTime is the RTO time on new connections -const DefaultRetransmissionTime = 500 * time.Millisecond - -// MinRetransmissionTime is the minimum RTO time -const MinRetransmissionTime = 200 * time.Millisecond - -// ClientHelloMinimumSize is the minimum size the server expectes an inchoate CHLO to have. -const ClientHelloMinimumSize = 1024 diff --git a/vendor/github.com/lucas-clemente/quic-go/protocol/protocol_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/protocol/protocol_suite_test.go deleted file mode 100644 index 204a368..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/protocol/protocol_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package protocol - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestProtocol(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Protocol Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/protocol/server_parameters.go b/vendor/github.com/lucas-clemente/quic-go/protocol/server_parameters.go deleted file mode 100644 index 9451fdc..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/protocol/server_parameters.go +++ /dev/null @@ -1,75 +0,0 @@ -package protocol - -import "time" - -// MaxCongestionWindow is the maximum size of the CWND, in packets. -// TODO: Unused? -const MaxCongestionWindow PacketNumber = 200 - -// DefaultMaxCongestionWindow is the default for the max congestion window -// Taken from Chrome -const DefaultMaxCongestionWindow PacketNumber = 107 - -// InitialCongestionWindow is the initial congestion window in QUIC packets -const InitialCongestionWindow PacketNumber = 32 - -// MaxUndecryptablePackets limits the number of undecryptable packets that a -// session queues for later until it sends a public reset. -const MaxUndecryptablePackets = 10 - -// SmallPacketPayloadSizeThreshold defines a threshold for small packets -// if the packet payload size (i.e. the packet without public header and private header) is below SmallPacketSizeThreshold, sending will be delayed by SmallPacketSendDelay -const SmallPacketPayloadSizeThreshold = MaxPacketSize / 2 - -// SmallPacketSendDelay is the time delay applied to small packets -const SmallPacketSendDelay = 500 * time.Microsecond - -// ReceiveStreamFlowControlWindow is the stream-level flow control window for receiving data -// This is the value that Google servers are using -const ReceiveStreamFlowControlWindow ByteCount = (1 << 20) // 1 MB - -// ReceiveConnectionFlowControlWindow is the stream-level flow control window for receiving data -// This is the value that Google servers are using -const ReceiveConnectionFlowControlWindow ByteCount = (1 << 20) * 1.5 // 1.5 MB - -// MaxStreamsPerConnection is the maximum value accepted for the number of streams per connection -const MaxStreamsPerConnection uint32 = 100 - -// MaxStreamsMultiplier is the slack the client is allowed for the maximum number of streams per connection, needed e.g. when packets are out of order or dropped. -const MaxStreamsMultiplier = 1.1 - -// MaxIdleConnectionStateLifetime is the maximum value accepted for the idle connection state lifetime -// TODO: set a reasonable value here -const MaxIdleConnectionStateLifetime = 60 * time.Second - -// WindowUpdateNumRepetitions is the number of times the same WindowUpdate frame will be sent to the client -const WindowUpdateNumRepetitions uint8 = 2 - -// MaxSessionUnprocessedPackets is the max number of packets stored in each session that are not yet processed. -const MaxSessionUnprocessedPackets = 128 - -// RetransmissionThreshold + 1 is the number of times a packet has to be NACKed so that it gets retransmitted -const RetransmissionThreshold uint8 = 3 - -// STKExpiryTimeSec is the valid time of a source address token in seconds -const STKExpiryTimeSec = 24 * 60 * 60 - -// MaxTrackedSentPackets is maximum number of sent packets saved for either later retransmission or entropy calculation -// TODO: find a reasonable value here -// TODO: decrease this value after dropping support for QUIC 33 and earlier -const MaxTrackedSentPackets uint32 = 2000 - -// MaxTrackedReceivedPackets is the maximum number of received packets saved for doing the entropy calculations -// TODO: think about what to do with this when adding support for QUIC 34 -const MaxTrackedReceivedPackets uint32 = 2000 - -// MaxStreamFrameSorterGaps is the maximum number of gaps between received StreamFrames -// prevents DOS attacks against the streamFrameSorter -const MaxStreamFrameSorterGaps = 50 - -// CryptoMaxParams is the upper limit for the number of parameters in a crypto message. -// Value taken from Chrome. -const CryptoMaxParams = 128 - -// CryptoParameterMaxLength is the upper limit for the length of a parameter in a crypto message. -const CryptoParameterMaxLength = 2000 diff --git a/vendor/github.com/lucas-clemente/quic-go/protocol/version.go b/vendor/github.com/lucas-clemente/quic-go/protocol/version.go deleted file mode 100644 index bf646c2..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/protocol/version.go +++ /dev/null @@ -1,68 +0,0 @@ -package protocol - -import ( - "bytes" - "encoding/binary" - "strconv" -) - -// VersionNumber is a version number as int -type VersionNumber int - -// The version numbers, making grepping easier -const ( - Version30 VersionNumber = 30 + iota - Version31 - Version32 - Version33 - Version34 -) - -// SupportedVersions lists the versions that the server supports -var SupportedVersions = []VersionNumber{ - Version30, Version31, Version32, Version33, -} - -// SupportedVersionsAsTags is needed for the SHLO crypto message -var SupportedVersionsAsTags []byte - -// SupportedVersionsAsString is needed for the Alt-Scv HTTP header -var SupportedVersionsAsString string - -// VersionNumberToTag maps version numbers ('32') to tags ('Q032') -func VersionNumberToTag(vn VersionNumber) uint32 { - v := uint32(vn) - return 'Q' + ((v/100%10)+'0')<<8 + ((v/10%10)+'0')<<16 + ((v%10)+'0')<<24 -} - -// VersionTagToNumber is built from VersionNumberToTag in init() -func VersionTagToNumber(v uint32) VersionNumber { - return VersionNumber(((v>>8)&0xff-'0')*100 + ((v>>16)&0xff-'0')*10 + ((v>>24)&0xff - '0')) -} - -// IsSupportedVersion returns true if the server supports this version -func IsSupportedVersion(v VersionNumber) bool { - for _, t := range SupportedVersions { - if t == v { - return true - } - } - return false -} - -func init() { - var b bytes.Buffer - for _, v := range SupportedVersions { - s := make([]byte, 4) - binary.LittleEndian.PutUint32(s, VersionNumberToTag(v)) - b.Write(s) - } - SupportedVersionsAsTags = b.Bytes() - - for i := len(SupportedVersions) - 1; i >= 0; i-- { - SupportedVersionsAsString += strconv.Itoa(int(SupportedVersions[i])) - if i != 0 { - SupportedVersionsAsString += "," - } - } -} diff --git a/vendor/github.com/lucas-clemente/quic-go/protocol/version_test.go b/vendor/github.com/lucas-clemente/quic-go/protocol/version_test.go deleted file mode 100644 index 89b2ddd..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/protocol/version_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package protocol - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Version", func() { - It("converts tags to numbers", func() { - Expect(VersionTagToNumber('Q' + '1'<<8 + '2'<<16 + '3'<<24)).To(Equal(VersionNumber(123))) - Expect(VersionTagToNumber('Q' + '0'<<8 + '3'<<16 + '0'<<24)).To(Equal(Version30)) - }) - - It("converts number to tag", func() { - Expect(VersionNumberToTag(VersionNumber(123))).To(Equal(uint32('Q' + '1'<<8 + '2'<<16 + '3'<<24))) - Expect(VersionNumberToTag(Version30)).To(Equal(uint32('Q' + '0'<<8 + '3'<<16 + '0'<<24))) - }) - - It("has proper tag list", func() { - Expect(SupportedVersionsAsTags).To(Equal([]byte("Q030Q031Q032Q033"))) - }) - - It("has proper version list", func() { - Expect(SupportedVersionsAsString).To(Equal("33,32,31,30")) - }) - - It("recognizes supported versions", func() { - Expect(IsSupportedVersion(0)).To(BeFalse()) - Expect(IsSupportedVersion(SupportedVersions[0])).To(BeTrue()) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/public_header.go b/vendor/github.com/lucas-clemente/quic-go/public_header.go deleted file mode 100644 index c1f9e7b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/public_header.go +++ /dev/null @@ -1,181 +0,0 @@ -package quic - -import ( - "bytes" - "errors" - "io" - - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -var ( - errPacketNumberLenNotSet = errors.New("PublicHeader: PacketNumberLen not set") - errResetAndVersionFlagSet = errors.New("PublicHeader: Reset Flag and Version Flag should not be set at the same time") - errReceivedTruncatedConnectionID = qerr.Error(qerr.InvalidPacketHeader, "receiving packets with truncated ConnectionID is not supported") - errInvalidConnectionID = qerr.Error(qerr.InvalidPacketHeader, "connection ID cannot be 0") - errGetLengthOnlyForRegularPackets = errors.New("PublicHeader: GetLength can only be called for regular packets") -) - -// The publicHeader of a QUIC packet -type publicHeader struct { - Raw []byte - VersionFlag bool - ResetFlag bool - ConnectionID protocol.ConnectionID - TruncateConnectionID bool - VersionNumber protocol.VersionNumber - QuicVersion uint32 - PacketNumberLen protocol.PacketNumberLen - PacketNumber protocol.PacketNumber - DiversificationNonce []byte -} - -// WritePublicHeader writes a public header -func (h *publicHeader) WritePublicHeader(b *bytes.Buffer, version protocol.VersionNumber) error { - publicFlagByte := uint8(0x00) - if h.VersionFlag && h.ResetFlag { - return errResetAndVersionFlagSet - } - if h.VersionFlag { - publicFlagByte |= 0x01 - } - if h.ResetFlag { - publicFlagByte |= 0x02 - } - if !h.TruncateConnectionID { - if version < protocol.Version33 { - publicFlagByte |= 0x0c - } else { - publicFlagByte |= 0x08 - } - } - if len(h.DiversificationNonce) > 0 { - if len(h.DiversificationNonce) != 32 { - return errors.New("invalid diversification nonce length") - } - publicFlagByte |= 0x04 - } - - if !h.ResetFlag && !h.VersionFlag { - switch h.PacketNumberLen { - case protocol.PacketNumberLen1: - publicFlagByte |= 0x00 - case protocol.PacketNumberLen2: - publicFlagByte |= 0x10 - case protocol.PacketNumberLen4: - publicFlagByte |= 0x20 - case protocol.PacketNumberLen6: - publicFlagByte |= 0x30 - } - } - - b.WriteByte(publicFlagByte) - - if !h.TruncateConnectionID { - utils.WriteUint64(b, uint64(h.ConnectionID)) - } - - if len(h.DiversificationNonce) > 0 { - b.Write(h.DiversificationNonce) - } - - if !h.ResetFlag && !h.VersionFlag { - switch h.PacketNumberLen { - case protocol.PacketNumberLen1: - b.WriteByte(uint8(h.PacketNumber)) - case protocol.PacketNumberLen2: - utils.WriteUint16(b, uint16(h.PacketNumber)) - case protocol.PacketNumberLen4: - utils.WriteUint32(b, uint32(h.PacketNumber)) - case protocol.PacketNumberLen6: - utils.WriteUint48(b, uint64(h.PacketNumber)) - default: - return errPacketNumberLenNotSet - } - } - - return nil -} - -// parsePublicHeader parses a QUIC packet's public header -func parsePublicHeader(b io.ByteReader) (*publicHeader, error) { - header := &publicHeader{} - - // First byte - publicFlagByte, err := b.ReadByte() - if err != nil { - return nil, err - } - header.VersionFlag = publicFlagByte&0x01 > 0 - header.ResetFlag = publicFlagByte&0x02 > 0 - - // TODO: Add this check when we drop support for 0 { - // return nil, errors.New("diversification nonces should only be sent by servers") - // } - - if publicFlagByte&0x08 == 0 { - return nil, errReceivedTruncatedConnectionID - } - - switch publicFlagByte & 0x30 { - case 0x30: - header.PacketNumberLen = protocol.PacketNumberLen6 - case 0x20: - header.PacketNumberLen = protocol.PacketNumberLen4 - case 0x10: - header.PacketNumberLen = protocol.PacketNumberLen2 - case 0x00: - header.PacketNumberLen = protocol.PacketNumberLen1 - } - - // Connection ID - connID, err := utils.ReadUint64(b) - if err != nil { - return nil, err - } - header.ConnectionID = protocol.ConnectionID(connID) - if header.ConnectionID == 0 { - return nil, errInvalidConnectionID - } - - // Version (optional) - if header.VersionFlag { - var versionTag uint32 - versionTag, err = utils.ReadUint32(b) - if err != nil { - return nil, err - } - header.VersionNumber = protocol.VersionTagToNumber(versionTag) - } - - // Packet number - packetNumber, err := utils.ReadUintN(b, uint8(header.PacketNumberLen)) - if err != nil { - return nil, err - } - header.PacketNumber = protocol.PacketNumber(packetNumber) - - return header, nil -} - -// GetLength gets the length of the publicHeader in bytes -// can only be called for regular packets -func (h *publicHeader) GetLength() (protocol.ByteCount, error) { - if h.VersionFlag || h.ResetFlag { - return 0, errGetLengthOnlyForRegularPackets - } - - length := protocol.ByteCount(1) // 1 byte for public flags - if h.PacketNumberLen != protocol.PacketNumberLen1 && h.PacketNumberLen != protocol.PacketNumberLen2 && h.PacketNumberLen != protocol.PacketNumberLen4 && h.PacketNumberLen != protocol.PacketNumberLen6 { - return 0, errPacketNumberLenNotSet - } - if !h.TruncateConnectionID { - length += 8 // 8 bytes for the connection ID - } - length += protocol.ByteCount(len(h.DiversificationNonce)) - length += protocol.ByteCount(h.PacketNumberLen) - return length, nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/public_header_test.go b/vendor/github.com/lucas-clemente/quic-go/public_header_test.go deleted file mode 100644 index defe46a..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/public_header_test.go +++ /dev/null @@ -1,303 +0,0 @@ -package quic - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Public Header", func() { - Context("when parsing", func() { - It("accepts a sample client header", func() { - b := bytes.NewReader([]byte{0x09, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x51, 0x30, 0x33, 0x30, 0x01}) - hdr, err := parsePublicHeader(b) - Expect(err).ToNot(HaveOccurred()) - Expect(hdr.VersionFlag).To(BeTrue()) - Expect(hdr.ResetFlag).To(BeFalse()) - Expect(hdr.ConnectionID).To(Equal(protocol.ConnectionID(0x4cfa9f9b668619f6))) - Expect(hdr.VersionNumber).To(Equal(protocol.Version30)) - Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(1))) - Expect(b.Len()).To(BeZero()) - }) - - It("does not accept 0-byte connection ID", func() { - b := bytes.NewReader([]byte{0x00, 0x01}) - _, err := parsePublicHeader(b) - Expect(err).To(MatchError(errReceivedTruncatedConnectionID)) - }) - - It("rejects 0 as a connection ID", func() { - b := bytes.NewReader([]byte{0x09, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x51, 0x30, 0x33, 0x30, 0x01}) - _, err := parsePublicHeader(b) - Expect(err).To(MatchError(errInvalidConnectionID)) - }) - - It("accepts 1-byte packet numbers", func() { - b := bytes.NewReader([]byte{0x08, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xde}) - hdr, err := parsePublicHeader(b) - Expect(err).ToNot(HaveOccurred()) - Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(0xde))) - Expect(b.Len()).To(BeZero()) - }) - - It("accepts 2-byte packet numbers", func() { - b := bytes.NewReader([]byte{0x18, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xde, 0xca}) - hdr, err := parsePublicHeader(b) - Expect(err).ToNot(HaveOccurred()) - Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(0xcade))) - Expect(b.Len()).To(BeZero()) - }) - - It("accepts 4-byte packet numbers", func() { - b := bytes.NewReader([]byte{0x28, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xad, 0xfb, 0xca, 0xde}) - hdr, err := parsePublicHeader(b) - Expect(err).ToNot(HaveOccurred()) - Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(0xdecafbad))) - Expect(b.Len()).To(BeZero()) - }) - - It("accepts 6-byte packet numbers", func() { - b := bytes.NewReader([]byte{0x38, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x23, 0x42, 0xad, 0xfb, 0xca, 0xde}) - hdr, err := parsePublicHeader(b) - Expect(err).ToNot(HaveOccurred()) - Expect(hdr.PacketNumber).To(Equal(protocol.PacketNumber(0xdecafbad4223))) - Expect(b.Len()).To(BeZero()) - }) - - PIt("rejects diversification nonces", func() { - b := bytes.NewReader([]byte{0x0c, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, - 0x01, - }) - _, err := parsePublicHeader(b) - Expect(err).To(MatchError("diversification nonces should only be sent by servers")) - }) - }) - - Context("when writing", func() { - It("writes a sample header", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 2, - PacketNumberLen: protocol.PacketNumberLen6, - } - hdr.WritePublicHeader(b, protocol.Version32) - Expect(b.Bytes()).To(Equal([]byte{0x38 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 2, 0, 0, 0, 0, 0})) - }) - - It("sets the Version Flag", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - VersionFlag: true, - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 2, - PacketNumberLen: protocol.PacketNumberLen6, - } - hdr.WritePublicHeader(b, protocol.Version32) - // must be the first assertion - Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID - firstByte, _ := b.ReadByte() - Expect(firstByte & 0x01).To(Equal(uint8(1))) - }) - - It("sets the Reset Flag", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ResetFlag: true, - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 2, - PacketNumberLen: protocol.PacketNumberLen6, - } - hdr.WritePublicHeader(b, protocol.Version32) - // must be the first assertion - Expect(b.Len()).To(Equal(1 + 8)) // 1 FlagByte + 8 ConnectionID - firstByte, _ := b.ReadByte() - Expect((firstByte & 0x02) >> 1).To(Equal(uint8(1))) - }) - - It("throws an error if both Reset Flag and Version Flag are set", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - VersionFlag: true, - ResetFlag: true, - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 2, - PacketNumberLen: protocol.PacketNumberLen6, - } - err := hdr.WritePublicHeader(b, protocol.Version32) - Expect(err).To(MatchError(errResetAndVersionFlagSet)) - }) - - It("truncates the connection ID", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - TruncateConnectionID: true, - PacketNumberLen: protocol.PacketNumberLen6, - PacketNumber: 1, - } - err := hdr.WritePublicHeader(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{0x30, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0})) - }) - - It("writes proper v33 packets", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 1, - PacketNumberLen: protocol.PacketNumberLen1, - } - err := hdr.WritePublicHeader(b, protocol.Version33) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{0x08, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x01})) - }) - - It("writes diversification nonces", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 1, - PacketNumberLen: protocol.PacketNumberLen1, - DiversificationNonce: bytes.Repeat([]byte{1}, 32), - } - err := hdr.WritePublicHeader(b, protocol.Version33) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{ - 0x0c, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 0x01, - })) - }) - - Context("GetLength", func() { - It("errors when calling GetLength for Version Negotiation packets", func() { - hdr := publicHeader{VersionFlag: true} - _, err := hdr.GetLength() - Expect(err).To(MatchError(errGetLengthOnlyForRegularPackets)) - }) - - It("errors when calling GetLength for Public Reset packets", func() { - hdr := publicHeader{ResetFlag: true} - _, err := hdr.GetLength() - Expect(err).To(MatchError(errGetLengthOnlyForRegularPackets)) - }) - - It("errors when PacketNumberLen is not set", func() { - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0xDECAFBAD, - } - _, err := hdr.GetLength() - Expect(err).To(MatchError(errPacketNumberLenNotSet)) - }) - - It("gets the length of a packet with longest packet number length and connectionID", func() { - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0xDECAFBAD, - PacketNumberLen: protocol.PacketNumberLen6, - } - length, err := hdr.GetLength() - Expect(err).ToNot(HaveOccurred()) - Expect(length).To(Equal(protocol.ByteCount(1 + 8 + 6))) // 1 byte public flag, 8 bytes connectionID, and packet number - }) - - It("gets the length of a packet with longest packet number length and truncated connectionID", func() { - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - TruncateConnectionID: true, - PacketNumber: 0xDECAFBAD, - PacketNumberLen: protocol.PacketNumberLen6, - } - length, err := hdr.GetLength() - Expect(err).ToNot(HaveOccurred()) - Expect(length).To(Equal(protocol.ByteCount(1 + 6))) // 1 byte public flag, and packet number - }) - - It("gets the length of a packet 2 byte packet number length ", func() { - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0xDECAFBAD, - PacketNumberLen: protocol.PacketNumberLen2, - } - length, err := hdr.GetLength() - Expect(err).ToNot(HaveOccurred()) - Expect(length).To(Equal(protocol.ByteCount(1 + 8 + 2))) // 1 byte public flag, 8 byte connectionID, and packet number - }) - - It("works with diversification nonce", func() { - hdr := publicHeader{ - DiversificationNonce: []byte("foo"), - PacketNumberLen: protocol.PacketNumberLen1, - } - length, err := hdr.GetLength() - Expect(err).NotTo(HaveOccurred()) - Expect(length).To(Equal(protocol.ByteCount(1 + 8 + 3 + 1))) - }) - }) - - Context("packet number length", func() { - It("doesn't write a header if the packet number length is not set", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0xDECAFBAD, - } - err := hdr.WritePublicHeader(b, protocol.Version32) - Expect(err).To(MatchError(errPacketNumberLenNotSet)) - }) - - It("writes a header with a 1-byte packet number", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0xDECAFBAD, - PacketNumberLen: protocol.PacketNumberLen1, - } - err := hdr.WritePublicHeader(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{0x08 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD})) - }) - - It("writes a header with a 2-byte packet number", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0xDECAFBAD, - PacketNumberLen: protocol.PacketNumberLen2, - } - err := hdr.WritePublicHeader(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{0x18 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB})) - }) - - It("writes a header with a 4-byte packet number", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0x13DECAFBAD, - PacketNumberLen: protocol.PacketNumberLen4, - } - err := hdr.WritePublicHeader(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{0x28 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB, 0xCA, 0xDE})) - }) - - It("writes a header with a 6-byte packet number", func() { - b := &bytes.Buffer{} - hdr := publicHeader{ - ConnectionID: 0x4cfa9f9b668619f6, - PacketNumber: 0xBE1337DECAFBAD, - PacketNumberLen: protocol.PacketNumberLen6, - } - err := hdr.WritePublicHeader(b, protocol.Version32) - Expect(err).ToNot(HaveOccurred()) - Expect(b.Bytes()).To(Equal([]byte{0x38 | 0x04, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0xAD, 0xFB, 0xCA, 0xDE, 0x37, 0x13})) - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/public_reset.go b/vendor/github.com/lucas-clemente/quic-go/public_reset.go deleted file mode 100644 index 7cceb2e..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/public_reset.go +++ /dev/null @@ -1,24 +0,0 @@ -package quic - -import ( - "bytes" - - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/utils" -) - -func writePublicReset(connectionID protocol.ConnectionID, rejectedPacketNumber protocol.PacketNumber, nonceProof uint64) []byte { - b := &bytes.Buffer{} - b.WriteByte(0x0a) - utils.WriteUint64(b, uint64(connectionID)) - utils.WriteUint32(b, uint32(handshake.TagPRST)) - utils.WriteUint32(b, 2) - utils.WriteUint32(b, uint32(handshake.TagRNON)) - utils.WriteUint32(b, 8) - utils.WriteUint32(b, uint32(handshake.TagRSEQ)) - utils.WriteUint32(b, 16) - utils.WriteUint64(b, nonceProof) - utils.WriteUint64(b, uint64(rejectedPacketNumber)) - return b.Bytes() -} diff --git a/vendor/github.com/lucas-clemente/quic-go/public_reset_test.go b/vendor/github.com/lucas-clemente/quic-go/public_reset_test.go deleted file mode 100644 index 446b4e7..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/public_reset_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package quic - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("public reset", func() { - Context("writing", func() { - It("writes public reset packets", func() { - Expect(writePublicReset(0xdeadbeef, 0x8badf00d, 0xdecafbad)).To(Equal([]byte{ - 0x0a, - 0xef, 0xbe, 0xad, 0xde, 0x00, 0x00, 0x00, 0x00, - 'P', 'R', 'S', 'T', - 0x02, 0x00, 0x00, 0x00, - 'R', 'N', 'O', 'N', - 0x08, 0x00, 0x00, 0x00, - 'R', 'S', 'E', 'Q', - 0x10, 0x00, 0x00, 0x00, - 0xad, 0xfb, 0xca, 0xde, 0x0, 0x0, 0x0, 0x0, - 0x0d, 0xf0, 0xad, 0x8b, 0x0, 0x0, 0x0, 0x0, - })) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/qerr/error_codes.go b/vendor/github.com/lucas-clemente/quic-go/qerr/error_codes.go deleted file mode 100644 index 4797530..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/qerr/error_codes.go +++ /dev/null @@ -1,190 +0,0 @@ -package qerr - -// The error codes defined by QUIC -// Remember to run `go generate ./...` whenever the error codes change. -//go:generate stringer -type=ErrorCode -const ( - InternalError ErrorCode = 1 - // There were data frames after the a fin or reset. - StreamDataAfterTermination ErrorCode = 2 - // Control frame is malformed. - InvalidPacketHeader ErrorCode = 3 - // Frame data is malformed. - InvalidFrameData ErrorCode = 4 - // The packet contained no payload. - MissingPayload ErrorCode = 48 - // FEC data is malformed. - InvalidFecData ErrorCode = 5 - // STREAM frame data is malformed. - InvalidStreamData ErrorCode = 46 - // STREAM frame data overlaps with buffered data. - OverlappingStreamData ErrorCode = 87 - // Received STREAM frame data is not encrypted. - UnencryptedStreamData ErrorCode = 61 - // Attempt to send unencrypted STREAM frame. - AttemptToSendUnencryptedStreamData ErrorCode = 88 - // FEC frame data is not encrypted. - UnencryptedFecData ErrorCode = 77 - // RST_STREAM frame data is malformed. - InvalidRstStreamData ErrorCode = 6 - // CONNECTION_CLOSE frame data is malformed. - InvalidConnectionCloseData ErrorCode = 7 - // GOAWAY frame data is malformed. - InvalidGoawayData ErrorCode = 8 - // WINDOW_UPDATE frame data is malformed. - InvalidWindowUpdateData ErrorCode = 57 - // BLOCKED frame data is malformed. - InvalidBlockedData ErrorCode = 58 - // STOP_WAITING frame data is malformed. - InvalidStopWaitingData ErrorCode = 60 - // PATH_CLOSE frame data is malformed. - InvalidPathCloseData ErrorCode = 78 - // ACK frame data is malformed. - InvalidAckData ErrorCode = 9 - - // Version negotiation packet is malformed. - InvalidVersionNegotiationPacket ErrorCode = 10 - // Public RST packet is malformed. - InvalidPublicRstPacket ErrorCode = 11 - // There was an error decrypting. - DecryptionFailure ErrorCode = 12 - // There was an error encrypting. - EncryptionFailure ErrorCode = 13 - // The packet exceeded kMaxPacketSize. - PacketTooLarge ErrorCode = 14 - // The peer is going away. May be a client or server. - PeerGoingAway ErrorCode = 16 - // A stream ID was invalid. - InvalidStreamID ErrorCode = 17 - // A priority was invalid. - InvalidPriority ErrorCode = 49 - // Too many streams already open. - TooManyOpenStreams ErrorCode = 18 - // The peer created too many available streams. - TooManyAvailableStreams ErrorCode = 76 - // Received public reset for this connection. - PublicReset ErrorCode = 19 - // Invalid protocol version. - InvalidVersion ErrorCode = 20 - - // The Header ID for a stream was too far from the previous. - InvalidHeaderID ErrorCode = 22 - // Negotiable parameter received during handshake had invalid value. - InvalidNegotiatedValue ErrorCode = 23 - // There was an error decompressing data. - DecompressionFailure ErrorCode = 24 - // The connection timed out due to no network activity. - NetworkIdleTimeout ErrorCode = 25 - // The connection timed out waiting for the handshake to complete. - HandshakeTimeout ErrorCode = 67 - // There was an error encountered migrating addresses. - ErrorMigratingAddress ErrorCode = 26 - // There was an error encountered migrating port only. - ErrorMigratingPort ErrorCode = 86 - // There was an error while writing to the socket. - PacketWriteError ErrorCode = 27 - // There was an error while reading from the socket. - PacketReadError ErrorCode = 51 - // We received a STREAM_FRAME with no data and no fin flag set. - EmptyStreamFrameNoFin ErrorCode = 50 - // We received invalid data on the headers stream. - InvalidHeadersStreamData ErrorCode = 56 - // The peer received too much data, violating flow control. - FlowControlReceivedTooMuchData ErrorCode = 59 - // The peer sent too much data, violating flow control. - FlowControlSentTooMuchData ErrorCode = 63 - // The peer received an invalid flow control window. - FlowControlInvalidWindow ErrorCode = 64 - // The connection has been IP pooled into an existing connection. - ConnectionIPPooled ErrorCode = 62 - // The connection has too many outstanding sent packets. - TooManyOutstandingSentPackets ErrorCode = 68 - // The connection has too many outstanding received packets. - TooManyOutstandingReceivedPackets ErrorCode = 69 - // The quic connection has been cancelled. - ConnectionCancelled ErrorCode = 70 - // Disabled QUIC because of high packet loss rate. - BadPacketLossRate ErrorCode = 71 - // Disabled QUIC because of too many PUBLIC_RESETs post handshake. - PublicResetsPostHandshake ErrorCode = 73 - // Disabled QUIC because of too many timeouts with streams open. - TimeoutsWithOpenStreams ErrorCode = 74 - // Closed because we failed to serialize a packet. - FailedToSerializePacket ErrorCode = 75 - // QUIC timed out after too many RTOs. - TooManyRtos ErrorCode = 85 - - // Crypto errors. - - // Hanshake failed. - HandshakeFailed ErrorCode = 28 - // Handshake message contained out of order tags. - CryptoTagsOutOfOrder ErrorCode = 29 - // Handshake message contained too many entries. - CryptoTooManyEntries ErrorCode = 30 - // Handshake message contained an invalid value length. - CryptoInvalidValueLength ErrorCode = 31 - // A crypto message was received after the handshake was complete. - CryptoMessageAfterHandshakeComplete ErrorCode = 32 - // A crypto message was received with an illegal message tag. - InvalidCryptoMessageType ErrorCode = 33 - // A crypto message was received with an illegal parameter. - InvalidCryptoMessageParameter ErrorCode = 34 - // An invalid channel id signature was supplied. - InvalidChannelIDSignature ErrorCode = 52 - // A crypto message was received with a mandatory parameter missing. - CryptoMessageParameterNotFound ErrorCode = 35 - // A crypto message was received with a parameter that has no overlap - // with the local parameter. - CryptoMessageParameterNoOverlap ErrorCode = 36 - // A crypto message was received that contained a parameter with too few - // values. - CryptoMessageIndexNotFound ErrorCode = 37 - // An internal error occurred in crypto processing. - CryptoInternalError ErrorCode = 38 - // A crypto handshake message specified an unsupported version. - CryptoVersionNotSupported ErrorCode = 39 - // A crypto handshake message resulted in a stateless reject. - CryptoHandshakeStatelessReject ErrorCode = 72 - // There was no intersection between the crypto primitives supported by the - // peer and ourselves. - CryptoNoSupport ErrorCode = 40 - // The server rejected our client hello messages too many times. - CryptoTooManyRejects ErrorCode = 41 - // The client rejected the server's certificate chain or signature. - ProofInvalid ErrorCode = 42 - // A crypto message was received with a duplicate tag. - CryptoDuplicateTag ErrorCode = 43 - // A crypto message was received with the wrong encryption level (i.e. it - // should have been encrypted but was not.) - CryptoEncryptionLevelIncorrect ErrorCode = 44 - // The server config for a server has expired. - CryptoServerConfigExpired ErrorCode = 45 - // We failed to setup the symmetric keys for a connection. - CryptoSymmetricKeySetupFailed ErrorCode = 53 - // A handshake message arrived, but we are still validating the - // previous handshake message. - CryptoMessageWhileValidatingClientHello ErrorCode = 54 - // A server config update arrived before the handshake is complete. - CryptoUpdateBeforeHandshakeComplete ErrorCode = 65 - // This connection involved a version negotiation which appears to have been - // tampered with. - VersionNegotiationMismatch ErrorCode = 55 - - // Multipath is not enabled, but a packet with multipath flag on is received. - BadMultipathFlag ErrorCode = 79 - - // IP address changed causing connection close. - IPAddressChanged ErrorCode = 80 - - // Connection migration errors. - // Network changed, but connection had no migratable streams. - ConnectionMigrationNoMigratableStreams ErrorCode = 81 - // Connection changed networks too many times. - ConnectionMigrationTooManyChanges ErrorCode = 82 - // Connection migration was attempted, but there was no new network to - // migrate to. - ConnectionMigrationNoNewNetwork ErrorCode = 83 - // Network changed, but connection had one or more non-migratable streams. - ConnectionMigrationNonMigratableStream ErrorCode = 84 -) diff --git a/vendor/github.com/lucas-clemente/quic-go/qerr/errorcode_string.go b/vendor/github.com/lucas-clemente/quic-go/qerr/errorcode_string.go deleted file mode 100644 index 50141c6..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/qerr/errorcode_string.go +++ /dev/null @@ -1,43 +0,0 @@ -// Code generated by "stringer -type=ErrorCode"; DO NOT EDIT - -package qerr - -import "fmt" - -const ( - _ErrorCode_name_0 = "InternalErrorStreamDataAfterTerminationInvalidPacketHeaderInvalidFrameDataInvalidFecDataInvalidRstStreamDataInvalidConnectionCloseDataInvalidGoawayDataInvalidAckDataInvalidVersionNegotiationPacketInvalidPublicRstPacketDecryptionFailureEncryptionFailurePacketTooLarge" - _ErrorCode_name_1 = "PeerGoingAwayInvalidStreamIDTooManyOpenStreamsPublicResetInvalidVersion" - _ErrorCode_name_2 = "InvalidHeaderIDInvalidNegotiatedValueDecompressionFailureNetworkIdleTimeoutErrorMigratingAddressPacketWriteErrorHandshakeFailedCryptoTagsOutOfOrderCryptoTooManyEntriesCryptoInvalidValueLengthCryptoMessageAfterHandshakeCompleteInvalidCryptoMessageTypeInvalidCryptoMessageParameterCryptoMessageParameterNotFoundCryptoMessageParameterNoOverlapCryptoMessageIndexNotFoundCryptoInternalErrorCryptoVersionNotSupportedCryptoNoSupportCryptoTooManyRejectsProofInvalidCryptoDuplicateTagCryptoEncryptionLevelIncorrectCryptoServerConfigExpiredInvalidStreamData" - _ErrorCode_name_3 = "MissingPayloadInvalidPriorityEmptyStreamFrameNoFinPacketReadErrorInvalidChannelIDSignatureCryptoSymmetricKeySetupFailedCryptoMessageWhileValidatingClientHelloVersionNegotiationMismatchInvalidHeadersStreamDataInvalidWindowUpdateDataInvalidBlockedDataFlowControlReceivedTooMuchDataInvalidStopWaitingDataUnencryptedStreamDataConnectionIPPooledFlowControlSentTooMuchDataFlowControlInvalidWindowCryptoUpdateBeforeHandshakeComplete" - _ErrorCode_name_4 = "HandshakeTimeoutTooManyOutstandingSentPacketsTooManyOutstandingReceivedPacketsConnectionCancelledBadPacketLossRateCryptoHandshakeStatelessRejectPublicResetsPostHandshakeTimeoutsWithOpenStreamsFailedToSerializePacketTooManyAvailableStreamsUnencryptedFecDataInvalidPathCloseDataBadMultipathFlagIPAddressChangedConnectionMigrationNoMigratableStreamsConnectionMigrationTooManyChangesConnectionMigrationNoNewNetworkConnectionMigrationNonMigratableStreamTooManyRtosErrorMigratingPortOverlappingStreamDataAttemptToSendUnencryptedStreamData" -) - -var ( - _ErrorCode_index_0 = [...]uint16{0, 13, 39, 58, 74, 88, 108, 134, 151, 165, 196, 218, 235, 252, 266} - _ErrorCode_index_1 = [...]uint8{0, 13, 28, 46, 57, 71} - _ErrorCode_index_2 = [...]uint16{0, 15, 37, 57, 75, 96, 112, 127, 147, 167, 191, 226, 250, 279, 309, 340, 366, 385, 410, 425, 445, 457, 475, 505, 530, 547} - _ErrorCode_index_3 = [...]uint16{0, 14, 29, 50, 65, 90, 119, 158, 184, 208, 231, 249, 279, 301, 322, 340, 366, 390, 425} - _ErrorCode_index_4 = [...]uint16{0, 16, 45, 78, 97, 114, 144, 169, 192, 215, 238, 256, 276, 292, 308, 346, 379, 410, 448, 459, 477, 498, 532} -) - -func (i ErrorCode) String() string { - switch { - case 1 <= i && i <= 14: - i -= 1 - return _ErrorCode_name_0[_ErrorCode_index_0[i]:_ErrorCode_index_0[i+1]] - case 16 <= i && i <= 20: - i -= 16 - return _ErrorCode_name_1[_ErrorCode_index_1[i]:_ErrorCode_index_1[i+1]] - case 22 <= i && i <= 46: - i -= 22 - return _ErrorCode_name_2[_ErrorCode_index_2[i]:_ErrorCode_index_2[i+1]] - case 48 <= i && i <= 65: - i -= 48 - return _ErrorCode_name_3[_ErrorCode_index_3[i]:_ErrorCode_index_3[i+1]] - case 67 <= i && i <= 88: - i -= 67 - return _ErrorCode_name_4[_ErrorCode_index_4[i]:_ErrorCode_index_4[i+1]] - default: - return fmt.Sprintf("ErrorCode(%d)", i) - } -} diff --git a/vendor/github.com/lucas-clemente/quic-go/qerr/errorcodes_test.go b/vendor/github.com/lucas-clemente/quic-go/qerr/errorcodes_test.go deleted file mode 100644 index 63bf487..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/qerr/errorcodes_test.go +++ /dev/null @@ -1,33 +0,0 @@ -package qerr - -import ( - "go/ast" - "go/parser" - "go/token" - "os" - "strconv" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("error codes", func() { - // If this test breaks, you should run `go generate ./...` - It("has a string representation for every error code", func() { - // We parse the error code file, extract all constants, and verify that - // each of them has a string version. Go FTW! - filename := os.Getenv("GOPATH") + "/src/github.com/lucas-clemente/quic-go/qerr/error_codes.go" - fileAst, err := parser.ParseFile(token.NewFileSet(), filename, nil, 0) - Expect(err).NotTo(HaveOccurred()) - constSpecs := fileAst.Decls[0].(*ast.GenDecl).Specs - Expect(len(constSpecs)).To(BeNumerically(">", 4)) // at time of writing - for _, c := range constSpecs { - name := c.(*ast.ValueSpec).Names[0].Name - valString := c.(*ast.ValueSpec).Values[0].(*ast.BasicLit).Value - val, err := strconv.Atoi(valString) - Expect(err).NotTo(HaveOccurred()) - Expect(ErrorCode(val).String()).To(Equal(name)) - } - Expect(ErrorCode(0).String()).To(Equal("ErrorCode(0)")) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/qerr/errors_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/qerr/errors_suite_test.go deleted file mode 100644 index 749cded..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/qerr/errors_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package qerr - -import ( - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func TestErrorcodes(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Errors Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/qerr/quic_error.go b/vendor/github.com/lucas-clemente/quic-go/qerr/quic_error.go deleted file mode 100644 index 6259476..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/qerr/quic_error.go +++ /dev/null @@ -1,45 +0,0 @@ -package qerr - -import ( - "fmt" - - "github.com/lucas-clemente/quic-go/utils" -) - -// ErrorCode can be used as a normal error without reason. -type ErrorCode uint32 - -func (e ErrorCode) Error() string { - return e.String() -} - -// A QuicError consists of an error code plus a error reason -type QuicError struct { - ErrorCode ErrorCode - ErrorMessage string -} - -// Error creates a new QuicError instance -func Error(errorCode ErrorCode, errorMessage string) *QuicError { - return &QuicError{ - ErrorCode: errorCode, - ErrorMessage: errorMessage, - } -} - -func (e *QuicError) Error() string { - return fmt.Sprintf("%s: %s", e.ErrorCode.String(), e.ErrorMessage) -} - -// ToQuicError converts an arbitrary error to a QuicError. It leaves QuicErrors -// unchanged, and properly handles `ErrorCode`s. -func ToQuicError(err error) *QuicError { - switch e := err.(type) { - case *QuicError: - return e - case ErrorCode: - return Error(e, "") - } - utils.Errorf("Internal error: %v", err) - return Error(InternalError, err.Error()) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/qerr/quic_error_test.go b/vendor/github.com/lucas-clemente/quic-go/qerr/quic_error_test.go deleted file mode 100644 index 5c84a75..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/qerr/quic_error_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package qerr - -import ( - "io" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Quic error", func() { - Context("QuicError", func() { - It("has a string representation", func() { - err := Error(DecryptionFailure, "foobar") - Expect(err.Error()).To(Equal("DecryptionFailure: foobar")) - }) - }) - - Context("ErrorCode", func() { - It("works as error", func() { - var err error = DecryptionFailure - Expect(err).To(MatchError("DecryptionFailure")) - }) - }) - - Context("ToQuicError", func() { - It("leaves QuicError unchanged", func() { - err := Error(DecryptionFailure, "foo") - Expect(ToQuicError(err)).To(Equal(err)) - }) - - It("wraps ErrorCode properly", func() { - var err error = DecryptionFailure - Expect(ToQuicError(err)).To(Equal(Error(DecryptionFailure, ""))) - }) - - It("changes default errors to InternalError", func() { - Expect(ToQuicError(io.EOF)).To(Equal(Error(InternalError, "EOF"))) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/quic_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/quic_suite_test.go deleted file mode 100644 index 31e8db1..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/quic_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package quic - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestQuicGo(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "QUIC Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/server.go b/vendor/github.com/lucas-clemente/quic-go/server.go deleted file mode 100644 index 2652dc8..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/server.go +++ /dev/null @@ -1,200 +0,0 @@ -package quic - -import ( - "bytes" - "crypto/tls" - "net" - "strings" - "sync" - - "github.com/lucas-clemente/quic-go/crypto" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -// packetHandler handles packets -type packetHandler interface { - handlePacket(addr interface{}, hdr *publicHeader, data []byte) - run() - Close(error) error -} - -// A Server of QUIC -type Server struct { - addr *net.UDPAddr - - conn *net.UDPConn - connMutex sync.Mutex - - signer crypto.Signer - scfg *handshake.ServerConfig - - sessions map[protocol.ConnectionID]packetHandler - sessionsMutex sync.RWMutex - - streamCallback StreamCallback - - newSession func(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, streamCallback StreamCallback, closeCallback closeCallback) (packetHandler, error) -} - -// NewServer makes a new server -func NewServer(addr string, tlsConfig *tls.Config, cb StreamCallback) (*Server, error) { - signer, err := crypto.NewProofSource(tlsConfig) - if err != nil { - return nil, err - } - - kex, err := crypto.NewCurve25519KEX() - if err != nil { - return nil, err - } - scfg, err := handshake.NewServerConfig(kex, signer) - if err != nil { - return nil, err - } - - udpAddr, err := net.ResolveUDPAddr("udp", addr) - if err != nil { - return nil, err - } - - return &Server{ - addr: udpAddr, - signer: signer, - scfg: scfg, - streamCallback: cb, - sessions: map[protocol.ConnectionID]packetHandler{}, - newSession: newSession, - }, nil -} - -// ListenAndServe listens and serves a connection -func (s *Server) ListenAndServe() error { - conn, err := net.ListenUDP("udp", s.addr) - if err != nil { - return err - } - return s.Serve(conn) -} - -// Serve on an existing UDP connection. -func (s *Server) Serve(conn *net.UDPConn) error { - s.connMutex.Lock() - s.conn = conn - s.connMutex.Unlock() - - for { - data := make([]byte, protocol.MaxPacketSize) - n, remoteAddr, err := conn.ReadFromUDP(data) - if err != nil { - if strings.HasSuffix(err.Error(), "use of closed network connection") { - return nil - } - return err - } - data = data[:n] - if err := s.handlePacket(conn, remoteAddr, data); err != nil { - utils.Errorf("error handling packet: %s", err.Error()) - } - } -} - -// Close the server -func (s *Server) Close() error { - s.sessionsMutex.Lock() - for _, session := range s.sessions { - if session != nil { - s.sessionsMutex.Unlock() - _ = session.Close(nil) - s.sessionsMutex.Lock() - } - } - s.sessionsMutex.Unlock() - - s.connMutex.Lock() - conn := s.conn - s.conn = nil - s.connMutex.Unlock() - - if conn == nil { - return nil - } - return conn.Close() -} - -func (s *Server) handlePacket(conn *net.UDPConn, remoteAddr *net.UDPAddr, packet []byte) error { - if protocol.ByteCount(len(packet)) > protocol.MaxPacketSize { - return qerr.PacketTooLarge - } - - r := bytes.NewReader(packet) - - hdr, err := parsePublicHeader(r) - if err != nil { - return qerr.Error(qerr.InvalidPacketHeader, err.Error()) - } - hdr.Raw = packet[:len(packet)-r.Len()] - - // Send Version Negotiation Packet if the client is speaking a different protocol version - if hdr.VersionFlag && !protocol.IsSupportedVersion(hdr.VersionNumber) { - utils.Infof("Client offered version %d, sending VersionNegotiationPacket", hdr.VersionNumber) - _, err = conn.WriteToUDP(composeVersionNegotiation(hdr.ConnectionID), remoteAddr) - if err != nil { - return err - } - return nil - } - - s.sessionsMutex.RLock() - session, ok := s.sessions[hdr.ConnectionID] - s.sessionsMutex.RUnlock() - - if !ok { - utils.Infof("Serving new connection: %x, version %d from %v", hdr.ConnectionID, hdr.VersionNumber, remoteAddr) - session, err = s.newSession( - &udpConn{conn: conn, currentAddr: remoteAddr}, - hdr.VersionNumber, - hdr.ConnectionID, - s.scfg, - s.streamCallback, - s.closeCallback, - ) - if err != nil { - return err - } - go session.run() - s.sessionsMutex.Lock() - s.sessions[hdr.ConnectionID] = session - s.sessionsMutex.Unlock() - } - if session == nil { - // Late packet for closed session - return nil - } - session.handlePacket(remoteAddr, hdr, packet[len(packet)-r.Len():]) - return nil -} - -func (s *Server) closeCallback(id protocol.ConnectionID) { - s.sessionsMutex.Lock() - s.sessions[id] = nil - s.sessionsMutex.Unlock() -} - -func composeVersionNegotiation(connectionID protocol.ConnectionID) []byte { - fullReply := &bytes.Buffer{} - responsePublicHeader := publicHeader{ - ConnectionID: connectionID, - PacketNumber: 1, - VersionFlag: true, - } - // TODO: Update version number - err := responsePublicHeader.WritePublicHeader(fullReply, protocol.Version32) - if err != nil { - utils.Errorf("error composing version negotiation packet: %s", err.Error()) - } - fullReply.Write(protocol.SupportedVersionsAsTags) - return fullReply.Bytes() -} diff --git a/vendor/github.com/lucas-clemente/quic-go/server_test.go b/vendor/github.com/lucas-clemente/quic-go/server_test.go deleted file mode 100644 index 678270b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/server_test.go +++ /dev/null @@ -1,165 +0,0 @@ -package quic - -import ( - "net" - - "github.com/lucas-clemente/quic-go/crypto" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/testdata" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type mockSession struct { - connectionID protocol.ConnectionID - packetCount int - closed bool -} - -func (s *mockSession) handlePacket(addr interface{}, hdr *publicHeader, data []byte) { - s.packetCount++ -} - -func (s *mockSession) run() {} -func (s *mockSession) Close(error) error { s.closed = true; return nil } - -func newMockSession(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, streamCallback StreamCallback, closeCallback closeCallback) (packetHandler, error) { - return &mockSession{ - connectionID: connectionID, - }, nil -} - -var _ = Describe("Server", func() { - Describe("with mock session", func() { - var ( - server *Server - ) - - BeforeEach(func() { - server = &Server{ - sessions: map[protocol.ConnectionID]packetHandler{}, - newSession: newMockSession, - } - }) - - It("composes version negotiation packets", func() { - expected := append( - []byte{0x01 | 0x08 | 0x04, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - protocol.SupportedVersionsAsTags..., - ) - Expect(composeVersionNegotiation(1)).To(Equal(expected)) - }) - - It("creates new sessions", func() { - err := server.handlePacket(nil, nil, []byte{0x08, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x01}) - Expect(err).ToNot(HaveOccurred()) - Expect(server.sessions).To(HaveLen(1)) - Expect(server.sessions[0x4cfa9f9b668619f6].(*mockSession).connectionID).To(Equal(protocol.ConnectionID(0x4cfa9f9b668619f6))) - Expect(server.sessions[0x4cfa9f9b668619f6].(*mockSession).packetCount).To(Equal(1)) - }) - - It("assigns packets to existing sessions", func() { - err := server.handlePacket(nil, nil, []byte{0x08, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x01}) - Expect(err).ToNot(HaveOccurred()) - err = server.handlePacket(nil, nil, []byte{0x08, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x01}) - Expect(err).ToNot(HaveOccurred()) - Expect(server.sessions).To(HaveLen(1)) - Expect(server.sessions[0x4cfa9f9b668619f6].(*mockSession).connectionID).To(Equal(protocol.ConnectionID(0x4cfa9f9b668619f6))) - Expect(server.sessions[0x4cfa9f9b668619f6].(*mockSession).packetCount).To(Equal(2)) - }) - - It("closes and deletes sessions", func() { - pheader := []byte{0x09, 0xf6, 0x19, 0x86, 0x66, 0x9b, 0x9f, 0xfa, 0x4c, 0x51, 0x30, 0x33, 0x32, 0x01} - err := server.handlePacket(nil, nil, append(pheader, (&crypto.NullAEAD{}).Seal(0, pheader, nil)...)) - Expect(err).ToNot(HaveOccurred()) - Expect(server.sessions).To(HaveLen(1)) - server.closeCallback(0x4cfa9f9b668619f6) - // The server should now have closed the session, leaving a nil value in the sessions map - Expect(server.sessions).To(HaveLen(1)) - Expect(server.sessions[0x4cfa9f9b668619f6]).To(BeNil()) - }) - - It("closes sessions when Close is called", func() { - session := &mockSession{} - server.sessions[1] = session - err := server.Close() - Expect(err).NotTo(HaveOccurred()) - Expect(session.closed).To(BeTrue()) - }) - }) - - It("setups and responds with version negotiation", func(done Done) { - addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0") - Expect(err).ToNot(HaveOccurred()) - - server, err := NewServer("", testdata.GetTLSConfig(), nil) - Expect(err).ToNot(HaveOccurred()) - - serverConn, err := net.ListenUDP("udp", addr) - Expect(err).NotTo(HaveOccurred()) - - addr = serverConn.LocalAddr().(*net.UDPAddr) - - go func() { - defer GinkgoRecover() - err := server.Serve(serverConn) - Expect(err).ToNot(HaveOccurred()) - close(done) - }() - - clientConn, err := net.DialUDP("udp", nil, addr) - Expect(err).ToNot(HaveOccurred()) - - _, err = clientConn.Write([]byte{0x09, 0x01, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x01, 'Q', '0', '0', '0', 0x01}) - Expect(err).NotTo(HaveOccurred()) - data := make([]byte, 1000) - var n int - n, _, err = clientConn.ReadFromUDP(data) - Expect(err).NotTo(HaveOccurred()) - data = data[:n] - expected := append( - []byte{0xd, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, - protocol.SupportedVersionsAsTags..., - ) - Expect(data).To(Equal(expected)) - - err = server.Close() - Expect(err).ToNot(HaveOccurred()) - }) - - It("setups and responds with error on invalid frame", func(done Done) { - addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0") - Expect(err).ToNot(HaveOccurred()) - - server, err := NewServer("", testdata.GetTLSConfig(), nil) - Expect(err).ToNot(HaveOccurred()) - - serverConn, err := net.ListenUDP("udp", addr) - Expect(err).NotTo(HaveOccurred()) - - addr = serverConn.LocalAddr().(*net.UDPAddr) - - go func() { - defer GinkgoRecover() - err := server.Serve(serverConn) - Expect(err).ToNot(HaveOccurred()) - close(done) - }() - - clientConn, err := net.DialUDP("udp", nil, addr) - Expect(err).ToNot(HaveOccurred()) - - _, err = clientConn.Write([]byte{0x09, 0x01, 0, 0, 0, 0, 0, 0, 0, 0x01, 0x01, 'Q', '0', '0', '0', 0x01, 0x00}) - Expect(err).NotTo(HaveOccurred()) - data := make([]byte, 1000) - var n int - n, _, err = clientConn.ReadFromUDP(data) - Expect(err).NotTo(HaveOccurred()) - Expect(n).ToNot(BeZero()) - - err = server.Close() - Expect(err).ToNot(HaveOccurred()) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/session.go b/vendor/github.com/lucas-clemente/quic-go/session.go deleted file mode 100644 index 3be10b1..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/session.go +++ /dev/null @@ -1,698 +0,0 @@ -package quic - -import ( - "bytes" - "errors" - "fmt" - "sync" - "sync/atomic" - "time" - - "github.com/lucas-clemente/quic-go/ackhandler" - "github.com/lucas-clemente/quic-go/flowcontrol" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -type receivedPacket struct { - remoteAddr interface{} - publicHeader *publicHeader - data []byte -} - -var ( - errRstStreamOnInvalidStream = errors.New("RST_STREAM received for unknown stream") - errWindowUpdateOnInvalidStream = qerr.Error(qerr.InvalidWindowUpdateData, "WINDOW_UPDATE received for unknown stream") - errWindowUpdateOnClosedStream = errors.New("WINDOW_UPDATE received for an already closed stream") -) - -// StreamCallback gets a stream frame and returns a reply frame -type StreamCallback func(*Session, utils.Stream) - -// closeCallback is called when a session is closed -type closeCallback func(id protocol.ConnectionID) - -// A Session is a QUIC session -type Session struct { - connectionID protocol.ConnectionID - - streamCallback StreamCallback - closeCallback closeCallback - - conn connection - - streams map[protocol.StreamID]*stream - openStreamsCount uint32 - streamsMutex sync.RWMutex - - sentPacketHandler ackhandler.SentPacketHandler - receivedPacketHandler ackhandler.ReceivedPacketHandler - stopWaitingManager ackhandler.StopWaitingManager - windowUpdateManager *windowUpdateManager - blockedManager *blockedManager - streamFrameQueue *streamFrameQueue - - flowControlManager flowcontrol.FlowControlManager - // TODO: remove - flowController flowcontrol.FlowController // connection level flow controller - - unpacker *packetUnpacker - packer *packetPacker - - cryptoSetup *handshake.CryptoSetup - - receivedPackets chan receivedPacket - sendingScheduled chan struct{} - closeChan chan struct{} - closed uint32 // atomic bool - - undecryptablePackets []receivedPacket - aeadChanged chan struct{} - - smallPacketDelayedOccurranceTime time.Time - - connectionParametersManager *handshake.ConnectionParametersManager - - // Used to calculate the next packet number from the truncated wire - // representation, and sent back in public reset packets - lastRcvdPacketNumber protocol.PacketNumber - - lastNetworkActivityTime time.Time - - timer *time.Timer - currentDeadline time.Time - timerRead bool -} - -// newSession makes a new session -func newSession(conn connection, v protocol.VersionNumber, connectionID protocol.ConnectionID, sCfg *handshake.ServerConfig, streamCallback StreamCallback, closeCallback closeCallback) (packetHandler, error) { - stopWaitingManager := ackhandler.NewStopWaitingManager() - connectionParametersManager := handshake.NewConnectionParamatersManager() - - session := &Session{ - connectionID: connectionID, - conn: conn, - streamCallback: streamCallback, - closeCallback: closeCallback, - streams: make(map[protocol.StreamID]*stream), - sentPacketHandler: ackhandler.NewSentPacketHandler(stopWaitingManager), - receivedPacketHandler: ackhandler.NewReceivedPacketHandler(), - stopWaitingManager: stopWaitingManager, - flowControlManager: flowcontrol.NewFlowControlManager(connectionParametersManager), - flowController: flowcontrol.NewFlowController(0, connectionParametersManager), - windowUpdateManager: newWindowUpdateManager(), - blockedManager: newBlockedManager(), - streamFrameQueue: newStreamFrameQueue(), - receivedPackets: make(chan receivedPacket, protocol.MaxSessionUnprocessedPackets), - closeChan: make(chan struct{}, 1), - sendingScheduled: make(chan struct{}, 1), - connectionParametersManager: connectionParametersManager, - undecryptablePackets: make([]receivedPacket, 0, protocol.MaxUndecryptablePackets), - aeadChanged: make(chan struct{}, 1), - timer: time.NewTimer(0), - lastNetworkActivityTime: time.Now(), - } - - cryptoStream, _ := session.OpenStream(1) - var err error - session.cryptoSetup, err = handshake.NewCryptoSetup(connectionID, conn.IP(), v, sCfg, cryptoStream, session.connectionParametersManager, session.aeadChanged) - if err != nil { - return nil, err - } - - session.packer = newPacketPacker(connectionID, session.cryptoSetup, session.sentPacketHandler, session.connectionParametersManager, session.blockedManager, session.streamFrameQueue, v) - session.unpacker = &packetUnpacker{aead: session.cryptoSetup, version: v} - - return session, err -} - -// run the session main loop -func (s *Session) run() { - // Start the crypto stream handler - go func() { - if err := s.cryptoSetup.HandleCryptoStream(); err != nil { - s.Close(err) - } - }() - - for { - // Close immediately if requested - select { - case <-s.closeChan: - return - default: - } - - s.maybeResetTimer() - - var err error - select { - case <-s.closeChan: - return - case <-s.timer.C: - s.timerRead = true - // We do all the interesting stuff after the switch statement, so - // nothing to see here. - case <-s.sendingScheduled: - // We do all the interesting stuff after the switch statement, so - // nothing to see here. - case p := <-s.receivedPackets: - err = s.handlePacketImpl(p.remoteAddr, p.publicHeader, p.data) - if qErr, ok := err.(*qerr.QuicError); ok && qErr.ErrorCode == qerr.DecryptionFailure { - s.tryQueueingUndecryptablePacket(p) - continue - } - case <-s.aeadChanged: - s.tryDecryptingQueuedPackets() - } - - if err != nil { - s.Close(err) - } - - if err := s.maybeSendPacket(); err != nil { - s.Close(err) - } - if time.Now().Sub(s.lastNetworkActivityTime) >= s.connectionParametersManager.GetIdleConnectionStateLifetime() { - s.Close(qerr.Error(qerr.NetworkIdleTimeout, "No recent network activity.")) - } - s.garbageCollectStreams() - } -} - -func (s *Session) maybeResetTimer() { - nextDeadline := s.lastNetworkActivityTime.Add(s.connectionParametersManager.GetIdleConnectionStateLifetime()) - - if !s.smallPacketDelayedOccurranceTime.IsZero() { - // nextDeadline = utils.MinDuration(firstTimeout, s.smallPacketDelayedOccurranceTime.Add(protocol.SmallPacketSendDelay).Sub(now)) - nextDeadline = utils.MinTime(nextDeadline, s.smallPacketDelayedOccurranceTime.Add(protocol.SmallPacketSendDelay)) - } - if rtoTime := s.sentPacketHandler.TimeOfFirstRTO(); !rtoTime.IsZero() { - nextDeadline = utils.MinTime(nextDeadline, rtoTime) - } - - if nextDeadline.Equal(s.currentDeadline) { - // No need to reset the timer - return - } - - // We need to drain the timer if the value from its channel was not read yet. - // See https://groups.google.com/forum/#!topic/golang-dev/c9UUfASVPoU - if !s.timer.Stop() && !s.timerRead { - <-s.timer.C - } - s.timer.Reset(nextDeadline.Sub(time.Now())) - - s.timerRead = false - s.currentDeadline = nextDeadline -} - -func (s *Session) handlePacketImpl(remoteAddr interface{}, hdr *publicHeader, data []byte) error { - s.lastNetworkActivityTime = time.Now() - r := bytes.NewReader(data) - - // Calculate packet number - hdr.PacketNumber = protocol.InferPacketNumber( - hdr.PacketNumberLen, - s.lastRcvdPacketNumber, - hdr.PacketNumber, - ) - s.lastRcvdPacketNumber = hdr.PacketNumber - if utils.Debug() { - utils.Debugf("<- Reading packet 0x%x (%d bytes) for connection %x", hdr.PacketNumber, r.Size()+int64(len(hdr.Raw)), hdr.ConnectionID) - } - - // TODO: Only do this after authenticating - s.conn.setCurrentRemoteAddr(remoteAddr) - - packet, err := s.unpacker.Unpack(hdr.Raw, hdr, r) - if err != nil { - return err - } - - err = s.receivedPacketHandler.ReceivedPacket(hdr.PacketNumber, packet.entropyBit) - if err != nil { - return err - } - - return s.handleFrames(packet.frames) -} - -func (s *Session) handleFrames(fs []frames.Frame) error { - for _, ff := range fs { - var err error - frames.LogFrame(ff, false) - switch frame := ff.(type) { - case *frames.StreamFrame: - err = s.handleStreamFrame(frame) - // TODO: send RstStreamFrame - case *frames.AckFrame: - err = s.handleAckFrame(frame) - case *frames.ConnectionCloseFrame: - s.closeImpl(qerr.Error(frame.ErrorCode, frame.ReasonPhrase), true) - case *frames.GoawayFrame: - err = errors.New("unimplemented: handling GOAWAY frames") - case *frames.StopWaitingFrame: - err = s.receivedPacketHandler.ReceivedStopWaiting(frame) - case *frames.RstStreamFrame: - err = s.handleRstStreamFrame(frame) - case *frames.WindowUpdateFrame: - err = s.handleWindowUpdateFrame(frame) - case *frames.BlockedFrame: - case *frames.PingFrame: - default: - return errors.New("Session BUG: unexpected frame type") - } - - if err != nil { - switch err { - case ackhandler.ErrDuplicateOrOutOfOrderAck: - // Can happen e.g. when packets thought missing arrive late - case errRstStreamOnInvalidStream: - // Can happen when RST_STREAMs arrive early or late (?) - utils.Errorf("Ignoring error in session: %s", err.Error()) - case errWindowUpdateOnClosedStream: - // Can happen when we already sent the last StreamFrame with the FinBit, but the client already sent a WindowUpdate for this Stream - default: - return err - } - } - } - return nil -} - -// handlePacket handles a packet -func (s *Session) handlePacket(remoteAddr interface{}, hdr *publicHeader, data []byte) { - // Discard packets once the amount of queued packets is larger than - // the channel size, protocol.MaxSessionUnprocessedPackets - select { - case s.receivedPackets <- receivedPacket{remoteAddr: remoteAddr, publicHeader: hdr, data: data}: - default: - } -} - -func (s *Session) handleStreamFrame(frame *frames.StreamFrame) error { - s.streamsMutex.Lock() - defer s.streamsMutex.Unlock() - str, streamExists := s.streams[frame.StreamID] - - var err error - if !streamExists { - if !s.isValidStreamID(frame.StreamID) { - return qerr.InvalidStreamID - } - - str, err = s.newStreamImpl(frame.StreamID) - if err != nil { - return err - } - } - if str == nil { - // Stream is closed, ignore - return nil - } - err = str.AddStreamFrame(frame) - if err != nil { - return err - } - if !streamExists { - s.streamCallback(s, str) - } - return nil -} - -func (s *Session) isValidStreamID(streamID protocol.StreamID) bool { - return streamID%2 == 1 -} - -func (s *Session) handleWindowUpdateFrame(frame *frames.WindowUpdateFrame) error { - if frame.StreamID == 0 { - updated := s.flowController.UpdateSendWindow(frame.ByteOffset) - if updated { - s.blockedManager.RemoveBlockedStream(0) - } - s.streamsMutex.RLock() - // tell all streams that the connection-level was updated - for _, stream := range s.streams { - if stream != nil { - stream.ConnectionFlowControlWindowUpdated() - } - } - s.streamsMutex.RUnlock() - } else { - s.streamsMutex.RLock() - defer s.streamsMutex.RUnlock() - stream, streamExists := s.streams[frame.StreamID] - if !streamExists { - return errWindowUpdateOnInvalidStream - } - if stream == nil { - return errWindowUpdateOnClosedStream - } - - updated := stream.UpdateSendFlowControlWindow(frame.ByteOffset) - if updated { - s.blockedManager.RemoveBlockedStream(frame.StreamID) - } - } - - return nil -} - -// TODO: Handle frame.byteOffset -func (s *Session) handleRstStreamFrame(frame *frames.RstStreamFrame) error { - s.streamsMutex.RLock() - str, streamExists := s.streams[frame.StreamID] - s.streamsMutex.RUnlock() - if !streamExists || str == nil { - return errRstStreamOnInvalidStream - } - s.closeStreamWithError(str, fmt.Errorf("RST_STREAM received with code %d", frame.ErrorCode)) - return nil -} - -func (s *Session) handleAckFrame(frame *frames.AckFrame) error { - if err := s.sentPacketHandler.ReceivedAck(frame); err != nil { - return err - } - return nil -} - -// Close the connection. If err is nil it will be set to qerr.PeerGoingAway. -func (s *Session) Close(e error) error { - return s.closeImpl(e, false) -} - -func (s *Session) closeImpl(e error, remoteClose bool) error { - // Only close once - if !atomic.CompareAndSwapUint32(&s.closed, 0, 1) { - return nil - } - s.closeChan <- struct{}{} - - if e == nil { - e = qerr.PeerGoingAway - } - - utils.Errorf("Closing session with error: %s", e.Error()) - s.closeStreamsWithError(e) - s.closeCallback(s.connectionID) - - if remoteClose { - return nil - } - - quicErr := qerr.ToQuicError(e) - if quicErr.ErrorCode == qerr.DecryptionFailure { - return s.sendPublicReset(s.lastRcvdPacketNumber) - } - return s.sendConnectionClose(quicErr) -} - -func (s *Session) closeStreamsWithError(err error) { - s.streamsMutex.Lock() - defer s.streamsMutex.Unlock() - for _, str := range s.streams { - if str == nil { - continue - } - s.closeStreamWithError(str, err) - } -} - -func (s *Session) closeStreamWithError(str *stream, err error) { - s.streamFrameQueue.RemoveStream(str.StreamID()) - str.RegisterError(err) -} - -// TODO: try sending more than one packet -func (s *Session) maybeSendPacket() error { - if !s.smallPacketDelayedOccurranceTime.IsZero() && time.Now().Sub(s.smallPacketDelayedOccurranceTime) > protocol.SmallPacketSendDelay { - return s.sendPacket() - } - - // always send out retransmissions immediately. No need to check the size of the packet - // in the edge cases where a belated ACK was received for a packet that was already queued for retransmission, we might send out a small packet. However, this shouldn't happen very often - if s.sentPacketHandler.ProbablyHasPacketForRetransmission() { - return s.sendPacket() - } - - if !s.sentPacketHandler.CongestionAllowsSending() { - return nil - } - - var maxPacketSize protocol.ByteCount // the maximum size of a packet we could send out at this moment - - // we only estimate the size of the StopWaitingFrame here - stopWaitingFrame := s.stopWaitingManager.GetStopWaitingFrame() - if stopWaitingFrame != nil { - // The actual size of a StopWaitingFrame depends on the packet number of the packet it is sent with, and it's easier here to neglect the fact the StopWaitingFrame could be 5 bytes smaller than calculated here - maxPacketSize += 8 - } - - ack, err := s.receivedPacketHandler.GetAckFrame(false) - if err != nil { - return err - } - - if ack != nil { - ackLength, _ := ack.MinLength() // MinLength never errors for an ACK frame - maxPacketSize += ackLength - } - - // note that maxPacketSize can get (much) larger than protocol.MaxPacketSize if there is a long queue of StreamFrames - maxPacketSize += s.streamFrameQueue.ByteLen() - - if maxPacketSize > protocol.SmallPacketPayloadSizeThreshold { - return s.sendPacket() - } - - if maxPacketSize == 0 { - return nil - } - - if s.smallPacketDelayedOccurranceTime.IsZero() { - s.smallPacketDelayedOccurranceTime = time.Now() - } - - return nil -} - -func (s *Session) sendPacket() error { - s.smallPacketDelayedOccurranceTime = time.Time{} // zero - - err := s.sentPacketHandler.CheckForError() - if err != nil { - return err - } - - if !s.sentPacketHandler.CongestionAllowsSending() { - return nil - } - - var controlFrames []frames.Frame - - // check for retransmissions first - for { - retransmitPacket := s.sentPacketHandler.DequeuePacketForRetransmission() - if retransmitPacket == nil { - break - } - utils.Debugf("\tDequeueing retransmission for packet 0x%x", retransmitPacket.PacketNumber) - s.stopWaitingManager.RegisterPacketForRetransmission(retransmitPacket) - // resend the frames that were in the packet - controlFrames = append(controlFrames, retransmitPacket.GetControlFramesForRetransmission()...) - for _, streamFrame := range retransmitPacket.GetStreamFramesForRetransmission() { - s.packer.AddHighPrioStreamFrame(*streamFrame) - } - } - - windowUpdateFrames := s.windowUpdateManager.GetWindowUpdateFrames() - - for _, wuf := range windowUpdateFrames { - controlFrames = append(controlFrames, wuf) - } - - ack, err := s.receivedPacketHandler.GetAckFrame(true) - if err != nil { - return err - } - if ack != nil { - controlFrames = append(controlFrames, ack) - } - - stopWaitingFrame := s.stopWaitingManager.GetStopWaitingFrame() - packet, err := s.packer.PackPacket(stopWaitingFrame, controlFrames) - - if err != nil { - return err - } - if packet == nil { - return nil - } - - err = s.sentPacketHandler.SentPacket(&ackhandler.Packet{ - PacketNumber: packet.number, - Frames: packet.frames, - EntropyBit: packet.entropyBit, - Length: protocol.ByteCount(len(packet.raw)), - }) - if err != nil { - return err - } - - s.stopWaitingManager.SentStopWaitingWithPacket(packet.number) - - s.logPacket(packet) - - err = s.conn.write(packet.raw) - if err != nil { - return err - } - - if s.streamFrameQueue.Len() > 0 { - s.scheduleSending() - } - - return nil -} - -func (s *Session) sendConnectionClose(quicErr *qerr.QuicError) error { - packet, err := s.packer.PackConnectionClose(&frames.ConnectionCloseFrame{ErrorCode: quicErr.ErrorCode, ReasonPhrase: quicErr.ErrorMessage}) - if err != nil { - return err - } - if packet == nil { - return errors.New("Session BUG: expected packet not to be nil") - } - s.logPacket(packet) - return s.conn.write(packet.raw) -} - -func (s *Session) logPacket(packet *packedPacket) { - if !utils.Debug() { - // We don't need to allocate the slices for calling the format functions - return - } - if utils.Debug() { - utils.Debugf("-> Sending packet 0x%x (%d bytes)", packet.number, len(packet.raw)) - for _, frame := range packet.frames { - frames.LogFrame(frame, true) - } - } -} - -// queueStreamFrame queues a frame for sending to the client -func (s *Session) queueStreamFrame(frame *frames.StreamFrame) error { - s.packer.AddStreamFrame(*frame) - s.scheduleSending() - return nil -} - -// updateReceiveFlowControlWindow updates the flow control window for a stream -func (s *Session) updateReceiveFlowControlWindow(streamID protocol.StreamID, byteOffset protocol.ByteCount) error { - s.windowUpdateManager.SetStreamOffset(streamID, byteOffset) - return nil -} - -func (s *Session) streamBlocked(streamID protocol.StreamID, byteOffset protocol.ByteCount) { - s.packer.AddBlocked(streamID, byteOffset) -} - -// OpenStream creates a new stream open for reading and writing -func (s *Session) OpenStream(id protocol.StreamID) (utils.Stream, error) { - s.streamsMutex.Lock() - defer s.streamsMutex.Unlock() - return s.newStreamImpl(id) -} - -// GetOrOpenStream returns an existing stream with the given id, or opens a new stream -func (s *Session) GetOrOpenStream(id protocol.StreamID) (utils.Stream, error) { - s.streamsMutex.Lock() - defer s.streamsMutex.Unlock() - if stream, ok := s.streams[id]; ok { - return stream, nil - } - return s.newStreamImpl(id) -} - -// The streamsMutex is locked by OpenStream or GetOrOpenStream before calling this function. -func (s *Session) newStreamImpl(id protocol.StreamID) (*stream, error) { - maxAllowedStreams := uint32(protocol.MaxStreamsMultiplier * float32(s.connectionParametersManager.GetMaxStreamsPerConnection())) - if atomic.LoadUint32(&s.openStreamsCount) >= maxAllowedStreams { - go s.Close(qerr.TooManyOpenStreams) - return nil, qerr.TooManyOpenStreams - } - if _, ok := s.streams[id]; ok { - return nil, fmt.Errorf("Session: stream with ID %d already exists", id) - } - stream, err := newStream(s, s.connectionParametersManager, s.flowController, s.flowControlManager, id) - if err != nil { - return nil, err - } - - // TODO: find a better solution for determining which streams contribute to connection level flow control - if id == 1 || id == 3 { - s.flowControlManager.NewStream(id, false) - } else { - s.flowControlManager.NewStream(id, true) - } - - atomic.AddUint32(&s.openStreamsCount, 1) - s.streams[id] = stream - return stream, nil -} - -// garbageCollectStreams goes through all streams and removes EOF'ed streams -// from the streams map. -func (s *Session) garbageCollectStreams() { - s.streamsMutex.Lock() - defer s.streamsMutex.Unlock() - for k, v := range s.streams { - if v == nil { - continue - } - if v.finishedWriting() { - s.blockedManager.RemoveBlockedStream(k) - } - if v.finishedReading() { - s.windowUpdateManager.RemoveStream(k) - } - if v.finished() { - utils.Debugf("Garbage-collecting stream %d", k) - atomic.AddUint32(&s.openStreamsCount, ^uint32(0)) // decrement - s.streams[k] = nil - } - } -} - -func (s *Session) sendPublicReset(rejectedPacketNumber protocol.PacketNumber) error { - utils.Infof("Sending public reset for connection %x, packet number %d", s.connectionID, rejectedPacketNumber) - return s.conn.write(writePublicReset(s.connectionID, rejectedPacketNumber, 0)) -} - -// scheduleSending signals that we have data for sending -func (s *Session) scheduleSending() { - select { - case s.sendingScheduled <- struct{}{}: - default: - } -} - -func (s *Session) tryQueueingUndecryptablePacket(p receivedPacket) { - utils.Debugf("Queueing packet 0x%x for later decryption", p.publicHeader.PacketNumber) - if len(s.undecryptablePackets)+1 >= protocol.MaxUndecryptablePackets { - s.Close(qerr.Error(qerr.DecryptionFailure, "too many undecryptable packets received")) - } - s.undecryptablePackets = append(s.undecryptablePackets, p) -} - -func (s *Session) tryDecryptingQueuedPackets() { - for _, p := range s.undecryptablePackets { - s.handlePacket(p.remoteAddr, p.publicHeader, p.data) - } - s.undecryptablePackets = s.undecryptablePackets[:0] -} diff --git a/vendor/github.com/lucas-clemente/quic-go/session_test.go b/vendor/github.com/lucas-clemente/quic-go/session_test.go deleted file mode 100644 index 5e7a1a8..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/session_test.go +++ /dev/null @@ -1,768 +0,0 @@ -package quic - -import ( - "bytes" - "errors" - "io" - "net" - "runtime" - "sync/atomic" - "time" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/lucas-clemente/quic-go/ackhandler" - "github.com/lucas-clemente/quic-go/crypto" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/testdata" - "github.com/lucas-clemente/quic-go/utils" -) - -type mockConnection struct { - written [][]byte -} - -func (m *mockConnection) write(p []byte) error { - m.written = append(m.written, p) - return nil -} - -func (*mockConnection) setCurrentRemoteAddr(addr interface{}) {} -func (*mockConnection) IP() net.IP { return nil } - -var _ = Describe("Session", func() { - var ( - session *Session - streamCallbackCalled bool - closeCallbackCalled bool - conn *mockConnection - ) - - BeforeEach(func() { - conn = &mockConnection{} - streamCallbackCalled = false - closeCallbackCalled = false - - signer, err := crypto.NewProofSource(testdata.GetTLSConfig()) - Expect(err).ToNot(HaveOccurred()) - kex, err := crypto.NewCurve25519KEX() - Expect(err).NotTo(HaveOccurred()) - scfg, err := handshake.NewServerConfig(kex, signer) - Expect(err).NotTo(HaveOccurred()) - pSession, err := newSession( - conn, - 0, - 0, - scfg, - func(*Session, utils.Stream) { streamCallbackCalled = true }, - func(protocol.ConnectionID) { closeCallbackCalled = true }, - ) - Expect(err).NotTo(HaveOccurred()) - session = pSession.(*Session) - Expect(session.streams).To(HaveLen(1)) // Crypto stream - }) - - Context("when handling stream frames", func() { - It("makes new streams", func() { - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - }) - Expect(session.streams).To(HaveLen(2)) - Expect(streamCallbackCalled).To(BeTrue()) - p := make([]byte, 4) - _, err := session.streams[5].Read(p) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(Equal([]byte{0xde, 0xca, 0xfb, 0xad})) - }) - - It("rejects streams with even StreamIDs", func() { - err := session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 4, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - }) - Expect(err).To(MatchError(qerr.InvalidStreamID)) - }) - - It("does not reject existing streams with even StreamIDs", func() { - _, err := session.OpenStream(4) - Expect(err).ToNot(HaveOccurred()) - err = session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 4, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - }) - Expect(err).ToNot(HaveOccurred()) - }) - - It("handles existing streams", func() { - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca}, - }) - Expect(session.streams).To(HaveLen(2)) - Expect(streamCallbackCalled).To(BeTrue()) - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Offset: 2, - Data: []byte{0xfb, 0xad}, - }) - Expect(session.streams).To(HaveLen(2)) - p := make([]byte, 4) - _, err := session.streams[5].Read(p) - Expect(err).ToNot(HaveOccurred()) - Expect(p).To(Equal([]byte{0xde, 0xca, 0xfb, 0xad})) - }) - - It("does not delete streams with Close()", func() { - str, err := session.OpenStream(5) - Expect(err).ToNot(HaveOccurred()) - str.Close() - session.garbageCollectStreams() - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).ToNot(BeNil()) - }) - - It("does not delete streams with FIN bit", func() { - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - FinBit: true, - }) - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).ToNot(BeNil()) - Expect(streamCallbackCalled).To(BeTrue()) - p := make([]byte, 4) - _, err := session.streams[5].Read(p) - Expect(err).To(MatchError(io.EOF)) - Expect(p).To(Equal([]byte{0xde, 0xca, 0xfb, 0xad})) - session.garbageCollectStreams() - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).ToNot(BeNil()) - }) - - It("closes streams with FIN bit & close", func() { - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - FinBit: true, - }) - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).ToNot(BeNil()) - Expect(streamCallbackCalled).To(BeTrue()) - p := make([]byte, 4) - _, err := session.streams[5].Read(p) - Expect(err).To(MatchError(io.EOF)) - Expect(p).To(Equal([]byte{0xde, 0xca, 0xfb, 0xad})) - session.garbageCollectStreams() - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).ToNot(BeNil()) - // We still need to close the stream locally - session.streams[5].Close() - session.garbageCollectStreams() - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).To(BeNil()) - }) - - It("closes streams with error", func() { - testErr := errors.New("test") - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - }) - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).ToNot(BeNil()) - Expect(streamCallbackCalled).To(BeTrue()) - p := make([]byte, 4) - _, err := session.streams[5].Read(p) - Expect(err).ToNot(HaveOccurred()) - session.closeStreamsWithError(testErr) - _, err = session.streams[5].Read(p) - Expect(err).To(MatchError(testErr)) - session.garbageCollectStreams() - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).To(BeNil()) - }) - - It("removes queued StreamFrames from StreamFrameQueue when closing with an error", func() { - testErr := errors.New("test") - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - }) - f := frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar"), - } - session.streamFrameQueue.Push(&f, true) - Expect(session.streams[5]).ToNot(BeNil()) - session.closeStreamsWithError(testErr) - Expect(session.streamFrameQueue.Pop(1000)).To(BeNil()) - }) - - PIt("removes closed streams from BlockedManager", func() { - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - }) - Expect(session.streams[5]).ToNot(BeNil()) - session.blockedManager.AddBlockedStream(5, 4) - Expect(session.blockedManager.blockedStreams).To(HaveKey(protocol.StreamID(5))) - err := session.streams[5].Close() - Expect(err).ToNot(HaveOccurred()) - session.garbageCollectStreams() - Expect(session.blockedManager.blockedStreams).ToNot(HaveKey(protocol.StreamID(5))) - }) - - It("removes closed streams from WindowUpdateManager", func() { - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{0xde, 0xca, 0xfb, 0xad}, - }) - session.updateReceiveFlowControlWindow(5, 0x1337) - session.streams[5].eof = 1 - session.garbageCollectStreams() - Expect(session.windowUpdateManager.streamOffsets).ToNot(HaveKey(protocol.StreamID(5))) - }) - - It("closes empty streams with error", func() { - testErr := errors.New("test") - session.newStreamImpl(5) - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).ToNot(BeNil()) - session.closeStreamsWithError(testErr) - _, err := session.streams[5].Read([]byte{0}) - Expect(err).To(MatchError(testErr)) - session.garbageCollectStreams() - Expect(session.streams).To(HaveLen(2)) - Expect(session.streams[5]).To(BeNil()) - }) - - It("informs the FlowControlManager about new streams", func() { - // since the stream doesn't yet exist, this will throw an error - err := session.flowControlManager.UpdateHighestReceived(5, 1000) - Expect(err).To(HaveOccurred()) - session.newStreamImpl(5) - err = session.flowControlManager.UpdateHighestReceived(5, 2000) - Expect(err).ToNot(HaveOccurred()) - }) - - It("ignores streams that existed previously", func() { - session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{}, - FinBit: true, - }) - _, err := session.streams[5].Read([]byte{0}) - Expect(err).To(MatchError(io.EOF)) - session.streams[5].Close() - session.garbageCollectStreams() - err = session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte{}, - }) - Expect(err).To(BeNil()) - }) - }) - - Context("handling RST_STREAM frames", func() { - It("closes the receiving streams for writing and reading", func() { - s, err := session.OpenStream(5) - Expect(err).ToNot(HaveOccurred()) - err = session.handleRstStreamFrame(&frames.RstStreamFrame{ - StreamID: 5, - ErrorCode: 42, - }) - Expect(err).ToNot(HaveOccurred()) - n, err := s.Write([]byte{0}) - Expect(n).To(BeZero()) - Expect(err).To(MatchError("RST_STREAM received with code 42")) - n, err = s.Read([]byte{0}) - Expect(n).To(BeZero()) - Expect(err).To(MatchError("RST_STREAM received with code 42")) - }) - - It("deletes queued StreamFrames from the StreamFrameQueue", func() { - _, err := session.OpenStream(5) - Expect(err).ToNot(HaveOccurred()) - f := frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar"), - } - session.streamFrameQueue.Push(&f, false) - err = session.handleRstStreamFrame(&frames.RstStreamFrame{ - StreamID: 5, - ErrorCode: 42, - }) - Expect(err).ToNot(HaveOccurred()) - Expect(session.streamFrameQueue.Pop(1000)).To(BeNil()) - }) - - It("errors when the stream is not known", func() { - err := session.handleRstStreamFrame(&frames.RstStreamFrame{ - StreamID: 5, - ErrorCode: 42, - }) - Expect(err).To(MatchError(errRstStreamOnInvalidStream)) - }) - }) - - Context("handling WINDOW_UPDATE frames", func() { - It("updates the Flow Control Windows of a stream", func() { - _, err := session.OpenStream(5) - Expect(err).ToNot(HaveOccurred()) - err = session.handleWindowUpdateFrame(&frames.WindowUpdateFrame{ - StreamID: 5, - ByteOffset: 0x8000, - }) - Expect(err).ToNot(HaveOccurred()) - Expect(session.streams[5].flowController.SendWindowSize()).To(Equal(protocol.ByteCount(0x8000))) - }) - - It("updates the Flow Control Windows of the connection", func() { - err := session.handleWindowUpdateFrame(&frames.WindowUpdateFrame{ - StreamID: 0, - ByteOffset: 0x800000, - }) - Expect(err).ToNot(HaveOccurred()) - Expect(session.flowController.SendWindowSize()).To(Equal(protocol.ByteCount(0x800000))) - }) - - It("errors when the stream is not known", func() { - err := session.handleWindowUpdateFrame(&frames.WindowUpdateFrame{ - StreamID: 5, - ByteOffset: 1337, - }) - Expect(err).To(MatchError(errWindowUpdateOnInvalidStream)) - }) - - It("errors when receiving a WindowUpdateFrame for a closed stream", func() { - session.streams[5] = nil // this is what the garbageCollectStreams() does when a Stream is closed - err := session.handleWindowUpdateFrame(&frames.WindowUpdateFrame{ - StreamID: 5, - ByteOffset: 1337, - }) - Expect(err).To(MatchError(errWindowUpdateOnClosedStream)) - }) - }) - - Context("closing", func() { - var ( - nGoRoutinesBefore int - ) - - BeforeEach(func() { - time.Sleep(10 * time.Millisecond) // Wait for old goroutines to finish - nGoRoutinesBefore = runtime.NumGoroutine() - go session.run() - Eventually(func() int { return runtime.NumGoroutine() }).Should(Equal(nGoRoutinesBefore + 2)) - }) - - It("shuts down without error", func() { - session.Close(nil) - Expect(closeCallbackCalled).To(BeTrue()) - Eventually(func() int { return runtime.NumGoroutine() }).Should(Equal(nGoRoutinesBefore)) - Expect(conn.written).To(HaveLen(1)) - Expect(conn.written[0][len(conn.written[0])-7:]).To(Equal([]byte{0x02, byte(qerr.PeerGoingAway), 0, 0, 0, 0, 0})) - }) - - It("only closes once", func() { - session.Close(nil) - session.Close(nil) - Eventually(func() int { return runtime.NumGoroutine() }).Should(Equal(nGoRoutinesBefore)) - Expect(conn.written).To(HaveLen(1)) - }) - - It("closes streams with proper error", func() { - testErr := errors.New("test error") - s, err := session.OpenStream(5) - Expect(err).NotTo(HaveOccurred()) - session.Close(testErr) - Expect(closeCallbackCalled).To(BeTrue()) - Eventually(func() int { return runtime.NumGoroutine() }).Should(Equal(nGoRoutinesBefore)) - n, err := s.Read([]byte{0}) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(testErr)) - n, err = s.Write([]byte{0}) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(testErr)) - }) - }) - - Context("sending packets", func() { - It("sends ack frames", func() { - packetNumber := protocol.PacketNumber(0x0135) - var entropy ackhandler.EntropyAccumulator - session.receivedPacketHandler.ReceivedPacket(packetNumber, true) - entropy.Add(packetNumber, true) - err := session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(1)) - // test for the beginning of an ACK frame: Entropy until LargestObserved - Expect(conn.written[0]).To(ContainSubstring(string([]byte{byte(entropy), 0x35, 0x01}))) - }) - - It("sends queued stream frames", func() { - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - }) - session.receivedPacketHandler.ReceivedPacket(1, true) - err := session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(1)) - // test for the beginning of an ACK frame: TypeByte until LargestObserved - Expect(conn.written[0]).To(ContainSubstring(string([]byte{0x40, 0x2, 0x1}))) - Expect(conn.written[0]).To(ContainSubstring(string("foobar"))) - }) - - It("sends a WindowUpdate frame", func() { - _, err := session.OpenStream(5) - Expect(err).ToNot(HaveOccurred()) - err = session.updateReceiveFlowControlWindow(5, 0xDECAFBAD) - Expect(err).ToNot(HaveOccurred()) - err = session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(1)) - Expect(conn.written[0]).To(ContainSubstring(string([]byte{0x04, 0x05, 0, 0, 0}))) - }) - - It("repeats a WindowUpdate frame in WindowUpdateNumRepetitions packets", func() { - _, err := session.OpenStream(5) - Expect(err).ToNot(HaveOccurred()) - err = session.updateReceiveFlowControlWindow(5, 0xDECAFBAD) - Expect(err).ToNot(HaveOccurred()) - for i := uint8(0); i < protocol.WindowUpdateNumRepetitions; i++ { - err = session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written[i]).To(ContainSubstring(string([]byte{0x04, 0x05, 0, 0, 0}))) - } - Expect(conn.written).To(HaveLen(int(protocol.WindowUpdateNumRepetitions))) - err = session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(int(protocol.WindowUpdateNumRepetitions))) // no packet was sent - }) - - It("sends public reset", func() { - err := session.sendPublicReset(1) - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(1)) - Expect(conn.written[0]).To(ContainSubstring(string([]byte("PRST")))) - }) - - PContext("Blocked", func() { - It("queues a Blocked frames", func() { - len := 500 - frame := frames.StreamFrame{ - StreamID: 0x1337, - Data: bytes.Repeat([]byte{'f'}, len), - } - session.streamBlocked(0x1337, protocol.ByteCount(len)) - session.packer.AddStreamFrame(frame) - err := session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(1)) - Expect(conn.written[0]).To(ContainSubstring(string([]byte{0x05, 0x37, 0x13, 0, 0}))) - }) - - It("does not send a blocked frame for a stream if a WindowUpdate arrived before", func() { - len := 500 - _, err := session.OpenStream(0x1337) - Expect(err).ToNot(HaveOccurred()) - session.streamBlocked(0x1337, protocol.ByteCount(len)) - wuf := frames.WindowUpdateFrame{ - StreamID: 0x1337, - ByteOffset: protocol.ByteCount(len * 2), - } - err = session.handleWindowUpdateFrame(&wuf) - Expect(err).ToNot(HaveOccurred()) - Expect(session.blockedManager.GetBlockedFrame(0x1337, protocol.ByteCount(len))).To(BeNil()) - }) - - It("does not send a blocked frame for the connection if a WindowUpdate arrived before", func() { - len := 500 - session.streamBlocked(0, protocol.ByteCount(len)) - wuf := frames.WindowUpdateFrame{ - StreamID: 0, - ByteOffset: protocol.ByteCount(len * 2), - } - err := session.handleWindowUpdateFrame(&wuf) - Expect(err).ToNot(HaveOccurred()) - Expect(session.blockedManager.GetBlockedFrame(0, protocol.ByteCount(len))).To(BeNil()) - }) - }) - }) - - Context("retransmissions", func() { - It("sends a StreamFrame from a packet queued for retransmission", func() { - f := frames.StreamFrame{ - StreamID: 0x5, - Data: []byte("foobar1234567"), - } - p := ackhandler.Packet{ - PacketNumber: 0x1337, - Frames: []frames.Frame{&f}, - } - sph := newMockSentPacketHandler() - sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandler.Packet{&p} - session.sentPacketHandler = sph - - err := session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(1)) - Expect(conn.written[0]).To(ContainSubstring("foobar1234567")) - }) - - It("sends a StreamFrame from a packet queued for retransmission", func() { - f1 := frames.StreamFrame{ - StreamID: 0x5, - Data: []byte("foobar"), - } - f2 := frames.StreamFrame{ - StreamID: 0x7, - Data: []byte("loremipsum"), - } - p1 := ackhandler.Packet{ - PacketNumber: 0x1337, - Frames: []frames.Frame{&f1}, - } - p2 := ackhandler.Packet{ - PacketNumber: 0x1338, - Frames: []frames.Frame{&f2}, - } - sph := newMockSentPacketHandler() - sph.(*mockSentPacketHandler).retransmissionQueue = []*ackhandler.Packet{&p1, &p2} - session.sentPacketHandler = sph - - err := session.sendPacket() - Expect(err).NotTo(HaveOccurred()) - Expect(conn.written).To(HaveLen(1)) - Expect(conn.written[0]).To(ContainSubstring("foobar")) - Expect(conn.written[0]).To(ContainSubstring("loremipsum")) - }) - }) - - Context("scheduling sending", func() { - It("sends after queuing a stream frame", func() { - Expect(session.sendingScheduled).NotTo(Receive()) - err := session.queueStreamFrame(&frames.StreamFrame{StreamID: 1}) - Expect(err).ToNot(HaveOccurred()) - // Try again, so that we detect blocking scheduleSending - err = session.queueStreamFrame(&frames.StreamFrame{StreamID: 1}) - Expect(err).ToNot(HaveOccurred()) - Expect(session.sendingScheduled).To(Receive()) - }) - - Context("bundling of small packets", func() { - It("bundles two small frames into one packet", func() { - go session.run() - - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar1"), - }) - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar2"), - }) - time.Sleep(10 * time.Millisecond) - Expect(conn.written).To(HaveLen(1)) - }) - - It("sends out two big frames in two packet", func() { - go session.run() - - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: bytes.Repeat([]byte{'e'}, int(protocol.SmallPacketPayloadSizeThreshold+50)), - }) - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: bytes.Repeat([]byte{'f'}, int(protocol.SmallPacketPayloadSizeThreshold+50)), - }) - time.Sleep(10 * time.Millisecond) - Expect(conn.written).To(HaveLen(2)) - }) - - It("sends out two small frames that are written to long after one another into two packet", func() { - go session.run() - - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar1"), - }) - time.Sleep(20 * protocol.SmallPacketSendDelay) - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar2"), - }) - time.Sleep(10 * time.Millisecond) - Expect(conn.written).To(HaveLen(2)) - }) - - It("sends a queued ACK frame only once", func() { - go session.run() - - packetNumber := protocol.PacketNumber(0x1337) - session.receivedPacketHandler.ReceivedPacket(packetNumber, true) - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar1"), - }) - time.Sleep(20 * protocol.SmallPacketSendDelay) - session.queueStreamFrame(&frames.StreamFrame{ - StreamID: 5, - Data: []byte("foobar2"), - }) - time.Sleep(10 * time.Millisecond) - Expect(conn.written).To(HaveLen(2)) - Expect(conn.written[0]).To(ContainSubstring(string([]byte{0x37, 0x13}))) - Expect(conn.written[1]).ToNot(ContainSubstring(string([]byte{0x37, 0x13}))) - }) - }) - }) - - It("closes when crypto stream errors", func() { - go session.run() - s, err := session.OpenStream(3) - Expect(err).NotTo(HaveOccurred()) - err = session.handleStreamFrame(&frames.StreamFrame{ - StreamID: 1, - Data: []byte("4242\x00\x00\x00\x00"), - }) - Expect(err).NotTo(HaveOccurred()) - Eventually(func() bool { return atomic.LoadUint32(&session.closed) != 0 }).Should(BeTrue()) - _, err = s.Write([]byte{}) - Expect(err).To(MatchError(qerr.InvalidCryptoMessageType)) - }) - - It("sends public reset after too many undecryptable packets", func() { - // Write protocol.MaxUndecryptablePackets and expect a public reset to happen - for i := 0; i < protocol.MaxUndecryptablePackets; i++ { - hdr := &publicHeader{ - PacketNumber: protocol.PacketNumber(i + 1), - } - session.handlePacket(nil, hdr, []byte("foobar")) - } - session.run() - - Expect(conn.written).To(HaveLen(1)) - Expect(conn.written[0]).To(ContainSubstring(string([]byte("PRST")))) - }) - - It("unqueues undecryptable packets for later decryption", func() { - session.undecryptablePackets = []receivedPacket{{ - nil, - &publicHeader{PacketNumber: protocol.PacketNumber(42)}, - nil, - }} - Expect(session.receivedPackets).NotTo(Receive()) - session.tryDecryptingQueuedPackets() - Expect(session.undecryptablePackets).To(BeEmpty()) - Expect(session.receivedPackets).To(Receive()) - }) - - It("times out", func(done Done) { - session.connectionParametersManager.SetFromMap(map[handshake.Tag][]byte{ - handshake.TagICSL: {0, 0, 0, 0}, - }) - session.packer.connectionParametersManager = session.connectionParametersManager - session.packer.sentPacketHandler = newMockSentPacketHandler() - session.run() // Would normally not return - Expect(conn.written[0]).To(ContainSubstring("No recent network activity.")) - close(done) - }, 3) - - It("errors when the SentPacketHandler has too many packets tracked", func() { - streamFrame := frames.StreamFrame{StreamID: 5, Data: []byte("foobar")} - for i := uint32(1); i < protocol.MaxTrackedSentPackets+10; i++ { - packet := ackhandler.Packet{PacketNumber: protocol.PacketNumber(i), Frames: []frames.Frame{&streamFrame}, Length: 1} - err := session.sentPacketHandler.SentPacket(&packet) - Expect(err).ToNot(HaveOccurred()) - } - // now session.sentPacketHandler.CheckForError will return an error - err := session.sendPacket() - Expect(err).To(MatchError(ackhandler.ErrTooManyTrackedSentPackets)) - }) - - It("stores up to MaxSessionUnprocessedPackets packets", func(done Done) { - // Nothing here should block - for i := 0; i < protocol.MaxSessionUnprocessedPackets+10; i++ { - session.handlePacket(nil, nil, nil) - } - close(done) - }, 0.5) - - It("retransmits RTO packets", func() { - // We simulate consistently low RTTs, so that the test works faster - n := protocol.PacketNumber(10) - for p := protocol.PacketNumber(1); p < n; p++ { - err := session.sentPacketHandler.SentPacket(&ackhandler.Packet{PacketNumber: p, Length: 1}) - Expect(err).NotTo(HaveOccurred()) - time.Sleep(time.Microsecond) - err = session.sentPacketHandler.ReceivedAck(&frames.AckFrame{LargestObserved: p}) - Expect(err).NotTo(HaveOccurred()) - } - // Now, we send a single packet, and expect that it was retransmitted later - go session.run() - Expect(conn.written).To(BeEmpty()) - err := session.sentPacketHandler.SentPacket(&ackhandler.Packet{ - PacketNumber: n, - Length: 1, - Frames: []frames.Frame{&frames.StreamFrame{ - Data: bytes.Repeat([]byte{'a'}, int(protocol.SmallPacketPayloadSizeThreshold)+1), - }}, - }) - session.packer.lastPacketNumber = n - Expect(err).NotTo(HaveOccurred()) - session.scheduleSending() - Eventually(func() bool { return len(conn.written) > 0 }).Should(BeTrue()) - }) - - Context("counting streams", func() { - It("errors when too many streams are opened", func(done Done) { - // 1.1 * 100 - for i := 2; i <= 110; i++ { - _, err := session.OpenStream(protocol.StreamID(i)) - Expect(err).NotTo(HaveOccurred()) - } - _, err := session.OpenStream(protocol.StreamID(111)) - Expect(err).To(MatchError(qerr.TooManyOpenStreams)) - Eventually(session.closeChan).Should(Receive()) - close(done) - }) - - It("does not error when many streams are opened and closed", func() { - for i := 2; i <= 1000; i++ { - s, err := session.OpenStream(protocol.StreamID(i)) - Expect(err).NotTo(HaveOccurred()) - err = s.Close() - Expect(err).NotTo(HaveOccurred()) - s.CloseRemote(0) - _, err = s.Read([]byte("a")) - Expect(err).To(MatchError(io.EOF)) - session.garbageCollectStreams() - } - }) - }) - - Context("ignoring errors", func() { - It("ignores duplicate acks", func() { - session.sentPacketHandler.SentPacket(&ackhandler.Packet{ - PacketNumber: 1, - Length: 1, - }) - err := session.handleFrames([]frames.Frame{&frames.AckFrame{ - LargestObserved: 1, - }}) - Expect(err).NotTo(HaveOccurred()) - err = session.handleFrames([]frames.Frame{&frames.AckFrame{ - LargestObserved: 1, - }}) - Expect(err).NotTo(HaveOccurred()) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/stream.go b/vendor/github.com/lucas-clemente/quic-go/stream.go deleted file mode 100644 index 17073b9..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/stream.go +++ /dev/null @@ -1,336 +0,0 @@ -package quic - -import ( - "io" - "sync" - "sync/atomic" - - "github.com/lucas-clemente/quic-go/flowcontrol" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -type streamHandler interface { - queueStreamFrame(*frames.StreamFrame) error - updateReceiveFlowControlWindow(streamID protocol.StreamID, byteOffset protocol.ByteCount) error - streamBlocked(streamID protocol.StreamID, byteOffset protocol.ByteCount) -} - -var ( - errFlowControlViolation = qerr.FlowControlReceivedTooMuchData - errConnectionFlowControlViolation = qerr.FlowControlReceivedTooMuchData -) - -// A Stream assembles the data from StreamFrames and provides a super-convenient Read-Interface -// -// Read() and Write() may be called concurrently, but multiple calls to Read() or Write() individually must be synchronized manually. -type stream struct { - streamID protocol.StreamID - session streamHandler - - readPosInFrame int - writeOffset protocol.ByteCount - readOffset protocol.ByteCount - - // Once set, err must not be changed! - err error - mutex sync.Mutex - - // eof is set if we are finished reading - eof int32 // really a bool - // closed is set when we are finished writing - closed int32 // really a bool - - frameQueue *streamFrameSorter - newFrameOrErrCond sync.Cond - - flowControlManager flowcontrol.FlowControlManager - // TODO: remove those - flowController flowcontrol.FlowController - connectionFlowController flowcontrol.FlowController - contributesToConnectionFlowControl bool - - windowUpdateOrErrCond sync.Cond -} - -// newStream creates a new Stream -func newStream(session streamHandler, connectionParameterManager *handshake.ConnectionParametersManager, connectionFlowController flowcontrol.FlowController, flowControlManager flowcontrol.FlowControlManager, StreamID protocol.StreamID) (*stream, error) { - s := &stream{ - session: session, - streamID: StreamID, - flowControlManager: flowControlManager, - connectionFlowController: connectionFlowController, - contributesToConnectionFlowControl: true, - flowController: flowcontrol.NewFlowController(StreamID, connectionParameterManager), - frameQueue: newStreamFrameSorter(), - } - - // crypto and header stream don't contribute to connection level flow control - // TODO: only include the header stream here when using HTTP2 - if s.streamID == 1 || s.streamID == 3 { - s.contributesToConnectionFlowControl = false - } - - s.newFrameOrErrCond.L = &s.mutex - s.windowUpdateOrErrCond.L = &s.mutex - - return s, nil -} - -// Read implements io.Reader. It is not thread safe! -func (s *stream) Read(p []byte) (int, error) { - if atomic.LoadInt32(&s.eof) != 0 { - return 0, io.EOF - } - - bytesRead := 0 - for bytesRead < len(p) { - s.mutex.Lock() - frame := s.frameQueue.Head() - - if frame == nil && bytesRead > 0 { - defer s.mutex.Unlock() - return bytesRead, s.err - } - - for { - // Stop waiting on errors - if s.err != nil { - break - } - if frame != nil { - // Pop and continue if the frame doesn't have any new data - if frame.Offset+frame.DataLen() <= s.readOffset && !frame.FinBit { - s.frameQueue.Pop() - frame = s.frameQueue.Head() - continue - } - // If the frame's offset is <= our current read pos, and we didn't - // go into the previous if, we can read data from the frame. - if frame.Offset <= s.readOffset { - // Set our read position in the frame properly - s.readPosInFrame = int(s.readOffset - frame.Offset) - break - } - } - s.newFrameOrErrCond.Wait() - frame = s.frameQueue.Head() - } - s.mutex.Unlock() - - if frame == nil { - atomic.StoreInt32(&s.eof, 1) - // We have an err and no data, return the error - return bytesRead, s.err - } - - m := utils.Min(len(p)-bytesRead, int(frame.DataLen())-s.readPosInFrame) - copy(p[bytesRead:], frame.Data[s.readPosInFrame:]) - - s.readPosInFrame += m - bytesRead += m - s.readOffset += protocol.ByteCount(m) - - s.flowControlManager.AddBytesRead(s.streamID, protocol.ByteCount(m)) - s.maybeTriggerWindowUpdate() - - if s.readPosInFrame >= int(frame.DataLen()) { - fin := frame.FinBit - s.mutex.Lock() - s.frameQueue.Pop() - s.mutex.Unlock() - if fin { - atomic.StoreInt32(&s.eof, 1) - return bytesRead, io.EOF - } - } - } - - return bytesRead, nil -} - -// ReadByte implements io.ByteReader -func (s *stream) ReadByte() (byte, error) { - p := make([]byte, 1) - _, err := io.ReadFull(s, p) - return p[0], err -} - -func (s *stream) ConnectionFlowControlWindowUpdated() { - s.windowUpdateOrErrCond.Broadcast() -} - -func (s *stream) UpdateSendFlowControlWindow(n protocol.ByteCount) bool { - if s.flowController.UpdateSendWindow(n) { - s.windowUpdateOrErrCond.Broadcast() - return true - } - return false -} - -func (s *stream) Write(p []byte) (int, error) { - s.mutex.Lock() - err := s.err - s.mutex.Unlock() - - if err != nil { - return 0, err - } - - dataWritten := 0 - - for dataWritten < len(p) { - s.mutex.Lock() - remainingBytesInWindow := utils.MinByteCount(s.flowController.SendWindowSize(), protocol.ByteCount(len(p)-dataWritten)) - if s.contributesToConnectionFlowControl { - remainingBytesInWindow = utils.MinByteCount(remainingBytesInWindow, s.connectionFlowController.SendWindowSize()) - } - for remainingBytesInWindow == 0 && s.err == nil { - s.windowUpdateOrErrCond.Wait() - remainingBytesInWindow = utils.MinByteCount(s.flowController.SendWindowSize(), protocol.ByteCount(len(p)-dataWritten)) - if s.contributesToConnectionFlowControl { - remainingBytesInWindow = utils.MinByteCount(remainingBytesInWindow, s.connectionFlowController.SendWindowSize()) - } - } - s.mutex.Unlock() - - if remainingBytesInWindow == 0 { - // We must have had an error - return 0, s.err - } - - dataLen := utils.MinByteCount(protocol.ByteCount(len(p)), remainingBytesInWindow) - data := make([]byte, dataLen) - copy(data, p[dataWritten:]) - err := s.session.queueStreamFrame(&frames.StreamFrame{ - StreamID: s.streamID, - Offset: s.writeOffset, - Data: data, - }) - - if err != nil { - return 0, err - } - - dataWritten += int(dataLen) // We cannot have written more than the int range - s.flowController.AddBytesSent(protocol.ByteCount(dataLen)) - if s.contributesToConnectionFlowControl { - s.connectionFlowController.AddBytesSent(protocol.ByteCount(dataLen)) - } - s.writeOffset += protocol.ByteCount(dataLen) - - s.maybeTriggerBlocked() - } - - return dataWritten, nil -} - -// Close implements io.Closer -func (s *stream) Close() error { - atomic.StoreInt32(&s.closed, 1) - return s.session.queueStreamFrame(&frames.StreamFrame{ - StreamID: s.streamID, - Offset: s.writeOffset, - FinBit: true, - }) -} - -// AddStreamFrame adds a new stream frame -func (s *stream) AddStreamFrame(frame *frames.StreamFrame) error { - maxOffset := frame.Offset + frame.DataLen() - err := s.flowControlManager.UpdateHighestReceived(s.streamID, maxOffset) - - if err == flowcontrol.ErrStreamFlowControlViolation { - return errFlowControlViolation - } - if err == flowcontrol.ErrConnectionFlowControlViolation { - return errConnectionFlowControlViolation - } - if err != nil { - return err - } - - s.mutex.Lock() - defer s.mutex.Unlock() - err = s.frameQueue.Push(frame) - if err != nil && err != errDuplicateStreamData { - return err - } - s.newFrameOrErrCond.Signal() - return nil -} - -// CloseRemote makes the stream receive a "virtual" FIN stream frame at a given offset -func (s *stream) CloseRemote(offset protocol.ByteCount) { - s.AddStreamFrame(&frames.StreamFrame{FinBit: true, Offset: offset}) -} - -func (s *stream) maybeTriggerWindowUpdate() error { - // check for stream level window updates - doUpdate, byteOffset, err := s.flowControlManager.MaybeTriggerStreamWindowUpdate(s.streamID) - if err != nil { - return err - } - if doUpdate { - s.session.updateReceiveFlowControlWindow(s.streamID, byteOffset) - } - - // check for connection level window updates - doUpdate, byteOffset = s.flowControlManager.MaybeTriggerConnectionWindowUpdate() - if doUpdate { - s.session.updateReceiveFlowControlWindow(0, byteOffset) - } - - return nil -} - -func (s *stream) maybeTriggerBlocked() { - streamBlocked := s.flowController.MaybeTriggerBlocked() - - if streamBlocked { - s.session.streamBlocked(s.streamID, s.writeOffset) - } - - if s.contributesToConnectionFlowControl { - connectionBlocked := s.connectionFlowController.MaybeTriggerBlocked() - - if connectionBlocked { - // TODO: send out connection-level BlockedFrames at the right time - // see https://github.com/lucas-clemente/quic-go/issues/113 - s.session.streamBlocked(0, 0) - } - } -} - -// RegisterError is called by session to indicate that an error occurred and the -// stream should be closed. -func (s *stream) RegisterError(err error) { - atomic.StoreInt32(&s.closed, 1) - s.mutex.Lock() - defer s.mutex.Unlock() - if s.err != nil { // s.err must not be changed! - return - } - s.err = err - s.windowUpdateOrErrCond.Signal() - s.newFrameOrErrCond.Signal() -} - -func (s *stream) finishedReading() bool { - return atomic.LoadInt32(&s.eof) != 0 -} - -func (s *stream) finishedWriting() bool { - return atomic.LoadInt32(&s.closed) != 0 -} - -func (s *stream) finished() bool { - return s.finishedReading() && s.finishedWriting() -} - -func (s *stream) StreamID() protocol.StreamID { - return s.streamID -} diff --git a/vendor/github.com/lucas-clemente/quic-go/stream_frame_queue.go b/vendor/github.com/lucas-clemente/quic-go/stream_frame_queue.go deleted file mode 100644 index 80a7d10..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/stream_frame_queue.go +++ /dev/null @@ -1,227 +0,0 @@ -package quic - -import ( - "sync" - - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" -) - -var errMapAccess = qerr.Error(qerr.InternalError, "Error accessing the StreamFrameQueue") - -// streamFrameQueue is a Queue that handles StreamFrames -type streamFrameQueue struct { - prioFrames []*frames.StreamFrame - frameMap map[protocol.StreamID][]*frames.StreamFrame - mutex sync.RWMutex - - activeStreams []protocol.StreamID - activeStreamsPosition int - - len int - byteLen protocol.ByteCount -} - -func newStreamFrameQueue() *streamFrameQueue { - return &streamFrameQueue{ - frameMap: make(map[protocol.StreamID][]*frames.StreamFrame), - } -} - -// Push adds a new StreamFrame to the queue -func (q *streamFrameQueue) Push(frame *frames.StreamFrame, prio bool) { - q.mutex.Lock() - defer q.mutex.Unlock() - - frame.DataLenPresent = true - - if prio { - q.prioFrames = append(q.prioFrames, frame) - } else { - _, streamExisted := q.frameMap[frame.StreamID] - q.frameMap[frame.StreamID] = append(q.frameMap[frame.StreamID], frame) - if !streamExisted { - q.activeStreams = append(q.activeStreams, frame.StreamID) - } - } - - q.byteLen += frame.DataLen() - q.len++ -} - -// Len returns the total number of queued StreamFrames -func (q *streamFrameQueue) Len() int { - q.mutex.RLock() - defer q.mutex.RUnlock() - - return q.len -} - -// ByteLen returns the total number of bytes queued -func (q *streamFrameQueue) ByteLen() protocol.ByteCount { - q.mutex.RLock() - defer q.mutex.RUnlock() - - return q.byteLen -} - -// Pop returns the next element and deletes it from the queue -func (q *streamFrameQueue) Pop(maxLength protocol.ByteCount) (*frames.StreamFrame, error) { - q.mutex.Lock() - defer q.mutex.Unlock() - - var isPrioFrame bool - var frame *frames.StreamFrame - var streamID protocol.StreamID - var err error - - for len(q.prioFrames) > 0 { - frame = q.prioFrames[0] - if frame == nil { // this happens when a Stream that had prioFrames queued gets deleted - q.prioFrames = q.prioFrames[1:] - continue - } - isPrioFrame = true - break - } - - if !isPrioFrame { - streamID, err = q.getNextStream() - if err != nil { - return nil, err - } - if streamID == 0 { - return nil, nil - } - frame = q.frameMap[streamID][0] - } - - // Does the frame fit into the remaining space? - frameMinLength, _ := frame.MinLength() // StreamFrame.MinLength *never* returns an error - if frameMinLength > maxLength { - return nil, nil - } - - splitFrame := q.maybeSplitOffFrame(frame, maxLength) - - if splitFrame != nil { // StreamFrame was split - q.byteLen -= splitFrame.DataLen() - return splitFrame, nil - } - - // StreamFrame was not split. Remove it from the appropriate queue - if isPrioFrame { - q.prioFrames = q.prioFrames[1:] - } else { - q.frameMap[streamID] = q.frameMap[streamID][1:] - } - - q.byteLen -= frame.DataLen() - q.len-- - return frame, nil -} - -func (q *streamFrameQueue) RemoveStream(streamID protocol.StreamID) { - q.mutex.Lock() - defer q.mutex.Unlock() - - for i, frame := range q.prioFrames { - if frame == nil { - continue - } - if frame.StreamID == streamID { - q.byteLen -= frame.DataLen() - q.len-- - q.prioFrames[i] = nil - } - } - - frameQueue, ok := q.frameMap[streamID] - if ok { - for _, frame := range frameQueue { - q.byteLen -= frame.DataLen() - q.len-- - } - delete(q.frameMap, streamID) - } - - for i, s := range q.activeStreams { - if s == streamID { - q.activeStreams[i] = 0 - } - } - - q.garbageCollectActiveStreams() -} - -func (q *streamFrameQueue) garbageCollectActiveStreams() { - var j int - var deletedIndex int - - for i, str := range q.activeStreams { - if str != 0 { - q.activeStreams[j] = str - j++ - } else { - deletedIndex = i - } - } - - if len(q.activeStreams) > 0 { - q.activeStreams = q.activeStreams[:len(q.activeStreams)-1] - } - - if deletedIndex < q.activeStreamsPosition { - q.activeStreamsPosition-- - } -} - -// front returns the next element without modifying the queue -// has to be called from a function that has already acquired the mutex -func (q *streamFrameQueue) getNextStream() (protocol.StreamID, error) { - if q.len-len(q.prioFrames) == 0 { - return 0, nil - } - - var counter int - for counter < len(q.activeStreams) { - counter++ - streamID := q.activeStreams[q.activeStreamsPosition] - q.activeStreamsPosition = (q.activeStreamsPosition + 1) % len(q.activeStreams) - - frameQueue, ok := q.frameMap[streamID] - if !ok { - return 0, errMapAccess - } - - if len(frameQueue) > 0 { - return streamID, nil - } - } - - return 0, nil -} - -// maybeSplitOffFrame removes the first n bytes and returns them as a separate frame. If n >= len(n), nil is returned and nothing is modified. -// has to be called from a function that has already acquired the mutex -func (q *streamFrameQueue) maybeSplitOffFrame(frame *frames.StreamFrame, n protocol.ByteCount) *frames.StreamFrame { - minLength, _ := frame.MinLength() // StreamFrame.MinLength *never* errors - if n >= minLength-1+frame.DataLen() { - return nil - } - n -= minLength - 1 - - defer func() { - frame.Data = frame.Data[n:] - frame.Offset += n - }() - - return &frames.StreamFrame{ - FinBit: false, - StreamID: frame.StreamID, - Offset: frame.Offset, - Data: frame.Data[:n], - DataLenPresent: frame.DataLenPresent, - } -} diff --git a/vendor/github.com/lucas-clemente/quic-go/stream_frame_queue_test.go b/vendor/github.com/lucas-clemente/quic-go/stream_frame_queue_test.go deleted file mode 100644 index 0b65106..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/stream_frame_queue_test.go +++ /dev/null @@ -1,473 +0,0 @@ -package quic - -import ( - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("streamFrameQueue", func() { - var prioFrame1, prioFrame2 *frames.StreamFrame - var frame1, frame2, frame3 *frames.StreamFrame - var queue *streamFrameQueue - - BeforeEach(func() { - queue = newStreamFrameQueue() - prioFrame1 = &frames.StreamFrame{ - StreamID: 5, - Data: []byte{0x13, 0x37}, - } - prioFrame2 = &frames.StreamFrame{ - StreamID: 6, - Data: []byte{0xDE, 0xCA, 0xFB, 0xAD}, - } - frame1 = &frames.StreamFrame{ - StreamID: 10, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF, 0xCA, 0xFE, 0x13, 0x37}, - } - frame2 = &frames.StreamFrame{ - StreamID: 11, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF, 0x37}, - } - frame3 = &frames.StreamFrame{ - StreamID: 11, - Data: []byte{0xBE, 0xEF}, - } - }) - - It("sets the DataLenPresent on all StreamFrames", func() { - queue.Push(frame1, false) - queue.Push(prioFrame1, true) - Expect(queue.prioFrames[0].DataLenPresent).To(BeTrue()) - Expect(queue.frameMap[frame1.StreamID][0].DataLenPresent).To(BeTrue()) - }) - - Context("Queue Length", func() { - It("returns the correct length for an empty queue", func() { - Expect(queue.Len()).To(BeZero()) - }) - - It("returns the correct length for a queue", func() { - queue.Push(prioFrame1, true) - Expect(queue.Len()).To(Equal(1)) - queue.Push(frame1, false) - queue.Push(frame2, false) - Expect(queue.Len()).To(Equal(3)) - }) - - It("reduces the length when popping", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - Expect(queue.Len()).To(Equal(2)) - queue.Pop(1000) - Expect(queue.Len()).To(Equal(1)) - queue.Pop(1000) - Expect(queue.Len()).To(Equal(0)) - }) - - It("reduces the length when deleting a stream for which a prio frame was queued", func() { - queue.Push(prioFrame1, true) - queue.Push(prioFrame2, true) - Expect(queue.Len()).To(Equal(2)) - queue.RemoveStream(prioFrame1.StreamID) - Expect(queue.Len()).To(Equal(1)) - }) - - It("reduces the length when deleting a stream for which a normal frame was queued", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - Expect(queue.Len()).To(Equal(2)) - queue.RemoveStream(frame1.StreamID) - Expect(queue.Len()).To(Equal(1)) - }) - }) - - Context("Queue Byte Length", func() { - It("returns the correct length for an empty queue", func() { - Expect(queue.ByteLen()).To(BeZero()) - }) - - It("returns the correct byte length for a queue", func() { - queue.Push(prioFrame1, true) - Expect(queue.ByteLen()).To(Equal(protocol.ByteCount(2))) - queue.Push(frame2, false) - Expect(queue.ByteLen()).To(Equal(prioFrame1.DataLen() + frame2.DataLen())) - }) - - It("returns the correct byte length when popping", func() { - queue.Push(prioFrame1, true) - queue.Push(frame1, false) - Expect(queue.ByteLen()).To(Equal(prioFrame1.DataLen() + frame1.DataLen())) - queue.Pop(1000) - Expect(queue.ByteLen()).To(Equal(frame1.DataLen())) - queue.Pop(1000) - Expect(queue.ByteLen()).To(Equal(protocol.ByteCount(0))) - }) - - It("reduces the byte length when deleting a stream for which a prio frame was queued", func() { - queue.Push(prioFrame1, true) - queue.Push(prioFrame2, true) - Expect(queue.ByteLen()).To(Equal(prioFrame1.DataLen() + prioFrame2.DataLen())) - queue.RemoveStream(prioFrame1.StreamID) - Expect(queue.ByteLen()).To(Equal(prioFrame2.DataLen())) - }) - - It("reduces the byte length when deleting a stream for which a normal frame was queued", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - Expect(queue.ByteLen()).To(Equal(frame1.DataLen() + frame2.DataLen())) - queue.RemoveStream(frame1.StreamID) - Expect(queue.ByteLen()).To(Equal(frame2.DataLen())) - }) - }) - - Context("Pushing", func() { - It("adds the streams to the map", func() { - queue.Push(frame1, false) - Expect(queue.frameMap).To(HaveKey(frame1.StreamID)) - Expect(queue.frameMap[frame1.StreamID][0]).To(Equal(frame1)) - }) - - It("only adds a StreamID once to the active stream list", func() { - queue.Push(frame1, false) - queue.Push(frame1, false) - Expect(queue.frameMap).To(HaveKey(frame1.StreamID)) - Expect(queue.frameMap[frame1.StreamID]).To(HaveLen(2)) - Expect(queue.activeStreams).To(HaveLen(1)) - Expect(queue.activeStreams[0]).To(Equal(frame1.StreamID)) - }) - }) - - Context("getNextStream", func() { - It("returns 0 for an empty queue", func() { - streamID, err := queue.getNextStream() - Expect(err).ToNot(HaveOccurred()) - Expect(streamID).To(BeZero()) - }) - - It("does not change the byte length when using getNextStream()", func() { - queue.Push(prioFrame1, true) - queue.Push(frame1, false) - length := prioFrame1.DataLen() + frame1.DataLen() - Expect(queue.ByteLen()).To(Equal(length)) - _, err := queue.getNextStream() - Expect(err).ToNot(HaveOccurred()) - Expect(queue.ByteLen()).To(Equal(length)) - }) - - It("does not change the length when using front()", func() { - queue.Push(prioFrame1, true) - queue.Push(frame1, false) - Expect(queue.Len()).To(Equal(2)) - _, err := queue.getNextStream() - Expect(err).ToNot(HaveOccurred()) - Expect(queue.Len()).To(Equal(2)) - }) - - It("returns normal frames if no prio frames are available", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - streamID, err := queue.getNextStream() - Expect(err).ToNot(HaveOccurred()) - Expect(streamID).To(Equal(frame1.StreamID)) - }) - - It("gets the frame inserted at first at first", func() { - queue.Push(frame2, false) - queue.Push(frame1, false) - streamID, err := queue.getNextStream() - Expect(err).ToNot(HaveOccurred()) - Expect(streamID).To(Equal(frame2.StreamID)) - streamID, err = queue.getNextStream() - Expect(err).ToNot(HaveOccurred()) - Expect(streamID).To(Equal(frame1.StreamID)) - }) - - It("gets the next frame if a stream was deleted", func() { - queue.Push(frame2, false) - queue.Push(frame1, false) - Expect(queue.activeStreams).To(ContainElement(frame1.StreamID)) - Expect(queue.activeStreams).To(ContainElement(frame2.StreamID)) - queue.RemoveStream(frame2.StreamID) - Expect(queue.activeStreams).To(ContainElement(frame1.StreamID)) - Expect(queue.activeStreams).ToNot(ContainElement(frame2.StreamID)) - streamID, err := queue.getNextStream() - Expect(err).ToNot(HaveOccurred()) - Expect(streamID).To(Equal(frame1.StreamID)) - }) - }) - - Context("Popping", func() { - It("returns nil when popping an empty queue", func() { - Expect(queue.Pop(1000)).To(BeNil()) - }) - - It("deletes elements once they are popped", func() { - queue.Push(frame1, false) - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame1)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(BeNil()) - }) - - It("returns normal frames if no prio frames are available", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame1)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame2)) - }) - - It("returns prio frames first", func() { - queue.Push(prioFrame1, true) - queue.Push(frame1, false) - queue.Push(frame2, false) - queue.Push(prioFrame2, true) - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(prioFrame1)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(prioFrame2)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame1)) - }) - - Context("scheduling", func() { - It("goes around", func() { - queue.Push(frame2, false) // StreamID: 11 - queue.Push(frame3, false) // StreamID: 11 - queue.Push(frame1, false) // StreamID: 10 - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame2)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame1)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame3)) - }) - - It("starts with the frame inserted first", func() { - queue.Push(frame1, false) // StreamID: 10 - queue.Push(frame2, false) // StreamID: 11 - queue.Push(frame3, false) // StreamID: 11 - frame, err := queue.Pop(1000) - Expect(frame).To(Equal(frame1)) - Expect(err).ToNot(HaveOccurred()) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame2)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame3)) - }) - - It("goes around, also when frame have to be split", func() { - queue.Push(frame2, false) // StreamID: 11 - queue.Push(frame1, false) // StreamID: 10 - frame, err := queue.Pop(5) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.StreamID).To(Equal(frame2.StreamID)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame1)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.StreamID).To(Equal(frame2.StreamID)) - }) - }) - - Context("splitting of frames", func() { - It("splits off nothing", func() { - f := &frames.StreamFrame{ - StreamID: 1, - Data: []byte("bar"), - Offset: 3, - } - Expect(queue.maybeSplitOffFrame(f, 1000)).To(BeNil()) - Expect(f.Offset).To(Equal(protocol.ByteCount(3))) - Expect(f.Data).To(Equal([]byte("bar"))) - }) - - It("splits off initial frame", func() { - f := &frames.StreamFrame{ - StreamID: 1, - Data: []byte("foobar"), - DataLenPresent: true, - Offset: 3, - FinBit: true, - } - minLength, _ := f.MinLength() - previous := queue.maybeSplitOffFrame(f, minLength-1+3) - Expect(previous).ToNot(BeNil()) - Expect(previous.StreamID).To(Equal(protocol.StreamID(1))) - Expect(previous.Data).To(Equal([]byte("foo"))) - Expect(previous.DataLenPresent).To(BeTrue()) - Expect(previous.Offset).To(Equal(protocol.ByteCount(3))) - Expect(previous.FinBit).To(BeFalse()) - Expect(f.StreamID).To(Equal(protocol.StreamID(1))) - Expect(f.Data).To(Equal([]byte("bar"))) - Expect(f.DataLenPresent).To(BeTrue()) - Expect(f.Offset).To(Equal(protocol.ByteCount(6))) - Expect(f.FinBit).To(BeTrue()) - }) - - It("splits a frame", func() { - queue.Push(frame1, false) - origlen := frame1.DataLen() - frame, err := queue.Pop(6) - Expect(err).ToNot(HaveOccurred()) - minLength, _ := frame.MinLength() - Expect(minLength - 1 + frame.DataLen()).To(Equal(protocol.ByteCount(6))) - Expect(queue.frameMap[frame1.StreamID][0].Data).To(HaveLen(int(origlen - frame.DataLen()))) - Expect(queue.frameMap[frame1.StreamID][0].Offset).To(Equal(frame.DataLen())) - }) - - It("only removes a frame from the queue after return all split parts", func() { - queue.Push(frame1, false) - Expect(queue.Len()).To(Equal(1)) - frame, err := queue.Pop(6) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).ToNot(BeNil()) - Expect(queue.Len()).To(Equal(1)) - frame, err = queue.Pop(100) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).ToNot(BeNil()) - Expect(queue.Len()).To(BeZero()) - }) - - It("gets the whole data of a frame, when it was split", func() { - length := frame1.DataLen() - origdata := make([]byte, length) - copy(origdata, frame1.Data) - queue.Push(frame1, false) - frame, err := queue.Pop(6) - Expect(err).ToNot(HaveOccurred()) - nextframe, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.DataLen() + nextframe.DataLen()).To(Equal(length)) - data := make([]byte, length) - copy(data, frame.Data) - copy(data[int(frame.DataLen()):], nextframe.Data) - Expect(data).To(Equal(origdata)) - }) - - It("correctly calculates the byte length when returning a split frame", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - startByteLength := queue.ByteLen() - frame, err := queue.Pop(6) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.StreamID).To(Equal(frame1.StreamID)) // make sure the right frame was popped - Expect(queue.ByteLen()).To(Equal(startByteLength - frame.DataLen())) - }) - - It("does not change the length of the queue when returning a split frame", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - frame, err := queue.Pop(6) - Expect(err).ToNot(HaveOccurred()) - Expect(frame.StreamID).To(Equal(frame1.StreamID)) // make sure the right frame was popped - Expect(queue.Len()).To(Equal(2)) - }) - }) - }) - - Context("deleting streams", func() { - It("deletes prioFrames", func() { - queue.Push(prioFrame1, true) - queue.Push(prioFrame2, true) - queue.RemoveStream(prioFrame1.StreamID) - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(prioFrame2)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(BeNil()) - }) - - It("deletes multiple prioFrames from different streams", func() { - queue.Push(prioFrame1, true) - queue.Push(prioFrame2, true) - queue.RemoveStream(prioFrame1.StreamID) - queue.RemoveStream(prioFrame2.StreamID) - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(BeNil()) - }) - - It("deletes the map entry", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - Expect(queue.frameMap).To(HaveKey(frame1.StreamID)) - queue.RemoveStream(frame1.StreamID) - Expect(queue.frameMap).ToNot(HaveKey(frame1.StreamID)) - }) - - It("gets a normal frame, when the stream of the prio frame was deleted", func() { - queue.Push(prioFrame1, true) - queue.Push(frame1, true) - queue.RemoveStream(prioFrame1.StreamID) - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame1)) - frame, err = queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(BeNil()) - }) - - It("deletes frames", func() { - queue.Push(frame1, false) - queue.Push(frame2, false) - queue.RemoveStream(frame1.StreamID) - frame, err := queue.Pop(1000) - Expect(err).ToNot(HaveOccurred()) - Expect(frame).To(Equal(frame2)) - }) - - Context("garbage collection of activeStreams", func() { - It("adjusts the activeStreams slice", func() { - queue.activeStreams = []protocol.StreamID{5, 6, 10, 2, 3} - queue.RemoveStream(10) - Expect(queue.activeStreams).To(Equal([]protocol.StreamID{5, 6, 2, 3})) - }) - - It("garbage collects correctly if there is only one stream", func() { - queue.activeStreams = []protocol.StreamID{10} - queue.RemoveStream(10) - Expect(queue.activeStreams).To(BeEmpty()) - Expect(queue.activeStreamsPosition).To(Equal(0)) - }) - - It("does not change the scheduling, when the stream deleted is after the current position in activeStreams", func() { - queue.activeStreams = []protocol.StreamID{5, 6, 10, 2, 3} - queue.activeStreamsPosition = 0 // the next frame would be from Stream 5 - queue.RemoveStream(10) - Expect(queue.activeStreamsPosition).To(Equal(0)) - }) - - It("makes sure that scheduling is adjusted, if the stream deleted is before the current position in activeStreams", func() { - queue.activeStreams = []protocol.StreamID{5, 6, 10, 2, 3} - queue.activeStreamsPosition = 3 // the next frame would be from Stream 2 - queue.RemoveStream(10) - Expect(queue.activeStreamsPosition).To(Equal(2)) - }) - - It("makes sure that scheduling is adjusted, when a frame from the deleted stream was scheduled", func() { - queue.activeStreams = []protocol.StreamID{5, 6, 10, 2, 3} - queue.activeStreamsPosition = 2 // the next frame would be from Stream 10 - queue.RemoveStream(10) - Expect(queue.activeStreamsPosition).To(Equal(2)) // the next frame will be from Stream 2 - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter.go b/vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter.go deleted file mode 100644 index e0d8c4a..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter.go +++ /dev/null @@ -1,120 +0,0 @@ -package quic - -import ( - "errors" - - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" -) - -type streamFrameSorter struct { - queuedFrames map[protocol.ByteCount]*frames.StreamFrame - readPosition protocol.ByteCount - gaps *utils.ByteIntervalList -} - -var ( - errOverlappingStreamData = qerr.Error(qerr.OverlappingStreamData, "") - errTooManyGapsInReceivedStreamData = errors.New("Too many gaps in received StreamFrame data") - errDuplicateStreamData = errors.New("Overlapping Stream Data") - errEmptyStreamData = errors.New("Stream Data empty") -) - -func newStreamFrameSorter() *streamFrameSorter { - s := streamFrameSorter{ - gaps: utils.NewByteIntervalList(), - queuedFrames: make(map[protocol.ByteCount]*frames.StreamFrame), - } - s.gaps.PushFront(utils.ByteInterval{Start: 0, End: protocol.MaxByteCount}) - return &s -} - -func (s *streamFrameSorter) Push(frame *frames.StreamFrame) error { - _, ok := s.queuedFrames[frame.Offset] - if ok { - return errDuplicateStreamData - } - - start := frame.Offset - end := frame.Offset + frame.DataLen() - - if start == end { - if frame.FinBit { - s.queuedFrames[frame.Offset] = frame - return nil - } - return errEmptyStreamData - } - - var foundInGap bool - - for gap := s.gaps.Front(); gap != nil; gap = gap.Next() { - // the complete frame lies before or after the gap - if end <= gap.Value.Start || start > gap.Value.End { - continue - } - - if start < gap.Value.Start { - return errOverlappingStreamData - } - - if start < gap.Value.End && end > gap.Value.End { - return errOverlappingStreamData - } - - foundInGap = true - - if start == gap.Value.Start { - if end == gap.Value.End { - s.gaps.Remove(gap) - break - } - if end < gap.Value.End { - gap.Value.Start = end - break - } - } - - if end == gap.Value.End { - gap.Value.End = start - break - } - - if end < gap.Value.End { - intv := utils.ByteInterval{Start: end, End: gap.Value.End} - s.gaps.InsertAfter(intv, gap) - gap.Value.End = start - break - } - } - - if !foundInGap { - return errDuplicateStreamData - } - - if s.gaps.Len() > protocol.MaxStreamFrameSorterGaps { - return errTooManyGapsInReceivedStreamData - } - - s.queuedFrames[frame.Offset] = frame - return nil -} - -func (s *streamFrameSorter) Pop() *frames.StreamFrame { - frame := s.Head() - if frame != nil { - s.readPosition += frame.DataLen() - delete(s.queuedFrames, frame.Offset) - } - return frame -} - -func (s *streamFrameSorter) Head() *frames.StreamFrame { - frame, ok := s.queuedFrames[s.readPosition] - if ok { - return frame - } - return nil -} diff --git a/vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter_test.go b/vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter_test.go deleted file mode 100644 index f8c40f7..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/stream_frame_sorter_test.go +++ /dev/null @@ -1,420 +0,0 @@ -package quic - -import ( - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" - "github.com/lucas-clemente/quic-go/qerr" - "github.com/lucas-clemente/quic-go/utils" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -func compareGapValues(gapList *utils.ByteIntervalList, expectedGaps []utils.ByteInterval) { - Expect(gapList.Len()).To(Equal(len(expectedGaps))) - var i int - for gap := gapList.Front(); gap != nil; gap = gap.Next() { - Expect(gap.Value).To(Equal(expectedGaps[i])) - i++ - } -} - -var _ = Describe("StreamFrame sorter", func() { - var s *streamFrameSorter - - BeforeEach(func() { - s = newStreamFrameSorter() - }) - - It("head returns nil when empty", func() { - Expect(s.Head()).To(BeNil()) - }) - - Context("Push", func() { - It("inserts and pops a single frame", func() { - f := &frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - err := s.Push(f) - Expect(err).ToNot(HaveOccurred()) - Expect(s.Head()).To(Equal(f)) - Expect(s.Pop()).To(Equal(f)) - Expect(s.Head()).To(BeNil()) - }) - - It("inserts and pops two consecutive frame", func() { - f1 := &frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - f2 := &frames.StreamFrame{ - Offset: 6, - Data: []byte("foobar2"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - Expect(s.Pop()).To(Equal(f1)) - Expect(s.Pop()).To(Equal(f2)) - Expect(s.Head()).To(BeNil()) - }) - - It("rejects empty frames", func() { - f := &frames.StreamFrame{} - err := s.Push(f) - Expect(err).To(MatchError(errEmptyStreamData)) - }) - - Context("FinBit handling", func() { - It("saves a FinBit frame at offset 0", func() { - f := &frames.StreamFrame{ - Offset: 0, - FinBit: true, - } - err := s.Push(f) - Expect(err).ToNot(HaveOccurred()) - Expect(s.Head()).To(Equal(f)) - }) - - It("sets the FinBit if a stream is closed after receiving some data", func() { - f1 := &frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - f2 := &frames.StreamFrame{ - Offset: 6, - FinBit: true, - } - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - Expect(s.Pop()).To(Equal(f1)) - Expect(s.Pop()).To(Equal(f2)) - }) - }) - - Context("Gap handling", func() { - It("finds the first gap", func() { - f := &frames.StreamFrame{ - Offset: 10, - Data: []byte("foobar"), - } - err := s.Push(f) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(2)) - Expect(s.gaps.Front().Value).To(Equal(utils.ByteInterval{Start: 0, End: 10})) - }) - - It("correctly sets the first gap for a frame with offset 0", func() { - f := &frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - err := s.Push(f) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(1)) - Expect(s.gaps.Front().Value).To(Equal(utils.ByteInterval{Start: 6, End: protocol.MaxByteCount})) - }) - - It("finds the two gaps", func() { - f1 := &frames.StreamFrame{ - Offset: 10, - Data: []byte("foobar"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - f2 := &frames.StreamFrame{ - Offset: 20, - Data: []byte("foobar"), - } - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(3)) - el := s.gaps.Front() // first gap - Expect(el.Value).To(Equal(utils.ByteInterval{Start: 0, End: 10})) - el = el.Next() // second gap - Expect(el.Value).To(Equal(utils.ByteInterval{Start: 16, End: 20})) - Expect(s.gaps.Back().Value.Start).To(Equal(protocol.ByteCount(26))) - }) - - It("finds the two gaps in reverse order", func() { - f1 := &frames.StreamFrame{ - Offset: 20, - Data: []byte("foobar"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - f2 := &frames.StreamFrame{ - Offset: 10, - Data: []byte("foobar"), - } - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(3)) - el := s.gaps.Front() // first gap - Expect(el.Value).To(Equal(utils.ByteInterval{Start: 0, End: 10})) - el = el.Next() // second gap - Expect(el.Value).To(Equal(utils.ByteInterval{Start: 16, End: 20})) - Expect(s.gaps.Back().Value).To(Equal(utils.ByteInterval{Start: 26, End: protocol.MaxByteCount})) - }) - - It("shrinks a gap when it is partially filled", func() { - f1 := &frames.StreamFrame{ - Offset: 10, - Data: []byte("test"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - f2 := &frames.StreamFrame{ - Offset: 4, - Data: []byte("foobar"), - } - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(2)) - Expect(s.gaps.Front().Value).To(Equal(utils.ByteInterval{Start: 0, End: 4})) - Expect(s.gaps.Back().Value).To(Equal(utils.ByteInterval{Start: 14, End: protocol.MaxByteCount})) - }) - - It("deletes a gap at the beginning, when it is filled", func() { - f1 := &frames.StreamFrame{ - Offset: 6, - Data: []byte("test"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - f2 := &frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(1)) - Expect(s.gaps.Front().Value).To(Equal(utils.ByteInterval{Start: 10, End: protocol.MaxByteCount})) - }) - - It("deletes a gap in the middle, when it is filled", func() { - f1 := &frames.StreamFrame{ - Offset: 0, - Data: []byte("test"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - f2 := &frames.StreamFrame{ - Offset: 10, - Data: []byte("test2"), - } - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - f3 := &frames.StreamFrame{ - Offset: 4, - Data: []byte("foobar"), - } - err = s.Push(f3) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(1)) - Expect(s.gaps.Front().Value).To(Equal(utils.ByteInterval{Start: 15, End: protocol.MaxByteCount})) - Expect(s.queuedFrames).To(HaveLen(3)) - }) - - It("splits a gap into two", func() { - f1 := &frames.StreamFrame{ - Offset: 100, - Data: []byte("test"), - } - err := s.Push(f1) - Expect(err).ToNot(HaveOccurred()) - f2 := &frames.StreamFrame{ - Offset: 50, - Data: []byte("foobar"), - } - err = s.Push(f2) - Expect(err).ToNot(HaveOccurred()) - Expect(s.gaps.Len()).To(Equal(3)) - el := s.gaps.Front() // first gap - Expect(el.Value).To(Equal(utils.ByteInterval{Start: 0, End: 50})) - el = el.Next() // second gap - Expect(el.Value).To(Equal(utils.ByteInterval{Start: 56, End: 100})) - Expect(s.gaps.Back().Value).To(Equal(utils.ByteInterval{Start: 104, End: protocol.MaxByteCount})) - Expect(s.queuedFrames).To(HaveLen(2)) - }) - - Context("Overlapping Stream Data detection", func() { - var expectedGaps []utils.ByteInterval - BeforeEach(func() { - // create gaps: 0-5, 10-15, 15-20, 30-inf - expectedGaps = expectedGaps[:0] - expectedGaps = append(expectedGaps, utils.ByteInterval{Start: 0, End: 5}) - err := s.Push(&frames.StreamFrame{Offset: 5, Data: []byte("12345")}) - Expect(err).ToNot(HaveOccurred()) - expectedGaps = append(expectedGaps, utils.ByteInterval{Start: 10, End: 15}) - err = s.Push(&frames.StreamFrame{Offset: 15, Data: []byte("12345")}) - Expect(err).ToNot(HaveOccurred()) - expectedGaps = append(expectedGaps, utils.ByteInterval{Start: 20, End: 25}) - err = s.Push(&frames.StreamFrame{Offset: 25, Data: []byte("12345")}) - Expect(err).ToNot(HaveOccurred()) - expectedGaps = append(expectedGaps, utils.ByteInterval{Start: 30, End: protocol.MaxByteCount}) - }) - - It("rejects a frame with offset 0 that overlaps at the end", func() { - f := &frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - err := s.Push(f) - Expect(err).To(MatchError(qerr.Error(qerr.OverlappingStreamData, ""))) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(0))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("rejects a frame that overlaps at the end", func() { - // 4 to 6 - f := &frames.StreamFrame{ - Offset: 4, - Data: []byte("12"), - } - err := s.Push(f) - Expect(err).To(MatchError(errOverlappingStreamData)) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(4))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("rejects a frame that completely fills a gap, but overlaps at the end", func() { - // 10 to 16 - f := &frames.StreamFrame{ - Offset: 10, - Data: []byte("foobar"), - } - err := s.Push(f) - Expect(err).To(MatchError(errOverlappingStreamData)) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(10))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("rejects a frame that overlaps at the beginning", func() { - // 8 to 14 - f := &frames.StreamFrame{ - Offset: 8, - Data: []byte("foobar"), - } - err := s.Push(f) - Expect(err).To(MatchError(errOverlappingStreamData)) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(8))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("rejects a frame that overlaps at the beginning and at the end, starting in a gap", func() { - // 2 to 11 - f := &frames.StreamFrame{ - Offset: 2, - Data: []byte("123456789"), - } - err := s.Push(f) - Expect(err).To(MatchError(errOverlappingStreamData)) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(2))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("rejects a frame that overlaps at the beginning and at the end, starting in data already received", func() { - // 8 to 17 - f := &frames.StreamFrame{ - Offset: 8, - Data: []byte("123456789"), - } - err := s.Push(f) - Expect(err).To(MatchError(errOverlappingStreamData)) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(8))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("rejects a frame that completely covers two gaps", func() { - // 10 to 20 - f := &frames.StreamFrame{ - Offset: 10, - Data: []byte("1234567890"), - } - err := s.Push(f) - Expect(err).To(MatchError(errOverlappingStreamData)) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(10))) - compareGapValues(s.gaps, expectedGaps) - }) - }) - - Context("Duplicate data detection", func() { - var expectedGaps []utils.ByteInterval - - BeforeEach(func() { - // create gaps: 5-10, 15-20, 25-inf - expectedGaps = expectedGaps[:0] - expectedGaps = append(expectedGaps, utils.ByteInterval{Start: 5, End: 10}) - err := s.Push(&frames.StreamFrame{Offset: 0, Data: []byte("12345")}) - Expect(err).ToNot(HaveOccurred()) - expectedGaps = append(expectedGaps, utils.ByteInterval{Start: 15, End: protocol.MaxByteCount}) - err = s.Push(&frames.StreamFrame{Offset: 10, Data: []byte("12345")}) - Expect(err).ToNot(HaveOccurred()) - }) - - It("detects a complete duplicate frame", func() { - err := s.Push(&frames.StreamFrame{Offset: 0, Data: []byte("12345")}) - Expect(err).To(MatchError(errDuplicateStreamData)) - compareGapValues(s.gaps, expectedGaps) - }) - - It("does not modify data when receiving a duplicate", func() { - err := s.Push(&frames.StreamFrame{Offset: 0, Data: []byte("67890")}) - Expect(err).To(MatchError(errDuplicateStreamData)) - Expect(s.queuedFrames[0].Data).To(Equal([]byte("12345"))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("detects a duplicate frame that is smaller than the original, starting at the beginning", func() { - // 10 to 12 - err := s.Push(&frames.StreamFrame{Offset: 10, Data: []byte("12")}) - Expect(err).To(MatchError(errDuplicateStreamData)) - Expect(s.queuedFrames[10].DataLen()).To(Equal(protocol.ByteCount(5))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("detects a duplicate frame that is smaller than the original, somewhere in the middle", func() { - // 1 to 4 - err := s.Push(&frames.StreamFrame{Offset: 1, Data: []byte("123")}) - Expect(err).To(MatchError(errDuplicateStreamData)) - Expect(s.queuedFrames[0].DataLen()).To(Equal(protocol.ByteCount(5))) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(1))) - compareGapValues(s.gaps, expectedGaps) - }) - - It("detects a duplicate frame that is smaller than the original, with aligned end", func() { - // 3 to 5 - err := s.Push(&frames.StreamFrame{Offset: 3, Data: []byte("12")}) - Expect(err).To(MatchError(errDuplicateStreamData)) - Expect(s.queuedFrames[0].DataLen()).To(Equal(protocol.ByteCount(5))) - Expect(s.queuedFrames).ToNot(HaveKey(protocol.ByteCount(8))) - compareGapValues(s.gaps, expectedGaps) - }) - }) - - Context("DOS protection", func() { - It("errors when too many gaps are created", func() { - for i := 0; i < protocol.MaxStreamFrameSorterGaps; i++ { - f := &frames.StreamFrame{ - Data: []byte("foobar"), - Offset: protocol.ByteCount(i * 7), - } - err := s.Push(f) - Expect(err).ToNot(HaveOccurred()) - } - Expect(s.gaps.Len()).To(Equal(protocol.MaxStreamFrameSorterGaps)) - f := &frames.StreamFrame{ - Data: []byte("foobar"), - Offset: protocol.ByteCount(protocol.MaxStreamFrameSorterGaps*7) + 100, - } - err := s.Push(f) - Expect(err).To(MatchError(errTooManyGapsInReceivedStreamData)) - }) - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/stream_test.go b/vendor/github.com/lucas-clemente/quic-go/stream_test.go deleted file mode 100644 index 55a3675..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/stream_test.go +++ /dev/null @@ -1,704 +0,0 @@ -package quic - -import ( - "errors" - "io" - "time" - - "github.com/lucas-clemente/quic-go/flowcontrol" - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/handshake" - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -type mockStreamHandler struct { - frames []*frames.StreamFrame - - receivedBlockedCalled bool - receivedBlockedForStream protocol.StreamID - - receiveFlowControlWindowCalled bool - receiveFlowControlWindowCalledForStream protocol.StreamID -} - -func (m *mockStreamHandler) streamBlocked(streamID protocol.StreamID, byteOffset protocol.ByteCount) { - m.receivedBlockedCalled = true - m.receivedBlockedForStream = streamID -} - -func (m *mockStreamHandler) updateReceiveFlowControlWindow(streamID protocol.StreamID, byteOffset protocol.ByteCount) error { - m.receiveFlowControlWindowCalled = true - m.receiveFlowControlWindowCalledForStream = streamID - return nil -} - -func (m *mockStreamHandler) queueStreamFrame(f *frames.StreamFrame) error { - m.frames = append(m.frames, f) - return nil -} - -type mockFlowControlHandler struct { - bytesReadForStream protocol.StreamID - bytesRead protocol.ByteCount - - highestReceivedForStream protocol.StreamID - highestReceived protocol.ByteCount - - triggerStreamWindowUpdate bool - triggerConnectionWindowUpdate bool -} - -func (m *mockFlowControlHandler) NewStream(streamID protocol.StreamID, contributesToConnectionFlow bool) { - panic("not implemented") -} - -func (m *mockFlowControlHandler) MaybeTriggerStreamWindowUpdate(streamID protocol.StreamID) (bool, protocol.ByteCount, error) { - return m.triggerStreamWindowUpdate, 0x1337, nil -} - -func (m *mockFlowControlHandler) MaybeTriggerConnectionWindowUpdate() (bool, protocol.ByteCount) { - return m.triggerConnectionWindowUpdate, 0x1337 -} - -func (m *mockFlowControlHandler) AddBytesRead(streamID protocol.StreamID, n protocol.ByteCount) error { - m.bytesReadForStream = streamID - m.bytesRead = n - return nil -} - -func (m *mockFlowControlHandler) UpdateHighestReceived(streamID protocol.StreamID, byteOffset protocol.ByteCount) error { - m.highestReceivedForStream = streamID - m.highestReceived = byteOffset - return nil -} - -var _ = Describe("Stream", func() { - var ( - str *stream - handler *mockStreamHandler - ) - - BeforeEach(func() { - var streamID protocol.StreamID = 1337 - handler = &mockStreamHandler{} - cpm := handshake.NewConnectionParamatersManager() - flowController := flowcontrol.NewFlowController(streamID, cpm) - flowControlManager := flowcontrol.NewFlowControlManager(cpm) - flowControlManager.NewStream(streamID, true) - str, _ = newStream(handler, cpm, flowController, flowControlManager, streamID) - }) - - It("gets stream id", func() { - Expect(str.StreamID()).To(Equal(protocol.StreamID(1337))) - }) - - Context("reading", func() { - It("reads a single StreamFrame", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF}, - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - }) - - It("reads a single StreamFrame in multiple goes", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF}, - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 2) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(2)) - Expect(b).To(Equal([]byte{0xDE, 0xAD})) - n, err = str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(2)) - Expect(b).To(Equal([]byte{0xBE, 0xEF})) - }) - - It("reads single bytes", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF}, - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - b, err := str.ReadByte() - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(Equal(byte(0xDE))) - b, err = str.ReadByte() - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(Equal(byte(0xAD))) - b, err = str.ReadByte() - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(Equal(byte(0xBE))) - b, err = str.ReadByte() - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(Equal(byte(0xEF))) - }) - - It("reads all data available", func() { - frame1 := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD}, - } - frame2 := frames.StreamFrame{ - Offset: 2, - Data: []byte{0xBE, 0xEF}, - } - err := str.AddStreamFrame(&frame1) - Expect(err).ToNot(HaveOccurred()) - err = str.AddStreamFrame(&frame2) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 6) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF, 0x00, 0x00})) - }) - - It("assembles multiple StreamFrames", func() { - frame1 := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD}, - } - frame2 := frames.StreamFrame{ - Offset: 2, - Data: []byte{0xBE, 0xEF}, - } - err := str.AddStreamFrame(&frame1) - Expect(err).ToNot(HaveOccurred()) - err = str.AddStreamFrame(&frame2) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - }) - - It("waits until data is available", func() { - go func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD}, - } - time.Sleep(time.Millisecond) - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - }() - b := make([]byte, 2) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(2)) - }) - - It("handles StreamFrames in wrong order", func() { - frame1 := frames.StreamFrame{ - Offset: 2, - Data: []byte{0xBE, 0xEF}, - } - frame2 := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD}, - } - err := str.AddStreamFrame(&frame1) - Expect(err).ToNot(HaveOccurred()) - err = str.AddStreamFrame(&frame2) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - }) - - It("ignores duplicate StreamFrames", func() { - frame1 := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD}, - } - frame2 := frames.StreamFrame{ - Offset: 0, - Data: []byte{0x13, 0x37}, - } - frame3 := frames.StreamFrame{ - Offset: 2, - Data: []byte{0xBE, 0xEF}, - } - err := str.AddStreamFrame(&frame1) - Expect(err).ToNot(HaveOccurred()) - err = str.AddStreamFrame(&frame2) - Expect(err).ToNot(HaveOccurred()) - err = str.AddStreamFrame(&frame3) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - }) - - It("rejects a StreamFrames with an overlapping data range", func() { - frame1 := frames.StreamFrame{ - Offset: 0, - Data: []byte("ab"), - } - frame2 := frames.StreamFrame{ - Offset: 1, - Data: []byte("xy"), - } - err := str.AddStreamFrame(&frame1) - Expect(err).ToNot(HaveOccurred()) - err = str.AddStreamFrame(&frame2) - Expect(err).To(MatchError(errOverlappingStreamData)) - }) - - }) - - Context("writing", func() { - It("writes str frames", func() { - n, err := str.Write([]byte("foobar")) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(6)) - Expect(handler.frames).To(HaveLen(1)) - Expect(handler.frames[0]).To(Equal(&frames.StreamFrame{ - StreamID: 1337, - Data: []byte("foobar"), - })) - }) - - It("writes multiple str frames", func() { - n, err := str.Write([]byte("foo")) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(3)) - n, err = str.Write([]byte("bar")) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(3)) - Expect(handler.frames).To(HaveLen(2)) - Expect(handler.frames[0]).To(Equal(&frames.StreamFrame{ - StreamID: 1337, - Data: []byte("foo"), - })) - Expect(handler.frames[1]).To(Equal(&frames.StreamFrame{ - StreamID: 1337, - Data: []byte("bar"), - Offset: 3, - })) - }) - - It("closes", func() { - err := str.Close() - Expect(err).ToNot(HaveOccurred()) - Expect(handler.frames).To(HaveLen(1)) - Expect(handler.frames[0]).To(Equal(&frames.StreamFrame{ - StreamID: 1337, - FinBit: true, - Offset: 0, - })) - }) - - It("returns remote errors", func() { - testErr := errors.New("test") - str.RegisterError(testErr) - n, err := str.Write([]byte("foo")) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(testErr)) - }) - - Context("flow control", func() { - It("writes everything if the flow control window is big enough", func() { - data := []byte{0xDE, 0xCA, 0xFB, 0xAD} - updated := str.flowController.UpdateSendWindow(4) - Expect(updated).To(BeTrue()) - n, err := str.Write(data) - Expect(n).To(Equal(4)) - Expect(err).ToNot(HaveOccurred()) - Expect(handler.frames).To(HaveLen(1)) - Expect(handler.frames[0].Data).To(Equal(data)) - }) - - It("doesn't care about the connection flow control window if it is not contributing", func() { - updated := str.flowController.UpdateSendWindow(4) - Expect(updated).To(BeTrue()) - str.contributesToConnectionFlowControl = false - updated = str.connectionFlowController.UpdateSendWindow(1) - Expect(updated).To(BeTrue()) - n, err := str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(4)) - }) - - It("returns true when the flow control window was updated", func() { - updated := str.flowController.UpdateSendWindow(4) - Expect(updated).To(BeTrue()) - updated = str.UpdateSendFlowControlWindow(5) - Expect(updated).To(BeTrue()) - }) - - It("returns false when the flow control window was not updated", func() { - updated := str.flowController.UpdateSendWindow(4) - Expect(updated).To(BeTrue()) - updated = str.UpdateSendFlowControlWindow(3) - Expect(updated).To(BeFalse()) - }) - - It("waits for a stream flow control window update", func() { - var b bool - updated := str.flowController.UpdateSendWindow(1) - Expect(updated).To(BeTrue()) - _, err := str.Write([]byte{0x42}) - Expect(err).ToNot(HaveOccurred()) - - go func() { - time.Sleep(2 * time.Millisecond) - b = true - str.UpdateSendFlowControlWindow(3) - }() - n, err := str.Write([]byte{0x13, 0x37}) - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(BeTrue()) - Expect(n).To(Equal(2)) - Expect(str.writeOffset).To(Equal(protocol.ByteCount(3))) - Expect(handler.frames).To(HaveLen(2)) - Expect(handler.frames[0].Offset).To(Equal(protocol.ByteCount(0))) - Expect(handler.frames[0].Data).To(Equal([]byte{0x42})) - Expect(handler.frames[1].Offset).To(Equal(protocol.ByteCount(1))) - Expect(handler.frames[1].Data).To(Equal([]byte{0x13, 0x37})) - }) - - It("does not write too much data after receiving a window update", func() { - var b bool - updated := str.flowController.UpdateSendWindow(1) - Expect(updated).To(BeTrue()) - - go func() { - time.Sleep(2 * time.Millisecond) - b = true - str.UpdateSendFlowControlWindow(5) - }() - n, err := str.Write([]byte{0x13, 0x37}) - Expect(b).To(BeTrue()) - Expect(n).To(Equal(2)) - Expect(str.writeOffset).To(Equal(protocol.ByteCount(2))) - Expect(err).ToNot(HaveOccurred()) - Expect(handler.frames).To(HaveLen(2)) - Expect(handler.frames[0].Data).To(Equal([]byte{0x13})) - Expect(handler.frames[1].Data).To(Equal([]byte{0x37})) - }) - - It("waits for a connection flow control window update", func() { - var b bool - updated := str.flowController.UpdateSendWindow(1000) - Expect(updated).To(BeTrue()) - updated = str.connectionFlowController.UpdateSendWindow(1) - Expect(updated).To(BeTrue()) - str.contributesToConnectionFlowControl = true - - _, err := str.Write([]byte{0x42}) - Expect(err).ToNot(HaveOccurred()) - Expect(str.writeOffset).To(Equal(protocol.ByteCount(1))) - - var sendWindowUpdated bool - go func() { - time.Sleep(2 * time.Millisecond) - b = true - sendWindowUpdated = str.connectionFlowController.UpdateSendWindow(3) - str.ConnectionFlowControlWindowUpdated() - }() - - n, err := str.Write([]byte{0x13, 0x37}) - Expect(b).To(BeTrue()) - Expect(sendWindowUpdated).To(BeTrue()) - Expect(n).To(Equal(2)) - Expect(str.writeOffset).To(Equal(protocol.ByteCount(3))) - Expect(err).ToNot(HaveOccurred()) - }) - - It("splits writing of frames when given more data than the flow control windows size", func() { - updated := str.flowController.UpdateSendWindow(2) - Expect(updated).To(BeTrue()) - var b bool - - go func() { - time.Sleep(time.Millisecond) - b = true - str.UpdateSendFlowControlWindow(4) - }() - - n, err := str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}) - Expect(err).ToNot(HaveOccurred()) - Expect(handler.frames).To(HaveLen(2)) - Expect(b).To(BeTrue()) - Expect(n).To(Equal(4)) - Expect(str.writeOffset).To(Equal(protocol.ByteCount(4))) - }) - - It("writes after a flow control window update", func() { - var b bool - updated := str.flowController.UpdateSendWindow(1) - Expect(updated).To(BeTrue()) - - _, err := str.Write([]byte{0x42}) - Expect(err).ToNot(HaveOccurred()) - - go func() { - time.Sleep(time.Millisecond) - b = true - str.UpdateSendFlowControlWindow(3) - }() - n, err := str.Write([]byte{0xDE, 0xAD}) - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(BeTrue()) - Expect(n).To(Equal(2)) - Expect(str.writeOffset).To(Equal(protocol.ByteCount(3))) - }) - - It("immediately returns on remote errors", func() { - var b bool - updated := str.flowController.UpdateSendWindow(1) - Expect(updated).To(BeTrue()) - - testErr := errors.New("test error") - - go func() { - time.Sleep(time.Millisecond) - b = true - str.RegisterError(testErr) - }() - - _, err := str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}) - Expect(err).To(MatchError(testErr)) - Expect(b).To(BeTrue()) - }) - - It("works with large flow control windows", func() { - // This paniced before due to a wrong cast, - // see https://github.com/lucas-clemente/quic-go/issues/143 - str.contributesToConnectionFlowControl = false - updated := str.UpdateSendFlowControlWindow(protocol.ByteCount(1) << 63) - Expect(updated).To(BeTrue()) - _, err := str.Write([]byte("foobar")) - Expect(err).NotTo(HaveOccurred()) - }) - }) - }) - - PContext("Blocked streams", func() { - It("notifies the session when a stream is flow control blocked", func() { - updated := str.flowController.UpdateSendWindow(1337) - Expect(updated).To(BeTrue()) - str.flowController.AddBytesSent(1337) - str.maybeTriggerBlocked() - Expect(handler.receivedBlockedCalled).To(BeTrue()) - Expect(handler.receivedBlockedForStream).To(Equal(str.streamID)) - }) - - It("notifies the session as soon as a stream is reaching the end of the window", func() { - updated := str.flowController.UpdateSendWindow(4) - Expect(updated).To(BeTrue()) - str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}) - Expect(handler.receivedBlockedCalled).To(BeTrue()) - Expect(handler.receivedBlockedForStream).To(Equal(str.streamID)) - }) - - It("notifies the session as soon as a stream is flow control blocked", func() { - updated := str.flowController.UpdateSendWindow(2) - Expect(updated).To(BeTrue()) - go func() { - str.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}) - }() - time.Sleep(time.Millisecond) - Expect(handler.receivedBlockedCalled).To(BeTrue()) - Expect(handler.receivedBlockedForStream).To(Equal(str.streamID)) - }) - }) - - Context("flow control, for receiving", func() { - BeforeEach(func() { - str.flowControlManager = &mockFlowControlHandler{} - }) - - It("updates the highestReceived value in the flow controller", func() { - frame := frames.StreamFrame{ - Offset: 2, - Data: []byte("foobar"), - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - Expect(err).ToNot(HaveOccurred()) - Expect(str.flowControlManager.(*mockFlowControlHandler).highestReceivedForStream).To(Equal(str.streamID)) - Expect(str.flowControlManager.(*mockFlowControlHandler).highestReceived).To(Equal(protocol.ByteCount(2 + 6))) - }) - - It("updates the flow control window", func() { - str.flowControlManager.(*mockFlowControlHandler).triggerStreamWindowUpdate = true - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 6) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(6)) - Expect(handler.receiveFlowControlWindowCalled).To(BeTrue()) - Expect(handler.receiveFlowControlWindowCalledForStream).To(Equal(str.streamID)) - }) - - It("updates the connection level flow control window", func() { - str.flowControlManager.(*mockFlowControlHandler).triggerConnectionWindowUpdate = true - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte("foobar"), - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 6) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(6)) - Expect(handler.receiveFlowControlWindowCalled).To(BeTrue()) - Expect(handler.receiveFlowControlWindowCalledForStream).To(Equal(protocol.StreamID(0))) - }) - - // TODO: think about flow control violation - }) - - Context("closing", func() { - Context("with fin bit", func() { - It("returns EOFs", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF}, - FinBit: true, - } - str.AddStreamFrame(&frame) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).To(MatchError(io.EOF)) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - n, err = str.Read(b) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(io.EOF)) - }) - - It("handles out-of-order frames", func() { - frame1 := frames.StreamFrame{ - Offset: 2, - Data: []byte{0xBE, 0xEF}, - FinBit: true, - } - frame2 := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD}, - } - err := str.AddStreamFrame(&frame1) - Expect(err).ToNot(HaveOccurred()) - err = str.AddStreamFrame(&frame2) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).To(MatchError(io.EOF)) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - n, err = str.Read(b) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(io.EOF)) - }) - - It("returns EOFs with partial read", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD}, - FinBit: true, - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).To(MatchError(io.EOF)) - Expect(n).To(Equal(2)) - Expect(b[:n]).To(Equal([]byte{0xDE, 0xAD})) - }) - - It("handles immediate FINs", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{}, - FinBit: true, - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(io.EOF)) - }) - }) - - Context("with remote errors", func() { - testErr := errors.New("test error") - - It("returns EOF if data is read before", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF}, - FinBit: true, - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - str.RegisterError(testErr) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).To(MatchError(io.EOF)) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - n, err = str.Read(b) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(io.EOF)) - }) - - It("returns errors", func() { - frame := frames.StreamFrame{ - Offset: 0, - Data: []byte{0xDE, 0xAD, 0xBE, 0xEF}, - } - err := str.AddStreamFrame(&frame) - Expect(err).ToNot(HaveOccurred()) - str.RegisterError(testErr) - b := make([]byte, 4) - n, err := str.Read(b) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(4)) - Expect(b).To(Equal([]byte{0xDE, 0xAD, 0xBE, 0xEF})) - n, err = str.Read(b) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(testErr)) - }) - }) - - Context("when CloseRemote is called", func() { - It("closes", func() { - str.CloseRemote(0) - b := make([]byte, 8) - n, err := str.Read(b) - Expect(n).To(BeZero()) - Expect(err).To(MatchError(io.EOF)) - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/testdata/cert.go b/vendor/github.com/lucas-clemente/quic-go/testdata/cert.go deleted file mode 100644 index b7c5475..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/testdata/cert.go +++ /dev/null @@ -1,31 +0,0 @@ -package testdata - -import ( - "crypto/tls" - "crypto/x509" -) - -// GetTLSConfig returns a tls config for quic.clemente.io -func GetTLSConfig() *tls.Config { - return &tls.Config{ - Certificates: []tls.Certificate{GetCertificate()}, - } -} - -// GetCertificate returns a certificate for quic.clemente.io -func GetCertificate() tls.Certificate { - key, err := x509.ParsePKCS1PrivateKey(keyDer) - if err != nil { - panic(err) - } - return tls.Certificate{ - Certificate: [][]byte{certDer, chainDer}, - PrivateKey: key, - } -} - -var certDer = []byte("0\x82\x05\x040\x82\x03\xec\xa0\x03\x02\x01\x02\x02\x12\x03\xde)\r\xc6N\xfd\x11*Z\xd5\xf3\xce\xf5\x8c:F\x970\r\x06\t*\x86H\x86\xf7\r\x01\x01\v\x05\x000J1\v0\t\x06\x03U\x04\x06\x13\x02US1\x160\x14\x06\x03U\x04\n\x13\rLet's Encrypt1#0!\x06\x03U\x04\x03\x13\x1aLet's Encrypt Authority X30\x1e\x17\r160415160800Z\x17\r160714160800Z0\x1b1\x190\x17\x06\x03U\x04\x03\x13\x10quic.clemente.io0\x82\x01\"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\xb7D\x11dAY0\x02\"u(HfCT\xb7\xc6E\x9e\xbfz\x80\x04\x14\xa3\xff`\xb1{\u02c8\v\xab\xfc\xa3/\xe7W\xb1c\xf4\x91e\xbd\xee\xd2\xdeBC\xfd\"f\xed\x01S\x17\x8d\xaf2C\xd5\x04m\xb1?\x88&\x8b\b\x02\xd1\xdc\x1e?\x80U=\xf3\x8f\xea\bL\xa7=\xa2\xc0NhY\xa4I_\xc8TV\x04\x86\x85.\x0e\x1a8\x12\x86v\v\xce\xdb%v{\xf3\xd3\xfb\xe4\x02\x8e\xd6\xf7\xe0\x98\x99E]W\xbe\xced\x10\xfaJcx\x1f\xa5t\x0f\xa0]\x8d\xb7\xa5\x96\xe6TT\x8e\xa3p!\xbd\x04\x9cR\x84I\xae\x88*[\x04<3:\u3e92<\u060c\x97\xe5:\xa9\x8a\xc1\x9b\xbdV~|\xc4k\x97\x8f.\u008d\u04db\xed\x02_\u33c6\u01c4\xac\xbd_\x9b\x8a\xc5\xfcn\xb8\x9cH\xb0Ug\xa5R\xc2i\u0082x\xad>\xb4\\\xcbl\u007f\xe4h0\xbd\x1e\x87\x8a\xd7\xd4yf\x95\x1d9\x9f\xfam\xf9e\t\x80n\xf4yr\xabz$o\xbf\x02\x03\x01\x00\x01\xa3\x82\x02\x110\x82\x02\r0\x0e\x06\x03U\x1d\x0f\x01\x01\xff\x04\x04\x03\x02\x05\xa00\x1d\x06\x03U\x1d%\x04\x160\x14\x06\b+\x06\x01\x05\x05\a\x03\x01\x06\b+\x06\x01\x05\x05\a\x03\x020\f\x06\x03U\x1d\x13\x01\x01\xff\x04\x020\x000\x1d\x06\x03U\x1d\x0e\x04\x16\x04\x14\x890\x12\x12\u0379\u68190\x0f\xac\x13\x98\x80\xd2?\xfc\x8f\xa60\x1f\x06\x03U\x1d#\x04\x180\x16\x80\x14\xa8Jjc\x04}\u077a\xe6\xd19\xb7\xa6Ee\xef\xf3\xa8\xec\xa10p\x06\b+\x06\x01\x05\x05\a\x01\x01\x04d0b0/\x06\b+\x06\x01\x05\x05\a0\x01\x86#http://ocsp.int-x3.letsencrypt.org/0/\x06\b+\x06\x01\x05\x05\a0\x02\x86#http://cert.int-x3.letsencrypt.org/0\x1b\x06\x03U\x1d\x11\x04\x140\x12\x82\x10quic.clemente.io0\x81\xfe\x06\x03U\x1d \x04\x81\xf60\x81\xf30\b\x06\x06g\x81\f\x01\x02\x010\x81\xe6\x06\v+\x06\x01\x04\x01\x82\xdf\x13\x01\x01\x010\x81\xd60&\x06\b+\x06\x01\x05\x05\a\x02\x01\x16\x1ahttp://cps.letsencrypt.org0\x81\xab\x06\b+\x06\x01\x05\x05\a\x02\x020\x81\x9e\f\x81\x9bThis Certificate may only be relied upon by Relying Parties and only in accordance with the Certificate Policy found at https://letsencrypt.org/repository/0\r\x06\t*\x86H\x86\xf7\r\x01\x01\v\x05\x00\x03\x82\x01\x01\x00\x1bo\xf3U\azq\xd6OUG\xa1K`\x81\x8b\xb5c\xf3\xb0\xa3Q\x05\xd9\xf8\xa7\x9aU\u0202\x96\xfc\xec\xcc^\xcc\xe1P\xd8j\xfeg\xf4\xab\x97\xe7v\x98\x1f>P\x1cPX\xc0Z\xef\x05Gf\xff\x81\xd9q\x96\xe2\x12\fM\xb2\xf2#\x1d\xee\xd7\xf7\xc8f\x11\ud5bcw(\x83\xc90\xbb\xba\x1aA\r\r\x1b\xa9\xc9\x19t\xa9bIEd\x8a\xdf\x19\u0154^\xb7\x95a_\xe2\x00\xaa\xfa\xf1Tk\xfb\xd2F\xa2l\xf2\xbdj\xdb\xe6q\x1d\x9d\xce\\G\x93='?\x89\xa5\x12\xecY\xf8\u9949<\x90\xbd\xc3\xf1\xb8\xbf&\xd1!\xc3%\u019353S7I\xf9Q\xb3RyY\xb3j\x81\xf6\rv\u007fY\x9a\xc4\x14\xa1\xf2\xd0\xe9\f\xf6W]\xf0\x8a\xad\x02\xediqlx\xc8\xd5\x18i\xc3\u0452\xbcw\x83\x9f\xb7\xb8'H@\x0f\xbd8\xb4v\x94\xac\xa2(]I\xa4\x91\xd0\x05i\xc9FS\xb8\xf7~ \xac\xba!\x94{YB\x93\u0469&J}E%") - -var chainDer = []byte("0\x82\x04\x920\x82\x03z\xa0\x03\x02\x01\x02\x02\x10\n\x01AB\x00\x00\x01S\x85sj\v\x85\xec\xa7\b0\r\x06\t*\x86H\x86\xf7\r\x01\x01\v\x05\x000?1$0\"\x06\x03U\x04\n\x13\x1bDigital Signature Trust Co.1\x170\x15\x06\x03U\x04\x03\x13\x0eDST Root CA X30\x1e\x17\r160317164046Z\x17\r210317164046Z0J1\v0\t\x06\x03U\x04\x06\x13\x02US1\x160\x14\x06\x03U\x04\n\x13\rLet's Encrypt1#0!\x06\x03U\x04\x03\x13\x1aLet's Encrypt Authority X30\x82\x01\"0\r\x06\t*\x86H\x86\xf7\r\x01\x01\x01\x05\x00\x03\x82\x01\x0f\x000\x82\x01\n\x02\x82\x01\x01\x00\x9c\xd3\f\xf0Z\xe5.G\xb7r]7\x83\xb3hc0\xea\xd75&\x19%\u1f7e5\xf1p\x92/\xb7\xb8KA\x05\xab\xa9\x9e5\bX\xec\xb1*\xc4h\x87\v\xa3\xe3u\xe4\xe6\xf3\xa7bq\xbay\x81`\x1f\u05d1\x9a\x9f\xf3\xd0xgq\xc8i\x0e\x95\x91\xcf\xfe\xe6\x99\xe9`W#\x9e\xa6\x1e\x04b\x9a\xff\xd7\x05\u02b7\x1f?\xc0\nH\xbc\x94\xb0\xb6eb\xe0\xc1T\xe5\xa3*\xad \xc4\xe9\xe6\xbb\xdc\xc8\xf6\xb5\xc32\xa3\x98\xccw\xa8\xe6ye\a+\xcb(\xfe:\x16R\x81\xceR\f._\x83\xe8\xd5\x063\xfbwl\xce@\xea2\x9e\x1f\x92\\A\xc1tl[]\n_3\xccM\x9f\xac8\xf0/{,b\x9d\u0663\x91o%\x1b/\x90\xb1\x19F=\xf6~\x1b\xa6z\x87\xb9\xa3zm\x18\xfa%\xa5\x91\x87\x15\xe0\xf2\x16/X\xb0\x06/,h&\xc6K\x98\xcd\u069f\f\xf9\u007f\x90\xedCJ\x12DNosz(\ua92an{L}\x87\xdd\xe0\xc9\x02D\xa7\x87\xaf\xc34[\xb4B") - -var keyDer = []byte("0\x82\x04\xa5\x02\x01\x00\x02\x82\x01\x01\x00\xb7D\x11dAY0\x02\"u(HfCT\xb7\xc6E\x9e\xbfz\x80\x04\x14\xa3\xff`\xb1{\u02c8\v\xab\xfc\xa3/\xe7W\xb1c\xf4\x91e\xbd\xee\xd2\xdeBC\xfd\"f\xed\x01S\x17\x8d\xaf2C\xd5\x04m\xb1?\x88&\x8b\b\x02\xd1\xdc\x1e?\x80U=\xf3\x8f\xea\bL\xa7=\xa2\xc0NhY\xa4I_\xc8TV\x04\x86\x85.\x0e\x1a8\x12\x86v\v\xce\xdb%v{\xf3\xd3\xfb\xe4\x02\x8e\xd6\xf7\xe0\x98\x99E]W\xbe\xced\x10\xfaJcx\x1f\xa5t\x0f\xa0]\x8d\xb7\xa5\x96\xe6TT\x8e\xa3p!\xbd\x04\x9cR\x84I\xae\x88*[\x04<3:\u3e92<\u060c\x97\xe5:\xa9\x8a\xc1\x9b\xbdV~|\xc4k\x97\x8f.\u008d\u04db\xed\x02_\u33c6\u01c4\xac\xbd_\x9b\x8a\xc5\xfcn\xb8\x9cH\xb0Ug\xa5R\xc2i\u0082x\xad>\xb4\\\xcbl\u007f\xe4h0\xbd\x1e\x87\x8a\xd7\xd4yf\x95\x1d9\x9f\xfam\xf9e\t\x80n\xf4yr\xabz$o\xbf\x02\x03\x01\x00\x01\x02\x82\x01\x01\x00\x8a\x05\xfb\xcb3\xe4E\xe1\xf5\xad\xa2\xcf\x14%\xb5\x92K\x03x\x11\xe1\xe2\xb40\x0fkp\x99{\x10\u023fq\xa2n\f\xd0\x01\x1d\x9a\x98AA\r\x10\xe7CyH\xd7F\xa7\x99\xec\x1bvk\xc0\xfc\xecUlfh\xcd\xden\x98\xdbI\xb4`Ao\xb5\xe9}%\b\xc8K\xc3\xdfX\xeePC=\x17\xf6AD\xa0\r\xd4R\xc85Y\x80I\x82\u0740\xe3:\xf5i\xdb\a'Gu\xea\t\xc9[f\xcf}\x19\xb0\xa5\xab-@\x89\x13P\xb0c\xa8\xbf\xe9X\x87&.\\yi^\xc0ujLA\x85\n\x14\x99\xb3O\xf7\xd0m\x05)\x8aklQ\u0162\xb1AQ\xf3\xa8l\xf9s\xd3}\x1bQ\xdcj\xb0\xd3\xf9\xd9\u00fbK\xf9\x9b\xb6&A\x97\xaf\xe8\xabWt\u007f\xb5W\x84P\u03ce\xd4\xcd;\u07b2\x9f\x16B\xbf4\x06\xe3%\x10\xa7\xce\x1b\xf4\x1e)\xa3=\xcb\x11v\xd7PD\xa2\xf3S\xa9\xbcCG\x0e\r\x940!\x8cZ#\xa6\xe0Sx|\xe2\xcai\xf7\xf1\x02\x81\x81\x00\xec8\xf2\x871\xad\x15\n\xcd;\xfd\xdc\u0599\x1e4\xfax\u02e3S\x80\x14I\xd6|1\xdb \xb3\xb7\xdb\x12\x9a/ej\xacA\x98?8*\xbc\xa1u\xbb\xb1\xbb\u06ac3\xf8X\xe2\x12\x1fhjI\xc3\xd8:\xad]\f\xc54\xab\xa9\xcc&\x1707XV\n\x9e\xf2\u0611\x17~\xe1{\xc8\r\xdb?i\xb9G\x02'\xcbDt\u0096x\x83Qp\x05\xcf+\xbb\u019c\x1b\x84\"}(\x05\xb7\x1b\xec\x13\xe4\xfbC\xe8\x03_\xa83\x02\x81\x81\x00\u019c\x14\xb5x\xa7<\xa5#\xdd\xc7:\x18\xb36\x05\xfe\tbKy\xa3\xae\u0667\u03f3\xad\x1bC\xf3lU\xaf\xbd+Vh\xcd\xf20>\xfe\xfb\x13t\xba\xfe\xc7\xe8\xfc\x84\x13\x18#\x8e\xc0\xd6*`I\x86\x11\u0703\xa5\x96\xf1r\x03\xfa\u06ce\xba\xb9brS\x11\\[\x1c\x9b\x9f\x99O'\xdb'\x00-\xb0\xa4\xf5}#\x8d}\u07f3rU\xf9\x98\u03f2f\x8a\x15\xeb^\x91\x04M\x04\xbeT\xeai\x11\x88\x95\u05d1\xfa!~E\x02\x81\x80\x04\xf4\xc0\xe9\xe39\xedj\x17\x9a=\x9eG\x86X\xe2\xe5\xaai#Y\x1a#\xd2\xd4\xc40K\x97\xa9\r\x9ft\tv\x1b\x1b\x9c\u05d7y$\x15\x89u\x9d\xc1\xbd]\u2760M\x82\x97\xe3\xa7s\n_\xd7\xd3\x0e\x90\x1a\x96\xad\x00\x88\xe5|\x1a\x04|\x87|\xbb\xf9g\x12SF\xe0\x06Rv\xc5`\xbd\v\u070c\xfd\x97f\xfcU\xc8YX\xcc\xd8|y\xec5G\x86\x9e\t\"n\xa8F\x95\xf3`\xbf\x1e9\xe0\xa1\x00\xf0\xba9d\x8f\x02\x81\x81\x00\xae\x85\xf6\xf8\xa4F(\xd7`\x96\x00\xfc\u007f9\xf3\x8d\xfevV\x86\xc6#\u0700\xec\xa2j\\\x02*\x8a\xdc6\u02cf\xeaf+\x00V\x02\xa9H\xbcn\x93S\u0090\xfe\x9d\xee\x9d,\xc8\n(O\u027b\x04\xc0\xa8/c\v~\x81:T^\xfa\xd2\b(\xe1f^\xb2Q\xba\xca\u007f\xc2\x16 \xe5\x80\x01\\y\xc9\u041a\xdb\xd5\x02\xff\x8a4\x90\x93\x16\x1a~\xe0`\x94\x94\xc0X@\fLu\x8f\x9e\xe4\xc1a#\xe9\xb0\x1dYtW\x15\x02\x81\x81\x00\x8b!\xd6\xfdA\xbe\xad\xf6W+6\xe1\x84:XX\xbawCy\xa5u\x02\b\ry\xb6\xe6\xa0\x1eJz3G?&\xa5\x9e2\xb40\xd2\xdf\xe0\xac\a|*\xc3\x15\x8f\xf9\xe0q\x86\xb2U]A#\x1d*]\xe5\u053fG\xe1\xe2\xbc\v\xaa\x8f\xec\xaa!\xf4\x9eT{/$h\x84u\u063d\xc0\u007f\x0f\x06\u01fc>K\x8f3\xa3\xd2\xf3\xac\xfa#\xf0l39\xf1\xf7\x0fr3\xd0\xd0]\x99\x90\xca\xfc\x10\u04ab`}\a&\bF") diff --git a/vendor/github.com/lucas-clemente/quic-go/udp_conn.go b/vendor/github.com/lucas-clemente/quic-go/udp_conn.go deleted file mode 100644 index ea1cc7e..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/udp_conn.go +++ /dev/null @@ -1,29 +0,0 @@ -package quic - -import "net" - -type connection interface { - write([]byte) error - setCurrentRemoteAddr(interface{}) - IP() net.IP -} - -type udpConn struct { - conn *net.UDPConn - currentAddr *net.UDPAddr -} - -var _ connection = &udpConn{} - -func (c *udpConn) write(p []byte) error { - _, err := c.conn.WriteToUDP(p, c.currentAddr) - return err -} - -func (c *udpConn) setCurrentRemoteAddr(addr interface{}) { - c.currentAddr = addr.(*net.UDPAddr) -} - -func (c *udpConn) IP() net.IP { - return c.currentAddr.IP -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/_gen.go b/vendor/github.com/lucas-clemente/quic-go/utils/_gen.go deleted file mode 100644 index 154515b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/_gen.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import ( - _ "github.com/clipperhouse/linkedlist" - _ "github.com/clipperhouse/slice" - _ "github.com/clipperhouse/stringer" -) diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/byteinterval_linkedlist.go b/vendor/github.com/lucas-clemente/quic-go/utils/byteinterval_linkedlist.go deleted file mode 100644 index 545fc20..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/byteinterval_linkedlist.go +++ /dev/null @@ -1,214 +0,0 @@ -// Generated by: main -// TypeWriter: linkedlist -// Directive: +gen on ByteInterval - -package utils - -// List is a modification of http://golang.org/pkg/container/list/ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// ByteIntervalElement is an element of a linked list. -type ByteIntervalElement struct { - // Next and previous pointers in the doubly-linked list of elements. - // To simplify the implementation, internally a list l is implemented - // as a ring, such that &l.root is both the next element of the last - // list element (l.Back()) and the previous element of the first list - // element (l.Front()). - next, prev *ByteIntervalElement - - // The list to which this element belongs. - list *ByteIntervalList - - // The value stored with this element. - Value ByteInterval -} - -// Next returns the next list element or nil. -func (e *ByteIntervalElement) Next() *ByteIntervalElement { - if p := e.next; e.list != nil && p != &e.list.root { - return p - } - return nil -} - -// Prev returns the previous list element or nil. -func (e *ByteIntervalElement) Prev() *ByteIntervalElement { - if p := e.prev; e.list != nil && p != &e.list.root { - return p - } - return nil -} - -// ByteIntervalList represents a doubly linked list. -// The zero value for ByteIntervalList is an empty list ready to use. -type ByteIntervalList struct { - root ByteIntervalElement // sentinel list element, only &root, root.prev, and root.next are used - len int // current list length excluding (this) sentinel element -} - -// Init initializes or clears list l. -func (l *ByteIntervalList) Init() *ByteIntervalList { - l.root.next = &l.root - l.root.prev = &l.root - l.len = 0 - return l -} - -// NewByteIntervalList returns an initialized list. -func NewByteIntervalList() *ByteIntervalList { return new(ByteIntervalList).Init() } - -// Len returns the number of elements of list l. -// The complexity is O(1). -func (l *ByteIntervalList) Len() int { return l.len } - -// Front returns the first element of list l or nil. -func (l *ByteIntervalList) Front() *ByteIntervalElement { - if l.len == 0 { - return nil - } - return l.root.next -} - -// Back returns the last element of list l or nil. -func (l *ByteIntervalList) Back() *ByteIntervalElement { - if l.len == 0 { - return nil - } - return l.root.prev -} - -// lazyInit lazily initializes a zero ByteIntervalList value. -func (l *ByteIntervalList) lazyInit() { - if l.root.next == nil { - l.Init() - } -} - -// insert inserts e after at, increments l.len, and returns e. -func (l *ByteIntervalList) insert(e, at *ByteIntervalElement) *ByteIntervalElement { - n := at.next - at.next = e - e.prev = at - e.next = n - n.prev = e - e.list = l - l.len++ - return e -} - -// insertValue is a convenience wrapper for insert(&ByteIntervalElement{Value: v}, at). -func (l *ByteIntervalList) insertValue(v ByteInterval, at *ByteIntervalElement) *ByteIntervalElement { - return l.insert(&ByteIntervalElement{Value: v}, at) -} - -// remove removes e from its list, decrements l.len, and returns e. -func (l *ByteIntervalList) remove(e *ByteIntervalElement) *ByteIntervalElement { - e.prev.next = e.next - e.next.prev = e.prev - e.next = nil // avoid memory leaks - e.prev = nil // avoid memory leaks - e.list = nil - l.len-- - return e -} - -// Remove removes e from l if e is an element of list l. -// It returns the element value e.Value. -func (l *ByteIntervalList) Remove(e *ByteIntervalElement) ByteInterval { - if e.list == l { - // if e.list == l, l must have been initialized when e was inserted - // in l or l == nil (e is a zero ByteIntervalElement) and l.remove will crash - l.remove(e) - } - return e.Value -} - -// PushFront inserts a new element e with value v at the front of list l and returns e. -func (l *ByteIntervalList) PushFront(v ByteInterval) *ByteIntervalElement { - l.lazyInit() - return l.insertValue(v, &l.root) -} - -// PushBack inserts a new element e with value v at the back of list l and returns e. -func (l *ByteIntervalList) PushBack(v ByteInterval) *ByteIntervalElement { - l.lazyInit() - return l.insertValue(v, l.root.prev) -} - -// InsertBefore inserts a new element e with value v immediately before mark and returns e. -// If mark is not an element of l, the list is not modified. -func (l *ByteIntervalList) InsertBefore(v ByteInterval, mark *ByteIntervalElement) *ByteIntervalElement { - if mark.list != l { - return nil - } - // see comment in ByteIntervalList.Remove about initialization of l - return l.insertValue(v, mark.prev) -} - -// InsertAfter inserts a new element e with value v immediately after mark and returns e. -// If mark is not an element of l, the list is not modified. -func (l *ByteIntervalList) InsertAfter(v ByteInterval, mark *ByteIntervalElement) *ByteIntervalElement { - if mark.list != l { - return nil - } - // see comment in ByteIntervalList.Remove about initialization of l - return l.insertValue(v, mark) -} - -// MoveToFront moves element e to the front of list l. -// If e is not an element of l, the list is not modified. -func (l *ByteIntervalList) MoveToFront(e *ByteIntervalElement) { - if e.list != l || l.root.next == e { - return - } - // see comment in ByteIntervalList.Remove about initialization of l - l.insert(l.remove(e), &l.root) -} - -// MoveToBack moves element e to the back of list l. -// If e is not an element of l, the list is not modified. -func (l *ByteIntervalList) MoveToBack(e *ByteIntervalElement) { - if e.list != l || l.root.prev == e { - return - } - // see comment in ByteIntervalList.Remove about initialization of l - l.insert(l.remove(e), l.root.prev) -} - -// MoveBefore moves element e to its new position before mark. -// If e or mark is not an element of l, or e == mark, the list is not modified. -func (l *ByteIntervalList) MoveBefore(e, mark *ByteIntervalElement) { - if e.list != l || e == mark || mark.list != l { - return - } - l.insert(l.remove(e), mark.prev) -} - -// MoveAfter moves element e to its new position after mark. -// If e is not an element of l, or e == mark, the list is not modified. -func (l *ByteIntervalList) MoveAfter(e, mark *ByteIntervalElement) { - if e.list != l || e == mark || mark.list != l { - return - } - l.insert(l.remove(e), mark) -} - -// PushBackList inserts a copy of an other list at the back of list l. -// The lists l and other may be the same. -func (l *ByteIntervalList) PushBackList(other *ByteIntervalList) { - l.lazyInit() - for i, e := other.Len(), other.Front(); i > 0; i, e = i-1, e.Next() { - l.insertValue(e.Value, l.root.prev) - } -} - -// PushFrontList inserts a copy of an other list at the front of list l. -// The lists l and other may be the same. -func (l *ByteIntervalList) PushFrontList(other *ByteIntervalList) { - l.lazyInit() - for i, e := other.Len(), other.Back(); i > 0; i, e = i-1, e.Prev() { - l.insertValue(e.Value, &l.root) - } -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/caching_reader.go b/vendor/github.com/lucas-clemente/quic-go/utils/caching_reader.go deleted file mode 100644 index e0203be..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/caching_reader.go +++ /dev/null @@ -1,35 +0,0 @@ -package utils - -import "bytes" - -// CachingReader wraps a reader and saves all data it reads -type CachingReader struct { - buf bytes.Buffer - r ReadStream -} - -// NewCachingReader returns a new CachingReader -func NewCachingReader(r ReadStream) *CachingReader { - return &CachingReader{r: r} -} - -// Read implements io.Reader -func (r *CachingReader) Read(p []byte) (int, error) { - n, err := r.r.Read(p) - r.buf.Write(p[:n]) - return n, err -} - -// ReadByte implements io.ByteReader -func (r *CachingReader) ReadByte() (byte, error) { - b, err := r.r.ReadByte() - if err == nil { - r.buf.WriteByte(b) - } - return b, err -} - -// Get the data cached -func (r *CachingReader) Get() []byte { - return r.buf.Bytes() -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/caching_reader_test.go b/vendor/github.com/lucas-clemente/quic-go/utils/caching_reader_test.go deleted file mode 100644 index 8f7513e..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/caching_reader_test.go +++ /dev/null @@ -1,36 +0,0 @@ -package utils - -import ( - "bytes" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Caching reader", func() { - It("caches Read()", func() { - r := bytes.NewReader([]byte("foobar")) - cr := NewCachingReader(r) - p := make([]byte, 3) - n, err := cr.Read(p) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(3)) - Expect(p).To(Equal([]byte("foo"))) - Expect(cr.Get()).To(Equal([]byte("foo"))) - }) - - It("caches ReadByte()", func() { - r := bytes.NewReader([]byte("foobar")) - cr := NewCachingReader(r) - b, err := cr.ReadByte() - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(Equal(byte('f'))) - b, err = cr.ReadByte() - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(Equal(byte('o'))) - b, err = cr.ReadByte() - Expect(err).ToNot(HaveOccurred()) - Expect(b).To(Equal(byte('o'))) - Expect(cr.Get()).To(Equal([]byte("foo"))) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/float16.go b/vendor/github.com/lucas-clemente/quic-go/utils/float16.go deleted file mode 100644 index 8abdb51..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/float16.go +++ /dev/null @@ -1,86 +0,0 @@ -package utils - -import ( - "bytes" - "io" - "math" -) - -// We define an unsigned 16-bit floating point value, inspired by IEEE floats -// (http://en.wikipedia.org/wiki/Half_precision_floating-point_format), -// with 5-bit exponent (bias 1), 11-bit mantissa (effective 12 with hidden -// bit) and denormals, but without signs, transfinites or fractions. Wire format -// 16 bits (little-endian byte order) are split into exponent (high 5) and -// mantissa (low 11) and decoded as: -// uint64_t value; -// if (exponent == 0) value = mantissa; -// else value = (mantissa | 1 << 11) << (exponent - 1) -const uFloat16ExponentBits = 5 -const uFloat16MaxExponent = (1 << uFloat16ExponentBits) - 2 // 30 -const uFloat16MantissaBits = 16 - uFloat16ExponentBits // 11 -const uFloat16MantissaEffectiveBits = uFloat16MantissaBits + 1 // 12 -const uFloat16MaxValue = ((uint64(1) << uFloat16MantissaEffectiveBits) - 1) << uFloat16MaxExponent // 0x3FFC0000000 - -// ReadUfloat16 reads a float in the QUIC-float16 format and returns its uint64 representation -func ReadUfloat16(b io.ByteReader) (uint64, error) { - val, err := ReadUint16(b) - if err != nil { - return 0, err - } - - res := uint64(val) - - if res < (1 << uFloat16MantissaEffectiveBits) { - // Fast path: either the value is denormalized (no hidden bit), or - // normalized (hidden bit set, exponent offset by one) with exponent zero. - // Zero exponent offset by one sets the bit exactly where the hidden bit is. - // So in both cases the value encodes itself. - return res, nil - } - - exponent := val >> uFloat16MantissaBits // No sign extend on uint! - // After the fast pass, the exponent is at least one (offset by one). - // Un-offset the exponent. - exponent-- - // Here we need to clear the exponent and set the hidden bit. We have already - // decremented the exponent, so when we subtract it, it leaves behind the - // hidden bit. - res -= uint64(exponent) << uFloat16MantissaBits - res <<= exponent - return res, nil -} - -// WriteUfloat16 writes a float in the QUIC-float16 format from its uint64 representation -func WriteUfloat16(b *bytes.Buffer, value uint64) { - var result uint16 - if value < (uint64(1) << uFloat16MantissaEffectiveBits) { - // Fast path: either the value is denormalized, or has exponent zero. - // Both cases are represented by the value itself. - result = uint16(value) - } else if value >= uFloat16MaxValue { - // Value is out of range; clamp it to the maximum representable. - result = math.MaxUint16 - } else { - // The highest bit is between position 13 and 42 (zero-based), which - // corresponds to exponent 1-30. In the output, mantissa is from 0 to 10, - // hidden bit is 11 and exponent is 11 to 15. Shift the highest bit to 11 - // and count the shifts. - exponent := uint16(0) - for offset := uint16(16); offset > 0; offset /= 2 { - // Right-shift the value until the highest bit is in position 11. - // For offset of 16, 8, 4, 2 and 1 (binary search over 1-30), - // shift if the bit is at or above 11 + offset. - if value >= (uint64(1) << (uFloat16MantissaBits + offset)) { - exponent += offset - value >>= offset - } - } - - // Hidden bit (position 11) is set. We should remove it and increment the - // exponent. Equivalently, we just add it to the exponent. - // This hides the bit. - result = (uint16(value) + (exponent << uFloat16MantissaBits)) - } - - WriteUint16(b, result) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/float16_test.go b/vendor/github.com/lucas-clemente/quic-go/utils/float16_test.go deleted file mode 100644 index 8e3c26f..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/float16_test.go +++ /dev/null @@ -1,150 +0,0 @@ -package utils - -import ( - "bytes" - "io" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("float16", func() { - It("reads", func() { - testcases := []struct { - expected uint64 - binary uint16 - }{ - // There are fewer decoding test cases because encoding truncates, and - // decoding returns the smallest expansion. - // Small numbers represent themselves. - {0, 0}, - {1, 1}, - {2, 2}, - {3, 3}, - {4, 4}, - {5, 5}, - {6, 6}, - {7, 7}, - {15, 15}, - {31, 31}, - {42, 42}, - {123, 123}, - {1234, 1234}, - // Check transition through 2^11. - {2046, 2046}, - {2047, 2047}, - {2048, 2048}, - {2049, 2049}, - // Running out of mantissa at 2^12. - {4094, 4094}, - {4095, 4095}, - {4096, 4096}, - {4098, 4097}, - {4100, 4098}, - // Check transition through 2^13. - {8190, 6143}, - {8192, 6144}, - {8196, 6145}, - // Half-way through the exponents. - {0x7FF8000, 0x87FF}, - {0x8000000, 0x8800}, - {0xFFF0000, 0x8FFF}, - {0x10000000, 0x9000}, - // Transition into the largest exponent. - {0x1FFE0000000, 0xF7FF}, - {0x20000000000, 0xF800}, - {0x20040000000, 0xF801}, - // Transition into the max value. - {0x3FF80000000, 0xFFFE}, - {0x3FFC0000000, 0xFFFF}, - } - for _, testcase := range testcases { - b := &bytes.Buffer{} - WriteUint16(b, testcase.binary) - val, err := ReadUfloat16(b) - Expect(err).NotTo(HaveOccurred()) - Expect(val).To(Equal(testcase.expected)) - } - }) - - It("errors on eof", func() { - _, err := ReadUfloat16(&bytes.Buffer{}) - Expect(err).To(MatchError(io.EOF)) - }) - - It("writes", func() { - testcases := []struct { - decoded uint64 - encoded uint16 - }{ - // Small numbers represent themselves. - {0, 0}, - {1, 1}, - {2, 2}, - {3, 3}, - {4, 4}, - {5, 5}, - {6, 6}, - {7, 7}, - {15, 15}, - {31, 31}, - {42, 42}, - {123, 123}, - {1234, 1234}, - // Check transition through 2^11. - {2046, 2046}, - {2047, 2047}, - {2048, 2048}, - {2049, 2049}, - // Running out of mantissa at 2^12. - {4094, 4094}, - {4095, 4095}, - {4096, 4096}, - {4097, 4096}, - {4098, 4097}, - {4099, 4097}, - {4100, 4098}, - {4101, 4098}, - // Check transition through 2^13. - {8190, 6143}, - {8191, 6143}, - {8192, 6144}, - {8193, 6144}, - {8194, 6144}, - {8195, 6144}, - {8196, 6145}, - {8197, 6145}, - // Half-way through the exponents. - {0x7FF8000, 0x87FF}, - {0x7FFFFFF, 0x87FF}, - {0x8000000, 0x8800}, - {0xFFF0000, 0x8FFF}, - {0xFFFFFFF, 0x8FFF}, - {0x10000000, 0x9000}, - // Transition into the largest exponent. - {0x1FFFFFFFFFE, 0xF7FF}, - {0x1FFFFFFFFFF, 0xF7FF}, - {0x20000000000, 0xF800}, - {0x20000000001, 0xF800}, - {0x2003FFFFFFE, 0xF800}, - {0x2003FFFFFFF, 0xF800}, - {0x20040000000, 0xF801}, - {0x20040000001, 0xF801}, - // Transition into the max value and clamping. - {0x3FF80000000, 0xFFFE}, - {0x3FFBFFFFFFF, 0xFFFE}, - {0x3FFC0000000, 0xFFFF}, - {0x3FFC0000001, 0xFFFF}, - {0x3FFFFFFFFFF, 0xFFFF}, - {0x40000000000, 0xFFFF}, - {0xFFFFFFFFFFFFFFFF, 0xFFFF}, - } - for _, testcase := range testcases { - b := &bytes.Buffer{} - WriteUfloat16(b, testcase.decoded) - val, err := ReadUint16(b) - Expect(err).NotTo(HaveOccurred()) - Expect(val).To(Equal(testcase.encoded)) - } - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/log.go b/vendor/github.com/lucas-clemente/quic-go/utils/log.go deleted file mode 100644 index bb0f255..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/log.go +++ /dev/null @@ -1,70 +0,0 @@ -package utils - -import ( - "fmt" - "io" - "os" - "sync" -) - -var out io.Writer = os.Stdout - -// LogLevel of quic-go -type LogLevel uint8 - -const ( - // LogLevelDebug enables debug logs (e.g. packet contents) - LogLevelDebug LogLevel = iota - // LogLevelInfo enables info logs (e.g. packets) - LogLevelInfo - // LogLevelError enables err logs - LogLevelError - // LogLevelNothing disables - LogLevelNothing -) - -var logLevel = LogLevelNothing - -var mutex sync.Mutex - -// SetLogWriter sets the log writer. -func SetLogWriter(w io.Writer) { - out = w -} - -// SetLogLevel sets the log level -func SetLogLevel(level LogLevel) { - logLevel = level -} - -// Debugf logs something -func Debugf(format string, args ...interface{}) { - if logLevel == LogLevelDebug { - mutex.Lock() - fmt.Fprintf(out, format+"\n", args...) - mutex.Unlock() - } -} - -// Infof logs something -func Infof(format string, args ...interface{}) { - if logLevel <= LogLevelInfo { - mutex.Lock() - fmt.Fprintf(out, format+"\n", args...) - mutex.Unlock() - } -} - -// Errorf logs something -func Errorf(format string, args ...interface{}) { - if logLevel <= LogLevelError { - mutex.Lock() - fmt.Fprintf(out, format+"\n", args...) - mutex.Unlock() - } -} - -// Debug returns true if the log level is LogLevelDebug -func Debug() bool { - return logLevel == LogLevelDebug -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/log_test.go b/vendor/github.com/lucas-clemente/quic-go/utils/log_test.go deleted file mode 100644 index 3590710..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/log_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package utils - -import ( - "bytes" - "os" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Log", func() { - var ( - b *bytes.Buffer - ) - - BeforeEach(func() { - b = bytes.NewBuffer([]byte{}) - out = b - }) - - AfterEach(func() { - out = os.Stdout - SetLogLevel(LogLevelNothing) - }) - - It("log level nothing", func() { - SetLogLevel(LogLevelNothing) - Debugf("debug") - Infof("info") - Errorf("err") - Expect(b.Bytes()).To(Equal([]byte(""))) - }) - - It("log level err", func() { - SetLogLevel(LogLevelError) - Debugf("debug") - Infof("info") - Errorf("err") - Expect(b.Bytes()).To(Equal([]byte("err\n"))) - }) - - It("log level info", func() { - SetLogLevel(LogLevelInfo) - Debugf("debug") - Infof("info") - Errorf("err") - Expect(b.Bytes()).To(Equal([]byte("info\nerr\n"))) - }) - - It("log level debug", func() { - SetLogLevel(LogLevelDebug) - Debugf("debug") - Infof("info") - Errorf("err") - Expect(b.Bytes()).To(Equal([]byte("debug\ninfo\nerr\n"))) - }) - - It("says whether debug is enabled", func() { - Expect(Debug()).To(BeFalse()) - SetLogLevel(LogLevelDebug) - Expect(Debug()).To(BeTrue()) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/minmax.go b/vendor/github.com/lucas-clemente/quic-go/utils/minmax.go deleted file mode 100644 index ec22139..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/minmax.go +++ /dev/null @@ -1,123 +0,0 @@ -package utils - -import ( - "math" - "time" - - "github.com/lucas-clemente/quic-go/protocol" -) - -// InfDuration is a duration of infinite length -const InfDuration = time.Duration(math.MaxInt64) - -// Max returns the maximum of two Ints -func Max(a, b int) int { - if a < b { - return b - } - return a -} - -// MaxUint32 returns the maximum of two uint32 -func MaxUint32(a, b uint32) uint32 { - if a < b { - return b - } - return a -} - -// MaxUint64 returns the maximum of two uint64 -func MaxUint64(a, b uint64) uint64 { - if a < b { - return b - } - return a -} - -// Min returns the minimum of two Ints -func Min(a, b int) int { - if a < b { - return a - } - return b -} - -// MinUint32 returns the maximum of two uint32 -func MinUint32(a, b uint32) uint32 { - if a < b { - return a - } - return b -} - -// MinInt64 returns the minimum of two int64 -func MinInt64(a, b int64) int64 { - if a < b { - return a - } - return b -} - -// MaxInt64 returns the minimum of two int64 -func MaxInt64(a, b int64) int64 { - if a > b { - return a - } - return b -} - -// MinByteCount returns the minimum of two ByteCounts -func MinByteCount(a, b protocol.ByteCount) protocol.ByteCount { - if a < b { - return a - } - return b -} - -// MaxDuration returns the max duration -func MaxDuration(a, b time.Duration) time.Duration { - if a > b { - return a - } - return b -} - -// MinDuration returns the minimum duration -func MinDuration(a, b time.Duration) time.Duration { - if a > b { - return b - } - return a -} - -// AbsDuration returns the absolute value of a time duration -func AbsDuration(d time.Duration) time.Duration { - if d >= 0 { - return d - } - return -d -} - -// MinTime returns the earlier time -func MinTime(a, b time.Time) time.Time { - if a.After(b) { - return b - } - return a -} - -// MaxPacketNumber returns the max packet number -func MaxPacketNumber(a, b protocol.PacketNumber) protocol.PacketNumber { - if a > b { - return a - } - return b -} - -// MinPacketNumber returns the min packet number -func MinPacketNumber(a, b protocol.PacketNumber) protocol.PacketNumber { - if a < b { - return a - } - return b -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/minmax_test.go b/vendor/github.com/lucas-clemente/quic-go/utils/minmax_test.go deleted file mode 100644 index be84bf5..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/minmax_test.go +++ /dev/null @@ -1,87 +0,0 @@ -package utils - -import ( - "time" - - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Min / Max", func() { - Context("Max", func() { - It("returns the maximum", func() { - Expect(Max(5, 7)).To(Equal(7)) - Expect(Max(7, 5)).To(Equal(7)) - }) - - It("returns the maximum uint32", func() { - Expect(MaxUint32(5, 7)).To(Equal(uint32(7))) - Expect(MaxUint32(7, 5)).To(Equal(uint32(7))) - }) - - It("returns the maximum uint64", func() { - Expect(MaxUint64(5, 7)).To(Equal(uint64(7))) - Expect(MaxUint64(7, 5)).To(Equal(uint64(7))) - }) - - It("returns the maximum int64", func() { - Expect(MaxInt64(5, 7)).To(Equal(int64(7))) - Expect(MaxInt64(7, 5)).To(Equal(int64(7))) - }) - - It("returns the maximum duration", func() { - Expect(MaxDuration(time.Microsecond, time.Nanosecond)).To(Equal(time.Microsecond)) - Expect(MaxDuration(time.Nanosecond, time.Microsecond)).To(Equal(time.Microsecond)) - }) - - It("returns the minimum duration", func() { - Expect(MinDuration(time.Microsecond, time.Nanosecond)).To(Equal(time.Nanosecond)) - Expect(MinDuration(time.Nanosecond, time.Microsecond)).To(Equal(time.Nanosecond)) - }) - - It("returns packet number max", func() { - Expect(MaxPacketNumber(1, 2)).To(Equal(protocol.PacketNumber(2))) - Expect(MaxPacketNumber(2, 1)).To(Equal(protocol.PacketNumber(2))) - }) - }) - - Context("Min", func() { - It("returns the minimum", func() { - Expect(Min(5, 7)).To(Equal(5)) - Expect(Min(7, 5)).To(Equal(5)) - }) - - It("returns the minimum uint32", func() { - Expect(MinUint32(7, 5)).To(Equal(uint32(5))) - Expect(MinUint32(5, 7)).To(Equal(uint32(5))) - }) - - It("returns the minimum int64", func() { - Expect(MinInt64(7, 5)).To(Equal(int64(5))) - Expect(MinInt64(5, 7)).To(Equal(int64(5))) - }) - - It("returns the minimum ByteCount", func() { - Expect(MinByteCount(7, 5)).To(Equal(protocol.ByteCount(5))) - Expect(MinByteCount(5, 7)).To(Equal(protocol.ByteCount(5))) - }) - - It("returns packet number min", func() { - Expect(MinPacketNumber(1, 2)).To(Equal(protocol.PacketNumber(1))) - Expect(MinPacketNumber(2, 1)).To(Equal(protocol.PacketNumber(1))) - }) - - It("returns the minimum time", func() { - a := time.Now() - b := a.Add(time.Second) - Expect(MinTime(a, b)).To(Equal(a)) - Expect(MinTime(b, a)).To(Equal(a)) - }) - }) - - It("returns the abs time", func() { - Expect(AbsDuration(time.Microsecond)).To(Equal(time.Microsecond)) - Expect(AbsDuration(-time.Microsecond)).To(Equal(time.Microsecond)) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer.go b/vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer.go deleted file mode 100644 index 2832b53..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer.go +++ /dev/null @@ -1,95 +0,0 @@ -package utils - -import ( - "errors" - "io" -) - -// RingBuffer is a ring buffer -type RingBuffer interface { - Write(p []byte, offset uint64) error - Read(n uint64) ([]byte, uint64, error) - Clear(n uint64) error - Len() uint64 -} - -type ringBuffer struct { - data []byte - length uint64 - - readPosition uint64 - writePosition uint64 - writeCapacity uint64 // remaining number of bytes that can be written -} - -// NewRingBuffer creates a new ring buffer -func NewRingBuffer(length uint64) RingBuffer { - return &ringBuffer{ - data: make([]byte, length, length), - length: length, - writeCapacity: length, - } -} - -// Writes copies the bytes of p into the buffer, if there's enough space -// it doesn't do any partial writes. If there's not enough space, it returns an io.EOF -func (b *ringBuffer) Write(p []byte, offset uint64) error { - len := uint64(len(p)) - if len+offset > b.writeCapacity { - return io.EOF - } - - writePosition := b.writePosition + offset - - if writePosition+len < b.length { - copy(b.data[writePosition:], p) - } else { - copy(b.data[writePosition:b.length], p[:b.length-writePosition]) - copy(b.data, p[b.length-writePosition:]) - } - - b.writePosition = (writePosition + len) % b.length - b.writeCapacity -= len - return nil -} - -// Read tries to read n bytes -// when reaching the end of the internal byte slice, it returns all bytes until the end, but no eror. It should then be called again to get the rest of the data -func (b *ringBuffer) Read(n uint64) ([]byte, uint64, error) { - var data []byte - var err error - var bytesRead uint64 - - diff := b.writePosition - b.readPosition - if n <= diff { - bytesRead = n - } - - if n >= diff { - bytesRead = diff - err = io.EOF - } - - if b.readPosition+bytesRead > b.length { - bytesRead = b.length - b.readPosition - } - - data = b.data[b.readPosition : b.readPosition+bytesRead] - b.readPosition += bytesRead - return data, bytesRead, err -} - -// Clear marks n bytes as being actually processed and allows us to overwrite them -func (b *ringBuffer) Clear(n uint64) error { - if b.writeCapacity+n > b.length { - return errors.New("Can't clear that much space") - } - - b.writeCapacity += n - return nil -} - -// Len gets the length of the underlying byte-slice -func (b *ringBuffer) Len() uint64 { - return b.length -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer_test.go b/vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer_test.go deleted file mode 100644 index db30157..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/ringbuffer_test.go +++ /dev/null @@ -1,188 +0,0 @@ -package utils - -import ( - "bytes" - "io" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("RingBuffer", func() { - Context("constructor", func() { - It("creates a byte slice of the correct size", func() { - rb := NewRingBuffer(1337).(*ringBuffer) - Expect(len(rb.data)).To(Equal(1337)) - Expect(cap(rb.data)).To(Equal(1337)) - }) - - It("returns the right size", func() { - rb := NewRingBuffer(1337) - Expect(rb.Len()).To(Equal(uint64(1337))) - }) - - It("sets the correct writeCapacity", func() { - rb := NewRingBuffer(1337).(*ringBuffer) - Expect(rb.writeCapacity).To(Equal(uint64(1337))) - }) - }) - - Context("usage", func() { - var rb *ringBuffer - var capacity uint64 - - BeforeEach(func() { - capacity = 32 - rb = NewRingBuffer(capacity).(*ringBuffer) - }) - - Context("Write", func() { - It("writes small sample data", func() { - err := rb.Write([]byte{0x11, 0x22}, 0) - Expect(err).ToNot(HaveOccurred()) - err = rb.Write([]byte{0x33, 0x44}, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(rb.data[0:4]).To(Equal([]byte{0x11, 0x22, 0x33, 0x44})) - }) - - It("writes at an offset", func() { - err := rb.Write([]byte{0x11, 0x22}, 2) - Expect(err).ToNot(HaveOccurred()) - Expect(rb.data[2:4]).To(Equal([]byte{0x11, 0x22})) - }) - - It("handles multiple writes with an offset", func() { - err := rb.Write([]byte{0x11, 0x22}, 2) - Expect(err).ToNot(HaveOccurred()) - err = rb.Write([]byte{0x33, 0x44}, 1) - Expect(err).ToNot(HaveOccurred()) - Expect(rb.data[2:7]).To(Equal([]byte{0x11, 0x22, 0, 0x33, 0x44})) - }) - - It("doesn't write if it doesn't fit, when using an offset", func() { - err := rb.Write([]byte{0x11, 0x22}, capacity-1) - Expect(err).To(MatchError(io.EOF)) - }) - - It("wraps data around at the end of the slice", func() { - rb.writePosition = capacity - 2 - err := rb.Write([]byte{0xDE, 0xCA, 0xFB, 0xAD}, 0) - Expect(err).ToNot(HaveOccurred()) - Expect(rb.data[capacity-2 : capacity]).To(Equal([]byte{0xDE, 0xCA})) - Expect(rb.data[0:2]).To(Equal([]byte{0xFB, 0xAD})) - }) - - It("does not write if limited by the clearPosition", func() { - rb.writePosition = 19 - rb.writeCapacity = 1 - err := rb.Write([]byte{0x11, 0x22}, 0) - Expect(err).To(MatchError(io.EOF)) - }) - - It("writes the maximum amount of data possible", func() { - rb.writePosition = 19 - rb.writeCapacity = 2 - err := rb.Write([]byte{0x11, 0x22}, 0) - Expect(err).ToNot(HaveOccurred()) - }) - - It("returns an error when not enough write capacity is left", func() { - rb.writePosition = 19 - rb.writeCapacity = 0 - err := rb.Write([]byte{0x11}, 0) - Expect(err).To(MatchError(io.EOF)) - }) - - It("does not write more data than possible", func() { - err := rb.Write(bytes.Repeat([]byte{'a'}, int(capacity)), 0) - Expect(err).ToNot(HaveOccurred()) - err = rb.Write([]byte{0x11}, 0) - Expect(err).To(MatchError(io.EOF)) - }) - }) - - Context("Read", func() { - It("reads everything requested, when possible", func() { - rb.writePosition = 20 - data, n, err := rb.Read(10) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(uint64(10))) - Expect(data).To(HaveLen(10)) - }) - - It("does repeated reads correctly", func() { - err := rb.Write([]byte{0x11, 0x22, 0x33, 0x44}, 0) - Expect(err).ToNot(HaveOccurred()) - data, n, err := rb.Read(2) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(uint64(2))) - Expect(data).To(Equal([]byte{0x11, 0x22})) - data, n, err = rb.Read(2) - Expect(err).To(MatchError(io.EOF)) - Expect(n).To(Equal(uint64(2))) - Expect(data).To(Equal([]byte{0x33, 0x44})) - }) - - It("reads everything and returns an io.EOF", func() { - rb.writePosition = 20 - data, n, err := rb.Read(20) - Expect(err).To(MatchError(io.EOF)) - Expect(n).To(Equal(uint64(20))) - Expect(data).To(HaveLen(20)) - }) - - It("does not read anything when readPosition = writePosition", func() { - rb.writePosition = 13 - rb.readPosition = 13 - data, n, err := rb.Read(1) - Expect(err).To(MatchError(io.EOF)) - Expect(n).To(Equal(uint64(0))) - Expect(data).To(HaveLen(0)) - }) - - It("returns a shorter slice when reading from the end", func() { - rb.readPosition = capacity - 2 - data, n, err := rb.Read(4) - Expect(err).ToNot(HaveOccurred()) - Expect(n).To(Equal(uint64(2))) - Expect(data).To(HaveLen(2)) - }) - }) - - Context("Clear", func() { - It("sets the clear position", func() { - rb.writeCapacity = 5 - err := rb.Clear(10) - Expect(err).ToNot(HaveOccurred()) - Expect(rb.writeCapacity).To(Equal(uint64(15))) - }) - - It("does repeated clears", func() { - rb.writeCapacity = 5 - err := rb.Clear(6) - Expect(err).ToNot(HaveOccurred()) - Expect(rb.writeCapacity).To(Equal(uint64(11))) - err = rb.Clear(6) - Expect(err).ToNot(HaveOccurred()) - Expect(rb.writeCapacity).To(Equal(uint64(17))) - }) - - It("doesn't overflow the writeCapacity", func() { - rb.writeCapacity = capacity - 2 - err := rb.Clear(10) - Expect(err).To(HaveOccurred()) - }) - }) - - Context("full cycle", func() { - It("does a full cycle", func() { - for i := uint64(0); i < capacity; i++ { - err := rb.Write([]byte{byte(i)}, 0) - Expect(err).ToNot(HaveOccurred()) - } - err := rb.Write([]byte{'a'}, 0) - Expect(err).To(MatchError(io.EOF)) - }) - }) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/streamframe_interval.go b/vendor/github.com/lucas-clemente/quic-go/utils/streamframe_interval.go deleted file mode 100644 index c918b62..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/streamframe_interval.go +++ /dev/null @@ -1,10 +0,0 @@ -package utils - -import "github.com/lucas-clemente/quic-go/protocol" - -// ByteInterval is an interval from one ByteCount to the other -// +gen linkedlist -type ByteInterval struct { - Start protocol.ByteCount - End protocol.ByteCount -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/utils.go b/vendor/github.com/lucas-clemente/quic-go/utils/utils.go deleted file mode 100644 index dcaf9f8..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/utils.go +++ /dev/null @@ -1,178 +0,0 @@ -package utils - -import ( - "bytes" - "crypto/rand" - "io" - - "github.com/lucas-clemente/quic-go/protocol" -) - -// ReadStream is the read part of a QUIC stream -type ReadStream interface { - io.Reader - io.ByteReader -} - -// Stream is the interface for QUIC streams -type Stream interface { - io.Reader - io.ByteReader - io.Writer - io.Closer - StreamID() protocol.StreamID - CloseRemote(offset protocol.ByteCount) -} - -// ReadUintN reads N bytes -func ReadUintN(b io.ByteReader, length uint8) (uint64, error) { - var res uint64 - for i := uint8(0); i < length; i++ { - bt, err := b.ReadByte() - if err != nil { - return 0, err - } - res ^= uint64(bt) << (i * 8) - } - return res, nil -} - -// ReadUint64 reads a uint64 -func ReadUint64(b io.ByteReader) (uint64, error) { - var b1, b2, b3, b4, b5, b6, b7, b8 uint8 - var err error - if b1, err = b.ReadByte(); err != nil { - return 0, err - } - if b2, err = b.ReadByte(); err != nil { - return 0, err - } - if b3, err = b.ReadByte(); err != nil { - return 0, err - } - if b4, err = b.ReadByte(); err != nil { - return 0, err - } - if b5, err = b.ReadByte(); err != nil { - return 0, err - } - if b6, err = b.ReadByte(); err != nil { - return 0, err - } - if b7, err = b.ReadByte(); err != nil { - return 0, err - } - if b8, err = b.ReadByte(); err != nil { - return 0, err - } - return uint64(b1) + uint64(b2)<<8 + uint64(b3)<<16 + uint64(b4)<<24 + uint64(b5)<<32 + uint64(b6)<<40 + uint64(b7)<<48 + uint64(b8)<<56, nil -} - -// ReadUint32 reads a uint32 -func ReadUint32(b io.ByteReader) (uint32, error) { - var b1, b2, b3, b4 uint8 - var err error - if b1, err = b.ReadByte(); err != nil { - return 0, err - } - if b2, err = b.ReadByte(); err != nil { - return 0, err - } - if b3, err = b.ReadByte(); err != nil { - return 0, err - } - if b4, err = b.ReadByte(); err != nil { - return 0, err - } - return uint32(b1) + uint32(b2)<<8 + uint32(b3)<<16 + uint32(b4)<<24, nil -} - -// ReadUint16 reads a uint16 -func ReadUint16(b io.ByteReader) (uint16, error) { - var b1, b2 uint8 - var err error - if b1, err = b.ReadByte(); err != nil { - return 0, err - } - if b2, err = b.ReadByte(); err != nil { - return 0, err - } - return uint16(b1) + uint16(b2)<<8, nil -} - -// WriteUint64 writes a uint64 -func WriteUint64(b *bytes.Buffer, i uint64) { - b.WriteByte(uint8(i)) - b.WriteByte(uint8(i >> 8)) - b.WriteByte(uint8(i >> 16)) - b.WriteByte(uint8(i >> 24)) - b.WriteByte(uint8(i >> 32)) - b.WriteByte(uint8(i >> 40)) - b.WriteByte(uint8(i >> 48)) - b.WriteByte(uint8(i >> 56)) -} - -// WriteUint56 writes 56 bit of a uint64 -func WriteUint56(b *bytes.Buffer, i uint64) { - b.WriteByte(uint8(i)) - b.WriteByte(uint8(i >> 8)) - b.WriteByte(uint8(i >> 16)) - b.WriteByte(uint8(i >> 24)) - b.WriteByte(uint8(i >> 32)) - b.WriteByte(uint8(i >> 40)) - b.WriteByte(uint8(i >> 48)) -} - -// WriteUint48 writes 48 bit of a uint64 -func WriteUint48(b *bytes.Buffer, i uint64) { - b.WriteByte(uint8(i)) - b.WriteByte(uint8(i >> 8)) - b.WriteByte(uint8(i >> 16)) - b.WriteByte(uint8(i >> 24)) - b.WriteByte(uint8(i >> 32)) - b.WriteByte(uint8(i >> 40)) -} - -// WriteUint40 writes 40 bit of a uint64 -func WriteUint40(b *bytes.Buffer, i uint64) { - b.WriteByte(uint8(i)) - b.WriteByte(uint8(i >> 8)) - b.WriteByte(uint8(i >> 16)) - b.WriteByte(uint8(i >> 24)) - b.WriteByte(uint8(i >> 32)) -} - -// WriteUint32 writes a uint32 -func WriteUint32(b *bytes.Buffer, i uint32) { - b.WriteByte(uint8(i)) - b.WriteByte(uint8(i >> 8)) - b.WriteByte(uint8(i >> 16)) - b.WriteByte(uint8(i >> 24)) -} - -// WriteUint24 writes 24 bit of a uint32 -func WriteUint24(b *bytes.Buffer, i uint32) { - b.WriteByte(uint8(i)) - b.WriteByte(uint8(i >> 8)) - b.WriteByte(uint8(i >> 16)) -} - -// WriteUint16 writes a uint16 -func WriteUint16(b *bytes.Buffer, i uint16) { - b.WriteByte(uint8(i)) - b.WriteByte(uint8(i >> 8)) -} - -// RandomBit returns a cryptographically secure random bit (encoded as true / false) -func RandomBit() (bool, error) { - b := make([]byte, 1) - _, err := rand.Read(b) - return uint8(b[0])%2 == 0, err -} - -// Uint32Slice attaches the methods of sort.Interface to []uint32, sorting in increasing order. -type Uint32Slice []uint32 - -func (s Uint32Slice) Len() int { return len(s) } -func (s Uint32Slice) Less(i, j int) bool { return s[i] < s[j] } -func (s Uint32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] } diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/utils_suite_test.go b/vendor/github.com/lucas-clemente/quic-go/utils/utils_suite_test.go deleted file mode 100644 index 2874819..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/utils_suite_test.go +++ /dev/null @@ -1,13 +0,0 @@ -package utils - -import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "testing" -) - -func TestCrypto(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Utils Suite") -} diff --git a/vendor/github.com/lucas-clemente/quic-go/utils/utils_test.go b/vendor/github.com/lucas-clemente/quic-go/utils/utils_test.go deleted file mode 100644 index 753188a..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/utils/utils_test.go +++ /dev/null @@ -1,221 +0,0 @@ -package utils - -import ( - "bytes" - "io" - "sort" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("Utils", func() { - Context("ReadUint16", func() { - It("reads a little endian", func() { - b := []byte{0x13, 0xEF} - val, err := ReadUint16(bytes.NewReader(b)) - Expect(err).ToNot(HaveOccurred()) - Expect(val).To(Equal(uint16(0xEF13))) - }) - - It("throws an error if less than 2 bytes are passed", func() { - b := []byte{0x13, 0xEF} - for i := 0; i < len(b); i++ { - _, err := ReadUint16(bytes.NewReader(b[:i])) - Expect(err).To(MatchError(io.EOF)) - } - }) - }) - - Context("ReadUint32", func() { - It("reads a little endian", func() { - b := []byte{0x12, 0x35, 0xAB, 0xFF} - val, err := ReadUint32(bytes.NewReader(b)) - Expect(err).ToNot(HaveOccurred()) - Expect(val).To(Equal(uint32(0xFFAB3512))) - }) - - It("throws an error if less than 4 bytes are passed", func() { - b := []byte{0x12, 0x35, 0xAB, 0xFF} - for i := 0; i < len(b); i++ { - _, err := ReadUint32(bytes.NewReader(b[:i])) - Expect(err).To(MatchError(io.EOF)) - } - }) - }) - - Context("ReadUint64", func() { - It("reads a little endian", func() { - b := []byte{0x12, 0x35, 0xAB, 0xFF, 0xEF, 0xBE, 0xAD, 0xDE} - val, err := ReadUint64(bytes.NewReader(b)) - Expect(err).ToNot(HaveOccurred()) - Expect(val).To(Equal(uint64(0xDEADBEEFFFAB3512))) - }) - - It("throws an error if less than 8 bytes are passed", func() { - b := []byte{0x12, 0x35, 0xAB, 0xFF, 0xEF, 0xBE, 0xAD, 0xDE} - for i := 0; i < len(b); i++ { - _, err := ReadUint64(bytes.NewReader(b[:i])) - Expect(err).To(MatchError(io.EOF)) - } - }) - }) - - Context("WriteUint16", func() { - It("outputs 2 bytes", func() { - b := &bytes.Buffer{} - WriteUint16(b, uint16(1)) - Expect(b.Len()).To(Equal(2)) - }) - - It("outputs a little endian", func() { - num := uint16(0xFF11) - b := &bytes.Buffer{} - WriteUint16(b, num) - Expect(b.Bytes()).To(Equal([]byte{0x11, 0xFF})) - }) - }) - - Context("WriteUint24", func() { - It("outputs 3 bytes", func() { - b := &bytes.Buffer{} - WriteUint24(b, uint32(1)) - Expect(b.Len()).To(Equal(3)) - }) - - It("outputs a little endian", func() { - num := uint32(0xEFAC3512) - b := &bytes.Buffer{} - WriteUint24(b, num) - Expect(b.Bytes()).To(Equal([]byte{0x12, 0x35, 0xAC})) - }) - }) - - Context("WriteUint32", func() { - It("outputs 4 bytes", func() { - b := &bytes.Buffer{} - WriteUint32(b, uint32(1)) - Expect(b.Len()).To(Equal(4)) - }) - - It("outputs a little endian", func() { - num := uint32(0xEFAC3512) - b := &bytes.Buffer{} - WriteUint32(b, num) - Expect(b.Bytes()).To(Equal([]byte{0x12, 0x35, 0xAC, 0xEF})) - }) - }) - - Context("WriteUint40", func() { - It("outputs 5 bytes", func() { - b := &bytes.Buffer{} - WriteUint40(b, uint64(1)) - Expect(b.Len()).To(Equal(5)) - }) - - It("outputs a little endian", func() { - num := uint64(0xDEADBEEFCAFE) - b := &bytes.Buffer{} - WriteUint40(b, num) - Expect(b.Bytes()).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD})) - }) - }) - - Context("WriteUint48", func() { - It("outputs 6 bytes", func() { - b := &bytes.Buffer{} - WriteUint48(b, uint64(1)) - Expect(b.Len()).To(Equal(6)) - }) - - It("outputs a little endian", func() { - num := uint64(0xDEADBEEFCAFE) - b := &bytes.Buffer{} - WriteUint48(b, num) - Expect(b.Bytes()).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE})) - }) - - It("doesn't care about the two higher order bytes", func() { - num := uint64(0x1337DEADBEEFCAFE) - b := &bytes.Buffer{} - WriteUint48(b, num) - Expect(b.Len()).To(Equal(6)) - Expect(b.Bytes()).To(Equal([]byte{0xFE, 0xCA, 0xEF, 0xBE, 0xAD, 0xDE})) - }) - }) - - Context("WriteUint56", func() { - It("outputs 7 bytes", func() { - b := &bytes.Buffer{} - WriteUint56(b, uint64(1)) - Expect(b.Len()).To(Equal(7)) - }) - - It("outputs a little endian", func() { - num := uint64(0xFFEEDDCCBBAA9988) - b := &bytes.Buffer{} - WriteUint56(b, num) - Expect(b.Bytes()).To(Equal([]byte{0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE})) - }) - }) - - Context("WriteUint64", func() { - It("outputs 8 bytes", func() { - b := &bytes.Buffer{} - WriteUint64(b, uint64(1)) - Expect(b.Len()).To(Equal(8)) - }) - - It("outputs a little endian", func() { - num := uint64(0xFFEEDDCCBBAA9988) - b := &bytes.Buffer{} - WriteUint64(b, num) - Expect(b.Bytes()).To(Equal([]byte{0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF})) - }) - }) - - Context("Rand", func() { - It("returns either true or false", func() { - countTrue := 0 - countFalse := 0 - for i := 0; i < 100; i++ { - val, err := RandomBit() - Expect(err).NotTo(HaveOccurred()) - if val { - countTrue++ - } else { - countFalse++ - } - } - Expect(countTrue).ToNot(BeZero()) - Expect(countFalse).ToNot(BeZero()) - }) - }) - - Context("ReadUintN", func() { - It("reads n bytes", func() { - m := map[uint8]uint64{ - 0: 0x0, 1: 0x01, 2: 0x0201, 3: 0x030201, 4: 0x04030201, 5: 0x0504030201, - 6: 0x060504030201, 7: 0x07060504030201, 8: 0x0807060504030201, - } - for n, expected := range m { - b := bytes.NewReader([]byte{0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8}) - i, err := ReadUintN(b, n) - Expect(err).ToNot(HaveOccurred()) - Expect(i).To(Equal(expected)) - } - }) - - It("errors", func() { - b := bytes.NewReader([]byte{0x1, 0x2}) - _, err := ReadUintN(b, 3) - Expect(err).To(HaveOccurred()) - }) - }) - - It("sorts uint32 slices", func() { - s := Uint32Slice{1, 5, 2, 4, 3} - sort.Sort(s) - Expect(s).To(Equal(Uint32Slice{1, 2, 3, 4, 5})) - }) -}) diff --git a/vendor/github.com/lucas-clemente/quic-go/window_update_manager.go b/vendor/github.com/lucas-clemente/quic-go/window_update_manager.go deleted file mode 100644 index 70e3bde..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/window_update_manager.go +++ /dev/null @@ -1,74 +0,0 @@ -package quic - -import ( - "sync" - - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" -) - -type windowUpdateItem struct { - Offset protocol.ByteCount - Counter uint8 -} - -// windowUpdateManager manages window update frames for receiving data -type windowUpdateManager struct { - streamOffsets map[protocol.StreamID]*windowUpdateItem - mutex sync.RWMutex -} - -// newWindowUpdateManager returns a new windowUpdateManager -func newWindowUpdateManager() *windowUpdateManager { - return &windowUpdateManager{ - streamOffsets: make(map[protocol.StreamID]*windowUpdateItem), - } -} - -// SetStreamOffset sets an offset for a stream -func (m *windowUpdateManager) SetStreamOffset(streamID protocol.StreamID, n protocol.ByteCount) { - m.mutex.Lock() - defer m.mutex.Unlock() - - entry, ok := m.streamOffsets[streamID] - if !ok { - m.streamOffsets[streamID] = &windowUpdateItem{Offset: n} - return - } - - if n > entry.Offset { - entry.Offset = n - entry.Counter = 0 - } -} - -// GetWindowUpdateFrames gets all the WindowUpdate frames that need to be sent -func (m *windowUpdateManager) GetWindowUpdateFrames() []*frames.WindowUpdateFrame { - m.mutex.RLock() - defer m.mutex.RUnlock() - - var wuf []*frames.WindowUpdateFrame - - for key, value := range m.streamOffsets { - if value.Counter >= protocol.WindowUpdateNumRepetitions { - continue - } - - frame := frames.WindowUpdateFrame{ - StreamID: key, - ByteOffset: value.Offset, - } - value.Counter++ - wuf = append(wuf, &frame) - } - - return wuf -} - -// RemoveStream should be called when a stream is closed for receiving -func (m *windowUpdateManager) RemoveStream(streamID protocol.StreamID) { - m.mutex.Lock() - defer m.mutex.Unlock() - - delete(m.streamOffsets, streamID) -} diff --git a/vendor/github.com/lucas-clemente/quic-go/window_update_manager_test.go b/vendor/github.com/lucas-clemente/quic-go/window_update_manager_test.go deleted file mode 100644 index 0e6607b..0000000 --- a/vendor/github.com/lucas-clemente/quic-go/window_update_manager_test.go +++ /dev/null @@ -1,86 +0,0 @@ -package quic - -import ( - "github.com/lucas-clemente/quic-go/frames" - "github.com/lucas-clemente/quic-go/protocol" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" -) - -var _ = Describe("WindowUpdateManager", func() { - var wum *windowUpdateManager - - BeforeEach(func() { - wum = newWindowUpdateManager() - }) - - Context("queueing new window updates", func() { - It("queues a window update for a new stream", func() { - wum.SetStreamOffset(5, 0x1000) - Expect(wum.streamOffsets).To(HaveKey(protocol.StreamID(5))) - Expect(wum.streamOffsets[5].Offset).To(Equal(protocol.ByteCount(0x1000))) - }) - - It("updates the offset for an existing stream", func() { - wum.SetStreamOffset(5, 0x1000) - wum.SetStreamOffset(5, 0x2000) - Expect(wum.streamOffsets).To(HaveKey(protocol.StreamID(5))) - Expect(wum.streamOffsets[5].Offset).To(Equal(protocol.ByteCount(0x2000))) - }) - - It("does not decrease the offset for an existing stream", func() { - wum.SetStreamOffset(5, 0x1000) - wum.SetStreamOffset(5, 0x500) - Expect(wum.streamOffsets).To(HaveKey(protocol.StreamID(5))) - Expect(wum.streamOffsets[5].Offset).To(Equal(protocol.ByteCount(0x1000))) - }) - - It("resets the counter after increasing the offset", func() { - wum.streamOffsets[5] = &windowUpdateItem{ - Offset: 0x1000, - Counter: 1, - } - wum.SetStreamOffset(5, 0x2000) - Expect(wum.streamOffsets[5].Offset).To(Equal(protocol.ByteCount(0x2000))) - Expect(wum.streamOffsets[5].Counter).To(Equal(uint8(0))) - }) - }) - - Context("dequeueing window updates", func() { - BeforeEach(func() { - wum.SetStreamOffset(7, 0x1000) - wum.SetStreamOffset(9, 0x500) - }) - - It("gets the window update frames", func() { - f := wum.GetWindowUpdateFrames() - Expect(f).To(HaveLen(2)) - Expect(f).To(ContainElement(&frames.WindowUpdateFrame{StreamID: 7, ByteOffset: 0x1000})) - Expect(f).To(ContainElement(&frames.WindowUpdateFrame{StreamID: 9, ByteOffset: 0x500})) - }) - - It("increases the counter", func() { - _ = wum.GetWindowUpdateFrames() - Expect(wum.streamOffsets[7].Counter).To(Equal(uint8(1))) - Expect(wum.streamOffsets[9].Counter).To(Equal(uint8(1))) - }) - - It("only sends out a window update frame WindowUpdateNumRepetitions times", func() { - for i := uint8(0); i < protocol.WindowUpdateNumRepetitions; i++ { - frames := wum.GetWindowUpdateFrames() - Expect(frames).To(HaveLen(2)) - } - frames := wum.GetWindowUpdateFrames() - Expect(frames).To(BeEmpty()) - }) - }) - - Context("removing streams", func() { - It("deletes the map entry", func() { - wum.SetStreamOffset(7, 0x1000) - Expect(wum.streamOffsets).To(HaveKey(protocol.StreamID(7))) - wum.RemoveStream(7) - Expect(wum.streamOffsets).ToNot(HaveKey(protocol.StreamID(7))) - }) - }) -}) diff --git a/vendor/github.com/mholt/caddy/.gitattributes b/vendor/github.com/mholt/caddy/.gitattributes deleted file mode 100644 index f42d752..0000000 --- a/vendor/github.com/mholt/caddy/.gitattributes +++ /dev/null @@ -1,14 +0,0 @@ -# shell scripts should not use tabs to indent! -*.bash text eol=lf core.whitespace whitespace=tab-in-indent,trailing-space,tabwidth=2 -*.sh text eol=lf core.whitespace whitespace=tab-in-indent,trailing-space,tabwidth=2 - -# files for systemd (shell-similar) -*.path text eol=lf core.whitespace whitespace=tab-in-indent,trailing-space,tabwidth=2 -*.service text eol=lf core.whitespace whitespace=tab-in-indent,trailing-space,tabwidth=2 -*.timer text eol=lf core.whitespace whitespace=tab-in-indent,trailing-space,tabwidth=2 - -# go fmt will enforce this, but in case a user has not called "go fmt" allow GIT to catch this: -*.go text eol=lf core.whitespace whitespace=indent-with-non-tab,trailing-space,tabwidth=4 - -*.yml text eol=lf core.whitespace whitespace=tab-in-indent,trailing-space,tabwidth=2 -.git* text eol=auto core.whitespace whitespace=trailing-space diff --git a/vendor/github.com/mholt/caddy/.gitignore b/vendor/github.com/mholt/caddy/.gitignore deleted file mode 100644 index 0dd26ce..0000000 --- a/vendor/github.com/mholt/caddy/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -.DS_Store -Thumbs.db -_gitignore/ -Vagrantfile -.vagrant/ - -dist/builds/ -dist/release/ - -error.log -access.log - -/*.conf -Caddyfile - -og_static/ \ No newline at end of file diff --git a/vendor/github.com/mholt/caddy/.travis.yml b/vendor/github.com/mholt/caddy/.travis.yml deleted file mode 100644 index c121a70..0000000 --- a/vendor/github.com/mholt/caddy/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -language: go - -go: - - 1.6.2 - - tip - -env: - - CGO_ENABLED=0 - -before_install: - # Decrypts a script that installs an authenticated cookie - # for git to use when cloning from googlesource.com. - # Bypasses "bandwidth limit exceeded" errors. - # See github.com/golang/go/issues/12933 - - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then openssl aes-256-cbc -K $encrypted_3df18f9af81d_key -iv $encrypted_3df18f9af81d_iv -in dist/gitcookie.sh.enc -out dist/gitcookie.sh -d; fi - -install: - - if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then bash dist/gitcookie.sh; fi - - go get -t ./... - - go get github.com/golang/lint/golint - - go get github.com/gordonklaus/ineffassign - -script: - - diff <(echo -n) <(gofmt -s -d .) - - ineffassign . - - go vet ./... - - go test ./... - -after_script: - - golint ./... diff --git a/vendor/github.com/mholt/caddy/CONTRIBUTING.md b/vendor/github.com/mholt/caddy/CONTRIBUTING.md deleted file mode 100644 index 5dd414e..0000000 --- a/vendor/github.com/mholt/caddy/CONTRIBUTING.md +++ /dev/null @@ -1,105 +0,0 @@ -## Contributing to Caddy - -Welcome! Our community focuses on helping others and making Caddy the best it -can be. We gladly accept contributions and encourage you to get involved! - - -### Join us in the forum - -The [Caddy forum](https://forum.caddyserver.com) is the place for all discussion -that doesn't belong in issues or pull requests. Feel free to participate with us! - -If you want to file a bug report or make an improvement to Caddy, however, you -should submit an issue or pull request. - - -### Bug reports - -Please [search this repository](https://github.com/mholt/caddy/search?q=&type=Issues&utf8=%E2%9C%93) -with a variety of keywords to ensure your bug is not already reported. - -If unique, [open an issue](https://github.com/mholt/caddy/issues) and answer the -questions so we can understand and reproduce the problematic behavior. - -The burden is on you to convince us that it is actually a bug in Caddy. This is -easiest to do when you write clear, concise instructions so we can reproduce -the behavior (even if it seems obvious). The more detailed and specific you are, -the faster we will be able to help you. Check out -[How to Report Bugs Effectively](http://www.chiark.greenend.org.uk/~sgtatham/bugs.html). - -Please be kind. :smile: Remember that Caddy comes at no cost to you, and you're -getting free help. If we helped you, please consider -[donating](https://caddyserver.com/donate) - it keeps us motivated! - - -### Minor improvements and new tests - -Submit [pull requests](https://github.com/mholt/caddy/pulls) at any time for -minor changes or new tests. Make sure to write tests to assert your change is -working properly and is thoroughly covered. We'll ask most pull requests to be -[squashed](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html), -especially with small commits. - -Your pull request may be thoroughly reviewed. This is because if we accept the -PR, we also assume responsibility for it, although we would prefer you to -help maintain your code after it gets merged. - - -### Proposals, suggestions, ideas, new features - -First, please [search](https://github.com/mholt/caddy/search?q=&type=Issues&utf8=%E2%9C%93) -with a variety of keywords to ensure your suggestion/proposal is new. - -If so, you may open either an issue or a pull request for discussion and -feedback. - -The advantage of issues is that you don't have to spend time implementing your -idea, but you should still describe it thoroughly as if someone reading it would -implement the whole thing starting from scratch. - -The advantage of pull requests is that we can immediately see the impact the -change will have on the project, what the code will look like, and how to -improve it. The disadvantage of pull requests is that they are unlikely to get -accepted without significant changes first, or it may be rejected entirely. -Don't worry, that won't happen without an open discussion first. - -If you are going to spend significant time writing code for a new pull request, -best to open an issue to "claim" it and get feedback before you invest a lot of -time. - -Remember: pull requests should always be thoroughly documented both via godoc -and with at least a rough draft of documentation that might go on the website -for users to read. - - -### Collaborator status - -If your pull request is merged, congratulations! You're technically a -collaborator. We may also grant you "Collaborator status" which means you can -push to the repository and merge other pull requests. We hope that you will -stay involved by reviewing pull requests, submitting more of your own, and -resolving issues as you are able to. Thanks for making Caddy amazing! - -We ask that collaborators will conduct thorough code reviews and be nice to -new contributors. Before merging a PR, it's best to get the approval of -at least one or two other collaborators and/or the project owner. We prefer -squashed commits instead of many little, semantically-unimportant commits. Also, -CI and other post-commit hooks must pass before being merged except in certain -unusual circumstances. - -Collaborator status may be removed for inactive users from time to time as -we see fit; this is not an insult, just a basic security precaution in case -the account becomes inactive or abandoned. Privileges can always be restored -later. - - -### Vulnerabilities - -If you've found a vulnerability that is serious, please email me: Matthew dot -Holt at Gmail. If it's not a big deal, a pull request will probably be faster. - - -## Thank you - -Thanks for your help! Caddy would not be what it is today without your -contributions. diff --git a/vendor/github.com/mholt/caddy/ISSUE_TEMPLATE b/vendor/github.com/mholt/caddy/ISSUE_TEMPLATE deleted file mode 100644 index 44e2caa..0000000 --- a/vendor/github.com/mholt/caddy/ISSUE_TEMPLATE +++ /dev/null @@ -1,24 +0,0 @@ -(Are you asking for help with using Caddy? Please use our forum instead: https://forum.caddyserver.com. If you are filing a bug report, please answer the following questions. If your issue is not a bug report, you do not need to use this template. Either way, please consider donating if we've helped you. Thanks!) - -#### 1. What version of Caddy are you running (`caddy -version`)? - - -#### 2. What are you trying to do? - - -#### 3. What is your entire Caddyfile? -```text -(Put Caddyfile here) -``` - -#### 4. How did you run Caddy (give the full command and describe the execution environment)? - - -#### 5. What did you expect to see? - - -#### 6. What did you see instead (give full error messages and/or log)? - - -#### 7. How can someone who is starting from scratch reproduce this behavior as minimally as possible? - diff --git a/vendor/github.com/mholt/caddy/LICENSE.txt b/vendor/github.com/mholt/caddy/LICENSE.txt deleted file mode 100644 index 8dada3e..0000000 --- a/vendor/github.com/mholt/caddy/LICENSE.txt +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/mholt/caddy/README.md b/vendor/github.com/mholt/caddy/README.md deleted file mode 100644 index 1f04a31..0000000 --- a/vendor/github.com/mholt/caddy/README.md +++ /dev/null @@ -1,172 +0,0 @@ -[![Caddy](https://caddyserver.com/resources/images/caddy-boxed.png)](https://caddyserver.com) - -[![community](https://img.shields.io/badge/community-forum-ff69b4.svg?style=flat-square)](https://forum.caddyserver.com) -[![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg?style=flat-square)](https://godoc.org/github.com/mholt/caddy) -[![Linux Build Status](https://img.shields.io/travis/mholt/caddy.svg?style=flat-square&label=linux+build)](https://travis-ci.org/mholt/caddy) -[![Windows Build Status](https://img.shields.io/appveyor/ci/mholt/caddy.svg?style=flat-square&label=windows+build)](https://ci.appveyor.com/project/mholt/caddy) - -Caddy is a lightweight, general-purpose web server for Windows, Mac, Linux, BSD -and [Android](https://github.com/mholt/caddy/wiki/Running-Caddy-on-Android). -It is a capable alternative to other popular and easy to use web servers. -([@caddyserver](https://twitter.com/caddyserver) on Twitter) - -The most notable features are HTTP/2, [Let's Encrypt](https://letsencrypt.org) -support, Virtual Hosts, TLS + SNI, and easy configuration with a -[Caddyfile](https://caddyserver.com/docs/caddyfile). In development, you usually -put one Caddyfile with each site. In production, Caddy serves HTTPS by default -and manages all cryptographic assets for you. - -[Download](https://github.com/mholt/caddy/releases) · -[User Guide](https://caddyserver.com/docs) - - - -### Menu - -- [Getting Caddy](#getting-caddy) -- [Quick Start](#quick-start) -- [Running from Source](#running-from-source) -- [Contributing](#contributing) -- [About the Project](#about-the-project) - - - - -## Getting Caddy - -Caddy binaries have no dependencies and are available for nearly every platform. - -[Latest release](https://github.com/mholt/caddy/releases/latest) - - - -## Quick Start - -The website has [full documentation](https://caddyserver.com/docs) but this will -get you started in about 30 seconds: - -Place a file named "Caddyfile" with your site. Paste this into it and save: - -``` -localhost - -gzip -browse -ext .html -websocket /echo cat -log ../access.log -header /api Access-Control-Allow-Origin * -``` - -Run `caddy` from that directory, and it will automatically use that Caddyfile to -configure itself. - -That simple file enables compression, allows directory browsing (for folders -without an index file), serves clean URLs, hosts a WebSocket echo server at -/echo, logs requests to access.log, and adds the coveted -`Access-Control-Allow-Origin: *` header for all responses from some API. - -Wow! Caddy can do a lot with just a few lines. - - -#### Defining multiple sites - -You can run multiple sites from the same Caddyfile, too: - -``` -site1.com { - # ... -} - -site2.com, sub.site2.com { - # ... -} -``` - -Note that all these sites will automatically be served over HTTPS using Let's -Encrypt as the CA. Caddy will manage the certificates (including renewals) for -you. You don't even have to think about it. - -For more documentation, please view [the website](https://caddyserver.com/docs). -You may also be interested in the [developer guide] -(https://github.com/mholt/caddy/wiki) on this project's GitHub wiki. - - - - -## Running from Source - -Note: You will need **[Go 1.6](https://golang.org/dl/)** or newer (required for -transparent automatic HTTP/2 support and to take advantage of performance improvements -in the TLS and crypto libraries). - -1. `$ go get github.com/mholt/caddy/caddy` -2. `cd` into your website's directory -3. Run `caddy` (assumes `$GOPATH/bin` is in your `$PATH`) - -If you're tinkering, you can also use `./build.bash && ./ecaddy`. - -By default, Caddy serves the current directory at -[localhost:2015](http://localhost:2015). You can place a Caddyfile to configure -Caddy for serving your site. - -Caddy accepts some flags from the command line. Run `caddy -h` to view the help - for flags or see the [CLI documentation](https://caddyserver.com/docs/cli). - -**Running as root:** We advise against this; use setcap instead, like so: -`setcap cap_net_bind_service=+ep ./caddy` This will allow you to listen on -ports < 1024 like 80 and 443. - - - -#### Docker Container - -Caddy is available as a Docker container from any of these sources: - -- [abiosoft/caddy](https://hub.docker.com/r/abiosoft/caddy/) -- [darron/caddy](https://hub.docker.com/r/darron/caddy/) -- [joshix/caddy](https://hub.docker.com/r/joshix/caddy/) -- [jumanjiman/caddy](https://hub.docker.com/r/jumanjiman/caddy/) -- [zenithar/nano-caddy](https://hub.docker.com/r/zenithar/nano-caddy/) -- [zzrot/alpine-caddy](https://hub.docker.com/r/zzrot/alpine-caddy/) - - - -#### 3rd-party dependencies - -Although Caddy's binaries are completely static, Caddy relies on some excellent -libraries. [Godoc.org](https://godoc.org/github.com/mholt/caddy) shows the -packages that each Caddy package imports. - - - - -## Contributing - -**[Join our community](https://forum.caddyserver.com) where you can chat with other Caddy users and developers!** - -Please see our [contributing guidelines](https://github.com/mholt/caddy/blob/master/CONTRIBUTING.md). - -We use GitHub issues and pull requests *only* for bug reports and discussing specific changes to Caddy. We welcome all other topics on the [forum](https://forum.caddyserver.com)! - -Thanks for making Caddy -- and the Web -- better! - -Special thanks to -[![DigitalOcean](https://i.imgur.com/sfGr0eY.png)](https://www.digitalocean.com) -for hosting the Caddy project. - - - - -## About the project - -Caddy was born out of the need for a "batteries-included" web server that runs -anywhere and doesn't have to take its configuration with it. Caddy took -inspiration from [spark](https://github.com/rif/spark), -[nginx](https://github.com/nginx/nginx), lighttpd, -[Websocketd](https://github.com/joewalnes/websocketd) -and [Vagrant](https://www.vagrantup.com/), -which provides a pleasant mixture of features from each of them. - - -*Twitter: [@mholt6](https://twitter.com/mholt6)* diff --git a/vendor/github.com/mholt/caddy/appveyor.yml b/vendor/github.com/mholt/caddy/appveyor.yml deleted file mode 100644 index 4368810..0000000 --- a/vendor/github.com/mholt/caddy/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -version: "{build}" - -os: Windows Server 2012 R2 - -clone_folder: c:\gopath\src\github.com\mholt\caddy - -environment: - GOPATH: c:\gopath - CGO_ENABLED: 0 - -install: - - rmdir c:\go /s /q - - appveyor DownloadFile https://storage.googleapis.com/golang/go1.6.2.windows-amd64.zip - - 7z x go1.6.2.windows-amd64.zip -y -oC:\ > NUL - - go version - - go env - - go get -t ./... - - go get github.com/golang/lint/golint - - go get github.com/gordonklaus/ineffassign - - set PATH=%GOPATH%\bin;%PATH% - -build: off - -test_script: - - go vet ./... - - go test ./... - - ineffassign . - -after_test: - - golint ./... - -deploy: off diff --git a/vendor/github.com/mholt/caddy/assets.go b/vendor/github.com/mholt/caddy/assets.go deleted file mode 100644 index e353af8..0000000 --- a/vendor/github.com/mholt/caddy/assets.go +++ /dev/null @@ -1,34 +0,0 @@ -package caddy - -import ( - "os" - "path/filepath" - "runtime" -) - -// AssetsPath returns the path to the folder -// where the application may store data. If -// CADDYPATH env variable is set, that value -// is used. Otherwise, the path is the result -// of evaluating "$HOME/.caddy". -func AssetsPath() string { - if caddyPath := os.Getenv("CADDYPATH"); caddyPath != "" { - return caddyPath - } - return filepath.Join(userHomeDir(), ".caddy") -} - -// userHomeDir returns the user's home directory according to -// environment variables. -// -// Credit: http://stackoverflow.com/a/7922977/1048862 -func userHomeDir() string { - if runtime.GOOS == "windows" { - home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") - if home == "" { - home = os.Getenv("USERPROFILE") - } - return home - } - return os.Getenv("HOME") -} diff --git a/vendor/github.com/mholt/caddy/assets_test.go b/vendor/github.com/mholt/caddy/assets_test.go deleted file mode 100644 index 1933610..0000000 --- a/vendor/github.com/mholt/caddy/assets_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package caddy - -import ( - "os" - "strings" - "testing" -) - -func TestAssetsPath(t *testing.T) { - if actual := AssetsPath(); !strings.HasSuffix(actual, ".caddy") { - t.Errorf("Expected path to be a .caddy folder, got: %v", actual) - } - - os.Setenv("CADDYPATH", "testpath") - if actual, expected := AssetsPath(), "testpath"; actual != expected { - t.Errorf("Expected path to be %v, got: %v", expected, actual) - } - os.Setenv("CADDYPATH", "") -} diff --git a/vendor/github.com/mholt/caddy/caddy.go b/vendor/github.com/mholt/caddy/caddy.go deleted file mode 100644 index 85913bb..0000000 --- a/vendor/github.com/mholt/caddy/caddy.go +++ /dev/null @@ -1,743 +0,0 @@ -// Package caddy implements the Caddy server manager. -// -// To use this package: -// -// 1. Set the AppName and AppVersion variables. -// 2. Call LoadCaddyfile() to get the Caddyfile. -// Pass in the name of the server type (like "http"). -// 3. Call caddy.Start() to start Caddy. You get back -// an Instance, on which you can call Restart() to -// restart it or Stop() to stop it. -// -// You should call Wait() on your instance to wait for -// all servers to quit before your process exits. -package caddy - -import ( - "bytes" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "os" - "os/exec" - "path" - "runtime" - "strconv" - "strings" - "sync" - "time" - - "github.com/mholt/caddy/caddyfile" -) - -// Configurable application parameters -var ( - // AppName is the name of the application. - AppName string - - // AppVersion is the version of the application. - AppVersion string - - // Quiet mode will not show any informative output on initialization. - Quiet bool - - // PidFile is the path to the pidfile to create. - PidFile string - - // GracefulTimeout is the maximum duration of a graceful shutdown. - GracefulTimeout time.Duration - - // isUpgrade will be set to true if this process - // was started as part of an upgrade, where a parent - // Caddy process started this one. - isUpgrade bool -) - -// Instance contains the state of servers created as a result of -// calling Start and can be used to access or control those servers. -type Instance struct { - // serverType is the name of the instance's server type - serverType string - - // caddyfileInput is the input configuration text used for this process - caddyfileInput Input - - // wg is used to wait for all servers to shut down - wg *sync.WaitGroup - - // servers is the list of servers with their listeners... - servers []serverListener - - // these are callbacks to execute when certain events happen - onStartup []func() error - onRestart []func() error - onShutdown []func() error -} - -// Stop stops all servers contained in i. It does NOT -// execute shutdown callbacks. -func (i *Instance) Stop() error { - // stop the servers - for _, s := range i.servers { - if gs, ok := s.server.(GracefulServer); ok { - if err := gs.Stop(); err != nil { - log.Printf("[ERROR] Stopping %s: %v", gs.Address(), err) - } - } - } - - // splice instance list to delete this one - instancesMu.Lock() - for j, other := range instances { - if other == i { - instances = append(instances[:j], instances[j+1:]...) - break - } - } - instancesMu.Unlock() - - return nil -} - -// shutdownCallbacks executes all the shutdown callbacks of i. -// An error returned from one does not stop execution of the rest. -// All the errors will be returned. -func (i *Instance) shutdownCallbacks() []error { - var errs []error - for _, shutdownFunc := range i.onShutdown { - err := shutdownFunc() - if err != nil { - errs = append(errs, err) - } - } - return errs -} - -// Restart replaces the servers in i with new servers created from -// executing the newCaddyfile. Upon success, it returns the new -// instance to replace i. Upon failure, i will not be replaced. -func (i *Instance) Restart(newCaddyfile Input) (*Instance, error) { - log.Println("[INFO] Reloading") - - i.wg.Add(1) - defer i.wg.Done() - - // run restart callbacks - for _, fn := range i.onRestart { - err := fn() - if err != nil { - return i, err - } - } - - if newCaddyfile == nil { - newCaddyfile = i.caddyfileInput - } - - // Add file descriptors of all the sockets that are capable of it - restartFds := make(map[string]restartPair) - for _, s := range i.servers { - gs, srvOk := s.server.(GracefulServer) - ln, lnOk := s.listener.(Listener) - if srvOk && lnOk { - restartFds[gs.Address()] = restartPair{server: gs, listener: ln} - } - } - - // create new instance; if the restart fails, it is simply discarded - newInst := &Instance{serverType: newCaddyfile.ServerType(), wg: i.wg} - - // attempt to start new instance - err := startWithListenerFds(newCaddyfile, newInst, restartFds) - if err != nil { - return i, err - } - - // success! stop the old instance - i.Stop() - - log.Println("[INFO] Reloading complete") - - return newInst, nil -} - -// SaveServer adds s and its associated listener ln to the -// internally-kept list of servers that is running. For -// saved servers, graceful restarts will be provided. -func (i *Instance) SaveServer(s Server, ln net.Listener) { - i.servers = append(i.servers, serverListener{server: s, listener: ln}) -} - -// HasListenerWithAddress returns whether this package is -// tracking a server using a listener with the address -// addr. -func HasListenerWithAddress(addr string) bool { - instancesMu.Lock() - defer instancesMu.Unlock() - for _, inst := range instances { - for _, sln := range inst.servers { - if listenerAddrEqual(sln.listener, addr) { - return true - } - } - } - return false -} - -// listenerAddrEqual compares a listener's address with -// addr. Extra care is taken to match addresses with an -// empty hostname portion, as listeners tend to report -// [::]:80, for example, when the matching address that -// created the listener might be simply :80. -func listenerAddrEqual(ln net.Listener, addr string) bool { - lnAddr := ln.Addr().String() - hostname, port, err := net.SplitHostPort(addr) - if err != nil || hostname != "" { - return lnAddr == addr - } - if lnAddr == net.JoinHostPort("::", port) { - return true - } - if lnAddr == net.JoinHostPort("0.0.0.0", port) { - return true - } - return false -} - -/* -// TODO: We should be able to support UDP servers... I'm considering this pattern. - -type UDPListener struct { - *net.UDPConn -} - -func (u UDPListener) Accept() (net.Conn, error) { - return u.UDPConn, nil -} - -func (u UDPListener) Close() error { - return u.UDPConn.Close() -} - -func (u UDPListener) Addr() net.Addr { - return u.UDPConn.LocalAddr() -} - -var _ net.Listener = UDPListener{} -*/ - -// Server is a type that can listen and serve. A Server -// must associate with exactly zero or one listeners. -type Server interface { - // Listen starts listening by creating a new listener - // and returning it. It does not start accepting - // connections. - Listen() (net.Listener, error) - - // Serve starts serving using the provided listener. - // Serve must start the server loop nearly immediately, - // or at least not return any errors before the server - // loop begins. Serve blocks indefinitely, or in other - // words, until the server is stopped. - Serve(net.Listener) error -} - -// Stopper is a type that can stop serving. The stop -// does not necessarily have to be graceful. -type Stopper interface { - // Stop stops the server. It blocks until the - // server is completely stopped. - Stop() error -} - -// GracefulServer is a Server and Stopper, the stopping -// of which is graceful (whatever that means for the kind -// of server being implemented). It must be able to return -// the address it is configured to listen on so that its -// listener can be paired with it upon graceful restarts. -// The net.Listener that a GracefulServer creates must -// implement the Listener interface for restarts to be -// graceful (assuming the listener is for TCP). -type GracefulServer interface { - Server - Stopper - - // Address returns the address the server should - // listen on; it is used to pair the server to - // its listener during a graceful/zero-downtime - // restart. Thus when implementing this method, - // you must not access a listener to get the - // address; you must store the address the - // server is to serve on some other way. - Address() string -} - -// Listener is a net.Listener with an underlying file descriptor. -// A server's listener should implement this interface if it is -// to support zero-downtime reloads. -type Listener interface { - net.Listener - File() (*os.File, error) -} - -// AfterStartup is an interface that can be implemented -// by a server type that wants to run some code after all -// servers for the same Instance have started. -type AfterStartup interface { - OnStartupComplete() -} - -// LoadCaddyfile loads a Caddyfile by calling the plugged in -// Caddyfile loader methods. An error is returned if more than -// one loader returns a non-nil Caddyfile input. If no loaders -// load a Caddyfile, the default loader is used. If no default -// loader is registered or it returns nil, the server type's -// default Caddyfile is loaded. If the server type does not -// specify any default Caddyfile value, then an empty Caddyfile -// is returned. Consequently, this function never returns a nil -// value as long as there are no errors. -func LoadCaddyfile(serverType string) (Input, error) { - // Ask plugged-in loaders for a Caddyfile - cdyfile, err := loadCaddyfileInput(serverType) - if err != nil { - return nil, err - } - - // Otherwise revert to default - if cdyfile == nil { - cdyfile = DefaultInput(serverType) - } - - // Still nil? Geez. - if cdyfile == nil { - cdyfile = CaddyfileInput{ServerTypeName: serverType} - } - - return cdyfile, nil -} - -// Wait blocks until all of i's servers have stopped. -func (i *Instance) Wait() { - i.wg.Wait() -} - -// CaddyfileFromPipe loads the Caddyfile input from f if f is -// not interactive input. f is assumed to be a pipe or stream, -// such as os.Stdin. If f is not a pipe, no error is returned -// but the Input value will be nil. An error is only returned -// if there was an error reading the pipe, even if the length -// of what was read is 0. -func CaddyfileFromPipe(f *os.File) (Input, error) { - fi, err := f.Stat() - if err == nil && fi.Mode()&os.ModeCharDevice == 0 { - // Note that a non-nil error is not a problem. Windows - // will not create a stdin if there is no pipe, which - // produces an error when calling Stat(). But Unix will - // make one either way, which is why we also check that - // bitmask. - // NOTE: Reading from stdin after this fails (e.g. for the let's encrypt email address) (OS X) - confBody, err := ioutil.ReadAll(f) - if err != nil { - return nil, err - } - return CaddyfileInput{ - Contents: confBody, - Filepath: f.Name(), - }, nil - } - - // not having input from the pipe is not itself an error, - // just means no input to return. - return nil, nil -} - -// Caddyfile returns the Caddyfile used to create i. -func (i *Instance) Caddyfile() Input { - return i.caddyfileInput -} - -// Start starts Caddy with the given Caddyfile. -// -// This function blocks until all the servers are listening. -func Start(cdyfile Input) (*Instance, error) { - writePidFile() - inst := &Instance{serverType: cdyfile.ServerType(), wg: new(sync.WaitGroup)} - return inst, startWithListenerFds(cdyfile, inst, nil) -} - -func startWithListenerFds(cdyfile Input, inst *Instance, restartFds map[string]restartPair) error { - if cdyfile == nil { - cdyfile = CaddyfileInput{} - } - - stypeName := cdyfile.ServerType() - - stype, err := getServerType(stypeName) - if err != nil { - return err - } - - inst.caddyfileInput = cdyfile - - sblocks, err := loadServerBlocks(stypeName, path.Base(cdyfile.Path()), bytes.NewReader(cdyfile.Body())) - if err != nil { - return err - } - - ctx := stype.NewContext() - - sblocks, err = ctx.InspectServerBlocks(cdyfile.Path(), sblocks) - if err != nil { - return err - } - - err = executeDirectives(inst, cdyfile.Path(), stype.Directives, sblocks) - if err != nil { - return err - } - - slist, err := ctx.MakeServers() - if err != nil { - return err - } - - for _, startupFunc := range inst.onStartup { - err := startupFunc() - if err != nil { - return err - } - } - - err = startServers(slist, inst, restartFds) - if err != nil { - return err - } - - instancesMu.Lock() - instances = append(instances, inst) - instancesMu.Unlock() - - // run any AfterStartup callbacks if this is not - // part of a restart; then show file descriptor notice - if restartFds == nil { - for _, srvln := range inst.servers { - if srv, ok := srvln.server.(AfterStartup); ok { - srv.OnStartupComplete() - } - } - if !Quiet { - for _, srvln := range inst.servers { - if !IsLoopback(srvln.listener.Addr().String()) { - checkFdlimit() - break - } - } - } - } - - return nil -} - -func executeDirectives(inst *Instance, filename string, - directives []string, sblocks []caddyfile.ServerBlock) error { - - // map of server block ID to map of directive name to whatever. - storages := make(map[int]map[string]interface{}) - - // It is crucial that directives are executed in the proper order. - // We loop with the directives on the outer loop so we execute - // a directive for all server blocks before going to the next directive. - // This is important mainly due to the parsing callbacks (below). - for _, dir := range directives { - for i, sb := range sblocks { - var once sync.Once - if _, ok := storages[i]; !ok { - storages[i] = make(map[string]interface{}) - } - - for j, key := range sb.Keys { - // Execute directive if it is in the server block - if tokens, ok := sb.Tokens[dir]; ok { - controller := &Controller{ - instance: inst, - Key: key, - Dispenser: caddyfile.NewDispenserTokens(filename, tokens), - OncePerServerBlock: func(f func() error) error { - var err error - once.Do(func() { - err = f() - }) - return err - }, - ServerBlockIndex: i, - ServerBlockKeyIndex: j, - ServerBlockKeys: sb.Keys, - ServerBlockStorage: storages[i][dir], - } - - setup, err := DirectiveAction(inst.serverType, dir) - if err != nil { - return err - } - - err = setup(controller) - if err != nil { - return err - } - - storages[i][dir] = controller.ServerBlockStorage // persist for this server block - } - } - } - - // See if there are any callbacks to execute after this directive - if allCallbacks, ok := parsingCallbacks[inst.serverType]; ok { - callbacks := allCallbacks[dir] - for _, callback := range callbacks { - if err := callback(); err != nil { - return err - } - } - } - } - - return nil -} - -func startServers(serverList []Server, inst *Instance, restartFds map[string]restartPair) error { - errChan := make(chan error, len(serverList)) - - for _, s := range serverList { - var ln net.Listener - var err error - - // If this is a reload and s is a GracefulServer, - // reuse the listener for a graceful restart. - if gs, ok := s.(GracefulServer); ok && restartFds != nil { - addr := gs.Address() - if old, ok := restartFds[addr]; ok { - file, err := old.listener.File() - if err != nil { - return err - } - ln, err = net.FileListener(file) - if err != nil { - return err - } - file.Close() - } - } - - if ln == nil { - ln, err = s.Listen() - if err != nil { - return err - } - } - - inst.wg.Add(1) - go func(s Server, ln net.Listener, inst *Instance) { - defer inst.wg.Done() - errChan <- s.Serve(ln) - }(s, ln, inst) - - inst.servers = append(inst.servers, serverListener{server: s, listener: ln}) - } - - // Log errors that may be returned from Serve() calls, - // these errors should only be occurring in the server loop. - go func() { - for err := range errChan { - if err == nil { - continue - } - if strings.Contains(err.Error(), "use of closed network connection") { - // this error is normal when closing the listener - continue - } - log.Println(err) - } - }() - - return nil -} - -func getServerType(serverType string) (ServerType, error) { - stype, ok := serverTypes[serverType] - if ok { - return stype, nil - } - if len(serverTypes) == 0 { - return ServerType{}, fmt.Errorf("no server types plugged in") - } - if serverType == "" { - if len(serverTypes) == 1 { - for _, stype := range serverTypes { - return stype, nil - } - } - return ServerType{}, fmt.Errorf("multiple server types available; must choose one") - } - return ServerType{}, fmt.Errorf("unknown server type '%s'", serverType) -} - -func loadServerBlocks(serverType, filename string, input io.Reader) ([]caddyfile.ServerBlock, error) { - validDirectives := ValidDirectives(serverType) - serverBlocks, err := caddyfile.ServerBlocks(filename, input, validDirectives) - if err != nil { - return nil, err - } - if len(serverBlocks) == 0 && serverTypes[serverType].DefaultInput != nil { - newInput := serverTypes[serverType].DefaultInput() - serverBlocks, err = caddyfile.ServerBlocks(newInput.Path(), - bytes.NewReader(newInput.Body()), validDirectives) - if err != nil { - return nil, err - } - } - return serverBlocks, nil -} - -// Stop stops ALL servers. It blocks until they are all stopped. -// It does NOT execute shutdown callbacks, and it deletes all -// instances after stopping is completed. Do not re-use any -// references to old instances after calling Stop. -func Stop() error { - instancesMu.Lock() - for _, inst := range instances { - if err := inst.Stop(); err != nil { - log.Printf("[ERROR] Stopping %s: %v", inst.serverType, err) - } - } - instances = []*Instance{} - instancesMu.Unlock() - return nil -} - -// IsLoopback returns true if the hostname of addr looks -// explicitly like a common local hostname. addr must only -// be a host or a host:port combination. -func IsLoopback(addr string) bool { - host, _, err := net.SplitHostPort(addr) - if err != nil { - host = addr // happens if the addr is just a hostname - } - return host == "localhost" || - strings.Trim(host, "[]") == "::1" || - strings.HasPrefix(host, "127.") -} - -// checkFdlimit issues a warning if the OS limit for -// max file descriptors is below a recommended minimum. -func checkFdlimit() { - const min = 8192 - - // Warn if ulimit is too low for production sites - if runtime.GOOS == "linux" || runtime.GOOS == "darwin" { - out, err := exec.Command("sh", "-c", "ulimit -n").Output() // use sh because ulimit isn't in Linux $PATH - if err == nil { - lim, err := strconv.Atoi(string(bytes.TrimSpace(out))) - if err == nil && lim < min { - fmt.Printf("WARNING: File descriptor limit %d is too low for production servers. "+ - "At least %d is recommended. Fix with \"ulimit -n %d\".\n", lim, min, min) - } - } - } -} - -// Upgrade re-launches the process, preserving the listeners -// for a graceful restart. It does NOT load new configuration; -// it only starts the process anew with a fresh binary. -// -// TODO: This is not yet implemented -func Upgrade() error { - return fmt.Errorf("not implemented") - // TODO: have child process set isUpgrade = true -} - -// IsUpgrade returns true if this process is part of an upgrade -// where a parent caddy process spawned this one to ugprade -// the binary. -func IsUpgrade() bool { - return isUpgrade -} - -// CaddyfileInput represents a Caddyfile as input -// and is simply a convenient way to implement -// the Input interface. -type CaddyfileInput struct { - Filepath string - Contents []byte - ServerTypeName string -} - -// Body returns c.Contents. -func (c CaddyfileInput) Body() []byte { return c.Contents } - -// Path returns c.Filepath. -func (c CaddyfileInput) Path() string { return c.Filepath } - -// ServerType returns c.ServerType. -func (c CaddyfileInput) ServerType() string { return c.ServerTypeName } - -// Input represents a Caddyfile; its contents and file path -// (which should include the file name at the end of the path). -// If path does not apply (e.g. piped input) you may use -// any understandable value. The path is mainly used for logging, -// error messages, and debugging. -type Input interface { - // Gets the Caddyfile contents - Body() []byte - - // Gets the path to the origin file - Path() string - - // The type of server this input is intended for - ServerType() string -} - -// DefaultInput returns the default Caddyfile input -// to use when it is otherwise empty or missing. -// It uses the default host and port (depends on -// host, e.g. localhost is 2015, otherwise 443) and -// root. -func DefaultInput(serverType string) Input { - if _, ok := serverTypes[serverType]; !ok { - return nil - } - if serverTypes[serverType].DefaultInput == nil { - return nil - } - return serverTypes[serverType].DefaultInput() -} - -// writePidFile writes the process ID to the file at PidFile. -// It does nothing if PidFile is not set. -func writePidFile() error { - if PidFile == "" { - return nil - } - pid := []byte(strconv.Itoa(os.Getpid()) + "\n") - return ioutil.WriteFile(PidFile, pid, 0644) -} - -type restartPair struct { - server GracefulServer - listener Listener -} - -var ( - // instances is the list of running Instances. - instances []*Instance - - // instancesMu protects instances. - instancesMu sync.Mutex -) - -const ( - // DefaultConfigFile is the name of the configuration file that is loaded - // by default if no other file is specified. - DefaultConfigFile = "Caddyfile" -) diff --git a/vendor/github.com/mholt/caddy/caddy/build.bash b/vendor/github.com/mholt/caddy/caddy/build.bash deleted file mode 100755 index 03c5534..0000000 --- a/vendor/github.com/mholt/caddy/caddy/build.bash +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env bash -# -# Caddy build script. Automates proper versioning. -# -# Usage: -# -# $ ./build.bash [output_filename] [git_repo] -# -# Outputs compiled program in current directory. -# Default git repo is current directory. -# Builds always take place from current directory. - -set -euo pipefail - -: ${output_filename:="${1:-}"} -: ${output_filename:="caddy"} - -: ${git_repo:="${2:-}"} -: ${git_repo:="."} - -pkg=github.com/mholt/caddy/caddy/caddymain -ldflags=() - -# Timestamp of build -name="${pkg}.buildDate" -value=$(date -u +"%a %b %d %H:%M:%S %Z %Y") -ldflags+=("-X" "\"${name}=${value}\"") - -# Current tag, if HEAD is on a tag -name="${pkg}.gitTag" -set +e -value="$(git -C "${git_repo}" describe --exact-match HEAD 2>/dev/null)" -set -e -ldflags+=("-X" "\"${name}=${value}\"") - -# Nearest tag on branch -name="${pkg}.gitNearestTag" -value="$(git -C "${git_repo}" describe --abbrev=0 --tags HEAD)" -ldflags+=("-X" "\"${name}=${value}\"") - -# Commit SHA -name="${pkg}.gitCommit" -value="$(git -C "${git_repo}" rev-parse --short HEAD)" -ldflags+=("-X" "\"${name}=${value}\"") - -# Summary of uncommitted changes -name="${pkg}.gitShortStat" -value="$(git -C "${git_repo}" diff-index --shortstat HEAD)" -ldflags+=("-X" "\"${name}=${value}\"") - -# List of modified files -name="${pkg}.gitFilesModified" -value="$(git -C "${git_repo}" diff-index --name-only HEAD)" -ldflags+=("-X" "\"${name}=${value}\"") - -go build -ldflags "${ldflags[*]}" -o "${output_filename}" diff --git a/vendor/github.com/mholt/caddy/caddy/caddymain/run.go b/vendor/github.com/mholt/caddy/caddy/caddymain/run.go deleted file mode 100644 index 2b1e01f..0000000 --- a/vendor/github.com/mholt/caddy/caddy/caddymain/run.go +++ /dev/null @@ -1,279 +0,0 @@ -package caddymain - -import ( - "errors" - "flag" - "fmt" - "io/ioutil" - "log" - "os" - "path/filepath" - "runtime" - "strconv" - "strings" - - "gopkg.in/natefinch/lumberjack.v2" - - "github.com/xenolf/lego/acme" - - "github.com/mholt/caddy" - // plug in the HTTP server type - _ "github.com/mholt/caddy/caddyhttp" - - "github.com/mholt/caddy/caddytls" - // This is where other plugins get plugged in (imported) -) - -func init() { - caddy.TrapSignals() - setVersion() - - flag.BoolVar(&caddytls.Agreed, "agree", false, "Agree to the CA's Subscriber Agreement") - flag.StringVar(&caddytls.DefaultCAUrl, "ca", "https://acme-v01.api.letsencrypt.org/directory", "URL to certificate authority's ACME server directory") - flag.StringVar(&conf, "conf", "", "Caddyfile to load (default \""+caddy.DefaultConfigFile+"\")") - flag.StringVar(&cpu, "cpu", "100%", "CPU cap") - flag.BoolVar(&plugins, "plugins", false, "List installed plugins") - flag.StringVar(&caddytls.DefaultEmail, "email", "", "Default ACME CA account email address") - flag.StringVar(&logfile, "log", "", "Process log file") - flag.StringVar(&caddy.PidFile, "pidfile", "", "Path to write pid file") - flag.BoolVar(&caddy.Quiet, "quiet", false, "Quiet mode (no initialization output)") - flag.StringVar(&revoke, "revoke", "", "Hostname for which to revoke the certificate") - flag.StringVar(&serverType, "type", "http", "Type of server to run") - flag.BoolVar(&version, "version", false, "Show version") - - caddy.RegisterCaddyfileLoader("flag", caddy.LoaderFunc(confLoader)) - caddy.SetDefaultCaddyfileLoader("default", caddy.LoaderFunc(defaultLoader)) -} - -// Run is Caddy's main() function. -func Run() { - flag.Parse() - moveStorage() // TODO: This is temporary for the 0.9 release, or until most users upgrade to 0.9+ - - caddy.AppName = appName - caddy.AppVersion = appVersion - acme.UserAgent = appName + "/" + appVersion - - // Set up process log before anything bad happens - switch logfile { - case "stdout": - log.SetOutput(os.Stdout) - case "stderr": - log.SetOutput(os.Stderr) - case "": - log.SetOutput(ioutil.Discard) - default: - log.SetOutput(&lumberjack.Logger{ - Filename: logfile, - MaxSize: 100, - MaxAge: 14, - MaxBackups: 10, - }) - } - - // Check for one-time actions - if revoke != "" { - err := caddytls.Revoke(revoke) - if err != nil { - log.Fatal(err) - } - fmt.Printf("Revoked certificate for %s\n", revoke) - os.Exit(0) - } - if version { - fmt.Printf("%s %s\n", appName, appVersion) - if devBuild && gitShortStat != "" { - fmt.Printf("%s\n%s\n", gitShortStat, gitFilesModified) - } - os.Exit(0) - } - if plugins { - fmt.Println(caddy.DescribePlugins()) - os.Exit(0) - } - - // Set CPU cap - err := setCPU(cpu) - if err != nil { - mustLogFatal(err) - } - - // Get Caddyfile input - caddyfile, err := caddy.LoadCaddyfile(serverType) - if err != nil { - mustLogFatal(err) - } - - // Start your engines - instance, err := caddy.Start(caddyfile) - if err != nil { - mustLogFatal(err) - } - - // Twiddle your thumbs - instance.Wait() -} - -// mustLogFatal wraps log.Fatal() in a way that ensures the -// output is always printed to stderr so the user can see it -// if the user is still there, even if the process log was not -// enabled. If this process is an upgrade, however, and the user -// might not be there anymore, this just logs to the process -// log and exits. -func mustLogFatal(args ...interface{}) { - if !caddy.IsUpgrade() { - log.SetOutput(os.Stderr) - } - log.Fatal(args...) -} - -// confLoader loads the Caddyfile using the -conf flag. -func confLoader(serverType string) (caddy.Input, error) { - if conf == "" { - return nil, nil - } - - if conf == "stdin" { - return caddy.CaddyfileFromPipe(os.Stdin) - } - - contents, err := ioutil.ReadFile(conf) - if err != nil { - return nil, err - } - return caddy.CaddyfileInput{ - Contents: contents, - Filepath: conf, - ServerTypeName: serverType, - }, nil -} - -// defaultLoader loads the Caddyfile from the current working directory. -func defaultLoader(serverType string) (caddy.Input, error) { - contents, err := ioutil.ReadFile(caddy.DefaultConfigFile) - if err != nil { - if os.IsNotExist(err) { - return nil, nil - } - return nil, err - } - return caddy.CaddyfileInput{ - Contents: contents, - Filepath: caddy.DefaultConfigFile, - ServerTypeName: serverType, - }, nil -} - -// moveStorage moves the old certificate storage location by -// renaming the "letsencrypt" folder to the hostname of the -// CA URL. This is TEMPORARY until most users have upgraded to 0.9+. -func moveStorage() { - oldPath := filepath.Join(caddy.AssetsPath(), "letsencrypt") - _, err := os.Stat(oldPath) - if os.IsNotExist(err) { - return - } - newPath, err := caddytls.StorageFor(caddytls.DefaultCAUrl) - if err != nil { - log.Fatalf("[ERROR] Unable to get new path for certificate storage: %v", err) - } - err = os.MkdirAll(string(newPath), 0700) - if err != nil { - log.Fatalf("[ERROR] Unable to make new certificate storage path: %v", err) - } - err = os.Rename(oldPath, string(newPath)) - if err != nil { - log.Fatalf("[ERROR] Unable to migrate certificate storage: %v", err) - } - // convert mixed case folder and file names to lowercase - filepath.Walk(string(newPath), func(path string, info os.FileInfo, err error) error { - // must be careful to only lowercase the base of the path, not the whole thing!! - base := filepath.Base(path) - if lowerBase := strings.ToLower(base); base != lowerBase { - lowerPath := filepath.Join(filepath.Dir(path), lowerBase) - err = os.Rename(path, lowerPath) - if err != nil { - log.Fatalf("[ERROR] Unable to lower-case: %v", err) - } - } - return nil - }) -} - -// setVersion figures out the version information -// based on variables set by -ldflags. -func setVersion() { - // A development build is one that's not at a tag or has uncommitted changes - devBuild = gitTag == "" || gitShortStat != "" - - // Only set the appVersion if -ldflags was used - if gitNearestTag != "" || gitTag != "" { - if devBuild && gitNearestTag != "" { - appVersion = fmt.Sprintf("%s (+%s %s)", - strings.TrimPrefix(gitNearestTag, "v"), gitCommit, buildDate) - } else if gitTag != "" { - appVersion = strings.TrimPrefix(gitTag, "v") - } - } -} - -// setCPU parses string cpu and sets GOMAXPROCS -// according to its value. It accepts either -// a number (e.g. 3) or a percent (e.g. 50%). -func setCPU(cpu string) error { - var numCPU int - - availCPU := runtime.NumCPU() - - if strings.HasSuffix(cpu, "%") { - // Percent - var percent float32 - pctStr := cpu[:len(cpu)-1] - pctInt, err := strconv.Atoi(pctStr) - if err != nil || pctInt < 1 || pctInt > 100 { - return errors.New("invalid CPU value: percentage must be between 1-100") - } - percent = float32(pctInt) / 100 - numCPU = int(float32(availCPU) * percent) - } else { - // Number - num, err := strconv.Atoi(cpu) - if err != nil || num < 1 { - return errors.New("invalid CPU value: provide a number or percent greater than 0") - } - numCPU = num - } - - if numCPU > availCPU { - numCPU = availCPU - } - - runtime.GOMAXPROCS(numCPU) - return nil -} - -const appName = "Caddy" - -// Flags that control program flow or startup -var ( - serverType string - conf string - cpu string - logfile string - revoke string - version bool - plugins bool -) - -// Build information obtained with the help of -ldflags -var ( - appVersion = "(untracked dev build)" // inferred at startup - devBuild = true // inferred at startup - - buildDate string // date -u - gitTag string // git describe --exact-match HEAD 2> /dev/null - gitNearestTag string // git describe --abbrev=0 --tags HEAD - gitCommit string // git rev-parse HEAD - gitShortStat string // git diff-index --shortstat - gitFilesModified string // git diff-index --name-only HEAD -) diff --git a/vendor/github.com/mholt/caddy/caddy/main.go b/vendor/github.com/mholt/caddy/caddy/main.go deleted file mode 100644 index 4559be0..0000000 --- a/vendor/github.com/mholt/caddy/caddy/main.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "github.com/mholt/caddy/caddy/caddymain" - -func main() { - caddymain.Run() -} diff --git a/vendor/github.com/mholt/caddy/caddy_test.go b/vendor/github.com/mholt/caddy/caddy_test.go deleted file mode 100644 index 51e93c8..0000000 --- a/vendor/github.com/mholt/caddy/caddy_test.go +++ /dev/null @@ -1,58 +0,0 @@ -package caddy - -import "testing" - -/* -// TODO -func TestCaddyStartStop(t *testing.T) { - caddyfile := "localhost:1984" - - for i := 0; i < 2; i++ { - _, err := Start(CaddyfileInput{Contents: []byte(caddyfile)}) - if err != nil { - t.Fatalf("Error starting, iteration %d: %v", i, err) - } - - client := http.Client{ - Timeout: time.Duration(2 * time.Second), - } - resp, err := client.Get("http://localhost:1984") - if err != nil { - t.Fatalf("Expected GET request to succeed (iteration %d), but it failed: %v", i, err) - } - resp.Body.Close() - - err = Stop() - if err != nil { - t.Fatalf("Error stopping, iteration %d: %v", i, err) - } - } -} -*/ - -func TestIsLoopback(t *testing.T) { - for i, test := range []struct { - input string - expect bool - }{ - {"example.com", false}, - {"localhost", true}, - {"localhost:1234", true}, - {"localhost:", true}, - {"127.0.0.1", true}, - {"127.0.0.1:443", true}, - {"127.0.1.5", true}, - {"10.0.0.5", false}, - {"12.7.0.1", false}, - {"[::1]", true}, - {"[::1]:1234", true}, - {"::1", true}, - {"::", false}, - {"[::]", false}, - {"local", false}, - } { - if got, want := IsLoopback(test.input), test.expect; got != want { - t.Errorf("Test %d (%s): expected %v but was %v", i, test.input, want, got) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth.go b/vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth.go deleted file mode 100644 index c75cc7d..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth.go +++ /dev/null @@ -1,148 +0,0 @@ -// Package basicauth implements HTTP Basic Authentication. -package basicauth - -import ( - "bufio" - "crypto/subtle" - "fmt" - "io" - "net/http" - "os" - "path/filepath" - "strings" - "sync" - - "github.com/jimstudt/http-authentication/basic" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// BasicAuth is middleware to protect resources with a username and password. -// Note that HTTP Basic Authentication is not secure by itself and should -// not be used to protect important assets without HTTPS. Even then, the -// security of HTTP Basic Auth is disputed. Use discretion when deciding -// what to protect with BasicAuth. -type BasicAuth struct { - Next httpserver.Handler - SiteRoot string - Rules []Rule -} - -// ServeHTTP implements the httpserver.Handler interface. -func (a BasicAuth) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - - var hasAuth bool - var isAuthenticated bool - - for _, rule := range a.Rules { - for _, res := range rule.Resources { - if !httpserver.Path(r.URL.Path).Matches(res) { - continue - } - - // Path matches; parse auth header - username, password, ok := r.BasicAuth() - hasAuth = true - - // Check credentials - if !ok || - username != rule.Username || - !rule.Password(password) { - //subtle.ConstantTimeCompare([]byte(password), []byte(rule.Password)) != 1 { - continue - } - - // Flag set only on successful authentication - isAuthenticated = true - } - } - - if hasAuth { - if !isAuthenticated { - w.Header().Set("WWW-Authenticate", "Basic") - return http.StatusUnauthorized, nil - } - // "It's an older code, sir, but it checks out. I was about to clear them." - return a.Next.ServeHTTP(w, r) - } - - // Pass-thru when no paths match - return a.Next.ServeHTTP(w, r) -} - -// Rule represents a BasicAuth rule. A username and password -// combination protect the associated resources, which are -// file or directory paths. -type Rule struct { - Username string - Password func(string) bool - Resources []string -} - -// PasswordMatcher determines whether a password matches a rule. -type PasswordMatcher func(pw string) bool - -var ( - htpasswords map[string]map[string]PasswordMatcher - htpasswordsMu sync.Mutex -) - -// GetHtpasswdMatcher matches password rules. -func GetHtpasswdMatcher(filename, username, siteRoot string) (PasswordMatcher, error) { - filename = filepath.Join(siteRoot, filename) - htpasswordsMu.Lock() - if htpasswords == nil { - htpasswords = make(map[string]map[string]PasswordMatcher) - } - pm := htpasswords[filename] - if pm == nil { - fh, err := os.Open(filename) - if err != nil { - return nil, fmt.Errorf("open %q: %v", filename, err) - } - defer fh.Close() - pm = make(map[string]PasswordMatcher) - if err = parseHtpasswd(pm, fh); err != nil { - return nil, fmt.Errorf("parsing htpasswd %q: %v", fh.Name(), err) - } - htpasswords[filename] = pm - } - htpasswordsMu.Unlock() - if pm[username] == nil { - return nil, fmt.Errorf("username %q not found in %q", username, filename) - } - return pm[username], nil -} - -func parseHtpasswd(pm map[string]PasswordMatcher, r io.Reader) error { - scanner := bufio.NewScanner(r) - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - if line == "" || strings.IndexByte(line, '#') == 0 { - continue - } - i := strings.IndexByte(line, ':') - if i <= 0 { - return fmt.Errorf("malformed line, no color: %q", line) - } - user, encoded := line[:i], line[i+1:] - for _, p := range basic.DefaultSystems { - matcher, err := p(encoded) - if err != nil { - return err - } - if matcher != nil { - pm[user] = matcher.MatchesPassword - break - } - } - } - return scanner.Err() -} - -// PlainMatcher returns a PasswordMatcher that does a constant-time -// byte-wise comparison. -func PlainMatcher(passw string) PasswordMatcher { - return func(pw string) bool { - return subtle.ConstantTimeCompare([]byte(pw), []byte(passw)) == 1 - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth_test.go b/vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth_test.go deleted file mode 100644 index 182feab..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/basicauth_test.go +++ /dev/null @@ -1,146 +0,0 @@ -package basicauth - -import ( - "encoding/base64" - "fmt" - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "path/filepath" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestBasicAuth(t *testing.T) { - rw := BasicAuth{ - Next: httpserver.HandlerFunc(contentHandler), - Rules: []Rule{ - {Username: "test", Password: PlainMatcher("ttest"), Resources: []string{"/testing"}}, - }, - } - - tests := []struct { - from string - result int - cred string - }{ - {"/testing", http.StatusUnauthorized, "ttest:test"}, - {"/testing", http.StatusOK, "test:ttest"}, - {"/testing", http.StatusUnauthorized, ""}, - } - - for i, test := range tests { - - req, err := http.NewRequest("GET", test.from, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request %v", i, err) - } - auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(test.cred)) - req.Header.Set("Authorization", auth) - - rec := httptest.NewRecorder() - result, err := rw.ServeHTTP(rec, req) - if err != nil { - t.Fatalf("Test %d: Could not ServeHTTP %v", i, err) - } - if result != test.result { - t.Errorf("Test %d: Expected Header '%d' but was '%d'", - i, test.result, result) - } - if result == http.StatusUnauthorized { - headers := rec.Header() - if val, ok := headers["Www-Authenticate"]; ok { - if val[0] != "Basic" { - t.Errorf("Test %d, Www-Authenticate should be %s provided %s", i, "Basic", val[0]) - } - } else { - t.Errorf("Test %d, should provide a header Www-Authenticate", i) - } - } - - } - -} - -func TestMultipleOverlappingRules(t *testing.T) { - rw := BasicAuth{ - Next: httpserver.HandlerFunc(contentHandler), - Rules: []Rule{ - {Username: "t", Password: PlainMatcher("p1"), Resources: []string{"/t"}}, - {Username: "t1", Password: PlainMatcher("p2"), Resources: []string{"/t/t"}}, - }, - } - - tests := []struct { - from string - result int - cred string - }{ - {"/t", http.StatusOK, "t:p1"}, - {"/t/t", http.StatusOK, "t:p1"}, - {"/t/t", http.StatusOK, "t1:p2"}, - {"/a", http.StatusOK, "t1:p2"}, - {"/t/t", http.StatusUnauthorized, "t1:p3"}, - {"/t", http.StatusUnauthorized, "t1:p2"}, - } - - for i, test := range tests { - - req, err := http.NewRequest("GET", test.from, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request %v", i, err) - } - auth := "Basic " + base64.StdEncoding.EncodeToString([]byte(test.cred)) - req.Header.Set("Authorization", auth) - - rec := httptest.NewRecorder() - result, err := rw.ServeHTTP(rec, req) - if err != nil { - t.Fatalf("Test %d: Could not ServeHTTP %v", i, err) - } - if result != test.result { - t.Errorf("Test %d: Expected Header '%d' but was '%d'", - i, test.result, result) - } - - } - -} - -func contentHandler(w http.ResponseWriter, r *http.Request) (int, error) { - fmt.Fprintf(w, r.URL.String()) - return http.StatusOK, nil -} - -func TestHtpasswd(t *testing.T) { - htpasswdPasswd := "IedFOuGmTpT8" - htpasswdFile := `sha1:{SHA}dcAUljwz99qFjYR0YLTXx0RqLww= -md5:$apr1$l42y8rex$pOA2VJ0x/0TwaFeAF9nX61` - - htfh, err := ioutil.TempFile("", "basicauth-") - if err != nil { - t.Skipf("Error creating temp file (%v), will skip htpassword test") - return - } - defer os.Remove(htfh.Name()) - if _, err = htfh.Write([]byte(htpasswdFile)); err != nil { - t.Fatalf("write htpasswd file %q: %v", htfh.Name(), err) - } - htfh.Close() - - for i, username := range []string{"sha1", "md5"} { - rule := Rule{Username: username, Resources: []string{"/testing"}} - - siteRoot := filepath.Dir(htfh.Name()) - filename := filepath.Base(htfh.Name()) - if rule.Password, err = GetHtpasswdMatcher(filename, rule.Username, siteRoot); err != nil { - t.Fatalf("GetHtpasswdMatcher(%q, %q): %v", htfh.Name(), rule.Username, err) - } - t.Logf("%d. username=%q", i, rule.Username) - if !rule.Password(htpasswdPasswd) || rule.Password(htpasswdPasswd+"!") { - t.Errorf("%d (%s) password does not match.", i, rule.Username) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup.go deleted file mode 100644 index e9c691b..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup.go +++ /dev/null @@ -1,82 +0,0 @@ -package basicauth - -import ( - "strings" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("basicauth", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new BasicAuth middleware instance. -func setup(c *caddy.Controller) error { - cfg := httpserver.GetConfig(c.Key) - root := cfg.Root - - rules, err := basicAuthParse(c) - if err != nil { - return err - } - - basic := BasicAuth{Rules: rules} - - cfg.AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - basic.Next = next - basic.SiteRoot = root - return basic - }) - - return nil -} - -func basicAuthParse(c *caddy.Controller) ([]Rule, error) { - var rules []Rule - cfg := httpserver.GetConfig(c.Key) - - var err error - for c.Next() { - var rule Rule - - args := c.RemainingArgs() - - switch len(args) { - case 2: - rule.Username = args[0] - if rule.Password, err = passwordMatcher(rule.Username, args[1], cfg.Root); err != nil { - return rules, c.Errf("Get password matcher from %s: %v", c.Val(), err) - } - - for c.NextBlock() { - rule.Resources = append(rule.Resources, c.Val()) - if c.NextArg() { - return rules, c.Errf("Expecting only one resource per line (extra '%s')", c.Val()) - } - } - case 3: - rule.Resources = append(rule.Resources, args[0]) - rule.Username = args[1] - if rule.Password, err = passwordMatcher(rule.Username, args[2], cfg.Root); err != nil { - return rules, c.Errf("Get password matcher from %s: %v", c.Val(), err) - } - default: - return rules, c.ArgErr() - } - - rules = append(rules, rule) - } - - return rules, nil -} - -func passwordMatcher(username, passw, siteRoot string) (PasswordMatcher, error) { - if !strings.HasPrefix(passw, "htpasswd=") { - return PlainMatcher(passw), nil - } - return GetHtpasswdMatcher(passw[9:], username, siteRoot) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup_test.go deleted file mode 100644 index c1245a9..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/basicauth/setup_test.go +++ /dev/null @@ -1,131 +0,0 @@ -package basicauth - -import ( - "fmt" - "io/ioutil" - "os" - "strings" - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`basicauth user pwd`)) - if err != nil { - t.Errorf("Expected no errors, but got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(BasicAuth) - if !ok { - t.Fatalf("Expected handler to be type BasicAuth, got: %#v", handler) - } - - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } -} - -func TestBasicAuthParse(t *testing.T) { - htpasswdPasswd := "IedFOuGmTpT8" - htpasswdFile := `sha1:{SHA}dcAUljwz99qFjYR0YLTXx0RqLww= -md5:$apr1$l42y8rex$pOA2VJ0x/0TwaFeAF9nX61` - - var skipHtpassword bool - htfh, err := ioutil.TempFile(".", "basicauth-") - if err != nil { - t.Logf("Error creating temp file (%v), will skip htpassword test", err) - skipHtpassword = true - } else { - if _, err = htfh.Write([]byte(htpasswdFile)); err != nil { - t.Fatalf("write htpasswd file %q: %v", htfh.Name(), err) - } - htfh.Close() - defer os.Remove(htfh.Name()) - } - - tests := []struct { - input string - shouldErr bool - password string - expected []Rule - }{ - {`basicauth user pwd`, false, "pwd", []Rule{ - {Username: "user"}, - }}, - {`basicauth user pwd { - }`, false, "pwd", []Rule{ - {Username: "user"}, - }}, - {`basicauth user pwd { - /resource1 - /resource2 - }`, false, "pwd", []Rule{ - {Username: "user", Resources: []string{"/resource1", "/resource2"}}, - }}, - {`basicauth /resource user pwd`, false, "pwd", []Rule{ - {Username: "user", Resources: []string{"/resource"}}, - }}, - {`basicauth /res1 user1 pwd1 - basicauth /res2 user2 pwd2`, false, "pwd", []Rule{ - {Username: "user1", Resources: []string{"/res1"}}, - {Username: "user2", Resources: []string{"/res2"}}, - }}, - {`basicauth user`, true, "", []Rule{}}, - {`basicauth`, true, "", []Rule{}}, - {`basicauth /resource user pwd asdf`, true, "", []Rule{}}, - - {`basicauth sha1 htpasswd=` + htfh.Name(), false, htpasswdPasswd, []Rule{ - {Username: "sha1"}, - }}, - } - - for i, test := range tests { - actual, err := basicAuthParse(caddy.NewTestController(test.input)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - - if len(actual) != len(test.expected) { - t.Fatalf("Test %d expected %d rules, but got %d", - i, len(test.expected), len(actual)) - } - - for j, expectedRule := range test.expected { - actualRule := actual[j] - - if actualRule.Username != expectedRule.Username { - t.Errorf("Test %d, rule %d: Expected username '%s', got '%s'", - i, j, expectedRule.Username, actualRule.Username) - } - - if strings.Contains(test.input, "htpasswd=") && skipHtpassword { - continue - } - pwd := test.password - if len(actual) > 1 { - pwd = fmt.Sprintf("%s%d", pwd, j+1) - } - if !actualRule.Password(pwd) || actualRule.Password(test.password+"!") { - t.Errorf("Test %d, rule %d: Expected password '%v', got '%v'", - i, j, test.password, actualRule.Password("")) - } - - expectedRes := fmt.Sprintf("%v", expectedRule.Resources) - actualRes := fmt.Sprintf("%v", actualRule.Resources) - if actualRes != expectedRes { - t.Errorf("Test %d, rule %d: Expected resource list %s, but got %s", - i, j, expectedRes, actualRes) - } - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/bind/bind.go b/vendor/github.com/mholt/caddy/caddyhttp/bind/bind.go deleted file mode 100644 index 460bd5b..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/bind/bind.go +++ /dev/null @@ -1,24 +0,0 @@ -package bind - -import ( - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("bind", caddy.Plugin{ - ServerType: "http", - Action: setupBind, - }) -} - -func setupBind(c *caddy.Controller) error { - config := httpserver.GetConfig(c.Key) - for c.Next() { - if !c.Args(&config.ListenHost) { - return c.ArgErr() - } - config.TLS.ListenHost = config.ListenHost // necessary for ACME challenges, see issue #309 - } - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/bind/bind_test.go b/vendor/github.com/mholt/caddy/caddyhttp/bind/bind_test.go deleted file mode 100644 index 330d542..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/bind/bind_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package bind - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetupBind(t *testing.T) { - err := setupBind(caddy.NewTestController(`bind 1.2.3.4`)) - if err != nil { - t.Fatalf("Expected no errors, but got: %v", err) - } - - cfg := httpserver.GetConfig("") - if got, want := cfg.ListenHost, "1.2.3.4"; got != want { - t.Errorf("Expected the config's ListenHost to be %s, was %s", want, got) - } - if got, want := cfg.TLS.ListenHost, "1.2.3.4"; got != want { - t.Errorf("Expected the TLS config's ListenHost to be %s, was %s", want, got) - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/browse.go b/vendor/github.com/mholt/caddy/caddyhttp/browse/browse.go deleted file mode 100644 index 4e804f0..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/browse.go +++ /dev/null @@ -1,432 +0,0 @@ -// Package browse provides middleware for listing files in a directory -// when directory path is requested instead of a specific file. -package browse - -import ( - "bytes" - "encoding/json" - "net/http" - "net/url" - "os" - "path" - "sort" - "strconv" - "strings" - "text/template" - "time" - - "github.com/dustin/go-humanize" - "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/mholt/caddy/caddyhttp/staticfiles" -) - -// Browse is an http.Handler that can show a file listing when -// directories in the given paths are specified. -type Browse struct { - Next httpserver.Handler - Configs []Config - IgnoreIndexes bool -} - -// Config is a configuration for browsing in a particular path. -type Config struct { - PathScope string - Root http.FileSystem - Variables interface{} - Template *template.Template -} - -// A Listing is the context used to fill out a template. -type Listing struct { - // The name of the directory (the last element of the path) - Name string - - // The full path of the request - Path string - - // Whether the parent directory is browsable - CanGoUp bool - - // The items (files and folders) in the path - Items []FileInfo - - // The number of directories in the listing - NumDirs int - - // The number of files (items that aren't directories) in the listing - NumFiles int - - // Which sorting order is used - Sort string - - // And which order - Order string - - // If ≠0 then Items have been limited to that many elements - ItemsLimitedTo int - - // Optional custom variables for use in browse templates - User interface{} - - httpserver.Context -} - -// BreadcrumbMap returns l.Path where every element is a map -// of URLs and path segment names. -func (l Listing) BreadcrumbMap() map[string]string { - result := map[string]string{} - - if len(l.Path) == 0 { - return result - } - - // skip trailing slash - lpath := l.Path - if lpath[len(lpath)-1] == '/' { - lpath = lpath[:len(lpath)-1] - } - - parts := strings.Split(lpath, "/") - for i, part := range parts { - if i == 0 && part == "" { - // Leading slash (root) - result["/"] = "/" - continue - } - result[strings.Join(parts[:i+1], "/")] = part - } - - return result -} - -// FileInfo is the info about a particular file or directory -type FileInfo struct { - IsDir bool - Name string - Size int64 - URL string - ModTime time.Time - Mode os.FileMode -} - -// HumanSize returns the size of the file as a human-readable string -// in IEC format (i.e. power of 2 or base 1024). -func (fi FileInfo) HumanSize() string { - return humanize.IBytes(uint64(fi.Size)) -} - -// HumanModTime returns the modified time of the file as a human-readable string. -func (fi FileInfo) HumanModTime(format string) string { - return fi.ModTime.Format(format) -} - -// Implement sorting for Listing -type byName Listing -type bySize Listing -type byTime Listing - -// By Name -func (l byName) Len() int { return len(l.Items) } -func (l byName) Swap(i, j int) { l.Items[i], l.Items[j] = l.Items[j], l.Items[i] } - -// Treat upper and lower case equally -func (l byName) Less(i, j int) bool { - return strings.ToLower(l.Items[i].Name) < strings.ToLower(l.Items[j].Name) -} - -// By Size -func (l bySize) Len() int { return len(l.Items) } -func (l bySize) Swap(i, j int) { l.Items[i], l.Items[j] = l.Items[j], l.Items[i] } - -const directoryOffset = -1 << 31 // = math.MinInt32 -func (l bySize) Less(i, j int) bool { - iSize, jSize := l.Items[i].Size, l.Items[j].Size - if l.Items[i].IsDir { - iSize = directoryOffset + iSize - } - if l.Items[j].IsDir { - jSize = directoryOffset + jSize - } - return iSize < jSize -} - -// By Time -func (l byTime) Len() int { return len(l.Items) } -func (l byTime) Swap(i, j int) { l.Items[i], l.Items[j] = l.Items[j], l.Items[i] } -func (l byTime) Less(i, j int) bool { return l.Items[i].ModTime.Before(l.Items[j].ModTime) } - -// Add sorting method to "Listing" -// it will apply what's in ".Sort" and ".Order" -func (l Listing) applySort() { - // Check '.Order' to know how to sort - if l.Order == "desc" { - switch l.Sort { - case "name": - sort.Sort(sort.Reverse(byName(l))) - case "size": - sort.Sort(sort.Reverse(bySize(l))) - case "time": - sort.Sort(sort.Reverse(byTime(l))) - default: - // If not one of the above, do nothing - return - } - } else { // If we had more Orderings we could add them here - switch l.Sort { - case "name": - sort.Sort(byName(l)) - case "size": - sort.Sort(bySize(l)) - case "time": - sort.Sort(byTime(l)) - default: - // If not one of the above, do nothing - return - } - } -} - -func directoryListing(files []os.FileInfo, canGoUp bool, urlPath string) (Listing, bool) { - var ( - fileinfos []FileInfo - dirCount, fileCount int - hasIndexFile bool - ) - - for _, f := range files { - name := f.Name() - - for _, indexName := range staticfiles.IndexPages { - if name == indexName { - hasIndexFile = true - break - } - } - - if f.IsDir() { - name += "/" - dirCount++ - } else { - fileCount++ - } - - url := url.URL{Path: "./" + name} // prepend with "./" to fix paths with ':' in the name - - fileinfos = append(fileinfos, FileInfo{ - IsDir: f.IsDir(), - Name: f.Name(), - Size: f.Size(), - URL: url.String(), - ModTime: f.ModTime().UTC(), - Mode: f.Mode(), - }) - } - - return Listing{ - Name: path.Base(urlPath), - Path: urlPath, - CanGoUp: canGoUp, - Items: fileinfos, - NumDirs: dirCount, - NumFiles: fileCount, - }, hasIndexFile -} - -// ServeHTTP determines if the request is for this plugin, and if all prerequisites are met. -// If so, control is handed over to ServeListing. -func (b Browse) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - var bc *Config - // See if there's a browse configuration to match the path - for i := range b.Configs { - if httpserver.Path(r.URL.Path).Matches(b.Configs[i].PathScope) { - bc = &b.Configs[i] - goto inScope - } - } - return b.Next.ServeHTTP(w, r) -inScope: - - // Browse works on existing directories; delegate everything else - requestedFilepath, err := bc.Root.Open(r.URL.Path) - if err != nil { - switch { - case os.IsPermission(err): - return http.StatusForbidden, err - case os.IsExist(err): - return http.StatusNotFound, err - default: - return b.Next.ServeHTTP(w, r) - } - } - defer requestedFilepath.Close() - - info, err := requestedFilepath.Stat() - if err != nil { - switch { - case os.IsPermission(err): - return http.StatusForbidden, err - case os.IsExist(err): - return http.StatusGone, err - default: - return b.Next.ServeHTTP(w, r) - } - } - if !info.IsDir() { - return b.Next.ServeHTTP(w, r) - } - - // Do not reply to anything else because it might be nonsensical - switch r.Method { - case http.MethodGet, http.MethodHead: - // proceed, noop - case "PROPFIND", http.MethodOptions: - return http.StatusNotImplemented, nil - default: - return b.Next.ServeHTTP(w, r) - } - - // Browsing navigation gets messed up if browsing a directory - // that doesn't end in "/" (which it should, anyway) - if !strings.HasSuffix(r.URL.Path, "/") { - http.Redirect(w, r, r.URL.Path+"/", http.StatusTemporaryRedirect) - return 0, nil - } - - return b.ServeListing(w, r, requestedFilepath, bc) -} - -func (b Browse) loadDirectoryContents(requestedFilepath http.File, urlPath string) (*Listing, bool, error) { - files, err := requestedFilepath.Readdir(-1) - if err != nil { - return nil, false, err - } - - // Determine if user can browse up another folder - var canGoUp bool - curPathDir := path.Dir(strings.TrimSuffix(urlPath, "/")) - for _, other := range b.Configs { - if strings.HasPrefix(curPathDir, other.PathScope) { - canGoUp = true - break - } - } - - // Assemble listing of directory contents - listing, hasIndex := directoryListing(files, canGoUp, urlPath) - - return &listing, hasIndex, nil -} - -// handleSortOrder gets and stores for a Listing the 'sort' and 'order', -// and reads 'limit' if given. The latter is 0 if not given. -// -// This sets Cookies. -func (b Browse) handleSortOrder(w http.ResponseWriter, r *http.Request, scope string) (sort string, order string, limit int, err error) { - sort, order, limitQuery := r.URL.Query().Get("sort"), r.URL.Query().Get("order"), r.URL.Query().Get("limit") - - // If the query 'sort' or 'order' is empty, use defaults or any values previously saved in Cookies - switch sort { - case "": - sort = "name" - if sortCookie, sortErr := r.Cookie("sort"); sortErr == nil { - sort = sortCookie.Value - } - case "name", "size", "type": - http.SetCookie(w, &http.Cookie{Name: "sort", Value: sort, Path: scope, Secure: r.TLS != nil}) - } - - switch order { - case "": - order = "asc" - if orderCookie, orderErr := r.Cookie("order"); orderErr == nil { - order = orderCookie.Value - } - case "asc", "desc": - http.SetCookie(w, &http.Cookie{Name: "order", Value: order, Path: scope, Secure: r.TLS != nil}) - } - - if limitQuery != "" { - limit, err = strconv.Atoi(limitQuery) - if err != nil { // if the 'limit' query can't be interpreted as a number, return err - return - } - } - - return -} - -// ServeListing returns a formatted view of 'requestedFilepath' contents'. -func (b Browse) ServeListing(w http.ResponseWriter, r *http.Request, requestedFilepath http.File, bc *Config) (int, error) { - listing, containsIndex, err := b.loadDirectoryContents(requestedFilepath, r.URL.Path) - if err != nil { - switch { - case os.IsPermission(err): - return http.StatusForbidden, err - case os.IsExist(err): - return http.StatusGone, err - default: - return http.StatusInternalServerError, err - } - } - if containsIndex && !b.IgnoreIndexes { // directory isn't browsable - return b.Next.ServeHTTP(w, r) - } - listing.Context = httpserver.Context{ - Root: bc.Root, - Req: r, - URL: r.URL, - } - listing.User = bc.Variables - - // Copy the query values into the Listing struct - var limit int - listing.Sort, listing.Order, limit, err = b.handleSortOrder(w, r, bc.PathScope) - if err != nil { - return http.StatusBadRequest, err - } - - listing.applySort() - - if limit > 0 && limit <= len(listing.Items) { - listing.Items = listing.Items[:limit] - listing.ItemsLimitedTo = limit - } - - var buf *bytes.Buffer - acceptHeader := strings.ToLower(strings.Join(r.Header["Accept"], ",")) - switch { - case strings.Contains(acceptHeader, "application/json"): - if buf, err = b.formatAsJSON(listing, bc); err != nil { - return http.StatusInternalServerError, err - } - w.Header().Set("Content-Type", "application/json; charset=utf-8") - - default: // There's no 'application/json' in the 'Accept' header; browse normally - if buf, err = b.formatAsHTML(listing, bc); err != nil { - return http.StatusInternalServerError, err - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - - } - - buf.WriteTo(w) - - return http.StatusOK, nil -} - -func (b Browse) formatAsJSON(listing *Listing, bc *Config) (*bytes.Buffer, error) { - marsh, err := json.Marshal(listing.Items) - if err != nil { - return nil, err - } - - buf := new(bytes.Buffer) - _, err = buf.Write(marsh) - return buf, err -} - -func (b Browse) formatAsHTML(listing *Listing, bc *Config) (*bytes.Buffer, error) { - buf := new(bytes.Buffer) - err := bc.Template.Execute(buf, listing) - return buf, err -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/browse_test.go b/vendor/github.com/mholt/caddy/caddyhttp/browse/browse_test.go deleted file mode 100644 index eb200d3..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/browse_test.go +++ /dev/null @@ -1,355 +0,0 @@ -package browse - -import ( - "encoding/json" - "net/http" - "net/http/httptest" - "net/url" - "os" - "path/filepath" - "sort" - "testing" - "text/template" - "time" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSort(t *testing.T) { - // making up []fileInfo with bogus values; - // to be used to make up our "listing" - fileInfos := []FileInfo{ - { - Name: "fizz", - Size: 4, - ModTime: time.Now().AddDate(-1, 1, 0), - }, - { - Name: "buzz", - Size: 2, - ModTime: time.Now().AddDate(0, -3, 3), - }, - { - Name: "bazz", - Size: 1, - ModTime: time.Now().AddDate(0, -2, -23), - }, - { - Name: "jazz", - Size: 3, - ModTime: time.Now(), - }, - } - listing := Listing{ - Name: "foobar", - Path: "/fizz/buzz", - CanGoUp: false, - Items: fileInfos, - } - - // sort by name - listing.Sort = "name" - listing.applySort() - if !sort.IsSorted(byName(listing)) { - t.Errorf("The listing isn't name sorted: %v", listing.Items) - } - - // sort by size - listing.Sort = "size" - listing.applySort() - if !sort.IsSorted(bySize(listing)) { - t.Errorf("The listing isn't size sorted: %v", listing.Items) - } - - // sort by Time - listing.Sort = "time" - listing.applySort() - if !sort.IsSorted(byTime(listing)) { - t.Errorf("The listing isn't time sorted: %v", listing.Items) - } - - // reverse by name - listing.Sort = "name" - listing.Order = "desc" - listing.applySort() - if !isReversed(byName(listing)) { - t.Errorf("The listing isn't reversed by name: %v", listing.Items) - } - - // reverse by size - listing.Sort = "size" - listing.Order = "desc" - listing.applySort() - if !isReversed(bySize(listing)) { - t.Errorf("The listing isn't reversed by size: %v", listing.Items) - } - - // reverse by time - listing.Sort = "time" - listing.Order = "desc" - listing.applySort() - if !isReversed(byTime(listing)) { - t.Errorf("The listing isn't reversed by time: %v", listing.Items) - } -} - -func TestBrowseHTTPMethods(t *testing.T) { - tmpl, err := template.ParseFiles("testdata/photos.tpl") - if err != nil { - t.Fatalf("An error occured while parsing the template: %v", err) - } - - b := Browse{ - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - return http.StatusTeapot, nil // not t.Fatalf, or we will not see what other methods yield - }), - Configs: []Config{ - { - PathScope: "/photos", - Root: http.Dir("./testdata"), - Template: tmpl, - }, - }, - } - - rec := httptest.NewRecorder() - for method, expected := range map[string]int{ - http.MethodGet: http.StatusOK, - http.MethodHead: http.StatusOK, - http.MethodOptions: http.StatusNotImplemented, - "PROPFIND": http.StatusNotImplemented, - } { - req, err := http.NewRequest(method, "/photos/", nil) - if err != nil { - t.Fatalf("Test: Could not create HTTP request: %v", err) - } - - code, _ := b.ServeHTTP(rec, req) - if code != expected { - t.Errorf("Wrong status with HTTP Method %s: expected %d, got %d", method, expected, code) - } - } -} - -func TestBrowseTemplate(t *testing.T) { - tmpl, err := template.ParseFiles("testdata/photos.tpl") - if err != nil { - t.Fatalf("An error occured while parsing the template: %v", err) - } - - b := Browse{ - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - t.Fatalf("Next shouldn't be called") - return 0, nil - }), - Configs: []Config{ - { - PathScope: "/photos", - Root: http.Dir("./testdata"), - Template: tmpl, - }, - }, - } - - req, err := http.NewRequest("GET", "/photos/", nil) - if err != nil { - t.Fatalf("Test: Could not create HTTP request: %v", err) - } - - rec := httptest.NewRecorder() - - code, _ := b.ServeHTTP(rec, req) - if code != http.StatusOK { - t.Fatalf("Wrong status, expected %d, got %d", http.StatusOK, code) - } - - respBody := rec.Body.String() - expectedBody := ` - - -Template - - -

Header

- -

/photos/

- -
test.html
- -test2.html
- -test3.html
- - - -` - - if respBody != expectedBody { - t.Fatalf("Expected body: %v got: %v", expectedBody, respBody) - } - -} - -func TestBrowseJson(t *testing.T) { - b := Browse{ - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - t.Fatalf("Next shouldn't be called") - return 0, nil - }), - Configs: []Config{ - { - PathScope: "/photos/", - Root: http.Dir("./testdata"), - }, - }, - } - - //Getting the listing from the ./testdata/photos, the listing returned will be used to validate test results - testDataPath := filepath.Join("./testdata", "photos") - file, err := os.Open(testDataPath) - if err != nil { - if os.IsPermission(err) { - t.Fatalf("Os Permission Error") - } - } - defer file.Close() - - files, err := file.Readdir(-1) - if err != nil { - t.Fatalf("Unable to Read Contents of the directory") - } - var fileinfos []FileInfo - - for i, f := range files { - name := f.Name() - - // Tests fail in CI environment because all file mod times are the same for - // some reason, making the sorting unpredictable. To hack around this, - // we ensure here that each file has a different mod time. - chTime := f.ModTime().UTC().Add(-(time.Duration(i) * time.Second)) - if err := os.Chtimes(filepath.Join(testDataPath, name), chTime, chTime); err != nil { - t.Fatal(err) - } - - if f.IsDir() { - name += "/" - } - - url := url.URL{Path: "./" + name} - - fileinfos = append(fileinfos, FileInfo{ - IsDir: f.IsDir(), - Name: f.Name(), - Size: f.Size(), - URL: url.String(), - ModTime: chTime, - Mode: f.Mode(), - }) - } - listing := Listing{Items: fileinfos} // this listing will be used for validation inside the tests - - tests := []struct { - QueryURL string - SortBy string - OrderBy string - Limit int - shouldErr bool - expectedResult []FileInfo - }{ - //test case 1: testing for default sort and order and without the limit parameter, default sort is by name and the default order is ascending - //without the limit query entire listing will be produced - {"/", "", "", -1, false, listing.Items}, - //test case 2: limit is set to 1, orderBy and sortBy is default - {"/?limit=1", "", "", 1, false, listing.Items[:1]}, - //test case 3 : if the listing request is bigger than total size of listing then it should return everything - {"/?limit=100000000", "", "", 100000000, false, listing.Items}, - //test case 4 : testing for negative limit - {"/?limit=-1", "", "", -1, false, listing.Items}, - //test case 5 : testing with limit set to -1 and order set to descending - {"/?limit=-1&order=desc", "", "desc", -1, false, listing.Items}, - //test case 6 : testing with limit set to 2 and order set to descending - {"/?limit=2&order=desc", "", "desc", 2, false, listing.Items}, - //test case 7 : testing with limit set to 3 and order set to descending - {"/?limit=3&order=desc", "", "desc", 3, false, listing.Items}, - //test case 8 : testing with limit set to 3 and order set to ascending - {"/?limit=3&order=asc", "", "asc", 3, false, listing.Items}, - //test case 9 : testing with limit set to 1111111 and order set to ascending - {"/?limit=1111111&order=asc", "", "asc", 1111111, false, listing.Items}, - //test case 10 : testing with limit set to default and order set to ascending and sorting by size - {"/?order=asc&sort=size", "size", "asc", -1, false, listing.Items}, - //test case 11 : testing with limit set to default and order set to ascending and sorting by last modified - {"/?order=asc&sort=time", "time", "asc", -1, false, listing.Items}, - //test case 12 : testing with limit set to 1 and order set to ascending and sorting by last modified - {"/?order=asc&sort=time&limit=1", "time", "asc", 1, false, listing.Items}, - //test case 13 : testing with limit set to -100 and order set to ascending and sorting by last modified - {"/?order=asc&sort=time&limit=-100", "time", "asc", -100, false, listing.Items}, - //test case 14 : testing with limit set to -100 and order set to ascending and sorting by size - {"/?order=asc&sort=size&limit=-100", "size", "asc", -100, false, listing.Items}, - } - - for i, test := range tests { - var marsh []byte - req, err := http.NewRequest("GET", "/photos"+test.QueryURL, nil) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - - req.Header.Set("Accept", "application/json") - rec := httptest.NewRecorder() - - code, err := b.ServeHTTP(rec, req) - - if code != http.StatusOK { - t.Fatalf("In test %d: Wrong status, expected %d, got %d", i, http.StatusOK, code) - } - if rec.HeaderMap.Get("Content-Type") != "application/json; charset=utf-8" { - t.Fatalf("Expected Content type to be application/json; charset=utf-8, but got %s ", rec.HeaderMap.Get("Content-Type")) - } - - actualJSONResponse := rec.Body.String() - copyOflisting := listing - if test.SortBy == "" { - copyOflisting.Sort = "name" - } else { - copyOflisting.Sort = test.SortBy - } - if test.OrderBy == "" { - copyOflisting.Order = "asc" - } else { - copyOflisting.Order = test.OrderBy - } - - copyOflisting.applySort() - - limit := test.Limit - if limit <= len(copyOflisting.Items) && limit > 0 { - marsh, err = json.Marshal(copyOflisting.Items[:limit]) - } else { // if the 'limit' query is empty, or has the wrong value, list everything - marsh, err = json.Marshal(copyOflisting.Items) - } - - if err != nil { - t.Fatalf("Unable to Marshal the listing ") - } - expectedJSON := string(marsh) - - if actualJSONResponse != expectedJSON { - t.Errorf("JSON response doesn't match the expected for test number %d with sort=%s, order=%s\nExpected response %s\nActual response = %s\n", - i+1, test.SortBy, test.OrderBy, expectedJSON, actualJSONResponse) - } - } -} - -// "sort" package has "IsSorted" function, but no "IsReversed"; -func isReversed(data sort.Interface) bool { - n := data.Len() - for i := n - 1; i > 0; i-- { - if !data.Less(i, i-1) { - return false - } - } - return true -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/browse/setup.go deleted file mode 100644 index 690f97d..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/setup.go +++ /dev/null @@ -1,427 +0,0 @@ -package browse - -import ( - "fmt" - "io/ioutil" - "net/http" - "text/template" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("browse", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Browse middleware instance. -func setup(c *caddy.Controller) error { - configs, err := browseParse(c) - if err != nil { - return err - } - - b := Browse{ - Configs: configs, - IgnoreIndexes: false, - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - b.Next = next - return b - }) - - return nil -} - -func browseParse(c *caddy.Controller) ([]Config, error) { - var configs []Config - - cfg := httpserver.GetConfig(c.Key) - - appendCfg := func(bc Config) error { - for _, c := range configs { - if c.PathScope == bc.PathScope { - return fmt.Errorf("duplicate browsing config for %s", c.PathScope) - } - } - configs = append(configs, bc) - return nil - } - - for c.Next() { - var bc Config - - // First argument is directory to allow browsing; default is site root - if c.NextArg() { - bc.PathScope = c.Val() - } else { - bc.PathScope = "/" - } - bc.Root = http.Dir(cfg.Root) - theRoot, err := bc.Root.Open("/") // catch a missing path early - if err != nil { - return configs, err - } - defer theRoot.Close() - _, err = theRoot.Readdir(-1) - if err != nil { - return configs, err - } - - // Second argument would be the template file to use - var tplText string - if c.NextArg() { - tplBytes, err := ioutil.ReadFile(c.Val()) - if err != nil { - return configs, err - } - tplText = string(tplBytes) - } else { - tplText = defaultTemplate - } - - // Build the template - tpl, err := template.New("listing").Parse(tplText) - if err != nil { - return configs, err - } - bc.Template = tpl - - // Save configuration - err = appendCfg(bc) - if err != nil { - return configs, err - } - } - - return configs, nil -} - -// The default template to use when serving up directory listings -const defaultTemplate = ` - - - {{.Name}} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-

- {{range $url, $name := .BreadcrumbMap}}{{$name}}{{if ne $url "/"}}/{{end}}{{end}} -

-
-
-
-
- {{.NumDirs}} director{{if eq 1 .NumDirs}}y{{else}}ies{{end}} - {{.NumFiles}} file{{if ne 1 .NumFiles}}s{{end}} - {{- if ne 0 .ItemsLimitedTo}} - (of which only {{.ItemsLimitedTo}} are displayed) - {{- end}} -
-
-
- - - - - - - - - - {{- if .CanGoUp}} - - - - - - {{- end}} - {{- range .Items}} - - - {{- if .IsDir}} - - {{- else}} - - {{- end}} - - - {{- end}} - -
- {{- if and (eq .Sort "name") (ne .Order "desc")}} - Name - {{- else if and (eq .Sort "name") (ne .Order "asc")}} - Name - {{- else}} - Name - {{- end}} - - {{- if and (eq .Sort "size") (ne .Order "desc")}} - Size - {{- else if and (eq .Sort "size") (ne .Order "asc")}} - Size - {{- else}} - Size - {{- end}} - - {{- if and (eq .Sort "time") (ne .Order "desc")}} - Modified - {{- else if and (eq .Sort "time") (ne .Order "asc")}} - Modified - {{- else}} - Modified - {{- end}} -
- - Go up - -
- - {{- if .IsDir}} - - {{- else}} - - {{- end}} - {{.Name}} - - {{.HumanSize}}
-
-
- - - -` diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/browse/setup_test.go deleted file mode 100644 index fadb7fa..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/setup_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package browse - -import ( - "io/ioutil" - "os" - "path/filepath" - "strconv" - "testing" - "time" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - tempDirPath := os.TempDir() - _, err := os.Stat(tempDirPath) - if err != nil { - t.Fatalf("BeforeTest: Failed to find an existing directory for testing! Error was: %v", err) - } - nonExistantDirPath := filepath.Join(tempDirPath, strconv.Itoa(int(time.Now().UnixNano()))) - - tempTemplate, err := ioutil.TempFile(".", "tempTemplate") - if err != nil { - t.Fatalf("BeforeTest: Failed to create a temporary file in the working directory! Error was: %v", err) - } - defer os.Remove(tempTemplate.Name()) - - tempTemplatePath := filepath.Join(".", tempTemplate.Name()) - - for i, test := range []struct { - input string - expectedPathScope []string - shouldErr bool - }{ - // test case #0 tests handling of multiple pathscopes - {"browse " + tempDirPath + "\n browse .", []string{tempDirPath, "."}, false}, - - // test case #1 tests instantiation of Config with default values - {"browse /", []string{"/"}, false}, - - // test case #2 tests detectaction of custom template - {"browse . " + tempTemplatePath, []string{"."}, false}, - - // test case #3 tests detection of non-existent template - {"browse . " + nonExistantDirPath, nil, true}, - - // test case #4 tests detection of duplicate pathscopes - {"browse " + tempDirPath + "\n browse " + tempDirPath, nil, true}, - } { - - err := setup(caddy.NewTestController(test.input)) - if err != nil && !test.shouldErr { - t.Errorf("Test case #%d recieved an error of %v", i, err) - } - if test.expectedPathScope == nil { - continue - } - mids := httpserver.GetConfig("").Middleware() - mid := mids[len(mids)-1] - recievedConfigs := mid(nil).(Browse).Configs - for j, config := range recievedConfigs { - if config.PathScope != test.expectedPathScope[j] { - t.Errorf("Test case #%d expected a pathscope of %v, but got %v", i, test.expectedPathScope, config.PathScope) - } - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/header.html b/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/header.html deleted file mode 100644 index 78e5a6a..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/header.html +++ /dev/null @@ -1 +0,0 @@ -

Header

diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos.tpl b/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos.tpl deleted file mode 100644 index 5163ca0..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos.tpl +++ /dev/null @@ -1,13 +0,0 @@ - - - -Template - - -{{.Include "header.html"}} -

{{.Path}}

-{{range .Items}} -{{.Name}}
-{{end}} - - diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test.html b/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test.html deleted file mode 100644 index 40535a2..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -Test - - - - diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test2.html b/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test2.html deleted file mode 100644 index 8e10c57..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test2.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -Test 2 - - - - diff --git a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test3.html b/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test3.html deleted file mode 100644 index 6c70af2..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/browse/testdata/photos/test3.html +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/vendor/github.com/mholt/caddy/caddyhttp/caddyhttp.go b/vendor/github.com/mholt/caddy/caddyhttp/caddyhttp.go deleted file mode 100644 index 86b5721..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/caddyhttp.go +++ /dev/null @@ -1,29 +0,0 @@ -package caddyhttp - -import ( - // plug in the server - _ "github.com/mholt/caddy/caddyhttp/httpserver" - - // plug in the standard directives - _ "github.com/mholt/caddy/caddyhttp/basicauth" - _ "github.com/mholt/caddy/caddyhttp/bind" - _ "github.com/mholt/caddy/caddyhttp/browse" - _ "github.com/mholt/caddy/caddyhttp/errors" - _ "github.com/mholt/caddy/caddyhttp/expvar" - _ "github.com/mholt/caddy/caddyhttp/extensions" - _ "github.com/mholt/caddy/caddyhttp/fastcgi" - _ "github.com/mholt/caddy/caddyhttp/gzip" - _ "github.com/mholt/caddy/caddyhttp/header" - _ "github.com/mholt/caddy/caddyhttp/internalsrv" - _ "github.com/mholt/caddy/caddyhttp/log" - _ "github.com/mholt/caddy/caddyhttp/markdown" - _ "github.com/mholt/caddy/caddyhttp/mime" - _ "github.com/mholt/caddy/caddyhttp/pprof" - _ "github.com/mholt/caddy/caddyhttp/proxy" - _ "github.com/mholt/caddy/caddyhttp/redirect" - _ "github.com/mholt/caddy/caddyhttp/rewrite" - _ "github.com/mholt/caddy/caddyhttp/root" - _ "github.com/mholt/caddy/caddyhttp/templates" - _ "github.com/mholt/caddy/caddyhttp/websocket" - _ "github.com/mholt/caddy/startupshutdown" -) diff --git a/vendor/github.com/mholt/caddy/caddyhttp/errors/errors.go b/vendor/github.com/mholt/caddy/caddyhttp/errors/errors.go deleted file mode 100644 index f933adc..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/errors/errors.go +++ /dev/null @@ -1,140 +0,0 @@ -// Package errors implements an HTTP error handling middleware. -package errors - -import ( - "fmt" - "io" - "log" - "net/http" - "os" - "runtime" - "strings" - "time" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("errors", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// ErrorHandler handles HTTP errors (and errors from other middleware). -type ErrorHandler struct { - Next httpserver.Handler - ErrorPages map[int]string // map of status code to filename - LogFile string - Log *log.Logger - LogRoller *httpserver.LogRoller - Debug bool // if true, errors are written out to client rather than to a log -} - -func (h ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - defer h.recovery(w, r) - - status, err := h.Next.ServeHTTP(w, r) - - if err != nil { - errMsg := fmt.Sprintf("%s [ERROR %d %s] %v", time.Now().Format(timeFormat), status, r.URL.Path, err) - if h.Debug { - // Write error to response instead of to log - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - w.WriteHeader(status) - fmt.Fprintln(w, errMsg) - return 0, err // returning 0 signals that a response has been written - } - h.Log.Println(errMsg) - } - - if status >= 400 { - h.errorPage(w, r, status) - return 0, err - } - - return status, err -} - -// errorPage serves a static error page to w according to the status -// code. If there is an error serving the error page, a plaintext error -// message is written instead, and the extra error is logged. -func (h ErrorHandler) errorPage(w http.ResponseWriter, r *http.Request, code int) { - // See if an error page for this status code was specified - if pagePath, ok := h.ErrorPages[code]; ok { - // Try to open it - errorPage, err := os.Open(pagePath) - if err != nil { - // An additional error handling an error... - h.Log.Printf("%s [NOTICE %d %s] could not load error page: %v", - time.Now().Format(timeFormat), code, r.URL.String(), err) - httpserver.DefaultErrorFunc(w, r, code) - return - } - defer errorPage.Close() - - // Copy the page body into the response - w.Header().Set("Content-Type", "text/html; charset=utf-8") - w.WriteHeader(code) - _, err = io.Copy(w, errorPage) - - if err != nil { - // Epic fail... sigh. - h.Log.Printf("%s [NOTICE %d %s] could not respond with %s: %v", - time.Now().Format(timeFormat), code, r.URL.String(), pagePath, err) - httpserver.DefaultErrorFunc(w, r, code) - } - - return - } - - // Default error response - httpserver.DefaultErrorFunc(w, r, code) -} - -func (h ErrorHandler) recovery(w http.ResponseWriter, r *http.Request) { - rec := recover() - if rec == nil { - return - } - - // Obtain source of panic - // From: https://gist.github.com/swdunlop/9629168 - var name, file string // function name, file name - var line int - var pc [16]uintptr - n := runtime.Callers(3, pc[:]) - for _, pc := range pc[:n] { - fn := runtime.FuncForPC(pc) - if fn == nil { - continue - } - file, line = fn.FileLine(pc) - name = fn.Name() - if !strings.HasPrefix(name, "runtime.") { - break - } - } - - // Trim file path - delim := "/caddy/" - pkgPathPos := strings.Index(file, delim) - if pkgPathPos > -1 && len(file) > pkgPathPos+len(delim) { - file = file[pkgPathPos+len(delim):] - } - - panicMsg := fmt.Sprintf("%s [PANIC %s] %s:%d - %v", time.Now().Format(timeFormat), r.URL.String(), file, line, rec) - if h.Debug { - // Write error and stack trace to the response rather than to a log - var stackBuf [4096]byte - stack := stackBuf[:runtime.Stack(stackBuf[:], false)] - httpserver.WriteTextResponse(w, http.StatusInternalServerError, fmt.Sprintf("%s\n\n%s", panicMsg, stack)) - } else { - // Currently we don't use the function name, since file:line is more conventional - h.Log.Printf(panicMsg) - h.errorPage(w, r, http.StatusInternalServerError) - } -} - -const timeFormat = "02/Jan/2006:15:04:05 -0700" diff --git a/vendor/github.com/mholt/caddy/caddyhttp/errors/errors_test.go b/vendor/github.com/mholt/caddy/caddyhttp/errors/errors_test.go deleted file mode 100644 index 26456c7..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/errors/errors_test.go +++ /dev/null @@ -1,168 +0,0 @@ -package errors - -import ( - "bytes" - "errors" - "fmt" - "log" - "net/http" - "net/http/httptest" - "os" - "path/filepath" - "strconv" - "strings" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestErrors(t *testing.T) { - // create a temporary page - path := filepath.Join(os.TempDir(), "errors_test.html") - f, err := os.Create(path) - if err != nil { - t.Fatal(err) - } - defer os.Remove(path) - - const content = "This is a error page" - _, err = f.WriteString(content) - if err != nil { - t.Fatal(err) - } - f.Close() - - buf := bytes.Buffer{} - em := ErrorHandler{ - ErrorPages: map[int]string{ - http.StatusNotFound: path, - http.StatusForbidden: "not_exist_file", - }, - Log: log.New(&buf, "", 0), - } - _, notExistErr := os.Open("not_exist_file") - - testErr := errors.New("test error") - tests := []struct { - next httpserver.Handler - expectedCode int - expectedBody string - expectedLog string - expectedErr error - }{ - { - next: genErrorHandler(http.StatusOK, nil, "normal"), - expectedCode: http.StatusOK, - expectedBody: "normal", - expectedLog: "", - expectedErr: nil, - }, - { - next: genErrorHandler(http.StatusMovedPermanently, testErr, ""), - expectedCode: http.StatusMovedPermanently, - expectedBody: "", - expectedLog: fmt.Sprintf("[ERROR %d %s] %v\n", http.StatusMovedPermanently, "/", testErr), - expectedErr: testErr, - }, - { - next: genErrorHandler(http.StatusBadRequest, nil, ""), - expectedCode: 0, - expectedBody: fmt.Sprintf("%d %s\n", http.StatusBadRequest, - http.StatusText(http.StatusBadRequest)), - expectedLog: "", - expectedErr: nil, - }, - { - next: genErrorHandler(http.StatusNotFound, nil, ""), - expectedCode: 0, - expectedBody: content, - expectedLog: "", - expectedErr: nil, - }, - { - next: genErrorHandler(http.StatusForbidden, nil, ""), - expectedCode: 0, - expectedBody: fmt.Sprintf("%d %s\n", http.StatusForbidden, - http.StatusText(http.StatusForbidden)), - expectedLog: fmt.Sprintf("[NOTICE %d /] could not load error page: %v\n", - http.StatusForbidden, notExistErr), - expectedErr: nil, - }, - } - - req, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatal(err) - } - for i, test := range tests { - em.Next = test.next - buf.Reset() - rec := httptest.NewRecorder() - code, err := em.ServeHTTP(rec, req) - - if err != test.expectedErr { - t.Errorf("Test %d: Expected error %v, but got %v", - i, test.expectedErr, err) - } - if code != test.expectedCode { - t.Errorf("Test %d: Expected status code %d, but got %d", - i, test.expectedCode, code) - } - if body := rec.Body.String(); body != test.expectedBody { - t.Errorf("Test %d: Expected body %q, but got %q", - i, test.expectedBody, body) - } - if log := buf.String(); !strings.Contains(log, test.expectedLog) { - t.Errorf("Test %d: Expected log %q, but got %q", - i, test.expectedLog, log) - } - } -} - -func TestVisibleErrorWithPanic(t *testing.T) { - const panicMsg = "I'm a panic" - eh := ErrorHandler{ - ErrorPages: make(map[int]string), - Debug: true, - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - panic(panicMsg) - }), - } - - req, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatal(err) - } - rec := httptest.NewRecorder() - - code, err := eh.ServeHTTP(rec, req) - - if code != 0 { - t.Errorf("Expected error handler to return 0 (it should write to response), got status %d", code) - } - if err != nil { - t.Errorf("Expected error handler to return nil error (it should panic!), but got '%v'", err) - } - - body := rec.Body.String() - - if !strings.Contains(body, "[PANIC /] caddyhttp/errors/errors_test.go") { - t.Errorf("Expected response body to contain error log line, but it didn't:\n%s", body) - } - if !strings.Contains(body, panicMsg) { - t.Errorf("Expected response body to contain panic message, but it didn't:\n%s", body) - } - if len(body) < 500 { - t.Errorf("Expected response body to contain stack trace, but it was too short: len=%d", len(body)) - } -} - -func genErrorHandler(status int, err error, body string) httpserver.Handler { - return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - if len(body) > 0 { - w.Header().Set("Content-Length", strconv.Itoa(len(body))) - fmt.Fprint(w, body) - } - return status, err - }) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/errors/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/errors/setup.go deleted file mode 100644 index f43c95e..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/errors/setup.go +++ /dev/null @@ -1,152 +0,0 @@ -package errors - -import ( - "io" - "log" - "os" - "path/filepath" - "strconv" - - "github.com/hashicorp/go-syslog" - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// setup configures a new errors middleware instance. -func setup(c *caddy.Controller) error { - handler, err := errorsParse(c) - if err != nil { - return err - } - - // Open the log file for writing when the server starts - c.OnStartup(func() error { - var err error - var writer io.Writer - - switch handler.LogFile { - case "visible": - handler.Debug = true - case "stdout": - writer = os.Stdout - case "stderr": - writer = os.Stderr - case "syslog": - writer, err = gsyslog.NewLogger(gsyslog.LOG_ERR, "LOCAL0", "caddy") - if err != nil { - return err - } - default: - if handler.LogFile == "" { - writer = os.Stderr // default - break - } - - var file *os.File - file, err = os.OpenFile(handler.LogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) - if err != nil { - return err - } - if handler.LogRoller != nil { - file.Close() - - handler.LogRoller.Filename = handler.LogFile - - writer = handler.LogRoller.GetLogWriter() - } else { - writer = file - } - } - - handler.Log = log.New(writer, "", 0) - return nil - }) - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - handler.Next = next - return handler - }) - - return nil -} - -func errorsParse(c *caddy.Controller) (*ErrorHandler, error) { - // Very important that we make a pointer because the startup - // function that opens the log file must have access to the - // same instance of the handler, not a copy. - handler := &ErrorHandler{ErrorPages: make(map[int]string)} - - cfg := httpserver.GetConfig(c.Key) - - optionalBlock := func() (bool, error) { - var hadBlock bool - - for c.NextBlock() { - hadBlock = true - - what := c.Val() - if !c.NextArg() { - return hadBlock, c.ArgErr() - } - where := c.Val() - - if what == "log" { - if where == "visible" { - handler.Debug = true - } else { - handler.LogFile = where - if c.NextArg() { - if c.Val() == "{" { - c.IncrNest() - logRoller, err := httpserver.ParseRoller(c) - if err != nil { - return hadBlock, err - } - handler.LogRoller = logRoller - } - } - } - } else { - // Error page; ensure it exists - where = filepath.Join(cfg.Root, where) - f, err := os.Open(where) - if err != nil { - log.Printf("[WARNING] Unable to open error page '%s': %v", where, err) - } - f.Close() - - whatInt, err := strconv.Atoi(what) - if err != nil { - return hadBlock, c.Err("Expecting a numeric status code, got '" + what + "'") - } - handler.ErrorPages[whatInt] = where - } - } - return hadBlock, nil - } - - for c.Next() { - // weird hack to avoid having the handler values overwritten. - if c.Val() == "}" { - continue - } - // Configuration may be in a block - hadBlock, err := optionalBlock() - if err != nil { - return handler, err - } - - // Otherwise, the only argument would be an error log file name or 'visible' - if !hadBlock { - if c.NextArg() { - if c.Val() == "visible" { - handler.Debug = true - } else { - handler.LogFile = c.Val() - } - } - } - } - - return handler, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/errors/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/errors/setup_test.go deleted file mode 100644 index aed907e..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/errors/setup_test.go +++ /dev/null @@ -1,154 +0,0 @@ -package errors - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`errors`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middlewares, was nil instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(*ErrorHandler) - if !ok { - t.Fatalf("Expected handler to be type ErrorHandler, got: %#v", handler) - } - - if myHandler.LogFile != "" { - t.Errorf("Expected '%s' as the default LogFile", "") - } - if myHandler.LogRoller != nil { - t.Errorf("Expected LogRoller to be nil, got: %v", *myHandler.LogRoller) - } - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } - - // Test Startup function -- TODO - // if len(c.Startup) == 0 { - // t.Fatal("Expected 1 startup function, had 0") - // } - // c.Startup[0]() - // if myHandler.Log == nil { - // t.Error("Expected Log to be non-nil after startup because Debug is not enabled") - // } -} - -func TestErrorsParse(t *testing.T) { - tests := []struct { - inputErrorsRules string - shouldErr bool - expectedErrorHandler ErrorHandler - }{ - {`errors`, false, ErrorHandler{ - LogFile: "", - }}, - {`errors errors.txt`, false, ErrorHandler{ - LogFile: "errors.txt", - }}, - {`errors visible`, false, ErrorHandler{ - LogFile: "", - Debug: true, - }}, - {`errors { log visible }`, false, ErrorHandler{ - LogFile: "", - Debug: true, - }}, - {`errors { log errors.txt - 404 404.html - 500 500.html -}`, false, ErrorHandler{ - LogFile: "errors.txt", - ErrorPages: map[int]string{ - 404: "404.html", - 500: "500.html", - }, - }}, - {`errors { log errors.txt { size 2 age 10 keep 3 } }`, false, ErrorHandler{ - LogFile: "errors.txt", - LogRoller: &httpserver.LogRoller{ - MaxSize: 2, - MaxAge: 10, - MaxBackups: 3, - LocalTime: true, - }, - }}, - {`errors { log errors.txt { - size 3 - age 11 - keep 5 - } - 404 404.html - 503 503.html -}`, false, ErrorHandler{ - LogFile: "errors.txt", - ErrorPages: map[int]string{ - 404: "404.html", - 503: "503.html", - }, - LogRoller: &httpserver.LogRoller{ - MaxSize: 3, - MaxAge: 11, - MaxBackups: 5, - LocalTime: true, - }, - }}, - } - for i, test := range tests { - actualErrorsRule, err := errorsParse(caddy.NewTestController(test.inputErrorsRules)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - if actualErrorsRule.LogFile != test.expectedErrorHandler.LogFile { - t.Errorf("Test %d expected LogFile to be %s, but got %s", - i, test.expectedErrorHandler.LogFile, actualErrorsRule.LogFile) - } - if actualErrorsRule.Debug != test.expectedErrorHandler.Debug { - t.Errorf("Test %d expected Debug to be %v, but got %v", - i, test.expectedErrorHandler.Debug, actualErrorsRule.Debug) - } - if actualErrorsRule.LogRoller != nil && test.expectedErrorHandler.LogRoller == nil || actualErrorsRule.LogRoller == nil && test.expectedErrorHandler.LogRoller != nil { - t.Fatalf("Test %d expected LogRoller to be %v, but got %v", - i, test.expectedErrorHandler.LogRoller, actualErrorsRule.LogRoller) - } - if len(actualErrorsRule.ErrorPages) != len(test.expectedErrorHandler.ErrorPages) { - t.Fatalf("Test %d expected %d no of Error pages, but got %d ", - i, len(test.expectedErrorHandler.ErrorPages), len(actualErrorsRule.ErrorPages)) - } - if actualErrorsRule.LogRoller != nil && test.expectedErrorHandler.LogRoller != nil { - if actualErrorsRule.LogRoller.Filename != test.expectedErrorHandler.LogRoller.Filename { - t.Fatalf("Test %d expected LogRoller Filename to be %s, but got %s", - i, test.expectedErrorHandler.LogRoller.Filename, actualErrorsRule.LogRoller.Filename) - } - if actualErrorsRule.LogRoller.MaxAge != test.expectedErrorHandler.LogRoller.MaxAge { - t.Fatalf("Test %d expected LogRoller MaxAge to be %d, but got %d", - i, test.expectedErrorHandler.LogRoller.MaxAge, actualErrorsRule.LogRoller.MaxAge) - } - if actualErrorsRule.LogRoller.MaxBackups != test.expectedErrorHandler.LogRoller.MaxBackups { - t.Fatalf("Test %d expected LogRoller MaxBackups to be %d, but got %d", - i, test.expectedErrorHandler.LogRoller.MaxBackups, actualErrorsRule.LogRoller.MaxBackups) - } - if actualErrorsRule.LogRoller.MaxSize != test.expectedErrorHandler.LogRoller.MaxSize { - t.Fatalf("Test %d expected LogRoller MaxSize to be %d, but got %d", - i, test.expectedErrorHandler.LogRoller.MaxSize, actualErrorsRule.LogRoller.MaxSize) - } - if actualErrorsRule.LogRoller.LocalTime != test.expectedErrorHandler.LogRoller.LocalTime { - t.Fatalf("Test %d expected LogRoller LocalTime to be %t, but got %t", - i, test.expectedErrorHandler.LogRoller.LocalTime, actualErrorsRule.LogRoller.LocalTime) - } - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar.go b/vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar.go deleted file mode 100644 index d3107a0..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar.go +++ /dev/null @@ -1,45 +0,0 @@ -package expvar - -import ( - "expvar" - "fmt" - "net/http" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// ExpVar is a simple struct to hold expvar's configuration -type ExpVar struct { - Next httpserver.Handler - Resource Resource -} - -// ServeHTTP handles requests to expvar's configured entry point with -// expvar, or passes all other requests up the chain. -func (e ExpVar) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - if httpserver.Path(r.URL.Path).Matches(string(e.Resource)) { - expvarHandler(w, r) - return 0, nil - } - return e.Next.ServeHTTP(w, r) -} - -// expvarHandler returns a JSON object will all the published variables. -// -// This is lifted straight from the expvar package. -func expvarHandler(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Type", "application/json; charset=utf-8") - fmt.Fprintf(w, "{\n") - first := true - expvar.Do(func(kv expvar.KeyValue) { - if !first { - fmt.Fprintf(w, ",\n") - } - first = false - fmt.Fprintf(w, "%q: %s", kv.Key, kv.Value) - }) - fmt.Fprintf(w, "\n}\n") -} - -// Resource contains the path to the expvar entry point -type Resource string diff --git a/vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar_test.go b/vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar_test.go deleted file mode 100644 index dfc7cb3..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/expvar/expvar_test.go +++ /dev/null @@ -1,46 +0,0 @@ -package expvar - -import ( - "fmt" - "net/http" - "net/http/httptest" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestExpVar(t *testing.T) { - rw := ExpVar{ - Next: httpserver.HandlerFunc(contentHandler), - Resource: "/d/v", - } - - tests := []struct { - from string - result int - }{ - {"/d/v", 0}, - {"/x/y", http.StatusOK}, - } - - for i, test := range tests { - req, err := http.NewRequest("GET", test.from, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request %v", i, err) - } - rec := httptest.NewRecorder() - result, err := rw.ServeHTTP(rec, req) - if err != nil { - t.Fatalf("Test %d: Could not ServeHTTP %v", i, err) - } - if result != test.result { - t.Errorf("Test %d: Expected Header '%d' but was '%d'", - i, test.result, result) - } - } -} - -func contentHandler(w http.ResponseWriter, r *http.Request) (int, error) { - fmt.Fprintf(w, r.URL.String()) - return http.StatusOK, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/expvar/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/expvar/setup.go deleted file mode 100644 index 4bbe69f..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/expvar/setup.go +++ /dev/null @@ -1,69 +0,0 @@ -package expvar - -import ( - "expvar" - "runtime" - "sync" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("expvar", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new ExpVar middleware instance. -func setup(c *caddy.Controller) error { - resource, err := expVarParse(c) - if err != nil { - return err - } - - // publish any extra information/metrics we may want to capture - publishExtraVars() - - ev := ExpVar{Resource: resource} - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - ev.Next = next - return ev - }) - - return nil -} - -func expVarParse(c *caddy.Controller) (Resource, error) { - var resource Resource - var err error - - for c.Next() { - args := c.RemainingArgs() - switch len(args) { - case 0: - resource = Resource(defaultExpvarPath) - case 1: - resource = Resource(args[0]) - default: - return resource, c.ArgErr() - } - } - - return resource, err -} - -func publishExtraVars() { - // By using sync.Once instead of an init() function, we don't clutter - // the app's expvar export unnecessarily, or risk colliding with it. - publishOnce.Do(func() { - expvar.Publish("Goroutines", expvar.Func(func() interface{} { - return runtime.NumGoroutine() - })) - }) -} - -var publishOnce sync.Once // publishing variables should only be done once -var defaultExpvarPath = "/debug/vars" diff --git a/vendor/github.com/mholt/caddy/caddyhttp/expvar/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/expvar/setup_test.go deleted file mode 100644 index 96dd4b0..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/expvar/setup_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package expvar - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`expvar`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - err = setup(caddy.NewTestController(`expvar /d/v`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids = httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - handler := mids[1](httpserver.EmptyNext) - myHandler, ok := handler.(ExpVar) - if !ok { - t.Fatalf("Expected handler to be type ExpVar, got: %#v", handler) - } - if myHandler.Resource != "/d/v" { - t.Errorf("Expected /d/v as expvar resource") - } - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/extensions/ext.go b/vendor/github.com/mholt/caddy/caddyhttp/extensions/ext.go deleted file mode 100644 index 46013b4..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/extensions/ext.go +++ /dev/null @@ -1,52 +0,0 @@ -// Package extensions contains middleware for clean URLs. -// -// The root path of the site is passed in as well as possible extensions -// to try internally for paths requested that don't match an existing -// resource. The first path+ext combination that matches a valid file -// will be used. -package extensions - -import ( - "net/http" - "os" - "path" - "strings" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Ext can assume an extension from clean URLs. -// It tries extensions in the order listed in Extensions. -type Ext struct { - // Next handler in the chain - Next httpserver.Handler - - // Path to ther root of the site - Root string - - // List of extensions to try - Extensions []string -} - -// ServeHTTP implements the httpserver.Handler interface. -func (e Ext) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - urlpath := strings.TrimSuffix(r.URL.Path, "/") - if path.Ext(urlpath) == "" && len(r.URL.Path) > 0 && r.URL.Path[len(r.URL.Path)-1] != '/' { - for _, ext := range e.Extensions { - if resourceExists(e.Root, urlpath+ext) { - r.URL.Path = urlpath + ext - break - } - } - } - return e.Next.ServeHTTP(w, r) -} - -// resourceExists returns true if the file specified at -// root + path exists; false otherwise. -func resourceExists(root, path string) bool { - _, err := os.Stat(root + path) - // technically we should use os.IsNotExist(err) - // but we don't handle any other kinds of errors anyway - return err == nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/extensions/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/extensions/setup.go deleted file mode 100644 index 4a1917a..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/extensions/setup.go +++ /dev/null @@ -1,53 +0,0 @@ -package extensions - -import ( - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("ext", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new instance of 'extensions' middleware for clean URLs. -func setup(c *caddy.Controller) error { - cfg := httpserver.GetConfig(c.Key) - root := cfg.Root - - exts, err := extParse(c) - if err != nil { - return err - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Ext{ - Next: next, - Extensions: exts, - Root: root, - } - }) - - return nil -} - -// extParse sets up an instance of extension middleware -// from a middleware controller and returns a list of extensions. -func extParse(c *caddy.Controller) ([]string, error) { - var exts []string - - for c.Next() { - // At least one extension is required - if !c.NextArg() { - return exts, c.ArgErr() - } - exts = append(exts, c.Val()) - - // Tack on any other extensions that may have been listed - exts = append(exts, c.RemainingArgs()...) - } - - return exts, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/extensions/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/extensions/setup_test.go deleted file mode 100644 index f6248be..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/extensions/setup_test.go +++ /dev/null @@ -1,74 +0,0 @@ -package extensions - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`ext .html .htm .php`)) - if err != nil { - t.Fatalf("Expected no errors, got: %v", err) - } - - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, had 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Ext) - - if !ok { - t.Fatalf("Expected handler to be type Ext, got: %#v", handler) - } - - if myHandler.Extensions[0] != ".html" { - t.Errorf("Expected .html in the list of Extensions") - } - if myHandler.Extensions[1] != ".htm" { - t.Errorf("Expected .htm in the list of Extensions") - } - if myHandler.Extensions[2] != ".php" { - t.Errorf("Expected .php in the list of Extensions") - } - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } - -} - -func TestExtParse(t *testing.T) { - tests := []struct { - inputExts string - shouldErr bool - expectedExts []string - }{ - {`ext .html .htm .php`, false, []string{".html", ".htm", ".php"}}, - {`ext .php .html .xml`, false, []string{".php", ".html", ".xml"}}, - {`ext .txt .php .xml`, false, []string{".txt", ".php", ".xml"}}, - } - for i, test := range tests { - actualExts, err := extParse(caddy.NewTestController(test.inputExts)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - - if len(actualExts) != len(test.expectedExts) { - t.Fatalf("Test %d expected %d rules, but got %d", - i, len(test.expectedExts), len(actualExts)) - } - for j, actualExt := range actualExts { - if actualExt != test.expectedExts[j] { - t.Fatalf("Test %d expected %dth extension to be %s , but got %s", - i, j, test.expectedExts[j], actualExt) - } - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi.go b/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi.go deleted file mode 100644 index 0ac886b..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi.go +++ /dev/null @@ -1,336 +0,0 @@ -// Package fastcgi has middleware that acts as a FastCGI client. Requests -// that get forwarded to FastCGI stop the middleware execution chain. -// The most common use for this package is to serve PHP websites via php-fpm. -package fastcgi - -import ( - "errors" - "io" - "net/http" - "os" - "path" - "path/filepath" - "strconv" - "strings" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Handler is a middleware type that can handle requests as a FastCGI client. -type Handler struct { - Next httpserver.Handler - Rules []Rule - Root string - AbsRoot string // same as root, but absolute path - FileSys http.FileSystem - - // These are sent to CGI scripts in env variables - SoftwareName string - SoftwareVersion string - ServerName string - ServerPort string -} - -// ServeHTTP satisfies the httpserver.Handler interface. -func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - for _, rule := range h.Rules { - - // First requirement: Base path must match and the path must be allowed. - if !httpserver.Path(r.URL.Path).Matches(rule.Path) || !rule.AllowedPath(r.URL.Path) { - continue - } - - // In addition to matching the path, a request must meet some - // other criteria before being proxied as FastCGI. For example, - // we probably want to exclude static assets (CSS, JS, images...) - // but we also want to be flexible for the script we proxy to. - - fpath := r.URL.Path - - if idx, ok := httpserver.IndexFile(h.FileSys, fpath, rule.IndexFiles); ok { - fpath = idx - // Index file present. - // If request path cannot be split, return error. - if !rule.canSplit(fpath) { - return http.StatusInternalServerError, ErrIndexMissingSplit - } - } else { - // No index file present. - // If request path cannot be split, ignore request. - if !rule.canSplit(fpath) { - continue - } - } - - // These criteria work well in this order for PHP sites - if !h.exists(fpath) || fpath[len(fpath)-1] == '/' || strings.HasSuffix(fpath, rule.Ext) { - - // Create environment for CGI script - env, err := h.buildEnv(r, rule, fpath) - if err != nil { - return http.StatusInternalServerError, err - } - - // Connect to FastCGI gateway - network, address := rule.parseAddress() - fcgiBackend, err := Dial(network, address) - if err != nil { - return http.StatusBadGateway, err - } - - var resp *http.Response - contentLength, _ := strconv.Atoi(r.Header.Get("Content-Length")) - switch r.Method { - case "HEAD": - resp, err = fcgiBackend.Head(env) - case "GET": - resp, err = fcgiBackend.Get(env) - case "OPTIONS": - resp, err = fcgiBackend.Options(env) - default: - resp, err = fcgiBackend.Post(env, r.Method, r.Header.Get("Content-Type"), r.Body, contentLength) - } - - if resp.Body != nil { - defer resp.Body.Close() - } - - if err != nil && err != io.EOF { - return http.StatusBadGateway, err - } - - // Write response header - writeHeader(w, resp) - - // Write the response body - _, err = io.Copy(w, resp.Body) - if err != nil { - return http.StatusBadGateway, err - } - - // Log any stderr output from upstream - if fcgiBackend.stderr.Len() != 0 { - // Remove trailing newline, error logger already does this. - err = LogError(strings.TrimSuffix(fcgiBackend.stderr.String(), "\n")) - } - - // Normally we would return the status code if it is an error status (>= 400), - // however, upstream FastCGI apps don't know about our contract and have - // probably already written an error page. So we just return 0, indicating - // that the response body is already written. However, we do return any - // error value so it can be logged. - // Note that the proxy middleware works the same way, returning status=0. - return 0, err - } - } - - return h.Next.ServeHTTP(w, r) -} - -// parseAddress returns the network and address of r. -// The first string is the network, "tcp" or "unix", implied from the scheme and address. -// The second string is r.Address, with scheme prefixes removed. -// The two returned strings can be used as parameters to the Dial() function. -func (r Rule) parseAddress() (string, string) { - // check if address has tcp scheme explicitly set - if strings.HasPrefix(r.Address, "tcp://") { - return "tcp", r.Address[len("tcp://"):] - } - // check if address has fastcgi scheme explicitly set - if strings.HasPrefix(r.Address, "fastcgi://") { - return "tcp", r.Address[len("fastcgi://"):] - } - // check if unix socket - if trim := strings.HasPrefix(r.Address, "unix"); strings.HasPrefix(r.Address, "/") || trim { - if trim { - return "unix", r.Address[len("unix:"):] - } - return "unix", r.Address - } - // default case, a plain tcp address with no scheme - return "tcp", r.Address -} - -func writeHeader(w http.ResponseWriter, r *http.Response) { - for key, vals := range r.Header { - for _, val := range vals { - w.Header().Add(key, val) - } - } - w.WriteHeader(r.StatusCode) -} - -func (h Handler) exists(path string) bool { - if _, err := os.Stat(h.Root + path); err == nil { - return true - } - return false -} - -// buildEnv returns a set of CGI environment variables for the request. -func (h Handler) buildEnv(r *http.Request, rule Rule, fpath string) (map[string]string, error) { - var env map[string]string - - // Get absolute path of requested resource - absPath := filepath.Join(h.AbsRoot, fpath) - - // Separate remote IP and port; more lenient than net.SplitHostPort - var ip, port string - if idx := strings.LastIndex(r.RemoteAddr, ":"); idx > -1 { - ip = r.RemoteAddr[:idx] - port = r.RemoteAddr[idx+1:] - } else { - ip = r.RemoteAddr - } - - // Remove [] from IPv6 addresses - ip = strings.Replace(ip, "[", "", 1) - ip = strings.Replace(ip, "]", "", 1) - - // Split path in preparation for env variables. - // Previous rule.canSplit checks ensure this can never be -1. - splitPos := rule.splitPos(fpath) - - // Request has the extension; path was split successfully - docURI := fpath[:splitPos+len(rule.SplitPath)] - pathInfo := fpath[splitPos+len(rule.SplitPath):] - scriptName := fpath - scriptFilename := absPath - - // Strip PATH_INFO from SCRIPT_NAME - scriptName = strings.TrimSuffix(scriptName, pathInfo) - - // Get the request URI. The request URI might be as it came in over the wire, - // or it might have been rewritten internally by the rewrite middleware (see issue #256). - // If it was rewritten, there will be a header indicating the original URL, - // which is needed to get the correct RequestURI value for PHP apps. - const internalRewriteFieldName = "Caddy-Rewrite-Original-URI" - reqURI := r.URL.RequestURI() - if origURI := r.Header.Get(internalRewriteFieldName); origURI != "" { - reqURI = origURI - r.Header.Del(internalRewriteFieldName) - } - - // Some variables are unused but cleared explicitly to prevent - // the parent environment from interfering. - env = map[string]string{ - - // Variables defined in CGI 1.1 spec - "AUTH_TYPE": "", // Not used - "CONTENT_LENGTH": r.Header.Get("Content-Length"), - "CONTENT_TYPE": r.Header.Get("Content-Type"), - "GATEWAY_INTERFACE": "CGI/1.1", - "PATH_INFO": pathInfo, - "QUERY_STRING": r.URL.RawQuery, - "REMOTE_ADDR": ip, - "REMOTE_HOST": ip, // For speed, remote host lookups disabled - "REMOTE_PORT": port, - "REMOTE_IDENT": "", // Not used - "REMOTE_USER": "", // Not used - "REQUEST_METHOD": r.Method, - "SERVER_NAME": h.ServerName, - "SERVER_PORT": h.ServerPort, - "SERVER_PROTOCOL": r.Proto, - "SERVER_SOFTWARE": h.SoftwareName + "/" + h.SoftwareVersion, - - // Other variables - "DOCUMENT_ROOT": h.AbsRoot, - "DOCUMENT_URI": docURI, - "HTTP_HOST": r.Host, // added here, since not always part of headers - "REQUEST_URI": reqURI, - "SCRIPT_FILENAME": scriptFilename, - "SCRIPT_NAME": scriptName, - } - - // compliance with the CGI specification that PATH_TRANSLATED - // should only exist if PATH_INFO is defined. - // Info: https://www.ietf.org/rfc/rfc3875 Page 14 - if env["PATH_INFO"] != "" { - env["PATH_TRANSLATED"] = filepath.Join(h.AbsRoot, pathInfo) // Info: http://www.oreilly.com/openbook/cgi/ch02_04.html - } - - // Some web apps rely on knowing HTTPS or not - if r.TLS != nil { - env["HTTPS"] = "on" - } - - // Add env variables from config - for _, envVar := range rule.EnvVars { - env[envVar[0]] = envVar[1] - } - - // Add all HTTP headers to env variables - for field, val := range r.Header { - header := strings.ToUpper(field) - header = headerNameReplacer.Replace(header) - env["HTTP_"+header] = strings.Join(val, ", ") - } - - return env, nil -} - -// Rule represents a FastCGI handling rule. -type Rule struct { - // The base path to match. Required. - Path string - - // The address of the FastCGI server. Required. - Address string - - // Always process files with this extension with fastcgi. - Ext string - - // The path in the URL will be split into two, with the first piece ending - // with the value of SplitPath. The first piece will be assumed as the - // actual resource (CGI script) name, and the second piece will be set to - // PATH_INFO for the CGI script to use. - SplitPath string - - // If the URL ends with '/' (which indicates a directory), these index - // files will be tried instead. - IndexFiles []string - - // Environment Variables - EnvVars [][2]string - - // Ignored paths - IgnoredSubPaths []string -} - -// canSplit checks if path can split into two based on rule.SplitPath. -func (r Rule) canSplit(path string) bool { - return r.splitPos(path) >= 0 -} - -// splitPos returns the index where path should be split -// based on rule.SplitPath. -func (r Rule) splitPos(path string) int { - if httpserver.CaseSensitivePath { - return strings.Index(path, r.SplitPath) - } - return strings.Index(strings.ToLower(path), strings.ToLower(r.SplitPath)) -} - -// AllowedPath checks if requestPath is not an ignored path. -func (r Rule) AllowedPath(requestPath string) bool { - for _, ignoredSubPath := range r.IgnoredSubPaths { - if httpserver.Path(path.Clean(requestPath)).Matches(path.Join(r.Path, ignoredSubPath)) { - return false - } - } - return true -} - -var ( - headerNameReplacer = strings.NewReplacer(" ", "_", "-", "_") - // ErrIndexMissingSplit describes an index configuration error. - ErrIndexMissingSplit = errors.New("configured index file(s) must include split value") -) - -// LogError is a non fatal error that allows requests to go through. -type LogError string - -// Error satisfies error interface. -func (l LogError) Error() string { - return string(l) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi_test.go b/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi_test.go deleted file mode 100644 index e1e3949..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fastcgi_test.go +++ /dev/null @@ -1,160 +0,0 @@ -package fastcgi - -import ( - "net" - "net/http" - "net/http/fcgi" - "net/http/httptest" - "net/url" - "strconv" - "testing" -) - -func TestServeHTTP(t *testing.T) { - body := "This is some test body content" - - bodyLenStr := strconv.Itoa(len(body)) - listener, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("Unable to create listener for test: %v", err) - } - defer listener.Close() - go fcgi.Serve(listener, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Content-Length", bodyLenStr) - w.Write([]byte(body)) - })) - - handler := Handler{ - Next: nil, - Rules: []Rule{{Path: "/", Address: listener.Addr().String()}}, - } - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Unable to create request: %v", err) - } - w := httptest.NewRecorder() - - status, err := handler.ServeHTTP(w, r) - - if got, want := status, 0; got != want { - t.Errorf("Expected returned status code to be %d, got %d", want, got) - } - if err != nil { - t.Errorf("Expected nil error, got: %v", err) - } - if got, want := w.Header().Get("Content-Length"), bodyLenStr; got != want { - t.Errorf("Expected Content-Length to be '%s', got: '%s'", want, got) - } - if got, want := w.Body.String(), body; got != want { - t.Errorf("Expected response body to be '%s', got: '%s'", want, got) - } -} - -func TestRuleParseAddress(t *testing.T) { - getClientTestTable := []struct { - rule *Rule - expectednetwork string - expectedaddress string - }{ - {&Rule{Address: "tcp://172.17.0.1:9000"}, "tcp", "172.17.0.1:9000"}, - {&Rule{Address: "fastcgi://localhost:9000"}, "tcp", "localhost:9000"}, - {&Rule{Address: "172.17.0.15"}, "tcp", "172.17.0.15"}, - {&Rule{Address: "/my/unix/socket"}, "unix", "/my/unix/socket"}, - {&Rule{Address: "unix:/second/unix/socket"}, "unix", "/second/unix/socket"}, - } - - for _, entry := range getClientTestTable { - if actualnetwork, _ := entry.rule.parseAddress(); actualnetwork != entry.expectednetwork { - t.Errorf("Unexpected network for address string %v. Got %v, expected %v", entry.rule.Address, actualnetwork, entry.expectednetwork) - } - if _, actualaddress := entry.rule.parseAddress(); actualaddress != entry.expectedaddress { - t.Errorf("Unexpected parsed address for address string %v. Got %v, expected %v", entry.rule.Address, actualaddress, entry.expectedaddress) - } - } -} - -func TestRuleIgnoredPath(t *testing.T) { - rule := &Rule{ - Path: "/fastcgi", - IgnoredSubPaths: []string{"/download", "/static"}, - } - tests := []struct { - url string - expected bool - }{ - {"/fastcgi", true}, - {"/fastcgi/dl", true}, - {"/fastcgi/download", false}, - {"/fastcgi/download/static", false}, - {"/fastcgi/static", false}, - {"/fastcgi/static/download", false}, - {"/fastcgi/something/download", true}, - {"/fastcgi/something/static", true}, - {"/fastcgi//static", false}, - {"/fastcgi//static//download", false}, - {"/fastcgi//download", false}, - } - - for i, test := range tests { - allowed := rule.AllowedPath(test.url) - if test.expected != allowed { - t.Errorf("Test %d: expected %v found %v", i, test.expected, allowed) - } - } -} - -func TestBuildEnv(t *testing.T) { - testBuildEnv := func(r *http.Request, rule Rule, fpath string, envExpected map[string]string) { - var h Handler - env, err := h.buildEnv(r, rule, fpath) - if err != nil { - t.Error("Unexpected error:", err.Error()) - } - for k, v := range envExpected { - if env[k] != v { - t.Errorf("Unexpected %v. Got %v, expected %v", k, env[k], v) - } - } - } - - rule := Rule{} - url, err := url.Parse("http://localhost:2015/fgci_test.php?test=blabla") - if err != nil { - t.Error("Unexpected error:", err.Error()) - } - - r := http.Request{ - Method: "GET", - URL: url, - Proto: "HTTP/1.1", - ProtoMajor: 1, - ProtoMinor: 1, - Host: "localhost:2015", - RemoteAddr: "[2b02:1810:4f2d:9400:70ab:f822:be8a:9093]:51688", - RequestURI: "/fgci_test.php", - } - - fpath := "/fgci_test.php" - - var envExpected = map[string]string{ - "REMOTE_ADDR": "2b02:1810:4f2d:9400:70ab:f822:be8a:9093", - "REMOTE_PORT": "51688", - "SERVER_PROTOCOL": "HTTP/1.1", - "QUERY_STRING": "test=blabla", - "REQUEST_METHOD": "GET", - "HTTP_HOST": "localhost:2015", - } - - // 1. Test for full canonical IPv6 address - testBuildEnv(&r, rule, fpath, envExpected) - - // 2. Test for shorthand notation of IPv6 address - r.RemoteAddr = "[::1]:51688" - envExpected["REMOTE_ADDR"] = "::1" - testBuildEnv(&r, rule, fpath, envExpected) - - // 3. Test for IPv4 address - r.RemoteAddr = "192.168.0.10:51688" - envExpected["REMOTE_ADDR"] = "192.168.0.10" - testBuildEnv(&r, rule, fpath, envExpected) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgi_test.php b/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgi_test.php deleted file mode 100644 index 3f5e5f2..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgi_test.php +++ /dev/null @@ -1,79 +0,0 @@ - $val) { - $md5 = md5($val); - - if ($key != $md5) { - $stat = "FAILED"; - echo "server:err ".$md5." != ".$key."\n"; - } - - $length += strlen($key) + strlen($val); - - $ret .= $key."(".strlen($key).") "; - } - $ret .= "] ["; - foreach ($_FILES as $k0 => $val) { - - $error = $val["error"]; - if ($error == UPLOAD_ERR_OK) { - $tmp_name = $val["tmp_name"]; - $name = $val["name"]; - $datafile = "/tmp/test.go"; - move_uploaded_file($tmp_name, $datafile); - $md5 = md5_file($datafile); - - if ($k0 != $md5) { - $stat = "FAILED"; - echo "server:err ".$md5." != ".$key."\n"; - } - - $length += strlen($k0) + filesize($datafile); - - unlink($datafile); - $ret .= $k0."(".strlen($k0).") "; - } - else{ - $stat = "FAILED"; - echo "server:file err ".file_upload_error_message($error)."\n"; - } - } - $ret .= "]"; - echo "server:got data length " .$length."\n"; -} - - -echo "-{$stat}-POST(".count($_POST).") FILE(".count($_FILES).")\n"; - -function file_upload_error_message($error_code) { - switch ($error_code) { - case UPLOAD_ERR_INI_SIZE: - return 'The uploaded file exceeds the upload_max_filesize directive in php.ini'; - case UPLOAD_ERR_FORM_SIZE: - return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form'; - case UPLOAD_ERR_PARTIAL: - return 'The uploaded file was only partially uploaded'; - case UPLOAD_ERR_NO_FILE: - return 'No file was uploaded'; - case UPLOAD_ERR_NO_TMP_DIR: - return 'Missing a temporary folder'; - case UPLOAD_ERR_CANT_WRITE: - return 'Failed to write file to disk'; - case UPLOAD_ERR_EXTENSION: - return 'File upload stopped by extension'; - default: - return 'Unknown upload error'; - } -} \ No newline at end of file diff --git a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient.go b/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient.go deleted file mode 100644 index f443f63..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient.go +++ /dev/null @@ -1,560 +0,0 @@ -// Forked Jan. 2015 from http://bitbucket.org/PinIdea/fcgi_client -// (which is forked from https://code.google.com/p/go-fastcgi-client/) - -// This fork contains several fixes and improvements by Matt Holt and -// other contributors to this project. - -// Copyright 2012 Junqing Tan and The Go Authors -// Use of this source code is governed by a BSD-style -// Part of source code is from Go fcgi package - -package fastcgi - -import ( - "bufio" - "bytes" - "encoding/binary" - "errors" - "io" - "io/ioutil" - "mime/multipart" - "net" - "net/http" - "net/http/httputil" - "net/textproto" - "net/url" - "os" - "path/filepath" - "strconv" - "strings" - "sync" -) - -// FCGIListenSockFileno describes listen socket file number. -const FCGIListenSockFileno uint8 = 0 - -// FCGIHeaderLen describes header length. -const FCGIHeaderLen uint8 = 8 - -// Version1 describes the version. -const Version1 uint8 = 1 - -// FCGINullRequestID describes the null request ID. -const FCGINullRequestID uint8 = 0 - -// FCGIKeepConn describes keep connection mode. -const FCGIKeepConn uint8 = 1 -const doubleCRLF = "\r\n\r\n" - -const ( - // BeginRequest is the begin request flag. - BeginRequest uint8 = iota + 1 - // AbortRequest is the abort request flag. - AbortRequest - // EndRequest is the end request flag. - EndRequest - // Params is the parameters flag. - Params - // Stdin is the standard input flag. - Stdin - // Stdout is the standard output flag. - Stdout - // Stderr is the standard error flag. - Stderr - // Data is the data flag. - Data - // GetValues is the get values flag. - GetValues - // GetValuesResult is the get values result flag. - GetValuesResult - // UnknownType is the unknown type flag. - UnknownType - // MaxType is the maximum type flag. - MaxType = UnknownType -) - -const ( - // Responder is the responder flag. - Responder uint8 = iota + 1 - // Authorizer is the authorizer flag. - Authorizer - // Filter is the filter flag. - Filter -) - -const ( - // RequestComplete is the completed request flag. - RequestComplete uint8 = iota - // CantMultiplexConns is the multiplexed connections flag. - CantMultiplexConns - // Overloaded is the overloaded flag. - Overloaded - // UnknownRole is the unknown role flag. - UnknownRole -) - -const ( - // MaxConns is the maximum connections flag. - MaxConns string = "MAX_CONNS" - // MaxRequests is the maximum requests flag. - MaxRequests string = "MAX_REQS" - // MultiplexConns is the multiplex connections flag. - MultiplexConns string = "MPXS_CONNS" -) - -const ( - maxWrite = 65500 // 65530 may work, but for compatibility - maxPad = 255 -) - -type header struct { - Version uint8 - Type uint8 - ID uint16 - ContentLength uint16 - PaddingLength uint8 - Reserved uint8 -} - -// for padding so we don't have to allocate all the time -// not synchronized because we don't care what the contents are -var pad [maxPad]byte - -func (h *header) init(recType uint8, reqID uint16, contentLength int) { - h.Version = 1 - h.Type = recType - h.ID = reqID - h.ContentLength = uint16(contentLength) - h.PaddingLength = uint8(-contentLength & 7) -} - -type record struct { - h header - rbuf []byte -} - -func (rec *record) read(r io.Reader) (buf []byte, err error) { - if err = binary.Read(r, binary.BigEndian, &rec.h); err != nil { - return - } - if rec.h.Version != 1 { - err = errors.New("fcgi: invalid header version") - return - } - if rec.h.Type == EndRequest { - err = io.EOF - return - } - n := int(rec.h.ContentLength) + int(rec.h.PaddingLength) - if len(rec.rbuf) < n { - rec.rbuf = make([]byte, n) - } - if _, err = io.ReadFull(r, rec.rbuf[:n]); err != nil { - return - } - buf = rec.rbuf[:int(rec.h.ContentLength)] - - return -} - -// FCGIClient implements a FastCGI client, which is a standard for -// interfacing external applications with Web servers. -type FCGIClient struct { - mutex sync.Mutex - rwc io.ReadWriteCloser - h header - buf bytes.Buffer - stderr bytes.Buffer - keepAlive bool - reqID uint16 -} - -// DialWithDialer connects to the fcgi responder at the specified network address, using custom net.Dialer. -// See func net.Dial for a description of the network and address parameters. -func DialWithDialer(network, address string, dialer net.Dialer) (fcgi *FCGIClient, err error) { - var conn net.Conn - conn, err = dialer.Dial(network, address) - if err != nil { - return - } - - fcgi = &FCGIClient{ - rwc: conn, - keepAlive: false, - reqID: 1, - } - - return -} - -// Dial connects to the fcgi responder at the specified network address, using default net.Dialer. -// See func net.Dial for a description of the network and address parameters. -func Dial(network, address string) (fcgi *FCGIClient, err error) { - return DialWithDialer(network, address, net.Dialer{}) -} - -// Close closes fcgi connnection -func (c *FCGIClient) Close() { - c.rwc.Close() -} - -func (c *FCGIClient) writeRecord(recType uint8, content []byte) (err error) { - c.mutex.Lock() - defer c.mutex.Unlock() - c.buf.Reset() - c.h.init(recType, c.reqID, len(content)) - if err := binary.Write(&c.buf, binary.BigEndian, c.h); err != nil { - return err - } - if _, err := c.buf.Write(content); err != nil { - return err - } - if _, err := c.buf.Write(pad[:c.h.PaddingLength]); err != nil { - return err - } - _, err = c.rwc.Write(c.buf.Bytes()) - return err -} - -func (c *FCGIClient) writeBeginRequest(role uint16, flags uint8) error { - b := [8]byte{byte(role >> 8), byte(role), flags} - return c.writeRecord(BeginRequest, b[:]) -} - -func (c *FCGIClient) writeEndRequest(appStatus int, protocolStatus uint8) error { - b := make([]byte, 8) - binary.BigEndian.PutUint32(b, uint32(appStatus)) - b[4] = protocolStatus - return c.writeRecord(EndRequest, b) -} - -func (c *FCGIClient) writePairs(recType uint8, pairs map[string]string) error { - w := newWriter(c, recType) - b := make([]byte, 8) - nn := 0 - for k, v := range pairs { - m := 8 + len(k) + len(v) - if m > maxWrite { - // param data size exceed 65535 bytes" - vl := maxWrite - 8 - len(k) - v = v[:vl] - } - n := encodeSize(b, uint32(len(k))) - n += encodeSize(b[n:], uint32(len(v))) - m = n + len(k) + len(v) - if (nn + m) > maxWrite { - w.Flush() - nn = 0 - } - nn += m - if _, err := w.Write(b[:n]); err != nil { - return err - } - if _, err := w.WriteString(k); err != nil { - return err - } - if _, err := w.WriteString(v); err != nil { - return err - } - } - w.Close() - return nil -} - -func readSize(s []byte) (uint32, int) { - if len(s) == 0 { - return 0, 0 - } - size, n := uint32(s[0]), 1 - if size&(1<<7) != 0 { - if len(s) < 4 { - return 0, 0 - } - n = 4 - size = binary.BigEndian.Uint32(s) - size &^= 1 << 31 - } - return size, n -} - -func readString(s []byte, size uint32) string { - if size > uint32(len(s)) { - return "" - } - return string(s[:size]) -} - -func encodeSize(b []byte, size uint32) int { - if size > 127 { - size |= 1 << 31 - binary.BigEndian.PutUint32(b, size) - return 4 - } - b[0] = byte(size) - return 1 -} - -// bufWriter encapsulates bufio.Writer but also closes the underlying stream when -// Closed. -type bufWriter struct { - closer io.Closer - *bufio.Writer -} - -func (w *bufWriter) Close() error { - if err := w.Writer.Flush(); err != nil { - w.closer.Close() - return err - } - return w.closer.Close() -} - -func newWriter(c *FCGIClient, recType uint8) *bufWriter { - s := &streamWriter{c: c, recType: recType} - w := bufio.NewWriterSize(s, maxWrite) - return &bufWriter{s, w} -} - -// streamWriter abstracts out the separation of a stream into discrete records. -// It only writes maxWrite bytes at a time. -type streamWriter struct { - c *FCGIClient - recType uint8 -} - -func (w *streamWriter) Write(p []byte) (int, error) { - nn := 0 - for len(p) > 0 { - n := len(p) - if n > maxWrite { - n = maxWrite - } - if err := w.c.writeRecord(w.recType, p[:n]); err != nil { - return nn, err - } - nn += n - p = p[n:] - } - return nn, nil -} - -func (w *streamWriter) Close() error { - // send empty record to close the stream - return w.c.writeRecord(w.recType, nil) -} - -type streamReader struct { - c *FCGIClient - buf []byte -} - -func (w *streamReader) Read(p []byte) (n int, err error) { - - if len(p) > 0 { - if len(w.buf) == 0 { - - // filter outputs for error log - for { - rec := &record{} - var buf []byte - buf, err = rec.read(w.c.rwc) - if err != nil { - return - } - // standard error output - if rec.h.Type == Stderr { - w.c.stderr.Write(buf) - continue - } - w.buf = buf - break - } - } - - n = len(p) - if n > len(w.buf) { - n = len(w.buf) - } - copy(p, w.buf[:n]) - w.buf = w.buf[n:] - } - - return -} - -// Do made the request and returns a io.Reader that translates the data read -// from fcgi responder out of fcgi packet before returning it. -func (c *FCGIClient) Do(p map[string]string, req io.Reader) (r io.Reader, err error) { - err = c.writeBeginRequest(uint16(Responder), 0) - if err != nil { - return - } - - err = c.writePairs(Params, p) - if err != nil { - return - } - - body := newWriter(c, Stdin) - if req != nil { - io.Copy(body, req) - } - body.Close() - - r = &streamReader{c: c} - return -} - -// clientCloser is a io.ReadCloser. It wraps a io.Reader with a Closer -// that closes FCGIClient connection. -type clientCloser struct { - *FCGIClient - io.Reader -} - -func (f clientCloser) Close() error { return f.rwc.Close() } - -// Request returns a HTTP Response with Header and Body -// from fcgi responder -func (c *FCGIClient) Request(p map[string]string, req io.Reader) (resp *http.Response, err error) { - - r, err := c.Do(p, req) - if err != nil { - return - } - - rb := bufio.NewReader(r) - tp := textproto.NewReader(rb) - resp = new(http.Response) - - // Parse the response headers. - mimeHeader, err := tp.ReadMIMEHeader() - if err != nil && err != io.EOF { - return - } - resp.Header = http.Header(mimeHeader) - - if resp.Header.Get("Status") != "" { - statusParts := strings.SplitN(resp.Header.Get("Status"), " ", 2) - resp.StatusCode, err = strconv.Atoi(statusParts[0]) - if err != nil { - return - } - if len(statusParts) > 1 { - resp.Status = statusParts[1] - } - - } else { - resp.StatusCode = http.StatusOK - } - - // TODO: fixTransferEncoding ? - resp.TransferEncoding = resp.Header["Transfer-Encoding"] - resp.ContentLength, _ = strconv.ParseInt(resp.Header.Get("Content-Length"), 10, 64) - - if chunked(resp.TransferEncoding) { - resp.Body = clientCloser{c, httputil.NewChunkedReader(rb)} - } else { - resp.Body = clientCloser{c, ioutil.NopCloser(rb)} - } - return -} - -// Get issues a GET request to the fcgi responder. -func (c *FCGIClient) Get(p map[string]string) (resp *http.Response, err error) { - - p["REQUEST_METHOD"] = "GET" - p["CONTENT_LENGTH"] = "0" - - return c.Request(p, nil) -} - -// Head issues a HEAD request to the fcgi responder. -func (c *FCGIClient) Head(p map[string]string) (resp *http.Response, err error) { - - p["REQUEST_METHOD"] = "HEAD" - p["CONTENT_LENGTH"] = "0" - - return c.Request(p, nil) -} - -// Options issues an OPTIONS request to the fcgi responder. -func (c *FCGIClient) Options(p map[string]string) (resp *http.Response, err error) { - - p["REQUEST_METHOD"] = "OPTIONS" - p["CONTENT_LENGTH"] = "0" - - return c.Request(p, nil) -} - -// Post issues a POST request to the fcgi responder. with request body -// in the format that bodyType specified -func (c *FCGIClient) Post(p map[string]string, method string, bodyType string, body io.Reader, l int) (resp *http.Response, err error) { - if p == nil { - p = make(map[string]string) - } - - p["REQUEST_METHOD"] = strings.ToUpper(method) - - if len(p["REQUEST_METHOD"]) == 0 || p["REQUEST_METHOD"] == "GET" { - p["REQUEST_METHOD"] = "POST" - } - - p["CONTENT_LENGTH"] = strconv.Itoa(l) - if len(bodyType) > 0 { - p["CONTENT_TYPE"] = bodyType - } else { - p["CONTENT_TYPE"] = "application/x-www-form-urlencoded" - } - - return c.Request(p, body) -} - -// PostForm issues a POST to the fcgi responder, with form -// as a string key to a list values (url.Values) -func (c *FCGIClient) PostForm(p map[string]string, data url.Values) (resp *http.Response, err error) { - body := bytes.NewReader([]byte(data.Encode())) - return c.Post(p, "POST", "application/x-www-form-urlencoded", body, body.Len()) -} - -// PostFile issues a POST to the fcgi responder in multipart(RFC 2046) standard, -// with form as a string key to a list values (url.Values), -// and/or with file as a string key to a list file path. -func (c *FCGIClient) PostFile(p map[string]string, data url.Values, file map[string]string) (resp *http.Response, err error) { - buf := &bytes.Buffer{} - writer := multipart.NewWriter(buf) - bodyType := writer.FormDataContentType() - - for key, val := range data { - for _, v0 := range val { - err = writer.WriteField(key, v0) - if err != nil { - return - } - } - } - - for key, val := range file { - fd, e := os.Open(val) - if e != nil { - return nil, e - } - defer fd.Close() - - part, e := writer.CreateFormFile(key, filepath.Base(val)) - if e != nil { - return nil, e - } - _, err = io.Copy(part, fd) - } - - err = writer.Close() - if err != nil { - return - } - - return c.Post(p, "POST", bodyType, buf, buf.Len()) -} - -// Checks whether chunked is part of the encodings stack -func chunked(te []string) bool { return len(te) > 0 && te[0] == "chunked" } diff --git a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient_test.go b/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient_test.go deleted file mode 100644 index c4d9978..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/fcgiclient_test.go +++ /dev/null @@ -1,275 +0,0 @@ -// NOTE: These tests were adapted from the original -// repository from which this package was forked. -// The tests are slow (~10s) and in dire need of rewriting. -// As such, the tests have been disabled to speed up -// automated builds until they can be properly written. - -package fastcgi - -import ( - "bytes" - "crypto/md5" - "encoding/binary" - "fmt" - "io" - "io/ioutil" - "log" - "math/rand" - "net" - "net/http" - "net/http/fcgi" - "net/url" - "os" - "path/filepath" - "strconv" - "strings" - "testing" - "time" -) - -// test fcgi protocol includes: -// Get, Post, Post in multipart/form-data, and Post with files -// each key should be the md5 of the value or the file uploaded -// sepicify remote fcgi responer ip:port to test with php -// test failed if the remote fcgi(script) failed md5 verification -// and output "FAILED" in response -const ( - scriptFile = "/tank/www/fcgic_test.php" - //ipPort = "remote-php-serv:59000" - ipPort = "127.0.0.1:59000" -) - -var globalt *testing.T - -type FastCGIServer struct{} - -func (s FastCGIServer) ServeHTTP(resp http.ResponseWriter, req *http.Request) { - - req.ParseMultipartForm(100000000) - - stat := "PASSED" - fmt.Fprintln(resp, "-") - fileNum := 0 - { - length := 0 - for k0, v0 := range req.Form { - h := md5.New() - io.WriteString(h, v0[0]) - md5 := fmt.Sprintf("%x", h.Sum(nil)) - - length += len(k0) - length += len(v0[0]) - - // echo error when key != md5(val) - if md5 != k0 { - fmt.Fprintln(resp, "server:err ", md5, k0) - stat = "FAILED" - } - } - if req.MultipartForm != nil { - fileNum = len(req.MultipartForm.File) - for kn, fns := range req.MultipartForm.File { - //fmt.Fprintln(resp, "server:filekey ", kn ) - length += len(kn) - for _, f := range fns { - fd, err := f.Open() - if err != nil { - log.Println("server:", err) - return - } - h := md5.New() - l0, err := io.Copy(h, fd) - if err != nil { - log.Println(err) - return - } - length += int(l0) - defer fd.Close() - md5 := fmt.Sprintf("%x", h.Sum(nil)) - //fmt.Fprintln(resp, "server:filemd5 ", md5 ) - - if kn != md5 { - fmt.Fprintln(resp, "server:err ", md5, kn) - stat = "FAILED" - } - //fmt.Fprintln(resp, "server:filename ", f.Filename ) - } - } - } - - fmt.Fprintln(resp, "server:got data length", length) - } - fmt.Fprintln(resp, "-"+stat+"-POST(", len(req.Form), ")-FILE(", fileNum, ")--") -} - -func sendFcgi(reqType int, fcgiParams map[string]string, data []byte, posts map[string]string, files map[string]string) (content []byte) { - fcgi, err := Dial("tcp", ipPort) - if err != nil { - log.Println("err:", err) - return - } - - length := 0 - - var resp *http.Response - switch reqType { - case 0: - if len(data) > 0 { - length = len(data) - rd := bytes.NewReader(data) - resp, err = fcgi.Post(fcgiParams, "", "", rd, rd.Len()) - } else if len(posts) > 0 { - values := url.Values{} - for k, v := range posts { - values.Set(k, v) - length += len(k) + 2 + len(v) - } - resp, err = fcgi.PostForm(fcgiParams, values) - } else { - resp, err = fcgi.Get(fcgiParams) - } - - default: - values := url.Values{} - for k, v := range posts { - values.Set(k, v) - length += len(k) + 2 + len(v) - } - - for k, v := range files { - fi, _ := os.Lstat(v) - length += len(k) + int(fi.Size()) - } - resp, err = fcgi.PostFile(fcgiParams, values, files) - } - - if err != nil { - log.Println("err:", err) - return - } - - defer resp.Body.Close() - content, _ = ioutil.ReadAll(resp.Body) - - log.Println("c: send data length ≈", length, string(content)) - fcgi.Close() - time.Sleep(1 * time.Second) - - if bytes.Index(content, []byte("FAILED")) >= 0 { - globalt.Error("Server return failed message") - } - - return -} - -func generateRandFile(size int) (p string, m string) { - - p = filepath.Join(os.TempDir(), "fcgict"+strconv.Itoa(rand.Int())) - - // open output file - fo, err := os.Create(p) - if err != nil { - panic(err) - } - // close fo on exit and check for its returned error - defer func() { - if err := fo.Close(); err != nil { - panic(err) - } - }() - - h := md5.New() - for i := 0; i < size/16; i++ { - buf := make([]byte, 16) - binary.PutVarint(buf, rand.Int63()) - fo.Write(buf) - h.Write(buf) - } - m = fmt.Sprintf("%x", h.Sum(nil)) - return -} - -func DisabledTest(t *testing.T) { - // TODO: test chunked reader - globalt = t - - rand.Seed(time.Now().UTC().UnixNano()) - - // server - go func() { - listener, err := net.Listen("tcp", ipPort) - if err != nil { - // handle error - log.Println("listener creation failed: ", err) - } - - srv := new(FastCGIServer) - fcgi.Serve(listener, srv) - }() - - time.Sleep(1 * time.Second) - - // init - fcgiParams := make(map[string]string) - fcgiParams["REQUEST_METHOD"] = "GET" - fcgiParams["SERVER_PROTOCOL"] = "HTTP/1.1" - //fcgi_params["GATEWAY_INTERFACE"] = "CGI/1.1" - fcgiParams["SCRIPT_FILENAME"] = scriptFile - - // simple GET - log.Println("test:", "get") - sendFcgi(0, fcgiParams, nil, nil, nil) - - // simple post data - log.Println("test:", "post") - sendFcgi(0, fcgiParams, []byte("c4ca4238a0b923820dcc509a6f75849b=1&7b8b965ad4bca0e41ab51de7b31363a1=n"), nil, nil) - - log.Println("test:", "post data (more than 60KB)") - data := "" - for i := 0x00; i < 0xff; i++ { - v0 := strings.Repeat(string(i), 256) - h := md5.New() - io.WriteString(h, v0) - k0 := fmt.Sprintf("%x", h.Sum(nil)) - data += k0 + "=" + url.QueryEscape(v0) + "&" - } - sendFcgi(0, fcgiParams, []byte(data), nil, nil) - - log.Println("test:", "post form (use url.Values)") - p0 := make(map[string]string, 1) - p0["c4ca4238a0b923820dcc509a6f75849b"] = "1" - p0["7b8b965ad4bca0e41ab51de7b31363a1"] = "n" - sendFcgi(1, fcgiParams, nil, p0, nil) - - log.Println("test:", "post forms (256 keys, more than 1MB)") - p1 := make(map[string]string, 1) - for i := 0x00; i < 0xff; i++ { - v0 := strings.Repeat(string(i), 4096) - h := md5.New() - io.WriteString(h, v0) - k0 := fmt.Sprintf("%x", h.Sum(nil)) - p1[k0] = v0 - } - sendFcgi(1, fcgiParams, nil, p1, nil) - - log.Println("test:", "post file (1 file, 500KB)) ") - f0 := make(map[string]string, 1) - path0, m0 := generateRandFile(500000) - f0[m0] = path0 - sendFcgi(1, fcgiParams, nil, p1, f0) - - log.Println("test:", "post multiple files (2 files, 5M each) and forms (256 keys, more than 1MB data") - path1, m1 := generateRandFile(5000000) - f0[m1] = path1 - sendFcgi(1, fcgiParams, nil, p1, f0) - - log.Println("test:", "post only files (2 files, 5M each)") - sendFcgi(1, fcgiParams, nil, nil, f0) - - log.Println("test:", "post only 1 file") - delete(f0, "m0") - sendFcgi(1, fcgiParams, nil, nil, f0) - - os.Remove(path0) - os.Remove(path1) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup.go deleted file mode 100644 index dd32c59..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup.go +++ /dev/null @@ -1,126 +0,0 @@ -package fastcgi - -import ( - "errors" - "net/http" - "path/filepath" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("fastcgi", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new FastCGI middleware instance. -func setup(c *caddy.Controller) error { - cfg := httpserver.GetConfig(c.Key) - absRoot, err := filepath.Abs(cfg.Root) - if err != nil { - return err - } - - rules, err := fastcgiParse(c) - if err != nil { - return err - } - - cfg.AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Handler{ - Next: next, - Rules: rules, - Root: cfg.Root, - AbsRoot: absRoot, - FileSys: http.Dir(cfg.Root), - SoftwareName: caddy.AppName, - SoftwareVersion: caddy.AppVersion, - ServerName: cfg.Addr.Host, - ServerPort: cfg.Addr.Port, - } - }) - - return nil -} - -func fastcgiParse(c *caddy.Controller) ([]Rule, error) { - var rules []Rule - - for c.Next() { - var rule Rule - - args := c.RemainingArgs() - - switch len(args) { - case 0: - return rules, c.ArgErr() - case 1: - rule.Path = "/" - rule.Address = args[0] - case 2: - rule.Path = args[0] - rule.Address = args[1] - case 3: - rule.Path = args[0] - rule.Address = args[1] - err := fastcgiPreset(args[2], &rule) - if err != nil { - return rules, c.Err("Invalid fastcgi rule preset '" + args[2] + "'") - } - } - - for c.NextBlock() { - switch c.Val() { - case "ext": - if !c.NextArg() { - return rules, c.ArgErr() - } - rule.Ext = c.Val() - case "split": - if !c.NextArg() { - return rules, c.ArgErr() - } - rule.SplitPath = c.Val() - case "index": - args := c.RemainingArgs() - if len(args) == 0 { - return rules, c.ArgErr() - } - rule.IndexFiles = args - case "env": - envArgs := c.RemainingArgs() - if len(envArgs) < 2 { - return rules, c.ArgErr() - } - rule.EnvVars = append(rule.EnvVars, [2]string{envArgs[0], envArgs[1]}) - case "except": - ignoredPaths := c.RemainingArgs() - if len(ignoredPaths) == 0 { - return rules, c.ArgErr() - } - rule.IgnoredSubPaths = ignoredPaths - } - } - - rules = append(rules, rule) - } - - return rules, nil -} - -// fastcgiPreset configures rule according to name. It returns an error if -// name is not a recognized preset name. -func fastcgiPreset(name string, rule *Rule) error { - switch name { - case "php": - rule.Ext = ".php" - rule.SplitPath = ".php" - rule.IndexFiles = []string{"index.php"} - default: - return errors.New(name + " is not a valid preset name") - } - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup_test.go deleted file mode 100644 index b28b147..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/fastcgi/setup_test.go +++ /dev/null @@ -1,121 +0,0 @@ -package fastcgi - -import ( - "fmt" - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`fastcgi / 127.0.0.1:9000`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Handler) - - if !ok { - t.Fatalf("Expected handler to be type , got: %#v", handler) - } - - if myHandler.Rules[0].Path != "/" { - t.Errorf("Expected / as the Path") - } - if myHandler.Rules[0].Address != "127.0.0.1:9000" { - t.Errorf("Expected 127.0.0.1:9000 as the Address") - } - -} - -func TestFastcgiParse(t *testing.T) { - tests := []struct { - inputFastcgiConfig string - shouldErr bool - expectedFastcgiConfig []Rule - }{ - - {`fastcgi /blog 127.0.0.1:9000 php`, - false, []Rule{{ - Path: "/blog", - Address: "127.0.0.1:9000", - Ext: ".php", - SplitPath: ".php", - IndexFiles: []string{"index.php"}, - }}}, - {`fastcgi / 127.0.0.1:9001 { - split .html - }`, - false, []Rule{{ - Path: "/", - Address: "127.0.0.1:9001", - Ext: "", - SplitPath: ".html", - IndexFiles: []string{}, - }}}, - {`fastcgi / 127.0.0.1:9001 { - split .html - except /admin /user - }`, - false, []Rule{{ - Path: "/", - Address: "127.0.0.1:9001", - Ext: "", - SplitPath: ".html", - IndexFiles: []string{}, - IgnoredSubPaths: []string{"/admin", "/user"}, - }}}, - } - for i, test := range tests { - actualFastcgiConfigs, err := fastcgiParse(caddy.NewTestController(test.inputFastcgiConfig)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - if len(actualFastcgiConfigs) != len(test.expectedFastcgiConfig) { - t.Fatalf("Test %d expected %d no of FastCGI configs, but got %d ", - i, len(test.expectedFastcgiConfig), len(actualFastcgiConfigs)) - } - for j, actualFastcgiConfig := range actualFastcgiConfigs { - - if actualFastcgiConfig.Path != test.expectedFastcgiConfig[j].Path { - t.Errorf("Test %d expected %dth FastCGI Path to be %s , but got %s", - i, j, test.expectedFastcgiConfig[j].Path, actualFastcgiConfig.Path) - } - - if actualFastcgiConfig.Address != test.expectedFastcgiConfig[j].Address { - t.Errorf("Test %d expected %dth FastCGI Address to be %s , but got %s", - i, j, test.expectedFastcgiConfig[j].Address, actualFastcgiConfig.Address) - } - - if actualFastcgiConfig.Ext != test.expectedFastcgiConfig[j].Ext { - t.Errorf("Test %d expected %dth FastCGI Ext to be %s , but got %s", - i, j, test.expectedFastcgiConfig[j].Ext, actualFastcgiConfig.Ext) - } - - if actualFastcgiConfig.SplitPath != test.expectedFastcgiConfig[j].SplitPath { - t.Errorf("Test %d expected %dth FastCGI SplitPath to be %s , but got %s", - i, j, test.expectedFastcgiConfig[j].SplitPath, actualFastcgiConfig.SplitPath) - } - - if fmt.Sprint(actualFastcgiConfig.IndexFiles) != fmt.Sprint(test.expectedFastcgiConfig[j].IndexFiles) { - t.Errorf("Test %d expected %dth FastCGI IndexFiles to be %s , but got %s", - i, j, test.expectedFastcgiConfig[j].IndexFiles, actualFastcgiConfig.IndexFiles) - } - - if fmt.Sprint(actualFastcgiConfig.IgnoredSubPaths) != fmt.Sprint(test.expectedFastcgiConfig[j].IgnoredSubPaths) { - t.Errorf("Test %d expected %dth FastCGI IgnoredSubPaths to be %s , but got %s", - i, j, test.expectedFastcgiConfig[j].IgnoredSubPaths, actualFastcgiConfig.IgnoredSubPaths) - } - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip.go deleted file mode 100644 index ed95156..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip.go +++ /dev/null @@ -1,167 +0,0 @@ -// Package gzip provides a middleware layer that performs -// gzip compression on the response. -package gzip - -import ( - "bufio" - "compress/gzip" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "strings" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("gzip", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// Gzip is a middleware type which gzips HTTP responses. It is -// imperative that any handler which writes to a gzipped response -// specifies the Content-Type, otherwise some clients will assume -// application/x-gzip and try to download a file. -type Gzip struct { - Next httpserver.Handler - Configs []Config -} - -// Config holds the configuration for Gzip middleware -type Config struct { - RequestFilters []RequestFilter - ResponseFilters []ResponseFilter - Level int // Compression level -} - -// ServeHTTP serves a gzipped response if the client supports it. -func (g Gzip) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { - return g.Next.ServeHTTP(w, r) - } -outer: - for _, c := range g.Configs { - - // Check request filters to determine if gzipping is permitted for this request - for _, filter := range c.RequestFilters { - if !filter.ShouldCompress(r) { - continue outer - } - } - - // Delete this header so gzipping is not repeated later in the chain - r.Header.Del("Accept-Encoding") - - // gzipWriter modifies underlying writer at init, - // use a discard writer instead to leave ResponseWriter in - // original form. - gzipWriter, err := newWriter(c, ioutil.Discard) - if err != nil { - // should not happen - return http.StatusInternalServerError, err - } - defer gzipWriter.Close() - gz := &gzipResponseWriter{Writer: gzipWriter, ResponseWriter: w} - - var rw http.ResponseWriter - // if no response filter is used - if len(c.ResponseFilters) == 0 { - // replace discard writer with ResponseWriter - gzipWriter.Reset(w) - rw = gz - } else { - // wrap gzip writer with ResponseFilterWriter - rw = NewResponseFilterWriter(c.ResponseFilters, gz) - } - - // Any response in forward middleware will now be compressed - status, err := g.Next.ServeHTTP(rw, r) - - // If there was an error that remained unhandled, we need - // to send something back before gzipWriter gets closed at - // the return of this method! - if status >= 400 { - httpserver.DefaultErrorFunc(w, r, status) - return 0, err - } - return status, err - } - - // no matching filter - return g.Next.ServeHTTP(w, r) -} - -// newWriter create a new Gzip Writer based on the compression level. -// If the level is valid (i.e. between 1 and 9), it uses the level. -// Otherwise, it uses default compression level. -func newWriter(c Config, w io.Writer) (*gzip.Writer, error) { - if c.Level >= gzip.BestSpeed && c.Level <= gzip.BestCompression { - return gzip.NewWriterLevel(w, c.Level) - } - return gzip.NewWriter(w), nil -} - -// gzipResponeWriter wraps the underlying Write method -// with a gzip.Writer to compress the output. -type gzipResponseWriter struct { - io.Writer - http.ResponseWriter - statusCodeWritten bool -} - -// WriteHeader wraps the underlying WriteHeader method to prevent -// problems with conflicting headers from proxied backends. For -// example, a backend system that calculates Content-Length would -// be wrong because it doesn't know it's being gzipped. -func (w *gzipResponseWriter) WriteHeader(code int) { - w.Header().Del("Content-Length") - w.Header().Set("Content-Encoding", "gzip") - w.Header().Add("Vary", "Accept-Encoding") - w.ResponseWriter.WriteHeader(code) - w.statusCodeWritten = true -} - -// Write wraps the underlying Write method to do compression. -func (w *gzipResponseWriter) Write(b []byte) (int, error) { - if w.Header().Get("Content-Type") == "" { - w.Header().Set("Content-Type", http.DetectContentType(b)) - } - if !w.statusCodeWritten { - w.WriteHeader(http.StatusOK) - } - n, err := w.Writer.Write(b) - return n, err -} - -// Hijack implements http.Hijacker. It simply wraps the underlying -// ResponseWriter's Hijack method if there is one, or returns an error. -func (w *gzipResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) { - if hj, ok := w.ResponseWriter.(http.Hijacker); ok { - return hj.Hijack() - } - return nil, nil, fmt.Errorf("not a Hijacker") -} - -// Flush implements http.Flusher. It simply wraps the underlying -// ResponseWriter's Flush method if there is one, or panics. -func (w *gzipResponseWriter) Flush() { - if f, ok := w.ResponseWriter.(http.Flusher); ok { - f.Flush() - } else { - panic("not a Flusher") // should be recovered at the beginning of middleware stack - } -} - -// CloseNotify implements http.CloseNotifier. -// It just inherits the underlying ResponseWriter's CloseNotify method. -func (w *gzipResponseWriter) CloseNotify() <-chan bool { - if cn, ok := w.ResponseWriter.(http.CloseNotifier); ok { - return cn.CloseNotify() - } - panic("not a CloseNotifier") -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip_test.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip_test.go deleted file mode 100644 index 738dff6..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/gzip_test.go +++ /dev/null @@ -1,122 +0,0 @@ -package gzip - -import ( - "fmt" - "io/ioutil" - "net/http" - "net/http/httptest" - "strings" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestGzipHandler(t *testing.T) { - pathFilter := PathFilter{make(Set)} - badPaths := []string{"/bad", "/nogzip", "/nongzip"} - for _, p := range badPaths { - pathFilter.IgnoredPaths.Add(p) - } - extFilter := ExtFilter{make(Set)} - for _, e := range []string{".txt", ".html", ".css", ".md"} { - extFilter.Exts.Add(e) - } - gz := Gzip{Configs: []Config{ - {RequestFilters: []RequestFilter{pathFilter, extFilter}}, - }} - - w := httptest.NewRecorder() - gz.Next = nextFunc(true) - var exts = []string{ - ".html", ".css", ".md", - } - for _, e := range exts { - url := "/file" + e - r, err := http.NewRequest("GET", url, nil) - if err != nil { - t.Error(err) - } - r.Header.Set("Accept-Encoding", "gzip") - _, err = gz.ServeHTTP(w, r) - if err != nil { - t.Error(err) - } - } - - w = httptest.NewRecorder() - gz.Next = nextFunc(false) - for _, p := range badPaths { - for _, e := range exts { - url := p + "/file" + e - r, err := http.NewRequest("GET", url, nil) - if err != nil { - t.Error(err) - } - r.Header.Set("Accept-Encoding", "gzip") - _, err = gz.ServeHTTP(w, r) - if err != nil { - t.Error(err) - } - } - } - - w = httptest.NewRecorder() - gz.Next = nextFunc(false) - exts = []string{ - ".htm1", ".abc", ".mdx", - } - for _, e := range exts { - url := "/file" + e - r, err := http.NewRequest("GET", url, nil) - if err != nil { - t.Error(err) - } - r.Header.Set("Accept-Encoding", "gzip") - _, err = gz.ServeHTTP(w, r) - if err != nil { - t.Error(err) - } - } -} - -func nextFunc(shouldGzip bool) httpserver.Handler { - return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - // write a relatively large text file - b, err := ioutil.ReadFile("testdata/test.txt") - if err != nil { - return 500, err - } - if _, err := w.Write(b); err != nil { - return 500, err - } - - if shouldGzip { - if r.Header.Get("Accept-Encoding") != "" { - return 0, fmt.Errorf("Accept-Encoding header not expected") - } - if w.Header().Get("Content-Encoding") != "gzip" { - return 0, fmt.Errorf("Content-Encoding must be gzip, found %v", r.Header.Get("Content-Encoding")) - } - if w.Header().Get("Vary") != "Accept-Encoding" { - return 0, fmt.Errorf("Vary must be Accept-Encoding, found %v", r.Header.Get("Vary")) - } - if _, ok := w.(*gzipResponseWriter); !ok { - return 0, fmt.Errorf("ResponseWriter should be gzipResponseWriter, found %T", w) - } - if strings.Contains(w.Header().Get("Content-Type"), "application/x-gzip") { - return 0, fmt.Errorf("Content type should not be gzip.") - } - return 0, nil - } - if r.Header.Get("Accept-Encoding") == "" { - return 0, fmt.Errorf("Accept-Encoding header expected") - } - if w.Header().Get("Content-Encoding") == "gzip" { - return 0, fmt.Errorf("Content-Encoding must not be gzip, found gzip") - } - if _, ok := w.(*gzipResponseWriter); ok { - return 0, fmt.Errorf("ResponseWriter should not be gzipResponseWriter") - } - return 0, nil - }) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter.go deleted file mode 100644 index 804232a..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter.go +++ /dev/null @@ -1,91 +0,0 @@ -package gzip - -import ( - "net/http" - "path" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// RequestFilter determines if a request should be gzipped. -type RequestFilter interface { - // ShouldCompress tells if gzip compression - // should be done on the request. - ShouldCompress(*http.Request) bool -} - -// defaultExtensions is the list of default extensions for which to enable gzipping. -var defaultExtensions = []string{"", ".txt", ".htm", ".html", ".css", ".php", ".js", ".json", - ".md", ".mdown", ".xml", ".svg", ".go", ".cgi", ".py", ".pl", ".aspx", ".asp"} - -// DefaultExtFilter creates an ExtFilter with default extensions. -func DefaultExtFilter() ExtFilter { - m := ExtFilter{Exts: make(Set)} - for _, extension := range defaultExtensions { - m.Exts.Add(extension) - } - return m -} - -// ExtFilter is RequestFilter for file name extensions. -type ExtFilter struct { - // Exts is the file name extensions to accept - Exts Set -} - -// ExtWildCard is the wildcard for extensions. -const ExtWildCard = "*" - -// ShouldCompress checks if the request file extension matches any -// of the registered extensions. It returns true if the extension is -// found and false otherwise. -func (e ExtFilter) ShouldCompress(r *http.Request) bool { - ext := path.Ext(r.URL.Path) - return e.Exts.Contains(ExtWildCard) || e.Exts.Contains(ext) -} - -// PathFilter is RequestFilter for request path. -type PathFilter struct { - // IgnoredPaths is the paths to ignore - IgnoredPaths Set -} - -// ShouldCompress checks if the request path matches any of the -// registered paths to ignore. It returns false if an ignored path -// is found and true otherwise. -func (p PathFilter) ShouldCompress(r *http.Request) bool { - return !p.IgnoredPaths.ContainsFunc(func(value string) bool { - return httpserver.Path(r.URL.Path).Matches(value) - }) -} - -// Set stores distinct strings. -type Set map[string]struct{} - -// Add adds an element to the set. -func (s Set) Add(value string) { - s[value] = struct{}{} -} - -// Remove removes an element from the set. -func (s Set) Remove(value string) { - delete(s, value) -} - -// Contains check if the set contains value. -func (s Set) Contains(value string) bool { - _, ok := s[value] - return ok -} - -// ContainsFunc is similar to Contains. It iterates all the -// elements in the set and passes each to f. It returns true -// on the first call to f that returns true and false otherwise. -func (s Set) ContainsFunc(f func(string) bool) bool { - for k := range s { - if f(k) { - return true - } - } - return false -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter_test.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter_test.go deleted file mode 100644 index ce31d7f..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/requestfilter_test.go +++ /dev/null @@ -1,113 +0,0 @@ -package gzip - -import ( - "net/http" - "testing" -) - -func TestSet(t *testing.T) { - set := make(Set) - set.Add("a") - if len(set) != 1 { - t.Errorf("Expected 1 found %v", len(set)) - } - set.Add("a") - if len(set) != 1 { - t.Errorf("Expected 1 found %v", len(set)) - } - set.Add("b") - if len(set) != 2 { - t.Errorf("Expected 2 found %v", len(set)) - } - if !set.Contains("a") { - t.Errorf("Set should contain a") - } - if !set.Contains("b") { - t.Errorf("Set should contain a") - } - set.Add("c") - if len(set) != 3 { - t.Errorf("Expected 3 found %v", len(set)) - } - if !set.Contains("c") { - t.Errorf("Set should contain c") - } - set.Remove("a") - if len(set) != 2 { - t.Errorf("Expected 2 found %v", len(set)) - } - if set.Contains("a") { - t.Errorf("Set should not contain a") - } - if !set.ContainsFunc(func(v string) bool { - return v == "c" - }) { - t.Errorf("ContainsFunc should return true") - } -} - -func TestExtFilter(t *testing.T) { - var filter RequestFilter = ExtFilter{make(Set)} - for _, e := range []string{".txt", ".html", ".css", ".md"} { - filter.(ExtFilter).Exts.Add(e) - } - r := urlRequest("file.txt") - if !filter.ShouldCompress(r) { - t.Errorf("Should be valid filter") - } - var exts = []string{ - ".html", ".css", ".md", - } - for i, e := range exts { - r := urlRequest("file" + e) - if !filter.ShouldCompress(r) { - t.Errorf("Test %v: Should be valid filter", i) - } - } - exts = []string{ - ".htm1", ".abc", ".mdx", - } - for i, e := range exts { - r := urlRequest("file" + e) - if filter.ShouldCompress(r) { - t.Errorf("Test %v: Should not be valid filter", i) - } - } - filter.(ExtFilter).Exts.Add(ExtWildCard) - for i, e := range exts { - r := urlRequest("file" + e) - if !filter.ShouldCompress(r) { - t.Errorf("Test %v: Should be valid filter. Wildcard used.", i) - } - } -} - -func TestPathFilter(t *testing.T) { - paths := []string{ - "/a", "/b", "/c", "/de", - } - var filter RequestFilter = PathFilter{make(Set)} - for _, p := range paths { - filter.(PathFilter).IgnoredPaths.Add(p) - } - for i, p := range paths { - r := urlRequest(p) - if filter.ShouldCompress(r) { - t.Errorf("Test %v: Should not be valid filter", i) - } - } - paths = []string{ - "/f", "/g", "/h", "/ed", - } - for i, p := range paths { - r := urlRequest(p) - if !filter.ShouldCompress(r) { - t.Errorf("Test %v: Should be valid filter", i) - } - } -} - -func urlRequest(url string) *http.Request { - r, _ := http.NewRequest("GET", url, nil) - return r -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter.go deleted file mode 100644 index 3039eb9..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter.go +++ /dev/null @@ -1,79 +0,0 @@ -package gzip - -import ( - "compress/gzip" - "net/http" - "strconv" -) - -// ResponseFilter determines if the response should be gzipped. -type ResponseFilter interface { - ShouldCompress(http.ResponseWriter) bool -} - -// LengthFilter is ResponseFilter for minimum content length. -type LengthFilter int64 - -// ShouldCompress returns if content length is greater than or -// equals to minimum length. -func (l LengthFilter) ShouldCompress(w http.ResponseWriter) bool { - contentLength := w.Header().Get("Content-Length") - length, err := strconv.ParseInt(contentLength, 10, 64) - if err != nil || length == 0 { - return false - } - return l != 0 && int64(l) <= length -} - -// ResponseFilterWriter validates ResponseFilters. It writes -// gzip compressed data if ResponseFilters are satisfied or -// uncompressed data otherwise. -type ResponseFilterWriter struct { - filters []ResponseFilter - shouldCompress bool - statusCodeWritten bool - *gzipResponseWriter -} - -// NewResponseFilterWriter creates and initializes a new ResponseFilterWriter. -func NewResponseFilterWriter(filters []ResponseFilter, gz *gzipResponseWriter) *ResponseFilterWriter { - return &ResponseFilterWriter{filters: filters, gzipResponseWriter: gz} -} - -// WriteHeader wraps underlying WriteHeader method and -// compresses if filters are satisfied. -func (r *ResponseFilterWriter) WriteHeader(code int) { - // Determine if compression should be used or not. - r.shouldCompress = true - for _, filter := range r.filters { - if !filter.ShouldCompress(r) { - r.shouldCompress = false - break - } - } - - if r.shouldCompress { - // replace discard writer with ResponseWriter - if gzWriter, ok := r.gzipResponseWriter.Writer.(*gzip.Writer); ok { - gzWriter.Reset(r.ResponseWriter) - } - // use gzip WriteHeader to include and delete - // necessary headers - r.gzipResponseWriter.WriteHeader(code) - } else { - r.ResponseWriter.WriteHeader(code) - } - r.statusCodeWritten = true -} - -// Write wraps underlying Write method and compresses if filters -// are satisfied -func (r *ResponseFilterWriter) Write(b []byte) (int, error) { - if !r.statusCodeWritten { - r.WriteHeader(http.StatusOK) - } - if r.shouldCompress { - return r.gzipResponseWriter.Write(b) - } - return r.ResponseWriter.Write(b) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter_test.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter_test.go deleted file mode 100644 index a34f58c..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/responsefilter_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package gzip - -import ( - "compress/gzip" - "fmt" - "net/http" - "net/http/httptest" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestLengthFilter(t *testing.T) { - var filters = []ResponseFilter{ - LengthFilter(100), - LengthFilter(1000), - LengthFilter(0), - } - - var tests = []struct { - length int64 - shouldCompress [3]bool - }{ - {20, [3]bool{false, false, false}}, - {50, [3]bool{false, false, false}}, - {100, [3]bool{true, false, false}}, - {500, [3]bool{true, false, false}}, - {1000, [3]bool{true, true, false}}, - {1500, [3]bool{true, true, false}}, - } - - for i, ts := range tests { - for j, filter := range filters { - r := httptest.NewRecorder() - r.Header().Set("Content-Length", fmt.Sprint(ts.length)) - wWriter := NewResponseFilterWriter([]ResponseFilter{filter}, &gzipResponseWriter{gzip.NewWriter(r), r, false}) - if filter.ShouldCompress(wWriter) != ts.shouldCompress[j] { - t.Errorf("Test %v: Expected %v found %v", i, ts.shouldCompress[j], filter.ShouldCompress(r)) - } - } - } -} - -func TestResponseFilterWriter(t *testing.T) { - tests := []struct { - body string - shouldCompress bool - }{ - {"Hello\t\t\t\n", false}, - {"Hello the \t\t\t world is\n\n\n great", true}, - {"Hello \t\t\nfrom gzip", true}, - {"Hello gzip\n", false}, - } - - filters := []ResponseFilter{ - LengthFilter(15), - } - - server := Gzip{Configs: []Config{ - {ResponseFilters: filters}, - }} - - for i, ts := range tests { - server.Next = httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - w.Header().Set("Content-Length", fmt.Sprint(len(ts.body))) - w.Write([]byte(ts.body)) - return 200, nil - }) - - r := urlRequest("/") - r.Header.Set("Accept-Encoding", "gzip") - - w := httptest.NewRecorder() - - server.ServeHTTP(w, r) - - resp := w.Body.String() - - if !ts.shouldCompress { - if resp != ts.body { - t.Errorf("Test %v: No compression expected, found %v", i, resp) - } - } else { - if resp == ts.body { - t.Errorf("Test %v: Compression expected, found %v", i, resp) - } - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/setup.go deleted file mode 100644 index 824ac21..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/setup.go +++ /dev/null @@ -1,119 +0,0 @@ -package gzip - -import ( - "fmt" - "strconv" - "strings" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// setup configures a new gzip middleware instance. -func setup(c *caddy.Controller) error { - configs, err := gzipParse(c) - if err != nil { - return err - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Gzip{Next: next, Configs: configs} - }) - - return nil -} - -func gzipParse(c *caddy.Controller) ([]Config, error) { - var configs []Config - - for c.Next() { - config := Config{} - - // Request Filters - pathFilter := PathFilter{IgnoredPaths: make(Set)} - extFilter := ExtFilter{Exts: make(Set)} - - // Response Filters - lengthFilter := LengthFilter(0) - - // No extra args expected - if len(c.RemainingArgs()) > 0 { - return configs, c.ArgErr() - } - - for c.NextBlock() { - switch c.Val() { - case "ext": - exts := c.RemainingArgs() - if len(exts) == 0 { - return configs, c.ArgErr() - } - for _, e := range exts { - if !strings.HasPrefix(e, ".") && e != ExtWildCard && e != "" { - return configs, fmt.Errorf(`gzip: invalid extension "%v" (must start with dot)`, e) - } - extFilter.Exts.Add(e) - } - case "not": - paths := c.RemainingArgs() - if len(paths) == 0 { - return configs, c.ArgErr() - } - for _, p := range paths { - if p == "/" { - return configs, fmt.Errorf(`gzip: cannot exclude path "/" - remove directive entirely instead`) - } - if !strings.HasPrefix(p, "/") { - return configs, fmt.Errorf(`gzip: invalid path "%v" (must start with /)`, p) - } - pathFilter.IgnoredPaths.Add(p) - } - case "level": - if !c.NextArg() { - return configs, c.ArgErr() - } - level, _ := strconv.Atoi(c.Val()) - config.Level = level - case "min_length": - if !c.NextArg() { - return configs, c.ArgErr() - } - length, err := strconv.ParseInt(c.Val(), 10, 64) - if err != nil { - return configs, err - } else if length == 0 { - return configs, fmt.Errorf(`gzip: min_length must be greater than 0`) - } - lengthFilter = LengthFilter(length) - default: - return configs, c.ArgErr() - } - } - - // Request Filters - config.RequestFilters = []RequestFilter{} - - // If ignored paths are specified, put in front to filter with path first - if len(pathFilter.IgnoredPaths) > 0 { - config.RequestFilters = []RequestFilter{pathFilter} - } - - // Then, if extensions are specified, use those to filter. - // Otherwise, use default extensions filter. - if len(extFilter.Exts) > 0 { - config.RequestFilters = append(config.RequestFilters, extFilter) - } else { - config.RequestFilters = append(config.RequestFilters, DefaultExtFilter()) - } - - // Response Filters - // If min_length is specified, use it. - if int64(lengthFilter) != 0 { - config.ResponseFilters = append(config.ResponseFilters, lengthFilter) - } - - configs = append(configs, config) - } - - return configs, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/gzip/setup_test.go deleted file mode 100644 index a71c9b1..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/setup_test.go +++ /dev/null @@ -1,100 +0,0 @@ -package gzip - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`gzip`)) - if err != nil { - t.Errorf("Expected no errors, but got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if mids == nil { - t.Fatal("Expected middleware, was nil instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Gzip) - if !ok { - t.Fatalf("Expected handler to be type Gzip, got: %#v", handler) - } - - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } - - tests := []struct { - input string - shouldErr bool - }{ - {`gzip {`, true}, - {`gzip {}`, true}, - {`gzip a b`, true}, - {`gzip a {`, true}, - {`gzip { not f } `, true}, - {`gzip { not } `, true}, - {`gzip { not /file - ext .html - level 1 - } `, false}, - {`gzip { level 9 } `, false}, - {`gzip { ext } `, true}, - {`gzip { ext /f - } `, true}, - {`gzip { not /file - ext .html - level 1 - } - gzip`, false}, - {`gzip { - ext "" - }`, false}, - {`gzip { not /file - ext .html - level 1 - } - gzip { not /file1 - ext .htm - level 3 - } - `, false}, - {`gzip { not /file - ext .html - level 1 - } - gzip { not /file1 - ext .htm - level 3 - } - `, false}, - {`gzip { not /file - ext * - level 1 - } - `, false}, - {`gzip { not /file - ext * - level 1 - min_length ab - } - `, true}, - {`gzip { not /file - ext * - level 1 - min_length 1000 - } - `, false}, - } - for i, test := range tests { - _, err := gzipParse(caddy.NewTestController(test.input)) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/gzip/testdata/test.txt b/vendor/github.com/mholt/caddy/caddyhttp/gzip/testdata/test.txt deleted file mode 100644 index e710a2f..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/gzip/testdata/test.txt +++ /dev/null @@ -1,199 +0,0 @@ -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus mattis, dolor et feugiat suscipit, nisi urna consectetur enim, et porta libero dui eget dolor. Sed ac enim aliquet, ornare ipsum a, aliquet augue. Fusce faucibus id mi at porta. Donec scelerisque consectetur rutrum. In aliquam est vel quam molestie porttitor. Sed eget nunc blandit, commodo dui ac, tempus mi. Nulla ac est ac leo hendrerit rhoncus. Etiam id finibus neque. In ultrices diam orci, eu tempor neque bibendum sed. Fusce facilisis mauris in finibus elementum. Pellentesque tristique bibendum diam, nec molestie velit facilisis quis. Nulla facilisi. Morbi nec velit eget massa blandit consequat sed hendrerit velit. Ut euismod elit sit amet dui venenatis, a luctus tortor vestibulum. - -Aliquam consequat rutrum sagittis. Donec eros felis, ultricies quis elementum nec, consequat et ex. Nullam feugiat eu sapien nec mollis. Quisque porttitor tortor ipsum, quis aliquam diam tincidunt a. Praesent tortor lorem, finibus sit amet tempor ac, iaculis et nunc. Duis enim justo, gravida in pharetra id, rhoncus id nisi. Maecenas dui risus, accumsan ut nisi vitae, placerat dignissim risus. Quisque orci lectus, sodales a lacus sit amet, bibendum gravida odio. Duis consectetur, ante et vulputate convallis, augue augue mollis ligula, sed tincidunt nunc ligula vel enim. Donec faucibus pulvinar consectetur. Nam laoreet, dolor ac elementum vestibulum, eros justo fringilla leo, pretium fringilla sem nunc non sem. Proin at nisl eget leo hendrerit lacinia. - -Aliquam id lacus mauris. Morbi et justo urna. Vestibulum venenatis pharetra lectus in pharetra. Fusce feugiat nisl nec enim rutrum finibus. Etiam a nunc metus. Phasellus non dignissim eros, non feugiat quam. Nunc velit ante, commodo at ex eu, fringilla semper tellus. - -Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam rhoncus ultricies nisl, id vestibulum dolor eleifend id. Quisque condimentum condimentum nisi, at dapibus sapien pharetra ut. Suspendisse a sodales odio, sit amet facilisis risus. Vestibulum varius pretium pellentesque. Nunc sit amet sollicitudin sapien, eu finibus mi. Aenean justo arcu, ornare id massa et, auctor dictum dui. Morbi et aliquet velit. - -Curabitur leo ligula, congue non tincidunt vel, consectetur at erat. In scelerisque orci in cursus molestie. Duis erat erat, vehicula sed sollicitudin eget, suscipit in erat. Quisque sed quam in ante dictum hendrerit. Aenean elementum mattis ipsum, sollicitudin luctus felis. Duis fringilla varius mattis. Integer dapibus efficitur blandit. - -Vivamus placerat enim vel est feugiat, cursus pretium ante aliquam. Curabitur hendrerit iaculis odio, in tristique nisl rutrum non. Aenean varius luctus ipsum quis interdum. Nam suscipit purus et lacus accumsan, a rutrum turpis mattis. Sed non bibendum mi. Pellentesque pulvinar ligula eget massa feugiat pharetra. Sed malesuada sem metus, sit amet feugiat purus pretium vel. Fusce magna est, fermentum vitae mauris vel, elementum pharetra est. In blandit faucibus tortor in elementum. Maecenas vitae ornare dui, quis commodo orci. Pellentesque sed scelerisque dolor. Aliquam eget libero in risus tempor efficitur vitae sit amet libero. Sed sed eros dapibus, consectetur mauris eget, auctor mauris. - -Quisque sed efficitur dui. Suspendisse tempor maximus varius. Vivamus tristique volutpat orci, sed placerat ligula condimentum in. Aliquam sodales mi interdum diam semper pulvinar. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vestibulum faucibus facilisis leo, eget suscipit urna luctus nec. Integer posuere gravida nibh in imperdiet. Nunc ultrices in lorem vel volutpat. Morbi laoreet augue id dapibus porta. Pellentesque ac convallis lectus. Proin placerat lorem sed lacus blandit rhoncus. - -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam mattis in nunc id scelerisque. Donec et elit ac odio blandit euismod. Mauris enim risus, fermentum ac accumsan in, rhoncus sed erat. Donec sed laoreet eros. In ut purus sed nunc consequat pretium sit amet in nibh. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aenean at semper nisl. Quisque vel lectus ut felis pellentesque imperdiet. - -Maecenas eget lacinia mi. Vivamus eget sollicitudin tortor. Pellentesque molestie, massa in bibendum ultrices, nunc mauris finibus ex, non porttitor enim leo ac dolor. Vivamus dapibus nisl dui, sit amet convallis ipsum dictum ac. Nulla facilisi. Curabitur laoreet auctor sapien, at porttitor urna scelerisque sit amet. Ut placerat neque congue vulputate ullamcorper. Nunc ut sem tristique, volutpat sem at, commodo augue. Ut facilisis pulvinar vestibulum. - -Duis volutpat eros laoreet, fringilla nulla eu, congue lorem. Fusce vestibulum bibendum ornare. Donec venenatis nisi at augue suscipit, vel cursus massa bibendum. Fusce facilisis nisl ut volutpat tempus. Fusce porttitor ante mauris, et bibendum sapien tincidunt non. In rhoncus tincidunt fermentum. Morbi id venenatis nunc. Maecenas blandit suscipit porta. Proin porttitor molestie nibh. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; - -Phasellus sed nulla nisi. Proin mollis hendrerit felis, ultricies sollicitudin mi semper eget. Fusce at neque at justo vehicula rhoncus a gravida lectus. Cras tristique eget arcu nec fringilla. Nam sit amet dolor mollis, fermentum lorem at, faucibus erat. Morbi eu urna laoreet, faucibus purus et, accumsan neque. Maecenas eget velit lorem. Sed eu est elementum, sagittis elit id, scelerisque elit. Nunc elementum fermentum sem, id viverra mauris viverra at. Sed molestie mi sed velit vestibulum, sit amet porttitor tellus dictum. Fusce rhoncus felis et molestie iaculis. Cras ornare eget urna non pulvinar. Pellentesque ultricies leo quis dignissim sollicitudin. Nunc elit mi, bibendum eu tellus quis, pellentesque dapibus erat. - -Morbi blandit sit amet sem sed fringilla. Ut quis augue egestas, pharetra sapien at, tincidunt neque. Aliquam sodales, justo et tincidunt posuere, nunc lacus tincidunt lectus, non iaculis sem arcu nec diam. Nullam lobortis lorem at quam euismod, non elementum eros vulputate. Vivamus gravida non libero ac tristique. Morbi sit amet lectus elementum, malesuada diam a, pharetra odio. Phasellus non erat ipsum. Phasellus ullamcorper feugiat nunc, ut porta mauris feugiat eu. Ut egestas ligula dolor, ac mollis massa rhoncus at. Donec maximus pulvinar est non eleifend. Quisque vulputate turpis sed ligula accumsan tincidunt. Cras tortor augue, aliquam sed pretium vel, semper sit amet nisi. Pellentesque gravida dapibus libero porta viverra. Donec lacinia, ante et porta mollis, lorem est feugiat odio, vitae sollicitudin augue ipsum ac mi. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. - -Phasellus non mauris consequat, congue metus at, sodales quam. Phasellus imperdiet et elit quis rhoncus. Phasellus aliquet euismod ligula quis elementum. Etiam sed nibh arcu. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed enim sem, pulvinar quis elit non, dignissim rhoncus mi. Quisque vitae ullamcorper enim, vitae varius lacus. Nunc hendrerit augue quis volutpat bibendum. Nulla ultricies justo sit amet lorem dignissim interdum. Duis congue, mauris vel posuere ornare, lacus justo accumsan ex, a malesuada arcu orci sit amet risus. Sed at nisl non massa sollicitudin convallis at in erat. Ut imperdiet, eros at hendrerit maximus, lacus orci molestie dolor, vitae aliquam ligula lacus eget mi. Sed massa purus, sagittis sed sollicitudin nec, condimentum eget metus. Sed commodo nunc in nibh auctor, a pellentesque nisl pretium. Vivamus ac ex sit amet libero posuere malesuada. Interdum et malesuada fames ac ante ipsum primis in faucibus. - -Praesent molestie est et pulvinar placerat. Sed tincidunt sapien eu justo vulputate rutrum. Donec vel ultrices erat. Morbi quis rhoncus metus. Cras pellentesque augue quis auctor eleifend. Suspendisse quis commodo quam. Etiam dapibus metus nec tortor pharetra lobortis. Quisque pharetra lectus ac velit commodo, nec blandit nisl viverra. Pellentesque aliquet tincidunt molestie. Vestibulum ullamcorper, eros eu posuere varius, metus enim rutrum elit, quis fringilla orci tellus at odio. Ut malesuada, justo vitae lobortis porta, nisi magna dictum metus, sed porta arcu turpis vitae tortor. Morbi in elit sapien. - -Maecenas quis feugiat augue. Integer sollicitudin dolor sit amet mi dictum, non consequat turpis scelerisque. Aliquam erat volutpat. Aliquam venenatis mollis orci, nec sollicitudin elit convallis quis. Vivamus varius, libero a sagittis lobortis, massa massa suscipit neque, lacinia lacinia ante justo non massa. Quisque ut erat ac purus euismod consequat. Phasellus malesuada elementum ipsum sed rutrum. Vivamus scelerisque erat vel nisl tempus euismod id eget arcu. - -Ut fermentum dapibus finibus. Praesent aliquam magna tellus, et pulvinar ipsum dignissim volutpat. Ut mollis diam eros, lacinia euismod lectus venenatis in. Sed lobortis eros massa, at vulputate ipsum hendrerit ac. Aenean id commodo sapien, id suscipit metus. Ut fringilla quam laoreet posuere pretium. Donec vel dapibus nibh. Donec non neque felis. Sed consequat efficitur semper. In ac porta mi. Fusce non elit urna. Aenean pharetra urna laoreet enim malesuada, vitae feugiat nibh molestie. Nam varius porta arcu non convallis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Etiam tempus ex et quam accumsan sodales. Aliquam eget metus ac est accumsan ultrices. - -Nullam eleifend mauris ac maximus scelerisque. Integer nec sapien massa. Ut laoreet, nibh non egestas congue, enim metus mollis mi, sit amet sodales dolor diam sed augue. Vestibulum dignissim metus at felis faucibus faucibus. Pellentesque molestie nisi viverra quam tincidunt, ut molestie est feugiat. Sed nulla tortor, gravida quis varius sed, commodo sit amet arcu. Curabitur viverra, lacus at placerat vestibulum, ligula orci semper ipsum, et mollis mi erat a ligula. Pellentesque ornare urna eu lorem blandit vestibulum. Mauris quis rutrum justo. Vivamus non sollicitudin odio. Curabitur ornare ante vitae justo mollis efficitur. - -Suspendisse interdum bibendum lobortis. Etiam commodo gravida sollicitudin. Curabitur interdum vel nisi a auctor. Nunc varius dui in aliquam porttitor. Nam consequat mi enim, sed tempor eros scelerisque eu. Proin auctor, enim nec imperdiet mollis, dui magna blandit tellus, non elementum orci lorem vitae odio. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec laoreet cursus risus. Curabitur porta massa vitae lorem posuere, non tristique mauris lacinia. Ut ligula nisl, pulvinar eget ligula eu, suscipit hendrerit ligula. - -Maecenas elementum justo quis odio vestibulum ullamcorper. Quisque commodo non odio quis vehicula. Ut vel ornare erat. Duis quis tristique tellus. Suspendisse dignissim aliquet purus sed consectetur. Cras in sollicitudin lectus. Donec posuere venenatis efficitur. Nullam ac pellentesque mi. - -Etiam malesuada ut tellus nec sodales. Cras malesuada eu arcu quis tincidunt. Sed consequat malesuada eleifend. Aenean accumsan vel ligula efficitur elementum. Sed elementum sapien nec magna iaculis pharetra. Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed in augue sit amet sem malesuada facilisis at ac risus. Aliquam aliquam dignissim mauris vel pharetra. In hac habitasse platea dictumst. Phasellus varius risus id urna pretium, fermentum tristique lorem condimentum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vestibulum tincidunt eu dolor at vehicula. Proin pulvinar ex non gravida venenatis. Donec lacinia, ipsum in congue hendrerit, risus turpis elementum elit, eget tempor purus lorem ut sapien. Maecenas dapibus eros eget viverra imperdiet. Donec ullamcorper nulla hendrerit molestie rutrum. - -Duis maximus molestie pellentesque. Duis mattis hendrerit dolor, et vulputate turpis pretium ut. Aliquam porta elit in pretium faucibus. Vivamus tortor nunc, elementum nec cursus facilisis, consequat ac elit. Suspendisse porttitor lobortis sollicitudin. Curabitur auctor velit ac gravida feugiat. Praesent convallis tempor nulla, id sodales eros ullamcorper eget. Praesent blandit massa quis placerat molestie. Integer elementum lacinia fermentum. Phasellus ullamcorper mattis finibus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur diam quam, egestas nec arcu vitae, efficitur pellentesque nisl. Curabitur a dui vitae metus vehicula condimentum vel sit amet dolor. Vestibulum vehicula dictum semper. Sed vitae aliquet odio. - -Etiam quis purus molestie, finibus nisi aliquam, venenatis nunc. Phasellus tempor id erat sed mattis. Praesent at facilisis diam. In tortor turpis, eleifend vitae facilisis sit amet, ultrices ut nibh. Cras placerat mollis risus, nec accumsan massa aliquam eu. Aliquam erat volutpat. Aliquam tincidunt, leo in laoreet viverra, metus sapien convallis justo, ut pellentesque massa est sit amet ligula. Suspendisse et arcu justo. Quisque at luctus urna. Vestibulum elit eros, dapibus at faucibus sit amet, dapibus a sem. Donec nec mi pulvinar, luctus nisi quis, sollicitudin mauris. Phasellus id velit a enim vehicula eleifend. - -Sed volutpat vel eros sit amet efficitur. Nullam ut neque lobortis, rutrum dui at, blandit massa. Vivamus quis commodo mi. Praesent ultrices lacinia consectetur. Phasellus nec imperdiet augue, eget eleifend arcu. Morbi viverra a sapien vel eleifend. Pellentesque in volutpat sapien. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Pellentesque facilisis metus a nulla fermentum sollicitudin. Nam hendrerit risus eget purus bibendum ultricies eu commodo leo. Nulla placerat feugiat massa nec efficitur. Nam quis mattis erat, vel porta ex. - -Fusce ullamcorper nibh velit. Praesent porttitor dignissim eros, nec fermentum tellus pellentesque sit amet. Suspendisse potenti. Suspendisse eget quam in lorem sollicitudin porttitor sed a arcu. Cras eget ligula venenatis, posuere sem ac, semper leo. Nam dictum ipsum at leo convallis finibus. Nam a lorem consectetur, ullamcorper nulla ut, posuere sapien. Quisque quis vulputate enim, sit amet consectetur tellus. Integer in massa sed diam mattis imperdiet non a velit. Maecenas consectetur posuere erat, sed cursus dui pretium sed. Etiam at pellentesque mi. Aliquam pharetra rutrum rhoncus. - -Proin finibus luctus leo, at iaculis arcu. Pellentesque ullamcorper ligula sapien, quis tempor velit bibendum ac. Fusce vestibulum posuere purus, quis efficitur diam venenatis quis. Sed posuere arcu ut diam varius laoreet. Integer non eros id odio finibus eleifend. Mauris vulputate arcu non sem placerat, vel sodales dolor accumsan. Phasellus felis elit, viverra nec congue ac, pretium in ante. Fusce ut ex eu massa rutrum dictum id sit amet lectus. Duis venenatis ligula erat, eu congue enim gravida suscipit. Pellentesque luctus eget sem eu luctus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean dignissim suscipit hendrerit. - -Vivamus vel dui ac leo maximus efficitur eget iaculis nisl. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent et elit ultrices, aliquet diam sed, placerat lorem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed lectus ex, elementum pretium sem nec, tincidunt tincidunt felis. Ut viverra neque mi, vitae convallis dolor tempor vel. Nam eleifend non erat id cursus. - -In euismod scelerisque auctor. Fusce ligula nunc, dictum non euismod nec, ultricies eget sapien. Fusce ultrices in ipsum non vehicula. Nunc a elit a mauris dapibus ullamcorper quis ac neque. Integer vel commodo eros, nec tincidunt mi. Maecenas mi augue, congue a condimentum a, gravida non tellus. Pellentesque tortor eros, fermentum in nunc non, placerat cursus tortor. Donec malesuada eleifend sem, ac consectetur neque ultricies dictum. - -Pellentesque mattis nulla sed bibendum viverra. Phasellus maximus dolor justo, et aliquam felis ultricies vel. Curabitur aliquet pulvinar elit vitae pulvinar. Praesent sed gravida turpis. Praesent ipsum ipsum, lacinia nec bibendum in, sagittis id felis. Donec nibh neque, aliquet non porttitor vitae, maximus id urna. Pellentesque est libero, placerat in libero et, cursus consectetur felis. - -Donec eget ipsum eu nisl aliquam pharetra. Suspendisse consequat enim mi, lacinia ullamcorper nisi vulputate id. Aliquam finibus ligula tortor, eget varius erat convallis a. Donec sollicitudin rutrum rutrum. Aenean mollis lacinia dictum. Morbi ac tempus arcu, sit amet auctor nunc. Nulla sed est dignissim, dictum sem vitae, tincidunt dolor. Pellentesque nunc ipsum, semper quis eros ut, luctus hendrerit velit. Maecenas risus ipsum, posuere et molestie id, tempor a elit. Etiam aliquam turpis sit amet accumsan vestibulum. Curabitur consectetur erat vel magna sodales, sit amet aliquet metus scelerisque. Proin pretium lacus in commodo efficitur. Pellentesque congue aliquam neque at imperdiet. Suspendisse faucibus, ex quis varius consectetur, sem magna congue ligula, sed fringilla urna ligula a libero. Nullam ut sapien at erat ullamcorper venenatis sit amet eu mauris. - -Praesent ante massa, laoreet eu tortor ut, molestie tristique risus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Curabitur fermentum vulputate mauris eget sodales. Nunc eleifend leo ac dui efficitur, sit amet volutpat enim semper. Morbi lorem diam, dictum nec felis sed, lobortis tempor nunc. Curabitur dapibus volutpat arcu, eget lacinia ipsum ultricies sed. Fusce hendrerit erat nunc, nec tempus risus pulvinar in. Suspendisse fringilla sagittis ante vel molestie. Suspendisse vulputate sagittis congue. Quisque gravida metus sit amet risus rutrum bibendum. Nullam id ex risus. Aliquam erat volutpat. Nunc vitae tellus id purus scelerisque efficitur. Quisque nulla dui, tempor sed sollicitudin vitae, hendrerit dapibus enim. Nullam tincidunt non est ut lobortis. - -Nunc molestie nisi non vestibulum maximus. Phasellus tincidunt maximus fringilla. Donec justo sem, viverra vel ligula in, ullamcorper mattis odio. Duis commodo urna nec pharetra mollis. Sed vehicula metus et nibh laoreet congue. In tincidunt, metus sit amet pulvinar placerat, arcu quam vestibulum lorem, vel efficitur elit mi at dui. Etiam id congue urna, sit amet tincidunt tellus. Vestibulum euismod magna eget orci semper, in placerat quam congue. Suspendisse eget turpis quis sapien imperdiet sollicitudin. Nullam sodales gravida justo at iaculis. Nunc iaculis leo at orci viverra, in facilisis neque ultricies. Integer gravida neque ut ex sodales posuere. Nullam odio mauris, consectetur ut ultrices eget, porttitor eu tortor. Proin ut risus quis erat tristique ornare non ut est. Nulla dignissim sed ipsum ut sagittis. Curabitur facilisis mattis nunc eget molestie. - -Nam ultrices vitae velit sollicitudin volutpat. Aenean sagittis diam aliquet pretium imperdiet. Donec ultricies nisl a nisi porttitor iaculis. Donec quis tempus purus, in suscipit nibh. Nulla dignissim tristique vulputate. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Praesent egestas sit amet enim at porttitor. Vivamus nec tortor lobortis mauris tempus varius non sed ante. Praesent lorem nisl, blandit ac rutrum at, faucibus eu sem. Nunc arcu nulla, mollis nec eros eget, hendrerit cursus ex. Praesent ut pretium dolor. Vestibulum varius sapien et eleifend commodo. Fusce auctor ut orci a consectetur. Praesent condimentum sit amet elit sit amet sollicitudin. - -In luctus, diam eu ultrices maximus, urna nibh ullamcorper orci, id tempor nibh arcu eu mauris. Phasellus lacus nunc, fringilla eu turpis sed, pharetra ultricies diam. Etiam nisi enim, sagittis et erat non, finibus rhoncus ex. Cras maximus ullamcorper magna, vel tempor lacus venenatis quis. Vivamus fringilla tincidunt purus et maximus. Quisque commodo ullamcorper tellus, eget accumsan massa maximus nec. Curabitur in imperdiet mi. Proin lorem est, pellentesque quis hendrerit at, condimentum non mi. Nulla id ante placerat, dapibus metus nec, hendrerit justo. Praesent pretium, est quis eleifend aliquam, nunc odio convallis mi, vitae dapibus enim sem quis quam. Nulla facilisi. - -Quisque ornare, erat non egestas vulputate, odio massa consequat ex, nec convallis ligula dui at urna. Pellentesque lacinia, est a ornare facilisis, mi leo malesuada nunc, sed tristique ex augue sed magna. Mauris imperdiet pharetra blandit. Etiam eget nisl id massa elementum imperdiet. Nullam tortor leo, volutpat ac nulla id, feugiat pulvinar eros. Pellentesque tempus bibendum felis et luctus. Duis non imperdiet nibh. Sed blandit ex a odio feugiat maximus. Maecenas elementum odio sit amet purus fermentum, ut mattis enim maximus. Proin efficitur lectus enim, nec fringilla velit pharetra quis. Aliquam ligula massa, tincidunt venenatis dolor sit amet, condimentum suscipit nisi. Cras a velit mi. Curabitur id ligula vestibulum, semper erat ut, tincidunt lacus. Nunc egestas urna et velit hendrerit, eu posuere libero sollicitudin. Suspendisse vitae fringilla nunc. Aenean eros ipsum, scelerisque at laoreet sed, mollis vel eros. - -Proin ac placerat nulla. Proin sollicitudin eget dolor eu luctus. Maecenas sit amet ante volutpat, molestie metus sit amet, tempus justo. Cras tellus odio, accumsan vitae urna eget, tempor eleifend turpis. Nulla venenatis posuere lacus congue convallis. Fusce suscipit egestas aliquet. Vivamus condimentum massa eget lacinia finibus. Morbi vitae leo ut eros consequat dapibus. - -Sed vel arcu a lorem posuere placerat in quis purus. Aliquam dapibus libero dui. Etiam in ex diam. Morbi nec nibh ut purus posuere euismod. Sed lobortis neque mauris, ac efficitur arcu venenatis ac. Donec orci purus, accumsan cursus ligula eu, mollis fermentum metus. Donec placerat diam et lorem dignissim, vel varius odio sagittis. Suspendisse potenti. Nam et erat facilisis ex maximus ultricies. Sed non magna nec turpis malesuada vulputate ac in massa. - -Cras ac dignissim purus, quis vehicula tortor. Maecenas vulputate, nisl vel egestas dignissim, nibh elit commodo elit, et maximus elit est vel massa. Vestibulum fermentum, dolor sed pellentesque scelerisque, ligula mauris lacinia lorem, ac commodo elit turpis rhoncus velit. Donec a enim in metus eleifend pharetra et ac elit. Morbi sed pellentesque leo. Nullam fringilla ultricies ante, nec pellentesque massa convallis nec. Maecenas elementum, mi a congue ullamcorper, arcu enim hendrerit enim, vitae fermentum sapien tellus ac sem. Nunc et tempus est. Aliquam lacinia, quam non tempor consequat, lorem lectus mollis nisl, id tempor nisl turpis eu purus. Sed eget maximus diam, convallis hendrerit neque. - -Donec venenatis odio ipsum, in consectetur dui tristique sit amet. Duis placerat neque nec lorem laoreet, et fermentum sapien rutrum. Quisque et diam odio. Phasellus ultrices nibh nec dolor laoreet fringilla. Nulla facilisi. Curabitur pretium erat quam, id facilisis nunc euismod ac. Duis condimentum risus ut vestibulum dapibus. Suspendisse lorem nunc, aliquet quis commodo eu, sagittis a neque. In sodales augue mattis odio sagittis scelerisque. Sed sem purus, commodo nec ornare non, dapibus id enim. - -Mauris urna nisl, consectetur vitae blandit a, posuere a dui. Praesent ut nisl accumsan, vehicula erat a, mattis ligula. Nam metus neque, blandit vel diam a, finibus sagittis orci. Sed metus lorem, congue in tincidunt quis, varius ut lectus. In ultrices augue nec sem bibendum ultricies. Cras a tellus at est gravida tempor vel id risus. Nullam erat nulla, fringilla nec nunc sit amet, placerat ultricies turpis. Sed interdum mi vitae ullamcorper posuere. Proin eu faucibus urna. Mauris maximus, quam a accumsan commodo, justo diam mollis nunc, ac laoreet lacus magna quis nisl. Quisque tincidunt lacus ipsum, ut sagittis elit mattis in. Donec elementum vitae purus ut tristique. Fusce lobortis orci ante, ut bibendum risus imperdiet at. - -Donec dignissim tristique tincidunt. Sed vitae felis justo. Curabitur tincidunt, enim non finibus luctus, elit nunc consectetur libero, sit amet tincidunt odio purus eget quam. Nam tincidunt id metus malesuada feugiat. Vivamus metus quam, posuere quis quam sollicitudin, tincidunt placerat nisi. Aenean nec enim elementum, varius augue id, iaculis urna. Mauris nec risus eu arcu elementum tristique. Nullam ultrices diam eget lorem porta iaculis. Donec fringilla nibh mi, vel auctor enim maximus sed. Vestibulum metus erat, sollicitudin nec pharetra at, sodales vel tellus. - -Phasellus sed erat ac velit faucibus semper ut ut justo. Proin commodo porttitor magna dapibus rutrum. Maecenas placerat neque ac aliquet maximus. Praesent rutrum, felis quis venenatis placerat, tortor ligula porta ipsum, eu dapibus mi urna eget nisl. Proin ultrices vitae ipsum non tristique. Donec convallis massa metus, id mollis felis sollicitudin eu. Nulla gravida nunc id dui bibendum blandit. Suspendisse ut venenatis quam, vitae tempus massa. Quisque tincidunt mi eget erat congue, ac volutpat nunc posuere. Aenean aliquet eros id sapien rhoncus, ac hendrerit urna tincidunt. Morbi vitae euismod nisl, ut accumsan diam. Sed ultricies, tellus nec mollis rhoncus, lacus tellus feugiat est, eu ullamcorper arcu eros nec nulla. - -Donec pretium arcu eget justo efficitur mollis. Vivamus id arcu sit amet mauris congue vulputate sit amet in tellus. Vivamus commodo est libero, et vulputate lorem convallis in. Donec cursus arcu et nibh congue porta. Suspendisse laoreet neque sit amet magna ultrices, consequat scelerisque velit fermentum. Curabitur faucibus lorem faucibus, condimentum sem id, volutpat velit. Donec sed odio dolor. Fusce sodales ligula sit amet pretium hendrerit. - -Mauris ultrices vehicula metus, sed finibus lectus tristique et. Morbi id egestas lacus. Nulla volutpat, lectus et molestie elementum, urna nulla semper massa, at feugiat enim magna quis lacus. Phasellus vitae erat vitae turpis mattis tempus et sed dui. Ut vitae cursus orci. Etiam in massa lectus. Donec purus augue, bibendum sit amet feugiat et, lacinia vitae velit. - -Nulla ac enim tempus, accumsan nunc quis, malesuada quam. Etiam cursus nisi ut aliquam dapibus. Ut vulputate pulvinar ante, id condimentum dui euismod a. Maecenas arcu velit, ornare in nibh eu, feugiat volutpat augue. Duis a diam vitae orci tristique auctor id auctor nisi. Curabitur tincidunt, leo viverra elementum auctor, mi ex efficitur libero, vel aliquet eros mauris sed odio. Nulla consectetur, metus non ullamcorper rutrum, quam eros egestas lacus, vitae luctus odio neque hendrerit nulla. Suspendisse ullamcorper orci massa, non pretium libero dignissim id. Aenean scelerisque justo sapien, quis convallis augue dapibus ut. Aenean ut tincidunt justo. Aenean a lacus lectus. - -Interdum et malesuada fames ac ante ipsum primis in faucibus. Sed sit amet magna eleifend, dictum risus non, dictum turpis. Nam ut quam malesuada, accumsan magna rhoncus, malesuada arcu. In id egestas purus. Nunc nec arcu vel elit vulputate dignissim accumsan sed quam. Suspendisse lacinia ex mattis mi ornare, et maximus ex rhoncus. Morbi ac posuere ligula, eu imperdiet mi. Fusce a dapibus turpis. Duis vel odio elementum, laoreet ipsum sit amet, blandit tellus. Vestibulum eleifend condimentum enim, fermentum vehicula nisi tincidunt nec. Aenean at maximus ante. Maecenas iaculis enim ac tortor feugiat, ac ultricies metus mollis. Nam posuere et turpis vitae egestas. - -Proin vitae eros vel quam tristique ullamcorper. In nec feugiat diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean dui elit, dictum sit amet mi non, dignissim laoreet nisi. Nulla eget congue ipsum. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Duis vitae libero sed nulla sagittis placerat nec sed lorem. Phasellus accumsan suscipit nunc a ultricies. Sed dapibus et elit a hendrerit. Ut fermentum quis velit vel dignissim. Etiam vel odio justo. In aliquet eros ut ultrices imperdiet. Aliquam erat volutpat. Phasellus quis dolor aliquam, lacinia mauris ut, blandit elit. Proin risus ipsum, laoreet nec gravida ut, condimentum at nisl. - -Nam eu ipsum vel sem semper consectetur porttitor ut sem. Pellentesque ac leo ultricies, ornare risus pulvinar, elementum ipsum. Maecenas a turpis et lorem auctor sagittis. Pellentesque porttitor eu erat non maximus. Duis tristique in orci sed facilisis. Nulla orci justo, facilisis eu libero et, consequat varius lectus. Fusce quis quam et mauris tristique condimentum at vitae urna. Proin tristique ex ut mauris eleifend, sed dapibus felis semper. Aenean placerat sollicitudin sollicitudin. Ut elementum tincidunt neque in feugiat. Aliquam rhoncus ligula id hendrerit dapibus. Nulla ac ex dolor. Phasellus ex nisi, viverra sit amet faucibus nec, malesuada nec nisl. Aliquam erat volutpat. Ut consequat egestas odio, pretium ullamcorper massa viverra at. - -Pellentesque blandit sit amet est a auctor. Nullam et arcu et risus tempus eleifend. Nunc tristique lectus est, quis rutrum magna sagittis eget. Etiam iaculis tellus eget metus laoreet faucibus vel vel nisi. Fusce et posuere enim. Morbi nec interdum nisl. Donec diam est, semper vel hendrerit at, rutrum sed eros. Nunc eu dapibus sem, eget ultricies elit. Nam condimentum ex pharetra turpis ornare, at pretium orci vehicula. Proin in tristique est, eu mollis ante. Sed tortor nisl, tincidunt et maximus quis, porta vitae elit. Quisque bibendum condimentum sodales. Vivamus fermentum posuere molestie. Morbi pharetra elit eget turpis vulputate, eget laoreet metus rutrum. - -Suspendisse at diam ac nisl vestibulum facilisis. Quisque non sollicitudin urna, sed lacinia tortor. Duis ultrices ut mauris at aliquet. Vestibulum eu mauris dapibus, dictum nibh rhoncus, bibendum magna. Suspendisse rutrum ligula eu posuere efficitur. Nullam in egestas arcu. Proin a urna ac felis tempor sagittis egestas nec tortor. Donec ac feugiat leo. Ut ac tempor sapien, ac lacinia dolor. In placerat sagittis libero, sit amet varius massa auctor sit amet. Fusce pellentesque finibus odio vel scelerisque. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Vivamus euismod nisi nisi, ac luctus sapien venenatis nec. - -Quisque sit amet metus et turpis laoreet pulvinar. Sed at accumsan ex. Aliquam eu tempus odio. Fusce consectetur dolor ut magna fringilla venenatis. Pellentesque rhoncus libero elementum, placerat eros et, laoreet eros. Nulla sit amet ligula viverra, aliquam felis accumsan, blandit eros. Vestibulum porta volutpat magna vel malesuada. - -Duis semper aliquam nisi, vel finibus tellus pretium mollis. Vivamus nec libero vitae neque blandit finibus. Aliquam maximus, libero ut tristique cursus, magna risus placerat dui, sit amet semper odio metus vel mauris. Aenean porta ut nisi in aliquet. Vivamus in felis eu odio porttitor finibus. Phasellus placerat urna non leo congue, at placerat magna volutpat. Etiam ut fermentum ligula. Sed nunc lectus, posuere et tellus sed, rutrum pulvinar ex. Nulla ullamcorper at mauris at efficitur. Vivamus ultrices, odio sit amet congue porttitor, purus ante mattis justo, quis dapibus sem tellus sit amet dui. Morbi nec neque efficitur, scelerisque erat in, posuere diam. Nam faucibus nunc eget condimentum pulvinar. Praesent rutrum nisi et mauris fermentum sagittis. Cras imperdiet elit in eros mollis, ut pulvinar lacus tincidunt. - -Vestibulum vel convallis ante. Duis et varius nibh. Praesent sodales purus at efficitur lacinia. In eget lacus odio. Vivamus eros nisi, lobortis non quam et, sollicitudin congue nulla. Pellentesque vestibulum turpis non purus pharetra egestas. Quisque accumsan vestibulum fermentum. Nam eu hendrerit neque. Proin ut aliquet lorem, id suscipit massa. Sed volutpat viverra magna, vel faucibus felis convallis in. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras a hendrerit odio, ac facilisis purus. - -Nam a nulla ultricies tellus porttitor feugiat. Morbi et urna suscipit, accumsan massa id, semper nisl. Nam eros nibh, eleifend semper erat vitae, vehicula cursus mauris. Nam semper pulvinar augue eu auctor. Morbi eget laoreet magna. Proin porta, nulla egestas commodo ultrices, risus felis efficitur eros, et mollis augue nisl in neque. Nullam dignissim dui eget tellus gravida, non congue nisl elementum. Nulla ac eros hendrerit, sollicitudin mauris vitae, tristique turpis. Maecenas id laoreet erat. - -Nullam vestibulum in felis euismod aliquam. Sed sit amet magna in mauris feugiat scelerisque et fermentum lorem. Aenean scelerisque eget mauris vel molestie. Sed vel ipsum non magna eleifend tristique. Phasellus viverra nulla justo, sed maximus neque sollicitudin hendrerit. Mauris facilisis sem vel elit mattis iaculis. Vivamus ac dapibus sem. Sed quis egestas sapien, eu volutpat augue. Vestibulum molestie suscipit est, ut fermentum diam rhoncus eu. Maecenas accumsan massa sed sapien viverra commodo. Duis eget lacus a urna accumsan mattis at sed orci. Aenean at scelerisque felis. Sed magna lectus, lacinia eu pharetra ac, pharetra at ex. Vestibulum vel tortor a sem luctus placerat. Maecenas efficitur, est sed auctor vehicula, ante lorem finibus dolor, tristique efficitur lacus risus eget ex. Pellentesque maximus velit eu ipsum lobortis blandit. - -Maecenas aliquam sollicitudin tellus, consequat ultricies lacus. Proin pretium nibh fermentum, malesuada quam sit amet, luctus orci. Curabitur sodales varius tortor, eu rutrum nisi blandit eu. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Quisque nec lectus quis nisi mattis dapibus. Donec dapibus leo ac nibh elementum pharetra. Aliquam lobortis ante a risus facilisis condimentum. Sed mauris enim, tristique sed viverra eu, varius vel lorem. Vivamus non ex mi. Etiam sed pellentesque ante. Ut leo ipsum, mattis a eleifend sed, tincidunt pharetra nibh. Nam vel tellus nunc. - -Nullam libero urna, euismod at consequat quis, fringilla eu turpis. Aliquam tellus leo, posuere elementum risus vel, pulvinar tincidunt quam. Interdum et malesuada fames ac ante ipsum primis in faucibus. Ut non nibh id massa bibendum porta a sed ante. Donec commodo accumsan orci, quis volutpat sem tincidunt id. Nulla mollis, lacus id pretium cursus, nisi nulla rhoncus quam, non maximus leo ligula consequat metus. In fringilla et est quis tristique. Nullam vestibulum urna leo, non molestie ipsum dignissim at. Donec tristique erat vitae interdum gravida. Vestibulum tincidunt nec nunc eget blandit. Vestibulum at laoreet arcu, sed ultrices orci. Nam vitae sapien bibendum, aliquam massa quis, convallis mauris. Morbi eu mi ultrices, aliquam tortor sit amet, elementum diam. Sed pulvinar lorem eget urna consequat consectetur. Integer hendrerit tortor quis ipsum suscipit, eget vulputate neque semper. Duis pulvinar hendrerit nisi sed pretium. - -Ut imperdiet tempor convallis. Nullam vehicula sem id ligula hendrerit consectetur. Nunc a ornare justo. Donec elementum eros id mi sagittis, sit amet consectetur nisi semper. Maecenas varius gravida turpis, quis dapibus ex consectetur sed. Cras tortor neque, lacinia et neque scelerisque, hendrerit semper est. In ultricies blandit nisl ut finibus. - -In sapien ante, euismod non molestie vel, venenatis eu tortor. Pellentesque nec tortor sed ante posuere faucibus. Morbi sed euismod urna, vel dictum neque. Aenean ultrices in eros a lobortis. Suspendisse lacinia est eu lacus porttitor ornare. Donec vitae sapien diam. Integer vitae pellentesque ex. Maecenas iaculis purus id felis hendrerit suscipit vitae non tortor. Pellentesque rhoncus facilisis orci, at ultrices nibh egestas nec. - -Quisque eu quam eros. Nam venenatis pharetra augue. Donec ut mauris maximus, rutrum nulla id, dignissim purus. Curabitur nec sem id risus mollis bibendum nec sit amet ipsum. Nam dignissim hendrerit ullamcorper. Suspendisse eu risus scelerisque, dapibus nibh vitae, pellentesque eros. Proin finibus sapien id cursus consequat. Quisque augue mi, imperdiet vitae dignissim eget, lacinia id lectus. Etiam at augue non lectus iaculis fermentum vel in arcu. Suspendisse et nunc sodales, auctor arcu in, faucibus est. Ut quis neque vitae leo placerat luctus sed quis velit. Suspendisse vehicula, erat vel dictum posuere, ligula sapien tristique velit, vel tincidunt orci leo at enim. Quisque non ullamcorper lectus. - -Aliquam dapibus mattis purus eu euismod. Maecenas sagittis mi quis tellus sodales hendrerit. Phasellus at sem egestas, condimentum purus in, cursus quam. Praesent nec suscipit diam, at laoreet ex. Suspendisse cursus lectus eu erat convallis accumsan et nec orci. Pellentesque finibus hendrerit tellus, at rutrum enim rhoncus eget. Etiam id hendrerit nulla. Phasellus tempus urna a lorem ullamcorper accumsan. Proin sit amet orci ante. - -Aenean pulvinar sem quis ligula dignissim tincidunt. Maecenas eu odio ut tortor venenatis elementum. Aenean a purus nunc. Suspendisse ut hendrerit elit. Phasellus ac lectus in tellus ullamcorper tincidunt. Aliquam ac pellentesque leo. Nam dignissim semper quam a efficitur. Suspendisse finibus pretium risus non lacinia. Phasellus consectetur porta pellentesque. Integer ac facilisis libero. Quisque pellentesque imperdiet tortor. Fusce porta mi nec consequat sagittis. Aliquam turpis sem, finibus ut tellus at, efficitur tincidunt velit. Nullam vitae diam sit amet quam malesuada lacinia. - -Proin in hendrerit nisi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Aenean elementum tortor libero, ac volutpat eros euismod quis. Ut malesuada convallis tortor a consectetur. Curabitur urna sem, consectetur in elit at, mollis dictum elit. Nulla rhoncus libero id purus fermentum faucibus. Curabitur finibus auctor suscipit. Ut sed molestie elit. In ut sem non sapien varius commodo. Duis nec facilisis erat. Donec sollicitudin mollis ex, in dapibus erat commodo eget. Vestibulum lorem sapien, consequat sed commodo ac, maximus vitae nunc. Pellentesque interdum interdum nulla, id facilisis magna viverra at. Donec porttitor ante id congue dignissim. Aliquam dignissim eget diam pellentesque accumsan. - -Donec a efficitur neque. Integer iaculis sit amet augue sed pharetra. Nulla dignissim dolor a orci maximus ullamcorper. Morbi varius enim ut posuere molestie. Donec volutpat magna ut suscipit interdum. Cras magna dolor, rutrum eget nisi quis, ornare fringilla libero. Nullam tempor tempor erat eget condimentum. Vivamus egestas ex ac tellus finibus maximus. Donec eget vehicula purus, a venenatis neque. Duis mollis quam sit amet lectus ullamcorper tempus. Etiam eget sapien in orci porta pharetra. Phasellus et viverra dolor, vitae placerat urna. Nullam vel porttitor tellus. Aenean dictum imperdiet lobortis. - -Suspendisse auctor metus ut aliquam ullamcorper. Morbi ac aliquet massa, a porta lorem. Etiam luctus dignissim erat. Etiam eu mi eu nisi convallis bibendum vel a nisi. Aenean condimentum enim et magna placerat, dictum aliquet tellus bibendum. Nam interdum mauris at facilisis porta. Morbi sodales sollicitudin tempus. - -Nam quis aliquam tellus. Vestibulum placerat nisi eget tempus egestas. Etiam congue diam ut leo blandit fermentum. Curabitur eu dui quis mauris sodales imperdiet ac ac urna. Integer at nisl cursus, suscipit odio vel, consequat neque. Suspendisse in lectus turpis. Nullam dui odio, tempus ut feugiat at, suscipit a justo. Phasellus mauris augue, aliquet efficitur cursus eu, finibus sit amet ipsum. Vestibulum urna mauris, mollis sit amet ex at, cursus imperdiet nulla. Donec velit justo, viverra et erat in, hendrerit hendrerit turpis. Proin pharetra nunc aliquam neque congue eleifend. - -Praesent vel egestas metus. Sed dui mi, laoreet a euismod ac, ullamcorper in orci. Aenean eu risus pulvinar, aliquet ex ac, ornare ex. Mauris lectus purus, placerat ut lacus ac, pellentesque sollicitudin sem. Proin sed volutpat sapien. Ut posuere ex ac odio eleifend, ac ultrices ligula ultricies. Vestibulum nec nunc a leo volutpat convallis eget vel turpis. Suspendisse ut dapibus enim, at scelerisque ligula. Mauris vestibulum nec tellus a porta. Quisque ac placerat sapien, nec maximus nunc. Vivamus mollis tincidunt risus in auctor. In laoreet elit et eleifend facilisis. Integer facilisis tortor quam, sed tristique purus mattis id. Etiam faucibus leo augue. - -Sed tristique efficitur nulla, et rutrum mauris euismod non. Praesent ac leo luctus dui rutrum dictum a vel ipsum. Vestibulum faucibus risus vitae imperdiet rhoncus. Nunc volutpat viverra nisl. Nunc sit amet urna sed purus iaculis egestas. Nam pretium dui eget ante ullamcorper tempus. Pellentesque gravida, dui non cursus tempus, nisl lorem viverra diam, in condimentum metus neque eu justo. In malesuada tortor sagittis posuere finibus. Nunc ac nisi lacus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Proin nec nibh nec orci sagittis venenatis sed et justo. Vestibulum et nisl vitae ex mattis efficitur. Interdum et malesuada fames ac ante ipsum primis in faucibus. - -Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Suspendisse hendrerit nibh nec ex consequat tempor. Suspendisse vestibulum urna in blandit iaculis. Aenean lacinia odio ex, eget tempor nulla condimentum sed. Proin suscipit, est eget sollicitudin feugiat, nisl felis ultrices massa, non finibus justo risus quis lectus. Mauris ipsum tellus, suscipit nec gravida sed, aliquet non sem. Ut suscipit sodales ante, vitae feugiat quam scelerisque in. Curabitur id luctus dui, eget interdum dui. Maecenas sagittis quis nisi et laoreet. Cras maximus in leo et feugiat. Proin aliquam egestas consequat. Suspendisse sit amet arcu auctor eros imperdiet rhoncus sed in lorem. Sed porttitor at elit laoreet mattis. Donec dui eros, dictum sit amet massa at, facilisis consequat nisi. Phasellus arcu est, viverra vel lacus id, efficitur sodales ligula. - -Nam ultrices dignissim mi vel vestibulum. Mauris a euismod lorem, in scelerisque enim. Pellentesque molestie fermentum purus, nec semper nunc placerat sit amet. Aenean ullamcorper sollicitudin faucibus. Curabitur a hendrerit leo. Donec congue massa nulla, vitae sodales ex posuere non. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Cras pharetra risus eu consequat commodo. Donec iaculis lorem vitae diam mollis feugiat. - -Nulla molestie dui quis blandit pretium. Curabitur et tempus nisi. Aliquam luctus interdum libero a varius. Morbi nec volutpat odio. Quisque elementum velit vitae mi hendrerit, nec aliquet arcu tempus. Aenean ullamcorper, tortor sit amet rutrum dapibus, metus dui sagittis nisl, id volutpat velit lorem sodales erat. Quisque vel justo sed massa rutrum accumsan eget non elit. Fusce luctus felis mi, id aliquet massa commodo sit amet. Morbi blandit et est ac faucibus. Quisque eget malesuada nibh, sit amet venenatis purus. Proin risus eros, ullamcorper nec posuere a, hendrerit eu dolor. Nunc a mattis dolor. Fusce ultricies arcu eu lectus consequat elementum. Phasellus euismod nunc sapien, eget lobortis urna efficitur vitae. Phasellus sed ligula rhoncus, imperdiet neque eget, luctus est. Praesent aliquam aliquet turpis, quis ornare lacus sagittis ut. - -Quisque rhoncus velit in suscipit commodo. Donec massa turpis, posuere ut vulputate vitae, ultrices gravida velit. Aenean lectus nulla, hendrerit vitae laoreet imperdiet, ultrices a ipsum. Morbi a tincidunt odio, et lacinia nisi. In in pulvinar nibh. Vestibulum vehicula tellus quis est mollis efficitur. Maecenas non pellentesque dui, et sagittis erat. Sed sed diam blandit diam convallis euismod sit amet sit amet arcu. - -Proin ullamcorper maximus suscipit. Aenean non volutpat quam. Vivamus ex justo, aliquam vitae vulputate eu, porttitor ut leo. Sed lorem mauris, finibus in feugiat sit amet, tincidunt ac risus. Duis accumsan lectus at purus dapibus ultricies. Ut ac sagittis velit. In vel enim eu neque imperdiet interdum eget eget massa. Aliquam varius sagittis pulvinar. Etiam fermentum sit amet mi finibus tempor. Aliquam varius risus erat, ac commodo sapien euismod et. Proin pretium mattis turpis et aliquet. Suspendisse facilisis ut mi ut maximus. Donec dictum dapibus feugiat. - -Proin tempor diam vestibulum odio elementum aliquam. Integer nunc urna, dictum id tortor eget, efficitur accumsan elit. Quisque lobortis ante ac mollis dignissim. Integer vel nunc rutrum, malesuada metus a, vestibulum neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec ac erat ut mi fermentum consequat. Praesent tempor, erat id porttitor tempor, erat mauris semper massa, ac vulputate lacus justo ac ligula. Sed ligula neque, tincidunt ut tortor sed, volutpat sollicitudin diam. Pellentesque ligula purus, volutpat nec velit non, vulputate euismod arcu. Aenean quis purus volutpat, placerat sem vitae, sollicitudin nunc. Cras laoreet semper ipsum quis finibus. Fusce pellentesque purus at nibh mattis, et consequat dui viverra. Proin eu tellus sit amet sapien volutpat dictum. Curabitur luctus feugiat massa ac vehicula. Nullam eu lacus tempus, hendrerit lectus ac, posuere odio. Donec eu dui metus. - -Quisque molestie turpis eget dolor iaculis cursus. Suspendisse facilisis tristique enim at efficitur. Quisque sit amet nunc nisl. Nam placerat interdum fringilla. Aliquam vulputate, risus et euismod vulputate, ante dolor consequat odio, at finibus diam ante quis sem. Nulla accumsan quam id neque aliquam maximus. Proin sed convallis eros. Phasellus imperdiet in quam a ultrices. Fusce et imperdiet elit. Sed et hendrerit ipsum. Fusce arcu odio, rutrum vitae posuere vitae, facilisis lacinia nibh. - -Fusce nec tincidunt sem. Morbi tempus, nisi quis malesuada ornare, turpis neque condimentum justo, bibendum bibendum justo ex eu nulla. Pellentesque laoreet tincidunt dolor nec venenatis. Morbi eros risus, venenatis ac luctus ut, luctus quis sapien. Etiam et tellus massa. Aenean sit amet libero massa. Fusce venenatis elit vitae tellus commodo hendrerit. Curabitur ipsum tellus, dignissim nec lacus non, suscipit efficitur magna. - -Integer et erat tortor. Ut elementum pharetra scelerisque. Pellentesque mollis, urna quis faucibus cursus, arcu orci mattis lorem, varius maximus magna justo quis massa. Donec id scelerisque metus. Fusce sit amet ex a lectus ornare mollis. Donec ut metus nisl. Sed at turpis turpis. Suspendisse ut nibh nunc. Duis eget viverra nisi. - -In massa velit, ultricies sit amet elementum vel, sollicitudin ac tellus. Ut euismod nisl non leo porta varius. Phasellus sapien velit, auctor quis pulvinar nec, venenatis in urna. Aliquam elementum, eros vitae dignissim condimentum, enim lacus suscipit nibh, eget imperdiet nibh metus ac arcu. Quisque condimentum, ligula in luctus pharetra, elit tortor lacinia neque, et aliquam ex velit sed ipsum. Maecenas convallis ante odio, finibus egestas dolor porta non. Nunc fringilla erat diam, nec lobortis est scelerisque eget. Cras dictum lectus rhoncus, rhoncus dui at, bibendum risus. Aenean eget tristique nunc. Etiam eget elementum urna. Nulla facilisi. - -Aliquam porta magna id est fermentum, sit amet iaculis mi viverra. Nullam pharetra, ex non ultricies fringilla, dui ligula cursus ipsum, vitae iaculis eros quam vel sem. Sed lacinia vestibulum tellus at sodales. Quisque vulputate, quam eu porta convallis, lectus lacus viverra metus, quis tincidunt augue libero nec tellus. Curabitur et fermentum turpis. Praesent urna neque, fermentum ac magna vitae, convallis fermentum enim. Nam ut nulla at dui viverra faucibus vel at justo. Praesent feugiat commodo ante et dictum. Nullam quis gravida diam. Curabitur nec nisl ac elit luctus bibendum a sed augue. Mauris nec dolor eget eros ullamcorper condimentum. - -In leo mauris, sagittis id rhoncus vel, aliquet non augue. Pellentesque ornare vitae nibh luctus pulvinar. Proin eu lacinia neque, ut faucibus lorem. Curabitur quis justo porttitor, tincidunt mauris id, porta turpis. Sed id leo elit. Morbi auctor nisi eget augue feugiat consequat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed ut purus felis. - -Ut pretium, purus eget ultricies condimentum, diam quam finibus lacus, non scelerisque leo nisi at arcu. Vestibulum consectetur quam ac dapibus dignissim. Cras et lacus sit amet nisl sodales dignissim non eu tortor. Nam ultrices enim quam, vitae lobortis est varius in. Sed tincidunt tincidunt eros eget semper. Etiam accumsan efficitur suscipit. Donec at facilisis purus, et egestas ex. Vivamus dapibus iaculis sapien. Sed fermentum dui sit amet est blandit scelerisque non vitae neque. Vivamus a placerat ex. Mauris feugiat ultrices turpis, id luctus nulla rhoncus mattis. Curabitur accumsan eleifend ligula id viverra. - -Aliquam molestie maximus nisl, vitae fermentum odio hendrerit quis. Fusce varius quis velit at sagittis. Morbi eu magna aliquet, scelerisque risus sit amet, sollicitudin ante. Mauris scelerisque pellentesque lacinia. Duis quis ligula nec mauris pretium lacinia. Nulla imperdiet lorem est, nec laoreet ante commodo et. Suspendisse et sollicitudin turpis, ut luctus nibh. - -Ut id libero nec purus condimentum pharetra eget ac mauris. Vivamus finibus dignissim lacus, at porta leo sodales sit amet. Nunc augue leo, eleifend eu ultricies eget, posuere et tellus. Maecenas porta, nibh in rutrum semper, ex eros fringilla nisl, eu ultricies sem nunc sit amet magna. Aenean nec pharetra odio. Pellentesque quis diam quam. Fusce tincidunt justo enim, in condimentum erat euismod id. Etiam varius dui ut turpis placerat efficitur non id nulla. Nunc in velit magna. Sed posuere enim enim, sed semper urna auctor at. Nam scelerisque, est sed accumsan convallis, ipsum ligula imperdiet purus, eget malesuada urna nisi at nisl. Donec massa purus, venenatis at ex in, lobortis porttitor erat. In hac habitasse platea dictumst. - -Mauris varius mattis fringilla. Ut pretium leo turpis. Etiam nec scelerisque sem. Donec velit elit, suscipit in dolor scelerisque, sagittis dignissim justo. Morbi egestas sit amet turpis vitae elementum. Integer maximus justo ac elit tempus faucibus. Donec consequat elementum dui consequat lobortis. Etiam eget est nec nibh pulvinar maximus. Integer egestas pulvinar leo vitae luctus. Nullam enim justo, vestibulum ac bibendum et, pharetra eleifend mauris. In ut ligula nec risus eleifend blandit. - -Mauris sagittis arcu quis magna pulvinar, quis interdum leo semper. Aenean viverra turpis eget erat molestie, sit amet malesuada ipsum maximus. Duis eros metus, consequat vel metus quis, ullamcorper ullamcorper tortor. Duis condimentum, metus non molestie mollis, ante augue eleifend elit, nec porttitor nunc ex id purus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nullam nisi velit, placerat et dictum sed, vulputate et mauris. Sed bibendum porttitor tellus vel vehicula. - -Nam non gravida sapien, et euismod nulla. Pellentesque dapibus tristique lectus, sed finibus turpis accumsan ut. Pellentesque ultricies diam eu felis iaculis, vitae egestas nulla tempus. Ut pharetra, sem ac feugiat lobortis, ex nisl congue libero, vel pellentesque leo nibh eu elit. Etiam vehicula non metus at ornare. Aliquam orci leo, eleifend a fermentum condimentum, eleifend at lectus. Ut sit amet iaculis elit. Nullam molestie mattis leo a aliquet. Vestibulum convallis commodo rhoncus. Vestibulum at eros leo. Nam tempus urna sit amet nunc sagittis blandit. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam condimentum, felis sit amet ultricies consectetur, velit ex ultrices ipsum, sit amet condimentum enim dui pulvinar risus. Vivamus euismod a quam et sagittis. Fusce posuere at sem non egestas. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. - -Maecenas urna felis, condimentum vitae pretium vel, consequat id ligula. Proin eget ante eget tellus luctus maximus vitae sit amet libero. Donec at risus eget tellus feugiat vulputate. Aliquam laoreet sapien at pellentesque vehicula. In egestas laoreet lobortis. Duis ultrices molestie urna sit amet dapibus. Fusce ultricies mauris lectus, in luctus est facilisis sit amet. Nunc sed faucibus orci. Fusce fringilla est a dictum commodo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam aliquam lacus a eros tincidunt maximus. - -Aenean vestibulum, metus vel interdum lacinia, libero metus consectetur tellus, non sollicitudin ante ipsum ut velit. Donec accumsan laoreet justo hendrerit venenatis. Mauris hendrerit tincidunt diam eu accumsan. Suspendisse egestas non orci at vulputate. Praesent sollicitudin congue magna egestas aliquet. Mauris at molestie mi. Mauris vel magna viverra, mattis velit at, fringilla elit. Cras porta lorem leo, ut tincidunt velit pharetra non. - -Praesent commodo turpis et ligula vulputate, non ullamcorper ante faucibus. Phasellus cursus magna quis est mollis, id suscipit libero mattis. Nam felis lectus, accumsan vitae sollicitudin eu, facilisis nec velit. Nam sollicitudin odio ut sapien vulputate, quis commodo diam convallis. Aliquam fringilla est quis lacus elementum lobortis. Mauris pulvinar enim justo, ut sollicitudin eros pulvinar sit amet. Sed lobortis vestibulum eleifend. Morbi at mattis elit. In sit amet porttitor lacus, eget pharetra sapien. Proin elit metus, varius in dictum sed, ornare vel odio. - -Suspendisse luctus viverra mollis. Vivamus est ante, egestas nec dignissim egestas, varius a libero. Phasellus id lacinia tellus. Sed pellentesque porttitor rutrum. Duis a mi sollicitudin, mollis purus et, fermentum ante. Nullam non metus et lacus vehicula ultricies eget non risus. Aenean ipsum dui, venenatis ut leo sed, ultricies volutpat tellus. Praesent consectetur id felis maximus suscipit. Nulla vel ipsum vel massa convallis ornare a vel felis. Aliquam convallis vestibulum ante. - -Quisque eu pretium libero. Morbi volutpat velit ut est finibus, eu condimentum dui tristique. Cras dignissim tempus risus id gravida. Donec vitae lorem dolor. Aliquam et cursus lorem. Sed molestie dui nibh, et bibendum turpis elementum quis. Nunc consequat diam et tortor consectetur, eget sollicitudin urna mollis. - -Cras vel est posuere ipsum viverra mollis. In lacus elit, interdum eget pretium non, dictum vitae dolor. Nulla arcu neque, sollicitudin varius iaculis in, gravida id justo. Phasellus ut condimentum justo. Aenean consectetur vitae sem quis rhoncus. Nam id nulla sit amet mauris ultricies bibendum et vitae quam. Mauris blandit metus in egestas egestas. Aenean erat ligula, consectetur nec elementum in, elementum quis quam. Quisque est arcu, auctor sed est eget, bibendum tristique mauris. Aliquam a varius purus, sit amet faucibus augue. Vestibulum a mattis lacus. Mauris eleifend, tortor sit amet fermentum lobortis, libero risus feugiat erat, sodales imperdiet magna nibh ut elit. In porta sapien urna, eget viverra magna egestas ut. Aliquam ac eleifend ligula. Morbi dignissim magna id varius pulvinar. Ut pulvinar commodo placerat. - -In iaculis tortor id molestie scelerisque. Quisque congue tristique nisi bibendum efficitur. Proin rutrum ultrices tincidunt. Praesent faucibus, mauris in dictum tincidunt, quam ligula suscipit nisi, nec efficitur ligula mi sit amet purus. Donec porta, velit convallis elementum posuere, sem nibh ornare dui, eget semper purus erat dictum diam. Mauris congue eros tellus, eget bibendum purus blandit sit amet. Sed faucibus ipsum vel velit maximus, vitae lobortis lectus luctus. Morbi tempor lacus sit amet hendrerit auctor. Aliquam auctor maximus laoreet. Nulla viverra massa eu tortor porta molestie. Fusce quis nisi arcu. Duis sit amet vestibulum quam, in posuere nunc. Nulla non placerat tortor. Curabitur malesuada eget metus ac auctor. Interdum et malesuada fames ac ante ipsum primis in faucibus. - -Donec bibendum libero nisl, eu varius est imperdiet id. Morbi sed arcu rhoncus, maximus libero eleifend, facilisis lacus. Sed sollicitudin, odio suscipit congue malesuada, justo magna finibus mauris, sed faucibus ipsum ligula ac augue. Sed sodales nulla mauris, efficitur bibendum sapien sagittis sit amet. Fusce consectetur justo diam, eu consequat nunc lacinia at. Curabitur ex ante, tempus at elementum non, maximus id lacus. Pellentesque in urna turpis. Proin tristique consequat lacus tincidunt faucibus. Proin ac tortor metus. Maecenas mollis blandit arcu, sit amet aliquam mauris laoreet sit amet. Nullam vulputate erat ac magna convallis efficitur. Proin cursus sodales est non suscipit. Nunc commodo lorem aliquet, commodo felis sit amet, dapibus orci. Nulla a enim vel ex facilisis laoreet. Donec malesuada laoreet turpis vel interdum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. - -Donec venenatis lectus eu tortor lobortis cursus. Quisque sit amet scelerisque quam, quis imperdiet ex. Morbi lacus purus, interdum non fringilla ut, ornare eget nisl. Morbi eleifend justo magna. Ut rutrum, nisl quis ultrices euismod, ligula arcu auctor quam, vel mattis ipsum lectus sit amet felis. Pellentesque vitae sagittis lorem. Morbi blandit finibus purus, quis commodo velit ultrices venenatis. Pellentesque eu erat enim. Fusce sollicitudin nunc nisi, non viverra neque aliquet at. - -Curabitur bibendum vel augue eget viverra. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Phasellus id hendrerit quam, id tempor ex. Fusce quis sem dapibus, ornare leo ut, fringilla metus. Praesent molestie posuere scelerisque. Praesent ut libero vitae nisi iaculis venenatis maximus in leo. Donec sed ipsum massa. Aenean id purus tellus. - -Maecenas varius pharetra dignissim. Nulla iaculis in elit a facilisis. Nam ipsum enim, tristique nec feugiat ut, tristique vel felis. Donec tincidunt suscipit justo, at dictum ante sollicitudin sed. Mauris nisi ipsum, faucibus id sollicitudin at, consequat eu nibh. Duis lorem lectus, vestibulum vel eros eget, efficitur semper ligula. Quisque tristique tortor eu eros fringilla scelerisque. Aenean nisl nisi, mollis non dolor in, sagittis blandit metus. Cras tellus turpis, volutpat in varius non, semper eget magna. Pellentesque finibus augue id fringilla cursus. - -Fusce id est elit. Aliquam sit amet nunc finibus mi consectetur hendrerit in sit amet leo. Nunc posuere lectus ut est pellentesque, eu mollis tortor efficitur. Aliquam tincidunt placerat mauris non aliquam. Sed finibus dapibus tortor, sit amet fringilla libero tincidunt ut. Morbi at lectus volutpat, congue turpis sit amet, dignissim quam. Sed suscipit dolor vel nibh facilisis porta. Donec ut purus a leo volutpat pellentesque. - -Mauris vitae ipsum bibendum, interdum metus nec, pharetra purus. Nulla facilisi. Donec dolor ligula, iaculis vitae tempor quis, euismod non tortor. Phasellus condimentum accumsan augue, vel hendrerit nisi dictum id. Nullam eget ante sit amet turpis tempus finibus. Morbi a dolor sollicitudin, sollicitudin sem a, placerat massa. Aenean consectetur elit non aliquet lacinia. Maecenas lobortis ex turpis, vel sollicitudin dolor elementum in. Sed sit amet facilisis elit. Duis iaculis faucibus ante, ac bibendum ex placerat id. Nulla facilisi. Praesent sollicitudin ut velit at interdum. Nulla viverra volutpat lorem. Sed mattis gravida auctor. Nam pharetra erat id convallis luctus. Vestibulum congue est lorem, eget fermentum magna consequat eu. - -Sed ac luctus lectus, egestas gravida lorem. Suspendisse a tortor et velit mattis efficitur. Integer ornare accumsan justo nec molestie. Donec leo nunc, ultrices a consequat ut, bibendum at nisl. Mauris varius sem ac malesuada pharetra. Quisque bibendum diam at interdum molestie. Mauris ac ante sapien. Integer ultricies vitae justo eu dictum. Nulla facilisi. Etiam aliquet tellus id dignissim pharetra. - -Nam sed nibh ex. Phasellus faucibus ante sapien, sit amet tristique elit posuere mattis. Proin porta vitae enim sed auctor. Vestibulum quis ex euismod, imperdiet ante iaculis, vehicula mi. Vivamus convallis augue pellentesque commodo bibendum. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Integer gravida vitae leo vel varius. Aenean porta vehicula lorem, vitae commodo turpis sagittis eu. Aenean mattis elit et mi sagittis vulputate. Morbi vitae nisi quis mauris malesuada scelerisque. Morbi id efficitur quam. Ut id elit quam. Fusce at nisi fringilla, pharetra diam ut, suscipit erat. \ No newline at end of file diff --git a/vendor/github.com/mholt/caddy/caddyhttp/header/header.go b/vendor/github.com/mholt/caddy/caddyhttp/header/header.go deleted file mode 100644 index c51199d..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/header/header.go +++ /dev/null @@ -1,51 +0,0 @@ -// Package header provides middleware that appends headers to -// requests based on a set of configuration rules that define -// which routes receive which headers. -package header - -import ( - "net/http" - "strings" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Headers is middleware that adds headers to the responses -// for requests matching a certain path. -type Headers struct { - Next httpserver.Handler - Rules []Rule -} - -// ServeHTTP implements the httpserver.Handler interface and serves requests, -// setting headers on the response according to the configured rules. -func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - replacer := httpserver.NewReplacer(r, nil, "") - for _, rule := range h.Rules { - if httpserver.Path(r.URL.Path).Matches(rule.Path) { - for _, header := range rule.Headers { - if strings.HasPrefix(header.Name, "-") { - w.Header().Del(strings.TrimLeft(header.Name, "-")) - } else { - w.Header().Set(header.Name, replacer.Replace(header.Value)) - } - } - } - } - return h.Next.ServeHTTP(w, r) -} - -type ( - // Rule groups a slice of HTTP headers by a URL pattern. - // TODO: use http.Header type instead? - Rule struct { - Path string - Headers []Header - } - - // Header represents a single HTTP header, simply a name and value. - Header struct { - Name string - Value string - } -) diff --git a/vendor/github.com/mholt/caddy/caddyhttp/header/header_test.go b/vendor/github.com/mholt/caddy/caddyhttp/header/header_test.go deleted file mode 100644 index dd86a09..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/header/header_test.go +++ /dev/null @@ -1,57 +0,0 @@ -package header - -import ( - "net/http" - "net/http/httptest" - "os" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestHeader(t *testing.T) { - hostname, err := os.Hostname() - if err != nil { - t.Fatalf("Could not determine hostname: %v", err) - } - for i, test := range []struct { - from string - name string - value string - }{ - {"/a", "Foo", "Bar"}, - {"/a", "Bar", ""}, - {"/a", "Baz", ""}, - {"/a", "ServerName", hostname}, - {"/b", "Foo", ""}, - {"/b", "Bar", "Removed in /a"}, - } { - he := Headers{ - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - return 0, nil - }), - Rules: []Rule{ - {Path: "/a", Headers: []Header{ - {Name: "Foo", Value: "Bar"}, - {Name: "ServerName", Value: "{hostname}"}, - {Name: "-Bar"}, - }}, - }, - } - - req, err := http.NewRequest("GET", test.from, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request: %v", i, err) - } - - rec := httptest.NewRecorder() - rec.Header().Set("Bar", "Removed in /a") - - he.ServeHTTP(rec, req) - - if got := rec.Header().Get(test.name); got != test.value { - t.Errorf("Test %d: Expected %s header to be %q but was %q", - i, test.name, test.value, got) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/header/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/header/setup.go deleted file mode 100644 index be03200..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/header/setup.go +++ /dev/null @@ -1,93 +0,0 @@ -package header - -import ( - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("header", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Headers middleware instance. -func setup(c *caddy.Controller) error { - rules, err := headersParse(c) - if err != nil { - return err - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Headers{Next: next, Rules: rules} - }) - - return nil -} - -func headersParse(c *caddy.Controller) ([]Rule, error) { - var rules []Rule - - for c.NextLine() { - var head Rule - var isNewPattern bool - - if !c.NextArg() { - return rules, c.ArgErr() - } - pattern := c.Val() - - // See if we already have a definition for this Path pattern... - for _, h := range rules { - if h.Path == pattern { - head = h - break - } - } - - // ...otherwise, this is a new pattern - if head.Path == "" { - head.Path = pattern - isNewPattern = true - } - - for c.NextBlock() { - // A block of headers was opened... - - h := Header{Name: c.Val()} - - if c.NextArg() { - h.Value = c.Val() - } - - head.Headers = append(head.Headers, h) - } - if c.NextArg() { - // ... or single header was defined as an argument instead. - - h := Header{Name: c.Val()} - - h.Value = c.Val() - - if c.NextArg() { - h.Value = c.Val() - } - - head.Headers = append(head.Headers, h) - } - - if isNewPattern { - rules = append(rules, head) - } else { - for i := 0; i < len(rules); i++ { - if rules[i].Path == pattern { - rules[i] = head - break - } - } - } - } - - return rules, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/header/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/header/setup_test.go deleted file mode 100644 index e3b6cbf..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/header/setup_test.go +++ /dev/null @@ -1,85 +0,0 @@ -package header - -import ( - "fmt" - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`header / Foo Bar`)) - if err != nil { - t.Errorf("Expected no errors, but got: %v", err) - } - - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, had 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Headers) - if !ok { - t.Fatalf("Expected handler to be type Headers, got: %#v", handler) - } - - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } -} - -func TestHeadersParse(t *testing.T) { - tests := []struct { - input string - shouldErr bool - expected []Rule - }{ - {`header /foo Foo "Bar Baz"`, - false, []Rule{ - {Path: "/foo", Headers: []Header{ - {Name: "Foo", Value: "Bar Baz"}, - }}, - }}, - {`header /bar { Foo "Bar Baz" Baz Qux }`, - false, []Rule{ - {Path: "/bar", Headers: []Header{ - {Name: "Foo", Value: "Bar Baz"}, - {Name: "Baz", Value: "Qux"}, - }}, - }}, - } - - for i, test := range tests { - actual, err := headersParse(caddy.NewTestController(test.input)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - - if len(actual) != len(test.expected) { - t.Fatalf("Test %d expected %d rules, but got %d", - i, len(test.expected), len(actual)) - } - - for j, expectedRule := range test.expected { - actualRule := actual[j] - - if actualRule.Path != expectedRule.Path { - t.Errorf("Test %d, rule %d: Expected path %s, but got %s", - i, j, expectedRule.Path, actualRule.Path) - } - - expectedHeaders := fmt.Sprintf("%v", expectedRule.Headers) - actualHeaders := fmt.Sprintf("%v", actualRule.Headers) - - if actualHeaders != expectedHeaders { - t.Errorf("Test %d, rule %d: Expected headers %s, but got %s", - i, j, expectedHeaders, actualHeaders) - } - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/context.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/context.go deleted file mode 100644 index 32ae2a4..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/context.go +++ /dev/null @@ -1,263 +0,0 @@ -package httpserver - -import ( - "bytes" - "fmt" - "io/ioutil" - "net" - "net/http" - "net/url" - "strings" - "text/template" - "time" - - "github.com/russross/blackfriday" -) - -// This file contains the context and functions available for -// use in the templates. - -// Context is the context with which Caddy templates are executed. -type Context struct { - Root http.FileSystem - Req *http.Request - URL *url.URL -} - -// Include returns the contents of filename relative to the site root. -func (c Context) Include(filename string) (string, error) { - return ContextInclude(filename, c, c.Root) -} - -// Now returns the current timestamp in the specified format. -func (c Context) Now(format string) string { - return time.Now().Format(format) -} - -// NowDate returns the current date/time that can be used -// in other time functions. -func (c Context) NowDate() time.Time { - return time.Now() -} - -// Cookie gets the value of a cookie with name name. -func (c Context) Cookie(name string) string { - cookies := c.Req.Cookies() - for _, cookie := range cookies { - if cookie.Name == name { - return cookie.Value - } - } - return "" -} - -// Header gets the value of a request header with field name. -func (c Context) Header(name string) string { - return c.Req.Header.Get(name) -} - -// IP gets the (remote) IP address of the client making the request. -func (c Context) IP() string { - ip, _, err := net.SplitHostPort(c.Req.RemoteAddr) - if err != nil { - return c.Req.RemoteAddr - } - return ip -} - -// URI returns the raw, unprocessed request URI (including query -// string and hash) obtained directly from the Request-Line of -// the HTTP request. -func (c Context) URI() string { - return c.Req.RequestURI -} - -// Host returns the hostname portion of the Host header -// from the HTTP request. -func (c Context) Host() (string, error) { - host, _, err := net.SplitHostPort(c.Req.Host) - if err != nil { - if !strings.Contains(c.Req.Host, ":") { - // common with sites served on the default port 80 - return c.Req.Host, nil - } - return "", err - } - return host, nil -} - -// Port returns the port portion of the Host header if specified. -func (c Context) Port() (string, error) { - _, port, err := net.SplitHostPort(c.Req.Host) - if err != nil { - if !strings.Contains(c.Req.Host, ":") { - // common with sites served on the default port 80 - return "80", nil - } - return "", err - } - return port, nil -} - -// Method returns the method (GET, POST, etc.) of the request. -func (c Context) Method() string { - return c.Req.Method -} - -// PathMatches returns true if the path portion of the request -// URL matches pattern. -func (c Context) PathMatches(pattern string) bool { - return Path(c.Req.URL.Path).Matches(pattern) -} - -// Truncate truncates the input string to the given length. -// If length is negative, it returns that many characters -// starting from the end of the string. If the absolute value -// of length is greater than len(input), the whole input is -// returned. -func (c Context) Truncate(input string, length int) string { - if length < 0 && len(input)+length > 0 { - return input[len(input)+length:] - } - if length >= 0 && len(input) > length { - return input[:length] - } - return input -} - -// StripHTML returns s without HTML tags. It is fairly naive -// but works with most valid HTML inputs. -func (c Context) StripHTML(s string) string { - var buf bytes.Buffer - var inTag, inQuotes bool - var tagStart int - for i, ch := range s { - if inTag { - if ch == '>' && !inQuotes { - inTag = false - } else if ch == '<' && !inQuotes { - // false start - buf.WriteString(s[tagStart:i]) - tagStart = i - } else if ch == '"' { - inQuotes = !inQuotes - } - continue - } - if ch == '<' { - inTag = true - tagStart = i - continue - } - buf.WriteRune(ch) - } - if inTag { - // false start - buf.WriteString(s[tagStart:]) - } - return buf.String() -} - -// StripExt returns the input string without the extension, -// which is the suffix starting with the final '.' character -// but not before the final path separator ('/') character. -// If there is no extension, the whole input is returned. -func (c Context) StripExt(path string) string { - for i := len(path) - 1; i >= 0 && path[i] != '/'; i-- { - if path[i] == '.' { - return path[:i] - } - } - return path -} - -// Replace replaces instances of find in input with replacement. -func (c Context) Replace(input, find, replacement string) string { - return strings.Replace(input, find, replacement, -1) -} - -// Markdown returns the HTML contents of the markdown contained in filename -// (relative to the site root). -func (c Context) Markdown(filename string) (string, error) { - body, err := c.Include(filename) - if err != nil { - return "", err - } - renderer := blackfriday.HtmlRenderer(0, "", "") - extns := 0 - extns |= blackfriday.EXTENSION_TABLES - extns |= blackfriday.EXTENSION_FENCED_CODE - extns |= blackfriday.EXTENSION_STRIKETHROUGH - extns |= blackfriday.EXTENSION_DEFINITION_LISTS - markdown := blackfriday.Markdown([]byte(body), renderer, extns) - - return string(markdown), nil -} - -// ContextInclude opens filename using fs and executes a template with the context ctx. -// This does the same thing that Context.Include() does, but with the ability to provide -// your own context so that the included files can have access to additional fields your -// type may provide. You can embed Context in your type, then override its Include method -// to call this function with ctx being the instance of your type, and fs being Context.Root. -func ContextInclude(filename string, ctx interface{}, fs http.FileSystem) (string, error) { - file, err := fs.Open(filename) - if err != nil { - return "", err - } - defer file.Close() - - body, err := ioutil.ReadAll(file) - if err != nil { - return "", err - } - - tpl, err := template.New(filename).Parse(string(body)) - if err != nil { - return "", err - } - - var buf bytes.Buffer - err = tpl.Execute(&buf, ctx) - if err != nil { - return "", err - } - - return buf.String(), nil -} - -// ToLower will convert the given string to lower case. -func (c Context) ToLower(s string) string { - return strings.ToLower(s) -} - -// ToUpper will convert the given string to upper case. -func (c Context) ToUpper(s string) string { - return strings.ToUpper(s) -} - -// Split is a passthrough to strings.Split. It will split the first argument at each instance of the separator and return a slice of strings. -func (c Context) Split(s string, sep string) []string { - return strings.Split(s, sep) -} - -// Slice will convert the given arguments into a slice. -func (c Context) Slice(elems ...interface{}) []interface{} { - return elems -} - -// Map will convert the arguments into a map. It expects alternating string keys and values. This is useful for building more complicated data structures -// if you are using subtemplates or things like that. -func (c Context) Map(values ...interface{}) (map[string]interface{}, error) { - if len(values)%2 != 0 { - return nil, fmt.Errorf("Map expects an even number of arguments") - } - dict := make(map[string]interface{}, len(values)/2) - for i := 0; i < len(values); i += 2 { - key, ok := values[i].(string) - if !ok { - return nil, fmt.Errorf("Map keys must be strings") - } - dict[key] = values[i+1] - } - return dict, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/context_test.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/context_test.go deleted file mode 100644 index 332a649..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/context_test.go +++ /dev/null @@ -1,650 +0,0 @@ -package httpserver - -import ( - "bytes" - "fmt" - "io/ioutil" - "net/http" - "net/url" - "os" - "path/filepath" - "strings" - "testing" - "time" - - "text/template" -) - -func TestInclude(t *testing.T) { - context := getContextOrFail(t) - - inputFilename := "test_file" - absInFilePath := filepath.Join(fmt.Sprintf("%s", context.Root), inputFilename) - defer func() { - err := os.Remove(absInFilePath) - if err != nil && !os.IsNotExist(err) { - t.Fatalf("Failed to clean test file!") - } - }() - - tests := []struct { - fileContent string - expectedContent string - shouldErr bool - expectedErrorContent string - }{ - // Test 0 - all good - { - fileContent: `str1 {{ .Root }} str2`, - expectedContent: fmt.Sprintf("str1 %s str2", context.Root), - shouldErr: false, - expectedErrorContent: "", - }, - // Test 1 - failure on template.Parse - { - fileContent: `str1 {{ .Root } str2`, - expectedContent: "", - shouldErr: true, - expectedErrorContent: `unexpected "}" in operand`, - }, - // Test 3 - failure on template.Execute - { - fileContent: `str1 {{ .InvalidField }} str2`, - expectedContent: "", - shouldErr: true, - expectedErrorContent: `InvalidField`, - }, - { - fileContent: `str1 {{ .InvalidField }} str2`, - expectedContent: "", - shouldErr: true, - expectedErrorContent: `type httpserver.Context`, - }, - } - - for i, test := range tests { - testPrefix := getTestPrefix(i) - - // WriteFile truncates the contentt - err := ioutil.WriteFile(absInFilePath, []byte(test.fileContent), os.ModePerm) - if err != nil { - t.Fatal(testPrefix+"Failed to create test file. Error was: %v", err) - } - - content, err := context.Include(inputFilename) - if err != nil { - if !test.shouldErr { - t.Errorf(testPrefix+"Expected no error, found [%s]", test.expectedErrorContent, err.Error()) - } - if !strings.Contains(err.Error(), test.expectedErrorContent) { - t.Errorf(testPrefix+"Expected error content [%s], found [%s]", test.expectedErrorContent, err.Error()) - } - } - - if err == nil && test.shouldErr { - t.Errorf(testPrefix+"Expected error [%s] but found nil. Input file was: %s", test.expectedErrorContent, inputFilename) - } - - if content != test.expectedContent { - t.Errorf(testPrefix+"Expected content [%s] but found [%s]. Input file was: %s", test.expectedContent, content, inputFilename) - } - } -} - -func TestIncludeNotExisting(t *testing.T) { - context := getContextOrFail(t) - - _, err := context.Include("not_existing") - if err == nil { - t.Errorf("Expected error but found nil!") - } -} - -func TestMarkdown(t *testing.T) { - context := getContextOrFail(t) - - inputFilename := "test_file" - absInFilePath := filepath.Join(fmt.Sprintf("%s", context.Root), inputFilename) - defer func() { - err := os.Remove(absInFilePath) - if err != nil && !os.IsNotExist(err) { - t.Fatalf("Failed to clean test file!") - } - }() - - tests := []struct { - fileContent string - expectedContent string - }{ - // Test 0 - test parsing of markdown - { - fileContent: "* str1\n* str2\n", - expectedContent: "
    \n
  • str1
  • \n
  • str2
  • \n
\n", - }, - } - - for i, test := range tests { - testPrefix := getTestPrefix(i) - - // WriteFile truncates the contentt - err := ioutil.WriteFile(absInFilePath, []byte(test.fileContent), os.ModePerm) - if err != nil { - t.Fatal(testPrefix+"Failed to create test file. Error was: %v", err) - } - - content, _ := context.Markdown(inputFilename) - if content != test.expectedContent { - t.Errorf(testPrefix+"Expected content [%s] but found [%s]. Input file was: %s", test.expectedContent, content, inputFilename) - } - } -} - -func TestCookie(t *testing.T) { - - tests := []struct { - cookie *http.Cookie - cookieName string - expectedValue string - }{ - // Test 0 - happy path - { - cookie: &http.Cookie{Name: "cookieName", Value: "cookieValue"}, - cookieName: "cookieName", - expectedValue: "cookieValue", - }, - // Test 1 - try to get a non-existing cookie - { - cookie: &http.Cookie{Name: "cookieName", Value: "cookieValue"}, - cookieName: "notExisting", - expectedValue: "", - }, - // Test 2 - partial name match - { - cookie: &http.Cookie{Name: "cookie", Value: "cookieValue"}, - cookieName: "cook", - expectedValue: "", - }, - // Test 3 - cookie with optional fields - { - cookie: &http.Cookie{Name: "cookie", Value: "cookieValue", Path: "/path", Domain: "https://localhost", Expires: (time.Now().Add(10 * time.Minute)), MaxAge: 120}, - cookieName: "cookie", - expectedValue: "cookieValue", - }, - } - - for i, test := range tests { - testPrefix := getTestPrefix(i) - - // reinitialize the context for each test - context := getContextOrFail(t) - - context.Req.AddCookie(test.cookie) - - actualCookieVal := context.Cookie(test.cookieName) - - if actualCookieVal != test.expectedValue { - t.Errorf(testPrefix+"Expected cookie value [%s] but found [%s] for cookie with name %s", test.expectedValue, actualCookieVal, test.cookieName) - } - } -} - -func TestCookieMultipleCookies(t *testing.T) { - context := getContextOrFail(t) - - cookieNameBase, cookieValueBase := "cookieName", "cookieValue" - - // make sure that there's no state and multiple requests for different cookies return the correct result - for i := 0; i < 10; i++ { - context.Req.AddCookie(&http.Cookie{Name: fmt.Sprintf("%s%d", cookieNameBase, i), Value: fmt.Sprintf("%s%d", cookieValueBase, i)}) - } - - for i := 0; i < 10; i++ { - expectedCookieVal := fmt.Sprintf("%s%d", cookieValueBase, i) - actualCookieVal := context.Cookie(fmt.Sprintf("%s%d", cookieNameBase, i)) - if actualCookieVal != expectedCookieVal { - t.Fatalf("Expected cookie value %s, found %s", expectedCookieVal, actualCookieVal) - } - } -} - -func TestHeader(t *testing.T) { - context := getContextOrFail(t) - - headerKey, headerVal := "Header1", "HeaderVal1" - context.Req.Header.Add(headerKey, headerVal) - - actualHeaderVal := context.Header(headerKey) - if actualHeaderVal != headerVal { - t.Errorf("Expected header %s, found %s", headerVal, actualHeaderVal) - } - - missingHeaderVal := context.Header("not-existing") - if missingHeaderVal != "" { - t.Errorf("Expected empty header value, found %s", missingHeaderVal) - } -} - -func TestIP(t *testing.T) { - context := getContextOrFail(t) - - tests := []struct { - inputRemoteAddr string - expectedIP string - }{ - // Test 0 - ipv4 with port - {"1.1.1.1:1111", "1.1.1.1"}, - // Test 1 - ipv4 without port - {"1.1.1.1", "1.1.1.1"}, - // Test 2 - ipv6 with port - {"[::1]:11", "::1"}, - // Test 3 - ipv6 without port and brackets - {"[2001:db8:a0b:12f0::1]", "[2001:db8:a0b:12f0::1]"}, - // Test 4 - ipv6 with zone and port - {`[fe80:1::3%eth0]:44`, `fe80:1::3%eth0`}, - } - - for i, test := range tests { - testPrefix := getTestPrefix(i) - - context.Req.RemoteAddr = test.inputRemoteAddr - actualIP := context.IP() - - if actualIP != test.expectedIP { - t.Errorf(testPrefix+"Expected IP %s, found %s", test.expectedIP, actualIP) - } - } -} - -func TestURL(t *testing.T) { - context := getContextOrFail(t) - - inputURL := "http://localhost" - context.Req.RequestURI = inputURL - - if inputURL != context.URI() { - t.Errorf("Expected url %s, found %s", inputURL, context.URI()) - } -} - -func TestHost(t *testing.T) { - tests := []struct { - input string - expectedHost string - shouldErr bool - }{ - { - input: "localhost:123", - expectedHost: "localhost", - shouldErr: false, - }, - { - input: "localhost", - expectedHost: "localhost", - shouldErr: false, - }, - { - input: "[::]", - expectedHost: "", - shouldErr: true, - }, - } - - for _, test := range tests { - testHostOrPort(t, true, test.input, test.expectedHost, test.shouldErr) - } -} - -func TestPort(t *testing.T) { - tests := []struct { - input string - expectedPort string - shouldErr bool - }{ - { - input: "localhost:123", - expectedPort: "123", - shouldErr: false, - }, - { - input: "localhost", - expectedPort: "80", // assuming 80 is the default port - shouldErr: false, - }, - { - input: ":8080", - expectedPort: "8080", - shouldErr: false, - }, - { - input: "[::]", - expectedPort: "", - shouldErr: true, - }, - } - - for _, test := range tests { - testHostOrPort(t, false, test.input, test.expectedPort, test.shouldErr) - } -} - -func testHostOrPort(t *testing.T, isTestingHost bool, input, expectedResult string, shouldErr bool) { - context := getContextOrFail(t) - - context.Req.Host = input - var actualResult, testedObject string - var err error - - if isTestingHost { - actualResult, err = context.Host() - testedObject = "host" - } else { - actualResult, err = context.Port() - testedObject = "port" - } - - if shouldErr && err == nil { - t.Errorf("Expected error, found nil!") - return - } - - if !shouldErr && err != nil { - t.Errorf("Expected no error, found %s", err) - return - } - - if actualResult != expectedResult { - t.Errorf("Expected %s %s, found %s", testedObject, expectedResult, actualResult) - } -} - -func TestMethod(t *testing.T) { - context := getContextOrFail(t) - - method := "POST" - context.Req.Method = method - - if method != context.Method() { - t.Errorf("Expected method %s, found %s", method, context.Method()) - } - -} - -func TestPathMatches(t *testing.T) { - context := getContextOrFail(t) - - tests := []struct { - urlStr string - pattern string - shouldMatch bool - }{ - // Test 0 - { - urlStr: "http://localhost/", - pattern: "", - shouldMatch: true, - }, - // Test 1 - { - urlStr: "http://localhost", - pattern: "", - shouldMatch: true, - }, - // Test 1 - { - urlStr: "http://localhost/", - pattern: "/", - shouldMatch: true, - }, - // Test 3 - { - urlStr: "http://localhost/?param=val", - pattern: "/", - shouldMatch: true, - }, - // Test 4 - { - urlStr: "http://localhost/dir1/dir2", - pattern: "/dir2", - shouldMatch: false, - }, - // Test 5 - { - urlStr: "http://localhost/dir1/dir2", - pattern: "/dir1", - shouldMatch: true, - }, - // Test 6 - { - urlStr: "http://localhost:444/dir1/dir2", - pattern: "/dir1", - shouldMatch: true, - }, - // Test 7 - { - urlStr: "http://localhost/dir1/dir2", - pattern: "*/dir2", - shouldMatch: false, - }, - } - - for i, test := range tests { - testPrefix := getTestPrefix(i) - var err error - context.Req.URL, err = url.Parse(test.urlStr) - if err != nil { - t.Fatalf("Failed to prepare test URL from string %s! Error was: %s", test.urlStr, err) - } - - matches := context.PathMatches(test.pattern) - if matches != test.shouldMatch { - t.Errorf(testPrefix+"Expected and actual result differ: expected to match [%t], actual matches [%t]", test.shouldMatch, matches) - } - } -} - -func TestTruncate(t *testing.T) { - context := getContextOrFail(t) - tests := []struct { - inputString string - inputLength int - expected string - }{ - // Test 0 - small length - { - inputString: "string", - inputLength: 1, - expected: "s", - }, - // Test 1 - exact length - { - inputString: "string", - inputLength: 6, - expected: "string", - }, - // Test 2 - bigger length - { - inputString: "string", - inputLength: 10, - expected: "string", - }, - // Test 3 - zero length - { - inputString: "string", - inputLength: 0, - expected: "", - }, - // Test 4 - negative, smaller length - { - inputString: "string", - inputLength: -5, - expected: "tring", - }, - // Test 5 - negative, exact length - { - inputString: "string", - inputLength: -6, - expected: "string", - }, - // Test 6 - negative, bigger length - { - inputString: "string", - inputLength: -7, - expected: "string", - }, - } - - for i, test := range tests { - actual := context.Truncate(test.inputString, test.inputLength) - if actual != test.expected { - t.Errorf(getTestPrefix(i)+"Expected '%s', found '%s'. Input was Truncate(%q, %d)", test.expected, actual, test.inputString, test.inputLength) - } - } -} - -func TestStripHTML(t *testing.T) { - context := getContextOrFail(t) - tests := []struct { - input string - expected string - }{ - // Test 0 - no tags - { - input: `h1`, - expected: `h1`, - }, - // Test 1 - happy path - { - input: `

h1

`, - expected: `h1`, - }, - // Test 2 - tag in quotes - { - input: `">h1`, - expected: `h1`, - }, - // Test 3 - multiple tags - { - input: `

h1

`, - expected: `h1`, - }, - // Test 4 - tags not closed - { - input: `hi`, - expected: ` 0 && serverType == "http" { - confBody := fmt.Sprintf("%s:%s\n%s", Host, Port, strings.Join(flag.Args(), "\n")) - return caddy.CaddyfileInput{ - Contents: []byte(confBody), - Filepath: "args", - ServerTypeName: serverType, - }, nil - } - return nil, nil -} - -// groupSiteConfigsByListenAddr groups site configs by their listen -// (bind) address, so sites that use the same listener can be served -// on the same server instance. The return value maps the listen -// address (what you pass into net.Listen) to the list of site configs. -// This function does NOT vet the configs to ensure they are compatible. -func groupSiteConfigsByListenAddr(configs []*SiteConfig) (map[string][]*SiteConfig, error) { - groups := make(map[string][]*SiteConfig) - - for _, conf := range configs { - if caddy.IsLoopback(conf.Addr.Host) && conf.ListenHost == "" { - // special case: one would not expect a site served - // at loopback to be connected to from the outside. - conf.ListenHost = conf.Addr.Host - } - if conf.Addr.Port == "" { - conf.Addr.Port = Port - } - addr, err := net.ResolveTCPAddr("tcp", net.JoinHostPort(conf.ListenHost, conf.Addr.Port)) - if err != nil { - return nil, err - } - addrstr := addr.String() - groups[addrstr] = append(groups[addrstr], conf) - } - - return groups, nil -} - -// AddMiddleware adds a middleware to a site's middleware stack. -func (sc *SiteConfig) AddMiddleware(m Middleware) { - sc.middleware = append(sc.middleware, m) -} - -// Address represents a site address. It contains -// the original input value, and the component -// parts of an address. -type Address struct { - Original, Scheme, Host, Port, Path string -} - -// String returns a human-friendly print of the address. -func (a Address) String() string { - if a.Host == "" && a.Port == "" { - return "" - } - scheme := a.Scheme - if scheme == "" { - if a.Port == "443" { - scheme = "https" - } else { - scheme = "http" - } - } - s := scheme - if s != "" { - s += "://" - } - s += a.Host - if a.Port != "" && - ((scheme == "https" && a.Port != "443") || - (scheme == "http" && a.Port != "80")) { - s += ":" + a.Port - } - if a.Path != "" { - s += a.Path - } - return s -} - -// VHost returns a sensible concatenation of Host:Port/Path from a. -// It's basically the a.Original but without the scheme. -func (a Address) VHost() string { - if idx := strings.Index(a.Original, "://"); idx > -1 { - return a.Original[idx+3:] - } - return a.Original -} - -// standardizeAddress parses an address string into a structured format with separate -// scheme, host, and port portions, as well as the original input string. -func standardizeAddress(str string) (Address, error) { - input := str - - // Split input into components (prepend with // to assert host by default) - if !strings.Contains(str, "//") { - str = "//" + str - } - u, err := url.Parse(str) - if err != nil { - return Address{}, err - } - - // separate host and port - host, port, err := net.SplitHostPort(u.Host) - if err != nil { - host, port, err = net.SplitHostPort(u.Host + ":") - if err != nil { - host = u.Host - } - } - - // see if we can set port based off scheme - if port == "" { - if u.Scheme == "http" { - port = "80" - } else if u.Scheme == "https" { - port = "443" - } - } - - // repeated or conflicting scheme is confusing, so error - if u.Scheme != "" && (port == "http" || port == "https") { - return Address{}, fmt.Errorf("[%s] scheme specified twice in address", input) - } - - // error if scheme and port combination violate convention - if (u.Scheme == "http" && port == "443") || (u.Scheme == "https" && port == "80") { - return Address{}, fmt.Errorf("[%s] scheme and port violate convention", input) - } - - // standardize http and https ports to their respective port numbers - if port == "http" { - u.Scheme = "http" - port = "80" - } else if port == "https" { - u.Scheme = "https" - port = "443" - } - - return Address{Original: input, Scheme: u.Scheme, Host: host, Port: port, Path: u.Path}, err -} - -// directives is the list of all directives known to exist for the -// http server type, including non-standard (3rd-party) directives. -// The ordering of this list is important. -var directives = []string{ - // primitive actions that set up the fundamental vitals of each config - "root", - "tls", - "bind", - - // services/utilities, or other directives that don't necessarily inject handlers - "startup", - "shutdown", - "realip", // github.com/captncraig/caddy-realip - "git", // github.com/abiosoft/caddy-git - - // directives that add middleware to the stack - "log", - "gzip", - "errors", - "minify", // github.com/hacdias/caddy-minify - "ipfilter", // github.com/pyed/ipfilter - "search", // github.com/pedronasser/caddy-search - "header", - "cors", // github.com/captncraig/cors/caddy - "rewrite", - "redir", - "ext", - "mime", - "basicauth", - "jwt", // github.com/BTBurke/caddy-jwt - "jsonp", // github.com/pschlump/caddy-jsonp - "upload", // blitznote.com/src/caddy.upload - "internal", - "pprof", - "expvar", - "proxy", - "fastcgi", - "websocket", - "markdown", - "templates", - "browse", - "hugo", // github.com/hacdias/caddy-hugo - "mailout", // github.com/SchumacherFM/mailout - "prometheus", // github.com/miekg/caddy-prometheus -} - -const ( - // DefaultHost is the default host. - DefaultHost = "" - // DefaultPort is the default port. - DefaultPort = "2015" - // DefaultRoot is the default root folder. - DefaultRoot = "." -) - -// These "soft defaults" are configurable by -// command line flags, etc. -var ( - // Root is the site root - Root = DefaultRoot - - // Host is the site host - Host = DefaultHost - - // Port is the site port - Port = DefaultPort - - // GracefulTimeout is the maximum duration of a graceful shutdown. - GracefulTimeout time.Duration - - // HTTP2 indicates whether HTTP2 is enabled or not. - HTTP2 bool - - // QUIC indicates whether QUIC is enabled or not. - QUIC bool -) diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/plugin_test.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/plugin_test.go deleted file mode 100644 index 9959ce9..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/plugin_test.go +++ /dev/null @@ -1,114 +0,0 @@ -package httpserver - -import "testing" - -func TestStandardizeAddress(t *testing.T) { - for i, test := range []struct { - input string - scheme, host, port, path string - shouldErr bool - }{ - {`localhost`, "", "localhost", "", "", false}, - {`localhost:1234`, "", "localhost", "1234", "", false}, - {`localhost:`, "", "localhost", "", "", false}, - {`0.0.0.0`, "", "0.0.0.0", "", "", false}, - {`127.0.0.1:1234`, "", "127.0.0.1", "1234", "", false}, - {`:1234`, "", "", "1234", "", false}, - {`[::1]`, "", "::1", "", "", false}, - {`[::1]:1234`, "", "::1", "1234", "", false}, - {`:`, "", "", "", "", false}, - {`localhost:http`, "http", "localhost", "80", "", false}, - {`localhost:https`, "https", "localhost", "443", "", false}, - {`:http`, "http", "", "80", "", false}, - {`:https`, "https", "", "443", "", false}, - {`http://localhost:https`, "", "", "", "", true}, // conflict - {`http://localhost:http`, "", "", "", "", true}, // repeated scheme - {`http://localhost:443`, "", "", "", "", true}, // not conventional - {`https://localhost:80`, "", "", "", "", true}, // not conventional - {`http://localhost`, "http", "localhost", "80", "", false}, - {`https://localhost`, "https", "localhost", "443", "", false}, - {`http://127.0.0.1`, "http", "127.0.0.1", "80", "", false}, - {`https://127.0.0.1`, "https", "127.0.0.1", "443", "", false}, - {`http://[::1]`, "http", "::1", "80", "", false}, - {`http://localhost:1234`, "http", "localhost", "1234", "", false}, - {`https://127.0.0.1:1234`, "https", "127.0.0.1", "1234", "", false}, - {`http://[::1]:1234`, "http", "::1", "1234", "", false}, - {``, "", "", "", "", false}, - {`::1`, "", "::1", "", "", true}, - {`localhost::`, "", "localhost::", "", "", true}, - {`#$%@`, "", "", "", "", true}, - {`host/path`, "", "host", "", "/path", false}, - {`http://host/`, "http", "host", "80", "/", false}, - {`//asdf`, "", "asdf", "", "", false}, - {`:1234/asdf`, "", "", "1234", "/asdf", false}, - {`http://host/path`, "http", "host", "80", "/path", false}, - {`https://host:443/path/foo`, "https", "host", "443", "/path/foo", false}, - {`host:80/path`, "", "host", "80", "/path", false}, - {`host:https/path`, "https", "host", "443", "/path", false}, - } { - actual, err := standardizeAddress(test.input) - - if err != nil && !test.shouldErr { - t.Errorf("Test %d (%s): Expected no error, but had error: %v", i, test.input, err) - } - if err == nil && test.shouldErr { - t.Errorf("Test %d (%s): Expected error, but had none", i, test.input) - } - - if !test.shouldErr && actual.Original != test.input { - t.Errorf("Test %d (%s): Expected original '%s', got '%s'", i, test.input, test.input, actual.Original) - } - if actual.Scheme != test.scheme { - t.Errorf("Test %d (%s): Expected scheme '%s', got '%s'", i, test.input, test.scheme, actual.Scheme) - } - if actual.Host != test.host { - t.Errorf("Test %d (%s): Expected host '%s', got '%s'", i, test.input, test.host, actual.Host) - } - if actual.Port != test.port { - t.Errorf("Test %d (%s): Expected port '%s', got '%s'", i, test.input, test.port, actual.Port) - } - if actual.Path != test.path { - t.Errorf("Test %d (%s): Expected path '%s', got '%s'", i, test.input, test.path, actual.Path) - } - } -} - -func TestAddressVHost(t *testing.T) { - for i, test := range []struct { - addr Address - expected string - }{ - {Address{Original: "host:1234"}, "host:1234"}, - {Address{Original: "host:1234/foo"}, "host:1234/foo"}, - {Address{Original: "host/foo"}, "host/foo"}, - {Address{Original: "http://host/foo"}, "host/foo"}, - {Address{Original: "https://host/foo"}, "host/foo"}, - } { - actual := test.addr.VHost() - if actual != test.expected { - t.Errorf("Test %d: expected '%s' but got '%s'", i, test.expected, actual) - } - } -} - -func TestAddressString(t *testing.T) { - for i, test := range []struct { - addr Address - expected string - }{ - {Address{Scheme: "http", Host: "host", Port: "1234", Path: "/path"}, "http://host:1234/path"}, - {Address{Scheme: "", Host: "host", Port: "", Path: ""}, "http://host"}, - {Address{Scheme: "", Host: "host", Port: "80", Path: ""}, "http://host"}, - {Address{Scheme: "", Host: "host", Port: "443", Path: ""}, "https://host"}, - {Address{Scheme: "https", Host: "host", Port: "443", Path: ""}, "https://host"}, - {Address{Scheme: "https", Host: "host", Port: "", Path: ""}, "https://host"}, - {Address{Scheme: "", Host: "host", Port: "80", Path: "/path"}, "http://host/path"}, - {Address{Scheme: "http", Host: "", Port: "1234", Path: ""}, "http://:1234"}, - {Address{Scheme: "", Host: "", Port: "", Path: ""}, ""}, - } { - actual := test.addr.String() - if actual != test.expected { - t.Errorf("Test %d: expected '%s' but got '%s'", i, test.expected, actual) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder.go deleted file mode 100644 index 5788ab4..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder.go +++ /dev/null @@ -1,98 +0,0 @@ -package httpserver - -import ( - "bufio" - "errors" - "net" - "net/http" - "time" -) - -// ResponseRecorder is a type of http.ResponseWriter that captures -// the status code written to it and also the size of the body -// written in the response. A status code does not have -// to be written, however, in which case 200 must be assumed. -// It is best to have the constructor initialize this type -// with that default status code. -// -// Setting the Replacer field allows middlewares to type-assert -// the http.ResponseWriter to ResponseRecorder and set their own -// placeholder values for logging utilities to use. -// -// Beware when accessing the Replacer value; it may be nil! -type ResponseRecorder struct { - http.ResponseWriter - Replacer Replacer - status int - size int - start time.Time -} - -// NewResponseRecorder makes and returns a new responseRecorder, -// which captures the HTTP Status code from the ResponseWriter -// and also the length of the response body written through it. -// Because a status is not set unless WriteHeader is called -// explicitly, this constructor initializes with a status code -// of 200 to cover the default case. -func NewResponseRecorder(w http.ResponseWriter) *ResponseRecorder { - return &ResponseRecorder{ - ResponseWriter: w, - status: http.StatusOK, - start: time.Now(), - } -} - -// WriteHeader records the status code and calls the -// underlying ResponseWriter's WriteHeader method. -func (r *ResponseRecorder) WriteHeader(status int) { - r.status = status - r.ResponseWriter.WriteHeader(status) -} - -// Write is a wrapper that records the size of the body -// that gets written. -func (r *ResponseRecorder) Write(buf []byte) (int, error) { - n, err := r.ResponseWriter.Write(buf) - if err == nil { - r.size += n - } - return n, err -} - -// Size is a Getter to size property -func (r *ResponseRecorder) Size() int { - return r.size -} - -// Status is a Getter to status property -func (r *ResponseRecorder) Status() int { - return r.status -} - -// Hijack implements http.Hijacker. It simply wraps the underlying -// ResponseWriter's Hijack method if there is one, or returns an error. -func (r *ResponseRecorder) Hijack() (net.Conn, *bufio.ReadWriter, error) { - if hj, ok := r.ResponseWriter.(http.Hijacker); ok { - return hj.Hijack() - } - return nil, nil, errors.New("not a Hijacker") -} - -// Flush implements http.Flusher. It simply wraps the underlying -// ResponseWriter's Flush method if there is one, or does nothing. -func (r *ResponseRecorder) Flush() { - if f, ok := r.ResponseWriter.(http.Flusher); ok { - f.Flush() - } else { - panic("not a Flusher") // should be recovered at the beginning of middleware stack - } -} - -// CloseNotify implements http.CloseNotifier. -// It just inherits the underlying ResponseWriter's CloseNotify method. -func (r *ResponseRecorder) CloseNotify() <-chan bool { - if cn, ok := r.ResponseWriter.(http.CloseNotifier); ok { - return cn.CloseNotify() - } - panic("not a CloseNotifier") -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder_test.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder_test.go deleted file mode 100644 index 0772d66..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/recorder_test.go +++ /dev/null @@ -1,40 +0,0 @@ -package httpserver - -import ( - "net/http" - "net/http/httptest" - "testing" -) - -func TestNewResponseRecorder(t *testing.T) { - w := httptest.NewRecorder() - recordRequest := NewResponseRecorder(w) - if !(recordRequest.ResponseWriter == w) { - t.Fatalf("Expected Response writer in the Recording to be same as the one sent\n") - } - if recordRequest.status != http.StatusOK { - t.Fatalf("Expected recorded status to be http.StatusOK (%d) , but found %d\n ", http.StatusOK, recordRequest.status) - } -} -func TestWriteHeader(t *testing.T) { - w := httptest.NewRecorder() - recordRequest := NewResponseRecorder(w) - recordRequest.WriteHeader(401) - if w.Code != 401 || recordRequest.status != 401 { - t.Fatalf("Expected Response status to be set to 401, but found %d\n", recordRequest.status) - } -} - -func TestWrite(t *testing.T) { - w := httptest.NewRecorder() - responseTestString := "test" - recordRequest := NewResponseRecorder(w) - buf := []byte(responseTestString) - recordRequest.Write(buf) - if recordRequest.size != len(buf) { - t.Fatalf("Expected the bytes written counter to be %d, but instead found %d\n", len(buf), recordRequest.size) - } - if w.Body.String() != responseTestString { - t.Fatalf("Expected Response Body to be %s , but found %s\n", responseTestString, w.Body.String()) - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer.go deleted file mode 100644 index cae5870..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer.go +++ /dev/null @@ -1,178 +0,0 @@ -package httpserver - -import ( - "net" - "net/http" - "net/http/httputil" - "net/url" - "os" - "path" - "strconv" - "strings" - "time" -) - -// requestReplacer is a strings.Replacer which is used to -// encode literal \r and \n characters and keep everything -// on one line -var requestReplacer = strings.NewReplacer( - "\r", "\\r", - "\n", "\\n", -) - -// Replacer is a type which can replace placeholder -// substrings in a string with actual values from a -// http.Request and ResponseRecorder. Always use -// NewReplacer to get one of these. Any placeholders -// made with Set() should overwrite existing values if -// the key is already used. -type Replacer interface { - Replace(string) string - Set(key, value string) -} - -// replacer implements Replacer. customReplacements -// is used to store custom replacements created with -// Set() until the time of replacement, at which point -// they will be used to overwrite other replacements -// if there is a name conflict. -type replacer struct { - replacements map[string]string - customReplacements map[string]string - emptyValue string - responseRecorder *ResponseRecorder -} - -// NewReplacer makes a new replacer based on r and rr which -// are used for request and response placeholders, respectively. -// Request placeholders are created immediately, whereas -// response placeholders are not created until Replace() -// is invoked. rr may be nil if it is not available. -// emptyValue should be the string that is used in place -// of empty string (can still be empty string). -func NewReplacer(r *http.Request, rr *ResponseRecorder, emptyValue string) Replacer { - rep := &replacer{ - responseRecorder: rr, - customReplacements: make(map[string]string), - replacements: map[string]string{ - "{method}": r.Method, - "{scheme}": func() string { - if r.TLS != nil { - return "https" - } - return "http" - }(), - "{hostname}": func() string { - name, err := os.Hostname() - if err != nil { - return "" - } - return name - }(), - "{host}": r.Host, - "{path}": r.URL.Path, - "{path_escaped}": url.QueryEscape(r.URL.Path), - "{query}": r.URL.RawQuery, - "{query_escaped}": url.QueryEscape(r.URL.RawQuery), - "{fragment}": r.URL.Fragment, - "{proto}": r.Proto, - "{remote}": func() string { - if fwdFor := r.Header.Get("X-Forwarded-For"); fwdFor != "" { - return fwdFor - } - host, _, err := net.SplitHostPort(r.RemoteAddr) - if err != nil { - return r.RemoteAddr - } - return host - }(), - "{port}": func() string { - _, port, err := net.SplitHostPort(r.RemoteAddr) - if err != nil { - return "" - } - return port - }(), - "{uri}": r.URL.RequestURI(), - "{uri_escaped}": url.QueryEscape(r.URL.RequestURI()), - "{when}": time.Now().Format(timeFormat), - "{file}": func() string { - _, file := path.Split(r.URL.Path) - return file - }(), - "{dir}": func() string { - dir, _ := path.Split(r.URL.Path) - return dir - }(), - "{request}": func() string { - dump, err := httputil.DumpRequest(r, false) - if err != nil { - return "" - } - - return requestReplacer.Replace(string(dump)) - }(), - }, - emptyValue: emptyValue, - } - - // Header placeholders (case-insensitive) - for header, values := range r.Header { - rep.replacements[headerReplacer+strings.ToLower(header)+"}"] = strings.Join(values, ",") - } - - return rep -} - -// Replace performs a replacement of values on s and returns -// the string with the replaced values. -func (r *replacer) Replace(s string) string { - // Make response placeholders now - if r.responseRecorder != nil { - r.replacements["{status}"] = strconv.Itoa(r.responseRecorder.status) - r.replacements["{size}"] = strconv.Itoa(r.responseRecorder.size) - r.replacements["{latency}"] = time.Since(r.responseRecorder.start).String() - } - - // Include custom placeholders, overwriting existing ones if necessary - for key, val := range r.customReplacements { - r.replacements[key] = val - } - - // Header replacements - these are case-insensitive, so we can't just use strings.Replace() - for strings.Contains(s, headerReplacer) { - idxStart := strings.Index(s, headerReplacer) - endOffset := idxStart + len(headerReplacer) - idxEnd := strings.Index(s[endOffset:], "}") - if idxEnd > -1 { - placeholder := strings.ToLower(s[idxStart : endOffset+idxEnd+1]) - replacement := r.replacements[placeholder] - if replacement == "" { - replacement = r.emptyValue - } - s = s[:idxStart] + replacement + s[endOffset+idxEnd+1:] - } else { - break - } - } - - // Regular replacements - these are easier because they're case-sensitive - for placeholder, replacement := range r.replacements { - if replacement == "" { - replacement = r.emptyValue - } - s = strings.Replace(s, placeholder, replacement, -1) - } - - return s -} - -// Set sets key to value in the r.customReplacements map. -func (r *replacer) Set(key, value string) { - r.customReplacements["{"+key+"}"] = value -} - -const ( - timeFormat = "02/Jan/2006:15:04:05 -0700" - headerReplacer = "{>" -) diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer_test.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer_test.go deleted file mode 100644 index b6f2f45..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/replacer_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package httpserver - -import ( - "net/http" - "net/http/httptest" - "os" - "strings" - "testing" -) - -func TestNewReplacer(t *testing.T) { - w := httptest.NewRecorder() - recordRequest := NewResponseRecorder(w) - reader := strings.NewReader(`{"username": "dennis"}`) - - request, err := http.NewRequest("POST", "http://localhost", reader) - if err != nil { - t.Fatal("Request Formation Failed\n") - } - rep := NewReplacer(request, recordRequest, "") - - switch v := rep.(type) { - case *replacer: - if v.replacements["{host}"] != "localhost" { - t.Error("Expected host to be localhost") - } - if v.replacements["{method}"] != "POST" { - t.Error("Expected request method to be POST") - } - - // Response placeholders should only be set after call to Replace() - if got, want := v.replacements["{status}"], ""; got != want { - t.Errorf("Expected status to NOT be set before Replace() is called; was: %s", got) - } - rep.Replace("foobar") - if got, want := v.replacements["{status}"], "200"; got != want { - t.Errorf("Expected status to be %s, was: %s", want, got) - } - default: - t.Fatalf("Expected *replacer underlying Replacer type, got: %#v", rep) - } -} - -func TestReplace(t *testing.T) { - w := httptest.NewRecorder() - recordRequest := NewResponseRecorder(w) - reader := strings.NewReader(`{"username": "dennis"}`) - - request, err := http.NewRequest("POST", "http://localhost", reader) - if err != nil { - t.Fatal("Request Formation Failed\n") - } - request.Header.Set("Custom", "foobarbaz") - request.Header.Set("ShorterVal", "1") - repl := NewReplacer(request, recordRequest, "-") - - hostname, err := os.Hostname() - if err != nil { - t.Fatal("Failed to determine hostname\n") - } - if expected, actual := "This hostname is "+hostname, repl.Replace("This hostname is {hostname}"); expected != actual { - t.Errorf("{hostname} replacement: expected '%s', got '%s'", expected, actual) - } - - if expected, actual := "This host is localhost.", repl.Replace("This host is {host}."); expected != actual { - t.Errorf("{host} replacement: expected '%s', got '%s'", expected, actual) - } - if expected, actual := "This request method is POST.", repl.Replace("This request method is {method}."); expected != actual { - t.Errorf("{method} replacement: expected '%s', got '%s'", expected, actual) - } - if expected, actual := "The response status is 200.", repl.Replace("The response status is {status}."); expected != actual { - t.Errorf("{status} replacement: expected '%s', got '%s'", expected, actual) - } - if expected, actual := "The Custom header is foobarbaz.", repl.Replace("The Custom header is {>Custom}."); expected != actual { - t.Errorf("{>Custom} replacement: expected '%s', got '%s'", expected, actual) - } - if expected, actual := "The request is POST / HTTP/1.1\\r\\nHost: localhost\\r\\nCustom: foobarbaz\\r\\nShorterval: 1\\r\\n\\r\\n.", repl.Replace("The request is {request}."); expected != actual { - t.Errorf("{request} replacement: expected '%s', got '%s'", expected, actual) - } - - // Test header case-insensitivity - if expected, actual := "The cUsToM header is foobarbaz...", repl.Replace("The cUsToM header is {>cUsToM}..."); expected != actual { - t.Errorf("{>cUsToM} replacement: expected '%s', got '%s'", expected, actual) - } - - // Test non-existent header/value - if expected, actual := "The Non-Existent header is -.", repl.Replace("The Non-Existent header is {>Non-Existent}."); expected != actual { - t.Errorf("{>Non-Existent} replacement: expected '%s', got '%s'", expected, actual) - } - - // Test bad placeholder - if expected, actual := "Bad {host placeholder...", repl.Replace("Bad {host placeholder..."); expected != actual { - t.Errorf("bad placeholder: expected '%s', got '%s'", expected, actual) - } - - // Test bad header placeholder - if expected, actual := "Bad {>Custom placeholder", repl.Replace("Bad {>Custom placeholder"); expected != actual { - t.Errorf("bad header placeholder: expected '%s', got '%s'", expected, actual) - } - - // Test bad header placeholder with valid one later - if expected, actual := "Bad -", repl.Replace("Bad {>Custom placeholder {>ShorterVal}"); expected != actual { - t.Errorf("bad header placeholders: expected '%s', got '%s'", expected, actual) - } - - // Test shorter header value with multiple placeholders - if expected, actual := "Short value 1 then foobarbaz.", repl.Replace("Short value {>ShorterVal} then {>Custom}."); expected != actual { - t.Errorf("short value: expected '%s', got '%s'", expected, actual) - } -} - -func TestSet(t *testing.T) { - w := httptest.NewRecorder() - recordRequest := NewResponseRecorder(w) - reader := strings.NewReader(`{"username": "dennis"}`) - - request, err := http.NewRequest("POST", "http://localhost", reader) - if err != nil { - t.Fatalf("Request Formation Failed \n") - } - repl := NewReplacer(request, recordRequest, "") - - repl.Set("host", "getcaddy.com") - repl.Set("method", "GET") - repl.Set("status", "201") - repl.Set("variable", "value") - - if repl.Replace("This host is {host}") != "This host is getcaddy.com" { - t.Error("Expected host replacement failed") - } - if repl.Replace("This request method is {method}") != "This request method is GET" { - t.Error("Expected method replacement failed") - } - if repl.Replace("The response status is {status}") != "The response status is 201" { - t.Error("Expected status replacement failed") - } - if repl.Replace("The value of variable is {variable}") != "The value of variable is value" { - t.Error("Expected variable replacement failed") - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/roller.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/roller.go deleted file mode 100644 index b826463..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/roller.go +++ /dev/null @@ -1,64 +0,0 @@ -package httpserver - -import ( - "io" - "strconv" - - "github.com/mholt/caddy" - - "gopkg.in/natefinch/lumberjack.v2" -) - -// LogRoller implements a type that provides a rolling logger. -type LogRoller struct { - Filename string - MaxSize int - MaxAge int - MaxBackups int - LocalTime bool -} - -// GetLogWriter returns an io.Writer that writes to a rolling logger. -func (l LogRoller) GetLogWriter() io.Writer { - return &lumberjack.Logger{ - Filename: l.Filename, - MaxSize: l.MaxSize, - MaxAge: l.MaxAge, - MaxBackups: l.MaxBackups, - LocalTime: l.LocalTime, - } -} - -// ParseRoller parses roller contents out of c. -func ParseRoller(c *caddy.Controller) (*LogRoller, error) { - var size, age, keep int - // This is kind of a hack to support nested blocks: - // As we are already in a block: either log or errors, - // c.nesting > 0 but, as soon as c meets a }, it thinks - // the block is over and return false for c.NextBlock. - for c.NextBlock() { - what := c.Val() - if !c.NextArg() { - return nil, c.ArgErr() - } - value := c.Val() - var err error - switch what { - case "size": - size, err = strconv.Atoi(value) - case "age": - age, err = strconv.Atoi(value) - case "keep": - keep, err = strconv.Atoi(value) - } - if err != nil { - return nil, err - } - } - return &LogRoller{ - MaxSize: size, - MaxAge: age, - MaxBackups: keep, - LocalTime: true, - }, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/server.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/server.go deleted file mode 100644 index 37ed016..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/server.go +++ /dev/null @@ -1,389 +0,0 @@ -// Package httpserver implements an HTTP server on top of Caddy. -package httpserver - -import ( - "crypto/tls" - "fmt" - "log" - "net" - "net/http" - "os" - "path" - "runtime" - "strings" - "sync" - "time" - - "github.com/lucas-clemente/quic-go/h2quic" - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/staticfiles" - "github.com/mholt/caddy/caddytls" -) - -// Server is the HTTP server implementation. -type Server struct { - Server *http.Server - quicServer *h2quic.Server - listener net.Listener - listenerMu sync.Mutex - sites []*SiteConfig - connTimeout time.Duration // max time to wait for a connection before force stop - connWg sync.WaitGroup // one increment per connection - tlsGovChan chan struct{} // close to stop the TLS maintenance goroutine - vhosts *vhostTrie -} - -// ensure it satisfies the interface -var _ caddy.GracefulServer = new(Server) - -// NewServer creates a new Server instance that will listen on addr -// and will serve the sites configured in group. -func NewServer(addr string, group []*SiteConfig) (*Server, error) { - s := &Server{ - Server: &http.Server{ - Addr: addr, - // TODO: Make these values configurable? - // ReadTimeout: 2 * time.Minute, - // WriteTimeout: 2 * time.Minute, - // MaxHeaderBytes: 1 << 16, - }, - vhosts: newVHostTrie(), - sites: group, - connTimeout: GracefulTimeout, - } - s.Server.Handler = s // this is weird, but whatever - s.Server.ConnState = func(c net.Conn, cs http.ConnState) { - if cs == http.StateIdle { - s.listenerMu.Lock() - // server stopped, close idle connection - if s.listener == nil { - c.Close() - } - s.listenerMu.Unlock() - } - } - - // Disable HTTP/2 if desired - if !HTTP2 { - s.Server.TLSNextProto = make(map[string]func(*http.Server, *tls.Conn, http.Handler)) - } - - // Enable QUIC if desired - if QUIC { - s.quicServer = &h2quic.Server{Server: s.Server} - } - - // We have to bound our wg with one increment - // to prevent a "race condition" that is hard-coded - // into sync.WaitGroup.Wait() - basically, an add - // with a positive delta must be guaranteed to - // occur before Wait() is called on the wg. - // In a way, this kind of acts as a safety barrier. - s.connWg.Add(1) - - // Set up TLS configuration - var tlsConfigs []*caddytls.Config - var err error - for _, site := range group { - tlsConfigs = append(tlsConfigs, site.TLS) - } - s.Server.TLSConfig, err = caddytls.MakeTLSConfig(tlsConfigs) - if err != nil { - return nil, err - } - - // Compile custom middleware for every site (enables virtual hosting) - for _, site := range group { - stack := Handler(staticfiles.FileServer{Root: http.Dir(site.Root), Hide: site.HiddenFiles}) - for i := len(site.middleware) - 1; i >= 0; i-- { - stack = site.middleware[i](stack) - } - site.middlewareChain = stack - s.vhosts.Insert(site.Addr.VHost(), site) - } - - return s, nil -} - -// Listen creates an active listener for s that can be -// used to serve requests. -func (s *Server) Listen() (net.Listener, error) { - if s.Server == nil { - return nil, fmt.Errorf("Server field is nil") - } - - ln, err := net.Listen("tcp", s.Server.Addr) - if err != nil { - var succeeded bool - if runtime.GOOS == "windows" { - // Windows has been known to keep sockets open even after closing the listeners. - // Tests reveal this error case easily because they call Start() then Stop() - // in succession. TODO: Better way to handle this? And why limit this to Windows? - for i := 0; i < 20; i++ { - time.Sleep(100 * time.Millisecond) - ln, err = net.Listen("tcp", s.Server.Addr) - if err == nil { - succeeded = true - break - } - } - } - if !succeeded { - return nil, err - } - } - - // Very important to return a concrete caddy.Listener - // implementation for graceful restarts. - return ln.(*net.TCPListener), nil -} - -// Serve serves requests on ln. It blocks until ln is closed. -func (s *Server) Serve(ln net.Listener) error { - if tcpLn, ok := ln.(*net.TCPListener); ok { - ln = tcpKeepAliveListener{TCPListener: tcpLn} - } - - ln = newGracefulListener(ln, &s.connWg) - - s.listenerMu.Lock() - s.listener = ln - s.listenerMu.Unlock() - - if s.Server.TLSConfig != nil { - // Create TLS listener - note that we do not replace s.listener - // with this TLS listener; tls.listener is unexported and does - // not implement the File() method we need for graceful restarts - // on POSIX systems. - // TODO: Is this ^ still relevant anymore? Maybe we can now that it's a net.Listener... - ln = tls.NewListener(ln, s.Server.TLSConfig) - - // Rotate TLS session ticket keys - s.tlsGovChan = caddytls.RotateSessionTicketKeys(s.Server.TLSConfig) - } - - if QUIC { - go func() { - err := s.quicServer.ListenAndServe() - if err != nil { - log.Printf("[ERROR] listening for QUIC connections: %v", err) - } - }() - } - - err := s.Server.Serve(ln) - if QUIC { - s.quicServer.Close() - } - return err -} - -// ServeHTTP is the entry point of all HTTP requests. -func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { - defer func() { - // We absolutely need to be sure we stay alive up here, - // even though, in theory, the errors middleware does this. - if rec := recover(); rec != nil { - log.Printf("[PANIC] %v", rec) - DefaultErrorFunc(w, r, http.StatusInternalServerError) - } - }() - - w.Header().Set("Server", "Caddy") - - sanitizePath(r) - - status, _ := s.serveHTTP(w, r) - - // Fallback error response in case error handling wasn't chained in - if status >= 400 { - DefaultErrorFunc(w, r, status) - } -} - -func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - // strip out the port because it's not used in virtual - // hosting; the port is irrelevant because each listener - // is on a different port. - hostname, _, err := net.SplitHostPort(r.Host) - if err != nil { - hostname = r.Host - } - - // look up the virtualhost; if no match, serve error - vhost, pathPrefix := s.vhosts.Match(hostname + r.URL.Path) - - if vhost == nil { - // check for ACME challenge even if vhost is nil; - // could be a new host coming online soon - if caddytls.HTTPChallengeHandler(w, r, caddytls.DefaultHTTPAlternatePort) { - return 0, nil - } - // otherwise, log the error and write a message to the client - remoteHost, _, err := net.SplitHostPort(r.RemoteAddr) - if err != nil { - remoteHost = r.RemoteAddr - } - WriteTextResponse(w, http.StatusNotFound, "No such site at "+s.Server.Addr) - log.Printf("[INFO] %s - No such site at %s (Remote: %s, Referer: %s)", - hostname, s.Server.Addr, remoteHost, r.Header.Get("Referer")) - return 0, nil - } - - // we still check for ACME challenge if the vhost exists, - // because we must apply its HTTP challenge config settings - if s.proxyHTTPChallenge(vhost, w, r) { - return 0, nil - } - - // trim the path portion of the site address from the beginning of - // the URL path, so a request to example.com/foo/blog on the site - // defined as example.com/foo appears as /blog instead of /foo/blog. - if pathPrefix != "/" { - r.URL.Path = strings.TrimPrefix(r.URL.Path, pathPrefix) - if !strings.HasPrefix(r.URL.Path, "/") { - r.URL.Path = "/" + r.URL.Path - } - } - - return vhost.middlewareChain.ServeHTTP(w, r) -} - -// proxyHTTPChallenge solves the ACME HTTP challenge if r is the HTTP -// request for the challenge. If it is, and if the request has been -// fulfilled (response written), true is returned; false otherwise. -// If you don't have a vhost, just call the challenge handler directly. -func (s *Server) proxyHTTPChallenge(vhost *SiteConfig, w http.ResponseWriter, r *http.Request) bool { - if vhost.Addr.Port != caddytls.HTTPChallengePort { - return false - } - if vhost.TLS != nil && vhost.TLS.Manual { - return false - } - altPort := caddytls.DefaultHTTPAlternatePort - if vhost.TLS != nil && vhost.TLS.AltHTTPPort != "" { - altPort = vhost.TLS.AltHTTPPort - } - return caddytls.HTTPChallengeHandler(w, r, altPort) -} - -// Address returns the address s was assigned to listen on. -func (s *Server) Address() string { - return s.Server.Addr -} - -// Stop stops s gracefully (or forcefully after timeout) and -// closes its listener. -func (s *Server) Stop() (err error) { - s.Server.SetKeepAlivesEnabled(false) - - if runtime.GOOS != "windows" { - // force connections to close after timeout - done := make(chan struct{}) - go func() { - s.connWg.Done() // decrement our initial increment used as a barrier - s.connWg.Wait() - close(done) - }() - - // Wait for remaining connections to finish or - // force them all to close after timeout - select { - case <-time.After(s.connTimeout): - case <-done: - } - } - - // Close the listener now; this stops the server without delay - s.listenerMu.Lock() - if s.listener != nil { - err = s.listener.Close() - s.listener = nil - } - s.listenerMu.Unlock() - - // Closing this signals any TLS governor goroutines to exit - if s.tlsGovChan != nil { - close(s.tlsGovChan) - } - - return -} - -// sanitizePath collapses any ./ ../ /// madness -// which helps prevent path traversal attacks. -// Note to middleware: use URL.RawPath If you need -// the "original" URL.Path value. -func sanitizePath(r *http.Request) { - if r.URL.Path == "/" { - return - } - cleanedPath := path.Clean(r.URL.Path) - if cleanedPath == "." { - r.URL.Path = "/" - } else { - if !strings.HasPrefix(cleanedPath, "/") { - cleanedPath = "/" + cleanedPath - } - if strings.HasSuffix(r.URL.Path, "/") && !strings.HasSuffix(cleanedPath, "/") { - cleanedPath = cleanedPath + "/" - } - r.URL.Path = cleanedPath - } -} - -// OnStartupComplete lists the sites served by this server -// and any relevant information, assuming caddy.Quiet == false. -func (s *Server) OnStartupComplete() { - if caddy.Quiet { - return - } - for _, site := range s.sites { - output := site.Addr.String() - if caddy.IsLoopback(s.Address()) && !caddy.IsLoopback(site.Addr.Host) { - output += " (only accessible on this machine)" - } - fmt.Println(output) - } -} - -// tcpKeepAliveListener sets TCP keep-alive timeouts on accepted -// connections. It's used by ListenAndServe and ListenAndServeTLS so -// dead TCP connections (e.g. closing laptop mid-download) eventually -// go away. -// -// Borrowed from the Go standard library. -type tcpKeepAliveListener struct { - *net.TCPListener -} - -// Accept accepts the connection with a keep-alive enabled. -func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) { - tc, err := ln.AcceptTCP() - if err != nil { - return - } - tc.SetKeepAlive(true) - tc.SetKeepAlivePeriod(3 * time.Minute) - return tc, nil -} - -// File implements caddy.Listener; it returns the underlying file of the listener. -func (ln tcpKeepAliveListener) File() (*os.File, error) { - return ln.TCPListener.File() -} - -// DefaultErrorFunc responds to an HTTP request with a simple description -// of the specified HTTP status code. -func DefaultErrorFunc(w http.ResponseWriter, r *http.Request, status int) { - WriteTextResponse(w, status, fmt.Sprintf("%d %s\n", status, http.StatusText(status))) -} - -// WriteTextResponse writes body with code status to w. The body will -// be interpreted as plain text. -func WriteTextResponse(w http.ResponseWriter, status int, body string) { - w.Header().Set("Content-Type", "text/plain; charset=utf-8") - w.Header().Set("X-Content-Type-Options", "nosniff") - w.WriteHeader(status) - w.Write([]byte(body)) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/server_test.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/server_test.go deleted file mode 100644 index d8e53c1..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/server_test.go +++ /dev/null @@ -1,15 +0,0 @@ -package httpserver - -import ( - "net/http" - "testing" -) - -func TestAddress(t *testing.T) { - addr := "127.0.0.1:9005" - srv := &Server{Server: &http.Server{Addr: addr}} - - if got, want := srv.Address(), addr; got != want { - t.Errorf("Expected '%s' but got '%s'", want, got) - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/siteconfig.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/siteconfig.go deleted file mode 100644 index dffe749..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/siteconfig.go +++ /dev/null @@ -1,53 +0,0 @@ -package httpserver - -import "github.com/mholt/caddy/caddytls" - -// SiteConfig contains information about a site -// (also known as a virtual host). -type SiteConfig struct { - // The address of the site - Addr Address - - // The hostname to bind listener to; - // defaults to Addr.Host - ListenHost string - - // TLS configuration - TLS *caddytls.Config - - // Uncompiled middleware stack - middleware []Middleware - - // Compiled middleware stack - middlewareChain Handler - - // Directory from which to serve files - Root string - - // A list of files to hide (for example, the - // source Caddyfile). TODO: Enforcing this - // should be centralized, for example, a - // standardized way of loading files from disk - // for a request. - HiddenFiles []string -} - -// TLSConfig returns s.TLS. -func (s SiteConfig) TLSConfig() *caddytls.Config { - return s.TLS -} - -// Host returns s.Addr.Host. -func (s SiteConfig) Host() string { - return s.Addr.Host -} - -// Port returns s.Addr.Port. -func (s SiteConfig) Port() string { - return s.Addr.Port -} - -// Middleware returns s.middleware (useful for tests). -func (s SiteConfig) Middleware() []Middleware { - return s.middleware -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie.go deleted file mode 100644 index 5582557..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie.go +++ /dev/null @@ -1,139 +0,0 @@ -package httpserver - -import ( - "net" - "strings" -) - -// vhostTrie facilitates virtual hosting. It matches -// requests first by hostname (with support for -// wildcards as TLS certificates support them), then -// by longest matching path. -type vhostTrie struct { - edges map[string]*vhostTrie - site *SiteConfig // also known as a virtual host - path string // the path portion of the key for this node -} - -// newVHostTrie returns a new vhostTrie. -func newVHostTrie() *vhostTrie { - return &vhostTrie{edges: make(map[string]*vhostTrie)} -} - -// Insert adds stack to t keyed by key. The key should be -// a valid "host/path" combination (or just host). -func (t *vhostTrie) Insert(key string, site *SiteConfig) { - host, path := t.splitHostPath(key) - if _, ok := t.edges[host]; !ok { - t.edges[host] = newVHostTrie() - } - t.edges[host].insertPath(path, path, site) -} - -// insertPath expects t to be a host node (not a root node), -// and inserts site into the t according to remainingPath. -func (t *vhostTrie) insertPath(remainingPath, originalPath string, site *SiteConfig) { - if remainingPath == "" { - t.site = site - t.path = originalPath - return - } - ch := string(remainingPath[0]) - if _, ok := t.edges[ch]; !ok { - t.edges[ch] = newVHostTrie() - } - t.edges[ch].insertPath(remainingPath[1:], originalPath, site) -} - -// Match returns the virtual host (site) in v with -// the closest match to key. If there was a match, -// it returns the SiteConfig and the path portion of -// the key used to make the match. The matched path -// would be a prefix of the path portion of the -// key, if not the whole path portion of the key. -// If there is no match, nil and empty string will -// be returned. -// -// A typical key will be in the form "host" or "host/path". -func (t *vhostTrie) Match(key string) (*SiteConfig, string) { - host, path := t.splitHostPath(key) - // try the given host, then, if no match, try wildcard hosts - branch := t.matchHost(host) - if branch == nil { - branch = t.matchHost("0.0.0.0") - } - if branch == nil { - branch = t.matchHost("") - } - if branch == nil { - return nil, "" - } - node := branch.matchPath(path) - if node == nil { - return nil, "" - } - return node.site, node.path -} - -// matchHost returns the vhostTrie matching host. The matching -// algorithm is the same as used to match certificates to host -// with SNI during TLS handshakes. In other words, it supports, -// to some degree, the use of wildcard (*) characters. -func (t *vhostTrie) matchHost(host string) *vhostTrie { - // try exact match - if subtree, ok := t.edges[host]; ok { - return subtree - } - - // then try replacing labels in the host - // with wildcards until we get a match - labels := strings.Split(host, ".") - for i := range labels { - labels[i] = "*" - candidate := strings.Join(labels, ".") - if subtree, ok := t.edges[candidate]; ok { - return subtree - } - } - - return nil -} - -// matchPath traverses t until it finds the longest key matching -// remainingPath, and returns its node. -func (t *vhostTrie) matchPath(remainingPath string) *vhostTrie { - var longestMatch *vhostTrie - for len(remainingPath) > 0 { - ch := string(remainingPath[0]) - next, ok := t.edges[ch] - if !ok { - break - } - if next.site != nil { - longestMatch = next - } - t = next - remainingPath = remainingPath[1:] - } - return longestMatch -} - -// splitHostPath separates host from path in key. -func (t *vhostTrie) splitHostPath(key string) (host, path string) { - parts := strings.SplitN(key, "/", 2) - host, path = strings.ToLower(parts[0]), "/" - if len(parts) > 1 { - path += parts[1] - } - // strip out the port (if present) from the host, since - // each port has its own socket, and each socket has its - // own listener, and each listener has its own server - // instance, and each server instance has its own vhosts. - // removing the port is a simple way to standardize so - // when requests come in, we can be sure to get a match. - hostname, _, err := net.SplitHostPort(host) - if err == nil { - host = hostname - } - return -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie_test.go b/vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie_test.go deleted file mode 100644 index 95ef1fb..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/httpserver/vhosttrie_test.go +++ /dev/null @@ -1,141 +0,0 @@ -package httpserver - -import ( - "net/http" - "net/http/httptest" - "testing" -) - -func TestVHostTrie(t *testing.T) { - trie := newVHostTrie() - populateTestTrie(trie, []string{ - "example", - "example.com", - "*.example.com", - "example.com/foo", - "example.com/foo/bar", - "*.example.com/test", - }) - assertTestTrie(t, trie, []vhostTrieTest{ - {"not-in-trie.com", false, "", "/"}, - {"example", true, "example", "/"}, - {"example.com", true, "example.com", "/"}, - {"example.com/test", true, "example.com", "/"}, - {"example.com/foo", true, "example.com/foo", "/foo"}, - {"example.com/foo/", true, "example.com/foo", "/foo"}, - {"EXAMPLE.COM/foo", true, "example.com/foo", "/foo"}, - {"EXAMPLE.COM/Foo", true, "example.com", "/"}, - {"example.com/foo/bar", true, "example.com/foo/bar", "/foo/bar"}, - {"example.com/foo/bar/baz", true, "example.com/foo/bar", "/foo/bar"}, - {"example.com/foo/other", true, "example.com/foo", "/foo"}, - {"foo.example.com", true, "*.example.com", "/"}, - {"foo.example.com/else", true, "*.example.com", "/"}, - }, false) -} - -func TestVHostTrieWildcard1(t *testing.T) { - trie := newVHostTrie() - populateTestTrie(trie, []string{ - "example.com", - "", - }) - assertTestTrie(t, trie, []vhostTrieTest{ - {"not-in-trie.com", true, "", "/"}, - {"example.com", true, "example.com", "/"}, - {"example.com/foo", true, "example.com", "/"}, - {"not-in-trie.com/asdf", true, "", "/"}, - }, true) -} - -func TestVHostTrieWildcard2(t *testing.T) { - trie := newVHostTrie() - populateTestTrie(trie, []string{ - "0.0.0.0/asdf", - }) - assertTestTrie(t, trie, []vhostTrieTest{ - {"example.com/asdf/foo", true, "0.0.0.0/asdf", "/asdf"}, - {"example.com/foo", false, "", "/"}, - {"host/asdf", true, "0.0.0.0/asdf", "/asdf"}, - }, true) -} - -func TestVHostTrieWildcard3(t *testing.T) { - trie := newVHostTrie() - populateTestTrie(trie, []string{ - "*/foo", - }) - assertTestTrie(t, trie, []vhostTrieTest{ - {"example.com/foo", true, "*/foo", "/foo"}, - {"example.com", false, "", "/"}, - }, true) -} - -func TestVHostTriePort(t *testing.T) { - // Make sure port is stripped out - trie := newVHostTrie() - populateTestTrie(trie, []string{ - "example.com:1234", - }) - assertTestTrie(t, trie, []vhostTrieTest{ - {"example.com/foo", true, "example.com:1234", "/"}, - }, true) -} - -func populateTestTrie(trie *vhostTrie, keys []string) { - for _, key := range keys { - // we wrap this in a func, passing in the key, otherwise the - // handler always writes the last key to the response, even - // if the handler is actually from one of the earlier keys. - func(key string) { - site := &SiteConfig{ - middlewareChain: HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - w.Write([]byte(key)) - return 0, nil - }), - } - trie.Insert(key, site) - }(key) - } -} - -type vhostTrieTest struct { - query string - expectMatch bool - expectedKey string - matchedPrefix string // the path portion of a key that is expected to be matched -} - -func assertTestTrie(t *testing.T, trie *vhostTrie, tests []vhostTrieTest, hasWildcardHosts bool) { - for i, test := range tests { - site, pathPrefix := trie.Match(test.query) - - if !test.expectMatch { - if site != nil { - // If not expecting a value, then just make sure we didn't get one - t.Errorf("Test %d: Expected no matches, but got %v", i, site) - } - continue - } - - // Otherwise, we must assert we got a value - if site == nil { - t.Errorf("Test %d: Expected non-nil return value, but got: %v", i, site) - continue - } - - // And it must be the correct value - resp := httptest.NewRecorder() - site.middlewareChain.ServeHTTP(resp, nil) - actualHandlerKey := resp.Body.String() - if actualHandlerKey != test.expectedKey { - t.Errorf("Test %d: Expected match '%s' but matched '%s'", - i, test.expectedKey, actualHandlerKey) - } - - // The path prefix must also be correct - if test.matchedPrefix != pathPrefix { - t.Errorf("Test %d: Expected matched path prefix to be '%s', got '%s'", - i, test.matchedPrefix, pathPrefix) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal.go b/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal.go deleted file mode 100644 index aa7b69a..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal.go +++ /dev/null @@ -1,93 +0,0 @@ -// Package internalsrv provides a simple middleware that (a) prevents access -// to internal locations and (b) allows to return files from internal location -// by setting a special header, e.g. in a proxy response. -// -// The package is named internalsrv so as not to conflict with Go tooling -// convention which treats folders called "internal" differently. -package internalsrv - -import ( - "net/http" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Internal middleware protects internal locations from external requests - -// but allows access from the inside by using a special HTTP header. -type Internal struct { - Next httpserver.Handler - Paths []string -} - -const ( - redirectHeader string = "X-Accel-Redirect" - maxRedirectCount int = 10 -) - -func isInternalRedirect(w http.ResponseWriter) bool { - return w.Header().Get(redirectHeader) != "" -} - -// ServeHTTP implements the httpserver.Handler interface. -func (i Internal) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - - // Internal location requested? -> Not found. - for _, prefix := range i.Paths { - if httpserver.Path(r.URL.Path).Matches(prefix) { - return http.StatusNotFound, nil - } - } - - // Use internal response writer to ignore responses that will be - // redirected to internal locations - iw := internalResponseWriter{ResponseWriter: w} - status, err := i.Next.ServeHTTP(iw, r) - - for c := 0; c < maxRedirectCount && isInternalRedirect(iw); c++ { - // Redirect - adapt request URL path and send it again - // "down the chain" - r.URL.Path = iw.Header().Get(redirectHeader) - iw.ClearHeader() - - status, err = i.Next.ServeHTTP(iw, r) - } - - if isInternalRedirect(iw) { - // Too many redirect cycles - iw.ClearHeader() - return http.StatusInternalServerError, nil - } - - return status, err -} - -// internalResponseWriter wraps the underlying http.ResponseWriter and ignores -// calls to Write and WriteHeader if the response should be redirected to an -// internal location. -type internalResponseWriter struct { - http.ResponseWriter -} - -// ClearHeader removes all header fields that are already set. -func (w internalResponseWriter) ClearHeader() { - for k := range w.Header() { - w.Header().Del(k) - } -} - -// WriteHeader ignores the call if the response should be redirected to an -// internal location. -func (w internalResponseWriter) WriteHeader(code int) { - if !isInternalRedirect(w) { - w.ResponseWriter.WriteHeader(code) - } -} - -// Write ignores the call if the response should be redirected to an internal -// location. -func (w internalResponseWriter) Write(b []byte) (int, error) { - if isInternalRedirect(w) { - return 0, nil - } - return w.ResponseWriter.Write(b) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal_test.go b/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal_test.go deleted file mode 100644 index fa9e05b..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/internal_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package internalsrv - -import ( - "fmt" - "net/http" - "net/http/httptest" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestInternal(t *testing.T) { - im := Internal{ - Next: httpserver.HandlerFunc(internalTestHandlerFunc), - Paths: []string{"/internal"}, - } - - tests := []struct { - url string - expectedCode int - expectedBody string - }{ - {"/internal", http.StatusNotFound, ""}, - - {"/public", 0, "/public"}, - {"/public/internal", 0, "/public/internal"}, - - {"/redirect", 0, "/internal"}, - - {"/cycle", http.StatusInternalServerError, ""}, - } - - for i, test := range tests { - req, err := http.NewRequest("GET", test.url, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request: %v", i, err) - } - - rec := httptest.NewRecorder() - code, _ := im.ServeHTTP(rec, req) - - if code != test.expectedCode { - t.Errorf("Test %d: Expected status code %d for %s, but got %d", - i, test.expectedCode, test.url, code) - } - if rec.Body.String() != test.expectedBody { - t.Errorf("Test %d: Expected body '%s' for %s, but got '%s'", - i, test.expectedBody, test.url, rec.Body.String()) - } - } -} - -func internalTestHandlerFunc(w http.ResponseWriter, r *http.Request) (int, error) { - switch r.URL.Path { - case "/redirect": - w.Header().Set("X-Accel-Redirect", "/internal") - case "/cycle": - w.Header().Set("X-Accel-Redirect", "/cycle") - } - w.WriteHeader(http.StatusOK) - fmt.Fprintf(w, r.URL.String()) - - return 0, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup.go deleted file mode 100644 index ed69c22..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup.go +++ /dev/null @@ -1,40 +0,0 @@ -package internalsrv - -import ( - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("internal", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// Internal configures a new Internal middleware instance. -func setup(c *caddy.Controller) error { - paths, err := internalParse(c) - if err != nil { - return err - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Internal{Next: next, Paths: paths} - }) - - return nil -} - -func internalParse(c *caddy.Controller) ([]string, error) { - var paths []string - - for c.Next() { - if !c.NextArg() { - return paths, c.ArgErr() - } - paths = append(paths, c.Val()) - } - - return paths, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup_test.go deleted file mode 100644 index e67982c..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/internalsrv/setup_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package internalsrv - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`internal /internal`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Internal) - - if !ok { - t.Fatalf("Expected handler to be type Internal, got: %#v", handler) - } - - if myHandler.Paths[0] != "/internal" { - t.Errorf("Expected internal in the list of internal Paths") - } - - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } - -} - -func TestInternalParse(t *testing.T) { - tests := []struct { - inputInternalPaths string - shouldErr bool - expectedInternalPaths []string - }{ - {`internal /internal`, false, []string{"/internal"}}, - - {`internal /internal1 - internal /internal2`, false, []string{"/internal1", "/internal2"}}, - } - for i, test := range tests { - actualInternalPaths, err := internalParse(caddy.NewTestController(test.inputInternalPaths)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - - if len(actualInternalPaths) != len(test.expectedInternalPaths) { - t.Fatalf("Test %d expected %d InternalPaths, but got %d", - i, len(test.expectedInternalPaths), len(actualInternalPaths)) - } - for j, actualInternalPath := range actualInternalPaths { - if actualInternalPath != test.expectedInternalPaths[j] { - t.Fatalf("Test %d expected %dth Internal Path to be %s , but got %s", - i, j, test.expectedInternalPaths[j], actualInternalPath) - } - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/log/log.go b/vendor/github.com/mholt/caddy/caddyhttp/log/log.go deleted file mode 100644 index e266f84..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/log/log.go +++ /dev/null @@ -1,83 +0,0 @@ -// Package log implements request (access) logging middleware. -package log - -import ( - "fmt" - "log" - "net/http" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("log", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// Logger is a basic request logging middleware. -type Logger struct { - Next httpserver.Handler - Rules []Rule - ErrorFunc func(http.ResponseWriter, *http.Request, int) // failover error handler -} - -func (l Logger) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - for _, rule := range l.Rules { - if httpserver.Path(r.URL.Path).Matches(rule.PathScope) { - // Record the response - responseRecorder := httpserver.NewResponseRecorder(w) - - // Attach the Replacer we'll use so that other middlewares can - // set their own placeholders if they want to. - rep := httpserver.NewReplacer(r, responseRecorder, CommonLogEmptyValue) - responseRecorder.Replacer = rep - - // Bon voyage, request! - status, err := l.Next.ServeHTTP(responseRecorder, r) - - if status >= 400 { - // There was an error up the chain, but no response has been written yet. - // The error must be handled here so the log entry will record the response size. - if l.ErrorFunc != nil { - l.ErrorFunc(responseRecorder, r, status) - } else { - // Default failover error handler - responseRecorder.WriteHeader(status) - fmt.Fprintf(responseRecorder, "%d %s", status, http.StatusText(status)) - } - status = 0 - } - - // Write log entry - rule.Log.Println(rep.Replace(rule.Format)) - - return status, err - } - } - return l.Next.ServeHTTP(w, r) -} - -// Rule configures the logging middleware. -type Rule struct { - PathScope string - OutputFile string - Format string - Log *log.Logger - Roller *httpserver.LogRoller -} - -const ( - // DefaultLogFilename is the default log filename. - DefaultLogFilename = "access.log" - // CommonLogFormat is the common log format. - CommonLogFormat = `{remote} ` + CommonLogEmptyValue + ` [{when}] "{method} {uri} {proto}" {status} {size}` - // CommonLogEmptyValue is the common empty log value. - CommonLogEmptyValue = "-" - // CombinedLogFormat is the combined log format. - CombinedLogFormat = CommonLogFormat + ` "{>Referer}" "{>User-Agent}"` - // DefaultLogFormat is the default log format. - DefaultLogFormat = CommonLogFormat -) diff --git a/vendor/github.com/mholt/caddy/caddyhttp/log/log_test.go b/vendor/github.com/mholt/caddy/caddyhttp/log/log_test.go deleted file mode 100644 index af48f44..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/log/log_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package log - -import ( - "bytes" - "log" - "net/http" - "net/http/httptest" - "strings" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -type erroringMiddleware struct{} - -func (erroringMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - if rr, ok := w.(*httpserver.ResponseRecorder); ok { - rr.Replacer.Set("testval", "foobar") - } - return http.StatusNotFound, nil -} - -func TestLoggedStatus(t *testing.T) { - var f bytes.Buffer - var next erroringMiddleware - rule := Rule{ - PathScope: "/", - Format: DefaultLogFormat + " {testval}", - Log: log.New(&f, "", 0), - } - - logger := Logger{ - Rules: []Rule{rule}, - Next: next, - } - - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatal(err) - } - - rec := httptest.NewRecorder() - - status, err := logger.ServeHTTP(rec, r) - if status != 0 { - t.Errorf("Expected status to be 0, but was %d", status) - } - - if err != nil { - t.Errorf("Expected error to be nil, instead got: %v", err) - } - - logged := f.String() - if !strings.Contains(logged, "404 13") { - t.Errorf("Expected log entry to contain '404 13', but it didn't: %s", logged) - } - - // check custom placeholder - if !strings.Contains(logged, "foobar") { - t.Errorf("Expected the log entry to contain 'foobar' (custom placeholder), but it didn't: %s", logged) - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/log/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/log/setup.go deleted file mode 100644 index 9aa3d9a..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/log/setup.go +++ /dev/null @@ -1,131 +0,0 @@ -package log - -import ( - "io" - "log" - "os" - - "github.com/hashicorp/go-syslog" - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// setup sets up the logging middleware. -func setup(c *caddy.Controller) error { - rules, err := logParse(c) - if err != nil { - return err - } - - // Open the log files for writing when the server starts - c.OnStartup(func() error { - for i := 0; i < len(rules); i++ { - var err error - var writer io.Writer - - if rules[i].OutputFile == "stdout" { - writer = os.Stdout - } else if rules[i].OutputFile == "stderr" { - writer = os.Stderr - } else if rules[i].OutputFile == "syslog" { - writer, err = gsyslog.NewLogger(gsyslog.LOG_INFO, "LOCAL0", "caddy") - if err != nil { - return err - } - } else { - var file *os.File - file, err = os.OpenFile(rules[i].OutputFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644) - if err != nil { - return err - } - if rules[i].Roller != nil { - file.Close() - rules[i].Roller.Filename = rules[i].OutputFile - writer = rules[i].Roller.GetLogWriter() - } else { - writer = file - } - } - - rules[i].Log = log.New(writer, "", 0) - } - - return nil - }) - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Logger{Next: next, Rules: rules, ErrorFunc: httpserver.DefaultErrorFunc} - }) - - return nil -} - -func logParse(c *caddy.Controller) ([]Rule, error) { - var rules []Rule - - for c.Next() { - args := c.RemainingArgs() - - var logRoller *httpserver.LogRoller - if c.NextBlock() { - if c.Val() == "rotate" { - if c.NextArg() { - if c.Val() == "{" { - var err error - logRoller, err = httpserver.ParseRoller(c) - if err != nil { - return nil, err - } - // This part doesn't allow having something after the rotate block - if c.Next() { - if c.Val() != "}" { - return nil, c.ArgErr() - } - } - } - } - } - } - if len(args) == 0 { - // Nothing specified; use defaults - rules = append(rules, Rule{ - PathScope: "/", - OutputFile: DefaultLogFilename, - Format: DefaultLogFormat, - Roller: logRoller, - }) - } else if len(args) == 1 { - // Only an output file specified - rules = append(rules, Rule{ - PathScope: "/", - OutputFile: args[0], - Format: DefaultLogFormat, - Roller: logRoller, - }) - } else { - // Path scope, output file, and maybe a format specified - - format := DefaultLogFormat - - if len(args) > 2 { - switch args[2] { - case "{common}": - format = CommonLogFormat - case "{combined}": - format = CombinedLogFormat - default: - format = args[2] - } - } - - rules = append(rules, Rule{ - PathScope: args[0], - OutputFile: args[1], - Format: format, - Roller: logRoller, - }) - } - } - - return rules, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/log/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/log/setup_test.go deleted file mode 100644 index 436002a..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/log/setup_test.go +++ /dev/null @@ -1,174 +0,0 @@ -package log - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - cfg := httpserver.GetConfig("") - - err := setup(caddy.NewTestController(`log`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - - mids := cfg.Middleware() - if mids == nil { - t.Fatal("Expected middleware, was nil instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Logger) - - if !ok { - t.Fatalf("Expected handler to be type Logger, got: %#v", handler) - } - - if myHandler.Rules[0].PathScope != "/" { - t.Errorf("Expected / as the default PathScope") - } - if myHandler.Rules[0].OutputFile != DefaultLogFilename { - t.Errorf("Expected %s as the default OutputFile", DefaultLogFilename) - } - if myHandler.Rules[0].Format != DefaultLogFormat { - t.Errorf("Expected %s as the default Log Format", DefaultLogFormat) - } - if myHandler.Rules[0].Roller != nil { - t.Errorf("Expected Roller to be nil, got: %v", *myHandler.Rules[0].Roller) - } - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } - -} - -func TestLogParse(t *testing.T) { - tests := []struct { - inputLogRules string - shouldErr bool - expectedLogRules []Rule - }{ - {`log`, false, []Rule{{ - PathScope: "/", - OutputFile: DefaultLogFilename, - Format: DefaultLogFormat, - }}}, - {`log log.txt`, false, []Rule{{ - PathScope: "/", - OutputFile: "log.txt", - Format: DefaultLogFormat, - }}}, - {`log /api log.txt`, false, []Rule{{ - PathScope: "/api", - OutputFile: "log.txt", - Format: DefaultLogFormat, - }}}, - {`log /serve stdout`, false, []Rule{{ - PathScope: "/serve", - OutputFile: "stdout", - Format: DefaultLogFormat, - }}}, - {`log /myapi log.txt {common}`, false, []Rule{{ - PathScope: "/myapi", - OutputFile: "log.txt", - Format: CommonLogFormat, - }}}, - {`log /test accesslog.txt {combined}`, false, []Rule{{ - PathScope: "/test", - OutputFile: "accesslog.txt", - Format: CombinedLogFormat, - }}}, - {`log /api1 log.txt - log /api2 accesslog.txt {combined}`, false, []Rule{{ - PathScope: "/api1", - OutputFile: "log.txt", - Format: DefaultLogFormat, - }, { - PathScope: "/api2", - OutputFile: "accesslog.txt", - Format: CombinedLogFormat, - }}}, - {`log /api3 stdout {host} - log /api4 log.txt {when}`, false, []Rule{{ - PathScope: "/api3", - OutputFile: "stdout", - Format: "{host}", - }, { - PathScope: "/api4", - OutputFile: "log.txt", - Format: "{when}", - }}}, - {`log access.log { rotate { size 2 age 10 keep 3 } }`, false, []Rule{{ - PathScope: "/", - OutputFile: "access.log", - Format: DefaultLogFormat, - Roller: &httpserver.LogRoller{ - MaxSize: 2, - MaxAge: 10, - MaxBackups: 3, - LocalTime: true, - }, - }}}, - } - for i, test := range tests { - c := caddy.NewTestController(test.inputLogRules) - actualLogRules, err := logParse(c) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - if len(actualLogRules) != len(test.expectedLogRules) { - t.Fatalf("Test %d expected %d no of Log rules, but got %d ", - i, len(test.expectedLogRules), len(actualLogRules)) - } - for j, actualLogRule := range actualLogRules { - - if actualLogRule.PathScope != test.expectedLogRules[j].PathScope { - t.Errorf("Test %d expected %dth LogRule PathScope to be %s , but got %s", - i, j, test.expectedLogRules[j].PathScope, actualLogRule.PathScope) - } - - if actualLogRule.OutputFile != test.expectedLogRules[j].OutputFile { - t.Errorf("Test %d expected %dth LogRule OutputFile to be %s , but got %s", - i, j, test.expectedLogRules[j].OutputFile, actualLogRule.OutputFile) - } - - if actualLogRule.Format != test.expectedLogRules[j].Format { - t.Errorf("Test %d expected %dth LogRule Format to be %s , but got %s", - i, j, test.expectedLogRules[j].Format, actualLogRule.Format) - } - if actualLogRule.Roller != nil && test.expectedLogRules[j].Roller == nil || actualLogRule.Roller == nil && test.expectedLogRules[j].Roller != nil { - t.Fatalf("Test %d expected %dth LogRule Roller to be %v, but got %v", - i, j, test.expectedLogRules[j].Roller, actualLogRule.Roller) - } - if actualLogRule.Roller != nil && test.expectedLogRules[j].Roller != nil { - if actualLogRule.Roller.Filename != test.expectedLogRules[j].Roller.Filename { - t.Fatalf("Test %d expected %dth LogRule Roller Filename to be %s, but got %s", - i, j, test.expectedLogRules[j].Roller.Filename, actualLogRule.Roller.Filename) - } - if actualLogRule.Roller.MaxAge != test.expectedLogRules[j].Roller.MaxAge { - t.Fatalf("Test %d expected %dth LogRule Roller MaxAge to be %d, but got %d", - i, j, test.expectedLogRules[j].Roller.MaxAge, actualLogRule.Roller.MaxAge) - } - if actualLogRule.Roller.MaxBackups != test.expectedLogRules[j].Roller.MaxBackups { - t.Fatalf("Test %d expected %dth LogRule Roller MaxBackups to be %d, but got %d", - i, j, test.expectedLogRules[j].Roller.MaxBackups, actualLogRule.Roller.MaxBackups) - } - if actualLogRule.Roller.MaxSize != test.expectedLogRules[j].Roller.MaxSize { - t.Fatalf("Test %d expected %dth LogRule Roller MaxSize to be %d, but got %d", - i, j, test.expectedLogRules[j].Roller.MaxSize, actualLogRule.Roller.MaxSize) - } - if actualLogRule.Roller.LocalTime != test.expectedLogRules[j].Roller.LocalTime { - t.Fatalf("Test %d expected %dth LogRule Roller LocalTime to be %t, but got %t", - i, j, test.expectedLogRules[j].Roller.LocalTime, actualLogRule.Roller.LocalTime) - } - } - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown.go deleted file mode 100644 index bef1dce..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown.go +++ /dev/null @@ -1,171 +0,0 @@ -// Package markdown is middleware to render markdown files as HTML -// on-the-fly. -package markdown - -import ( - "net/http" - "os" - "path" - "strconv" - "strings" - "text/template" - "time" - - "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/russross/blackfriday" -) - -// Markdown implements a layer of middleware that serves -// markdown as HTML. -type Markdown struct { - // Server root - Root string - - // Jail the requests to site root with a mock file system - FileSys http.FileSystem - - // Next HTTP handler in the chain - Next httpserver.Handler - - // The list of markdown configurations - Configs []*Config - - // The list of index files to try - IndexFiles []string -} - -// Config stores markdown middleware configurations. -type Config struct { - // Markdown renderer - Renderer blackfriday.Renderer - - // Base path to match - PathScope string - - // List of extensions to consider as markdown files - Extensions map[string]struct{} - - // List of style sheets to load for each markdown file - Styles []string - - // List of JavaScript files to load for each markdown file - Scripts []string - - // Template(s) to render with - Template *template.Template -} - -// ServeHTTP implements the http.Handler interface. -func (md Markdown) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - var cfg *Config - for _, c := range md.Configs { - if httpserver.Path(r.URL.Path).Matches(c.PathScope) { // not negated - cfg = c - break // or goto - } - } - if cfg == nil { - return md.Next.ServeHTTP(w, r) // exit early - } - - // We only deal with HEAD/GET - switch r.Method { - case http.MethodGet, http.MethodHead: - default: - return http.StatusMethodNotAllowed, nil - } - - var dirents []os.FileInfo - var lastModTime time.Time - fpath := r.URL.Path - if idx, ok := httpserver.IndexFile(md.FileSys, fpath, md.IndexFiles); ok { - // We're serving a directory index file, which may be a markdown - // file with a template. Let's grab a list of files this directory - // URL points to, and pass that in to any possible template invocations, - // so that templates can customize the look and feel of a directory. - fdp, err := md.FileSys.Open(fpath) - switch { - case err == nil: // nop - case os.IsPermission(err): - return http.StatusForbidden, err - case os.IsExist(err): - return http.StatusNotFound, nil - default: // did we run out of FD? - return http.StatusInternalServerError, err - } - defer fdp.Close() - - // Grab a possible set of directory entries. Note, we do not check - // for errors here (unreadable directory, for example). It may - // still be useful to have a directory template file, without the - // directory contents being present. Note, the directory's last - // modification is also present here (entry "."). - dirents, _ = fdp.Readdir(-1) - for _, d := range dirents { - lastModTime = latest(lastModTime, d.ModTime()) - } - - // Set path to found index file - fpath = idx - } - - // If not supported extension, pass on it - if _, ok := cfg.Extensions[path.Ext(fpath)]; !ok { - return md.Next.ServeHTTP(w, r) - } - - // At this point we have a supported extension/markdown - f, err := md.FileSys.Open(fpath) - switch { - case err == nil: // nop - case os.IsPermission(err): - return http.StatusForbidden, err - case os.IsExist(err): - return http.StatusNotFound, nil - default: // did we run out of FD? - return http.StatusInternalServerError, err - } - defer f.Close() - - if fs, err := f.Stat(); err != nil { - return http.StatusGone, nil - } else { - lastModTime = latest(lastModTime, fs.ModTime()) - } - - ctx := httpserver.Context{ - Root: md.FileSys, - Req: r, - URL: r.URL, - } - html, err := cfg.Markdown(title(fpath), f, dirents, ctx) - if err != nil { - return http.StatusInternalServerError, err - } - - w.Header().Set("Content-Type", "text/html; charset=utf-8") - w.Header().Set("Content-Length", strconv.FormatInt(int64(len(html)), 10)) - httpserver.SetLastModifiedHeader(w, lastModTime) - if r.Method == http.MethodGet { - w.Write(html) - } - return http.StatusOK, nil -} - -// latest returns the latest time.Time -func latest(t ...time.Time) time.Time { - var last time.Time - - for _, tt := range t { - if tt.After(last) { - last = tt - } - } - - return last -} - -// title gives a backup generated title for a page -func title(p string) string { - return strings.TrimRight(path.Base(p), path.Ext(p)) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown_test.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown_test.go deleted file mode 100644 index b4db6ea..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/markdown_test.go +++ /dev/null @@ -1,230 +0,0 @@ -package markdown - -import ( - "bufio" - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "path/filepath" - "strings" - "testing" - "text/template" - "time" - - "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/russross/blackfriday" -) - -func TestMarkdown(t *testing.T) { - rootDir := "./testdata" - - f := func(filename string) string { - return filepath.ToSlash(rootDir + string(filepath.Separator) + filename) - } - - md := Markdown{ - Root: rootDir, - FileSys: http.Dir(rootDir), - Configs: []*Config{ - { - Renderer: blackfriday.HtmlRenderer(0, "", ""), - PathScope: "/blog", - Extensions: map[string]struct{}{ - ".md": {}, - }, - Styles: []string{}, - Scripts: []string{}, - Template: setDefaultTemplate(f("markdown_tpl.html")), - }, - { - Renderer: blackfriday.HtmlRenderer(0, "", ""), - PathScope: "/docflags", - Extensions: map[string]struct{}{ - ".md": {}, - }, - Styles: []string{}, - Scripts: []string{}, - Template: setDefaultTemplate(f("docflags/template.txt")), - }, - { - Renderer: blackfriday.HtmlRenderer(0, "", ""), - PathScope: "/log", - Extensions: map[string]struct{}{ - ".md": {}, - }, - Styles: []string{"/resources/css/log.css", "/resources/css/default.css"}, - Scripts: []string{"/resources/js/log.js", "/resources/js/default.js"}, - Template: GetDefaultTemplate(), - }, - { - Renderer: blackfriday.HtmlRenderer(0, "", ""), - PathScope: "/og", - Extensions: map[string]struct{}{ - ".md": {}, - }, - Styles: []string{}, - Scripts: []string{}, - Template: setDefaultTemplate(f("markdown_tpl.html")), - }, - }, - IndexFiles: []string{"index.html"}, - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - t.Fatalf("Next shouldn't be called") - return 0, nil - }), - } - - req, err := http.NewRequest("GET", "/blog/test.md", nil) - if err != nil { - t.Fatalf("Could not create HTTP request: %v", err) - } - - rec := httptest.NewRecorder() - - md.ServeHTTP(rec, req) - if rec.Code != http.StatusOK { - t.Fatalf("Wrong status, expected: %d and got %d", http.StatusOK, rec.Code) - } - - respBody := rec.Body.String() - expectedBody := ` - - -Markdown test 1 - - -

Header for: Markdown test 1

- -Welcome to A Caddy website! -

Welcome on the blog

- -

Body

- -
func getTrue() bool {
-    return true
-}
-
- - - -` - if !equalStrings(respBody, expectedBody) { - t.Fatalf("Expected body: %v got: %v", expectedBody, respBody) - } - - req, err = http.NewRequest("GET", "/docflags/test.md", nil) - if err != nil { - t.Fatalf("Could not create HTTP request: %v", err) - } - rec = httptest.NewRecorder() - - md.ServeHTTP(rec, req) - if rec.Code != http.StatusOK { - t.Fatalf("Wrong status, expected: %d and got %d", http.StatusOK, rec.Code) - } - respBody = rec.Body.String() - expectedBody = `Doc.var_string hello -Doc.var_bool -DocFlags.var_string -DocFlags.var_bool true` - - if !equalStrings(respBody, expectedBody) { - t.Fatalf("Expected body: %v got: %v", expectedBody, respBody) - } - - req, err = http.NewRequest("GET", "/log/test.md", nil) - if err != nil { - t.Fatalf("Could not create HTTP request: %v", err) - } - rec = httptest.NewRecorder() - - md.ServeHTTP(rec, req) - if rec.Code != http.StatusOK { - t.Fatalf("Wrong status, expected: %d and got %d", http.StatusOK, rec.Code) - } - respBody = rec.Body.String() - expectedBody = ` - - - Markdown test 2 - - - - - - - -

Welcome on the blog

- -

Body

- -
func getTrue() bool {
-    return true
-}
-
- - -` - - if !equalStrings(respBody, expectedBody) { - t.Fatalf("Expected body: %v got: %v", expectedBody, respBody) - } - - req, err = http.NewRequest("GET", "/og/first.md", nil) - if err != nil { - t.Fatalf("Could not create HTTP request: %v", err) - } - rec = httptest.NewRecorder() - currenttime := time.Now().Local().Add(-time.Second) - _ = os.Chtimes("testdata/og/first.md", currenttime, currenttime) - currenttime = time.Now().Local() - _ = os.Chtimes("testdata/og_static/og/first.md/index.html", currenttime, currenttime) - time.Sleep(time.Millisecond * 200) - - md.ServeHTTP(rec, req) - if rec.Code != http.StatusOK { - t.Fatalf("Wrong status, expected: %d and got %d", http.StatusOK, rec.Code) - } - respBody = rec.Body.String() - expectedBody = ` - - -first_post - - -

Header for: first_post

- -Welcome to title! -

Test h1

- - -` - - if !equalStrings(respBody, expectedBody) { - t.Fatalf("Expected body: %v got: %v", expectedBody, respBody) - } -} - -func equalStrings(s1, s2 string) bool { - s1 = strings.TrimSpace(s1) - s2 = strings.TrimSpace(s2) - in := bufio.NewScanner(strings.NewReader(s1)) - for in.Scan() { - txt := strings.TrimSpace(in.Text()) - if !strings.HasPrefix(strings.TrimSpace(s2), txt) { - return false - } - s2 = strings.Replace(s2, txt, "", 1) - } - return true -} - -func setDefaultTemplate(filename string) *template.Template { - buf, err := ioutil.ReadFile(filename) - if err != nil { - return nil - } - - return template.Must(GetDefaultTemplate().Parse(string(buf))) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata.go deleted file mode 100644 index ade7fcc..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata.go +++ /dev/null @@ -1,158 +0,0 @@ -package metadata - -import ( - "bufio" - "bytes" - "time" -) - -var ( - // Date format YYYY-MM-DD HH:MM:SS or YYYY-MM-DD - timeLayout = []string{ - `2006-01-02 15:04:05-0700`, - `2006-01-02 15:04:05`, - `2006-01-02`, - } -) - -// Metadata stores a page's metadata -type Metadata struct { - // Page title - Title string - - // Page template - Template string - - // Publish date - Date time.Time - - // Variables to be used with Template - Variables map[string]string - - // Flags to be used with Template - Flags map[string]bool -} - -// NewMetadata() returns a new Metadata struct, loaded with the given map -func NewMetadata(parsedMap map[string]interface{}) Metadata { - md := Metadata{ - Variables: make(map[string]string), - Flags: make(map[string]bool), - } - md.load(parsedMap) - - return md -} - -// load loads parsed values in parsedMap into Metadata -func (m *Metadata) load(parsedMap map[string]interface{}) { - - // Pull top level things out - if title, ok := parsedMap["title"]; ok { - m.Title, _ = title.(string) - } - if template, ok := parsedMap["template"]; ok { - m.Template, _ = template.(string) - } - if date, ok := parsedMap["date"].(string); ok { - for _, layout := range timeLayout { - if t, err := time.Parse(layout, date); err == nil { - m.Date = t - break - } - } - } - - // Store everything as a flag or variable - for key, val := range parsedMap { - switch v := val.(type) { - case bool: - m.Flags[key] = v - case string: - m.Variables[key] = v - } - } -} - -// MetadataParser is a an interface that must be satisfied by each parser -type MetadataParser interface { - // Initialize a parser - Init(b *bytes.Buffer) bool - - // Type of metadata - Type() string - - // Parsed metadata. - Metadata() Metadata - - // Raw markdown. - Markdown() []byte -} - -// GetParser returns a parser for the given data -func GetParser(buf []byte) MetadataParser { - for _, p := range parsers() { - b := bytes.NewBuffer(buf) - if p.Init(b) { - return p - } - } - - return nil -} - -// parsers returns all available parsers -func parsers() []MetadataParser { - return []MetadataParser{ - &TOMLMetadataParser{}, - &YAMLMetadataParser{}, - &JSONMetadataParser{}, - - // This one must be last - &NoneMetadataParser{}, - } -} - -// Split out prefixed/suffixed metadata with given delimiter -func splitBuffer(b *bytes.Buffer, delim string) (*bytes.Buffer, *bytes.Buffer) { - scanner := bufio.NewScanner(b) - - // Read and check first line - if !scanner.Scan() { - return nil, nil - } - if string(bytes.TrimSpace(scanner.Bytes())) != delim { - return nil, nil - } - - // Accumulate metadata, until delimiter - meta := bytes.NewBuffer(nil) - for scanner.Scan() { - if string(bytes.TrimSpace(scanner.Bytes())) == delim { - break - } - if _, err := meta.Write(scanner.Bytes()); err != nil { - return nil, nil - } - if _, err := meta.WriteRune('\n'); err != nil { - return nil, nil - } - } - // Make sure we saw closing delimiter - if string(bytes.TrimSpace(scanner.Bytes())) != delim { - return nil, nil - } - - // The rest is markdown - markdown := new(bytes.Buffer) - for scanner.Scan() { - if _, err := markdown.Write(scanner.Bytes()); err != nil { - return nil, nil - } - if _, err := markdown.WriteRune('\n'); err != nil { - return nil, nil - } - } - - return meta, markdown -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_json.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_json.go deleted file mode 100644 index d3b9991..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_json.go +++ /dev/null @@ -1,53 +0,0 @@ -package metadata - -import ( - "bytes" - "encoding/json" -) - -// JSONMetadataParser is the MetadataParser for JSON -type JSONMetadataParser struct { - metadata Metadata - markdown *bytes.Buffer -} - -func (j *JSONMetadataParser) Type() string { - return "JSON" -} - -// Parse metadata/markdown file -func (j *JSONMetadataParser) Init(b *bytes.Buffer) bool { - m := make(map[string]interface{}) - - err := json.Unmarshal(b.Bytes(), &m) - if err != nil { - var offset int - - if jerr, ok := err.(*json.SyntaxError); !ok { - return false - } else { - offset = int(jerr.Offset) - } - - m = make(map[string]interface{}) - err = json.Unmarshal(b.Next(offset-1), &m) - if err != nil { - return false - } - } - - j.metadata = NewMetadata(m) - j.markdown = bytes.NewBuffer(b.Bytes()) - - return true -} - -// Metadata returns parsed metadata. It should be called -// only after a call to Parse returns without error. -func (j *JSONMetadataParser) Metadata() Metadata { - return j.metadata -} - -func (j *JSONMetadataParser) Markdown() []byte { - return j.markdown.Bytes() -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_none.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_none.go deleted file mode 100644 index ed034f2..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_none.go +++ /dev/null @@ -1,39 +0,0 @@ -package metadata - -import ( - "bytes" -) - -// TOMLMetadataParser is the MetadataParser for TOML -type NoneMetadataParser struct { - metadata Metadata - markdown *bytes.Buffer -} - -func (n *NoneMetadataParser) Type() string { - return "None" -} - -// Parse metadata/markdown file -func (n *NoneMetadataParser) Init(b *bytes.Buffer) bool { - m := make(map[string]interface{}) - n.metadata = NewMetadata(m) - n.markdown = bytes.NewBuffer(b.Bytes()) - - return true -} - -// Parse the metadata -func (n *NoneMetadataParser) Parse(b []byte) ([]byte, error) { - return nil, nil -} - -// Metadata returns parsed metadata. It should be called -// only after a call to Parse returns without error. -func (n *NoneMetadataParser) Metadata() Metadata { - return n.metadata -} - -func (n *NoneMetadataParser) Markdown() []byte { - return n.markdown.Bytes() -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_test.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_test.go deleted file mode 100644 index 0c155d3..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_test.go +++ /dev/null @@ -1,261 +0,0 @@ -package metadata - -import ( - "bytes" - "strings" - "testing" -) - -func check(t *testing.T, err error) { - if err != nil { - t.Fatal(err) - } -} - -var TOML = [5]string{` -title = "A title" -template = "default" -name = "value" -positive = true -negative = false -`, - `+++ -title = "A title" -template = "default" -name = "value" -positive = true -negative = false -+++ -Page content - `, - `+++ -title = "A title" -template = "default" -name = "value" -positive = true -negative = false - `, - `title = "A title" template = "default" [variables] name = "value"`, - `+++ -title = "A title" -template = "default" -name = "value" -positive = true -negative = false -+++ -`, -} - -var YAML = [5]string{` -title : A title -template : default -name : value -positive : true -negative : false -`, - `--- -title : A title -template : default -name : value -positive : true -negative : false ---- - Page content - `, - `--- -title : A title -template : default -name : value - `, - `title : A title template : default variables : name : value : positive : true : negative : false`, - `--- -title : A title -template : default -name : value -positive : true -negative : false ---- -`, -} - -var JSON = [5]string{` - "title" : "A title", - "template" : "default", - "name" : "value", - "positive" : true, - "negative" : false -`, - `{ - "title" : "A title", - "template" : "default", - "name" : "value", - "positive" : true, - "negative" : false -} -Page content - `, - ` -{ - "title" : "A title", - "template" : "default", - "name" : "value", - "positive" : true, - "negative" : false - `, - ` -{ - "title" :: "A title", - "template" : "default", - "name" : "value", - "positive" : true, - "negative" : false -} - `, - `{ - "title" : "A title", - "template" : "default", - "name" : "value", - "positive" : true, - "negative" : false -} -`, -} - -func TestParsers(t *testing.T) { - expected := Metadata{ - Title: "A title", - Template: "default", - Variables: map[string]string{ - "name": "value", - "title": "A title", - "template": "default", - }, - Flags: map[string]bool{ - "positive": true, - "negative": false, - }, - } - compare := func(m Metadata) bool { - if m.Title != expected.Title { - return false - } - if m.Template != expected.Template { - return false - } - for k, v := range m.Variables { - if v != expected.Variables[k] { - return false - } - } - for k, v := range m.Flags { - if v != expected.Flags[k] { - return false - } - } - varLenOK := len(m.Variables) == len(expected.Variables) - flagLenOK := len(m.Flags) == len(expected.Flags) - return varLenOK && flagLenOK - } - - data := []struct { - parser MetadataParser - testData [5]string - name string - }{ - {&JSONMetadataParser{}, JSON, "JSON"}, - {&YAMLMetadataParser{}, YAML, "YAML"}, - {&TOMLMetadataParser{}, TOML, "TOML"}, - } - - for _, v := range data { - // metadata without identifiers - if v.parser.Init(bytes.NewBufferString(v.testData[0])) { - t.Fatalf("Expected error for invalid metadata for %v", v.name) - } - - // metadata with identifiers - if !v.parser.Init(bytes.NewBufferString(v.testData[1])) { - t.Fatalf("Metadata failed to initialize, type %v", v.parser.Type()) - } - md := v.parser.Markdown() - if !compare(v.parser.Metadata()) { - t.Fatalf("Expected %v, found %v for %v", expected, v.parser.Metadata(), v.name) - } - if "Page content" != strings.TrimSpace(string(md)) { - t.Fatalf("Expected %v, found %v for %v", "Page content", string(md), v.name) - } - // Check that we find the correct metadata parser type - if p := GetParser([]byte(v.testData[1])); p.Type() != v.name { - t.Fatalf("Wrong parser found, expected %v, found %v", v.name, p.Type()) - } - - // metadata without closing identifier - if v.parser.Init(bytes.NewBufferString(v.testData[2])) { - t.Fatalf("Expected error for missing closing identifier for %v parser", v.name) - } - - // invalid metadata - if v.parser.Init(bytes.NewBufferString(v.testData[3])) { - t.Fatalf("Expected error for invalid metadata for %v", v.name) - } - - // front matter but no body - if !v.parser.Init(bytes.NewBufferString(v.testData[4])) { - t.Fatalf("Unexpected error for valid metadata but no body for %v", v.name) - } - } -} - -func TestLargeBody(t *testing.T) { - - var JSON = `{ -"template": "chapter" -} - -Mycket olika byggnader har man i de nordiska rikena: pyramidformiga, kilformiga, välvda, runda och fyrkantiga. De pyramidformiga består helt enkelt av träribbor, som upptill löper samman och nedtill bildar en vidare krets; de är avsedda att användas av hantverkarna under sommaren, för att de inte ska plågas av solen, på samma gång som de besväras av rök och eld. De kilformiga husen är i regel försedda med höga tak, för att de täta och tunga snömassorna fortare ska kunna blåsa av och inte tynga ned taken. Dessa är täckta av björknäver, tegel eller kluvet spån av furu - för kådans skull -, gran, ek eller bok; taken på de förmögnas hus däremot med plåtar av koppar eller bly, i likhet med kyrktaken. Valvbyggnaderna uppförs ganska konstnärligt till skydd mot våldsamma vindar och snöfall, görs av sten eller trä, och är avsedda för olika alldagliga viktiga ändamål. Liknande byggnader kan finnas i stormännens gårdar där de används som förvaringsrum för husgeråd och jordbruksredskap. De runda byggnaderna - som för övrigt är de högst sällsynta - används av konstnärer, som vid sitt arbete behöver ett jämnt fördelat ljus från taket. Vanligast är de fyrkantiga husen, vars grova bjälkar är synnerligen väl hopfogade i hörnen - ett sant mästerverk av byggnadskonst; även dessa har fönster högt uppe i taken, för att dagsljuset skall kunna strömma in och ge alla därinne full belysning. Stenhusen har dörröppningar i förhållande till byggnadens storlek, men smala fönstergluggar, som skydd mot den stränga kölden, frosten och snön. Vore de större och vidare, såsom fönstren i Italien, skulle husen i följd av den fint yrande snön, som röres upp av den starka blåsten, precis som dammet av virvelvinden, snart nog fyllas med massor av snö och inte kunna stå emot dess tryck, utan störta samman. - - ` - var TOML = `+++ -template = "chapter" -+++ - -Mycket olika byggnader har man i de nordiska rikena: pyramidformiga, kilformiga, välvda, runda och fyrkantiga. De pyramidformiga består helt enkelt av träribbor, som upptill löper samman och nedtill bildar en vidare krets; de är avsedda att användas av hantverkarna under sommaren, för att de inte ska plågas av solen, på samma gång som de besväras av rök och eld. De kilformiga husen är i regel försedda med höga tak, för att de täta och tunga snömassorna fortare ska kunna blåsa av och inte tynga ned taken. Dessa är täckta av björknäver, tegel eller kluvet spån av furu - för kådans skull -, gran, ek eller bok; taken på de förmögnas hus däremot med plåtar av koppar eller bly, i likhet med kyrktaken. Valvbyggnaderna uppförs ganska konstnärligt till skydd mot våldsamma vindar och snöfall, görs av sten eller trä, och är avsedda för olika alldagliga viktiga ändamål. Liknande byggnader kan finnas i stormännens gårdar där de används som förvaringsrum för husgeråd och jordbruksredskap. De runda byggnaderna - som för övrigt är de högst sällsynta - används av konstnärer, som vid sitt arbete behöver ett jämnt fördelat ljus från taket. Vanligast är de fyrkantiga husen, vars grova bjälkar är synnerligen väl hopfogade i hörnen - ett sant mästerverk av byggnadskonst; även dessa har fönster högt uppe i taken, för att dagsljuset skall kunna strömma in och ge alla därinne full belysning. Stenhusen har dörröppningar i förhållande till byggnadens storlek, men smala fönstergluggar, som skydd mot den stränga kölden, frosten och snön. Vore de större och vidare, såsom fönstren i Italien, skulle husen i följd av den fint yrande snön, som röres upp av den starka blåsten, precis som dammet av virvelvinden, snart nog fyllas med massor av snö och inte kunna stå emot dess tryck, utan störta samman. - - ` - var YAML = `--- -template : chapter ---- - -Mycket olika byggnader har man i de nordiska rikena: pyramidformiga, kilformiga, välvda, runda och fyrkantiga. De pyramidformiga består helt enkelt av träribbor, som upptill löper samman och nedtill bildar en vidare krets; de är avsedda att användas av hantverkarna under sommaren, för att de inte ska plågas av solen, på samma gång som de besväras av rök och eld. De kilformiga husen är i regel försedda med höga tak, för att de täta och tunga snömassorna fortare ska kunna blåsa av och inte tynga ned taken. Dessa är täckta av björknäver, tegel eller kluvet spån av furu - för kådans skull -, gran, ek eller bok; taken på de förmögnas hus däremot med plåtar av koppar eller bly, i likhet med kyrktaken. Valvbyggnaderna uppförs ganska konstnärligt till skydd mot våldsamma vindar och snöfall, görs av sten eller trä, och är avsedda för olika alldagliga viktiga ändamål. Liknande byggnader kan finnas i stormännens gårdar där de används som förvaringsrum för husgeråd och jordbruksredskap. De runda byggnaderna - som för övrigt är de högst sällsynta - används av konstnärer, som vid sitt arbete behöver ett jämnt fördelat ljus från taket. Vanligast är de fyrkantiga husen, vars grova bjälkar är synnerligen väl hopfogade i hörnen - ett sant mästerverk av byggnadskonst; även dessa har fönster högt uppe i taken, för att dagsljuset skall kunna strömma in och ge alla därinne full belysning. Stenhusen har dörröppningar i förhållande till byggnadens storlek, men smala fönstergluggar, som skydd mot den stränga kölden, frosten och snön. Vore de större och vidare, såsom fönstren i Italien, skulle husen i följd av den fint yrande snön, som röres upp av den starka blåsten, precis som dammet av virvelvinden, snart nog fyllas med massor av snö och inte kunna stå emot dess tryck, utan störta samman. - - ` - var NONE = ` - -Mycket olika byggnader har man i de nordiska rikena: pyramidformiga, kilformiga, välvda, runda och fyrkantiga. De pyramidformiga består helt enkelt av träribbor, som upptill löper samman och nedtill bildar en vidare krets; de är avsedda att användas av hantverkarna under sommaren, för att de inte ska plågas av solen, på samma gång som de besväras av rök och eld. De kilformiga husen är i regel försedda med höga tak, för att de täta och tunga snömassorna fortare ska kunna blåsa av och inte tynga ned taken. Dessa är täckta av björknäver, tegel eller kluvet spån av furu - för kådans skull -, gran, ek eller bok; taken på de förmögnas hus däremot med plåtar av koppar eller bly, i likhet med kyrktaken. Valvbyggnaderna uppförs ganska konstnärligt till skydd mot våldsamma vindar och snöfall, görs av sten eller trä, och är avsedda för olika alldagliga viktiga ändamål. Liknande byggnader kan finnas i stormännens gårdar där de används som förvaringsrum för husgeråd och jordbruksredskap. De runda byggnaderna - som för övrigt är de högst sällsynta - används av konstnärer, som vid sitt arbete behöver ett jämnt fördelat ljus från taket. Vanligast är de fyrkantiga husen, vars grova bjälkar är synnerligen väl hopfogade i hörnen - ett sant mästerverk av byggnadskonst; även dessa har fönster högt uppe i taken, för att dagsljuset skall kunna strömma in och ge alla därinne full belysning. Stenhusen har dörröppningar i förhållande till byggnadens storlek, men smala fönstergluggar, som skydd mot den stränga kölden, frosten och snön. Vore de större och vidare, såsom fönstren i Italien, skulle husen i följd av den fint yrande snön, som röres upp av den starka blåsten, precis som dammet av virvelvinden, snart nog fyllas med massor av snö och inte kunna stå emot dess tryck, utan störta samman. - - ` - var expectedBody = `Mycket olika byggnader har man i de nordiska rikena: pyramidformiga, kilformiga, välvda, runda och fyrkantiga. De pyramidformiga består helt enkelt av träribbor, som upptill löper samman och nedtill bildar en vidare krets; de är avsedda att användas av hantverkarna under sommaren, för att de inte ska plågas av solen, på samma gång som de besväras av rök och eld. De kilformiga husen är i regel försedda med höga tak, för att de täta och tunga snömassorna fortare ska kunna blåsa av och inte tynga ned taken. Dessa är täckta av björknäver, tegel eller kluvet spån av furu - för kådans skull -, gran, ek eller bok; taken på de förmögnas hus däremot med plåtar av koppar eller bly, i likhet med kyrktaken. Valvbyggnaderna uppförs ganska konstnärligt till skydd mot våldsamma vindar och snöfall, görs av sten eller trä, och är avsedda för olika alldagliga viktiga ändamål. Liknande byggnader kan finnas i stormännens gårdar där de används som förvaringsrum för husgeråd och jordbruksredskap. De runda byggnaderna - som för övrigt är de högst sällsynta - används av konstnärer, som vid sitt arbete behöver ett jämnt fördelat ljus från taket. Vanligast är de fyrkantiga husen, vars grova bjälkar är synnerligen väl hopfogade i hörnen - ett sant mästerverk av byggnadskonst; även dessa har fönster högt uppe i taken, för att dagsljuset skall kunna strömma in och ge alla därinne full belysning. Stenhusen har dörröppningar i förhållande till byggnadens storlek, men smala fönstergluggar, som skydd mot den stränga kölden, frosten och snön. Vore de större och vidare, såsom fönstren i Italien, skulle husen i följd av den fint yrande snön, som röres upp av den starka blåsten, precis som dammet av virvelvinden, snart nog fyllas med massor av snö och inte kunna stå emot dess tryck, utan störta samman. -` - - data := []struct { - pType string - testData string - }{ - {"JSON", JSON}, - {"TOML", TOML}, - {"YAML", YAML}, - {"None", NONE}, - } - for _, v := range data { - p := GetParser([]byte(v.testData)) - if v.pType != p.Type() { - t.Fatalf("Wrong parser type, expected %v, got %v", v.pType, p.Type()) - } - md := p.Markdown() - if strings.TrimSpace(string(md)) != strings.TrimSpace(expectedBody) { - t.Log("Provided:", v.testData) - t.Log("Returned:", p.Markdown()) - t.Fatalf("Error, mismatched body in expected type %v, matched type %v", v.pType, p.Type()) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_toml.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_toml.go deleted file mode 100644 index 75c2067..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_toml.go +++ /dev/null @@ -1,44 +0,0 @@ -package metadata - -import ( - "bytes" - - "github.com/BurntSushi/toml" -) - -// TOMLMetadataParser is the MetadataParser for TOML -type TOMLMetadataParser struct { - metadata Metadata - markdown *bytes.Buffer -} - -func (t *TOMLMetadataParser) Type() string { - return "TOML" -} - -// Parse metadata/markdown file -func (t *TOMLMetadataParser) Init(b *bytes.Buffer) bool { - meta, data := splitBuffer(b, "+++") - if meta == nil || data == nil { - return false - } - t.markdown = data - - m := make(map[string]interface{}) - if err := toml.Unmarshal(meta.Bytes(), &m); err != nil { - return false - } - t.metadata = NewMetadata(m) - - return true -} - -// Metadata returns parsed metadata. It should be called -// only after a call to Parse returns without error. -func (t *TOMLMetadataParser) Metadata() Metadata { - return t.metadata -} - -func (t *TOMLMetadataParser) Markdown() []byte { - return t.markdown.Bytes() -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_yaml.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_yaml.go deleted file mode 100644 index f7ef5bb..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/metadata/metadata_yaml.go +++ /dev/null @@ -1,43 +0,0 @@ -package metadata - -import ( - "bytes" - - "gopkg.in/yaml.v2" -) - -// YAMLMetadataParser is the MetadataParser for YAML -type YAMLMetadataParser struct { - metadata Metadata - markdown *bytes.Buffer -} - -func (y *YAMLMetadataParser) Type() string { - return "YAML" -} - -func (y *YAMLMetadataParser) Init(b *bytes.Buffer) bool { - meta, data := splitBuffer(b, "---") - if meta == nil || data == nil { - return false - } - y.markdown = data - - m := make(map[string]interface{}) - if err := yaml.Unmarshal(meta.Bytes(), &m); err != nil { - return false - } - y.metadata = NewMetadata(m) - - return true -} - -// Metadata returns parsed metadata. It should be called -// only after a call to Parse returns without error. -func (y *YAMLMetadataParser) Metadata() Metadata { - return y.metadata -} - -func (y *YAMLMetadataParser) Markdown() []byte { - return y.markdown.Bytes() -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/process.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/process.go deleted file mode 100644 index 32c887c..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/process.go +++ /dev/null @@ -1,74 +0,0 @@ -package markdown - -import ( - "io" - "io/ioutil" - "os" - - "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/mholt/caddy/caddyhttp/markdown/metadata" - "github.com/mholt/caddy/caddyhttp/markdown/summary" - "github.com/russross/blackfriday" -) - -type FileInfo struct { - os.FileInfo - ctx httpserver.Context -} - -func (f FileInfo) Summarize(wordcount int) (string, error) { - fp, err := f.ctx.Root.Open(f.Name()) - if err != nil { - return "", err - } - defer fp.Close() - - buf, err := ioutil.ReadAll(fp) - if err != nil { - return "", err - } - - return string(summary.Markdown(buf, wordcount)), nil -} - -// Markdown processes the contents of a page in b. It parses the metadata -// (if any) and uses the template (if found). -func (c *Config) Markdown(title string, r io.Reader, dirents []os.FileInfo, ctx httpserver.Context) ([]byte, error) { - body, err := ioutil.ReadAll(r) - if err != nil { - return nil, err - } - - parser := metadata.GetParser(body) - markdown := parser.Markdown() - mdata := parser.Metadata() - - // process markdown - extns := 0 - extns |= blackfriday.EXTENSION_TABLES - extns |= blackfriday.EXTENSION_FENCED_CODE - extns |= blackfriday.EXTENSION_STRIKETHROUGH - extns |= blackfriday.EXTENSION_DEFINITION_LISTS - html := blackfriday.Markdown(markdown, c.Renderer, extns) - - // set it as body for template - mdata.Variables["body"] = string(html) - - // fixup title - mdata.Variables["title"] = mdata.Title - if mdata.Variables["title"] == "" { - mdata.Variables["title"] = title - } - - // massage possible files - files := []FileInfo{} - for _, ent := range dirents { - file := FileInfo{ - FileInfo: ent, - ctx: ctx, - } - files = append(files, file) - } - - return execTemplate(c, mdata, files, ctx) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/setup.go deleted file mode 100644 index 5c15417..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/setup.go +++ /dev/null @@ -1,140 +0,0 @@ -package markdown - -import ( - "net/http" - "path/filepath" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/russross/blackfriday" -) - -func init() { - caddy.RegisterPlugin("markdown", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Markdown middleware instance. -func setup(c *caddy.Controller) error { - mdconfigs, err := markdownParse(c) - if err != nil { - return err - } - - cfg := httpserver.GetConfig(c.Key) - - md := Markdown{ - Root: cfg.Root, - FileSys: http.Dir(cfg.Root), - Configs: mdconfigs, - IndexFiles: []string{"index.md"}, - } - - cfg.AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - md.Next = next - return md - }) - - return nil -} - -func markdownParse(c *caddy.Controller) ([]*Config, error) { - var mdconfigs []*Config - - for c.Next() { - md := &Config{ - Renderer: blackfriday.HtmlRenderer(0, "", ""), - Extensions: make(map[string]struct{}), - Template: GetDefaultTemplate(), - } - - // Get the path scope - args := c.RemainingArgs() - switch len(args) { - case 0: - md.PathScope = "/" - case 1: - md.PathScope = args[0] - default: - return mdconfigs, c.ArgErr() - } - - // Load any other configuration parameters - for c.NextBlock() { - if err := loadParams(c, md); err != nil { - return mdconfigs, err - } - } - - // If no extensions were specified, assume some defaults - if len(md.Extensions) == 0 { - md.Extensions[".md"] = struct{}{} - md.Extensions[".markdown"] = struct{}{} - md.Extensions[".mdown"] = struct{}{} - } - - mdconfigs = append(mdconfigs, md) - } - - return mdconfigs, nil -} - -func loadParams(c *caddy.Controller, mdc *Config) error { - cfg := httpserver.GetConfig(c.Key) - - switch c.Val() { - case "ext": - for _, ext := range c.RemainingArgs() { - mdc.Extensions[ext] = struct{}{} - } - return nil - case "css": - if !c.NextArg() { - return c.ArgErr() - } - mdc.Styles = append(mdc.Styles, c.Val()) - return nil - case "js": - if !c.NextArg() { - return c.ArgErr() - } - mdc.Scripts = append(mdc.Scripts, c.Val()) - return nil - case "template": - tArgs := c.RemainingArgs() - switch len(tArgs) { - default: - return c.ArgErr() - case 1: - fpath := filepath.ToSlash(filepath.Clean(cfg.Root + string(filepath.Separator) + tArgs[0])) - - if err := SetTemplate(mdc.Template, "", fpath); err != nil { - c.Errf("default template parse error: %v", err) - } - return nil - case 2: - fpath := filepath.ToSlash(filepath.Clean(cfg.Root + string(filepath.Separator) + tArgs[1])) - - if err := SetTemplate(mdc.Template, tArgs[0], fpath); err != nil { - c.Errf("template parse error: %v", err) - } - return nil - } - case "templatedir": - if !c.NextArg() { - return c.ArgErr() - } - _, err := mdc.Template.ParseGlob(c.Val()) - if err != nil { - c.Errf("template load error: %v", err) - } - if c.NextArg() { - return c.ArgErr() - } - return nil - default: - return c.Err("Expected valid markdown configuration property") - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/setup_test.go deleted file mode 100644 index 2880a23..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/setup_test.go +++ /dev/null @@ -1,152 +0,0 @@ -package markdown - -import ( - "bytes" - "fmt" - "net/http" - "testing" - "text/template" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`markdown /blog`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Markdown) - - if !ok { - t.Fatalf("Expected handler to be type Markdown, got: %#v", handler) - } - - if myHandler.Configs[0].PathScope != "/blog" { - t.Errorf("Expected /blog as the Path Scope") - } - if len(myHandler.Configs[0].Extensions) != 3 { - t.Error("Expected 3 markdown extensions") - } - for _, key := range []string{".md", ".markdown", ".mdown"} { - if ext, ok := myHandler.Configs[0].Extensions[key]; !ok { - t.Errorf("Expected extensions to contain %v", ext) - } - } -} - -func TestMarkdownParse(t *testing.T) { - tests := []struct { - inputMarkdownConfig string - shouldErr bool - expectedMarkdownConfig []Config - }{ - - {`markdown /blog { - ext .md .txt - css /resources/css/blog.css - js /resources/js/blog.js -}`, false, []Config{{ - PathScope: "/blog", - Extensions: map[string]struct{}{ - ".md": {}, - ".txt": {}, - }, - Styles: []string{"/resources/css/blog.css"}, - Scripts: []string{"/resources/js/blog.js"}, - Template: GetDefaultTemplate(), - }}}, - {`markdown /blog { - ext .md - template tpl_with_include.html -}`, false, []Config{{ - PathScope: "/blog", - Extensions: map[string]struct{}{ - ".md": {}, - }, - Template: GetDefaultTemplate(), - }}}, - } - // Setup the extra template - tmpl := tests[1].expectedMarkdownConfig[0].Template - SetTemplate(tmpl, "", "./testdata/tpl_with_include.html") - - for i, test := range tests { - c := caddy.NewTestController(test.inputMarkdownConfig) - httpserver.GetConfig("").Root = "./testdata" - actualMarkdownConfigs, err := markdownParse(c) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - if len(actualMarkdownConfigs) != len(test.expectedMarkdownConfig) { - t.Fatalf("Test %d expected %d no of WebSocket configs, but got %d ", - i, len(test.expectedMarkdownConfig), len(actualMarkdownConfigs)) - } - for j, actualMarkdownConfig := range actualMarkdownConfigs { - - if actualMarkdownConfig.PathScope != test.expectedMarkdownConfig[j].PathScope { - t.Errorf("Test %d expected %dth Markdown PathScope to be %s , but got %s", - i, j, test.expectedMarkdownConfig[j].PathScope, actualMarkdownConfig.PathScope) - } - - if fmt.Sprint(actualMarkdownConfig.Styles) != fmt.Sprint(test.expectedMarkdownConfig[j].Styles) { - t.Errorf("Test %d expected %dth Markdown Config Styles to be %s , but got %s", - i, j, fmt.Sprint(test.expectedMarkdownConfig[j].Styles), fmt.Sprint(actualMarkdownConfig.Styles)) - } - if fmt.Sprint(actualMarkdownConfig.Scripts) != fmt.Sprint(test.expectedMarkdownConfig[j].Scripts) { - t.Errorf("Test %d expected %dth Markdown Config Scripts to be %s , but got %s", - i, j, fmt.Sprint(test.expectedMarkdownConfig[j].Scripts), fmt.Sprint(actualMarkdownConfig.Scripts)) - } - if ok, tx, ty := equalTemplates(actualMarkdownConfig.Template, test.expectedMarkdownConfig[j].Template); !ok { - t.Errorf("Test %d the %dth Markdown Config Templates did not match, expected %s to be %s", i, j, tx, ty) - } - } - } -} - -func equalTemplates(i, j *template.Template) (bool, string, string) { - // Just in case :) - if i == j { - return true, "", "" - } - - // We can't do much here, templates can't really be compared. However, - // we can execute the templates and compare their outputs to be reasonably - // sure that they're the same. - - // This is exceedingly ugly. - ctx := httpserver.Context{ - Root: http.Dir("./testdata"), - } - - md := Data{ - Context: ctx, - Doc: make(map[string]string), - DocFlags: make(map[string]bool), - Styles: []string{"style1"}, - Scripts: []string{"js1"}, - } - md.Doc["title"] = "some title" - md.Doc["body"] = "some body" - - bufi := new(bytes.Buffer) - bufj := new(bytes.Buffer) - - if err := i.Execute(bufi, md); err != nil { - return false, fmt.Sprintf("%v", err), "" - } - if err := j.Execute(bufj, md); err != nil { - return false, "", fmt.Sprintf("%v", err) - } - - return bytes.Equal(bufi.Bytes(), bufj.Bytes()), string(bufi.Bytes()), string(bufj.Bytes()) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/render.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/render.go deleted file mode 100644 index b23affb..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/render.go +++ /dev/null @@ -1,153 +0,0 @@ -package summary - -import ( - "bytes" - - "github.com/russross/blackfriday" -) - -// Ensure we implement the Blackfriday Markdown Renderer interface -var _ blackfriday.Renderer = (*renderer)(nil) - -// renderer renders Markdown to plain-text meant for listings and excerpts, -// and implements the blackfriday.Renderer interface. -// -// Many of the methods are stubs with no output to prevent output of HTML markup. -type renderer struct{} - -// Blocklevel callbacks - -// BlockCode is the code tag callback. -func (r renderer) BlockCode(out *bytes.Buffer, text []byte, land string) {} - -// BlockQuote is the quote tag callback. -func (r renderer) BlockQuote(out *bytes.Buffer, text []byte) {} - -// BlockHtml is the HTML tag callback. -func (r renderer) BlockHtml(out *bytes.Buffer, text []byte) {} - -// Header is the header tag callback. -func (r renderer) Header(out *bytes.Buffer, text func() bool, level int, id string) {} - -// HRule is the horizontal rule tag callback. -func (r renderer) HRule(out *bytes.Buffer) {} - -// List is the list tag callback. -func (r renderer) List(out *bytes.Buffer, text func() bool, flags int) { - // TODO: This is not desired (we'd rather not write lists as part of summary), - // but see this issue: https://github.com/russross/blackfriday/issues/189 - marker := out.Len() - if !text() { - out.Truncate(marker) - } - out.Write([]byte{' '}) -} - -// ListItem is the list item tag callback. -func (r renderer) ListItem(out *bytes.Buffer, text []byte, flags int) {} - -// Paragraph is the paragraph tag callback. This renders simple paragraph text -// into plain text, such that summaries can be easily generated. -func (r renderer) Paragraph(out *bytes.Buffer, text func() bool) { - marker := out.Len() - if !text() { - out.Truncate(marker) - } - out.Write([]byte{' '}) -} - -// Table is the table tag callback. -func (r renderer) Table(out *bytes.Buffer, header []byte, body []byte, columnData []int) {} - -// TableRow is the table row tag callback. -func (r renderer) TableRow(out *bytes.Buffer, text []byte) {} - -// TableHeaderCell is the table header cell tag callback. -func (r renderer) TableHeaderCell(out *bytes.Buffer, text []byte, flags int) {} - -// TableCell is the table cell tag callback. -func (r renderer) TableCell(out *bytes.Buffer, text []byte, flags int) {} - -// Footnotes is the foot notes tag callback. -func (r renderer) Footnotes(out *bytes.Buffer, text func() bool) {} - -// FootnoteItem is the footnote item tag callback. -func (r renderer) FootnoteItem(out *bytes.Buffer, name, text []byte, flags int) {} - -// TitleBlock is the title tag callback. -func (r renderer) TitleBlock(out *bytes.Buffer, text []byte) {} - -// Spanlevel callbacks - -// AutoLink is the autolink tag callback. -func (r renderer) AutoLink(out *bytes.Buffer, link []byte, kind int) {} - -// CodeSpan is the code span tag callback. Outputs a simple Markdown version -// of the code span. -func (r renderer) CodeSpan(out *bytes.Buffer, text []byte) { - out.Write([]byte("`")) - out.Write(text) - out.Write([]byte("`")) -} - -// DoubleEmphasis is the double emphasis tag callback. Outputs a simple -// plain-text version of the input. -func (r renderer) DoubleEmphasis(out *bytes.Buffer, text []byte) { - out.Write(text) -} - -// Emphasis is the emphasis tag callback. Outputs a simple plain-text -// version of the input. -func (r renderer) Emphasis(out *bytes.Buffer, text []byte) { - out.Write(text) -} - -// Image is the image tag callback. -func (r renderer) Image(out *bytes.Buffer, link []byte, title []byte, alt []byte) {} - -// LineBreak is the line break tag callback. -func (r renderer) LineBreak(out *bytes.Buffer) {} - -// Link is the link tag callback. Outputs a sipmle plain-text version -// of the input. -func (r renderer) Link(out *bytes.Buffer, link []byte, title []byte, content []byte) { - out.Write(content) -} - -// RawHtmlTag is the raw HTML tag callback. -func (r renderer) RawHtmlTag(out *bytes.Buffer, tag []byte) {} - -// TripleEmphasis is the triple emphasis tag callback. Outputs a simple plain-text -// version of the input. -func (r renderer) TripleEmphasis(out *bytes.Buffer, text []byte) { - out.Write(text) -} - -// StrikeThrough is the strikethrough tag callback. -func (r renderer) StrikeThrough(out *bytes.Buffer, text []byte) {} - -// FootnoteRef is the footnote ref tag callback. -func (r renderer) FootnoteRef(out *bytes.Buffer, ref []byte, id int) {} - -// Lowlevel callbacks - -// Entity callback. Outputs a simple plain-text version of the input. -func (r renderer) Entity(out *bytes.Buffer, entity []byte) { - out.Write(entity) -} - -// NormalText callback. Outputs a simple plain-text version of the input. -func (r renderer) NormalText(out *bytes.Buffer, text []byte) { - out.Write(text) -} - -// Header and footer - -// DocumentHeader callback. -func (r renderer) DocumentHeader(out *bytes.Buffer) {} - -// DocumentFooter callback. -func (r renderer) DocumentFooter(out *bytes.Buffer) {} - -// GetFlags returns zero. -func (r renderer) GetFlags() int { return 0 } diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/summary.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/summary.go deleted file mode 100644 index e55bba2..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/summary/summary.go +++ /dev/null @@ -1,17 +0,0 @@ -package summary - -import ( - "bytes" - - "github.com/russross/blackfriday" -) - -// Markdown formats input using a plain-text renderer, and -// then returns up to the first `wordcount` words as a summary. -func Markdown(input []byte, wordcount int) []byte { - words := bytes.Fields(blackfriday.Markdown(input, renderer{}, 0)) - if wordcount > len(words) { - wordcount = len(words) - } - return bytes.Join(words[0:wordcount], []byte{' '}) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/markdown/template.go b/vendor/github.com/mholt/caddy/caddyhttp/markdown/template.go deleted file mode 100644 index fcd8f31..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/markdown/template.go +++ /dev/null @@ -1,88 +0,0 @@ -package markdown - -import ( - "bytes" - "io/ioutil" - "text/template" - - "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/mholt/caddy/caddyhttp/markdown/metadata" -) - -// Data represents a markdown document. -type Data struct { - httpserver.Context - Doc map[string]string - DocFlags map[string]bool - Styles []string - Scripts []string - Files []FileInfo -} - -// Include "overrides" the embedded httpserver.Context's Include() -// method so that included files have access to d's fields. -// Note: using {{template 'template-name' .}} instead might be better. -func (d Data) Include(filename string) (string, error) { - return httpserver.ContextInclude(filename, d, d.Root) -} - -// execTemplate executes a template given a requestPath, template, and metadata -func execTemplate(c *Config, mdata metadata.Metadata, files []FileInfo, ctx httpserver.Context) ([]byte, error) { - mdData := Data{ - Context: ctx, - Doc: mdata.Variables, - DocFlags: mdata.Flags, - Styles: c.Styles, - Scripts: c.Scripts, - Files: files, - } - - b := new(bytes.Buffer) - if err := c.Template.ExecuteTemplate(b, mdata.Template, mdData); err != nil { - return nil, err - } - - return b.Bytes(), nil -} - -func SetTemplate(t *template.Template, name, filename string) error { - - // Read template - buf, err := ioutil.ReadFile(filename) - if err != nil { - return err - } - - // Update if exists - if tt := t.Lookup(name); tt != nil { - _, err = tt.Parse(string(buf)) - return err - } - - // Allocate new name if not - _, err = t.New(name).Parse(string(buf)) - return err -} - -func GetDefaultTemplate() *template.Template { - return template.Must(template.New("").Parse(defaultTemplate)) -} - -const ( - defaultTemplate = ` - - - {{.Doc.title}} - - {{- range .Styles}} - - {{- end}} - {{- range .Scripts}} - - {{- end}} - - - {{.Doc.body}} - -` -) diff --git a/vendor/github.com/mholt/caddy/caddyhttp/mime/mime.go b/vendor/github.com/mholt/caddy/caddyhttp/mime/mime.go deleted file mode 100644 index b215fc8..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/mime/mime.go +++ /dev/null @@ -1,31 +0,0 @@ -package mime - -import ( - "net/http" - "path" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Config represent a mime config. Map from extension to mime-type. -// Note, this should be safe with concurrent read access, as this is -// not modified concurrently. -type Config map[string]string - -// Mime sets Content-Type header of requests based on configurations. -type Mime struct { - Next httpserver.Handler - Configs Config -} - -// ServeHTTP implements the httpserver.Handler interface. -func (e Mime) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - // Get a clean /-path, grab the extension - ext := path.Ext(path.Clean(r.URL.Path)) - - if contentType, ok := e.Configs[ext]; ok { - w.Header().Set("Content-Type", contentType) - } - - return e.Next.ServeHTTP(w, r) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/mime/mime_test.go b/vendor/github.com/mholt/caddy/caddyhttp/mime/mime_test.go deleted file mode 100644 index f97fffa..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/mime/mime_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package mime - -import ( - "fmt" - "net/http" - "net/http/httptest" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestMimeHandler(t *testing.T) { - mimes := Config{ - ".html": "text/html", - ".txt": "text/plain", - ".swf": "application/x-shockwave-flash", - } - - m := Mime{Configs: mimes} - - w := httptest.NewRecorder() - exts := []string{ - ".html", ".txt", ".swf", - } - for _, e := range exts { - url := "/file" + e - r, err := http.NewRequest("GET", url, nil) - if err != nil { - t.Error(err) - } - m.Next = nextFunc(true, mimes[e]) - _, err = m.ServeHTTP(w, r) - if err != nil { - t.Error(err) - } - } - - w = httptest.NewRecorder() - exts = []string{ - ".htm1", ".abc", ".mdx", - } - for _, e := range exts { - url := "/file" + e - r, err := http.NewRequest("GET", url, nil) - if err != nil { - t.Error(err) - } - m.Next = nextFunc(false, "") - _, err = m.ServeHTTP(w, r) - if err != nil { - t.Error(err) - } - } -} - -func nextFunc(shouldMime bool, contentType string) httpserver.Handler { - return httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - if shouldMime { - if w.Header().Get("Content-Type") != contentType { - return 0, fmt.Errorf("expected Content-Type: %v, found %v", contentType, r.Header.Get("Content-Type")) - } - return 0, nil - } - if w.Header().Get("Content-Type") != "" { - return 0, fmt.Errorf("Content-Type header not expected") - } - return 0, nil - }) -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/mime/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/mime/setup.go deleted file mode 100644 index 28e31a7..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/mime/setup.go +++ /dev/null @@ -1,74 +0,0 @@ -package mime - -import ( - "fmt" - "strings" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("mime", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new mime middleware instance. -func setup(c *caddy.Controller) error { - configs, err := mimeParse(c) - if err != nil { - return err - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Mime{Next: next, Configs: configs} - }) - - return nil -} - -func mimeParse(c *caddy.Controller) (Config, error) { - configs := Config{} - - for c.Next() { - // At least one extension is required - - args := c.RemainingArgs() - switch len(args) { - case 2: - if err := validateExt(configs, args[0]); err != nil { - return configs, err - } - configs[args[0]] = args[1] - case 1: - return configs, c.ArgErr() - case 0: - for c.NextBlock() { - ext := c.Val() - if err := validateExt(configs, ext); err != nil { - return configs, err - } - if !c.NextArg() { - return configs, c.ArgErr() - } - configs[ext] = c.Val() - } - } - - } - - return configs, nil -} - -// validateExt checks for valid file name extension. -func validateExt(configs Config, ext string) error { - if !strings.HasPrefix(ext, ".") { - return fmt.Errorf(`mime: invalid extension "%v" (must start with dot)`, ext) - } - if _, ok := configs[ext]; ok { - return fmt.Errorf(`mime: duplicate extension "%v" found`, ext) - } - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/mime/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/mime/setup_test.go deleted file mode 100644 index 3d1fce6..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/mime/setup_test.go +++ /dev/null @@ -1,62 +0,0 @@ -package mime - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`mime .txt text/plain`)) - if err != nil { - t.Errorf("Expected no errors, but got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, but had 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Mime) - if !ok { - t.Fatalf("Expected handler to be type Mime, got: %#v", handler) - } - - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } - - tests := []struct { - input string - shouldErr bool - }{ - {`mime {`, true}, - {`mime {}`, true}, - {`mime a b`, true}, - {`mime a {`, true}, - {`mime { txt f } `, true}, - {`mime { html } `, true}, - {`mime { - .html text/html - .txt text/plain - } `, false}, - {`mime { - .foo text/foo - .bar text/bar - .foo text/foobar - } `, true}, - {`mime { .html text/html } `, false}, - {`mime { .html - } `, true}, - {`mime .txt text/plain`, false}, - } - for i, test := range tests { - m, err := mimeParse(caddy.NewTestController(test.input)) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil %v", i, m) - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof.go b/vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof.go deleted file mode 100644 index 9ac0894..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof.go +++ /dev/null @@ -1,41 +0,0 @@ -package pprof - -import ( - "net/http" - pp "net/http/pprof" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// BasePath is the base path to match for all pprof requests. -const BasePath = "/debug/pprof" - -// Handler is a simple struct whose ServeHTTP will delegate pprof -// endpoints to their equivalent net/http/pprof handlers. -type Handler struct { - Next httpserver.Handler - Mux *http.ServeMux -} - -// ServeHTTP handles requests to BasePath with pprof, or passes -// all other requests up the chain. -func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - if httpserver.Path(r.URL.Path).Matches(BasePath) { - h.Mux.ServeHTTP(w, r) - return 0, nil - } - return h.Next.ServeHTTP(w, r) -} - -// NewMux returns a new http.ServeMux that routes pprof requests. -// It pretty much copies what the std lib pprof does on init: -// https://golang.org/src/net/http/pprof/pprof.go#L67 -func NewMux() *http.ServeMux { - mux := http.NewServeMux() - mux.HandleFunc(BasePath+"/", pp.Index) - mux.HandleFunc(BasePath+"/cmdline", pp.Cmdline) - mux.HandleFunc(BasePath+"/profile", pp.Profile) - mux.HandleFunc(BasePath+"/symbol", pp.Symbol) - mux.HandleFunc(BasePath+"/trace", pp.Trace) - return mux -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof_test.go b/vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof_test.go deleted file mode 100644 index 8166586..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/pprof/pprof_test.go +++ /dev/null @@ -1,55 +0,0 @@ -package pprof - -import ( - "fmt" - "net/http" - "net/http/httptest" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestServeHTTP(t *testing.T) { - h := Handler{ - Next: httpserver.HandlerFunc(nextHandler), - Mux: NewMux(), - } - - w := httptest.NewRecorder() - r, err := http.NewRequest("GET", "/debug/pprof", nil) - if err != nil { - t.Fatal(err) - } - status, err := h.ServeHTTP(w, r) - - if status != 0 { - t.Errorf("Expected status %d but got %d", 0, status) - } - if err != nil { - t.Errorf("Expected nil error, but got: %v", err) - } - if w.Body.String() == "content" { - t.Errorf("Expected pprof to handle request, but it didn't") - } - - w = httptest.NewRecorder() - r, err = http.NewRequest("GET", "/foo", nil) - if err != nil { - t.Fatal(err) - } - status, err = h.ServeHTTP(w, r) - if status != http.StatusNotFound { - t.Errorf("Test two: Expected status %d but got %d", http.StatusNotFound, status) - } - if err != nil { - t.Errorf("Test two: Expected nil error, but got: %v", err) - } - if w.Body.String() != "content" { - t.Errorf("Expected pprof to pass the request thru, but it didn't; got: %s", w.Body.String()) - } -} - -func nextHandler(w http.ResponseWriter, r *http.Request) (int, error) { - fmt.Fprintf(w, "content") - return http.StatusNotFound, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/pprof/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/pprof/setup.go deleted file mode 100644 index 7a66cf0..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/pprof/setup.go +++ /dev/null @@ -1,37 +0,0 @@ -package pprof - -import ( - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("pprof", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup returns a new instance of a pprof handler. It accepts no arguments or options. -func setup(c *caddy.Controller) error { - found := false - - for c.Next() { - if found { - return c.Err("pprof can only be specified once") - } - if len(c.RemainingArgs()) != 0 { - return c.ArgErr() - } - if c.NextBlock() { - return c.ArgErr() - } - found = true - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return &Handler{Next: next, Mux: NewMux()} - }) - - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/pprof/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/pprof/setup_test.go deleted file mode 100644 index d53257d..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/pprof/setup_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package pprof - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestSetup(t *testing.T) { - tests := []struct { - input string - shouldErr bool - }{ - {`pprof`, false}, - {`pprof {}`, true}, - {`pprof /foo`, true}, - {`pprof { - a b - }`, true}, - {`pprof - pprof`, true}, - } - for i, test := range tests { - err := setup(caddy.NewTestController(test.input)) - if test.shouldErr && err == nil { - t.Errorf("Test %v: Expected error but found nil", i) - } else if !test.shouldErr && err != nil { - t.Errorf("Test %v: Expected no error but found error: %v", i, err) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/policy.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/policy.go deleted file mode 100644 index 0bf657c..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/policy.go +++ /dev/null @@ -1,103 +0,0 @@ -package proxy - -import ( - "math/rand" - "sync" -) - -// HostPool is a collection of UpstreamHosts. -type HostPool []*UpstreamHost - -// Policy decides how a host will be selected from a pool. -type Policy interface { - Select(pool HostPool) *UpstreamHost -} - -func init() { - RegisterPolicy("random", func() Policy { return &Random{} }) - RegisterPolicy("least_conn", func() Policy { return &LeastConn{} }) - RegisterPolicy("round_robin", func() Policy { return &RoundRobin{} }) -} - -// Random is a policy that selects up hosts from a pool at random. -type Random struct{} - -// Select selects an up host at random from the specified pool. -func (r *Random) Select(pool HostPool) *UpstreamHost { - // instead of just generating a random index - // this is done to prevent selecting a unavailable host - var randHost *UpstreamHost - count := 0 - for _, host := range pool { - if !host.Available() { - continue - } - count++ - if count == 1 { - randHost = host - } else { - r := rand.Int() % count - if r == (count - 1) { - randHost = host - } - } - } - return randHost -} - -// LeastConn is a policy that selects the host with the least connections. -type LeastConn struct{} - -// Select selects the up host with the least number of connections in the -// pool. If more than one host has the same least number of connections, -// one of the hosts is chosen at random. -func (r *LeastConn) Select(pool HostPool) *UpstreamHost { - var bestHost *UpstreamHost - count := 0 - leastConn := int64(1<<63 - 1) - for _, host := range pool { - if !host.Available() { - continue - } - hostConns := host.Conns - if hostConns < leastConn { - bestHost = host - leastConn = hostConns - count = 1 - } else if hostConns == leastConn { - // randomly select host among hosts with least connections - count++ - if count == 1 { - bestHost = host - } else { - r := rand.Int() % count - if r == (count - 1) { - bestHost = host - } - } - } - } - return bestHost -} - -// RoundRobin is a policy that selects hosts based on round robin ordering. -type RoundRobin struct { - robin uint32 - mutex sync.Mutex -} - -// Select selects an up host from the pool using a round robin ordering scheme. -func (r *RoundRobin) Select(pool HostPool) *UpstreamHost { - poolLen := uint32(len(pool)) - r.mutex.Lock() - defer r.mutex.Unlock() - // Return next available host - for i := uint32(0); i < poolLen; i++ { - r.robin++ - host := pool[r.robin%poolLen] - if host.Available() { - return host - } - } - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/policy_test.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/policy_test.go deleted file mode 100644 index 4ef5911..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/policy_test.go +++ /dev/null @@ -1,105 +0,0 @@ -package proxy - -import ( - "net/http" - "net/http/httptest" - "os" - "testing" -) - -var workableServer *httptest.Server - -func TestMain(m *testing.M) { - workableServer = httptest.NewServer(http.HandlerFunc( - func(w http.ResponseWriter, r *http.Request) { - // do nothing - })) - r := m.Run() - workableServer.Close() - os.Exit(r) -} - -type customPolicy struct{} - -func (r *customPolicy) Select(pool HostPool) *UpstreamHost { - return pool[0] -} - -func testPool() HostPool { - pool := []*UpstreamHost{ - { - Name: workableServer.URL, // this should resolve (healthcheck test) - }, - { - Name: "http://shouldnot.resolve", // this shouldn't - }, - { - Name: "http://C", - }, - } - return HostPool(pool) -} - -func TestRoundRobinPolicy(t *testing.T) { - pool := testPool() - rrPolicy := &RoundRobin{} - h := rrPolicy.Select(pool) - // First selected host is 1, because counter starts at 0 - // and increments before host is selected - if h != pool[1] { - t.Error("Expected first round robin host to be second host in the pool.") - } - h = rrPolicy.Select(pool) - if h != pool[2] { - t.Error("Expected second round robin host to be third host in the pool.") - } - h = rrPolicy.Select(pool) - if h != pool[0] { - t.Error("Expected third round robin host to be first host in the pool.") - } - // mark host as down - pool[1].Unhealthy = true - h = rrPolicy.Select(pool) - if h != pool[2] { - t.Error("Expected to skip down host.") - } - // mark host as up - pool[1].Unhealthy = false - - h = rrPolicy.Select(pool) - if h == pool[2] { - t.Error("Expected to balance evenly among healthy hosts") - } - // mark host as full - pool[1].Conns = 1 - pool[1].MaxConns = 1 - h = rrPolicy.Select(pool) - if h != pool[2] { - t.Error("Expected to skip full host.") - } -} - -func TestLeastConnPolicy(t *testing.T) { - pool := testPool() - lcPolicy := &LeastConn{} - pool[0].Conns = 10 - pool[1].Conns = 10 - h := lcPolicy.Select(pool) - if h != pool[2] { - t.Error("Expected least connection host to be third host.") - } - pool[2].Conns = 100 - h = lcPolicy.Select(pool) - if h != pool[0] && h != pool[1] { - t.Error("Expected least connection host to be first or second host.") - } -} - -func TestCustomPolicy(t *testing.T) { - pool := testPool() - customPolicy := &customPolicy{} - h := customPolicy.Select(pool) - if h != pool[0] { - t.Error("Expected custom policy host to be the first host.") - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy.go deleted file mode 100644 index 4cdce97..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy.go +++ /dev/null @@ -1,242 +0,0 @@ -// Package proxy is middleware that proxies HTTP requests. -package proxy - -import ( - "errors" - "net" - "net/http" - "net/url" - "strings" - "sync/atomic" - "time" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -var errUnreachable = errors.New("unreachable backend") - -// Proxy represents a middleware instance that can proxy requests. -type Proxy struct { - Next httpserver.Handler - Upstreams []Upstream -} - -// Upstream manages a pool of proxy upstream hosts. Select should return a -// suitable upstream host, or nil if no such hosts are available. -type Upstream interface { - // The path this upstream host should be routed on - From() string - // Selects an upstream host to be routed to. - Select() *UpstreamHost - // Checks if subpath is not an ignored path - AllowedPath(string) bool -} - -// UpstreamHostDownFunc can be used to customize how Down behaves. -type UpstreamHostDownFunc func(*UpstreamHost) bool - -// UpstreamHost represents a single proxy upstream -type UpstreamHost struct { - Conns int64 // must be first field to be 64-bit aligned on 32-bit systems - Name string // hostname of this upstream host - ReverseProxy *ReverseProxy - Fails int32 - FailTimeout time.Duration - Unhealthy bool - UpstreamHeaders http.Header - DownstreamHeaders http.Header - CheckDown UpstreamHostDownFunc - WithoutPathPrefix string - MaxConns int64 -} - -// Down checks whether the upstream host is down or not. -// Down will try to use uh.CheckDown first, and will fall -// back to some default criteria if necessary. -func (uh *UpstreamHost) Down() bool { - if uh.CheckDown == nil { - // Default settings - return uh.Unhealthy || uh.Fails > 0 - } - return uh.CheckDown(uh) -} - -// Full checks whether the upstream host has reached its maximum connections -func (uh *UpstreamHost) Full() bool { - return uh.MaxConns > 0 && uh.Conns >= uh.MaxConns -} - -// Available checks whether the upstream host is available for proxying to -func (uh *UpstreamHost) Available() bool { - return !uh.Down() && !uh.Full() -} - -// tryDuration is how long to try upstream hosts; failures result in -// immediate retries until this duration ends or we get a nil host. -var tryDuration = 60 * time.Second - -// ServeHTTP satisfies the httpserver.Handler interface. -func (p Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - for _, upstream := range p.Upstreams { - if !httpserver.Path(r.URL.Path).Matches(upstream.From()) || - !upstream.AllowedPath(r.URL.Path) { - continue - } - - var replacer httpserver.Replacer - start := time.Now() - - outreq := createUpstreamRequest(r) - - // Since Select() should give us "up" hosts, keep retrying - // hosts until timeout (or until we get a nil host). - for time.Now().Sub(start) < tryDuration { - host := upstream.Select() - if host == nil { - return http.StatusBadGateway, errUnreachable - } - if rr, ok := w.(*httpserver.ResponseRecorder); ok && rr.Replacer != nil { - rr.Replacer.Set("upstream", host.Name) - } - - outreq.Host = host.Name - if host.UpstreamHeaders != nil { - if replacer == nil { - rHost := r.Host - replacer = httpserver.NewReplacer(r, nil, "") - outreq.Host = rHost - } - if v, ok := host.UpstreamHeaders["Host"]; ok { - outreq.Host = replacer.Replace(v[len(v)-1]) - } - // Modify headers for request that will be sent to the upstream host - upHeaders := createHeadersByRules(host.UpstreamHeaders, r.Header, replacer) - for k, v := range upHeaders { - outreq.Header[k] = v - } - } - - var downHeaderUpdateFn respUpdateFn - if host.DownstreamHeaders != nil { - if replacer == nil { - rHost := r.Host - replacer = httpserver.NewReplacer(r, nil, "") - outreq.Host = rHost - } - //Creates a function that is used to update headers the response received by the reverse proxy - downHeaderUpdateFn = createRespHeaderUpdateFn(host.DownstreamHeaders, replacer) - } - - proxy := host.ReverseProxy - if baseURL, err := url.Parse(host.Name); err == nil { - r.Host = baseURL.Host - if proxy == nil { - proxy = NewSingleHostReverseProxy(baseURL, host.WithoutPathPrefix) - } - } else if proxy == nil { - return http.StatusInternalServerError, err - } - - atomic.AddInt64(&host.Conns, 1) - backendErr := proxy.ServeHTTP(w, outreq, downHeaderUpdateFn) - atomic.AddInt64(&host.Conns, -1) - if backendErr == nil { - return 0, nil - } - timeout := host.FailTimeout - if timeout == 0 { - timeout = 10 * time.Second - } - atomic.AddInt32(&host.Fails, 1) - go func(host *UpstreamHost, timeout time.Duration) { - time.Sleep(timeout) - atomic.AddInt32(&host.Fails, -1) - }(host, timeout) - } - return http.StatusBadGateway, errUnreachable - } - - return p.Next.ServeHTTP(w, r) -} - -// createUpstremRequest shallow-copies r into a new request -// that can be sent upstream. -func createUpstreamRequest(r *http.Request) *http.Request { - outreq := new(http.Request) - *outreq = *r // includes shallow copies of maps, but okay - - // Restore URL Path if it has been modified - if outreq.URL.RawPath != "" { - outreq.URL.Opaque = outreq.URL.RawPath - } - - // Remove hop-by-hop headers to the backend. Especially - // important is "Connection" because we want a persistent - // connection, regardless of what the client sent to us. This - // is modifying the same underlying map from r (shallow - // copied above) so we only copy it if necessary. - for _, h := range hopHeaders { - if outreq.Header.Get(h) != "" { - outreq.Header = make(http.Header) - copyHeader(outreq.Header, r.Header) - outreq.Header.Del(h) - } - } - - if clientIP, _, err := net.SplitHostPort(r.RemoteAddr); err == nil { - // If we aren't the first proxy, retain prior - // X-Forwarded-For information as a comma+space - // separated list and fold multiple headers into one. - if prior, ok := outreq.Header["X-Forwarded-For"]; ok { - clientIP = strings.Join(prior, ", ") + ", " + clientIP - } - outreq.Header.Set("X-Forwarded-For", clientIP) - } - - return outreq -} - -func createRespHeaderUpdateFn(rules http.Header, replacer httpserver.Replacer) respUpdateFn { - return func(resp *http.Response) { - newHeaders := createHeadersByRules(rules, resp.Header, replacer) - for h, v := range newHeaders { - resp.Header[h] = v - } - } -} - -func createHeadersByRules(rules http.Header, base http.Header, repl httpserver.Replacer) http.Header { - newHeaders := make(http.Header) - for header, values := range rules { - if strings.HasPrefix(header, "+") { - header = strings.TrimLeft(header, "+") - add(newHeaders, header, base[header]) - applyEach(values, repl.Replace) - add(newHeaders, header, values) - } else if strings.HasPrefix(header, "-") { - base.Del(strings.TrimLeft(header, "-")) - } else if _, ok := base[header]; ok { - applyEach(values, repl.Replace) - for _, v := range values { - newHeaders.Set(header, v) - } - } else { - applyEach(values, repl.Replace) - add(newHeaders, header, values) - add(newHeaders, header, base[header]) - } - } - return newHeaders -} - -func applyEach(values []string, mapFn func(string) string) { - for i, v := range values { - values[i] = mapFn(v) - } -} - -func add(base http.Header, header string, values []string) { - for _, v := range values { - base.Add(header, v) - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy_test.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy_test.go deleted file mode 100644 index 4c04fd2..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/proxy_test.go +++ /dev/null @@ -1,583 +0,0 @@ -package proxy - -import ( - "bufio" - "bytes" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - "net/http/httptest" - "net/url" - "os" - "path/filepath" - "runtime" - "strings" - "testing" - "time" - - "github.com/mholt/caddy/caddyhttp/httpserver" - - "golang.org/x/net/websocket" -) - -func init() { - tryDuration = 50 * time.Millisecond // prevent tests from hanging -} - -func TestReverseProxy(t *testing.T) { - log.SetOutput(ioutil.Discard) - defer log.SetOutput(os.Stderr) - - var requestReceived bool - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - requestReceived = true - w.Write([]byte("Hello, client")) - })) - defer backend.Close() - - // set up proxy - p := &Proxy{ - Upstreams: []Upstream{newFakeUpstream(backend.URL, false)}, - } - - // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } - w := httptest.NewRecorder() - - p.ServeHTTP(w, r) - - if !requestReceived { - t.Error("Expected backend to receive request, but it didn't") - } - - // Make sure {upstream} placeholder is set - rr := httpserver.NewResponseRecorder(httptest.NewRecorder()) - rr.Replacer = httpserver.NewReplacer(r, rr, "-") - - p.ServeHTTP(rr, r) - - if got, want := rr.Replacer.Replace("{upstream}"), backend.URL; got != want { - t.Errorf("Expected custom placeholder {upstream} to be set (%s), but it wasn't; got: %s", want, got) - } -} - -func TestReverseProxyInsecureSkipVerify(t *testing.T) { - log.SetOutput(ioutil.Discard) - defer log.SetOutput(os.Stderr) - - var requestReceived bool - backend := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - requestReceived = true - w.Write([]byte("Hello, client")) - })) - defer backend.Close() - - // set up proxy - p := &Proxy{ - Upstreams: []Upstream{newFakeUpstream(backend.URL, true)}, - } - - // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } - w := httptest.NewRecorder() - - p.ServeHTTP(w, r) - - if !requestReceived { - t.Error("Even with insecure HTTPS, expected backend to receive request, but it didn't") - } -} - -func TestWebSocketReverseProxyServeHTTPHandler(t *testing.T) { - // No-op websocket backend simply allows the WS connection to be - // accepted then it will be immediately closed. Perfect for testing. - wsNop := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) {})) - defer wsNop.Close() - - // Get proxy to use for the test - p := newWebSocketTestProxy(wsNop.URL) - - // Create client request - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } - r.Header = http.Header{ - "Connection": {"Upgrade"}, - "Upgrade": {"websocket"}, - "Origin": {wsNop.URL}, - "Sec-WebSocket-Key": {"x3JJHMbDL1EzLkh9GBhXDw=="}, - "Sec-WebSocket-Version": {"13"}, - } - - // Capture the request - w := &recorderHijacker{httptest.NewRecorder(), new(fakeConn)} - - // Booya! Do the test. - p.ServeHTTP(w, r) - - // Make sure the backend accepted the WS connection. - // Mostly interested in the Upgrade and Connection response headers - // and the 101 status code. - expected := []byte("HTTP/1.1 101 Switching Protocols\r\nUpgrade: websocket\r\nConnection: Upgrade\r\nSec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=\r\n\r\n") - actual := w.fakeConn.writeBuf.Bytes() - if !bytes.Equal(actual, expected) { - t.Errorf("Expected backend to accept response:\n'%s'\nActually got:\n'%s'", expected, actual) - } -} - -func TestWebSocketReverseProxyFromWSClient(t *testing.T) { - // Echo server allows us to test that socket bytes are properly - // being proxied. - wsEcho := httptest.NewServer(websocket.Handler(func(ws *websocket.Conn) { - io.Copy(ws, ws) - })) - defer wsEcho.Close() - - // Get proxy to use for the test - p := newWebSocketTestProxy(wsEcho.URL) - - // This is a full end-end test, so the proxy handler - // has to be part of a server listening on a port. Our - // WS client will connect to this test server, not - // the echo client directly. - echoProxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - p.ServeHTTP(w, r) - })) - defer echoProxy.Close() - - // Set up WebSocket client - url := strings.Replace(echoProxy.URL, "http://", "ws://", 1) - ws, err := websocket.Dial(url, "", echoProxy.URL) - if err != nil { - t.Fatal(err) - } - defer ws.Close() - - // Send test message - trialMsg := "Is it working?" - websocket.Message.Send(ws, trialMsg) - - // It should be echoed back to us - var actualMsg string - websocket.Message.Receive(ws, &actualMsg) - if actualMsg != trialMsg { - t.Errorf("Expected '%s' but got '%s' instead", trialMsg, actualMsg) - } -} - -func TestUnixSocketProxy(t *testing.T) { - if runtime.GOOS == "windows" { - return - } - - trialMsg := "Is it working?" - - var proxySuccess bool - - // This is our fake "application" we want to proxy to - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - // Request was proxied when this is called - proxySuccess = true - - fmt.Fprint(w, trialMsg) - })) - - // Get absolute path for unix: socket - socketPath, err := filepath.Abs("./test_socket") - if err != nil { - t.Fatalf("Unable to get absolute path: %v", err) - } - - // Change httptest.Server listener to listen to unix: socket - ln, err := net.Listen("unix", socketPath) - if err != nil { - t.Fatalf("Unable to listen: %v", err) - } - ts.Listener = ln - - ts.Start() - defer ts.Close() - - url := strings.Replace(ts.URL, "http://", "unix:", 1) - p := newWebSocketTestProxy(url) - - echoProxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - p.ServeHTTP(w, r) - })) - defer echoProxy.Close() - - res, err := http.Get(echoProxy.URL) - if err != nil { - t.Fatalf("Unable to GET: %v", err) - } - - greeting, err := ioutil.ReadAll(res.Body) - res.Body.Close() - if err != nil { - t.Fatalf("Unable to GET: %v", err) - } - - actualMsg := fmt.Sprintf("%s", greeting) - - if !proxySuccess { - t.Errorf("Expected request to be proxied, but it wasn't") - } - - if actualMsg != trialMsg { - t.Errorf("Expected '%s' but got '%s' instead", trialMsg, actualMsg) - } -} - -func GetHTTPProxy(messageFormat string, prefix string) (*Proxy, *httptest.Server) { - ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, messageFormat, r.URL.String()) - })) - - return newPrefixedWebSocketTestProxy(ts.URL, prefix), ts -} - -func GetSocketProxy(messageFormat string, prefix string) (*Proxy, *httptest.Server, error) { - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, messageFormat, r.URL.String()) - })) - - socketPath, err := filepath.Abs("./test_socket") - if err != nil { - return nil, nil, fmt.Errorf("Unable to get absolute path: %v", err) - } - - ln, err := net.Listen("unix", socketPath) - if err != nil { - return nil, nil, fmt.Errorf("Unable to listen: %v", err) - } - ts.Listener = ln - - ts.Start() - - tsURL := strings.Replace(ts.URL, "http://", "unix:", 1) - - return newPrefixedWebSocketTestProxy(tsURL, prefix), ts, nil -} - -func GetTestServerMessage(p *Proxy, ts *httptest.Server, path string) (string, error) { - echoProxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - p.ServeHTTP(w, r) - })) - - // *httptest.Server is passed so it can be `defer`red properly - defer ts.Close() - defer echoProxy.Close() - - res, err := http.Get(echoProxy.URL + path) - if err != nil { - return "", fmt.Errorf("Unable to GET: %v", err) - } - - greeting, err := ioutil.ReadAll(res.Body) - res.Body.Close() - if err != nil { - return "", fmt.Errorf("Unable to read body: %v", err) - } - - return fmt.Sprintf("%s", greeting), nil -} - -func TestUnixSocketProxyPaths(t *testing.T) { - greeting := "Hello route %s" - - tests := []struct { - url string - prefix string - expected string - }{ - {"", "", fmt.Sprintf(greeting, "/")}, - {"/hello", "", fmt.Sprintf(greeting, "/hello")}, - {"/foo/bar", "", fmt.Sprintf(greeting, "/foo/bar")}, - {"/foo?bar", "", fmt.Sprintf(greeting, "/foo?bar")}, - {"/greet?name=john", "", fmt.Sprintf(greeting, "/greet?name=john")}, - {"/world?wonderful&colorful", "", fmt.Sprintf(greeting, "/world?wonderful&colorful")}, - {"/proxy/hello", "/proxy", fmt.Sprintf(greeting, "/hello")}, - {"/proxy/foo/bar", "/proxy", fmt.Sprintf(greeting, "/foo/bar")}, - {"/proxy/?foo=bar", "/proxy", fmt.Sprintf(greeting, "/?foo=bar")}, - {"/queues/%2F/fetchtasks", "", fmt.Sprintf(greeting, "/queues/%2F/fetchtasks")}, - {"/queues/%2F/fetchtasks?foo=bar", "", fmt.Sprintf(greeting, "/queues/%2F/fetchtasks?foo=bar")}, - } - - for _, test := range tests { - p, ts := GetHTTPProxy(greeting, test.prefix) - - actualMsg, err := GetTestServerMessage(p, ts, test.url) - - if err != nil { - t.Fatalf("Getting server message failed - %v", err) - } - - if actualMsg != test.expected { - t.Errorf("Expected '%s' but got '%s' instead", test.expected, actualMsg) - } - } - - if runtime.GOOS == "windows" { - return - } - - for _, test := range tests { - p, ts, err := GetSocketProxy(greeting, test.prefix) - - if err != nil { - t.Fatalf("Getting socket proxy failed - %v", err) - } - - actualMsg, err := GetTestServerMessage(p, ts, test.url) - - if err != nil { - t.Fatalf("Getting server message failed - %v", err) - } - - if actualMsg != test.expected { - t.Errorf("Expected '%s' but got '%s' instead", test.expected, actualMsg) - } - } -} - -func TestUpstreamHeadersUpdate(t *testing.T) { - log.SetOutput(ioutil.Discard) - defer log.SetOutput(os.Stderr) - - var actualHeaders http.Header - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("Hello, client")) - actualHeaders = r.Header - })) - defer backend.Close() - - upstream := newFakeUpstream(backend.URL, false) - upstream.host.UpstreamHeaders = http.Header{ - "Connection": {"{>Connection}"}, - "Upgrade": {"{>Upgrade}"}, - "+Merge-Me": {"Merge-Value"}, - "+Add-Me": {"Add-Value"}, - "-Remove-Me": {""}, - "Replace-Me": {"{hostname}"}, - } - // set up proxy - p := &Proxy{ - Upstreams: []Upstream{upstream}, - } - - // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } - w := httptest.NewRecorder() - - //add initial headers - r.Header.Add("Merge-Me", "Initial") - r.Header.Add("Remove-Me", "Remove-Value") - r.Header.Add("Replace-Me", "Replace-Value") - - p.ServeHTTP(w, r) - - replacer := httpserver.NewReplacer(r, nil, "") - - headerKey := "Merge-Me" - values, ok := actualHeaders[headerKey] - if !ok { - t.Errorf("Request sent to upstream backend does not contain expected %v header. Expected header to be added", headerKey) - } else if len(values) < 2 && (values[0] != "Initial" || values[1] != replacer.Replace("{hostname}")) { - t.Errorf("Values for proxy header `+Merge-Me` should be merged. Got %v", values) - } - - headerKey = "Add-Me" - if _, ok := actualHeaders[headerKey]; !ok { - t.Errorf("Request sent to upstream backend does not contain expected %v header", headerKey) - } - - headerKey = "Remove-Me" - if _, ok := actualHeaders[headerKey]; ok { - t.Errorf("Request sent to upstream backend should not contain %v header", headerKey) - } - - headerKey = "Replace-Me" - headerValue := replacer.Replace("{hostname}") - value, ok := actualHeaders[headerKey] - if !ok { - t.Errorf("Request sent to upstream backend should not remove %v header", headerKey) - } else if len(value) > 0 && headerValue != value[0] { - t.Errorf("Request sent to upstream backend should replace value of %v header with %v. Instead value was %v", headerKey, headerValue, value) - } - -} - -func TestDownstreamHeadersUpdate(t *testing.T) { - log.SetOutput(ioutil.Discard) - defer log.SetOutput(os.Stderr) - - backend := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("Merge-Me", "Initial") - w.Header().Add("Remove-Me", "Remove-Value") - w.Header().Add("Replace-Me", "Replace-Value") - w.Write([]byte("Hello, client")) - })) - defer backend.Close() - - upstream := newFakeUpstream(backend.URL, false) - upstream.host.DownstreamHeaders = http.Header{ - "+Merge-Me": {"Merge-Value"}, - "+Add-Me": {"Add-Value"}, - "-Remove-Me": {""}, - "Replace-Me": {"{hostname}"}, - } - // set up proxy - p := &Proxy{ - Upstreams: []Upstream{upstream}, - } - - // create request and response recorder - r, err := http.NewRequest("GET", "/", nil) - if err != nil { - t.Fatalf("Failed to create request: %v", err) - } - w := httptest.NewRecorder() - - p.ServeHTTP(w, r) - - replacer := httpserver.NewReplacer(r, nil, "") - actualHeaders := w.Header() - - headerKey := "Merge-Me" - values, ok := actualHeaders[headerKey] - if !ok { - t.Errorf("Downstream response does not contain expected %v header. Expected header should be added", headerKey) - } else if len(values) < 2 && (values[0] != "Initial" || values[1] != replacer.Replace("{hostname}")) { - t.Errorf("Values for header `+Merge-Me` should be merged. Got %v", values) - } - - headerKey = "Add-Me" - if _, ok := actualHeaders[headerKey]; !ok { - t.Errorf("Downstream response does not contain expected %v header", headerKey) - } - - headerKey = "Remove-Me" - if _, ok := actualHeaders[headerKey]; ok { - t.Errorf("Downstream response should not contain %v header received from upstream", headerKey) - } - - headerKey = "Replace-Me" - headerValue := replacer.Replace("{hostname}") - value, ok := actualHeaders[headerKey] - if !ok { - t.Errorf("Downstream response should contain %v header and not remove it", headerKey) - } else if len(value) > 0 && headerValue != value[0] { - t.Errorf("Downstream response should have header %v with value %v. Instead value was %v", headerKey, headerValue, value) - } - -} - -func newFakeUpstream(name string, insecure bool) *fakeUpstream { - uri, _ := url.Parse(name) - u := &fakeUpstream{ - name: name, - host: &UpstreamHost{ - Name: name, - ReverseProxy: NewSingleHostReverseProxy(uri, ""), - }, - } - if insecure { - u.host.ReverseProxy.Transport = InsecureTransport - } - return u -} - -type fakeUpstream struct { - name string - host *UpstreamHost -} - -func (u *fakeUpstream) From() string { - return "/" -} - -func (u *fakeUpstream) Select() *UpstreamHost { - return u.host -} - -func (u *fakeUpstream) AllowedPath(requestPath string) bool { - return true -} - -// newWebSocketTestProxy returns a test proxy that will -// redirect to the specified backendAddr. The function -// also sets up the rules/environment for testing WebSocket -// proxy. -func newWebSocketTestProxy(backendAddr string) *Proxy { - return &Proxy{ - Upstreams: []Upstream{&fakeWsUpstream{name: backendAddr, without: ""}}, - } -} - -func newPrefixedWebSocketTestProxy(backendAddr string, prefix string) *Proxy { - return &Proxy{ - Upstreams: []Upstream{&fakeWsUpstream{name: backendAddr, without: prefix}}, - } -} - -type fakeWsUpstream struct { - name string - without string -} - -func (u *fakeWsUpstream) From() string { - return "/" -} - -func (u *fakeWsUpstream) Select() *UpstreamHost { - uri, _ := url.Parse(u.name) - return &UpstreamHost{ - Name: u.name, - ReverseProxy: NewSingleHostReverseProxy(uri, u.without), - UpstreamHeaders: http.Header{ - "Connection": {"{>Connection}"}, - "Upgrade": {"{>Upgrade}"}}, - } -} - -func (u *fakeWsUpstream) AllowedPath(requestPath string) bool { - return true -} - -// recorderHijacker is a ResponseRecorder that can -// be hijacked. -type recorderHijacker struct { - *httptest.ResponseRecorder - fakeConn *fakeConn -} - -func (rh *recorderHijacker) Hijack() (net.Conn, *bufio.ReadWriter, error) { - return rh.fakeConn, nil, nil -} - -type fakeConn struct { - readBuf bytes.Buffer - writeBuf bytes.Buffer -} - -func (c *fakeConn) LocalAddr() net.Addr { return nil } -func (c *fakeConn) RemoteAddr() net.Addr { return nil } -func (c *fakeConn) SetDeadline(t time.Time) error { return nil } -func (c *fakeConn) SetReadDeadline(t time.Time) error { return nil } -func (c *fakeConn) SetWriteDeadline(t time.Time) error { return nil } -func (c *fakeConn) Close() error { return nil } -func (c *fakeConn) Read(b []byte) (int, error) { return c.readBuf.Read(b) } -func (c *fakeConn) Write(b []byte) (int, error) { return c.writeBuf.Write(b) } diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go deleted file mode 100644 index 5a14aea..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/reverseproxy.go +++ /dev/null @@ -1,269 +0,0 @@ -// This file is adapted from code in the net/http/httputil -// package of the Go standard library, which is by the -// Go Authors, and bears this copyright and license info: -// -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. -// -// This file has been modified from the standard lib to -// meet the needs of the application. - -package proxy - -import ( - "crypto/tls" - "io" - "net" - "net/http" - "net/url" - "strings" - "sync" - "time" -) - -// onExitFlushLoop is a callback set by tests to detect the state of the -// flushLoop() goroutine. -var onExitFlushLoop func() - -// ReverseProxy is an HTTP Handler that takes an incoming request and -// sends it to another server, proxying the response back to the -// client. -type ReverseProxy struct { - // Director must be a function which modifies - // the request into a new request to be sent - // using Transport. Its response is then copied - // back to the original client unmodified. - Director func(*http.Request) - - // The transport used to perform proxy requests. - // If nil, http.DefaultTransport is used. - Transport http.RoundTripper - - // FlushInterval specifies the flush interval - // to flush to the client while copying the - // response body. - // If zero, no periodic flushing is done. - FlushInterval time.Duration -} - -func singleJoiningSlash(a, b string) string { - aslash := strings.HasSuffix(a, "/") - bslash := strings.HasPrefix(b, "/") - switch { - case aslash && bslash: - return a + b[1:] - case !aslash && !bslash: - return a + "/" + b - } - return a + b -} - -// Though the relevant directive prefix is just "unix:", url.Parse -// will - assuming the regular URL scheme - add additional slashes -// as if "unix" was a request protocol. -// What we need is just the path, so if "unix:/var/run/www.socket" -// was the proxy directive, the parsed hostName would be -// "unix:///var/run/www.socket", hence the ambiguous trimming. -func socketDial(hostName string) func(network, addr string) (conn net.Conn, err error) { - return func(network, addr string) (conn net.Conn, err error) { - return net.Dial("unix", hostName[len("unix://"):]) - } -} - -// NewSingleHostReverseProxy returns a new ReverseProxy that rewrites -// URLs to the scheme, host, and base path provided in target. If the -// target's path is "/base" and the incoming request was for "/dir", -// the target request will be for /base/dir. -// Without logic: target's path is "/", incoming is "/api/messages", -// without is "/api", then the target request will be for /messages. -func NewSingleHostReverseProxy(target *url.URL, without string) *ReverseProxy { - targetQuery := target.RawQuery - director := func(req *http.Request) { - if target.Scheme == "unix" { - // to make Dial work with unix URL, - // scheme and host have to be faked - req.URL.Scheme = "http" - req.URL.Host = "socket" - } else { - req.URL.Scheme = target.Scheme - req.URL.Host = target.Host - } - req.URL.Path = singleJoiningSlash(target.Path, req.URL.Path) - if targetQuery == "" || req.URL.RawQuery == "" { - req.URL.RawQuery = targetQuery + req.URL.RawQuery - } else { - req.URL.RawQuery = targetQuery + "&" + req.URL.RawQuery - } - // Trims the path of the socket from the URL path. - // This is done because req.URL passed to your proxied service - // will have the full path of the socket file prefixed to it. - // Calling /test on a server that proxies requests to - // unix:/var/run/www.socket will thus set the requested path - // to /var/run/www.socket/test, rendering paths useless. - if target.Scheme == "unix" { - // See comment on socketDial for the trim - socketPrefix := target.String()[len("unix://"):] - req.URL.Path = strings.TrimPrefix(req.URL.Path, socketPrefix) - } - // We are then safe to remove the `without` prefix. - if without != "" { - req.URL.Path = strings.TrimPrefix(req.URL.Path, without) - } - } - rp := &ReverseProxy{Director: director, FlushInterval: 250 * time.Millisecond} // flushing good for streaming & server-sent events - if target.Scheme == "unix" { - rp.Transport = &http.Transport{ - Dial: socketDial(target.String()), - } - } - return rp -} - -func copyHeader(dst, src http.Header) { - for k, vv := range src { - for _, v := range vv { - dst.Add(k, v) - } - } -} - -// Hop-by-hop headers. These are removed when sent to the backend. -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html -var hopHeaders = []string{ - "Connection", - "Keep-Alive", - "Proxy-Authenticate", - "Proxy-Authorization", - "Te", // canonicalized version of "TE" - "Trailers", - "Transfer-Encoding", - "Upgrade", -} - -// InsecureTransport is used to facilitate HTTPS proxying -// when it is OK for upstream to be using a bad certificate, -// since this transport skips verification. -var InsecureTransport http.RoundTripper = &http.Transport{ - Proxy: http.ProxyFromEnvironment, - Dial: (&net.Dialer{ - Timeout: 30 * time.Second, - KeepAlive: 30 * time.Second, - }).Dial, - TLSHandshakeTimeout: 10 * time.Second, - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, -} - -type respUpdateFn func(resp *http.Response) - -func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request, respUpdateFn respUpdateFn) error { - transport := p.Transport - if transport == nil { - transport = http.DefaultTransport - } - - p.Director(outreq) - outreq.Proto = "HTTP/1.1" - outreq.ProtoMajor = 1 - outreq.ProtoMinor = 1 - outreq.Close = false - - res, err := transport.RoundTrip(outreq) - if err != nil { - return err - } else if respUpdateFn != nil { - respUpdateFn(res) - } - - if res.StatusCode == http.StatusSwitchingProtocols && strings.ToLower(res.Header.Get("Upgrade")) == "websocket" { - res.Body.Close() - hj, ok := rw.(http.Hijacker) - if !ok { - return nil - } - - conn, _, err := hj.Hijack() - if err != nil { - return err - } - defer conn.Close() - - backendConn, err := net.Dial("tcp", outreq.URL.Host) - if err != nil { - return err - } - defer backendConn.Close() - - outreq.Write(backendConn) - - go func() { - io.Copy(backendConn, conn) // write tcp stream to backend. - }() - io.Copy(conn, backendConn) // read tcp stream from backend. - } else { - defer res.Body.Close() - for _, h := range hopHeaders { - res.Header.Del(h) - } - copyHeader(rw.Header(), res.Header) - rw.WriteHeader(res.StatusCode) - p.copyResponse(rw, res.Body) - } - - return nil -} - -func (p *ReverseProxy) copyResponse(dst io.Writer, src io.Reader) { - if p.FlushInterval != 0 { - if wf, ok := dst.(writeFlusher); ok { - mlw := &maxLatencyWriter{ - dst: wf, - latency: p.FlushInterval, - done: make(chan bool), - } - go mlw.flushLoop() - defer mlw.stop() - dst = mlw - } - } - io.Copy(dst, src) -} - -type writeFlusher interface { - io.Writer - http.Flusher -} - -type maxLatencyWriter struct { - dst writeFlusher - latency time.Duration - - lk sync.Mutex // protects Write + Flush - done chan bool -} - -func (m *maxLatencyWriter) Write(p []byte) (int, error) { - m.lk.Lock() - defer m.lk.Unlock() - return m.dst.Write(p) -} - -func (m *maxLatencyWriter) flushLoop() { - t := time.NewTicker(m.latency) - defer t.Stop() - for { - select { - case <-m.done: - if onExitFlushLoop != nil { - onExitFlushLoop() - } - return - case <-t.C: - m.lk.Lock() - m.dst.Flush() - m.lk.Unlock() - } - } -} - -func (m *maxLatencyWriter) stop() { m.done <- true } diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/setup.go deleted file mode 100644 index 6005890..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/setup.go +++ /dev/null @@ -1,25 +0,0 @@ -package proxy - -import ( - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("proxy", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Proxy middleware instance. -func setup(c *caddy.Controller) error { - upstreams, err := NewStaticUpstreams(c.Dispenser) - if err != nil { - return err - } - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Proxy{Next: next, Upstreams: upstreams} - }) - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/setup_test.go deleted file mode 100644 index c48d347..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/setup_test.go +++ /dev/null @@ -1,140 +0,0 @@ -package proxy - -import ( - "reflect" - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - for i, test := range []struct { - input string - shouldErr bool - expectedHosts map[string]struct{} - }{ - // test #0 test usual to destination still works normally - { - "proxy / localhost:80", - false, - map[string]struct{}{ - "http://localhost:80": {}, - }, - }, - - // test #1 test usual to destination with port range - { - "proxy / localhost:8080-8082", - false, - map[string]struct{}{ - "http://localhost:8080": {}, - "http://localhost:8081": {}, - "http://localhost:8082": {}, - }, - }, - - // test #2 test upstream directive - { - "proxy / {\n upstream localhost:8080\n}", - false, - map[string]struct{}{ - "http://localhost:8080": {}, - }, - }, - - // test #3 test upstream directive with port range - { - "proxy / {\n upstream localhost:8080-8081\n}", - false, - map[string]struct{}{ - "http://localhost:8080": {}, - "http://localhost:8081": {}, - }, - }, - - // test #4 test to destination with upstream directive - { - "proxy / localhost:8080 {\n upstream localhost:8081-8082\n}", - false, - map[string]struct{}{ - "http://localhost:8080": {}, - "http://localhost:8081": {}, - "http://localhost:8082": {}, - }, - }, - - // test #5 test with unix sockets - { - "proxy / localhost:8080 {\n upstream unix:/var/foo\n}", - false, - map[string]struct{}{ - "http://localhost:8080": {}, - "unix:/var/foo": {}, - }, - }, - - // test #6 test fail on malformed port range - { - "proxy / localhost:8090-8080", - true, - nil, - }, - - // test #7 test fail on malformed port range 2 - { - "proxy / {\n upstream localhost:80-A\n}", - true, - nil, - }, - - // test #8 test upstreams without ports work correctly - { - "proxy / http://localhost {\n upstream testendpoint\n}", - false, - map[string]struct{}{ - "http://localhost": {}, - "http://testendpoint": {}, - }, - }, - - // test #9 test several upstream directives - { - "proxy / localhost:8080 {\n upstream localhost:8081-8082\n upstream localhost:8083-8085\n}", - false, - map[string]struct{}{ - "http://localhost:8080": {}, - "http://localhost:8081": {}, - "http://localhost:8082": {}, - "http://localhost:8083": {}, - "http://localhost:8084": {}, - "http://localhost:8085": {}, - }, - }, - } { - err := setup(caddy.NewTestController(test.input)) - if err != nil && !test.shouldErr { - t.Errorf("Test case #%d received an error of %v", i, err) - } else if test.shouldErr { - continue - } - - mids := httpserver.GetConfig("").Middleware() - mid := mids[len(mids)-1] - - upstreams := mid(nil).(Proxy).Upstreams - for _, upstream := range upstreams { - val := reflect.ValueOf(upstream).Elem() - hosts := val.FieldByName("Hosts").Interface().(HostPool) - if len(hosts) != len(test.expectedHosts) { - t.Errorf("Test case #%d expected %d hosts but received %d", i, len(test.expectedHosts), len(hosts)) - } else { - for _, host := range hosts { - if _, found := test.expectedHosts[host.Name]; !found { - t.Errorf("Test case #%d has an unexpected host %s", i, host.Name) - } - } - } - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream.go deleted file mode 100644 index 00d23e3..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream.go +++ /dev/null @@ -1,349 +0,0 @@ -package proxy - -import ( - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "path" - "strconv" - "strings" - "time" - - "github.com/mholt/caddy/caddyfile" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -var ( - supportedPolicies = make(map[string]func() Policy) -) - -type staticUpstream struct { - from string - upstreamHeaders http.Header - downstreamHeaders http.Header - Hosts HostPool - Policy Policy - insecureSkipVerify bool - - FailTimeout time.Duration - MaxFails int32 - MaxConns int64 - HealthCheck struct { - Path string - Interval time.Duration - } - WithoutPathPrefix string - IgnoredSubPaths []string -} - -// NewStaticUpstreams parses the configuration input and sets up -// static upstreams for the proxy middleware. -func NewStaticUpstreams(c caddyfile.Dispenser) ([]Upstream, error) { - var upstreams []Upstream - for c.Next() { - upstream := &staticUpstream{ - from: "", - upstreamHeaders: make(http.Header), - downstreamHeaders: make(http.Header), - Hosts: nil, - Policy: &Random{}, - FailTimeout: 10 * time.Second, - MaxFails: 1, - MaxConns: 0, - } - - if !c.Args(&upstream.from) { - return upstreams, c.ArgErr() - } - - var to []string - for _, t := range c.RemainingArgs() { - parsed, err := parseUpstream(t) - if err != nil { - return upstreams, err - } - to = append(to, parsed...) - } - - for c.NextBlock() { - switch c.Val() { - case "upstream": - if !c.NextArg() { - return upstreams, c.ArgErr() - } - parsed, err := parseUpstream(c.Val()) - if err != nil { - return upstreams, err - } - to = append(to, parsed...) - default: - if err := parseBlock(&c, upstream); err != nil { - return upstreams, err - } - } - } - - if len(to) == 0 { - return upstreams, c.ArgErr() - } - - upstream.Hosts = make([]*UpstreamHost, len(to)) - for i, host := range to { - uh, err := upstream.NewHost(host) - if err != nil { - return upstreams, err - } - upstream.Hosts[i] = uh - } - - if upstream.HealthCheck.Path != "" { - go upstream.HealthCheckWorker(nil) - } - upstreams = append(upstreams, upstream) - } - return upstreams, nil -} - -// RegisterPolicy adds a custom policy to the proxy. -func RegisterPolicy(name string, policy func() Policy) { - supportedPolicies[name] = policy -} - -func (u *staticUpstream) From() string { - return u.from -} - -func (u *staticUpstream) NewHost(host string) (*UpstreamHost, error) { - if !strings.HasPrefix(host, "http") && - !strings.HasPrefix(host, "unix:") { - host = "http://" + host - } - uh := &UpstreamHost{ - Name: host, - Conns: 0, - Fails: 0, - FailTimeout: u.FailTimeout, - Unhealthy: false, - UpstreamHeaders: u.upstreamHeaders, - DownstreamHeaders: u.downstreamHeaders, - CheckDown: func(u *staticUpstream) UpstreamHostDownFunc { - return func(uh *UpstreamHost) bool { - if uh.Unhealthy { - return true - } - if uh.Fails >= u.MaxFails && - u.MaxFails != 0 { - return true - } - return false - } - }(u), - WithoutPathPrefix: u.WithoutPathPrefix, - MaxConns: u.MaxConns, - } - - baseURL, err := url.Parse(uh.Name) - if err != nil { - return nil, err - } - - uh.ReverseProxy = NewSingleHostReverseProxy(baseURL, uh.WithoutPathPrefix) - if u.insecureSkipVerify { - uh.ReverseProxy.Transport = InsecureTransport - } - return uh, nil -} - -func parseUpstream(u string) ([]string, error) { - if !strings.HasPrefix(u, "unix:") { - colonIdx := strings.LastIndex(u, ":") - protoIdx := strings.Index(u, "://") - - if colonIdx != -1 && colonIdx != protoIdx { - us := u[:colonIdx] - ports := u[len(us)+1:] - if separators := strings.Count(ports, "-"); separators > 1 { - return nil, fmt.Errorf("port range [%s] is invalid", ports) - } else if separators == 1 { - portsStr := strings.Split(ports, "-") - pIni, err := strconv.Atoi(portsStr[0]) - if err != nil { - return nil, err - } - - pEnd, err := strconv.Atoi(portsStr[1]) - if err != nil { - return nil, err - } - - if pEnd <= pIni { - return nil, fmt.Errorf("port range [%s] is invalid", ports) - } - - hosts := []string{} - for p := pIni; p <= pEnd; p++ { - hosts = append(hosts, fmt.Sprintf("%s:%d", us, p)) - } - return hosts, nil - } - } - } - - return []string{u}, nil - -} - -func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error { - switch c.Val() { - case "policy": - if !c.NextArg() { - return c.ArgErr() - } - policyCreateFunc, ok := supportedPolicies[c.Val()] - if !ok { - return c.ArgErr() - } - u.Policy = policyCreateFunc() - case "fail_timeout": - if !c.NextArg() { - return c.ArgErr() - } - dur, err := time.ParseDuration(c.Val()) - if err != nil { - return err - } - u.FailTimeout = dur - case "max_fails": - if !c.NextArg() { - return c.ArgErr() - } - n, err := strconv.Atoi(c.Val()) - if err != nil { - return err - } - u.MaxFails = int32(n) - case "max_conns": - if !c.NextArg() { - return c.ArgErr() - } - n, err := strconv.ParseInt(c.Val(), 10, 64) - if err != nil { - return err - } - u.MaxConns = n - case "health_check": - if !c.NextArg() { - return c.ArgErr() - } - u.HealthCheck.Path = c.Val() - u.HealthCheck.Interval = 30 * time.Second - if c.NextArg() { - dur, err := time.ParseDuration(c.Val()) - if err != nil { - return err - } - u.HealthCheck.Interval = dur - } - case "header_upstream": - fallthrough - case "proxy_header": - var header, value string - if !c.Args(&header, &value) { - return c.ArgErr() - } - u.upstreamHeaders.Add(header, value) - case "header_downstream": - var header, value string - if !c.Args(&header, &value) { - return c.ArgErr() - } - u.downstreamHeaders.Add(header, value) - case "transparent": - u.upstreamHeaders.Add("Host", "{host}") - u.upstreamHeaders.Add("X-Real-IP", "{remote}") - u.upstreamHeaders.Add("X-Forwarded-Proto", "{scheme}") - case "websocket": - u.upstreamHeaders.Add("Connection", "{>Connection}") - u.upstreamHeaders.Add("Upgrade", "{>Upgrade}") - case "without": - if !c.NextArg() { - return c.ArgErr() - } - u.WithoutPathPrefix = c.Val() - case "except": - ignoredPaths := c.RemainingArgs() - if len(ignoredPaths) == 0 { - return c.ArgErr() - } - u.IgnoredSubPaths = ignoredPaths - case "insecure_skip_verify": - u.insecureSkipVerify = true - default: - return c.Errf("unknown property '%s'", c.Val()) - } - return nil -} - -func (u *staticUpstream) healthCheck() { - for _, host := range u.Hosts { - hostURL := host.Name + u.HealthCheck.Path - if r, err := http.Get(hostURL); err == nil { - io.Copy(ioutil.Discard, r.Body) - r.Body.Close() - host.Unhealthy = r.StatusCode < 200 || r.StatusCode >= 400 - } else { - host.Unhealthy = true - } - } -} - -func (u *staticUpstream) HealthCheckWorker(stop chan struct{}) { - ticker := time.NewTicker(u.HealthCheck.Interval) - u.healthCheck() - for { - select { - case <-ticker.C: - u.healthCheck() - case <-stop: - // TODO: the library should provide a stop channel and global - // waitgroup to allow goroutines started by plugins a chance - // to clean themselves up. - } - } -} - -func (u *staticUpstream) Select() *UpstreamHost { - pool := u.Hosts - if len(pool) == 1 { - if !pool[0].Available() { - return nil - } - return pool[0] - } - allUnavailable := true - for _, host := range pool { - if host.Available() { - allUnavailable = false - break - } - } - if allUnavailable { - return nil - } - - if u.Policy == nil { - return (&Random{}).Select(pool) - } - return u.Policy.Select(pool) -} - -func (u *staticUpstream) AllowedPath(requestPath string) bool { - for _, ignoredSubPath := range u.IgnoredSubPaths { - if httpserver.Path(path.Clean(requestPath)).Matches(path.Join(u.From(), ignoredSubPath)) { - return false - } - } - return true -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream_test.go b/vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream_test.go deleted file mode 100644 index 0378475..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/proxy/upstream_test.go +++ /dev/null @@ -1,175 +0,0 @@ -package proxy - -import ( - "strings" - "testing" - "time" - - "github.com/mholt/caddy/caddyfile" -) - -func TestNewHost(t *testing.T) { - upstream := &staticUpstream{ - FailTimeout: 10 * time.Second, - MaxConns: 1, - MaxFails: 1, - } - - uh, err := upstream.NewHost("example.com") - if err != nil { - t.Error("Expected no error") - } - if uh.Name != "http://example.com" { - t.Error("Expected default schema to be added to Name.") - } - if uh.FailTimeout != upstream.FailTimeout { - t.Error("Expected default FailTimeout to be set.") - } - if uh.MaxConns != upstream.MaxConns { - t.Error("Expected default MaxConns to be set.") - } - if uh.CheckDown == nil { - t.Error("Expected default CheckDown to be set.") - } - if uh.CheckDown(uh) { - t.Error("Expected new host not to be down.") - } - // mark Unhealthy - uh.Unhealthy = true - if !uh.CheckDown(uh) { - t.Error("Expected unhealthy host to be down.") - } - // mark with Fails - uh.Unhealthy = false - uh.Fails = 1 - if !uh.CheckDown(uh) { - t.Error("Expected failed host to be down.") - } -} - -func TestHealthCheck(t *testing.T) { - upstream := &staticUpstream{ - from: "", - Hosts: testPool(), - Policy: &Random{}, - FailTimeout: 10 * time.Second, - MaxFails: 1, - } - upstream.healthCheck() - if upstream.Hosts[0].Down() { - t.Error("Expected first host in testpool to not fail healthcheck.") - } - if !upstream.Hosts[1].Down() { - t.Error("Expected second host in testpool to fail healthcheck.") - } -} - -func TestSelect(t *testing.T) { - upstream := &staticUpstream{ - from: "", - Hosts: testPool()[:3], - Policy: &Random{}, - FailTimeout: 10 * time.Second, - MaxFails: 1, - } - upstream.Hosts[0].Unhealthy = true - upstream.Hosts[1].Unhealthy = true - upstream.Hosts[2].Unhealthy = true - if h := upstream.Select(); h != nil { - t.Error("Expected select to return nil as all host are down") - } - upstream.Hosts[2].Unhealthy = false - if h := upstream.Select(); h == nil { - t.Error("Expected select to not return nil") - } - upstream.Hosts[0].Conns = 1 - upstream.Hosts[0].MaxConns = 1 - upstream.Hosts[1].Conns = 1 - upstream.Hosts[1].MaxConns = 1 - upstream.Hosts[2].Conns = 1 - upstream.Hosts[2].MaxConns = 1 - if h := upstream.Select(); h != nil { - t.Error("Expected select to return nil as all hosts are full") - } - upstream.Hosts[2].Conns = 0 - if h := upstream.Select(); h == nil { - t.Error("Expected select to not return nil") - } -} - -func TestRegisterPolicy(t *testing.T) { - name := "custom" - customPolicy := &customPolicy{} - RegisterPolicy(name, func() Policy { return customPolicy }) - if _, ok := supportedPolicies[name]; !ok { - t.Error("Expected supportedPolicies to have a custom policy.") - } - -} - -func TestAllowedPaths(t *testing.T) { - upstream := &staticUpstream{ - from: "/proxy", - IgnoredSubPaths: []string{"/download", "/static"}, - } - tests := []struct { - url string - expected bool - }{ - {"/proxy", true}, - {"/proxy/dl", true}, - {"/proxy/download", false}, - {"/proxy/download/static", false}, - {"/proxy/static", false}, - {"/proxy/static/download", false}, - {"/proxy/something/download", true}, - {"/proxy/something/static", true}, - {"/proxy//static", false}, - {"/proxy//static//download", false}, - {"/proxy//download", false}, - } - - for i, test := range tests { - allowed := upstream.AllowedPath(test.url) - if test.expected != allowed { - t.Errorf("Test %d: expected %v found %v", i+1, test.expected, allowed) - } - } -} - -func TestParseBlock(t *testing.T) { - tests := []struct { - config string - }{ - // Test #1: transparent preset - {"proxy / localhost:8080 {\n transparent \n}"}, - - // Test #2: transparent preset with another param - {"proxy / localhost:8080 {\n transparent \nproxy_header X-Test Tester \n}"}, - - // Test #3: transparent preset on multiple sites - {"proxy / localhost:8080 {\n transparent \n} \nproxy /api localhost:8081 { \ntransparent \n}"}, - } - - for i, test := range tests { - upstreams, err := NewStaticUpstreams(caddyfile.NewDispenser("Testfile", strings.NewReader(test.config))) - if err != nil { - t.Error("Expected no error. Got:", err.Error()) - } - for _, upstream := range upstreams { - headers := upstream.Select().UpstreamHeaders - - if _, ok := headers["Host"]; !ok { - t.Errorf("Test %d: Could not find the Host header", i+1) - } - - if _, ok := headers["X-Real-Ip"]; !ok { - t.Errorf("Test %d: Could not find the X-Real-Ip header", i+1) - } - - if _, ok := headers["X-Forwarded-Proto"]; !ok { - t.Errorf("Test %d: Could not find the X-Forwarded-Proto header", i+1) - } - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect.go b/vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect.go deleted file mode 100644 index edb7cae..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect.go +++ /dev/null @@ -1,58 +0,0 @@ -// Package redirect is middleware for redirecting certain requests -// to other locations. -package redirect - -import ( - "fmt" - "html" - "net/http" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Redirect is middleware to respond with HTTP redirects -type Redirect struct { - Next httpserver.Handler - Rules []Rule -} - -// ServeHTTP implements the httpserver.Handler interface. -func (rd Redirect) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - for _, rule := range rd.Rules { - if (rule.FromPath == "/" || r.URL.Path == rule.FromPath) && schemeMatches(rule, r) { - to := httpserver.NewReplacer(r, nil, "").Replace(rule.To) - if rule.Meta { - safeTo := html.EscapeString(to) - fmt.Fprintf(w, metaRedir, safeTo, safeTo) - } else { - http.Redirect(w, r, to, rule.Code) - } - return 0, nil - } - } - return rd.Next.ServeHTTP(w, r) -} - -func schemeMatches(rule Rule, req *http.Request) bool { - return (rule.FromScheme == "https" && req.TLS != nil) || - (rule.FromScheme != "https" && req.TLS == nil) -} - -// Rule describes an HTTP redirect rule. -type Rule struct { - FromScheme, FromPath, To string - Code int - Meta bool -} - -// Script tag comes first since that will better imitate a redirect in the browser's -// history, but the meta tag is a fallback for most non-JS clients. -const metaRedir = ` - - - - - - Redirecting... - -` diff --git a/vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect_test.go b/vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect_test.go deleted file mode 100644 index b6f8f74..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/redirect/redirect_test.go +++ /dev/null @@ -1,154 +0,0 @@ -package redirect - -import ( - "bytes" - "crypto/tls" - "io/ioutil" - "net/http" - "net/http/httptest" - "strings" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestRedirect(t *testing.T) { - for i, test := range []struct { - from string - expectedLocation string - expectedCode int - }{ - {"http://localhost/from", "/to", http.StatusMovedPermanently}, - {"http://localhost/a", "/b", http.StatusTemporaryRedirect}, - {"http://localhost/aa", "", http.StatusOK}, - {"http://localhost/", "", http.StatusOK}, - {"http://localhost/a?foo=bar", "/b", http.StatusTemporaryRedirect}, - {"http://localhost/asdf?foo=bar", "", http.StatusOK}, - {"http://localhost/foo#bar", "", http.StatusOK}, - {"http://localhost/a#foo", "/b", http.StatusTemporaryRedirect}, - - // The scheme checks that were added to this package don't actually - // help with redirects because of Caddy's design: a redirect middleware - // for http will always be different than the redirect middleware for - // https because they have to be on different listeners. These tests - // just go to show extra bulletproofing, I guess. - {"http://localhost/scheme", "https://localhost/scheme", http.StatusMovedPermanently}, - {"https://localhost/scheme", "", http.StatusOK}, - {"https://localhost/scheme2", "http://localhost/scheme2", http.StatusMovedPermanently}, - {"http://localhost/scheme2", "", http.StatusOK}, - {"http://localhost/scheme3", "https://localhost/scheme3", http.StatusMovedPermanently}, - {"https://localhost/scheme3", "", http.StatusOK}, - } { - var nextCalled bool - - re := Redirect{ - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - nextCalled = true - return 0, nil - }), - Rules: []Rule{ - {FromPath: "/from", To: "/to", Code: http.StatusMovedPermanently}, - {FromPath: "/a", To: "/b", Code: http.StatusTemporaryRedirect}, - - // These http and https schemes would never actually be mixed in the same - // redirect rule with Caddy because http and https schemes have different listeners, - // so they don't share a redirect rule. So although these tests prove something - // impossible with Caddy, it's extra bulletproofing at very little cost. - {FromScheme: "http", FromPath: "/scheme", To: "https://localhost/scheme", Code: http.StatusMovedPermanently}, - {FromScheme: "https", FromPath: "/scheme2", To: "http://localhost/scheme2", Code: http.StatusMovedPermanently}, - {FromScheme: "", FromPath: "/scheme3", To: "https://localhost/scheme3", Code: http.StatusMovedPermanently}, - }, - } - - req, err := http.NewRequest("GET", test.from, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request: %v", i, err) - } - if strings.HasPrefix(test.from, "https://") { - req.TLS = new(tls.ConnectionState) // faux HTTPS - } - - rec := httptest.NewRecorder() - re.ServeHTTP(rec, req) - - if rec.Header().Get("Location") != test.expectedLocation { - t.Errorf("Test %d: Expected Location header to be %q but was %q", - i, test.expectedLocation, rec.Header().Get("Location")) - } - - if rec.Code != test.expectedCode { - t.Errorf("Test %d: Expected status code to be %d but was %d", - i, test.expectedCode, rec.Code) - } - - if nextCalled && test.expectedLocation != "" { - t.Errorf("Test %d: Next handler was unexpectedly called", i) - } - } -} - -func TestParametersRedirect(t *testing.T) { - re := Redirect{ - Rules: []Rule{ - {FromPath: "/", Meta: false, To: "http://example.com{uri}"}, - }, - } - - req, err := http.NewRequest("GET", "/a?b=c", nil) - if err != nil { - t.Fatalf("Test: Could not create HTTP request: %v", err) - } - - rec := httptest.NewRecorder() - re.ServeHTTP(rec, req) - - if rec.Header().Get("Location") != "http://example.com/a?b=c" { - t.Fatalf("Test: expected location header %q but was %q", "http://example.com/a?b=c", rec.Header().Get("Location")) - } - - re = Redirect{ - Rules: []Rule{ - {FromPath: "/", Meta: false, To: "http://example.com/a{path}?b=c&{query}"}, - }, - } - - req, err = http.NewRequest("GET", "/d?e=f", nil) - if err != nil { - t.Fatalf("Test: Could not create HTTP request: %v", err) - } - - re.ServeHTTP(rec, req) - - if "http://example.com/a/d?b=c&e=f" != rec.Header().Get("Location") { - t.Fatalf("Test: expected location header %q but was %q", "http://example.com/a/d?b=c&e=f", rec.Header().Get("Location")) - } -} - -func TestMetaRedirect(t *testing.T) { - re := Redirect{ - Rules: []Rule{ - {FromPath: "/whatever", Meta: true, To: "/something"}, - {FromPath: "/", Meta: true, To: "https://example.com/"}, - }, - } - - for i, test := range re.Rules { - req, err := http.NewRequest("GET", test.FromPath, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request: %v", i, err) - } - - rec := httptest.NewRecorder() - re.ServeHTTP(rec, req) - - body, err := ioutil.ReadAll(rec.Body) - if err != nil { - t.Fatalf("Test %d: Could not read HTTP response body: %v", i, err) - } - expectedSnippet := `` - if !bytes.Contains(body, []byte(expectedSnippet)) { - t.Errorf("Test %d: Expected Response Body to contain %q but was %q", - i, expectedSnippet, body) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/redirect/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/redirect/setup.go deleted file mode 100644 index bc83811..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/redirect/setup.go +++ /dev/null @@ -1,184 +0,0 @@ -package redirect - -import ( - "net/http" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("redir", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Redirect middleware instance. -func setup(c *caddy.Controller) error { - rules, err := redirParse(c) - if err != nil { - return err - } - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Redirect{Next: next, Rules: rules} - }) - - return nil -} - -func redirParse(c *caddy.Controller) ([]Rule, error) { - var redirects []Rule - - cfg := httpserver.GetConfig(c.Key) - - // setRedirCode sets the redirect code for rule if it can, or returns an error - setRedirCode := func(code string, rule *Rule) error { - if code == "meta" { - rule.Meta = true - } else if codeNumber, ok := httpRedirs[code]; ok { - rule.Code = codeNumber - } else { - return c.Errf("Invalid redirect code '%v'", code) - } - return nil - } - - // checkAndSaveRule checks the rule for validity (except the redir code) - // and saves it if it's valid, or returns an error. - checkAndSaveRule := func(rule Rule) error { - if rule.FromPath == rule.To { - return c.Err("'from' and 'to' values of redirect rule cannot be the same") - } - - for _, otherRule := range redirects { - if otherRule.FromPath == rule.FromPath { - return c.Errf("rule with duplicate 'from' value: %s -> %s", otherRule.FromPath, otherRule.To) - } - } - - redirects = append(redirects, rule) - return nil - } - - for c.Next() { - args := c.RemainingArgs() - - var hadOptionalBlock bool - for c.NextBlock() { - hadOptionalBlock = true - - var rule Rule - - if cfg.TLS.Enabled { - rule.FromScheme = "https" - } else { - rule.FromScheme = "http" - } - - // Set initial redirect code - // BUG: If the code is specified for a whole block and that code is invalid, - // the line number will appear on the first line inside the block, even if that - // line overwrites the block-level code with a valid redirect code. The program - // still functions correctly, but the line number in the error reporting is - // misleading to the user. - if len(args) == 1 { - err := setRedirCode(args[0], &rule) - if err != nil { - return redirects, err - } - } else { - rule.Code = http.StatusMovedPermanently // default code - } - - // RemainingArgs only gets the values after the current token, but in our - // case we want to include the current token to get an accurate count. - insideArgs := append([]string{c.Val()}, c.RemainingArgs()...) - - switch len(insideArgs) { - case 1: - // To specified (catch-all redirect) - // Not sure why user is doing this in a table, as it causes all other redirects to be ignored. - // As such, this feature remains undocumented. - rule.FromPath = "/" - rule.To = insideArgs[0] - case 2: - // From and To specified - rule.FromPath = insideArgs[0] - rule.To = insideArgs[1] - case 3: - // From, To, and Code specified - rule.FromPath = insideArgs[0] - rule.To = insideArgs[1] - err := setRedirCode(insideArgs[2], &rule) - if err != nil { - return redirects, err - } - default: - return redirects, c.ArgErr() - } - - err := checkAndSaveRule(rule) - if err != nil { - return redirects, err - } - } - - if !hadOptionalBlock { - var rule Rule - - if cfg.TLS.Enabled { - rule.FromScheme = "https" - } else { - rule.FromScheme = "http" - } - - rule.Code = http.StatusMovedPermanently // default - - switch len(args) { - case 1: - // To specified (catch-all redirect) - rule.FromPath = "/" - rule.To = args[0] - case 2: - // To and Code specified (catch-all redirect) - rule.FromPath = "/" - rule.To = args[0] - err := setRedirCode(args[1], &rule) - if err != nil { - return redirects, err - } - case 3: - // From, To, and Code specified - rule.FromPath = args[0] - rule.To = args[1] - err := setRedirCode(args[2], &rule) - if err != nil { - return redirects, err - } - default: - return redirects, c.ArgErr() - } - - err := checkAndSaveRule(rule) - if err != nil { - return redirects, err - } - } - } - - return redirects, nil -} - -// httpRedirs is a list of supported HTTP redirect codes. -var httpRedirs = map[string]int{ - "300": http.StatusMultipleChoices, - "301": http.StatusMovedPermanently, - "302": http.StatusFound, // (NOT CORRECT for "Temporary Redirect", see 307) - "303": http.StatusSeeOther, - "304": http.StatusNotModified, - "305": http.StatusUseProxy, - "307": http.StatusTemporaryRedirect, - "308": 308, // Permanent Redirect -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/redirect/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/redirect/setup_test.go deleted file mode 100644 index c4774cf..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/redirect/setup_test.go +++ /dev/null @@ -1,69 +0,0 @@ -package redirect - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - - for j, test := range []struct { - input string - shouldErr bool - expectedRules []Rule - }{ - // test case #0 tests the recognition of a valid HTTP status code defined outside of block statement - {"redir 300 {\n/ /foo\n}", false, []Rule{{FromPath: "/", To: "/foo", Code: 300}}}, - - // test case #1 tests the recognition of an invalid HTTP status code defined outside of block statement - {"redir 9000 {\n/ /foo\n}", true, []Rule{{}}}, - - // test case #2 tests the detection of a valid HTTP status code outside of a block statement being overriden by an invalid HTTP status code inside statement of a block statement - {"redir 300 {\n/ /foo 9000\n}", true, []Rule{{}}}, - - // test case #3 tests the detection of an invalid HTTP status code outside of a block statement being overriden by a valid HTTP status code inside statement of a block statement - {"redir 9000 {\n/ /foo 300\n}", true, []Rule{{}}}, - - // test case #4 tests the recognition of a TO redirection in a block statement.The HTTP status code is set to the default of 301 - MovedPermanently - {"redir 302 {\n/foo\n}", false, []Rule{{FromPath: "/", To: "/foo", Code: 302}}}, - - // test case #5 tests the recognition of a TO and From redirection in a block statement - {"redir {\n/bar /foo 303\n}", false, []Rule{{FromPath: "/bar", To: "/foo", Code: 303}}}, - - // test case #6 tests the recognition of a TO redirection in a non-block statement. The HTTP status code is set to the default of 301 - MovedPermanently - {"redir /foo", false, []Rule{{FromPath: "/", To: "/foo", Code: 301}}}, - - // test case #7 tests the recognition of a TO and From redirection in a non-block statement - {"redir /bar /foo 303", false, []Rule{{FromPath: "/bar", To: "/foo", Code: 303}}}, - - // test case #8 tests the recognition of multiple redirections - {"redir {\n / /foo 304 \n} \n redir {\n /bar /foobar 305 \n}", false, []Rule{{FromPath: "/", To: "/foo", Code: 304}, {FromPath: "/bar", To: "/foobar", Code: 305}}}, - - // test case #9 tests the detection of duplicate redirections - {"redir {\n /bar /foo 304 \n} redir {\n /bar /foo 304 \n}", true, []Rule{{}}}, - } { - err := setup(caddy.NewTestController(test.input)) - if err != nil && !test.shouldErr { - t.Errorf("Test case #%d recieved an error of %v", j, err) - } else if test.shouldErr { - continue - } - mids := httpserver.GetConfig("").Middleware() - recievedRules := mids[len(mids)-1](nil).(Redirect).Rules - - for i, recievedRule := range recievedRules { - if recievedRule.FromPath != test.expectedRules[i].FromPath { - t.Errorf("Test case #%d.%d expected a from path of %s, but recieved a from path of %s", j, i, test.expectedRules[i].FromPath, recievedRule.FromPath) - } - if recievedRule.To != test.expectedRules[i].To { - t.Errorf("Test case #%d.%d expected a TO path of %s, but recieved a TO path of %s", j, i, test.expectedRules[i].To, recievedRule.To) - } - if recievedRule.Code != test.expectedRules[i].Code { - t.Errorf("Test case #%d.%d expected a HTTP status code of %d, but recieved a code of %d", j, i, test.expectedRules[i].Code, recievedRule.Code) - } - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition.go deleted file mode 100644 index 97b0e96..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition.go +++ /dev/null @@ -1,130 +0,0 @@ -package rewrite - -import ( - "fmt" - "net/http" - "regexp" - "strings" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Operators -const ( - Is = "is" - Not = "not" - Has = "has" - NotHas = "not_has" - StartsWith = "starts_with" - EndsWith = "ends_with" - Match = "match" - NotMatch = "not_match" -) - -func operatorError(operator string) error { - return fmt.Errorf("Invalid operator %v", operator) -} - -func newReplacer(r *http.Request) httpserver.Replacer { - return httpserver.NewReplacer(r, nil, "") -} - -// condition is a rewrite condition. -type condition func(string, string) bool - -var conditions = map[string]condition{ - Is: isFunc, - Not: notFunc, - Has: hasFunc, - NotHas: notHasFunc, - StartsWith: startsWithFunc, - EndsWith: endsWithFunc, - Match: matchFunc, - NotMatch: notMatchFunc, -} - -// isFunc is condition for Is operator. -// It checks for equality. -func isFunc(a, b string) bool { - return a == b -} - -// notFunc is condition for Not operator. -// It checks for inequality. -func notFunc(a, b string) bool { - return a != b -} - -// hasFunc is condition for Has operator. -// It checks if b is a substring of a. -func hasFunc(a, b string) bool { - return strings.Contains(a, b) -} - -// notHasFunc is condition for NotHas operator. -// It checks if b is not a substring of a. -func notHasFunc(a, b string) bool { - return !strings.Contains(a, b) -} - -// startsWithFunc is condition for StartsWith operator. -// It checks if b is a prefix of a. -func startsWithFunc(a, b string) bool { - return strings.HasPrefix(a, b) -} - -// endsWithFunc is condition for EndsWith operator. -// It checks if b is a suffix of a. -func endsWithFunc(a, b string) bool { - return strings.HasSuffix(a, b) -} - -// matchFunc is condition for Match operator. -// It does regexp matching of a against pattern in b -// and returns if they match. -func matchFunc(a, b string) bool { - matched, _ := regexp.MatchString(b, a) - return matched -} - -// notMatchFunc is condition for NotMatch operator. -// It does regexp matching of a against pattern in b -// and returns if they do not match. -func notMatchFunc(a, b string) bool { - matched, _ := regexp.MatchString(b, a) - return !matched -} - -// If is statement for a rewrite condition. -type If struct { - A string - Operator string - B string -} - -// True returns true if the condition is true and false otherwise. -// If r is not nil, it replaces placeholders before comparison. -func (i If) True(r *http.Request) bool { - if c, ok := conditions[i.Operator]; ok { - a, b := i.A, i.B - if r != nil { - replacer := newReplacer(r) - a = replacer.Replace(i.A) - b = replacer.Replace(i.B) - } - return c(a, b) - } - return false -} - -// NewIf creates a new If condition. -func NewIf(a, operator, b string) (If, error) { - if _, ok := conditions[operator]; !ok { - return If{}, operatorError(operator) - } - return If{ - A: a, - Operator: operator, - B: b, - }, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition_test.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition_test.go deleted file mode 100644 index 3c3b605..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/condition_test.go +++ /dev/null @@ -1,106 +0,0 @@ -package rewrite - -import ( - "net/http" - "strings" - "testing" -) - -func TestConditions(t *testing.T) { - tests := []struct { - condition string - isTrue bool - }{ - {"a is b", false}, - {"a is a", true}, - {"a not b", true}, - {"a not a", false}, - {"a has a", true}, - {"a has b", false}, - {"ba has b", true}, - {"bab has b", true}, - {"bab has bb", false}, - {"a not_has a", false}, - {"a not_has b", true}, - {"ba not_has b", false}, - {"bab not_has b", false}, - {"bab not_has bb", true}, - {"bab starts_with bb", false}, - {"bab starts_with ba", true}, - {"bab starts_with bab", true}, - {"bab ends_with bb", false}, - {"bab ends_with bab", true}, - {"bab ends_with ab", true}, - {"a match *", false}, - {"a match a", true}, - {"a match .*", true}, - {"a match a.*", true}, - {"a match b.*", false}, - {"ba match b.*", true}, - {"ba match b[a-z]", true}, - {"b0 match b[a-z]", false}, - {"b0a match b[a-z]", false}, - {"b0a match b[a-z]+", false}, - {"b0a match b[a-z0-9]+", true}, - {"a not_match *", true}, - {"a not_match a", false}, - {"a not_match .*", false}, - {"a not_match a.*", false}, - {"a not_match b.*", true}, - {"ba not_match b.*", false}, - {"ba not_match b[a-z]", false}, - {"b0 not_match b[a-z]", true}, - {"b0a not_match b[a-z]", true}, - {"b0a not_match b[a-z]+", true}, - {"b0a not_match b[a-z0-9]+", false}, - } - - for i, test := range tests { - str := strings.Fields(test.condition) - ifCond, err := NewIf(str[0], str[1], str[2]) - if err != nil { - t.Error(err) - } - isTrue := ifCond.True(nil) - if isTrue != test.isTrue { - t.Errorf("Test %v: expected %v found %v", i, test.isTrue, isTrue) - } - } - - invalidOperators := []string{"ss", "and", "if"} - for _, op := range invalidOperators { - _, err := NewIf("a", op, "b") - if err == nil { - t.Errorf("Invalid operator %v used, expected error.", op) - } - } - - replaceTests := []struct { - url string - condition string - isTrue bool - }{ - {"/home", "{uri} match /home", true}, - {"/hom", "{uri} match /home", false}, - {"/hom", "{uri} starts_with /home", false}, - {"/hom", "{uri} starts_with /h", true}, - {"/home/.hiddenfile", `{uri} match \/\.(.*)`, true}, - {"/home/.hiddendir/afile", `{uri} match \/\.(.*)`, true}, - } - - for i, test := range replaceTests { - r, err := http.NewRequest("GET", test.url, nil) - if err != nil { - t.Error(err) - } - str := strings.Fields(test.condition) - ifCond, err := NewIf(str[0], str[1], str[2]) - if err != nil { - t.Error(err) - } - isTrue := ifCond.True(r) - if isTrue != test.isTrue { - t.Errorf("Test %v: expected %v found %v", i, test.isTrue, isTrue) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite.go deleted file mode 100644 index 7567f5d..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite.go +++ /dev/null @@ -1,236 +0,0 @@ -// Package rewrite is middleware for rewriting requests internally to -// a different path. -package rewrite - -import ( - "fmt" - "net/http" - "net/url" - "path" - "path/filepath" - "regexp" - "strings" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// Result is the result of a rewrite -type Result int - -const ( - // RewriteIgnored is returned when rewrite is not done on request. - RewriteIgnored Result = iota - // RewriteDone is returned when rewrite is done on request. - RewriteDone - // RewriteStatus is returned when rewrite is not needed and status code should be set - // for the request. - RewriteStatus -) - -// Rewrite is middleware to rewrite request locations internally before being handled. -type Rewrite struct { - Next httpserver.Handler - FileSys http.FileSystem - Rules []Rule -} - -// ServeHTTP implements the httpserver.Handler interface. -func (rw Rewrite) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { -outer: - for _, rule := range rw.Rules { - switch result := rule.Rewrite(rw.FileSys, r); result { - case RewriteDone: - break outer - case RewriteIgnored: - break - case RewriteStatus: - // only valid for complex rules. - if cRule, ok := rule.(*ComplexRule); ok && cRule.Status != 0 { - return cRule.Status, nil - } - } - } - return rw.Next.ServeHTTP(w, r) -} - -// Rule describes an internal location rewrite rule. -type Rule interface { - // Rewrite rewrites the internal location of the current request. - Rewrite(http.FileSystem, *http.Request) Result -} - -// SimpleRule is a simple rewrite rule. -type SimpleRule struct { - From, To string -} - -// NewSimpleRule creates a new Simple Rule -func NewSimpleRule(from, to string) SimpleRule { - return SimpleRule{from, to} -} - -// Rewrite rewrites the internal location of the current request. -func (s SimpleRule) Rewrite(fs http.FileSystem, r *http.Request) Result { - if s.From == r.URL.Path { - // take note of this rewrite for internal use by fastcgi - // all we need is the URI, not full URL - r.Header.Set(headerFieldName, r.URL.RequestURI()) - - // attempt rewrite - return To(fs, r, s.To, newReplacer(r)) - } - return RewriteIgnored -} - -// ComplexRule is a rewrite rule based on a regular expression -type ComplexRule struct { - // Path base. Request to this path and subpaths will be rewritten - Base string - - // Path to rewrite to - To string - - // If set, neither performs rewrite nor proceeds - // with request. Only returns code. - Status int - - // Extensions to filter by - Exts []string - - // Rewrite conditions - Ifs []If - - *regexp.Regexp -} - -// NewComplexRule creates a new RegexpRule. It returns an error if regexp -// pattern (pattern) or extensions (ext) are invalid. -func NewComplexRule(base, pattern, to string, status int, ext []string, ifs []If) (*ComplexRule, error) { - // validate regexp if present - var r *regexp.Regexp - if pattern != "" { - var err error - r, err = regexp.Compile(pattern) - if err != nil { - return nil, err - } - } - - // validate extensions if present - for _, v := range ext { - if len(v) < 2 || (len(v) < 3 && v[0] == '!') { - // check if no extension is specified - if v != "/" && v != "!/" { - return nil, fmt.Errorf("invalid extension %v", v) - } - } - } - - return &ComplexRule{ - Base: base, - To: to, - Status: status, - Exts: ext, - Ifs: ifs, - Regexp: r, - }, nil -} - -// Rewrite rewrites the internal location of the current request. -func (r *ComplexRule) Rewrite(fs http.FileSystem, req *http.Request) (re Result) { - rPath := req.URL.Path - replacer := newReplacer(req) - - // validate base - if !httpserver.Path(rPath).Matches(r.Base) { - return - } - - // validate extensions - if !r.matchExt(rPath) { - return - } - - // validate regexp if present - if r.Regexp != nil { - // include trailing slash in regexp if present - start := len(r.Base) - if strings.HasSuffix(r.Base, "/") { - start-- - } - - matches := r.FindStringSubmatch(rPath[start:]) - switch len(matches) { - case 0: - // no match - return - default: - // set regexp match variables {1}, {2} ... - - // url escaped values of ? and #. - q, f := url.QueryEscape("?"), url.QueryEscape("#") - - for i := 1; i < len(matches); i++ { - // Special case of unescaped # and ? by stdlib regexp. - // Reverse the unescape. - if strings.ContainsAny(matches[i], "?#") { - matches[i] = strings.NewReplacer("?", q, "#", f).Replace(matches[i]) - } - - replacer.Set(fmt.Sprint(i), matches[i]) - } - } - } - - // validate rewrite conditions - for _, i := range r.Ifs { - if !i.True(req) { - return - } - } - - // if status is present, stop rewrite and return it. - if r.Status != 0 { - return RewriteStatus - } - - // attempt rewrite - return To(fs, req, r.To, replacer) -} - -// matchExt matches rPath against registered file extensions. -// Returns true if a match is found and false otherwise. -func (r *ComplexRule) matchExt(rPath string) bool { - f := filepath.Base(rPath) - ext := path.Ext(f) - if ext == "" { - ext = "/" - } - - mustUse := false - for _, v := range r.Exts { - use := true - if v[0] == '!' { - use = false - v = v[1:] - } - - if use { - mustUse = true - } - - if ext == v { - return use - } - } - - if mustUse { - return false - } - return true -} - -// When a rewrite is performed, this header is added to the request -// and is for internal use only, specifically the fastcgi middleware. -// It contains the original request URI before the rewrite. -const headerFieldName = "Caddy-Rewrite-Original-URI" diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite_test.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite_test.go deleted file mode 100644 index c2c59af..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/rewrite_test.go +++ /dev/null @@ -1,163 +0,0 @@ -package rewrite - -import ( - "fmt" - "net/http" - "net/http/httptest" - "strings" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestRewrite(t *testing.T) { - rw := Rewrite{ - Next: httpserver.HandlerFunc(urlPrinter), - Rules: []Rule{ - NewSimpleRule("/from", "/to"), - NewSimpleRule("/a", "/b"), - NewSimpleRule("/b", "/b{uri}"), - }, - FileSys: http.Dir("."), - } - - regexps := [][]string{ - {"/reg/", ".*", "/to", ""}, - {"/r/", "[a-z]+", "/toaz", "!.html|"}, - {"/url/", "a([a-z0-9]*)s([A-Z]{2})", "/to/{path}", ""}, - {"/ab/", "ab", "/ab?{query}", ".txt|"}, - {"/ab/", "ab", "/ab?type=html&{query}", ".html|"}, - {"/abc/", "ab", "/abc/{file}", ".html|"}, - {"/abcd/", "ab", "/a/{dir}/{file}", ".html|"}, - {"/abcde/", "ab", "/a#{fragment}", ".html|"}, - {"/ab/", `.*\.jpg`, "/ajpg", ""}, - {"/reggrp", `/ad/([0-9]+)([a-z]*)`, "/a{1}/{2}", ""}, - {"/reg2grp", `(.*)`, "/{1}", ""}, - {"/reg3grp", `(.*)/(.*)/(.*)`, "/{1}{2}{3}", ""}, - {"/hashtest", "(.*)", "/{1}", ""}, - } - - for _, regexpRule := range regexps { - var ext []string - if s := strings.Split(regexpRule[3], "|"); len(s) > 1 { - ext = s[:len(s)-1] - } - rule, err := NewComplexRule(regexpRule[0], regexpRule[1], regexpRule[2], 0, ext, nil) - if err != nil { - t.Fatal(err) - } - rw.Rules = append(rw.Rules, rule) - } - - tests := []struct { - from string - expectedTo string - }{ - {"/from", "/to"}, - {"/a", "/b"}, - {"/b", "/b/b"}, - {"/aa", "/aa"}, - {"/", "/"}, - {"/a?foo=bar", "/b?foo=bar"}, - {"/asdf?foo=bar", "/asdf?foo=bar"}, - {"/foo#bar", "/foo#bar"}, - {"/a#foo", "/b#foo"}, - {"/reg/foo", "/to"}, - {"/re", "/re"}, - {"/r/", "/r/"}, - {"/r/123", "/r/123"}, - {"/r/a123", "/toaz"}, - {"/r/abcz", "/toaz"}, - {"/r/z", "/toaz"}, - {"/r/z.html", "/r/z.html"}, - {"/r/z.js", "/toaz"}, - {"/url/asAB", "/to/url/asAB"}, - {"/url/aBsAB", "/url/aBsAB"}, - {"/url/a00sAB", "/to/url/a00sAB"}, - {"/url/a0z0sAB", "/to/url/a0z0sAB"}, - {"/ab/aa", "/ab/aa"}, - {"/ab/ab", "/ab/ab"}, - {"/ab/ab.txt", "/ab"}, - {"/ab/ab.txt?name=name", "/ab?name=name"}, - {"/ab/ab.html?name=name", "/ab?type=html&name=name"}, - {"/abc/ab.html", "/abc/ab.html"}, - {"/abcd/abcd.html", "/a/abcd/abcd.html"}, - {"/abcde/abcde.html", "/a"}, - {"/abcde/abcde.html#1234", "/a#1234"}, - {"/ab/ab.jpg", "/ajpg"}, - {"/reggrp/ad/12", "/a12"}, - {"/reggrp/ad/124a", "/a124/a"}, - {"/reggrp/ad/124abc", "/a124/abc"}, - {"/reg2grp/ad/124abc", "/ad/124abc"}, - {"/reg3grp/ad/aa/66", "/adaa66"}, - {"/reg3grp/ad612/n1n/ab", "/ad612n1nab"}, - {"/hashtest/a%20%23%20test", "/a%20%23%20test"}, - {"/hashtest/a%20%3F%20test", "/a%20%3F%20test"}, - {"/hashtest/a%20%3F%23test", "/a%20%3F%23test"}, - } - - for i, test := range tests { - req, err := http.NewRequest("GET", test.from, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request: %v", i, err) - } - - rec := httptest.NewRecorder() - rw.ServeHTTP(rec, req) - - if rec.Body.String() != test.expectedTo { - t.Errorf("Test %d: Expected URL to be '%s' but was '%s'", - i, test.expectedTo, rec.Body.String()) - } - } - - statusTests := []struct { - status int - base string - to string - regexp string - statusExpected bool - }{ - {400, "/status", "", "", true}, - {400, "/ignore", "", "", false}, - {400, "/", "", "^/ignore", false}, - {400, "/", "", "(.*)", true}, - {400, "/status", "", "", true}, - } - - for i, s := range statusTests { - urlPath := fmt.Sprintf("/status%d", i) - rule, err := NewComplexRule(s.base, s.regexp, s.to, s.status, nil, nil) - if err != nil { - t.Fatalf("Test %d: No error expected for rule but found %v", i, err) - } - rw.Rules = []Rule{rule} - req, err := http.NewRequest("GET", urlPath, nil) - if err != nil { - t.Fatalf("Test %d: Could not create HTTP request: %v", i, err) - } - - rec := httptest.NewRecorder() - code, err := rw.ServeHTTP(rec, req) - if err != nil { - t.Fatalf("Test %d: No error expected for handler but found %v", i, err) - } - if s.statusExpected { - if rec.Body.String() != "" { - t.Errorf("Test %d: Expected empty body but found %s", i, rec.Body.String()) - } - if code != s.status { - t.Errorf("Test %d: Expected status code %d found %d", i, s.status, code) - } - } else { - if code != 0 { - t.Errorf("Test %d: Expected no status code found %d", i, code) - } - } - } -} - -func urlPrinter(w http.ResponseWriter, r *http.Request) (int, error) { - fmt.Fprint(w, r.URL.String()) - return 0, nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup.go deleted file mode 100644 index 9cf3b33..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup.go +++ /dev/null @@ -1,120 +0,0 @@ -package rewrite - -import ( - "net/http" - "strconv" - "strings" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("rewrite", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Rewrite middleware instance. -func setup(c *caddy.Controller) error { - rewrites, err := rewriteParse(c) - if err != nil { - return err - } - - cfg := httpserver.GetConfig(c.Key) - - cfg.AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return Rewrite{ - Next: next, - FileSys: http.Dir(cfg.Root), - Rules: rewrites, - } - }) - - return nil -} - -func rewriteParse(c *caddy.Controller) ([]Rule, error) { - var simpleRules []Rule - var regexpRules []Rule - - for c.Next() { - var rule Rule - var err error - var base = "/" - var pattern, to string - var status int - var ext []string - - args := c.RemainingArgs() - - var ifs []If - - switch len(args) { - case 1: - base = args[0] - fallthrough - case 0: - for c.NextBlock() { - switch c.Val() { - case "r", "regexp": - if !c.NextArg() { - return nil, c.ArgErr() - } - pattern = c.Val() - case "to": - args1 := c.RemainingArgs() - if len(args1) == 0 { - return nil, c.ArgErr() - } - to = strings.Join(args1, " ") - case "ext": - args1 := c.RemainingArgs() - if len(args1) == 0 { - return nil, c.ArgErr() - } - ext = args1 - case "if": - args1 := c.RemainingArgs() - if len(args1) != 3 { - return nil, c.ArgErr() - } - ifCond, err := NewIf(args1[0], args1[1], args1[2]) - if err != nil { - return nil, err - } - ifs = append(ifs, ifCond) - case "status": - if !c.NextArg() { - return nil, c.ArgErr() - } - status, _ = strconv.Atoi(c.Val()) - if status < 200 || (status > 299 && status < 400) || status > 499 { - return nil, c.Err("status must be 2xx or 4xx") - } - default: - return nil, c.ArgErr() - } - } - // ensure to or status is specified - if to == "" && status == 0 { - return nil, c.ArgErr() - } - if rule, err = NewComplexRule(base, pattern, to, status, ext, ifs); err != nil { - return nil, err - } - regexpRules = append(regexpRules, rule) - - // the only unhandled case is 2 and above - default: - rule = NewSimpleRule(args[0], strings.Join(args[1:], " ")) - simpleRules = append(simpleRules, rule) - } - - } - - // put simple rules in front to avoid regexp computation for them - return append(simpleRules, regexpRules...), nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup_test.go deleted file mode 100644 index ec22aa3..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/setup_test.go +++ /dev/null @@ -1,239 +0,0 @@ -package rewrite - -import ( - "fmt" - "regexp" - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`rewrite /from /to`)) - if err != nil { - t.Errorf("Expected no errors, but got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, had 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Rewrite) - if !ok { - t.Fatalf("Expected handler to be type Rewrite, got: %#v", handler) - } - - if !httpserver.SameNext(myHandler.Next, httpserver.EmptyNext) { - t.Error("'Next' field of handler was not set properly") - } - - if len(myHandler.Rules) != 1 { - t.Errorf("Expected handler to have %d rule, has %d instead", 1, len(myHandler.Rules)) - } -} - -func TestRewriteParse(t *testing.T) { - simpleTests := []struct { - input string - shouldErr bool - expected []Rule - }{ - {`rewrite /from /to`, false, []Rule{ - SimpleRule{From: "/from", To: "/to"}, - }}, - {`rewrite /from /to - rewrite a b`, false, []Rule{ - SimpleRule{From: "/from", To: "/to"}, - SimpleRule{From: "a", To: "b"}, - }}, - {`rewrite a`, true, []Rule{}}, - {`rewrite`, true, []Rule{}}, - {`rewrite a b c`, false, []Rule{ - SimpleRule{From: "a", To: "b c"}, - }}, - } - - for i, test := range simpleTests { - actual, err := rewriteParse(caddy.NewTestController(test.input)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } else if err != nil && test.shouldErr { - continue - } - - if len(actual) != len(test.expected) { - t.Fatalf("Test %d expected %d rules, but got %d", - i, len(test.expected), len(actual)) - } - - for j, e := range test.expected { - actualRule := actual[j].(SimpleRule) - expectedRule := e.(SimpleRule) - - if actualRule.From != expectedRule.From { - t.Errorf("Test %d, rule %d: Expected From=%s, got %s", - i, j, expectedRule.From, actualRule.From) - } - - if actualRule.To != expectedRule.To { - t.Errorf("Test %d, rule %d: Expected To=%s, got %s", - i, j, expectedRule.To, actualRule.To) - } - } - } - - regexpTests := []struct { - input string - shouldErr bool - expected []Rule - }{ - {`rewrite { - r .* - to /to /index.php? - }`, false, []Rule{ - &ComplexRule{Base: "/", To: "/to /index.php?", Regexp: regexp.MustCompile(".*")}, - }}, - {`rewrite { - regexp .* - to /to - ext / html txt - }`, false, []Rule{ - &ComplexRule{Base: "/", To: "/to", Exts: []string{"/", "html", "txt"}, Regexp: regexp.MustCompile(".*")}, - }}, - {`rewrite /path { - r rr - to /dest - } - rewrite / { - regexp [a-z]+ - to /to /to2 - } - `, false, []Rule{ - &ComplexRule{Base: "/path", To: "/dest", Regexp: regexp.MustCompile("rr")}, - &ComplexRule{Base: "/", To: "/to /to2", Regexp: regexp.MustCompile("[a-z]+")}, - }}, - {`rewrite { - r .* - }`, true, []Rule{ - &ComplexRule{}, - }}, - {`rewrite { - - }`, true, []Rule{ - &ComplexRule{}, - }}, - {`rewrite /`, true, []Rule{ - &ComplexRule{}, - }}, - {`rewrite { - to /to - if {path} is a - }`, false, []Rule{ - &ComplexRule{Base: "/", To: "/to", Ifs: []If{{A: "{path}", Operator: "is", B: "a"}}}, - }}, - {`rewrite { - status 500 - }`, true, []Rule{ - &ComplexRule{}, - }}, - {`rewrite { - status 400 - }`, false, []Rule{ - &ComplexRule{Base: "/", Status: 400}, - }}, - {`rewrite { - to /to - status 400 - }`, false, []Rule{ - &ComplexRule{Base: "/", To: "/to", Status: 400}, - }}, - {`rewrite { - status 399 - }`, true, []Rule{ - &ComplexRule{}, - }}, - {`rewrite { - status 200 - }`, false, []Rule{ - &ComplexRule{Base: "/", Status: 200}, - }}, - {`rewrite { - to /to - status 200 - }`, false, []Rule{ - &ComplexRule{Base: "/", To: "/to", Status: 200}, - }}, - {`rewrite { - status 199 - }`, true, []Rule{ - &ComplexRule{}, - }}, - {`rewrite { - status 0 - }`, true, []Rule{ - &ComplexRule{}, - }}, - {`rewrite { - to /to - status 0 - }`, true, []Rule{ - &ComplexRule{}, - }}, - } - - for i, test := range regexpTests { - actual, err := rewriteParse(caddy.NewTestController(test.input)) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } else if err != nil && test.shouldErr { - continue - } - - if len(actual) != len(test.expected) { - t.Fatalf("Test %d expected %d rules, but got %d", - i, len(test.expected), len(actual)) - } - - for j, e := range test.expected { - actualRule := actual[j].(*ComplexRule) - expectedRule := e.(*ComplexRule) - - if actualRule.Base != expectedRule.Base { - t.Errorf("Test %d, rule %d: Expected Base=%s, got %s", - i, j, expectedRule.Base, actualRule.Base) - } - - if actualRule.To != expectedRule.To { - t.Errorf("Test %d, rule %d: Expected To=%s, got %s", - i, j, expectedRule.To, actualRule.To) - } - - if fmt.Sprint(actualRule.Exts) != fmt.Sprint(expectedRule.Exts) { - t.Errorf("Test %d, rule %d: Expected Ext=%v, got %v", - i, j, expectedRule.To, actualRule.To) - } - - if actualRule.Regexp != nil { - if actualRule.String() != expectedRule.String() { - t.Errorf("Test %d, rule %d: Expected Pattern=%s, got %s", - i, j, expectedRule.String(), actualRule.String()) - } - } - - if fmt.Sprint(actualRule.Ifs) != fmt.Sprint(expectedRule.Ifs) { - t.Errorf("Test %d, rule %d: Expected Pattern=%s, got %s", - i, j, fmt.Sprint(expectedRule.Ifs), fmt.Sprint(actualRule.Ifs)) - } - - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/testdata/testdir/empty b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/testdata/testdir/empty deleted file mode 100644 index e69de29..0000000 diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/testdata/testfile b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/testdata/testfile deleted file mode 100644 index 7b4d68d..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/testdata/testfile +++ /dev/null @@ -1 +0,0 @@ -empty \ No newline at end of file diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/to.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/to.go deleted file mode 100644 index c49d4da..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/to.go +++ /dev/null @@ -1,94 +0,0 @@ -package rewrite - -import ( - "log" - "net/http" - "net/url" - "path" - "strings" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// To attempts rewrite. It attempts to rewrite to first valid path -// or the last path if none of the paths are valid. -// Returns true if rewrite is successful and false otherwise. -func To(fs http.FileSystem, r *http.Request, to string, replacer httpserver.Replacer) Result { - tos := strings.Fields(to) - - // try each rewrite paths - t := "" - query := "" - for _, v := range tos { - t = replacer.Replace(v) - tparts := strings.SplitN(t, "?", 2) - t = path.Clean(tparts[0]) - - if len(tparts) > 1 { - query = tparts[1] - } - - // add trailing slash for directories, if present - if strings.HasSuffix(v, "/") && !strings.HasSuffix(t, "/") { - t += "/" - } - - // validate file - if isValidFile(fs, t) { - break - } - } - - // validate resulting path - u, err := url.Parse(t) - if err != nil { - // Let the user know we got here. Rewrite is expected but - // the resulting url is invalid. - log.Printf("[ERROR] rewrite: resulting path '%v' is invalid. error: %v", t, err) - return RewriteIgnored - } - - // take note of this rewrite for internal use by fastcgi - // all we need is the URI, not full URL - r.Header.Set(headerFieldName, r.URL.RequestURI()) - - // perform rewrite - r.URL.Path = u.Path - if query != "" { - // overwrite query string if present - r.URL.RawQuery = query - } - if u.Fragment != "" { - // overwrite fragment if present - r.URL.Fragment = u.Fragment - } - - return RewriteDone -} - -// isValidFile checks if file exists on the filesystem. -// if file ends with `/`, it is validated as a directory. -func isValidFile(fs http.FileSystem, file string) bool { - if fs == nil { - return false - } - - f, err := fs.Open(file) - if err != nil { - return false - } - defer f.Close() - - stat, err := f.Stat() - if err != nil { - return false - } - - // directory - if strings.HasSuffix(file, "/") { - return stat.IsDir() - } - - // file - return !stat.IsDir() -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/to_test.go b/vendor/github.com/mholt/caddy/caddyhttp/rewrite/to_test.go deleted file mode 100644 index 75b7156..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/rewrite/to_test.go +++ /dev/null @@ -1,45 +0,0 @@ -package rewrite - -import ( - "net/http" - "net/url" - "testing" -) - -func TestTo(t *testing.T) { - fs := http.Dir("testdata") - tests := []struct { - url string - to string - expected string - }{ - {"/", "/somefiles", "/somefiles"}, - {"/somefiles", "/somefiles /index.php{uri}", "/index.php/somefiles"}, - {"/somefiles", "/testfile /index.php{uri}", "/testfile"}, - {"/somefiles", "/testfile/ /index.php{uri}", "/index.php/somefiles"}, - {"/somefiles", "/somefiles /index.php{uri}", "/index.php/somefiles"}, - {"/?a=b", "/somefiles /index.php?{query}", "/index.php?a=b"}, - {"/?a=b", "/testfile /index.php?{query}", "/testfile?a=b"}, - {"/?a=b", "/testdir /index.php?{query}", "/index.php?a=b"}, - {"/?a=b", "/testdir/ /index.php?{query}", "/testdir/?a=b"}, - {"/test?url=http://caddyserver.com", " /p/{path}?{query}", "/p/test?url=http://caddyserver.com"}, - } - - uri := func(r *url.URL) string { - uri := r.Path - if r.RawQuery != "" { - uri += "?" + r.RawQuery - } - return uri - } - for i, test := range tests { - r, err := http.NewRequest("GET", test.url, nil) - if err != nil { - t.Error(err) - } - To(fs, r, test.to, newReplacer(r)) - if uri(r.URL) != test.expected { - t.Errorf("Test %v: expected %v found %v", i, test.expected, uri(r.URL)) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/root/root.go b/vendor/github.com/mholt/caddy/caddyhttp/root/root.go deleted file mode 100644 index d96309f..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/root/root.go +++ /dev/null @@ -1,41 +0,0 @@ -package root - -import ( - "log" - "os" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("root", caddy.Plugin{ - ServerType: "http", - Action: setupRoot, - }) -} - -func setupRoot(c *caddy.Controller) error { - config := httpserver.GetConfig(c.Key) - - for c.Next() { - if !c.NextArg() { - return c.ArgErr() - } - config.Root = c.Val() - } - - // Check if root path exists - _, err := os.Stat(config.Root) - if err != nil { - if os.IsNotExist(err) { - // Allow this, because the folder might appear later. - // But make sure the user knows! - log.Printf("[WARNING] Root path does not exist: %s", config.Root) - } else { - return c.Errf("Unable to access root path '%s': %v", config.Root, err) - } - } - - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/root/root_test.go b/vendor/github.com/mholt/caddy/caddyhttp/root/root_test.go deleted file mode 100644 index 20b2c7a..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/root/root_test.go +++ /dev/null @@ -1,104 +0,0 @@ -package root - -import ( - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strings" - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestRoot(t *testing.T) { - cfg := httpserver.GetConfig("") - - // Predefined error substrings - parseErrContent := "Parse error:" - unableToAccessErrContent := "Unable to access root path" - - existingDirPath, err := getTempDirPath() - if err != nil { - t.Fatalf("BeforeTest: Failed to find an existing directory for testing! Error was: %v", err) - } - - nonExistingDir := filepath.Join(existingDirPath, "highly_unlikely_to_exist_dir") - - existingFile, err := ioutil.TempFile("", "root_test") - if err != nil { - t.Fatalf("BeforeTest: Failed to create temp file for testing! Error was: %v", err) - } - defer func() { - existingFile.Close() - os.Remove(existingFile.Name()) - }() - - inaccessiblePath := getInaccessiblePath(existingFile.Name()) - - tests := []struct { - input string - shouldErr bool - expectedRoot string // expected root, set to the controller. Empty for negative cases. - expectedErrContent string // substring from the expected error. Empty for positive cases. - }{ - // positive - { - fmt.Sprintf(`root %s`, nonExistingDir), false, nonExistingDir, "", - }, - { - fmt.Sprintf(`root %s`, existingDirPath), false, existingDirPath, "", - }, - // negative - { - `root `, true, "", parseErrContent, - }, - { - fmt.Sprintf(`root %s`, inaccessiblePath), true, "", unableToAccessErrContent, - }, - { - fmt.Sprintf(`root { - %s - }`, existingDirPath), true, "", parseErrContent, - }, - } - - for i, test := range tests { - c := caddy.NewTestController(test.input) - err := setupRoot(c) - - if test.shouldErr && err == nil { - t.Errorf("Test %d: Expected error but found %s for input %s", i, err, test.input) - } - - if err != nil { - if !test.shouldErr { - t.Errorf("Test %d: Expected no error but found one for input %s. Error was: %v", i, test.input, err) - } - - if !strings.Contains(err.Error(), test.expectedErrContent) { - t.Errorf("Test %d: Expected error to contain: %v, found error: %v, input: %s", i, test.expectedErrContent, err, test.input) - } - } - - // check root only if we are in a positive test. - if !test.shouldErr && test.expectedRoot != cfg.Root { - t.Errorf("Root not correctly set for input %s. Expected: %s, actual: %s", test.input, test.expectedRoot, cfg.Root) - } - } -} - -// getTempDirPath returnes the path to the system temp directory. If it does not exists - an error is returned. -func getTempDirPath() (string, error) { - tempDir := os.TempDir() - _, err := os.Stat(tempDir) - if err != nil { - return "", err - } - return tempDir, nil -} - -func getInaccessiblePath(file string) string { - return filepath.Join("C:", "file\x00name") // null byte in filename is not allowed on Windows AND unix -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver.go b/vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver.go deleted file mode 100644 index a2b874f..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver.go +++ /dev/null @@ -1,171 +0,0 @@ -package staticfiles - -import ( - "fmt" - "math/rand" - "net/http" - "os" - "path" - "path/filepath" - "runtime" - "strconv" - "strings" -) - -// FileServer implements a production-ready file server -// and is the 'default' handler for all requests to Caddy. -// It simply loads and serves the URI requested. FileServer -// is adapted from the one in net/http by the Go authors. -// Significant modifications have been made. -// -// Original license: -// -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. -type FileServer struct { - // Jailed disk access - Root http.FileSystem - - // List of files to treat as "Not Found" - Hide []string -} - -// ServeHTTP serves static files for r according to fs's configuration. -func (fs FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - // r.URL.Path has already been cleaned by Caddy. - if r.URL.Path == "" { - r.URL.Path = "/" - } - return fs.serveFile(w, r, r.URL.Path) -} - -// serveFile writes the specified file to the HTTP response. -// name is '/'-separated, not filepath.Separator. -func (fs FileServer) serveFile(w http.ResponseWriter, r *http.Request, name string) (int, error) { - // Prevent absolute path access on Windows. - // TODO remove when stdlib http.Dir fixes this. - if runtime.GOOS == "windows" { - if filepath.IsAbs(name[1:]) { - return http.StatusNotFound, nil - } - } - - f, err := fs.Root.Open(name) - if err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, nil - } else if os.IsPermission(err) { - return http.StatusForbidden, err - } - // Likely the server is under load and ran out of file descriptors - backoff := int(3 + rand.Int31()%3) // 3–5 seconds to prevent a stampede - w.Header().Set("Retry-After", strconv.Itoa(backoff)) - return http.StatusServiceUnavailable, err - } - defer f.Close() - - d, err := f.Stat() - if err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, nil - } else if os.IsPermission(err) { - return http.StatusForbidden, err - } - // Return a different status code than above so as to distinguish these cases - return http.StatusInternalServerError, err - } - - // redirect to canonical path - url := r.URL.Path - if d.IsDir() { - // Ensure / at end of directory url - if !strings.HasSuffix(url, "/") { - redirect(w, r, path.Base(url)+"/") - return http.StatusMovedPermanently, nil - } - } else { - // Ensure no / at end of file url - if strings.HasSuffix(url, "/") { - redirect(w, r, "../"+path.Base(url)) - return http.StatusMovedPermanently, nil - } - } - - // use contents of an index file, if present, for directory - if d.IsDir() { - for _, indexPage := range IndexPages { - index := strings.TrimSuffix(name, "/") + "/" + indexPage - ff, err := fs.Root.Open(index) - if err == nil { - // this defer does not leak fds because previous iterations - // of the loop must have had an err, so nothing to close - defer ff.Close() - dd, err := ff.Stat() - if err == nil { - name = index - d = dd - f = ff - break - } - } - } - } - - // Still a directory? (we didn't find an index file) - // Return 404 to hide the fact that the folder exists - if d.IsDir() { - return http.StatusNotFound, nil - } - - if fs.isHidden(d) { - return http.StatusNotFound, nil - } - - // Experimental ETag header - e := fmt.Sprintf(`W/"%x-%x"`, d.ModTime().Unix(), d.Size()) - w.Header().Set("ETag", e) - - // Note: Errors generated by ServeContent are written immediately - // to the response. This usually only happens if seeking fails (rare). - http.ServeContent(w, r, d.Name(), d.ModTime(), f) - - return http.StatusOK, nil -} - -// isHidden checks if file with FileInfo d is on hide list. -func (fs FileServer) isHidden(d os.FileInfo) bool { - // If the file is supposed to be hidden, return a 404 - for _, hiddenPath := range fs.Hide { - // Check if the served file is exactly the hidden file. - if hFile, err := fs.Root.Open(hiddenPath); err == nil { - fs, _ := hFile.Stat() - hFile.Close() - if os.SameFile(d, fs) { - return true - } - } - } - return false -} - -// redirect is taken from http.localRedirect of the std lib. It -// sends an HTTP permanent redirect to the client but will -// preserve the query string for the new path. -func redirect(w http.ResponseWriter, r *http.Request, newPath string) { - if q := r.URL.RawQuery; q != "" { - newPath += "?" + q - } - http.Redirect(w, r, newPath, http.StatusMovedPermanently) -} - -// IndexPages is a list of pages that may be understood as -// the "index" files to directories. -var IndexPages = []string{ - "index.html", - "index.htm", - "index.txt", - "default.html", - "default.htm", - "default.txt", -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver_test.go b/vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver_test.go deleted file mode 100644 index 6c77cec..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/staticfiles/fileserver_test.go +++ /dev/null @@ -1,389 +0,0 @@ -package staticfiles - -import ( - "errors" - "net/http" - "net/http/httptest" - "net/url" - "os" - "path/filepath" - "strings" - "testing" - "time" -) - -var ( - ErrCustom = errors.New("Custom Error") - - testDir = filepath.Join(os.TempDir(), "caddy_testdir") - testWebRoot = filepath.Join(testDir, "webroot") -) - -// testFiles is a map with relative paths to test files as keys and file content as values. -// The map represents the following structure: -// - $TEMP/caddy_testdir/ -// '-- unreachable.html -// '-- webroot/ -// '---- file1.html -// '---- dirwithindex/ -// '------ index.html -// '---- dir/ -// '------ file2.html -// '------ hidden.html -var testFiles = map[string]string{ - "unreachable.html": "

must not leak

", - filepath.Join("webroot", "file1.html"): "

file1.html

", - filepath.Join("webroot", "dirwithindex", "index.html"): "

dirwithindex/index.html

", - filepath.Join("webroot", "dir", "file2.html"): "

dir/file2.html

", - filepath.Join("webroot", "dir", "hidden.html"): "

dir/hidden.html

", -} - -// TestServeHTTP covers positive scenarios when serving files. -func TestServeHTTP(t *testing.T) { - - beforeServeHTTPTest(t) - defer afterServeHTTPTest(t) - - fileserver := FileServer{ - Root: http.Dir(testWebRoot), - Hide: []string{"dir/hidden.html"}, - } - - movedPermanently := "Moved Permanently" - - tests := []struct { - url string - - expectedStatus int - expectedBodyContent string - expectedEtag string - }{ - // Test 0 - access without any path - { - url: "https://foo", - expectedStatus: http.StatusNotFound, - }, - // Test 1 - access root (without index.html) - { - url: "https://foo/", - expectedStatus: http.StatusNotFound, - }, - // Test 2 - access existing file - { - url: "https://foo/file1.html", - expectedStatus: http.StatusOK, - expectedBodyContent: testFiles["file1.html"], - expectedEtag: `W/"1e240-13"`, - }, - // Test 3 - access folder with index file with trailing slash - { - url: "https://foo/dirwithindex/", - expectedStatus: http.StatusOK, - expectedBodyContent: testFiles[filepath.Join("dirwithindex", "index.html")], - expectedEtag: `W/"1e240-20"`, - }, - // Test 4 - access folder with index file without trailing slash - { - url: "https://foo/dirwithindex", - expectedStatus: http.StatusMovedPermanently, - expectedBodyContent: movedPermanently, - }, - // Test 5 - access folder without index file - { - url: "https://foo/dir/", - expectedStatus: http.StatusNotFound, - }, - // Test 6 - access folder without trailing slash - { - url: "https://foo/dir", - expectedStatus: http.StatusMovedPermanently, - expectedBodyContent: movedPermanently, - }, - // Test 7 - access file with trailing slash - { - url: "https://foo/file1.html/", - expectedStatus: http.StatusMovedPermanently, - expectedBodyContent: movedPermanently, - }, - // Test 8 - access not existing path - { - url: "https://foo/not_existing", - expectedStatus: http.StatusNotFound, - }, - // Test 9 - access a file, marked as hidden - { - url: "https://foo/dir/hidden.html", - expectedStatus: http.StatusNotFound, - }, - // Test 10 - access a index file directly - { - url: "https://foo/dirwithindex/index.html", - expectedStatus: http.StatusOK, - expectedBodyContent: testFiles[filepath.Join("dirwithindex", "index.html")], - expectedEtag: `W/"1e240-20"`, - }, - // Test 11 - send a request with query params - { - url: "https://foo/dir?param1=val", - expectedStatus: http.StatusMovedPermanently, - expectedBodyContent: movedPermanently, - }, - // Test 12 - attempt to bypass hidden file - { - url: "https://foo/dir/hidden.html%20", - expectedStatus: http.StatusNotFound, - }, - // Test 13 - attempt to bypass hidden file - { - url: "https://foo/dir/hidden.html.", - expectedStatus: http.StatusNotFound, - }, - // Test 14 - attempt to bypass hidden file - { - url: "https://foo/dir/hidden.html.%20", - expectedStatus: http.StatusNotFound, - }, - // Test 15 - attempt to bypass hidden file - { - url: "https://foo/dir/hidden.html%20.", - expectedStatus: http.StatusNotFound, - }, - // Test 16 - serve another file with same name as hidden file. - { - url: "https://foo/hidden.html", - expectedStatus: http.StatusNotFound, - }, - // Test 17 - try to get below the root directory. - { - url: "https://foo/%2f..%2funreachable.html", - expectedStatus: http.StatusNotFound, - }, - } - - for i, test := range tests { - responseRecorder := httptest.NewRecorder() - request, err := http.NewRequest("GET", test.url, nil) - // prevent any URL sanitization within Go: we need unmodified paths here - if u, _ := url.Parse(test.url); u.RawPath != "" { - request.URL.Path = u.RawPath - } - status, err := fileserver.ServeHTTP(responseRecorder, request) - etag := responseRecorder.Header().Get("Etag") - - // check if error matches expectations - if err != nil { - t.Errorf("Test %d: Serving file at %s failed. Error was: %v", i, test.url, err) - } - - // check status code - if test.expectedStatus != status { - t.Errorf("Test %d: Expected status %d, found %d", i, test.expectedStatus, status) - } - - // check etag - if test.expectedEtag != etag { - t.Errorf("Test %d: Expected Etag header %s, found %s", i, test.expectedEtag, etag) - } - - // check body content - if !strings.Contains(responseRecorder.Body.String(), test.expectedBodyContent) { - t.Errorf("Test %d: Expected body to contain %q, found %q", i, test.expectedBodyContent, responseRecorder.Body.String()) - } - } - -} - -// beforeServeHTTPTest creates a test directory with the structure, defined in the variable testFiles -func beforeServeHTTPTest(t *testing.T) { - // make the root test dir - err := os.MkdirAll(testWebRoot, os.ModePerm) - if err != nil { - if !os.IsExist(err) { - t.Fatalf("Failed to create test dir. Error was: %v", err) - return - } - } - - fixedTime := time.Unix(123456, 0) - - for relFile, fileContent := range testFiles { - absFile := filepath.Join(testDir, relFile) - - // make sure the parent directories exist - parentDir := filepath.Dir(absFile) - _, err = os.Stat(parentDir) - if err != nil { - os.MkdirAll(parentDir, os.ModePerm) - } - - // now create the test files - f, err := os.Create(absFile) - if err != nil { - t.Fatalf("Failed to create test file %s. Error was: %v", absFile, err) - return - } - - // and fill them with content - _, err = f.WriteString(fileContent) - if err != nil { - t.Fatalf("Failed to write to %s. Error was: %v", absFile, err) - return - } - f.Close() - - // and set the last modified time - err = os.Chtimes(absFile, fixedTime, fixedTime) - if err != nil { - t.Fatalf("Failed to set file time to %s. Error was: %v", fixedTime, err) - } - } - -} - -// afterServeHTTPTest removes the test dir and all its content -func afterServeHTTPTest(t *testing.T) { - // cleans up everything under the test dir. No need to clean the individual files. - err := os.RemoveAll(testDir) - if err != nil { - t.Fatalf("Failed to clean up test dir %s. Error was: %v", testDir, err) - } -} - -// failingFS implements the http.FileSystem interface. The Open method always returns the error, assigned to err -type failingFS struct { - err error // the error to return when Open is called - fileImpl http.File // inject the file implementation -} - -// Open returns the assigned failingFile and error -func (f failingFS) Open(path string) (http.File, error) { - return f.fileImpl, f.err -} - -// failingFile implements http.File but returns a predefined error on every Stat() method call. -type failingFile struct { - http.File - err error -} - -// Stat returns nil FileInfo and the provided error on every call -func (ff failingFile) Stat() (os.FileInfo, error) { - return nil, ff.err -} - -// Close is noop and returns no error -func (ff failingFile) Close() error { - return nil -} - -// TestServeHTTPFailingFS tests error cases where the Open function fails with various errors. -func TestServeHTTPFailingFS(t *testing.T) { - - tests := []struct { - fsErr error - expectedStatus int - expectedErr error - expectedHeaders map[string]string - }{ - { - fsErr: os.ErrNotExist, - expectedStatus: http.StatusNotFound, - expectedErr: nil, - }, - { - fsErr: os.ErrPermission, - expectedStatus: http.StatusForbidden, - expectedErr: os.ErrPermission, - }, - { - fsErr: ErrCustom, - expectedStatus: http.StatusServiceUnavailable, - expectedErr: ErrCustom, - expectedHeaders: map[string]string{"Retry-After": "5"}, - }, - } - - for i, test := range tests { - // initialize a file server with the failing FileSystem - fileserver := FileServer{Root: failingFS{err: test.fsErr}} - - // prepare the request and response - request, err := http.NewRequest("GET", "https://foo/", nil) - if err != nil { - t.Fatalf("Failed to build request. Error was: %v", err) - } - responseRecorder := httptest.NewRecorder() - - status, actualErr := fileserver.ServeHTTP(responseRecorder, request) - - // check the status - if status != test.expectedStatus { - t.Errorf("Test %d: Expected status %d, found %d", i, test.expectedStatus, status) - } - - // check the error - if actualErr != test.expectedErr { - t.Errorf("Test %d: Expected err %v, found %v", i, test.expectedErr, actualErr) - } - - // check the headers - a special case for server under load - if test.expectedHeaders != nil && len(test.expectedHeaders) > 0 { - for expectedKey, expectedVal := range test.expectedHeaders { - actualVal := responseRecorder.Header().Get(expectedKey) - if expectedVal != actualVal { - t.Errorf("Test %d: Expected header %s: %s, found %s", i, expectedKey, expectedVal, actualVal) - } - } - } - } -} - -// TestServeHTTPFailingStat tests error cases where the initial Open function succeeds, but the Stat method on the opened file fails. -func TestServeHTTPFailingStat(t *testing.T) { - - tests := []struct { - statErr error - expectedStatus int - expectedErr error - }{ - { - statErr: os.ErrNotExist, - expectedStatus: http.StatusNotFound, - expectedErr: nil, - }, - { - statErr: os.ErrPermission, - expectedStatus: http.StatusForbidden, - expectedErr: os.ErrPermission, - }, - { - statErr: ErrCustom, - expectedStatus: http.StatusInternalServerError, - expectedErr: ErrCustom, - }, - } - - for i, test := range tests { - // initialize a file server. The FileSystem will not fail, but calls to the Stat method of the returned File object will - fileserver := FileServer{Root: failingFS{err: nil, fileImpl: failingFile{err: test.statErr}}} - - // prepare the request and response - request, err := http.NewRequest("GET", "https://foo/", nil) - if err != nil { - t.Fatalf("Failed to build request. Error was: %v", err) - } - responseRecorder := httptest.NewRecorder() - - status, actualErr := fileserver.ServeHTTP(responseRecorder, request) - - // check the status - if status != test.expectedStatus { - t.Errorf("Test %d: Expected status %d, found %d", i, test.expectedStatus, status) - } - - // check the error - if actualErr != test.expectedErr { - t.Errorf("Test %d: Expected err %v, found %v", i, test.expectedErr, actualErr) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/templates/setup.go deleted file mode 100644 index 70363f9..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/setup.go +++ /dev/null @@ -1,101 +0,0 @@ -package templates - -import ( - "net/http" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("templates", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new Templates middleware instance. -func setup(c *caddy.Controller) error { - rules, err := templatesParse(c) - if err != nil { - return err - } - - cfg := httpserver.GetConfig(c.Key) - - tmpls := Templates{ - Rules: rules, - Root: cfg.Root, - FileSys: http.Dir(cfg.Root), - } - - cfg.AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - tmpls.Next = next - return tmpls - }) - - return nil -} - -func templatesParse(c *caddy.Controller) ([]Rule, error) { - var rules []Rule - - for c.Next() { - var rule Rule - - rule.Path = defaultTemplatePath - rule.Extensions = defaultTemplateExtensions - - args := c.RemainingArgs() - - switch len(args) { - case 0: - // Optional block - for c.NextBlock() { - switch c.Val() { - case "path": - args := c.RemainingArgs() - if len(args) != 1 { - return nil, c.ArgErr() - } - rule.Path = args[0] - - case "ext": - args := c.RemainingArgs() - if len(args) == 0 { - return nil, c.ArgErr() - } - rule.Extensions = args - - case "between": - args := c.RemainingArgs() - if len(args) != 2 { - return nil, c.ArgErr() - } - rule.Delims[0] = args[0] - rule.Delims[1] = args[1] - } - } - default: - // First argument would be the path - rule.Path = args[0] - - // Any remaining arguments are extensions - rule.Extensions = args[1:] - if len(rule.Extensions) == 0 { - rule.Extensions = defaultTemplateExtensions - } - } - - for _, ext := range rule.Extensions { - rule.IndexFiles = append(rule.IndexFiles, "index"+ext) - } - - rules = append(rules, rule) - } - return rules, nil -} - -const defaultTemplatePath = "/" - -var defaultTemplateExtensions = []string{".html", ".htm", ".tmpl", ".tpl", ".txt"} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/templates/setup_test.go deleted file mode 100644 index 2427afd..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/setup_test.go +++ /dev/null @@ -1,107 +0,0 @@ -package templates - -import ( - "fmt" - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestSetup(t *testing.T) { - err := setup(caddy.NewTestController(`templates`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(Templates) - - if !ok { - t.Fatalf("Expected handler to be type Templates, got: %#v", handler) - } - - if myHandler.Rules[0].Path != defaultTemplatePath { - t.Errorf("Expected / as the default Path") - } - if fmt.Sprint(myHandler.Rules[0].Extensions) != fmt.Sprint(defaultTemplateExtensions) { - t.Errorf("Expected %v to be the Default Extensions", defaultTemplateExtensions) - } - var indexFiles []string - for _, extension := range defaultTemplateExtensions { - indexFiles = append(indexFiles, "index"+extension) - } - if fmt.Sprint(myHandler.Rules[0].IndexFiles) != fmt.Sprint(indexFiles) { - t.Errorf("Expected %v to be the Default Index files", indexFiles) - } - if myHandler.Rules[0].Delims != [2]string{} { - t.Errorf("Expected %v to be the Default Delims", [2]string{}) - } -} - -func TestTemplatesParse(t *testing.T) { - tests := []struct { - inputTemplateConfig string - shouldErr bool - expectedTemplateConfig []Rule - }{ - {`templates /api1`, false, []Rule{{ - Path: "/api1", - Extensions: defaultTemplateExtensions, - Delims: [2]string{}, - }}}, - {`templates /api2 .txt .htm`, false, []Rule{{ - Path: "/api2", - Extensions: []string{".txt", ".htm"}, - Delims: [2]string{}, - }}}, - - {`templates /api3 .htm .html - templates /api4 .txt .tpl `, false, []Rule{{ - Path: "/api3", - Extensions: []string{".htm", ".html"}, - Delims: [2]string{}, - }, { - Path: "/api4", - Extensions: []string{".txt", ".tpl"}, - Delims: [2]string{}, - }}}, - {`templates { - path /api5 - ext .html - between {% %} - }`, false, []Rule{{ - Path: "/api5", - Extensions: []string{".html"}, - Delims: [2]string{"{%", "%}"}, - }}}, - } - for i, test := range tests { - c := caddy.NewTestController(test.inputTemplateConfig) - actualTemplateConfigs, err := templatesParse(c) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - if len(actualTemplateConfigs) != len(test.expectedTemplateConfig) { - t.Fatalf("Test %d expected %d no of Template configs, but got %d ", - i, len(test.expectedTemplateConfig), len(actualTemplateConfigs)) - } - for j, actualTemplateConfig := range actualTemplateConfigs { - if actualTemplateConfig.Path != test.expectedTemplateConfig[j].Path { - t.Errorf("Test %d expected %dth Template Config Path to be %s , but got %s", - i, j, test.expectedTemplateConfig[j].Path, actualTemplateConfig.Path) - } - if fmt.Sprint(actualTemplateConfig.Extensions) != fmt.Sprint(test.expectedTemplateConfig[j].Extensions) { - t.Errorf("Expected %v to be the Extensions , but got %v instead", test.expectedTemplateConfig[j].Extensions, actualTemplateConfig.Extensions) - } - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/templates.go b/vendor/github.com/mholt/caddy/caddyhttp/templates/templates.go deleted file mode 100644 index 91491f1..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/templates.go +++ /dev/null @@ -1,96 +0,0 @@ -// Package templates implements template execution for files to be -// dynamically rendered for the client. -package templates - -import ( - "bytes" - "net/http" - "os" - "path" - "path/filepath" - "text/template" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -// ServeHTTP implements the httpserver.Handler interface. -func (t Templates) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - for _, rule := range t.Rules { - if !httpserver.Path(r.URL.Path).Matches(rule.Path) { - continue - } - - // Check for index files - fpath := r.URL.Path - if idx, ok := httpserver.IndexFile(t.FileSys, fpath, rule.IndexFiles); ok { - fpath = idx - } - - // Check the extension - reqExt := path.Ext(fpath) - - for _, ext := range rule.Extensions { - if reqExt == ext { - // Create execution context - ctx := httpserver.Context{Root: t.FileSys, Req: r, URL: r.URL} - - // New template - templateName := filepath.Base(fpath) - tpl := template.New(templateName) - - // Set delims - if rule.Delims != [2]string{} { - tpl.Delims(rule.Delims[0], rule.Delims[1]) - } - - // Build the template - templatePath := filepath.Join(t.Root, fpath) - tpl, err := tpl.ParseFiles(templatePath) - if err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, nil - } else if os.IsPermission(err) { - return http.StatusForbidden, nil - } - return http.StatusInternalServerError, err - } - - // Execute it - var buf bytes.Buffer - err = tpl.Execute(&buf, ctx) - if err != nil { - return http.StatusInternalServerError, err - } - - templateInfo, err := os.Stat(templatePath) - if err == nil { - // add the Last-Modified header if we were able to read the stamp - httpserver.SetLastModifiedHeader(w, templateInfo.ModTime()) - } - buf.WriteTo(w) - - return http.StatusOK, nil - } - } - } - - return t.Next.ServeHTTP(w, r) -} - -// Templates is middleware to render templated files as the HTTP response. -type Templates struct { - Next httpserver.Handler - Rules []Rule - Root string - FileSys http.FileSystem -} - -// Rule represents a template rule. A template will only execute -// with this rule if the request path matches the Path specified -// and requests a resource with one of the extensions specified. -type Rule struct { - Path string - Extensions []string - IndexFiles []string - Delims [2]string -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/templates_test.go b/vendor/github.com/mholt/caddy/caddyhttp/templates/templates_test.go deleted file mode 100644 index 841cf20..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/templates_test.go +++ /dev/null @@ -1,138 +0,0 @@ -package templates - -import ( - "net/http" - "net/http/httptest" - "testing" - - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestTemplates(t *testing.T) { - tmpl := Templates{ - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - return 0, nil - }), - Rules: []Rule{ - { - Extensions: []string{".html"}, - IndexFiles: []string{"index.html"}, - Path: "/photos", - }, - { - Extensions: []string{".html", ".htm"}, - IndexFiles: []string{"index.html", "index.htm"}, - Path: "/images", - Delims: [2]string{"{%", "%}"}, - }, - }, - Root: "./testdata", - FileSys: http.Dir("./testdata"), - } - - tmplroot := Templates{ - Next: httpserver.HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) { - return 0, nil - }), - Rules: []Rule{ - { - Extensions: []string{".html"}, - IndexFiles: []string{"index.html"}, - Path: "/", - }, - }, - Root: "./testdata", - FileSys: http.Dir("./testdata"), - } - - // Test tmpl on /photos/test.html - req, err := http.NewRequest("GET", "/photos/test.html", nil) - if err != nil { - t.Fatalf("Test: Could not create HTTP request: %v", err) - } - - rec := httptest.NewRecorder() - - tmpl.ServeHTTP(rec, req) - - if rec.Code != http.StatusOK { - t.Fatalf("Test: Wrong response code: %d, should be %d", rec.Code, http.StatusOK) - } - - respBody := rec.Body.String() - expectedBody := `test page

Header title

- -` - - if respBody != expectedBody { - t.Fatalf("Test: the expected body %v is different from the response one: %v", expectedBody, respBody) - } - - // Test tmpl on /images/img.htm - req, err = http.NewRequest("GET", "/images/img.htm", nil) - if err != nil { - t.Fatalf("Could not create HTTP request: %v", err) - } - - rec = httptest.NewRecorder() - - tmpl.ServeHTTP(rec, req) - - if rec.Code != http.StatusOK { - t.Fatalf("Test: Wrong response code: %d, should be %d", rec.Code, http.StatusOK) - } - - respBody = rec.Body.String() - expectedBody = `img

Header title

- -` - - if respBody != expectedBody { - t.Fatalf("Test: the expected body %v is different from the response one: %v", expectedBody, respBody) - } - - // Test tmpl on /images/img2.htm - req, err = http.NewRequest("GET", "/images/img2.htm", nil) - if err != nil { - t.Fatalf("Could not create HTTP request: %v", err) - } - - rec = httptest.NewRecorder() - - tmpl.ServeHTTP(rec, req) - - if rec.Code != http.StatusOK { - t.Fatalf("Test: Wrong response code: %d, should be %d", rec.Code, http.StatusOK) - } - - respBody = rec.Body.String() - expectedBody = `img{{.Include "header.html"}} -` - - if respBody != expectedBody { - t.Fatalf("Test: the expected body %v is different from the response one: %v", expectedBody, respBody) - } - - // Test tmplroot on /root.html - req, err = http.NewRequest("GET", "/root.html", nil) - if err != nil { - t.Fatalf("Could not create HTTP request: %v", err) - } - - rec = httptest.NewRecorder() - - tmplroot.ServeHTTP(rec, req) - - if rec.Code != http.StatusOK { - t.Fatalf("Test: Wrong response code: %d, should be %d", rec.Code, http.StatusOK) - } - - respBody = rec.Body.String() - expectedBody = `root

Header title

- -` - - if respBody != expectedBody { - t.Fatalf("Test: the expected body %v is different from the response one: %v", expectedBody, respBody) - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/header.html b/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/header.html deleted file mode 100644 index 9c96e0e..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/header.html +++ /dev/null @@ -1 +0,0 @@ -

Header title

diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/header.html b/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/header.html deleted file mode 100644 index 9c96e0e..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/header.html +++ /dev/null @@ -1 +0,0 @@ -

Header title

diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img.htm b/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img.htm deleted file mode 100644 index c906020..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img.htm +++ /dev/null @@ -1 +0,0 @@ -img{%.Include "header.html"%} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img2.htm b/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img2.htm deleted file mode 100644 index 865a738..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/images/img2.htm +++ /dev/null @@ -1 +0,0 @@ -img{{.Include "header.html"}} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/photos/test.html b/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/photos/test.html deleted file mode 100644 index e2e95e1..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/photos/test.html +++ /dev/null @@ -1 +0,0 @@ -test page{{.Include "../header.html"}} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/root.html b/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/root.html deleted file mode 100644 index e1720e7..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/templates/testdata/root.html +++ /dev/null @@ -1 +0,0 @@ -root{{.Include "header.html"}} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/websocket/setup.go b/vendor/github.com/mholt/caddy/caddyhttp/websocket/setup.go deleted file mode 100644 index 5939aaf..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/websocket/setup.go +++ /dev/null @@ -1,96 +0,0 @@ -package websocket - -import ( - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func init() { - caddy.RegisterPlugin("websocket", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// setup configures a new WebSocket middleware instance. -func setup(c *caddy.Controller) error { - websocks, err := webSocketParse(c) - if err != nil { - return err - } - - GatewayInterface = caddy.AppName + "-CGI/1.1" - ServerSoftware = caddy.AppName + "/" + caddy.AppVersion - - httpserver.GetConfig(c.Key).AddMiddleware(func(next httpserver.Handler) httpserver.Handler { - return WebSocket{Next: next, Sockets: websocks} - }) - - return nil -} - -func webSocketParse(c *caddy.Controller) ([]Config, error) { - var websocks []Config - var respawn bool - - optionalBlock := func() (hadBlock bool, err error) { - for c.NextBlock() { - hadBlock = true - if c.Val() == "respawn" { - respawn = true - } else { - return true, c.Err("Expected websocket configuration parameter in block") - } - } - return - } - - for c.Next() { - var val, path, command string - - // Path or command; not sure which yet - if !c.NextArg() { - return nil, c.ArgErr() - } - val = c.Val() - - // Extra configuration may be in a block - hadBlock, err := optionalBlock() - if err != nil { - return nil, err - } - - if !hadBlock { - // The next argument on this line will be the command or an open curly brace - if c.NextArg() { - path = val - command = c.Val() - } else { - path = "/" - command = val - } - - // Okay, check again for optional block - _, err = optionalBlock() - if err != nil { - return nil, err - } - } - - // Split command into the actual command and its arguments - cmd, args, err := caddy.SplitCommandAndArgs(command) - if err != nil { - return nil, err - } - - websocks = append(websocks, Config{ - Path: path, - Command: cmd, - Arguments: args, - Respawn: respawn, // TODO: This isn't used currently - }) - } - - return websocks, nil - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/websocket/setup_test.go b/vendor/github.com/mholt/caddy/caddyhttp/websocket/setup_test.go deleted file mode 100644 index f8b2833..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/websocket/setup_test.go +++ /dev/null @@ -1,102 +0,0 @@ -package websocket - -import ( - "testing" - - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -func TestWebSocket(t *testing.T) { - err := setup(caddy.NewTestController(`websocket cat`)) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - mids := httpserver.GetConfig("").Middleware() - if len(mids) == 0 { - t.Fatal("Expected middleware, got 0 instead") - } - - handler := mids[0](httpserver.EmptyNext) - myHandler, ok := handler.(WebSocket) - - if !ok { - t.Fatalf("Expected handler to be type WebSocket, got: %#v", handler) - } - - if myHandler.Sockets[0].Path != "/" { - t.Errorf("Expected / as the default Path") - } - if myHandler.Sockets[0].Command != "cat" { - t.Errorf("Expected %s as the command", "cat") - } - -} -func TestWebSocketParse(t *testing.T) { - tests := []struct { - inputWebSocketConfig string - shouldErr bool - expectedWebSocketConfig []Config - }{ - {`websocket /api1 cat`, false, []Config{{ - Path: "/api1", - Command: "cat", - }}}, - - {`websocket /api3 cat - websocket /api4 cat `, false, []Config{{ - Path: "/api3", - Command: "cat", - }, { - Path: "/api4", - Command: "cat", - }}}, - - {`websocket /api5 "cmd arg1 arg2 arg3"`, false, []Config{{ - Path: "/api5", - Command: "cmd", - Arguments: []string{"arg1", "arg2", "arg3"}, - }}}, - - // accept respawn - {`websocket /api6 cat { - respawn - }`, false, []Config{{ - Path: "/api6", - Command: "cat", - }}}, - - // invalid configuration - {`websocket /api7 cat { - invalid - }`, true, []Config{}}, - } - for i, test := range tests { - c := caddy.NewTestController(test.inputWebSocketConfig) - actualWebSocketConfigs, err := webSocketParse(c) - - if err == nil && test.shouldErr { - t.Errorf("Test %d didn't error, but it should have", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d errored, but it shouldn't have; got '%v'", i, err) - } - if len(actualWebSocketConfigs) != len(test.expectedWebSocketConfig) { - t.Fatalf("Test %d expected %d no of WebSocket configs, but got %d ", - i, len(test.expectedWebSocketConfig), len(actualWebSocketConfigs)) - } - for j, actualWebSocketConfig := range actualWebSocketConfigs { - - if actualWebSocketConfig.Path != test.expectedWebSocketConfig[j].Path { - t.Errorf("Test %d expected %dth WebSocket Config Path to be %s , but got %s", - i, j, test.expectedWebSocketConfig[j].Path, actualWebSocketConfig.Path) - } - - if actualWebSocketConfig.Command != test.expectedWebSocketConfig[j].Command { - t.Errorf("Test %d expected %dth WebSocket Config Command to be %s , but got %s", - i, j, test.expectedWebSocketConfig[j].Command, actualWebSocketConfig.Command) - } - - } - } - -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket.go b/vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket.go deleted file mode 100644 index ca135f3..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket.go +++ /dev/null @@ -1,259 +0,0 @@ -// Package websocket implements a WebSocket server by executing -// a command and piping its input and output through the WebSocket -// connection. -package websocket - -import ( - "bufio" - "bytes" - "io" - "net" - "net/http" - "os" - "os/exec" - "strings" - "time" - - "github.com/gorilla/websocket" - "github.com/mholt/caddy/caddyhttp/httpserver" -) - -const ( - // Time allowed to write a message to the peer. - writeWait = 10 * time.Second - - // Time allowed to read the next pong message from the peer. - pongWait = 60 * time.Second - - // Send pings to peer with this period. Must be less than pongWait. - pingPeriod = (pongWait * 9) / 10 - - // Maximum message size allowed from peer. - maxMessageSize = 1024 * 1024 * 10 // 10 MB default. -) - -var ( - // GatewayInterface is the dialect of CGI being used by the server - // to communicate with the script. See CGI spec, 4.1.4 - GatewayInterface string - - // ServerSoftware is the name and version of the information server - // software making the CGI request. See CGI spec, 4.1.17 - ServerSoftware string -) - -type ( - // WebSocket is a type that holds configuration for the - // websocket middleware generally, like a list of all the - // websocket endpoints. - WebSocket struct { - // Next is the next HTTP handler in the chain for when the path doesn't match - Next httpserver.Handler - - // Sockets holds all the web socket endpoint configurations - Sockets []Config - } - - // Config holds the configuration for a single websocket - // endpoint which may serve multiple websocket connections. - Config struct { - Path string - Command string - Arguments []string - Respawn bool // TODO: Not used, but parser supports it until we decide on it - } -) - -// ServeHTTP converts the HTTP request to a WebSocket connection and serves it up. -func (ws WebSocket) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - for _, sockconfig := range ws.Sockets { - if httpserver.Path(r.URL.Path).Matches(sockconfig.Path) { - return serveWS(w, r, &sockconfig) - } - } - - // Didn't match a websocket path, so pass-thru - return ws.Next.ServeHTTP(w, r) -} - -// serveWS is used for setting and upgrading the HTTP connection to a websocket connection. -// It also spawns the child process that is associated with matched HTTP path/url. -func serveWS(w http.ResponseWriter, r *http.Request, config *Config) (int, error) { - upgrader := websocket.Upgrader{ - ReadBufferSize: 1024, - WriteBufferSize: 1024, - CheckOrigin: func(r *http.Request) bool { return true }, - } - conn, err := upgrader.Upgrade(w, r, nil) - if err != nil { - return http.StatusBadRequest, err - } - defer conn.Close() - - cmd := exec.Command(config.Command, config.Arguments...) - - stdout, err := cmd.StdoutPipe() - if err != nil { - return http.StatusBadGateway, err - } - defer stdout.Close() - - stdin, err := cmd.StdinPipe() - if err != nil { - return http.StatusBadGateway, err - } - defer stdin.Close() - - metavars, err := buildEnv(cmd.Path, r) - if err != nil { - return http.StatusBadGateway, err - } - - cmd.Env = metavars - - if err := cmd.Start(); err != nil { - return http.StatusBadGateway, err - } - - done := make(chan struct{}) - go pumpStdout(conn, stdout, done) - pumpStdin(conn, stdin) - - stdin.Close() // close stdin to end the process - - if err := cmd.Process.Signal(os.Interrupt); err != nil { // signal an interrupt to kill the process - return http.StatusInternalServerError, err - } - - select { - case <-done: - case <-time.After(time.Second): - // terminate with extreme prejudice. - if err := cmd.Process.Signal(os.Kill); err != nil { - return http.StatusInternalServerError, err - } - <-done - } - - // not sure what we want to do here. - // status for an "exited" process is greater - // than 0, but isn't really an error per se. - // just going to ignore it for now. - cmd.Wait() - - return 0, nil -} - -// buildEnv creates the meta-variables for the child process according -// to the CGI 1.1 specification: http://tools.ietf.org/html/rfc3875#section-4.1 -// cmdPath should be the path of the command being run. -// The returned string slice can be set to the command's Env property. -func buildEnv(cmdPath string, r *http.Request) (metavars []string, err error) { - if !strings.Contains(r.RemoteAddr, ":") { - r.RemoteAddr += ":" - } - remoteHost, remotePort, err := net.SplitHostPort(r.RemoteAddr) - if err != nil { - return - } - - if !strings.Contains(r.Host, ":") { - r.Host += ":" - } - serverHost, serverPort, err := net.SplitHostPort(r.Host) - if err != nil { - return - } - - metavars = []string{ - `AUTH_TYPE=`, // Not used - `CONTENT_LENGTH=`, // Not used - `CONTENT_TYPE=`, // Not used - `GATEWAY_INTERFACE=` + GatewayInterface, - `PATH_INFO=`, // TODO - `PATH_TRANSLATED=`, // TODO - `QUERY_STRING=` + r.URL.RawQuery, - `REMOTE_ADDR=` + remoteHost, - `REMOTE_HOST=` + remoteHost, // Host lookups are slow - don't do them - `REMOTE_IDENT=`, // Not used - `REMOTE_PORT=` + remotePort, - `REMOTE_USER=`, // Not used, - `REQUEST_METHOD=` + r.Method, - `REQUEST_URI=` + r.RequestURI, - `SCRIPT_NAME=` + cmdPath, // path of the program being executed - `SERVER_NAME=` + serverHost, - `SERVER_PORT=` + serverPort, - `SERVER_PROTOCOL=` + r.Proto, - `SERVER_SOFTWARE=` + ServerSoftware, - } - - // Add each HTTP header to the environment as well - for header, values := range r.Header { - value := strings.Join(values, ", ") - header = strings.ToUpper(header) - header = strings.Replace(header, "-", "_", -1) - value = strings.Replace(value, "\n", " ", -1) - metavars = append(metavars, "HTTP_"+header+"="+value) - } - - return -} - -// pumpStdin handles reading data from the websocket connection and writing -// it to stdin of the process. -func pumpStdin(conn *websocket.Conn, stdin io.WriteCloser) { - // Setup our connection's websocket ping/pong handlers from our const values. - defer conn.Close() - conn.SetReadLimit(maxMessageSize) - conn.SetReadDeadline(time.Now().Add(pongWait)) - conn.SetPongHandler(func(string) error { conn.SetReadDeadline(time.Now().Add(pongWait)); return nil }) - for { - _, message, err := conn.ReadMessage() - if err != nil { - break - } - message = append(message, '\n') - if _, err := stdin.Write(message); err != nil { - break - } - } -} - -// pumpStdout handles reading data from stdout of the process and writing -// it to websocket connection. -func pumpStdout(conn *websocket.Conn, stdout io.Reader, done chan struct{}) { - go pinger(conn, done) - defer func() { - conn.Close() - close(done) // make sure to close the pinger when we are done. - }() - - s := bufio.NewScanner(stdout) - for s.Scan() { - conn.SetWriteDeadline(time.Now().Add(writeWait)) - if err := conn.WriteMessage(websocket.TextMessage, bytes.TrimSpace(s.Bytes())); err != nil { - break - } - } - if s.Err() != nil { - conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseGoingAway, s.Err().Error()), time.Time{}) - } -} - -// pinger simulates the websocket to keep it alive with ping messages. -func pinger(conn *websocket.Conn, done chan struct{}) { - ticker := time.NewTicker(pingPeriod) - defer ticker.Stop() - - for { // blocking loop with select to wait for stimulation. - select { - case <-ticker.C: - if err := conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(writeWait)); err != nil { - conn.WriteControl(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseGoingAway, err.Error()), time.Time{}) - return - } - case <-done: - return // clean up this routine. - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket_test.go b/vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket_test.go deleted file mode 100644 index 61d7d38..0000000 --- a/vendor/github.com/mholt/caddy/caddyhttp/websocket/websocket_test.go +++ /dev/null @@ -1,22 +0,0 @@ -package websocket - -import ( - "net/http" - "testing" -) - -func TestBuildEnv(t *testing.T) { - req, err := http.NewRequest("GET", "http://localhost", nil) - if err != nil { - t.Fatal("Error setting up request:", err) - } - req.RemoteAddr = "localhost:50302" - - env, err := buildEnv("/bin/command", req) - if err != nil { - t.Fatal("Didn't expect an error:", err) - } - if len(env) == 0 { - t.Fatalf("Expected non-empty environment; got %#v", env) - } -} diff --git a/vendor/github.com/mholt/caddy/caddytls/certificates.go b/vendor/github.com/mholt/caddy/caddytls/certificates.go deleted file mode 100644 index 5151d01..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/certificates.go +++ /dev/null @@ -1,240 +0,0 @@ -package caddytls - -import ( - "crypto/tls" - "crypto/x509" - "errors" - "io/ioutil" - "log" - "strings" - "sync" - "time" - - "github.com/xenolf/lego/acme" - "golang.org/x/crypto/ocsp" -) - -// certCache stores certificates in memory, -// keying certificates by name. -var certCache = make(map[string]Certificate) -var certCacheMu sync.RWMutex - -// Certificate is a tls.Certificate with associated metadata tacked on. -// Even if the metadata can be obtained by parsing the certificate, -// we can be more efficient by extracting the metadata once so it's -// just there, ready to use. -type Certificate struct { - tls.Certificate - - // Names is the list of names this certificate is written for. - // The first is the CommonName (if any), the rest are SAN. - Names []string - - // NotAfter is when the certificate expires. - NotAfter time.Time - - // OCSP contains the certificate's parsed OCSP response. - OCSP *ocsp.Response - - // Config is the configuration with which the certificate was - // loaded or obtained and with which it should be maintained. - Config *Config -} - -// getCertificate gets a certificate that matches name (a server name) -// from the in-memory cache. If there is no exact match for name, it -// will be checked against names of the form '*.example.com' (wildcard -// certificates) according to RFC 6125. If a match is found, matched will -// be true. If no matches are found, matched will be false and a default -// certificate will be returned with defaulted set to true. If no default -// certificate is set, defaulted will be set to false. -// -// The logic in this function is adapted from the Go standard library, -// which is by the Go Authors. -// -// This function is safe for concurrent use. -func getCertificate(name string) (cert Certificate, matched, defaulted bool) { - var ok bool - - // Not going to trim trailing dots here since RFC 3546 says, - // "The hostname is represented ... without a trailing dot." - // Just normalize to lowercase. - name = strings.ToLower(name) - - certCacheMu.RLock() - defer certCacheMu.RUnlock() - - // exact match? great, let's use it - if cert, ok = certCache[name]; ok { - matched = true - return - } - - // try replacing labels in the name with wildcards until we get a match - labels := strings.Split(name, ".") - for i := range labels { - labels[i] = "*" - candidate := strings.Join(labels, ".") - if cert, ok = certCache[candidate]; ok { - matched = true - return - } - } - - // if nothing matches, use the default certificate or bust - cert, defaulted = certCache[""] - return -} - -// CacheManagedCertificate loads the certificate for domain into the -// cache, flagging it as Managed and, if onDemand is true, as "OnDemand" -// (meaning that it was obtained or loaded during a TLS handshake). -// -// This function is safe for concurrent use. -func CacheManagedCertificate(domain string, cfg *Config) (Certificate, error) { - storage, err := StorageFor(cfg.CAUrl) - if err != nil { - return Certificate{}, err - } - cert, err := makeCertificateFromDisk(storage.SiteCertFile(domain), storage.SiteKeyFile(domain)) - if err != nil { - return cert, err - } - cert.Config = cfg - cacheCertificate(cert) - return cert, nil -} - -// cacheUnmanagedCertificatePEMFile loads a certificate for host using certFile -// and keyFile, which must be in PEM format. It stores the certificate in -// memory. The Managed and OnDemand flags of the certificate will be set to -// false. -// -// This function is safe for concurrent use. -func cacheUnmanagedCertificatePEMFile(certFile, keyFile string) error { - cert, err := makeCertificateFromDisk(certFile, keyFile) - if err != nil { - return err - } - cacheCertificate(cert) - return nil -} - -// cacheUnmanagedCertificatePEMBytes makes a certificate out of the PEM bytes -// of the certificate and key, then caches it in memory. -// -// This function is safe for concurrent use. -func cacheUnmanagedCertificatePEMBytes(certBytes, keyBytes []byte) error { - cert, err := makeCertificate(certBytes, keyBytes) - if err != nil { - return err - } - cacheCertificate(cert) - return nil -} - -// makeCertificateFromDisk makes a Certificate by loading the -// certificate and key files. It fills out all the fields in -// the certificate except for the Managed and OnDemand flags. -// (It is up to the caller to set those.) -func makeCertificateFromDisk(certFile, keyFile string) (Certificate, error) { - certPEMBlock, err := ioutil.ReadFile(certFile) - if err != nil { - return Certificate{}, err - } - keyPEMBlock, err := ioutil.ReadFile(keyFile) - if err != nil { - return Certificate{}, err - } - return makeCertificate(certPEMBlock, keyPEMBlock) -} - -// makeCertificate turns a certificate PEM bundle and a key PEM block into -// a Certificate, with OCSP and other relevant metadata tagged with it, -// except for the OnDemand and Managed flags. It is up to the caller to -// set those properties. -func makeCertificate(certPEMBlock, keyPEMBlock []byte) (Certificate, error) { - var cert Certificate - - // Convert to a tls.Certificate - tlsCert, err := tls.X509KeyPair(certPEMBlock, keyPEMBlock) - if err != nil { - return cert, err - } - if len(tlsCert.Certificate) == 0 { - return cert, errors.New("certificate is empty") - } - - // Parse leaf certificate and extract relevant metadata - leaf, err := x509.ParseCertificate(tlsCert.Certificate[0]) - if err != nil { - return cert, err - } - if leaf.Subject.CommonName != "" { - cert.Names = []string{strings.ToLower(leaf.Subject.CommonName)} - } - for _, name := range leaf.DNSNames { - if name != leaf.Subject.CommonName { - cert.Names = append(cert.Names, strings.ToLower(name)) - } - } - cert.NotAfter = leaf.NotAfter - - // Staple OCSP - ocspBytes, ocspResp, err := acme.GetOCSPForCert(certPEMBlock) - if err != nil { - // An error here is not a problem because a certificate may simply - // not contain a link to an OCSP server. But we should log it anyway. - log.Printf("[WARNING] No OCSP stapling for %v: %v", cert.Names, err) - } else if ocspResp.Status == ocsp.Good { - tlsCert.OCSPStaple = ocspBytes - cert.OCSP = ocspResp - } - - cert.Certificate = tlsCert - return cert, nil -} - -// cacheCertificate adds cert to the in-memory cache. If the cache is -// empty, cert will be used as the default certificate. If the cache is -// full, random entries are deleted until there is room to map all the -// names on the certificate. -// -// This certificate will be keyed to the names in cert.Names. Any name -// that is already a key in the cache will be replaced with this cert. -// -// This function is safe for concurrent use. -func cacheCertificate(cert Certificate) { - if cert.Config == nil { - cert.Config = new(Config) - } - certCacheMu.Lock() - if _, ok := certCache[""]; !ok { - // use as default - must be *appended* to list, or bad things happen! - cert.Names = append(cert.Names, "") - certCache[""] = cert - } - for len(certCache)+len(cert.Names) > 10000 { - // for simplicity, just remove random elements - for key := range certCache { - if key == "" { // ... but not the default cert - continue - } - delete(certCache, key) - break - } - } - for _, name := range cert.Names { - certCache[name] = cert - } - certCacheMu.Unlock() -} - -// uncacheCertificate deletes name's certificate from the -// cache. If name is not a key in the certificate cache, -// this function does nothing. -func uncacheCertificate(name string) { - certCacheMu.Lock() - delete(certCache, name) - certCacheMu.Unlock() -} diff --git a/vendor/github.com/mholt/caddy/caddytls/certificates_test.go b/vendor/github.com/mholt/caddy/caddytls/certificates_test.go deleted file mode 100644 index 02f46cf..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/certificates_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package caddytls - -import "testing" - -func TestUnexportedGetCertificate(t *testing.T) { - defer func() { certCache = make(map[string]Certificate) }() - - // When cache is empty - if _, matched, defaulted := getCertificate("example.com"); matched || defaulted { - t.Errorf("Got a certificate when cache was empty; matched=%v, defaulted=%v", matched, defaulted) - } - - // When cache has one certificate in it (also is default) - defaultCert := Certificate{Names: []string{"example.com", ""}} - certCache[""] = defaultCert - certCache["example.com"] = defaultCert - if cert, matched, defaulted := getCertificate("Example.com"); !matched || defaulted || cert.Names[0] != "example.com" { - t.Errorf("Didn't get a cert for 'Example.com' or got the wrong one: %v, matched=%v, defaulted=%v", cert, matched, defaulted) - } - if cert, matched, defaulted := getCertificate(""); !matched || defaulted || cert.Names[0] != "example.com" { - t.Errorf("Didn't get a cert for '' or got the wrong one: %v, matched=%v, defaulted=%v", cert, matched, defaulted) - } - - // When retrieving wildcard certificate - certCache["*.example.com"] = Certificate{Names: []string{"*.example.com"}} - if cert, matched, defaulted := getCertificate("sub.example.com"); !matched || defaulted || cert.Names[0] != "*.example.com" { - t.Errorf("Didn't get wildcard cert for 'sub.example.com' or got the wrong one: %v, matched=%v, defaulted=%v", cert, matched, defaulted) - } - - // When no certificate matches, the default is returned - if cert, matched, defaulted := getCertificate("nomatch"); matched || !defaulted { - t.Errorf("Expected matched=false, defaulted=true; but got matched=%v, defaulted=%v (cert: %v)", matched, defaulted, cert) - } else if cert.Names[0] != "example.com" { - t.Errorf("Expected default cert, got: %v", cert) - } -} - -func TestCacheCertificate(t *testing.T) { - defer func() { certCache = make(map[string]Certificate) }() - - cacheCertificate(Certificate{Names: []string{"example.com", "sub.example.com"}}) - if _, ok := certCache["example.com"]; !ok { - t.Error("Expected first cert to be cached by key 'example.com', but it wasn't") - } - if _, ok := certCache["sub.example.com"]; !ok { - t.Error("Expected first cert to be cached by key 'sub.exmaple.com', but it wasn't") - } - if cert, ok := certCache[""]; !ok || cert.Names[2] != "" { - t.Error("Expected first cert to be cached additionally as the default certificate with empty name added, but it wasn't") - } - - cacheCertificate(Certificate{Names: []string{"example2.com"}}) - if _, ok := certCache["example2.com"]; !ok { - t.Error("Expected second cert to be cached by key 'exmaple2.com', but it wasn't") - } - if cert, ok := certCache[""]; ok && cert.Names[0] == "example2.com" { - t.Error("Expected second cert to NOT be cached as default, but it was") - } -} diff --git a/vendor/github.com/mholt/caddy/caddytls/client.go b/vendor/github.com/mholt/caddy/caddytls/client.go deleted file mode 100644 index 8324b83..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/client.go +++ /dev/null @@ -1,294 +0,0 @@ -package caddytls - -import ( - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "log" - "net" - "net/url" - "os" - "strings" - "sync" - "time" - - "github.com/mholt/caddy" - "github.com/xenolf/lego/acme" -) - -// acmeMu ensures that only one ACME challenge occurs at a time. -var acmeMu sync.Mutex - -// ACMEClient is an acme.Client with custom state attached. -type ACMEClient struct { - *acme.Client - AllowPrompts bool - config *Config -} - -// newACMEClient creates a new ACMEClient given an email and whether -// prompting the user is allowed. It's a variable so we can mock in tests. -var newACMEClient = func(config *Config, allowPrompts bool) (*ACMEClient, error) { - storage, err := StorageFor(config.CAUrl) - if err != nil { - return nil, err - } - - // Look up or create the LE user account - leUser, err := getUser(storage, config.ACMEEmail) - if err != nil { - return nil, err - } - - // ensure key type is set - keyType := DefaultKeyType - if config.KeyType != "" { - keyType = config.KeyType - } - - // ensure CA URL (directory endpoint) is set - caURL := DefaultCAUrl - if config.CAUrl != "" { - caURL = config.CAUrl - } - - // ensure endpoint is secure (assume HTTPS if scheme is missing) - if !strings.Contains(caURL, "://") { - caURL = "https://" + caURL - } - u, err := url.Parse(caURL) - if u.Scheme != "https" && !caddy.IsLoopback(u.Host) && !strings.HasPrefix(u.Host, "10.") { - return nil, fmt.Errorf("%s: insecure CA URL (HTTPS required)", caURL) - } - - // The client facilitates our communication with the CA server. - client, err := acme.NewClient(caURL, &leUser, keyType) - if err != nil { - return nil, err - } - - // If not registered, the user must register an account with the CA - // and agree to terms - if leUser.Registration == nil { - reg, err := client.Register() - if err != nil { - return nil, errors.New("registration error: " + err.Error()) - } - leUser.Registration = reg - - if allowPrompts { // can't prompt a user who isn't there - if !Agreed && reg.TosURL == "" { - Agreed = promptUserAgreement(saURL, false) // TODO - latest URL - } - if !Agreed && reg.TosURL == "" { - return nil, errors.New("user must agree to terms") - } - } - - err = client.AgreeToTOS() - if err != nil { - saveUser(storage, leUser) // Might as well try, right? - return nil, errors.New("error agreeing to terms: " + err.Error()) - } - - // save user to the file system - err = saveUser(storage, leUser) - if err != nil { - return nil, errors.New("could not save user: " + err.Error()) - } - } - - c := &ACMEClient{Client: client, AllowPrompts: allowPrompts, config: config} - - if config.DNSProvider == "" { - // Use HTTP and TLS-SNI challenges by default - - // See if HTTP challenge needs to be proxied - if caddy.HasListenerWithAddress(net.JoinHostPort(config.ListenHost, HTTPChallengePort)) { - altPort := config.AltHTTPPort - if altPort == "" { - altPort = DefaultHTTPAlternatePort - } - c.SetHTTPAddress(net.JoinHostPort(config.ListenHost, altPort)) - } - - // See if TLS challenge needs to be handled by our own facilities - if caddy.HasListenerWithAddress(net.JoinHostPort(config.ListenHost, TLSSNIChallengePort)) { - c.SetChallengeProvider(acme.TLSSNI01, tlsSniSolver{}) - } - } else { - // Otherwise, DNS challenge it is - - // Load provider constructor function - provFn, ok := dnsProviders[config.DNSProvider] - if !ok { - return nil, errors.New("unknown DNS provider by name '" + config.DNSProvider + "'") - } - - // we could pass credentials to create the provider, but for now - // we just let the solver package get them from the environment - prov, err := provFn() - if err != nil { - return nil, err - } - - // Use the DNS challenge exclusively - c.ExcludeChallenges([]acme.Challenge{acme.HTTP01, acme.TLSSNI01}) - c.SetChallengeProvider(acme.DNS01, prov) - } - - return c, nil -} - -// Obtain obtains a single certificate for names. It stores the certificate -// on the disk if successful. -func (c *ACMEClient) Obtain(names []string) error { -Attempts: - for attempts := 0; attempts < 2; attempts++ { - acmeMu.Lock() - certificate, failures := c.ObtainCertificate(names, true, nil) - acmeMu.Unlock() - if len(failures) > 0 { - // Error - try to fix it or report it to the user and abort - var errMsg string // we'll combine all the failures into a single error message - var promptedForAgreement bool // only prompt user for agreement at most once - - for errDomain, obtainErr := range failures { - if obtainErr == nil { - continue - } - if tosErr, ok := obtainErr.(acme.TOSError); ok { - // Terms of Service agreement error; we can probably deal with this - if !Agreed && !promptedForAgreement && c.AllowPrompts { - Agreed = promptUserAgreement(tosErr.Detail, true) // TODO: Use latest URL - promptedForAgreement = true - } - if Agreed || !c.AllowPrompts { - err := c.AgreeToTOS() - if err != nil { - return errors.New("error agreeing to updated terms: " + err.Error()) - } - continue Attempts - } - } - - // If user did not agree or it was any other kind of error, just append to the list of errors - errMsg += "[" + errDomain + "] failed to get certificate: " + obtainErr.Error() + "\n" - } - return errors.New(errMsg) - } - - // Success - immediately save the certificate resource - storage, err := StorageFor(c.config.CAUrl) - if err != nil { - return err - } - err = saveCertResource(storage, certificate) - if err != nil { - return fmt.Errorf("error saving assets for %v: %v", names, err) - } - - break - } - - return nil -} - -// Renew renews the managed certificate for name. Right now our storage -// mechanism only supports one name per certificate, so this function only -// accepts one domain as input. It can be easily modified to support SAN -// certificates if, one day, they become desperately needed enough that our -// storage mechanism is upgraded to be more complex to support SAN certs. -// -// Anyway, this function is safe for concurrent use. -func (c *ACMEClient) Renew(name string) error { - // Get access to ACME storage - storage, err := StorageFor(c.config.CAUrl) - if err != nil { - return err - } - - // Prepare for renewal (load PEM cert, key, and meta) - certBytes, err := ioutil.ReadFile(storage.SiteCertFile(name)) - if err != nil { - return err - } - keyBytes, err := ioutil.ReadFile(storage.SiteKeyFile(name)) - if err != nil { - return err - } - metaBytes, err := ioutil.ReadFile(storage.SiteMetaFile(name)) - if err != nil { - return err - } - var certMeta acme.CertificateResource - err = json.Unmarshal(metaBytes, &certMeta) - certMeta.Certificate = certBytes - certMeta.PrivateKey = keyBytes - - // Perform renewal and retry if necessary, but not too many times. - var newCertMeta acme.CertificateResource - var success bool - for attempts := 0; attempts < 2; attempts++ { - acmeMu.Lock() - newCertMeta, err = c.RenewCertificate(certMeta, true) - acmeMu.Unlock() - if err == nil { - success = true - break - } - - // If the legal terms changed and need to be agreed to again, - // we can handle that. - if _, ok := err.(acme.TOSError); ok { - err := c.AgreeToTOS() - if err != nil { - return err - } - continue - } - - // For any other kind of error, wait 10s and try again. - wait := 10 * time.Second - log.Printf("[ERROR] Renewing: %v; trying again in %s", err, wait) - time.Sleep(wait) - } - - if !success { - return errors.New("too many renewal attempts; last error: " + err.Error()) - } - - return saveCertResource(storage, newCertMeta) -} - -// Revoke revokes the certificate for name and deltes -// it from storage. -func (c *ACMEClient) Revoke(name string) error { - storage, err := StorageFor(c.config.CAUrl) - if err != nil { - return err - } - - if !existingCertAndKey(storage, name) { - return errors.New("no certificate and key for " + name) - } - - certFile := storage.SiteCertFile(name) - certBytes, err := ioutil.ReadFile(certFile) - if err != nil { - return err - } - - err = c.Client.RevokeCertificate(certBytes) - if err != nil { - return err - } - - err = os.Remove(certFile) - if err != nil { - return errors.New("certificate revoked, but unable to delete certificate file: " + err.Error()) - } - - return nil -} diff --git a/vendor/github.com/mholt/caddy/caddytls/client_test.go b/vendor/github.com/mholt/caddy/caddytls/client_test.go deleted file mode 100644 index bd9cbbc..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/client_test.go +++ /dev/null @@ -1,3 +0,0 @@ -package caddytls - -// TODO diff --git a/vendor/github.com/mholt/caddy/caddytls/config.go b/vendor/github.com/mholt/caddy/caddytls/config.go deleted file mode 100644 index 5250ecc..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/config.go +++ /dev/null @@ -1,437 +0,0 @@ -package caddytls - -import ( - "crypto/tls" - "crypto/x509" - "encoding/json" - "errors" - "fmt" - "io/ioutil" - "time" - - "github.com/xenolf/lego/acme" -) - -// Config describes how TLS should be configured and used. -type Config struct { - // The hostname or class of hostnames this config is - // designated for; can contain wildcard characters - // according to RFC 6125 §6.4.3 - this field MUST - // be set in order for things to work as expected - Hostname string - - // Whether TLS is enabled - Enabled bool - - // Minimum and maximum protocol versions to allow - ProtocolMinVersion uint16 - ProtocolMaxVersion uint16 - - // The list of cipher suites; first should be - // TLS_FALLBACK_SCSV to prevent degrade attacks - Ciphers []uint16 - - // Whether to prefer server cipher suites - PreferServerCipherSuites bool - - // Client authentication policy - ClientAuth tls.ClientAuthType - - // List of client CA certificates to allow, if - // client authentication is enabled - ClientCerts []string - - // Manual means user provides own certs and keys - Manual bool - - // Managed means config qualifies for implicit, - // automatic, managed TLS; as opposed to the user - // providing and managing the certificate manually - Managed bool - - // OnDemand means the class of hostnames this - // config applies to may obtain and manage - // certificates at handshake-time (as opposed - // to pre-loaded at startup); OnDemand certs - // will be managed the same way as preloaded - // ones, however, if an OnDemand cert fails to - // renew, it is removed from the in-memory - // cache; if this is true, Managed must - // necessarily be true - OnDemand bool - - // SelfSigned means that this hostname is - // served with a self-signed certificate - // that we generated in memory for convenience - SelfSigned bool - - // The endpoint of the directory for the ACME - // CA we are to use - CAUrl string - - // The host (ONLY the host, not port) to listen - //on if necessary to start a a listener to solve - // an ACME challenge - ListenHost string - - // The alternate port (ONLY port, not host) - // to use for the ACME HTTP challenge; this - // port will be used if we proxy challenges - // coming in on port 80 to this alternate port - AltHTTPPort string - - // The string identifier of the DNS provider - // to use when solving the ACME DNS challenge - DNSProvider string - - // The email address to use when creating or - // using an ACME account (fun fact: if this - // is set to "off" then this config will not - // qualify for managed TLS) - ACMEEmail string - - // The type of key to use when generating - // certificates - KeyType acme.KeyType -} - -// ObtainCert obtains a certificate for c.Hostname, as long as a certificate -// does not already exist in storage on disk. It only obtains and stores -// certificates (and their keys) to disk, it does not load them into memory. -// If allowPrompts is true, the user may be shown a prompt. If proxyACME is -// true, the relevant ACME challenges will be proxied to the alternate port. -func (c *Config) ObtainCert(allowPrompts bool) error { - return c.obtainCertName(c.Hostname, allowPrompts) -} - -func (c *Config) obtainCertName(name string, allowPrompts bool) error { - storage, err := StorageFor(c.CAUrl) - if err != nil { - return err - } - - if !c.Managed || !HostQualifies(name) || existingCertAndKey(storage, name) { - return nil - } - - if c.ACMEEmail == "" { - c.ACMEEmail = getEmail(storage, allowPrompts) - } - - client, err := newACMEClient(c, allowPrompts) - if err != nil { - return err - } - - return client.Obtain([]string{name}) -} - -// RenewCert renews the certificate for c.Hostname. -func (c *Config) RenewCert(allowPrompts bool) error { - return c.renewCertName(c.Hostname, allowPrompts) -} - -func (c *Config) renewCertName(name string, allowPrompts bool) error { - storage, err := StorageFor(c.CAUrl) - if err != nil { - return err - } - - // Prepare for renewal (load PEM cert, key, and meta) - certBytes, err := ioutil.ReadFile(storage.SiteCertFile(c.Hostname)) - if err != nil { - return err - } - keyBytes, err := ioutil.ReadFile(storage.SiteKeyFile(c.Hostname)) - if err != nil { - return err - } - metaBytes, err := ioutil.ReadFile(storage.SiteMetaFile(c.Hostname)) - if err != nil { - return err - } - var certMeta acme.CertificateResource - err = json.Unmarshal(metaBytes, &certMeta) - certMeta.Certificate = certBytes - certMeta.PrivateKey = keyBytes - - client, err := newACMEClient(c, allowPrompts) - if err != nil { - return err - } - - // Perform renewal and retry if necessary, but not too many times. - var newCertMeta acme.CertificateResource - var success bool - for attempts := 0; attempts < 2; attempts++ { - acmeMu.Lock() - newCertMeta, err = client.RenewCertificate(certMeta, true) - acmeMu.Unlock() - if err == nil { - success = true - break - } - - // If the legal terms were updated and need to be - // agreed to again, we can handle that. - if _, ok := err.(acme.TOSError); ok { - err := client.AgreeToTOS() - if err != nil { - return err - } - continue - } - - // For any other kind of error, wait 10s and try again. - time.Sleep(10 * time.Second) - } - - if !success { - return errors.New("too many renewal attempts; last error: " + err.Error()) - } - - return saveCertResource(storage, newCertMeta) -} - -// MakeTLSConfig reduces configs into a single tls.Config. -// If TLS is to be disabled, a nil tls.Config will be returned. -func MakeTLSConfig(configs []*Config) (*tls.Config, error) { - if configs == nil || len(configs) == 0 { - return nil, nil - } - - config := new(tls.Config) - ciphersAdded := make(map[uint16]struct{}) - configMap := make(configGroup) - - for i, cfg := range configs { - if cfg == nil { - // avoid nil pointer dereference below - configs[i] = new(Config) - continue - } - - // Key this config by its hostname; this - // overwrites configs with the same hostname - configMap[cfg.Hostname] = cfg - - // Can't serve TLS and not-TLS on same port - if i > 0 && cfg.Enabled != configs[i-1].Enabled { - thisConfProto, lastConfProto := "not TLS", "not TLS" - if cfg.Enabled { - thisConfProto = "TLS" - } - if configs[i-1].Enabled { - lastConfProto = "TLS" - } - return nil, fmt.Errorf("cannot multiplex %s (%s) and %s (%s) on same listener", - configs[i-1].Hostname, lastConfProto, cfg.Hostname, thisConfProto) - } - - // Union cipher suites - for _, ciph := range cfg.Ciphers { - if _, ok := ciphersAdded[ciph]; !ok { - ciphersAdded[ciph] = struct{}{} - config.CipherSuites = append(config.CipherSuites, ciph) - } - } - - // Can't resolve conflicting PreferServerCipherSuites settings - if i > 0 && cfg.PreferServerCipherSuites != configs[i-1].PreferServerCipherSuites { - return nil, fmt.Errorf("cannot both use PreferServerCipherSuites and not use it") - } - - // Go with the widest range of protocol versions - if cfg.ProtocolMinVersion < config.MinVersion { - config.MinVersion = cfg.ProtocolMinVersion - } - if cfg.ProtocolMaxVersion < config.MaxVersion { - config.MaxVersion = cfg.ProtocolMaxVersion - } - - // Go with the strictest ClientAuth type - if cfg.ClientAuth > config.ClientAuth { - config.ClientAuth = cfg.ClientAuth - } - } - - // Is TLS disabled? If so, we're done here. - // By now, we know that all configs agree - // whether it is or not, so we can just look - // at the first one. - if len(configs) == 0 || !configs[0].Enabled { - return nil, nil - } - - // Default cipher suites - if len(config.CipherSuites) == 0 { - config.CipherSuites = defaultCiphers - } - - // For security, ensure TLS_FALLBACK_SCSV is always included - if config.CipherSuites[0] != tls.TLS_FALLBACK_SCSV { - config.CipherSuites = append([]uint16{tls.TLS_FALLBACK_SCSV}, config.CipherSuites...) - } - - // Set up client authentication if enabled - if config.ClientAuth != tls.NoClientCert { - pool := x509.NewCertPool() - clientCertsAdded := make(map[string]struct{}) - for _, cfg := range configs { - for _, caFile := range cfg.ClientCerts { - // don't add cert to pool more than once - if _, ok := clientCertsAdded[caFile]; ok { - continue - } - clientCertsAdded[caFile] = struct{}{} - - // Any client with a certificate from this CA will be allowed to connect - caCrt, err := ioutil.ReadFile(caFile) - if err != nil { - return nil, err - } - - if !pool.AppendCertsFromPEM(caCrt) { - return nil, fmt.Errorf("error loading client certificate '%s': no certificates were successfully parsed", caFile) - } - } - } - config.ClientCAs = pool - } - - // Associate the GetCertificate callback, or almost nothing we just did will work - config.GetCertificate = configMap.GetCertificate - - return config, nil -} - -// ConfigGetter gets a Config keyed by key. -type ConfigGetter func(key string) *Config - -var configGetters = make(map[string]ConfigGetter) - -// RegisterConfigGetter registers fn as the way to get a -// Config for server type serverType. -func RegisterConfigGetter(serverType string, fn ConfigGetter) { - configGetters[serverType] = fn -} - -// SetDefaultTLSParams sets the default TLS cipher suites, protocol versions, -// and server preferences of a server.Config if they were not previously set -// (it does not overwrite; only fills in missing values). -func SetDefaultTLSParams(config *Config) { - // If no ciphers provided, use default list - if len(config.Ciphers) == 0 { - config.Ciphers = defaultCiphers - } - - // Not a cipher suite, but still important for mitigating protocol downgrade attacks - // (prepend since having it at end breaks http2 due to non-h2-approved suites before it) - config.Ciphers = append([]uint16{tls.TLS_FALLBACK_SCSV}, config.Ciphers...) - - // Set default protocol min and max versions - must balance compatibility and security - if config.ProtocolMinVersion == 0 { - config.ProtocolMinVersion = tls.VersionTLS11 - } - if config.ProtocolMaxVersion == 0 { - config.ProtocolMaxVersion = tls.VersionTLS12 - } - - // Prefer server cipher suites - config.PreferServerCipherSuites = true -} - -// Map of supported key types -var supportedKeyTypes = map[string]acme.KeyType{ - "P384": acme.EC384, - "P256": acme.EC256, - "RSA8192": acme.RSA8192, - "RSA4096": acme.RSA4096, - "RSA2048": acme.RSA2048, -} - -// Map of supported protocols. -// HTTP/2 only supports TLS 1.2 and higher. -var supportedProtocols = map[string]uint16{ - "tls1.0": tls.VersionTLS10, - "tls1.1": tls.VersionTLS11, - "tls1.2": tls.VersionTLS12, -} - -// Map of supported ciphers, used only for parsing config. -// -// Note that, at time of writing, HTTP/2 blacklists 276 cipher suites, -// including all but four of the suites below (the four GCM suites). -// See https://http2.github.io/http2-spec/#BadCipherSuites -// -// TLS_FALLBACK_SCSV is not in this list because we manually ensure -// it is always added (even though it is not technically a cipher suite). -// -// This map, like any map, is NOT ORDERED. Do not range over this map. -var supportedCiphersMap = map[string]uint16{ - "ECDHE-RSA-AES256-GCM-SHA384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, - "ECDHE-ECDSA-AES256-GCM-SHA384": tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, - "ECDHE-RSA-AES128-GCM-SHA256": tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - "ECDHE-ECDSA-AES128-GCM-SHA256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - "ECDHE-RSA-AES128-CBC-SHA": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - "ECDHE-RSA-AES256-CBC-SHA": tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - "ECDHE-ECDSA-AES256-CBC-SHA": tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - "ECDHE-ECDSA-AES128-CBC-SHA": tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - "RSA-AES128-CBC-SHA": tls.TLS_RSA_WITH_AES_128_CBC_SHA, - "RSA-AES256-CBC-SHA": tls.TLS_RSA_WITH_AES_256_CBC_SHA, - "ECDHE-RSA-3DES-EDE-CBC-SHA": tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - "RSA-3DES-EDE-CBC-SHA": tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, -} - -// List of supported cipher suites in descending order of preference. -// Ordering is very important! Getting the wrong order will break -// mainstream clients, especially with HTTP/2. -// -// Note that TLS_FALLBACK_SCSV is not in this list since it is always -// added manually. -var supportedCiphers = []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, -} - -// List of all the ciphers we want to use by default -var defaultCiphers = []uint16{ - tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, -} - -const ( - // HTTPChallengePort is the officially designated port for - // the HTTP challenge. - HTTPChallengePort = "80" - - // TLSSNIChallengePort is the officially designated port for - // the TLS-SNI challenge. - TLSSNIChallengePort = "443" - - // DefaultHTTPAlternatePort is the port on which the ACME - // client will open a listener and solve the HTTP challenge. - // If this alternate port is used instead of the default - // port, then whatever is listening on the default port must - // be capable of proxying or forwarding the request to this - // alternate port. - DefaultHTTPAlternatePort = "5033" -) diff --git a/vendor/github.com/mholt/caddy/caddytls/crypto.go b/vendor/github.com/mholt/caddy/caddytls/crypto.go deleted file mode 100644 index 243b37f..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/crypto.go +++ /dev/null @@ -1,258 +0,0 @@ -package caddytls - -import ( - "bytes" - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/rsa" - "crypto/tls" - "crypto/x509" - "crypto/x509/pkix" - "encoding/pem" - "errors" - "fmt" - "io" - "io/ioutil" - "math/big" - "net" - "os" - "time" - - "github.com/xenolf/lego/acme" -) - -// loadPrivateKey loads a PEM-encoded ECC/RSA private key from file. -func loadPrivateKey(file string) (crypto.PrivateKey, error) { - keyBytes, err := ioutil.ReadFile(file) - if err != nil { - return nil, err - } - keyBlock, _ := pem.Decode(keyBytes) - - switch keyBlock.Type { - case "RSA PRIVATE KEY": - return x509.ParsePKCS1PrivateKey(keyBlock.Bytes) - case "EC PRIVATE KEY": - return x509.ParseECPrivateKey(keyBlock.Bytes) - } - - return nil, errors.New("unknown private key type") -} - -// savePrivateKey saves a PEM-encoded ECC/RSA private key to file. -func savePrivateKey(key crypto.PrivateKey, file string) error { - var pemType string - var keyBytes []byte - switch key := key.(type) { - case *ecdsa.PrivateKey: - var err error - pemType = "EC" - keyBytes, err = x509.MarshalECPrivateKey(key) - if err != nil { - return err - } - case *rsa.PrivateKey: - pemType = "RSA" - keyBytes = x509.MarshalPKCS1PrivateKey(key) - } - - pemKey := pem.Block{Type: pemType + " PRIVATE KEY", Bytes: keyBytes} - keyOut, err := os.Create(file) - if err != nil { - return err - } - keyOut.Chmod(0600) - defer keyOut.Close() - return pem.Encode(keyOut, &pemKey) -} - -// stapleOCSP staples OCSP information to cert for hostname name. -// If you have it handy, you should pass in the PEM-encoded certificate -// bundle; otherwise the DER-encoded cert will have to be PEM-encoded. -// If you don't have the PEM blocks handy, just pass in nil. -// -// Errors here are not necessarily fatal, it could just be that the -// certificate doesn't have an issuer URL. -func stapleOCSP(cert *Certificate, pemBundle []byte) error { - if pemBundle == nil { - // The function in the acme package that gets OCSP requires a PEM-encoded cert - bundle := new(bytes.Buffer) - for _, derBytes := range cert.Certificate.Certificate { - pem.Encode(bundle, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes}) - } - pemBundle = bundle.Bytes() - } - - ocspBytes, ocspResp, err := acme.GetOCSPForCert(pemBundle) - if err != nil { - return err - } - - cert.Certificate.OCSPStaple = ocspBytes - cert.OCSP = ocspResp - - return nil -} - -// makeSelfSignedCert makes a self-signed certificate according -// to the parameters in config. It then caches the certificate -// in our cache. -func makeSelfSignedCert(config *Config) error { - // start by generating private key - var privKey interface{} - var err error - switch config.KeyType { - case "", acme.EC256: - privKey, err = ecdsa.GenerateKey(elliptic.P256(), rand.Reader) - case acme.EC384: - privKey, err = ecdsa.GenerateKey(elliptic.P384(), rand.Reader) - case acme.RSA2048: - privKey, err = rsa.GenerateKey(rand.Reader, 2048) - case acme.RSA4096: - privKey, err = rsa.GenerateKey(rand.Reader, 4096) - case acme.RSA8192: - privKey, err = rsa.GenerateKey(rand.Reader, 8192) - default: - return fmt.Errorf("cannot generate private key; unknown key type %v", config.KeyType) - } - if err != nil { - return fmt.Errorf("failed to generate private key: %v", err) - } - - // create certificate structure with proper values - notBefore := time.Now() - notAfter := notBefore.Add(24 * time.Hour * 7) - serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) - serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) - if err != nil { - return fmt.Errorf("failed to generate serial number: %v", err) - } - cert := &x509.Certificate{ - SerialNumber: serialNumber, - Subject: pkix.Name{Organization: []string{"Caddy Self-Signed"}}, - NotBefore: notBefore, - NotAfter: notAfter, - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, - } - if ip := net.ParseIP(config.Hostname); ip != nil { - cert.IPAddresses = append(cert.IPAddresses, ip) - } else { - cert.DNSNames = append(cert.DNSNames, config.Hostname) - } - - publicKey := func(privKey interface{}) interface{} { - switch k := privKey.(type) { - case *rsa.PrivateKey: - return &k.PublicKey - case *ecdsa.PrivateKey: - return &k.PublicKey - default: - return errors.New("unknown key type") - } - } - derBytes, err := x509.CreateCertificate(rand.Reader, cert, cert, publicKey(privKey), privKey) - if err != nil { - return fmt.Errorf("could not create certificate: %v", err) - } - - cacheCertificate(Certificate{ - Certificate: tls.Certificate{ - Certificate: [][]byte{derBytes}, - PrivateKey: privKey, - Leaf: cert, - }, - Names: cert.DNSNames, - NotAfter: cert.NotAfter, - Config: config, - }) - - return nil -} - -// RotateSessionTicketKeys rotates the TLS session ticket keys -// on cfg every TicketRotateInterval. It spawns a new goroutine so -// this function does NOT block. It returns a channel you should -// close when you are ready to stop the key rotation, like when the -// server using cfg is no longer running. -func RotateSessionTicketKeys(cfg *tls.Config) chan struct{} { - ch := make(chan struct{}) - ticker := time.NewTicker(TicketRotateInterval) - go runTLSTicketKeyRotation(cfg, ticker, ch) - return ch -} - -// Functions that may be swapped out for testing -var ( - runTLSTicketKeyRotation = standaloneTLSTicketKeyRotation - setSessionTicketKeysTestHook = func(keys [][32]byte) [][32]byte { return keys } -) - -// standaloneTLSTicketKeyRotation governs over the array of TLS ticket keys used to de/crypt TLS tickets. -// It periodically sets a new ticket key as the first one, used to encrypt (and decrypt), -// pushing any old ticket keys to the back, where they are considered for decryption only. -// -// Lack of entropy for the very first ticket key results in the feature being disabled (as does Go), -// later lack of entropy temporarily disables ticket key rotation. -// Old ticket keys are still phased out, though. -// -// Stops the ticker when returning. -func standaloneTLSTicketKeyRotation(c *tls.Config, ticker *time.Ticker, exitChan chan struct{}) { - defer ticker.Stop() - - // The entire page should be marked as sticky, but Go cannot do that - // without resorting to syscall#Mlock. And, we don't have madvise (for NODUMP), too. ☹ - keys := make([][32]byte, 1, NumTickets) - - rng := c.Rand - if rng == nil { - rng = rand.Reader - } - if _, err := io.ReadFull(rng, keys[0][:]); err != nil { - c.SessionTicketsDisabled = true // bail if we don't have the entropy for the first one - return - } - c.SessionTicketKey = keys[0] // SetSessionTicketKeys doesn't set a 'tls.keysAlreadySet' - c.SetSessionTicketKeys(setSessionTicketKeysTestHook(keys)) - - for { - select { - case _, isOpen := <-exitChan: - if !isOpen { - return - } - case <-ticker.C: - rng = c.Rand // could've changed since the start - if rng == nil { - rng = rand.Reader - } - var newTicketKey [32]byte - _, err := io.ReadFull(rng, newTicketKey[:]) - - if len(keys) < NumTickets { - keys = append(keys, keys[0]) // manipulates the internal length - } - for idx := len(keys) - 1; idx >= 1; idx-- { - keys[idx] = keys[idx-1] // yes, this makes copies - } - - if err == nil { - keys[0] = newTicketKey - } - // pushes the last key out, doesn't matter that we don't have a new one - c.SetSessionTicketKeys(setSessionTicketKeysTestHook(keys)) - } - } -} - -const ( - // NumTickets is how many tickets to hold and consider - // to decrypt TLS sessions. - NumTickets = 4 - - // TicketRotateInterval is how often to generate - // new ticket for TLS PFS encryption - TicketRotateInterval = 10 * time.Hour -) diff --git a/vendor/github.com/mholt/caddy/caddytls/crypto_test.go b/vendor/github.com/mholt/caddy/caddytls/crypto_test.go deleted file mode 100644 index 3eca43a..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/crypto_test.go +++ /dev/null @@ -1,166 +0,0 @@ -package caddytls - -import ( - "bytes" - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/rsa" - "crypto/tls" - "crypto/x509" - "os" - "runtime" - "testing" - "time" -) - -func TestSaveAndLoadRSAPrivateKey(t *testing.T) { - keyFile := "test.key" - defer os.Remove(keyFile) - - privateKey, err := rsa.GenerateKey(rand.Reader, 128) // make tests faster; small key size OK for testing - if err != nil { - t.Fatal(err) - } - - // test save - err = savePrivateKey(privateKey, keyFile) - if err != nil { - t.Fatal("error saving private key:", err) - } - - // it doesn't make sense to test file permission on windows - if runtime.GOOS != "windows" { - // get info of the key file - info, err := os.Stat(keyFile) - if err != nil { - t.Fatal("error stating private key:", err) - } - // verify permission of key file is correct - if info.Mode().Perm() != 0600 { - t.Error("Expected key file to have permission 0600, but it wasn't") - } - } - - // test load - loadedKey, err := loadPrivateKey(keyFile) - if err != nil { - t.Error("error loading private key:", err) - } - - // verify loaded key is correct - if !PrivateKeysSame(privateKey, loadedKey) { - t.Error("Expected key bytes to be the same, but they weren't") - } -} - -func TestSaveAndLoadECCPrivateKey(t *testing.T) { - keyFile := "test.key" - defer os.Remove(keyFile) - - privateKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader) - if err != nil { - t.Fatal(err) - } - - // test save - err = savePrivateKey(privateKey, keyFile) - if err != nil { - t.Fatal("error saving private key:", err) - } - - // it doesn't make sense to test file permission on windows - if runtime.GOOS != "windows" { - // get info of the key file - info, err := os.Stat(keyFile) - if err != nil { - t.Fatal("error stating private key:", err) - } - // verify permission of key file is correct - if info.Mode().Perm() != 0600 { - t.Error("Expected key file to have permission 0600, but it wasn't") - } - } - - // test load - loadedKey, err := loadPrivateKey(keyFile) - if err != nil { - t.Error("error loading private key:", err) - } - - // verify loaded key is correct - if !PrivateKeysSame(privateKey, loadedKey) { - t.Error("Expected key bytes to be the same, but they weren't") - } -} - -// PrivateKeysSame compares the bytes of a and b and returns true if they are the same. -func PrivateKeysSame(a, b crypto.PrivateKey) bool { - return bytes.Equal(PrivateKeyBytes(a), PrivateKeyBytes(b)) -} - -// PrivateKeyBytes returns the bytes of DER-encoded key. -func PrivateKeyBytes(key crypto.PrivateKey) []byte { - var keyBytes []byte - switch key := key.(type) { - case *rsa.PrivateKey: - keyBytes = x509.MarshalPKCS1PrivateKey(key) - case *ecdsa.PrivateKey: - keyBytes, _ = x509.MarshalECPrivateKey(key) - } - return keyBytes -} - -func TestStandaloneTLSTicketKeyRotation(t *testing.T) { - tlsGovChan := make(chan struct{}) - defer close(tlsGovChan) - callSync := make(chan bool, 1) - defer close(callSync) - - oldHook := setSessionTicketKeysTestHook - defer func() { - setSessionTicketKeysTestHook = oldHook - }() - var keysInUse [][32]byte - setSessionTicketKeysTestHook = func(keys [][32]byte) [][32]byte { - keysInUse = keys - callSync <- true - return keys - } - - c := new(tls.Config) - timer := time.NewTicker(time.Millisecond * 1) - - go standaloneTLSTicketKeyRotation(c, timer, tlsGovChan) - - rounds := 0 - var lastTicketKey [32]byte - for { - select { - case <-callSync: - if lastTicketKey == keysInUse[0] { - close(tlsGovChan) - t.Errorf("The same TLS ticket key has been used again (not rotated): %x.", lastTicketKey) - return - } - lastTicketKey = keysInUse[0] - rounds++ - if rounds <= NumTickets && len(keysInUse) != rounds { - close(tlsGovChan) - t.Errorf("Expected TLS ticket keys in use: %d; Got instead: %d.", rounds, len(keysInUse)) - return - } - if c.SessionTicketsDisabled == true { - t.Error("Session tickets have been disabled unexpectedly.") - return - } - if rounds >= NumTickets+1 { - return - } - case <-time.After(time.Second * 1): - t.Errorf("Timeout after %d rounds.", rounds) - return - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddytls/handshake.go b/vendor/github.com/mholt/caddy/caddytls/handshake.go deleted file mode 100644 index f389dd7..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/handshake.go +++ /dev/null @@ -1,312 +0,0 @@ -package caddytls - -import ( - "crypto/tls" - "errors" - "fmt" - "log" - "strings" - "sync" - "sync/atomic" - "time" -) - -// configGroup is a type that keys configs by their hostname -// (hostnames can have wildcard characters; use the getConfig -// method to get a config by matching its hostname). Its -// GetCertificate function can be used with tls.Config. -type configGroup map[string]*Config - -// getConfig gets the config by the first key match for name. -// In other words, "sub.foo.bar" will get the config for "*.foo.bar" -// if that is the closest match. This function MAY return nil -// if no match is found. -// -// This function follows nearly the same logic to lookup -// a hostname as the getCertificate function uses. -func (cg configGroup) getConfig(name string) *Config { - name = strings.ToLower(name) - - // exact match? great, let's use it - if config, ok := cg[name]; ok { - return config - } - - // try replacing labels in the name with wildcards until we get a match - labels := strings.Split(name, ".") - for i := range labels { - labels[i] = "*" - candidate := strings.Join(labels, ".") - if config, ok := cg[candidate]; ok { - return config - } - } - - // as last resort, try a config that serves all names - if config, ok := cg[""]; ok { - return config - } - - return nil -} - -// GetCertificate gets a certificate to satisfy clientHello. In getting -// the certificate, it abides the rules and settings defined in the -// Config that matches clientHello.ServerName. It first checks the in- -// memory cache, then, if the config enables "OnDemand", it accessses -// disk, then accesses the network if it must obtain a new certificate -// via ACME. -// -// This method is safe for use as a tls.Config.GetCertificate callback. -func (cg configGroup) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error) { - cert, err := cg.getCertDuringHandshake(clientHello.ServerName, true, true) - return &cert.Certificate, err -} - -// getCertDuringHandshake will get a certificate for name. It first tries -// the in-memory cache. If no certificate for name is in the cache, the -// config most closely corresponding to name will be loaded. If that config -// allows it (OnDemand==true) and if loadIfNecessary == true, it goes to disk -// to load it into the cache and serve it. If it's not on disk and if -// obtainIfNecessary == true, the certificate will be obtained from the CA, -// cached, and served. If obtainIfNecessary is true, then loadIfNecessary -// must also be set to true. An error will be returned if and only if no -// certificate is available. -// -// This function is safe for concurrent use. -func (cg configGroup) getCertDuringHandshake(name string, loadIfNecessary, obtainIfNecessary bool) (Certificate, error) { - // First check our in-memory cache to see if we've already loaded it - cert, matched, defaulted := getCertificate(name) - if matched { - return cert, nil - } - - // Get the relevant TLS config for this name. If OnDemand is enabled, - // then we might be able to load or obtain a needed certificate. - cfg := cg.getConfig(name) - if cfg != nil && cfg.OnDemand && loadIfNecessary { - // Then check to see if we have one on disk - loadedCert, err := CacheManagedCertificate(name, cfg) - if err == nil { - loadedCert, err = cg.handshakeMaintenance(name, loadedCert) - if err != nil { - log.Printf("[ERROR] Maintaining newly-loaded certificate for %s: %v", name, err) - } - return loadedCert, nil - } - if obtainIfNecessary { - // By this point, we need to ask the CA for a certificate - - name = strings.ToLower(name) - - // Make sure aren't over any applicable limits - err := cg.checkLimitsForObtainingNewCerts(name) - if err != nil { - return Certificate{}, err - } - - // Name has to qualify for a certificate - if !HostQualifies(name) { - return cert, errors.New("hostname '" + name + "' does not qualify for certificate") - } - - // Obtain certificate from the CA - return cg.obtainOnDemandCertificate(name, cfg) - } - } - - // Fall back to the default certificate if there is one - if defaulted { - return cert, nil - } - - return Certificate{}, fmt.Errorf("no certificate available for %s", name) -} - -// checkLimitsForObtainingNewCerts checks to see if name can be issued right -// now according to mitigating factors we keep track of and preferences the -// user has set. If a non-nil error is returned, do not issue a new certificate -// for name. -func (cg configGroup) checkLimitsForObtainingNewCerts(name string) error { - // User can set hard limit for number of certs for the process to issue - if onDemandMaxIssue > 0 && atomic.LoadInt32(OnDemandIssuedCount) >= onDemandMaxIssue { - return fmt.Errorf("%s: maximum certificates issued (%d)", name, onDemandMaxIssue) - } - - // Make sure name hasn't failed a challenge recently - failedIssuanceMu.RLock() - when, ok := failedIssuance[name] - failedIssuanceMu.RUnlock() - if ok { - return fmt.Errorf("%s: throttled; refusing to issue cert since last attempt on %s failed", name, when.String()) - } - - // Make sure, if we've issued a few certificates already, that we haven't - // issued any recently - lastIssueTimeMu.Lock() - since := time.Since(lastIssueTime) - lastIssueTimeMu.Unlock() - if atomic.LoadInt32(OnDemandIssuedCount) >= 10 && since < 10*time.Minute { - return fmt.Errorf("%s: throttled; last certificate was obtained %v ago", name, since) - } - - // ðŸ‘Good to go - return nil -} - -// obtainOnDemandCertificate obtains a certificate for name for the given -// name. If another goroutine has already started obtaining a cert for -// name, it will wait and use what the other goroutine obtained. -// -// This function is safe for use by multiple concurrent goroutines. -func (cg configGroup) obtainOnDemandCertificate(name string, cfg *Config) (Certificate, error) { - // We must protect this process from happening concurrently, so synchronize. - obtainCertWaitChansMu.Lock() - wait, ok := obtainCertWaitChans[name] - if ok { - // lucky us -- another goroutine is already obtaining the certificate. - // wait for it to finish obtaining the cert and then we'll use it. - obtainCertWaitChansMu.Unlock() - <-wait - return cg.getCertDuringHandshake(name, true, false) - } - - // looks like it's up to us to do all the work and obtain the cert - wait = make(chan struct{}) - obtainCertWaitChans[name] = wait - obtainCertWaitChansMu.Unlock() - - // Unblock waiters and delete waitgroup when we return - defer func() { - obtainCertWaitChansMu.Lock() - close(wait) - delete(obtainCertWaitChans, name) - obtainCertWaitChansMu.Unlock() - }() - - log.Printf("[INFO] Obtaining new certificate for %s", name) - - if err := cfg.obtainCertName(name, false); err != nil { - // Failed to solve challenge, so don't allow another on-demand - // issue for this name to be attempted for a little while. - failedIssuanceMu.Lock() - failedIssuance[name] = time.Now() - go func(name string) { - time.Sleep(5 * time.Minute) - failedIssuanceMu.Lock() - delete(failedIssuance, name) - failedIssuanceMu.Unlock() - }(name) - failedIssuanceMu.Unlock() - return Certificate{}, err - } - - // Success - update counters and stuff - atomic.AddInt32(OnDemandIssuedCount, 1) - lastIssueTimeMu.Lock() - lastIssueTime = time.Now() - lastIssueTimeMu.Unlock() - - // The certificate is already on disk; now just start over to load it and serve it - return cg.getCertDuringHandshake(name, true, false) -} - -// handshakeMaintenance performs a check on cert for expiration and OCSP -// validity. -// -// This function is safe for use by multiple concurrent goroutines. -func (cg configGroup) handshakeMaintenance(name string, cert Certificate) (Certificate, error) { - // Check cert expiration - timeLeft := cert.NotAfter.Sub(time.Now().UTC()) - if timeLeft < RenewDurationBefore { - log.Printf("[INFO] Certificate for %v expires in %v; attempting renewal", cert.Names, timeLeft) - return cg.renewDynamicCertificate(name, cert.Config) - } - - // Check OCSP staple validity - if cert.OCSP != nil { - refreshTime := cert.OCSP.ThisUpdate.Add(cert.OCSP.NextUpdate.Sub(cert.OCSP.ThisUpdate) / 2) - if time.Now().After(refreshTime) { - err := stapleOCSP(&cert, nil) - if err != nil { - // An error with OCSP stapling is not the end of the world, and in fact, is - // quite common considering not all certs have issuer URLs that support it. - log.Printf("[ERROR] Getting OCSP for %s: %v", name, err) - } - certCacheMu.Lock() - certCache[name] = cert - certCacheMu.Unlock() - } - } - - return cert, nil -} - -// renewDynamicCertificate renews the certificate for name using cfg. It returns the -// certificate to use and an error, if any. currentCert may be returned even if an -// error occurs, since we perform renewals before they expire and it may still be -// usable. name should already be lower-cased before calling this function. -// -// This function is safe for use by multiple concurrent goroutines. -func (cg configGroup) renewDynamicCertificate(name string, cfg *Config) (Certificate, error) { - obtainCertWaitChansMu.Lock() - wait, ok := obtainCertWaitChans[name] - if ok { - // lucky us -- another goroutine is already renewing the certificate. - // wait for it to finish, then we'll use the new one. - obtainCertWaitChansMu.Unlock() - <-wait - return cg.getCertDuringHandshake(name, true, false) - } - - // looks like it's up to us to do all the work and renew the cert - wait = make(chan struct{}) - obtainCertWaitChans[name] = wait - obtainCertWaitChansMu.Unlock() - - // unblock waiters and delete waitgroup when we return - defer func() { - obtainCertWaitChansMu.Lock() - close(wait) - delete(obtainCertWaitChans, name) - obtainCertWaitChansMu.Unlock() - }() - - log.Printf("[INFO] Renewing certificate for %s", name) - - err := cfg.renewCertName(name, false) - if err != nil { - return Certificate{}, err - } - - return cg.getCertDuringHandshake(name, true, false) -} - -// obtainCertWaitChans is used to coordinate obtaining certs for each hostname. -var obtainCertWaitChans = make(map[string]chan struct{}) -var obtainCertWaitChansMu sync.Mutex - -// OnDemandIssuedCount is the number of certificates that have been issued -// on-demand by this process. It is only safe to modify this count atomically. -// If it reaches onDemandMaxIssue, on-demand issuances will fail. -var OnDemandIssuedCount = new(int32) - -// onDemandMaxIssue is set based on max_certs in tls config. It specifies the -// maximum number of certificates that can be issued. -// TODO: This applies globally, but we should probably make a server-specific -// way to keep track of these limits and counts, since it's specified in the -// Caddyfile... -var onDemandMaxIssue int32 - -// failedIssuance is a set of names that we recently failed to get a -// certificate for from the ACME CA. They are removed after some time. -// When a name is in this map, do not issue a certificate for it on-demand. -var failedIssuance = make(map[string]time.Time) -var failedIssuanceMu sync.RWMutex - -// lastIssueTime records when we last obtained a certificate successfully. -// If this value is recent, do not make any on-demand certificate requests. -var lastIssueTime time.Time -var lastIssueTimeMu sync.Mutex - -var errNoCert = errors.New("no certificate available") diff --git a/vendor/github.com/mholt/caddy/caddytls/handshake_test.go b/vendor/github.com/mholt/caddy/caddytls/handshake_test.go deleted file mode 100644 index 6abfb76..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/handshake_test.go +++ /dev/null @@ -1,56 +0,0 @@ -package caddytls - -import ( - "crypto/tls" - "crypto/x509" - "testing" -) - -func TestGetCertificate(t *testing.T) { - defer func() { certCache = make(map[string]Certificate) }() - - cg := make(configGroup) - - hello := &tls.ClientHelloInfo{ServerName: "example.com"} - helloSub := &tls.ClientHelloInfo{ServerName: "sub.example.com"} - helloNoSNI := &tls.ClientHelloInfo{} - helloNoMatch := &tls.ClientHelloInfo{ServerName: "nomatch"} - - // When cache is empty - if cert, err := cg.GetCertificate(hello); err == nil { - t.Errorf("GetCertificate should return error when cache is empty, got: %v", cert) - } - if cert, err := cg.GetCertificate(helloNoSNI); err == nil { - t.Errorf("GetCertificate should return error when cache is empty even if server name is blank, got: %v", cert) - } - - // When cache has one certificate in it (also is default) - defaultCert := Certificate{Names: []string{"example.com", ""}, Certificate: tls.Certificate{Leaf: &x509.Certificate{DNSNames: []string{"example.com"}}}} - certCache[""] = defaultCert - certCache["example.com"] = defaultCert - if cert, err := cg.GetCertificate(hello); err != nil { - t.Errorf("Got an error but shouldn't have, when cert exists in cache: %v", err) - } else if cert.Leaf.DNSNames[0] != "example.com" { - t.Errorf("Got wrong certificate with exact match; expected 'example.com', got: %v", cert) - } - if cert, err := cg.GetCertificate(helloNoSNI); err != nil { - t.Errorf("Got an error with no SNI but shouldn't have, when cert exists in cache: %v", err) - } else if cert.Leaf.DNSNames[0] != "example.com" { - t.Errorf("Got wrong certificate for no SNI; expected 'example.com' as default, got: %v", cert) - } - - // When retrieving wildcard certificate - certCache["*.example.com"] = Certificate{Names: []string{"*.example.com"}, Certificate: tls.Certificate{Leaf: &x509.Certificate{DNSNames: []string{"*.example.com"}}}} - if cert, err := cg.GetCertificate(helloSub); err != nil { - t.Errorf("Didn't get wildcard cert, got: cert=%v, err=%v ", cert, err) - } else if cert.Leaf.DNSNames[0] != "*.example.com" { - t.Errorf("Got wrong certificate, expected wildcard: %v", cert) - } - - // When no certificate matches, the default is returned - if cert, err := cg.GetCertificate(helloNoMatch); err != nil { - t.Errorf("Expected default certificate with no error when no matches, got err: %v", err) - } else if cert.Leaf.DNSNames[0] != "example.com" { - t.Errorf("Expected default cert with no matches, got: %v", cert) - } -} diff --git a/vendor/github.com/mholt/caddy/caddytls/httphandler.go b/vendor/github.com/mholt/caddy/caddytls/httphandler.go deleted file mode 100644 index 8115f94..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/httphandler.go +++ /dev/null @@ -1,42 +0,0 @@ -package caddytls - -import ( - "crypto/tls" - "log" - "net/http" - "net/http/httputil" - "net/url" - "strings" -) - -const challengeBasePath = "/.well-known/acme-challenge" - -// HTTPChallengeHandler proxies challenge requests to ACME client if the -// request path starts with challengeBasePath. It returns true if it -// handled the request and no more needs to be done; it returns false -// if this call was a no-op and the request still needs handling. -func HTTPChallengeHandler(w http.ResponseWriter, r *http.Request, altPort string) bool { - if !strings.HasPrefix(r.URL.Path, challengeBasePath) { - return false - } - - scheme := "http" - if r.TLS != nil { - scheme = "https" - } - - upstream, err := url.Parse(scheme + "://localhost:" + altPort) - if err != nil { - w.WriteHeader(http.StatusInternalServerError) - log.Printf("[ERROR] ACME proxy handler: %v", err) - return true - } - - proxy := httputil.NewSingleHostReverseProxy(upstream) - proxy.Transport = &http.Transport{ - TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // solver uses self-signed certs - } - proxy.ServeHTTP(w, r) - - return true -} diff --git a/vendor/github.com/mholt/caddy/caddytls/httphandler_test.go b/vendor/github.com/mholt/caddy/caddytls/httphandler_test.go deleted file mode 100644 index fc04e8e..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/httphandler_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package caddytls - -import ( - "net" - "net/http" - "net/http/httptest" - "testing" -) - -func TestHTTPChallengeHandlerNoOp(t *testing.T) { - // try base paths that aren't handled by this handler - for _, url := range []string{ - "http://localhost/", - "http://localhost/foo.html", - "http://localhost/.git", - "http://localhost/.well-known/", - "http://localhost/.well-known/acme-challenging", - } { - req, err := http.NewRequest("GET", url, nil) - if err != nil { - t.Fatalf("Could not craft request, got error: %v", err) - } - rw := httptest.NewRecorder() - if HTTPChallengeHandler(rw, req, DefaultHTTPAlternatePort) { - t.Errorf("Got true with this URL, but shouldn't have: %s", url) - } - } -} - -func TestHTTPChallengeHandlerSuccess(t *testing.T) { - expectedPath := challengeBasePath + "/asdf" - - // Set up fake acme handler backend to make sure proxying succeeds - var proxySuccess bool - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - proxySuccess = true - if r.URL.Path != expectedPath { - t.Errorf("Expected path '%s' but got '%s' instead", expectedPath, r.URL.Path) - } - })) - - // Custom listener that uses the port we expect - ln, err := net.Listen("tcp", "127.0.0.1:"+DefaultHTTPAlternatePort) - if err != nil { - t.Fatalf("Unable to start test server listener: %v", err) - } - ts.Listener = ln - - // Start our engines and run the test - ts.Start() - defer ts.Close() - req, err := http.NewRequest("GET", "http://127.0.0.1:"+DefaultHTTPAlternatePort+expectedPath, nil) - if err != nil { - t.Fatalf("Could not craft request, got error: %v", err) - } - rw := httptest.NewRecorder() - - HTTPChallengeHandler(rw, req, DefaultHTTPAlternatePort) - - if !proxySuccess { - t.Fatal("Expected request to be proxied, but it wasn't") - } -} diff --git a/vendor/github.com/mholt/caddy/caddytls/maintain.go b/vendor/github.com/mholt/caddy/caddytls/maintain.go deleted file mode 100644 index 96514ac..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/maintain.go +++ /dev/null @@ -1,228 +0,0 @@ -package caddytls - -import ( - "log" - "time" - - "golang.org/x/crypto/ocsp" -) - -func init() { - // maintain assets while this package is imported, which is - // always. we don't ever stop it, since we need it running. - go maintainAssets(make(chan struct{})) -} - -const ( - // RenewInterval is how often to check certificates for renewal. - RenewInterval = 12 * time.Hour - - // OCSPInterval is how often to check if OCSP stapling needs updating. - OCSPInterval = 1 * time.Hour - - // RenewDurationBefore is how long before expiration to renew certificates. - RenewDurationBefore = (24 * time.Hour) * 30 -) - -// maintainAssets is a permanently-blocking function -// that loops indefinitely and, on a regular schedule, checks -// certificates for expiration and initiates a renewal of certs -// that are expiring soon. It also updates OCSP stapling and -// performs other maintenance of assets. It should only be -// called once per process. -// -// You must pass in the channel which you'll close when -// maintenance should stop, to allow this goroutine to clean up -// after itself and unblock. (Not that you HAVE to stop it...) -func maintainAssets(stopChan chan struct{}) { - renewalTicker := time.NewTicker(RenewInterval) - ocspTicker := time.NewTicker(OCSPInterval) - - for { - select { - case <-renewalTicker.C: - log.Println("[INFO] Scanning for expiring certificates") - RenewManagedCertificates(false) - log.Println("[INFO] Done checking certificates") - case <-ocspTicker.C: - log.Println("[INFO] Scanning for stale OCSP staples") - UpdateOCSPStaples() - log.Println("[INFO] Done checking OCSP staples") - case <-stopChan: - renewalTicker.Stop() - ocspTicker.Stop() - log.Println("[INFO] Stopped background maintenance routine") - return - } - } -} - -// RenewManagedCertificates renews managed certificates. -func RenewManagedCertificates(allowPrompts bool) (err error) { - var renewed, deleted []Certificate - visitedNames := make(map[string]struct{}) - - certCacheMu.RLock() - for name, cert := range certCache { - if !cert.Config.Managed || cert.Config.SelfSigned { - continue - } - - // the list of names on this cert should never be empty... - if cert.Names == nil || len(cert.Names) == 0 { - log.Printf("[WARNING] Certificate keyed by '%s' has no names: %v - removing from cache", name, cert.Names) - deleted = append(deleted, cert) - continue - } - - // skip names whose certificate we've already renewed - if _, ok := visitedNames[name]; ok { - continue - } - for _, name := range cert.Names { - visitedNames[name] = struct{}{} - } - - // if its time is up or ending soon, we need to try to renew it - timeLeft := cert.NotAfter.Sub(time.Now().UTC()) - if timeLeft < RenewDurationBefore { - log.Printf("[INFO] Certificate for %v expires in %v; attempting renewal", cert.Names, timeLeft) - - if cert.Config == nil { - log.Printf("[ERROR] %s: No associated TLS config; unable to renew", name) - continue - } - - // this works well because managed certs are only associated with one name per config - err := cert.Config.RenewCert(allowPrompts) - - if err != nil { - if allowPrompts && timeLeft < 0 { - // Certificate renewal failed, the operator is present, and the certificate - // is already expired; we should stop immediately and return the error. Note - // that we used to do this any time a renewal failed at startup. However, - // after discussion in https://github.com/mholt/caddy/issues/642 we decided to - // only stop startup if the certificate is expired. We still log the error - // otherwise. - certCacheMu.RUnlock() - return err - } - log.Printf("[ERROR] %v", err) - if cert.Config.OnDemand { - deleted = append(deleted, cert) - } - } else { - renewed = append(renewed, cert) - } - } - } - certCacheMu.RUnlock() - - // Apply changes to the cache - for _, cert := range renewed { - if cert.Names[len(cert.Names)-1] == "" { - // Special case: This is the default certificate. We must - // flush it out of the cache so that we no longer point to - // the old, un-renewed certificate. Otherwise it will be - // renewed on every scan, which is too often. When we cache - // this certificate in a moment, it will be the default again. - certCacheMu.Lock() - delete(certCache, "") - certCacheMu.Unlock() - } - _, err := CacheManagedCertificate(cert.Names[0], cert.Config) - if err != nil { - if allowPrompts { - return err // operator is present, so report error immediately - } - log.Printf("[ERROR] %v", err) - } - } - for _, cert := range deleted { - certCacheMu.Lock() - for _, name := range cert.Names { - delete(certCache, name) - } - certCacheMu.Unlock() - } - - return nil -} - -// UpdateOCSPStaples updates the OCSP stapling in all -// eligible, cached certificates. -func UpdateOCSPStaples() { - // Create a temporary place to store updates - // until we release the potentially long-lived - // read lock and use a short-lived write lock. - type ocspUpdate struct { - rawBytes []byte - parsed *ocsp.Response - } - updated := make(map[string]ocspUpdate) - - // A single SAN certificate maps to multiple names, so we use this - // set to make sure we don't waste cycles checking OCSP for the same - // certificate multiple times. - visited := make(map[string]struct{}) - - certCacheMu.RLock() - for name, cert := range certCache { - // skip this certificate if we've already visited it, - // and if not, mark all the names as visited - if _, ok := visited[name]; ok { - continue - } - for _, n := range cert.Names { - visited[n] = struct{}{} - } - - // no point in updating OCSP for expired certificates - if time.Now().After(cert.NotAfter) { - continue - } - - var lastNextUpdate time.Time - if cert.OCSP != nil { - // start checking OCSP staple about halfway through validity period for good measure - lastNextUpdate = cert.OCSP.NextUpdate - refreshTime := cert.OCSP.ThisUpdate.Add(lastNextUpdate.Sub(cert.OCSP.ThisUpdate) / 2) - - // since OCSP is already stapled, we need only check if we're in that "refresh window" - if time.Now().Before(refreshTime) { - continue - } - } - - err := stapleOCSP(&cert, nil) - if err != nil { - if cert.OCSP != nil { - // if there was no staple before, that's fine; otherwise we should log the error - log.Printf("[ERROR] Checking OCSP for %v: %v", cert.Names, err) - } - continue - } - - // By this point, we've obtained the latest OCSP response. - // If there was no staple before, or if the response is updated, make - // sure we apply the update to all names on the certificate. - if lastNextUpdate.IsZero() || lastNextUpdate != cert.OCSP.NextUpdate { - log.Printf("[INFO] Advancing OCSP staple for %v from %s to %s", - cert.Names, lastNextUpdate, cert.OCSP.NextUpdate) - for _, n := range cert.Names { - updated[n] = ocspUpdate{rawBytes: cert.Certificate.OCSPStaple, parsed: cert.OCSP} - } - } - } - certCacheMu.RUnlock() - - // This write lock should be brief since we have all the info we need now. - certCacheMu.Lock() - for name, update := range updated { - cert := certCache[name] - cert.OCSP = update.parsed - cert.Certificate.OCSPStaple = update.rawBytes - certCache[name] = cert - } - certCacheMu.Unlock() -} diff --git a/vendor/github.com/mholt/caddy/caddytls/setup.go b/vendor/github.com/mholt/caddy/caddytls/setup.go deleted file mode 100644 index 9db647e..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/setup.go +++ /dev/null @@ -1,275 +0,0 @@ -package caddytls - -import ( - "bytes" - "crypto/tls" - "encoding/pem" - "fmt" - "io/ioutil" - "log" - "os" - "path/filepath" - "strconv" - "strings" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("tls", caddy.Plugin{Action: setupTLS}) -} - -// setupTLS sets up the TLS configuration and installs certificates that -// are specified by the user in the config file. All the automatic HTTPS -// stuff comes later outside of this function. -func setupTLS(c *caddy.Controller) error { - configGetter, ok := configGetters[c.ServerType()] - if !ok { - return fmt.Errorf("no caddytls.ConfigGetter for %s server type; must call RegisterConfigGetter", c.ServerType()) - } - config := configGetter(c.Key) - if config == nil { - return fmt.Errorf("no caddytls.Config to set up for %s", c.Key) - } - - config.Enabled = true - - for c.Next() { - var certificateFile, keyFile, loadDir, maxCerts string - - args := c.RemainingArgs() - switch len(args) { - case 1: - // even if the email is one of the special values below, - // it is still necessary for future analysis that we store - // that value in the ACMEEmail field. - config.ACMEEmail = args[0] - - // user can force-disable managed TLS this way - if args[0] == "off" { - config.Enabled = false - return nil - } - - // user might want a temporary, in-memory, self-signed cert - if args[0] == "self_signed" { - config.SelfSigned = true - } - case 2: - certificateFile = args[0] - keyFile = args[1] - config.Manual = true - } - - // Optional block with extra parameters - var hadBlock bool - for c.NextBlock() { - hadBlock = true - switch c.Val() { - case "key_type": - arg := c.RemainingArgs() - value, ok := supportedKeyTypes[strings.ToUpper(arg[0])] - if !ok { - return c.Errf("Wrong key type name or key type not supported: '%s'", c.Val()) - } - config.KeyType = value - case "protocols": - args := c.RemainingArgs() - if len(args) != 2 { - return c.ArgErr() - } - value, ok := supportedProtocols[strings.ToLower(args[0])] - if !ok { - return c.Errf("Wrong protocol name or protocol not supported: '%s'", args[0]) - } - config.ProtocolMinVersion = value - value, ok = supportedProtocols[strings.ToLower(args[1])] - if !ok { - return c.Errf("Wrong protocol name or protocol not supported: '%s'", args[1]) - } - config.ProtocolMaxVersion = value - case "ciphers": - for c.NextArg() { - value, ok := supportedCiphersMap[strings.ToUpper(c.Val())] - if !ok { - return c.Errf("Wrong cipher name or cipher not supported: '%s'", c.Val()) - } - config.Ciphers = append(config.Ciphers, value) - } - case "clients": - clientCertList := c.RemainingArgs() - if len(clientCertList) == 0 { - return c.ArgErr() - } - - listStart, mustProvideCA := 1, true - switch clientCertList[0] { - case "request": - config.ClientAuth = tls.RequestClientCert - mustProvideCA = false - case "require": - config.ClientAuth = tls.RequireAnyClientCert - mustProvideCA = false - case "verify_if_given": - config.ClientAuth = tls.VerifyClientCertIfGiven - default: - config.ClientAuth = tls.RequireAndVerifyClientCert - listStart = 0 - } - if mustProvideCA && len(clientCertList) <= listStart { - return c.ArgErr() - } - - config.ClientCerts = clientCertList[listStart:] - case "load": - c.Args(&loadDir) - config.Manual = true - case "max_certs": - c.Args(&maxCerts) - config.OnDemand = true - case "dns": - args := c.RemainingArgs() - if len(args) != 1 { - return c.ArgErr() - } - dnsProvName := args[0] - if _, ok := dnsProviders[dnsProvName]; !ok { - return c.Errf("Unsupported DNS provider '%s'", args[0]) - } - config.DNSProvider = args[0] - default: - return c.Errf("Unknown keyword '%s'", c.Val()) - } - } - - // tls requires at least one argument if a block is not opened - if len(args) == 0 && !hadBlock { - return c.ArgErr() - } - - // set certificate limit if on-demand TLS is enabled - if maxCerts != "" { - maxCertsNum, err := strconv.Atoi(maxCerts) - if err != nil || maxCertsNum < 1 { - return c.Err("max_certs must be a positive integer") - } - if onDemandMaxIssue == 0 || int32(maxCertsNum) < onDemandMaxIssue { // keep the minimum; TODO: We have to do this because it is global; should be per-server or per-vhost... - onDemandMaxIssue = int32(maxCertsNum) - } - } - - // don't try to load certificates unless we're supposed to - if !config.Enabled || !config.Manual { - continue - } - - // load a single certificate and key, if specified - if certificateFile != "" && keyFile != "" { - err := cacheUnmanagedCertificatePEMFile(certificateFile, keyFile) - if err != nil { - return c.Errf("Unable to load certificate and key files for '%s': %v", c.Key, err) - } - log.Printf("[INFO] Successfully loaded TLS assets from %s and %s", certificateFile, keyFile) - } - - // load a directory of certificates, if specified - if loadDir != "" { - err := loadCertsInDir(c, loadDir) - if err != nil { - return err - } - } - } - - SetDefaultTLSParams(config) - - // generate self-signed cert if needed - if config.SelfSigned { - err := makeSelfSignedCert(config) - if err != nil { - return fmt.Errorf("self-signed: %v", err) - } - } - - return nil -} - -// loadCertsInDir loads all the certificates/keys in dir, as long as -// the file ends with .pem. This method of loading certificates is -// modeled after haproxy, which expects the certificate and key to -// be bundled into the same file: -// https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#5.1-crt -// -// This function may write to the log as it walks the directory tree. -func loadCertsInDir(c *caddy.Controller, dir string) error { - return filepath.Walk(dir, func(path string, info os.FileInfo, err error) error { - if err != nil { - log.Printf("[WARNING] Unable to traverse into %s; skipping", path) - return nil - } - if info.IsDir() { - return nil - } - if strings.HasSuffix(strings.ToLower(info.Name()), ".pem") { - certBuilder, keyBuilder := new(bytes.Buffer), new(bytes.Buffer) - var foundKey bool // use only the first key in the file - - bundle, err := ioutil.ReadFile(path) - if err != nil { - return err - } - - for { - // Decode next block so we can see what type it is - var derBlock *pem.Block - derBlock, bundle = pem.Decode(bundle) - if derBlock == nil { - break - } - - if derBlock.Type == "CERTIFICATE" { - // Re-encode certificate as PEM, appending to certificate chain - pem.Encode(certBuilder, derBlock) - } else if derBlock.Type == "EC PARAMETERS" { - // EC keys generated from openssl can be composed of two blocks: - // parameters and key (parameter block should come first) - if !foundKey { - // Encode parameters - pem.Encode(keyBuilder, derBlock) - - // Key must immediately follow - derBlock, bundle = pem.Decode(bundle) - if derBlock == nil || derBlock.Type != "EC PRIVATE KEY" { - return c.Errf("%s: expected elliptic private key to immediately follow EC parameters", path) - } - pem.Encode(keyBuilder, derBlock) - foundKey = true - } - } else if derBlock.Type == "PRIVATE KEY" || strings.HasSuffix(derBlock.Type, " PRIVATE KEY") { - // RSA key - if !foundKey { - pem.Encode(keyBuilder, derBlock) - foundKey = true - } - } else { - return c.Errf("%s: unrecognized PEM block type: %s", path, derBlock.Type) - } - } - - certPEMBytes, keyPEMBytes := certBuilder.Bytes(), keyBuilder.Bytes() - if len(certPEMBytes) == 0 { - return c.Errf("%s: failed to parse PEM data", path) - } - if len(keyPEMBytes) == 0 { - return c.Errf("%s: no private key block found", path) - } - - err = cacheUnmanagedCertificatePEMBytes(certPEMBytes, keyPEMBytes) - if err != nil { - return c.Errf("%s: failed to load cert and key for '%s': %v", path, c.Key, err) - } - log.Printf("[INFO] Successfully loaded TLS assets from %s", path) - } - return nil - }) -} diff --git a/vendor/github.com/mholt/caddy/caddytls/setup_test.go b/vendor/github.com/mholt/caddy/caddytls/setup_test.go deleted file mode 100644 index ceb1c2a..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/setup_test.go +++ /dev/null @@ -1,298 +0,0 @@ -package caddytls - -import ( - "crypto/tls" - "io/ioutil" - "log" - "os" - "testing" - - "github.com/mholt/caddy" - "github.com/xenolf/lego/acme" -) - -func TestMain(m *testing.M) { - // Write test certificates to disk before tests, and clean up - // when we're done. - err := ioutil.WriteFile(certFile, testCert, 0644) - if err != nil { - log.Fatal(err) - } - err = ioutil.WriteFile(keyFile, testKey, 0644) - if err != nil { - os.Remove(certFile) - log.Fatal(err) - } - - result := m.Run() - - os.Remove(certFile) - os.Remove(keyFile) - os.Exit(result) -} - -func TestSetupParseBasic(t *testing.T) { - cfg := new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c := caddy.NewTestController(`tls ` + certFile + ` ` + keyFile + ``) - - err := setupTLS(c) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - - // Basic checks - if !cfg.Manual { - t.Error("Expected TLS Manual=true, but was false") - } - if !cfg.Enabled { - t.Error("Expected TLS Enabled=true, but was false") - } - - // Security defaults - if cfg.ProtocolMinVersion != tls.VersionTLS11 { - t.Errorf("Expected 'tls1.1 (0x0302)' as ProtocolMinVersion, got %#v", cfg.ProtocolMinVersion) - } - if cfg.ProtocolMaxVersion != tls.VersionTLS12 { - t.Errorf("Expected 'tls1.2 (0x0303)' as ProtocolMaxVersion, got %v", cfg.ProtocolMaxVersion) - } - - // Cipher checks - expectedCiphers := []uint16{ - tls.TLS_FALLBACK_SCSV, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - } - - // Ensure count is correct (plus one for TLS_FALLBACK_SCSV) - if len(cfg.Ciphers) != len(expectedCiphers) { - t.Errorf("Expected %v Ciphers (including TLS_FALLBACK_SCSV), got %v", - len(expectedCiphers), len(cfg.Ciphers)) - } - - // Ensure ordering is correct - for i, actual := range cfg.Ciphers { - if actual != expectedCiphers[i] { - t.Errorf("Expected cipher in position %d to be %0x, got %0x", i, expectedCiphers[i], actual) - } - } - - if !cfg.PreferServerCipherSuites { - t.Error("Expected PreferServerCipherSuites = true, but was false") - } -} - -func TestSetupParseIncompleteParams(t *testing.T) { - // Using tls without args is an error because it's unnecessary. - c := caddy.NewTestController(`tls`) - err := setupTLS(c) - if err == nil { - t.Error("Expected an error, but didn't get one") - } -} - -func TestSetupParseWithOptionalParams(t *testing.T) { - params := `tls ` + certFile + ` ` + keyFile + ` { - protocols tls1.0 tls1.2 - ciphers RSA-AES256-CBC-SHA ECDHE-RSA-AES128-GCM-SHA256 ECDHE-ECDSA-AES256-GCM-SHA384 - }` - cfg := new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c := caddy.NewTestController(params) - - err := setupTLS(c) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - - if cfg.ProtocolMinVersion != tls.VersionTLS10 { - t.Errorf("Expected 'tls1.0 (0x0301)' as ProtocolMinVersion, got %#v", cfg.ProtocolMinVersion) - } - - if cfg.ProtocolMaxVersion != tls.VersionTLS12 { - t.Errorf("Expected 'tls1.2 (0x0303)' as ProtocolMaxVersion, got %#v", cfg.ProtocolMaxVersion) - } - - if len(cfg.Ciphers)-1 != 3 { - t.Errorf("Expected 3 Ciphers (not including TLS_FALLBACK_SCSV), got %v", len(cfg.Ciphers)-1) - } -} - -func TestSetupDefaultWithOptionalParams(t *testing.T) { - params := `tls { - ciphers RSA-3DES-EDE-CBC-SHA - }` - cfg := new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c := caddy.NewTestController(params) - - err := setupTLS(c) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - if len(cfg.Ciphers)-1 != 1 { - t.Errorf("Expected 1 ciphers (not including TLS_FALLBACK_SCSV), got %v", len(cfg.Ciphers)-1) - } -} - -func TestSetupParseWithWrongOptionalParams(t *testing.T) { - // Test protocols wrong params - params := `tls ` + certFile + ` ` + keyFile + ` { - protocols ssl tls - }` - cfg := new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c := caddy.NewTestController(params) - err := setupTLS(c) - if err == nil { - t.Errorf("Expected errors, but no error returned") - } - - // Test ciphers wrong params - params = `tls ` + certFile + ` ` + keyFile + ` { - ciphers not-valid-cipher - }` - cfg = new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c = caddy.NewTestController(params) - err = setupTLS(c) - if err == nil { - t.Errorf("Expected errors, but no error returned") - } - - // Test key_type wrong params - params = `tls { - key_type ab123 - }` - cfg = new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c = caddy.NewTestController(params) - err = setupTLS(c) - if err == nil { - t.Errorf("Expected errors, but no error returned") - } -} - -func TestSetupParseWithClientAuth(t *testing.T) { - // Test missing client cert file - params := `tls ` + certFile + ` ` + keyFile + ` { - clients - }` - cfg := new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c := caddy.NewTestController(params) - err := setupTLS(c) - if err == nil { - t.Errorf("Expected an error, but no error returned") - } - - noCAs, twoCAs := []string{}, []string{"client_ca.crt", "client2_ca.crt"} - for caseNumber, caseData := range []struct { - params string - clientAuthType tls.ClientAuthType - expectedErr bool - expectedCAs []string - }{ - {"", tls.NoClientCert, false, noCAs}, - {`tls ` + certFile + ` ` + keyFile + ` { - clients client_ca.crt client2_ca.crt - }`, tls.RequireAndVerifyClientCert, false, twoCAs}, - // now come modifier - {`tls ` + certFile + ` ` + keyFile + ` { - clients request - }`, tls.RequestClientCert, false, noCAs}, - {`tls ` + certFile + ` ` + keyFile + ` { - clients require - }`, tls.RequireAnyClientCert, false, noCAs}, - {`tls ` + certFile + ` ` + keyFile + ` { - clients verify_if_given client_ca.crt client2_ca.crt - }`, tls.VerifyClientCertIfGiven, false, twoCAs}, - {`tls ` + certFile + ` ` + keyFile + ` { - clients verify_if_given - }`, tls.VerifyClientCertIfGiven, true, noCAs}, - } { - cfg := new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c := caddy.NewTestController(caseData.params) - err := setupTLS(c) - if caseData.expectedErr { - if err == nil { - t.Errorf("In case %d: Expected an error, got: %v", caseNumber, err) - } - continue - } - if err != nil { - t.Errorf("In case %d: Expected no errors, got: %v", caseNumber, err) - } - - if caseData.clientAuthType != cfg.ClientAuth { - t.Errorf("In case %d: Expected TLS client auth type %v, got: %v", - caseNumber, caseData.clientAuthType, cfg.ClientAuth) - } - - if count := len(cfg.ClientCerts); count < len(caseData.expectedCAs) { - t.Fatalf("In case %d: Expected %d client certs, had %d", caseNumber, len(caseData.expectedCAs), count) - } - - for idx, expected := range caseData.expectedCAs { - if actual := cfg.ClientCerts[idx]; actual != expected { - t.Errorf("In case %d: Expected %dth client cert file to be '%s', but was '%s'", - caseNumber, idx, expected, actual) - } - } - } -} - -func TestSetupParseWithKeyType(t *testing.T) { - params := `tls { - key_type p384 - }` - cfg := new(Config) - RegisterConfigGetter("", func(key string) *Config { return cfg }) - c := caddy.NewTestController(params) - - err := setupTLS(c) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - - if cfg.KeyType != acme.EC384 { - t.Errorf("Expected 'P384' as KeyType, got %#v", cfg.KeyType) - } -} - -const ( - certFile = "test_cert.pem" - keyFile = "test_key.pem" -) - -var testCert = []byte(`-----BEGIN CERTIFICATE----- -MIIBkjCCATmgAwIBAgIJANfFCBcABL6LMAkGByqGSM49BAEwFDESMBAGA1UEAxMJ -bG9jYWxob3N0MB4XDTE2MDIxMDIyMjAyNFoXDTE4MDIwOTIyMjAyNFowFDESMBAG -A1UEAxMJbG9jYWxob3N0MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEs22MtnG7 -9K1mvIyjEO9GLx7BFD0tBbGnwQ0VPsuCxC6IeVuXbQDLSiVQvFZ6lUszTlczNxVk -pEfqrM6xAupB7qN1MHMwHQYDVR0OBBYEFHxYDvAxUwL4XrjPev6qZ/BiLDs5MEQG -A1UdIwQ9MDuAFHxYDvAxUwL4XrjPev6qZ/BiLDs5oRikFjAUMRIwEAYDVQQDEwls -b2NhbGhvc3SCCQDXxQgXAAS+izAMBgNVHRMEBTADAQH/MAkGByqGSM49BAEDSAAw -RQIgRvBqbyJM2JCJqhA1FmcoZjeMocmhxQHTt1c+1N2wFUgCIQDtvrivbBPA688N -Qh3sMeAKNKPsx5NxYdoWuu9KWcKz9A== ------END CERTIFICATE----- -`) - -var testKey = []byte(`-----BEGIN EC PARAMETERS----- -BggqhkjOPQMBBw== ------END EC PARAMETERS----- ------BEGIN EC PRIVATE KEY----- -MHcCAQEEIGLtRmwzYVcrH3J0BnzYbGPdWVF10i9p6mxkA4+b2fURoAoGCCqGSM49 -AwEHoUQDQgAEs22MtnG79K1mvIyjEO9GLx7BFD0tBbGnwQ0VPsuCxC6IeVuXbQDL -SiVQvFZ6lUszTlczNxVkpEfqrM6xAupB7g== ------END EC PRIVATE KEY----- -`) diff --git a/vendor/github.com/mholt/caddy/caddytls/storage.go b/vendor/github.com/mholt/caddy/caddytls/storage.go deleted file mode 100644 index 1a00a9d..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/storage.go +++ /dev/null @@ -1,134 +0,0 @@ -package caddytls - -import ( - "fmt" - "net/url" - "path/filepath" - "strings" - - "github.com/mholt/caddy" -) - -// StorageFor gets the storage value associated with the -// caURL, which should be unique for every different -// ACME CA. -func StorageFor(caURL string) (Storage, error) { - if caURL == "" { - caURL = DefaultCAUrl - } - if caURL == "" { - return "", fmt.Errorf("cannot create storage without CA URL") - } - caURL = strings.ToLower(caURL) - - // scheme required or host will be parsed as path (as of Go 1.6) - if !strings.Contains(caURL, "://") { - caURL = "https://" + caURL - } - - u, err := url.Parse(caURL) - if err != nil { - return "", fmt.Errorf("%s: unable to parse CA URL: %v", caURL, err) - } - - if u.Host == "" { - return "", fmt.Errorf("%s: no host in CA URL", caURL) - } - - return Storage(filepath.Join(storageBasePath, u.Host)), nil -} - -// Storage is a root directory and facilitates -// forming file paths derived from it. It is used -// to get file paths in a consistent, cross- -// platform way for persisting ACME assets. -// on the file system. -type Storage string - -// Sites gets the directory that stores site certificate and keys. -func (s Storage) Sites() string { - return filepath.Join(string(s), "sites") -} - -// Site returns the path to the folder containing assets for domain. -func (s Storage) Site(domain string) string { - domain = strings.ToLower(domain) - return filepath.Join(s.Sites(), domain) -} - -// SiteCertFile returns the path to the certificate file for domain. -func (s Storage) SiteCertFile(domain string) string { - domain = strings.ToLower(domain) - return filepath.Join(s.Site(domain), domain+".crt") -} - -// SiteKeyFile returns the path to domain's private key file. -func (s Storage) SiteKeyFile(domain string) string { - domain = strings.ToLower(domain) - return filepath.Join(s.Site(domain), domain+".key") -} - -// SiteMetaFile returns the path to the domain's asset metadata file. -func (s Storage) SiteMetaFile(domain string) string { - domain = strings.ToLower(domain) - return filepath.Join(s.Site(domain), domain+".json") -} - -// Users gets the directory that stores account folders. -func (s Storage) Users() string { - return filepath.Join(string(s), "users") -} - -// User gets the account folder for the user with email. -func (s Storage) User(email string) string { - if email == "" { - email = emptyEmail - } - email = strings.ToLower(email) - return filepath.Join(s.Users(), email) -} - -// UserRegFile gets the path to the registration file for -// the user with the given email address. -func (s Storage) UserRegFile(email string) string { - if email == "" { - email = emptyEmail - } - email = strings.ToLower(email) - fileName := emailUsername(email) - if fileName == "" { - fileName = "registration" - } - return filepath.Join(s.User(email), fileName+".json") -} - -// UserKeyFile gets the path to the private key file for -// the user with the given email address. -func (s Storage) UserKeyFile(email string) string { - if email == "" { - email = emptyEmail - } - email = strings.ToLower(email) - fileName := emailUsername(email) - if fileName == "" { - fileName = "private" - } - return filepath.Join(s.User(email), fileName+".key") -} - -// emailUsername returns the username portion of an -// email address (part before '@') or the original -// input if it can't find the "@" symbol. -func emailUsername(email string) string { - at := strings.Index(email, "@") - if at == -1 { - return email - } else if at == 0 { - return email[1:] - } - return email[:at] -} - -// storageBasePath is the root path in which all TLS/ACME assets are -// stored. Do not change this value during the lifetime of the program. -var storageBasePath = filepath.Join(caddy.AssetsPath(), "acme") diff --git a/vendor/github.com/mholt/caddy/caddytls/storage_test.go b/vendor/github.com/mholt/caddy/caddytls/storage_test.go deleted file mode 100644 index e9175af..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/storage_test.go +++ /dev/null @@ -1,135 +0,0 @@ -package caddytls - -import ( - "path/filepath" - "testing" -) - -func TestStorageFor(t *testing.T) { - // first try without DefaultCAUrl set - DefaultCAUrl = "" - _, err := StorageFor("") - if err == nil { - t.Errorf("Without a default CA, expected error, but didn't get one") - } - st, err := StorageFor("https://example.com/foo") - if err != nil { - t.Errorf("Without a default CA but given input, expected no error, but got: %v", err) - } - if string(st) != filepath.Join(storageBasePath, "example.com") { - t.Errorf("Without a default CA but given input, expected '%s' not '%s'", "example.com", st) - } - - // try with the DefaultCAUrl set - DefaultCAUrl = "https://defaultCA/directory" - for i, test := range []struct { - input, expect string - shouldErr bool - }{ - {"https://acme-staging.api.letsencrypt.org/directory", "acme-staging.api.letsencrypt.org", false}, - {"https://foo/boo?bar=q", "foo", false}, - {"http://foo", "foo", false}, - {"", "defaultca", false}, - {"https://FooBar/asdf", "foobar", false}, - {"noscheme/path", "noscheme", false}, - {"/nohost", "", true}, - {"https:///nohost", "", true}, - {"FooBar", "foobar", false}, - } { - st, err := StorageFor(test.input) - if err == nil && test.shouldErr { - t.Errorf("Test %d: Expected an error, but didn't get one", i) - } else if err != nil && !test.shouldErr { - t.Errorf("Test %d: Expected no errors, but got: %v", i, err) - } - want := filepath.Join(storageBasePath, test.expect) - if test.shouldErr { - want = "" - } - if string(st) != want { - t.Errorf("Test %d: Expected '%s' but got '%s'", i, want, string(st)) - } - } -} - -func TestStorage(t *testing.T) { - storage := Storage("./le_test") - - if expected, actual := filepath.Join("le_test", "sites"), storage.Sites(); actual != expected { - t.Errorf("Expected Sites() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "sites", "test.com"), storage.Site("Test.com"); actual != expected { - t.Errorf("Expected Site() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "sites", "test.com", "test.com.crt"), storage.SiteCertFile("Test.com"); actual != expected { - t.Errorf("Expected SiteCertFile() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "sites", "test.com", "test.com.key"), storage.SiteKeyFile("test.com"); actual != expected { - t.Errorf("Expected SiteKeyFile() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "sites", "test.com", "test.com.json"), storage.SiteMetaFile("TEST.COM"); actual != expected { - t.Errorf("Expected SiteMetaFile() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "users"), storage.Users(); actual != expected { - t.Errorf("Expected Users() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "users", "me@example.com"), storage.User("Me@example.com"); actual != expected { - t.Errorf("Expected User() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "users", "me@example.com", "me.json"), storage.UserRegFile("ME@EXAMPLE.COM"); actual != expected { - t.Errorf("Expected UserRegFile() to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "users", "me@example.com", "me.key"), storage.UserKeyFile("me@example.com"); actual != expected { - t.Errorf("Expected UserKeyFile() to return '%s' but got '%s'", expected, actual) - } - - // Test with empty emails - if expected, actual := filepath.Join("le_test", "users", emptyEmail), storage.User(emptyEmail); actual != expected { - t.Errorf("Expected User(\"\") to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "users", emptyEmail, emptyEmail+".json"), storage.UserRegFile(""); actual != expected { - t.Errorf("Expected UserRegFile(\"\") to return '%s' but got '%s'", expected, actual) - } - if expected, actual := filepath.Join("le_test", "users", emptyEmail, emptyEmail+".key"), storage.UserKeyFile(""); actual != expected { - t.Errorf("Expected UserKeyFile(\"\") to return '%s' but got '%s'", expected, actual) - } -} - -func TestEmailUsername(t *testing.T) { - for i, test := range []struct { - input, expect string - }{ - { - input: "username@example.com", - expect: "username", - }, - { - input: "plus+addressing@example.com", - expect: "plus+addressing", - }, - { - input: "me+plus-addressing@example.com", - expect: "me+plus-addressing", - }, - { - input: "not-an-email", - expect: "not-an-email", - }, - { - input: "@foobar.com", - expect: "foobar.com", - }, - { - input: emptyEmail, - expect: emptyEmail, - }, - { - input: "", - expect: "", - }, - } { - if actual := emailUsername(test.input); actual != test.expect { - t.Errorf("Test %d: Expected username to be '%s' but was '%s'", i, test.expect, actual) - } - } -} diff --git a/vendor/github.com/mholt/caddy/caddytls/tls.go b/vendor/github.com/mholt/caddy/caddytls/tls.go deleted file mode 100644 index c871492..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/tls.go +++ /dev/null @@ -1,202 +0,0 @@ -// Package caddytls facilitates the management of TLS assets and integrates -// Let's Encrypt functionality into Caddy with first-class support for -// creating and renewing certificates automatically. It also implements -// the tls directive. -// -// This package is meant to be used by Caddy server types. To use the -// tls directive, a server type must import this package and call -// RegisterConfigGetter(). The server type must make and keep track of -// the caddytls.Config structs that this package produces. It must also -// add tls to its list of directives. When it comes time to make the -// server instances, the server type can call MakeTLSConfig() to convert -// a []caddytls.Config to a single tls.Config for use in tls.NewListener(). -// It is also recommended to call RotateSessionTicketKeys() when -// starting a new listener. -package caddytls - -import ( - "encoding/json" - "io/ioutil" - "net" - "os" - "strings" - - "github.com/xenolf/lego/acme" -) - -// HostQualifies returns true if the hostname alone -// appears eligible for automatic HTTPS. For example, -// localhost, empty hostname, and IP addresses are -// not eligible because we cannot obtain certificates -// for those names. -func HostQualifies(hostname string) bool { - return hostname != "localhost" && // localhost is ineligible - - // hostname must not be empty - strings.TrimSpace(hostname) != "" && - - // must not contain wildcard (*) characters (until CA supports it) - !strings.Contains(hostname, "*") && - - // must not start or end with a dot - !strings.HasPrefix(hostname, ".") && - !strings.HasSuffix(hostname, ".") && - - // cannot be an IP address, see - // https://community.letsencrypt.org/t/certificate-for-static-ip/84/2?u=mholt - net.ParseIP(hostname) == nil -} - -// existingCertAndKey returns true if the hostname has -// a certificate and private key in storage already under -// the storage provided, otherwise it returns false. -func existingCertAndKey(storage Storage, hostname string) bool { - _, err := os.Stat(storage.SiteCertFile(hostname)) - if err != nil { - return false - } - _, err = os.Stat(storage.SiteKeyFile(hostname)) - if err != nil { - return false - } - return true -} - -// saveCertResource saves the certificate resource to disk. This -// includes the certificate file itself, the private key, and the -// metadata file. -func saveCertResource(storage Storage, cert acme.CertificateResource) error { - err := os.MkdirAll(storage.Site(cert.Domain), 0700) - if err != nil { - return err - } - - // Save cert - err = ioutil.WriteFile(storage.SiteCertFile(cert.Domain), cert.Certificate, 0600) - if err != nil { - return err - } - - // Save private key - err = ioutil.WriteFile(storage.SiteKeyFile(cert.Domain), cert.PrivateKey, 0600) - if err != nil { - return err - } - - // Save cert metadata - jsonBytes, err := json.MarshalIndent(&cert, "", "\t") - if err != nil { - return err - } - err = ioutil.WriteFile(storage.SiteMetaFile(cert.Domain), jsonBytes, 0600) - if err != nil { - return err - } - - return nil -} - -// Revoke revokes the certificate for host via ACME protocol. -// It assumes the certificate was obtained from the -// CA at DefaultCAUrl. -func Revoke(host string) error { - client, err := newACMEClient(new(Config), true) - if err != nil { - return err - } - return client.Revoke(host) -} - -// tlsSniSolver is a type that can solve tls-sni challenges using -// an existing listener and our custom, in-memory certificate cache. -type tlsSniSolver struct{} - -// Present adds the challenge certificate to the cache. -func (s tlsSniSolver) Present(domain, token, keyAuth string) error { - cert, acmeDomain, err := acme.TLSSNI01ChallengeCert(keyAuth) - if err != nil { - return err - } - cacheCertificate(Certificate{ - Certificate: cert, - Names: []string{acmeDomain}, - }) - return nil -} - -// CleanUp removes the challenge certificate from the cache. -func (s tlsSniSolver) CleanUp(domain, token, keyAuth string) error { - _, acmeDomain, err := acme.TLSSNI01ChallengeCert(keyAuth) - if err != nil { - return err - } - uncacheCertificate(acmeDomain) - return nil -} - -// ConfigHolder is any type that has a Config; it presumably is -// connected to a hostname and port on which it is serving. -type ConfigHolder interface { - TLSConfig() *Config - Host() string - Port() string -} - -// QualifiesForManagedTLS returns true if c qualifies for -// for managed TLS (but not on-demand TLS specifically). -// It does NOT check to see if a cert and key already exist -// for the config. If the return value is true, you should -// be OK to set c.TLSConfig().Managed to true; then you should -// check that value in the future instead, because the process -// of setting up the config may make it look like it doesn't -// qualify even though it originally did. -func QualifiesForManagedTLS(c ConfigHolder) bool { - if c == nil { - return false - } - tlsConfig := c.TLSConfig() - if tlsConfig == nil { - return false - } - - return (!tlsConfig.Manual || tlsConfig.OnDemand) && // user might provide own cert and key - - // if self-signed, we've already generated one to use - !tlsConfig.SelfSigned && - - // user can force-disable managed TLS - c.Port() != "80" && - tlsConfig.ACMEEmail != "off" && - - // we get can't certs for some kinds of hostnames, but - // on-demand TLS allows empty hostnames at startup - (HostQualifies(c.Host()) || tlsConfig.OnDemand) -} - -// DNSProviderConstructor is a function that takes credentials and -// returns a type that can solve the ACME DNS challenges. -type DNSProviderConstructor func(credentials ...string) (acme.ChallengeProvider, error) - -// dnsProviders is the list of DNS providers that have been plugged in. -var dnsProviders = make(map[string]DNSProviderConstructor) - -// RegisterDNSProvider registers provider by name for solving the ACME DNS challenge. -func RegisterDNSProvider(name string, provider DNSProviderConstructor) { - dnsProviders[name] = provider -} - -var ( - // DefaultEmail represents the Let's Encrypt account email to use if none provided. - DefaultEmail string - - // Agreed indicates whether user has agreed to the Let's Encrypt SA. - Agreed bool - - // DefaultCAUrl is the default URL to the CA's ACME directory endpoint. - // It's very important to set this unless you set it in every Config. - DefaultCAUrl string - - // DefaultKeyType is used as the type of key for new certificates - // when no other key type is specified. - DefaultKeyType = acme.RSA2048 -) diff --git a/vendor/github.com/mholt/caddy/caddytls/tls_test.go b/vendor/github.com/mholt/caddy/caddytls/tls_test.go deleted file mode 100644 index c46e249..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/tls_test.go +++ /dev/null @@ -1,165 +0,0 @@ -package caddytls - -import ( - "io/ioutil" - "os" - "testing" - - "github.com/xenolf/lego/acme" -) - -func TestHostQualifies(t *testing.T) { - for i, test := range []struct { - host string - expect bool - }{ - {"example.com", true}, - {"sub.example.com", true}, - {"Sub.Example.COM", true}, - {"127.0.0.1", false}, - {"127.0.1.5", false}, - {"69.123.43.94", false}, - {"::1", false}, - {"::", false}, - {"0.0.0.0", false}, - {"", false}, - {" ", false}, - {"*.example.com", false}, - {".com", false}, - {"example.com.", false}, - {"localhost", false}, - {"local", true}, - {"devsite", true}, - {"192.168.1.3", false}, - {"10.0.2.1", false}, - {"169.112.53.4", false}, - } { - actual := HostQualifies(test.host) - if actual != test.expect { - t.Errorf("Test %d: Expected HostQualifies(%s)=%v, but got %v", - i, test.host, test.expect, actual) - } - } -} - -type holder struct { - host, port string - cfg *Config -} - -func (h holder) TLSConfig() *Config { return h.cfg } -func (h holder) Host() string { return h.host } -func (h holder) Port() string { return h.port } - -func TestQualifiesForManagedTLS(t *testing.T) { - for i, test := range []struct { - cfg ConfigHolder - expect bool - }{ - {holder{host: ""}, false}, - {holder{host: "localhost"}, false}, - {holder{host: "123.44.3.21"}, false}, - {holder{host: "example.com"}, false}, - {holder{host: "", cfg: new(Config)}, false}, - {holder{host: "localhost", cfg: new(Config)}, false}, - {holder{host: "123.44.3.21", cfg: new(Config)}, false}, - {holder{host: "example.com", cfg: new(Config)}, true}, - {holder{host: "*.example.com", cfg: new(Config)}, false}, - {holder{host: "example.com", cfg: &Config{Manual: true}}, false}, - {holder{host: "example.com", cfg: &Config{ACMEEmail: "off"}}, false}, - {holder{host: "example.com", cfg: &Config{ACMEEmail: "foo@bar.com"}}, true}, - {holder{host: "example.com", port: "80"}, false}, - {holder{host: "example.com", port: "1234", cfg: new(Config)}, true}, - {holder{host: "example.com", port: "443", cfg: new(Config)}, true}, - {holder{host: "example.com", port: "80"}, false}, - } { - if got, want := QualifiesForManagedTLS(test.cfg), test.expect; got != want { - t.Errorf("Test %d: Expected %v but got %v", i, want, got) - } - } -} - -func TestSaveCertResource(t *testing.T) { - storage := Storage("./le_test_save") - defer func() { - err := os.RemoveAll(string(storage)) - if err != nil { - t.Fatalf("Could not remove temporary storage directory (%s): %v", storage, err) - } - }() - - domain := "example.com" - certContents := "certificate" - keyContents := "private key" - metaContents := `{ - "domain": "example.com", - "certUrl": "https://example.com/cert", - "certStableUrl": "https://example.com/cert/stable" -}` - - cert := acme.CertificateResource{ - Domain: domain, - CertURL: "https://example.com/cert", - CertStableURL: "https://example.com/cert/stable", - PrivateKey: []byte(keyContents), - Certificate: []byte(certContents), - } - - err := saveCertResource(storage, cert) - if err != nil { - t.Fatalf("Expected no error, got: %v", err) - } - - certFile, err := ioutil.ReadFile(storage.SiteCertFile(domain)) - if err != nil { - t.Errorf("Expected no error reading certificate file, got: %v", err) - } - if string(certFile) != certContents { - t.Errorf("Expected certificate file to contain '%s', got '%s'", certContents, string(certFile)) - } - - keyFile, err := ioutil.ReadFile(storage.SiteKeyFile(domain)) - if err != nil { - t.Errorf("Expected no error reading private key file, got: %v", err) - } - if string(keyFile) != keyContents { - t.Errorf("Expected private key file to contain '%s', got '%s'", keyContents, string(keyFile)) - } - - metaFile, err := ioutil.ReadFile(storage.SiteMetaFile(domain)) - if err != nil { - t.Errorf("Expected no error reading meta file, got: %v", err) - } - if string(metaFile) != metaContents { - t.Errorf("Expected meta file to contain '%s', got '%s'", metaContents, string(metaFile)) - } -} - -func TestExistingCertAndKey(t *testing.T) { - storage := Storage("./le_test_existing") - defer func() { - err := os.RemoveAll(string(storage)) - if err != nil { - t.Fatalf("Could not remove temporary storage directory (%s): %v", storage, err) - } - }() - - domain := "example.com" - - if existingCertAndKey(storage, domain) { - t.Errorf("Did NOT expect %v to have existing cert or key, but it did", domain) - } - - err := saveCertResource(storage, acme.CertificateResource{ - Domain: domain, - PrivateKey: []byte("key"), - Certificate: []byte("cert"), - }) - if err != nil { - t.Fatalf("Expected no error, got: %v", err) - } - - if !existingCertAndKey(storage, domain) { - t.Errorf("Expected %v to have existing cert and key, but it did NOT", domain) - } -} diff --git a/vendor/github.com/mholt/caddy/caddytls/user.go b/vendor/github.com/mholt/caddy/caddytls/user.go deleted file mode 100644 index d10680b..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/user.go +++ /dev/null @@ -1,200 +0,0 @@ -package caddytls - -import ( - "bufio" - "crypto" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "encoding/json" - "errors" - "fmt" - "io" - "io/ioutil" - "os" - "strings" - - "github.com/xenolf/lego/acme" -) - -// User represents a Let's Encrypt user account. -type User struct { - Email string - Registration *acme.RegistrationResource - key crypto.PrivateKey -} - -// GetEmail gets u's email. -func (u User) GetEmail() string { - return u.Email -} - -// GetRegistration gets u's registration resource. -func (u User) GetRegistration() *acme.RegistrationResource { - return u.Registration -} - -// GetPrivateKey gets u's private key. -func (u User) GetPrivateKey() crypto.PrivateKey { - return u.key -} - -// newUser creates a new User for the given email address -// with a new private key. This function does NOT save the -// user to disk or register it via ACME. If you want to use -// a user account that might already exist, call getUser -// instead. It does NOT prompt the user. -func newUser(email string) (User, error) { - user := User{Email: email} - privateKey, err := ecdsa.GenerateKey(elliptic.P384(), rand.Reader) - if err != nil { - return user, errors.New("error generating private key: " + err.Error()) - } - user.key = privateKey - return user, nil -} - -// getEmail does everything it can to obtain an email -// address from the user within the scope of storage -// to use for ACME TLS. If it cannot get an email -// address, it returns empty string. (It will warn the -// user of the consequences of an empty email.) This -// function MAY prompt the user for input. If userPresent -// is false, the operator will NOT be prompted and an -// empty email may be returned. -func getEmail(storage Storage, userPresent bool) string { - // First try memory (command line flag or typed by user previously) - leEmail := DefaultEmail - if leEmail == "" { - // Then try to get most recent user email - userDirs, err := ioutil.ReadDir(storage.Users()) - if err == nil { - var mostRecent os.FileInfo - for _, dir := range userDirs { - if !dir.IsDir() { - continue - } - if mostRecent == nil || dir.ModTime().After(mostRecent.ModTime()) { - leEmail = dir.Name() - DefaultEmail = leEmail // save for next time - mostRecent = dir - } - } - } - } - if leEmail == "" && userPresent { - // Alas, we must bother the user and ask for an email address; - // if they proceed they also agree to the SA. - reader := bufio.NewReader(stdin) - fmt.Println("\nYour sites will be served over HTTPS automatically using Let's Encrypt.") - fmt.Println("By continuing, you agree to the Let's Encrypt Subscriber Agreement at:") - fmt.Println(" " + saURL) // TODO: Show current SA link - fmt.Println("Please enter your email address so you can recover your account if needed.") - fmt.Println("You can leave it blank, but you'll lose the ability to recover your account.") - fmt.Print("Email address: ") - var err error - leEmail, err = reader.ReadString('\n') - if err != nil { - return "" - } - leEmail = strings.TrimSpace(leEmail) - DefaultEmail = leEmail - Agreed = true - } - return strings.ToLower(leEmail) -} - -// getUser loads the user with the given email from disk -// using the provided storage. If the user does not exist, -// it will create a new one, but it does NOT save new -// users to the disk or register them via ACME. It does -// NOT prompt the user. -func getUser(storage Storage, email string) (User, error) { - var user User - - // open user file - regFile, err := os.Open(storage.UserRegFile(email)) - if err != nil { - if os.IsNotExist(err) { - // create a new user - return newUser(email) - } - return user, err - } - defer regFile.Close() - - // load user information - err = json.NewDecoder(regFile).Decode(&user) - if err != nil { - return user, err - } - - // load their private key - user.key, err = loadPrivateKey(storage.UserKeyFile(email)) - if err != nil { - return user, err - } - - return user, nil -} - -// saveUser persists a user's key and account registration -// to the file system. It does NOT register the user via ACME -// or prompt the user. You must also pass in the storage -// wherein the user should be saved. It should be the storage -// for the CA with which user has an account. -func saveUser(storage Storage, user User) error { - // make user account folder - err := os.MkdirAll(storage.User(user.Email), 0700) - if err != nil { - return err - } - - // save private key file - err = savePrivateKey(user.key, storage.UserKeyFile(user.Email)) - if err != nil { - return err - } - - // save registration file - jsonBytes, err := json.MarshalIndent(&user, "", "\t") - if err != nil { - return err - } - - return ioutil.WriteFile(storage.UserRegFile(user.Email), jsonBytes, 0600) -} - -// promptUserAgreement prompts the user to agree to the agreement -// at agreementURL via stdin. If the agreement has changed, then pass -// true as the second argument. If this is the user's first time -// agreeing, pass false. It returns whether the user agreed or not. -func promptUserAgreement(agreementURL string, changed bool) bool { - if changed { - fmt.Printf("The Let's Encrypt Subscriber Agreement has changed:\n %s\n", agreementURL) - fmt.Print("Do you agree to the new terms? (y/n): ") - } else { - fmt.Printf("To continue, you must agree to the Let's Encrypt Subscriber Agreement:\n %s\n", agreementURL) - fmt.Print("Do you agree to the terms? (y/n): ") - } - - reader := bufio.NewReader(stdin) - answer, err := reader.ReadString('\n') - if err != nil { - return false - } - answer = strings.ToLower(strings.TrimSpace(answer)) - - return answer == "y" || answer == "yes" -} - -// stdin is used to read the user's input if prompted; -// this is changed by tests during tests. -var stdin = io.ReadWriter(os.Stdin) - -// The name of the folder for accounts where the email -// address was not provided; default 'username' if you will. -const emptyEmail = "default" - -// TODO: Use latest -const saURL = "https://letsencrypt.org/documents/LE-SA-v1.0.1-July-27-2015.pdf" diff --git a/vendor/github.com/mholt/caddy/caddytls/user_test.go b/vendor/github.com/mholt/caddy/caddytls/user_test.go deleted file mode 100644 index 67f7308..0000000 --- a/vendor/github.com/mholt/caddy/caddytls/user_test.go +++ /dev/null @@ -1,184 +0,0 @@ -package caddytls - -import ( - "bytes" - "crypto/rand" - "crypto/rsa" - "io" - "os" - "strings" - "testing" - "time" - - "github.com/xenolf/lego/acme" -) - -func TestUser(t *testing.T) { - privateKey, err := rsa.GenerateKey(rand.Reader, 128) - if err != nil { - t.Fatalf("Could not generate test private key: %v", err) - } - u := User{ - Email: "me@mine.com", - Registration: new(acme.RegistrationResource), - key: privateKey, - } - - if expected, actual := "me@mine.com", u.GetEmail(); actual != expected { - t.Errorf("Expected email '%s' but got '%s'", expected, actual) - } - if u.GetRegistration() == nil { - t.Error("Expected a registration resource, but got nil") - } - if expected, actual := privateKey, u.GetPrivateKey(); actual != expected { - t.Errorf("Expected the private key at address %p but got one at %p instead ", expected, actual) - } -} - -func TestNewUser(t *testing.T) { - email := "me@foobar.com" - user, err := newUser(email) - if err != nil { - t.Fatalf("Error creating user: %v", err) - } - if user.key == nil { - t.Error("Private key is nil") - } - if user.Email != email { - t.Errorf("Expected email to be %s, but was %s", email, user.Email) - } - if user.Registration != nil { - t.Error("New user already has a registration resource; it shouldn't") - } -} - -func TestSaveUser(t *testing.T) { - defer os.RemoveAll(string(testStorage)) - - email := "me@foobar.com" - user, err := newUser(email) - if err != nil { - t.Fatalf("Error creating user: %v", err) - } - - err = saveUser(testStorage, user) - if err != nil { - t.Fatalf("Error saving user: %v", err) - } - _, err = os.Stat(testStorage.UserRegFile(email)) - if err != nil { - t.Errorf("Cannot access user registration file, error: %v", err) - } - _, err = os.Stat(testStorage.UserKeyFile(email)) - if err != nil { - t.Errorf("Cannot access user private key file, error: %v", err) - } -} - -func TestGetUserDoesNotAlreadyExist(t *testing.T) { - defer os.RemoveAll(string(testStorage)) - - user, err := getUser(testStorage, "user_does_not_exist@foobar.com") - if err != nil { - t.Fatalf("Error getting user: %v", err) - } - - if user.key == nil { - t.Error("Expected user to have a private key, but it was nil") - } -} - -func TestGetUserAlreadyExists(t *testing.T) { - defer os.RemoveAll(string(testStorage)) - - email := "me@foobar.com" - - // Set up test - user, err := newUser(email) - if err != nil { - t.Fatalf("Error creating user: %v", err) - } - err = saveUser(testStorage, user) - if err != nil { - t.Fatalf("Error saving user: %v", err) - } - - // Expect to load user from disk - user2, err := getUser(testStorage, email) - if err != nil { - t.Fatalf("Error getting user: %v", err) - } - - // Assert keys are the same - if !PrivateKeysSame(user.key, user2.key) { - t.Error("Expected private key to be the same after loading, but it wasn't") - } - - // Assert emails are the same - if user.Email != user2.Email { - t.Errorf("Expected emails to be equal, but was '%s' before and '%s' after loading", user.Email, user2.Email) - } -} - -func TestGetEmail(t *testing.T) { - storageBasePath = string(testStorage) // to contain calls that create a new Storage... - - // let's not clutter up the output - origStdout := os.Stdout - os.Stdout = nil - defer func() { os.Stdout = origStdout }() - - defer os.RemoveAll(string(testStorage)) - DefaultEmail = "test2@foo.com" - - // Test1: Use default email from flag (or user previously typing it) - actual := getEmail(testStorage, true) - if actual != DefaultEmail { - t.Errorf("Did not get correct email from memory; expected '%s' but got '%s'", DefaultEmail, actual) - } - - // Test2: Get input from user - DefaultEmail = "" - stdin = new(bytes.Buffer) - _, err := io.Copy(stdin, strings.NewReader("test3@foo.com\n")) - if err != nil { - t.Fatalf("Could not simulate user input, error: %v", err) - } - actual = getEmail(testStorage, true) - if actual != "test3@foo.com" { - t.Errorf("Did not get correct email from user input prompt; expected '%s' but got '%s'", "test3@foo.com", actual) - } - - // Test3: Get most recent email from before - DefaultEmail = "" - for i, eml := range []string{ - "TEST4-3@foo.com", // test case insensitivity - "test4-2@foo.com", - "test4-1@foo.com", - } { - u, err := newUser(eml) - if err != nil { - t.Fatalf("Error creating user %d: %v", i, err) - } - err = saveUser(testStorage, u) - if err != nil { - t.Fatalf("Error saving user %d: %v", i, err) - } - - // Change modified time so they're all different, so the test becomes deterministic - f, err := os.Stat(testStorage.User(eml)) - if err != nil { - t.Fatalf("Could not access user folder for '%s': %v", eml, err) - } - chTime := f.ModTime().Add(-(time.Duration(i) * time.Second)) - if err := os.Chtimes(testStorage.User(eml), chTime, chTime); err != nil { - t.Fatalf("Could not change user folder mod time for '%s': %v", eml, err) - } - } - actual = getEmail(testStorage, true) - if actual != "test4-3@foo.com" { - t.Errorf("Did not get correct email from storage; expected '%s' but got '%s'", "test4-3@foo.com", actual) - } -} - -var testStorage = Storage("./testdata") diff --git a/vendor/github.com/mholt/caddy/commands.go b/vendor/github.com/mholt/caddy/commands.go deleted file mode 100644 index 3e64c90..0000000 --- a/vendor/github.com/mholt/caddy/commands.go +++ /dev/null @@ -1,119 +0,0 @@ -package caddy - -import ( - "errors" - "runtime" - "unicode" - - "github.com/flynn/go-shlex" -) - -var runtimeGoos = runtime.GOOS - -// SplitCommandAndArgs takes a command string and parses it shell-style into the -// command and its separate arguments. -func SplitCommandAndArgs(command string) (cmd string, args []string, err error) { - var parts []string - - if runtimeGoos == "windows" { - parts = parseWindowsCommand(command) // parse it Windows-style - } else { - parts, err = parseUnixCommand(command) // parse it Unix-style - if err != nil { - err = errors.New("error parsing command: " + err.Error()) - return - } - } - - if len(parts) == 0 { - err = errors.New("no command contained in '" + command + "'") - return - } - - cmd = parts[0] - if len(parts) > 1 { - args = parts[1:] - } - - return -} - -// parseUnixCommand parses a unix style command line and returns the -// command and its arguments or an error -func parseUnixCommand(cmd string) ([]string, error) { - return shlex.Split(cmd) -} - -// parseWindowsCommand parses windows command lines and -// returns the command and the arguments as an array. It -// should be able to parse commonly used command lines. -// Only basic syntax is supported: -// - spaces in double quotes are not token delimiters -// - double quotes are escaped by either backspace or another double quote -// - except for the above case backspaces are path separators (not special) -// -// Many sources point out that escaping quotes using backslash can be unsafe. -// Use two double quotes when possible. (Source: http://stackoverflow.com/a/31413730/2616179 ) -// -// This function has to be used on Windows instead -// of the shlex package because this function treats backslash -// characters properly. -func parseWindowsCommand(cmd string) []string { - const backslash = '\\' - const quote = '"' - - var parts []string - var part string - var inQuotes bool - var lastRune rune - - for i, ch := range cmd { - - if i != 0 { - lastRune = rune(cmd[i-1]) - } - - if ch == backslash { - // put it in the part - for now we don't know if it's an - // escaping char or path separator - part += string(ch) - continue - } - - if ch == quote { - if lastRune == backslash { - // remove the backslash from the part and add the escaped quote instead - part = part[:len(part)-1] - part += string(ch) - continue - } - - if lastRune == quote { - // revert the last change of the inQuotes state - // it was an escaping quote - inQuotes = !inQuotes - part += string(ch) - continue - } - - // normal escaping quotes - inQuotes = !inQuotes - continue - - } - - if unicode.IsSpace(ch) && !inQuotes && len(part) > 0 { - parts = append(parts, part) - part = "" - continue - } - - part += string(ch) - } - - if len(part) > 0 { - parts = append(parts, part) - } - - return parts -} diff --git a/vendor/github.com/mholt/caddy/commands_test.go b/vendor/github.com/mholt/caddy/commands_test.go deleted file mode 100644 index 5de37c7..0000000 --- a/vendor/github.com/mholt/caddy/commands_test.go +++ /dev/null @@ -1,291 +0,0 @@ -package caddy - -import ( - "fmt" - "runtime" - "strings" - "testing" -) - -func TestParseUnixCommand(t *testing.T) { - tests := []struct { - input string - expected []string - }{ - // 0 - emtpy command - { - input: ``, - expected: []string{}, - }, - // 1 - command without arguments - { - input: `command`, - expected: []string{`command`}, - }, - // 2 - command with single argument - { - input: `command arg1`, - expected: []string{`command`, `arg1`}, - }, - // 3 - command with multiple arguments - { - input: `command arg1 arg2`, - expected: []string{`command`, `arg1`, `arg2`}, - }, - // 4 - command with single argument with space character - in quotes - { - input: `command "arg1 arg1"`, - expected: []string{`command`, `arg1 arg1`}, - }, - // 5 - command with multiple spaces and tab character - { - input: "command arg1 arg2\targ3", - expected: []string{`command`, `arg1`, `arg2`, `arg3`}, - }, - // 6 - command with single argument with space character - escaped with backspace - { - input: `command arg1\ arg2`, - expected: []string{`command`, `arg1 arg2`}, - }, - // 7 - single quotes should escape special chars - { - input: `command 'arg1\ arg2'`, - expected: []string{`command`, `arg1\ arg2`}, - }, - } - - for i, test := range tests { - errorPrefix := fmt.Sprintf("Test [%d]: ", i) - errorSuffix := fmt.Sprintf(" Command to parse: [%s]", test.input) - actual, _ := parseUnixCommand(test.input) - if len(actual) != len(test.expected) { - t.Errorf(errorPrefix+"Expected %d parts, got %d: %#v."+errorSuffix, len(test.expected), len(actual), actual) - continue - } - for j := 0; j < len(actual); j++ { - if expectedPart, actualPart := test.expected[j], actual[j]; expectedPart != actualPart { - t.Errorf(errorPrefix+"Expected: %v Actual: %v (index %d)."+errorSuffix, expectedPart, actualPart, j) - } - } - } -} - -func TestParseWindowsCommand(t *testing.T) { - tests := []struct { - input string - expected []string - }{ - { // 0 - empty command - do not fail - input: ``, - expected: []string{}, - }, - { // 1 - cmd without args - input: `cmd`, - expected: []string{`cmd`}, - }, - { // 2 - multiple args - input: `cmd arg1 arg2`, - expected: []string{`cmd`, `arg1`, `arg2`}, - }, - { // 3 - multiple args with space - input: `cmd "combined arg" arg2`, - expected: []string{`cmd`, `combined arg`, `arg2`}, - }, - { // 4 - path without spaces - input: `mkdir C:\Windows\foo\bar`, - expected: []string{`mkdir`, `C:\Windows\foo\bar`}, - }, - { // 5 - command with space in quotes - input: `"command here"`, - expected: []string{`command here`}, - }, - { // 6 - argument with escaped quotes (two quotes) - input: `cmd ""arg""`, - expected: []string{`cmd`, `"arg"`}, - }, - { // 7 - argument with escaped quotes (backslash) - input: `cmd \"arg\"`, - expected: []string{`cmd`, `"arg"`}, - }, - { // 8 - two quotes (escaped) inside an inQuote element - input: `cmd "a ""quoted value"`, - expected: []string{`cmd`, `a "quoted value`}, - }, - // TODO - see how many quotes are dislayed if we use "", """, """"""" - { // 9 - two quotes outside an inQuote element - input: `cmd a ""quoted value`, - expected: []string{`cmd`, `a`, `"quoted`, `value`}, - }, - { // 10 - path with space in quotes - input: `mkdir "C:\directory name\foobar"`, - expected: []string{`mkdir`, `C:\directory name\foobar`}, - }, - { // 11 - space without quotes - input: `mkdir C:\ space`, - expected: []string{`mkdir`, `C:\`, `space`}, - }, - { // 12 - space in quotes - input: `mkdir "C:\ space"`, - expected: []string{`mkdir`, `C:\ space`}, - }, - { // 13 - UNC - input: `mkdir \\?\C:\Users`, - expected: []string{`mkdir`, `\\?\C:\Users`}, - }, - { // 14 - UNC with space - input: `mkdir "\\?\C:\Program Files"`, - expected: []string{`mkdir`, `\\?\C:\Program Files`}, - }, - - { // 15 - unclosed quotes - treat as if the path ends with quote - input: `mkdir "c:\Program files`, - expected: []string{`mkdir`, `c:\Program files`}, - }, - { // 16 - quotes used inside the argument - input: `mkdir "c:\P"rogra"m f"iles`, - expected: []string{`mkdir`, `c:\Program files`}, - }, - } - - for i, test := range tests { - errorPrefix := fmt.Sprintf("Test [%d]: ", i) - errorSuffix := fmt.Sprintf(" Command to parse: [%s]", test.input) - - actual := parseWindowsCommand(test.input) - if len(actual) != len(test.expected) { - t.Errorf(errorPrefix+"Expected %d parts, got %d: %#v."+errorSuffix, len(test.expected), len(actual), actual) - continue - } - for j := 0; j < len(actual); j++ { - if expectedPart, actualPart := test.expected[j], actual[j]; expectedPart != actualPart { - t.Errorf(errorPrefix+"Expected: %v Actual: %v (index %d)."+errorSuffix, expectedPart, actualPart, j) - } - } - } -} - -func TestSplitCommandAndArgs(t *testing.T) { - - // force linux parsing. It's more robust and covers error cases - runtimeGoos = "linux" - defer func() { - runtimeGoos = runtime.GOOS - }() - - var parseErrorContent = "error parsing command:" - var noCommandErrContent = "no command contained in" - - tests := []struct { - input string - expectedCommand string - expectedArgs []string - expectedErrContent string - }{ - // 0 - emtpy command - { - input: ``, - expectedCommand: ``, - expectedArgs: nil, - expectedErrContent: noCommandErrContent, - }, - // 1 - command without arguments - { - input: `command`, - expectedCommand: `command`, - expectedArgs: nil, - expectedErrContent: ``, - }, - // 2 - command with single argument - { - input: `command arg1`, - expectedCommand: `command`, - expectedArgs: []string{`arg1`}, - expectedErrContent: ``, - }, - // 3 - command with multiple arguments - { - input: `command arg1 arg2`, - expectedCommand: `command`, - expectedArgs: []string{`arg1`, `arg2`}, - expectedErrContent: ``, - }, - // 4 - command with unclosed quotes - { - input: `command "arg1 arg2`, - expectedCommand: "", - expectedArgs: nil, - expectedErrContent: parseErrorContent, - }, - // 5 - command with unclosed quotes - { - input: `command 'arg1 arg2"`, - expectedCommand: "", - expectedArgs: nil, - expectedErrContent: parseErrorContent, - }, - } - - for i, test := range tests { - errorPrefix := fmt.Sprintf("Test [%d]: ", i) - errorSuffix := fmt.Sprintf(" Command to parse: [%s]", test.input) - actualCommand, actualArgs, actualErr := SplitCommandAndArgs(test.input) - - // test if error matches expectation - if test.expectedErrContent != "" { - if actualErr == nil { - t.Errorf(errorPrefix+"Expected error with content [%s], found no error."+errorSuffix, test.expectedErrContent) - } else if !strings.Contains(actualErr.Error(), test.expectedErrContent) { - t.Errorf(errorPrefix+"Expected error with content [%s], found [%v]."+errorSuffix, test.expectedErrContent, actualErr) - } - } else if actualErr != nil { - t.Errorf(errorPrefix+"Expected no error, found [%v]."+errorSuffix, actualErr) - } - - // test if command matches - if test.expectedCommand != actualCommand { - t.Errorf(errorPrefix+"Expected command: [%s], actual: [%s]."+errorSuffix, test.expectedCommand, actualCommand) - } - - // test if arguments match - if len(test.expectedArgs) != len(actualArgs) { - t.Errorf(errorPrefix+"Wrong number of arguments! Expected [%v], actual [%v]."+errorSuffix, test.expectedArgs, actualArgs) - } else { - // test args only if the count matches. - for j, actualArg := range actualArgs { - expectedArg := test.expectedArgs[j] - if actualArg != expectedArg { - t.Errorf(errorPrefix+"Argument at position [%d] differ! Expected [%s], actual [%s]"+errorSuffix, j, expectedArg, actualArg) - } - } - } - } -} - -func ExampleSplitCommandAndArgs() { - var commandLine string - var command string - var args []string - - // just for the test - change GOOS and reset it at the end of the test - runtimeGoos = "windows" - defer func() { - runtimeGoos = runtime.GOOS - }() - - commandLine = `mkdir /P "C:\Program Files"` - command, args, _ = SplitCommandAndArgs(commandLine) - - fmt.Printf("Windows: %s: %s [%s]\n", commandLine, command, strings.Join(args, ",")) - - // set GOOS to linux - runtimeGoos = "linux" - - commandLine = `mkdir -p /path/with\ space` - command, args, _ = SplitCommandAndArgs(commandLine) - - fmt.Printf("Linux: %s: %s [%s]\n", commandLine, command, strings.Join(args, ",")) - - // Output: - // Windows: mkdir /P "C:\Program Files": mkdir [/P,C:\Program Files] - // Linux: mkdir -p /path/with\ space: mkdir [-p,/path/with space] -} diff --git a/vendor/github.com/mholt/caddy/controller.go b/vendor/github.com/mholt/caddy/controller.go deleted file mode 100644 index 4be7948..0000000 --- a/vendor/github.com/mholt/caddy/controller.go +++ /dev/null @@ -1,86 +0,0 @@ -package caddy - -import ( - "strings" - - "github.com/mholt/caddy/caddyfile" -) - -// Controller is given to the setup function of directives which -// gives them access to be able to read tokens and do whatever -// they need to do. -type Controller struct { - caddyfile.Dispenser - - // The instance in which the setup is occurring - instance *Instance - - // Key is the key from the top of the server block, usually - // an address, hostname, or identifier of some sort. - Key string - - // OncePerServerBlock is a function that executes f - // exactly once per server block, no matter how many - // hosts are associated with it. If it is the first - // time, the function f is executed immediately - // (not deferred) and may return an error which is - // returned by OncePerServerBlock. - OncePerServerBlock func(f func() error) error - - // ServerBlockIndex is the 0-based index of the - // server block as it appeared in the input. - ServerBlockIndex int - - // ServerBlockKeyIndex is the 0-based index of this - // key as it appeared in the input at the head of the - // server block. - ServerBlockKeyIndex int - - // ServerBlockKeys is a list of keys that are - // associated with this server block. All these - // keys, consequently, share the same tokens. - ServerBlockKeys []string - - // ServerBlockStorage is used by a directive's - // setup function to persist state between all - // the keys on a server block. - ServerBlockStorage interface{} -} - -// ServerType gets the name of the server type that is being set up. -func (c *Controller) ServerType() string { - return c.instance.serverType -} - -// OnStartup adds fn to the list of callback functions to execute -// when the server is about to be started. -func (c *Controller) OnStartup(fn func() error) { - c.instance.onStartup = append(c.instance.onStartup, fn) -} - -// OnRestart adds fn to the list of callback functions to execute -// when the server is about to be restarted. -func (c *Controller) OnRestart(fn func() error) { - c.instance.onRestart = append(c.instance.onRestart, fn) -} - -// OnShutdown adds fn to the list of callback functions to execute -// when the server is about to be shut down.. -func (c *Controller) OnShutdown(fn func() error) { - c.instance.onShutdown = append(c.instance.onShutdown, fn) -} - -// NewTestController creates a new *Controller for -// the input specified, with a filename of "Testfile". -// The Config is bare, consisting only of a Root of cwd. -// -// Used primarily for testing but needs to be exported so -// add-ons can use this as a convenience. Does not initialize -// the server-block-related fields. -func NewTestController(input string) *Controller { - return &Controller{ - instance: &Instance{serverType: ""}, - Dispenser: caddyfile.NewDispenser("Testfile", strings.NewReader(input)), - OncePerServerBlock: func(f func() error) error { return f() }, - } -} diff --git a/vendor/github.com/mholt/caddy/dist/CHANGES.txt b/vendor/github.com/mholt/caddy/dist/CHANGES.txt deleted file mode 100644 index 5c33712..0000000 --- a/vendor/github.com/mholt/caddy/dist/CHANGES.txt +++ /dev/null @@ -1,229 +0,0 @@ -CHANGES - -0.9 beta 1 (June 7, 2016) -- New core -- New experimental QUIC support with -quic flag (HTTPS only) -- New -type flag to specify other server types -- Moved ~/.caddy/letsencrypt to ~/.caddy/acme and reorganized assets -- Moved caddy package to top level folder, and pushed main to subfolder -- Site addresses can have paths -- Site addresses can make some use of wildcards in domains -- Renamed -directives flag to -plugins -- Restarting no longer requires spawning a new process -- Removed -restart option -- log: New {request} placeholder to dump entire request (sans body) -- markdown: Overhauled; removed site generation features -- proxy: More control of headers -- proxy: Specify multiple upstreams with optional port ranges -- tls: Generate self-signed certificates in memory -- tls: Support for ACME DNS challenge across 10 providers -- tls: Support for TLS-SNI challenge during restarts -- Various bug fixes and enhancements - - -0.8.3 (April 26, 2016) -- Built with Go 1.6.2 -- New pprof middleware for exposing process profiling endpoints -- New expvar middleware for exposing memory/GC performance -- New -restart option to force in-process restarts on Unix systems -- Only fail to start if managed certificate is expired (issue #642) -- Toggle case-sensitive path matching with environment variable -- File server now adds ETag header for static files -- browse: Replace .LinkedPath action with .BreadcrumbMap -- fastcgi: New except clause to exclude paths -- proxy: New max_conns setting to limit max connections per upstream -- proxy: New replaceable value for name of upstream host -- templates: New utility actions for dealing with strings -- tls: Customize certificate key with key_type (+ECC) -- tls: Session ticket keys are now rotated -- Many other minor internal improvements and bug fixes - - -0.8.2 (February 25, 2016) -- On-demand TLS can obtain certificates during handshakes -- Built with Go 1.6 -- Process log (-log) is rotated when it gets large -- Managed certificates get renewed 30 days early instead of just 14 -- fastcgi: Allow scheme prefix before address -- markdown: Support for definition lists -- proxy: Allow proxy to insecure HTTPS backends -- proxy: Support proxy to unix socket -- rewrite: Status code can be 2xx or 4xx -- templates: New .Markdown action to interpret included file as Markdown -- templates: .Truncate now truncates from end of string when length is negative -- tls: Set hard limit for certificates obtained with on-demand TLS -- tls: Load certificates from directory -- tls: Add SHA384 cipher suites -- Multiple bug fixes and internal changes - - -0.8.1 (January 12, 2016) -- Improved OCSP stapling -- Better graceful reload when new hosts need certificates from Let's Encrypt -- Current pidfile is now deleted when Caddy exits -- browse: New default template -- gzip: Added min_length setting -- import: Support for glob patterns (*) to import multiple files -- rewrite: New complex rules with conditions, regex captures, and status code -- tls: Removed DES ciphers from default cipher suite list -- tls: All supported certificates are OCSP-stapled -- tls: Allow custom configuration without specifying certificate and key -- tls: No longer allow HTTPS over port 80 -- Dozens of bug fixes, improvements, and more tests across the board - - -0.8 (December 4, 2015) -- HTTPS by default via Let's Encrypt (certs & keys are fully managed) -- Graceful restarts (on POSIX-compliant systems) -- Major internal refactoring to allow use of Caddy as library -- New directive 'mime' to customize Content-Type based on file extension -- New -accept flag to accept Let's Encrypt SA without prompt -- New -email flag to customize default email used for ACME transactions -- New -ca flag to customize ACME CA server URL -- New -revoke flag to revoke a certificate -- New -log flag to enable process log -- New -pidfile flag to enable writing pidfile -- New -grace flag to customize the graceful shutdown timeout -- New support for SIGHUP, SIGTERM, and SIGQUIT signals -- browse: Render filenames with multiple whitespace properly -- core: Use environment variables in Caddyfile -- markdown: Include Last-Modified header in response -- markdown: Render tables, strikethrough, and fenced code blocks -- proxy: Ability to exclude/ignore paths from proxying -- startup, shutdown: Better Windows support -- templates: Bug fix for .Host when port is absent -- templates: Include Last-Modified header in response -- templates: Support for custom delimiters -- tls: For non-local hosts, default port is now 443 unless specified -- tls: Force-disable HTTPS -- tls: Specify Let's Encrypt email address -- Many, many more tests and numerous bug fixes and improvements - - -0.7.6 (September 28, 2015) -- Pass in simple Caddyfile as command line arguments -- basicauth: Support for legacy htpasswd files -- browse: JSON response with file listing -- core: Caddyfile as command line argument -- errors: Can write full stack trace to HTTP response for debugging -- errors, log: Roll log files after certain size or age -- proxy: Fix for 32-bit architectures -- rewrite: Better compatibility with fastcgi and PHP apps -- templates: Added .StripExt and .StripHTML methods -- Internal improvements and minor bug fixes - - -0.7.5 (August 5, 2015) -- core: All listeners bind to 0.0.0.0 unless 'bind' directive is used -- fastcgi: Set HTTPS env variable if connection is secure -- log: Output to system log (except Windows) -- markdown: Added dev command to disable caching during development -- markdown: Fixed error reporting during initial site generation -- markdown: Fixed crash if path does not exist when server starts -- markdown: Fixed site generation and link indexing when files change -- templates: Added .NowDate for use in date-related functions -- Several bug fixes related to startup and shutdown functions - - -0.7.4 (July 30, 2015) -- browse: Sorting preference persisted in cookie -- browse: Added index.txt and default.txt to list of default files -- browse: Template files may now use Caddy template actions -- markdown: Template files may now use Caddy template actions -- markdown: Several bug fixes, especially for large and empty Markdown files -- markdown: Generate index pages to link to markdown pages (sitegen only) -- markdown: Flatten structure of front matter, changed template variables -- redir: Can use variables (placeholders) like log formats can -- redir: Catch-all redirects no longer preserve path; use {uri} instead -- redir: Syntax supports redirect tables by opening a block -- templates: Renamed .Date to .Now and added .Truncate, .Replace actions -- Other minor internal improvements and more tests - - -0.7.3 (July 15, 2015) -- errors: Error log now shows timestamp with each entry -- gzip: Fixed; Default filtering is by extension; removed MIME type filter -- import: Fixed; works inside and outside server blocks -- redir: Query string preserved on catch-all redirects -- templates: Proper 403 or 404 errors for restricted or missing files - - -0.7.2 (July 1, 2015) -- Custom builds through caddyserver.com - extend Caddy by writing addons -- browse: Sort by clicking column heading or using query string -- core: Serving hostname that doesn't resolve issues warning then listens on 0.0.0.0 -- errors: Missing error page during parse time is warning, not error -- ext: Extension only appended if request path does not end in / -- fastcgi: Fix for backend responding without status text -- fastcgi: Fix PATH_TRANSLATED when PATH_INFO is empty (RFC 3875) -- git: Removed from core (available as add-on) -- gzip: Enable by file path and/or extension -- gzip: Customize compression level -- log: Fix for missing status in log entry when error unhandled -- proxy: Strip prefix from path for proxy to path -- redir: Meta tag redirects -- templates: Support for nested includes -- Internal improvements and more tests - - -0.7.1 (June 2, 2015) -- basicauth: Patched timing vulnerability -- proxy: Support for WebSocket backends -- tls: Client authentication - - -0.7 (May 25, 2015) -- New directive 'internal' to protect resources with X-Accel-Redirect -- New -version flag to show program name and version -- core: Fixed escaped backslash characters inside quoted strings -- core: Fixed parsing Caddyfile for IPv6 addresses missing ports -- core: A notice is shown when non-local address resolves to loopback interface -- core: Warns if file descriptor limit is too low for production site (Mac/Linux) -- fastcgi: Support for Unix sockets -- git: Fixed issue that prevented pulling at designated interval -- header: Remove a header field by prefixing field name with "-" -- markdown: Simple static site generation -- markdown: Support for metadata ("front matter") at beginning of files -- rewrite: Experimental support for regular expressions -- tls: Customize cipher suites and protocols -- tls: Removed RC4 ciphers -- Other internal improvements that are not user-facing (more tests, etc.) - - -0.6 (May 7, 2015) -- New directive 'git' to automatically pull changes -- New directive 'bind' to override host server binds to -- New -root flag to specify root path to default site -- Ability to receive config data piped through stdin -- core: Warning if root directory doesn't exist at startup -- core: Entire process dies if any server fails to start -- gzip: Fixed Content-Length value when proxying requests -- errors: Error log now includes file and line number of panics -- fastcgi: Pass custom environment variables -- fastcgi: Support for HEAD, OPTIONS, PUT, PATCH, and DELETE methods -- fastcgi: Fixed SERVER_SOFTWARE variables -- markdown: Support for index files when URL points to a directory -- proxy: Load balancing with multiple backends, health checks, failovers, and multiple policies -- proxy: Add custom headers -- startup/shutdown: Run command in background with '&' at end -- templates: Added .tpl and .tmpl as default extensions -- templates: Support for index files when URL points to a directory -- templates: Changed .RemoteAddr to .IP and stripped out remote port -- tls: TLS disabled (with warning) for servers that are explicitly http:// -- websocket: Fixed SERVER_SOFTWARE and GATEWAY_INTERFACE variables -- Many internal improvements - - -0.5.1 (April 30, 2015) -- Default host is now 0.0.0.0 (wildcard) -- New -host and -port flags to override default host and port -- core: Support for binding to 0.0.0.0 -- core: Graceful error handling during heavy load; proper error responses -- errors: Fixed file path handling -- errors: Fixed panic due to nil log file -- fastcgi: Support for index files -- fastcgi: Fix for handling errors that come from responder - - -0.5 (April 28, 2015) -- Initial release diff --git a/vendor/github.com/mholt/caddy/dist/LICENSES.txt b/vendor/github.com/mholt/caddy/dist/LICENSES.txt deleted file mode 100644 index c6ca2e2..0000000 --- a/vendor/github.com/mholt/caddy/dist/LICENSES.txt +++ /dev/null @@ -1,539 +0,0 @@ -The enclosed software makes use of third-party libraries either in full -or in part, original or modified. This file is part of your download so -as to be in full compliance with the licenses of all bundled property. - - - -### -### github.com/mholt/caddy -### - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - - - - - - - - - -### -### Go standard library and http2 -### - - -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - - - - - - -### -### github.com/russross/blackfriday -### - - -Blackfriday is distributed under the Simplified BSD License: - -> Copyright © 2011 Russ Ross -> All rights reserved. -> -> Redistribution and use in source and binary forms, with or without -> modification, are permitted provided that the following conditions -> are met: -> -> 1. Redistributions of source code must retain the above copyright -> notice, this list of conditions and the following disclaimer. -> -> 2. Redistributions in binary form must reproduce the above -> copyright notice, this list of conditions and the following -> disclaimer in the documentation and/or other materials provided with -> the distribution. -> -> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -> "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -> LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -> FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -> COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -> INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -> BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -> LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -> LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -> ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -> POSSIBILITY OF SUCH DAMAGE. - - - - - - - - -### -### github.com/dustin/go-humanize -### - - -Copyright (c) 2005-2008 Dustin Sallings - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - - - - - - - - - - -### -### github.com/flynn/go-shlex -### - -Apache 2.0 license as found in this file - - - - - - -### -### github.com/go-yaml/yaml -### - - -Copyright (c) 2011-2014 - Canonical Inc. - -This software is licensed under the LGPLv3, included below. - -As a special exception to the GNU Lesser General Public License version 3 -("LGPL3"), the copyright holders of this Library give you permission to -convey to a third party a Combined Work that links statically or dynamically -to this Library without providing any Minimal Corresponding Source or -Minimal Application Code as set out in 4d or providing the installation -information set out in section 4e, provided that you comply with the other -provisions of LGPL3 and provided that you meet, for the Application the -terms and conditions of the license(s) which apply to the Application. - -Except as stated in this special exception, the provisions of LGPL3 will -continue to comply in full to this Library. If you modify this Library, you -may apply this exception to your version of this Library, but you are not -obliged to do so. If you do not wish to do so, delete this exception -statement from your version. This exception does not (and cannot) modify any -license terms which apply to the Application, with which you must still -comply. - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - - This version of the GNU Lesser General Public License incorporates -the terms and conditions of version 3 of the GNU General Public -License, supplemented by the additional permissions listed below. - - 0. Additional Definitions. - - As used herein, "this License" refers to version 3 of the GNU Lesser -General Public License, and the "GNU GPL" refers to version 3 of the GNU -General Public License. - - "The Library" refers to a covered work governed by this License, -other than an Application or a Combined Work as defined below. - - An "Application" is any work that makes use of an interface provided -by the Library, but which is not otherwise based on the Library. -Defining a subclass of a class defined by the Library is deemed a mode -of using an interface provided by the Library. - - A "Combined Work" is a work produced by combining or linking an -Application with the Library. The particular version of the Library -with which the Combined Work was made is also called the "Linked -Version". - - The "Minimal Corresponding Source" for a Combined Work means the -Corresponding Source for the Combined Work, excluding any source code -for portions of the Combined Work that, considered in isolation, are -based on the Application, and not on the Linked Version. - - The "Corresponding Application Code" for a Combined Work means the -object code and/or source code for the Application, including any data -and utility programs needed for reproducing the Combined Work from the -Application, but excluding the System Libraries of the Combined Work. - - 1. Exception to Section 3 of the GNU GPL. - - You may convey a covered work under sections 3 and 4 of this License -without being bound by section 3 of the GNU GPL. - - 2. Conveying Modified Versions. - - If you modify a copy of the Library, and, in your modifications, a -facility refers to a function or data to be supplied by an Application -that uses the facility (other than as an argument passed when the -facility is invoked), then you may convey a copy of the modified -version: - - a) under this License, provided that you make a good faith effort to - ensure that, in the event an Application does not supply the - function or data, the facility still operates, and performs - whatever part of its purpose remains meaningful, or - - b) under the GNU GPL, with none of the additional permissions of - this License applicable to that copy. - - 3. Object Code Incorporating Material from Library Header Files. - - The object code form of an Application may incorporate material from -a header file that is part of the Library. You may convey such object -code under terms of your choice, provided that, if the incorporated -material is not limited to numerical parameters, data structure -layouts and accessors, or small macros, inline functions and templates -(ten or fewer lines in length), you do both of the following: - - a) Give prominent notice with each copy of the object code that the - Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the object code with a copy of the GNU GPL and this license - document. - - 4. Combined Works. - - You may convey a Combined Work under terms of your choice that, -taken together, effectively do not restrict modification of the -portions of the Library contained in the Combined Work and reverse -engineering for debugging such modifications, if you also do each of -the following: - - a) Give prominent notice with each copy of the Combined Work that - the Library is used in it and that the Library and its use are - covered by this License. - - b) Accompany the Combined Work with a copy of the GNU GPL and this license - document. - - c) For a Combined Work that displays copyright notices during - execution, include the copyright notice for the Library among - these notices, as well as a reference directing the user to the - copies of the GNU GPL and this license document. - - d) Do one of the following: - - 0) Convey the Minimal Corresponding Source under the terms of this - License, and the Corresponding Application Code in a form - suitable for, and under terms that permit, the user to - recombine or relink the Application with a modified version of - the Linked Version to produce a modified Combined Work, in the - manner specified by section 6 of the GNU GPL for conveying - Corresponding Source. - - 1) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (a) uses at run time - a copy of the Library already present on the user's computer - system, and (b) will operate properly with a modified version - of the Library that is interface-compatible with the Linked - Version. - - e) Provide Installation Information, but only if you would otherwise - be required to provide such information under section 6 of the - GNU GPL, and only to the extent that such information is - necessary to install and execute a modified version of the - Combined Work produced by recombining or relinking the - Application with a modified version of the Linked Version. (If - you use option 4d0, the Installation Information must accompany - the Minimal Corresponding Source and Corresponding Application - Code. If you use option 4d1, you must provide the Installation - Information in the manner specified by section 6 of the GNU GPL - for conveying Corresponding Source.) - - 5. Combined Libraries. - - You may place library facilities that are a work based on the -Library side by side in a single library together with other library -facilities that are not Applications and are not covered by this -License, and convey such a combined library under terms of your -choice, if you do both of the following: - - a) Accompany the combined library with a copy of the same work based - on the Library, uncombined with any other library facilities, - conveyed under the terms of this License. - - b) Give prominent notice with the combined library that part of it - is a work based on the Library, and explaining where to find the - accompanying uncombined form of the same work. - - 6. Revised Versions of the GNU Lesser General Public License. - - The Free Software Foundation may publish revised and/or new versions -of the GNU Lesser General Public License from time to time. Such new -versions will be similar in spirit to the present version, but may -differ in detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the -Library as you received it specifies that a certain numbered version -of the GNU Lesser General Public License "or any later version" -applies to it, you have the option of following the terms and -conditions either of that published version or of any later version -published by the Free Software Foundation. If the Library as you -received it does not specify a version number of the GNU Lesser -General Public License, you may choose any version of the GNU Lesser -General Public License ever published by the Free Software Foundation. - - If the Library as you received it specifies that a proxy can decide -whether future versions of the GNU Lesser General Public License shall -apply, that proxy's public statement of acceptance of any version is -permanent authorization for you to choose that version for the -Library. diff --git a/vendor/github.com/mholt/caddy/dist/README.txt b/vendor/github.com/mholt/caddy/dist/README.txt deleted file mode 100644 index 03e8b8d..0000000 --- a/vendor/github.com/mholt/caddy/dist/README.txt +++ /dev/null @@ -1,39 +0,0 @@ -CADDY 0.9 beta 1 - -Website - https://caddyserver.com - -Community Forum - https://forum.caddyserver.com - -Twitter - @caddyserver - -Source Code - https://github.com/mholt/caddy - https://github.com/caddyserver - - -For instructions on using Caddy, please see the user guide on -the website. For a list of what's new in this version, see -CHANGES.txt. - -The Caddy project accepts pull requests! That means you can make -changes to the code and submit it for review, and if it's good, -we'll use it! You can help thousands of Caddy users and level -up your Go programming game by contributing to Caddy's source. - -To report bugs or request features, open an issue on GitHub. - -Want to support the project financially? Consider donating, -especially if your company is using Caddy. Believe me, your -contributions do not go unnoticed! We also have sponsorship -opportunities available. - -For a good time, follow @mholt6 on Twitter. - -And thanks - you're awesome! - - ---- -(c) 2015 - 2016 Matthew Holt diff --git a/vendor/github.com/mholt/caddy/dist/automate.go b/vendor/github.com/mholt/caddy/dist/automate.go deleted file mode 100644 index af3dce1..0000000 --- a/vendor/github.com/mholt/caddy/dist/automate.go +++ /dev/null @@ -1,161 +0,0 @@ -package main - -import ( - "fmt" - "log" - "os" - "os/exec" - "path/filepath" - "runtime" - "sync" - - "github.com/mholt/archiver" -) - -var buildScript, repoDir, mainDir, distDir, buildDir, releaseDir string - -func init() { - repoDir = filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "mholt", "caddy") - mainDir = filepath.Join(repoDir, "caddy") - buildScript = filepath.Join(mainDir, "build.bash") - distDir = filepath.Join(repoDir, "dist") - buildDir = filepath.Join(distDir, "builds") - releaseDir = filepath.Join(distDir, "release") -} - -func main() { - // First, clean up - err := os.RemoveAll(buildDir) - if err != nil { - log.Fatal(err) - } - err = os.RemoveAll(releaseDir) - if err != nil { - log.Fatal(err) - } - - // Then set up - err = os.MkdirAll(buildDir, 0755) - if err != nil { - log.Fatal(err) - } - err = os.MkdirAll(releaseDir, 0755) - if err != nil { - log.Fatal(err) - } - - // Perform builds and make archives in parallel; only as many - // goroutines as we have processors. - var wg sync.WaitGroup - var throttle = make(chan struct{}, numProcs()) - for _, p := range platforms { - wg.Add(1) - throttle <- struct{}{} - - if p.os == "" || p.arch == "" || p.archive == "" { - log.Fatalf("Platform OS, architecture, and archive format is required: %+v", p) - } - - go func(p platform) { - defer wg.Done() - defer func() { <-throttle }() - - fmt.Printf("== Building %s\n", p) - - var baseFilename, binFilename string - baseFilename = fmt.Sprintf("caddy_%s_%s", p.os, p.arch) - if p.arch == "arm" { - baseFilename += p.arm - } - binFilename = baseFilename + p.binExt - - binPath := filepath.Join(buildDir, binFilename) - archive := filepath.Join(releaseDir, fmt.Sprintf("%s.%s", baseFilename, p.archive)) - archiveContents := append(distContents, binPath) - - err := build(p, binPath) - if err != nil { - log.Fatal(err) - } - - fmt.Printf("== Compressing %s\n", baseFilename) - - if p.archive == "zip" { - err := archiver.Zip(archive, archiveContents) - if err != nil { - log.Fatal(err) - } - } else if p.archive == "tar.gz" { - err := archiver.TarGz(archive, archiveContents) - if err != nil { - log.Fatal(err) - } - } - }(p) - } - - wg.Wait() -} - -func build(p platform, out string) error { - cmd := exec.Command(buildScript, out) - cmd.Dir = mainDir - cmd.Env = os.Environ() - cmd.Env = append(cmd.Env, "CGO_ENABLED=0") - cmd.Env = append(cmd.Env, "GOOS="+p.os) - cmd.Env = append(cmd.Env, "GOARCH="+p.arch) - cmd.Env = append(cmd.Env, "GOARM="+p.arm) - cmd.Stderr = os.Stderr - return cmd.Run() -} - -type platform struct { - os, arch, arm, binExt, archive string -} - -func (p platform) String() string { - outStr := fmt.Sprintf("%s/%s", p.os, p.arch) - if p.arch == "arm" { - outStr += fmt.Sprintf(" (ARM v%s)", p.arm) - } - return outStr -} - -func numProcs() int { - n := runtime.GOMAXPROCS(0) - if n == runtime.NumCPU() && n > 1 { - n-- - } - return n -} - -// See: https://golang.org/doc/install/source#environment -// Not all supported platforms are listed since some are -// problematic and we only build the most common ones. -// These are just the pre-made, readily-available static -// builds, and we can try to add more upon request if there -// is enough demand. -var platforms = []platform{ - {os: "darwin", arch: "amd64", archive: "zip"}, - {os: "freebsd", arch: "386", archive: "tar.gz"}, - {os: "freebsd", arch: "amd64", archive: "tar.gz"}, - {os: "freebsd", arch: "arm", arm: "7", archive: "tar.gz"}, - {os: "linux", arch: "386", archive: "tar.gz"}, - {os: "linux", arch: "amd64", archive: "tar.gz"}, - {os: "linux", arch: "arm", arm: "7", archive: "tar.gz"}, - {os: "linux", arch: "arm64", archive: "tar.gz"}, - {os: "netbsd", arch: "386", archive: "tar.gz"}, - {os: "netbsd", arch: "amd64", archive: "tar.gz"}, - {os: "openbsd", arch: "386", archive: "tar.gz"}, - {os: "openbsd", arch: "amd64", archive: "tar.gz"}, - {os: "solaris", arch: "amd64", archive: "tar.gz"}, - {os: "windows", arch: "386", binExt: ".exe", archive: "zip"}, - {os: "windows", arch: "amd64", binExt: ".exe", archive: "zip"}, -} - -var distContents = []string{ - filepath.Join(distDir, "init"), - filepath.Join(distDir, "CHANGES.txt"), - filepath.Join(distDir, "LICENSES.txt"), - filepath.Join(distDir, "README.txt"), -} diff --git a/vendor/github.com/mholt/caddy/dist/gitcookie.sh.enc b/vendor/github.com/mholt/caddy/dist/gitcookie.sh.enc deleted file mode 100644 index 1a51f39..0000000 --- a/vendor/github.com/mholt/caddy/dist/gitcookie.sh.enc +++ /dev/null @@ -1,3 +0,0 @@ -(Ù Íã#劕-óš¢ ¶DÂórŸ}`ç:ï,0î@9²‹pŸK8äZ°“ ËŽVm0^B%¼Õ¬·@©ã9Æ]ßl†ÐŸ)–8³"Z˜Ö_šž›µÍ‘:g›÷Í7v‚]¼7#`Þ¸'Þ¾ïÞ…êǦ‘B9Àôz^‘'5Ÿ\*»ÇN -åk~=€ w^$ªˆøß-DÐÒÀf(Æ*°ÓCïdœƒ/u¢’ñk¦ û_•àövM ËçÿñU+ÍðLï¼gJ#[¯] -¢.wQ/“Ù«€B‡à\áB‰Ji'"v{ÂÁæšy)x·¿¨ƒ\ðâð8Äì'2°ë ‹¹ˆ«ta˜}¿ˆ<†G7Gb I0o~RŸ¨¬Æ)O \ No newline at end of file diff --git a/vendor/github.com/mholt/caddy/dist/init/README.md b/vendor/github.com/mholt/caddy/dist/init/README.md deleted file mode 100644 index 018f065..0000000 --- a/vendor/github.com/mholt/caddy/dist/init/README.md +++ /dev/null @@ -1,12 +0,0 @@ -Init/Service Scripts -==================== - -This folder contains init/service scripts for using Caddy on various Linux and BSD distributions. They are created and maintained by the community. - -## Getting Help - -Different scripts have different maintainers; please consult the comments in the file and any README for assistance setting it up. Do not open an issue on the Caddy project about these scripts; instead, to ask a question or suggest a change, please contact the maintainer of the script directly. - -## Disclaimer - -The files contained herein are not officially supported by the Caddy project author and/or contributors, and as such, the files are not endorsed by the same. The Caddy project author and its contributors are not responsible for the function or malfunction of these scripts/files, or any unintended consequences to your system or website in attempting to set up Caddy. Users are expected to know how to administer their system, and these files should be considered as only a guide or suggestion for using Caddy in certain environments. diff --git a/vendor/github.com/mholt/caddy/dist/init/freebsd/caddy b/vendor/github.com/mholt/caddy/dist/init/freebsd/caddy deleted file mode 100755 index a48ca45..0000000 --- a/vendor/github.com/mholt/caddy/dist/init/freebsd/caddy +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# - -# PROVIDE: caddy -# REQUIRE: LOGIN NETWORKING named cleanvar sshd -# KEYWORD: shutdown - -# -# Add the following lines to /etc/rc.conf to enable caddy: -# caddy_enable (bool): Set to "NO" by default. -# Set it to "YES" to enable caddy -# -# caddy_cert_email (str): Set to "" by default. -# Defines the SSL certificate issuer email. By providing an -# email address you automatically agree to letsencrypt.org's -# general terms and conditions -# -# caddy_bin_path (str): Set to "/usr/local/bin/caddy" by default. -# Provides the path to the caddy server executable -# -# caddy_cpu (str): Set to "99%" by default. -# Configures, how much CPU capacity caddy may gain -# -# caddy_config_path (str): Set to "/usr/local/www/Caddyfile" by default. -# Defines the path for the configuration file caddy will load on boot -# -# caddy_run_user (str): Set to "root" by default. -# Defines the user that caddy will run on -# - -. /etc/rc.subr - -name="caddy" -rcvar=${name}_enable - -load_rc_config $name -: ${caddy_enable:=no} -: ${caddy_cert_email=""} -: ${caddy_bin_path="/usr/local/bin/caddy"} -: ${caddy_cpu="99%"} # was a bug for me that caused a crash within jails -: ${caddy_config_path="/usr/local/www/Caddyfile"} -: ${caddy_run_user="root"} - -if [ "$caddy_cert_email" = "" ] -then - echo "rc variable \$caddy_cert_email is not set. Please provide a valid SSL certificate issuer email." - exit 1 -fi - -pidfile="/var/run/caddy.pid" -logfile="/var/log/caddy.log" - -command="${caddy_bin_path} -log ${logfile} -pidfile ${pidfile} -cpu ${caddy_cpu} -conf ${caddy_config_path} -agree -email ${caddy_cert_email}" - -start_cmd="caddy_start" -status_cmd="caddy_status" -stop_cmd="caddy_stop" - -caddy_start() { - echo "Starting Caddy..." - /usr/sbin/daemon -u ${caddy_run_user} -c ${command} >> ${logfile} -} - -caddy_status() { - ps -p `cat ${pidfile} 2> /dev/null` > /dev/null 2>&1 && echo 'Running' || echo 'Not Running. Please note that upon startup it will take Caddy a few seconds to come up. So you might just wanna wait a few seconds before starting it again.' -} - -caddy_stop() { - echo "Stopping Caddy..." - kill -QUIT `cat $pidfile 2> /dev/null` -} - -run_rc_command "$1" diff --git a/vendor/github.com/mholt/caddy/dist/init/linux-systemd/README.md b/vendor/github.com/mholt/caddy/dist/init/linux-systemd/README.md deleted file mode 100644 index 2176304..0000000 --- a/vendor/github.com/mholt/caddy/dist/init/linux-systemd/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# systemd unit for caddy - -Please do not hesitate to ask on -[caddyserver/support](https://gitter.im/caddyserver/support) -if you have any questions. -Feel free to prepend to your question the username of whoever touched the file most recently, -for example `@wmark re systemd: …`. - -The provided file is written for **systemd version 229** or later! - -## Quickstart - -In the following sections, we will assume that you want to run caddy -as user `www-data` and group `www-data`, with UID and GID 33. -Adjust this to your liking according to the preferences of your Linux distribution! - -```bash -groupadd -g 33 www-data -useradd \ - -g www-data --no-user-group \ - --home-dir /var/www --no-create-home \ - --shell /usr/sbin/nologin \ - --system --uid 33 www-data - -mkdir /etc/caddy -chown -R root:www-data /etc/caddy -mkdir /etc/ssl/caddy -chown -R www-data:root /etc/ssl/caddy -chmod 0770 /etc/ssl/caddy -``` - -- Install the unit configuration file: `cp caddy.service /etc/systemd/system/` -- Reload the systemd daemon: `systemctl daemon-reload` -- Make sure to [configure](#configuration) the service unit before starting caddy. -- Start caddy: `systemctl start caddy.service` -- Enable the service (automatically start on boot): `systemctl enable caddy.service` -- A folder `.caddy` will be created inside the home directory of the user that runs caddy; - you can change that by providing an environment variable `HOME`, - i.e. `Environment=HOME=/var/lib/caddy` will result in `/var/lib/caddy/.caddy` - -## Configuration - -- Prefer `systemctl edit` over modifying the unit file directly: - - `systemctl edit caddy.service` to make user-local modifications - - `systemctl edit --full caddy.service` for system-wide ones -- In most cases it is enough to override arguments in the `ExecStart` directive: - -```ini -[Service] -; an empty value clears the original (and preceding) settings -ExecStart= -ExecStart=/usr/bin/caddy -conf="/etc/caddy/myCaddy.conf" -``` - -- To view the resulting configuration use `systemctl cat caddy` -- systemd needs absolute paths, therefore make sure that the path to caddy is correct. -- Double check permissions of your *document root* path. - The user caddy runs as needs to have access to it. For example: - -```bash -# caddy would run as www-data:www-data -# serving, in this example: /var/www - -sudo -u www-data -g www-data -s \ - ls -hlAS /var/www - -# Got an error? Revisit permissions! -``` - -## Tips - -- Use `log stdout` and `errors stderr` in your Caddyfile to fully utilize **journald**. -- `journalctl` is *journald's* log query tool. -- Did caddy not start? Check the logfiles for any error messages using `journalctl --boot -u caddy.service` -- To follow caddy's log output: `journalctl -f -u caddy.service` -- If your GNU/Linux distribution does not use *systemd* with *journald* then check any logfiles in: `/var/log` - -- If you have more files that start with `caddy` – like a `caddy.timer`, `caddy.path`, or `caddy.socket` – then it is important to append `.service`. - Although if `caddy.service` is all you have, then you can just use `caddy` without any extension, such as in: `systemctl status caddy` - -- You can make other certificates and private key files accessible to a user `www-data` by command `setfacl`, if you must: - -```bash -setfacl -m user:www-data:r-- /etc/ssl/private/my.key -``` diff --git a/vendor/github.com/mholt/caddy/dist/init/linux-systemd/caddy.service b/vendor/github.com/mholt/caddy/dist/init/linux-systemd/caddy.service deleted file mode 100644 index aa5020e..0000000 --- a/vendor/github.com/mholt/caddy/dist/init/linux-systemd/caddy.service +++ /dev/null @@ -1,50 +0,0 @@ -[Unit] -Description=Caddy HTTP/2 web server -Documentation=https://caddyserver.com/docs -After=network-online.target -Wants=network-online.target systemd-networkd-wait-online.service - -[Service] -Restart=on-failure - -; User and group the process will run as. -User=www-data -Group=www-data - -; Letsencrypt-issued certificates will be written to this directory. -Environment=HOME=/etc/ssl/caddy - -; Always set "-root" to something safe in case it gets forgotten in the Caddyfile. -ExecStart=/usr/bin/caddy -log stdout -agree=true -conf=/etc/caddy/Caddyfile -root=/var/tmp -ExecReload=/bin/kill -USR1 $MAINPID - -; Limit the number of file descriptors; see `man systemd.exec` for more limit settings. -LimitNOFILE=1048576 -; Unmodified caddy is not expected to use more than that. -LimitNPROC=64 - -; Use private /tmp and /var/tmp, which are discarded after caddy stops. -PrivateTmp=true -; Use a minimal /dev -PrivateDevices=true -; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys. -ProtectHome=true -; Make /usr, /boot, /etc and possibly some more folders read-only. -ProtectSystem=full -; … except /etc/ssl/caddy, because we want Letsencrypt-certificates there. -; This merely retains r/w access rights, it does not add any new. Must still be writable on the host! -ReadWriteDirectories=/etc/ssl/caddy - -; Drop all other capabilities. Important if you run caddy as privileged user (which you should not). -CapabilityBoundingSet=CAP_NET_BIND_SERVICE -; … but permit caddy to open ports reserved for system services. -; This could be redundant here, but is needed in case caddy runs as nobody:nogroup. -AmbientCapabilities=CAP_NET_BIND_SERVICE -; … and prevent gaining any new privileges. -NoNewPrivileges=true - -; Caveat: Some plugins need additional capabilities. Add them to both above lines. -; - plugin "upload" needs: CAP_LEASE - -[Install] -WantedBy=multi-user.target diff --git a/vendor/github.com/mholt/caddy/dist/init/linux-upstart/README.md b/vendor/github.com/mholt/caddy/dist/init/linux-upstart/README.md deleted file mode 100644 index 33af460..0000000 --- a/vendor/github.com/mholt/caddy/dist/init/linux-upstart/README.md +++ /dev/null @@ -1,14 +0,0 @@ -Upstart conf for Caddy -===================== - -Usage ------ - -Usage in this blogpost: [Running Caddy Server as a service with Upstart](https://denbeke.be/blog/servers/running-caddy-server-as-a-service/). -Short recap: - -* Download Caddy in `/usr/bin/caddy` and execute `sudo setcap cap_net_bind_service=+ep /usr/bin/caddy`. -* Save the upstart config file in `/etc/init/caddy.conf`. -* Ensure that the folder `/etc/caddy` exists and that the subfolder .caddy is owned by `www-data`. -* Create a Caddyfile in `/etc/caddy/Caddyfile`. -* Now you can use `sudo service caddy start|stop|restart`. diff --git a/vendor/github.com/mholt/caddy/dist/init/linux-upstart/caddy.conf b/vendor/github.com/mholt/caddy/dist/init/linux-upstart/caddy.conf deleted file mode 100644 index 43a6cd0..0000000 --- a/vendor/github.com/mholt/caddy/dist/init/linux-upstart/caddy.conf +++ /dev/null @@ -1,23 +0,0 @@ -description "Caddy HTTP/2 web server" - -start on runlevel [2345] -stop on runlevel [016] - -console log - -setuid www-data -setgid www-data - -respawn -respawn limit 10 5 - -# Let's Encrypt certificates will be written to this directory. -env HOME=/etc/caddy - -limit nofile 1048576 1048576 - -script - cd /etc/caddy - rootdir="$(mktemp -d -t "caddy-run.XXXXXX")" - exec /usr/bin/caddy -agree -log=stdout -conf=/etc/caddy/Caddyfile -root=$rootdir -end script diff --git a/vendor/github.com/mholt/caddy/plugins.go b/vendor/github.com/mholt/caddy/plugins.go deleted file mode 100644 index 22e5e6f..0000000 --- a/vendor/github.com/mholt/caddy/plugins.go +++ /dev/null @@ -1,302 +0,0 @@ -package caddy - -import ( - "fmt" - "net" - "sort" - - "github.com/mholt/caddy/caddyfile" -) - -// These are all the registered plugins. -var ( - // serverTypes is a map of registered server types. - serverTypes = make(map[string]ServerType) - - // plugins is a map of server type to map of plugin name to - // Plugin. These are the "general" plugins that may or may - // not be associated with a specific server type. If it's - // applicable to multiple server types or the server type is - // irrelevant, the key is empty string (""). But all plugins - // must have a name. - plugins = make(map[string]map[string]Plugin) - - // parsingCallbacks maps server type to map of directive - // to list of callback functions. These aren't really - // plugins on their own, but are often registered from - // plugins. - parsingCallbacks = make(map[string]map[string][]func() error) - - // caddyfileLoaders is the list of all Caddyfile loaders - // in registration order. - caddyfileLoaders []caddyfileLoader -) - -// DescribePlugins returns a string describing the registered plugins. -func DescribePlugins() string { - str := "Server types:\n" - for name := range serverTypes { - str += " " + name + "\n" - } - - // List the loaders in registration order - str += "\nCaddyfile loaders:\n" - for _, loader := range caddyfileLoaders { - str += " " + loader.name + "\n" - } - if defaultCaddyfileLoader.name != "" { - str += " " + defaultCaddyfileLoader.name + "\n" - } - - // Let's alphabetize the rest of these... - var others []string - for stype, stypePlugins := range plugins { - for name := range stypePlugins { - var s string - if stype != "" { - s = stype + "." - } - s += name - others = append(others, s) - } - } - sort.Strings(others) - str += "\nOther plugins:\n" - for _, name := range others { - str += " " + name + "\n" - } - - return str -} - -// ValidDirectives returns the list of all directives that are -// recognized for the server type serverType. However, not all -// directives may be installed. This makes it possible to give -// more helpful error messages, like "did you mean ..." or -// "maybe you need to plug in ...". -func ValidDirectives(serverType string) []string { - stype, err := getServerType(serverType) - if err != nil { - return nil - } - return stype.Directives -} - -// serverListener pairs a server to its listener. -type serverListener struct { - server Server - listener net.Listener -} - -// Context is a type which carries a server type through -// the load and setup phase; it maintains the state -// between loading the Caddyfile, then executing its -// directives, then making the servers for Caddy to -// manage. Typically, such state involves configuration -// structs, etc. -type Context interface { - // Called after the Caddyfile is parsed into server - // blocks but before the directives are executed, - // this method gives you an opportunity to inspect - // the server blocks and prepare for the execution - // of directives. Return the server blocks (which - // you may modify, if desired) and an error, if any. - // The first argument is the name or path to the - // configuration file (Caddyfile). - // - // This function can be a no-op and simply return its - // input if there is nothing to do here. - InspectServerBlocks(string, []caddyfile.ServerBlock) ([]caddyfile.ServerBlock, error) - - // This is what Caddy calls to make server instances. - // By this time, all directives have been executed and, - // presumably, the context has enough state to produce - // server instances for Caddy to start. - MakeServers() ([]Server, error) -} - -// RegisterServerType registers a server type srv by its -// name, typeName. -func RegisterServerType(typeName string, srv ServerType) { - if _, ok := serverTypes[typeName]; ok { - panic("server type already registered") - } - serverTypes[typeName] = srv -} - -// ServerType contains information about a server type. -type ServerType struct { - // List of directives, in execution order, that are - // valid for this server type. Directives should be - // one word if possible and lower-cased. - Directives []string - - // DefaultInput returns a default config input if none - // is otherwise loaded. This is optional, but highly - // recommended, otherwise a blank Caddyfile will be - // used. - DefaultInput func() Input - - // The function that produces a new server type context. - // This will be called when a new Caddyfile is being - // loaded, parsed, and executed independently of any - // startup phases before this one. It's a way to keep - // each set of server instances separate and to reduce - // the amount of global state you need. - NewContext func() Context -} - -// Plugin is a type which holds information about a plugin. -type Plugin struct { - // ServerType is the type of server this plugin is for. - // Can be empty if not applicable, or if the plugin - // can associate with any server type. - ServerType string - - // Action is the plugin's setup function, if associated - // with a directive in the Caddyfile. - Action SetupFunc -} - -// RegisterPlugin plugs in plugin. All plugins should register -// themselves, even if they do not perform an action associated -// with a directive. It is important for the process to know -// which plugins are available. -// -// The plugin MUST have a name: lower case and one word. -// If this plugin has an action, it must be the name of -// the directive that invokes it. A name is always required -// and must be unique for the server type. -func RegisterPlugin(name string, plugin Plugin) { - if name == "" { - panic("plugin must have a name") - } - if _, ok := plugins[plugin.ServerType]; !ok { - plugins[plugin.ServerType] = make(map[string]Plugin) - } - if _, dup := plugins[plugin.ServerType][name]; dup { - panic("plugin named " + name + " already registered for server type " + plugin.ServerType) - } - plugins[plugin.ServerType][name] = plugin -} - -// RegisterParsingCallback registers callback to be called after -// executing the directive afterDir for server type serverType. -func RegisterParsingCallback(serverType, afterDir string, callback func() error) { - if _, ok := parsingCallbacks[serverType]; !ok { - parsingCallbacks[serverType] = make(map[string][]func() error) - } - parsingCallbacks[serverType][afterDir] = append(parsingCallbacks[serverType][afterDir], callback) -} - -// SetupFunc is used to set up a plugin, or in other words, -// execute a directive. It will be called once per key for -// each server block it appears in. -type SetupFunc func(c *Controller) error - -// DirectiveAction gets the action for directive dir of -// server type serverType. -func DirectiveAction(serverType, dir string) (SetupFunc, error) { - if stypePlugins, ok := plugins[serverType]; ok { - if plugin, ok := stypePlugins[dir]; ok { - return plugin.Action, nil - } - } - if genericPlugins, ok := plugins[""]; ok { - if plugin, ok := genericPlugins[dir]; ok { - return plugin.Action, nil - } - } - return nil, fmt.Errorf("no action found for directive '%s' with server type '%s' (missing a plugin?)", - dir, serverType) -} - -// Loader is a type that can load a Caddyfile. -// It is passed the name of the server type. -// It returns an error only if something went -// wrong, not simply if there is no Caddyfile -// for this loader to load. -// -// A Loader should only load the Caddyfile if -// a certain condition or requirement is met, -// as returning a non-nil Input value along with -// another Loader will result in an error. -// In other words, loading the Caddyfile must -// be deliberate & deterministic, not haphazard. -// -// The exception is the default Caddyfile loader, -// which will be called only if no other Caddyfile -// loaders return a non-nil Input. The default -// loader may always return an Input value. -type Loader interface { - Load(serverType string) (Input, error) -} - -// LoaderFunc is a convenience type similar to http.HandlerFunc -// that allows you to use a plain function as a Load() method. -type LoaderFunc func(serverType string) (Input, error) - -// Load loads a Caddyfile. -func (lf LoaderFunc) Load(serverType string) (Input, error) { - return lf(serverType) -} - -// RegisterCaddyfileLoader registers loader named name. -func RegisterCaddyfileLoader(name string, loader Loader) { - caddyfileLoaders = append(caddyfileLoaders, caddyfileLoader{name: name, loader: loader}) -} - -// SetDefaultCaddyfileLoader registers loader by name -// as the default Caddyfile loader if no others produce -// a Caddyfile. If another Caddyfile loader has already -// been set as the default, this replaces it. -// -// Do not call RegisterCaddyfileLoader on the same -// loader; that would be redundant. -func SetDefaultCaddyfileLoader(name string, loader Loader) { - defaultCaddyfileLoader = caddyfileLoader{name: name, loader: loader} -} - -// loadCaddyfileInput iterates the registered Caddyfile loaders -// and, if needed, calls the default loader, to load a Caddyfile. -// It is an error if any of the loaders return an error or if -// more than one loader returns a Caddyfile. -func loadCaddyfileInput(serverType string) (Input, error) { - var loadedBy string - var caddyfileToUse Input - for _, l := range caddyfileLoaders { - if cdyfile, err := l.loader.Load(serverType); cdyfile != nil { - if caddyfileToUse != nil { - return nil, fmt.Errorf("Caddyfile loaded multiple times; first by %s, then by %s", loadedBy, l.name) - } - if err != nil { - return nil, err - } - loaderUsed = l - caddyfileToUse = cdyfile - loadedBy = l.name - } - } - if caddyfileToUse == nil && defaultCaddyfileLoader.loader != nil { - cdyfile, err := defaultCaddyfileLoader.loader.Load(serverType) - if err != nil { - return nil, err - } - if cdyfile != nil { - loaderUsed = defaultCaddyfileLoader - caddyfileToUse = cdyfile - } - } - return caddyfileToUse, nil -} - -// caddyfileLoader pairs the name of a loader to the loader. -type caddyfileLoader struct { - name string - loader Loader -} - -var ( - defaultCaddyfileLoader caddyfileLoader // the default loader if all else fail - loaderUsed caddyfileLoader // the loader that was used (relevant for reloads) -) diff --git a/vendor/github.com/mholt/caddy/sigtrap.go b/vendor/github.com/mholt/caddy/sigtrap.go deleted file mode 100644 index 7acdbc4..0000000 --- a/vendor/github.com/mholt/caddy/sigtrap.go +++ /dev/null @@ -1,83 +0,0 @@ -package caddy - -import ( - "log" - "os" - "os/signal" - "sync" -) - -// TrapSignals create signal handlers for all applicable signals for this -// system. If your Go program uses signals, this is a rather invasive -// function; best to implement them yourself in that case. Signals are not -// required for the caddy package to function properly, but this is a -// convenient way to allow the user to control this part of your program. -func TrapSignals() { - trapSignalsCrossPlatform() - trapSignalsPosix() -} - -// trapSignalsCrossPlatform captures SIGINT, which triggers forceful -// shutdown that executes shutdown callbacks first. A second interrupt -// signal will exit the process immediately. -func trapSignalsCrossPlatform() { - go func() { - shutdown := make(chan os.Signal, 1) - signal.Notify(shutdown, os.Interrupt) - - for i := 0; true; i++ { - <-shutdown - - if i > 0 { - log.Println("[INFO] SIGINT: Force quit") - if PidFile != "" { - os.Remove(PidFile) - } - os.Exit(1) - } - - log.Println("[INFO] SIGINT: Shutting down") - - if PidFile != "" { - os.Remove(PidFile) - } - - go os.Exit(executeShutdownCallbacks("SIGINT")) - } - }() -} - -// executeShutdownCallbacks executes the shutdown callbacks as initiated -// by signame. It logs any errors and returns the recommended exit status. -// This function is idempotent; subsequent invocations always return 0. -func executeShutdownCallbacks(signame string) (exitCode int) { - shutdownCallbacksOnce.Do(func() { - errs := allShutdownCallbacks() - if len(errs) > 0 { - for _, err := range errs { - log.Printf("[ERROR] %s shutdown: %v", signame, err) - } - exitCode = 1 - } - }) - return -} - -// allShutdownCallbacks executes all the shutdown callbacks -// for all the instances, and returns all the errors generated -// during their execution. An error executing one shutdown -// callback does not stop execution of others. Only one shutdown -// callback is executed at a time. -func allShutdownCallbacks() []error { - var errs []error - instancesMu.Lock() - for _, inst := range instances { - errs = append(errs, inst.shutdownCallbacks()...) - } - instancesMu.Unlock() - return errs -} - -// shutdownCallbacksOnce ensures that shutdown callbacks -// for all instances are only executed once. -var shutdownCallbacksOnce sync.Once diff --git a/vendor/github.com/mholt/caddy/sigtrap_posix.go b/vendor/github.com/mholt/caddy/sigtrap_posix.go deleted file mode 100644 index 9ee7bbb..0000000 --- a/vendor/github.com/mholt/caddy/sigtrap_posix.go +++ /dev/null @@ -1,84 +0,0 @@ -// +build !windows - -package caddy - -import ( - "log" - "os" - "os/signal" - "syscall" -) - -// trapSignalsPosix captures POSIX-only signals. -func trapSignalsPosix() { - go func() { - sigchan := make(chan os.Signal, 1) - signal.Notify(sigchan, syscall.SIGTERM, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGUSR1) - - for sig := range sigchan { - switch sig { - case syscall.SIGTERM: - log.Println("[INFO] SIGTERM: Terminating process") - if PidFile != "" { - os.Remove(PidFile) - } - os.Exit(0) - - case syscall.SIGQUIT: - log.Println("[INFO] SIGQUIT: Shutting down") - exitCode := executeShutdownCallbacks("SIGQUIT") - err := Stop() - if err != nil { - log.Printf("[ERROR] SIGQUIT stop: %v", err) - exitCode = 1 - } - if PidFile != "" { - os.Remove(PidFile) - } - os.Exit(exitCode) - - case syscall.SIGHUP: - log.Println("[INFO] SIGHUP: Hanging up") - err := Stop() - if err != nil { - log.Printf("[ERROR] SIGHUP stop: %v", err) - } - - case syscall.SIGUSR1: - log.Println("[INFO] SIGUSR1: Reloading") - - // Start with the existing Caddyfile - instancesMu.Lock() - inst := instances[0] // we only support one instance at this time - instancesMu.Unlock() - updatedCaddyfile := inst.caddyfileInput - if updatedCaddyfile == nil { - // Hmm, did spawing process forget to close stdin? Anyhow, this is unusual. - log.Println("[ERROR] SIGUSR1: no Caddyfile to reload (was stdin left open?)") - continue - } - if loaderUsed.loader == nil { - // This also should never happen - log.Println("[ERROR] SIGUSR1: no Caddyfile loader with which to reload Caddyfile") - continue - } - - // Load the updated Caddyfile - newCaddyfile, err := loaderUsed.loader.Load(inst.serverType) - if err != nil { - log.Printf("[ERROR] SIGUSR1: loading updated Caddyfile: %v", err) - continue - } - if newCaddyfile != nil { - updatedCaddyfile = newCaddyfile - } - - // Kick off the restart; our work is done - inst, err = inst.Restart(updatedCaddyfile) - if err != nil { - log.Printf("[ERROR] SIGUSR1: %v", err) - } - } - } - }() -} diff --git a/vendor/github.com/mholt/caddy/sigtrap_windows.go b/vendor/github.com/mholt/caddy/sigtrap_windows.go deleted file mode 100644 index cbe7c01..0000000 --- a/vendor/github.com/mholt/caddy/sigtrap_windows.go +++ /dev/null @@ -1,3 +0,0 @@ -package caddy - -func trapSignalsPosix() {} diff --git a/vendor/github.com/mholt/caddy/startupshutdown/startupshutdown.go b/vendor/github.com/mholt/caddy/startupshutdown/startupshutdown.go deleted file mode 100644 index 0a14e0c..0000000 --- a/vendor/github.com/mholt/caddy/startupshutdown/startupshutdown.go +++ /dev/null @@ -1,70 +0,0 @@ -package startupshutdown - -import ( - "os" - "os/exec" - "strings" - - "github.com/mholt/caddy" -) - -func init() { - caddy.RegisterPlugin("startup", caddy.Plugin{Action: Startup}) - caddy.RegisterPlugin("shutdown", caddy.Plugin{Action: Shutdown}) -} - -// Startup registers a startup callback to execute during server start. -func Startup(c *caddy.Controller) error { - return registerCallback(c, c.OnStartup) -} - -// Shutdown registers a shutdown callback to execute during server stop. -func Shutdown(c *caddy.Controller) error { - return registerCallback(c, c.OnShutdown) -} - -// registerCallback registers a callback function to execute by -// using c to parse the directive. It registers the callback -// to be executed using registerFunc. -func registerCallback(c *caddy.Controller, registerFunc func(func() error)) error { - var funcs []func() error - - for c.Next() { - args := c.RemainingArgs() - if len(args) == 0 { - return c.ArgErr() - } - - nonblock := false - if len(args) > 1 && args[len(args)-1] == "&" { - // Run command in background; non-blocking - nonblock = true - args = args[:len(args)-1] - } - - command, args, err := caddy.SplitCommandAndArgs(strings.Join(args, " ")) - if err != nil { - return c.Err(err.Error()) - } - - fn := func() error { - cmd := exec.Command(command, args...) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if nonblock { - return cmd.Start() - } - return cmd.Run() - } - - funcs = append(funcs, fn) - } - - return c.OncePerServerBlock(func() error { - for _, fn := range funcs { - registerFunc(fn) - } - return nil - }) -} diff --git a/vendor/github.com/mholt/caddy/startupshutdown/startupshutdown_test.go b/vendor/github.com/mholt/caddy/startupshutdown/startupshutdown_test.go deleted file mode 100644 index 8bc98f9..0000000 --- a/vendor/github.com/mholt/caddy/startupshutdown/startupshutdown_test.go +++ /dev/null @@ -1,66 +0,0 @@ -package startupshutdown - -import ( - "os" - "path/filepath" - "strconv" - "testing" - "time" - - "github.com/mholt/caddy" -) - -// The Startup function's tests are symmetrical to Shutdown tests, -// because the Startup and Shutdown functions share virtually the -// same functionality -func TestStartup(t *testing.T) { - tempDirPath := os.TempDir() - - testDir := filepath.Join(tempDirPath, "temp_dir_for_testing_startupshutdown") - defer func() { - // clean up after non-blocking startup function quits - time.Sleep(500 * time.Millisecond) - os.RemoveAll(testDir) - }() - osSenitiveTestDir := filepath.FromSlash(testDir) - os.RemoveAll(osSenitiveTestDir) // start with a clean slate - - var registeredFunction func() error - fakeRegister := func(fn func() error) { - registeredFunction = fn - } - - tests := []struct { - input string - shouldExecutionErr bool - shouldRemoveErr bool - }{ - // test case #0 tests proper functionality blocking commands - {"startup mkdir " + osSenitiveTestDir, false, false}, - - // test case #1 tests proper functionality of non-blocking commands - {"startup mkdir " + osSenitiveTestDir + " &", false, true}, - - // test case #2 tests handling of non-existent commands - {"startup " + strconv.Itoa(int(time.Now().UnixNano())), true, true}, - } - - for i, test := range tests { - c := caddy.NewTestController(test.input) - err := registerCallback(c, fakeRegister) - if err != nil { - t.Errorf("Expected no errors, got: %v", err) - } - if registeredFunction == nil { - t.Fatalf("Expected function to be registered, but it wasn't") - } - err = registeredFunction() - if err != nil && !test.shouldExecutionErr { - t.Errorf("Test %d recieved an error of:\n%v", i, err) - } - err = os.Remove(osSenitiveTestDir) - if err != nil && !test.shouldRemoveErr { - t.Errorf("Test %d recieved an error of:\n%v", i, err) - } - } -} diff --git a/vendor/github.com/micromdm/scep/.gitignore b/vendor/github.com/micromdm/scep/.gitignore deleted file mode 100644 index 78acd88..0000000 --- a/vendor/github.com/micromdm/scep/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -cmd/scepserver/scepserver -cmd/scepclient/scepclient -build/ diff --git a/vendor/github.com/micromdm/scep/Dockerfile b/vendor/github.com/micromdm/scep/Dockerfile deleted file mode 100644 index 0aefb28..0000000 --- a/vendor/github.com/micromdm/scep/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM alpine:3.3 - -ENV SCEP_VERSION=0.1.0.0 -RUN apk --no-cache add curl && \ - curl -L https://github.com/micromdm/scep/releases/download/${SCEP_VERSION}/scep-linux-amd64 -o /scep && \ - chmod a+x /scep && \ - apk del curl - -CMD ["/scep"] diff --git a/vendor/github.com/micromdm/scep/LICENSE b/vendor/github.com/micromdm/scep/LICENSE deleted file mode 100644 index 9ad8579..0000000 --- a/vendor/github.com/micromdm/scep/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2016 Victor Vrantchan - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/github.com/micromdm/scep/README.md b/vendor/github.com/micromdm/scep/README.md deleted file mode 100644 index 0c8e4f2..0000000 --- a/vendor/github.com/micromdm/scep/README.md +++ /dev/null @@ -1,151 +0,0 @@ -`scep` is a Simple Certificate Enrollment Protocol server and client - -# Installation -A binary release is available on the releases page. - -# Example -minimal example for both server and client -``` -# create a new CA -scepserver ca -init -# start server -scepserver -depot depot -port 2016 -challenge=secret - -# in a separate terminal window, run a client -# note, if the client.key doesn't exist, the client will create a new rsa private key. Must be in PEM format. -scepclient -private-key client.key -server-url=http://scep.groob.io:2016 -challenge=secret -``` -# Server Usage - -The default flags configure and run the scep server. -depot must be the path to a folder with `ca.pem` and `ca.key` files. - -If you don't already have a CA to use, you can create one using the `scep ca` subcommand. - -``` -Usage of ./cmd/scepserver/scepserver: - -challenge string - enforce a challenge password - -depot string - path to ca folder (default "depot") - -port string - port to listen on (default "8080") - -version - prints version information -``` - -`scep ca -init` to create a new CA and private key. - -``` -Usage of ./cmd/scepserver/scepserver ca: - -country string - country for CA cert (default "US") - -depot string - path to ca folder (default "depot") - -init - create a new CA - -key-password string - password to store rsa key - -keySize int - rsa key size (default 4096) - -organization string - organization for CA cert (default "scep-ca") - -years int - default CA years (default 10) -``` - -# Client Usage - -``` -Usage of scepclient: - -certificate string - certificate path, if there is no key, scepclient will create one - -challenge string - enforce a challenge password - -cn string - common name for certificate (default "scepclient") - -country string - country code in certificate (default "US") - -keySize int - rsa key size (default 2048) - -organization string - organization for cert (default "scep-client") - -private-key string - private key path, if there is no key, scepclient will create one - -server-url string - SCEP server url - -version - prints version information -``` - -# Docker -``` -docker pull micromdm/scep -# create CA -docker run -it --rm -v /path/to/ca/folder:/depot micromdm/scep ./scep ca -init - -# run -docker run -it --rm -v /path/to/ca/folder:/depot -p 8080:8080 micromdm/scep -``` - -# SCEP library - -``` -go get github.com/micromdm/scep/scep -``` - -For detailed usage, see [godoc](https://godoc.org/github.com/micromdm/scep/scep) - -Example: -``` -// read a request body containing SCEP message -body, err := ioutil.ReadAll(r.Body) -if err != nil { - // handle err -} - -// parse the SCEP message -msg, err := scep.ParsePKIMessage(body) -if err != nil { - // handle err -} - -// do something with msg -fmt.Println(msg.MessageType) - -// extract encrypted pkiEnvelope -err := msg.DecryptPKIEnvelope(CAcert, CAkey) -if err != nil { - // handle err -} - -// use the csr from decrypted PKCRS request -csr := msg.CSRReqMessage.CSR - -// create cert template -tmpl := &x509.Certificate{ - SerialNumber: big.NewInt(1), - Subject: csr.Subject, - NotBefore: time.Now().Add(-600).UTC(), - NotAfter: time.Now().AddDate(1, 0, 0).UTC(), - SubjectKeyId: id, - ExtKeyUsage: []x509.ExtKeyUsage{ - x509.ExtKeyUsageAny, - x509.ExtKeyUsageClientAuth, - }, -} - -// create a CertRep message from the original -certRep, err := msg.SignCSR(CAcert, CAkey, tmlp) -if err != nil { - // handle err -} - -// send response back -// w is a http.ResponseWriter -w.Write(certRep.Raw) -``` - -# Server library - -You can import the scep endpoint into another Go project. For an example take a look at `cmd/scep/main.go` diff --git a/vendor/github.com/micromdm/scep/caddy/config.json b/vendor/github.com/micromdm/scep/caddy/config.json deleted file mode 100644 index 78a7c2f..0000000 --- a/vendor/github.com/micromdm/scep/caddy/config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directive" : "scep" -} diff --git a/vendor/github.com/micromdm/scep/caddy/scep.go b/vendor/github.com/micromdm/scep/caddy/scep.go deleted file mode 100644 index d251251..0000000 --- a/vendor/github.com/micromdm/scep/caddy/scep.go +++ /dev/null @@ -1,152 +0,0 @@ -package scep - -import ( - "fmt" - "net/http" - "os" - "path/filepath" - - "golang.org/x/net/context" - - "github.com/go-kit/kit/log" - "github.com/mholt/caddy" - "github.com/mholt/caddy/caddyhttp/httpserver" - "github.com/micromdm/scep/server" -) - -// SCEP holds the configuration for the SCEP server -type SCEP struct { - next httpserver.Handler - challengePassword string - depotPath string // cert store path - caKeyPassword []byte - scepHandler http.Handler -} - -func (s SCEP) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - paths := []string{"/scep"} - for _, p := range paths { - if httpserver.Path(r.URL.Path).Matches(p) { - s.scepHandler.ServeHTTP(w, r) - return 0, nil - } - } - return s.next.ServeHTTP(w, r) -} - -func init() { - caddy.RegisterPlugin("scep", caddy.Plugin{ - ServerType: "http", - Action: setup, - }) -} - -// Setup creates a caddy middleware -func setup(c *caddy.Controller) error { - scp, err := parse(c) - if err != nil { - return err - } - - // Runs on Caddy startup, useful for services or other setups. - c.OnStartup(func() error { - fmt.Println("scep middleware is initiated") - return nil - }) - - // Runs on Caddy shutdown, useful for cleanups. - c.OnShutdown(func() error { - fmt.Println("api middleware is cleaning up") - return nil - }) - ctx := context.Background() - - // go kig logger - var logger log.Logger - { - logger = log.NewLogfmtLogger(os.Stderr) - logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) - logger = log.NewContext(logger).With("caller", log.DefaultCaller) - } - // scep cert depot - var depot scepserver.Depot // cert storage - { - depot, err = scepserver.NewFileDepot(scp.depotPath) - if err != nil { - return err - } - } - // scep service - var svc scepserver.Service // scep service - { - svcOptions := []scepserver.ServiceOption{ - scepserver.ChallengePassword(scp.challengePassword), - } - svc, err = scepserver.NewService(depot, svcOptions...) - if err != nil { - return err - } - svc = scepserver.NewLoggingService(log.NewContext(logger).With("component", "service"), svc) - } - - // scep handler - var h http.Handler - { - h = scepserver.ServiceHandler(ctx, svc, log.NewContext(logger).With("component", "http")) - } - - // caddy middleware - var m httpserver.Middleware - { - m = func(next httpserver.Handler) httpserver.Handler { - scp.next = next - scp.scepHandler = h - return scp - } - } - cfg := httpserver.GetConfig(c.Key) - cfg.AddMiddleware(m) - return nil -} - -func parse(c *caddy.Controller) (*SCEP, error) { - var ( - config *SCEP - err error - cfg = httpserver.GetConfig(c.Key) - ) - - for c.Next() { - config = &SCEP{} - args := c.RemainingArgs() - switch len(args) { - case 0: - case 1: - default: - return nil, c.ArgErr() - } - - for c.NextBlock() { - switch c.Val() { - case "depot": - if !c.NextArg() { - return nil, c.ArgErr() - } - config.depotPath = filepath.Clean(cfg.Root + string(filepath.Separator) + c.Val()) - case "keypass": - if !c.NextArg() { - return nil, c.ArgErr() - } - config.caKeyPassword = []byte(c.Val()) - case "challenge": - if !c.NextArg() { - return nil, c.ArgErr() - } - config.challengePassword = c.Val() - default: - return nil, c.ArgErr() - } - } - } - return config, err -} diff --git a/vendor/github.com/micromdm/scep/caddy/scep_test.go b/vendor/github.com/micromdm/scep/caddy/scep_test.go deleted file mode 100644 index d8aeb2b..0000000 --- a/vendor/github.com/micromdm/scep/caddy/scep_test.go +++ /dev/null @@ -1,20 +0,0 @@ -package scep - -import ( - "testing" - - "github.com/mholt/caddy" -) - -func TestCaddySetup(t *testing.T) { - input := `scep { - depot ../scep/testdata/testca - # keepass secret - # challenge sharedsecret - }` - c := caddy.NewTestController(input) - err := setup(c) - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/micromdm/scep/client/scep.go b/vendor/github.com/micromdm/scep/client/scep.go deleted file mode 100644 index 3ccc755..0000000 --- a/vendor/github.com/micromdm/scep/client/scep.go +++ /dev/null @@ -1,100 +0,0 @@ -package scepclient - -import ( - "bytes" - "errors" - "net/http" - "net/url" - - "github.com/go-kit/kit/endpoint" - httptransport "github.com/go-kit/kit/transport/http" - "github.com/micromdm/scep/server" - "golang.org/x/net/context" -) - -// Client implements the SCEP service and extra methods -type Client interface { - scepserver.Service - Supports(string) bool -} -type client struct { - getRemote endpoint.Endpoint - postRemote endpoint.Endpoint - capabilities []byte -} - -func (c *client) Supports(cap string) bool { - if len(c.capabilities) == 0 { - ctx := context.Background() - // try to retrieve caps - c.GetCACaps(ctx) - } - return bytes.Contains(c.capabilities, []byte(cap)) -} - -// NewClient returns a SCEP service that's backed by the provided Endpoint -func NewClient(baseURL string) Client { - scepURL, _ := url.Parse(baseURL) - httpc := http.DefaultClient - return &client{ - getRemote: httptransport.NewClient( - "GET", - scepURL, - scepserver.EncodeSCEPRequest, - scepserver.DecodeSCEPResponse, - httptransport.SetClient(httpc), - ).Endpoint(), - postRemote: httptransport.NewClient( - "POST", - scepURL, - scepserver.EncodeSCEPRequest, - scepserver.DecodeSCEPResponse, - httptransport.SetClient(httpc), - ).Endpoint(), - } -} - -func (c *client) GetCACaps(ctx context.Context) ([]byte, error) { - request := scepserver.SCEPRequest{ - Operation: "GetCACaps", - } - reply, err := c.getRemote(ctx, request) - if err != nil { - return nil, err - } - r := reply.(scepserver.SCEPResponse) - c.capabilities = r.Data - return r.Data, nil -} - -func (c *client) GetCACert(ctx context.Context) ([]byte, int, error) { - request := scepserver.SCEPRequest{ - Operation: "GetCACert", - } - reply, err := c.getRemote(ctx, request) - if err != nil { - return nil, 0, err - } - r := reply.(scepserver.SCEPResponse) - return r.Data, r.CACertNum, nil -} - -func (c *client) PKIOperation(ctx context.Context, data []byte) ([]byte, error) { - request := scepserver.SCEPRequest{ - Operation: "PKIOperation", - Message: data, - } - if c.Supports("POSTPKIOperation") { - reply, err := c.postRemote(ctx, request) - if err != nil { - return nil, err - } - r := reply.(scepserver.SCEPResponse) - return r.Data, nil - } - return nil, errors.New("no POSTPKIOperation support") -} - -func (c *client) GetNextCACert(ctx context.Context) ([]byte, error) { - panic("not implemented") -} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/cert.go b/vendor/github.com/micromdm/scep/cmd/scepclient/cert.go deleted file mode 100644 index f4ae94d..0000000 --- a/vendor/github.com/micromdm/scep/cmd/scepclient/cert.go +++ /dev/null @@ -1,100 +0,0 @@ -package main - -import ( - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/pem" - "errors" - "fmt" - "io/ioutil" - "math/big" - "os" - "time" -) - -const ( - certificatePEMBlockType = "CERTIFICATE" -) - -func pemCert(derBytes []byte) []byte { - pemBlock := &pem.Block{ - Type: certificatePEMBlockType, - Headers: nil, - Bytes: derBytes, - } - out := pem.EncodeToMemory(pemBlock) - return out -} - -func loadOrSign(path string, priv *rsa.PrivateKey, csr *x509.CertificateRequest) (*x509.Certificate, error) { - file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) - if err != nil { - if os.IsExist(err) { - return loadPEMCertFromFile(path) - } - return nil, err - } - defer file.Close() - self, err := selfSign(priv, csr) - if err != nil { - return nil, err - } - pemBlock := &pem.Block{ - Type: certificatePEMBlockType, - Headers: nil, - Bytes: self.Raw, - } - if err = pem.Encode(file, pemBlock); err != nil { - return nil, err - } - return self, nil -} - -func selfSign(priv *rsa.PrivateKey, csr *x509.CertificateRequest) (*x509.Certificate, error) { - serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) - serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) - if err != nil { - return nil, fmt.Errorf("failed to generate serial number: %s", err) - } - - notBefore := time.Now() - notAfter := notBefore.Add(time.Hour * 1) - template := x509.Certificate{ - SerialNumber: serialNumber, - Subject: pkix.Name{ - CommonName: "SCEP SIGNER", - Organization: csr.Subject.Organization, - }, - NotBefore: notBefore, - NotAfter: notAfter, - - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, - BasicConstraintsValid: true, - } - - derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) - if err != nil { - return nil, err - } - return x509.ParseCertificate(derBytes) -} - -func loadPEMCertFromFile(path string) (*x509.Certificate, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != certificatePEMBlockType { - return nil, errors.New("unmatched type or headers") - } - - return x509.ParseCertificate(pemBlock.Bytes) -} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/csr.go b/vendor/github.com/micromdm/scep/cmd/scepclient/csr.go deleted file mode 100644 index 34ba66c..0000000 --- a/vendor/github.com/micromdm/scep/cmd/scepclient/csr.go +++ /dev/null @@ -1,86 +0,0 @@ -package main - -import ( - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/pem" - "errors" - "io/ioutil" - "os" -) - -const ( - csrPEMBlockType = "CERTIFICATE REQUEST" -) - -type csrOptions struct { - cn, org, country, challenge string - key *rsa.PrivateKey -} - -func loadOrMakeCSR(path string, opts *csrOptions) (*x509.CertificateRequest, error) { - file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) - if err != nil { - if os.IsExist(err) { - return loadCSRfromFile(path) - } - return nil, err - } - defer file.Close() - - csrBytes, err := newCSR(opts.key, opts.country, opts.cn, opts.org) - if err != nil { - return nil, err - } - pemBlock := &pem.Block{ - Type: csrPEMBlockType, - Headers: nil, - Bytes: csrBytes, - } - if err := pem.Encode(file, pemBlock); err != nil { - return nil, err - } - return x509.ParseCertificateRequest(csrBytes) -} - -// create a CSR using the same parameters as Keychain Access would produce -func newCSR(priv *rsa.PrivateKey, country, cname, org string) ([]byte, error) { - subj := pkix.Name{ - Country: []string{country}, - CommonName: cname, - Organization: []string{org}, - } - template := &x509.CertificateRequest{ - Subject: subj, - } - return x509.CreateCertificateRequest(rand.Reader, template, priv) -} - -// convert DER to PEM format -func pemCSR(derBytes []byte) []byte { - pemBlock := &pem.Block{ - Type: csrPEMBlockType, - Headers: nil, - Bytes: derBytes, - } - out := pem.EncodeToMemory(pemBlock) - return out -} - -// load PEM encoded CSR from file -func loadCSRfromFile(path string) (*x509.CertificateRequest, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("cannot find the next PEM formatted block") - } - if pemBlock.Type != csrPEMBlockType || len(pemBlock.Headers) != 0 { - return nil, errors.New("unmatched type or headers") - } - return x509.ParseCertificateRequest(pemBlock.Bytes) -} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/key.go b/vendor/github.com/micromdm/scep/cmd/scepclient/key.go deleted file mode 100644 index b21c0b1..0000000 --- a/vendor/github.com/micromdm/scep/cmd/scepclient/key.go +++ /dev/null @@ -1,70 +0,0 @@ -package main - -import ( - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "encoding/pem" - "errors" - "io/ioutil" - "os" -) - -const ( - rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" -) - -// create a new RSA private key -func newRSAKey(bits int) (*rsa.PrivateKey, error) { - private, err := rsa.GenerateKey(rand.Reader, bits) - if err != nil { - return nil, err - } - return private, nil -} - -// load key if it exists or create a new one -func loadOrMakeKey(path string, rsaBits int) (*rsa.PrivateKey, error) { - file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) - if err != nil { - if os.IsExist(err) { - return loadKeyFromFile(path) - } - return nil, err - } - defer file.Close() - - // write key - priv, err := newRSAKey(rsaBits) - if err != nil { - return nil, err - } - privBytes := x509.MarshalPKCS1PrivateKey(priv) - pemBlock := &pem.Block{ - Type: rsaPrivateKeyPEMBlockType, - Headers: nil, - Bytes: privBytes, - } - if err = pem.Encode(file, pemBlock); err != nil { - return nil, err - } - return priv, nil -} - -// load a PEM private key from disk -func loadKeyFromFile(path string) (*rsa.PrivateKey, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != rsaPrivateKeyPEMBlockType { - return nil, errors.New("unmatched type or headers") - } - - return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) -} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/release.sh b/vendor/github.com/micromdm/scep/cmd/scepclient/release.sh deleted file mode 100755 index b9954f6..0000000 --- a/vendor/github.com/micromdm/scep/cmd/scepclient/release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -VERSION="0.3.0.0" -NAME=scepclient -OUTPUT=../../build - -echo "Building $NAME version $VERSION" - -mkdir -p ${OUTPUT} - -build() { - echo -n "=> $1-$2: " - GOOS=$1 GOARCH=$2 go build -o ${OUTPUT}/$NAME-$1-$2 -ldflags "-X main.version=$VERSION -X main.gitHash=`git rev-parse HEAD`" ./*.go - du -h ${OUTPUT}/${NAME}-$1-$2 -} - -build "darwin" "amd64" -build "linux" "amd64" diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/scepclient.go b/vendor/github.com/micromdm/scep/cmd/scepclient/scepclient.go deleted file mode 100644 index a319970..0000000 --- a/vendor/github.com/micromdm/scep/cmd/scepclient/scepclient.go +++ /dev/null @@ -1,232 +0,0 @@ -package main - -import ( - "crypto/x509" - "errors" - "flag" - "fmt" - "io/ioutil" - "net/url" - "os" - "path/filepath" - "strings" - - "golang.org/x/net/context" - - "github.com/micromdm/scep/client" - "github.com/micromdm/scep/scep" -) - -// version info -var ( - version = "unreleased" - gitHash = "unknown" -) - -type runCfg struct { - dir string - csrPath string - keyPath string - keyBits int - selfSignPath string - certPath string - cn string - org string - country string - challenge string - serverURL string -} - -func run(cfg runCfg) error { - key, err := loadOrMakeKey(cfg.keyPath, cfg.keyBits) - if err != nil { - return err - } - - opts := &csrOptions{ - cn: cfg.cn, - org: cfg.org, - country: strings.ToUpper(cfg.country), - challenge: cfg.challenge, - key: key, - } - - csr, err := loadOrMakeCSR(cfg.csrPath, opts) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - var self *x509.Certificate - cert, err := loadPEMCertFromFile(cfg.certPath) - if err != nil { - if !os.IsNotExist(err) { - return err - } - s, err := loadOrSign(cfg.selfSignPath, key, csr) - if err != nil { - return err - } - self = s - } - - ctx := context.Background() - var client scepclient.Client - { - client = scepclient.NewClient(cfg.serverURL) - } - - resp, certNum, err := client.GetCACert(ctx) - if err != nil { - return err - } - var certs []*x509.Certificate - { - if certNum > 1 { - certs, err = scep.CACerts(resp) - if err != nil { - return err - } - if len(certs) < 1 { - return fmt.Errorf("no certificates returned") - } - } else { - certs, err = x509.ParseCertificates(resp) - if err != nil { - return err - } - } - } - - var signerCert *x509.Certificate - { - if cert != nil { - signerCert = cert - } else { - signerCert = self - } - } - - var msgType scep.MessageType - { - // TODO validate CA and set UpdateReq if needed - if cert != nil { - msgType = scep.RenewalReq - } else { - msgType = scep.PKCSReq - } - } - - tmpl := &scep.PKIMessage{ - MessageType: msgType, - Recipients: certs, - SignerKey: key, - SignerCert: signerCert, - } - - if cfg.challenge != "" && msgType == scep.PKCSReq { - tmpl.CSRReqMessage = &scep.CSRReqMessage{ - ChallengePassword: cfg.challenge, - } - } - - msg, err := scep.NewCSRRequest(csr, tmpl) - if err != nil { - return err - } - - respBytes, err := client.PKIOperation(ctx, msg.Raw) - if err != nil { - return err - } - respMsg, err := scep.ParsePKIMessage(respBytes) - if err != nil { - return err - } - if err := respMsg.DecryptPKIEnvelope(signerCert, key); err != nil { - fmt.Println(err) - os.Exit(1) - } - - respCert := respMsg.CertRepMessage.Certificate - if err := ioutil.WriteFile(cfg.certPath, pemCert(respCert.Raw), 0666); err != nil { - return err - } - - // remove self signer if used - if self != nil { - if err := os.Remove(cfg.selfSignPath); err != nil { - return err - } - } - - return nil -} - -func validateFlags(keyPath, serverURL string) error { - if keyPath == "" { - return errors.New("must specify private key path") - } - if serverURL == "" { - return errors.New("must specify server-url flag parameter") - } - _, err := url.Parse(serverURL) - if err != nil { - return fmt.Errorf("invalid server-url flag parameter %s", err) - } - return nil -} - -func main() { - // flags - var ( - flVersion = flag.Bool("version", false, "prints version information") - flServerURL = flag.String("server-url", "", "SCEP server url") - flChallengePassword = flag.String("challenge", "", "enforce a challenge password") - flPKeyPath = flag.String("private-key", "", "private key path, if there is no key, scepclient will create one") - flCertPath = flag.String("certificate", "", "certificate path, if there is no key, scepclient will create one") - flKeySize = flag.Int("keySize", 2048, "rsa key size") - flOrg = flag.String("organization", "scep-client", "organization for cert") - flCName = flag.String("cn", "scepclient", "common name for certificate") - flCountry = flag.String("country", "US", "country code in certificate") - ) - flag.Parse() - - // print version information - if *flVersion { - fmt.Printf("scepclient - %v\n", version) - fmt.Printf("git revision - %v\n", gitHash) - os.Exit(0) - } - - if err := validateFlags(*flPKeyPath, *flServerURL); err != nil { - fmt.Println(err) - os.Exit(1) - } - - dir := filepath.Dir(*flPKeyPath) - csrPath := dir + "/csr.pem" - selfSignPath := dir + "/self.pem" - if *flCertPath == "" { - *flCertPath = dir + "/client.pem" - } - - cfg := runCfg{ - dir: dir, - csrPath: csrPath, - keyPath: *flPKeyPath, - keyBits: *flKeySize, - selfSignPath: selfSignPath, - certPath: *flCertPath, - cn: *flCName, - org: *flOrg, - country: *flCountry, - challenge: *flChallengePassword, - serverURL: *flServerURL, - } - - if err := run(cfg); err != nil { - fmt.Println(err) - os.Exit(1) - } -} diff --git a/vendor/github.com/micromdm/scep/cmd/scepserver/release.sh b/vendor/github.com/micromdm/scep/cmd/scepserver/release.sh deleted file mode 100755 index 64d8590..0000000 --- a/vendor/github.com/micromdm/scep/cmd/scepserver/release.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash - -VERSION="0.3.0.0" -NAME=scepserver -OUTPUT=../../build - -echo "Building $NAME version $VERSION" - -mkdir -p ${OUTPUT} - -build() { - echo -n "=> $1-$2: " - GOOS=$1 GOARCH=$2 go build -o ${OUTPUT}/$NAME-$1-$2 -ldflags "-X main.version=$VERSION -X main.gitHash=`git rev-parse HEAD`" ./*.go - du -h ${OUTPUT}/${NAME}-$1-$2 -} - -build "darwin" "amd64" -build "linux" "amd64" diff --git a/vendor/github.com/micromdm/scep/cmd/scepserver/scepserver.go b/vendor/github.com/micromdm/scep/cmd/scepserver/scepserver.go deleted file mode 100644 index b22d48f..0000000 --- a/vendor/github.com/micromdm/scep/cmd/scepserver/scepserver.go +++ /dev/null @@ -1,328 +0,0 @@ -package main - -import ( - "crypto" - "crypto/rand" - "crypto/rsa" - "crypto/sha1" - "crypto/x509" - "crypto/x509/pkix" - "encoding/asn1" - "encoding/pem" - "errors" - "flag" - "fmt" - "math/big" - "net/http" - "os" - "os/signal" - "syscall" - "time" - - "github.com/go-kit/kit/log" - "github.com/micromdm/scep/server" - "golang.org/x/net/context" -) - -// version info -var ( - version = "unreleased" - gitHash = "unknown" -) - -func main() { - var caCMD = flag.NewFlagSet("ca", flag.ExitOnError) - { - if len(os.Args) >= 2 { - if os.Args[1] == "ca" { - status := caMain(caCMD) - os.Exit(status) - } - } - } - - //main flags - var ( - flVersion = flag.Bool("version", false, "prints version information") - flPort = flag.String("port", envString("SCEP_HTTP_LISTEN_PORT", "8080"), "port to listen on") - flDepotPath = flag.String("depot", envString("SCEP_FILE_DEPOT", "depot"), "path to ca folder") - flChallengePassword = flag.String("challenge", envString("SCEP_CHALLENGE_PASSWORD", ""), "enforce a challenge password") - ) - flag.Usage = func() { - flag.PrintDefaults() - - fmt.Println("usage: scep [] []") - fmt.Println(" ca create/manage a CA") - fmt.Println("type --help to see usage for each subcommand") - } - flag.Parse() - - // print version information - if *flVersion { - fmt.Printf("scep - %v\n", version) - fmt.Printf("git revision - %v\n", gitHash) - os.Exit(0) - } - port := ":" + *flPort - ctx := context.Background() - - var logger log.Logger - { - logger = log.NewLogfmtLogger(os.Stderr) - logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) - logger = log.NewContext(logger).With("caller", log.DefaultCaller) - } - - var err error - var depot scepserver.Depot // cert storage - { - depot, err = scepserver.NewFileDepot(*flDepotPath) - if err != nil { - logger.Log("err", err) - os.Exit(1) - } - } - - var svc scepserver.Service // scep service - { - svcOptions := []scepserver.ServiceOption{ - scepserver.ChallengePassword(*flChallengePassword), - } - svc, err = scepserver.NewService(depot, svcOptions...) - if err != nil { - logger.Log("err", err) - os.Exit(1) - } - svc = scepserver.NewLoggingService(log.NewContext(logger).With("component", "service"), svc) - } - - var h http.Handler // http handler - { - h = scepserver.ServiceHandler(ctx, svc, log.NewContext(logger).With("component", "http")) - } - - // start http server - errs := make(chan error, 2) - go func() { - logger.Log("transport", "http", "address", port, "msg", "listening") - errs <- http.ListenAndServe(port, h) - }() - go func() { - c := make(chan os.Signal) - signal.Notify(c, syscall.SIGINT) - errs <- fmt.Errorf("%s", <-c) - }() - - logger.Log("terminated", <-errs) -} - -func caMain(cmd *flag.FlagSet) int { - var ( - flDepotPath = cmd.String("depot", "depot", "path to ca folder") - flInit = cmd.Bool("init", false, "create a new CA") - flYears = cmd.Int("years", 10, "default CA years") - flKeySize = cmd.Int("keySize", 4096, "rsa key size") - flOrg = cmd.String("organization", "scep-ca", "organization for CA cert") - flPassword = cmd.String("key-password", "", "password to store rsa key") - flCountry = cmd.String("country", "US", "country for CA cert") - ) - cmd.Parse(os.Args[2:]) - if *flInit { - fmt.Println("Initializing new CA") - key, err := createKey(*flKeySize, []byte(*flPassword), *flDepotPath) - if err != nil { - fmt.Println(err) - return 1 - } - if err := createCertificateAuthority(key, *flYears, *flOrg, *flCountry, *flDepotPath); err != nil { - fmt.Println(err) - return 1 - } - } - - return 0 -} - -// create a key, save it to depot and return it for further usage -func createKey(bits int, password []byte, depot string) (*rsa.PrivateKey, error) { - key, err := newRSAKey(bits) - if err != nil { - return nil, err - } - e, err := encryptedKey(key, password) - if err != nil { - return nil, err - } - - if err := os.MkdirAll(depot, 0755); err != nil { - return nil, err - } - - name := depot + "/" + "ca.key" - file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0400) - if err != nil { - return nil, err - } - defer file.Close() - - if _, err := file.Write(e); err != nil { - file.Close() - os.Remove(name) - return nil, err - } - - return key, nil -} - -func createCertificateAuthority(key *rsa.PrivateKey, years int, organization string, country string, depot string) error { - var ( - authPkixName = pkix.Name{ - Country: nil, - Organization: nil, - OrganizationalUnit: []string{"SCEP CA"}, - Locality: nil, - Province: nil, - StreetAddress: nil, - PostalCode: nil, - SerialNumber: "", - CommonName: "", - } - // Build CA based on RFC5280 - authTemplate = x509.Certificate{ - SerialNumber: big.NewInt(1), - Subject: authPkixName, - // NotBefore is set to be 10min earlier to fix gap on time difference in cluster - NotBefore: time.Now().Add(-600).UTC(), - NotAfter: time.Time{}, - // Used for certificate signing only - KeyUsage: x509.KeyUsageCertSign, - - ExtKeyUsage: nil, - UnknownExtKeyUsage: nil, - - // activate CA - BasicConstraintsValid: true, - IsCA: true, - // Not allow any non-self-issued intermediate CA - MaxPathLen: 0, - - // 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey - // (excluding the tag, length, and number of unused bits) - // **SHOULD** be filled in later - SubjectKeyId: nil, - - // Subject Alternative Name - DNSNames: nil, - - PermittedDNSDomainsCritical: false, - PermittedDNSDomains: nil, - } - ) - - subjectKeyID, err := generateSubjectKeyID(&key.PublicKey) - if err != nil { - return err - } - authTemplate.SubjectKeyId = subjectKeyID - authTemplate.NotAfter = time.Now().AddDate(years, 0, 0).UTC() - authTemplate.Subject.Country = []string{country} - authTemplate.Subject.Organization = []string{organization} - crtBytes, err := x509.CreateCertificate(rand.Reader, &authTemplate, &authTemplate, &key.PublicKey, key) - if err != nil { - return err - } - - name := depot + "/" + "ca.pem" - file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0400) - if err != nil { - return err - } - defer file.Close() - - if _, err := file.Write(pemCert(crtBytes)); err != nil { - file.Close() - os.Remove(name) - return err - } - - return nil -} - -const ( - rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" - certificatePEMBlockType = "CERTIFICATE" -) - -// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. -type rsaPublicKey struct { - N *big.Int - E int -} - -// GenerateSubjectKeyID generates SubjectKeyId used in Certificate -// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey -func generateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { - var pubBytes []byte - var err error - switch pub := pub.(type) { - case *rsa.PublicKey: - pubBytes, err = asn1.Marshal(rsaPublicKey{ - N: pub.N, - E: pub.E, - }) - if err != nil { - return nil, err - } - default: - return nil, errors.New("only RSA public key is supported") - } - - hash := sha1.Sum(pubBytes) - - return hash[:], nil -} - -func pemCert(derBytes []byte) []byte { - pemBlock := &pem.Block{ - Type: certificatePEMBlockType, - Headers: nil, - Bytes: derBytes, - } - out := pem.EncodeToMemory(pemBlock) - return out -} - -// protect an rsa key with a password -func encryptedKey(key *rsa.PrivateKey, password []byte) ([]byte, error) { - privBytes := x509.MarshalPKCS1PrivateKey(key) - privPEMBlock, err := x509.EncryptPEMBlock(rand.Reader, rsaPrivateKeyPEMBlockType, privBytes, password, x509.PEMCipher3DES) - if err != nil { - return nil, err - } - - out := pem.EncodeToMemory(privPEMBlock) - return out, nil -} - -// create a new RSA private key -func newRSAKey(bits int) (*rsa.PrivateKey, error) { - private, err := rsa.GenerateKey(rand.Reader, bits) - if err != nil { - return nil, err - } - return private, nil -} - -func envString(key, def string) string { - if env := os.Getenv(key); env != "" { - return env - } - return def -} - -func envBool(key string) bool { - if env := os.Getenv(key); env == "true" { - return true - } - return false -} diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/.gitignore b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/.gitignore deleted file mode 100644 index daf913b..0000000 --- a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/LICENSE b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/LICENSE deleted file mode 100644 index 75f3209..0000000 --- a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Andrew Smith - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/README.md b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/README.md deleted file mode 100644 index 32f2159..0000000 --- a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# pkcs7 - -Original at https://github.com/fullsailor/pkcs7 -This package is internal to the scep repo and is meant to be replaced with the upstream version at a later time. - -[![GoDoc](https://godoc.org/github.com/fullsailor/pkcs7?status.svg)](https://godoc.org/github.com/fullsailor/pkcs7) - -pkcs7 implements parsing and creating signed and enveloped messages. - -- Documentation on [GoDoc](http://godoc.org/github.com/fullsailor/pkcs7) diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber.go deleted file mode 100644 index 45924ba..0000000 --- a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber.go +++ /dev/null @@ -1,228 +0,0 @@ -package pkcs7 - -import ( - "bytes" - "errors" -) - -var encodeIndent = 0 - -type asn1Object interface { - EncodeTo(writer *bytes.Buffer) error -} - -type asn1Structured struct { - tagBytes []byte - content []asn1Object -} - -func (s asn1Structured) EncodeTo(out *bytes.Buffer) error { - //fmt.Printf("%s--> tag: % X\n", strings.Repeat("| ", encodeIndent), s.tagBytes) - encodeIndent++ - inner := new(bytes.Buffer) - for _, obj := range s.content { - err := obj.EncodeTo(inner) - if err != nil { - return err - } - } - encodeIndent-- - out.Write(s.tagBytes) - encodeLength(out, inner.Len()) - out.Write(inner.Bytes()) - return nil -} - -type asn1Primitive struct { - tagBytes []byte - length int - content []byte -} - -func (p asn1Primitive) EncodeTo(out *bytes.Buffer) error { - _, err := out.Write(p.tagBytes) - if err != nil { - return err - } - if err = encodeLength(out, p.length); err != nil { - return err - } - //fmt.Printf("%s--> tag: % X length: %d\n", strings.Repeat("| ", encodeIndent), p.tagBytes, p.length) - //fmt.Printf("%s--> content length: %d\n", strings.Repeat("| ", encodeIndent), len(p.content)) - out.Write(p.content) - - return nil -} - -func ber2der(ber []byte) ([]byte, error) { - if len(ber) == 0 { - return nil, errors.New("ber2der: input ber is empty") - } - //fmt.Printf("--> ber2der: Transcoding %d bytes\n", len(ber)) - out := new(bytes.Buffer) - - obj, _, err := readObject(ber, 0) - if err != nil { - return nil, err - } - obj.EncodeTo(out) - - // if offset < len(ber) { - // return nil, fmt.Errorf("ber2der: Content longer than expected. Got %d, expected %d", offset, len(ber)) - //} - - return out.Bytes(), nil -} - -// encodes lengths that are longer than 127 into string of bytes -func marshalLongLength(out *bytes.Buffer, i int) (err error) { - n := lengthLength(i) - - for ; n > 0; n-- { - err = out.WriteByte(byte(i >> uint((n-1)*8))) - if err != nil { - return - } - } - - return nil -} - -// computes the byte length of an encoded length value -func lengthLength(i int) (numBytes int) { - numBytes = 1 - for i > 255 { - numBytes++ - i >>= 8 - } - return -} - -// encodes the length in DER format -// If the length fits in 7 bits, the value is encoded directly. -// -// Otherwise, the number of bytes to encode the length is first determined. -// This number is likely to be 4 or less for a 32bit length. This number is -// added to 0x80. The length is encoded in big endian encoding follow after -// -// Examples: -// length | byte 1 | bytes n -// 0 | 0x00 | - -// 120 | 0x78 | - -// 200 | 0x81 | 0xC8 -// 500 | 0x82 | 0x01 0xF4 -// -func encodeLength(out *bytes.Buffer, length int) (err error) { - if length >= 128 { - l := lengthLength(length) - err = out.WriteByte(0x80 | byte(l)) - if err != nil { - return - } - err = marshalLongLength(out, length) - if err != nil { - return - } - } else { - err = out.WriteByte(byte(length)) - if err != nil { - return - } - } - return -} - -func readObject(ber []byte, offset int) (asn1Object, int, error) { - //fmt.Printf("\n====> Starting readObject at offset: %d\n\n", offset) - tagStart := offset - b := ber[offset] - offset++ - tag := b & 0x1F // last 5 bits - if tag == 0x1F { - tag = 0 - for ber[offset] >= 0x80 { - tag = tag*128 + ber[offset] - 0x80 - offset++ - } - tag = tag*128 + ber[offset] - 0x80 - offset++ - } - tagEnd := offset - - kind := b & 0x20 - /* - if kind == 0 { - fmt.Print("--> Primitive\n") - } else { - fmt.Print("--> Constructed\n") - } - */ - // read length - var length int - l := ber[offset] - offset++ - hack := 0 - if l > 0x80 { - numberOfBytes := (int)(l & 0x7F) - if numberOfBytes > 4 { // int is only guaranteed to be 32bit - return nil, 0, errors.New("ber2der: BER tag length too long") - } - if numberOfBytes == 4 && (int)(ber[offset]) > 0x7F { - return nil, 0, errors.New("ber2der: BER tag length is negative") - } - if 0x0 == (int)(ber[offset]) { - return nil, 0, errors.New("ber2der: BER tag length has leading zero") - } - //fmt.Printf("--> (compute length) indicator byte: %x\n", l) - //fmt.Printf("--> (compute length) length bytes: % X\n", ber[offset:offset+numberOfBytes]) - for i := 0; i < numberOfBytes; i++ { - length = length*256 + (int)(ber[offset]) - offset++ - } - } else if l == 0x80 { - // find length by searching content - markerIndex := bytes.LastIndex(ber[offset:], []byte{0x0, 0x0}) - if markerIndex == -1 { - return nil, 0, errors.New("ber2der: Invalid BER format") - } - length = markerIndex - hack = 2 - //fmt.Printf("--> (compute length) marker found at offset: %d\n", markerIndex+offset) - } else { - length = (int)(l) - } - - //fmt.Printf("--> length : %d\n", length) - contentEnd := offset + length - if contentEnd > len(ber) { - return nil, 0, errors.New("ber2der: BER tag length is more than available data") - } - //fmt.Printf("--> content start : %d\n", offset) - //fmt.Printf("--> content end : %d\n", contentEnd) - //fmt.Printf("--> content : % X\n", ber[offset:contentEnd]) - var obj asn1Object - if kind == 0 { - obj = asn1Primitive{ - tagBytes: ber[tagStart:tagEnd], - length: length, - content: ber[offset:contentEnd], - } - } else { - var subObjects []asn1Object - for offset < contentEnd { - var subObj asn1Object - var err error - subObj, offset, err = readObject(ber[:contentEnd], offset) - if err != nil { - return nil, 0, err - } - subObjects = append(subObjects, subObj) - } - obj = asn1Structured{ - tagBytes: ber[tagStart:tagEnd], - content: subObjects, - } - } - - return obj, contentEnd + hack, nil -} diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber_test.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber_test.go deleted file mode 100644 index 32dc88a..0000000 --- a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package pkcs7 - -import ( - "bytes" - "encoding/asn1" - "strings" - "testing" -) - -func TestBer2Der(t *testing.T) { - // indefinite length fixture - ber := []byte{0x30, 0x80, 0x02, 0x01, 0x01, 0x00, 0x00} - expected := []byte{0x30, 0x03, 0x02, 0x01, 0x01} - der, err := ber2der(ber) - if err != nil { - t.Fatalf("ber2der failed with error: %v", err) - } - if bytes.Compare(der, expected) != 0 { - t.Errorf("ber2der result did not match.\n\tExpected: % X\n\tActual: % X", expected, der) - } - - if der2, err := ber2der(der); err != nil { - t.Errorf("ber2der on DER bytes failed with error: %v", err) - } else { - if !bytes.Equal(der, der2) { - t.Error("ber2der is not idempotent") - } - } - var thing struct { - Number int - } - rest, err := asn1.Unmarshal(der, &thing) - if err != nil { - t.Errorf("Cannot parse resulting DER because: %v", err) - } else if len(rest) > 0 { - t.Errorf("Resulting DER has trailing data: % X", rest) - } -} - -func TestBer2Der_Negatives(t *testing.T) { - fixtures := []struct { - Input []byte - ErrorContains string - }{ - {[]byte{0x30, 0x85}, "length too long"}, - {[]byte{0x30, 0x84, 0x80, 0x0, 0x0, 0x0}, "length is negative"}, - {[]byte{0x30, 0x82, 0x0, 0x1}, "length has leading zero"}, - {[]byte{0x30, 0x80, 0x1, 0x2}, "Invalid BER format"}, - {[]byte{0x30, 0x03, 0x01, 0x02}, "length is more than available data"}, - } - - for _, fixture := range fixtures { - _, err := ber2der(fixture.Input) - if err == nil { - t.Errorf("No error thrown. Expected: %s", fixture.ErrorContains) - } - if !strings.Contains(err.Error(), fixture.ErrorContains) { - t.Errorf("Unexpected error thrown.\n\tExpected: /%s/\n\tActual: %s", fixture.ErrorContains, err.Error()) - } - } -} diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7.go deleted file mode 100644 index 82024d2..0000000 --- a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7.go +++ /dev/null @@ -1,788 +0,0 @@ -// Package pkcs7 implements parsing and generation of some PKCS#7 structures. -package pkcs7 - -import ( - "bytes" - "crypto" - "crypto/aes" - "crypto/cipher" - "crypto/des" - "crypto/hmac" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/asn1" - "errors" - "fmt" - "math/big" - "sort" - "time" - - _ "crypto/sha1" // for crypto.SHA1 -) - -// PKCS7 Represents a PKCS7 structure -type PKCS7 struct { - Content []byte - Certificates []*x509.Certificate - CRLs []pkix.CertificateList - Signers []signerInfo - raw interface{} -} - -type contentInfo struct { - ContentType asn1.ObjectIdentifier - Content asn1.RawValue `asn1:"explicit,optional,tag:0"` -} - -// ErrUnsupportedContentType is returned when a PKCS7 content is not supported. -// Currently only Data (1.2.840.113549.1.7.1), Signed Data (1.2.840.113549.1.7.2), -// and Enveloped Data are supported (1.2.840.113549.1.7.3) -var ErrUnsupportedContentType = errors.New("pkcs7: cannot parse data: unimplemented content type") - -type unsignedData []byte - -var ( - oidData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 1} - oidSignedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2} - oidEnvelopedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 3} - oidSignedAndEnvelopedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 4} - oidDigestedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 5} - oidEncryptedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 6} - oidAttributeContentType = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 3} - oidAttributeMessageDigest = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 4} - oidAttributeSigningTime = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 5} -) - -type signedData struct { - Version int `asn1:"default:1"` - DigestAlgorithmIdentifiers []pkix.AlgorithmIdentifier `asn1:"set"` - ContentInfo contentInfo - Certificates rawCertificates `asn1:"optional,tag:0"` - CRLs []pkix.CertificateList `asn1:"optional,tag:1"` - SignerInfos []signerInfo `asn1:"set"` -} - -type rawCertificates struct { - Raw asn1.RawContent -} - -type envelopedData struct { - Version int - RecipientInfos []recipientInfo `asn1:"set"` - EncryptedContentInfo encryptedContentInfo -} - -type recipientInfo struct { - Version int - IssuerAndSerialNumber issuerAndSerial - KeyEncryptionAlgorithm pkix.AlgorithmIdentifier - EncryptedKey []byte -} - -type encryptedContentInfo struct { - ContentType asn1.ObjectIdentifier - ContentEncryptionAlgorithm pkix.AlgorithmIdentifier - EncryptedContent asn1.RawValue `asn1:"tag:0,optional,explicit"` -} - -type attribute struct { - Type asn1.ObjectIdentifier - Value asn1.RawValue `asn1:"set"` -} - -type issuerAndSerial struct { - IssuerName asn1.RawValue - SerialNumber *big.Int -} - -// MessageDigestMismatchError is returned when the signer data digest does not -// match the computed digest for the contained content -type MessageDigestMismatchError struct { - ExpectedDigest []byte - ActualDigest []byte -} - -func (err *MessageDigestMismatchError) Error() string { - return fmt.Sprintf("pkcs7: Message digest mismatch\n\tExpected: %X\n\tActual : %X", err.ExpectedDigest, err.ActualDigest) -} - -type signerInfo struct { - Version int `asn1:"default:1"` - IssuerAndSerialNumber issuerAndSerial - DigestAlgorithm pkix.AlgorithmIdentifier - AuthenticatedAttributes []attribute `asn1:"optional,tag:0"` - DigestEncryptionAlgorithm pkix.AlgorithmIdentifier - EncryptedDigest []byte - UnauthenticatedAttributes []attribute `asn1:"optional,tag:1"` -} - -// Parse decodes a DER encoded PKCS7 package -func Parse(data []byte) (p7 *PKCS7, err error) { - if len(data) == 0 { - return nil, errors.New("pkcs7: input data is empty") - } - var info contentInfo - der, err := ber2der(data) - if err != nil { - return nil, err - } - rest, err := asn1.Unmarshal(der, &info) - if len(rest) > 0 { - err = asn1.SyntaxError{Msg: "trailing data"} - return - } - if err != nil { - return - } - - // fmt.Printf("--> Content Type: %s", info.ContentType) - switch { - case info.ContentType.Equal(oidSignedData): - return parseSignedData(info.Content.Bytes) - case info.ContentType.Equal(oidEnvelopedData): - return parseEnvelopedData(info.Content.Bytes) - } - return nil, ErrUnsupportedContentType -} - -func parseSignedData(data []byte) (*PKCS7, error) { - var sd signedData - asn1.Unmarshal(data, &sd) - certs, err := sd.Certificates.Parse() - if err != nil { - return nil, err - } - // fmt.Printf("--> Signed Data Version %d\n", sd.Version) - - var compound asn1.RawValue - var content unsignedData - - // The Content.Bytes maybe empty on PKI responses. - if len(sd.ContentInfo.Content.Bytes) > 0 { - if _, err := asn1.Unmarshal(sd.ContentInfo.Content.Bytes, &compound); err != nil { - return nil, err - } - } - // Compound octet string - if compound.IsCompound { - if _, err = asn1.Unmarshal(compound.Bytes, &content); err != nil { - return nil, err - } - } else { - // assuming this is tag 04 - content = compound.Bytes - } - return &PKCS7{ - Content: content, - Certificates: certs, - CRLs: sd.CRLs, - Signers: sd.SignerInfos, - raw: sd}, nil -} - -func (raw rawCertificates) Parse() ([]*x509.Certificate, error) { - if len(raw.Raw) == 0 { - return nil, nil - } - - var val asn1.RawValue - if _, err := asn1.Unmarshal(raw.Raw, &val); err != nil { - return nil, err - } - - return x509.ParseCertificates(val.Bytes) -} - -func parseEnvelopedData(data []byte) (*PKCS7, error) { - var ed envelopedData - if _, err := asn1.Unmarshal(data, &ed); err != nil { - return nil, err - } - return &PKCS7{ - raw: ed, - }, nil -} - -// Verify checks the signatures of a PKCS7 object -// WARNING: Verify does not check signing time or verify certificate chains at -// this time. -func (p7 *PKCS7) Verify() (err error) { - if len(p7.Signers) == 0 { - return errors.New("pkcs7: Message has no signers") - } - for _, signer := range p7.Signers { - if err := verifySignature(p7, signer); err != nil { - return err - } - } - return nil -} - -func verifySignature(p7 *PKCS7, signer signerInfo) error { - if len(signer.AuthenticatedAttributes) > 0 { - // TODO(fullsailor): First check the content type match - var digest []byte - err := unmarshalAttribute(signer.AuthenticatedAttributes, oidAttributeMessageDigest, &digest) - if err != nil { - return err - } - hash, err := getHashForOID(signer.DigestAlgorithm.Algorithm) - if err != nil { - return err - } - h := hash.New() - h.Write(p7.Content) - computed := h.Sum(nil) - if !hmac.Equal(digest, computed) { - return &MessageDigestMismatchError{ - ExpectedDigest: digest, - ActualDigest: computed, - } - } - } - cert := getCertFromCertsByIssuerAndSerial(p7.Certificates, signer.IssuerAndSerialNumber) - if cert == nil { - return errors.New("pkcs7: No certificate for signer") - } - // TODO(fullsailor): Optionally verify certificate chain - // TODO(fullsailor): Optionally verify signingTime against certificate NotAfter/NotBefore - encodedAttributes, err := marshalAttributes(signer.AuthenticatedAttributes) - if err != nil { - return err - } - algo := x509.SHA1WithRSA - return cert.CheckSignature(algo, encodedAttributes, signer.EncryptedDigest) -} - -func marshalAttributes(attrs []attribute) ([]byte, error) { - encodedAttributes, err := asn1.Marshal(struct { - A []attribute `asn1:"set"` - }{A: attrs}) - if err != nil { - return nil, err - } - - // Remove the leading sequence octets - var raw asn1.RawValue - asn1.Unmarshal(encodedAttributes, &raw) - return raw.Bytes, nil -} - -var ( - oidDigestAlgorithmSHA1 = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26} - oidEncryptionAlgorithmRSA = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1} -) - -func getCertFromCertsByIssuerAndSerial(certs []*x509.Certificate, ias issuerAndSerial) *x509.Certificate { - for _, cert := range certs { - if isCertMatchForIssuerAndSerial(cert, ias) { - return cert - } - } - return nil -} - -func getHashForOID(oid asn1.ObjectIdentifier) (crypto.Hash, error) { - switch { - case oid.Equal(oidDigestAlgorithmSHA1): - return crypto.SHA1, nil - } - return crypto.Hash(0), ErrUnsupportedAlgorithm -} - -// GetOnlySigner returns an x509.Certificate for the first signer of the signed -// data payload. If there are more or less than one signer, nil is returned -func (p7 *PKCS7) GetOnlySigner() *x509.Certificate { - if len(p7.Signers) != 1 { - return nil - } - signer := p7.Signers[0] - return getCertFromCertsByIssuerAndSerial(p7.Certificates, signer.IssuerAndSerialNumber) -} - -// ErrUnsupportedAlgorithm tells you when our quick dev assumptions have failed -var ErrUnsupportedAlgorithm = errors.New("pkcs7: cannot decrypt data: only RSA, DES, DES-EDE3 and AES-256-CBC supported") - -// ErrNotEncryptedContent is returned when attempting to Decrypt data that is not encrypted data -var ErrNotEncryptedContent = errors.New("pkcs7: content data is a decryptable data type") - -// Decrypt decrypts encrypted content info for recipient cert and private key -func (p7 *PKCS7) Decrypt(cert *x509.Certificate, pk crypto.PrivateKey) ([]byte, error) { - data, ok := p7.raw.(envelopedData) - if !ok { - return nil, ErrNotEncryptedContent - } - recipient := selectRecipientForCertificate(data.RecipientInfos, cert) - if recipient.EncryptedKey == nil { - return nil, errors.New("pkcs7: no enveloped recipient for provided certificate") - } - if priv := pk.(*rsa.PrivateKey); priv != nil { - var contentKey []byte - contentKey, err := rsa.DecryptPKCS1v15(rand.Reader, priv, recipient.EncryptedKey) - if err != nil { - return nil, err - } - return data.EncryptedContentInfo.decrypt(contentKey) - } - fmt.Printf("Unsupported Private Key: %v\n", pk) - return nil, ErrUnsupportedAlgorithm -} - -var oidEncryptionAlgorithmDESCBC = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 7} -var oidEncryptionAlgorithmDESEDE3CBC = asn1.ObjectIdentifier{1, 2, 840, 113549, 3, 7} -var oidEncryptionAlgorithmAES256CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 42} - -func (eci encryptedContentInfo) decrypt(key []byte) ([]byte, error) { - alg := eci.ContentEncryptionAlgorithm.Algorithm - if !alg.Equal(oidEncryptionAlgorithmDESCBC) && !alg.Equal(oidEncryptionAlgorithmDESEDE3CBC) && !alg.Equal(oidEncryptionAlgorithmAES256CBC) { - fmt.Printf("Unsupported Content Encryption Algorithm: %s\n", alg) - return nil, ErrUnsupportedAlgorithm - } - - // EncryptedContent can either be constructed of multple OCTET STRINGs - // or _be_ a tagged OCTET STRING - var cyphertext []byte - if eci.EncryptedContent.IsCompound { - // Complex case to concat all of the children OCTET STRINGs - var buf bytes.Buffer - cypherbytes := eci.EncryptedContent.Bytes - for { - var part []byte - cypherbytes, _ = asn1.Unmarshal(cypherbytes, &part) - buf.Write(part) - if cypherbytes == nil { - break - } - } - cyphertext = buf.Bytes() - } else { - // Simple case, the bytes _are_ the cyphertext - cyphertext = eci.EncryptedContent.Bytes - } - - var block cipher.Block - var err error - - switch { - case alg.Equal(oidEncryptionAlgorithmDESCBC): - block, err = des.NewCipher(key) - case alg.Equal(oidEncryptionAlgorithmDESEDE3CBC): - block, err = des.NewTripleDESCipher(key) - case alg.Equal(oidEncryptionAlgorithmAES256CBC): - block, err = aes.NewCipher(key) - } - if err != nil { - return nil, err - } - - iv := eci.ContentEncryptionAlgorithm.Parameters.Bytes - if len(iv) != block.BlockSize() { - return nil, errors.New("pkcs7: encryption algorithm parameters are malformed") - } - mode := cipher.NewCBCDecrypter(block, iv) - plaintext := make([]byte, len(cyphertext)) - mode.CryptBlocks(plaintext, cyphertext) - if plaintext, err = unpad(plaintext, mode.BlockSize()); err != nil { - return nil, err - } - return plaintext, nil -} - -func selectRecipientForCertificate(recipients []recipientInfo, cert *x509.Certificate) recipientInfo { - for _, recp := range recipients { - if isCertMatchForIssuerAndSerial(cert, recp.IssuerAndSerialNumber) { - return recp - } - } - return recipientInfo{} -} - -func isCertMatchForIssuerAndSerial(cert *x509.Certificate, ias issuerAndSerial) bool { - return cert.SerialNumber.Cmp(ias.SerialNumber) == 0 && bytes.Compare(cert.RawIssuer, ias.IssuerName.FullBytes) == 0 -} - -func pad(data []byte, blocklen int) ([]byte, error) { - if blocklen < 1 { - return nil, fmt.Errorf("invalid blocklen %d", blocklen) - } - padlen := blocklen - (len(data) % blocklen) - if padlen == 0 { - padlen = blocklen - } - pad := bytes.Repeat([]byte{byte(padlen)}, padlen) - return append(data, pad...), nil -} - -func unpad(data []byte, blocklen int) ([]byte, error) { - if blocklen < 1 { - return nil, fmt.Errorf("invalid blocklen %d", blocklen) - } - if len(data)%blocklen != 0 || len(data) == 0 { - return nil, fmt.Errorf("invalid data len %d", len(data)) - } - - // the last byte is the length of padding - padlen := int(data[len(data)-1]) - - // check padding integrity, all bytes should be the same - pad := data[len(data)-padlen:] - for _, padbyte := range pad { - if padbyte != byte(padlen) { - return nil, errors.New("invalid padding") - } - } - - return data[:len(data)-padlen], nil -} - -func unmarshalAttribute(attrs []attribute, attributeType asn1.ObjectIdentifier, out interface{}) error { - for _, attr := range attrs { - if attr.Type.Equal(attributeType) { - _, err := asn1.Unmarshal(attr.Value.Bytes, out) - return err - } - } - return errors.New("pkcs7: attribute type not in attributes") -} - -// UnmarshalSignedAttribute decodes a single attribute from the signer info -func (p7 *PKCS7) UnmarshalSignedAttribute(attributeType asn1.ObjectIdentifier, out interface{}) error { - sd, ok := p7.raw.(signedData) - if !ok { - return errors.New("pkcs7: payload is not signedData content") - } - if len(sd.SignerInfos) < 1 { - return errors.New("pkcs7: payload has no signers") - } - attributes := sd.SignerInfos[0].AuthenticatedAttributes - return unmarshalAttribute(attributes, attributeType, out) -} - -// SignedData is an opaque data structure for creating signed data payloads -type SignedData struct { - sd signedData - certs []*x509.Certificate - messageDigest []byte -} - -// Attribute represents a key value pair attribute. Value must be marshalable byte -// `encoding/asn1` -type Attribute struct { - Type asn1.ObjectIdentifier - Value interface{} -} - -// SignerInfoConfig are optional values to include when adding a signer -type SignerInfoConfig struct { - ExtraSignedAttributes []Attribute -} - -// NewSignedData initializes a SignedData with content -func NewSignedData(data []byte) (*SignedData, error) { - content, err := asn1.Marshal(data) - if err != nil { - return nil, err - } - ci := contentInfo{ - ContentType: oidData, - Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: content, IsCompound: true}, - } - digAlg := pkix.AlgorithmIdentifier{ - Algorithm: oidDigestAlgorithmSHA1, - } - h := crypto.SHA1.New() - h.Write(data) - md := h.Sum(nil) - sd := signedData{ - ContentInfo: ci, - Version: 1, - DigestAlgorithmIdentifiers: []pkix.AlgorithmIdentifier{digAlg}, - } - return &SignedData{sd: sd, messageDigest: md}, nil -} - -type attributes struct { - types []asn1.ObjectIdentifier - values []interface{} -} - -// Add adds the attribute, maintaining insertion order -func (attrs *attributes) Add(attrType asn1.ObjectIdentifier, value interface{}) { - attrs.types = append(attrs.types, attrType) - attrs.values = append(attrs.values, value) -} - -type sortableAttribute struct { - SortKey []byte - Attribute attribute -} - -type attributeSet []sortableAttribute - -func (sa attributeSet) Len() int { - return len(sa) -} - -func (sa attributeSet) Less(i, j int) bool { - return bytes.Compare(sa[i].SortKey, sa[j].SortKey) < 0 -} - -func (sa attributeSet) Swap(i, j int) { - sa[i], sa[j] = sa[j], sa[i] -} - -func (sa attributeSet) Attributes() []attribute { - attrs := make([]attribute, len(sa)) - for i, attr := range sa { - attrs[i] = attr.Attribute - } - return attrs -} - -func (attrs *attributes) ForMarshaling() ([]attribute, error) { - sortables := make(attributeSet, len(attrs.types)) - for i := range sortables { - attrType := attrs.types[i] - attrValue := attrs.values[i] - asn1Value, err := asn1.Marshal(attrValue) - if err != nil { - return nil, err - } - attr := attribute{ - Type: attrType, - Value: asn1.RawValue{Tag: 17, IsCompound: true, Bytes: asn1Value}, // 17 == SET tag - } - encoded, err := asn1.Marshal(attr) - if err != nil { - return nil, err - } - sortables[i] = sortableAttribute{ - SortKey: encoded, - Attribute: attr, - } - } - sort.Sort(sortables) - return sortables.Attributes(), nil -} - -// AddSigner signs attributes about the content and adds certificate to payload -func (sd *SignedData) AddSigner(cert *x509.Certificate, pkey crypto.PrivateKey, config SignerInfoConfig) error { - attrs := &attributes{} - attrs.Add(oidAttributeContentType, sd.sd.ContentInfo.ContentType) - attrs.Add(oidAttributeMessageDigest, sd.messageDigest) - attrs.Add(oidAttributeSigningTime, time.Now()) - for _, attr := range config.ExtraSignedAttributes { - attrs.Add(attr.Type, attr.Value) - } - finalAttrs, err := attrs.ForMarshaling() - if err != nil { - return err - } - signature, err := signAttributes(finalAttrs, pkey, crypto.SHA1) - if err != nil { - return err - } - - ias, err := cert2issuerAndSerial(cert) - if err != nil { - return err - } - - signer := signerInfo{ - AuthenticatedAttributes: finalAttrs, - DigestAlgorithm: pkix.AlgorithmIdentifier{Algorithm: oidDigestAlgorithmSHA1}, - DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{Algorithm: oidEncryptionAlgorithmRSA}, - IssuerAndSerialNumber: ias, - EncryptedDigest: signature, - Version: 1, - } - // create signature of signed attributes - sd.certs = append(sd.certs, cert) - sd.sd.SignerInfos = append(sd.sd.SignerInfos, signer) - return nil -} - -// AddCertificate adds the certificate to the payload. Useful for parent certificates -func (sd *SignedData) AddCertificate(cert *x509.Certificate) { - sd.certs = append(sd.certs, cert) -} - -// Finish marshals the content and its signers -func (sd *SignedData) Finish() ([]byte, error) { - sd.sd.Certificates = marshalCertificates(sd.certs) - inner, err := asn1.Marshal(sd.sd) - if err != nil { - return nil, err - } - outer := contentInfo{ - ContentType: oidSignedData, - Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: inner, IsCompound: true}, - } - return asn1.Marshal(outer) -} - -func cert2issuerAndSerial(cert *x509.Certificate) (issuerAndSerial, error) { - var ias issuerAndSerial - // The issuer RDNSequence has to match exactly the sequence in the certificate - // We cannot use cert.Issuer.ToRDNSequence() here since it mangles the sequence - ias.IssuerName = asn1.RawValue{FullBytes: cert.RawIssuer} - ias.SerialNumber = cert.SerialNumber - - return ias, nil -} - -// signs the DER encoded form of the attributes with the private key -func signAttributes(attrs []attribute, pkey crypto.PrivateKey, hash crypto.Hash) ([]byte, error) { - attrBytes, err := marshalAttributes(attrs) - if err != nil { - return nil, err - } - h := hash.New() - h.Write(attrBytes) - hashed := h.Sum(nil) - switch priv := pkey.(type) { - case *rsa.PrivateKey: - return rsa.SignPKCS1v15(rand.Reader, priv, crypto.SHA1, hashed) - } - return nil, ErrUnsupportedAlgorithm -} - -// concats and wraps the certificates in the RawValue structure -func marshalCertificates(certs []*x509.Certificate) rawCertificates { - var buf bytes.Buffer - for _, cert := range certs { - buf.Write(cert.Raw) - } - rawCerts, _ := marshalCertificateBytes(buf.Bytes()) - return rawCerts -} - -// Even though, the tag & length are stripped out during marshalling the -// RawContent, we have to encode it into the RawContent. If its missing, -// then `asn1.Marshal()` will strip out the certificate wrapper instead. -func marshalCertificateBytes(certs []byte) (rawCertificates, error) { - var val = asn1.RawValue{Bytes: certs, Class: 2, Tag: 0, IsCompound: true} - b, err := asn1.Marshal(val) - if err != nil { - return rawCertificates{}, err - } - return rawCertificates{Raw: b}, nil -} - -// DegenerateCertificate creates a signed data structure containing only the -// provided certificate or certificate chain. -func DegenerateCertificate(cert []byte) ([]byte, error) { - rawCert, err := marshalCertificateBytes(cert) - if err != nil { - return nil, err - } - emptyContent := contentInfo{ContentType: oidData} - sd := signedData{ - Version: 1, - ContentInfo: emptyContent, - Certificates: rawCert, - CRLs: []pkix.CertificateList{}, - } - content, err := asn1.Marshal(sd) - if err != nil { - return nil, err - } - signedContent := contentInfo{ - ContentType: oidSignedData, - Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: content, IsCompound: true}, - } - return asn1.Marshal(signedContent) -} - -// Encrypt creates and returns an envelope data PKCS7 structure with encrypted -// recipient keys for each recipient public key -// TODO(fullsailor): Add support for encrypting content with other algorithms -func Encrypt(content []byte, recipients []*x509.Certificate) ([]byte, error) { - - // Create DES key & CBC IV - key := make([]byte, 8) - iv := make([]byte, des.BlockSize) - _, err := rand.Read(key) - if err != nil { - return nil, err - } - _, err = rand.Read(iv) - if err != nil { - return nil, err - } - - // Encrypt padded content - block, err := des.NewCipher(key) - if err != nil { - return nil, err - } - mode := cipher.NewCBCEncrypter(block, iv) - plaintext, err := pad(content, mode.BlockSize()) - cyphertext := make([]byte, len(plaintext)) - mode.CryptBlocks(cyphertext, plaintext) - - // Prepare ASN.1 Encrypted Content Info - eci := encryptedContentInfo{ - ContentType: oidData, - ContentEncryptionAlgorithm: pkix.AlgorithmIdentifier{ - Algorithm: oidEncryptionAlgorithmDESCBC, - Parameters: asn1.RawValue{Tag: 4, Bytes: iv}, - }, - EncryptedContent: marshalEncryptedContent(cyphertext), - } - - // Prepare each recipient's encrypted cipher key - recipientInfos := make([]recipientInfo, len(recipients)) - for i, recipient := range recipients { - encrypted, err := encryptKey(key, recipient) - if err != nil { - return nil, err - } - ias, err := cert2issuerAndSerial(recipient) - if err != nil { - return nil, err - } - info := recipientInfo{ - Version: 0, - IssuerAndSerialNumber: ias, - KeyEncryptionAlgorithm: pkix.AlgorithmIdentifier{ - Algorithm: oidEncryptionAlgorithmRSA, - }, - EncryptedKey: encrypted, - } - recipientInfos[i] = info - } - - // Prepare envelope content - envelope := envelopedData{ - EncryptedContentInfo: eci, - Version: 0, - RecipientInfos: recipientInfos, - } - innerContent, err := asn1.Marshal(envelope) - if err != nil { - return nil, err - } - - // Prepare outer payload structure - wrapper := contentInfo{ - ContentType: oidEnvelopedData, - Content: asn1.RawValue{Class: 2, Tag: 0, IsCompound: true, Bytes: innerContent}, - } - - return asn1.Marshal(wrapper) -} - -func marshalEncryptedContent(content []byte) asn1.RawValue { - asn1Content, _ := asn1.Marshal(content) - return asn1.RawValue{Tag: 0, Class: 2, Bytes: asn1Content, IsCompound: true} -} - -func encryptKey(key []byte, recipient *x509.Certificate) ([]byte, error) { - if pub := recipient.PublicKey.(*rsa.PublicKey); pub != nil { - return rsa.EncryptPKCS1v15(rand.Reader, pub, key) - } - return nil, ErrUnsupportedAlgorithm -} diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7_test.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7_test.go deleted file mode 100644 index c66f8fe..0000000 --- a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7_test.go +++ /dev/null @@ -1,439 +0,0 @@ -package pkcs7 - -import ( - "bytes" - "crypto" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/asn1" - "encoding/pem" - "fmt" - "io" - "io/ioutil" - "math/big" - "os" - "os/exec" - "testing" - "time" -) - -func TestVerify(t *testing.T) { - fixture := UnmarshalTestFixture(SignedTestFixture) - p7, err := Parse(fixture.Input) - if err != nil { - t.Errorf("Parse encountered unexpected error: %v", err) - } - - if err := p7.Verify(); err != nil { - t.Errorf("Verify failed with error: %v", err) - } - expected := []byte("We the People") - if bytes.Compare(p7.Content, expected) != 0 { - t.Errorf("Signed content does not match.\n\tExpected:%s\n\tActual:%s", expected, p7.Content) - - } -} - -func TestVerifyEC2(t *testing.T) { - fixture := UnmarshalTestFixture(EC2IdentityDocumentFixture) - p7, err := Parse(fixture.Input) - if err != nil { - t.Errorf("Parse encountered unexpected error: %v", err) - } - p7.Certificates = []*x509.Certificate{fixture.Certificate} - if err := p7.Verify(); err != nil { - t.Errorf("Verify failed with error: %v", err) - } -} - -func TestDecrypt(t *testing.T) { - fixture := UnmarshalTestFixture(EncryptedTestFixture) - p7, err := Parse(fixture.Input) - if err != nil { - t.Fatal(err) - } - content, err := p7.Decrypt(fixture.Certificate, fixture.PrivateKey) - if err != nil { - t.Errorf("Cannot Decrypt with error: %v", err) - } - expected := []byte("This is a test") - if bytes.Compare(content, expected) != 0 { - t.Errorf("Decrypted result does not match.\n\tExpected:%s\n\tActual:%s", expected, content) - } -} - -func TestDegenerateCertificate(t *testing.T) { - cert, err := createTestCertificate() - if err != nil { - t.Fatal(err) - } - deg, err := DegenerateCertificate(cert.Certificate.Raw) - if err != nil { - t.Fatal(err) - } - testOpenSSLParse(t, deg) - - fmt.Printf("=== BEGIN DEGENERATE CERT ===\n% X\n=== END DEGENERATE CERT ===\n", deg) -} - -// writes the cert to a temporary file and tests that openssl can read it. -func testOpenSSLParse(t *testing.T, certBytes []byte) { - tmpCertFile, err := ioutil.TempFile("", "testCertificate") - if err != nil { - t.Fatal(err) - } - defer os.Remove(tmpCertFile.Name()) // clean up - - if _, err := tmpCertFile.Write(certBytes); err != nil { - t.Fatal(err) - } - - opensslCMD := exec.Command("openssl", "pkcs7", "-inform", "der", "-in", tmpCertFile.Name()) - _, err = opensslCMD.Output() - if err != nil { - t.Fatal(err) - } - - if err := tmpCertFile.Close(); err != nil { - t.Fatal(err) - } - -} - -func TestSign(t *testing.T) { - cert, err := createTestCertificate() - if err != nil { - t.Fatal(err) - } - content := []byte("Hello World") - toBeSigned, err := NewSignedData(content) - if err != nil { - t.Fatalf("Cannot initialize signed data: %s", err) - } - if err := toBeSigned.AddSigner(cert.Certificate, cert.PrivateKey, SignerInfoConfig{}); err != nil { - t.Fatalf("Cannot add signer: %s", err) - } - signed, err := toBeSigned.Finish() - if err != nil { - t.Fatalf("Cannot finish signing data: %s", err) - } - fmt.Printf("=== BEGIN SIGNED RESULT ===\n% X\n=== END SIGNED RESULT ===\n", signed) - - p7, err := Parse(signed) - if err != nil { - t.Fatalf("Cannot parse our signed data: %s", err) - } - if bytes.Compare(content, p7.Content) != 0 { - t.Errorf("Our content was not in the parsed data:\n\tExpected: %s\n\tActual: %s", content, p7.Content) - } - if err := p7.Verify(); err != nil { - t.Errorf("Cannot verify our signed data: %s", err) - } -} - -func TestEncrypt(t *testing.T) { - plaintext := []byte("Hello Secret World!") - cert, err := createTestCertificate() - if err != nil { - t.Fatal(err) - } - encrypted, err := Encrypt(plaintext, []*x509.Certificate{cert.Certificate}) - if err != nil { - t.Fatal(err) - } - p7, err := Parse(encrypted) - if err != nil { - t.Fatalf("cannot Parse encrypted result: %s", err) - } - result, err := p7.Decrypt(cert.Certificate, cert.PrivateKey) - if err != nil { - t.Fatalf("cannot Decrypt encrypted result: %s", err) - } - if bytes.Compare(plaintext, result) != 0 { - t.Errorf("encrypted data does not match plaintext:\n\tExpected: %s\n\tActual: %s", plaintext, result) - } -} - -func TestUnmarshalSignedAttribute(t *testing.T) { - cert, err := createTestCertificate() - if err != nil { - t.Fatal(err) - } - content := []byte("Hello World") - toBeSigned, err := NewSignedData(content) - if err != nil { - t.Fatalf("Cannot initialize signed data: %s", err) - } - oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7} - testValue := "TestValue" - if err := toBeSigned.AddSigner(cert.Certificate, cert.PrivateKey, SignerInfoConfig{ - ExtraSignedAttributes: []Attribute{Attribute{Type: oidTest, Value: testValue}}, - }); err != nil { - t.Fatalf("Cannot add signer: %s", err) - } - signed, err := toBeSigned.Finish() - if err != nil { - t.Fatalf("Cannot finish signing data: %s", err) - } - p7, err := Parse(signed) - var actual string - err = p7.UnmarshalSignedAttribute(oidTest, &actual) - if err != nil { - t.Fatalf("Cannot unmarshal test value: %s", err) - } - if testValue != actual { - t.Errorf("Attribute does not match test value\n\tExpected: %s\n\tActual: %s", testValue, actual) - } -} - -func TestPad(t *testing.T) { - tests := []struct { - Original []byte - Expected []byte - BlockSize int - }{ - {[]byte{0x1, 0x2, 0x3, 0x10}, []byte{0x1, 0x2, 0x3, 0x10, 0x4, 0x4, 0x4, 0x4}, 8}, - {[]byte{0x1, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0}, []byte{0x1, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8}, 8}, - } - for _, test := range tests { - padded, err := pad(test.Original, test.BlockSize) - if err != nil { - t.Errorf("pad encountered error: %s", err) - continue - } - if bytes.Compare(test.Expected, padded) != 0 { - t.Errorf("pad results mismatch:\n\tExpected: %X\n\tActual: %X", test.Expected, padded) - } - } -} - -type certKeyPair struct { - Certificate *x509.Certificate - PrivateKey *rsa.PrivateKey -} - -func createTestCertificate() (certKeyPair, error) { - signer, err := createTestCertificateByIssuer("Eddard Stark", nil) - if err != nil { - return certKeyPair{}, err - } - pair, err := createTestCertificateByIssuer("Jon Snow", signer) - if err != nil { - return certKeyPair{}, err - } - return *pair, nil -} - -func createTestCertificateByIssuer(name string, issuer *certKeyPair) (*certKeyPair, error) { - - priv, err := rsa.GenerateKey(rand.Reader, 1024) - if err != nil { - return nil, err - } - serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 32) - serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) - if err != nil { - return nil, err - } - - template := x509.Certificate{ - SerialNumber: serialNumber, - SignatureAlgorithm: x509.SHA256WithRSA, - Subject: pkix.Name{ - CommonName: name, - Organization: []string{"Acme Co"}, - }, - NotBefore: time.Now(), - NotAfter: time.Now().AddDate(1, 0, 0), - KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, - } - var issuerCert *x509.Certificate - var issuerKey crypto.PrivateKey - if issuer != nil { - issuerCert = issuer.Certificate - issuerKey = issuer.PrivateKey - } else { - issuerCert = &template - issuerKey = priv - } - cert, err := x509.CreateCertificate(rand.Reader, &template, issuerCert, priv.Public(), issuerKey) - if err != nil { - return nil, err - } - leaf, err := x509.ParseCertificate(cert) - if err != nil { - return nil, err - } - return &certKeyPair{ - Certificate: leaf, - PrivateKey: priv, - }, nil -} - -type TestFixture struct { - Input []byte - Certificate *x509.Certificate - PrivateKey *rsa.PrivateKey -} - -func UnmarshalTestFixture(testPEMBlock string) TestFixture { - var result TestFixture - var derBlock *pem.Block - var pemBlock = []byte(testPEMBlock) - for { - derBlock, pemBlock = pem.Decode(pemBlock) - if derBlock == nil { - break - } - switch derBlock.Type { - case "PKCS7": - result.Input = derBlock.Bytes - case "CERTIFICATE": - result.Certificate, _ = x509.ParseCertificate(derBlock.Bytes) - case "PRIVATE KEY": - result.PrivateKey, _ = x509.ParsePKCS1PrivateKey(derBlock.Bytes) - } - } - - return result -} - -func MarshalTestFixture(t TestFixture, w io.Writer) { - if t.Input != nil { - pem.Encode(w, &pem.Block{Type: "PKCS7", Bytes: t.Input}) - } - if t.Certificate != nil { - pem.Encode(w, &pem.Block{Type: "CERTIFICATE", Bytes: t.Certificate.Raw}) - } - if t.PrivateKey != nil { - pem.Encode(w, &pem.Block{Type: "PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(t.PrivateKey)}) - } -} - -var SignedTestFixture = ` ------BEGIN PKCS7----- -MIIDVgYJKoZIhvcNAQcCoIIDRzCCA0MCAQExCTAHBgUrDgMCGjAcBgkqhkiG9w0B -BwGgDwQNV2UgdGhlIFBlb3BsZaCCAdkwggHVMIIBQKADAgECAgRpuDctMAsGCSqG -SIb3DQEBCzApMRAwDgYDVQQKEwdBY21lIENvMRUwEwYDVQQDEwxFZGRhcmQgU3Rh -cmswHhcNMTUwNTA2MDQyNDQ4WhcNMTYwNTA2MDQyNDQ4WjAlMRAwDgYDVQQKEwdB -Y21lIENvMREwDwYDVQQDEwhKb24gU25vdzCBnzANBgkqhkiG9w0BAQEFAAOBjQAw -gYkCgYEAqr+tTF4mZP5rMwlXp1y+crRtFpuLXF1zvBZiYMfIvAHwo1ta8E1IcyEP -J1jIiKMcwbzeo6kAmZzIJRCTezq9jwXUsKbQTvcfOH9HmjUmXBRWFXZYoQs/OaaF -a45deHmwEeMQkuSWEtYiVKKZXtJOtflKIT3MryJEDiiItMkdybUCAwEAAaMSMBAw -DgYDVR0PAQH/BAQDAgCgMAsGCSqGSIb3DQEBCwOBgQDK1EweZWRL+f7Z+J0kVzY8 -zXptcBaV4Lf5wGZJLJVUgp33bpLNpT3yadS++XQJ+cvtW3wADQzBSTMduyOF8Zf+ -L7TjjrQ2+F2HbNbKUhBQKudxTfv9dJHdKbD+ngCCdQJYkIy2YexsoNG0C8nQkggy -axZd/J69xDVx6pui3Sj8sDGCATYwggEyAgEBMDEwKTEQMA4GA1UEChMHQWNtZSBD -bzEVMBMGA1UEAxMMRWRkYXJkIFN0YXJrAgRpuDctMAcGBSsOAwIaoGEwGAYJKoZI -hvcNAQkDMQsGCSqGSIb3DQEHATAgBgkqhkiG9w0BCQUxExcRMTUwNTA2MDAyNDQ4 -LTA0MDAwIwYJKoZIhvcNAQkEMRYEFG9D7gcTh9zfKiYNJ1lgB0yTh4sZMAsGCSqG -SIb3DQEBAQSBgFF3sGDU9PtXty/QMtpcFa35vvIOqmWQAIZt93XAskQOnBq4OloX -iL9Ct7t1m4pzjRm0o9nDkbaSLZe7HKASHdCqijroScGlI8M+alJ8drHSFv6ZIjnM -FIwIf0B2Lko6nh9/6mUXq7tbbIHa3Gd1JUVire/QFFtmgRXMbXYk8SIS ------END PKCS7----- ------BEGIN CERTIFICATE----- -MIIB1TCCAUCgAwIBAgIEabg3LTALBgkqhkiG9w0BAQswKTEQMA4GA1UEChMHQWNt -ZSBDbzEVMBMGA1UEAxMMRWRkYXJkIFN0YXJrMB4XDTE1MDUwNjA0MjQ0OFoXDTE2 -MDUwNjA0MjQ0OFowJTEQMA4GA1UEChMHQWNtZSBDbzERMA8GA1UEAxMISm9uIFNu -b3cwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKq/rUxeJmT+azMJV6dcvnK0 -bRabi1xdc7wWYmDHyLwB8KNbWvBNSHMhDydYyIijHMG83qOpAJmcyCUQk3s6vY8F -1LCm0E73Hzh/R5o1JlwUVhV2WKELPzmmhWuOXXh5sBHjEJLklhLWIlSimV7STrX5 -SiE9zK8iRA4oiLTJHcm1AgMBAAGjEjAQMA4GA1UdDwEB/wQEAwIAoDALBgkqhkiG -9w0BAQsDgYEAytRMHmVkS/n+2fidJFc2PM16bXAWleC3+cBmSSyVVIKd926SzaU9 -8mnUvvl0CfnL7Vt8AA0MwUkzHbsjhfGX/i+04460Nvhdh2zWylIQUCrncU37/XSR -3Smw/p4AgnUCWJCMtmHsbKDRtAvJ0JIIMmsWXfyevcQ1ceqbot0o/LA= ------END CERTIFICATE----- ------BEGIN PRIVATE KEY----- -MIICXgIBAAKBgQCqv61MXiZk/mszCVenXL5ytG0Wm4tcXXO8FmJgx8i8AfCjW1rw -TUhzIQ8nWMiIoxzBvN6jqQCZnMglEJN7Or2PBdSwptBO9x84f0eaNSZcFFYVdlih -Cz85poVrjl14ebAR4xCS5JYS1iJUople0k61+UohPcyvIkQOKIi0yR3JtQIDAQAB -AoGBAIPLCR9N+IKxodq11lNXEaUFwMHXc1zqwP8no+2hpz3+nVfplqqubEJ4/PJY -5AgbJoIfnxVhyBXJXu7E+aD/OPneKZrgp58YvHKgGvvPyJg2gpC/1Fh0vQB0HNpI -1ZzIZUl8ZTUtVgtnCBUOh5JGI4bFokAqrT//Uvcfd+idgxqBAkEA1ZbP/Kseld14 -qbWmgmU5GCVxsZRxgR1j4lG3UVjH36KXMtRTm1atAam1uw3OEGa6Y3ANjpU52FaB -Hep5rkk4FQJBAMynMo1L1uiN5GP+KYLEF5kKRxK+FLjXR0ywnMh+gpGcZDcOae+J -+t1gLoWBIESH/Xt639T7smuSfrZSA9V0EyECQA8cvZiWDvLxmaEAXkipmtGPjKzQ -4PsOtkuEFqFl07aKDYKmLUg3aMROWrJidqsIabWxbvQgsNgSvs38EiH3wkUCQQCg -ndxb7piVXb9RBwm3OoU2tE1BlXMX+sVXmAkEhd2dwDsaxrI3sHf1xGXem5AimQRF -JBOFyaCnMotGNioSHY5hAkEAxyXcNixQ2RpLXJTQZtwnbk0XDcbgB+fBgXnv/4f3 -BCvcu85DqJeJyQv44Oe1qsXEX9BfcQIOVaoep35RPlKi9g== ------END PRIVATE KEY-----` - -// Content is "This is a test" -var EncryptedTestFixture = ` ------BEGIN PKCS7----- -MIIBFwYJKoZIhvcNAQcDoIIBCDCCAQQCAQAxgcowgccCAQAwMjApMRAwDgYDVQQK -EwdBY21lIENvMRUwEwYDVQQDEwxFZGRhcmQgU3RhcmsCBQDL+CvWMAsGCSqGSIb3 -DQEBAQSBgKyP/5WlRTZD3dWMrLOX6QRNDrXEkQjhmToRwFZdY3LgUh25ZU0S/q4G -dHPV21Fv9lQD+q7l3vfeHw8M6Z1PKi9sHMVfxAkQpvaI96DTIT3YHtuLC1w3geCO -8eFWTq2qS4WChSuS/yhYosjA1kTkE0eLnVZcGw0z/WVuEZznkdyIMDIGCSqGSIb3 -DQEHATARBgUrDgMCBwQImpKsUyMPpQigEgQQRcWWrCRXqpD5Njs0GkJl+g== ------END PKCS7----- ------BEGIN CERTIFICATE----- -MIIB1jCCAUGgAwIBAgIFAMv4K9YwCwYJKoZIhvcNAQELMCkxEDAOBgNVBAoTB0Fj -bWUgQ28xFTATBgNVBAMTDEVkZGFyZCBTdGFyazAeFw0xNTA1MDYwMzU2NDBaFw0x -NjA1MDYwMzU2NDBaMCUxEDAOBgNVBAoTB0FjbWUgQ28xETAPBgNVBAMTCEpvbiBT -bm93MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK6NU0R0eiCYVquU4RcjKc -LzGfx0aa1lMr2TnLQUSeLFZHFxsyyMXXuMPig3HK4A7SGFHupO+/1H/sL4xpH5zg -8+Zg2r8xnnney7abxcuv0uATWSIeKlNnb1ZO1BAxFnESc3GtyOCr2dUwZHX5mRVP -+Zxp2ni5qHNraf3wE2VPIQIDAQABoxIwEDAOBgNVHQ8BAf8EBAMCAKAwCwYJKoZI -hvcNAQELA4GBAIr2F7wsqmEU/J/kLyrCgEVXgaV/sKZq4pPNnzS0tBYk8fkV3V18 -sBJyHKRLL/wFZASvzDcVGCplXyMdAOCyfd8jO3F9Ac/xdlz10RrHJT75hNu3a7/n -9KNwKhfN4A1CQv2x372oGjRhCW5bHNCWx4PIVeNzCyq/KZhyY9sxHE6f ------END CERTIFICATE----- ------BEGIN PRIVATE KEY----- -MIICXgIBAAKBgQDK6NU0R0eiCYVquU4RcjKcLzGfx0aa1lMr2TnLQUSeLFZHFxsy -yMXXuMPig3HK4A7SGFHupO+/1H/sL4xpH5zg8+Zg2r8xnnney7abxcuv0uATWSIe -KlNnb1ZO1BAxFnESc3GtyOCr2dUwZHX5mRVP+Zxp2ni5qHNraf3wE2VPIQIDAQAB -AoGBALyvnSt7KUquDen7nXQtvJBudnf9KFPt//OjkdHHxNZNpoF/JCSqfQeoYkeu -MdAVYNLQGMiRifzZz4dDhA9xfUAuy7lcGQcMCxEQ1dwwuFaYkawbS0Tvy2PFlq2d -H5/HeDXU4EDJ3BZg0eYj2Bnkt1sJI35UKQSxblQ0MY2q0uFBAkEA5MMOogkgUx1C -67S1tFqMUSM8D0mZB0O5vOJZC5Gtt2Urju6vywge2ArExWRXlM2qGl8afFy2SgSv -Xk5eybcEiQJBAOMRwwbEoW5NYHuFFbSJyWll4n71CYuWuQOCzehDPyTb80WFZGLV -i91kFIjeERyq88eDE5xVB3ZuRiXqaShO/9kCQQCKOEkpInaDgZSjskZvuJ47kByD -6CYsO4GIXQMMeHML8ncFH7bb6AYq5ybJVb2NTU7QLFJmfeYuhvIm+xdOreRxAkEA -o5FC5Jg2FUfFzZSDmyZ6IONUsdF/i78KDV5nRv1R+hI6/oRlWNCtTNBv/lvBBd6b -dseUE9QoaQZsn5lpILEvmQJAZ0B+Or1rAYjnbjnUhdVZoy9kC4Zov+4UH3N/BtSy -KJRWUR0wTWfZBPZ5hAYZjTBEAFULaYCXlQKsODSp0M1aQA== ------END PRIVATE KEY-----` - -var EC2IdentityDocumentFixture = ` ------BEGIN PKCS7----- -MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAaCA -JIAEggGmewogICJwcml2YXRlSXAiIDogIjE3Mi4zMC4wLjI1MiIsCiAgImRldnBh -eVByb2R1Y3RDb2RlcyIgOiBudWxsLAogICJhdmFpbGFiaWxpdHlab25lIiA6ICJ1 -cy1lYXN0LTFhIiwKICAidmVyc2lvbiIgOiAiMjAxMC0wOC0zMSIsCiAgImluc3Rh -bmNlSWQiIDogImktZjc5ZmU1NmMiLAogICJiaWxsaW5nUHJvZHVjdHMiIDogbnVs -bCwKICAiaW5zdGFuY2VUeXBlIiA6ICJ0Mi5taWNybyIsCiAgImFjY291bnRJZCIg -OiAiMTIxNjU5MDE0MzM0IiwKICAiaW1hZ2VJZCIgOiAiYW1pLWZjZTNjNjk2IiwK -ICAicGVuZGluZ1RpbWUiIDogIjIwMTYtMDQtMDhUMDM6MDE6MzhaIiwKICAiYXJj -aGl0ZWN0dXJlIiA6ICJ4ODZfNjQiLAogICJrZXJuZWxJZCIgOiBudWxsLAogICJy -YW1kaXNrSWQiIDogbnVsbCwKICAicmVnaW9uIiA6ICJ1cy1lYXN0LTEiCn0AAAAA -AAAxggEYMIIBFAIBATBpMFwxCzAJBgNVBAYTAlVTMRkwFwYDVQQIExBXYXNoaW5n -dG9uIFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYDVQQKExdBbWF6b24gV2Vi -IFNlcnZpY2VzIExMQwIJAJa6SNnlXhpnMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0B -CQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xNjA0MDgwMzAxNDRaMCMG -CSqGSIb3DQEJBDEWBBTuUc28eBXmImAautC+wOjqcFCBVjAJBgcqhkjOOAQDBC8w -LQIVAKA54NxGHWWCz5InboDmY/GHs33nAhQ6O/ZI86NwjA9Vz3RNMUJrUPU5tAAA -AAAAAA== ------END PKCS7----- ------BEGIN CERTIFICATE----- -MIIC7TCCAq0CCQCWukjZ5V4aZzAJBgcqhkjOOAQDMFwxCzAJBgNVBAYTAlVTMRkw -FwYDVQQIExBXYXNoaW5ndG9uIFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYD -VQQKExdBbWF6b24gV2ViIFNlcnZpY2VzIExMQzAeFw0xMjAxMDUxMjU2MTJaFw0z -ODAxMDUxMjU2MTJaMFwxCzAJBgNVBAYTAlVTMRkwFwYDVQQIExBXYXNoaW5ndG9u -IFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYDVQQKExdBbWF6b24gV2ViIFNl -cnZpY2VzIExMQzCCAbcwggEsBgcqhkjOOAQBMIIBHwKBgQCjkvcS2bb1VQ4yt/5e -ih5OO6kK/n1Lzllr7D8ZwtQP8fOEpp5E2ng+D6Ud1Z1gYipr58Kj3nssSNpI6bX3 -VyIQzK7wLclnd/YozqNNmgIyZecN7EglK9ITHJLP+x8FtUpt3QbyYXJdmVMegN6P -hviYt5JH/nYl4hh3Pa1HJdskgQIVALVJ3ER11+Ko4tP6nwvHwh6+ERYRAoGBAI1j -k+tkqMVHuAFcvAGKocTgsjJem6/5qomzJuKDmbJNu9Qxw3rAotXau8Qe+MBcJl/U -hhy1KHVpCGl9fueQ2s6IL0CaO/buycU1CiYQk40KNHCcHfNiZbdlx1E9rpUp7bnF -lRa2v1ntMX3caRVDdbtPEWmdxSCYsYFDk4mZrOLBA4GEAAKBgEbmeve5f8LIE/Gf -MNmP9CM5eovQOGx5ho8WqD+aTebs+k2tn92BBPqeZqpWRa5P/+jrdKml1qx4llHW -MXrs3IgIb6+hUIB+S8dz8/mmO0bpr76RoZVCXYab2CZedFut7qc3WUH9+EUAH5mw -vSeDCOUMYQR7R9LINYwouHIziqQYMAkGByqGSM44BAMDLwAwLAIUWXBlk40xTwSw -7HX32MxXYruse9ACFBNGmdX2ZBrVNGrN9N2f6ROk0k9K ------END CERTIFICATE-----` diff --git a/vendor/github.com/micromdm/scep/scep/scep.go b/vendor/github.com/micromdm/scep/scep/scep.go deleted file mode 100644 index 70db27a..0000000 --- a/vendor/github.com/micromdm/scep/scep/scep.go +++ /dev/null @@ -1,618 +0,0 @@ -// Package scep provides common functionality for encoding and decoding -// Simple Certificate Enrolment Protocol pki messages as defined by -// https://tools.ietf.org/html/draft-gutmann-scep-02 -package scep - -import ( - "bytes" - "crypto" - "crypto/rand" - "crypto/rsa" - "crypto/sha1" - "crypto/x509" - "crypto/x509/pkix" - "encoding/asn1" - "encoding/base64" - "errors" - "math/big" - - "github.com/micromdm/scep/scep/internal/pkcs7" -) - -// errors -var ( - errNotImplemented = errors.New("not implemented") - errUnknownMessageType = errors.New("unknown messageType") -) - -// The MessageType attribute specifies the type of operation performed -// by the transaction. This attribute MUST be included in all PKI -// messages. -// -// The following message types are defined: -type MessageType string - -// Undefined message types are treated as an error. -const ( - CertRep MessageType = "3" - RenewalReq = "17" - UpdateReq = "18" - PKCSReq = "19" - CertPoll = "20" - GetCert = "21" - GetCRL = "22" -) - -// PKIStatus is a SCEP pkiStatus attribute which holds transaction status information. -// All SCEP responses MUST include a pkiStatus. -// -// The following pkiStatuses are defined: -type PKIStatus string - -// Undefined pkiStatus attributes are treated as an error -const ( - SUCCESS PKIStatus = "0" - FAILURE = "2" - PENDING = "3" -) - -// FailInfo is a SCEP failInfo attribute -// -// The FailInfo attribute MUST contain one of the following failure -// reasons: -type FailInfo string - -// -const ( - BadAlg FailInfo = "0" - BadMessageCheck = "1" - BadRequest = "2" - BadTime = "3" - BadCertID = "4" -) - -// SenderNonce is a random 16 byte number. -// A sender must include the senderNonce in each transaction to a recipient. -type SenderNonce []byte - -// The RecipientNonce MUST be copied from the SenderNonce -// and included in the reply. -type RecipientNonce []byte - -// The TransactionID is a text -// string generated by the client when starting a transaction. The -// client MUST generate a unique string as the transaction identifier, -// which MUST be used for all PKI messages exchanged for a given -// enrolment, encoded as a PrintableString. -type TransactionID string - -// SCEP OIDs -var ( - oidSCEPmessageType = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 2} - oidSCEPpkiStatus = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 3} - oidSCEPfailInfo = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 4} - oidSCEPsenderNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 5} - oidSCEPrecipientNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 6} - oidSCEPtransactionID = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 7} - oidChallengePassword = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 7} -) - -// PKIMessage defines the possible SCEP message types -type PKIMessage struct { - TransactionID - MessageType - SenderNonce - *CertRepMessage - *CSRReqMessage - - // DER Encoded PKIMessage - Raw []byte - - // parsed - p7 *pkcs7.PKCS7 - - // decrypted enveloped content - pkiEnvelope []byte - - // Used to sign message - Recipients []*x509.Certificate - - // Signer info - SignerKey *rsa.PrivateKey - SignerCert *x509.Certificate -} - -// CertRepMessage is a type of PKIMessage -type CertRepMessage struct { - PKIStatus - RecipientNonce - FailInfo - - Certificate *x509.Certificate - - degenerate []byte -} - -// CSRReqMessage can be of the type PKCSReq/RenewalReq/UpdateReq -// and includes a PKCS#10 CSR request. -// The content of this message is protected -// by the recipient public key(example CA) -type CSRReqMessage struct { - // PKCS#10 Certificate request inside the envelope - CSR *x509.CertificateRequest - - ChallengePassword string -} - -// ParsePKIMessage unmarshals a PKCS#7 signed data into a PKI message struct -func ParsePKIMessage(data []byte) (*PKIMessage, error) { - // parse PKCS#7 signed data - p7, err := pkcs7.Parse(data) - if err != nil { - return nil, err - } - - var tID TransactionID - if err := p7.UnmarshalSignedAttribute(oidSCEPtransactionID, &tID); err != nil { - return nil, err - } - - var msgType MessageType - if err := p7.UnmarshalSignedAttribute(oidSCEPmessageType, &msgType); err != nil { - return nil, err - } - - msg := &PKIMessage{ - TransactionID: tID, - MessageType: msgType, - Raw: data, - p7: p7, - } - - if err := msg.parseMessageType(); err != nil { - return nil, err - } - - return msg, nil -} - -func (msg *PKIMessage) parseMessageType() error { - switch msg.MessageType { - case CertRep: - var status PKIStatus - if err := msg.p7.UnmarshalSignedAttribute(oidSCEPpkiStatus, &status); err != nil { - return err - } - var rn RecipientNonce - if err := msg.p7.UnmarshalSignedAttribute(oidSCEPrecipientNonce, &rn); err != nil { - return err - } - if len(rn) == 0 { - return errors.New("scep pkiMessage must include recipientNonce attribute") - } - cr := &CertRepMessage{ - PKIStatus: status, - RecipientNonce: rn, - } - switch status { - case SUCCESS: - break - case FAILURE: - var fi FailInfo - if err := msg.p7.UnmarshalSignedAttribute(oidSCEPfailInfo, &fi); err != nil { - return err - } - if fi == "" { - return errors.New("scep pkiStatus FAILURE must have a failInfo attribute") - } - cr.FailInfo = fi - case PENDING: - return errNotImplemented - default: - return errors.New("unknown scep pkiStatus") - } - msg.CertRepMessage = cr - return nil - case PKCSReq, UpdateReq, RenewalReq: - var sn SenderNonce - if err := msg.p7.UnmarshalSignedAttribute(oidSCEPsenderNonce, &sn); err != nil { - return err - } - if len(sn) == 0 { - return errors.New("scep pkiMessage must include senderNonce attribute") - } - msg.SenderNonce = sn - return nil - case GetCRL, GetCert, CertPoll: - return errNotImplemented - default: - return errUnknownMessageType - } -} - -type publicKeyInfo struct { - Raw asn1.RawContent - Algorithm pkix.AlgorithmIdentifier - PublicKey asn1.BitString -} - -type tbsCertificateRequest struct { - Raw asn1.RawContent - Version int - Subject asn1.RawValue - PublicKey publicKeyInfo - RawAttributes []asn1.RawValue `asn1:"tag:0"` -} - -type certificateRequest struct { - Raw asn1.RawContent - TBSCSR tbsCertificateRequest - SignatureAlgorithm pkix.AlgorithmIdentifier - SignatureValue asn1.BitString -} - -// stdlib ignores the challengePassword attribute in csr -func parseChallengePassword(asn1Data []byte) (string, error) { - type attribute struct { - ID asn1.ObjectIdentifier - Value asn1.RawValue `asn1:"set"` - } - var csr certificateRequest - rest, err := asn1.Unmarshal(asn1Data, &csr) - if err != nil { - return "", err - } else if len(rest) != 0 { - err = asn1.SyntaxError{Msg: "trailing data"} - return "", err - } - - var password string - for _, rawAttr := range csr.TBSCSR.RawAttributes { - var attr attribute - _, err := asn1.Unmarshal(rawAttr.FullBytes, &attr) - if err != nil { - return "", err - } - if attr.ID.Equal(oidChallengePassword) { - password = string(attr.Value.Bytes) - } - } - - return password, nil -} - -// AddChallenge adds a challenge password to the CSR -func addChallenge(csr *x509.CertificateRequest, challenge string) ([]byte, error) { - // unmarshal csr - var req certificateRequest - rest, err := asn1.Unmarshal(csr.Raw, &req) - if err != nil { - return nil, err - } else if len(rest) != 0 { - err = asn1.SyntaxError{Msg: "trailing data"} - return nil, err - } - - passwordAttribute := pkix.AttributeTypeAndValue{ - Type: oidChallengePassword, - Value: []byte(challenge), - } - b, err := asn1.Marshal(passwordAttribute) - - var rawAttribute asn1.RawValue - rest, err = asn1.Unmarshal(b, &rawAttribute) - if err != nil { - return nil, err - } else if len(rest) != 0 { - err = asn1.SyntaxError{Msg: "trailing data"} - return nil, err - } - - // append attribute - req.TBSCSR.RawAttributes = append(req.TBSCSR.RawAttributes, rawAttribute) - - // recreate request - tbsCSR := tbsCertificateRequest{ - Version: 0, - Subject: req.TBSCSR.Subject, - PublicKey: req.TBSCSR.PublicKey, - RawAttributes: req.TBSCSR.RawAttributes, - } - - tbsCSRContents, err := asn1.Marshal(tbsCSR) - if err != nil { - return nil, err - } - tbsCSR.Raw = tbsCSRContents - - // marshal csr with challenge password - csrBytes, err := asn1.Marshal(certificateRequest{ - TBSCSR: tbsCSR, - SignatureAlgorithm: req.SignatureAlgorithm, - SignatureValue: req.SignatureValue, - }) - if err != nil { - return nil, err - } - - return csrBytes, nil -} - -// DecryptPKIEnvelope decrypts the pkcs envelopedData inside the SCEP PKIMessage -func (msg *PKIMessage) DecryptPKIEnvelope(cert *x509.Certificate, key *rsa.PrivateKey) error { - p7, err := pkcs7.Parse(msg.p7.Content) - if err != nil { - return err - } - msg.pkiEnvelope, err = p7.Decrypt(cert, key) - if err != nil { - return err - } - - switch msg.MessageType { - case CertRep: - certs, err := CACerts(msg.pkiEnvelope) - if err != nil { - return err - } - msg.CertRepMessage.Certificate = certs[0] - return nil - case PKCSReq, UpdateReq, RenewalReq: - csr, err := x509.ParseCertificateRequest(msg.pkiEnvelope) - if err != nil { - return err - } - // check for challengePassword - cp, err := parseChallengePassword(msg.pkiEnvelope) - if err != nil { - return err - } - msg.CSRReqMessage = &CSRReqMessage{ - CSR: csr, - ChallengePassword: cp, - } - return nil - case GetCRL, GetCert, CertPoll: - return errNotImplemented - default: - return errUnknownMessageType - } -} - -// SignCSR creates an x509.Certificate based on a template and Cert Authority credentials -// returns a new PKIMessage with CertRep data -func (msg *PKIMessage) SignCSR(crtAuth *x509.Certificate, keyAuth *rsa.PrivateKey, template *x509.Certificate) (*PKIMessage, error) { - // check if CSRReqMessage has already been decrypted - if msg.CSRReqMessage.CSR == nil { - if err := msg.DecryptPKIEnvelope(crtAuth, keyAuth); err != nil { - return nil, err - } - } - // sign the CSR creating a DER encoded cert - crtBytes, err := x509.CreateCertificate(rand.Reader, template, crtAuth, msg.CSRReqMessage.CSR.PublicKey, keyAuth) - if err != nil { - return nil, err - } - // parse the certificate - crt, err := x509.ParseCertificate(crtBytes) - if err != nil { - return nil, err - } - - // create a degenerate cert structure - deg, err := DegenerateCertificates([]*x509.Certificate{crt}) - if err != nil { - return nil, err - } - - // encrypt degenerate data using the original messages recipients - e7, err := pkcs7.Encrypt(deg, msg.p7.Certificates) - if err != nil { - return nil, err - } - - // PKIMessageAttributes to be signed - config := pkcs7.SignerInfoConfig{ - ExtraSignedAttributes: []pkcs7.Attribute{ - pkcs7.Attribute{ - Type: oidSCEPtransactionID, - Value: msg.TransactionID, - }, - pkcs7.Attribute{ - Type: oidSCEPpkiStatus, - Value: SUCCESS, - }, - pkcs7.Attribute{ - Type: oidSCEPmessageType, - Value: CertRep, - }, - pkcs7.Attribute{ - Type: oidSCEPrecipientNonce, - Value: msg.SenderNonce, - }, - }, - } - - signedData, err := pkcs7.NewSignedData(e7) - if err != nil { - return nil, err - } - // add the certificate into the signed data type - // this cert must be added before the signedData because the recipient will expect it - // as the first certificate in the array - signedData.AddCertificate(crt) - // sign the attributes - if err := signedData.AddSigner(crtAuth, keyAuth, config); err != nil { - return nil, err - } - - certRepBytes, err := signedData.Finish() - if err != nil { - return nil, err - } - - cr := &CertRepMessage{ - PKIStatus: SUCCESS, - RecipientNonce: RecipientNonce(msg.SenderNonce), - Certificate: crt, - degenerate: deg, - } - - // create a CertRep message from the original - crepMsg := &PKIMessage{ - Raw: certRepBytes, - TransactionID: msg.TransactionID, - MessageType: CertRep, - CertRepMessage: cr, - } - - return crepMsg, nil -} - -// DegenerateCertificates creates degenerate certificates pkcs#7 type -func DegenerateCertificates(certs []*x509.Certificate) ([]byte, error) { - var buf bytes.Buffer - for _, cert := range certs { - buf.Write(cert.Raw) - } - degenerate, err := pkcs7.DegenerateCertificate(buf.Bytes()) - if err != nil { - return nil, err - } - return degenerate, nil -} - -// CACerts extract CA Certificate or chain from pkcs7 degenerate signed data -func CACerts(data []byte) ([]*x509.Certificate, error) { - p7, err := pkcs7.Parse(data) - if err != nil { - return nil, err - } - return p7.Certificates, nil -} - -// NewCSRRequest creates a scep PKI PKCSReq/UpdateReq message -func NewCSRRequest(csr *x509.CertificateRequest, tmpl *PKIMessage) (*PKIMessage, error) { - csrBytes := csr.Raw - if tmpl.CSRReqMessage != nil { - if tmpl.ChallengePassword != "" { - b, err := addChallenge(csr, tmpl.ChallengePassword) - if err != nil { - return nil, err - } - csrBytes = b - } - } - e7, err := pkcs7.Encrypt(csrBytes, tmpl.Recipients) - if err != nil { - return nil, err - } - - signedData, err := pkcs7.NewSignedData(e7) - if err != nil { - return nil, err - } - - // create transaction ID from public key hash - tID, err := newTransactionID(csr.PublicKey) - if err != nil { - return nil, err - } - - sn, err := newNonce() - if err != nil { - return nil, err - } - - // PKIMessageAttributes to be signed - config := pkcs7.SignerInfoConfig{ - ExtraSignedAttributes: []pkcs7.Attribute{ - pkcs7.Attribute{ - Type: oidSCEPtransactionID, - Value: tID, - }, - pkcs7.Attribute{ - Type: oidSCEPmessageType, - Value: tmpl.MessageType, - }, - pkcs7.Attribute{ - Type: oidSCEPsenderNonce, - Value: sn, - }, - }, - } - - // sign attributes - if err := signedData.AddSigner(tmpl.SignerCert, tmpl.SignerKey, config); err != nil { - return nil, err - } - - rawPKIMessage, err := signedData.Finish() - if err != nil { - return nil, err - } - - cr := &CSRReqMessage{ - CSR: csr, - } - - newMsg := &PKIMessage{ - Raw: rawPKIMessage, - MessageType: tmpl.MessageType, - TransactionID: tID, - SenderNonce: sn, - CSRReqMessage: cr, - } - - return newMsg, nil -} - -func newNonce() (SenderNonce, error) { - size := 16 - b := make([]byte, size) - _, err := rand.Read(b) - if err != nil { - return SenderNonce{}, err - } - return SenderNonce(b), nil -} - -// use public key to create a deterministric transactionID -func newTransactionID(key crypto.PublicKey) (TransactionID, error) { - id, err := generateSubjectKeyID(key) - if err != nil { - return "", err - } - - encHash := base64.StdEncoding.EncodeToString(id) - return TransactionID(encHash), nil -} - -// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. -type rsaPublicKey struct { - N *big.Int - E int -} - -// GenerateSubjectKeyID generates SubjectKeyId used in Certificate -// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey -func generateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { - var pubBytes []byte - var err error - switch pub := pub.(type) { - case *rsa.PublicKey: - pubBytes, err = asn1.Marshal(rsaPublicKey{ - N: pub.N, - E: pub.E, - }) - if err != nil { - return nil, err - } - default: - return nil, errors.New("only RSA public key is supported") - } - - hash := sha1.Sum(pubBytes) - - return hash[:], nil -} diff --git a/vendor/github.com/micromdm/scep/scep/scep_test.go b/vendor/github.com/micromdm/scep/scep/scep_test.go deleted file mode 100644 index d67452d..0000000 --- a/vendor/github.com/micromdm/scep/scep/scep_test.go +++ /dev/null @@ -1,266 +0,0 @@ -package scep_test - -import ( - "crypto" - "crypto/rand" - "crypto/rsa" - "crypto/sha1" - "crypto/x509" - "crypto/x509/pkix" - "encoding/asn1" - "encoding/pem" - "errors" - "io/ioutil" - "math/big" - "testing" - "time" - - "github.com/micromdm/scep/scep" -) - -func testParsePKIMessage(t *testing.T, data []byte) *scep.PKIMessage { - msg, err := scep.ParsePKIMessage(data) - if err != nil { - t.Fatal(err) - } - if msg.TransactionID == "" { - t.Errorf("expected TransactionID attribute") - } - if msg.MessageType == "" { - t.Errorf("expected MessageType attribute") - } - switch msg.MessageType { - case scep.CertRep: - if len(msg.RecipientNonce) == 0 { - t.Errorf("expected RecipientNonce attribute") - } - case scep.PKCSReq, scep.UpdateReq, scep.RenewalReq: - if len(msg.SenderNonce) == 0 { - t.Errorf("expected SenderNonce attribute") - } - } - return msg -} - -func TestDecryptPKIEnvelopeCSR(t *testing.T) { - pkcsReq := loadTestFile(t, "testdata/PKCSReq.der") - msg := testParsePKIMessage(t, pkcsReq) - cacert, cakey := loadCACredentials(t) - err := msg.DecryptPKIEnvelope(cacert, cakey) - if err != nil { - t.Fatal(err) - } - if msg.CSRReqMessage.CSR == nil { - t.Errorf("expected non-nil CSR field") - } -} - -func TestDecryptPKIEnvelopeCert(t *testing.T) { - certRep := loadTestFile(t, "testdata/CertRep.der") - testParsePKIMessage(t, certRep) - // clientcert, clientkey := loadClientCredentials(t) - // err = msg.DecryptPKIEnvelope(clientcert, clientkey) - // if err != nil { - // t.Fatal(err) - // } -} - -func TestSignCSR(t *testing.T) { - pkcsReq := loadTestFile(t, "testdata/PKCSReq.der") - msg := testParsePKIMessage(t, pkcsReq) - cacert, cakey := loadCACredentials(t) - err := msg.DecryptPKIEnvelope(cacert, cakey) - if err != nil { - t.Fatal(err) - } - csr := msg.CSRReqMessage.CSR - id, err := GenerateSubjectKeyID(csr.PublicKey) - if err != nil { - t.Fatal(err) - } - tmpl := &x509.Certificate{ - SerialNumber: big.NewInt(4), - Subject: csr.Subject, - NotBefore: time.Now().Add(-600).UTC(), - NotAfter: time.Now().AddDate(1, 0, 0).UTC(), - SubjectKeyId: id, - ExtKeyUsage: []x509.ExtKeyUsage{ - x509.ExtKeyUsageAny, - x509.ExtKeyUsageClientAuth, - }, - } - certRep, err := msg.SignCSR(cacert, cakey, tmpl) - if err != nil { - t.Fatal(err) - } - testParsePKIMessage(t, certRep.Raw) -} - -func TestNewCSRRequest(t *testing.T) { - key, err := newRSAKey(2048) - if err != nil { - t.Fatal(err) - } - derBytes, err := newCSR(key, "john.doe@example.com", "US", "com.apple.scep.2379B935-294B-4AF1-A213-9BD44A2C6688") - if err != nil { - t.Fatal(err) - } - csr, err := x509.ParseCertificateRequest(derBytes) - if err != nil { - t.Fatal(err) - } - clientcert, clientkey := loadClientCredentials(t) - cacert, cakey := loadCACredentials(t) - tmpl := &scep.PKIMessage{ - MessageType: scep.PKCSReq, - Recipients: []*x509.Certificate{cacert}, - SignerCert: clientcert, - SignerKey: clientkey, - } - - pkcsreq, err := scep.NewCSRRequest(csr, tmpl) - if err != nil { - t.Fatal(err) - } - msg := testParsePKIMessage(t, pkcsreq.Raw) - err = msg.DecryptPKIEnvelope(cacert, cakey) - if err != nil { - t.Fatal(err) - } -} - -// create a new RSA private key -func newRSAKey(bits int) (*rsa.PrivateKey, error) { - private, err := rsa.GenerateKey(rand.Reader, bits) - if err != nil { - return nil, err - } - return private, nil -} - -// create a CSR using the same parameters as Keychain Access would produce -func newCSR(priv *rsa.PrivateKey, email, country, cname string) ([]byte, error) { - subj := pkix.Name{ - Country: []string{country}, - CommonName: cname, - ExtraNames: []pkix.AttributeTypeAndValue{pkix.AttributeTypeAndValue{ - Type: []int{1, 2, 840, 113549, 1, 9, 1}, - Value: email, - }}, - } - template := &x509.CertificateRequest{ - Subject: subj, - } - return x509.CreateCertificateRequest(rand.Reader, template, priv) -} - -func loadTestFile(t *testing.T, path string) []byte { - data, err := ioutil.ReadFile(path) - if err != nil { - t.Fatal(err) - } - return data -} - -func loadCACredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { - cert, err := loadCertFromFile("testdata/testca/ca.crt") - if err != nil { - t.Fatal(err) - } - key, err := loadKeyFromFile("testdata/testca/ca.key") - if err != nil { - t.Fatal(err) - } - return cert, key -} - -func loadClientCredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { - cert, err := loadCertFromFile("testdata/testclient/client.pem") - if err != nil { - t.Fatal(err) - } - key, err := loadKeyFromFile("testdata/testclient/client.key") - if err != nil { - t.Fatal(err) - } - return cert, key -} - -const ( - rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" - certificatePEMBlockType = "CERTIFICATE" -) - -func loadCertFromFile(path string) (*x509.Certificate, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != certificatePEMBlockType { - return nil, errors.New("unmatched type or headers") - } - return x509.ParseCertificate(pemBlock.Bytes) -} - -// load an encrypted private key from disk -func loadKeyFromFile(path string) (*rsa.PrivateKey, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != rsaPrivateKeyPEMBlockType { - return nil, errors.New("unmatched type or headers") - } - - // testca key has a password - if len(pemBlock.Headers) > 0 { - password := []byte("") - b, err := x509.DecryptPEMBlock(pemBlock, password) - if err != nil { - return nil, err - } - return x509.ParsePKCS1PrivateKey(b) - } - - return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) - -} - -// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. -type rsaPublicKey struct { - N *big.Int - E int -} - -// GenerateSubjectKeyID generates SubjectKeyId used in Certificate -// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey -func GenerateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { - var pubBytes []byte - var err error - switch pub := pub.(type) { - case *rsa.PublicKey: - pubBytes, err = asn1.Marshal(rsaPublicKey{ - N: pub.N, - E: pub.E, - }) - if err != nil { - return nil, err - } - default: - return nil, errors.New("only RSA public key is supported") - } - - hash := sha1.Sum(pubBytes) - - return hash[:], nil -} diff --git a/vendor/github.com/micromdm/scep/scep/testdata/CertRep.der b/vendor/github.com/micromdm/scep/scep/testdata/CertRep.der deleted file mode 100755 index 16ebc2bebbbb96bf1c6666961c11e5d25a816c75..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4621 zcmbVPc|4Tu`k&2MhsM}db;nMDQSb5z;bu%ufBS1i{ z>aYbAh1;6$o+ z2H&H5Ynh*IZl01KH@l$T-355_=QSjCGPXQvx!-@Rz$eh6))qa_`Ldv*Dqi0u=x)P8 z*GLNPHLHoQwezK{Cxf(F#)k_N2)sP{Tt~Jx+M(ggF@yB;ci*_oz%gK zUMYXRqxWx91=Nh#74$lF0?cWdyVA`cXx0ijWt#=>iC53^7mD~LRANi%a|L~tvy5Kb z#?ehPo{bX~?v1QH^q>B8p6K^E#PepbOhJZVtunGtbV!3fUVD2oY#yO9EY)>62BG@g z*=j#mv7R;PX(VAUswQ--(sg{Q;+**Vt8rH_d<+nzc**{Kemii=t3u~Hc<^Gt+ zelP8`!J7=5m7PS~j(qX^j4yt(^zgvSN1_A7kf~SVVbk6#!Fp}h>4&#CoyIlhZoy+8 z;YZEsX?HesC1V+H7?*ESyjt5fcbfm{=?C($CS@4JVYky9)HijpE^Ze}H_{J(WM=eU zP2+KT-xNt=A{BCaI_~Q035DXG3I#kz4~GU+2fmv+O$a*<7A*-C+c#6aHhPI>sW*%B z%XLe?qUtokH20XwED|*pK!SFVdABSJ3IRhPU>Jb-n>)a?6d(YNp#y0C;#;T@P8D+s zpg*x_P?Q7@D{His<-hru76nmP1$bBy7&$;z27|%K02r((*_8jy1TJDU0rh_pJ4)Hg z#YxiA)zy(8NhDZ#y5I5ektA9XTqOZH84Y;_Ss64&M&>LUtEL5@&uS?spcPJRX$1v2 zX=yAFl==Hk!4x29&_fUq6bT6m0u5~j75CrgE{JYslq7ugVd*HT7CiS8CET%rxPkDd zIc{P)$3U9xH(O#F5V|#*9Zz6>Gt6FXjIU2nq0b8Bq)iE*WHmS+rlb~Q?5J^5_>XOL z6uX4SaUutP|LWHjvr=;4M1KoD|NW~arQ<;PTLN0>oM zWCOe>&8K1HXE2ay&s?RCBHxd_Tq6@z@OjqTbD`kT@24l<6O=@LIE5aS>Kg$y0r6%{ zV|3b>vI45>_vs$F(99H3=}Ud4l^qu1W=PHHOx<&`{U#DV5UPUMvpPM-UtxG5`{Us| zD!WoyJ15rsNO}cz-=GT#rYk?B7TLUeForxWm)Qq`q;_~1L-uoHog3GPr5wK51UU1GHyvyM} zZ;bB8!I%)12YU}7E9Xp=Il7XMcI>JUf<>8&GhtUX9gJXKG=f!ldhc#Oa{r{6F7hzS za3x=!=AQB>7xD-ib9BEe5oePZTJ1Bq-SB*~cV`XV|L$}|3Yz!+ts`1tAFbY51;W1P z{^~(J^P~v;>E4c3M{RF;aDrFDWiL|T{7T32#t^Is#70%vT%D6#>Z*Z$pM{Fz66tlr zkKIexJ#k9~r(v(sBeY?fugDVe3CtR7K z*J5DN(>7wDWqrXv19`K@spV><6}=7>*kLp@&Fkim*JsX%^xNrLtvZ7d5e{_3Me}DRm6=|r>cGrDT{lH-3)@t!Shx{oN1EdG ztC~A?w_FSHI9pt?pa1bEWD>>x zvvQ3h-kfXqLls2gapuK$md(}f^tJeXeo+5hZKI?gR%hZr>3and%I9I?%Bx_%DQf7V z@>o?F4>{6RFgw3wVef9UdYtvDy+`i@atjObw=>4Q?LM0+DIX@;8Z2lzT;b-{5L8&9 zYj@t4sx5Fx+P*C!X+bsd&Ff;gY z2vupEy7BULboiSKy85s4O^RX89N{#%b>5c_1mN&C#dDqSnx~;TSY<-t>+9_n@0pe* z*@<|jLMW>kt?iTQk^7dpAHKf4t*$bthaF0ZMpHKt;5Oy!emUYDjoQViu)Naha}Xdu z9rlhY_iAM0nE)fC`^(;>^=2vW8=gs3R>^bx;!T>k%(_qh;nDNAa3V2$q{m`29Ga$q zx`bwm*bdlnKa-s=h6I%%bEnivMk)PYQrpRxe(Uku@eMEJ1P#V5k;x21f!(89~Q~6-lL*kAMtHlh` zKXUg9I5rT^8&cv(;6tb_`3%8@%awGSK2n{5N;q}VDJfDBn%*+JXC}Hc%wB%>B>mlf z_mso=Ee40|T|?Ra{Te+S9#D1hGiroa2)94$O}lAkiAIg*C~RF^b;)PZ6QQDmjCV1C@g#Q(VVi1hUSU*`h?s*;!G1 z4B^SK*H*cF#&mbe0oFI$N(P)<_bkjtsG+1vmR7#6yV117>j{yCfcs^Lpd-!;?A{2ru?`M~y`)WCSa%cL#4y&+{hT9mt$+UvaYhp57D{?OAwhI-;h@JM1>JGl4OIOR=(~a|bfCk-)z9bCb zKn5a^0wDr)5CC8yNC3;HDS`&&_)rjnIru#dU?3Q441yu^WYh05nkVbW;7yPq7VV0`;?b@LOkpudWFr#9;{s0kAJOvn`+6Bq5yFG!ro77`;csOD zfDeU1K$NY5gP{=r;2I-6cwbq-7t_?v_m>`@J6GCEv#URHtir{Ab>(EFy7WY@eO;ds z_3oOxUbU&V@@JExmR+MBDGl7{h8Lw)KFZYjvZvE*r9pK|PMQ5%e0jGy%Wp>AtND## zS)G}+&rUqsd$%&w2Og$rDdzM~?bb2WM57v)LUDp-w|DAm$<#B^rBj(eRpr@5ncIeq_g;oi>_cw`+Jl|Vc zWNjbrcI0?Z{$*(mNoG8^$=2mTZQ}g}$+`YKnQ?BIYK7A^-pElkkGY0wV<~dzgDwd{Plm~T7HAS&wXM!U8P-~6D@wzPAuCR$&Y6|_cB$-E8@ki(m{F(%-eya12C(h=-8aZ5& zh*R;fK8QBW8oW=bhN~Cvrv~Ws9rMX3@N9bcz_3l%CEC`}wRZ$@t4QA2SUyh0a?$bP zAVJ`Hw1Zwwh+tLuSn(_Mll^ZR#om>$0#+7WOWQg}(eh<-+yF(dBPT6~n0oa(?R&Gt&6 zmW`>5B|b1#JTqu7>bYX}QfZx%On<2DM2Shsa~cWSs?i;NMG;@$lATySkzrjWCz%-J zzvvtGmTgnwxLNzW^{TwBq%Hfw%_9uQ{P~@q$JC~q(~{D{xUrct@~u-laO*L^sH93l zCPgN+b<#k6baok!7D~8#!9RWMJWg-qY7m4oq+RM7F(>Z=OhipLR zt;%PIyH1yi<9(Cdr1xz*p&H(I_1Q05Z-Tg}m>!mT+ACy8`CxUx>|kE176Sp7c&M1? zHTXRP4Fcd#^Do51&kk4ylG;E9dXp%{f}(Q3ob0G_zSy(~iJx_&Fp5J4WDE3sDDwY}VJnl4&-@nve0PS%K7 z{NA_o3VvNZ%khM?2Y5p8-8nA08IXP5Hg{5F4+l++yw|yD+`YVik)BDpq#vYqw(K|ej=pm=g7>~#hw)o? z**z?3@D-2{7d}`dy1qUf-gGg&C(sFZ$9ZhRa8ZP@Ce}cJI1iYD=zI(xD4r1?fGA22j9F4M_bf$`wTcU>$=&gShyw zeNx=E5pO`BUlR-P@!`<-%FtWRbe z-1bdu-xDYP4sg-5l#TmbpLV7~Buq0QV*920xty3cbDY)tO?O22U51%)Zz`qmm{(`s zi=BU>RqZ$$G2dfylSM!37GH?=!E%!q{r|}GwkSOH@CMDUownG=9jY)Msl6^cY_;35 z$7<8ycx8$~qRYgMFm*O(*tstlffJem(?N_)%P-6BGO-m>!pD<}o2hBV>V}dvEE4me zZNE`QesoePze2<{{{>aI7ga%V3(}3vb_GaM!{Vd)rG|Ez@#kJCH51vcn~&#WWK>t01XR$3wY#|`5~JR7R2!1rEwEZG&2Vvg>PvBe6Z+GqXemaKgGaO z7zwK~Z(@ibYf1j^NUxyKnHAv~bpX=;p*RlKz^j|`2GIc0Bf+Kw$dbhSh?e@g76d&a zfncEnk#xztQPnXsg@5$N*Od>Tux!uasCL%*=jpzMyFRpuy*7w+Jylqzx{^3xlNhjW z7L&h{h7!0nOs#UWd@mI$c~zF>ZZ0F0MXferEcC@r()Pzzk}m^J~In)ze0m%bs3P)FT|pLMmK`+3F - - - - PayloadContent - - - PayloadContent - - Key Type - RSA - Keysize - 1024 - Retries - 3 - RetryDelay - 10 - URL - http://localhost:9001/scep - - PayloadDescription - Configures SCEP settings - PayloadDisplayName - SCEP - PayloadIdentifier - com.apple.security.scep.063D7953-1338-4BF0-8F99-913382996224 - PayloadType - com.apple.security.scep - PayloadUUID - 063D7953-1338-4BF0-8F99-913382996224 - PayloadVersion - 1 - - - PayloadCertificateFileName - ca.crt - PayloadContent - - LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZPRENDQXlD - Z0F3SUJBZ0lCQVRBTkJna3Foa2lHOXcwQkFRc0ZBREF0TVF3d0Nn - WURWUVFHRXdOVlUwRXgKRURBT0JnTlZCQW9UQjJWMFkyUXRZMkV4 - Q3pBSkJnTlZCQXNUQWtOQk1CNFhEVEUyTURVeU9URXpORGN3TlZv - WApEVEkyTURVeU9URXpORGN3T0Zvd0xURU1NQW9HQTFVRUJoTURW - Vk5CTVJBd0RnWURWUVFLRXdkbGRHTmtMV05oCk1Rc3dDUVlEVlFR - TEV3SkRRVENDQWlJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dJUEFE - Q0NBZ29DZ2dJQkFMRUcKUzg2NlVmNzl6bm14OCtCYWtKMTd0b3g4 - VlllbTBOWnpQYzJqRjRSVldYZlQ0ODFZejlqZHNqWnViTUNGdUpp - SQpKenBNQlQ3UnpYdlp2dXpNelpFZTc3VGIwbU0rODN0NWtWd1dX - dXhrRXo3SFFuMHRXeHVMUjdOR2FBaTVNSDUzCnBjU0dSTkg4UmdD - N1dkaHlRLzNId05HV09iZTB3UVQ2OXRmejFwSERTdk5SOXY3RFM5 - S0lpR3NNYytkY3FheXoKbjNZUXV3RVY4bkQxS0dlbnhFRmpGaDBO - c1A1RktyekRyc3Z6ZEZPV0xKM2plZGZEQ1NRU2UweTMzc3laSVlB - UQp3UzIvYitpbzZHTVdEUWVtY2lyTjlRaUkxTkdrY045emlvUFJ1 - WVB4a2F4R05hME8rM2NUZ0E4ZWdURk1pZ3ZJCjRaRnNtRVJmWmtK - TTRzQk1LMXVVbXhYS2I4N25BMXpvb1B2UGsxS0dRQ2hYQkVucmtI - UGJrUDFWTyt5WU9TNG0KdDlMRHdlR1ZTNkdvQzV2anFRZ3ltT0hl - Y2FOZktwQm5VNnQ3ZlAvYUVaVUYrNm14UktvZm9sUi9oVGtua1ZO - YwpxMm5yWEVKcHo4SjczSXE4cmtMMHJOQUV1MWg4M25wUEFvVWdk - Rmh3SHpscTlTaFJieitaUVR4ZEF2NU1PVnMrCjZGOXFjbWJ2LzZD - NHhjMU4xeEgyTkFKOGFGWlR4c3c0bnk0M2hpN0RneVJoMUxKeGNi - MkJwN0pNYUQ1NkNNU0EKMHpKcXhJaVY1a0dVd2JtckJqWE15dmpZ - engvMHFJM2ozYlpsM3A4QmpaZ3lqa3ZPUDBuQXJQM2JieTVtRVVZ - eAppNytZZ1BtOGRmR0l6UGgxOUk0b0ZSZXN6T0psK0pyZExuYmY0 - NWVmQWdNQkFBR2pZekJoTUE0R0ExVWREd0VCCi93UUVBd0lDQkRB - UEJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXQkJUNlhE - L1BCYVY3R2JGRW54T20KM09KM2RlYW1rekFmQmdOVkhTTUVHREFX - Z0JUNlhEL1BCYVY3R2JGRW54T20zT0ozZGVhbWt6QU5CZ2txaGtp - Rwo5dzBCQVFzRkFBT0NBZ0VBQzZ5QkhyUkVsWjdvdkRycWpWQmY4 - ZkxHK25JTkVUUEova1BUbFROdHZxQ2xMYWVFCk5LUEg2SlZwMC91 - dXNvS21xdkUwTHh5QkVkUDd3YUhRVnEyWG5mWWdnRENOakFVRnhk - djdPS0F3bEJqSjBKR3MKNVJzSjlERWVoeUxlY25ERERodGU5Mk0y - eFVjZk1ldDFCbXVpekxEREthVVUxN3NJMWcvVU5FK2M3aFZpWkEy - SgplK3dlelZPVVpxQ1kwcElDc200YXI4SkJZL3BmVVorMUowMEFa - SnRYdVZXcUs1R1lHa3JMWjdaak56ekRGMGNZClVtSnhraTVyajEx - WHBDQ1FPWmpWQitQcDN0N1lwVU9leTFFQysxZktLcmRTNDB6YVJT - M1ZWZ2grR3VhdnM1SFYKZWdCektEUVV1UnJaRGJvZEpTdjI4Ulls - VmJGVG1rbDNoR0dORTBsMnYwTDJYSGFzWkhvQmtEWnp6OW5MdWlJ - OApaZGhXUytmbjdkYnN3TjlXenpCK2RQektTMVdrVGo1UlhML2x1 - SS83K2ZZTlF5dklKWWRuTkNlZ3lpMkMyeVRECmEvdm1GSmtCVSt1 - TEhXc1c5YThSNUNhN0E5MWx0Sm9iVEpFM3V3eGRYdVpNVHJtbFdL - c0ViaHFIQ3FPN2QwajgKSWdZR3hEbzl5c2ZBNEFPaU5EeGxwN2xY - eFYvSkZPc3VHWE5kRktjREZ5a0xaNXUyMVg5aG85ZnB0V0pEUDlK - TgpOTk9YakMwSnYyVUdackh6ZTZJcXlMNUpxeE9HcEsyMlBRSXdw - WndFeHdpalVvbStMSDVWRVhLMXpwWHp3QzkzCldYV1Z0R09XNHlF - cXYwVlRuN3ZhZkllTTVHQlRKNDRnZ3BrcDRScEZXb0JNWmNBRmo4 - Z0UvOUFVYUhvPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== - - PayloadDescription - Configures certificate settings. - PayloadDisplayName - ca.crt - PayloadIdentifier - com.apple.security.root.2E5B325F-84CA-4914-844F-703F9C4B11CE - PayloadType - com.apple.security.root - PayloadUUID - 2E5B325F-84CA-4914-844F-703F9C4B11CE - PayloadVersion - 1 - - - PayloadDisplayName - scept - PayloadIdentifier - vvrantchmbp.local.A795EFE8-60CA-47DA-92F3-FE2E435D800F - PayloadRemovalDisallowed - - PayloadType - Configuration - PayloadUUID - 7F0CF6ED-09FF-490E-AD53-89ACB920CD37 - PayloadVersion - 1 - - diff --git a/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.key b/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.key deleted file mode 100644 index be2febb..0000000 --- a/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.key +++ /dev/null @@ -1,19 +0,0 @@ -Bag Attributes - friendlyName: com.apple.security.scep.063D7953-1338-4BF0-8F99-913382996224 - localKeyID: A1 30 90 76 1A 30 F6 66 64 F8 5D 37 43 3D 20 65 E1 11 2B A1 -Key Attributes: ------BEGIN RSA PRIVATE KEY----- -MIICXgIBAAKBgQDT9YGr0H8dpozAEi5l2XkWyKy2JD3yEybI9A1ZDXcK/78UPQ+C -4tBb6BTRJWDWoZFlFcHUGbZWXbySPw6ggBsLl4feF1A+hjtCjlZsRF4mnfctixkr -dP+UGl37UunsW63mn8uM6oM+7elhB2zRscZrZPBDKZx1V+Et+BFrX49xNwIDAQAB -AoGAP9bzDmfG0YxnWjZfqSd+NCGO+3EhAzdHeEEhgA/xKevrhlH5yQc9kGDvXCrw -5tRU8WhDL/nqlEq5UCcT5b2P5zp1L0PY+X6gD5C7KGEIio5SvimAnQMh2HCKftDc -KX9NA9EJLq9BUsqK9HjXdsfIGzyoqhZQpDGTrgyVlfm/zwkCQQDyuKJvxm/6tWry -GBN0eBLyA4F738MFP/3kb87zUsGTD8dh92vwjMhGv1woKp09POs2s2MnADw2wOEa -hh+v6R5zAkEA344KSwaKZZSf7E5qFayg3qG9M55uhbus9CazoAWiceYMR6ImIevA -EtnhwQczIRGI8Bp4jgUtO9gu4IgjCUHNLQJBAIJkS+cuPGP75+sMog70noDi/0GT -0MnWOcfphMzUzWb6mAr6B0Of7cuL668sTXJjcpzdO8vs5WworAU6vnUbEB8CQQCB -+Hy3fcf8otoPcs9uZnzosrPjTNsI2UIGeHG6OUxmV88P3o+47O0wiIgdx2fMc/tf -TKSGPTA9OMSYOc3U1fLJAkEArLyCHxxDzcEuhyHnmoct/dTUg5Q8CYKIQfo5oVKZ -jvtL/r0udFpxLUDxZ7590I32cTSrtfgNBJegHr54YKN9KA== ------END RSA PRIVATE KEY----- diff --git a/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.pem b/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.pem deleted file mode 100644 index ca00313..0000000 --- a/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.pem +++ /dev/null @@ -1,28 +0,0 @@ -Bag Attributes - friendlyName: com.apple.security.scep.063D7953-1338-4BF0-8F99-913382996224 - localKeyID: A1 30 90 76 1A 30 F6 66 64 F8 5D 37 43 3D 20 65 E1 11 2B A1 -subject=/CN=com.apple.security.scep.063D7953-1338-4BF0-8F99-913382996224 -issuer=/C=USA/O=etcd-ca/OU=CA ------BEGIN CERTIFICATE----- -MIIDyDCCAbCgAwIBAgIBBDANBgkqhkiG9w0BAQsFADAtMQwwCgYDVQQGEwNVU0Ex -EDAOBgNVBAoTB2V0Y2QtY2ExCzAJBgNVBAsTAkNBMB4XDTE2MDUzMTExMzAxNFoX -DTE3MDUzMTExMzAxNFowRzFFMEMGA1UEAxM8Y29tLmFwcGxlLnNlY3VyaXR5LnNj -ZXAuMDYzRDc5NTMtMTMzOC00QkYwLThGOTktOTEzMzgyOTk2MjI0MIGfMA0GCSqG -SIb3DQEBAQUAA4GNADCBiQKBgQDT9YGr0H8dpozAEi5l2XkWyKy2JD3yEybI9A1Z -DXcK/78UPQ+C4tBb6BTRJWDWoZFlFcHUGbZWXbySPw6ggBsLl4feF1A+hjtCjlZs -RF4mnfctixkrdP+UGl37UunsW63mn8uM6oM+7elhB2zRscZrZPBDKZx1V+Et+BFr -X49xNwIDAQABo10wWzAZBgNVHSUEEjAQBgRVHSUABggrBgEFBQcDAjAdBgNVHQ4E -FgQUoTCQdhow9mZk+F03Qz0gZeERK6EwHwYDVR0jBBgwFoAU+lw/zwWlexmxRJ8T -ptzid3XmppMwDQYJKoZIhvcNAQELBQADggIBACWTrU5VMLd+kVu/2AxJMbCmCFd/ -DJNvCuGqCE4v3As11CUdD5iiypj6bWfqJ4fRhT8N+mMj2CGyUUCh2f3HCGitNWht -F6WJDjlDeoFAklrs7i/nGHfNMVEewkoZ0YEv+B4ShPujj26+8Rwc3zmkj7Xy3G2j -p9pEv5IU3TEjlGdlzsRLqMVkh/Y/qbMfKHS35OQOqk+n7OGp5IgE2qp2BhvNXW/9 -+x+OTNnSjoQWivqKAuw9Wjway5b++Gi0DSSqn+fhhlJFa1UE5USDPx7OePeTctpF -nCeNi1HspTcKfTzWHBH+A47+f8uUU2akhbZ50ve9rvXO+PEt0McjiJctH39g/gsm -eUbO4jll+3X77/y8Fd4nBqj6+EbIus6xg5J2kkp2goDk7Mjr9NMEqgAYCKfAtqKW -rXBELcmgE4scJ85xXdh9mB8OlUuh+YShifpOlB3b24VQSbPny5aLHivIBqRQAYKw -cuh0DTIOx3MefQR2W3+rc0f5Q92ntT24k2jD4QXl7BfWsGr6fF5dJE26QJANOgQH -T1qnfIlaEirJxV+Z/E+NKN1wFQNUjgSM4GYpAOtOJPCAH6HbCTa3Mjp2/TkZBAoK -wPNcmfPhLCnQNFGYmAQP2u3naPdFZHyAhnMsRJxCh5UVcD/bOfk0DevEOimCYgki -WrNcgABYGlAaBpo7 ------END CERTIFICATE----- diff --git a/vendor/github.com/micromdm/scep/server/depot.go b/vendor/github.com/micromdm/scep/server/depot.go deleted file mode 100644 index 21d5823..0000000 --- a/vendor/github.com/micromdm/scep/server/depot.go +++ /dev/null @@ -1,213 +0,0 @@ -package scepserver - -import ( - "crypto/rsa" - "crypto/x509" - "encoding/pem" - "errors" - "io/ioutil" - "math/big" - "os" - "path/filepath" -) - -// Depot is a repository for managing certificates -type Depot interface { - CA(pass []byte) ([]*x509.Certificate, *rsa.PrivateKey, error) - Put(name string, cert []byte) error - Serial() (*big.Int, error) -} - -// NewFileDepot returns a new cert depot -func NewFileDepot(path string) (Depot, error) { - return fileDepot{dirPath: path}, nil -} - -type fileDepot struct { - dirPath string -} - -func (d fileDepot) CA(pass []byte) ([]*x509.Certificate, *rsa.PrivateKey, error) { - caPEM, err := d.getFile("ca.pem") - if err != nil { - return nil, nil, err - } - cert, err := loadCert(caPEM.Data) - if err != nil { - return nil, nil, err - } - keyPEM, err := d.getFile("ca.key") - if err != nil { - return nil, nil, err - } - key, err := loadKey(keyPEM.Data, pass) - if err != nil { - return nil, nil, err - } - return []*x509.Certificate{cert}, key, nil -} - -// file permissions -const ( - certPerm = 0444 - serialPerm = 0400 -) - -// Put adds a certificate to the depot -func (d fileDepot) Put(name string, data []byte) error { - if data == nil { - return errors.New("data is nil") - } - - if err := os.MkdirAll(d.dirPath, 0755); err != nil { - return err - } - - serial, err := d.Serial() - if err != nil { - return err - } - - name = d.path(name) + "." + serial.String() + ".pem" - file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, certPerm) - if err != nil { - return err - } - defer file.Close() - - if _, err := file.Write(pemCert(data)); err != nil { - file.Close() - os.Remove(name) - return err - } - - if err := d.incrementSerial(serial); err != nil { - return err - } - - return nil -} - -func (d fileDepot) Serial() (*big.Int, error) { - name := d.path("serial") - s := big.NewInt(2) - if err := d.check("serial"); err != nil { - // assuming it doesnt exist, create - if err := d.writeSerial(s); err != nil { - return nil, err - } - return s, nil - } - data, err := ioutil.ReadFile(name) - if err != nil { - return nil, err - } - serial := s.SetBytes(data) - return serial, nil -} - -func (d fileDepot) writeSerial(serial *big.Int) error { - if err := os.MkdirAll(d.dirPath, 0755); err != nil { - return err - } - name := d.path("serial") - os.Remove(name) - - file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, serialPerm) - if err != nil { - return err - } - defer file.Close() - - if _, err := file.Write(serial.Bytes()); err != nil { - file.Close() - os.Remove(name) - return err - } - return nil -} - -// read serial and increment -func (d fileDepot) incrementSerial(s *big.Int) error { - serial := s.Add(s, big.NewInt(1)) - if err := d.writeSerial(serial); err != nil { - return err - } - return nil -} - -type file struct { - Info os.FileInfo - Data []byte -} - -func (d *fileDepot) check(path string) error { - name := d.path(path) - _, err := os.Stat(name) - if err != nil { - return err - } - return nil -} - -func (d *fileDepot) getFile(path string) (*file, error) { - if err := d.check(path); err != nil { - return nil, err - } - fi, err := os.Stat(d.path(path)) - if err != nil { - return nil, err - } - b, err := ioutil.ReadFile(d.path(path)) - return &file{fi, b}, err -} - -func (d *fileDepot) path(name string) string { - return filepath.Join(d.dirPath, name) -} - -const ( - rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" - certificatePEMBlockType = "CERTIFICATE" -) - -// load an encrypted private key from disk -func loadKey(data []byte, password []byte) (*rsa.PrivateKey, error) { - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != rsaPrivateKeyPEMBlockType { - return nil, errors.New("unmatched type or headers") - } - - b, err := x509.DecryptPEMBlock(pemBlock, password) - if err != nil { - return nil, err - } - return x509.ParsePKCS1PrivateKey(b) - -} - -// load an encrypted private key from disk -func loadCert(data []byte) (*x509.Certificate, error) { - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != certificatePEMBlockType { - return nil, errors.New("unmatched type or headers") - } - - return x509.ParseCertificate(pemBlock.Bytes) -} - -func pemCert(derBytes []byte) []byte { - pemBlock := &pem.Block{ - Type: certificatePEMBlockType, - Headers: nil, - Bytes: derBytes, - } - out := pem.EncodeToMemory(pemBlock) - return out -} diff --git a/vendor/github.com/micromdm/scep/server/endpoint.go b/vendor/github.com/micromdm/scep/server/endpoint.go deleted file mode 100644 index 6278a71..0000000 --- a/vendor/github.com/micromdm/scep/server/endpoint.go +++ /dev/null @@ -1,17 +0,0 @@ -package scepserver - -// SCEPRequest is a SCEP server request. -type SCEPRequest struct { - Operation string - Message []byte - Err error // request error -} - -// SCEPResponse is a SCEP server response. -// Business errors will be encoded as a CertRep message -// with pkiStatus FAILURE and a failInfo attribute. -type SCEPResponse struct { - CACertNum int //chain - Data []byte - Err error // response error -} diff --git a/vendor/github.com/micromdm/scep/server/service.go b/vendor/github.com/micromdm/scep/server/service.go deleted file mode 100644 index 69290ba..0000000 --- a/vendor/github.com/micromdm/scep/server/service.go +++ /dev/null @@ -1,211 +0,0 @@ -package scepserver - -import ( - "crypto" - "crypto/rsa" - "crypto/sha1" - "crypto/x509" - "encoding/asn1" - "errors" - "math/big" - "time" - - "github.com/micromdm/scep/scep" - - "golang.org/x/net/context" -) - -// Service is the interface for all supported SCEP server operations. -type Service interface { - // GetCACaps returns a list of options - // which are supported by the server. - GetCACaps(ctx context.Context) ([]byte, error) - - // GetCACert returns CA certificate or - // a CA certificate chain with intermediates - // in a PKCS#7 Degenerate Certificates format - GetCACert(ctx context.Context) ([]byte, int, error) - - // PKIOperation handles incoming SCEP messages such as PKCSReq and - // sends back a CertRep PKIMessag. - PKIOperation(ctx context.Context, msg []byte) ([]byte, error) - - // GetNextCACert returns a replacement certificate or certificate chain - // when the old one expires. The response format is a PKCS#7 Degenerate - // Certificates type. - GetNextCACert(ctx context.Context) ([]byte, error) -} - -type service struct { - depot Depot - ca []*x509.Certificate // CA cert or chain - caKey *rsa.PrivateKey - caKeyPassword []byte - csrTemplate *x509.Certificate - challengePassword string -} - -func (svc service) GetCACaps(ctx context.Context) ([]byte, error) { - defaultCaps := []byte(`POSTPKIOperation`) - return defaultCaps, nil -} - -func (svc service) GetCACert(ctx context.Context) ([]byte, int, error) { - if len(svc.ca) == 0 { - return nil, 0, errors.New("missing CA Cert") - } - if len(svc.ca) == 1 { - return svc.ca[0].Raw, 1, nil - } - data, err := scep.DegenerateCertificates(svc.ca) - return data, len(svc.ca), err -} - -func (svc service) PKIOperation(ctx context.Context, data []byte) ([]byte, error) { - msg, err := scep.ParsePKIMessage(data) - if err != nil { - // handle err - return nil, err - } - ca := svc.ca[0] - if err := msg.DecryptPKIEnvelope(svc.ca[0], svc.caKey); err != nil { - return nil, err - } - - // validate challenge passwords - if msg.MessageType == scep.PKCSReq { - if !svc.challengePasswordMatch(msg.CSRReqMessage.ChallengePassword) { - // handle err - return nil, errors.New("scep challenge password does not match") - } - } - - csr := msg.CSRReqMessage.CSR - id, err := generateSubjectKeyID(csr.PublicKey) - if err != nil { - return nil, err - } - - serial, err := svc.depot.Serial() - if err != nil { - return nil, err - } - - // create cert template - tmpl := &x509.Certificate{ - SerialNumber: serial, - Subject: csr.Subject, - NotBefore: time.Now().Add(-600).UTC(), - NotAfter: time.Now().AddDate(1, 0, 0).UTC(), - SubjectKeyId: id, - KeyUsage: x509.KeyUsageDigitalSignature, - ExtKeyUsage: []x509.ExtKeyUsage{ - x509.ExtKeyUsageClientAuth, - }, - } - - certRep, err := msg.SignCSR(ca, svc.caKey, tmpl) - if err != nil { - return nil, err - } - - crt := certRep.CertRepMessage.Certificate - name := certName(crt) - if err := svc.depot.Put(name, crt.Raw); err != nil { - return nil, err - } - - return certRep.Raw, nil - -} - -func certName(crt *x509.Certificate) string { - if crt.Subject.CommonName != "" { - return crt.Subject.CommonName - } - return string(crt.Signature) -} - -func (svc service) GetNextCACert(ctx context.Context) ([]byte, error) { - panic("not implemented") -} - -func (svc service) challengePasswordMatch(pw string) bool { - if svc.challengePassword == "" { - // empty password, don't validate - return true - } - if svc.challengePassword == pw { - return true - } - return false -} - -// ServiceOption is a server configuration option -type ServiceOption func(*service) error - -// ChallengePassword is an optional argument to NewService -// which allows setting a preshared key for SCEP. -func ChallengePassword(pw string) ServiceOption { - return func(s *service) error { - s.challengePassword = pw - return nil - } -} - -// CAKeyPassword is an optional argument to NewService for -// specifying the CA private key password. -func CAKeyPassword(pw []byte) ServiceOption { - return func(s *service) error { - s.caKeyPassword = pw - return nil - } -} - -// NewService creates a new scep service -func NewService(depot Depot, opts ...ServiceOption) (Service, error) { - s := &service{ - depot: depot, - } - for _, opt := range opts { - if err := opt(s); err != nil { - return nil, err - } - } - - var err error - s.ca, s.caKey, err = depot.CA(s.caKeyPassword) - if err != nil { - return nil, err - } - return s, nil -} - -// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. -type rsaPublicKey struct { - N *big.Int - E int -} - -// GenerateSubjectKeyID generates SubjectKeyId used in Certificate -// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey -func generateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { - var pubBytes []byte - var err error - switch pub := pub.(type) { - case *rsa.PublicKey: - pubBytes, err = asn1.Marshal(rsaPublicKey{ - N: pub.N, - E: pub.E, - }) - if err != nil { - return nil, err - } - default: - return nil, errors.New("only RSA public key is supported") - } - - hash := sha1.Sum(pubBytes) - - return hash[:], nil -} diff --git a/vendor/github.com/micromdm/scep/server/service_logging.go b/vendor/github.com/micromdm/scep/server/service_logging.go deleted file mode 100644 index 3c4a1e8..0000000 --- a/vendor/github.com/micromdm/scep/server/service_logging.go +++ /dev/null @@ -1,54 +0,0 @@ -package scepserver - -import ( - "time" - - "github.com/go-kit/kit/log" - "golang.org/x/net/context" -) - -type loggingService struct { - logger log.Logger - Service -} - -// NewLoggingService creates adds logging to the SCEP service -func NewLoggingService(logger log.Logger, s Service) Service { - return &loggingService{logger, s} -} - -func (mw loggingService) GetCACaps(ctx context.Context) (caps []byte, err error) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "GetCACaps", - "err", err, - "took", time.Since(begin), - ) - }(time.Now()) - caps, err = mw.Service.GetCACaps(ctx) - return -} - -func (mw loggingService) GetCACert(ctx context.Context) (cert []byte, certNum int, err error) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "GetCACert", - "err", err, - "took", time.Since(begin), - ) - }(time.Now()) - cert, certNum, err = mw.Service.GetCACert(ctx) - return -} - -func (mw loggingService) PKIOperation(ctx context.Context, data []byte) (certRep []byte, err error) { - defer func(begin time.Time) { - _ = mw.logger.Log( - "method", "PKIOperation", - "err", err, - "took", time.Since(begin), - ) - }(time.Now()) - certRep, err = mw.Service.PKIOperation(ctx, data) - return -} diff --git a/vendor/github.com/micromdm/scep/server/transport.go b/vendor/github.com/micromdm/scep/server/transport.go deleted file mode 100644 index a2fb664..0000000 --- a/vendor/github.com/micromdm/scep/server/transport.go +++ /dev/null @@ -1,181 +0,0 @@ -package scepserver - -import ( - "bytes" - "errors" - "fmt" - "io/ioutil" - "net/http" - - "github.com/go-kit/kit/endpoint" - kitlog "github.com/go-kit/kit/log" - kithttp "github.com/go-kit/kit/transport/http" - "golang.org/x/net/context" -) - -// ServiceHandler is an HTTP Handler for a SCEP endpoint. -func ServiceHandler(ctx context.Context, svc Service, logger kitlog.Logger) http.Handler { - opts := []kithttp.ServerOption{ - kithttp.ServerErrorLogger(logger), - kithttp.ServerBefore(updateContext), - } - - scepHandler := kithttp.NewServer( - ctx, - makeSCEPEndpoint(svc), - decodeSCEPRequest, - encodeSCEPResponse, - opts..., - ) - - mux := http.NewServeMux() - mux.Handle("/scep", scepHandler) - return mux -} - -func updateContext(ctx context.Context, r *http.Request) context.Context { - q := r.URL.Query() - if _, ok := q["operation"]; ok { - ctx = context.WithValue(ctx, "operation", q.Get("operation")) - } - return ctx -} - -// EncodeSCEPRequest encodes a SCEP http request -func EncodeSCEPRequest(ctx context.Context, r *http.Request, request interface{}) error { - req := request.(SCEPRequest) - params := r.URL.Query() - params.Set("operation", req.Operation) - switch r.Method { - case "GET": - if len(req.Message) > 0 { - return errors.New("only POSTPKIOperation supported") - } - case "POST": - var buf bytes.Buffer - _, err := buf.Write(req.Message) - if err != nil { - return err - } - r.Body = ioutil.NopCloser(&buf) - default: - return errors.New("method not supported") - } - r.URL.RawQuery = params.Encode() - return nil -} - -// DecodeSCEPRequest decodes an HTTP request to the SCEP server -// extracting the Operation and Message. -func decodeSCEPRequest(ctx context.Context, r *http.Request) (interface{}, error) { - msg, err := message(r) - if err != nil { - return nil, err - } - - request := SCEPRequest{ - Message: msg, - } - - return request, nil -} - -// extract message from request -func message(r *http.Request) ([]byte, error) { - switch r.Method { - case "GET": - var msg string - q := r.URL.Query() - if _, ok := q["message"]; ok { - msg = q.Get("message") - } - return []byte(msg), nil - case "POST": - return ioutil.ReadAll(r.Body) - default: - return nil, errors.New("method not supported") - } -} - -// EncodeSCEPResponse writes a SCEP response back to the SCEP client. -func encodeSCEPResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { - resp := response.(SCEPResponse) - if resp.Err != nil { - fmt.Println(resp.Err) - return resp.Err - } - w.Header().Set("Content-Type", contentHeader(ctx, resp.CACertNum)) - w.Write(resp.Data) - return nil -} - -// DecodeSCEPResponse decodes a SCEP response -func DecodeSCEPResponse(ctx context.Context, r *http.Response) (interface{}, error) { - data, err := ioutil.ReadAll(r.Body) - if err != nil { - return nil, err - } - resp := SCEPResponse{ - Data: data, - } - header := r.Header.Get("Content-Type") - if header == certChainHeader { - // TODO decode the response instead of just passing []byte around - // 0 or 1 - resp.CACertNum = 2 - } - return resp, nil -} - -const ( - certChainHeader = "application/x-x509-ca-ra-cert" - leafHeader = "application/x-x509-ca-cert" - pkiOpHeader = "application/x-pki-message" -) - -func contentHeader(ctx context.Context, certNum int) string { - op := ctx.Value("operation") - switch op { - case "GetCACert": - if certNum > 1 { - return certChainHeader - } - return leafHeader - case "PKIOperation": - return pkiOpHeader - default: - return "text/plain" - } -} - -func makeSCEPEndpoint(svc Service) endpoint.Endpoint { - return func(ctx context.Context, request interface{}) (interface{}, error) { - op := ctx.Value("operation") - if op == nil { - return SCEPResponse{Err: errors.New("unknown operation")}, nil - } - req := request.(SCEPRequest) - switch op { - case "GetCACaps": - caps, err := svc.GetCACaps(ctx) - if err != nil { - return SCEPResponse{Err: err}, nil - } - return SCEPResponse{Data: caps}, nil - case "GetCACert": - cert, certNum, err := svc.GetCACert(ctx) - if err != nil { - return SCEPResponse{Err: err, CACertNum: certNum}, nil - } - return SCEPResponse{Data: cert}, nil - case "PKIOperation": - resp, err := svc.PKIOperation(ctx, req.Message) - if err != nil { - return SCEPResponse{Err: err}, nil - } - return SCEPResponse{Data: resp}, nil - default: - return nil, errors.New("operation not implemented") - } - } -} diff --git a/vendor/github.com/micromdm/scep/server/transport_test.go b/vendor/github.com/micromdm/scep/server/transport_test.go deleted file mode 100644 index 03a85ce..0000000 --- a/vendor/github.com/micromdm/scep/server/transport_test.go +++ /dev/null @@ -1,177 +0,0 @@ -package scepserver_test - -import ( - "bytes" - "crypto/rand" - "crypto/rsa" - "crypto/x509" - "crypto/x509/pkix" - "encoding/pem" - "errors" - "io/ioutil" - "net/http" - "net/http/httptest" - "testing" - - kitlog "github.com/go-kit/kit/log" - "golang.org/x/net/context" - - "github.com/micromdm/scep/server" -) - -func TestCACaps(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - url := server.URL + "/scep?operation=GetCACaps" - resp, err := http.Get(url) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != http.StatusOK { - t.Error("expected", http.StatusOK, "got", resp.StatusCode) - } -} - -func TestPKIOperation(t *testing.T) { - server, _ := newServer(t) - defer server.Close() - pkcsreq := loadTestFile(t, "../scep/testdata/PKCSReq.der") - body := bytes.NewReader(pkcsreq) - url := server.URL + "/scep?operation=PKIOperation" - resp, err := http.Post(url, "", body) - if err != nil { - t.Fatal(err) - } - if resp.StatusCode != http.StatusOK { - t.Error("expected", http.StatusOK, "got", resp.StatusCode) - } -} - -func newServer(t *testing.T, opts ...scepserver.ServiceOption) (*httptest.Server, scepserver.Service) { - var err error - var depot scepserver.Depot // cert storage - { - depot, err = scepserver.NewFileDepot("../scep/testdata/testca") - if err != nil { - t.Fatal(err) - } - } - var svc scepserver.Service // scep service - { - svc, err = scepserver.NewService(depot, opts...) - if err != nil { - t.Fatal(err) - } - } - ctx := context.Background() - logger := kitlog.NewNopLogger() - handler := scepserver.ServiceHandler(ctx, svc, logger) - server := httptest.NewServer(handler) - return server, svc -} - -/* helpers */ -const ( - rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" - certificatePEMBlockType = "CERTIFICATE" -) - -func loadTestFile(t *testing.T, path string) []byte { - data, err := ioutil.ReadFile(path) - if err != nil { - t.Fatal(err) - } - return data -} - -// create a new RSA private key -func newRSAKey(bits int) (*rsa.PrivateKey, error) { - private, err := rsa.GenerateKey(rand.Reader, bits) - if err != nil { - return nil, err - } - return private, nil -} - -// create a CSR using the same parameters as Keychain Access would produce -func newCSR(priv *rsa.PrivateKey, email, country, cname string) ([]byte, error) { - subj := pkix.Name{ - Country: []string{country}, - CommonName: cname, - ExtraNames: []pkix.AttributeTypeAndValue{pkix.AttributeTypeAndValue{ - Type: []int{1, 2, 840, 113549, 1, 9, 1}, - Value: email, - }}, - } - template := &x509.CertificateRequest{ - Subject: subj, - } - return x509.CreateCertificateRequest(rand.Reader, template, priv) -} -func loadCACredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { - cert, err := loadCertFromFile("../scep/testdata/testca/ca.crt") - if err != nil { - t.Fatal(err) - } - key, err := loadKeyFromFile("../scep/testdata/testca/ca.key") - if err != nil { - t.Fatal(err) - } - return cert, key -} - -func loadClientCredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { - cert, err := loadCertFromFile("../scep/testdata/testclient/client.pem") - if err != nil { - t.Fatal(err) - } - key, err := loadKeyFromFile("../scep/testdata/testclient/client.key") - if err != nil { - t.Fatal(err) - } - return cert, key -} - -func loadCertFromFile(path string) (*x509.Certificate, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != certificatePEMBlockType { - return nil, errors.New("unmatched type or headers") - } - return x509.ParseCertificate(pemBlock.Bytes) -} - -// load an encrypted private key from disk -func loadKeyFromFile(path string) (*rsa.PrivateKey, error) { - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - - pemBlock, _ := pem.Decode(data) - if pemBlock == nil { - return nil, errors.New("PEM decode failed") - } - if pemBlock.Type != rsaPrivateKeyPEMBlockType { - return nil, errors.New("unmatched type or headers") - } - - // testca key has a password - if len(pemBlock.Headers) > 0 { - password := []byte("") - b, err := x509.DecryptPEMBlock(pemBlock, password) - if err != nil { - return nil, err - } - return x509.ParsePKCS1PrivateKey(b) - } - - return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) -} diff --git a/vendor/github.com/miekg/dns/.gitignore b/vendor/github.com/miekg/dns/.gitignore deleted file mode 100644 index 776cd95..0000000 --- a/vendor/github.com/miekg/dns/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.6 -tags -test.out -a.out diff --git a/vendor/github.com/miekg/dns/.travis.yml b/vendor/github.com/miekg/dns/.travis.yml deleted file mode 100644 index 1f056ab..0000000 --- a/vendor/github.com/miekg/dns/.travis.yml +++ /dev/null @@ -1,7 +0,0 @@ -language: go -sudo: false -go: - - 1.5 - - 1.6 -script: - - go test -race -v -bench=. diff --git a/vendor/github.com/miekg/dns/AUTHORS b/vendor/github.com/miekg/dns/AUTHORS deleted file mode 100644 index 1965683..0000000 --- a/vendor/github.com/miekg/dns/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Miek Gieben diff --git a/vendor/github.com/miekg/dns/CONTRIBUTORS b/vendor/github.com/miekg/dns/CONTRIBUTORS deleted file mode 100644 index f77e8a8..0000000 --- a/vendor/github.com/miekg/dns/CONTRIBUTORS +++ /dev/null @@ -1,9 +0,0 @@ -Alex A. Skinner -Andrew Tunnell-Jones -Ask Bjørn Hansen -Dave Cheney -Dusty Wilson -Marek Majkowski -Peter van Dijk -Omri Bahumi -Alex Sergeyev diff --git a/vendor/github.com/miekg/dns/COPYRIGHT b/vendor/github.com/miekg/dns/COPYRIGHT deleted file mode 100644 index 35702b1..0000000 --- a/vendor/github.com/miekg/dns/COPYRIGHT +++ /dev/null @@ -1,9 +0,0 @@ -Copyright 2009 The Go Authors. All rights reserved. Use of this source code -is governed by a BSD-style license that can be found in the LICENSE file. -Extensions of the original work are copyright (c) 2011 Miek Gieben - -Copyright 2011 Miek Gieben. All rights reserved. Use of this source code is -governed by a BSD-style license that can be found in the LICENSE file. - -Copyright 2014 CloudFlare. All rights reserved. Use of this source code is -governed by a BSD-style license that can be found in the LICENSE file. diff --git a/vendor/github.com/miekg/dns/LICENSE b/vendor/github.com/miekg/dns/LICENSE deleted file mode 100644 index 5763fa7..0000000 --- a/vendor/github.com/miekg/dns/LICENSE +++ /dev/null @@ -1,32 +0,0 @@ -Extensions of the original work are copyright (c) 2011 Miek Gieben - -As this is fork of the official Go code the same license applies: - -Copyright (c) 2009 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/vendor/github.com/miekg/dns/README.md b/vendor/github.com/miekg/dns/README.md deleted file mode 100644 index 83b4183..0000000 --- a/vendor/github.com/miekg/dns/README.md +++ /dev/null @@ -1,151 +0,0 @@ -[![Build Status](https://travis-ci.org/miekg/dns.svg?branch=master)](https://travis-ci.org/miekg/dns) - -# Alternative (more granular) approach to a DNS library - -> Less is more. - -Complete and usable DNS library. All widely used Resource Records are -supported, including the DNSSEC types. It follows a lean and mean philosophy. -If there is stuff you should know as a DNS programmer there isn't a convenience -function for it. Server side and client side programming is supported, i.e. you -can build servers and resolvers with it. - -We try to keep the "master" branch as sane as possible and at the bleeding edge -of standards, avoiding breaking changes wherever reasonable. We support the last -two versions of Go, currently: 1.5 and 1.6. - -# Goals - -* KISS; -* Fast; -* Small API, if its easy to code in Go, don't make a function for it. - -# Users - -A not-so-up-to-date-list-that-may-be-actually-current: - -* https://cloudflare.com -* https://github.com/abh/geodns -* http://www.statdns.com/ -* http://www.dnsinspect.com/ -* https://github.com/chuangbo/jianbing-dictionary-dns -* http://www.dns-lg.com/ -* https://github.com/fcambus/rrda -* https://github.com/kenshinx/godns -* https://github.com/skynetservices/skydns -* https://github.com/hashicorp/consul -* https://github.com/DevelopersPL/godnsagent -* https://github.com/duedil-ltd/discodns -* https://github.com/StalkR/dns-reverse-proxy -* https://github.com/tianon/rawdns -* https://mesosphere.github.io/mesos-dns/ -* https://pulse.turbobytes.com/ -* https://play.google.com/store/apps/details?id=com.turbobytes.dig -* https://github.com/fcambus/statzone -* https://github.com/benschw/dns-clb-go -* https://github.com/corny/dnscheck for http://public-dns.info/ -* https://namesmith.io -* https://github.com/miekg/unbound -* https://github.com/miekg/exdns -* https://dnslookup.org -* https://github.com/looterz/grimd -* https://github.com/phamhongviet/serf-dns - -Send pull request if you want to be listed here. - -# Features - -* UDP/TCP queries, IPv4 and IPv6; -* RFC 1035 zone file parsing ($INCLUDE, $ORIGIN, $TTL and $GENERATE (for all record types) are supported; -* Fast: - * Reply speed around ~ 80K qps (faster hardware results in more qps); - * Parsing RRs ~ 100K RR/s, that's 5M records in about 50 seconds; -* Server side programming (mimicking the net/http package); -* Client side programming; -* DNSSEC: signing, validating and key generation for DSA, RSA and ECDSA; -* EDNS0, NSID, Cookies; -* AXFR/IXFR; -* TSIG, SIG(0); -* DNS over TLS: optional encrypted connection between client and server; -* DNS name compression; -* Depends only on the standard library. - -Have fun! - -Miek Gieben - 2010-2012 - - -# Building - -Building is done with the `go` tool. If you have setup your GOPATH -correctly, the following should work: - - go get github.com/miekg/dns - go build github.com/miekg/dns - -## Examples - -A short "how to use the API" is at the beginning of doc.go (this also will show -when you call `godoc github.com/miekg/dns`). - -Example programs can be found in the `github.com/miekg/exdns` repository. - -## Supported RFCs - -*all of them* - -* 103{4,5} - DNS standard -* 1348 - NSAP record (removed the record) -* 1982 - Serial Arithmetic -* 1876 - LOC record -* 1995 - IXFR -* 1996 - DNS notify -* 2136 - DNS Update (dynamic updates) -* 2181 - RRset definition - there is no RRset type though, just []RR -* 2537 - RSAMD5 DNS keys -* 2065 - DNSSEC (updated in later RFCs) -* 2671 - EDNS record -* 2782 - SRV record -* 2845 - TSIG record -* 2915 - NAPTR record -* 2929 - DNS IANA Considerations -* 3110 - RSASHA1 DNS keys -* 3225 - DO bit (DNSSEC OK) -* 340{1,2,3} - NAPTR record -* 3445 - Limiting the scope of (DNS)KEY -* 3597 - Unknown RRs -* 403{3,4,5} - DNSSEC + validation functions -* 4255 - SSHFP record -* 4343 - Case insensitivity -* 4408 - SPF record -* 4509 - SHA256 Hash in DS -* 4592 - Wildcards in the DNS -* 4635 - HMAC SHA TSIG -* 4701 - DHCID -* 4892 - id.server -* 5001 - NSID -* 5155 - NSEC3 record -* 5205 - HIP record -* 5702 - SHA2 in the DNS -* 5936 - AXFR -* 5966 - TCP implementation recommendations -* 6605 - ECDSA -* 6725 - IANA Registry Update -* 6742 - ILNP DNS -* 6840 - Clarifications and Implementation Notes for DNS Security -* 6844 - CAA record -* 6891 - EDNS0 update -* 6895 - DNS IANA considerations -* 6975 - Algorithm Understanding in DNSSEC -* 7043 - EUI48/EUI64 records -* 7314 - DNS (EDNS) EXPIRE Option -* 7553 - URI record -* 7858 - DNS over TLS: Initiation and Performance Considerations (draft) -* 7873 - Domain Name System (DNS) Cookies (draft-ietf-dnsop-cookies) -* xxxx - EDNS0 DNS Update Lease (draft) - -## Loosely based upon - -* `ldns` -* `NSD` -* `Net::DNS` -* `GRONG` diff --git a/vendor/github.com/miekg/dns/client.go b/vendor/github.com/miekg/dns/client.go deleted file mode 100644 index 1302e4e..0000000 --- a/vendor/github.com/miekg/dns/client.go +++ /dev/null @@ -1,455 +0,0 @@ -package dns - -// A client implementation. - -import ( - "bytes" - "crypto/tls" - "encoding/binary" - "io" - "net" - "time" -) - -const dnsTimeout time.Duration = 2 * time.Second -const tcpIdleTimeout time.Duration = 8 * time.Second - -// A Conn represents a connection to a DNS server. -type Conn struct { - net.Conn // a net.Conn holding the connection - UDPSize uint16 // minimum receive buffer for UDP messages - TsigSecret map[string]string // secret(s) for Tsig map[], zonename must be fully qualified - rtt time.Duration - t time.Time - tsigRequestMAC string -} - -// A Client defines parameters for a DNS client. -type Client struct { - Net string // if "tcp" or "tcp-tls" (DNS over TLS) a TCP query will be initiated, otherwise an UDP one (default is "" for UDP) - UDPSize uint16 // minimum receive buffer for UDP messages - TLSConfig *tls.Config // TLS connection configuration - Timeout time.Duration // a cumulative timeout for dial, write and read, defaults to 0 (disabled) - overrides DialTimeout, ReadTimeout and WriteTimeout when non-zero - DialTimeout time.Duration // net.DialTimeout, defaults to 2 seconds - overridden by Timeout when that value is non-zero - ReadTimeout time.Duration // net.Conn.SetReadTimeout value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero - WriteTimeout time.Duration // net.Conn.SetWriteTimeout value for connections, defaults to 2 seconds - overridden by Timeout when that value is non-zero - TsigSecret map[string]string // secret(s) for Tsig map[], zonename must be fully qualified - SingleInflight bool // if true suppress multiple outstanding queries for the same Qname, Qtype and Qclass - group singleflight -} - -// Exchange performs a synchronous UDP query. It sends the message m to the address -// contained in a and waits for an reply. Exchange does not retry a failed query, nor -// will it fall back to TCP in case of truncation. -// See client.Exchange for more information on setting larger buffer sizes. -func Exchange(m *Msg, a string) (r *Msg, err error) { - var co *Conn - co, err = DialTimeout("udp", a, dnsTimeout) - if err != nil { - return nil, err - } - - defer co.Close() - - opt := m.IsEdns0() - // If EDNS0 is used use that for size. - if opt != nil && opt.UDPSize() >= MinMsgSize { - co.UDPSize = opt.UDPSize() - } - - co.SetWriteDeadline(time.Now().Add(dnsTimeout)) - if err = co.WriteMsg(m); err != nil { - return nil, err - } - - co.SetReadDeadline(time.Now().Add(dnsTimeout)) - r, err = co.ReadMsg() - if err == nil && r.Id != m.Id { - err = ErrId - } - return r, err -} - -// ExchangeConn performs a synchronous query. It sends the message m via the connection -// c and waits for a reply. The connection c is not closed by ExchangeConn. -// This function is going away, but can easily be mimicked: -// -// co := &dns.Conn{Conn: c} // c is your net.Conn -// co.WriteMsg(m) -// in, _ := co.ReadMsg() -// co.Close() -// -func ExchangeConn(c net.Conn, m *Msg) (r *Msg, err error) { - println("dns: this function is deprecated") - co := new(Conn) - co.Conn = c - if err = co.WriteMsg(m); err != nil { - return nil, err - } - r, err = co.ReadMsg() - if err == nil && r.Id != m.Id { - err = ErrId - } - return r, err -} - -// Exchange performs an synchronous query. It sends the message m to the address -// contained in a and waits for an reply. Basic use pattern with a *dns.Client: -// -// c := new(dns.Client) -// in, rtt, err := c.Exchange(message, "127.0.0.1:53") -// -// Exchange does not retry a failed query, nor will it fall back to TCP in -// case of truncation. -// It is up to the caller to create a message that allows for larger responses to be -// returned. Specifically this means adding an EDNS0 OPT RR that will advertise a larger -// buffer, see SetEdns0. Messsages without an OPT RR will fallback to the historic limit -// of 512 bytes. -func (c *Client) Exchange(m *Msg, a string) (r *Msg, rtt time.Duration, err error) { - if !c.SingleInflight { - return c.exchange(m, a) - } - // This adds a bunch of garbage, TODO(miek). - t := "nop" - if t1, ok := TypeToString[m.Question[0].Qtype]; ok { - t = t1 - } - cl := "nop" - if cl1, ok := ClassToString[m.Question[0].Qclass]; ok { - cl = cl1 - } - r, rtt, err, shared := c.group.Do(m.Question[0].Name+t+cl, func() (*Msg, time.Duration, error) { - return c.exchange(m, a) - }) - if err != nil { - return r, rtt, err - } - if shared { - return r.Copy(), rtt, nil - } - return r, rtt, nil -} - -func (c *Client) dialTimeout() time.Duration { - if c.Timeout != 0 { - return c.Timeout - } - if c.DialTimeout != 0 { - return c.DialTimeout - } - return dnsTimeout -} - -func (c *Client) readTimeout() time.Duration { - if c.ReadTimeout != 0 { - return c.ReadTimeout - } - return dnsTimeout -} - -func (c *Client) writeTimeout() time.Duration { - if c.WriteTimeout != 0 { - return c.WriteTimeout - } - return dnsTimeout -} - -func (c *Client) exchange(m *Msg, a string) (r *Msg, rtt time.Duration, err error) { - var co *Conn - network := "udp" - tls := false - - switch c.Net { - case "tcp-tls": - network = "tcp" - tls = true - case "tcp4-tls": - network = "tcp4" - tls = true - case "tcp6-tls": - network = "tcp6" - tls = true - default: - if c.Net != "" { - network = c.Net - } - } - - var deadline time.Time - if c.Timeout != 0 { - deadline = time.Now().Add(c.Timeout) - } - - if tls { - co, err = DialTimeoutWithTLS(network, a, c.TLSConfig, c.dialTimeout()) - } else { - co, err = DialTimeout(network, a, c.dialTimeout()) - } - - if err != nil { - return nil, 0, err - } - defer co.Close() - - opt := m.IsEdns0() - // If EDNS0 is used use that for size. - if opt != nil && opt.UDPSize() >= MinMsgSize { - co.UDPSize = opt.UDPSize() - } - // Otherwise use the client's configured UDP size. - if opt == nil && c.UDPSize >= MinMsgSize { - co.UDPSize = c.UDPSize - } - - co.TsigSecret = c.TsigSecret - co.SetWriteDeadline(deadlineOrTimeout(deadline, c.writeTimeout())) - if err = co.WriteMsg(m); err != nil { - return nil, 0, err - } - - co.SetReadDeadline(deadlineOrTimeout(deadline, c.readTimeout())) - r, err = co.ReadMsg() - if err == nil && r.Id != m.Id { - err = ErrId - } - return r, co.rtt, err -} - -// ReadMsg reads a message from the connection co. -// If the received message contains a TSIG record the transaction -// signature is verified. -func (co *Conn) ReadMsg() (*Msg, error) { - p, err := co.ReadMsgHeader(nil) - if err != nil { - return nil, err - } - - m := new(Msg) - if err := m.Unpack(p); err != nil { - // If ErrTruncated was returned, we still want to allow the user to use - // the message, but naively they can just check err if they don't want - // to use a truncated message - if err == ErrTruncated { - return m, err - } - return nil, err - } - if t := m.IsTsig(); t != nil { - if _, ok := co.TsigSecret[t.Hdr.Name]; !ok { - return m, ErrSecret - } - // Need to work on the original message p, as that was used to calculate the tsig. - err = TsigVerify(p, co.TsigSecret[t.Hdr.Name], co.tsigRequestMAC, false) - } - return m, err -} - -// ReadMsgHeader reads a DNS message, parses and populates hdr (when hdr is not nil). -// Returns message as a byte slice to be parsed with Msg.Unpack later on. -// Note that error handling on the message body is not possible as only the header is parsed. -func (co *Conn) ReadMsgHeader(hdr *Header) ([]byte, error) { - var ( - p []byte - n int - err error - ) - - switch t := co.Conn.(type) { - case *net.TCPConn, *tls.Conn: - r := t.(io.Reader) - - // First two bytes specify the length of the entire message. - l, err := tcpMsgLen(r) - if err != nil { - return nil, err - } - p = make([]byte, l) - n, err = tcpRead(r, p) - co.rtt = time.Since(co.t) - default: - if co.UDPSize > MinMsgSize { - p = make([]byte, co.UDPSize) - } else { - p = make([]byte, MinMsgSize) - } - n, err = co.Read(p) - co.rtt = time.Since(co.t) - } - - if err != nil { - return nil, err - } else if n < headerSize { - return nil, ErrShortRead - } - - p = p[:n] - if hdr != nil { - dh, _, err := unpackMsgHdr(p, 0) - if err != nil { - return nil, err - } - *hdr = dh - } - return p, err -} - -// tcpMsgLen is a helper func to read first two bytes of stream as uint16 packet length. -func tcpMsgLen(t io.Reader) (int, error) { - p := []byte{0, 0} - n, err := t.Read(p) - if err != nil { - return 0, err - } - if n != 2 { - return 0, ErrShortRead - } - l := binary.BigEndian.Uint16(p) - if l == 0 { - return 0, ErrShortRead - } - return int(l), nil -} - -// tcpRead calls TCPConn.Read enough times to fill allocated buffer. -func tcpRead(t io.Reader, p []byte) (int, error) { - n, err := t.Read(p) - if err != nil { - return n, err - } - for n < len(p) { - j, err := t.Read(p[n:]) - if err != nil { - return n, err - } - n += j - } - return n, err -} - -// Read implements the net.Conn read method. -func (co *Conn) Read(p []byte) (n int, err error) { - if co.Conn == nil { - return 0, ErrConnEmpty - } - if len(p) < 2 { - return 0, io.ErrShortBuffer - } - switch t := co.Conn.(type) { - case *net.TCPConn, *tls.Conn: - r := t.(io.Reader) - - l, err := tcpMsgLen(r) - if err != nil { - return 0, err - } - if l > len(p) { - return int(l), io.ErrShortBuffer - } - return tcpRead(r, p[:l]) - } - // UDP connection - n, err = co.Conn.Read(p) - if err != nil { - return n, err - } - return n, err -} - -// WriteMsg sends a message through the connection co. -// If the message m contains a TSIG record the transaction -// signature is calculated. -func (co *Conn) WriteMsg(m *Msg) (err error) { - var out []byte - if t := m.IsTsig(); t != nil { - mac := "" - if _, ok := co.TsigSecret[t.Hdr.Name]; !ok { - return ErrSecret - } - out, mac, err = TsigGenerate(m, co.TsigSecret[t.Hdr.Name], co.tsigRequestMAC, false) - // Set for the next read, although only used in zone transfers - co.tsigRequestMAC = mac - } else { - out, err = m.Pack() - } - if err != nil { - return err - } - co.t = time.Now() - if _, err = co.Write(out); err != nil { - return err - } - return nil -} - -// Write implements the net.Conn Write method. -func (co *Conn) Write(p []byte) (n int, err error) { - switch t := co.Conn.(type) { - case *net.TCPConn, *tls.Conn: - w := t.(io.Writer) - - lp := len(p) - if lp < 2 { - return 0, io.ErrShortBuffer - } - if lp > MaxMsgSize { - return 0, &Error{err: "message too large"} - } - l := make([]byte, 2, lp+2) - binary.BigEndian.PutUint16(l, uint16(lp)) - p = append(l, p...) - n, err := io.Copy(w, bytes.NewReader(p)) - return int(n), err - } - n, err = co.Conn.(*net.UDPConn).Write(p) - return n, err -} - -// Dial connects to the address on the named network. -func Dial(network, address string) (conn *Conn, err error) { - conn = new(Conn) - conn.Conn, err = net.Dial(network, address) - if err != nil { - return nil, err - } - return conn, nil -} - -// DialTimeout acts like Dial but takes a timeout. -func DialTimeout(network, address string, timeout time.Duration) (conn *Conn, err error) { - conn = new(Conn) - conn.Conn, err = net.DialTimeout(network, address, timeout) - if err != nil { - return nil, err - } - return conn, nil -} - -// DialWithTLS connects to the address on the named network with TLS. -func DialWithTLS(network, address string, tlsConfig *tls.Config) (conn *Conn, err error) { - conn = new(Conn) - conn.Conn, err = tls.Dial(network, address, tlsConfig) - if err != nil { - return nil, err - } - return conn, nil -} - -// DialTimeoutWithTLS acts like DialWithTLS but takes a timeout. -func DialTimeoutWithTLS(network, address string, tlsConfig *tls.Config, timeout time.Duration) (conn *Conn, err error) { - var dialer net.Dialer - dialer.Timeout = timeout - - conn = new(Conn) - conn.Conn, err = tls.DialWithDialer(&dialer, network, address, tlsConfig) - if err != nil { - return nil, err - } - return conn, nil -} - -func deadlineOrTimeout(deadline time.Time, timeout time.Duration) time.Time { - if deadline.IsZero() { - return time.Now().Add(timeout) - } - return deadline -} diff --git a/vendor/github.com/miekg/dns/client_test.go b/vendor/github.com/miekg/dns/client_test.go deleted file mode 100644 index 850bcfc..0000000 --- a/vendor/github.com/miekg/dns/client_test.go +++ /dev/null @@ -1,452 +0,0 @@ -package dns - -import ( - "crypto/tls" - "fmt" - "net" - "strconv" - "testing" - "time" -) - -func TestClientSync(t *testing.T) { - HandleFunc("miek.nl.", HelloServer) - defer HandleRemove("miek.nl.") - - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - m := new(Msg) - m.SetQuestion("miek.nl.", TypeSOA) - - c := new(Client) - r, _, err := c.Exchange(m, addrstr) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - if r != nil && r.Rcode != RcodeSuccess { - t.Errorf("failed to get an valid answer\n%v", r) - } - // And now with plain Exchange(). - r, err = Exchange(m, addrstr) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - if r == nil || r.Rcode != RcodeSuccess { - t.Errorf("failed to get an valid answer\n%v", r) - } -} - -func TestClientTLSSync(t *testing.T) { - HandleFunc("miek.nl.", HelloServer) - defer HandleRemove("miek.nl.") - - cert, err := tls.X509KeyPair(CertPEMBlock, KeyPEMBlock) - if err != nil { - t.Fatalf("unable to build certificate: %v", err) - } - - config := tls.Config{ - Certificates: []tls.Certificate{cert}, - } - - s, addrstr, err := RunLocalTLSServer("127.0.0.1:0", &config) - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - m := new(Msg) - m.SetQuestion("miek.nl.", TypeSOA) - - c := new(Client) - c.Net = "tcp-tls" - c.TLSConfig = &tls.Config{ - InsecureSkipVerify: true, - } - - r, _, err := c.Exchange(m, addrstr) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - if r != nil && r.Rcode != RcodeSuccess { - t.Errorf("failed to get an valid answer\n%v", r) - } -} - -func TestClientSyncBadId(t *testing.T) { - HandleFunc("miek.nl.", HelloServerBadId) - defer HandleRemove("miek.nl.") - - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - m := new(Msg) - m.SetQuestion("miek.nl.", TypeSOA) - - c := new(Client) - if _, _, err := c.Exchange(m, addrstr); err != ErrId { - t.Errorf("did not find a bad Id") - } - // And now with plain Exchange(). - if _, err := Exchange(m, addrstr); err != ErrId { - t.Errorf("did not find a bad Id") - } -} - -func TestClientEDNS0(t *testing.T) { - HandleFunc("miek.nl.", HelloServer) - defer HandleRemove("miek.nl.") - - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - m := new(Msg) - m.SetQuestion("miek.nl.", TypeDNSKEY) - - m.SetEdns0(2048, true) - - c := new(Client) - r, _, err := c.Exchange(m, addrstr) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - - if r != nil && r.Rcode != RcodeSuccess { - t.Errorf("failed to get an valid answer\n%v", r) - } -} - -// Validates the transmission and parsing of local EDNS0 options. -func TestClientEDNS0Local(t *testing.T) { - optStr1 := "1979:0x0707" - optStr2 := strconv.Itoa(EDNS0LOCALSTART) + ":0x0601" - - handler := func(w ResponseWriter, req *Msg) { - m := new(Msg) - m.SetReply(req) - - m.Extra = make([]RR, 1, 2) - m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello local edns"}} - - // If the local options are what we expect, then reflect them back. - ec1 := req.Extra[0].(*OPT).Option[0].(*EDNS0_LOCAL).String() - ec2 := req.Extra[0].(*OPT).Option[1].(*EDNS0_LOCAL).String() - if ec1 == optStr1 && ec2 == optStr2 { - m.Extra = append(m.Extra, req.Extra[0]) - } - - w.WriteMsg(m) - } - - HandleFunc("miek.nl.", handler) - defer HandleRemove("miek.nl.") - - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %s", err) - } - defer s.Shutdown() - - m := new(Msg) - m.SetQuestion("miek.nl.", TypeTXT) - - // Add two local edns options to the query. - ec1 := &EDNS0_LOCAL{Code: 1979, Data: []byte{7, 7}} - ec2 := &EDNS0_LOCAL{Code: EDNS0LOCALSTART, Data: []byte{6, 1}} - o := &OPT{Hdr: RR_Header{Name: ".", Rrtype: TypeOPT}, Option: []EDNS0{ec1, ec2}} - m.Extra = append(m.Extra, o) - - c := new(Client) - r, _, err := c.Exchange(m, addrstr) - if err != nil { - t.Errorf("failed to exchange: %s", err) - } - - if r != nil && r.Rcode != RcodeSuccess { - t.Error("failed to get a valid answer") - t.Logf("%v\n", r) - } - - txt := r.Extra[0].(*TXT).Txt[0] - if txt != "Hello local edns" { - t.Error("Unexpected result for miek.nl", txt, "!= Hello local edns") - } - - // Validate the local options in the reply. - got := r.Extra[1].(*OPT).Option[0].(*EDNS0_LOCAL).String() - if got != optStr1 { - t.Errorf("failed to get local edns0 answer; got %s, expected %s", got, optStr1) - t.Logf("%v\n", r) - } - - got = r.Extra[1].(*OPT).Option[1].(*EDNS0_LOCAL).String() - if got != optStr2 { - t.Errorf("failed to get local edns0 answer; got %s, expected %s", got, optStr2) - t.Logf("%v\n", r) - } -} - -// ExampleTsigSecret_updateLeaseTSIG shows how to update a lease signed with TSIG -func ExampleTsigSecret_updateLeaseTSIG() { - m := new(Msg) - m.SetUpdate("t.local.ip6.io.") - rr, _ := NewRR("t.local.ip6.io. 30 A 127.0.0.1") - rrs := make([]RR, 1) - rrs[0] = rr - m.Insert(rrs) - - leaseRr := new(OPT) - leaseRr.Hdr.Name = "." - leaseRr.Hdr.Rrtype = TypeOPT - e := new(EDNS0_UL) - e.Code = EDNS0UL - e.Lease = 120 - leaseRr.Option = append(leaseRr.Option, e) - m.Extra = append(m.Extra, leaseRr) - - c := new(Client) - m.SetTsig("polvi.", HmacMD5, 300, time.Now().Unix()) - c.TsigSecret = map[string]string{"polvi.": "pRZgBrBvI4NAHZYhxmhs/Q=="} - - _, _, err := c.Exchange(m, "127.0.0.1:53") - if err != nil { - panic(err) - } -} - -func TestClientConn(t *testing.T) { - HandleFunc("miek.nl.", HelloServer) - defer HandleRemove("miek.nl.") - - // This uses TCP just to make it slightly different than TestClientSync - s, addrstr, err := RunLocalTCPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - m := new(Msg) - m.SetQuestion("miek.nl.", TypeSOA) - - cn, err := Dial("tcp", addrstr) - if err != nil { - t.Errorf("failed to dial %s: %v", addrstr, err) - } - - err = cn.WriteMsg(m) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - r, err := cn.ReadMsg() - if r == nil || r.Rcode != RcodeSuccess { - t.Errorf("failed to get an valid answer\n%v", r) - } - - err = cn.WriteMsg(m) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - h := new(Header) - buf, err := cn.ReadMsgHeader(h) - if buf == nil { - t.Errorf("failed to get an valid answer\n%v", r) - } - if int(h.Bits&0xF) != RcodeSuccess { - t.Errorf("failed to get an valid answer in ReadMsgHeader\n%v", r) - } - if h.Ancount != 0 || h.Qdcount != 1 || h.Nscount != 0 || h.Arcount != 1 { - t.Errorf("expected to have question and additional in response; got something else: %+v", h) - } - if err = r.Unpack(buf); err != nil { - t.Errorf("unable to unpack message fully: %v", err) - } -} - -func TestTruncatedMsg(t *testing.T) { - m := new(Msg) - m.SetQuestion("miek.nl.", TypeSRV) - cnt := 10 - for i := 0; i < cnt; i++ { - r := &SRV{ - Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeSRV, Class: ClassINET, Ttl: 0}, - Port: uint16(i + 8000), - Target: "target.miek.nl.", - } - m.Answer = append(m.Answer, r) - - re := &A{ - Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeA, Class: ClassINET, Ttl: 0}, - A: net.ParseIP(fmt.Sprintf("127.0.0.%d", i)).To4(), - } - m.Extra = append(m.Extra, re) - } - buf, err := m.Pack() - if err != nil { - t.Errorf("failed to pack: %v", err) - } - - r := new(Msg) - if err = r.Unpack(buf); err != nil { - t.Errorf("unable to unpack message: %v", err) - } - if len(r.Answer) != cnt { - t.Errorf("answer count after regular unpack doesn't match: %d", len(r.Answer)) - } - if len(r.Extra) != cnt { - t.Errorf("extra count after regular unpack doesn't match: %d", len(r.Extra)) - } - - m.Truncated = true - buf, err = m.Pack() - if err != nil { - t.Errorf("failed to pack truncated: %v", err) - } - - r = new(Msg) - if err = r.Unpack(buf); err != nil && err != ErrTruncated { - t.Errorf("unable to unpack truncated message: %v", err) - } - if !r.Truncated { - t.Errorf("truncated message wasn't unpacked as truncated") - } - if len(r.Answer) != cnt { - t.Errorf("answer count after truncated unpack doesn't match: %d", len(r.Answer)) - } - if len(r.Extra) != cnt { - t.Errorf("extra count after truncated unpack doesn't match: %d", len(r.Extra)) - } - - // Now we want to remove almost all of the extra records - // We're going to loop over the extra to get the count of the size of all - // of them - off := 0 - buf1 := make([]byte, m.Len()) - for i := 0; i < len(m.Extra); i++ { - off, err = PackRR(m.Extra[i], buf1, off, nil, m.Compress) - if err != nil { - t.Errorf("failed to pack extra: %v", err) - } - } - - // Remove all of the extra bytes but 10 bytes from the end of buf - off -= 10 - buf1 = buf[:len(buf)-off] - - r = new(Msg) - if err = r.Unpack(buf1); err != nil && err != ErrTruncated { - t.Errorf("unable to unpack cutoff message: %v", err) - } - if !r.Truncated { - t.Error("truncated cutoff message wasn't unpacked as truncated") - } - if len(r.Answer) != cnt { - t.Errorf("answer count after cutoff unpack doesn't match: %d", len(r.Answer)) - } - if len(r.Extra) != 0 { - t.Errorf("extra count after cutoff unpack is not zero: %d", len(r.Extra)) - } - - // Now we want to remove almost all of the answer records too - buf1 = make([]byte, m.Len()) - as := 0 - for i := 0; i < len(m.Extra); i++ { - off1 := off - off, err = PackRR(m.Extra[i], buf1, off, nil, m.Compress) - as = off - off1 - if err != nil { - t.Errorf("failed to pack extra: %v", err) - } - } - - // Keep exactly one answer left - // This should still cause Answer to be nil - off -= as - buf1 = buf[:len(buf)-off] - - r = new(Msg) - if err = r.Unpack(buf1); err != nil && err != ErrTruncated { - t.Errorf("unable to unpack cutoff message: %v", err) - } - if !r.Truncated { - t.Error("truncated cutoff message wasn't unpacked as truncated") - } - if len(r.Answer) != 0 { - t.Errorf("answer count after second cutoff unpack is not zero: %d", len(r.Answer)) - } - - // Now leave only 1 byte of the question - // Since the header is always 12 bytes, we just need to keep 13 - buf1 = buf[:13] - - r = new(Msg) - err = r.Unpack(buf1) - if err == nil || err == ErrTruncated { - t.Errorf("error should not be ErrTruncated from question cutoff unpack: %v", err) - } - - // Finally, if we only have the header, we should still return an error - buf1 = buf[:12] - - r = new(Msg) - if err = r.Unpack(buf1); err == nil || err != ErrTruncated { - t.Errorf("error not ErrTruncated from header-only unpack: %v", err) - } -} - -func TestTimeout(t *testing.T) { - // Set up a dummy UDP server that won't respond - addr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0") - if err != nil { - t.Fatalf("unable to resolve local udp address: %v", err) - } - conn, err := net.ListenUDP("udp", addr) - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer conn.Close() - addrstr := conn.LocalAddr().String() - - // Message to send - m := new(Msg) - m.SetQuestion("miek.nl.", TypeTXT) - - // Use a channel + timeout to ensure we don't get stuck if the - // Client Timeout is not working properly - done := make(chan struct{}) - - timeout := time.Millisecond - allowable := timeout + (10 * time.Millisecond) - abortAfter := timeout + (100 * time.Millisecond) - - start := time.Now() - - go func() { - c := &Client{Timeout: timeout} - _, _, err := c.Exchange(m, addrstr) - if err == nil { - t.Error("no timeout using Client") - } - done <- struct{}{} - }() - - select { - case <-done: - case <-time.After(abortAfter): - } - - length := time.Since(start) - - if length > allowable { - t.Errorf("exchange took longer (%v) than specified Timeout (%v)", length, timeout) - } -} diff --git a/vendor/github.com/miekg/dns/clientconfig.go b/vendor/github.com/miekg/dns/clientconfig.go deleted file mode 100644 index cfa9ad0..0000000 --- a/vendor/github.com/miekg/dns/clientconfig.go +++ /dev/null @@ -1,99 +0,0 @@ -package dns - -import ( - "bufio" - "os" - "strconv" - "strings" -) - -// ClientConfig wraps the contents of the /etc/resolv.conf file. -type ClientConfig struct { - Servers []string // servers to use - Search []string // suffixes to append to local name - Port string // what port to use - Ndots int // number of dots in name to trigger absolute lookup - Timeout int // seconds before giving up on packet - Attempts int // lost packets before giving up on server, not used in the package dns -} - -// ClientConfigFromFile parses a resolv.conf(5) like file and returns -// a *ClientConfig. -func ClientConfigFromFile(resolvconf string) (*ClientConfig, error) { - file, err := os.Open(resolvconf) - if err != nil { - return nil, err - } - defer file.Close() - c := new(ClientConfig) - scanner := bufio.NewScanner(file) - c.Servers = make([]string, 0) - c.Search = make([]string, 0) - c.Port = "53" - c.Ndots = 1 - c.Timeout = 5 - c.Attempts = 2 - - for scanner.Scan() { - if err := scanner.Err(); err != nil { - return nil, err - } - line := scanner.Text() - f := strings.Fields(line) - if len(f) < 1 { - continue - } - switch f[0] { - case "nameserver": // add one name server - if len(f) > 1 { - // One more check: make sure server name is - // just an IP address. Otherwise we need DNS - // to look it up. - name := f[1] - c.Servers = append(c.Servers, name) - } - - case "domain": // set search path to just this domain - if len(f) > 1 { - c.Search = make([]string, 1) - c.Search[0] = f[1] - } else { - c.Search = make([]string, 0) - } - - case "search": // set search path to given servers - c.Search = make([]string, len(f)-1) - for i := 0; i < len(c.Search); i++ { - c.Search[i] = f[i+1] - } - - case "options": // magic options - for i := 1; i < len(f); i++ { - s := f[i] - switch { - case len(s) >= 6 && s[:6] == "ndots:": - n, _ := strconv.Atoi(s[6:]) - if n < 1 { - n = 1 - } - c.Ndots = n - case len(s) >= 8 && s[:8] == "timeout:": - n, _ := strconv.Atoi(s[8:]) - if n < 1 { - n = 1 - } - c.Timeout = n - case len(s) >= 8 && s[:9] == "attempts:": - n, _ := strconv.Atoi(s[9:]) - if n < 1 { - n = 1 - } - c.Attempts = n - case s == "rotate": - /* not imp */ - } - } - } - } - return c, nil -} diff --git a/vendor/github.com/miekg/dns/clientconfig_test.go b/vendor/github.com/miekg/dns/clientconfig_test.go deleted file mode 100644 index 63bc5c8..0000000 --- a/vendor/github.com/miekg/dns/clientconfig_test.go +++ /dev/null @@ -1,50 +0,0 @@ -package dns - -import ( - "io/ioutil" - "os" - "path/filepath" - "testing" -) - -const normal string = ` -# Comment -domain somedomain.com -nameserver 10.28.10.2 -nameserver 11.28.10.1 -` - -const missingNewline string = ` -domain somedomain.com -nameserver 10.28.10.2 -nameserver 11.28.10.1` // <- NOTE: NO newline. - -func testConfig(t *testing.T, data string) { - tempDir, err := ioutil.TempDir("", "") - if err != nil { - t.Fatalf("tempDir: %v", err) - } - defer os.RemoveAll(tempDir) - - path := filepath.Join(tempDir, "resolv.conf") - if err := ioutil.WriteFile(path, []byte(data), 0644); err != nil { - t.Fatalf("writeFile: %v", err) - } - cc, err := ClientConfigFromFile(path) - if err != nil { - t.Errorf("error parsing resolv.conf: %v", err) - } - if l := len(cc.Servers); l != 2 { - t.Errorf("incorrect number of nameservers detected: %d", l) - } - if l := len(cc.Search); l != 1 { - t.Errorf("domain directive not parsed correctly: %v", cc.Search) - } else { - if cc.Search[0] != "somedomain.com" { - t.Errorf("domain is unexpected: %v", cc.Search[0]) - } - } -} - -func TestNameserver(t *testing.T) { testConfig(t, normal) } -func TestMissingFinalNewLine(t *testing.T) { testConfig(t, missingNewline) } diff --git a/vendor/github.com/miekg/dns/defaults.go b/vendor/github.com/miekg/dns/defaults.go deleted file mode 100644 index cf45616..0000000 --- a/vendor/github.com/miekg/dns/defaults.go +++ /dev/null @@ -1,282 +0,0 @@ -package dns - -import ( - "errors" - "net" - "strconv" -) - -const hexDigit = "0123456789abcdef" - -// Everything is assumed in ClassINET. - -// SetReply creates a reply message from a request message. -func (dns *Msg) SetReply(request *Msg) *Msg { - dns.Id = request.Id - dns.RecursionDesired = request.RecursionDesired // Copy rd bit - dns.Response = true - dns.Opcode = OpcodeQuery - dns.Rcode = RcodeSuccess - if len(request.Question) > 0 { - dns.Question = make([]Question, 1) - dns.Question[0] = request.Question[0] - } - return dns -} - -// SetQuestion creates a question message, it sets the Question -// section, generates an Id and sets the RecursionDesired (RD) -// bit to true. -func (dns *Msg) SetQuestion(z string, t uint16) *Msg { - dns.Id = Id() - dns.RecursionDesired = true - dns.Question = make([]Question, 1) - dns.Question[0] = Question{z, t, ClassINET} - return dns -} - -// SetNotify creates a notify message, it sets the Question -// section, generates an Id and sets the Authoritative (AA) -// bit to true. -func (dns *Msg) SetNotify(z string) *Msg { - dns.Opcode = OpcodeNotify - dns.Authoritative = true - dns.Id = Id() - dns.Question = make([]Question, 1) - dns.Question[0] = Question{z, TypeSOA, ClassINET} - return dns -} - -// SetRcode creates an error message suitable for the request. -func (dns *Msg) SetRcode(request *Msg, rcode int) *Msg { - dns.SetReply(request) - dns.Rcode = rcode - return dns -} - -// SetRcodeFormatError creates a message with FormError set. -func (dns *Msg) SetRcodeFormatError(request *Msg) *Msg { - dns.Rcode = RcodeFormatError - dns.Opcode = OpcodeQuery - dns.Response = true - dns.Authoritative = false - dns.Id = request.Id - return dns -} - -// SetUpdate makes the message a dynamic update message. It -// sets the ZONE section to: z, TypeSOA, ClassINET. -func (dns *Msg) SetUpdate(z string) *Msg { - dns.Id = Id() - dns.Response = false - dns.Opcode = OpcodeUpdate - dns.Compress = false // BIND9 cannot handle compression - dns.Question = make([]Question, 1) - dns.Question[0] = Question{z, TypeSOA, ClassINET} - return dns -} - -// SetIxfr creates message for requesting an IXFR. -func (dns *Msg) SetIxfr(z string, serial uint32, ns, mbox string) *Msg { - dns.Id = Id() - dns.Question = make([]Question, 1) - dns.Ns = make([]RR, 1) - s := new(SOA) - s.Hdr = RR_Header{z, TypeSOA, ClassINET, defaultTtl, 0} - s.Serial = serial - s.Ns = ns - s.Mbox = mbox - dns.Question[0] = Question{z, TypeIXFR, ClassINET} - dns.Ns[0] = s - return dns -} - -// SetAxfr creates message for requesting an AXFR. -func (dns *Msg) SetAxfr(z string) *Msg { - dns.Id = Id() - dns.Question = make([]Question, 1) - dns.Question[0] = Question{z, TypeAXFR, ClassINET} - return dns -} - -// SetTsig appends a TSIG RR to the message. -// This is only a skeleton TSIG RR that is added as the last RR in the -// additional section. The Tsig is calculated when the message is being send. -func (dns *Msg) SetTsig(z, algo string, fudge, timesigned int64) *Msg { - t := new(TSIG) - t.Hdr = RR_Header{z, TypeTSIG, ClassANY, 0, 0} - t.Algorithm = algo - t.Fudge = 300 - t.TimeSigned = uint64(timesigned) - t.OrigId = dns.Id - dns.Extra = append(dns.Extra, t) - return dns -} - -// SetEdns0 appends a EDNS0 OPT RR to the message. -// TSIG should always the last RR in a message. -func (dns *Msg) SetEdns0(udpsize uint16, do bool) *Msg { - e := new(OPT) - e.Hdr.Name = "." - e.Hdr.Rrtype = TypeOPT - e.SetUDPSize(udpsize) - if do { - e.SetDo() - } - dns.Extra = append(dns.Extra, e) - return dns -} - -// IsTsig checks if the message has a TSIG record as the last record -// in the additional section. It returns the TSIG record found or nil. -func (dns *Msg) IsTsig() *TSIG { - if len(dns.Extra) > 0 { - if dns.Extra[len(dns.Extra)-1].Header().Rrtype == TypeTSIG { - return dns.Extra[len(dns.Extra)-1].(*TSIG) - } - } - return nil -} - -// IsEdns0 checks if the message has a EDNS0 (OPT) record, any EDNS0 -// record in the additional section will do. It returns the OPT record -// found or nil. -func (dns *Msg) IsEdns0() *OPT { - // EDNS0 is at the end of the additional section, start there. - // We might want to change this to *only* look at the last two - // records. So we see TSIG and/or OPT - this a slightly bigger - // change though. - for i := len(dns.Extra) - 1; i >= 0; i-- { - if dns.Extra[i].Header().Rrtype == TypeOPT { - return dns.Extra[i].(*OPT) - } - } - return nil -} - -// IsDomainName checks if s is a valid domain name, it returns the number of -// labels and true, when a domain name is valid. Note that non fully qualified -// domain name is considered valid, in this case the last label is counted in -// the number of labels. When false is returned the number of labels is not -// defined. Also note that this function is extremely liberal; almost any -// string is a valid domain name as the DNS is 8 bit protocol. It checks if each -// label fits in 63 characters, but there is no length check for the entire -// string s. I.e. a domain name longer than 255 characters is considered valid. -func IsDomainName(s string) (labels int, ok bool) { - _, labels, err := packDomainName(s, nil, 0, nil, false) - return labels, err == nil -} - -// IsSubDomain checks if child is indeed a child of the parent. If child and parent -// are the same domain true is returned as well. -func IsSubDomain(parent, child string) bool { - // Entire child is contained in parent - return CompareDomainName(parent, child) == CountLabel(parent) -} - -// IsMsg sanity checks buf and returns an error if it isn't a valid DNS packet. -// The checking is performed on the binary payload. -func IsMsg(buf []byte) error { - // Header - if len(buf) < 12 { - return errors.New("dns: bad message header") - } - // Header: Opcode - // TODO(miek): more checks here, e.g. check all header bits. - return nil -} - -// IsFqdn checks if a domain name is fully qualified. -func IsFqdn(s string) bool { - l := len(s) - if l == 0 { - return false - } - return s[l-1] == '.' -} - -// IsRRset checks if a set of RRs is a valid RRset as defined by RFC 2181. -// This means the RRs need to have the same type, name, and class. Returns true -// if the RR set is valid, otherwise false. -func IsRRset(rrset []RR) bool { - if len(rrset) == 0 { - return false - } - if len(rrset) == 1 { - return true - } - rrHeader := rrset[0].Header() - rrType := rrHeader.Rrtype - rrClass := rrHeader.Class - rrName := rrHeader.Name - - for _, rr := range rrset[1:] { - curRRHeader := rr.Header() - if curRRHeader.Rrtype != rrType || curRRHeader.Class != rrClass || curRRHeader.Name != rrName { - // Mismatch between the records, so this is not a valid rrset for - //signing/verifying - return false - } - } - - return true -} - -// Fqdn return the fully qualified domain name from s. -// If s is already fully qualified, it behaves as the identity function. -func Fqdn(s string) string { - if IsFqdn(s) { - return s - } - return s + "." -} - -// Copied from the official Go code. - -// ReverseAddr returns the in-addr.arpa. or ip6.arpa. hostname of the IP -// address suitable for reverse DNS (PTR) record lookups or an error if it fails -// to parse the IP address. -func ReverseAddr(addr string) (arpa string, err error) { - ip := net.ParseIP(addr) - if ip == nil { - return "", &Error{err: "unrecognized address: " + addr} - } - if ip.To4() != nil { - return strconv.Itoa(int(ip[15])) + "." + strconv.Itoa(int(ip[14])) + "." + strconv.Itoa(int(ip[13])) + "." + - strconv.Itoa(int(ip[12])) + ".in-addr.arpa.", nil - } - // Must be IPv6 - buf := make([]byte, 0, len(ip)*4+len("ip6.arpa.")) - // Add it, in reverse, to the buffer - for i := len(ip) - 1; i >= 0; i-- { - v := ip[i] - buf = append(buf, hexDigit[v&0xF]) - buf = append(buf, '.') - buf = append(buf, hexDigit[v>>4]) - buf = append(buf, '.') - } - // Append "ip6.arpa." and return (buf already has the final .) - buf = append(buf, "ip6.arpa."...) - return string(buf), nil -} - -// String returns the string representation for the type t. -func (t Type) String() string { - if t1, ok := TypeToString[uint16(t)]; ok { - return t1 - } - return "TYPE" + strconv.Itoa(int(t)) -} - -// String returns the string representation for the class c. -func (c Class) String() string { - if c1, ok := ClassToString[uint16(c)]; ok { - return c1 - } - return "CLASS" + strconv.Itoa(int(c)) -} - -// String returns the string representation for the name n. -func (n Name) String() string { - return sprintName(string(n)) -} diff --git a/vendor/github.com/miekg/dns/dns.go b/vendor/github.com/miekg/dns/dns.go deleted file mode 100644 index b329228..0000000 --- a/vendor/github.com/miekg/dns/dns.go +++ /dev/null @@ -1,104 +0,0 @@ -package dns - -import "strconv" - -const ( - year68 = 1 << 31 // For RFC1982 (Serial Arithmetic) calculations in 32 bits. - defaultTtl = 3600 // Default internal TTL. - - DefaultMsgSize = 4096 // DefaultMsgSize is the standard default for messages larger than 512 bytes. - MinMsgSize = 512 // MinMsgSize is the minimal size of a DNS packet. - MaxMsgSize = 65535 // MaxMsgSize is the largest possible DNS packet. -) - -// Error represents a DNS error. -type Error struct{ err string } - -func (e *Error) Error() string { - if e == nil { - return "dns: " - } - return "dns: " + e.err -} - -// An RR represents a resource record. -type RR interface { - // Header returns the header of an resource record. The header contains - // everything up to the rdata. - Header() *RR_Header - // String returns the text representation of the resource record. - String() string - - // copy returns a copy of the RR - copy() RR - // len returns the length (in octets) of the uncompressed RR in wire format. - len() int - // pack packs an RR into wire format. - pack([]byte, int, map[string]int, bool) (int, error) -} - -// RR_Header is the header all DNS resource records share. -type RR_Header struct { - Name string `dns:"cdomain-name"` - Rrtype uint16 - Class uint16 - Ttl uint32 - Rdlength uint16 // Length of data after header. -} - -// Header returns itself. This is here to make RR_Header implements the RR interface. -func (h *RR_Header) Header() *RR_Header { return h } - -// Just to implement the RR interface. -func (h *RR_Header) copy() RR { return nil } - -func (h *RR_Header) copyHeader() *RR_Header { - r := new(RR_Header) - r.Name = h.Name - r.Rrtype = h.Rrtype - r.Class = h.Class - r.Ttl = h.Ttl - r.Rdlength = h.Rdlength - return r -} - -func (h *RR_Header) String() string { - var s string - - if h.Rrtype == TypeOPT { - s = ";" - // and maybe other things - } - - s += sprintName(h.Name) + "\t" - s += strconv.FormatInt(int64(h.Ttl), 10) + "\t" - s += Class(h.Class).String() + "\t" - s += Type(h.Rrtype).String() + "\t" - return s -} - -func (h *RR_Header) len() int { - l := len(h.Name) + 1 - l += 10 // rrtype(2) + class(2) + ttl(4) + rdlength(2) - return l -} - -// ToRFC3597 converts a known RR to the unknown RR representation from RFC 3597. -func (rr *RFC3597) ToRFC3597(r RR) error { - buf := make([]byte, r.len()*2) - off, err := PackRR(r, buf, 0, nil, false) - if err != nil { - return err - } - buf = buf[:off] - if int(r.Header().Rdlength) > off { - return ErrBuf - } - - rfc3597, _, err := unpackRFC3597(*r.Header(), buf, off-int(r.Header().Rdlength)) - if err != nil { - return err - } - *rr = *rfc3597.(*RFC3597) - return nil -} diff --git a/vendor/github.com/miekg/dns/dns_bench_test.go b/vendor/github.com/miekg/dns/dns_bench_test.go deleted file mode 100644 index bccc3d5..0000000 --- a/vendor/github.com/miekg/dns/dns_bench_test.go +++ /dev/null @@ -1,211 +0,0 @@ -package dns - -import ( - "net" - "testing" -) - -func BenchmarkMsgLength(b *testing.B) { - b.StopTimer() - makeMsg := func(question string, ans, ns, e []RR) *Msg { - msg := new(Msg) - msg.SetQuestion(Fqdn(question), TypeANY) - msg.Answer = append(msg.Answer, ans...) - msg.Ns = append(msg.Ns, ns...) - msg.Extra = append(msg.Extra, e...) - msg.Compress = true - return msg - } - name1 := "12345678901234567890123456789012345.12345678.123." - rrMx, _ := NewRR(name1 + " 3600 IN MX 10 " + name1) - msg := makeMsg(name1, []RR{rrMx, rrMx}, nil, nil) - b.StartTimer() - for i := 0; i < b.N; i++ { - msg.Len() - } -} - -func BenchmarkMsgLengthPack(b *testing.B) { - makeMsg := func(question string, ans, ns, e []RR) *Msg { - msg := new(Msg) - msg.SetQuestion(Fqdn(question), TypeANY) - msg.Answer = append(msg.Answer, ans...) - msg.Ns = append(msg.Ns, ns...) - msg.Extra = append(msg.Extra, e...) - msg.Compress = true - return msg - } - name1 := "12345678901234567890123456789012345.12345678.123." - rrMx, _ := NewRR(name1 + " 3600 IN MX 10 " + name1) - msg := makeMsg(name1, []RR{rrMx, rrMx}, nil, nil) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _ = msg.Pack() - } -} - -func BenchmarkPackDomainName(b *testing.B) { - name1 := "12345678901234567890123456789012345.12345678.123." - buf := make([]byte, len(name1)+1) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _ = PackDomainName(name1, buf, 0, nil, false) - } -} - -func BenchmarkUnpackDomainName(b *testing.B) { - name1 := "12345678901234567890123456789012345.12345678.123." - buf := make([]byte, len(name1)+1) - _, _ = PackDomainName(name1, buf, 0, nil, false) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _, _ = UnpackDomainName(buf, 0) - } -} - -func BenchmarkUnpackDomainNameUnprintable(b *testing.B) { - name1 := "\x02\x02\x02\x025\x02\x02\x02\x02.12345678.123." - buf := make([]byte, len(name1)+1) - _, _ = PackDomainName(name1, buf, 0, nil, false) - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _, _ = UnpackDomainName(buf, 0) - } -} - -func BenchmarkCopy(b *testing.B) { - b.ReportAllocs() - m := new(Msg) - m.SetQuestion("miek.nl.", TypeA) - rr, _ := NewRR("miek.nl. 2311 IN A 127.0.0.1") - m.Answer = []RR{rr} - rr, _ = NewRR("miek.nl. 2311 IN NS 127.0.0.1") - m.Ns = []RR{rr} - rr, _ = NewRR("miek.nl. 2311 IN A 127.0.0.1") - m.Extra = []RR{rr} - - b.ResetTimer() - for i := 0; i < b.N; i++ { - m.Copy() - } -} - -func BenchmarkPackA(b *testing.B) { - a := &A{Hdr: RR_Header{Name: ".", Rrtype: TypeA, Class: ClassANY}, A: net.IPv4(127, 0, 0, 1)} - - buf := make([]byte, a.len()) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _ = PackRR(a, buf, 0, nil, false) - } -} - -func BenchmarkUnpackA(b *testing.B) { - a := &A{Hdr: RR_Header{Name: ".", Rrtype: TypeA, Class: ClassANY}, A: net.IPv4(127, 0, 0, 1)} - - buf := make([]byte, a.len()) - PackRR(a, buf, 0, nil, false) - a = nil - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _, _ = UnpackRR(buf, 0) - } -} - -func BenchmarkPackMX(b *testing.B) { - m := &MX{Hdr: RR_Header{Name: ".", Rrtype: TypeA, Class: ClassANY}, Mx: "mx.miek.nl."} - - buf := make([]byte, m.len()) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _ = PackRR(m, buf, 0, nil, false) - } -} - -func BenchmarkUnpackMX(b *testing.B) { - m := &MX{Hdr: RR_Header{Name: ".", Rrtype: TypeA, Class: ClassANY}, Mx: "mx.miek.nl."} - - buf := make([]byte, m.len()) - PackRR(m, buf, 0, nil, false) - m = nil - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _, _ = UnpackRR(buf, 0) - } -} - -func BenchmarkPackAAAAA(b *testing.B) { - aaaa, _ := NewRR(". IN A ::1") - - buf := make([]byte, aaaa.len()) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _ = PackRR(aaaa, buf, 0, nil, false) - } -} - -func BenchmarkUnpackAAAA(b *testing.B) { - aaaa, _ := NewRR(". IN A ::1") - - buf := make([]byte, aaaa.len()) - PackRR(aaaa, buf, 0, nil, false) - aaaa = nil - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _, _ = UnpackRR(buf, 0) - } -} - -func BenchmarkPackMsg(b *testing.B) { - makeMsg := func(question string, ans, ns, e []RR) *Msg { - msg := new(Msg) - msg.SetQuestion(Fqdn(question), TypeANY) - msg.Answer = append(msg.Answer, ans...) - msg.Ns = append(msg.Ns, ns...) - msg.Extra = append(msg.Extra, e...) - msg.Compress = true - return msg - } - name1 := "12345678901234567890123456789012345.12345678.123." - rrMx, _ := NewRR(name1 + " 3600 IN MX 10 " + name1) - msg := makeMsg(name1, []RR{rrMx, rrMx}, nil, nil) - buf := make([]byte, 512) - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _, _ = msg.PackBuffer(buf) - } -} - -func BenchmarkUnpackMsg(b *testing.B) { - makeMsg := func(question string, ans, ns, e []RR) *Msg { - msg := new(Msg) - msg.SetQuestion(Fqdn(question), TypeANY) - msg.Answer = append(msg.Answer, ans...) - msg.Ns = append(msg.Ns, ns...) - msg.Extra = append(msg.Extra, e...) - msg.Compress = true - return msg - } - name1 := "12345678901234567890123456789012345.12345678.123." - rrMx, _ := NewRR(name1 + " 3600 IN MX 10 " + name1) - msg := makeMsg(name1, []RR{rrMx, rrMx}, nil, nil) - msgBuf, _ := msg.Pack() - b.ReportAllocs() - b.ResetTimer() - for i := 0; i < b.N; i++ { - _ = msg.Unpack(msgBuf) - } -} - -func BenchmarkIdGeneration(b *testing.B) { - for i := 0; i < b.N; i++ { - _ = id() - } -} diff --git a/vendor/github.com/miekg/dns/dns_test.go b/vendor/github.com/miekg/dns/dns_test.go deleted file mode 100644 index ad68533..0000000 --- a/vendor/github.com/miekg/dns/dns_test.go +++ /dev/null @@ -1,433 +0,0 @@ -package dns - -import ( - "encoding/hex" - "net" - "testing" -) - -func TestPackUnpack(t *testing.T) { - out := new(Msg) - out.Answer = make([]RR, 1) - key := new(DNSKEY) - key = &DNSKEY{Flags: 257, Protocol: 3, Algorithm: RSASHA1} - key.Hdr = RR_Header{Name: "miek.nl.", Rrtype: TypeDNSKEY, Class: ClassINET, Ttl: 3600} - key.PublicKey = "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ" - - out.Answer[0] = key - msg, err := out.Pack() - if err != nil { - t.Error("failed to pack msg with DNSKEY") - } - in := new(Msg) - if in.Unpack(msg) != nil { - t.Error("failed to unpack msg with DNSKEY") - } - - sig := new(RRSIG) - sig = &RRSIG{TypeCovered: TypeDNSKEY, Algorithm: RSASHA1, Labels: 2, - OrigTtl: 3600, Expiration: 4000, Inception: 4000, KeyTag: 34641, SignerName: "miek.nl.", - Signature: "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ"} - sig.Hdr = RR_Header{Name: "miek.nl.", Rrtype: TypeRRSIG, Class: ClassINET, Ttl: 3600} - - out.Answer[0] = sig - msg, err = out.Pack() - if err != nil { - t.Error("failed to pack msg with RRSIG") - } - - if in.Unpack(msg) != nil { - t.Error("failed to unpack msg with RRSIG") - } -} - -func TestPackUnpack2(t *testing.T) { - m := new(Msg) - m.Extra = make([]RR, 1) - m.Answer = make([]RR, 1) - dom := "miek.nl." - rr := new(A) - rr.Hdr = RR_Header{Name: dom, Rrtype: TypeA, Class: ClassINET, Ttl: 0} - rr.A = net.IPv4(127, 0, 0, 1) - - x := new(TXT) - x.Hdr = RR_Header{Name: dom, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0} - x.Txt = []string{"heelalaollo"} - - m.Extra[0] = x - m.Answer[0] = rr - _, err := m.Pack() - if err != nil { - t.Error("Packing failed: ", err) - return - } -} - -func TestPackUnpack3(t *testing.T) { - m := new(Msg) - m.Extra = make([]RR, 2) - m.Answer = make([]RR, 1) - dom := "miek.nl." - rr := new(A) - rr.Hdr = RR_Header{Name: dom, Rrtype: TypeA, Class: ClassINET, Ttl: 0} - rr.A = net.IPv4(127, 0, 0, 1) - - x1 := new(TXT) - x1.Hdr = RR_Header{Name: dom, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0} - x1.Txt = []string{} - - x2 := new(TXT) - x2.Hdr = RR_Header{Name: dom, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0} - x2.Txt = []string{"heelalaollo"} - - m.Extra[0] = x1 - m.Extra[1] = x2 - m.Answer[0] = rr - b, err := m.Pack() - if err != nil { - t.Error("packing failed: ", err) - return - } - - var unpackMsg Msg - err = unpackMsg.Unpack(b) - if err != nil { - t.Error("unpacking failed") - return - } -} - -func TestBailiwick(t *testing.T) { - yes := map[string]string{ - "miek1.nl": "miek1.nl", - "miek.nl": "ns.miek.nl", - ".": "miek.nl", - } - for parent, child := range yes { - if !IsSubDomain(parent, child) { - t.Errorf("%s should be child of %s", child, parent) - t.Errorf("comparelabels %d", CompareDomainName(parent, child)) - t.Errorf("lenlabels %d %d", CountLabel(parent), CountLabel(child)) - } - } - no := map[string]string{ - "www.miek.nl": "ns.miek.nl", - "m\\.iek.nl": "ns.miek.nl", - "w\\.iek.nl": "w.iek.nl", - "p\\\\.iek.nl": "ns.p.iek.nl", // p\\.iek.nl , literal \ in domain name - "miek.nl": ".", - } - for parent, child := range no { - if IsSubDomain(parent, child) { - t.Errorf("%s should not be child of %s", child, parent) - t.Errorf("comparelabels %d", CompareDomainName(parent, child)) - t.Errorf("lenlabels %d %d", CountLabel(parent), CountLabel(child)) - } - } -} - -func TestPack(t *testing.T) { - rr := []string{"US. 86400 IN NSEC 0-.us. NS SOA RRSIG NSEC DNSKEY TYPE65534"} - m := new(Msg) - var err error - m.Answer = make([]RR, 1) - for _, r := range rr { - m.Answer[0], err = NewRR(r) - if err != nil { - t.Errorf("failed to create RR: %v", err) - continue - } - if _, err := m.Pack(); err != nil { - t.Errorf("packing failed: %v", err) - } - } - x := new(Msg) - ns, _ := NewRR("pool.ntp.org. 390 IN NS a.ntpns.org") - ns.(*NS).Ns = "a.ntpns.org" - x.Ns = append(m.Ns, ns) - x.Ns = append(m.Ns, ns) - x.Ns = append(m.Ns, ns) - // This crashes due to the fact the a.ntpns.org isn't a FQDN - // How to recover() from a remove panic()? - if _, err := x.Pack(); err == nil { - t.Error("packing should fail") - } - x.Answer = make([]RR, 1) - x.Answer[0], err = NewRR(rr[0]) - if _, err := x.Pack(); err == nil { - t.Error("packing should fail") - } - x.Question = make([]Question, 1) - x.Question[0] = Question{";sd#eddddsé›↙èµÂ‘℅∥↙xzztsestxssweewwsssstx@s@Z嵌e@cn.pool.ntp.org.", TypeA, ClassINET} - if _, err := x.Pack(); err == nil { - t.Error("packing should fail") - } -} - -func TestPackNAPTR(t *testing.T) { - for _, n := range []string{ - `apple.com. IN NAPTR 100 50 "se" "SIP+D2U" "" _sip._udp.apple.com.`, - `apple.com. IN NAPTR 90 50 "se" "SIP+D2T" "" _sip._tcp.apple.com.`, - `apple.com. IN NAPTR 50 50 "se" "SIPS+D2T" "" _sips._tcp.apple.com.`, - } { - rr, _ := NewRR(n) - msg := make([]byte, rr.len()) - if off, err := PackRR(rr, msg, 0, nil, false); err != nil { - t.Errorf("packing failed: %v", err) - t.Errorf("length %d, need more than %d", rr.len(), off) - } else { - t.Logf("buf size needed: %d", off) - } - } -} - -func TestCompressLength(t *testing.T) { - m := new(Msg) - m.SetQuestion("miek.nl", TypeMX) - ul := m.Len() - m.Compress = true - if ul != m.Len() { - t.Fatalf("should be equal") - } -} - -// Does the predicted length match final packed length? -func TestMsgCompressLength(t *testing.T) { - makeMsg := func(question string, ans, ns, e []RR) *Msg { - msg := new(Msg) - msg.SetQuestion(Fqdn(question), TypeANY) - msg.Answer = append(msg.Answer, ans...) - msg.Ns = append(msg.Ns, ns...) - msg.Extra = append(msg.Extra, e...) - msg.Compress = true - return msg - } - - name1 := "12345678901234567890123456789012345.12345678.123." - rrA, _ := NewRR(name1 + " 3600 IN A 192.0.2.1") - rrMx, _ := NewRR(name1 + " 3600 IN MX 10 " + name1) - tests := []*Msg{ - makeMsg(name1, []RR{rrA}, nil, nil), - makeMsg(name1, []RR{rrMx, rrMx}, nil, nil)} - - for _, msg := range tests { - predicted := msg.Len() - buf, err := msg.Pack() - if err != nil { - t.Error(err) - } - if predicted < len(buf) { - t.Errorf("predicted compressed length is wrong: predicted %s (len=%d) %d, actual %d", - msg.Question[0].Name, len(msg.Answer), predicted, len(buf)) - } - } -} - -func TestMsgLength(t *testing.T) { - makeMsg := func(question string, ans, ns, e []RR) *Msg { - msg := new(Msg) - msg.SetQuestion(Fqdn(question), TypeANY) - msg.Answer = append(msg.Answer, ans...) - msg.Ns = append(msg.Ns, ns...) - msg.Extra = append(msg.Extra, e...) - return msg - } - - name1 := "12345678901234567890123456789012345.12345678.123." - rrA, _ := NewRR(name1 + " 3600 IN A 192.0.2.1") - rrMx, _ := NewRR(name1 + " 3600 IN MX 10 " + name1) - tests := []*Msg{ - makeMsg(name1, []RR{rrA}, nil, nil), - makeMsg(name1, []RR{rrMx, rrMx}, nil, nil)} - - for _, msg := range tests { - predicted := msg.Len() - buf, err := msg.Pack() - if err != nil { - t.Error(err) - } - if predicted < len(buf) { - t.Errorf("predicted length is wrong: predicted %s (len=%d), actual %d", - msg.Question[0].Name, predicted, len(buf)) - } - } -} - -func TestMsgLength2(t *testing.T) { - // Serialized replies - var testMessages = []string{ - // google.com. IN A? - "064e81800001000b0004000506676f6f676c6503636f6d0000010001c00c00010001000000050004adc22986c00c00010001000000050004adc22987c00c00010001000000050004adc22988c00c00010001000000050004adc22989c00c00010001000000050004adc2298ec00c00010001000000050004adc22980c00c00010001000000050004adc22981c00c00010001000000050004adc22982c00c00010001000000050004adc22983c00c00010001000000050004adc22984c00c00010001000000050004adc22985c00c00020001000000050006036e7331c00cc00c00020001000000050006036e7332c00cc00c00020001000000050006036e7333c00cc00c00020001000000050006036e7334c00cc0d800010001000000050004d8ef200ac0ea00010001000000050004d8ef220ac0fc00010001000000050004d8ef240ac10e00010001000000050004d8ef260a0000290500000000050000", - // amazon.com. IN A? (reply has no EDNS0 record) - // TODO(miek): this one is off-by-one, need to find out why - //"6de1818000010004000a000806616d617a6f6e03636f6d0000010001c00c000100010000000500044815c2d4c00c000100010000000500044815d7e8c00c00010001000000050004b02062a6c00c00010001000000050004cdfbf236c00c000200010000000500140570646e733408756c747261646e73036f726700c00c000200010000000500150570646e733508756c747261646e7304696e666f00c00c000200010000000500160570646e733608756c747261646e7302636f02756b00c00c00020001000000050014036e7331037033310664796e656374036e657400c00c00020001000000050006036e7332c0cfc00c00020001000000050006036e7333c0cfc00c00020001000000050006036e7334c0cfc00c000200010000000500110570646e733108756c747261646e73c0dac00c000200010000000500080570646e7332c127c00c000200010000000500080570646e7333c06ec0cb00010001000000050004d04e461fc0eb00010001000000050004cc0dfa1fc0fd00010001000000050004d04e471fc10f00010001000000050004cc0dfb1fc12100010001000000050004cc4a6c01c121001c000100000005001020010502f3ff00000000000000000001c13e00010001000000050004cc4a6d01c13e001c0001000000050010261000a1101400000000000000000001", - // yahoo.com. IN A? - "fc2d81800001000300070008057961686f6f03636f6d0000010001c00c00010001000000050004628afd6dc00c00010001000000050004628bb718c00c00010001000000050004cebe242dc00c00020001000000050006036e7336c00cc00c00020001000000050006036e7338c00cc00c00020001000000050006036e7331c00cc00c00020001000000050006036e7332c00cc00c00020001000000050006036e7333c00cc00c00020001000000050006036e7334c00cc00c00020001000000050006036e7335c00cc07b0001000100000005000444b48310c08d00010001000000050004448eff10c09f00010001000000050004cb54dd35c0b100010001000000050004628a0b9dc0c30001000100000005000477a0f77cc05700010001000000050004ca2bdfaac06900010001000000050004caa568160000290500000000050000", - // microsoft.com. IN A? - "f4368180000100020005000b096d6963726f736f667403636f6d0000010001c00c0001000100000005000440040b25c00c0001000100000005000441373ac9c00c0002000100000005000e036e7331046d736674036e657400c00c00020001000000050006036e7332c04fc00c00020001000000050006036e7333c04fc00c00020001000000050006036e7334c04fc00c00020001000000050006036e7335c04fc04b000100010000000500044137253ec04b001c00010000000500102a010111200500000000000000010001c0650001000100000005000440043badc065001c00010000000500102a010111200600060000000000010001c07700010001000000050004d5c7b435c077001c00010000000500102a010111202000000000000000010001c08900010001000000050004cf2e4bfec089001c00010000000500102404f800200300000000000000010001c09b000100010000000500044137e28cc09b001c00010000000500102a010111200f000100000000000100010000290500000000050000", - // google.com. IN MX? - "724b8180000100050004000b06676f6f676c6503636f6d00000f0001c00c000f000100000005000c000a056173706d78016cc00cc00c000f0001000000050009001404616c7431c02ac00c000f0001000000050009001e04616c7432c02ac00c000f0001000000050009002804616c7433c02ac00c000f0001000000050009003204616c7434c02ac00c00020001000000050006036e7332c00cc00c00020001000000050006036e7333c00cc00c00020001000000050006036e7334c00cc00c00020001000000050006036e7331c00cc02a00010001000000050004adc2421bc02a001c00010000000500102a00145040080c01000000000000001bc04200010001000000050004adc2461bc05700010001000000050004adc2451bc06c000100010000000500044a7d8f1bc081000100010000000500044a7d191bc0ca00010001000000050004d8ef200ac09400010001000000050004d8ef220ac0a600010001000000050004d8ef240ac0b800010001000000050004d8ef260a0000290500000000050000", - // reddit.com. IN A? - "12b98180000100080000000c0672656464697403636f6d0000020001c00c0002000100000005000f046175733204616b616d036e657400c00c000200010000000500070475736534c02dc00c000200010000000500070475737733c02dc00c000200010000000500070475737735c02dc00c00020001000000050008056173696131c02dc00c00020001000000050008056173696139c02dc00c00020001000000050008056e73312d31c02dc00c0002000100000005000a076e73312d313935c02dc02800010001000000050004c30a242ec04300010001000000050004451f1d39c05600010001000000050004451f3bc7c0690001000100000005000460073240c07c000100010000000500046007fb81c090000100010000000500047c283484c090001c00010000000500102a0226f0006700000000000000000064c0a400010001000000050004c16c5b01c0a4001c000100000005001026001401000200000000000000000001c0b800010001000000050004c16c5bc3c0b8001c0001000000050010260014010002000000000000000000c30000290500000000050000", - } - - for i, hexData := range testMessages { - // we won't fail the decoding of the hex - input, _ := hex.DecodeString(hexData) - - m := new(Msg) - m.Unpack(input) - m.Compress = true - lenComp := m.Len() - b, _ := m.Pack() - pacComp := len(b) - m.Compress = false - lenUnComp := m.Len() - b, _ = m.Pack() - pacUnComp := len(b) - if pacComp+1 != lenComp { - t.Errorf("msg.Len(compressed)=%d actual=%d for test %d", lenComp, pacComp, i) - } - if pacUnComp+1 != lenUnComp { - t.Errorf("msg.Len(uncompressed)=%d actual=%d for test %d", lenUnComp, pacUnComp, i) - } - } -} - -func TestMsgLengthCompressionMalformed(t *testing.T) { - // SOA with empty hostmaster, which is illegal - soa := &SOA{Hdr: RR_Header{Name: ".", Rrtype: TypeSOA, Class: ClassINET, Ttl: 12345}, - Ns: ".", - Mbox: "", - Serial: 0, - Refresh: 28800, - Retry: 7200, - Expire: 604800, - Minttl: 60} - m := new(Msg) - m.Compress = true - m.Ns = []RR{soa} - m.Len() // Should not crash. -} - -func TestToRFC3597(t *testing.T) { - a, _ := NewRR("miek.nl. IN A 10.0.1.1") - x := new(RFC3597) - x.ToRFC3597(a) - if x.String() != `miek.nl. 3600 CLASS1 TYPE1 \# 4 0a000101` { - t.Errorf("string mismatch, got: %s", x) - } - - b, _ := NewRR("miek.nl. IN MX 10 mx.miek.nl.") - x.ToRFC3597(b) - if x.String() != `miek.nl. 3600 CLASS1 TYPE15 \# 14 000a026d78046d69656b026e6c00` { - t.Errorf("string mismatch, got: %s", x) - } -} - -func TestNoRdataPack(t *testing.T) { - data := make([]byte, 1024) - for typ, fn := range TypeToRR { - r := fn() - *r.Header() = RR_Header{Name: "miek.nl.", Rrtype: typ, Class: ClassINET, Ttl: 16} - _, err := PackRR(r, data, 0, nil, false) - if err != nil { - t.Errorf("failed to pack RR with zero rdata: %s: %v", TypeToString[typ], err) - } - } -} - -func TestNoRdataUnpack(t *testing.T) { - data := make([]byte, 1024) - for typ, fn := range TypeToRR { - if typ == TypeSOA || typ == TypeTSIG { - // SOA, TSIG will not be seen (like this) in dyn. updates? - continue - } - r := fn() - *r.Header() = RR_Header{Name: "miek.nl.", Rrtype: typ, Class: ClassINET, Ttl: 16} - off, err := PackRR(r, data, 0, nil, false) - if err != nil { - // Should always works, TestNoDataPack should have caught this - t.Errorf("failed to pack RR: %v", err) - continue - } - rr, _, err := UnpackRR(data[:off], 0) - if err != nil { - t.Errorf("failed to unpack RR with zero rdata: %s: %v", TypeToString[typ], err) - } - t.Log(rr) - } -} - -func TestRdataOverflow(t *testing.T) { - rr := new(RFC3597) - rr.Hdr.Name = "." - rr.Hdr.Class = ClassINET - rr.Hdr.Rrtype = 65280 - rr.Rdata = hex.EncodeToString(make([]byte, 0xFFFF)) - buf := make([]byte, 0xFFFF*2) - if _, err := PackRR(rr, buf, 0, nil, false); err != nil { - t.Fatalf("maximum size rrdata pack failed: %v", err) - } - rr.Rdata += "00" - if _, err := PackRR(rr, buf, 0, nil, false); err != ErrRdata { - t.Fatalf("oversize rrdata pack didn't return ErrRdata - instead: %v", err) - } -} - -func TestCopy(t *testing.T) { - rr, _ := NewRR("miek.nl. 2311 IN A 127.0.0.1") // Weird TTL to avoid catching TTL - rr1 := Copy(rr) - if rr.String() != rr1.String() { - t.Fatalf("Copy() failed %s != %s", rr.String(), rr1.String()) - } -} - -func TestMsgCopy(t *testing.T) { - m := new(Msg) - m.SetQuestion("miek.nl.", TypeA) - rr, _ := NewRR("miek.nl. 2311 IN A 127.0.0.1") - m.Answer = []RR{rr} - rr, _ = NewRR("miek.nl. 2311 IN NS 127.0.0.1") - m.Ns = []RR{rr} - - m1 := m.Copy() - if m.String() != m1.String() { - t.Fatalf("Msg.Copy() failed %s != %s", m.String(), m1.String()) - } - - m1.Answer[0], _ = NewRR("somethingelse.nl. 2311 IN A 127.0.0.1") - if m.String() == m1.String() { - t.Fatalf("Msg.Copy() failed; change to copy changed template %s", m.String()) - } - - rr, _ = NewRR("miek.nl. 2311 IN A 127.0.0.2") - m1.Answer = append(m1.Answer, rr) - if m1.Ns[0].String() == m1.Answer[1].String() { - t.Fatalf("Msg.Copy() failed; append changed underlying array %s", m1.Ns[0].String()) - } -} - -func TestMsgPackBuffer(t *testing.T) { - var testMessages = []string{ - // news.ycombinator.com.in.escapemg.com. IN A, response - "586285830001000000010000046e6577730b79636f6d62696e61746f7203636f6d02696e086573636170656d6703636f6d0000010001c0210006000100000e10002c036e7332c02103646e730b67726f6f7665736861726bc02d77ed50e600002a3000000e1000093a8000000e10", - - // news.ycombinator.com.in.escapemg.com. IN A, question - "586201000001000000000000046e6577730b79636f6d62696e61746f7203636f6d02696e086573636170656d6703636f6d0000010001", - - "398781020001000000000000046e6577730b79636f6d62696e61746f7203636f6d0000010001", - } - - for i, hexData := range testMessages { - // we won't fail the decoding of the hex - input, _ := hex.DecodeString(hexData) - m := new(Msg) - if err := m.Unpack(input); err != nil { - t.Errorf("packet %d failed to unpack", i) - continue - } - t.Logf("packet %d %s", i, m.String()) - } -} diff --git a/vendor/github.com/miekg/dns/dnssec.go b/vendor/github.com/miekg/dns/dnssec.go deleted file mode 100644 index f5f3fbd..0000000 --- a/vendor/github.com/miekg/dns/dnssec.go +++ /dev/null @@ -1,721 +0,0 @@ -package dns - -import ( - "bytes" - "crypto" - "crypto/dsa" - "crypto/ecdsa" - "crypto/elliptic" - _ "crypto/md5" - "crypto/rand" - "crypto/rsa" - _ "crypto/sha1" - _ "crypto/sha256" - _ "crypto/sha512" - "encoding/asn1" - "encoding/binary" - "encoding/hex" - "math/big" - "sort" - "strings" - "time" -) - -// DNSSEC encryption algorithm codes. -const ( - _ uint8 = iota - RSAMD5 - DH - DSA - _ // Skip 4, RFC 6725, section 2.1 - RSASHA1 - DSANSEC3SHA1 - RSASHA1NSEC3SHA1 - RSASHA256 - _ // Skip 9, RFC 6725, section 2.1 - RSASHA512 - _ // Skip 11, RFC 6725, section 2.1 - ECCGOST - ECDSAP256SHA256 - ECDSAP384SHA384 - INDIRECT uint8 = 252 - PRIVATEDNS uint8 = 253 // Private (experimental keys) - PRIVATEOID uint8 = 254 -) - -// Map for algorithm names. -var AlgorithmToString = map[uint8]string{ - RSAMD5: "RSAMD5", - DH: "DH", - DSA: "DSA", - RSASHA1: "RSASHA1", - DSANSEC3SHA1: "DSA-NSEC3-SHA1", - RSASHA1NSEC3SHA1: "RSASHA1-NSEC3-SHA1", - RSASHA256: "RSASHA256", - RSASHA512: "RSASHA512", - ECCGOST: "ECC-GOST", - ECDSAP256SHA256: "ECDSAP256SHA256", - ECDSAP384SHA384: "ECDSAP384SHA384", - INDIRECT: "INDIRECT", - PRIVATEDNS: "PRIVATEDNS", - PRIVATEOID: "PRIVATEOID", -} - -// Map of algorithm strings. -var StringToAlgorithm = reverseInt8(AlgorithmToString) - -// Map of algorithm crypto hashes. -var AlgorithmToHash = map[uint8]crypto.Hash{ - RSAMD5: crypto.MD5, // Deprecated in RFC 6725 - RSASHA1: crypto.SHA1, - RSASHA1NSEC3SHA1: crypto.SHA1, - RSASHA256: crypto.SHA256, - ECDSAP256SHA256: crypto.SHA256, - ECDSAP384SHA384: crypto.SHA384, - RSASHA512: crypto.SHA512, -} - -// DNSSEC hashing algorithm codes. -const ( - _ uint8 = iota - SHA1 // RFC 4034 - SHA256 // RFC 4509 - GOST94 // RFC 5933 - SHA384 // Experimental - SHA512 // Experimental -) - -// Map for hash names. -var HashToString = map[uint8]string{ - SHA1: "SHA1", - SHA256: "SHA256", - GOST94: "GOST94", - SHA384: "SHA384", - SHA512: "SHA512", -} - -// Map of hash strings. -var StringToHash = reverseInt8(HashToString) - -// DNSKEY flag values. -const ( - SEP = 1 - REVOKE = 1 << 7 - ZONE = 1 << 8 -) - -// The RRSIG needs to be converted to wireformat with some of the rdata (the signature) missing. -type rrsigWireFmt struct { - TypeCovered uint16 - Algorithm uint8 - Labels uint8 - OrigTtl uint32 - Expiration uint32 - Inception uint32 - KeyTag uint16 - SignerName string `dns:"domain-name"` - /* No Signature */ -} - -// Used for converting DNSKEY's rdata to wirefmt. -type dnskeyWireFmt struct { - Flags uint16 - Protocol uint8 - Algorithm uint8 - PublicKey string `dns:"base64"` - /* Nothing is left out */ -} - -func divRoundUp(a, b int) int { - return (a + b - 1) / b -} - -// KeyTag calculates the keytag (or key-id) of the DNSKEY. -func (k *DNSKEY) KeyTag() uint16 { - if k == nil { - return 0 - } - var keytag int - switch k.Algorithm { - case RSAMD5: - // Look at the bottom two bytes of the modules, which the last - // item in the pubkey. We could do this faster by looking directly - // at the base64 values. But I'm lazy. - modulus, _ := fromBase64([]byte(k.PublicKey)) - if len(modulus) > 1 { - x := binary.BigEndian.Uint16(modulus[len(modulus)-2:]) - keytag = int(x) - } - default: - keywire := new(dnskeyWireFmt) - keywire.Flags = k.Flags - keywire.Protocol = k.Protocol - keywire.Algorithm = k.Algorithm - keywire.PublicKey = k.PublicKey - wire := make([]byte, DefaultMsgSize) - n, err := packKeyWire(keywire, wire) - if err != nil { - return 0 - } - wire = wire[:n] - for i, v := range wire { - if i&1 != 0 { - keytag += int(v) // must be larger than uint32 - } else { - keytag += int(v) << 8 - } - } - keytag += (keytag >> 16) & 0xFFFF - keytag &= 0xFFFF - } - return uint16(keytag) -} - -// ToDS converts a DNSKEY record to a DS record. -func (k *DNSKEY) ToDS(h uint8) *DS { - if k == nil { - return nil - } - ds := new(DS) - ds.Hdr.Name = k.Hdr.Name - ds.Hdr.Class = k.Hdr.Class - ds.Hdr.Rrtype = TypeDS - ds.Hdr.Ttl = k.Hdr.Ttl - ds.Algorithm = k.Algorithm - ds.DigestType = h - ds.KeyTag = k.KeyTag() - - keywire := new(dnskeyWireFmt) - keywire.Flags = k.Flags - keywire.Protocol = k.Protocol - keywire.Algorithm = k.Algorithm - keywire.PublicKey = k.PublicKey - wire := make([]byte, DefaultMsgSize) - n, err := packKeyWire(keywire, wire) - if err != nil { - return nil - } - wire = wire[:n] - - owner := make([]byte, 255) - off, err1 := PackDomainName(strings.ToLower(k.Hdr.Name), owner, 0, nil, false) - if err1 != nil { - return nil - } - owner = owner[:off] - // RFC4034: - // digest = digest_algorithm( DNSKEY owner name | DNSKEY RDATA); - // "|" denotes concatenation - // DNSKEY RDATA = Flags | Protocol | Algorithm | Public Key. - - // digest buffer - digest := append(owner, wire...) // another copy - - var hash crypto.Hash - switch h { - case SHA1: - hash = crypto.SHA1 - case SHA256: - hash = crypto.SHA256 - case SHA384: - hash = crypto.SHA384 - case SHA512: - hash = crypto.SHA512 - default: - return nil - } - - s := hash.New() - s.Write(digest) - ds.Digest = hex.EncodeToString(s.Sum(nil)) - return ds -} - -// ToCDNSKEY converts a DNSKEY record to a CDNSKEY record. -func (k *DNSKEY) ToCDNSKEY() *CDNSKEY { - c := &CDNSKEY{DNSKEY: *k} - c.Hdr = *k.Hdr.copyHeader() - c.Hdr.Rrtype = TypeCDNSKEY - return c -} - -// ToCDS converts a DS record to a CDS record. -func (d *DS) ToCDS() *CDS { - c := &CDS{DS: *d} - c.Hdr = *d.Hdr.copyHeader() - c.Hdr.Rrtype = TypeCDS - return c -} - -// Sign signs an RRSet. The signature needs to be filled in with the values: -// Inception, Expiration, KeyTag, SignerName and Algorithm. The rest is copied -// from the RRset. Sign returns a non-nill error when the signing went OK. -// There is no check if RRSet is a proper (RFC 2181) RRSet. If OrigTTL is non -// zero, it is used as-is, otherwise the TTL of the RRset is used as the -// OrigTTL. -func (rr *RRSIG) Sign(k crypto.Signer, rrset []RR) error { - if k == nil { - return ErrPrivKey - } - // s.Inception and s.Expiration may be 0 (rollover etc.), the rest must be set - if rr.KeyTag == 0 || len(rr.SignerName) == 0 || rr.Algorithm == 0 { - return ErrKey - } - - rr.Hdr.Rrtype = TypeRRSIG - rr.Hdr.Name = rrset[0].Header().Name - rr.Hdr.Class = rrset[0].Header().Class - if rr.OrigTtl == 0 { // If set don't override - rr.OrigTtl = rrset[0].Header().Ttl - } - rr.TypeCovered = rrset[0].Header().Rrtype - rr.Labels = uint8(CountLabel(rrset[0].Header().Name)) - - if strings.HasPrefix(rrset[0].Header().Name, "*") { - rr.Labels-- // wildcard, remove from label count - } - - sigwire := new(rrsigWireFmt) - sigwire.TypeCovered = rr.TypeCovered - sigwire.Algorithm = rr.Algorithm - sigwire.Labels = rr.Labels - sigwire.OrigTtl = rr.OrigTtl - sigwire.Expiration = rr.Expiration - sigwire.Inception = rr.Inception - sigwire.KeyTag = rr.KeyTag - // For signing, lowercase this name - sigwire.SignerName = strings.ToLower(rr.SignerName) - - // Create the desired binary blob - signdata := make([]byte, DefaultMsgSize) - n, err := packSigWire(sigwire, signdata) - if err != nil { - return err - } - signdata = signdata[:n] - wire, err := rawSignatureData(rrset, rr) - if err != nil { - return err - } - signdata = append(signdata, wire...) - - hash, ok := AlgorithmToHash[rr.Algorithm] - if !ok { - return ErrAlg - } - - h := hash.New() - h.Write(signdata) - - signature, err := sign(k, h.Sum(nil), hash, rr.Algorithm) - if err != nil { - return err - } - - rr.Signature = toBase64(signature) - - return nil -} - -func sign(k crypto.Signer, hashed []byte, hash crypto.Hash, alg uint8) ([]byte, error) { - signature, err := k.Sign(rand.Reader, hashed, hash) - if err != nil { - return nil, err - } - - switch alg { - case RSASHA1, RSASHA1NSEC3SHA1, RSASHA256, RSASHA512: - return signature, nil - - case ECDSAP256SHA256, ECDSAP384SHA384: - ecdsaSignature := &struct { - R, S *big.Int - }{} - if _, err := asn1.Unmarshal(signature, ecdsaSignature); err != nil { - return nil, err - } - - var intlen int - switch alg { - case ECDSAP256SHA256: - intlen = 32 - case ECDSAP384SHA384: - intlen = 48 - } - - signature := intToBytes(ecdsaSignature.R, intlen) - signature = append(signature, intToBytes(ecdsaSignature.S, intlen)...) - return signature, nil - - // There is no defined interface for what a DSA backed crypto.Signer returns - case DSA, DSANSEC3SHA1: - // t := divRoundUp(divRoundUp(p.PublicKey.Y.BitLen(), 8)-64, 8) - // signature := []byte{byte(t)} - // signature = append(signature, intToBytes(r1, 20)...) - // signature = append(signature, intToBytes(s1, 20)...) - // rr.Signature = signature - } - - return nil, ErrAlg -} - -// Verify validates an RRSet with the signature and key. This is only the -// cryptographic test, the signature validity period must be checked separately. -// This function copies the rdata of some RRs (to lowercase domain names) for the validation to work. -func (rr *RRSIG) Verify(k *DNSKEY, rrset []RR) error { - // First the easy checks - if !IsRRset(rrset) { - return ErrRRset - } - if rr.KeyTag != k.KeyTag() { - return ErrKey - } - if rr.Hdr.Class != k.Hdr.Class { - return ErrKey - } - if rr.Algorithm != k.Algorithm { - return ErrKey - } - if strings.ToLower(rr.SignerName) != strings.ToLower(k.Hdr.Name) { - return ErrKey - } - if k.Protocol != 3 { - return ErrKey - } - - // IsRRset checked that we have at least one RR and that the RRs in - // the set have consistent type, class, and name. Also check that type and - // class matches the RRSIG record. - if rrset[0].Header().Class != rr.Hdr.Class { - return ErrRRset - } - if rrset[0].Header().Rrtype != rr.TypeCovered { - return ErrRRset - } - - // RFC 4035 5.3.2. Reconstructing the Signed Data - // Copy the sig, except the rrsig data - sigwire := new(rrsigWireFmt) - sigwire.TypeCovered = rr.TypeCovered - sigwire.Algorithm = rr.Algorithm - sigwire.Labels = rr.Labels - sigwire.OrigTtl = rr.OrigTtl - sigwire.Expiration = rr.Expiration - sigwire.Inception = rr.Inception - sigwire.KeyTag = rr.KeyTag - sigwire.SignerName = strings.ToLower(rr.SignerName) - // Create the desired binary blob - signeddata := make([]byte, DefaultMsgSize) - n, err := packSigWire(sigwire, signeddata) - if err != nil { - return err - } - signeddata = signeddata[:n] - wire, err := rawSignatureData(rrset, rr) - if err != nil { - return err - } - signeddata = append(signeddata, wire...) - - sigbuf := rr.sigBuf() // Get the binary signature data - if rr.Algorithm == PRIVATEDNS { // PRIVATEOID - // TODO(miek) - // remove the domain name and assume its ours? - } - - hash, ok := AlgorithmToHash[rr.Algorithm] - if !ok { - return ErrAlg - } - - switch rr.Algorithm { - case RSASHA1, RSASHA1NSEC3SHA1, RSASHA256, RSASHA512, RSAMD5: - // TODO(mg): this can be done quicker, ie. cache the pubkey data somewhere?? - pubkey := k.publicKeyRSA() // Get the key - if pubkey == nil { - return ErrKey - } - - h := hash.New() - h.Write(signeddata) - return rsa.VerifyPKCS1v15(pubkey, hash, h.Sum(nil), sigbuf) - - case ECDSAP256SHA256, ECDSAP384SHA384: - pubkey := k.publicKeyECDSA() - if pubkey == nil { - return ErrKey - } - - // Split sigbuf into the r and s coordinates - r := new(big.Int).SetBytes(sigbuf[:len(sigbuf)/2]) - s := new(big.Int).SetBytes(sigbuf[len(sigbuf)/2:]) - - h := hash.New() - h.Write(signeddata) - if ecdsa.Verify(pubkey, h.Sum(nil), r, s) { - return nil - } - return ErrSig - - default: - return ErrAlg - } -} - -// ValidityPeriod uses RFC1982 serial arithmetic to calculate -// if a signature period is valid. If t is the zero time, the -// current time is taken other t is. Returns true if the signature -// is valid at the given time, otherwise returns false. -func (rr *RRSIG) ValidityPeriod(t time.Time) bool { - var utc int64 - if t.IsZero() { - utc = time.Now().UTC().Unix() - } else { - utc = t.UTC().Unix() - } - modi := (int64(rr.Inception) - utc) / year68 - mode := (int64(rr.Expiration) - utc) / year68 - ti := int64(rr.Inception) + (modi * year68) - te := int64(rr.Expiration) + (mode * year68) - return ti <= utc && utc <= te -} - -// Return the signatures base64 encodedig sigdata as a byte slice. -func (rr *RRSIG) sigBuf() []byte { - sigbuf, err := fromBase64([]byte(rr.Signature)) - if err != nil { - return nil - } - return sigbuf -} - -// publicKeyRSA returns the RSA public key from a DNSKEY record. -func (k *DNSKEY) publicKeyRSA() *rsa.PublicKey { - keybuf, err := fromBase64([]byte(k.PublicKey)) - if err != nil { - return nil - } - - // RFC 2537/3110, section 2. RSA Public KEY Resource Records - // Length is in the 0th byte, unless its zero, then it - // it in bytes 1 and 2 and its a 16 bit number - explen := uint16(keybuf[0]) - keyoff := 1 - if explen == 0 { - explen = uint16(keybuf[1])<<8 | uint16(keybuf[2]) - keyoff = 3 - } - pubkey := new(rsa.PublicKey) - - pubkey.N = big.NewInt(0) - shift := uint64((explen - 1) * 8) - expo := uint64(0) - for i := int(explen - 1); i > 0; i-- { - expo += uint64(keybuf[keyoff+i]) << shift - shift -= 8 - } - // Remainder - expo += uint64(keybuf[keyoff]) - if expo > 2<<31 { - // Larger expo than supported. - // println("dns: F5 primes (or larger) are not supported") - return nil - } - pubkey.E = int(expo) - - pubkey.N.SetBytes(keybuf[keyoff+int(explen):]) - return pubkey -} - -// publicKeyECDSA returns the Curve public key from the DNSKEY record. -func (k *DNSKEY) publicKeyECDSA() *ecdsa.PublicKey { - keybuf, err := fromBase64([]byte(k.PublicKey)) - if err != nil { - return nil - } - pubkey := new(ecdsa.PublicKey) - switch k.Algorithm { - case ECDSAP256SHA256: - pubkey.Curve = elliptic.P256() - if len(keybuf) != 64 { - // wrongly encoded key - return nil - } - case ECDSAP384SHA384: - pubkey.Curve = elliptic.P384() - if len(keybuf) != 96 { - // Wrongly encoded key - return nil - } - } - pubkey.X = big.NewInt(0) - pubkey.X.SetBytes(keybuf[:len(keybuf)/2]) - pubkey.Y = big.NewInt(0) - pubkey.Y.SetBytes(keybuf[len(keybuf)/2:]) - return pubkey -} - -func (k *DNSKEY) publicKeyDSA() *dsa.PublicKey { - keybuf, err := fromBase64([]byte(k.PublicKey)) - if err != nil { - return nil - } - if len(keybuf) < 22 { - return nil - } - t, keybuf := int(keybuf[0]), keybuf[1:] - size := 64 + t*8 - q, keybuf := keybuf[:20], keybuf[20:] - if len(keybuf) != 3*size { - return nil - } - p, keybuf := keybuf[:size], keybuf[size:] - g, y := keybuf[:size], keybuf[size:] - pubkey := new(dsa.PublicKey) - pubkey.Parameters.Q = big.NewInt(0).SetBytes(q) - pubkey.Parameters.P = big.NewInt(0).SetBytes(p) - pubkey.Parameters.G = big.NewInt(0).SetBytes(g) - pubkey.Y = big.NewInt(0).SetBytes(y) - return pubkey -} - -type wireSlice [][]byte - -func (p wireSlice) Len() int { return len(p) } -func (p wireSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p wireSlice) Less(i, j int) bool { - _, ioff, _ := UnpackDomainName(p[i], 0) - _, joff, _ := UnpackDomainName(p[j], 0) - return bytes.Compare(p[i][ioff+10:], p[j][joff+10:]) < 0 -} - -// Return the raw signature data. -func rawSignatureData(rrset []RR, s *RRSIG) (buf []byte, err error) { - wires := make(wireSlice, len(rrset)) - for i, r := range rrset { - r1 := r.copy() - r1.Header().Ttl = s.OrigTtl - labels := SplitDomainName(r1.Header().Name) - // 6.2. Canonical RR Form. (4) - wildcards - if len(labels) > int(s.Labels) { - // Wildcard - r1.Header().Name = "*." + strings.Join(labels[len(labels)-int(s.Labels):], ".") + "." - } - // RFC 4034: 6.2. Canonical RR Form. (2) - domain name to lowercase - r1.Header().Name = strings.ToLower(r1.Header().Name) - // 6.2. Canonical RR Form. (3) - domain rdata to lowercase. - // NS, MD, MF, CNAME, SOA, MB, MG, MR, PTR, - // HINFO, MINFO, MX, RP, AFSDB, RT, SIG, PX, NXT, NAPTR, KX, - // SRV, DNAME, A6 - // - // RFC 6840 - Clarifications and Implementation Notes for DNS Security (DNSSEC): - // Section 6.2 of [RFC4034] also erroneously lists HINFO as a record - // that needs conversion to lowercase, and twice at that. Since HINFO - // records contain no domain names, they are not subject to case - // conversion. - switch x := r1.(type) { - case *NS: - x.Ns = strings.ToLower(x.Ns) - case *CNAME: - x.Target = strings.ToLower(x.Target) - case *SOA: - x.Ns = strings.ToLower(x.Ns) - x.Mbox = strings.ToLower(x.Mbox) - case *MB: - x.Mb = strings.ToLower(x.Mb) - case *MG: - x.Mg = strings.ToLower(x.Mg) - case *MR: - x.Mr = strings.ToLower(x.Mr) - case *PTR: - x.Ptr = strings.ToLower(x.Ptr) - case *MINFO: - x.Rmail = strings.ToLower(x.Rmail) - x.Email = strings.ToLower(x.Email) - case *MX: - x.Mx = strings.ToLower(x.Mx) - case *NAPTR: - x.Replacement = strings.ToLower(x.Replacement) - case *KX: - x.Exchanger = strings.ToLower(x.Exchanger) - case *SRV: - x.Target = strings.ToLower(x.Target) - case *DNAME: - x.Target = strings.ToLower(x.Target) - } - // 6.2. Canonical RR Form. (5) - origTTL - wire := make([]byte, r1.len()+1) // +1 to be safe(r) - off, err1 := PackRR(r1, wire, 0, nil, false) - if err1 != nil { - return nil, err1 - } - wire = wire[:off] - wires[i] = wire - } - sort.Sort(wires) - for i, wire := range wires { - if i > 0 && bytes.Equal(wire, wires[i-1]) { - continue - } - buf = append(buf, wire...) - } - return buf, nil -} - -func packSigWire(sw *rrsigWireFmt, msg []byte) (int, error) { - // copied from zmsg.go RRSIG packing - off, err := packUint16(sw.TypeCovered, msg, 0) - if err != nil { - return off, err - } - off, err = packUint8(sw.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(sw.Labels, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(sw.OrigTtl, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(sw.Expiration, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(sw.Inception, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(sw.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(sw.SignerName, msg, off, nil, false) - if err != nil { - return off, err - } - return off, nil -} - -func packKeyWire(dw *dnskeyWireFmt, msg []byte) (int, error) { - // copied from zmsg.go DNSKEY packing - off, err := packUint16(dw.Flags, msg, 0) - if err != nil { - return off, err - } - off, err = packUint8(dw.Protocol, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(dw.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase64(dw.PublicKey, msg, off) - if err != nil { - return off, err - } - return off, nil -} diff --git a/vendor/github.com/miekg/dns/dnssec_keygen.go b/vendor/github.com/miekg/dns/dnssec_keygen.go deleted file mode 100644 index 229a079..0000000 --- a/vendor/github.com/miekg/dns/dnssec_keygen.go +++ /dev/null @@ -1,156 +0,0 @@ -package dns - -import ( - "crypto" - "crypto/dsa" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/rsa" - "math/big" -) - -// Generate generates a DNSKEY of the given bit size. -// The public part is put inside the DNSKEY record. -// The Algorithm in the key must be set as this will define -// what kind of DNSKEY will be generated. -// The ECDSA algorithms imply a fixed keysize, in that case -// bits should be set to the size of the algorithm. -func (k *DNSKEY) Generate(bits int) (crypto.PrivateKey, error) { - switch k.Algorithm { - case DSA, DSANSEC3SHA1: - if bits != 1024 { - return nil, ErrKeySize - } - case RSAMD5, RSASHA1, RSASHA256, RSASHA1NSEC3SHA1: - if bits < 512 || bits > 4096 { - return nil, ErrKeySize - } - case RSASHA512: - if bits < 1024 || bits > 4096 { - return nil, ErrKeySize - } - case ECDSAP256SHA256: - if bits != 256 { - return nil, ErrKeySize - } - case ECDSAP384SHA384: - if bits != 384 { - return nil, ErrKeySize - } - } - - switch k.Algorithm { - case DSA, DSANSEC3SHA1: - params := new(dsa.Parameters) - if err := dsa.GenerateParameters(params, rand.Reader, dsa.L1024N160); err != nil { - return nil, err - } - priv := new(dsa.PrivateKey) - priv.PublicKey.Parameters = *params - err := dsa.GenerateKey(priv, rand.Reader) - if err != nil { - return nil, err - } - k.setPublicKeyDSA(params.Q, params.P, params.G, priv.PublicKey.Y) - return priv, nil - case RSAMD5, RSASHA1, RSASHA256, RSASHA512, RSASHA1NSEC3SHA1: - priv, err := rsa.GenerateKey(rand.Reader, bits) - if err != nil { - return nil, err - } - k.setPublicKeyRSA(priv.PublicKey.E, priv.PublicKey.N) - return priv, nil - case ECDSAP256SHA256, ECDSAP384SHA384: - var c elliptic.Curve - switch k.Algorithm { - case ECDSAP256SHA256: - c = elliptic.P256() - case ECDSAP384SHA384: - c = elliptic.P384() - } - priv, err := ecdsa.GenerateKey(c, rand.Reader) - if err != nil { - return nil, err - } - k.setPublicKeyECDSA(priv.PublicKey.X, priv.PublicKey.Y) - return priv, nil - default: - return nil, ErrAlg - } -} - -// Set the public key (the value E and N) -func (k *DNSKEY) setPublicKeyRSA(_E int, _N *big.Int) bool { - if _E == 0 || _N == nil { - return false - } - buf := exponentToBuf(_E) - buf = append(buf, _N.Bytes()...) - k.PublicKey = toBase64(buf) - return true -} - -// Set the public key for Elliptic Curves -func (k *DNSKEY) setPublicKeyECDSA(_X, _Y *big.Int) bool { - if _X == nil || _Y == nil { - return false - } - var intlen int - switch k.Algorithm { - case ECDSAP256SHA256: - intlen = 32 - case ECDSAP384SHA384: - intlen = 48 - } - k.PublicKey = toBase64(curveToBuf(_X, _Y, intlen)) - return true -} - -// Set the public key for DSA -func (k *DNSKEY) setPublicKeyDSA(_Q, _P, _G, _Y *big.Int) bool { - if _Q == nil || _P == nil || _G == nil || _Y == nil { - return false - } - buf := dsaToBuf(_Q, _P, _G, _Y) - k.PublicKey = toBase64(buf) - return true -} - -// Set the public key (the values E and N) for RSA -// RFC 3110: Section 2. RSA Public KEY Resource Records -func exponentToBuf(_E int) []byte { - var buf []byte - i := big.NewInt(int64(_E)) - if len(i.Bytes()) < 256 { - buf = make([]byte, 1) - buf[0] = uint8(len(i.Bytes())) - } else { - buf = make([]byte, 3) - buf[0] = 0 - buf[1] = uint8(len(i.Bytes()) >> 8) - buf[2] = uint8(len(i.Bytes())) - } - buf = append(buf, i.Bytes()...) - return buf -} - -// Set the public key for X and Y for Curve. The two -// values are just concatenated. -func curveToBuf(_X, _Y *big.Int, intlen int) []byte { - buf := intToBytes(_X, intlen) - buf = append(buf, intToBytes(_Y, intlen)...) - return buf -} - -// Set the public key for X and Y for Curve. The two -// values are just concatenated. -func dsaToBuf(_Q, _P, _G, _Y *big.Int) []byte { - t := divRoundUp(divRoundUp(_G.BitLen(), 8)-64, 8) - buf := []byte{byte(t)} - buf = append(buf, intToBytes(_Q, 20)...) - buf = append(buf, intToBytes(_P, 64+t*8)...) - buf = append(buf, intToBytes(_G, 64+t*8)...) - buf = append(buf, intToBytes(_Y, 64+t*8)...) - return buf -} diff --git a/vendor/github.com/miekg/dns/dnssec_keyscan.go b/vendor/github.com/miekg/dns/dnssec_keyscan.go deleted file mode 100644 index c0b54dc..0000000 --- a/vendor/github.com/miekg/dns/dnssec_keyscan.go +++ /dev/null @@ -1,249 +0,0 @@ -package dns - -import ( - "crypto" - "crypto/dsa" - "crypto/ecdsa" - "crypto/rsa" - "io" - "math/big" - "strconv" - "strings" -) - -// NewPrivateKey returns a PrivateKey by parsing the string s. -// s should be in the same form of the BIND private key files. -func (k *DNSKEY) NewPrivateKey(s string) (crypto.PrivateKey, error) { - if s[len(s)-1] != '\n' { // We need a closing newline - return k.ReadPrivateKey(strings.NewReader(s+"\n"), "") - } - return k.ReadPrivateKey(strings.NewReader(s), "") -} - -// ReadPrivateKey reads a private key from the io.Reader q. The string file is -// only used in error reporting. -// The public key must be known, because some cryptographic algorithms embed -// the public inside the privatekey. -func (k *DNSKEY) ReadPrivateKey(q io.Reader, file string) (crypto.PrivateKey, error) { - m, err := parseKey(q, file) - if m == nil { - return nil, err - } - if _, ok := m["private-key-format"]; !ok { - return nil, ErrPrivKey - } - if m["private-key-format"] != "v1.2" && m["private-key-format"] != "v1.3" { - return nil, ErrPrivKey - } - // TODO(mg): check if the pubkey matches the private key - algo, err := strconv.Atoi(strings.SplitN(m["algorithm"], " ", 2)[0]) - if err != nil { - return nil, ErrPrivKey - } - switch uint8(algo) { - case DSA: - priv, err := readPrivateKeyDSA(m) - if err != nil { - return nil, err - } - pub := k.publicKeyDSA() - if pub == nil { - return nil, ErrKey - } - priv.PublicKey = *pub - return priv, nil - case RSAMD5: - fallthrough - case RSASHA1: - fallthrough - case RSASHA1NSEC3SHA1: - fallthrough - case RSASHA256: - fallthrough - case RSASHA512: - priv, err := readPrivateKeyRSA(m) - if err != nil { - return nil, err - } - pub := k.publicKeyRSA() - if pub == nil { - return nil, ErrKey - } - priv.PublicKey = *pub - return priv, nil - case ECCGOST: - return nil, ErrPrivKey - case ECDSAP256SHA256: - fallthrough - case ECDSAP384SHA384: - priv, err := readPrivateKeyECDSA(m) - if err != nil { - return nil, err - } - pub := k.publicKeyECDSA() - if pub == nil { - return nil, ErrKey - } - priv.PublicKey = *pub - return priv, nil - default: - return nil, ErrPrivKey - } -} - -// Read a private key (file) string and create a public key. Return the private key. -func readPrivateKeyRSA(m map[string]string) (*rsa.PrivateKey, error) { - p := new(rsa.PrivateKey) - p.Primes = []*big.Int{nil, nil} - for k, v := range m { - switch k { - case "modulus", "publicexponent", "privateexponent", "prime1", "prime2": - v1, err := fromBase64([]byte(v)) - if err != nil { - return nil, err - } - switch k { - case "modulus": - p.PublicKey.N = big.NewInt(0) - p.PublicKey.N.SetBytes(v1) - case "publicexponent": - i := big.NewInt(0) - i.SetBytes(v1) - p.PublicKey.E = int(i.Int64()) // int64 should be large enough - case "privateexponent": - p.D = big.NewInt(0) - p.D.SetBytes(v1) - case "prime1": - p.Primes[0] = big.NewInt(0) - p.Primes[0].SetBytes(v1) - case "prime2": - p.Primes[1] = big.NewInt(0) - p.Primes[1].SetBytes(v1) - } - case "exponent1", "exponent2", "coefficient": - // not used in Go (yet) - case "created", "publish", "activate": - // not used in Go (yet) - } - } - return p, nil -} - -func readPrivateKeyDSA(m map[string]string) (*dsa.PrivateKey, error) { - p := new(dsa.PrivateKey) - p.X = big.NewInt(0) - for k, v := range m { - switch k { - case "private_value(x)": - v1, err := fromBase64([]byte(v)) - if err != nil { - return nil, err - } - p.X.SetBytes(v1) - case "created", "publish", "activate": - /* not used in Go (yet) */ - } - } - return p, nil -} - -func readPrivateKeyECDSA(m map[string]string) (*ecdsa.PrivateKey, error) { - p := new(ecdsa.PrivateKey) - p.D = big.NewInt(0) - // TODO: validate that the required flags are present - for k, v := range m { - switch k { - case "privatekey": - v1, err := fromBase64([]byte(v)) - if err != nil { - return nil, err - } - p.D.SetBytes(v1) - case "created", "publish", "activate": - /* not used in Go (yet) */ - } - } - return p, nil -} - -// parseKey reads a private key from r. It returns a map[string]string, -// with the key-value pairs, or an error when the file is not correct. -func parseKey(r io.Reader, file string) (map[string]string, error) { - s := scanInit(r) - m := make(map[string]string) - c := make(chan lex) - k := "" - // Start the lexer - go klexer(s, c) - for l := range c { - // It should alternate - switch l.value { - case zKey: - k = l.token - case zValue: - if k == "" { - return nil, &ParseError{file, "no private key seen", l} - } - //println("Setting", strings.ToLower(k), "to", l.token, "b") - m[strings.ToLower(k)] = l.token - k = "" - } - } - return m, nil -} - -// klexer scans the sourcefile and returns tokens on the channel c. -func klexer(s *scan, c chan lex) { - var l lex - str := "" // Hold the current read text - commt := false - key := true - x, err := s.tokenText() - defer close(c) - for err == nil { - l.column = s.position.Column - l.line = s.position.Line - switch x { - case ':': - if commt { - break - } - l.token = str - if key { - l.value = zKey - c <- l - // Next token is a space, eat it - s.tokenText() - key = false - str = "" - } else { - l.value = zValue - } - case ';': - commt = true - case '\n': - if commt { - // Reset a comment - commt = false - } - l.value = zValue - l.token = str - c <- l - str = "" - commt = false - key = true - default: - if commt { - break - } - str += string(x) - } - x, err = s.tokenText() - } - if len(str) > 0 { - // Send remainder - l.token = str - l.value = zValue - c <- l - } -} diff --git a/vendor/github.com/miekg/dns/dnssec_privkey.go b/vendor/github.com/miekg/dns/dnssec_privkey.go deleted file mode 100644 index 56f3ea9..0000000 --- a/vendor/github.com/miekg/dns/dnssec_privkey.go +++ /dev/null @@ -1,85 +0,0 @@ -package dns - -import ( - "crypto" - "crypto/dsa" - "crypto/ecdsa" - "crypto/rsa" - "math/big" - "strconv" -) - -const format = "Private-key-format: v1.3\n" - -// PrivateKeyString converts a PrivateKey to a string. This string has the same -// format as the private-key-file of BIND9 (Private-key-format: v1.3). -// It needs some info from the key (the algorithm), so its a method of the DNSKEY -// It supports rsa.PrivateKey, ecdsa.PrivateKey and dsa.PrivateKey -func (r *DNSKEY) PrivateKeyString(p crypto.PrivateKey) string { - algorithm := strconv.Itoa(int(r.Algorithm)) - algorithm += " (" + AlgorithmToString[r.Algorithm] + ")" - - switch p := p.(type) { - case *rsa.PrivateKey: - modulus := toBase64(p.PublicKey.N.Bytes()) - e := big.NewInt(int64(p.PublicKey.E)) - publicExponent := toBase64(e.Bytes()) - privateExponent := toBase64(p.D.Bytes()) - prime1 := toBase64(p.Primes[0].Bytes()) - prime2 := toBase64(p.Primes[1].Bytes()) - // Calculate Exponent1/2 and Coefficient as per: http://en.wikipedia.org/wiki/RSA#Using_the_Chinese_remainder_algorithm - // and from: http://code.google.com/p/go/issues/detail?id=987 - one := big.NewInt(1) - p1 := big.NewInt(0).Sub(p.Primes[0], one) - q1 := big.NewInt(0).Sub(p.Primes[1], one) - exp1 := big.NewInt(0).Mod(p.D, p1) - exp2 := big.NewInt(0).Mod(p.D, q1) - coeff := big.NewInt(0).ModInverse(p.Primes[1], p.Primes[0]) - - exponent1 := toBase64(exp1.Bytes()) - exponent2 := toBase64(exp2.Bytes()) - coefficient := toBase64(coeff.Bytes()) - - return format + - "Algorithm: " + algorithm + "\n" + - "Modulus: " + modulus + "\n" + - "PublicExponent: " + publicExponent + "\n" + - "PrivateExponent: " + privateExponent + "\n" + - "Prime1: " + prime1 + "\n" + - "Prime2: " + prime2 + "\n" + - "Exponent1: " + exponent1 + "\n" + - "Exponent2: " + exponent2 + "\n" + - "Coefficient: " + coefficient + "\n" - - case *ecdsa.PrivateKey: - var intlen int - switch r.Algorithm { - case ECDSAP256SHA256: - intlen = 32 - case ECDSAP384SHA384: - intlen = 48 - } - private := toBase64(intToBytes(p.D, intlen)) - return format + - "Algorithm: " + algorithm + "\n" + - "PrivateKey: " + private + "\n" - - case *dsa.PrivateKey: - T := divRoundUp(divRoundUp(p.PublicKey.Parameters.G.BitLen(), 8)-64, 8) - prime := toBase64(intToBytes(p.PublicKey.Parameters.P, 64+T*8)) - subprime := toBase64(intToBytes(p.PublicKey.Parameters.Q, 20)) - base := toBase64(intToBytes(p.PublicKey.Parameters.G, 64+T*8)) - priv := toBase64(intToBytes(p.X, 20)) - pub := toBase64(intToBytes(p.PublicKey.Y, 64+T*8)) - return format + - "Algorithm: " + algorithm + "\n" + - "Prime(p): " + prime + "\n" + - "Subprime(q): " + subprime + "\n" + - "Base(g): " + base + "\n" + - "Private_value(x): " + priv + "\n" + - "Public_value(y): " + pub + "\n" - - default: - return "" - } -} diff --git a/vendor/github.com/miekg/dns/dnssec_test.go b/vendor/github.com/miekg/dns/dnssec_test.go deleted file mode 100644 index ca085ed..0000000 --- a/vendor/github.com/miekg/dns/dnssec_test.go +++ /dev/null @@ -1,733 +0,0 @@ -package dns - -import ( - "crypto" - "crypto/ecdsa" - "crypto/rsa" - "reflect" - "strings" - "testing" - "time" -) - -func getKey() *DNSKEY { - key := new(DNSKEY) - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - key.PublicKey = "AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5ECIoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXHPy7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz" - return key -} - -func getSoa() *SOA { - soa := new(SOA) - soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0} - soa.Ns = "open.nlnetlabs.nl." - soa.Mbox = "miekg.atoom.net." - soa.Serial = 1293945905 - soa.Refresh = 14400 - soa.Retry = 3600 - soa.Expire = 604800 - soa.Minttl = 86400 - return soa -} - -func TestGenerateEC(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } - key := new(DNSKEY) - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = ECDSAP256SHA256 - privkey, _ := key.Generate(256) - t.Log(key.String()) - t.Log(key.PrivateKeyString(privkey)) -} - -func TestGenerateDSA(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } - key := new(DNSKEY) - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = DSA - privkey, _ := key.Generate(1024) - t.Log(key.String()) - t.Log(key.PrivateKeyString(privkey)) -} - -func TestGenerateRSA(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } - key := new(DNSKEY) - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - privkey, _ := key.Generate(1024) - t.Log(key.String()) - t.Log(key.PrivateKeyString(privkey)) -} - -func TestSecure(t *testing.T) { - soa := getSoa() - - sig := new(RRSIG) - sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0} - sig.TypeCovered = TypeSOA - sig.Algorithm = RSASHA256 - sig.Labels = 2 - sig.Expiration = 1296534305 // date -u '+%s' -d"2011-02-01 04:25:05" - sig.Inception = 1293942305 // date -u '+%s' -d"2011-01-02 04:25:05" - sig.OrigTtl = 14400 - sig.KeyTag = 12051 - sig.SignerName = "miek.nl." - sig.Signature = "oMCbslaAVIp/8kVtLSms3tDABpcPRUgHLrOR48OOplkYo+8TeEGWwkSwaz/MRo2fB4FxW0qj/hTlIjUGuACSd+b1wKdH5GvzRJc2pFmxtCbm55ygAh4EUL0F6U5cKtGJGSXxxg6UFCQ0doJCmiGFa78LolaUOXImJrk6AFrGa0M=" - - key := new(DNSKEY) - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - key.PublicKey = "AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5ECIoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXHPy7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz" - - // It should validate. Period is checked separately, so this will keep on working - if sig.Verify(key, []RR{soa}) != nil { - t.Error("failure to validate") - } -} - -func TestSignature(t *testing.T) { - sig := new(RRSIG) - sig.Hdr.Name = "miek.nl." - sig.Hdr.Class = ClassINET - sig.Hdr.Ttl = 3600 - sig.TypeCovered = TypeDNSKEY - sig.Algorithm = RSASHA1 - sig.Labels = 2 - sig.OrigTtl = 4000 - sig.Expiration = 1000 //Thu Jan 1 02:06:40 CET 1970 - sig.Inception = 800 //Thu Jan 1 01:13:20 CET 1970 - sig.KeyTag = 34641 - sig.SignerName = "miek.nl." - sig.Signature = "AwEAAaHIwpx3w4VHKi6i1LHnTaWeHCL154Jug0Rtc9ji5qwPXpBo6A5sRv7cSsPQKPIwxLpyCrbJ4mr2L0EPOdvP6z6YfljK2ZmTbogU9aSU2fiq/4wjxbdkLyoDVgtO+JsxNN4bjr4WcWhsmk1Hg93FV9ZpkWb0Tbad8DFqNDzr//kZ" - - // Should not be valid - if sig.ValidityPeriod(time.Now()) { - t.Error("should not be valid") - } - - sig.Inception = 315565800 //Tue Jan 1 10:10:00 CET 1980 - sig.Expiration = 4102477800 //Fri Jan 1 10:10:00 CET 2100 - if !sig.ValidityPeriod(time.Now()) { - t.Error("should be valid") - } -} - -func TestSignVerify(t *testing.T) { - // The record we want to sign - soa := new(SOA) - soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0} - soa.Ns = "open.nlnetlabs.nl." - soa.Mbox = "miekg.atoom.net." - soa.Serial = 1293945905 - soa.Refresh = 14400 - soa.Retry = 3600 - soa.Expire = 604800 - soa.Minttl = 86400 - - soa1 := new(SOA) - soa1.Hdr = RR_Header{"*.miek.nl.", TypeSOA, ClassINET, 14400, 0} - soa1.Ns = "open.nlnetlabs.nl." - soa1.Mbox = "miekg.atoom.net." - soa1.Serial = 1293945905 - soa1.Refresh = 14400 - soa1.Retry = 3600 - soa1.Expire = 604800 - soa1.Minttl = 86400 - - srv := new(SRV) - srv.Hdr = RR_Header{"srv.miek.nl.", TypeSRV, ClassINET, 14400, 0} - srv.Port = 1000 - srv.Weight = 800 - srv.Target = "web1.miek.nl." - - hinfo := &HINFO{ - Hdr: RR_Header{ - Name: "miek.nl.", - Rrtype: TypeHINFO, - Class: ClassINET, - Ttl: 3789, - }, - Cpu: "X", - Os: "Y", - } - - // With this key - key := new(DNSKEY) - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - privkey, _ := key.Generate(512) - - // Fill in the values of the Sig, before signing - sig := new(RRSIG) - sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0} - sig.TypeCovered = soa.Hdr.Rrtype - sig.Labels = uint8(CountLabel(soa.Hdr.Name)) // works for all 3 - sig.OrigTtl = soa.Hdr.Ttl - sig.Expiration = 1296534305 // date -u '+%s' -d"2011-02-01 04:25:05" - sig.Inception = 1293942305 // date -u '+%s' -d"2011-01-02 04:25:05" - sig.KeyTag = key.KeyTag() // Get the keyfrom the Key - sig.SignerName = key.Hdr.Name - sig.Algorithm = RSASHA256 - - for _, r := range []RR{soa, soa1, srv, hinfo} { - if err := sig.Sign(privkey.(*rsa.PrivateKey), []RR{r}); err != nil { - t.Error("failure to sign the record:", err) - continue - } - if err := sig.Verify(key, []RR{r}); err != nil { - t.Error("failure to validate") - continue - } - t.Logf("validated: %s", r.Header().Name) - } -} - -func Test65534(t *testing.T) { - t6 := new(RFC3597) - t6.Hdr = RR_Header{"miek.nl.", 65534, ClassINET, 14400, 0} - t6.Rdata = "505D870001" - key := new(DNSKEY) - key.Hdr.Name = "miek.nl." - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - privkey, _ := key.Generate(1024) - - sig := new(RRSIG) - sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0} - sig.TypeCovered = t6.Hdr.Rrtype - sig.Labels = uint8(CountLabel(t6.Hdr.Name)) - sig.OrigTtl = t6.Hdr.Ttl - sig.Expiration = 1296534305 // date -u '+%s' -d"2011-02-01 04:25:05" - sig.Inception = 1293942305 // date -u '+%s' -d"2011-01-02 04:25:05" - sig.KeyTag = key.KeyTag() - sig.SignerName = key.Hdr.Name - sig.Algorithm = RSASHA256 - if err := sig.Sign(privkey.(*rsa.PrivateKey), []RR{t6}); err != nil { - t.Error(err) - t.Error("failure to sign the TYPE65534 record") - } - if err := sig.Verify(key, []RR{t6}); err != nil { - t.Error(err) - t.Error("failure to validate") - } else { - t.Logf("validated: %s", t6.Header().Name) - } -} - -func TestDnskey(t *testing.T) { - pubkey, err := ReadRR(strings.NewReader(` -miek.nl. IN DNSKEY 256 3 10 AwEAAZuMCu2FdugHkTrXYgl5qixvcDw1aDDlvL46/xJKbHBAHY16fNUb2b65cwko2Js/aJxUYJbZk5dwCDZxYfrfbZVtDPQuc3o8QaChVxC7/JYz2AHc9qHvqQ1j4VrH71RWINlQo6VYjzN/BGpMhOZoZOEwzp1HfsOE3lNYcoWU1smL ;{id = 5240 (zsk), size = 1024b} -`), "Kmiek.nl.+010+05240.key") - if err != nil { - t.Fatal(err) - } - privStr := `Private-key-format: v1.3 -Algorithm: 10 (RSASHA512) -Modulus: m4wK7YV26AeROtdiCXmqLG9wPDVoMOW8vjr/EkpscEAdjXp81RvZvrlzCSjYmz9onFRgltmTl3AINnFh+t9tlW0M9C5zejxBoKFXELv8ljPYAdz2oe+pDWPhWsfvVFYg2VCjpViPM38EakyE5mhk4TDOnUd+w4TeU1hyhZTWyYs= -PublicExponent: AQAB -PrivateExponent: UfCoIQ/Z38l8vB6SSqOI/feGjHEl/fxIPX4euKf0D/32k30fHbSaNFrFOuIFmWMB3LimWVEs6u3dpbB9CQeCVg7hwU5puG7OtuiZJgDAhNeOnxvo5btp4XzPZrJSxR4WNQnwIiYWbl0aFlL1VGgHC/3By89ENZyWaZcMLW4KGWE= -Prime1: yxwC6ogAu8aVcDx2wg1V0b5M5P6jP8qkRFVMxWNTw60Vkn+ECvw6YAZZBHZPaMyRYZLzPgUlyYRd0cjupy4+fQ== -Prime2: xA1bF8M0RTIQ6+A11AoVG6GIR/aPGg5sogRkIZ7ID/sF6g9HMVU/CM2TqVEBJLRPp73cv6ZeC3bcqOCqZhz+pw== -Exponent1: xzkblyZ96bGYxTVZm2/vHMOXswod4KWIyMoOepK6B/ZPcZoIT6omLCgtypWtwHLfqyCz3MK51Nc0G2EGzg8rFQ== -Exponent2: Pu5+mCEb7T5F+kFNZhQadHUklt0JUHbi3hsEvVoHpEGSw3BGDQrtIflDde0/rbWHgDPM4WQY+hscd8UuTXrvLw== -Coefficient: UuRoNqe7YHnKmQzE6iDWKTMIWTuoqqrFAmXPmKQnC+Y+BQzOVEHUo9bXdDnoI9hzXP1gf8zENMYwYLeWpuYlFQ== -` - privkey, err := pubkey.(*DNSKEY).ReadPrivateKey(strings.NewReader(privStr), - "Kmiek.nl.+010+05240.private") - if err != nil { - t.Fatal(err) - } - if pubkey.(*DNSKEY).PublicKey != "AwEAAZuMCu2FdugHkTrXYgl5qixvcDw1aDDlvL46/xJKbHBAHY16fNUb2b65cwko2Js/aJxUYJbZk5dwCDZxYfrfbZVtDPQuc3o8QaChVxC7/JYz2AHc9qHvqQ1j4VrH71RWINlQo6VYjzN/BGpMhOZoZOEwzp1HfsOE3lNYcoWU1smL" { - t.Error("pubkey is not what we've read") - } - if pubkey.(*DNSKEY).PrivateKeyString(privkey) != privStr { - t.Error("privkey is not what we've read") - t.Errorf("%v", pubkey.(*DNSKEY).PrivateKeyString(privkey)) - } -} - -func TestTag(t *testing.T) { - key := new(DNSKEY) - key.Hdr.Name = "miek.nl." - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 3600 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - key.PublicKey = "AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5ECIoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXHPy7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz" - - tag := key.KeyTag() - if tag != 12051 { - t.Errorf("wrong key tag: %d for key %v", tag, key) - } -} - -func TestKeyRSA(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } - key := new(DNSKEY) - key.Hdr.Name = "miek.nl." - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 3600 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - priv, _ := key.Generate(2048) - - soa := new(SOA) - soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0} - soa.Ns = "open.nlnetlabs.nl." - soa.Mbox = "miekg.atoom.net." - soa.Serial = 1293945905 - soa.Refresh = 14400 - soa.Retry = 3600 - soa.Expire = 604800 - soa.Minttl = 86400 - - sig := new(RRSIG) - sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0} - sig.TypeCovered = TypeSOA - sig.Algorithm = RSASHA256 - sig.Labels = 2 - sig.Expiration = 1296534305 // date -u '+%s' -d"2011-02-01 04:25:05" - sig.Inception = 1293942305 // date -u '+%s' -d"2011-01-02 04:25:05" - sig.OrigTtl = soa.Hdr.Ttl - sig.KeyTag = key.KeyTag() - sig.SignerName = key.Hdr.Name - - if err := sig.Sign(priv.(*rsa.PrivateKey), []RR{soa}); err != nil { - t.Error("failed to sign") - return - } - if err := sig.Verify(key, []RR{soa}); err != nil { - t.Error("failed to verify") - } -} - -func TestKeyToDS(t *testing.T) { - key := new(DNSKEY) - key.Hdr.Name = "miek.nl." - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 3600 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = RSASHA256 - key.PublicKey = "AwEAAcNEU67LJI5GEgF9QLNqLO1SMq1EdoQ6E9f85ha0k0ewQGCblyW2836GiVsm6k8Kr5ECIoMJ6fZWf3CQSQ9ycWfTyOHfmI3eQ/1Covhb2y4bAmL/07PhrL7ozWBW3wBfM335Ft9xjtXHPy7ztCbV9qZ4TVDTW/Iyg0PiwgoXVesz" - - ds := key.ToDS(SHA1) - if strings.ToUpper(ds.Digest) != "B5121BDB5B8D86D0CC5FFAFBAAABE26C3E20BAC1" { - t.Errorf("wrong DS digest for SHA1\n%v", ds) - } -} - -func TestSignRSA(t *testing.T) { - pub := "miek.nl. IN DNSKEY 256 3 5 AwEAAb+8lGNCxJgLS8rYVer6EnHVuIkQDghdjdtewDzU3G5R7PbMbKVRvH2Ma7pQyYceoaqWZQirSj72euPWfPxQnMy9ucCylA+FuH9cSjIcPf4PqJfdupHk9X6EBYjxrCLY4p1/yBwgyBIRJtZtAqM3ceAH2WovEJD6rTtOuHo5AluJ" - - priv := `Private-key-format: v1.3 -Algorithm: 5 (RSASHA1) -Modulus: v7yUY0LEmAtLythV6voScdW4iRAOCF2N217APNTcblHs9sxspVG8fYxrulDJhx6hqpZlCKtKPvZ649Z8/FCczL25wLKUD4W4f1xKMhw9/g+ol926keT1foQFiPGsItjinX/IHCDIEhEm1m0Cozdx4AfZai8QkPqtO064ejkCW4k= -PublicExponent: AQAB -PrivateExponent: YPwEmwjk5HuiROKU4xzHQ6l1hG8Iiha4cKRG3P5W2b66/EN/GUh07ZSf0UiYB67o257jUDVEgwCuPJz776zfApcCB4oGV+YDyEu7Hp/rL8KcSN0la0k2r9scKwxTp4BTJT23zyBFXsV/1wRDK1A5NxsHPDMYi2SoK63Enm/1ptk= -Prime1: /wjOG+fD0ybNoSRn7nQ79udGeR1b0YhUA5mNjDx/x2fxtIXzygYk0Rhx9QFfDy6LOBvz92gbNQlzCLz3DJt5hw== -Prime2: wHZsJ8OGhkp5p3mrJFZXMDc2mbYusDVTA+t+iRPdS797Tj0pjvU2HN4vTnTj8KBQp6hmnY7dLp9Y1qserySGbw== -Exponent1: N0A7FsSRIg+IAN8YPQqlawoTtG1t1OkJ+nWrurPootScApX6iMvn8fyvw3p2k51rv84efnzpWAYiC8SUaQDNxQ== -Exponent2: SvuYRaGyvo0zemE3oS+WRm2scxR8eiA8WJGeOc+obwOKCcBgeZblXzfdHGcEC1KaOcetOwNW/vwMA46lpLzJNw== -Coefficient: 8+7ZN/JgByqv0NfULiFKTjtyegUcijRuyij7yNxYbCBneDvZGxJwKNi4YYXWx743pcAj4Oi4Oh86gcmxLs+hGw== -Created: 20110302104537 -Publish: 20110302104537 -Activate: 20110302104537` - - xk, _ := NewRR(pub) - k := xk.(*DNSKEY) - p, err := k.NewPrivateKey(priv) - if err != nil { - t.Error(err) - } - switch priv := p.(type) { - case *rsa.PrivateKey: - if 65537 != priv.PublicKey.E { - t.Error("exponenent should be 65537") - } - default: - t.Errorf("we should have read an RSA key: %v", priv) - } - if k.KeyTag() != 37350 { - t.Errorf("keytag should be 37350, got %d %v", k.KeyTag(), k) - } - - soa := new(SOA) - soa.Hdr = RR_Header{"miek.nl.", TypeSOA, ClassINET, 14400, 0} - soa.Ns = "open.nlnetlabs.nl." - soa.Mbox = "miekg.atoom.net." - soa.Serial = 1293945905 - soa.Refresh = 14400 - soa.Retry = 3600 - soa.Expire = 604800 - soa.Minttl = 86400 - - sig := new(RRSIG) - sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0} - sig.Expiration = 1296534305 // date -u '+%s' -d"2011-02-01 04:25:05" - sig.Inception = 1293942305 // date -u '+%s' -d"2011-01-02 04:25:05" - sig.KeyTag = k.KeyTag() - sig.SignerName = k.Hdr.Name - sig.Algorithm = k.Algorithm - - sig.Sign(p.(*rsa.PrivateKey), []RR{soa}) - if sig.Signature != "D5zsobpQcmMmYsUMLxCVEtgAdCvTu8V/IEeP4EyLBjqPJmjt96bwM9kqihsccofA5LIJ7DN91qkCORjWSTwNhzCv7bMyr2o5vBZElrlpnRzlvsFIoAZCD9xg6ZY7ZyzUJmU6IcTwG4v3xEYajcpbJJiyaw/RqR90MuRdKPiBzSo=" { - t.Errorf("signature is not correct: %v", sig) - } -} - -func TestSignVerifyECDSA(t *testing.T) { - pub := `example.net. 3600 IN DNSKEY 257 3 14 ( - xKYaNhWdGOfJ+nPrL8/arkwf2EY3MDJ+SErKivBVSum1 - w/egsXvSADtNJhyem5RCOpgQ6K8X1DRSEkrbYQ+OB+v8 - /uX45NBwY8rp65F6Glur8I/mlVNgF6W/qTI37m40 )` - priv := `Private-key-format: v1.2 -Algorithm: 14 (ECDSAP384SHA384) -PrivateKey: WURgWHCcYIYUPWgeLmiPY2DJJk02vgrmTfitxgqcL4vwW7BOrbawVmVe0d9V94SR` - - eckey, err := NewRR(pub) - if err != nil { - t.Fatal(err) - } - privkey, err := eckey.(*DNSKEY).NewPrivateKey(priv) - if err != nil { - t.Fatal(err) - } - // TODO: Create separate test for this - ds := eckey.(*DNSKEY).ToDS(SHA384) - if ds.KeyTag != 10771 { - t.Fatal("wrong keytag on DS") - } - if ds.Digest != "72d7b62976ce06438e9c0bf319013cf801f09ecc84b8d7e9495f27e305c6a9b0563a9b5f4d288405c3008a946df983d6" { - t.Fatal("wrong DS Digest") - } - a, _ := NewRR("www.example.net. 3600 IN A 192.0.2.1") - sig := new(RRSIG) - sig.Hdr = RR_Header{"example.net.", TypeRRSIG, ClassINET, 14400, 0} - sig.Expiration, _ = StringToTime("20100909102025") - sig.Inception, _ = StringToTime("20100812102025") - sig.KeyTag = eckey.(*DNSKEY).KeyTag() - sig.SignerName = eckey.(*DNSKEY).Hdr.Name - sig.Algorithm = eckey.(*DNSKEY).Algorithm - - if sig.Sign(privkey.(*ecdsa.PrivateKey), []RR{a}) != nil { - t.Fatal("failure to sign the record") - } - - if err := sig.Verify(eckey.(*DNSKEY), []RR{a}); err != nil { - t.Fatalf("failure to validate:\n%s\n%s\n%s\n\n%s\n\n%v", - eckey.(*DNSKEY).String(), - a.String(), - sig.String(), - eckey.(*DNSKEY).PrivateKeyString(privkey), - err, - ) - } -} - -func TestSignVerifyECDSA2(t *testing.T) { - srv1, err := NewRR("srv.miek.nl. IN SRV 1000 800 0 web1.miek.nl.") - if err != nil { - t.Fatal(err) - } - srv := srv1.(*SRV) - - // With this key - key := new(DNSKEY) - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = ECDSAP256SHA256 - privkey, err := key.Generate(256) - if err != nil { - t.Fatal("failure to generate key") - } - - // Fill in the values of the Sig, before signing - sig := new(RRSIG) - sig.Hdr = RR_Header{"miek.nl.", TypeRRSIG, ClassINET, 14400, 0} - sig.TypeCovered = srv.Hdr.Rrtype - sig.Labels = uint8(CountLabel(srv.Hdr.Name)) // works for all 3 - sig.OrigTtl = srv.Hdr.Ttl - sig.Expiration = 1296534305 // date -u '+%s' -d"2011-02-01 04:25:05" - sig.Inception = 1293942305 // date -u '+%s' -d"2011-01-02 04:25:05" - sig.KeyTag = key.KeyTag() // Get the keyfrom the Key - sig.SignerName = key.Hdr.Name - sig.Algorithm = ECDSAP256SHA256 - - if sig.Sign(privkey.(*ecdsa.PrivateKey), []RR{srv}) != nil { - t.Fatal("failure to sign the record") - } - - err = sig.Verify(key, []RR{srv}) - if err != nil { - t.Logf("failure to validate:\n%s\n%s\n%s\n\n%s\n\n%v", - key.String(), - srv.String(), - sig.String(), - key.PrivateKeyString(privkey), - err, - ) - } -} - -// Here the test vectors from the relevant RFCs are checked. -// rfc6605 6.1 -func TestRFC6605P256(t *testing.T) { - exDNSKEY := `example.net. 3600 IN DNSKEY 257 3 13 ( - GojIhhXUN/u4v54ZQqGSnyhWJwaubCvTmeexv7bR6edb - krSqQpF64cYbcB7wNcP+e+MAnLr+Wi9xMWyQLc8NAA== )` - exPriv := `Private-key-format: v1.2 -Algorithm: 13 (ECDSAP256SHA256) -PrivateKey: GU6SnQ/Ou+xC5RumuIUIuJZteXT2z0O/ok1s38Et6mQ=` - rrDNSKEY, err := NewRR(exDNSKEY) - if err != nil { - t.Fatal(err) - } - priv, err := rrDNSKEY.(*DNSKEY).NewPrivateKey(exPriv) - if err != nil { - t.Fatal(err) - } - - exDS := `example.net. 3600 IN DS 55648 13 2 ( - b4c8c1fe2e7477127b27115656ad6256f424625bf5c1 - e2770ce6d6e37df61d17 )` - rrDS, err := NewRR(exDS) - if err != nil { - t.Fatal(err) - } - ourDS := rrDNSKEY.(*DNSKEY).ToDS(SHA256) - if !reflect.DeepEqual(ourDS, rrDS.(*DS)) { - t.Errorf("DS record differs:\n%v\n%v", ourDS, rrDS.(*DS)) - } - - exA := `www.example.net. 3600 IN A 192.0.2.1` - exRRSIG := `www.example.net. 3600 IN RRSIG A 13 3 3600 ( - 20100909100439 20100812100439 55648 example.net. - qx6wLYqmh+l9oCKTN6qIc+bw6ya+KJ8oMz0YP107epXA - yGmt+3SNruPFKG7tZoLBLlUzGGus7ZwmwWep666VCw== )` - rrA, err := NewRR(exA) - if err != nil { - t.Fatal(err) - } - rrRRSIG, err := NewRR(exRRSIG) - if err != nil { - t.Fatal(err) - } - if err = rrRRSIG.(*RRSIG).Verify(rrDNSKEY.(*DNSKEY), []RR{rrA}); err != nil { - t.Errorf("failure to validate the spec RRSIG: %v", err) - } - - ourRRSIG := &RRSIG{ - Hdr: RR_Header{ - Ttl: rrA.Header().Ttl, - }, - KeyTag: rrDNSKEY.(*DNSKEY).KeyTag(), - SignerName: rrDNSKEY.(*DNSKEY).Hdr.Name, - Algorithm: rrDNSKEY.(*DNSKEY).Algorithm, - } - ourRRSIG.Expiration, _ = StringToTime("20100909100439") - ourRRSIG.Inception, _ = StringToTime("20100812100439") - err = ourRRSIG.Sign(priv.(*ecdsa.PrivateKey), []RR{rrA}) - if err != nil { - t.Fatal(err) - } - - if err = ourRRSIG.Verify(rrDNSKEY.(*DNSKEY), []RR{rrA}); err != nil { - t.Errorf("failure to validate our RRSIG: %v", err) - } - - // Signatures are randomized - rrRRSIG.(*RRSIG).Signature = "" - ourRRSIG.Signature = "" - if !reflect.DeepEqual(ourRRSIG, rrRRSIG.(*RRSIG)) { - t.Fatalf("RRSIG record differs:\n%v\n%v", ourRRSIG, rrRRSIG.(*RRSIG)) - } -} - -// rfc6605 6.2 -func TestRFC6605P384(t *testing.T) { - exDNSKEY := `example.net. 3600 IN DNSKEY 257 3 14 ( - xKYaNhWdGOfJ+nPrL8/arkwf2EY3MDJ+SErKivBVSum1 - w/egsXvSADtNJhyem5RCOpgQ6K8X1DRSEkrbYQ+OB+v8 - /uX45NBwY8rp65F6Glur8I/mlVNgF6W/qTI37m40 )` - exPriv := `Private-key-format: v1.2 -Algorithm: 14 (ECDSAP384SHA384) -PrivateKey: WURgWHCcYIYUPWgeLmiPY2DJJk02vgrmTfitxgqcL4vwW7BOrbawVmVe0d9V94SR` - rrDNSKEY, err := NewRR(exDNSKEY) - if err != nil { - t.Fatal(err) - } - priv, err := rrDNSKEY.(*DNSKEY).NewPrivateKey(exPriv) - if err != nil { - t.Fatal(err) - } - - exDS := `example.net. 3600 IN DS 10771 14 4 ( - 72d7b62976ce06438e9c0bf319013cf801f09ecc84b8 - d7e9495f27e305c6a9b0563a9b5f4d288405c3008a94 - 6df983d6 )` - rrDS, err := NewRR(exDS) - if err != nil { - t.Fatal(err) - } - ourDS := rrDNSKEY.(*DNSKEY).ToDS(SHA384) - if !reflect.DeepEqual(ourDS, rrDS.(*DS)) { - t.Fatalf("DS record differs:\n%v\n%v", ourDS, rrDS.(*DS)) - } - - exA := `www.example.net. 3600 IN A 192.0.2.1` - exRRSIG := `www.example.net. 3600 IN RRSIG A 14 3 3600 ( - 20100909102025 20100812102025 10771 example.net. - /L5hDKIvGDyI1fcARX3z65qrmPsVz73QD1Mr5CEqOiLP - 95hxQouuroGCeZOvzFaxsT8Glr74hbavRKayJNuydCuz - WTSSPdz7wnqXL5bdcJzusdnI0RSMROxxwGipWcJm )` - rrA, err := NewRR(exA) - if err != nil { - t.Fatal(err) - } - rrRRSIG, err := NewRR(exRRSIG) - if err != nil { - t.Fatal(err) - } - if err = rrRRSIG.(*RRSIG).Verify(rrDNSKEY.(*DNSKEY), []RR{rrA}); err != nil { - t.Errorf("failure to validate the spec RRSIG: %v", err) - } - - ourRRSIG := &RRSIG{ - Hdr: RR_Header{ - Ttl: rrA.Header().Ttl, - }, - KeyTag: rrDNSKEY.(*DNSKEY).KeyTag(), - SignerName: rrDNSKEY.(*DNSKEY).Hdr.Name, - Algorithm: rrDNSKEY.(*DNSKEY).Algorithm, - } - ourRRSIG.Expiration, _ = StringToTime("20100909102025") - ourRRSIG.Inception, _ = StringToTime("20100812102025") - err = ourRRSIG.Sign(priv.(*ecdsa.PrivateKey), []RR{rrA}) - if err != nil { - t.Fatal(err) - } - - if err = ourRRSIG.Verify(rrDNSKEY.(*DNSKEY), []RR{rrA}); err != nil { - t.Errorf("failure to validate our RRSIG: %v", err) - } - - // Signatures are randomized - rrRRSIG.(*RRSIG).Signature = "" - ourRRSIG.Signature = "" - if !reflect.DeepEqual(ourRRSIG, rrRRSIG.(*RRSIG)) { - t.Fatalf("RRSIG record differs:\n%v\n%v", ourRRSIG, rrRRSIG.(*RRSIG)) - } -} - -func TestInvalidRRSet(t *testing.T) { - goodRecords := make([]RR, 2) - goodRecords[0] = &TXT{Hdr: RR_Header{Name: "name.cloudflare.com.", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} - goodRecords[1] = &TXT{Hdr: RR_Header{Name: "name.cloudflare.com.", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"_o/"}} - - // Generate key - keyname := "cloudflare.com." - key := &DNSKEY{ - Hdr: RR_Header{Name: keyname, Rrtype: TypeDNSKEY, Class: ClassINET, Ttl: 0}, - Algorithm: ECDSAP256SHA256, - Flags: ZONE, - Protocol: 3, - } - privatekey, err := key.Generate(256) - if err != nil { - t.Fatal(err.Error()) - } - - // Need to fill in: Inception, Expiration, KeyTag, SignerName and Algorithm - curTime := time.Now() - signature := &RRSIG{ - Inception: uint32(curTime.Unix()), - Expiration: uint32(curTime.Add(time.Hour).Unix()), - KeyTag: key.KeyTag(), - SignerName: keyname, - Algorithm: ECDSAP256SHA256, - } - - // Inconsistent name between records - badRecords := make([]RR, 2) - badRecords[0] = &TXT{Hdr: RR_Header{Name: "name.cloudflare.com.", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} - badRecords[1] = &TXT{Hdr: RR_Header{Name: "nama.cloudflare.com.", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"_o/"}} - - if IsRRset(badRecords) { - t.Fatal("Record set with inconsistent names considered valid") - } - - badRecords[0] = &TXT{Hdr: RR_Header{Name: "name.cloudflare.com.", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} - badRecords[1] = &A{Hdr: RR_Header{Name: "name.cloudflare.com.", Rrtype: TypeA, Class: ClassINET, Ttl: 0}} - - if IsRRset(badRecords) { - t.Fatal("Record set with inconsistent record types considered valid") - } - - badRecords[0] = &TXT{Hdr: RR_Header{Name: "name.cloudflare.com.", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} - badRecords[1] = &TXT{Hdr: RR_Header{Name: "name.cloudflare.com.", Rrtype: TypeTXT, Class: ClassCHAOS, Ttl: 0}, Txt: []string{"_o/"}} - - if IsRRset(badRecords) { - t.Fatal("Record set with inconsistent record class considered valid") - } - - // Sign the good record set and then make sure verification fails on the bad record set - if err := signature.Sign(privatekey.(crypto.Signer), goodRecords); err != nil { - t.Fatal("Signing good records failed") - } - - if err := signature.Verify(key, badRecords); err != ErrRRset { - t.Fatal("Verification did not return ErrRRset with inconsistent records") - } -} diff --git a/vendor/github.com/miekg/dns/dnsutil/util.go b/vendor/github.com/miekg/dns/dnsutil/util.go deleted file mode 100644 index 9ed03f2..0000000 --- a/vendor/github.com/miekg/dns/dnsutil/util.go +++ /dev/null @@ -1,79 +0,0 @@ -// Package dnsutil contains higher-level methods useful with the dns -// package. While package dns implements the DNS protocols itself, -// these functions are related but not directly required for protocol -// processing. They are often useful in preparing input/output of the -// functions in package dns. -package dnsutil - -import ( - "strings" - - "github.com/miekg/dns" -) - -// AddDomain adds origin to s if s is not already a FQDN. -// Note that the result may not be a FQDN. If origin does not end -// with a ".", the result won't either. -// This implements the zonefile convention (specified in RFC 1035, -// Section "5.1. Format") that "@" represents the -// apex (bare) domain. i.e. AddOrigin("@", "foo.com.") returns "foo.com.". -func AddOrigin(s, origin string) string { - // ("foo.", "origin.") -> "foo." (already a FQDN) - // ("foo", "origin.") -> "foo.origin." - // ("foo"), "origin" -> "foo.origin" - // ("@", "origin.") -> "origin." (@ represents the apex (bare) domain) - // ("", "origin.") -> "origin." (not obvious) - // ("foo", "") -> "foo" (not obvious) - - if dns.IsFqdn(s) { - return s // s is already a FQDN, no need to mess with it. - } - if len(origin) == 0 { - return s // Nothing to append. - } - if s == "@" || len(s) == 0 { - return origin // Expand apex. - } - - if origin == "." { - return s + origin // AddOrigin(s, ".") is an expensive way to add a ".". - } - - return s + "." + origin // The simple case. -} - -// TrimDomainName trims origin from s if s is a subdomain. -// This function will never return "", but returns "@" instead (@ represents the apex (bare) domain). -func TrimDomainName(s, origin string) string { - // An apex (bare) domain is always returned as "@". - // If the return value ends in a ".", the domain was not the suffix. - // origin can end in "." or not. Either way the results should be the same. - - if len(s) == 0 { - return "@" // Return the apex (@) rather than "". - } - // Someone is using TrimDomainName(s, ".") to remove a dot if it exists. - if origin == "." { - return strings.TrimSuffix(s, origin) - } - - // Dude, you aren't even if the right subdomain! - if !dns.IsSubDomain(origin, s) { - return s - } - - slabels := dns.Split(s) - olabels := dns.Split(origin) - m := dns.CompareDomainName(s, origin) - if len(olabels) == m { - if len(olabels) == len(slabels) { - return "@" // origin == s - } - if (s[0] == '.') && (len(slabels) == (len(olabels) + 1)) { - return "@" // TrimDomainName(".foo.", "foo.") - } - } - - // Return the first (len-m) labels: - return s[:slabels[len(slabels)-m]-1] -} diff --git a/vendor/github.com/miekg/dns/dnsutil/util_test.go b/vendor/github.com/miekg/dns/dnsutil/util_test.go deleted file mode 100644 index 0f1ecec..0000000 --- a/vendor/github.com/miekg/dns/dnsutil/util_test.go +++ /dev/null @@ -1,130 +0,0 @@ -package dnsutil - -import "testing" - -func TestAddOrigin(t *testing.T) { - var tests = []struct{ e1, e2, expected string }{ - {"@", "example.com", "example.com"}, - {"foo", "example.com", "foo.example.com"}, - {"foo.", "example.com", "foo."}, - {"@", "example.com.", "example.com."}, - {"foo", "example.com.", "foo.example.com."}, - {"foo.", "example.com.", "foo."}, - // Oddball tests: - // In general origin should not be "" or "." but at least - // these tests verify we don't crash and will keep results - // from changing unexpectedly. - {"*.", "", "*."}, - {"@", "", "@"}, - {"foobar", "", "foobar"}, - {"foobar.", "", "foobar."}, - {"*.", ".", "*."}, - {"@", ".", "."}, - {"foobar", ".", "foobar."}, - {"foobar.", ".", "foobar."}, - } - for _, test := range tests { - actual := AddOrigin(test.e1, test.e2) - if test.expected != actual { - t.Errorf("AddOrigin(%#v, %#v) expected %#v, go %#v\n", test.e1, test.e2, test.expected, actual) - } - } -} - -func TestTrimDomainName(t *testing.T) { - - // Basic tests. - // Try trimming "example.com" and "example.com." from typical use cases. - var tests_examplecom = []struct{ experiment, expected string }{ - {"foo.example.com", "foo"}, - {"foo.example.com.", "foo"}, - {".foo.example.com", ".foo"}, - {".foo.example.com.", ".foo"}, - {"*.example.com", "*"}, - {"example.com", "@"}, - {"example.com.", "@"}, - {"com.", "com."}, - {"foo.", "foo."}, - {"serverfault.com.", "serverfault.com."}, - {"serverfault.com", "serverfault.com"}, - {".foo.ronco.com", ".foo.ronco.com"}, - {".foo.ronco.com.", ".foo.ronco.com."}, - } - for _, dom := range []string{"example.com", "example.com."} { - for i, test := range tests_examplecom { - actual := TrimDomainName(test.experiment, dom) - if test.expected != actual { - t.Errorf("%d TrimDomainName(%#v, %#v): expected (%v) got (%v)\n", i, test.experiment, dom, test.expected, actual) - } - } - } - - // Paranoid tests. - // These test shouldn't be needed but I was weary of off-by-one errors. - // In theory, these can't happen because there are no single-letter TLDs, - // but it is good to exercize the code this way. - var tests = []struct{ experiment, expected string }{ - {"", "@"}, - {".", "."}, - {"a.b.c.d.e.f.", "a.b.c.d.e"}, - {"b.c.d.e.f.", "b.c.d.e"}, - {"c.d.e.f.", "c.d.e"}, - {"d.e.f.", "d.e"}, - {"e.f.", "e"}, - {"f.", "@"}, - {".a.b.c.d.e.f.", ".a.b.c.d.e"}, - {".b.c.d.e.f.", ".b.c.d.e"}, - {".c.d.e.f.", ".c.d.e"}, - {".d.e.f.", ".d.e"}, - {".e.f.", ".e"}, - {".f.", "@"}, - {"a.b.c.d.e.f", "a.b.c.d.e"}, - {"a.b.c.d.e.", "a.b.c.d.e."}, - {"a.b.c.d.e", "a.b.c.d.e"}, - {"a.b.c.d.", "a.b.c.d."}, - {"a.b.c.d", "a.b.c.d"}, - {"a.b.c.", "a.b.c."}, - {"a.b.c", "a.b.c"}, - {"a.b.", "a.b."}, - {"a.b", "a.b"}, - {"a.", "a."}, - {"a", "a"}, - {".a.b.c.d.e.f", ".a.b.c.d.e"}, - {".a.b.c.d.e.", ".a.b.c.d.e."}, - {".a.b.c.d.e", ".a.b.c.d.e"}, - {".a.b.c.d.", ".a.b.c.d."}, - {".a.b.c.d", ".a.b.c.d"}, - {".a.b.c.", ".a.b.c."}, - {".a.b.c", ".a.b.c"}, - {".a.b.", ".a.b."}, - {".a.b", ".a.b"}, - {".a.", ".a."}, - {".a", ".a"}, - } - for _, dom := range []string{"f", "f."} { - for i, test := range tests { - actual := TrimDomainName(test.experiment, dom) - if test.expected != actual { - t.Errorf("%d TrimDomainName(%#v, %#v): expected (%v) got (%v)\n", i, test.experiment, dom, test.expected, actual) - } - } - } - - // Test cases for bugs found in the wild. - // These test cases provide both origin, s, and the expected result. - // If you find a bug in the while, this is probably the easiest place - // to add it as a test case. - var tests_wild = []struct{ e1, e2, expected string }{ - {"mathoverflow.net.", ".", "mathoverflow.net"}, - {"mathoverflow.net", ".", "mathoverflow.net"}, - {"", ".", "@"}, - {"@", ".", "@"}, - } - for i, test := range tests_wild { - actual := TrimDomainName(test.e1, test.e2) - if test.expected != actual { - t.Errorf("%d TrimDomainName(%#v, %#v): expected (%v) got (%v)\n", i, test.e1, test.e2, test.expected, actual) - } - } - -} diff --git a/vendor/github.com/miekg/dns/doc.go b/vendor/github.com/miekg/dns/doc.go deleted file mode 100644 index f3555e4..0000000 --- a/vendor/github.com/miekg/dns/doc.go +++ /dev/null @@ -1,251 +0,0 @@ -/* -Package dns implements a full featured interface to the Domain Name System. -Server- and client-side programming is supported. -The package allows complete control over what is send out to the DNS. The package -API follows the less-is-more principle, by presenting a small, clean interface. - -The package dns supports (asynchronous) querying/replying, incoming/outgoing zone transfers, -TSIG, EDNS0, dynamic updates, notifies and DNSSEC validation/signing. -Note that domain names MUST be fully qualified, before sending them, unqualified -names in a message will result in a packing failure. - -Resource records are native types. They are not stored in wire format. -Basic usage pattern for creating a new resource record: - - r := new(dns.MX) - r.Hdr = dns.RR_Header{Name: "miek.nl.", Rrtype: dns.TypeMX, - Class: dns.ClassINET, Ttl: 3600} - r.Preference = 10 - r.Mx = "mx.miek.nl." - -Or directly from a string: - - mx, err := dns.NewRR("miek.nl. 3600 IN MX 10 mx.miek.nl.") - -Or when the default TTL (3600) and class (IN) suit you: - - mx, err := dns.NewRR("miek.nl. MX 10 mx.miek.nl.") - -Or even: - - mx, err := dns.NewRR("$ORIGIN nl.\nmiek 1H IN MX 10 mx.miek") - -In the DNS messages are exchanged, these messages contain resource -records (sets). Use pattern for creating a message: - - m := new(dns.Msg) - m.SetQuestion("miek.nl.", dns.TypeMX) - -Or when not certain if the domain name is fully qualified: - - m.SetQuestion(dns.Fqdn("miek.nl"), dns.TypeMX) - -The message m is now a message with the question section set to ask -the MX records for the miek.nl. zone. - -The following is slightly more verbose, but more flexible: - - m1 := new(dns.Msg) - m1.Id = dns.Id() - m1.RecursionDesired = true - m1.Question = make([]dns.Question, 1) - m1.Question[0] = dns.Question{"miek.nl.", dns.TypeMX, dns.ClassINET} - -After creating a message it can be send. -Basic use pattern for synchronous querying the DNS at a -server configured on 127.0.0.1 and port 53: - - c := new(dns.Client) - in, rtt, err := c.Exchange(m1, "127.0.0.1:53") - -Suppressing multiple outstanding queries (with the same question, type and -class) is as easy as setting: - - c.SingleInflight = true - -If these "advanced" features are not needed, a simple UDP query can be send, -with: - - in, err := dns.Exchange(m1, "127.0.0.1:53") - -When this functions returns you will get dns message. A dns message consists -out of four sections. -The question section: in.Question, the answer section: in.Answer, -the authority section: in.Ns and the additional section: in.Extra. - -Each of these sections (except the Question section) contain a []RR. Basic -use pattern for accessing the rdata of a TXT RR as the first RR in -the Answer section: - - if t, ok := in.Answer[0].(*dns.TXT); ok { - // do something with t.Txt - } - -Domain Name and TXT Character String Representations - -Both domain names and TXT character strings are converted to presentation -form both when unpacked and when converted to strings. - -For TXT character strings, tabs, carriage returns and line feeds will be -converted to \t, \r and \n respectively. Back slashes and quotations marks -will be escaped. Bytes below 32 and above 127 will be converted to \DDD -form. - -For domain names, in addition to the above rules brackets, periods, -spaces, semicolons and the at symbol are escaped. - -DNSSEC - -DNSSEC (DNS Security Extension) adds a layer of security to the DNS. It -uses public key cryptography to sign resource records. The -public keys are stored in DNSKEY records and the signatures in RRSIG records. - -Requesting DNSSEC information for a zone is done by adding the DO (DNSSEC OK) bit -to a request. - - m := new(dns.Msg) - m.SetEdns0(4096, true) - -Signature generation, signature verification and key generation are all supported. - -DYNAMIC UPDATES - -Dynamic updates reuses the DNS message format, but renames three of -the sections. Question is Zone, Answer is Prerequisite, Authority is -Update, only the Additional is not renamed. See RFC 2136 for the gory details. - -You can set a rather complex set of rules for the existence of absence of -certain resource records or names in a zone to specify if resource records -should be added or removed. The table from RFC 2136 supplemented with the Go -DNS function shows which functions exist to specify the prerequisites. - - 3.2.4 - Table Of Metavalues Used In Prerequisite Section - - CLASS TYPE RDATA Meaning Function - -------------------------------------------------------------- - ANY ANY empty Name is in use dns.NameUsed - ANY rrset empty RRset exists (value indep) dns.RRsetUsed - NONE ANY empty Name is not in use dns.NameNotUsed - NONE rrset empty RRset does not exist dns.RRsetNotUsed - zone rrset rr RRset exists (value dep) dns.Used - -The prerequisite section can also be left empty. -If you have decided on the prerequisites you can tell what RRs should -be added or deleted. The next table shows the options you have and -what functions to call. - - 3.4.2.6 - Table Of Metavalues Used In Update Section - - CLASS TYPE RDATA Meaning Function - --------------------------------------------------------------- - ANY ANY empty Delete all RRsets from name dns.RemoveName - ANY rrset empty Delete an RRset dns.RemoveRRset - NONE rrset rr Delete an RR from RRset dns.Remove - zone rrset rr Add to an RRset dns.Insert - -TRANSACTION SIGNATURE - -An TSIG or transaction signature adds a HMAC TSIG record to each message sent. -The supported algorithms include: HmacMD5, HmacSHA1, HmacSHA256 and HmacSHA512. - -Basic use pattern when querying with a TSIG name "axfr." (note that these key names -must be fully qualified - as they are domain names) and the base64 secret -"so6ZGir4GPAqINNh9U5c3A==": - - c := new(dns.Client) - c.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="} - m := new(dns.Msg) - m.SetQuestion("miek.nl.", dns.TypeMX) - m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix()) - ... - // When sending the TSIG RR is calculated and filled in before sending - -When requesting an zone transfer (almost all TSIG usage is when requesting zone transfers), with -TSIG, this is the basic use pattern. In this example we request an AXFR for -miek.nl. with TSIG key named "axfr." and secret "so6ZGir4GPAqINNh9U5c3A==" -and using the server 176.58.119.54: - - t := new(dns.Transfer) - m := new(dns.Msg) - t.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="} - m.SetAxfr("miek.nl.") - m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix()) - c, err := t.In(m, "176.58.119.54:53") - for r := range c { ... } - -You can now read the records from the transfer as they come in. Each envelope is checked with TSIG. -If something is not correct an error is returned. - -Basic use pattern validating and replying to a message that has TSIG set. - - server := &dns.Server{Addr: ":53", Net: "udp"} - server.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="} - go server.ListenAndServe() - dns.HandleFunc(".", handleRequest) - - func handleRequest(w dns.ResponseWriter, r *dns.Msg) { - m := new(dns.Msg) - m.SetReply(r) - if r.IsTsig() != nil { - if w.TsigStatus() == nil { - // *Msg r has an TSIG record and it was validated - m.SetTsig("axfr.", dns.HmacMD5, 300, time.Now().Unix()) - } else { - // *Msg r has an TSIG records and it was not valided - } - } - w.WriteMsg(m) - } - -PRIVATE RRS - -RFC 6895 sets aside a range of type codes for private use. This range -is 65,280 - 65,534 (0xFF00 - 0xFFFE). When experimenting with new Resource Records these -can be used, before requesting an official type code from IANA. - -see http://miek.nl/posts/2014/Sep/21/Private%20RRs%20and%20IDN%20in%20Go%20DNS/ for more -information. - -EDNS0 - -EDNS0 is an extension mechanism for the DNS defined in RFC 2671 and updated -by RFC 6891. It defines an new RR type, the OPT RR, which is then completely -abused. -Basic use pattern for creating an (empty) OPT RR: - - o := new(dns.OPT) - o.Hdr.Name = "." // MUST be the root zone, per definition. - o.Hdr.Rrtype = dns.TypeOPT - -The rdata of an OPT RR consists out of a slice of EDNS0 (RFC 6891) -interfaces. Currently only a few have been standardized: EDNS0_NSID -(RFC 5001) and EDNS0_SUBNET (draft-vandergaast-edns-client-subnet-02). Note -that these options may be combined in an OPT RR. -Basic use pattern for a server to check if (and which) options are set: - - // o is a dns.OPT - for _, s := range o.Option { - switch e := s.(type) { - case *dns.EDNS0_NSID: - // do stuff with e.Nsid - case *dns.EDNS0_SUBNET: - // access e.Family, e.Address, etc. - } - } - -SIG(0) - -From RFC 2931: - - SIG(0) provides protection for DNS transactions and requests .... - ... protection for glue records, DNS requests, protection for message headers - on requests and responses, and protection of the overall integrity of a response. - -It works like TSIG, except that SIG(0) uses public key cryptography, instead of the shared -secret approach in TSIG. -Supported algorithms: DSA, ECDSAP256SHA256, ECDSAP384SHA384, RSASHA1, RSASHA256 and -RSASHA512. - -Signing subsequent messages in multi-message sessions is not implemented. -*/ -package dns diff --git a/vendor/github.com/miekg/dns/dyn_test.go b/vendor/github.com/miekg/dns/dyn_test.go deleted file mode 100644 index 09986a5..0000000 --- a/vendor/github.com/miekg/dns/dyn_test.go +++ /dev/null @@ -1,3 +0,0 @@ -package dns - -// Find better solution diff --git a/vendor/github.com/miekg/dns/edns.go b/vendor/github.com/miekg/dns/edns.go deleted file mode 100644 index 7a58aa9..0000000 --- a/vendor/github.com/miekg/dns/edns.go +++ /dev/null @@ -1,532 +0,0 @@ -package dns - -import ( - "encoding/binary" - "encoding/hex" - "errors" - "net" - "strconv" -) - -// EDNS0 Option codes. -const ( - EDNS0LLQ = 0x1 // long lived queries: http://tools.ietf.org/html/draft-sekar-dns-llq-01 - EDNS0UL = 0x2 // update lease draft: http://files.dns-sd.org/draft-sekar-dns-ul.txt - EDNS0NSID = 0x3 // nsid (RFC5001) - EDNS0DAU = 0x5 // DNSSEC Algorithm Understood - EDNS0DHU = 0x6 // DS Hash Understood - EDNS0N3U = 0x7 // NSEC3 Hash Understood - EDNS0SUBNET = 0x8 // client-subnet (RFC6891) - EDNS0EXPIRE = 0x9 // EDNS0 expire - EDNS0COOKIE = 0xa // EDNS0 Cookie - EDNS0SUBNETDRAFT = 0x50fa // Don't use! Use EDNS0SUBNET - EDNS0LOCALSTART = 0xFDE9 // Beginning of range reserved for local/experimental use (RFC6891) - EDNS0LOCALEND = 0xFFFE // End of range reserved for local/experimental use (RFC6891) - _DO = 1 << 15 // dnssec ok -) - -// OPT is the EDNS0 RR appended to messages to convey extra (meta) information. -// See RFC 6891. -type OPT struct { - Hdr RR_Header - Option []EDNS0 `dns:"opt"` -} - -func (rr *OPT) String() string { - s := "\n;; OPT PSEUDOSECTION:\n; EDNS: version " + strconv.Itoa(int(rr.Version())) + "; " - if rr.Do() { - s += "flags: do; " - } else { - s += "flags: ; " - } - s += "udp: " + strconv.Itoa(int(rr.UDPSize())) - - for _, o := range rr.Option { - switch o.(type) { - case *EDNS0_NSID: - s += "\n; NSID: " + o.String() - h, e := o.pack() - var r string - if e == nil { - for _, c := range h { - r += "(" + string(c) + ")" - } - s += " " + r - } - case *EDNS0_SUBNET: - s += "\n; SUBNET: " + o.String() - if o.(*EDNS0_SUBNET).DraftOption { - s += " (draft)" - } - case *EDNS0_COOKIE: - s += "\n; COOKIE: " + o.String() - case *EDNS0_UL: - s += "\n; UPDATE LEASE: " + o.String() - case *EDNS0_LLQ: - s += "\n; LONG LIVED QUERIES: " + o.String() - case *EDNS0_DAU: - s += "\n; DNSSEC ALGORITHM UNDERSTOOD: " + o.String() - case *EDNS0_DHU: - s += "\n; DS HASH UNDERSTOOD: " + o.String() - case *EDNS0_N3U: - s += "\n; NSEC3 HASH UNDERSTOOD: " + o.String() - case *EDNS0_LOCAL: - s += "\n; LOCAL OPT: " + o.String() - } - } - return s -} - -func (rr *OPT) len() int { - l := rr.Hdr.len() - for i := 0; i < len(rr.Option); i++ { - l += 4 // Account for 2-byte option code and 2-byte option length. - lo, _ := rr.Option[i].pack() - l += len(lo) - } - return l -} - -// return the old value -> delete SetVersion? - -// Version returns the EDNS version used. Only zero is defined. -func (rr *OPT) Version() uint8 { - return uint8((rr.Hdr.Ttl & 0x00FF0000) >> 16) -} - -// SetVersion sets the version of EDNS. This is usually zero. -func (rr *OPT) SetVersion(v uint8) { - rr.Hdr.Ttl = rr.Hdr.Ttl&0xFF00FFFF | (uint32(v) << 16) -} - -// ExtendedRcode returns the EDNS extended RCODE field (the upper 8 bits of the TTL). -func (rr *OPT) ExtendedRcode() int { - return int((rr.Hdr.Ttl&0xFF000000)>>24) + 15 -} - -// SetExtendedRcode sets the EDNS extended RCODE field. -func (rr *OPT) SetExtendedRcode(v uint8) { - if v < RcodeBadVers { // Smaller than 16.. Use the 4 bits you have! - return - } - rr.Hdr.Ttl = rr.Hdr.Ttl&0x00FFFFFF | (uint32(v-15) << 24) -} - -// UDPSize returns the UDP buffer size. -func (rr *OPT) UDPSize() uint16 { - return rr.Hdr.Class -} - -// SetUDPSize sets the UDP buffer size. -func (rr *OPT) SetUDPSize(size uint16) { - rr.Hdr.Class = size -} - -// Do returns the value of the DO (DNSSEC OK) bit. -func (rr *OPT) Do() bool { - return rr.Hdr.Ttl&_DO == _DO -} - -// SetDo sets the DO (DNSSEC OK) bit. -func (rr *OPT) SetDo() { - rr.Hdr.Ttl |= _DO -} - -// EDNS0 defines an EDNS0 Option. An OPT RR can have multiple options appended to it. -type EDNS0 interface { - // Option returns the option code for the option. - Option() uint16 - // pack returns the bytes of the option data. - pack() ([]byte, error) - // unpack sets the data as found in the buffer. Is also sets - // the length of the slice as the length of the option data. - unpack([]byte) error - // String returns the string representation of the option. - String() string -} - -// The nsid EDNS0 option is used to retrieve a nameserver -// identifier. When sending a request Nsid must be set to the empty string -// The identifier is an opaque string encoded as hex. -// Basic use pattern for creating an nsid option: -// -// o := new(dns.OPT) -// o.Hdr.Name = "." -// o.Hdr.Rrtype = dns.TypeOPT -// e := new(dns.EDNS0_NSID) -// e.Code = dns.EDNS0NSID -// e.Nsid = "AA" -// o.Option = append(o.Option, e) -type EDNS0_NSID struct { - Code uint16 // Always EDNS0NSID - Nsid string // This string needs to be hex encoded -} - -func (e *EDNS0_NSID) pack() ([]byte, error) { - h, err := hex.DecodeString(e.Nsid) - if err != nil { - return nil, err - } - return h, nil -} - -func (e *EDNS0_NSID) Option() uint16 { return EDNS0NSID } -func (e *EDNS0_NSID) unpack(b []byte) error { e.Nsid = hex.EncodeToString(b); return nil } -func (e *EDNS0_NSID) String() string { return string(e.Nsid) } - -// EDNS0_SUBNET is the subnet option that is used to give the remote nameserver -// an idea of where the client lives. It can then give back a different -// answer depending on the location or network topology. -// Basic use pattern for creating an subnet option: -// -// o := new(dns.OPT) -// o.Hdr.Name = "." -// o.Hdr.Rrtype = dns.TypeOPT -// e := new(dns.EDNS0_SUBNET) -// e.Code = dns.EDNS0SUBNET -// e.Family = 1 // 1 for IPv4 source address, 2 for IPv6 -// e.NetMask = 32 // 32 for IPV4, 128 for IPv6 -// e.SourceScope = 0 -// e.Address = net.ParseIP("127.0.0.1").To4() // for IPv4 -// // e.Address = net.ParseIP("2001:7b8:32a::2") // for IPV6 -// o.Option = append(o.Option, e) -// -// Note: the spec (draft-ietf-dnsop-edns-client-subnet-00) has some insane logic -// for which netmask applies to the address. This code will parse all the -// available bits when unpacking (up to optlen). When packing it will apply -// SourceNetmask. If you need more advanced logic, patches welcome and good luck. -type EDNS0_SUBNET struct { - Code uint16 // Always EDNS0SUBNET - Family uint16 // 1 for IP, 2 for IP6 - SourceNetmask uint8 - SourceScope uint8 - Address net.IP - DraftOption bool // Set to true if using the old (0x50fa) option code -} - -func (e *EDNS0_SUBNET) Option() uint16 { - if e.DraftOption { - return EDNS0SUBNETDRAFT - } - return EDNS0SUBNET -} - -func (e *EDNS0_SUBNET) pack() ([]byte, error) { - b := make([]byte, 4) - binary.BigEndian.PutUint16(b[0:], e.Family) - b[2] = e.SourceNetmask - b[3] = e.SourceScope - switch e.Family { - case 1: - if e.SourceNetmask > net.IPv4len*8 { - return nil, errors.New("dns: bad netmask") - } - if len(e.Address.To4()) != net.IPv4len { - return nil, errors.New("dns: bad address") - } - ip := e.Address.To4().Mask(net.CIDRMask(int(e.SourceNetmask), net.IPv4len*8)) - needLength := (e.SourceNetmask + 8 - 1) / 8 // division rounding up - b = append(b, ip[:needLength]...) - case 2: - if e.SourceNetmask > net.IPv6len*8 { - return nil, errors.New("dns: bad netmask") - } - if len(e.Address) != net.IPv6len { - return nil, errors.New("dns: bad address") - } - ip := e.Address.Mask(net.CIDRMask(int(e.SourceNetmask), net.IPv6len*8)) - needLength := (e.SourceNetmask + 8 - 1) / 8 // division rounding up - b = append(b, ip[:needLength]...) - default: - return nil, errors.New("dns: bad address family") - } - return b, nil -} - -func (e *EDNS0_SUBNET) unpack(b []byte) error { - if len(b) < 4 { - return ErrBuf - } - e.Family = binary.BigEndian.Uint16(b) - e.SourceNetmask = b[2] - e.SourceScope = b[3] - switch e.Family { - case 1: - if e.SourceNetmask > net.IPv4len*8 || e.SourceScope > net.IPv4len*8 { - return errors.New("dns: bad netmask") - } - addr := make([]byte, net.IPv4len) - for i := 0; i < net.IPv4len && 4+i < len(b); i++ { - addr[i] = b[4+i] - } - e.Address = net.IPv4(addr[0], addr[1], addr[2], addr[3]) - case 2: - if e.SourceNetmask > net.IPv6len*8 || e.SourceScope > net.IPv6len*8 { - return errors.New("dns: bad netmask") - } - addr := make([]byte, net.IPv6len) - for i := 0; i < net.IPv6len && 4+i < len(b); i++ { - addr[i] = b[4+i] - } - e.Address = net.IP{addr[0], addr[1], addr[2], addr[3], addr[4], - addr[5], addr[6], addr[7], addr[8], addr[9], addr[10], - addr[11], addr[12], addr[13], addr[14], addr[15]} - default: - return errors.New("dns: bad address family") - } - return nil -} - -func (e *EDNS0_SUBNET) String() (s string) { - if e.Address == nil { - s = "" - } else if e.Address.To4() != nil { - s = e.Address.String() - } else { - s = "[" + e.Address.String() + "]" - } - s += "/" + strconv.Itoa(int(e.SourceNetmask)) + "/" + strconv.Itoa(int(e.SourceScope)) - return -} - -// The Cookie EDNS0 option -// -// o := new(dns.OPT) -// o.Hdr.Name = "." -// o.Hdr.Rrtype = dns.TypeOPT -// e := new(dns.EDNS0_COOKIE) -// e.Code = dns.EDNS0COOKIE -// e.Cookie = "24a5ac.." -// o.Option = append(o.Option, e) -// -// The Cookie field consists out of a client cookie (RFC 7873 Section 4), that is -// always 8 bytes. It may then optionally be followed by the server cookie. The server -// cookie is of variable length, 8 to a maximum of 32 bytes. In other words: -// -// cCookie := o.Cookie[:16] -// sCookie := o.Cookie[16:] -// -// There is no guarantee that the Cookie string has a specific length. -type EDNS0_COOKIE struct { - Code uint16 // Always EDNS0COOKIE - Cookie string // Hex-encoded cookie data -} - -func (e *EDNS0_COOKIE) pack() ([]byte, error) { - h, err := hex.DecodeString(e.Cookie) - if err != nil { - return nil, err - } - return h, nil -} - -func (e *EDNS0_COOKIE) Option() uint16 { return EDNS0COOKIE } -func (e *EDNS0_COOKIE) unpack(b []byte) error { e.Cookie = hex.EncodeToString(b); return nil } -func (e *EDNS0_COOKIE) String() string { return e.Cookie } - -// The EDNS0_UL (Update Lease) (draft RFC) option is used to tell the server to set -// an expiration on an update RR. This is helpful for clients that cannot clean -// up after themselves. This is a draft RFC and more information can be found at -// http://files.dns-sd.org/draft-sekar-dns-ul.txt -// -// o := new(dns.OPT) -// o.Hdr.Name = "." -// o.Hdr.Rrtype = dns.TypeOPT -// e := new(dns.EDNS0_UL) -// e.Code = dns.EDNS0UL -// e.Lease = 120 // in seconds -// o.Option = append(o.Option, e) -type EDNS0_UL struct { - Code uint16 // Always EDNS0UL - Lease uint32 -} - -func (e *EDNS0_UL) Option() uint16 { return EDNS0UL } -func (e *EDNS0_UL) String() string { return strconv.FormatUint(uint64(e.Lease), 10) } - -// Copied: http://golang.org/src/pkg/net/dnsmsg.go -func (e *EDNS0_UL) pack() ([]byte, error) { - b := make([]byte, 4) - binary.BigEndian.PutUint32(b, e.Lease) - return b, nil -} - -func (e *EDNS0_UL) unpack(b []byte) error { - if len(b) < 4 { - return ErrBuf - } - e.Lease = binary.BigEndian.Uint32(b) - return nil -} - -// EDNS0_LLQ stands for Long Lived Queries: http://tools.ietf.org/html/draft-sekar-dns-llq-01 -// Implemented for completeness, as the EDNS0 type code is assigned. -type EDNS0_LLQ struct { - Code uint16 // Always EDNS0LLQ - Version uint16 - Opcode uint16 - Error uint16 - Id uint64 - LeaseLife uint32 -} - -func (e *EDNS0_LLQ) Option() uint16 { return EDNS0LLQ } - -func (e *EDNS0_LLQ) pack() ([]byte, error) { - b := make([]byte, 18) - binary.BigEndian.PutUint16(b[0:], e.Version) - binary.BigEndian.PutUint16(b[2:], e.Opcode) - binary.BigEndian.PutUint16(b[4:], e.Error) - binary.BigEndian.PutUint64(b[6:], e.Id) - binary.BigEndian.PutUint32(b[14:], e.LeaseLife) - return b, nil -} - -func (e *EDNS0_LLQ) unpack(b []byte) error { - if len(b) < 18 { - return ErrBuf - } - e.Version = binary.BigEndian.Uint16(b[0:]) - e.Opcode = binary.BigEndian.Uint16(b[2:]) - e.Error = binary.BigEndian.Uint16(b[4:]) - e.Id = binary.BigEndian.Uint64(b[6:]) - e.LeaseLife = binary.BigEndian.Uint32(b[14:]) - return nil -} - -func (e *EDNS0_LLQ) String() string { - s := strconv.FormatUint(uint64(e.Version), 10) + " " + strconv.FormatUint(uint64(e.Opcode), 10) + - " " + strconv.FormatUint(uint64(e.Error), 10) + " " + strconv.FormatUint(uint64(e.Id), 10) + - " " + strconv.FormatUint(uint64(e.LeaseLife), 10) - return s -} - -type EDNS0_DAU struct { - Code uint16 // Always EDNS0DAU - AlgCode []uint8 -} - -func (e *EDNS0_DAU) Option() uint16 { return EDNS0DAU } -func (e *EDNS0_DAU) pack() ([]byte, error) { return e.AlgCode, nil } -func (e *EDNS0_DAU) unpack(b []byte) error { e.AlgCode = b; return nil } - -func (e *EDNS0_DAU) String() string { - s := "" - for i := 0; i < len(e.AlgCode); i++ { - if a, ok := AlgorithmToString[e.AlgCode[i]]; ok { - s += " " + a - } else { - s += " " + strconv.Itoa(int(e.AlgCode[i])) - } - } - return s -} - -type EDNS0_DHU struct { - Code uint16 // Always EDNS0DHU - AlgCode []uint8 -} - -func (e *EDNS0_DHU) Option() uint16 { return EDNS0DHU } -func (e *EDNS0_DHU) pack() ([]byte, error) { return e.AlgCode, nil } -func (e *EDNS0_DHU) unpack(b []byte) error { e.AlgCode = b; return nil } - -func (e *EDNS0_DHU) String() string { - s := "" - for i := 0; i < len(e.AlgCode); i++ { - if a, ok := HashToString[e.AlgCode[i]]; ok { - s += " " + a - } else { - s += " " + strconv.Itoa(int(e.AlgCode[i])) - } - } - return s -} - -type EDNS0_N3U struct { - Code uint16 // Always EDNS0N3U - AlgCode []uint8 -} - -func (e *EDNS0_N3U) Option() uint16 { return EDNS0N3U } -func (e *EDNS0_N3U) pack() ([]byte, error) { return e.AlgCode, nil } -func (e *EDNS0_N3U) unpack(b []byte) error { e.AlgCode = b; return nil } - -func (e *EDNS0_N3U) String() string { - // Re-use the hash map - s := "" - for i := 0; i < len(e.AlgCode); i++ { - if a, ok := HashToString[e.AlgCode[i]]; ok { - s += " " + a - } else { - s += " " + strconv.Itoa(int(e.AlgCode[i])) - } - } - return s -} - -type EDNS0_EXPIRE struct { - Code uint16 // Always EDNS0EXPIRE - Expire uint32 -} - -func (e *EDNS0_EXPIRE) Option() uint16 { return EDNS0EXPIRE } -func (e *EDNS0_EXPIRE) String() string { return strconv.FormatUint(uint64(e.Expire), 10) } - -func (e *EDNS0_EXPIRE) pack() ([]byte, error) { - b := make([]byte, 4) - b[0] = byte(e.Expire >> 24) - b[1] = byte(e.Expire >> 16) - b[2] = byte(e.Expire >> 8) - b[3] = byte(e.Expire) - return b, nil -} - -func (e *EDNS0_EXPIRE) unpack(b []byte) error { - if len(b) < 4 { - return ErrBuf - } - e.Expire = binary.BigEndian.Uint32(b) - return nil -} - -// The EDNS0_LOCAL option is used for local/experimental purposes. The option -// code is recommended to be within the range [EDNS0LOCALSTART, EDNS0LOCALEND] -// (RFC6891), although any unassigned code can actually be used. The content of -// the option is made available in Data, unaltered. -// Basic use pattern for creating a local option: -// -// o := new(dns.OPT) -// o.Hdr.Name = "." -// o.Hdr.Rrtype = dns.TypeOPT -// e := new(dns.EDNS0_LOCAL) -// e.Code = dns.EDNS0LOCALSTART -// e.Data = []byte{72, 82, 74} -// o.Option = append(o.Option, e) -type EDNS0_LOCAL struct { - Code uint16 - Data []byte -} - -func (e *EDNS0_LOCAL) Option() uint16 { return e.Code } -func (e *EDNS0_LOCAL) String() string { - return strconv.FormatInt(int64(e.Code), 10) + ":0x" + hex.EncodeToString(e.Data) -} - -func (e *EDNS0_LOCAL) pack() ([]byte, error) { - b := make([]byte, len(e.Data)) - copied := copy(b, e.Data) - if copied != len(e.Data) { - return nil, ErrBuf - } - return b, nil -} - -func (e *EDNS0_LOCAL) unpack(b []byte) error { - e.Data = make([]byte, len(b)) - copied := copy(e.Data, b) - if copied != len(b) { - return ErrBuf - } - return nil -} diff --git a/vendor/github.com/miekg/dns/edns_test.go b/vendor/github.com/miekg/dns/edns_test.go deleted file mode 100644 index 5fd75ab..0000000 --- a/vendor/github.com/miekg/dns/edns_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package dns - -import "testing" - -func TestOPTTtl(t *testing.T) { - e := &OPT{} - e.Hdr.Name = "." - e.Hdr.Rrtype = TypeOPT - - if e.Do() { - t.Errorf("DO bit should be zero") - } - - e.SetDo() - if !e.Do() { - t.Errorf("DO bit should be non-zero") - } - - if e.Version() != 0 { - t.Errorf("version should be non-zero") - } - - e.SetVersion(42) - if e.Version() != 42 { - t.Errorf("set 42, expected %d, got %d", 42, e.Version()) - } - - e.SetExtendedRcode(42) - if e.ExtendedRcode() != 42 { - t.Errorf("set 42, expected %d, got %d", 42-15, e.ExtendedRcode()) - } -} diff --git a/vendor/github.com/miekg/dns/example_test.go b/vendor/github.com/miekg/dns/example_test.go deleted file mode 100644 index 64c1496..0000000 --- a/vendor/github.com/miekg/dns/example_test.go +++ /dev/null @@ -1,146 +0,0 @@ -package dns_test - -import ( - "errors" - "fmt" - "log" - "net" - - "github.com/miekg/dns" -) - -// Retrieve the MX records for miek.nl. -func ExampleMX() { - config, _ := dns.ClientConfigFromFile("/etc/resolv.conf") - c := new(dns.Client) - m := new(dns.Msg) - m.SetQuestion("miek.nl.", dns.TypeMX) - m.RecursionDesired = true - r, _, err := c.Exchange(m, config.Servers[0]+":"+config.Port) - if err != nil { - return - } - if r.Rcode != dns.RcodeSuccess { - return - } - for _, a := range r.Answer { - if mx, ok := a.(*dns.MX); ok { - fmt.Printf("%s\n", mx.String()) - } - } -} - -// Retrieve the DNSKEY records of a zone and convert them -// to DS records for SHA1, SHA256 and SHA384. -func ExampleDS() { - config, _ := dns.ClientConfigFromFile("/etc/resolv.conf") - c := new(dns.Client) - m := new(dns.Msg) - zone := "miek.nl" - m.SetQuestion(dns.Fqdn(zone), dns.TypeDNSKEY) - m.SetEdns0(4096, true) - r, _, err := c.Exchange(m, config.Servers[0]+":"+config.Port) - if err != nil { - return - } - if r.Rcode != dns.RcodeSuccess { - return - } - for _, k := range r.Answer { - if key, ok := k.(*dns.DNSKEY); ok { - for _, alg := range []uint8{dns.SHA1, dns.SHA256, dns.SHA384} { - fmt.Printf("%s; %d\n", key.ToDS(alg).String(), key.Flags) - } - } - } -} - -const TypeAPAIR = 0x0F99 - -type APAIR struct { - addr [2]net.IP -} - -func NewAPAIR() dns.PrivateRdata { return new(APAIR) } - -func (rd *APAIR) String() string { return rd.addr[0].String() + " " + rd.addr[1].String() } -func (rd *APAIR) Parse(txt []string) error { - if len(txt) != 2 { - return errors.New("two addresses required for APAIR") - } - for i, s := range txt { - ip := net.ParseIP(s) - if ip == nil { - return errors.New("invalid IP in APAIR text representation") - } - rd.addr[i] = ip - } - return nil -} - -func (rd *APAIR) Pack(buf []byte) (int, error) { - b := append([]byte(rd.addr[0]), []byte(rd.addr[1])...) - n := copy(buf, b) - if n != len(b) { - return n, dns.ErrBuf - } - return n, nil -} - -func (rd *APAIR) Unpack(buf []byte) (int, error) { - ln := net.IPv4len * 2 - if len(buf) != ln { - return 0, errors.New("invalid length of APAIR rdata") - } - cp := make([]byte, ln) - copy(cp, buf) // clone bytes to use them in IPs - - rd.addr[0] = net.IP(cp[:3]) - rd.addr[1] = net.IP(cp[4:]) - - return len(buf), nil -} - -func (rd *APAIR) Copy(dest dns.PrivateRdata) error { - cp := make([]byte, rd.Len()) - _, err := rd.Pack(cp) - if err != nil { - return err - } - - d := dest.(*APAIR) - d.addr[0] = net.IP(cp[:3]) - d.addr[1] = net.IP(cp[4:]) - return nil -} - -func (rd *APAIR) Len() int { - return net.IPv4len * 2 -} - -func ExamplePrivateHandle() { - dns.PrivateHandle("APAIR", TypeAPAIR, NewAPAIR) - defer dns.PrivateHandleRemove(TypeAPAIR) - - rr, err := dns.NewRR("miek.nl. APAIR (1.2.3.4 1.2.3.5)") - if err != nil { - log.Fatal("could not parse APAIR record: ", err) - } - fmt.Println(rr) - // Output: miek.nl. 3600 IN APAIR 1.2.3.4 1.2.3.5 - - m := new(dns.Msg) - m.Id = 12345 - m.SetQuestion("miek.nl.", TypeAPAIR) - m.Answer = append(m.Answer, rr) - - fmt.Println(m) - // ;; opcode: QUERY, status: NOERROR, id: 12345 - // ;; flags: rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 - // - // ;; QUESTION SECTION: - // ;miek.nl. IN APAIR - // - // ;; ANSWER SECTION: - // miek.nl. 3600 IN APAIR 1.2.3.4 1.2.3.5 -} diff --git a/vendor/github.com/miekg/dns/format.go b/vendor/github.com/miekg/dns/format.go deleted file mode 100644 index 3f5303c..0000000 --- a/vendor/github.com/miekg/dns/format.go +++ /dev/null @@ -1,87 +0,0 @@ -package dns - -import ( - "net" - "reflect" - "strconv" -) - -// NumField returns the number of rdata fields r has. -func NumField(r RR) int { - return reflect.ValueOf(r).Elem().NumField() - 1 // Remove RR_Header -} - -// Field returns the rdata field i as a string. Fields are indexed starting from 1. -// RR types that holds slice data, for instance the NSEC type bitmap will return a single -// string where the types are concatenated using a space. -// Accessing non existing fields will cause a panic. -func Field(r RR, i int) string { - if i == 0 { - return "" - } - d := reflect.ValueOf(r).Elem().Field(i) - switch k := d.Kind(); k { - case reflect.String: - return d.String() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return strconv.FormatInt(d.Int(), 10) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return strconv.FormatUint(d.Uint(), 10) - case reflect.Slice: - switch reflect.ValueOf(r).Elem().Type().Field(i).Tag { - case `dns:"a"`: - // TODO(miek): Hmm store this as 16 bytes - if d.Len() < net.IPv6len { - return net.IPv4(byte(d.Index(0).Uint()), - byte(d.Index(1).Uint()), - byte(d.Index(2).Uint()), - byte(d.Index(3).Uint())).String() - } - return net.IPv4(byte(d.Index(12).Uint()), - byte(d.Index(13).Uint()), - byte(d.Index(14).Uint()), - byte(d.Index(15).Uint())).String() - case `dns:"aaaa"`: - return net.IP{ - byte(d.Index(0).Uint()), - byte(d.Index(1).Uint()), - byte(d.Index(2).Uint()), - byte(d.Index(3).Uint()), - byte(d.Index(4).Uint()), - byte(d.Index(5).Uint()), - byte(d.Index(6).Uint()), - byte(d.Index(7).Uint()), - byte(d.Index(8).Uint()), - byte(d.Index(9).Uint()), - byte(d.Index(10).Uint()), - byte(d.Index(11).Uint()), - byte(d.Index(12).Uint()), - byte(d.Index(13).Uint()), - byte(d.Index(14).Uint()), - byte(d.Index(15).Uint()), - }.String() - case `dns:"nsec"`: - if d.Len() == 0 { - return "" - } - s := Type(d.Index(0).Uint()).String() - for i := 1; i < d.Len(); i++ { - s += " " + Type(d.Index(i).Uint()).String() - } - return s - default: - // if it does not have a tag its a string slice - fallthrough - case `dns:"txt"`: - if d.Len() == 0 { - return "" - } - s := d.Index(0).String() - for i := 1; i < d.Len(); i++ { - s += " " + d.Index(i).String() - } - return s - } - } - return "" -} diff --git a/vendor/github.com/miekg/dns/fuzz_test.go b/vendor/github.com/miekg/dns/fuzz_test.go deleted file mode 100644 index 2558697..0000000 --- a/vendor/github.com/miekg/dns/fuzz_test.go +++ /dev/null @@ -1,25 +0,0 @@ -package dns - -import "testing" - -func TestFuzzString(t *testing.T) { - testcases := []string{"", " MINFO ", " RP ", " NSEC 0 0", " \" NSEC 0 0\"", " \" MINFO \"", - ";a ", ";a����������", - " NSAP O ", " NSAP N ", - " TYPE4 TYPE6a789a3bc0045c8a5fb42c7d1bd998f5444 IN 9579b47d46817afbd17273e6", - " TYPE45 3 3 4147994 TYPE\\(\\)\\)\\(\\)\\(\\(\\)\\(\\)\\)\\)\\(\\)\\(\\)\\(\\(\\R 948\"\")\\(\\)\\)\\)\\(\\ ", - "$GENERATE 0-3 ${441189,5039418474430,o}", - "$INCLUDE 00 TYPE00000000000n ", - "$INCLUDE PE4 TYPE061463623/727071511 \\(\\)\\$GENERATE 6-462/0", - } - for i, tc := range testcases { - rr, err := NewRR(tc) - if err == nil { - // rr can be nil because we can (for instance) just parse a comment - if rr == nil { - continue - } - t.Fatalf("parsed mailformed RR %d: %s", i, rr.String()) - } - } -} diff --git a/vendor/github.com/miekg/dns/generate.go b/vendor/github.com/miekg/dns/generate.go deleted file mode 100644 index e4481a4..0000000 --- a/vendor/github.com/miekg/dns/generate.go +++ /dev/null @@ -1,159 +0,0 @@ -package dns - -import ( - "bytes" - "errors" - "fmt" - "strconv" - "strings" -) - -// Parse the $GENERATE statement as used in BIND9 zones. -// See http://www.zytrax.com/books/dns/ch8/generate.html for instance. -// We are called after '$GENERATE '. After which we expect: -// * the range (12-24/2) -// * lhs (ownername) -// * [[ttl][class]] -// * type -// * rhs (rdata) -// But we are lazy here, only the range is parsed *all* occurrences -// of $ after that are interpreted. -// Any error are returned as a string value, the empty string signals -// "no error". -func generate(l lex, c chan lex, t chan *Token, o string) string { - step := 1 - if i := strings.IndexAny(l.token, "/"); i != -1 { - if i+1 == len(l.token) { - return "bad step in $GENERATE range" - } - if s, err := strconv.Atoi(l.token[i+1:]); err == nil { - if s < 0 { - return "bad step in $GENERATE range" - } - step = s - } else { - return "bad step in $GENERATE range" - } - l.token = l.token[:i] - } - sx := strings.SplitN(l.token, "-", 2) - if len(sx) != 2 { - return "bad start-stop in $GENERATE range" - } - start, err := strconv.Atoi(sx[0]) - if err != nil { - return "bad start in $GENERATE range" - } - end, err := strconv.Atoi(sx[1]) - if err != nil { - return "bad stop in $GENERATE range" - } - if end < 0 || start < 0 || end < start { - return "bad range in $GENERATE range" - } - - <-c // _BLANK - // Create a complete new string, which we then parse again. - s := "" -BuildRR: - l = <-c - if l.value != zNewline && l.value != zEOF { - s += l.token - goto BuildRR - } - for i := start; i <= end; i += step { - var ( - escape bool - dom bytes.Buffer - mod string - err error - offset int - ) - - for j := 0; j < len(s); j++ { // No 'range' because we need to jump around - switch s[j] { - case '\\': - if escape { - dom.WriteByte('\\') - escape = false - continue - } - escape = true - case '$': - mod = "%d" - offset = 0 - if escape { - dom.WriteByte('$') - escape = false - continue - } - escape = false - if j+1 >= len(s) { // End of the string - dom.WriteString(fmt.Sprintf(mod, i+offset)) - continue - } else { - if s[j+1] == '$' { - dom.WriteByte('$') - j++ - continue - } - } - // Search for { and } - if s[j+1] == '{' { // Modifier block - sep := strings.Index(s[j+2:], "}") - if sep == -1 { - return "bad modifier in $GENERATE" - } - mod, offset, err = modToPrintf(s[j+2 : j+2+sep]) - if err != nil { - return err.Error() - } - j += 2 + sep // Jump to it - } - dom.WriteString(fmt.Sprintf(mod, i+offset)) - default: - if escape { // Pretty useless here - escape = false - continue - } - dom.WriteByte(s[j]) - } - } - // Re-parse the RR and send it on the current channel t - rx, err := NewRR("$ORIGIN " + o + "\n" + dom.String()) - if err != nil { - return err.Error() - } - t <- &Token{RR: rx} - // Its more efficient to first built the rrlist and then parse it in - // one go! But is this a problem? - } - return "" -} - -// Convert a $GENERATE modifier 0,0,d to something Printf can deal with. -func modToPrintf(s string) (string, int, error) { - xs := strings.SplitN(s, ",", 3) - if len(xs) != 3 { - return "", 0, errors.New("bad modifier in $GENERATE") - } - // xs[0] is offset, xs[1] is width, xs[2] is base - if xs[2] != "o" && xs[2] != "d" && xs[2] != "x" && xs[2] != "X" { - return "", 0, errors.New("bad base in $GENERATE") - } - offset, err := strconv.Atoi(xs[0]) - if err != nil || offset > 255 { - return "", 0, errors.New("bad offset in $GENERATE") - } - width, err := strconv.Atoi(xs[1]) - if err != nil || width > 255 { - return "", offset, errors.New("bad width in $GENERATE") - } - switch { - case width < 0: - return "", offset, errors.New("bad width in $GENERATE") - case width == 0: - return "%" + xs[1] + xs[2], offset, nil - } - return "%0" + xs[1] + xs[2], offset, nil -} diff --git a/vendor/github.com/miekg/dns/idn/code_points.go b/vendor/github.com/miekg/dns/idn/code_points.go deleted file mode 100644 index 129c374..0000000 --- a/vendor/github.com/miekg/dns/idn/code_points.go +++ /dev/null @@ -1,2346 +0,0 @@ -package idn - -const ( - propertyUnknown property = iota // unknown character property - propertyPVALID // allowed to be used in IDNs - propertyCONTEXTJ // invisible or problematic characters (join controls) - propertyCONTEXTO // invisible or problematic characters (others) - propertyDISALLOWED // should not be included in IDNs - propertyUNASSIGNED // code points that are not designated in the Unicode Standard -) - -// property stores the property of a code point, as described in RFC 5892, -// section 1 -type property int - -// codePoints list all code points in Unicode Character Database (UCD) Format -// according to RFC 5892, appendix B.1. Thanks to libidn2 (GNU) - -// http://www.gnu.org/software/libidn/libidn2/ -var codePoints = []struct { - start rune - end rune - state property -}{ - {0x0000, 0x002C, propertyDISALLOWED}, // ..COMMA - {0x002D, 0x0, propertyPVALID}, // HYPHEN-MINUS - {0x002E, 0x002F, propertyDISALLOWED}, // FULL STOP..SOLIDUS - {0x0030, 0x0039, propertyPVALID}, // DIGIT ZERO..DIGIT NINE - {0x003A, 0x0060, propertyDISALLOWED}, // COLON..GRAVE ACCENT - {0x0041, 0x005A, propertyPVALID}, // LATIN CAPITAL LETTER A..LATIN CAPITAL LETTER Z - {0x0061, 0x007A, propertyPVALID}, // LATIN SMALL LETTER A..LATIN SMALL LETTER Z - {0x007B, 0x00B6, propertyDISALLOWED}, // LEFT CURLY BRACKET..PILCROW SIGN - {0x00B7, 0x0, propertyCONTEXTO}, // MIDDLE DOT - {0x00B8, 0x00DE, propertyDISALLOWED}, // CEDILLA..LATIN CAPITAL LETTER THORN - {0x00DF, 0x00F6, propertyPVALID}, // LATIN SMALL LETTER SHARP S..LATIN SMALL LETT - {0x00F7, 0x0, propertyDISALLOWED}, // DIVISION SIGN - {0x00F8, 0x00FF, propertyPVALID}, // LATIN SMALL LETTER O WITH STROKE..LATIN SMAL - {0x0100, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH MACRON - {0x0101, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH MACRON - {0x0102, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH BREVE - {0x0103, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH BREVE - {0x0104, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH OGONEK - {0x0105, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH OGONEK - {0x0106, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER C WITH ACUTE - {0x0107, 0x0, propertyPVALID}, // LATIN SMALL LETTER C WITH ACUTE - {0x0108, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER C WITH CIRCUMFLEX - {0x0109, 0x0, propertyPVALID}, // LATIN SMALL LETTER C WITH CIRCUMFLEX - {0x010A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER C WITH DOT ABOVE - {0x010B, 0x0, propertyPVALID}, // LATIN SMALL LETTER C WITH DOT ABOVE - {0x010C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER C WITH CARON - {0x010D, 0x0, propertyPVALID}, // LATIN SMALL LETTER C WITH CARON - {0x010E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER D WITH CARON - {0x010F, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH CARON - {0x0110, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER D WITH STROKE - {0x0111, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH STROKE - {0x0112, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH MACRON - {0x0113, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH MACRON - {0x0114, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH BREVE - {0x0115, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH BREVE - {0x0116, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH DOT ABOVE - {0x0117, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH DOT ABOVE - {0x0118, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH OGONEK - {0x0119, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH OGONEK - {0x011A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CARON - {0x011B, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CARON - {0x011C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH CIRCUMFLEX - {0x011D, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH CIRCUMFLEX - {0x011E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH BREVE - {0x011F, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH BREVE - {0x0120, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH DOT ABOVE - {0x0121, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH DOT ABOVE - {0x0122, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH CEDILLA - {0x0123, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH CEDILLA - {0x0124, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH CIRCUMFLEX - {0x0125, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH CIRCUMFLEX - {0x0126, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH STROKE - {0x0127, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH STROKE - {0x0128, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH TILDE - {0x0129, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH TILDE - {0x012A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH MACRON - {0x012B, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH MACRON - {0x012C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH BREVE - {0x012D, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH BREVE - {0x012E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH OGONEK - {0x012F, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH OGONEK - {0x0130, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH DOT ABOVE - {0x0131, 0x0, propertyPVALID}, // LATIN SMALL LETTER DOTLESS I - {0x0132, 0x0134, propertyDISALLOWED}, // LATIN CAPITAL LIGATURE IJ..LATIN CAPITAL LET - {0x0135, 0x0, propertyPVALID}, // LATIN SMALL LETTER J WITH CIRCUMFLEX - {0x0136, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH CEDILLA - {0x0137, 0x0138, propertyPVALID}, // LATIN SMALL LETTER K WITH CEDILLA..LATIN SMA - {0x0139, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH ACUTE - {0x013A, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH ACUTE - {0x013B, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH CEDILLA - {0x013C, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH CEDILLA - {0x013D, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH CARON - {0x013E, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH CARON - {0x013F, 0x0141, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH MIDDLE DOT..LATI - {0x0142, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH STROKE - {0x0143, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH ACUTE - {0x0144, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH ACUTE - {0x0145, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH CEDILLA - {0x0146, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH CEDILLA - {0x0147, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH CARON - {0x0148, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH CARON - {0x0149, 0x014A, propertyDISALLOWED}, // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE. - {0x014B, 0x0, propertyPVALID}, // LATIN SMALL LETTER ENG - {0x014C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH MACRON - {0x014D, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH MACRON - {0x014E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH BREVE - {0x014F, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH BREVE - {0x0150, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE - {0x0151, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH DOUBLE ACUTE - {0x0152, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LIGATURE OE - {0x0153, 0x0, propertyPVALID}, // LATIN SMALL LIGATURE OE - {0x0154, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH ACUTE - {0x0155, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH ACUTE - {0x0156, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH CEDILLA - {0x0157, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH CEDILLA - {0x0158, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH CARON - {0x0159, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH CARON - {0x015A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH ACUTE - {0x015B, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH ACUTE - {0x015C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH CIRCUMFLEX - {0x015D, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH CIRCUMFLEX - {0x015E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH CEDILLA - {0x015F, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH CEDILLA - {0x0160, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH CARON - {0x0161, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH CARON - {0x0162, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH CEDILLA - {0x0163, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH CEDILLA - {0x0164, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH CARON - {0x0165, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH CARON - {0x0166, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH STROKE - {0x0167, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH STROKE - {0x0168, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH TILDE - {0x0169, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH TILDE - {0x016A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH MACRON - {0x016B, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH MACRON - {0x016C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH BREVE - {0x016D, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH BREVE - {0x016E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH RING ABOVE - {0x016F, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH RING ABOVE - {0x0170, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE - {0x0171, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH DOUBLE ACUTE - {0x0172, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH OGONEK - {0x0173, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH OGONEK - {0x0174, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER W WITH CIRCUMFLEX - {0x0175, 0x0, propertyPVALID}, // LATIN SMALL LETTER W WITH CIRCUMFLEX - {0x0176, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH CIRCUMFLEX - {0x0177, 0x0, propertyPVALID}, // LATIN SMALL LETTER Y WITH CIRCUMFLEX - {0x0178, 0x0179, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH DIAERESIS..LATIN - {0x017A, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH ACUTE - {0x017B, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH DOT ABOVE - {0x017C, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH DOT ABOVE - {0x017D, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH CARON - {0x017E, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH CARON - {0x017F, 0x0, propertyDISALLOWED}, // LATIN SMALL LETTER LONG S - {0x0180, 0x0, propertyPVALID}, // LATIN SMALL LETTER B WITH STROKE - {0x0181, 0x0182, propertyDISALLOWED}, // LATIN CAPITAL LETTER B WITH HOOK..LATIN CAPI - {0x0183, 0x0, propertyPVALID}, // LATIN SMALL LETTER B WITH TOPBAR - {0x0184, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER TONE SIX - {0x0185, 0x0, propertyPVALID}, // LATIN SMALL LETTER TONE SIX - {0x0186, 0x0187, propertyDISALLOWED}, // LATIN CAPITAL LETTER OPEN O..LATIN CAPITAL L - {0x0188, 0x0, propertyPVALID}, // LATIN SMALL LETTER C WITH HOOK - {0x0189, 0x018B, propertyDISALLOWED}, // LATIN CAPITAL LETTER AFRICAN D..LATIN CAPITA - {0x018C, 0x018D, propertyPVALID}, // LATIN SMALL LETTER D WITH TOPBAR..LATIN SMAL - {0x018E, 0x0191, propertyDISALLOWED}, // LATIN CAPITAL LETTER REVERSED E..LATIN CAPIT - {0x0192, 0x0, propertyPVALID}, // LATIN SMALL LETTER F WITH HOOK - {0x0193, 0x0194, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH HOOK..LATIN CAPI - {0x0195, 0x0, propertyPVALID}, // LATIN SMALL LETTER HV - {0x0196, 0x0198, propertyDISALLOWED}, // LATIN CAPITAL LETTER IOTA..LATIN CAPITAL LET - {0x0199, 0x019B, propertyPVALID}, // LATIN SMALL LETTER K WITH HOOK..LATIN SMALL - {0x019C, 0x019D, propertyDISALLOWED}, // LATIN CAPITAL LETTER TURNED M..LATIN CAPITAL - {0x019E, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH LONG RIGHT LEG - {0x019F, 0x01A0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH MIDDLE TILDE..LA - {0x01A1, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH HORN - {0x01A2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER OI - {0x01A3, 0x0, propertyPVALID}, // LATIN SMALL LETTER OI - {0x01A4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER P WITH HOOK - {0x01A5, 0x0, propertyPVALID}, // LATIN SMALL LETTER P WITH HOOK - {0x01A6, 0x01A7, propertyDISALLOWED}, // LATIN LETTER YR..LATIN CAPITAL LETTER TONE T - {0x01A8, 0x0, propertyPVALID}, // LATIN SMALL LETTER TONE TWO - {0x01A9, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER ESH - {0x01AA, 0x01AB, propertyPVALID}, // LATIN LETTER REVERSED ESH LOOP..LATIN SMALL - {0x01AC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH HOOK - {0x01AD, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH HOOK - {0x01AE, 0x01AF, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH RETROFLEX HOOK.. - {0x01B0, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH HORN - {0x01B1, 0x01B3, propertyDISALLOWED}, // LATIN CAPITAL LETTER UPSILON..LATIN CAPITAL - {0x01B4, 0x0, propertyPVALID}, // LATIN SMALL LETTER Y WITH HOOK - {0x01B5, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH STROKE - {0x01B6, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH STROKE - {0x01B7, 0x01B8, propertyDISALLOWED}, // LATIN CAPITAL LETTER EZH..LATIN CAPITAL LETT - {0x01B9, 0x01BB, propertyPVALID}, // LATIN SMALL LETTER EZH REVERSED..LATIN LETTE - {0x01BC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER TONE FIVE - {0x01BD, 0x01C3, propertyPVALID}, // LATIN SMALL LETTER TONE FIVE..LATIN LETTER R - {0x01C4, 0x01CD, propertyDISALLOWED}, // LATIN CAPITAL LETTER DZ WITH CARON..LATIN CA - {0x01CE, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH CARON - {0x01CF, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH CARON - {0x01D0, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH CARON - {0x01D1, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH CARON - {0x01D2, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH CARON - {0x01D3, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH CARON - {0x01D4, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH CARON - {0x01D5, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DIAERESIS AND MA - {0x01D6, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH DIAERESIS AND MACR - {0x01D7, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DIAERESIS AND AC - {0x01D8, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH DIAERESIS AND ACUT - {0x01D9, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DIAERESIS AND CA - {0x01DA, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH DIAERESIS AND CARO - {0x01DB, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DIAERESIS AND GR - {0x01DC, 0x01DD, propertyPVALID}, // LATIN SMALL LETTER U WITH DIAERESIS AND GRAV - {0x01DE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH DIAERESIS AND MA - {0x01DF, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH DIAERESIS AND MACR - {0x01E0, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH DOT ABOVE AND MA - {0x01E1, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH DOT ABOVE AND MACR - {0x01E2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AE WITH MACRON - {0x01E3, 0x0, propertyPVALID}, // LATIN SMALL LETTER AE WITH MACRON - {0x01E4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH STROKE - {0x01E5, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH STROKE - {0x01E6, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH CARON - {0x01E7, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH CARON - {0x01E8, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH CARON - {0x01E9, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH CARON - {0x01EA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH OGONEK - {0x01EB, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH OGONEK - {0x01EC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH OGONEK AND MACRO - {0x01ED, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH OGONEK AND MACRON - {0x01EE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER EZH WITH CARON - {0x01EF, 0x01F0, propertyPVALID}, // LATIN SMALL LETTER EZH WITH CARON..LATIN SMA - {0x01F1, 0x01F4, propertyDISALLOWED}, // LATIN CAPITAL LETTER DZ..LATIN CAPITAL LETTE - {0x01F5, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH ACUTE - {0x01F6, 0x01F8, propertyDISALLOWED}, // LATIN CAPITAL LETTER HWAIR..LATIN CAPITAL LE - {0x01F9, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH GRAVE - {0x01FA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH RING ABOVE AND A - {0x01FB, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH RING ABOVE AND ACU - {0x01FC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AE WITH ACUTE - {0x01FD, 0x0, propertyPVALID}, // LATIN SMALL LETTER AE WITH ACUTE - {0x01FE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH STROKE AND ACUTE - {0x01FF, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH STROKE AND ACUTE - {0x0200, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH DOUBLE GRAVE - {0x0201, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH DOUBLE GRAVE - {0x0202, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH INVERTED BREVE - {0x0203, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH INVERTED BREVE - {0x0204, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH DOUBLE GRAVE - {0x0205, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH DOUBLE GRAVE - {0x0206, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH INVERTED BREVE - {0x0207, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH INVERTED BREVE - {0x0208, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH DOUBLE GRAVE - {0x0209, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH DOUBLE GRAVE - {0x020A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH INVERTED BREVE - {0x020B, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH INVERTED BREVE - {0x020C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH DOUBLE GRAVE - {0x020D, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH DOUBLE GRAVE - {0x020E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH INVERTED BREVE - {0x020F, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH INVERTED BREVE - {0x0210, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH DOUBLE GRAVE - {0x0211, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH DOUBLE GRAVE - {0x0212, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH INVERTED BREVE - {0x0213, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH INVERTED BREVE - {0x0214, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DOUBLE GRAVE - {0x0215, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH DOUBLE GRAVE - {0x0216, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH INVERTED BREVE - {0x0217, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH INVERTED BREVE - {0x0218, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH COMMA BELOW - {0x0219, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH COMMA BELOW - {0x021A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH COMMA BELOW - {0x021B, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH COMMA BELOW - {0x021C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER YOGH - {0x021D, 0x0, propertyPVALID}, // LATIN SMALL LETTER YOGH - {0x021E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH CARON - {0x021F, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH CARON - {0x0220, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH LONG RIGHT LEG - {0x0221, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH CURL - {0x0222, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER OU - {0x0223, 0x0, propertyPVALID}, // LATIN SMALL LETTER OU - {0x0224, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH HOOK - {0x0225, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH HOOK - {0x0226, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH DOT ABOVE - {0x0227, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH DOT ABOVE - {0x0228, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CEDILLA - {0x0229, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CEDILLA - {0x022A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH DIAERESIS AND MA - {0x022B, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH DIAERESIS AND MACR - {0x022C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH TILDE AND MACRON - {0x022D, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH TILDE AND MACRON - {0x022E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH DOT ABOVE - {0x022F, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH DOT ABOVE - {0x0230, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH DOT ABOVE AND MA - {0x0231, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH DOT ABOVE AND MACR - {0x0232, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH MACRON - {0x0233, 0x0239, propertyPVALID}, // LATIN SMALL LETTER Y WITH MACRON..LATIN SMAL - {0x023A, 0x023B, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH STROKE..LATIN CA - {0x023C, 0x0, propertyPVALID}, // LATIN SMALL LETTER C WITH STROKE - {0x023D, 0x023E, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH BAR..LATIN CAPIT - {0x023F, 0x0240, propertyPVALID}, // LATIN SMALL LETTER S WITH SWASH TAIL..LATIN - {0x0241, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER GLOTTAL STOP - {0x0242, 0x0, propertyPVALID}, // LATIN SMALL LETTER GLOTTAL STOP - {0x0243, 0x0246, propertyDISALLOWED}, // LATIN CAPITAL LETTER B WITH STROKE..LATIN CA - {0x0247, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH STROKE - {0x0248, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER J WITH STROKE - {0x0249, 0x0, propertyPVALID}, // LATIN SMALL LETTER J WITH STROKE - {0x024A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER SMALL Q WITH HOOK TAIL - {0x024B, 0x0, propertyPVALID}, // LATIN SMALL LETTER Q WITH HOOK TAIL - {0x024C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH STROKE - {0x024D, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH STROKE - {0x024E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH STROKE - {0x024F, 0x02AF, propertyPVALID}, // LATIN SMALL LETTER Y WITH STROKE..LATIN SMAL - {0x02B0, 0x02B8, propertyDISALLOWED}, // MODIFIER LETTER SMALL H..MODIFIER LETTER SMA - {0x02B9, 0x02C1, propertyPVALID}, // MODIFIER LETTER PRIME..MODIFIER LETTER REVER - {0x02C2, 0x02C5, propertyDISALLOWED}, // MODIFIER LETTER LEFT ARROWHEAD..MODIFIER LET - {0x02C6, 0x02D1, propertyPVALID}, // MODIFIER LETTER CIRCUMFLEX ACCENT..MODIFIER - {0x02D2, 0x02EB, propertyDISALLOWED}, // MODIFIER LETTER CENTRED RIGHT HALF RING..MOD - {0x02EC, 0x0, propertyPVALID}, // MODIFIER LETTER VOICING - {0x02ED, 0x0, propertyDISALLOWED}, // MODIFIER LETTER UNASPIRATED - {0x02EE, 0x0, propertyPVALID}, // MODIFIER LETTER DOUBLE APOSTROPHE - {0x02EF, 0x02FF, propertyDISALLOWED}, // MODIFIER LETTER LOW DOWN ARROWHEAD..MODIFIER - {0x0300, 0x033F, propertyPVALID}, // COMBINING GRAVE ACCENT..COMBINING DOUBLE OVE - {0x0340, 0x0341, propertyDISALLOWED}, // COMBINING GRAVE TONE MARK..COMBINING ACUTE T - {0x0342, 0x0, propertyPVALID}, // COMBINING GREEK PERISPOMENI - {0x0343, 0x0345, propertyDISALLOWED}, // COMBINING GREEK KORONIS..COMBINING GREEK YPO - {0x0346, 0x034E, propertyPVALID}, // COMBINING BRIDGE ABOVE..COMBINING UPWARDS AR - {0x034F, 0x0, propertyDISALLOWED}, // COMBINING GRAPHEME JOINER - {0x0350, 0x036F, propertyPVALID}, // COMBINING RIGHT ARROWHEAD ABOVE..COMBINING L - {0x0370, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER HETA - {0x0371, 0x0, propertyPVALID}, // GREEK SMALL LETTER HETA - {0x0372, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER ARCHAIC SAMPI - {0x0373, 0x0, propertyPVALID}, // GREEK SMALL LETTER ARCHAIC SAMPI - {0x0374, 0x0, propertyDISALLOWED}, // GREEK NUMERAL SIGN - {0x0375, 0x0, propertyCONTEXTO}, // GREEK LOWER NUMERAL SIGN - {0x0376, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER PAMPHYLIAN DIGAMMA - {0x0377, 0x0, propertyPVALID}, // GREEK SMALL LETTER PAMPHYLIAN DIGAMMA - {0x0378, 0x0379, propertyUNASSIGNED}, // .. - {0x037A, 0x0, propertyDISALLOWED}, // GREEK YPOGEGRAMMENI - {0x037B, 0x037D, propertyPVALID}, // GREEK SMALL REVERSED LUNATE SIGMA SYMBOL..GR - {0x037E, 0x0, propertyDISALLOWED}, // GREEK QUESTION MARK - {0x037F, 0x0383, propertyUNASSIGNED}, // .. - {0x0384, 0x038A, propertyDISALLOWED}, // GREEK TONOS..GREEK CAPITAL LETTER IOTA WITH - {0x038B, 0x0, propertyUNASSIGNED}, // - {0x038C, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER OMICRON WITH TONOS - {0x038D, 0x0, propertyUNASSIGNED}, // - {0x038E, 0x038F, propertyDISALLOWED}, // GREEK CAPITAL LETTER UPSILON WITH TONOS..GRE - {0x0390, 0x0, propertyPVALID}, // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND T - {0x0391, 0x03A1, propertyDISALLOWED}, // GREEK CAPITAL LETTER ALPHA..GREEK CAPITAL LE - {0x03A2, 0x0, propertyUNASSIGNED}, // - {0x03A3, 0x03AB, propertyDISALLOWED}, // GREEK CAPITAL LETTER SIGMA..GREEK CAPITAL LE - {0x03AC, 0x03CE, propertyPVALID}, // GREEK SMALL LETTER ALPHA WITH TONOS..GREEK S - {0x03CF, 0x03D6, propertyDISALLOWED}, // GREEK CAPITAL KAI SYMBOL..GREEK PI SYMBOL - {0x03D7, 0x0, propertyPVALID}, // GREEK KAI SYMBOL - {0x03D8, 0x0, propertyDISALLOWED}, // GREEK LETTER ARCHAIC KOPPA - {0x03D9, 0x0, propertyPVALID}, // GREEK SMALL LETTER ARCHAIC KOPPA - {0x03DA, 0x0, propertyDISALLOWED}, // GREEK LETTER STIGMA - {0x03DB, 0x0, propertyPVALID}, // GREEK SMALL LETTER STIGMA - {0x03DC, 0x0, propertyDISALLOWED}, // GREEK LETTER DIGAMMA - {0x03DD, 0x0, propertyPVALID}, // GREEK SMALL LETTER DIGAMMA - {0x03DE, 0x0, propertyDISALLOWED}, // GREEK LETTER KOPPA - {0x03DF, 0x0, propertyPVALID}, // GREEK SMALL LETTER KOPPA - {0x03E0, 0x0, propertyDISALLOWED}, // GREEK LETTER SAMPI - {0x03E1, 0x0, propertyPVALID}, // GREEK SMALL LETTER SAMPI - {0x03E2, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER SHEI - {0x03E3, 0x0, propertyPVALID}, // COPTIC SMALL LETTER SHEI - {0x03E4, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER FEI - {0x03E5, 0x0, propertyPVALID}, // COPTIC SMALL LETTER FEI - {0x03E6, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER KHEI - {0x03E7, 0x0, propertyPVALID}, // COPTIC SMALL LETTER KHEI - {0x03E8, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER HORI - {0x03E9, 0x0, propertyPVALID}, // COPTIC SMALL LETTER HORI - {0x03EA, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER GANGIA - {0x03EB, 0x0, propertyPVALID}, // COPTIC SMALL LETTER GANGIA - {0x03EC, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER SHIMA - {0x03ED, 0x0, propertyPVALID}, // COPTIC SMALL LETTER SHIMA - {0x03EE, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER DEI - {0x03EF, 0x0, propertyPVALID}, // COPTIC SMALL LETTER DEI - {0x03F0, 0x03F2, propertyDISALLOWED}, // GREEK KAPPA SYMBOL..GREEK LUNATE SIGMA SYMBO - {0x03F3, 0x0, propertyPVALID}, // GREEK LETTER YOT - {0x03F4, 0x03F7, propertyDISALLOWED}, // GREEK CAPITAL THETA SYMBOL..GREEK CAPITAL LE - {0x03F8, 0x0, propertyPVALID}, // GREEK SMALL LETTER SHO - {0x03F9, 0x03FA, propertyDISALLOWED}, // GREEK CAPITAL LUNATE SIGMA SYMBOL..GREEK CAP - {0x03FB, 0x03FC, propertyPVALID}, // GREEK SMALL LETTER SAN..GREEK RHO WITH STROK - {0x03FD, 0x042F, propertyDISALLOWED}, // GREEK CAPITAL REVERSED LUNATE SIGMA SYMBOL.. - {0x0430, 0x045F, propertyPVALID}, // CYRILLIC SMALL LETTER A..CYRILLIC SMALL LETT - {0x0460, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER OMEGA - {0x0461, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER OMEGA - {0x0462, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER YAT - {0x0463, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER YAT - {0x0464, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IOTIFIED E - {0x0465, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IOTIFIED E - {0x0466, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER LITTLE YUS - {0x0467, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER LITTLE YUS - {0x0468, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IOTIFIED LITTLE YUS - {0x0469, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IOTIFIED LITTLE YUS - {0x046A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER BIG YUS - {0x046B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER BIG YUS - {0x046C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IOTIFIED BIG YUS - {0x046D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IOTIFIED BIG YUS - {0x046E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KSI - {0x046F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KSI - {0x0470, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER PSI - {0x0471, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER PSI - {0x0472, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER FITA - {0x0473, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER FITA - {0x0474, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IZHITSA - {0x0475, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IZHITSA - {0x0476, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IZHITSA WITH DOUBLE - {0x0477, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IZHITSA WITH DOUBLE GR - {0x0478, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER UK - {0x0479, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER UK - {0x047A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ROUND OMEGA - {0x047B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ROUND OMEGA - {0x047C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER OMEGA WITH TITLO - {0x047D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER OMEGA WITH TITLO - {0x047E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER OT - {0x047F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER OT - {0x0480, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOPPA - {0x0481, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOPPA - {0x0482, 0x0, propertyDISALLOWED}, // CYRILLIC THOUSANDS SIGN - {0x0483, 0x0487, propertyPVALID}, // COMBINING CYRILLIC TITLO..COMBINING CYRILLIC - {0x0488, 0x048A, propertyDISALLOWED}, // COMBINING CYRILLIC HUNDRED THOUSANDS SIGN..C - {0x048B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SHORT I WITH TAIL - {0x048C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SEMISOFT SIGN - {0x048D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SEMISOFT SIGN - {0x048E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ER WITH TICK - {0x048F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ER WITH TICK - {0x0490, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER GHE WITH UPTURN - {0x0491, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER GHE WITH UPTURN - {0x0492, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER GHE WITH STROKE - {0x0493, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER GHE WITH STROKE - {0x0494, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER GHE WITH MIDDLE HOOK - {0x0495, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER GHE WITH MIDDLE HOOK - {0x0496, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER - {0x0497, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ZHE WITH DESCENDER - {0x0498, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ZE WITH DESCENDER - {0x0499, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ZE WITH DESCENDER - {0x049A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KA WITH DESCENDER - {0x049B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KA WITH DESCENDER - {0x049C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KA WITH VERTICAL STR - {0x049D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KA WITH VERTICAL STROK - {0x049E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KA WITH STROKE - {0x049F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KA WITH STROKE - {0x04A0, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER BASHKIR KA - {0x04A1, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER BASHKIR KA - {0x04A2, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EN WITH DESCENDER - {0x04A3, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER EN WITH DESCENDER - {0x04A4, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LIGATURE EN GHE - {0x04A5, 0x0, propertyPVALID}, // CYRILLIC SMALL LIGATURE EN GHE - {0x04A6, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER PE WITH MIDDLE HOOK - {0x04A7, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER PE WITH MIDDLE HOOK - {0x04A8, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ABKHASIAN HA - {0x04A9, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ABKHASIAN HA - {0x04AA, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ES WITH DESCENDER - {0x04AB, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ES WITH DESCENDER - {0x04AC, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER TE WITH DESCENDER - {0x04AD, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER TE WITH DESCENDER - {0x04AE, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER STRAIGHT U - {0x04AF, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER STRAIGHT U - {0x04B0, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER STRAIGHT U WITH STRO - {0x04B1, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE - {0x04B2, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER HA WITH DESCENDER - {0x04B3, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER HA WITH DESCENDER - {0x04B4, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LIGATURE TE TSE - {0x04B5, 0x0, propertyPVALID}, // CYRILLIC SMALL LIGATURE TE TSE - {0x04B6, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER CHE WITH DESCENDER - {0x04B7, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER CHE WITH DESCENDER - {0x04B8, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER CHE WITH VERTICAL ST - {0x04B9, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER CHE WITH VERTICAL STRO - {0x04BA, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SHHA - {0x04BB, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SHHA - {0x04BC, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ABKHASIAN CHE - {0x04BD, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ABKHASIAN CHE - {0x04BE, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ABKHASIAN CHE WITH D - {0x04BF, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ABKHASIAN CHE WITH DES - {0x04C0, 0x04C1, propertyDISALLOWED}, // CYRILLIC LETTER PALOCHKA..CYRILLIC CAPITAL L - {0x04C2, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ZHE WITH BREVE - {0x04C3, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KA WITH HOOK - {0x04C4, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KA WITH HOOK - {0x04C5, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EL WITH TAIL - {0x04C6, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER EL WITH TAIL - {0x04C7, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EN WITH HOOK - {0x04C8, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER EN WITH HOOK - {0x04C9, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EN WITH TAIL - {0x04CA, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER EN WITH TAIL - {0x04CB, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KHAKASSIAN CHE - {0x04CC, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KHAKASSIAN CHE - {0x04CD, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EM WITH TAIL - {0x04CE, 0x04CF, propertyPVALID}, // CYRILLIC SMALL LETTER EM WITH TAIL..CYRILLIC - {0x04D0, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER A WITH BREVE - {0x04D1, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER A WITH BREVE - {0x04D2, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER A WITH DIAERESIS - {0x04D3, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER A WITH DIAERESIS - {0x04D4, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LIGATURE A IE - {0x04D5, 0x0, propertyPVALID}, // CYRILLIC SMALL LIGATURE A IE - {0x04D6, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IE WITH BREVE - {0x04D7, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IE WITH BREVE - {0x04D8, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SCHWA - {0x04D9, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SCHWA - {0x04DA, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SCHWA WITH DIAERESIS - {0x04DB, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SCHWA WITH DIAERESIS - {0x04DC, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ZHE WITH DIAERESIS - {0x04DD, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ZHE WITH DIAERESIS - {0x04DE, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ZE WITH DIAERESIS - {0x04DF, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ZE WITH DIAERESIS - {0x04E0, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ABKHASIAN DZE - {0x04E1, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ABKHASIAN DZE - {0x04E2, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER I WITH MACRON - {0x04E3, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER I WITH MACRON - {0x04E4, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER I WITH DIAERESIS - {0x04E5, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER I WITH DIAERESIS - {0x04E6, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER O WITH DIAERESIS - {0x04E7, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER O WITH DIAERESIS - {0x04E8, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER BARRED O - {0x04E9, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER BARRED O - {0x04EA, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER BARRED O WITH DIAERE - {0x04EB, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER BARRED O WITH DIAERESI - {0x04EC, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER E WITH DIAERESIS - {0x04ED, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER E WITH DIAERESIS - {0x04EE, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER U WITH MACRON - {0x04EF, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER U WITH MACRON - {0x04F0, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER U WITH DIAERESIS - {0x04F1, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER U WITH DIAERESIS - {0x04F2, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE - {0x04F3, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER U WITH DOUBLE ACUTE - {0x04F4, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER CHE WITH DIAERESIS - {0x04F5, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER CHE WITH DIAERESIS - {0x04F6, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER GHE WITH DESCENDER - {0x04F7, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER GHE WITH DESCENDER - {0x04F8, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS - {0x04F9, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER YERU WITH DIAERESIS - {0x04FA, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER GHE WITH STROKE AND - {0x04FB, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER GHE WITH STROKE AND HO - {0x04FC, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER HA WITH HOOK - {0x04FD, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER HA WITH HOOK - {0x04FE, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER HA WITH STROKE - {0x04FF, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER HA WITH STROKE - {0x0500, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI DE - {0x0501, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI DE - {0x0502, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI DJE - {0x0503, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI DJE - {0x0504, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI ZJE - {0x0505, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI ZJE - {0x0506, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI DZJE - {0x0507, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI DZJE - {0x0508, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI LJE - {0x0509, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI LJE - {0x050A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI NJE - {0x050B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI NJE - {0x050C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI SJE - {0x050D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI SJE - {0x050E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER KOMI TJE - {0x050F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER KOMI TJE - {0x0510, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER REVERSED ZE - {0x0511, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER REVERSED ZE - {0x0512, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EL WITH HOOK - {0x0513, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER EL WITH HOOK - {0x0514, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER LHA - {0x0515, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER LHA - {0x0516, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER RHA - {0x0517, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER RHA - {0x0518, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER YAE - {0x0519, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER YAE - {0x051A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER QA - {0x051B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER QA - {0x051C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER WE - {0x051D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER WE - {0x051E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ALEUT KA - {0x051F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ALEUT KA - {0x0520, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EL WITH MIDDLE HOOK - {0x0521, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER EL WITH MIDDLE HOOK - {0x0522, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER EN WITH MIDDLE HOOK - {0x0523, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER EN WITH MIDDLE HOOK - {0x0524, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER PE WITH DESCENDER - {0x0525, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER PE WITH DESCENDER - {0x0526, 0x0530, propertyUNASSIGNED}, // .. - {0x0531, 0x0556, propertyDISALLOWED}, // ARMENIAN CAPITAL LETTER AYB..ARMENIAN CAPITA - {0x0557, 0x0558, propertyUNASSIGNED}, // .. - {0x0559, 0x0, propertyPVALID}, // ARMENIAN MODIFIER LETTER LEFT HALF RING - {0x055A, 0x055F, propertyDISALLOWED}, // ARMENIAN APOSTROPHE..ARMENIAN ABBREVIATION M - {0x0560, 0x0, propertyUNASSIGNED}, // - {0x0561, 0x0586, propertyPVALID}, // ARMENIAN SMALL LETTER AYB..ARMENIAN SMALL LE - {0x0587, 0x0, propertyDISALLOWED}, // ARMENIAN SMALL LIGATURE ECH YIWN - {0x0588, 0x0, propertyUNASSIGNED}, // - {0x0589, 0x058A, propertyDISALLOWED}, // ARMENIAN FULL STOP..ARMENIAN HYPHEN - {0x058B, 0x0590, propertyUNASSIGNED}, // .. - {0x0591, 0x05BD, propertyPVALID}, // HEBREW ACCENT ETNAHTA..HEBREW POINT METEG - {0x05BE, 0x0, propertyDISALLOWED}, // HEBREW PUNCTUATION MAQAF - {0x05BF, 0x0, propertyPVALID}, // HEBREW POINT RAFE - {0x05C0, 0x0, propertyDISALLOWED}, // HEBREW PUNCTUATION PASEQ - {0x05C1, 0x05C2, propertyPVALID}, // HEBREW POINT SHIN DOT..HEBREW POINT SIN DOT - {0x05C3, 0x0, propertyDISALLOWED}, // HEBREW PUNCTUATION SOF PASUQ - {0x05C4, 0x05C5, propertyPVALID}, // HEBREW MARK UPPER DOT..HEBREW MARK LOWER DOT - {0x05C6, 0x0, propertyDISALLOWED}, // HEBREW PUNCTUATION NUN HAFUKHA - {0x05C7, 0x0, propertyPVALID}, // HEBREW POINT QAMATS QATAN - {0x05C8, 0x05CF, propertyUNASSIGNED}, // .. - {0x05D0, 0x05EA, propertyPVALID}, // HEBREW LETTER ALEF..HEBREW LETTER TAV - {0x05EB, 0x05EF, propertyUNASSIGNED}, // .. - {0x05F0, 0x05F2, propertyPVALID}, // HEBREW LIGATURE YIDDISH DOUBLE VAV..HEBREW L - {0x05F3, 0x05F4, propertyCONTEXTO}, // HEBREW PUNCTUATION GERESH..HEBREW PUNCTUATIO - {0x05F5, 0x05FF, propertyUNASSIGNED}, // .. - {0x0600, 0x0603, propertyDISALLOWED}, // ARABIC NUMBER SIGN..ARABIC SIGN SAFHA - {0x0604, 0x0605, propertyUNASSIGNED}, // .. - {0x0606, 0x060F, propertyDISALLOWED}, // ARABIC-INDIC CUBE ROOT..ARABIC SIGN MISRA - {0x0610, 0x061A, propertyPVALID}, // ARABIC SIGN SALLALLAHOU ALAYHE WASSALLAM..AR - {0x061B, 0x0, propertyDISALLOWED}, // ARABIC SEMICOLON - {0x061C, 0x061D, propertyUNASSIGNED}, // .. - {0x061E, 0x061F, propertyDISALLOWED}, // ARABIC TRIPLE DOT PUNCTUATION MARK..ARABIC Q - {0x0620, 0x0, propertyUNASSIGNED}, // - {0x0621, 0x063F, propertyPVALID}, // ARABIC LETTER HAMZA..ARABIC LETTER FARSI YEH - {0x0640, 0x0, propertyDISALLOWED}, // ARABIC TATWEEL - {0x0641, 0x065E, propertyPVALID}, // ARABIC LETTER FEH..ARABIC FATHA WITH TWO DOT - {0x065F, 0x0, propertyUNASSIGNED}, // - {0x0660, 0x0669, propertyCONTEXTO}, // ARABIC-INDIC DIGIT ZERO..ARABIC-INDIC DIGIT - {0x066A, 0x066D, propertyDISALLOWED}, // ARABIC PERCENT SIGN..ARABIC FIVE POINTED STA - {0x066E, 0x0674, propertyPVALID}, // ARABIC LETTER DOTLESS BEH..ARABIC LETTER HIG - {0x0675, 0x0678, propertyDISALLOWED}, // ARABIC LETTER HIGH HAMZA ALEF..ARABIC LETTER - {0x0679, 0x06D3, propertyPVALID}, // ARABIC LETTER TTEH..ARABIC LETTER YEH BARREE - {0x06D4, 0x0, propertyDISALLOWED}, // ARABIC FULL STOP - {0x06D5, 0x06DC, propertyPVALID}, // ARABIC LETTER AE..ARABIC SMALL HIGH SEEN - {0x06DD, 0x06DE, propertyDISALLOWED}, // ARABIC END OF AYAH..ARABIC START OF RUB EL H - {0x06DF, 0x06E8, propertyPVALID}, // ARABIC SMALL HIGH ROUNDED ZERO..ARABIC SMALL - {0x06E9, 0x0, propertyDISALLOWED}, // ARABIC PLACE OF SAJDAH - {0x06EA, 0x06EF, propertyPVALID}, // ARABIC EMPTY CENTRE LOW STOP..ARABIC LETTER - {0x06F0, 0x06F9, propertyCONTEXTO}, // EXTENDED ARABIC-INDIC DIGIT ZERO..EXTENDED A - {0x06FA, 0x06FF, propertyPVALID}, // ARABIC LETTER SHEEN WITH DOT BELOW..ARABIC L - {0x0700, 0x070D, propertyDISALLOWED}, // SYRIAC END OF PARAGRAPH..SYRIAC HARKLEAN AST - {0x070E, 0x0, propertyUNASSIGNED}, // - {0x070F, 0x0, propertyDISALLOWED}, // SYRIAC ABBREVIATION MARK - {0x0710, 0x074A, propertyPVALID}, // SYRIAC LETTER ALAPH..SYRIAC BARREKH - {0x074B, 0x074C, propertyUNASSIGNED}, // .. - {0x074D, 0x07B1, propertyPVALID}, // SYRIAC LETTER SOGDIAN ZHAIN..THAANA LETTER N - {0x07B2, 0x07BF, propertyUNASSIGNED}, // .. - {0x07C0, 0x07F5, propertyPVALID}, // NKO DIGIT ZERO..NKO LOW TONE APOSTROPHE - {0x07F6, 0x07FA, propertyDISALLOWED}, // NKO SYMBOL OO DENNEN..NKO LAJANYALAN - {0x07FB, 0x07FF, propertyUNASSIGNED}, // .. - {0x0800, 0x082D, propertyPVALID}, // SAMARITAN LETTER ALAF..SAMARITAN MARK NEQUDA - {0x082E, 0x082F, propertyUNASSIGNED}, // .. - {0x0830, 0x083E, propertyDISALLOWED}, // SAMARITAN PUNCTUATION NEQUDAA..SAMARITAN PUN - {0x083F, 0x08FF, propertyUNASSIGNED}, // .. - {0x0900, 0x0939, propertyPVALID}, // DEVANAGARI SIGN INVERTED CANDRABINDU..DEVANA - {0x093A, 0x093B, propertyUNASSIGNED}, // .. - {0x093C, 0x094E, propertyPVALID}, // DEVANAGARI SIGN NUKTA..DEVANAGARI VOWEL SIGN - {0x094F, 0x0, propertyUNASSIGNED}, // - {0x0950, 0x0955, propertyPVALID}, // DEVANAGARI OM..DEVANAGARI VOWEL SIGN CANDRA - {0x0956, 0x0957, propertyUNASSIGNED}, // .. - {0x0958, 0x095F, propertyDISALLOWED}, // DEVANAGARI LETTER QA..DEVANAGARI LETTER YYA - {0x0960, 0x0963, propertyPVALID}, // DEVANAGARI LETTER VOCALIC RR..DEVANAGARI VOW - {0x0964, 0x0965, propertyDISALLOWED}, // DEVANAGARI DANDA..DEVANAGARI DOUBLE DANDA - {0x0966, 0x096F, propertyPVALID}, // DEVANAGARI DIGIT ZERO..DEVANAGARI DIGIT NINE - {0x0970, 0x0, propertyDISALLOWED}, // DEVANAGARI ABBREVIATION SIGN - {0x0971, 0x0972, propertyPVALID}, // DEVANAGARI SIGN HIGH SPACING DOT..DEVANAGARI - {0x0973, 0x0978, propertyUNASSIGNED}, // .. - {0x0979, 0x097F, propertyPVALID}, // DEVANAGARI LETTER ZHA..DEVANAGARI LETTER BBA - {0x0980, 0x0, propertyUNASSIGNED}, // - {0x0981, 0x0983, propertyPVALID}, // BENGALI SIGN CANDRABINDU..BENGALI SIGN VISAR - {0x0984, 0x0, propertyUNASSIGNED}, // - {0x0985, 0x098C, propertyPVALID}, // BENGALI LETTER A..BENGALI LETTER VOCALIC L - {0x098D, 0x098E, propertyUNASSIGNED}, // .. - {0x098F, 0x0990, propertyPVALID}, // BENGALI LETTER E..BENGALI LETTER AI - {0x0991, 0x0992, propertyUNASSIGNED}, // .. - {0x0993, 0x09A8, propertyPVALID}, // BENGALI LETTER O..BENGALI LETTER NA - {0x09A9, 0x0, propertyUNASSIGNED}, // - {0x09AA, 0x09B0, propertyPVALID}, // BENGALI LETTER PA..BENGALI LETTER RA - {0x09B1, 0x0, propertyUNASSIGNED}, // - {0x09B2, 0x0, propertyPVALID}, // BENGALI LETTER LA - {0x09B3, 0x09B5, propertyUNASSIGNED}, // .. - {0x09B6, 0x09B9, propertyPVALID}, // BENGALI LETTER SHA..BENGALI LETTER HA - {0x09BA, 0x09BB, propertyUNASSIGNED}, // .. - {0x09BC, 0x09C4, propertyPVALID}, // BENGALI SIGN NUKTA..BENGALI VOWEL SIGN VOCAL - {0x09C5, 0x09C6, propertyUNASSIGNED}, // .. - {0x09C7, 0x09C8, propertyPVALID}, // BENGALI VOWEL SIGN E..BENGALI VOWEL SIGN AI - {0x09C9, 0x09CA, propertyUNASSIGNED}, // .. - {0x09CB, 0x09CE, propertyPVALID}, // BENGALI VOWEL SIGN O..BENGALI LETTER KHANDA - {0x09CF, 0x09D6, propertyUNASSIGNED}, // .. - {0x09D7, 0x0, propertyPVALID}, // BENGALI AU LENGTH MARK - {0x09D8, 0x09DB, propertyUNASSIGNED}, // .. - {0x09DC, 0x09DD, propertyDISALLOWED}, // BENGALI LETTER RRA..BENGALI LETTER RHA - {0x09DE, 0x0, propertyUNASSIGNED}, // - {0x09DF, 0x0, propertyDISALLOWED}, // BENGALI LETTER YYA - {0x09E0, 0x09E3, propertyPVALID}, // BENGALI LETTER VOCALIC RR..BENGALI VOWEL SIG - {0x09E4, 0x09E5, propertyUNASSIGNED}, // .. - {0x09E6, 0x09F1, propertyPVALID}, // BENGALI DIGIT ZERO..BENGALI LETTER RA WITH L - {0x09F2, 0x09FB, propertyDISALLOWED}, // BENGALI RUPEE MARK..BENGALI GANDA MARK - {0x09FC, 0x0A00, propertyUNASSIGNED}, // .. - {0x0A01, 0x0A03, propertyPVALID}, // GURMUKHI SIGN ADAK BINDI..GURMUKHI SIGN VISA - {0x0A04, 0x0, propertyUNASSIGNED}, // - {0x0A05, 0x0A0A, propertyPVALID}, // GURMUKHI LETTER A..GURMUKHI LETTER UU - {0x0A0B, 0x0A0E, propertyUNASSIGNED}, // .. - {0x0A0F, 0x0A10, propertyPVALID}, // GURMUKHI LETTER EE..GURMUKHI LETTER AI - {0x0A11, 0x0A12, propertyUNASSIGNED}, // .. - {0x0A13, 0x0A28, propertyPVALID}, // GURMUKHI LETTER OO..GURMUKHI LETTER NA - {0x0A29, 0x0, propertyUNASSIGNED}, // - {0x0A2A, 0x0A30, propertyPVALID}, // GURMUKHI LETTER PA..GURMUKHI LETTER RA - {0x0A31, 0x0, propertyUNASSIGNED}, // - {0x0A32, 0x0, propertyPVALID}, // GURMUKHI LETTER LA - {0x0A33, 0x0, propertyDISALLOWED}, // GURMUKHI LETTER LLA - {0x0A34, 0x0, propertyUNASSIGNED}, // - {0x0A35, 0x0, propertyPVALID}, // GURMUKHI LETTER VA - {0x0A36, 0x0, propertyDISALLOWED}, // GURMUKHI LETTER SHA - {0x0A37, 0x0, propertyUNASSIGNED}, // - {0x0A38, 0x0A39, propertyPVALID}, // GURMUKHI LETTER SA..GURMUKHI LETTER HA - {0x0A3A, 0x0A3B, propertyUNASSIGNED}, // .. - {0x0A3C, 0x0, propertyPVALID}, // GURMUKHI SIGN NUKTA - {0x0A3D, 0x0, propertyUNASSIGNED}, // - {0x0A3E, 0x0A42, propertyPVALID}, // GURMUKHI VOWEL SIGN AA..GURMUKHI VOWEL SIGN - {0x0A43, 0x0A46, propertyUNASSIGNED}, // .. - {0x0A47, 0x0A48, propertyPVALID}, // GURMUKHI VOWEL SIGN EE..GURMUKHI VOWEL SIGN - {0x0A49, 0x0A4A, propertyUNASSIGNED}, // .. - {0x0A4B, 0x0A4D, propertyPVALID}, // GURMUKHI VOWEL SIGN OO..GURMUKHI SIGN VIRAMA - {0x0A4E, 0x0A50, propertyUNASSIGNED}, // .. - {0x0A51, 0x0, propertyPVALID}, // GURMUKHI SIGN UDAAT - {0x0A52, 0x0A58, propertyUNASSIGNED}, // .. - {0x0A59, 0x0A5B, propertyDISALLOWED}, // GURMUKHI LETTER KHHA..GURMUKHI LETTER ZA - {0x0A5C, 0x0, propertyPVALID}, // GURMUKHI LETTER RRA - {0x0A5D, 0x0, propertyUNASSIGNED}, // - {0x0A5E, 0x0, propertyDISALLOWED}, // GURMUKHI LETTER FA - {0x0A5F, 0x0A65, propertyUNASSIGNED}, // .. - {0x0A66, 0x0A75, propertyPVALID}, // GURMUKHI DIGIT ZERO..GURMUKHI SIGN YAKASH - {0x0A76, 0x0A80, propertyUNASSIGNED}, // .. - {0x0A81, 0x0A83, propertyPVALID}, // GUJARATI SIGN CANDRABINDU..GUJARATI SIGN VIS - {0x0A84, 0x0, propertyUNASSIGNED}, // - {0x0A85, 0x0A8D, propertyPVALID}, // GUJARATI LETTER A..GUJARATI VOWEL CANDRA E - {0x0A8E, 0x0, propertyUNASSIGNED}, // - {0x0A8F, 0x0A91, propertyPVALID}, // GUJARATI LETTER E..GUJARATI VOWEL CANDRA O - {0x0A92, 0x0, propertyUNASSIGNED}, // - {0x0A93, 0x0AA8, propertyPVALID}, // GUJARATI LETTER O..GUJARATI LETTER NA - {0x0AA9, 0x0, propertyUNASSIGNED}, // - {0x0AAA, 0x0AB0, propertyPVALID}, // GUJARATI LETTER PA..GUJARATI LETTER RA - {0x0AB1, 0x0, propertyUNASSIGNED}, // - {0x0AB2, 0x0AB3, propertyPVALID}, // GUJARATI LETTER LA..GUJARATI LETTER LLA - {0x0AB4, 0x0, propertyUNASSIGNED}, // - {0x0AB5, 0x0AB9, propertyPVALID}, // GUJARATI LETTER VA..GUJARATI LETTER HA - {0x0ABA, 0x0ABB, propertyUNASSIGNED}, // .. - {0x0ABC, 0x0AC5, propertyPVALID}, // GUJARATI SIGN NUKTA..GUJARATI VOWEL SIGN CAN - {0x0AC6, 0x0, propertyUNASSIGNED}, // - {0x0AC7, 0x0AC9, propertyPVALID}, // GUJARATI VOWEL SIGN E..GUJARATI VOWEL SIGN C - {0x0ACA, 0x0, propertyUNASSIGNED}, // - {0x0ACB, 0x0ACD, propertyPVALID}, // GUJARATI VOWEL SIGN O..GUJARATI SIGN VIRAMA - {0x0ACE, 0x0ACF, propertyUNASSIGNED}, // .. - {0x0AD0, 0x0, propertyPVALID}, // GUJARATI OM - {0x0AD1, 0x0ADF, propertyUNASSIGNED}, // .. - {0x0AE0, 0x0AE3, propertyPVALID}, // GUJARATI LETTER VOCALIC RR..GUJARATI VOWEL S - {0x0AE4, 0x0AE5, propertyUNASSIGNED}, // .. - {0x0AE6, 0x0AEF, propertyPVALID}, // GUJARATI DIGIT ZERO..GUJARATI DIGIT NINE - {0x0AF0, 0x0, propertyUNASSIGNED}, // - {0x0AF1, 0x0, propertyDISALLOWED}, // GUJARATI RUPEE SIGN - {0x0AF2, 0x0B00, propertyUNASSIGNED}, // .. - {0x0B01, 0x0B03, propertyPVALID}, // ORIYA SIGN CANDRABINDU..ORIYA SIGN VISARGA - {0x0B04, 0x0, propertyUNASSIGNED}, // - {0x0B05, 0x0B0C, propertyPVALID}, // ORIYA LETTER A..ORIYA LETTER VOCALIC L - {0x0B0D, 0x0B0E, propertyUNASSIGNED}, // .. - {0x0B0F, 0x0B10, propertyPVALID}, // ORIYA LETTER E..ORIYA LETTER AI - {0x0B11, 0x0B12, propertyUNASSIGNED}, // .. - {0x0B13, 0x0B28, propertyPVALID}, // ORIYA LETTER O..ORIYA LETTER NA - {0x0B29, 0x0, propertyUNASSIGNED}, // - {0x0B2A, 0x0B30, propertyPVALID}, // ORIYA LETTER PA..ORIYA LETTER RA - {0x0B31, 0x0, propertyUNASSIGNED}, // - {0x0B32, 0x0B33, propertyPVALID}, // ORIYA LETTER LA..ORIYA LETTER LLA - {0x0B34, 0x0, propertyUNASSIGNED}, // - {0x0B35, 0x0B39, propertyPVALID}, // ORIYA LETTER VA..ORIYA LETTER HA - {0x0B3A, 0x0B3B, propertyUNASSIGNED}, // .. - {0x0B3C, 0x0B44, propertyPVALID}, // ORIYA SIGN NUKTA..ORIYA VOWEL SIGN VOCALIC R - {0x0B45, 0x0B46, propertyUNASSIGNED}, // .. - {0x0B47, 0x0B48, propertyPVALID}, // ORIYA VOWEL SIGN E..ORIYA VOWEL SIGN AI - {0x0B49, 0x0B4A, propertyUNASSIGNED}, // .. - {0x0B4B, 0x0B4D, propertyPVALID}, // ORIYA VOWEL SIGN O..ORIYA SIGN VIRAMA - {0x0B4E, 0x0B55, propertyUNASSIGNED}, // .. - {0x0B56, 0x0B57, propertyPVALID}, // ORIYA AI LENGTH MARK..ORIYA AU LENGTH MARK - {0x0B58, 0x0B5B, propertyUNASSIGNED}, // .. - {0x0B5C, 0x0B5D, propertyDISALLOWED}, // ORIYA LETTER RRA..ORIYA LETTER RHA - {0x0B5E, 0x0, propertyUNASSIGNED}, // - {0x0B5F, 0x0B63, propertyPVALID}, // ORIYA LETTER YYA..ORIYA VOWEL SIGN VOCALIC L - {0x0B64, 0x0B65, propertyUNASSIGNED}, // .. - {0x0B66, 0x0B6F, propertyPVALID}, // ORIYA DIGIT ZERO..ORIYA DIGIT NINE - {0x0B70, 0x0, propertyDISALLOWED}, // ORIYA ISSHAR - {0x0B71, 0x0, propertyPVALID}, // ORIYA LETTER WA - {0x0B72, 0x0B81, propertyUNASSIGNED}, // .. - {0x0B82, 0x0B83, propertyPVALID}, // TAMIL SIGN ANUSVARA..TAMIL SIGN VISARGA - {0x0B84, 0x0, propertyUNASSIGNED}, // - {0x0B85, 0x0B8A, propertyPVALID}, // TAMIL LETTER A..TAMIL LETTER UU - {0x0B8B, 0x0B8D, propertyUNASSIGNED}, // .. - {0x0B8E, 0x0B90, propertyPVALID}, // TAMIL LETTER E..TAMIL LETTER AI - {0x0B91, 0x0, propertyUNASSIGNED}, // - {0x0B92, 0x0B95, propertyPVALID}, // TAMIL LETTER O..TAMIL LETTER KA - {0x0B96, 0x0B98, propertyUNASSIGNED}, // .. - {0x0B99, 0x0B9A, propertyPVALID}, // TAMIL LETTER NGA..TAMIL LETTER CA - {0x0B9B, 0x0, propertyUNASSIGNED}, // - {0x0B9C, 0x0, propertyPVALID}, // TAMIL LETTER JA - {0x0B9D, 0x0, propertyUNASSIGNED}, // - {0x0B9E, 0x0B9F, propertyPVALID}, // TAMIL LETTER NYA..TAMIL LETTER TTA - {0x0BA0, 0x0BA2, propertyUNASSIGNED}, // .. - {0x0BA3, 0x0BA4, propertyPVALID}, // TAMIL LETTER NNA..TAMIL LETTER TA - {0x0BA5, 0x0BA7, propertyUNASSIGNED}, // .. - {0x0BA8, 0x0BAA, propertyPVALID}, // TAMIL LETTER NA..TAMIL LETTER PA - {0x0BAB, 0x0BAD, propertyUNASSIGNED}, // .. - {0x0BAE, 0x0BB9, propertyPVALID}, // TAMIL LETTER MA..TAMIL LETTER HA - {0x0BBA, 0x0BBD, propertyUNASSIGNED}, // .. - {0x0BBE, 0x0BC2, propertyPVALID}, // TAMIL VOWEL SIGN AA..TAMIL VOWEL SIGN UU - {0x0BC3, 0x0BC5, propertyUNASSIGNED}, // .. - {0x0BC6, 0x0BC8, propertyPVALID}, // TAMIL VOWEL SIGN E..TAMIL VOWEL SIGN AI - {0x0BC9, 0x0, propertyUNASSIGNED}, // - {0x0BCA, 0x0BCD, propertyPVALID}, // TAMIL VOWEL SIGN O..TAMIL SIGN VIRAMA - {0x0BCE, 0x0BCF, propertyUNASSIGNED}, // .. - {0x0BD0, 0x0, propertyPVALID}, // TAMIL OM - {0x0BD1, 0x0BD6, propertyUNASSIGNED}, // .. - {0x0BD7, 0x0, propertyPVALID}, // TAMIL AU LENGTH MARK - {0x0BD8, 0x0BE5, propertyUNASSIGNED}, // .. - {0x0BE6, 0x0BEF, propertyPVALID}, // TAMIL DIGIT ZERO..TAMIL DIGIT NINE - {0x0BF0, 0x0BFA, propertyDISALLOWED}, // TAMIL NUMBER TEN..TAMIL NUMBER SIGN - {0x0BFB, 0x0C00, propertyUNASSIGNED}, // .. - {0x0C01, 0x0C03, propertyPVALID}, // TELUGU SIGN CANDRABINDU..TELUGU SIGN VISARGA - {0x0C04, 0x0, propertyUNASSIGNED}, // - {0x0C05, 0x0C0C, propertyPVALID}, // TELUGU LETTER A..TELUGU LETTER VOCALIC L - {0x0C0D, 0x0, propertyUNASSIGNED}, // - {0x0C0E, 0x0C10, propertyPVALID}, // TELUGU LETTER E..TELUGU LETTER AI - {0x0C11, 0x0, propertyUNASSIGNED}, // - {0x0C12, 0x0C28, propertyPVALID}, // TELUGU LETTER O..TELUGU LETTER NA - {0x0C29, 0x0, propertyUNASSIGNED}, // - {0x0C2A, 0x0C33, propertyPVALID}, // TELUGU LETTER PA..TELUGU LETTER LLA - {0x0C34, 0x0, propertyUNASSIGNED}, // - {0x0C35, 0x0C39, propertyPVALID}, // TELUGU LETTER VA..TELUGU LETTER HA - {0x0C3A, 0x0C3C, propertyUNASSIGNED}, // .. - {0x0C3D, 0x0C44, propertyPVALID}, // TELUGU SIGN AVAGRAHA..TELUGU VOWEL SIGN VOCA - {0x0C45, 0x0, propertyUNASSIGNED}, // - {0x0C46, 0x0C48, propertyPVALID}, // TELUGU VOWEL SIGN E..TELUGU VOWEL SIGN AI - {0x0C49, 0x0, propertyUNASSIGNED}, // - {0x0C4A, 0x0C4D, propertyPVALID}, // TELUGU VOWEL SIGN O..TELUGU SIGN VIRAMA - {0x0C4E, 0x0C54, propertyUNASSIGNED}, // .. - {0x0C55, 0x0C56, propertyPVALID}, // TELUGU LENGTH MARK..TELUGU AI LENGTH MARK - {0x0C57, 0x0, propertyUNASSIGNED}, // - {0x0C58, 0x0C59, propertyPVALID}, // TELUGU LETTER TSA..TELUGU LETTER DZA - {0x0C5A, 0x0C5F, propertyUNASSIGNED}, // .. - {0x0C60, 0x0C63, propertyPVALID}, // TELUGU LETTER VOCALIC RR..TELUGU VOWEL SIGN - {0x0C64, 0x0C65, propertyUNASSIGNED}, // .. - {0x0C66, 0x0C6F, propertyPVALID}, // TELUGU DIGIT ZERO..TELUGU DIGIT NINE - {0x0C70, 0x0C77, propertyUNASSIGNED}, // .. - {0x0C78, 0x0C7F, propertyDISALLOWED}, // TELUGU FRACTION DIGIT ZERO FOR ODD POWERS OF - {0x0C80, 0x0C81, propertyUNASSIGNED}, // .. - {0x0C82, 0x0C83, propertyPVALID}, // KANNADA SIGN ANUSVARA..KANNADA SIGN VISARGA - {0x0C84, 0x0, propertyUNASSIGNED}, // - {0x0C85, 0x0C8C, propertyPVALID}, // KANNADA LETTER A..KANNADA LETTER VOCALIC L - {0x0C8D, 0x0, propertyUNASSIGNED}, // - {0x0C8E, 0x0C90, propertyPVALID}, // KANNADA LETTER E..KANNADA LETTER AI - {0x0C91, 0x0, propertyUNASSIGNED}, // - {0x0C92, 0x0CA8, propertyPVALID}, // KANNADA LETTER O..KANNADA LETTER NA - {0x0CA9, 0x0, propertyUNASSIGNED}, // - {0x0CAA, 0x0CB3, propertyPVALID}, // KANNADA LETTER PA..KANNADA LETTER LLA - {0x0CB4, 0x0, propertyUNASSIGNED}, // - {0x0CB5, 0x0CB9, propertyPVALID}, // KANNADA LETTER VA..KANNADA LETTER HA - {0x0CBA, 0x0CBB, propertyUNASSIGNED}, // .. - {0x0CBC, 0x0CC4, propertyPVALID}, // KANNADA SIGN NUKTA..KANNADA VOWEL SIGN VOCAL - {0x0CC5, 0x0, propertyUNASSIGNED}, // - {0x0CC6, 0x0CC8, propertyPVALID}, // KANNADA VOWEL SIGN E..KANNADA VOWEL SIGN AI - {0x0CC9, 0x0, propertyUNASSIGNED}, // - {0x0CCA, 0x0CCD, propertyPVALID}, // KANNADA VOWEL SIGN O..KANNADA SIGN VIRAMA - {0x0CCE, 0x0CD4, propertyUNASSIGNED}, // .. - {0x0CD5, 0x0CD6, propertyPVALID}, // KANNADA LENGTH MARK..KANNADA AI LENGTH MARK - {0x0CD7, 0x0CDD, propertyUNASSIGNED}, // .. - {0x0CDE, 0x0, propertyPVALID}, // KANNADA LETTER FA - {0x0CDF, 0x0, propertyUNASSIGNED}, // - {0x0CE0, 0x0CE3, propertyPVALID}, // KANNADA LETTER VOCALIC RR..KANNADA VOWEL SIG - {0x0CE4, 0x0CE5, propertyUNASSIGNED}, // .. - {0x0CE6, 0x0CEF, propertyPVALID}, // KANNADA DIGIT ZERO..KANNADA DIGIT NINE - {0x0CF0, 0x0, propertyUNASSIGNED}, // - {0x0CF1, 0x0CF2, propertyDISALLOWED}, // KANNADA SIGN JIHVAMULIYA..KANNADA SIGN UPADH - {0x0CF3, 0x0D01, propertyUNASSIGNED}, // .. - {0x0D02, 0x0D03, propertyPVALID}, // MALAYALAM SIGN ANUSVARA..MALAYALAM SIGN VISA - {0x0D04, 0x0, propertyUNASSIGNED}, // - {0x0D05, 0x0D0C, propertyPVALID}, // MALAYALAM LETTER A..MALAYALAM LETTER VOCALIC - {0x0D0D, 0x0, propertyUNASSIGNED}, // - {0x0D0E, 0x0D10, propertyPVALID}, // MALAYALAM LETTER E..MALAYALAM LETTER AI - {0x0D11, 0x0, propertyUNASSIGNED}, // - {0x0D12, 0x0D28, propertyPVALID}, // MALAYALAM LETTER O..MALAYALAM LETTER NA - {0x0D29, 0x0, propertyUNASSIGNED}, // - {0x0D2A, 0x0D39, propertyPVALID}, // MALAYALAM LETTER PA..MALAYALAM LETTER HA - {0x0D3A, 0x0D3C, propertyUNASSIGNED}, // .. - {0x0D3D, 0x0D44, propertyPVALID}, // MALAYALAM SIGN AVAGRAHA..MALAYALAM VOWEL SIG - {0x0D45, 0x0, propertyUNASSIGNED}, // - {0x0D46, 0x0D48, propertyPVALID}, // MALAYALAM VOWEL SIGN E..MALAYALAM VOWEL SIGN - {0x0D49, 0x0, propertyUNASSIGNED}, // - {0x0D4A, 0x0D4D, propertyPVALID}, // MALAYALAM VOWEL SIGN O..MALAYALAM SIGN VIRAM - {0x0D4E, 0x0D56, propertyUNASSIGNED}, // .. - {0x0D57, 0x0, propertyPVALID}, // MALAYALAM AU LENGTH MARK - {0x0D58, 0x0D5F, propertyUNASSIGNED}, // .. - {0x0D60, 0x0D63, propertyPVALID}, // MALAYALAM LETTER VOCALIC RR..MALAYALAM VOWEL - {0x0D64, 0x0D65, propertyUNASSIGNED}, // .. - {0x0D66, 0x0D6F, propertyPVALID}, // MALAYALAM DIGIT ZERO..MALAYALAM DIGIT NINE - {0x0D70, 0x0D75, propertyDISALLOWED}, // MALAYALAM NUMBER TEN..MALAYALAM FRACTION THR - {0x0D76, 0x0D78, propertyUNASSIGNED}, // .. - {0x0D79, 0x0, propertyDISALLOWED}, // MALAYALAM DATE MARK - {0x0D7A, 0x0D7F, propertyPVALID}, // MALAYALAM LETTER CHILLU NN..MALAYALAM LETTER - {0x0D80, 0x0D81, propertyUNASSIGNED}, // .. - {0x0D82, 0x0D83, propertyPVALID}, // SINHALA SIGN ANUSVARAYA..SINHALA SIGN VISARG - {0x0D84, 0x0, propertyUNASSIGNED}, // - {0x0D85, 0x0D96, propertyPVALID}, // SINHALA LETTER AYANNA..SINHALA LETTER AUYANN - {0x0D97, 0x0D99, propertyUNASSIGNED}, // .. - {0x0D9A, 0x0DB1, propertyPVALID}, // SINHALA LETTER ALPAPRAANA KAYANNA..SINHALA L - {0x0DB2, 0x0, propertyUNASSIGNED}, // - {0x0DB3, 0x0DBB, propertyPVALID}, // SINHALA LETTER SANYAKA DAYANNA..SINHALA LETT - {0x0DBC, 0x0, propertyUNASSIGNED}, // - {0x0DBD, 0x0, propertyPVALID}, // SINHALA LETTER DANTAJA LAYANNA - {0x0DBE, 0x0DBF, propertyUNASSIGNED}, // .. - {0x0DC0, 0x0DC6, propertyPVALID}, // SINHALA LETTER VAYANNA..SINHALA LETTER FAYAN - {0x0DC7, 0x0DC9, propertyUNASSIGNED}, // .. - {0x0DCA, 0x0, propertyPVALID}, // SINHALA SIGN AL-LAKUNA - {0x0DCB, 0x0DCE, propertyUNASSIGNED}, // .. - {0x0DCF, 0x0DD4, propertyPVALID}, // SINHALA VOWEL SIGN AELA-PILLA..SINHALA VOWEL - {0x0DD5, 0x0, propertyUNASSIGNED}, // - {0x0DD6, 0x0, propertyPVALID}, // SINHALA VOWEL SIGN DIGA PAA-PILLA - {0x0DD7, 0x0, propertyUNASSIGNED}, // - {0x0DD8, 0x0DDF, propertyPVALID}, // SINHALA VOWEL SIGN GAETTA-PILLA..SINHALA VOW - {0x0DE0, 0x0DF1, propertyUNASSIGNED}, // .. - {0x0DF2, 0x0DF3, propertyPVALID}, // SINHALA VOWEL SIGN DIGA GAETTA-PILLA..SINHAL - {0x0DF4, 0x0, propertyDISALLOWED}, // SINHALA PUNCTUATION KUNDDALIYA - {0x0DF5, 0x0E00, propertyUNASSIGNED}, // .. - {0x0E01, 0x0E32, propertyPVALID}, // THAI CHARACTER KO KAI..THAI CHARACTER SARA A - {0x0E33, 0x0, propertyDISALLOWED}, // THAI CHARACTER SARA AM - {0x0E34, 0x0E3A, propertyPVALID}, // THAI CHARACTER SARA I..THAI CHARACTER PHINTH - {0x0E3B, 0x0E3E, propertyUNASSIGNED}, // .. - {0x0E3F, 0x0, propertyDISALLOWED}, // THAI CURRENCY SYMBOL BAHT - {0x0E40, 0x0E4E, propertyPVALID}, // THAI CHARACTER SARA E..THAI CHARACTER YAMAKK - {0x0E4F, 0x0, propertyDISALLOWED}, // THAI CHARACTER FONGMAN - {0x0E50, 0x0E59, propertyPVALID}, // THAI DIGIT ZERO..THAI DIGIT NINE - {0x0E5A, 0x0E5B, propertyDISALLOWED}, // THAI CHARACTER ANGKHANKHU..THAI CHARACTER KH - {0x0E5C, 0x0E80, propertyUNASSIGNED}, // .. - {0x0E81, 0x0E82, propertyPVALID}, // LAO LETTER KO..LAO LETTER KHO SUNG - {0x0E83, 0x0, propertyUNASSIGNED}, // - {0x0E84, 0x0, propertyPVALID}, // LAO LETTER KHO TAM - {0x0E85, 0x0E86, propertyUNASSIGNED}, // .. - {0x0E87, 0x0E88, propertyPVALID}, // LAO LETTER NGO..LAO LETTER CO - {0x0E89, 0x0, propertyUNASSIGNED}, // - {0x0E8A, 0x0, propertyPVALID}, // LAO LETTER SO TAM - {0x0E8B, 0x0E8C, propertyUNASSIGNED}, // .. - {0x0E8D, 0x0, propertyPVALID}, // LAO LETTER NYO - {0x0E8E, 0x0E93, propertyUNASSIGNED}, // .. - {0x0E94, 0x0E97, propertyPVALID}, // LAO LETTER DO..LAO LETTER THO TAM - {0x0E98, 0x0, propertyUNASSIGNED}, // - {0x0E99, 0x0E9F, propertyPVALID}, // LAO LETTER NO..LAO LETTER FO SUNG - {0x0EA0, 0x0, propertyUNASSIGNED}, // - {0x0EA1, 0x0EA3, propertyPVALID}, // LAO LETTER MO..LAO LETTER LO LING - {0x0EA4, 0x0, propertyUNASSIGNED}, // - {0x0EA5, 0x0, propertyPVALID}, // LAO LETTER LO LOOT - {0x0EA6, 0x0, propertyUNASSIGNED}, // - {0x0EA7, 0x0, propertyPVALID}, // LAO LETTER WO - {0x0EA8, 0x0EA9, propertyUNASSIGNED}, // .. - {0x0EAA, 0x0EAB, propertyPVALID}, // LAO LETTER SO SUNG..LAO LETTER HO SUNG - {0x0EAC, 0x0, propertyUNASSIGNED}, // - {0x0EAD, 0x0EB2, propertyPVALID}, // LAO LETTER O..LAO VOWEL SIGN AA - {0x0EB3, 0x0, propertyDISALLOWED}, // LAO VOWEL SIGN AM - {0x0EB4, 0x0EB9, propertyPVALID}, // LAO VOWEL SIGN I..LAO VOWEL SIGN UU - {0x0EBA, 0x0, propertyUNASSIGNED}, // - {0x0EBB, 0x0EBD, propertyPVALID}, // LAO VOWEL SIGN MAI KON..LAO SEMIVOWEL SIGN N - {0x0EBE, 0x0EBF, propertyUNASSIGNED}, // .. - {0x0EC0, 0x0EC4, propertyPVALID}, // LAO VOWEL SIGN E..LAO VOWEL SIGN AI - {0x0EC5, 0x0, propertyUNASSIGNED}, // - {0x0EC6, 0x0, propertyPVALID}, // LAO KO LA - {0x0EC7, 0x0, propertyUNASSIGNED}, // - {0x0EC8, 0x0ECD, propertyPVALID}, // LAO TONE MAI EK..LAO NIGGAHITA - {0x0ECE, 0x0ECF, propertyUNASSIGNED}, // .. - {0x0ED0, 0x0ED9, propertyPVALID}, // LAO DIGIT ZERO..LAO DIGIT NINE - {0x0EDA, 0x0EDB, propertyUNASSIGNED}, // .. - {0x0EDC, 0x0EDD, propertyDISALLOWED}, // LAO HO NO..LAO HO MO - {0x0EDE, 0x0EFF, propertyUNASSIGNED}, // .. - {0x0F00, 0x0, propertyPVALID}, // TIBETAN SYLLABLE OM - {0x0F01, 0x0F0A, propertyDISALLOWED}, // TIBETAN MARK GTER YIG MGO TRUNCATED A..TIBET - {0x0F0B, 0x0, propertyPVALID}, // TIBETAN MARK INTERSYLLABIC TSHEG - {0x0F0C, 0x0F17, propertyDISALLOWED}, // TIBETAN MARK DELIMITER TSHEG BSTAR..TIBETAN - {0x0F18, 0x0F19, propertyPVALID}, // TIBETAN ASTROLOGICAL SIGN -KHYUD PA..TIBETAN - {0x0F1A, 0x0F1F, propertyDISALLOWED}, // TIBETAN SIGN RDEL DKAR GCIG..TIBETAN SIGN RD - {0x0F20, 0x0F29, propertyPVALID}, // TIBETAN DIGIT ZERO..TIBETAN DIGIT NINE - {0x0F2A, 0x0F34, propertyDISALLOWED}, // TIBETAN DIGIT HALF ONE..TIBETAN MARK BSDUS R - {0x0F35, 0x0, propertyPVALID}, // TIBETAN MARK NGAS BZUNG NYI ZLA - {0x0F36, 0x0, propertyDISALLOWED}, // TIBETAN MARK CARET -DZUD RTAGS BZHI MIG CAN - {0x0F37, 0x0, propertyPVALID}, // TIBETAN MARK NGAS BZUNG SGOR RTAGS - {0x0F38, 0x0, propertyDISALLOWED}, // TIBETAN MARK CHE MGO - {0x0F39, 0x0, propertyPVALID}, // TIBETAN MARK TSA -PHRU - {0x0F3A, 0x0F3D, propertyDISALLOWED}, // TIBETAN MARK GUG RTAGS GYON..TIBETAN MARK AN - {0x0F3E, 0x0F42, propertyPVALID}, // TIBETAN SIGN YAR TSHES..TIBETAN LETTER GA - {0x0F43, 0x0, propertyDISALLOWED}, // TIBETAN LETTER GHA - {0x0F44, 0x0F47, propertyPVALID}, // TIBETAN LETTER NGA..TIBETAN LETTER JA - {0x0F48, 0x0, propertyUNASSIGNED}, // - {0x0F49, 0x0F4C, propertyPVALID}, // TIBETAN LETTER NYA..TIBETAN LETTER DDA - {0x0F4D, 0x0, propertyDISALLOWED}, // TIBETAN LETTER DDHA - {0x0F4E, 0x0F51, propertyPVALID}, // TIBETAN LETTER NNA..TIBETAN LETTER DA - {0x0F52, 0x0, propertyDISALLOWED}, // TIBETAN LETTER DHA - {0x0F53, 0x0F56, propertyPVALID}, // TIBETAN LETTER NA..TIBETAN LETTER BA - {0x0F57, 0x0, propertyDISALLOWED}, // TIBETAN LETTER BHA - {0x0F58, 0x0F5B, propertyPVALID}, // TIBETAN LETTER MA..TIBETAN LETTER DZA - {0x0F5C, 0x0, propertyDISALLOWED}, // TIBETAN LETTER DZHA - {0x0F5D, 0x0F68, propertyPVALID}, // TIBETAN LETTER WA..TIBETAN LETTER A - {0x0F69, 0x0, propertyDISALLOWED}, // TIBETAN LETTER KSSA - {0x0F6A, 0x0F6C, propertyPVALID}, // TIBETAN LETTER FIXED-FORM RA..TIBETAN LETTER - {0x0F6D, 0x0F70, propertyUNASSIGNED}, // .. - {0x0F71, 0x0F72, propertyPVALID}, // TIBETAN VOWEL SIGN AA..TIBETAN VOWEL SIGN I - {0x0F73, 0x0, propertyDISALLOWED}, // TIBETAN VOWEL SIGN II - {0x0F74, 0x0, propertyPVALID}, // TIBETAN VOWEL SIGN U - {0x0F75, 0x0F79, propertyDISALLOWED}, // TIBETAN VOWEL SIGN UU..TIBETAN VOWEL SIGN VO - {0x0F7A, 0x0F80, propertyPVALID}, // TIBETAN VOWEL SIGN E..TIBETAN VOWEL SIGN REV - {0x0F81, 0x0, propertyDISALLOWED}, // TIBETAN VOWEL SIGN REVERSED II - {0x0F82, 0x0F84, propertyPVALID}, // TIBETAN SIGN NYI ZLA NAA DA..TIBETAN MARK HA - {0x0F85, 0x0, propertyDISALLOWED}, // TIBETAN MARK PALUTA - {0x0F86, 0x0F8B, propertyPVALID}, // TIBETAN SIGN LCI RTAGS..TIBETAN SIGN GRU MED - {0x0F8C, 0x0F8F, propertyUNASSIGNED}, // .. - {0x0F90, 0x0F92, propertyPVALID}, // TIBETAN SUBJOINED LETTER KA..TIBETAN SUBJOIN - {0x0F93, 0x0, propertyDISALLOWED}, // TIBETAN SUBJOINED LETTER GHA - {0x0F94, 0x0F97, propertyPVALID}, // TIBETAN SUBJOINED LETTER NGA..TIBETAN SUBJOI - {0x0F98, 0x0, propertyUNASSIGNED}, // - {0x0F99, 0x0F9C, propertyPVALID}, // TIBETAN SUBJOINED LETTER NYA..TIBETAN SUBJOI - {0x0F9D, 0x0, propertyDISALLOWED}, // TIBETAN SUBJOINED LETTER DDHA - {0x0F9E, 0x0FA1, propertyPVALID}, // TIBETAN SUBJOINED LETTER NNA..TIBETAN SUBJOI - {0x0FA2, 0x0, propertyDISALLOWED}, // TIBETAN SUBJOINED LETTER DHA - {0x0FA3, 0x0FA6, propertyPVALID}, // TIBETAN SUBJOINED LETTER NA..TIBETAN SUBJOIN - {0x0FA7, 0x0, propertyDISALLOWED}, // TIBETAN SUBJOINED LETTER BHA - {0x0FA8, 0x0FAB, propertyPVALID}, // TIBETAN SUBJOINED LETTER MA..TIBETAN SUBJOIN - {0x0FAC, 0x0, propertyDISALLOWED}, // TIBETAN SUBJOINED LETTER DZHA - {0x0FAD, 0x0FB8, propertyPVALID}, // TIBETAN SUBJOINED LETTER WA..TIBETAN SUBJOIN - {0x0FB9, 0x0, propertyDISALLOWED}, // TIBETAN SUBJOINED LETTER KSSA - {0x0FBA, 0x0FBC, propertyPVALID}, // TIBETAN SUBJOINED LETTER FIXED-FORM WA..TIBE - {0x0FBD, 0x0, propertyUNASSIGNED}, // - {0x0FBE, 0x0FC5, propertyDISALLOWED}, // TIBETAN KU RU KHA..TIBETAN SYMBOL RDO RJE - {0x0FC6, 0x0, propertyPVALID}, // TIBETAN SYMBOL PADMA GDAN - {0x0FC7, 0x0FCC, propertyDISALLOWED}, // TIBETAN SYMBOL RDO RJE RGYA GRAM..TIBETAN SY - {0x0FCD, 0x0, propertyUNASSIGNED}, // - {0x0FCE, 0x0FD8, propertyDISALLOWED}, // TIBETAN SIGN RDEL NAG RDEL DKAR..LEFT-FACING - {0x0FD9, 0x0FFF, propertyUNASSIGNED}, // .. - {0x1000, 0x1049, propertyPVALID}, // MYANMAR LETTER KA..MYANMAR DIGIT NINE - {0x104A, 0x104F, propertyDISALLOWED}, // MYANMAR SIGN LITTLE SECTION..MYANMAR SYMBOL - {0x1050, 0x109D, propertyPVALID}, // MYANMAR LETTER SHA..MYANMAR VOWEL SIGN AITON - {0x109E, 0x10C5, propertyDISALLOWED}, // MYANMAR SYMBOL SHAN ONE..GEORGIAN CAPITAL LE - {0x10C6, 0x10CF, propertyUNASSIGNED}, // .. - {0x10D0, 0x10FA, propertyPVALID}, // GEORGIAN LETTER AN..GEORGIAN LETTER AIN - {0x10FB, 0x10FC, propertyDISALLOWED}, // GEORGIAN PARAGRAPH SEPARATOR..MODIFIER LETTE - {0x10FD, 0x10FF, propertyUNASSIGNED}, // .. - {0x1100, 0x11FF, propertyDISALLOWED}, // HANGUL CHOSEONG KIYEOK..HANGUL JONGSEONG SSA - {0x1200, 0x1248, propertyPVALID}, // ETHIOPIC SYLLABLE HA..ETHIOPIC SYLLABLE QWA - {0x1249, 0x0, propertyUNASSIGNED}, // - {0x124A, 0x124D, propertyPVALID}, // ETHIOPIC SYLLABLE QWI..ETHIOPIC SYLLABLE QWE - {0x124E, 0x124F, propertyUNASSIGNED}, // .. - {0x1250, 0x1256, propertyPVALID}, // ETHIOPIC SYLLABLE QHA..ETHIOPIC SYLLABLE QHO - {0x1257, 0x0, propertyUNASSIGNED}, // - {0x1258, 0x0, propertyPVALID}, // ETHIOPIC SYLLABLE QHWA - {0x1259, 0x0, propertyUNASSIGNED}, // - {0x125A, 0x125D, propertyPVALID}, // ETHIOPIC SYLLABLE QHWI..ETHIOPIC SYLLABLE QH - {0x125E, 0x125F, propertyUNASSIGNED}, // .. - {0x1260, 0x1288, propertyPVALID}, // ETHIOPIC SYLLABLE BA..ETHIOPIC SYLLABLE XWA - {0x1289, 0x0, propertyUNASSIGNED}, // - {0x128A, 0x128D, propertyPVALID}, // ETHIOPIC SYLLABLE XWI..ETHIOPIC SYLLABLE XWE - {0x128E, 0x128F, propertyUNASSIGNED}, // .. - {0x1290, 0x12B0, propertyPVALID}, // ETHIOPIC SYLLABLE NA..ETHIOPIC SYLLABLE KWA - {0x12B1, 0x0, propertyUNASSIGNED}, // - {0x12B2, 0x12B5, propertyPVALID}, // ETHIOPIC SYLLABLE KWI..ETHIOPIC SYLLABLE KWE - {0x12B6, 0x12B7, propertyUNASSIGNED}, // .. - {0x12B8, 0x12BE, propertyPVALID}, // ETHIOPIC SYLLABLE KXA..ETHIOPIC SYLLABLE KXO - {0x12BF, 0x0, propertyUNASSIGNED}, // - {0x12C0, 0x0, propertyPVALID}, // ETHIOPIC SYLLABLE KXWA - {0x12C1, 0x0, propertyUNASSIGNED}, // - {0x12C2, 0x12C5, propertyPVALID}, // ETHIOPIC SYLLABLE KXWI..ETHIOPIC SYLLABLE KX - {0x12C6, 0x12C7, propertyUNASSIGNED}, // .. - {0x12C8, 0x12D6, propertyPVALID}, // ETHIOPIC SYLLABLE WA..ETHIOPIC SYLLABLE PHAR - {0x12D7, 0x0, propertyUNASSIGNED}, // - {0x12D8, 0x1310, propertyPVALID}, // ETHIOPIC SYLLABLE ZA..ETHIOPIC SYLLABLE GWA - {0x1311, 0x0, propertyUNASSIGNED}, // - {0x1312, 0x1315, propertyPVALID}, // ETHIOPIC SYLLABLE GWI..ETHIOPIC SYLLABLE GWE - {0x1316, 0x1317, propertyUNASSIGNED}, // .. - {0x1318, 0x135A, propertyPVALID}, // ETHIOPIC SYLLABLE GGA..ETHIOPIC SYLLABLE FYA - {0x135B, 0x135E, propertyUNASSIGNED}, // .. - {0x135F, 0x0, propertyPVALID}, // ETHIOPIC COMBINING GEMINATION MARK - {0x1360, 0x137C, propertyDISALLOWED}, // ETHIOPIC SECTION MARK..ETHIOPIC NUMBER TEN T - {0x137D, 0x137F, propertyUNASSIGNED}, // .. - {0x1380, 0x138F, propertyPVALID}, // ETHIOPIC SYLLABLE SEBATBEIT MWA..ETHIOPIC SY - {0x1390, 0x1399, propertyDISALLOWED}, // ETHIOPIC TONAL MARK YIZET..ETHIOPIC TONAL MA - {0x139A, 0x139F, propertyUNASSIGNED}, // .. - {0x13A0, 0x13F4, propertyPVALID}, // CHEROKEE LETTER A..CHEROKEE LETTER YV - {0x13F5, 0x13FF, propertyUNASSIGNED}, // .. - {0x1400, 0x0, propertyDISALLOWED}, // CANADIAN SYLLABICS HYPHEN - {0x1401, 0x166C, propertyPVALID}, // CANADIAN SYLLABICS E..CANADIAN SYLLABICS CAR - {0x166D, 0x166E, propertyDISALLOWED}, // CANADIAN SYLLABICS CHI SIGN..CANADIAN SYLLAB - {0x166F, 0x167F, propertyPVALID}, // CANADIAN SYLLABICS QAI..CANADIAN SYLLABICS B - {0x1680, 0x0, propertyDISALLOWED}, // OGHAM SPACE MARK - {0x1681, 0x169A, propertyPVALID}, // OGHAM LETTER BEITH..OGHAM LETTER PEITH - {0x169B, 0x169C, propertyDISALLOWED}, // OGHAM FEATHER MARK..OGHAM REVERSED FEATHER M - {0x169D, 0x169F, propertyUNASSIGNED}, // .. - {0x16A0, 0x16EA, propertyPVALID}, // RUNIC LETTER FEHU FEOH FE F..RUNIC LETTER X - {0x16EB, 0x16F0, propertyDISALLOWED}, // RUNIC SINGLE PUNCTUATION..RUNIC BELGTHOR SYM - {0x16F1, 0x16FF, propertyUNASSIGNED}, // .. - {0x1700, 0x170C, propertyPVALID}, // TAGALOG LETTER A..TAGALOG LETTER YA - {0x170D, 0x0, propertyUNASSIGNED}, // - {0x170E, 0x1714, propertyPVALID}, // TAGALOG LETTER LA..TAGALOG SIGN VIRAMA - {0x1715, 0x171F, propertyUNASSIGNED}, // .. - {0x1720, 0x1734, propertyPVALID}, // HANUNOO LETTER A..HANUNOO SIGN PAMUDPOD - {0x1735, 0x1736, propertyDISALLOWED}, // PHILIPPINE SINGLE PUNCTUATION..PHILIPPINE DO - {0x1737, 0x173F, propertyUNASSIGNED}, // .. - {0x1740, 0x1753, propertyPVALID}, // BUHID LETTER A..BUHID VOWEL SIGN U - {0x1754, 0x175F, propertyUNASSIGNED}, // .. - {0x1760, 0x176C, propertyPVALID}, // TAGBANWA LETTER A..TAGBANWA LETTER YA - {0x176D, 0x0, propertyUNASSIGNED}, // - {0x176E, 0x1770, propertyPVALID}, // TAGBANWA LETTER LA..TAGBANWA LETTER SA - {0x1771, 0x0, propertyUNASSIGNED}, // - {0x1772, 0x1773, propertyPVALID}, // TAGBANWA VOWEL SIGN I..TAGBANWA VOWEL SIGN U - {0x1774, 0x177F, propertyUNASSIGNED}, // .. - {0x1780, 0x17B3, propertyPVALID}, // KHMER LETTER KA..KHMER INDEPENDENT VOWEL QAU - {0x17B4, 0x17B5, propertyDISALLOWED}, // KHMER VOWEL INHERENT AQ..KHMER VOWEL INHEREN - {0x17B6, 0x17D3, propertyPVALID}, // KHMER VOWEL SIGN AA..KHMER SIGN BATHAMASAT - {0x17D4, 0x17D6, propertyDISALLOWED}, // KHMER SIGN KHAN..KHMER SIGN CAMNUC PII KUUH - {0x17D7, 0x0, propertyPVALID}, // KHMER SIGN LEK TOO - {0x17D8, 0x17DB, propertyDISALLOWED}, // KHMER SIGN BEYYAL..KHMER CURRENCY SYMBOL RIE - {0x17DC, 0x17DD, propertyPVALID}, // KHMER SIGN AVAKRAHASANYA..KHMER SIGN ATTHACA - {0x17DE, 0x17DF, propertyUNASSIGNED}, // .. - {0x17E0, 0x17E9, propertyPVALID}, // KHMER DIGIT ZERO..KHMER DIGIT NINE - {0x17EA, 0x17EF, propertyUNASSIGNED}, // .. - {0x17F0, 0x17F9, propertyDISALLOWED}, // KHMER SYMBOL LEK ATTAK SON..KHMER SYMBOL LEK - {0x17FA, 0x17FF, propertyUNASSIGNED}, // .. - {0x1800, 0x180E, propertyDISALLOWED}, // MONGOLIAN BIRGA..MONGOLIAN VOWEL SEPARATOR - {0x180F, 0x0, propertyUNASSIGNED}, // - {0x1810, 0x1819, propertyPVALID}, // MONGOLIAN DIGIT ZERO..MONGOLIAN DIGIT NINE - {0x181A, 0x181F, propertyUNASSIGNED}, // .. - {0x1820, 0x1877, propertyPVALID}, // MONGOLIAN LETTER A..MONGOLIAN LETTER MANCHU - {0x1878, 0x187F, propertyUNASSIGNED}, // .. - {0x1880, 0x18AA, propertyPVALID}, // MONGOLIAN LETTER ALI GALI ANUSVARA ONE..MONG - {0x18AB, 0x18AF, propertyUNASSIGNED}, // .. - {0x18B0, 0x18F5, propertyPVALID}, // CANADIAN SYLLABICS OY..CANADIAN SYLLABICS CA - {0x18F6, 0x18FF, propertyUNASSIGNED}, // .. - {0x1900, 0x191C, propertyPVALID}, // LIMBU VOWEL-CARRIER LETTER..LIMBU LETTER HA - {0x191D, 0x191F, propertyUNASSIGNED}, // .. - {0x1920, 0x192B, propertyPVALID}, // LIMBU VOWEL SIGN A..LIMBU SUBJOINED LETTER W - {0x192C, 0x192F, propertyUNASSIGNED}, // .. - {0x1930, 0x193B, propertyPVALID}, // LIMBU SMALL LETTER KA..LIMBU SIGN SA-I - {0x193C, 0x193F, propertyUNASSIGNED}, // .. - {0x1940, 0x0, propertyDISALLOWED}, // LIMBU SIGN LOO - {0x1941, 0x1943, propertyUNASSIGNED}, // .. - {0x1944, 0x1945, propertyDISALLOWED}, // LIMBU EXCLAMATION MARK..LIMBU QUESTION MARK - {0x1946, 0x196D, propertyPVALID}, // LIMBU DIGIT ZERO..TAI LE LETTER AI - {0x196E, 0x196F, propertyUNASSIGNED}, // .. - {0x1970, 0x1974, propertyPVALID}, // TAI LE LETTER TONE-2..TAI LE LETTER TONE-6 - {0x1975, 0x197F, propertyUNASSIGNED}, // .. - {0x1980, 0x19AB, propertyPVALID}, // NEW TAI LUE LETTER HIGH QA..NEW TAI LUE LETT - {0x19AC, 0x19AF, propertyUNASSIGNED}, // .. - {0x19B0, 0x19C9, propertyPVALID}, // NEW TAI LUE VOWEL SIGN VOWEL SHORTENER..NEW - {0x19CA, 0x19CF, propertyUNASSIGNED}, // .. - {0x19D0, 0x19DA, propertyPVALID}, // NEW TAI LUE DIGIT ZERO..NEW TAI LUE THAM DIG - {0x19DB, 0x19DD, propertyUNASSIGNED}, // .. - {0x19DE, 0x19FF, propertyDISALLOWED}, // NEW TAI LUE SIGN LAE..KHMER SYMBOL DAP-PRAM - {0x1A00, 0x1A1B, propertyPVALID}, // BUGINESE LETTER KA..BUGINESE VOWEL SIGN AE - {0x1A1C, 0x1A1D, propertyUNASSIGNED}, // .. - {0x1A1E, 0x1A1F, propertyDISALLOWED}, // BUGINESE PALLAWA..BUGINESE END OF SECTION - {0x1A20, 0x1A5E, propertyPVALID}, // TAI THAM LETTER HIGH KA..TAI THAM CONSONANT - {0x1A5F, 0x0, propertyUNASSIGNED}, // - {0x1A60, 0x1A7C, propertyPVALID}, // TAI THAM SIGN SAKOT..TAI THAM SIGN KHUEN-LUE - {0x1A7D, 0x1A7E, propertyUNASSIGNED}, // .. - {0x1A7F, 0x1A89, propertyPVALID}, // TAI THAM COMBINING CRYPTOGRAMMIC DOT..TAI TH - {0x1A8A, 0x1A8F, propertyUNASSIGNED}, // .. - {0x1A90, 0x1A99, propertyPVALID}, // TAI THAM THAM DIGIT ZERO..TAI THAM THAM DIGI - {0x1A9A, 0x1A9F, propertyUNASSIGNED}, // .. - {0x1AA0, 0x1AA6, propertyDISALLOWED}, // TAI THAM SIGN WIANG..TAI THAM SIGN REVERSED - {0x1AA7, 0x0, propertyPVALID}, // TAI THAM SIGN MAI YAMOK - {0x1AA8, 0x1AAD, propertyDISALLOWED}, // TAI THAM SIGN KAAN..TAI THAM SIGN CAANG - {0x1AAE, 0x1AFF, propertyUNASSIGNED}, // .. - {0x1B00, 0x1B4B, propertyPVALID}, // BALINESE SIGN ULU RICEM..BALINESE LETTER ASY - {0x1B4C, 0x1B4F, propertyUNASSIGNED}, // .. - {0x1B50, 0x1B59, propertyPVALID}, // BALINESE DIGIT ZERO..BALINESE DIGIT NINE - {0x1B5A, 0x1B6A, propertyDISALLOWED}, // BALINESE PANTI..BALINESE MUSICAL SYMBOL DANG - {0x1B6B, 0x1B73, propertyPVALID}, // BALINESE MUSICAL SYMBOL COMBINING TEGEH..BAL - {0x1B74, 0x1B7C, propertyDISALLOWED}, // BALINESE MUSICAL SYMBOL RIGHT-HAND OPEN DUG. - {0x1B7D, 0x1B7F, propertyUNASSIGNED}, // .. - {0x1B80, 0x1BAA, propertyPVALID}, // SUNDANESE SIGN PANYECEK..SUNDANESE SIGN PAMA - {0x1BAB, 0x1BAD, propertyUNASSIGNED}, // .. - {0x1BAE, 0x1BB9, propertyPVALID}, // SUNDANESE LETTER KHA..SUNDANESE DIGIT NINE - {0x1BBA, 0x1BFF, propertyUNASSIGNED}, // .. - {0x1C00, 0x1C37, propertyPVALID}, // LEPCHA LETTER KA..LEPCHA SIGN NUKTA - {0x1C38, 0x1C3A, propertyUNASSIGNED}, // .. - {0x1C3B, 0x1C3F, propertyDISALLOWED}, // LEPCHA PUNCTUATION TA-ROL..LEPCHA PUNCTUATIO - {0x1C40, 0x1C49, propertyPVALID}, // LEPCHA DIGIT ZERO..LEPCHA DIGIT NINE - {0x1C4A, 0x1C4C, propertyUNASSIGNED}, // .. - {0x1C4D, 0x1C7D, propertyPVALID}, // LEPCHA LETTER TTA..OL CHIKI AHAD - {0x1C7E, 0x1C7F, propertyDISALLOWED}, // OL CHIKI PUNCTUATION MUCAAD..OL CHIKI PUNCTU - {0x1C80, 0x1CCF, propertyUNASSIGNED}, // .. - {0x1CD0, 0x1CD2, propertyPVALID}, // VEDIC TONE KARSHANA..VEDIC TONE PRENKHA - {0x1CD3, 0x0, propertyDISALLOWED}, // VEDIC SIGN NIHSHVASA - {0x1CD4, 0x1CF2, propertyPVALID}, // VEDIC SIGN YAJURVEDIC MIDLINE SVARITA..VEDIC - {0x1CF3, 0x1CFF, propertyUNASSIGNED}, // .. - {0x1D00, 0x1D2B, propertyPVALID}, // LATIN LETTER SMALL CAPITAL A..CYRILLIC LETTE - {0x1D2C, 0x1D2E, propertyDISALLOWED}, // MODIFIER LETTER CAPITAL A..MODIFIER LETTER C - {0x1D2F, 0x0, propertyPVALID}, // MODIFIER LETTER CAPITAL BARRED B - {0x1D30, 0x1D3A, propertyDISALLOWED}, // MODIFIER LETTER CAPITAL D..MODIFIER LETTER C - {0x1D3B, 0x0, propertyPVALID}, // MODIFIER LETTER CAPITAL REVERSED N - {0x1D3C, 0x1D4D, propertyDISALLOWED}, // MODIFIER LETTER CAPITAL O..MODIFIER LETTER S - {0x1D4E, 0x0, propertyPVALID}, // MODIFIER LETTER SMALL TURNED I - {0x1D4F, 0x1D6A, propertyDISALLOWED}, // MODIFIER LETTER SMALL K..GREEK SUBSCRIPT SMA - {0x1D6B, 0x1D77, propertyPVALID}, // LATIN SMALL LETTER UE..LATIN SMALL LETTER TU - {0x1D78, 0x0, propertyDISALLOWED}, // MODIFIER LETTER CYRILLIC EN - {0x1D79, 0x1D9A, propertyPVALID}, // LATIN SMALL LETTER INSULAR G..LATIN SMALL LE - {0x1D9B, 0x1DBF, propertyDISALLOWED}, // MODIFIER LETTER SMALL TURNED ALPHA..MODIFIER - {0x1DC0, 0x1DE6, propertyPVALID}, // COMBINING DOTTED GRAVE ACCENT..COMBINING LAT - {0x1DE7, 0x1DFC, propertyUNASSIGNED}, // .. - {0x1DFD, 0x1DFF, propertyPVALID}, // COMBINING ALMOST EQUAL TO BELOW..COMBINING R - {0x1E00, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH RING BELOW - {0x1E01, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH RING BELOW - {0x1E02, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER B WITH DOT ABOVE - {0x1E03, 0x0, propertyPVALID}, // LATIN SMALL LETTER B WITH DOT ABOVE - {0x1E04, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER B WITH DOT BELOW - {0x1E05, 0x0, propertyPVALID}, // LATIN SMALL LETTER B WITH DOT BELOW - {0x1E06, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER B WITH LINE BELOW - {0x1E07, 0x0, propertyPVALID}, // LATIN SMALL LETTER B WITH LINE BELOW - {0x1E08, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER C WITH CEDILLA AND ACUT - {0x1E09, 0x0, propertyPVALID}, // LATIN SMALL LETTER C WITH CEDILLA AND ACUTE - {0x1E0A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER D WITH DOT ABOVE - {0x1E0B, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH DOT ABOVE - {0x1E0C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER D WITH DOT BELOW - {0x1E0D, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH DOT BELOW - {0x1E0E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER D WITH LINE BELOW - {0x1E0F, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH LINE BELOW - {0x1E10, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER D WITH CEDILLA - {0x1E11, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH CEDILLA - {0x1E12, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER D WITH CIRCUMFLEX BELOW - {0x1E13, 0x0, propertyPVALID}, // LATIN SMALL LETTER D WITH CIRCUMFLEX BELOW - {0x1E14, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH MACRON AND GRAVE - {0x1E15, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH MACRON AND GRAVE - {0x1E16, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH MACRON AND ACUTE - {0x1E17, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH MACRON AND ACUTE - {0x1E18, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX BELOW - {0x1E19, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CIRCUMFLEX BELOW - {0x1E1A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH TILDE BELOW - {0x1E1B, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH TILDE BELOW - {0x1E1C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CEDILLA AND BREV - {0x1E1D, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CEDILLA AND BREVE - {0x1E1E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER F WITH DOT ABOVE - {0x1E1F, 0x0, propertyPVALID}, // LATIN SMALL LETTER F WITH DOT ABOVE - {0x1E20, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER G WITH MACRON - {0x1E21, 0x0, propertyPVALID}, // LATIN SMALL LETTER G WITH MACRON - {0x1E22, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH DOT ABOVE - {0x1E23, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH DOT ABOVE - {0x1E24, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH DOT BELOW - {0x1E25, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH DOT BELOW - {0x1E26, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH DIAERESIS - {0x1E27, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH DIAERESIS - {0x1E28, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH CEDILLA - {0x1E29, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH CEDILLA - {0x1E2A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH BREVE BELOW - {0x1E2B, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH BREVE BELOW - {0x1E2C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH TILDE BELOW - {0x1E2D, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH TILDE BELOW - {0x1E2E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH DIAERESIS AND AC - {0x1E2F, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH DIAERESIS AND ACUT - {0x1E30, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH ACUTE - {0x1E31, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH ACUTE - {0x1E32, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH DOT BELOW - {0x1E33, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH DOT BELOW - {0x1E34, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH LINE BELOW - {0x1E35, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH LINE BELOW - {0x1E36, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH DOT BELOW - {0x1E37, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH DOT BELOW - {0x1E38, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH DOT BELOW AND MA - {0x1E39, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH DOT BELOW AND MACR - {0x1E3A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH LINE BELOW - {0x1E3B, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH LINE BELOW - {0x1E3C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH CIRCUMFLEX BELOW - {0x1E3D, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH CIRCUMFLEX BELOW - {0x1E3E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER M WITH ACUTE - {0x1E3F, 0x0, propertyPVALID}, // LATIN SMALL LETTER M WITH ACUTE - {0x1E40, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER M WITH DOT ABOVE - {0x1E41, 0x0, propertyPVALID}, // LATIN SMALL LETTER M WITH DOT ABOVE - {0x1E42, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER M WITH DOT BELOW - {0x1E43, 0x0, propertyPVALID}, // LATIN SMALL LETTER M WITH DOT BELOW - {0x1E44, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH DOT ABOVE - {0x1E45, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH DOT ABOVE - {0x1E46, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH DOT BELOW - {0x1E47, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH DOT BELOW - {0x1E48, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH LINE BELOW - {0x1E49, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH LINE BELOW - {0x1E4A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER N WITH CIRCUMFLEX BELOW - {0x1E4B, 0x0, propertyPVALID}, // LATIN SMALL LETTER N WITH CIRCUMFLEX BELOW - {0x1E4C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH TILDE AND ACUTE - {0x1E4D, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH TILDE AND ACUTE - {0x1E4E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH TILDE AND DIAERE - {0x1E4F, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH TILDE AND DIAERESI - {0x1E50, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH MACRON AND GRAVE - {0x1E51, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH MACRON AND GRAVE - {0x1E52, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH MACRON AND ACUTE - {0x1E53, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH MACRON AND ACUTE - {0x1E54, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER P WITH ACUTE - {0x1E55, 0x0, propertyPVALID}, // LATIN SMALL LETTER P WITH ACUTE - {0x1E56, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER P WITH DOT ABOVE - {0x1E57, 0x0, propertyPVALID}, // LATIN SMALL LETTER P WITH DOT ABOVE - {0x1E58, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH DOT ABOVE - {0x1E59, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH DOT ABOVE - {0x1E5A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH DOT BELOW - {0x1E5B, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH DOT BELOW - {0x1E5C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH DOT BELOW AND MA - {0x1E5D, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH DOT BELOW AND MACR - {0x1E5E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R WITH LINE BELOW - {0x1E5F, 0x0, propertyPVALID}, // LATIN SMALL LETTER R WITH LINE BELOW - {0x1E60, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH DOT ABOVE - {0x1E61, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH DOT ABOVE - {0x1E62, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH DOT BELOW - {0x1E63, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH DOT BELOW - {0x1E64, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH ACUTE AND DOT AB - {0x1E65, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH ACUTE AND DOT ABOV - {0x1E66, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH CARON AND DOT AB - {0x1E67, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH CARON AND DOT ABOV - {0x1E68, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER S WITH DOT BELOW AND DO - {0x1E69, 0x0, propertyPVALID}, // LATIN SMALL LETTER S WITH DOT BELOW AND DOT - {0x1E6A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH DOT ABOVE - {0x1E6B, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH DOT ABOVE - {0x1E6C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH DOT BELOW - {0x1E6D, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH DOT BELOW - {0x1E6E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH LINE BELOW - {0x1E6F, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH LINE BELOW - {0x1E70, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER T WITH CIRCUMFLEX BELOW - {0x1E71, 0x0, propertyPVALID}, // LATIN SMALL LETTER T WITH CIRCUMFLEX BELOW - {0x1E72, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DIAERESIS BELOW - {0x1E73, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH DIAERESIS BELOW - {0x1E74, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH TILDE BELOW - {0x1E75, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH TILDE BELOW - {0x1E76, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH CIRCUMFLEX BELOW - {0x1E77, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH CIRCUMFLEX BELOW - {0x1E78, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH TILDE AND ACUTE - {0x1E79, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH TILDE AND ACUTE - {0x1E7A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH MACRON AND DIAER - {0x1E7B, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH MACRON AND DIAERES - {0x1E7C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER V WITH TILDE - {0x1E7D, 0x0, propertyPVALID}, // LATIN SMALL LETTER V WITH TILDE - {0x1E7E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER V WITH DOT BELOW - {0x1E7F, 0x0, propertyPVALID}, // LATIN SMALL LETTER V WITH DOT BELOW - {0x1E80, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER W WITH GRAVE - {0x1E81, 0x0, propertyPVALID}, // LATIN SMALL LETTER W WITH GRAVE - {0x1E82, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER W WITH ACUTE - {0x1E83, 0x0, propertyPVALID}, // LATIN SMALL LETTER W WITH ACUTE - {0x1E84, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER W WITH DIAERESIS - {0x1E85, 0x0, propertyPVALID}, // LATIN SMALL LETTER W WITH DIAERESIS - {0x1E86, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER W WITH DOT ABOVE - {0x1E87, 0x0, propertyPVALID}, // LATIN SMALL LETTER W WITH DOT ABOVE - {0x1E88, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER W WITH DOT BELOW - {0x1E89, 0x0, propertyPVALID}, // LATIN SMALL LETTER W WITH DOT BELOW - {0x1E8A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER X WITH DOT ABOVE - {0x1E8B, 0x0, propertyPVALID}, // LATIN SMALL LETTER X WITH DOT ABOVE - {0x1E8C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER X WITH DIAERESIS - {0x1E8D, 0x0, propertyPVALID}, // LATIN SMALL LETTER X WITH DIAERESIS - {0x1E8E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH DOT ABOVE - {0x1E8F, 0x0, propertyPVALID}, // LATIN SMALL LETTER Y WITH DOT ABOVE - {0x1E90, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH CIRCUMFLEX - {0x1E91, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH CIRCUMFLEX - {0x1E92, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH DOT BELOW - {0x1E93, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH DOT BELOW - {0x1E94, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH LINE BELOW - {0x1E95, 0x1E99, propertyPVALID}, // LATIN SMALL LETTER Z WITH LINE BELOW..LATIN - {0x1E9A, 0x1E9B, propertyDISALLOWED}, // LATIN SMALL LETTER A WITH RIGHT HALF RING..L - {0x1E9C, 0x1E9D, propertyPVALID}, // LATIN SMALL LETTER LONG S WITH DIAGONAL STRO - {0x1E9E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER SHARP S - {0x1E9F, 0x0, propertyPVALID}, // LATIN SMALL LETTER DELTA - {0x1EA0, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH DOT BELOW - {0x1EA1, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH DOT BELOW - {0x1EA2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH HOOK ABOVE - {0x1EA3, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH HOOK ABOVE - {0x1EA4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND A - {0x1EA5, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACU - {0x1EA6, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND G - {0x1EA7, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRA - {0x1EA8, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND H - {0x1EA9, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOO - {0x1EAA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND T - {0x1EAB, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH CIRCUMFLEX AND TIL - {0x1EAC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND D - {0x1EAD, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT - {0x1EAE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH BREVE AND ACUTE - {0x1EAF, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH BREVE AND ACUTE - {0x1EB0, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH BREVE AND GRAVE - {0x1EB1, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH BREVE AND GRAVE - {0x1EB2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH BREVE AND HOOK A - {0x1EB3, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH BREVE AND HOOK ABO - {0x1EB4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH BREVE AND TILDE - {0x1EB5, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH BREVE AND TILDE - {0x1EB6, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER A WITH BREVE AND DOT BE - {0x1EB7, 0x0, propertyPVALID}, // LATIN SMALL LETTER A WITH BREVE AND DOT BELO - {0x1EB8, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH DOT BELOW - {0x1EB9, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH DOT BELOW - {0x1EBA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH HOOK ABOVE - {0x1EBB, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH HOOK ABOVE - {0x1EBC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH TILDE - {0x1EBD, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH TILDE - {0x1EBE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND A - {0x1EBF, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACU - {0x1EC0, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND G - {0x1EC1, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRA - {0x1EC2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND H - {0x1EC3, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOO - {0x1EC4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND T - {0x1EC5, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CIRCUMFLEX AND TIL - {0x1EC6, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND D - {0x1EC7, 0x0, propertyPVALID}, // LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT - {0x1EC8, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH HOOK ABOVE - {0x1EC9, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH HOOK ABOVE - {0x1ECA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER I WITH DOT BELOW - {0x1ECB, 0x0, propertyPVALID}, // LATIN SMALL LETTER I WITH DOT BELOW - {0x1ECC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH DOT BELOW - {0x1ECD, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH DOT BELOW - {0x1ECE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH HOOK ABOVE - {0x1ECF, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH HOOK ABOVE - {0x1ED0, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND A - {0x1ED1, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACU - {0x1ED2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND G - {0x1ED3, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRA - {0x1ED4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND H - {0x1ED5, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOO - {0x1ED6, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND T - {0x1ED7, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH CIRCUMFLEX AND TIL - {0x1ED8, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND D - {0x1ED9, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT - {0x1EDA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH HORN AND ACUTE - {0x1EDB, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH HORN AND ACUTE - {0x1EDC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH HORN AND GRAVE - {0x1EDD, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH HORN AND GRAVE - {0x1EDE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH HORN AND HOOK AB - {0x1EDF, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH HORN AND HOOK ABOV - {0x1EE0, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH HORN AND TILDE - {0x1EE1, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH HORN AND TILDE - {0x1EE2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH HORN AND DOT BEL - {0x1EE3, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH HORN AND DOT BELOW - {0x1EE4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH DOT BELOW - {0x1EE5, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH DOT BELOW - {0x1EE6, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH HOOK ABOVE - {0x1EE7, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH HOOK ABOVE - {0x1EE8, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH HORN AND ACUTE - {0x1EE9, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH HORN AND ACUTE - {0x1EEA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH HORN AND GRAVE - {0x1EEB, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH HORN AND GRAVE - {0x1EEC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH HORN AND HOOK AB - {0x1EED, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH HORN AND HOOK ABOV - {0x1EEE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH HORN AND TILDE - {0x1EEF, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH HORN AND TILDE - {0x1EF0, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER U WITH HORN AND DOT BEL - {0x1EF1, 0x0, propertyPVALID}, // LATIN SMALL LETTER U WITH HORN AND DOT BELOW - {0x1EF2, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH GRAVE - {0x1EF3, 0x0, propertyPVALID}, // LATIN SMALL LETTER Y WITH GRAVE - {0x1EF4, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH DOT BELOW - {0x1EF5, 0x0, propertyPVALID}, // LATIN SMALL LETTER Y WITH DOT BELOW - {0x1EF6, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH HOOK ABOVE - {0x1EF7, 0x0, propertyPVALID}, // LATIN SMALL LETTER Y WITH HOOK ABOVE - {0x1EF8, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH TILDE - {0x1EF9, 0x0, propertyPVALID}, // LATIN SMALL LETTER Y WITH TILDE - {0x1EFA, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER MIDDLE-WELSH LL - {0x1EFB, 0x0, propertyPVALID}, // LATIN SMALL LETTER MIDDLE-WELSH LL - {0x1EFC, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER MIDDLE-WELSH V - {0x1EFD, 0x0, propertyPVALID}, // LATIN SMALL LETTER MIDDLE-WELSH V - {0x1EFE, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Y WITH LOOP - {0x1EFF, 0x1F07, propertyPVALID}, // LATIN SMALL LETTER Y WITH LOOP..GREEK SMALL - {0x1F08, 0x1F0F, propertyDISALLOWED}, // GREEK CAPITAL LETTER ALPHA WITH PSILI..GREEK - {0x1F10, 0x1F15, propertyPVALID}, // GREEK SMALL LETTER EPSILON WITH PSILI..GREEK - {0x1F16, 0x1F17, propertyUNASSIGNED}, // .. - {0x1F18, 0x1F1D, propertyDISALLOWED}, // GREEK CAPITAL LETTER EPSILON WITH PSILI..GRE - {0x1F1E, 0x1F1F, propertyUNASSIGNED}, // .. - {0x1F20, 0x1F27, propertyPVALID}, // GREEK SMALL LETTER ETA WITH PSILI..GREEK SMA - {0x1F28, 0x1F2F, propertyDISALLOWED}, // GREEK CAPITAL LETTER ETA WITH PSILI..GREEK C - {0x1F30, 0x1F37, propertyPVALID}, // GREEK SMALL LETTER IOTA WITH PSILI..GREEK SM - {0x1F38, 0x1F3F, propertyDISALLOWED}, // GREEK CAPITAL LETTER IOTA WITH PSILI..GREEK - {0x1F40, 0x1F45, propertyPVALID}, // GREEK SMALL LETTER OMICRON WITH PSILI..GREEK - {0x1F46, 0x1F47, propertyUNASSIGNED}, // .. - {0x1F48, 0x1F4D, propertyDISALLOWED}, // GREEK CAPITAL LETTER OMICRON WITH PSILI..GRE - {0x1F4E, 0x1F4F, propertyUNASSIGNED}, // .. - {0x1F50, 0x1F57, propertyPVALID}, // GREEK SMALL LETTER UPSILON WITH PSILI..GREEK - {0x1F58, 0x0, propertyUNASSIGNED}, // - {0x1F59, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER UPSILON WITH DASIA - {0x1F5A, 0x0, propertyUNASSIGNED}, // - {0x1F5B, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER UPSILON WITH DASIA AND - {0x1F5C, 0x0, propertyUNASSIGNED}, // - {0x1F5D, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER UPSILON WITH DASIA AND - {0x1F5E, 0x0, propertyUNASSIGNED}, // - {0x1F5F, 0x0, propertyDISALLOWED}, // GREEK CAPITAL LETTER UPSILON WITH DASIA AND - {0x1F60, 0x1F67, propertyPVALID}, // GREEK SMALL LETTER OMEGA WITH PSILI..GREEK S - {0x1F68, 0x1F6F, propertyDISALLOWED}, // GREEK CAPITAL LETTER OMEGA WITH PSILI..GREEK - {0x1F70, 0x0, propertyPVALID}, // GREEK SMALL LETTER ALPHA WITH VARIA - {0x1F71, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER ALPHA WITH OXIA - {0x1F72, 0x0, propertyPVALID}, // GREEK SMALL LETTER EPSILON WITH VARIA - {0x1F73, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER EPSILON WITH OXIA - {0x1F74, 0x0, propertyPVALID}, // GREEK SMALL LETTER ETA WITH VARIA - {0x1F75, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER ETA WITH OXIA - {0x1F76, 0x0, propertyPVALID}, // GREEK SMALL LETTER IOTA WITH VARIA - {0x1F77, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER IOTA WITH OXIA - {0x1F78, 0x0, propertyPVALID}, // GREEK SMALL LETTER OMICRON WITH VARIA - {0x1F79, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER OMICRON WITH OXIA - {0x1F7A, 0x0, propertyPVALID}, // GREEK SMALL LETTER UPSILON WITH VARIA - {0x1F7B, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER UPSILON WITH OXIA - {0x1F7C, 0x0, propertyPVALID}, // GREEK SMALL LETTER OMEGA WITH VARIA - {0x1F7D, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER OMEGA WITH OXIA - {0x1F7E, 0x1F7F, propertyUNASSIGNED}, // .. - {0x1F80, 0x1FAF, propertyDISALLOWED}, // GREEK SMALL LETTER ALPHA WITH PSILI AND YPOG - {0x1FB0, 0x1FB1, propertyPVALID}, // GREEK SMALL LETTER ALPHA WITH VRACHY..GREEK - {0x1FB2, 0x1FB4, propertyDISALLOWED}, // GREEK SMALL LETTER ALPHA WITH VARIA AND YPOG - {0x1FB5, 0x0, propertyUNASSIGNED}, // - {0x1FB6, 0x0, propertyPVALID}, // GREEK SMALL LETTER ALPHA WITH PERISPOMENI - {0x1FB7, 0x1FC4, propertyDISALLOWED}, // GREEK SMALL LETTER ALPHA WITH PERISPOMENI AN - {0x1FC5, 0x0, propertyUNASSIGNED}, // - {0x1FC6, 0x0, propertyPVALID}, // GREEK SMALL LETTER ETA WITH PERISPOMENI - {0x1FC7, 0x1FCF, propertyDISALLOWED}, // GREEK SMALL LETTER ETA WITH PERISPOMENI AND - {0x1FD0, 0x1FD2, propertyPVALID}, // GREEK SMALL LETTER IOTA WITH VRACHY..GREEK S - {0x1FD3, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND O - {0x1FD4, 0x1FD5, propertyUNASSIGNED}, // .. - {0x1FD6, 0x1FD7, propertyPVALID}, // GREEK SMALL LETTER IOTA WITH PERISPOMENI..GR - {0x1FD8, 0x1FDB, propertyDISALLOWED}, // GREEK CAPITAL LETTER IOTA WITH VRACHY..GREEK - {0x1FDC, 0x0, propertyUNASSIGNED}, // - {0x1FDD, 0x1FDF, propertyDISALLOWED}, // GREEK DASIA AND VARIA..GREEK DASIA AND PERIS - {0x1FE0, 0x1FE2, propertyPVALID}, // GREEK SMALL LETTER UPSILON WITH VRACHY..GREE - {0x1FE3, 0x0, propertyDISALLOWED}, // GREEK SMALL LETTER UPSILON WITH DIALYTIKA AN - {0x1FE4, 0x1FE7, propertyPVALID}, // GREEK SMALL LETTER RHO WITH PSILI..GREEK SMA - {0x1FE8, 0x1FEF, propertyDISALLOWED}, // GREEK CAPITAL LETTER UPSILON WITH VRACHY..GR - {0x1FF0, 0x1FF1, propertyUNASSIGNED}, // .. - {0x1FF2, 0x1FF4, propertyDISALLOWED}, // GREEK SMALL LETTER OMEGA WITH VARIA AND YPOG - {0x1FF5, 0x0, propertyUNASSIGNED}, // - {0x1FF6, 0x0, propertyPVALID}, // GREEK SMALL LETTER OMEGA WITH PERISPOMENI - {0x1FF7, 0x1FFE, propertyDISALLOWED}, // GREEK SMALL LETTER OMEGA WITH PERISPOMENI AN - {0x1FFF, 0x0, propertyUNASSIGNED}, // - {0x2000, 0x200B, propertyDISALLOWED}, // EN QUAD..ZERO WIDTH SPACE - {0x200C, 0x200D, propertyCONTEXTJ}, // ZERO WIDTH NON-JOINER..ZERO WIDTH JOINER - {0x200E, 0x2064, propertyDISALLOWED}, // LEFT-TO-RIGHT MARK..INVISIBLE PLUS - {0x2065, 0x2069, propertyUNASSIGNED}, // .. - {0x206A, 0x2071, propertyDISALLOWED}, // INHIBIT SYMMETRIC SWAPPING..SUPERSCRIPT LATI - {0x2072, 0x2073, propertyUNASSIGNED}, // .. - {0x2074, 0x208E, propertyDISALLOWED}, // SUPERSCRIPT FOUR..SUBSCRIPT RIGHT PARENTHESI - {0x208F, 0x0, propertyUNASSIGNED}, // - {0x2090, 0x2094, propertyDISALLOWED}, // LATIN SUBSCRIPT SMALL LETTER A..LATIN SUBSCR - {0x2095, 0x209F, propertyUNASSIGNED}, // .. - {0x20A0, 0x20B8, propertyDISALLOWED}, // EURO-CURRENCY SIGN..TENGE SIGN - {0x20B9, 0x20CF, propertyUNASSIGNED}, // .. - {0x20D0, 0x20F0, propertyDISALLOWED}, // COMBINING LEFT HARPOON ABOVE..COMBINING ASTE - {0x20F1, 0x20FF, propertyUNASSIGNED}, // .. - {0x2100, 0x214D, propertyDISALLOWED}, // ACCOUNT OF..AKTIESELSKAB - {0x214E, 0x0, propertyPVALID}, // TURNED SMALL F - {0x214F, 0x2183, propertyDISALLOWED}, // SYMBOL FOR SAMARITAN SOURCE..ROMAN NUMERAL R - {0x2184, 0x0, propertyPVALID}, // LATIN SMALL LETTER REVERSED C - {0x2185, 0x2189, propertyDISALLOWED}, // ROMAN NUMERAL SIX LATE FORM..VULGAR FRACTION - {0x218A, 0x218F, propertyUNASSIGNED}, // .. - {0x2190, 0x23E8, propertyDISALLOWED}, // LEFTWARDS ARROW..DECIMAL EXPONENT SYMBOL - {0x23E9, 0x23FF, propertyUNASSIGNED}, // .. - {0x2400, 0x2426, propertyDISALLOWED}, // SYMBOL FOR NULL..SYMBOL FOR SUBSTITUTE FORM - {0x2427, 0x243F, propertyUNASSIGNED}, // .. - {0x2440, 0x244A, propertyDISALLOWED}, // OCR HOOK..OCR DOUBLE BACKSLASH - {0x244B, 0x245F, propertyUNASSIGNED}, // .. - {0x2460, 0x26CD, propertyDISALLOWED}, // CIRCLED DIGIT ONE..DISABLED CAR - {0x26CE, 0x0, propertyUNASSIGNED}, // - {0x26CF, 0x26E1, propertyDISALLOWED}, // PICK..RESTRICTED LEFT ENTRY-2 - {0x26E2, 0x0, propertyUNASSIGNED}, // - {0x26E3, 0x0, propertyDISALLOWED}, // HEAVY CIRCLE WITH STROKE AND TWO DOTS ABOVE - {0x26E4, 0x26E7, propertyUNASSIGNED}, // .. - {0x26E8, 0x26FF, propertyDISALLOWED}, // BLACK CROSS ON SHIELD..WHITE FLAG WITH HORIZ - {0x2700, 0x0, propertyUNASSIGNED}, // - {0x2701, 0x2704, propertyDISALLOWED}, // UPPER BLADE SCISSORS..WHITE SCISSORS - {0x2705, 0x0, propertyUNASSIGNED}, // - {0x2706, 0x2709, propertyDISALLOWED}, // TELEPHONE LOCATION SIGN..ENVELOPE - {0x270A, 0x270B, propertyUNASSIGNED}, // .. - {0x270C, 0x2727, propertyDISALLOWED}, // VICTORY HAND..WHITE FOUR POINTED STAR - {0x2728, 0x0, propertyUNASSIGNED}, // - {0x2729, 0x274B, propertyDISALLOWED}, // STRESS OUTLINED WHITE STAR..HEAVY EIGHT TEAR - {0x274C, 0x0, propertyUNASSIGNED}, // - {0x274D, 0x0, propertyDISALLOWED}, // SHADOWED WHITE CIRCLE - {0x274E, 0x0, propertyUNASSIGNED}, // - {0x274F, 0x2752, propertyDISALLOWED}, // LOWER RIGHT DROP-SHADOWED WHITE SQUARE..UPPE - {0x2753, 0x2755, propertyUNASSIGNED}, // .. - {0x2756, 0x275E, propertyDISALLOWED}, // BLACK DIAMOND MINUS WHITE X..HEAVY DOUBLE CO - {0x275F, 0x2760, propertyUNASSIGNED}, // .. - {0x2761, 0x2794, propertyDISALLOWED}, // CURVED STEM PARAGRAPH SIGN ORNAMENT..HEAVY W - {0x2795, 0x2797, propertyUNASSIGNED}, // .. - {0x2798, 0x27AF, propertyDISALLOWED}, // HEAVY SOUTH EAST ARROW..NOTCHED LOWER RIGHT- - {0x27B0, 0x0, propertyUNASSIGNED}, // - {0x27B1, 0x27BE, propertyDISALLOWED}, // NOTCHED UPPER RIGHT-SHADOWED WHITE RIGHTWARD - {0x27BF, 0x0, propertyUNASSIGNED}, // - {0x27C0, 0x27CA, propertyDISALLOWED}, // THREE DIMENSIONAL ANGLE..VERTICAL BAR WITH H - {0x27CB, 0x0, propertyUNASSIGNED}, // - {0x27CC, 0x0, propertyDISALLOWED}, // LONG DIVISION - {0x27CD, 0x27CF, propertyUNASSIGNED}, // .. - {0x27D0, 0x2B4C, propertyDISALLOWED}, // WHITE DIAMOND WITH CENTRED DOT..RIGHTWARDS A - {0x2B4D, 0x2B4F, propertyUNASSIGNED}, // .. - {0x2B50, 0x2B59, propertyDISALLOWED}, // WHITE MEDIUM STAR..HEAVY CIRCLED SALTIRE - {0x2B5A, 0x2BFF, propertyUNASSIGNED}, // .. - {0x2C00, 0x2C2E, propertyDISALLOWED}, // GLAGOLITIC CAPITAL LETTER AZU..GLAGOLITIC CA - {0x2C2F, 0x0, propertyUNASSIGNED}, // - {0x2C30, 0x2C5E, propertyPVALID}, // GLAGOLITIC SMALL LETTER AZU..GLAGOLITIC SMAL - {0x2C5F, 0x0, propertyUNASSIGNED}, // - {0x2C60, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH DOUBLE BAR - {0x2C61, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH DOUBLE BAR - {0x2C62, 0x2C64, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH MIDDLE TILDE..LA - {0x2C65, 0x2C66, propertyPVALID}, // LATIN SMALL LETTER A WITH STROKE..LATIN SMAL - {0x2C67, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER H WITH DESCENDER - {0x2C68, 0x0, propertyPVALID}, // LATIN SMALL LETTER H WITH DESCENDER - {0x2C69, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH DESCENDER - {0x2C6A, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH DESCENDER - {0x2C6B, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Z WITH DESCENDER - {0x2C6C, 0x0, propertyPVALID}, // LATIN SMALL LETTER Z WITH DESCENDER - {0x2C6D, 0x2C70, propertyDISALLOWED}, // LATIN CAPITAL LETTER ALPHA..LATIN CAPITAL LE - {0x2C71, 0x0, propertyPVALID}, // LATIN SMALL LETTER V WITH RIGHT HOOK - {0x2C72, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER W WITH HOOK - {0x2C73, 0x2C74, propertyPVALID}, // LATIN SMALL LETTER W WITH HOOK..LATIN SMALL - {0x2C75, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER HALF H - {0x2C76, 0x2C7B, propertyPVALID}, // LATIN SMALL LETTER HALF H..LATIN LETTER SMAL - {0x2C7C, 0x2C80, propertyDISALLOWED}, // LATIN SUBSCRIPT SMALL LETTER J..COPTIC CAPIT - {0x2C81, 0x0, propertyPVALID}, // COPTIC SMALL LETTER ALFA - {0x2C82, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER VIDA - {0x2C83, 0x0, propertyPVALID}, // COPTIC SMALL LETTER VIDA - {0x2C84, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER GAMMA - {0x2C85, 0x0, propertyPVALID}, // COPTIC SMALL LETTER GAMMA - {0x2C86, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER DALDA - {0x2C87, 0x0, propertyPVALID}, // COPTIC SMALL LETTER DALDA - {0x2C88, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER EIE - {0x2C89, 0x0, propertyPVALID}, // COPTIC SMALL LETTER EIE - {0x2C8A, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER SOU - {0x2C8B, 0x0, propertyPVALID}, // COPTIC SMALL LETTER SOU - {0x2C8C, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER ZATA - {0x2C8D, 0x0, propertyPVALID}, // COPTIC SMALL LETTER ZATA - {0x2C8E, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER HATE - {0x2C8F, 0x0, propertyPVALID}, // COPTIC SMALL LETTER HATE - {0x2C90, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER THETHE - {0x2C91, 0x0, propertyPVALID}, // COPTIC SMALL LETTER THETHE - {0x2C92, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER IAUDA - {0x2C93, 0x0, propertyPVALID}, // COPTIC SMALL LETTER IAUDA - {0x2C94, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER KAPA - {0x2C95, 0x0, propertyPVALID}, // COPTIC SMALL LETTER KAPA - {0x2C96, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER LAULA - {0x2C97, 0x0, propertyPVALID}, // COPTIC SMALL LETTER LAULA - {0x2C98, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER MI - {0x2C99, 0x0, propertyPVALID}, // COPTIC SMALL LETTER MI - {0x2C9A, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER NI - {0x2C9B, 0x0, propertyPVALID}, // COPTIC SMALL LETTER NI - {0x2C9C, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER KSI - {0x2C9D, 0x0, propertyPVALID}, // COPTIC SMALL LETTER KSI - {0x2C9E, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER O - {0x2C9F, 0x0, propertyPVALID}, // COPTIC SMALL LETTER O - {0x2CA0, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER PI - {0x2CA1, 0x0, propertyPVALID}, // COPTIC SMALL LETTER PI - {0x2CA2, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER RO - {0x2CA3, 0x0, propertyPVALID}, // COPTIC SMALL LETTER RO - {0x2CA4, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER SIMA - {0x2CA5, 0x0, propertyPVALID}, // COPTIC SMALL LETTER SIMA - {0x2CA6, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER TAU - {0x2CA7, 0x0, propertyPVALID}, // COPTIC SMALL LETTER TAU - {0x2CA8, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER UA - {0x2CA9, 0x0, propertyPVALID}, // COPTIC SMALL LETTER UA - {0x2CAA, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER FI - {0x2CAB, 0x0, propertyPVALID}, // COPTIC SMALL LETTER FI - {0x2CAC, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER KHI - {0x2CAD, 0x0, propertyPVALID}, // COPTIC SMALL LETTER KHI - {0x2CAE, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER PSI - {0x2CAF, 0x0, propertyPVALID}, // COPTIC SMALL LETTER PSI - {0x2CB0, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OOU - {0x2CB1, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OOU - {0x2CB2, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER DIALECT-P ALEF - {0x2CB3, 0x0, propertyPVALID}, // COPTIC SMALL LETTER DIALECT-P ALEF - {0x2CB4, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC AIN - {0x2CB5, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC AIN - {0x2CB6, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER CRYPTOGRAMMIC EIE - {0x2CB7, 0x0, propertyPVALID}, // COPTIC SMALL LETTER CRYPTOGRAMMIC EIE - {0x2CB8, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER DIALECT-P KAPA - {0x2CB9, 0x0, propertyPVALID}, // COPTIC SMALL LETTER DIALECT-P KAPA - {0x2CBA, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER DIALECT-P NI - {0x2CBB, 0x0, propertyPVALID}, // COPTIC SMALL LETTER DIALECT-P NI - {0x2CBC, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER CRYPTOGRAMMIC NI - {0x2CBD, 0x0, propertyPVALID}, // COPTIC SMALL LETTER CRYPTOGRAMMIC NI - {0x2CBE, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC OOU - {0x2CBF, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC OOU - {0x2CC0, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER SAMPI - {0x2CC1, 0x0, propertyPVALID}, // COPTIC SMALL LETTER SAMPI - {0x2CC2, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER CROSSED SHEI - {0x2CC3, 0x0, propertyPVALID}, // COPTIC SMALL LETTER CROSSED SHEI - {0x2CC4, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC SHEI - {0x2CC5, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC SHEI - {0x2CC6, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC ESH - {0x2CC7, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC ESH - {0x2CC8, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER AKHMIMIC KHEI - {0x2CC9, 0x0, propertyPVALID}, // COPTIC SMALL LETTER AKHMIMIC KHEI - {0x2CCA, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER DIALECT-P HORI - {0x2CCB, 0x0, propertyPVALID}, // COPTIC SMALL LETTER DIALECT-P HORI - {0x2CCC, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC HORI - {0x2CCD, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC HORI - {0x2CCE, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC HA - {0x2CCF, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC HA - {0x2CD0, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER L-SHAPED HA - {0x2CD1, 0x0, propertyPVALID}, // COPTIC SMALL LETTER L-SHAPED HA - {0x2CD2, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC HEI - {0x2CD3, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC HEI - {0x2CD4, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC HAT - {0x2CD5, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC HAT - {0x2CD6, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC GANGIA - {0x2CD7, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC GANGIA - {0x2CD8, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC DJA - {0x2CD9, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC DJA - {0x2CDA, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD COPTIC SHIMA - {0x2CDB, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD COPTIC SHIMA - {0x2CDC, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD NUBIAN SHIMA - {0x2CDD, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD NUBIAN SHIMA - {0x2CDE, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD NUBIAN NGI - {0x2CDF, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD NUBIAN NGI - {0x2CE0, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD NUBIAN NYI - {0x2CE1, 0x0, propertyPVALID}, // COPTIC SMALL LETTER OLD NUBIAN NYI - {0x2CE2, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER OLD NUBIAN WAU - {0x2CE3, 0x2CE4, propertyPVALID}, // COPTIC SMALL LETTER OLD NUBIAN WAU..COPTIC S - {0x2CE5, 0x2CEB, propertyDISALLOWED}, // COPTIC SYMBOL MI RO..COPTIC CAPITAL LETTER C - {0x2CEC, 0x0, propertyPVALID}, // COPTIC SMALL LETTER CRYPTOGRAMMIC SHEI - {0x2CED, 0x0, propertyDISALLOWED}, // COPTIC CAPITAL LETTER CRYPTOGRAMMIC GANGIA - {0x2CEE, 0x2CF1, propertyPVALID}, // COPTIC SMALL LETTER CRYPTOGRAMMIC GANGIA..CO - {0x2CF2, 0x2CF8, propertyUNASSIGNED}, // .. - {0x2CF9, 0x2CFF, propertyDISALLOWED}, // COPTIC OLD NUBIAN FULL STOP..COPTIC MORPHOLO - {0x2D00, 0x2D25, propertyPVALID}, // GEORGIAN SMALL LETTER AN..GEORGIAN SMALL LET - {0x2D26, 0x2D2F, propertyUNASSIGNED}, // .. - {0x2D30, 0x2D65, propertyPVALID}, // TIFINAGH LETTER YA..TIFINAGH LETTER YAZZ - {0x2D66, 0x2D6E, propertyUNASSIGNED}, // .. - {0x2D6F, 0x0, propertyDISALLOWED}, // TIFINAGH MODIFIER LETTER LABIALIZATION MARK - {0x2D70, 0x2D7F, propertyUNASSIGNED}, // .. - {0x2D80, 0x2D96, propertyPVALID}, // ETHIOPIC SYLLABLE LOA..ETHIOPIC SYLLABLE GGW - {0x2D97, 0x2D9F, propertyUNASSIGNED}, // .. - {0x2DA0, 0x2DA6, propertyPVALID}, // ETHIOPIC SYLLABLE SSA..ETHIOPIC SYLLABLE SSO - {0x2DA7, 0x0, propertyUNASSIGNED}, // - {0x2DA8, 0x2DAE, propertyPVALID}, // ETHIOPIC SYLLABLE CCA..ETHIOPIC SYLLABLE CCO - {0x2DAF, 0x0, propertyUNASSIGNED}, // - {0x2DB0, 0x2DB6, propertyPVALID}, // ETHIOPIC SYLLABLE ZZA..ETHIOPIC SYLLABLE ZZO - {0x2DB7, 0x0, propertyUNASSIGNED}, // - {0x2DB8, 0x2DBE, propertyPVALID}, // ETHIOPIC SYLLABLE CCHA..ETHIOPIC SYLLABLE CC - {0x2DBF, 0x0, propertyUNASSIGNED}, // - {0x2DC0, 0x2DC6, propertyPVALID}, // ETHIOPIC SYLLABLE QYA..ETHIOPIC SYLLABLE QYO - {0x2DC7, 0x0, propertyUNASSIGNED}, // - {0x2DC8, 0x2DCE, propertyPVALID}, // ETHIOPIC SYLLABLE KYA..ETHIOPIC SYLLABLE KYO - {0x2DCF, 0x0, propertyUNASSIGNED}, // - {0x2DD0, 0x2DD6, propertyPVALID}, // ETHIOPIC SYLLABLE XYA..ETHIOPIC SYLLABLE XYO - {0x2DD7, 0x0, propertyUNASSIGNED}, // - {0x2DD8, 0x2DDE, propertyPVALID}, // ETHIOPIC SYLLABLE GYA..ETHIOPIC SYLLABLE GYO - {0x2DDF, 0x0, propertyUNASSIGNED}, // - {0x2DE0, 0x2DFF, propertyPVALID}, // COMBINING CYRILLIC LETTER BE..COMBINING CYRI - {0x2E00, 0x2E2E, propertyDISALLOWED}, // RIGHT ANGLE SUBSTITUTION MARKER..REVERSED QU - {0x2E2F, 0x0, propertyPVALID}, // VERTICAL TILDE - {0x2E30, 0x2E31, propertyDISALLOWED}, // RING POINT..WORD SEPARATOR MIDDLE DOT - {0x2E32, 0x2E7F, propertyUNASSIGNED}, // .. - {0x2E80, 0x2E99, propertyDISALLOWED}, // CJK RADICAL REPEAT..CJK RADICAL RAP - {0x2E9A, 0x0, propertyUNASSIGNED}, // - {0x2E9B, 0x2EF3, propertyDISALLOWED}, // CJK RADICAL CHOKE..CJK RADICAL C-SIMPLIFIED - {0x2EF4, 0x2EFF, propertyUNASSIGNED}, // .. - {0x2F00, 0x2FD5, propertyDISALLOWED}, // KANGXI RADICAL ONE..KANGXI RADICAL FLUTE - {0x2FD6, 0x2FEF, propertyUNASSIGNED}, // .. - {0x2FF0, 0x2FFB, propertyDISALLOWED}, // IDEOGRAPHIC DESCRIPTION CHARACTER LEFT TO RI - {0x2FFC, 0x2FFF, propertyUNASSIGNED}, // .. - {0x3000, 0x3004, propertyDISALLOWED}, // IDEOGRAPHIC SPACE..JAPANESE INDUSTRIAL STAND - {0x3005, 0x3007, propertyPVALID}, // IDEOGRAPHIC ITERATION MARK..IDEOGRAPHIC NUMB - {0x3008, 0x3029, propertyDISALLOWED}, // LEFT ANGLE BRACKET..HANGZHOU NUMERAL NINE - {0x302A, 0x302D, propertyPVALID}, // IDEOGRAPHIC LEVEL TONE MARK..IDEOGRAPHIC ENT - {0x302E, 0x303B, propertyDISALLOWED}, // HANGUL SINGLE DOT TONE MARK..VERTICAL IDEOGR - {0x303C, 0x0, propertyPVALID}, // MASU MARK - {0x303D, 0x303F, propertyDISALLOWED}, // PART ALTERNATION MARK..IDEOGRAPHIC HALF FILL - {0x3040, 0x0, propertyUNASSIGNED}, // - {0x3041, 0x3096, propertyPVALID}, // HIRAGANA LETTER SMALL A..HIRAGANA LETTER SMA - {0x3097, 0x3098, propertyUNASSIGNED}, // .. - {0x3099, 0x309A, propertyPVALID}, // COMBINING KATAKANA-HIRAGANA VOICED SOUND MAR - {0x309B, 0x309C, propertyDISALLOWED}, // KATAKANA-HIRAGANA VOICED SOUND MARK..KATAKAN - {0x309D, 0x309E, propertyPVALID}, // HIRAGANA ITERATION MARK..HIRAGANA VOICED ITE - {0x309F, 0x30A0, propertyDISALLOWED}, // HIRAGANA DIGRAPH YORI..KATAKANA-HIRAGANA DOU - {0x30A1, 0x30FA, propertyPVALID}, // KATAKANA LETTER SMALL A..KATAKANA LETTER VO - {0x30FB, 0x0, propertyCONTEXTO}, // KATAKANA MIDDLE DOT - {0x30FC, 0x30FE, propertyPVALID}, // KATAKANA-HIRAGANA PROLONGED SOUND MARK..KATA - {0x30FF, 0x0, propertyDISALLOWED}, // KATAKANA DIGRAPH KOTO - {0x3100, 0x3104, propertyUNASSIGNED}, // .. - {0x3105, 0x312D, propertyPVALID}, // BOPOMOFO LETTER B..BOPOMOFO LETTER IH - {0x312E, 0x3130, propertyUNASSIGNED}, // .. - {0x3131, 0x318E, propertyDISALLOWED}, // HANGUL LETTER KIYEOK..HANGUL LETTER ARAEAE - {0x318F, 0x0, propertyUNASSIGNED}, // - {0x3190, 0x319F, propertyDISALLOWED}, // IDEOGRAPHIC ANNOTATION LINKING MARK..IDEOGRA - {0x31A0, 0x31B7, propertyPVALID}, // BOPOMOFO LETTER BU..BOPOMOFO FINAL LETTER H - {0x31B8, 0x31BF, propertyUNASSIGNED}, // .. - {0x31C0, 0x31E3, propertyDISALLOWED}, // CJK STROKE T..CJK STROKE Q - {0x31E4, 0x31EF, propertyUNASSIGNED}, // .. - {0x31F0, 0x31FF, propertyPVALID}, // KATAKANA LETTER SMALL KU..KATAKANA LETTER SM - {0x3200, 0x321E, propertyDISALLOWED}, // PARENTHESIZED HANGUL KIYEOK..PARENTHESIZED K - {0x321F, 0x0, propertyUNASSIGNED}, // - {0x3220, 0x32FE, propertyDISALLOWED}, // PARENTHESIZED IDEOGRAPH ONE..CIRCLED KATAKAN - {0x32FF, 0x0, propertyUNASSIGNED}, // - {0x3300, 0x33FF, propertyDISALLOWED}, // SQUARE APAATO..SQUARE GAL - {0x3400, 0x4DB5, propertyPVALID}, // .... - {0x4DC0, 0x4DFF, propertyDISALLOWED}, // HEXAGRAM FOR THE CREATIVE HEAVEN..HEXAGRAM F - {0x4E00, 0x9FCB, propertyPVALID}, // .. - {0x9FCC, 0x9FFF, propertyUNASSIGNED}, // .. - {0xA000, 0xA48C, propertyPVALID}, // YI SYLLABLE IT..YI SYLLABLE YYR - {0xA48D, 0xA48F, propertyUNASSIGNED}, // .. - {0xA490, 0xA4C6, propertyDISALLOWED}, // YI RADICAL QOT..YI RADICAL KE - {0xA4C7, 0xA4CF, propertyUNASSIGNED}, // .. - {0xA4D0, 0xA4FD, propertyPVALID}, // LISU LETTER BA..LISU LETTER TONE MYA JEU - {0xA4FE, 0xA4FF, propertyDISALLOWED}, // LISU PUNCTUATION COMMA..LISU PUNCTUATION FUL - {0xA500, 0xA60C, propertyPVALID}, // VAI SYLLABLE EE..VAI SYLLABLE LENGTHENER - {0xA60D, 0xA60F, propertyDISALLOWED}, // VAI COMMA..VAI QUESTION MARK - {0xA610, 0xA62B, propertyPVALID}, // VAI SYLLABLE NDOLE FA..VAI SYLLABLE NDOLE DO - {0xA62C, 0xA63F, propertyUNASSIGNED}, // .. - {0xA640, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ZEMLYA - {0xA641, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ZEMLYA - {0xA642, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER DZELO - {0xA643, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER DZELO - {0xA644, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER REVERSED DZE - {0xA645, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER REVERSED DZE - {0xA646, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IOTA - {0xA647, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IOTA - {0xA648, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER DJERV - {0xA649, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER DJERV - {0xA64A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER MONOGRAPH UK - {0xA64B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER MONOGRAPH UK - {0xA64C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER BROAD OMEGA - {0xA64D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER BROAD OMEGA - {0xA64E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER NEUTRAL YER - {0xA64F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER NEUTRAL YER - {0xA650, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER YERU WITH BACK YER - {0xA651, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER YERU WITH BACK YER - {0xA652, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IOTIFIED YAT - {0xA653, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IOTIFIED YAT - {0xA654, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER REVERSED YU - {0xA655, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER REVERSED YU - {0xA656, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IOTIFIED A - {0xA657, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IOTIFIED A - {0xA658, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER CLOSED LITTLE YUS - {0xA659, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER CLOSED LITTLE YUS - {0xA65A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER BLENDED YUS - {0xA65B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER BLENDED YUS - {0xA65C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER IOTIFIED CLOSED LITT - {0xA65D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER IOTIFIED CLOSED LITTLE - {0xA65E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER YN - {0xA65F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER YN - {0xA660, 0xA661, propertyUNASSIGNED}, // .. - {0xA662, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SOFT DE - {0xA663, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SOFT DE - {0xA664, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SOFT EL - {0xA665, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SOFT EL - {0xA666, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SOFT EM - {0xA667, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SOFT EM - {0xA668, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER MONOCULAR O - {0xA669, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER MONOCULAR O - {0xA66A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER BINOCULAR O - {0xA66B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER BINOCULAR O - {0xA66C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER DOUBLE MONOCULAR O - {0xA66D, 0xA66F, propertyPVALID}, // CYRILLIC SMALL LETTER DOUBLE MONOCULAR O..CO - {0xA670, 0xA673, propertyDISALLOWED}, // COMBINING CYRILLIC TEN MILLIONS SIGN..SLAVON - {0xA674, 0xA67B, propertyUNASSIGNED}, // .. - {0xA67C, 0xA67D, propertyPVALID}, // COMBINING CYRILLIC KAVYKA..COMBINING CYRILLI - {0xA67E, 0x0, propertyDISALLOWED}, // CYRILLIC KAVYKA - {0xA67F, 0x0, propertyPVALID}, // CYRILLIC PAYEROK - {0xA680, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER DWE - {0xA681, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER DWE - {0xA682, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER DZWE - {0xA683, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER DZWE - {0xA684, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER ZHWE - {0xA685, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER ZHWE - {0xA686, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER CCHE - {0xA687, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER CCHE - {0xA688, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER DZZE - {0xA689, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER DZZE - {0xA68A, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER TE WITH MIDDLE HOOK - {0xA68B, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER TE WITH MIDDLE HOOK - {0xA68C, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER TWE - {0xA68D, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER TWE - {0xA68E, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER TSWE - {0xA68F, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER TSWE - {0xA690, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER TSSE - {0xA691, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER TSSE - {0xA692, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER TCHE - {0xA693, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER TCHE - {0xA694, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER HWE - {0xA695, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER HWE - {0xA696, 0x0, propertyDISALLOWED}, // CYRILLIC CAPITAL LETTER SHWE - {0xA697, 0x0, propertyPVALID}, // CYRILLIC SMALL LETTER SHWE - {0xA698, 0xA69F, propertyUNASSIGNED}, // .. - {0xA6A0, 0xA6E5, propertyPVALID}, // BAMUM LETTER A..BAMUM LETTER KI - {0xA6E6, 0xA6EF, propertyDISALLOWED}, // BAMUM LETTER MO..BAMUM LETTER KOGHOM - {0xA6F0, 0xA6F1, propertyPVALID}, // BAMUM COMBINING MARK KOQNDON..BAMUM COMBININ - {0xA6F2, 0xA6F7, propertyDISALLOWED}, // BAMUM NJAEMLI..BAMUM QUESTION MARK - {0xA6F8, 0xA6FF, propertyUNASSIGNED}, // .. - {0xA700, 0xA716, propertyDISALLOWED}, // MODIFIER LETTER CHINESE TONE YIN PING..MODIF - {0xA717, 0xA71F, propertyPVALID}, // MODIFIER LETTER DOT VERTICAL BAR..MODIFIER L - {0xA720, 0xA722, propertyDISALLOWED}, // MODIFIER LETTER STRESS AND HIGH TONE..LATIN - {0xA723, 0x0, propertyPVALID}, // LATIN SMALL LETTER EGYPTOLOGICAL ALEF - {0xA724, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER EGYPTOLOGICAL AIN - {0xA725, 0x0, propertyPVALID}, // LATIN SMALL LETTER EGYPTOLOGICAL AIN - {0xA726, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER HENG - {0xA727, 0x0, propertyPVALID}, // LATIN SMALL LETTER HENG - {0xA728, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER TZ - {0xA729, 0x0, propertyPVALID}, // LATIN SMALL LETTER TZ - {0xA72A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER TRESILLO - {0xA72B, 0x0, propertyPVALID}, // LATIN SMALL LETTER TRESILLO - {0xA72C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER CUATRILLO - {0xA72D, 0x0, propertyPVALID}, // LATIN SMALL LETTER CUATRILLO - {0xA72E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER CUATRILLO WITH COMMA - {0xA72F, 0xA731, propertyPVALID}, // LATIN SMALL LETTER CUATRILLO WITH COMMA..LAT - {0xA732, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AA - {0xA733, 0x0, propertyPVALID}, // LATIN SMALL LETTER AA - {0xA734, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AO - {0xA735, 0x0, propertyPVALID}, // LATIN SMALL LETTER AO - {0xA736, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AU - {0xA737, 0x0, propertyPVALID}, // LATIN SMALL LETTER AU - {0xA738, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AV - {0xA739, 0x0, propertyPVALID}, // LATIN SMALL LETTER AV - {0xA73A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AV WITH HORIZONTAL BAR - {0xA73B, 0x0, propertyPVALID}, // LATIN SMALL LETTER AV WITH HORIZONTAL BAR - {0xA73C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER AY - {0xA73D, 0x0, propertyPVALID}, // LATIN SMALL LETTER AY - {0xA73E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER REVERSED C WITH DOT - {0xA73F, 0x0, propertyPVALID}, // LATIN SMALL LETTER REVERSED C WITH DOT - {0xA740, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH STROKE - {0xA741, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH STROKE - {0xA742, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH DIAGONAL STROKE - {0xA743, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH DIAGONAL STROKE - {0xA744, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER K WITH STROKE AND DIAGO - {0xA745, 0x0, propertyPVALID}, // LATIN SMALL LETTER K WITH STROKE AND DIAGONA - {0xA746, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER BROKEN L - {0xA747, 0x0, propertyPVALID}, // LATIN SMALL LETTER BROKEN L - {0xA748, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER L WITH HIGH STROKE - {0xA749, 0x0, propertyPVALID}, // LATIN SMALL LETTER L WITH HIGH STROKE - {0xA74A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH LONG STROKE OVER - {0xA74B, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH LONG STROKE OVERLA - {0xA74C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER O WITH LOOP - {0xA74D, 0x0, propertyPVALID}, // LATIN SMALL LETTER O WITH LOOP - {0xA74E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER OO - {0xA74F, 0x0, propertyPVALID}, // LATIN SMALL LETTER OO - {0xA750, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER P WITH STROKE THROUGH D - {0xA751, 0x0, propertyPVALID}, // LATIN SMALL LETTER P WITH STROKE THROUGH DES - {0xA752, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER P WITH FLOURISH - {0xA753, 0x0, propertyPVALID}, // LATIN SMALL LETTER P WITH FLOURISH - {0xA754, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER P WITH SQUIRREL TAIL - {0xA755, 0x0, propertyPVALID}, // LATIN SMALL LETTER P WITH SQUIRREL TAIL - {0xA756, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Q WITH STROKE THROUGH D - {0xA757, 0x0, propertyPVALID}, // LATIN SMALL LETTER Q WITH STROKE THROUGH DES - {0xA758, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER Q WITH DIAGONAL STROKE - {0xA759, 0x0, propertyPVALID}, // LATIN SMALL LETTER Q WITH DIAGONAL STROKE - {0xA75A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER R ROTUNDA - {0xA75B, 0x0, propertyPVALID}, // LATIN SMALL LETTER R ROTUNDA - {0xA75C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER RUM ROTUNDA - {0xA75D, 0x0, propertyPVALID}, // LATIN SMALL LETTER RUM ROTUNDA - {0xA75E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER V WITH DIAGONAL STROKE - {0xA75F, 0x0, propertyPVALID}, // LATIN SMALL LETTER V WITH DIAGONAL STROKE - {0xA760, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER VY - {0xA761, 0x0, propertyPVALID}, // LATIN SMALL LETTER VY - {0xA762, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER VISIGOTHIC Z - {0xA763, 0x0, propertyPVALID}, // LATIN SMALL LETTER VISIGOTHIC Z - {0xA764, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER THORN WITH STROKE - {0xA765, 0x0, propertyPVALID}, // LATIN SMALL LETTER THORN WITH STROKE - {0xA766, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER THORN WITH STROKE THROU - {0xA767, 0x0, propertyPVALID}, // LATIN SMALL LETTER THORN WITH STROKE THROUGH - {0xA768, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER VEND - {0xA769, 0x0, propertyPVALID}, // LATIN SMALL LETTER VEND - {0xA76A, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER ET - {0xA76B, 0x0, propertyPVALID}, // LATIN SMALL LETTER ET - {0xA76C, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER IS - {0xA76D, 0x0, propertyPVALID}, // LATIN SMALL LETTER IS - {0xA76E, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER CON - {0xA76F, 0x0, propertyPVALID}, // LATIN SMALL LETTER CON - {0xA770, 0x0, propertyDISALLOWED}, // MODIFIER LETTER US - {0xA771, 0xA778, propertyPVALID}, // LATIN SMALL LETTER DUM..LATIN SMALL LETTER U - {0xA779, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER INSULAR D - {0xA77A, 0x0, propertyPVALID}, // LATIN SMALL LETTER INSULAR D - {0xA77B, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER INSULAR F - {0xA77C, 0x0, propertyPVALID}, // LATIN SMALL LETTER INSULAR F - {0xA77D, 0xA77E, propertyDISALLOWED}, // LATIN CAPITAL LETTER INSULAR G..LATIN CAPITA - {0xA77F, 0x0, propertyPVALID}, // LATIN SMALL LETTER TURNED INSULAR G - {0xA780, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER TURNED L - {0xA781, 0x0, propertyPVALID}, // LATIN SMALL LETTER TURNED L - {0xA782, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER INSULAR R - {0xA783, 0x0, propertyPVALID}, // LATIN SMALL LETTER INSULAR R - {0xA784, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER INSULAR S - {0xA785, 0x0, propertyPVALID}, // LATIN SMALL LETTER INSULAR S - {0xA786, 0x0, propertyDISALLOWED}, // LATIN CAPITAL LETTER INSULAR T - {0xA787, 0xA788, propertyPVALID}, // LATIN SMALL LETTER INSULAR T..MODIFIER LETTE - {0xA789, 0xA78B, propertyDISALLOWED}, // MODIFIER LETTER COLON..LATIN CAPITAL LETTER - {0xA78C, 0x0, propertyPVALID}, // LATIN SMALL LETTER SALTILLO - {0xA78D, 0xA7FA, propertyUNASSIGNED}, // .. - {0xA7FB, 0xA827, propertyPVALID}, // LATIN EPIGRAPHIC LETTER REVERSED F..SYLOTI N - {0xA828, 0xA82B, propertyDISALLOWED}, // SYLOTI NAGRI POETRY MARK-1..SYLOTI NAGRI POE - {0xA82C, 0xA82F, propertyUNASSIGNED}, // .. - {0xA830, 0xA839, propertyDISALLOWED}, // NORTH INDIC FRACTION ONE QUARTER..NORTH INDI - {0xA83A, 0xA83F, propertyUNASSIGNED}, // .. - {0xA840, 0xA873, propertyPVALID}, // PHAGS-PA LETTER KA..PHAGS-PA LETTER CANDRABI - {0xA874, 0xA877, propertyDISALLOWED}, // PHAGS-PA SINGLE HEAD MARK..PHAGS-PA MARK DOU - {0xA878, 0xA87F, propertyUNASSIGNED}, // .. - {0xA880, 0xA8C4, propertyPVALID}, // SAURASHTRA SIGN ANUSVARA..SAURASHTRA SIGN VI - {0xA8C5, 0xA8CD, propertyUNASSIGNED}, // .. - {0xA8CE, 0xA8CF, propertyDISALLOWED}, // SAURASHTRA DANDA..SAURASHTRA DOUBLE DANDA - {0xA8D0, 0xA8D9, propertyPVALID}, // SAURASHTRA DIGIT ZERO..SAURASHTRA DIGIT NINE - {0xA8DA, 0xA8DF, propertyUNASSIGNED}, // .. - {0xA8E0, 0xA8F7, propertyPVALID}, // COMBINING DEVANAGARI DIGIT ZERO..DEVANAGARI - {0xA8F8, 0xA8FA, propertyDISALLOWED}, // DEVANAGARI SIGN PUSHPIKA..DEVANAGARI CARET - {0xA8FB, 0x0, propertyPVALID}, // DEVANAGARI HEADSTROKE - {0xA8FC, 0xA8FF, propertyUNASSIGNED}, // .. - {0xA900, 0xA92D, propertyPVALID}, // KAYAH LI DIGIT ZERO..KAYAH LI TONE CALYA PLO - {0xA92E, 0xA92F, propertyDISALLOWED}, // KAYAH LI SIGN CWI..KAYAH LI SIGN SHYA - {0xA930, 0xA953, propertyPVALID}, // REJANG LETTER KA..REJANG VIRAMA - {0xA954, 0xA95E, propertyUNASSIGNED}, // .. - {0xA95F, 0xA97C, propertyDISALLOWED}, // REJANG SECTION MARK..HANGUL CHOSEONG SSANGYE - {0xA97D, 0xA97F, propertyUNASSIGNED}, // .. - {0xA980, 0xA9C0, propertyPVALID}, // JAVANESE SIGN PANYANGGA..JAVANESE PANGKON - {0xA9C1, 0xA9CD, propertyDISALLOWED}, // JAVANESE LEFT RERENGGAN..JAVANESE TURNED PAD - {0xA9CE, 0x0, propertyUNASSIGNED}, // - {0xA9CF, 0xA9D9, propertyPVALID}, // JAVANESE PANGRANGKEP..JAVANESE DIGIT NINE - {0xA9DA, 0xA9DD, propertyUNASSIGNED}, // .. - {0xA9DE, 0xA9DF, propertyDISALLOWED}, // JAVANESE PADA TIRTA TUMETES..JAVANESE PADA I - {0xA9E0, 0xA9FF, propertyUNASSIGNED}, // .. - {0xAA00, 0xAA36, propertyPVALID}, // CHAM LETTER A..CHAM CONSONANT SIGN WA - {0xAA37, 0xAA3F, propertyUNASSIGNED}, // .. - {0xAA40, 0xAA4D, propertyPVALID}, // CHAM LETTER FINAL K..CHAM CONSONANT SIGN FIN - {0xAA4E, 0xAA4F, propertyUNASSIGNED}, // .. - {0xAA50, 0xAA59, propertyPVALID}, // CHAM DIGIT ZERO..CHAM DIGIT NINE - {0xAA5A, 0xAA5B, propertyUNASSIGNED}, // .. - {0xAA5C, 0xAA5F, propertyDISALLOWED}, // CHAM PUNCTUATION SPIRAL..CHAM PUNCTUATION TR - {0xAA60, 0xAA76, propertyPVALID}, // MYANMAR LETTER KHAMTI GA..MYANMAR LOGOGRAM K - {0xAA77, 0xAA79, propertyDISALLOWED}, // MYANMAR SYMBOL AITON EXCLAMATION..MYANMAR SY - {0xAA7A, 0xAA7B, propertyPVALID}, // MYANMAR LETTER AITON RA..MYANMAR SIGN PAO KA - {0xAA7C, 0xAA7F, propertyUNASSIGNED}, // .. - {0xAA80, 0xAAC2, propertyPVALID}, // TAI VIET LETTER LOW KO..TAI VIET TONE MAI SO - {0xAAC3, 0xAADA, propertyUNASSIGNED}, // .. - {0xAADB, 0xAADD, propertyPVALID}, // TAI VIET SYMBOL KON..TAI VIET SYMBOL SAM - {0xAADE, 0xAADF, propertyDISALLOWED}, // TAI VIET SYMBOL HO HOI..TAI VIET SYMBOL KOI - {0xAAE0, 0xABBF, propertyUNASSIGNED}, // .. - {0xABC0, 0xABEA, propertyPVALID}, // MEETEI MAYEK LETTER KOK..MEETEI MAYEK VOWEL - {0xABEB, 0x0, propertyDISALLOWED}, // MEETEI MAYEK CHEIKHEI - {0xABEC, 0xABED, propertyPVALID}, // MEETEI MAYEK LUM IYEK..MEETEI MAYEK APUN IYE - {0xABEE, 0xABEF, propertyUNASSIGNED}, // .. - {0xABF0, 0xABF9, propertyPVALID}, // MEETEI MAYEK DIGIT ZERO..MEETEI MAYEK DIGIT - {0xABFA, 0xABFF, propertyUNASSIGNED}, // .. - {0xAC00, 0xD7A3, propertyPVALID}, // .. - {0xD7A4, 0xD7AF, propertyUNASSIGNED}, // .. - {0xD7B0, 0xD7C6, propertyDISALLOWED}, // HANGUL JUNGSEONG O-YEO..HANGUL JUNGSEONG ARA - {0xD7C7, 0xD7CA, propertyUNASSIGNED}, // .. - {0xD7CB, 0xD7FB, propertyDISALLOWED}, // HANGUL JONGSEONG NIEUN-RIEUL..HANGUL JONGSEO - {0xD7FC, 0xD7FF, propertyUNASSIGNED}, // .. - {0xD800, 0xFA0D, propertyDISALLOWED}, // ..CJK COMPAT - {0xFA0E, 0xFA0F, propertyPVALID}, // CJK COMPATIBILITY IDEOGRAPH-FA0E..CJK COMPAT - {0xFA10, 0x0, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA10 - {0xFA11, 0x0, propertyPVALID}, // CJK COMPATIBILITY IDEOGRAPH-FA11 - {0xFA12, 0x0, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA12 - {0xFA13, 0xFA14, propertyPVALID}, // CJK COMPATIBILITY IDEOGRAPH-FA13..CJK COMPAT - {0xFA15, 0xFA1E, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA15..CJK COMPAT - {0xFA1F, 0x0, propertyPVALID}, // CJK COMPATIBILITY IDEOGRAPH-FA1F - {0xFA20, 0x0, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA20 - {0xFA21, 0x0, propertyPVALID}, // CJK COMPATIBILITY IDEOGRAPH-FA21 - {0xFA22, 0x0, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA22 - {0xFA23, 0xFA24, propertyPVALID}, // CJK COMPATIBILITY IDEOGRAPH-FA23..CJK COMPAT - {0xFA25, 0xFA26, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA25..CJK COMPAT - {0xFA27, 0xFA29, propertyPVALID}, // CJK COMPATIBILITY IDEOGRAPH-FA27..CJK COMPAT - {0xFA2A, 0xFA2D, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA2A..CJK COMPAT - {0xFA2E, 0xFA2F, propertyUNASSIGNED}, // .. - {0xFA30, 0xFA6D, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA30..CJK COMPAT - {0xFA6E, 0xFA6F, propertyUNASSIGNED}, // .. - {0xFA70, 0xFAD9, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-FA70..CJK COMPAT - {0xFADA, 0xFAFF, propertyUNASSIGNED}, // .. - {0xFB00, 0xFB06, propertyDISALLOWED}, // LATIN SMALL LIGATURE FF..LATIN SMALL LIGATUR - {0xFB07, 0xFB12, propertyUNASSIGNED}, // .. - {0xFB13, 0xFB17, propertyDISALLOWED}, // ARMENIAN SMALL LIGATURE MEN NOW..ARMENIAN SM - {0xFB18, 0xFB1C, propertyUNASSIGNED}, // .. - {0xFB1D, 0x0, propertyDISALLOWED}, // HEBREW LETTER YOD WITH HIRIQ - {0xFB1E, 0x0, propertyPVALID}, // HEBREW POINT JUDEO-SPANISH VARIKA - {0xFB1F, 0xFB36, propertyDISALLOWED}, // HEBREW LIGATURE YIDDISH YOD YOD PATAH..HEBRE - {0xFB37, 0x0, propertyUNASSIGNED}, // - {0xFB38, 0xFB3C, propertyDISALLOWED}, // HEBREW LETTER TET WITH DAGESH..HEBREW LETTER - {0xFB3D, 0x0, propertyUNASSIGNED}, // - {0xFB3E, 0x0, propertyDISALLOWED}, // HEBREW LETTER MEM WITH DAGESH - {0xFB3F, 0x0, propertyUNASSIGNED}, // - {0xFB40, 0xFB41, propertyDISALLOWED}, // HEBREW LETTER NUN WITH DAGESH..HEBREW LETTER - {0xFB42, 0x0, propertyUNASSIGNED}, // - {0xFB43, 0xFB44, propertyDISALLOWED}, // HEBREW LETTER FINAL PE WITH DAGESH..HEBREW L - {0xFB45, 0x0, propertyUNASSIGNED}, // - {0xFB46, 0xFBB1, propertyDISALLOWED}, // HEBREW LETTER TSADI WITH DAGESH..ARABIC LETT - {0xFBB2, 0xFBD2, propertyUNASSIGNED}, // .. - {0xFBD3, 0xFD3F, propertyDISALLOWED}, // ARABIC LETTER NG ISOLATED FORM..ORNATE RIGHT - {0xFD40, 0xFD4F, propertyUNASSIGNED}, // .. - {0xFD50, 0xFD8F, propertyDISALLOWED}, // ARABIC LIGATURE TEH WITH JEEM WITH MEEM INIT - {0xFD90, 0xFD91, propertyUNASSIGNED}, // .. - {0xFD92, 0xFDC7, propertyDISALLOWED}, // ARABIC LIGATURE MEEM WITH JEEM WITH KHAH INI - {0xFDC8, 0xFDCF, propertyUNASSIGNED}, // .. - {0xFDD0, 0xFDFD, propertyDISALLOWED}, // ..ARABIC LIGATURE BISMILLAH AR - {0xFDFE, 0xFDFF, propertyUNASSIGNED}, // .. - {0xFE00, 0xFE19, propertyDISALLOWED}, // VARIATION SELECTOR-1..PRESENTATION FORM FOR - {0xFE1A, 0xFE1F, propertyUNASSIGNED}, // .. - {0xFE20, 0xFE26, propertyPVALID}, // COMBINING LIGATURE LEFT HALF..COMBINING CONJ - {0xFE27, 0xFE2F, propertyUNASSIGNED}, // .. - {0xFE30, 0xFE52, propertyDISALLOWED}, // PRESENTATION FORM FOR VERTICAL TWO DOT LEADE - {0xFE53, 0x0, propertyUNASSIGNED}, // - {0xFE54, 0xFE66, propertyDISALLOWED}, // SMALL SEMICOLON..SMALL EQUALS SIGN - {0xFE67, 0x0, propertyUNASSIGNED}, // - {0xFE68, 0xFE6B, propertyDISALLOWED}, // SMALL REVERSE SOLIDUS..SMALL COMMERCIAL AT - {0xFE6C, 0xFE6F, propertyUNASSIGNED}, // .. - {0xFE70, 0xFE72, propertyDISALLOWED}, // ARABIC FATHATAN ISOLATED FORM..ARABIC DAMMAT - {0xFE73, 0x0, propertyPVALID}, // ARABIC TAIL FRAGMENT - {0xFE74, 0x0, propertyDISALLOWED}, // ARABIC KASRATAN ISOLATED FORM - {0xFE75, 0x0, propertyUNASSIGNED}, // - {0xFE76, 0xFEFC, propertyDISALLOWED}, // ARABIC FATHA ISOLATED FORM..ARABIC LIGATURE - {0xFEFD, 0xFEFE, propertyUNASSIGNED}, // .. - {0xFEFF, 0x0, propertyDISALLOWED}, // ZERO WIDTH NO-BREAK SPACE - {0xFF00, 0x0, propertyUNASSIGNED}, // - {0xFF01, 0xFFBE, propertyDISALLOWED}, // FULLWIDTH EXCLAMATION MARK..HALFWIDTH HANGUL - {0xFFBF, 0xFFC1, propertyUNASSIGNED}, // .. - {0xFFC2, 0xFFC7, propertyDISALLOWED}, // HALFWIDTH HANGUL LETTER A..HALFWIDTH HANGUL - {0xFFC8, 0xFFC9, propertyUNASSIGNED}, // .. - {0xFFCA, 0xFFCF, propertyDISALLOWED}, // HALFWIDTH HANGUL LETTER YEO..HALFWIDTH HANGU - {0xFFD0, 0xFFD1, propertyUNASSIGNED}, // .. - {0xFFD2, 0xFFD7, propertyDISALLOWED}, // HALFWIDTH HANGUL LETTER YO..HALFWIDTH HANGUL - {0xFFD8, 0xFFD9, propertyUNASSIGNED}, // .. - {0xFFDA, 0xFFDC, propertyDISALLOWED}, // HALFWIDTH HANGUL LETTER EU..HALFWIDTH HANGUL - {0xFFDD, 0xFFDF, propertyUNASSIGNED}, // .. - {0xFFE0, 0xFFE6, propertyDISALLOWED}, // FULLWIDTH CENT SIGN..FULLWIDTH WON SIGN - {0xFFE7, 0x0, propertyUNASSIGNED}, // - {0xFFE8, 0xFFEE, propertyDISALLOWED}, // HALFWIDTH FORMS LIGHT VERTICAL..HALFWIDTH WH - {0xFFEF, 0xFFF8, propertyUNASSIGNED}, // .. - {0xFFF9, 0xFFFF, propertyDISALLOWED}, // INTERLINEAR ANNOTATION ANCHOR.. - {0x1000D, 0x10026, propertyPVALID}, // LINEAR B SYLLABLE B036 JO..LINEAR B SYLLABLE - {0x10027, 0x0, propertyUNASSIGNED}, // - {0x10028, 0x1003A, propertyPVALID}, // LINEAR B SYLLABLE B060 RA..LINEAR B SYLLABLE - {0x1003B, 0x0, propertyUNASSIGNED}, // - {0x1003C, 0x1003D, propertyPVALID}, // LINEAR B SYLLABLE B017 ZA..LINEAR B SYLLABLE - {0x1003E, 0x0, propertyUNASSIGNED}, // - {0x1003F, 0x1004D, propertyPVALID}, // LINEAR B SYLLABLE B020 ZO..LINEAR B SYLLABLE - {0x1004E, 0x1004F, propertyUNASSIGNED}, // .. - {0x10050, 0x1005D, propertyPVALID}, // LINEAR B SYMBOL B018..LINEAR B SYMBOL B089 - {0x1005E, 0x1007F, propertyUNASSIGNED}, // .. - {0x10080, 0x100FA, propertyPVALID}, // LINEAR B IDEOGRAM B100 MAN..LINEAR B IDEOGRA - {0x100FB, 0x100FF, propertyUNASSIGNED}, // .. - {0x10100, 0x10102, propertyDISALLOWED}, // AEGEAN WORD SEPARATOR LINE..AEGEAN CHECK MAR - {0x10103, 0x10106, propertyUNASSIGNED}, // .. - {0x10107, 0x10133, propertyDISALLOWED}, // AEGEAN NUMBER ONE..AEGEAN NUMBER NINETY THOU - {0x10134, 0x10136, propertyUNASSIGNED}, // .. - {0x10137, 0x1018A, propertyDISALLOWED}, // AEGEAN WEIGHT BASE UNIT..GREEK ZERO SIGN - {0x1018B, 0x1018F, propertyUNASSIGNED}, // .. - {0x10190, 0x1019B, propertyDISALLOWED}, // ROMAN SEXTANS SIGN..ROMAN CENTURIAL SIGN - {0x1019C, 0x101CF, propertyUNASSIGNED}, // .. - {0x101D0, 0x101FC, propertyDISALLOWED}, // PHAISTOS DISC SIGN PEDESTRIAN..PHAISTOS DISC - {0x101FD, 0x0, propertyPVALID}, // PHAISTOS DISC SIGN COMBINING OBLIQUE STROKE - {0x101FE, 0x1027F, propertyUNASSIGNED}, // .. - {0x10280, 0x1029C, propertyPVALID}, // LYCIAN LETTER A..LYCIAN LETTER X - {0x1029D, 0x1029F, propertyUNASSIGNED}, // .. - {0x102A0, 0x102D0, propertyPVALID}, // CARIAN LETTER A..CARIAN LETTER UUU3 - {0x102D1, 0x102FF, propertyUNASSIGNED}, // .. - {0x10300, 0x1031E, propertyPVALID}, // OLD ITALIC LETTER A..OLD ITALIC LETTER UU - {0x1031F, 0x0, propertyUNASSIGNED}, // - {0x10320, 0x10323, propertyDISALLOWED}, // OLD ITALIC NUMERAL ONE..OLD ITALIC NUMERAL F - {0x10324, 0x1032F, propertyUNASSIGNED}, // .. - {0x10330, 0x10340, propertyPVALID}, // GOTHIC LETTER AHSA..GOTHIC LETTER PAIRTHRA - {0x10341, 0x0, propertyDISALLOWED}, // GOTHIC LETTER NINETY - {0x10342, 0x10349, propertyPVALID}, // GOTHIC LETTER RAIDA..GOTHIC LETTER OTHAL - {0x1034A, 0x0, propertyDISALLOWED}, // GOTHIC LETTER NINE HUNDRED - {0x1034B, 0x1037F, propertyUNASSIGNED}, // .. - {0x10380, 0x1039D, propertyPVALID}, // UGARITIC LETTER ALPA..UGARITIC LETTER SSU - {0x1039E, 0x0, propertyUNASSIGNED}, // - {0x1039F, 0x0, propertyDISALLOWED}, // UGARITIC WORD DIVIDER - {0x103A0, 0x103C3, propertyPVALID}, // OLD PERSIAN SIGN A..OLD PERSIAN SIGN HA - {0x103C4, 0x103C7, propertyUNASSIGNED}, // .. - {0x103C8, 0x103CF, propertyPVALID}, // OLD PERSIAN SIGN AURAMAZDAA..OLD PERSIAN SIG - {0x103D0, 0x103D5, propertyDISALLOWED}, // OLD PERSIAN WORD DIVIDER..OLD PERSIAN NUMBER - {0x103D6, 0x103FF, propertyUNASSIGNED}, // .. - {0x10400, 0x10427, propertyDISALLOWED}, // DESERET CAPITAL LETTER LONG I..DESERET CAPIT - {0x10428, 0x1049D, propertyPVALID}, // DESERET SMALL LETTER LONG I..OSMANYA LETTER - {0x1049E, 0x1049F, propertyUNASSIGNED}, // .. - {0x104A0, 0x104A9, propertyPVALID}, // OSMANYA DIGIT ZERO..OSMANYA DIGIT NINE - {0x104AA, 0x107FF, propertyUNASSIGNED}, // .. - {0x10800, 0x10805, propertyPVALID}, // CYPRIOT SYLLABLE A..CYPRIOT SYLLABLE JA - {0x10806, 0x10807, propertyUNASSIGNED}, // .. - {0x10808, 0x0, propertyPVALID}, // CYPRIOT SYLLABLE JO - {0x10809, 0x0, propertyUNASSIGNED}, // - {0x1080A, 0x10835, propertyPVALID}, // CYPRIOT SYLLABLE KA..CYPRIOT SYLLABLE WO - {0x10836, 0x0, propertyUNASSIGNED}, // - {0x10837, 0x10838, propertyPVALID}, // CYPRIOT SYLLABLE XA..CYPRIOT SYLLABLE XE - {0x10839, 0x1083B, propertyUNASSIGNED}, // .. - {0x1083C, 0x0, propertyPVALID}, // CYPRIOT SYLLABLE ZA - {0x1083D, 0x1083E, propertyUNASSIGNED}, // .. - {0x1083F, 0x10855, propertyPVALID}, // CYPRIOT SYLLABLE ZO..IMPERIAL ARAMAIC LETTER - {0x10856, 0x0, propertyUNASSIGNED}, // - {0x10857, 0x1085F, propertyDISALLOWED}, // IMPERIAL ARAMAIC SECTION SIGN..IMPERIAL ARAM - {0x10860, 0x108FF, propertyUNASSIGNED}, // .. - {0x10900, 0x10915, propertyPVALID}, // PHOENICIAN LETTER ALF..PHOENICIAN LETTER TAU - {0x10916, 0x1091B, propertyDISALLOWED}, // PHOENICIAN NUMBER ONE..PHOENICIAN NUMBER THR - {0x1091C, 0x1091E, propertyUNASSIGNED}, // .. - {0x1091F, 0x0, propertyDISALLOWED}, // PHOENICIAN WORD SEPARATOR - {0x10920, 0x10939, propertyPVALID}, // LYDIAN LETTER A..LYDIAN LETTER C - {0x1093A, 0x1093E, propertyUNASSIGNED}, // .. - {0x1093F, 0x0, propertyDISALLOWED}, // LYDIAN TRIANGULAR MARK - {0x10940, 0x109FF, propertyUNASSIGNED}, // .. - {0x10A00, 0x10A03, propertyPVALID}, // KHAROSHTHI LETTER A..KHAROSHTHI VOWEL SIGN V - {0x10A04, 0x0, propertyUNASSIGNED}, // - {0x10A05, 0x10A06, propertyPVALID}, // KHAROSHTHI VOWEL SIGN E..KHAROSHTHI VOWEL SI - {0x10A07, 0x10A0B, propertyUNASSIGNED}, // .. - {0x10A0C, 0x10A13, propertyPVALID}, // KHAROSHTHI VOWEL LENGTH MARK..KHAROSHTHI LET - {0x10A14, 0x0, propertyUNASSIGNED}, // - {0x10A15, 0x10A17, propertyPVALID}, // KHAROSHTHI LETTER CA..KHAROSHTHI LETTER JA - {0x10A18, 0x0, propertyUNASSIGNED}, // - {0x10A19, 0x10A33, propertyPVALID}, // KHAROSHTHI LETTER NYA..KHAROSHTHI LETTER TTT - {0x10A34, 0x10A37, propertyUNASSIGNED}, // .. - {0x10A38, 0x10A3A, propertyPVALID}, // KHAROSHTHI SIGN BAR ABOVE..KHAROSHTHI SIGN D - {0x10A3B, 0x10A3E, propertyUNASSIGNED}, // .. - {0x10A3F, 0x0, propertyPVALID}, // KHAROSHTHI VIRAMA - {0x10A40, 0x10A47, propertyDISALLOWED}, // KHAROSHTHI DIGIT ONE..KHAROSHTHI NUMBER ONE - {0x10A48, 0x10A4F, propertyUNASSIGNED}, // .. - {0x10A50, 0x10A58, propertyDISALLOWED}, // KHAROSHTHI PUNCTUATION DOT..KHAROSHTHI PUNCT - {0x10A59, 0x10A5F, propertyUNASSIGNED}, // .. - {0x10A60, 0x10A7C, propertyPVALID}, // OLD SOUTH ARABIAN LETTER HE..OLD SOUTH ARABI - {0x10A7D, 0x10A7F, propertyDISALLOWED}, // OLD SOUTH ARABIAN NUMBER ONE..OLD SOUTH ARAB - {0x10A80, 0x10AFF, propertyUNASSIGNED}, // .. - {0x10B00, 0x10B35, propertyPVALID}, // AVESTAN LETTER A..AVESTAN LETTER HE - {0x10B36, 0x10B38, propertyUNASSIGNED}, // .. - {0x10B39, 0x10B3F, propertyDISALLOWED}, // AVESTAN ABBREVIATION MARK..LARGE ONE RING OV - {0x10B40, 0x10B55, propertyPVALID}, // INSCRIPTIONAL PARTHIAN LETTER ALEPH..INSCRIP - {0x10B56, 0x10B57, propertyUNASSIGNED}, // .. - {0x10B58, 0x10B5F, propertyDISALLOWED}, // INSCRIPTIONAL PARTHIAN NUMBER ONE..INSCRIPTI - {0x10B60, 0x10B72, propertyPVALID}, // INSCRIPTIONAL PAHLAVI LETTER ALEPH..INSCRIPT - {0x10B73, 0x10B77, propertyUNASSIGNED}, // .. - {0x10B78, 0x10B7F, propertyDISALLOWED}, // INSCRIPTIONAL PAHLAVI NUMBER ONE..INSCRIPTIO - {0x10B80, 0x10BFF, propertyUNASSIGNED}, // .. - {0x10C00, 0x10C48, propertyPVALID}, // OLD TURKIC LETTER ORKHON A..OLD TURKIC LETTE - {0x10C49, 0x10E5F, propertyUNASSIGNED}, // .. - {0x10E60, 0x10E7E, propertyDISALLOWED}, // RUMI DIGIT ONE..RUMI FRACTION TWO THIRDS - {0x10E7F, 0x1107F, propertyUNASSIGNED}, // .. - {0x11080, 0x110BA, propertyPVALID}, // KAITHI SIGN CANDRABINDU..KAITHI SIGN NUKTA - {0x110BB, 0x110C1, propertyDISALLOWED}, // KAITHI ABBREVIATION SIGN..KAITHI DOUBLE DAND - {0x110C2, 0x11FFF, propertyUNASSIGNED}, // .. - {0x12000, 0x1236E, propertyPVALID}, // CUNEIFORM SIGN A..CUNEIFORM SIGN ZUM - {0x1236F, 0x123FF, propertyUNASSIGNED}, // .. - {0x12400, 0x12462, propertyDISALLOWED}, // CUNEIFORM NUMERIC SIGN TWO ASH..CUNEIFORM NU - {0x12463, 0x1246F, propertyUNASSIGNED}, // .. - {0x12470, 0x12473, propertyDISALLOWED}, // CUNEIFORM PUNCTUATION SIGN OLD ASSYRIAN WORD - {0x12474, 0x12FFF, propertyUNASSIGNED}, // .. - {0x13000, 0x1342E, propertyPVALID}, // EGYPTIAN HIEROGLYPH A001..EGYPTIAN HIEROGLYP - {0x1342F, 0x1CFFF, propertyUNASSIGNED}, // .. - {0x1D000, 0x1D0F5, propertyDISALLOWED}, // BYZANTINE MUSICAL SYMBOL PSILI..BYZANTINE MU - {0x1D0F6, 0x1D0FF, propertyUNASSIGNED}, // .. - {0x1D100, 0x1D126, propertyDISALLOWED}, // MUSICAL SYMBOL SINGLE BARLINE..MUSICAL SYMBO - {0x1D127, 0x1D128, propertyUNASSIGNED}, // .. - {0x1D129, 0x1D1DD, propertyDISALLOWED}, // MUSICAL SYMBOL MULTIPLE MEASURE REST..MUSICA - {0x1D1DE, 0x1D1FF, propertyUNASSIGNED}, // .. - {0x1D200, 0x1D245, propertyDISALLOWED}, // GREEK VOCAL NOTATION SYMBOL-1..GREEK MUSICAL - {0x1D246, 0x1D2FF, propertyUNASSIGNED}, // .. - {0x1D300, 0x1D356, propertyDISALLOWED}, // MONOGRAM FOR EARTH..TETRAGRAM FOR FOSTERING - {0x1D357, 0x1D35F, propertyUNASSIGNED}, // .. - {0x1D360, 0x1D371, propertyDISALLOWED}, // COUNTING ROD UNIT DIGIT ONE..COUNTING ROD TE - {0x1D372, 0x1D3FF, propertyUNASSIGNED}, // .. - {0x1D400, 0x1D454, propertyDISALLOWED}, // MATHEMATICAL BOLD CAPITAL A..MATHEMATICAL IT - {0x1D455, 0x0, propertyUNASSIGNED}, // - {0x1D456, 0x1D49C, propertyDISALLOWED}, // MATHEMATICAL ITALIC SMALL I..MATHEMATICAL SC - {0x1D49D, 0x0, propertyUNASSIGNED}, // - {0x1D49E, 0x1D49F, propertyDISALLOWED}, // MATHEMATICAL SCRIPT CAPITAL C..MATHEMATICAL - {0x1D4A0, 0x1D4A1, propertyUNASSIGNED}, // .. - {0x1D4A2, 0x0, propertyDISALLOWED}, // MATHEMATICAL SCRIPT CAPITAL G - {0x1D4A3, 0x1D4A4, propertyUNASSIGNED}, // .. - {0x1D4A5, 0x1D4A6, propertyDISALLOWED}, // MATHEMATICAL SCRIPT CAPITAL J..MATHEMATICAL - {0x1D4A7, 0x1D4A8, propertyUNASSIGNED}, // .. - {0x1D4A9, 0x1D4AC, propertyDISALLOWED}, // MATHEMATICAL SCRIPT CAPITAL N..MATHEMATICAL - {0x1D4AD, 0x0, propertyUNASSIGNED}, // - {0x1D4AE, 0x1D4B9, propertyDISALLOWED}, // MATHEMATICAL SCRIPT CAPITAL S..MATHEMATICAL - {0x1D4BA, 0x0, propertyUNASSIGNED}, // - {0x1D4BB, 0x0, propertyDISALLOWED}, // MATHEMATICAL SCRIPT SMALL F - {0x1D4BC, 0x0, propertyUNASSIGNED}, // - {0x1D4BD, 0x1D4C3, propertyDISALLOWED}, // MATHEMATICAL SCRIPT SMALL H..MATHEMATICAL SC - {0x1D4C4, 0x0, propertyUNASSIGNED}, // - {0x1D4C5, 0x1D505, propertyDISALLOWED}, // MATHEMATICAL SCRIPT SMALL P..MATHEMATICAL FR - {0x1D506, 0x0, propertyUNASSIGNED}, // - {0x1D507, 0x1D50A, propertyDISALLOWED}, // MATHEMATICAL FRAKTUR CAPITAL D..MATHEMATICAL - {0x1D50B, 0x1D50C, propertyUNASSIGNED}, // .. - {0x1D50D, 0x1D514, propertyDISALLOWED}, // MATHEMATICAL FRAKTUR CAPITAL J..MATHEMATICAL - {0x1D515, 0x0, propertyUNASSIGNED}, // - {0x1D516, 0x1D51C, propertyDISALLOWED}, // MATHEMATICAL FRAKTUR CAPITAL S..MATHEMATICAL - {0x1D51D, 0x0, propertyUNASSIGNED}, // - {0x1D51E, 0x1D539, propertyDISALLOWED}, // MATHEMATICAL FRAKTUR SMALL A..MATHEMATICAL D - {0x1D53A, 0x0, propertyUNASSIGNED}, // - {0x1D53B, 0x1D53E, propertyDISALLOWED}, // MATHEMATICAL DOUBLE-STRUCK CAPITAL D..MATHEM - {0x1D53F, 0x0, propertyUNASSIGNED}, // - {0x1D540, 0x1D544, propertyDISALLOWED}, // MATHEMATICAL DOUBLE-STRUCK CAPITAL I..MATHEM - {0x1D545, 0x0, propertyUNASSIGNED}, // - {0x1D546, 0x0, propertyDISALLOWED}, // MATHEMATICAL DOUBLE-STRUCK CAPITAL O - {0x1D547, 0x1D549, propertyUNASSIGNED}, // .. - {0x1D54A, 0x1D550, propertyDISALLOWED}, // MATHEMATICAL DOUBLE-STRUCK CAPITAL S..MATHEM - {0x1D551, 0x0, propertyUNASSIGNED}, // - {0x1D552, 0x1D6A5, propertyDISALLOWED}, // MATHEMATICAL DOUBLE-STRUCK SMALL A..MATHEMAT - {0x1D6A6, 0x1D6A7, propertyUNASSIGNED}, // .. - {0x1D6A8, 0x1D7CB, propertyDISALLOWED}, // MATHEMATICAL BOLD CAPITAL ALPHA..MATHEMATICA - {0x1D7CC, 0x1D7CD, propertyUNASSIGNED}, // .. - {0x1D7CE, 0x1D7FF, propertyDISALLOWED}, // MATHEMATICAL BOLD DIGIT ZERO..MATHEMATICAL M - {0x1D800, 0x1EFFF, propertyUNASSIGNED}, // .. - {0x1F000, 0x1F02B, propertyDISALLOWED}, // MAHJONG TILE EAST WIND..MAHJONG TILE BACK - {0x1F02C, 0x1F02F, propertyUNASSIGNED}, // .. - {0x1F030, 0x1F093, propertyDISALLOWED}, // DOMINO TILE HORIZONTAL BACK..DOMINO TILE VER - {0x1F094, 0x1F0FF, propertyUNASSIGNED}, // .. - {0x1F100, 0x1F10A, propertyDISALLOWED}, // DIGIT ZERO FULL STOP..DIGIT NINE COMMA - {0x1F10B, 0x1F10F, propertyUNASSIGNED}, // .. - {0x1F110, 0x1F12E, propertyDISALLOWED}, // PARENTHESIZED LATIN CAPITAL LETTER A..CIRCLE - {0x1F12F, 0x1F130, propertyUNASSIGNED}, // .. - {0x1F131, 0x0, propertyDISALLOWED}, // SQUARED LATIN CAPITAL LETTER B - {0x1F132, 0x1F13C, propertyUNASSIGNED}, // .. - {0x1F13D, 0x0, propertyDISALLOWED}, // SQUARED LATIN CAPITAL LETTER N - {0x1F13E, 0x0, propertyUNASSIGNED}, // - {0x1F13F, 0x0, propertyDISALLOWED}, // SQUARED LATIN CAPITAL LETTER P - {0x1F140, 0x1F141, propertyUNASSIGNED}, // .. - {0x1F142, 0x0, propertyDISALLOWED}, // SQUARED LATIN CAPITAL LETTER S - {0x1F143, 0x1F145, propertyUNASSIGNED}, // .. - {0x1F146, 0x0, propertyDISALLOWED}, // SQUARED LATIN CAPITAL LETTER W - {0x1F147, 0x1F149, propertyUNASSIGNED}, // .. - {0x1F14A, 0x1F14E, propertyDISALLOWED}, // SQUARED HV..SQUARED PPV - {0x1F14F, 0x1F156, propertyUNASSIGNED}, // .. - {0x1F157, 0x0, propertyDISALLOWED}, // NEGATIVE CIRCLED LATIN CAPITAL LETTER H - {0x1F158, 0x1F15E, propertyUNASSIGNED}, // .. - {0x1F15F, 0x0, propertyDISALLOWED}, // NEGATIVE CIRCLED LATIN CAPITAL LETTER P - {0x1F160, 0x1F178, propertyUNASSIGNED}, // .. - {0x1F179, 0x0, propertyDISALLOWED}, // NEGATIVE SQUARED LATIN CAPITAL LETTER J - {0x1F17A, 0x0, propertyUNASSIGNED}, // - {0x1F17B, 0x1F17C, propertyDISALLOWED}, // NEGATIVE SQUARED LATIN CAPITAL LETTER L..NEG - {0x1F17D, 0x1F17E, propertyUNASSIGNED}, // .. - {0x1F17F, 0x0, propertyDISALLOWED}, // NEGATIVE SQUARED LATIN CAPITAL LETTER P - {0x1F180, 0x1F189, propertyUNASSIGNED}, // .. - {0x1F18A, 0x1F18D, propertyDISALLOWED}, // CROSSED NEGATIVE SQUARED LATIN CAPITAL LETTE - {0x1F18E, 0x1F18F, propertyUNASSIGNED}, // .. - {0x1F190, 0x0, propertyDISALLOWED}, // SQUARE DJ - {0x1F191, 0x1F1FF, propertyUNASSIGNED}, // .. - {0x1F200, 0x0, propertyDISALLOWED}, // SQUARE HIRAGANA HOKA - {0x1F201, 0x1F20F, propertyUNASSIGNED}, // .. - {0x1F210, 0x1F231, propertyDISALLOWED}, // SQUARED CJK UNIFIED IDEOGRAPH-624B..SQUARED - {0x1F232, 0x1F23F, propertyUNASSIGNED}, // .. - {0x1F240, 0x1F248, propertyDISALLOWED}, // TORTOISE SHELL BRACKETED CJK UNIFIED IDEOGRA - {0x1F249, 0x1FFFD, propertyUNASSIGNED}, // .. - {0x1FFFE, 0x1FFFF, propertyDISALLOWED}, // .. - {0x20000, 0x2A6D6, propertyPVALID}, // .... - {0x2A700, 0x2B734, propertyPVALID}, // .... - {0x2F800, 0x2FA1D, propertyDISALLOWED}, // CJK COMPATIBILITY IDEOGRAPH-2F800..CJK COMPA - {0x2FA1E, 0x2FFFD, propertyUNASSIGNED}, // .. - {0x2FFFE, 0x2FFFF, propertyDISALLOWED}, // .. - {0x30000, 0x3FFFD, propertyUNASSIGNED}, // .. - {0x3FFFE, 0x3FFFF, propertyDISALLOWED}, // .. - {0x40000, 0x4FFFD, propertyUNASSIGNED}, // .. - {0x4FFFE, 0x4FFFF, propertyDISALLOWED}, // .. - {0x50000, 0x5FFFD, propertyUNASSIGNED}, // .. - {0x5FFFE, 0x5FFFF, propertyDISALLOWED}, // .. - {0x60000, 0x6FFFD, propertyUNASSIGNED}, // .. - {0x6FFFE, 0x6FFFF, propertyDISALLOWED}, // .. - {0x70000, 0x7FFFD, propertyUNASSIGNED}, // .. - {0x7FFFE, 0x7FFFF, propertyDISALLOWED}, // .. - {0x80000, 0x8FFFD, propertyUNASSIGNED}, // .. - {0x8FFFE, 0x8FFFF, propertyDISALLOWED}, // .. - {0x90000, 0x9FFFD, propertyUNASSIGNED}, // .. - {0x9FFFE, 0x9FFFF, propertyDISALLOWED}, // .. - {0xA0000, 0xAFFFD, propertyUNASSIGNED}, // .. - {0xAFFFE, 0xAFFFF, propertyDISALLOWED}, // .. - {0xB0000, 0xBFFFD, propertyUNASSIGNED}, // .. - {0xBFFFE, 0xBFFFF, propertyDISALLOWED}, // .. - {0xC0000, 0xCFFFD, propertyUNASSIGNED}, // .. - {0xCFFFE, 0xCFFFF, propertyDISALLOWED}, // .. - {0xD0000, 0xDFFFD, propertyUNASSIGNED}, // .. - {0xDFFFE, 0xDFFFF, propertyDISALLOWED}, // .. - {0xE0000, 0x0, propertyUNASSIGNED}, // - {0xE0001, 0x0, propertyDISALLOWED}, // LANGUAGE TAG - {0xE0002, 0xE001F, propertyUNASSIGNED}, // .. - {0xE0020, 0xE007F, propertyDISALLOWED}, // TAG SPACE..CANCEL TAG - {0xE0080, 0xE00FF, propertyUNASSIGNED}, // .. - {0xE0100, 0xE01EF, propertyDISALLOWED}, // VARIATION SELECTOR-17..VARIATION SELECTOR-25 - {0xE01F0, 0xEFFFD, propertyUNASSIGNED}, // .. - {0xEFFFE, 0x10FFFF, propertyDISALLOWED}, // .. -} diff --git a/vendor/github.com/miekg/dns/idn/example_test.go b/vendor/github.com/miekg/dns/idn/example_test.go deleted file mode 100644 index 8833cd9..0000000 --- a/vendor/github.com/miekg/dns/idn/example_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package idn_test - -import ( - "fmt" - "github.com/miekg/dns/idn" -) - -func ExampleToPunycode() { - name := "インターãƒãƒƒãƒˆ.テスト" - fmt.Printf("%s -> %s", name, idn.ToPunycode(name)) - // Output: インターãƒãƒƒãƒˆ.テスト -> xn--eckucmux0ukc.xn--zckzah -} - -func ExampleFromPunycode() { - name := "xn--mgbaja8a1hpac.xn--mgbachtv" - fmt.Printf("%s -> %s", name, idn.FromPunycode(name)) - // Output: xn--mgbaja8a1hpac.xn--mgbachtv -> الانترنت.اختبار -} diff --git a/vendor/github.com/miekg/dns/idn/punycode.go b/vendor/github.com/miekg/dns/idn/punycode.go deleted file mode 100644 index 7e5c263..0000000 --- a/vendor/github.com/miekg/dns/idn/punycode.go +++ /dev/null @@ -1,373 +0,0 @@ -// Package idn implements encoding from and to punycode as speficied by RFC 3492. -package idn - -import ( - "bytes" - "strings" - "unicode" - "unicode/utf8" - - "github.com/miekg/dns" -) - -// Implementation idea from RFC itself and from from IDNA::Punycode created by -// Tatsuhiko Miyagawa and released under Perl Artistic -// License in 2002. - -const ( - _MIN rune = 1 - _MAX rune = 26 - _SKEW rune = 38 - _BASE rune = 36 - _BIAS rune = 72 - _N rune = 128 - _DAMP rune = 700 - - _DELIMITER = '-' - _PREFIX = "xn--" -) - -// ToPunycode converts unicode domain names to DNS-appropriate punycode names. -// This function will return an empty string result for domain names with -// invalid unicode strings. This function expects domain names in lowercase. -func ToPunycode(s string) string { - // Early check to see if encoding is needed. - // This will prevent making heap allocations when not needed. - if !needToPunycode(s) { - return s - } - - tokens := dns.SplitDomainName(s) - switch { - case s == "": - return "" - case tokens == nil: // s == . - return "." - case s[len(s)-1] == '.': - tokens = append(tokens, "") - } - - for i := range tokens { - t := encode([]byte(tokens[i])) - if t == nil { - return "" - } - tokens[i] = string(t) - } - return strings.Join(tokens, ".") -} - -// FromPunycode returns unicode domain name from provided punycode string. -// This function expects punycode strings in lowercase. -func FromPunycode(s string) string { - // Early check to see if decoding is needed. - // This will prevent making heap allocations when not needed. - if !needFromPunycode(s) { - return s - } - - tokens := dns.SplitDomainName(s) - switch { - case s == "": - return "" - case tokens == nil: // s == . - return "." - case s[len(s)-1] == '.': - tokens = append(tokens, "") - } - for i := range tokens { - tokens[i] = string(decode([]byte(tokens[i]))) - } - return strings.Join(tokens, ".") -} - -// digitval converts single byte into meaningful value that's used to calculate decoded unicode character. -const errdigit = 0xffff - -func digitval(code rune) rune { - switch { - case code >= 'A' && code <= 'Z': - return code - 'A' - case code >= 'a' && code <= 'z': - return code - 'a' - case code >= '0' && code <= '9': - return code - '0' + 26 - } - return errdigit -} - -// lettercode finds BASE36 byte (a-z0-9) based on calculated number. -func lettercode(digit rune) rune { - switch { - case digit >= 0 && digit <= 25: - return digit + 'a' - case digit >= 26 && digit <= 36: - return digit - 26 + '0' - } - panic("dns: not reached") -} - -// adapt calculates next bias to be used for next iteration delta. -func adapt(delta rune, numpoints int, firsttime bool) rune { - if firsttime { - delta /= _DAMP - } else { - delta /= 2 - } - - var k rune - for delta = delta + delta/rune(numpoints); delta > (_BASE-_MIN)*_MAX/2; k += _BASE { - delta /= _BASE - _MIN - } - - return k + ((_BASE-_MIN+1)*delta)/(delta+_SKEW) -} - -// next finds minimal rune (one with lowest codepoint value) that should be equal or above boundary. -func next(b []rune, boundary rune) rune { - if len(b) == 0 { - panic("dns: invalid set of runes to determine next one") - } - m := b[0] - for _, x := range b[1:] { - if x >= boundary && (m < boundary || x < m) { - m = x - } - } - return m -} - -// preprune converts unicode rune to lower case. At this time it's not -// supporting all things described in RFCs. -func preprune(r rune) rune { - if unicode.IsUpper(r) { - r = unicode.ToLower(r) - } - return r -} - -// tfunc is a function that helps calculate each character weight. -func tfunc(k, bias rune) rune { - switch { - case k <= bias: - return _MIN - case k >= bias+_MAX: - return _MAX - } - return k - bias -} - -// needToPunycode returns true for strings that require punycode encoding -// (contain unicode characters). -func needToPunycode(s string) bool { - // This function is very similar to bytes.Runes. We don't use bytes.Runes - // because it makes a heap allocation that's not needed here. - for i := 0; len(s) > 0; i++ { - r, l := utf8.DecodeRuneInString(s) - if r > 0x7f { - return true - } - s = s[l:] - } - return false -} - -// needFromPunycode returns true for strings that require punycode decoding. -func needFromPunycode(s string) bool { - if s == "." { - return false - } - - off := 0 - end := false - pl := len(_PREFIX) - sl := len(s) - - // If s starts with _PREFIX. - if sl > pl && s[off:off+pl] == _PREFIX { - return true - } - - for { - // Find the part after the next ".". - off, end = dns.NextLabel(s, off) - if end { - return false - } - // If this parts starts with _PREFIX. - if sl-off > pl && s[off:off+pl] == _PREFIX { - return true - } - } -} - -// encode transforms Unicode input bytes (that represent DNS label) into -// punycode bytestream. This function would return nil if there's an invalid -// character in the label. -func encode(input []byte) []byte { - n, bias := _N, _BIAS - - b := bytes.Runes(input) - for i := range b { - if !isValidRune(b[i]) { - return nil - } - - b[i] = preprune(b[i]) - } - - basic := make([]byte, 0, len(b)) - for _, ltr := range b { - if ltr <= 0x7f { - basic = append(basic, byte(ltr)) - } - } - basiclen := len(basic) - fulllen := len(b) - if basiclen == fulllen { - return basic - } - - var out bytes.Buffer - - out.WriteString(_PREFIX) - if basiclen > 0 { - out.Write(basic) - out.WriteByte(_DELIMITER) - } - - var ( - ltr, nextltr rune - delta, q rune // delta calculation (see rfc) - t, k, cp rune // weight and codepoint calculation - ) - - s := &bytes.Buffer{} - for h := basiclen; h < fulllen; n, delta = n+1, delta+1 { - nextltr = next(b, n) - s.Truncate(0) - s.WriteRune(nextltr) - delta, n = delta+(nextltr-n)*rune(h+1), nextltr - - for _, ltr = range b { - if ltr < n { - delta++ - } - if ltr == n { - q = delta - for k = _BASE; ; k += _BASE { - t = tfunc(k, bias) - if q < t { - break - } - cp = t + ((q - t) % (_BASE - t)) - out.WriteRune(lettercode(cp)) - q = (q - t) / (_BASE - t) - } - - out.WriteRune(lettercode(q)) - - bias = adapt(delta, h+1, h == basiclen) - h, delta = h+1, 0 - } - } - } - return out.Bytes() -} - -// decode transforms punycode input bytes (that represent DNS label) into Unicode bytestream. -func decode(b []byte) []byte { - src := b // b would move and we need to keep it - - n, bias := _N, _BIAS - if !bytes.HasPrefix(b, []byte(_PREFIX)) { - return b - } - out := make([]rune, 0, len(b)) - b = b[len(_PREFIX):] - for pos := len(b) - 1; pos >= 0; pos-- { - // only last delimiter is our interest - if b[pos] == _DELIMITER { - out = append(out, bytes.Runes(b[:pos])...) - b = b[pos+1:] // trim source string - break - } - } - if len(b) == 0 { - return src - } - var ( - i, oldi, w rune - ch byte - t, digit rune - ln int - ) - - for i = 0; len(b) > 0; i++ { - oldi, w = i, 1 - for k := _BASE; len(b) > 0; k += _BASE { - ch, b = b[0], b[1:] - digit = digitval(rune(ch)) - if digit == errdigit { - return src - } - i += digit * w - if i < 0 { - // safety check for rune overflow - return src - } - - t = tfunc(k, bias) - if digit < t { - break - } - - w *= _BASE - t - } - ln = len(out) + 1 - bias = adapt(i-oldi, ln, oldi == 0) - n += i / rune(ln) - i = i % rune(ln) - // insert - out = append(out, 0) - copy(out[i+1:], out[i:]) - out[i] = n - } - - var ret bytes.Buffer - for _, r := range out { - ret.WriteRune(r) - } - return ret.Bytes() -} - -// isValidRune checks if the character is valid. We will look for the -// character property in the code points list. For now we aren't checking special -// rules in case of contextual property -func isValidRune(r rune) bool { - return findProperty(r) == propertyPVALID -} - -// findProperty will try to check the code point property of the given -// character. It will use a binary search algorithm as we have a slice of -// ordered ranges (average case performance O(log n)) -func findProperty(r rune) property { - imin, imax := 0, len(codePoints) - - for imax >= imin { - imid := (imin + imax) / 2 - - codePoint := codePoints[imid] - if (codePoint.start == r && codePoint.end == 0) || (codePoint.start <= r && codePoint.end >= r) { - return codePoint.state - } - - if (codePoint.end > 0 && codePoint.end < r) || (codePoint.end == 0 && codePoint.start < r) { - imin = imid + 1 - } else { - imax = imid - 1 - } - } - - return propertyUnknown -} diff --git a/vendor/github.com/miekg/dns/idn/punycode_test.go b/vendor/github.com/miekg/dns/idn/punycode_test.go deleted file mode 100644 index 9c9a15f..0000000 --- a/vendor/github.com/miekg/dns/idn/punycode_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package idn - -import ( - "strings" - "testing" -) - -var testcases = [][2]string{ - {"", ""}, - {"a", "a"}, - {"a-b", "a-b"}, - {"a-b-c", "a-b-c"}, - {"abc", "abc"}, - {"Ñ", "xn--41a"}, - {"zÑ", "xn--z-0ub"}, - {"ÑZ", "xn--z-zub"}, - {"а-Ñ", "xn----7sb8g"}, - {"إختبار", "xn--kgbechtv"}, - {"آزمایشی", "xn--hgbk6aj7f53bba"}, - {"测试", "xn--0zwm56d"}, - {"測試", "xn--g6w251d"}, - {"иÑпытание", "xn--80akhbyknj4f"}, - {"परीकà¥à¤·à¤¾", "xn--11b5bs3a9aj6g"}, - {"δοκιμή", "xn--jxalpdlp"}, - {"테스트", "xn--9t4b11yi5a"}, - {"טעסט", "xn--deba0ad"}, - {"テスト", "xn--zckzah"}, - {"பரிடà¯à®šà¯ˆ", "xn--hlcj6aya9esc7a"}, - {"mamão-com-açúcar", "xn--mamo-com-acar-yeb1e6q"}, - {"σ", "xn--4xa"}, -} - -func TestEncodeDecodePunycode(t *testing.T) { - for _, tst := range testcases { - enc := encode([]byte(tst[0])) - if string(enc) != tst[1] { - t.Errorf("%s encodeded as %s but should be %s", tst[0], enc, tst[1]) - } - dec := decode([]byte(tst[1])) - if string(dec) != strings.ToLower(tst[0]) { - t.Errorf("%s decoded as %s but should be %s", tst[1], dec, strings.ToLower(tst[0])) - } - } -} - -func TestToFromPunycode(t *testing.T) { - for _, tst := range testcases { - // assert unicode.com == punycode.com - full := ToPunycode(tst[0] + ".com") - if full != tst[1]+".com" { - t.Errorf("invalid result from string conversion to punycode, %s and should be %s.com", full, tst[1]) - } - // assert punycode.punycode == unicode.unicode - decoded := FromPunycode(tst[1] + "." + tst[1]) - if decoded != strings.ToLower(tst[0]+"."+tst[0]) { - t.Errorf("invalid result from string conversion to punycode, %s and should be %s.%s", decoded, tst[0], tst[0]) - } - } -} - -func TestEncodeDecodeFinalPeriod(t *testing.T) { - for _, tst := range testcases { - // assert unicode.com. == punycode.com. - full := ToPunycode(tst[0] + ".") - if full != tst[1]+"." { - t.Errorf("invalid result from string conversion to punycode when period added at the end, %#v and should be %#v", full, tst[1]+".") - } - // assert punycode.com. == unicode.com. - decoded := FromPunycode(tst[1] + ".") - if decoded != strings.ToLower(tst[0]+".") { - t.Errorf("invalid result from string conversion to punycode when period added, %#v and should be %#v", decoded, tst[0]+".") - } - full = ToPunycode(tst[0]) - if full != tst[1] { - t.Errorf("invalid result from string conversion to punycode when no period added at the end, %#v and should be %#v", full, tst[1]+".") - } - // assert punycode.com. == unicode.com. - decoded = FromPunycode(tst[1]) - if decoded != strings.ToLower(tst[0]) { - t.Errorf("invalid result from string conversion to punycode when no period added, %#v and should be %#v", decoded, tst[0]+".") - } - } -} - -var invalidACEs = []string{ - "xn--*", - "xn--", - "xn---", - "xn--a000000000", -} - -func TestInvalidPunycode(t *testing.T) { - for _, d := range invalidACEs { - s := FromPunycode(d) - if s != d { - t.Errorf("Changed invalid name %s to %#v", d, s) - } - } -} - -// You can verify the labels that are valid or not comparing to the Verisign -// website: http://mct.verisign-grs.com/ -var invalidUnicodes = []string{ - "Σ", - "ЯZ", - "ИÑпытание", -} - -func TestInvalidUnicodes(t *testing.T) { - for _, d := range invalidUnicodes { - s := ToPunycode(d) - if s != "" { - t.Errorf("Changed invalid name %s to %#v", d, s) - } - } -} diff --git a/vendor/github.com/miekg/dns/issue_test.go b/vendor/github.com/miekg/dns/issue_test.go deleted file mode 100644 index 3025fc9..0000000 --- a/vendor/github.com/miekg/dns/issue_test.go +++ /dev/null @@ -1,23 +0,0 @@ -package dns - -// Tests that solve that an specific issue. - -import "testing" - -func TestTCPRtt(t *testing.T) { - m := new(Msg) - m.RecursionDesired = true - m.SetQuestion("example.org.", TypeA) - - c := &Client{} - for _, proto := range []string{"udp", "tcp"} { - c.Net = proto - _, rtt, err := c.Exchange(m, "8.8.4.4:53") - if err != nil { - t.Fatal(err) - } - if rtt == 0 { - t.Fatalf("expecting non zero rtt %s, got zero", c.Net) - } - } -} diff --git a/vendor/github.com/miekg/dns/labels.go b/vendor/github.com/miekg/dns/labels.go deleted file mode 100644 index fca5c7d..0000000 --- a/vendor/github.com/miekg/dns/labels.go +++ /dev/null @@ -1,168 +0,0 @@ -package dns - -// Holds a bunch of helper functions for dealing with labels. - -// SplitDomainName splits a name string into it's labels. -// www.miek.nl. returns []string{"www", "miek", "nl"} -// .www.miek.nl. returns []string{"", "www", "miek", "nl"}, -// The root label (.) returns nil. Note that using -// strings.Split(s) will work in most cases, but does not handle -// escaped dots (\.) for instance. -// s must be a syntactically valid domain name, see IsDomainName. -func SplitDomainName(s string) (labels []string) { - if len(s) == 0 { - return nil - } - fqdnEnd := 0 // offset of the final '.' or the length of the name - idx := Split(s) - begin := 0 - if s[len(s)-1] == '.' { - fqdnEnd = len(s) - 1 - } else { - fqdnEnd = len(s) - } - - switch len(idx) { - case 0: - return nil - case 1: - // no-op - default: - end := 0 - for i := 1; i < len(idx); i++ { - end = idx[i] - labels = append(labels, s[begin:end-1]) - begin = end - } - } - - labels = append(labels, s[begin:fqdnEnd]) - return labels -} - -// CompareDomainName compares the names s1 and s2 and -// returns how many labels they have in common starting from the *right*. -// The comparison stops at the first inequality. The names are not downcased -// before the comparison. -// -// www.miek.nl. and miek.nl. have two labels in common: miek and nl -// www.miek.nl. and www.bla.nl. have one label in common: nl -// -// s1 and s2 must be syntactically valid domain names. -func CompareDomainName(s1, s2 string) (n int) { - s1 = Fqdn(s1) - s2 = Fqdn(s2) - l1 := Split(s1) - l2 := Split(s2) - - // the first check: root label - if l1 == nil || l2 == nil { - return - } - - j1 := len(l1) - 1 // end - i1 := len(l1) - 2 // start - j2 := len(l2) - 1 - i2 := len(l2) - 2 - // the second check can be done here: last/only label - // before we fall through into the for-loop below - if s1[l1[j1]:] == s2[l2[j2]:] { - n++ - } else { - return - } - for { - if i1 < 0 || i2 < 0 { - break - } - if s1[l1[i1]:l1[j1]] == s2[l2[i2]:l2[j2]] { - n++ - } else { - break - } - j1-- - i1-- - j2-- - i2-- - } - return -} - -// CountLabel counts the the number of labels in the string s. -// s must be a syntactically valid domain name. -func CountLabel(s string) (labels int) { - if s == "." { - return - } - off := 0 - end := false - for { - off, end = NextLabel(s, off) - labels++ - if end { - return - } - } -} - -// Split splits a name s into its label indexes. -// www.miek.nl. returns []int{0, 4, 9}, www.miek.nl also returns []int{0, 4, 9}. -// The root name (.) returns nil. Also see SplitDomainName. -// s must be a syntactically valid domain name. -func Split(s string) []int { - if s == "." { - return nil - } - idx := make([]int, 1, 3) - off := 0 - end := false - - for { - off, end = NextLabel(s, off) - if end { - return idx - } - idx = append(idx, off) - } -} - -// NextLabel returns the index of the start of the next label in the -// string s starting at offset. -// The bool end is true when the end of the string has been reached. -// Also see PrevLabel. -func NextLabel(s string, offset int) (i int, end bool) { - quote := false - for i = offset; i < len(s)-1; i++ { - switch s[i] { - case '\\': - quote = !quote - default: - quote = false - case '.': - if quote { - quote = !quote - continue - } - return i + 1, false - } - } - return i + 1, true -} - -// PrevLabel returns the index of the label when starting from the right and -// jumping n labels to the left. -// The bool start is true when the start of the string has been overshot. -// Also see NextLabel. -func PrevLabel(s string, n int) (i int, start bool) { - if n == 0 { - return len(s), false - } - lab := Split(s) - if lab == nil { - return 0, true - } - if n > len(lab) { - return 0, true - } - return lab[len(lab)-n], false -} diff --git a/vendor/github.com/miekg/dns/labels_test.go b/vendor/github.com/miekg/dns/labels_test.go deleted file mode 100644 index 536757d..0000000 --- a/vendor/github.com/miekg/dns/labels_test.go +++ /dev/null @@ -1,200 +0,0 @@ -package dns - -import "testing" - -func TestCompareDomainName(t *testing.T) { - s1 := "www.miek.nl." - s2 := "miek.nl." - s3 := "www.bla.nl." - s4 := "nl.www.bla." - s5 := "nl" - s6 := "miek.nl" - - if CompareDomainName(s1, s2) != 2 { - t.Errorf("%s with %s should be %d", s1, s2, 2) - } - if CompareDomainName(s1, s3) != 1 { - t.Errorf("%s with %s should be %d", s1, s3, 1) - } - if CompareDomainName(s3, s4) != 0 { - t.Errorf("%s with %s should be %d", s3, s4, 0) - } - // Non qualified tests - if CompareDomainName(s1, s5) != 1 { - t.Errorf("%s with %s should be %d", s1, s5, 1) - } - if CompareDomainName(s1, s6) != 2 { - t.Errorf("%s with %s should be %d", s1, s5, 2) - } - - if CompareDomainName(s1, ".") != 0 { - t.Errorf("%s with %s should be %d", s1, s5, 0) - } - if CompareDomainName(".", ".") != 0 { - t.Errorf("%s with %s should be %d", ".", ".", 0) - } -} - -func TestSplit(t *testing.T) { - splitter := map[string]int{ - "www.miek.nl.": 3, - "www.miek.nl": 3, - "www..miek.nl": 4, - `www\.miek.nl.`: 2, - `www\\.miek.nl.`: 3, - ".": 0, - "nl.": 1, - "nl": 1, - "com.": 1, - ".com.": 2, - } - for s, i := range splitter { - if x := len(Split(s)); x != i { - t.Errorf("labels should be %d, got %d: %s %v", i, x, s, Split(s)) - } else { - t.Logf("%s %v", s, Split(s)) - } - } -} - -func TestSplit2(t *testing.T) { - splitter := map[string][]int{ - "www.miek.nl.": {0, 4, 9}, - "www.miek.nl": {0, 4, 9}, - "nl": {0}, - } - for s, i := range splitter { - x := Split(s) - switch len(i) { - case 1: - if x[0] != i[0] { - t.Errorf("labels should be %v, got %v: %s", i, x, s) - } - default: - if x[0] != i[0] || x[1] != i[1] || x[2] != i[2] { - t.Errorf("labels should be %v, got %v: %s", i, x, s) - } - } - } -} - -func TestPrevLabel(t *testing.T) { - type prev struct { - string - int - } - prever := map[prev]int{ - prev{"www.miek.nl.", 0}: 12, - prev{"www.miek.nl.", 1}: 9, - prev{"www.miek.nl.", 2}: 4, - - prev{"www.miek.nl", 0}: 11, - prev{"www.miek.nl", 1}: 9, - prev{"www.miek.nl", 2}: 4, - - prev{"www.miek.nl.", 5}: 0, - prev{"www.miek.nl", 5}: 0, - - prev{"www.miek.nl.", 3}: 0, - prev{"www.miek.nl", 3}: 0, - } - for s, i := range prever { - x, ok := PrevLabel(s.string, s.int) - if i != x { - t.Errorf("label should be %d, got %d, %t: preving %d, %s", i, x, ok, s.int, s.string) - } - } -} - -func TestCountLabel(t *testing.T) { - splitter := map[string]int{ - "www.miek.nl.": 3, - "www.miek.nl": 3, - "nl": 1, - ".": 0, - } - for s, i := range splitter { - x := CountLabel(s) - if x != i { - t.Errorf("CountLabel should have %d, got %d", i, x) - } - } -} - -func TestSplitDomainName(t *testing.T) { - labels := map[string][]string{ - "miek.nl": {"miek", "nl"}, - ".": nil, - "www.miek.nl.": {"www", "miek", "nl"}, - "www.miek.nl": {"www", "miek", "nl"}, - "www..miek.nl": {"www", "", "miek", "nl"}, - `www\.miek.nl`: {`www\.miek`, "nl"}, - `www\\.miek.nl`: {`www\\`, "miek", "nl"}, - ".www.miek.nl.": {"", "www", "miek", "nl"}, - } -domainLoop: - for domain, splits := range labels { - parts := SplitDomainName(domain) - if len(parts) != len(splits) { - t.Errorf("SplitDomainName returned %v for %s, expected %v", parts, domain, splits) - continue domainLoop - } - for i := range parts { - if parts[i] != splits[i] { - t.Errorf("SplitDomainName returned %v for %s, expected %v", parts, domain, splits) - continue domainLoop - } - } - } -} - -func TestIsDomainName(t *testing.T) { - type ret struct { - ok bool - lab int - } - names := map[string]*ret{ - "..": {false, 1}, - "@.": {true, 1}, - "www.example.com": {true, 3}, - "www.e%ample.com": {true, 3}, - "www.example.com.": {true, 3}, - "mi\\k.nl.": {true, 2}, - "mi\\k.nl": {true, 2}, - } - for d, ok := range names { - l, k := IsDomainName(d) - if ok.ok != k || ok.lab != l { - t.Errorf(" got %v %d for %s ", k, l, d) - t.Errorf("have %v %d for %s ", ok.ok, ok.lab, d) - } - } -} - -func BenchmarkSplitLabels(b *testing.B) { - for i := 0; i < b.N; i++ { - Split("www.example.com") - } -} - -func BenchmarkLenLabels(b *testing.B) { - for i := 0; i < b.N; i++ { - CountLabel("www.example.com") - } -} - -func BenchmarkCompareLabels(b *testing.B) { - b.ReportAllocs() - for i := 0; i < b.N; i++ { - CompareDomainName("www.example.com", "aa.example.com") - } -} - -func BenchmarkIsSubDomain(b *testing.B) { - b.ReportAllocs() - for i := 0; i < b.N; i++ { - IsSubDomain("www.example.com", "aa.example.com") - IsSubDomain("example.com", "aa.example.com") - IsSubDomain("miek.nl", "aa.example.com") - } -} diff --git a/vendor/github.com/miekg/dns/msg.go b/vendor/github.com/miekg/dns/msg.go deleted file mode 100644 index ec2f7ab..0000000 --- a/vendor/github.com/miekg/dns/msg.go +++ /dev/null @@ -1,1231 +0,0 @@ -// DNS packet assembly, see RFC 1035. Converting from - Unpack() - -// and to - Pack() - wire format. -// All the packers and unpackers take a (msg []byte, off int) -// and return (off1 int, ok bool). If they return ok==false, they -// also return off1==len(msg), so that the next unpacker will -// also fail. This lets us avoid checks of ok until the end of a -// packing sequence. - -package dns - -//go:generate go run msg_generate.go - -import ( - crand "crypto/rand" - "encoding/binary" - "math/big" - "math/rand" - "strconv" -) - -func init() { - // Initialize default math/rand source using crypto/rand to provide better - // security without the performance trade-off. - buf := make([]byte, 8) - _, err := crand.Read(buf) - if err != nil { - // Failed to read from cryptographic source, fallback to default initial - // seed (1) by returning early - return - } - seed := binary.BigEndian.Uint64(buf) - rand.Seed(int64(seed)) -} - -const maxCompressionOffset = 2 << 13 // We have 14 bits for the compression pointer - -var ( - ErrAlg error = &Error{err: "bad algorithm"} // ErrAlg indicates an error with the (DNSSEC) algorithm. - ErrAuth error = &Error{err: "bad authentication"} // ErrAuth indicates an error in the TSIG authentication. - ErrBuf error = &Error{err: "buffer size too small"} // ErrBuf indicates that the buffer used it too small for the message. - ErrConnEmpty error = &Error{err: "conn has no connection"} // ErrConnEmpty indicates a connection is being uses before it is initialized. - ErrExtendedRcode error = &Error{err: "bad extended rcode"} // ErrExtendedRcode ... - ErrFqdn error = &Error{err: "domain must be fully qualified"} // ErrFqdn indicates that a domain name does not have a closing dot. - ErrId error = &Error{err: "id mismatch"} // ErrId indicates there is a mismatch with the message's ID. - ErrKeyAlg error = &Error{err: "bad key algorithm"} // ErrKeyAlg indicates that the algorithm in the key is not valid. - ErrKey error = &Error{err: "bad key"} - ErrKeySize error = &Error{err: "bad key size"} - ErrNoSig error = &Error{err: "no signature found"} - ErrPrivKey error = &Error{err: "bad private key"} - ErrRcode error = &Error{err: "bad rcode"} - ErrRdata error = &Error{err: "bad rdata"} - ErrRRset error = &Error{err: "bad rrset"} - ErrSecret error = &Error{err: "no secrets defined"} - ErrShortRead error = &Error{err: "short read"} - ErrSig error = &Error{err: "bad signature"} // ErrSig indicates that a signature can not be cryptographically validated. - ErrSoa error = &Error{err: "no SOA"} // ErrSOA indicates that no SOA RR was seen when doing zone transfers. - ErrTime error = &Error{err: "bad time"} // ErrTime indicates a timing error in TSIG authentication. - ErrTruncated error = &Error{err: "failed to unpack truncated message"} // ErrTruncated indicates that we failed to unpack a truncated message. We unpacked as much as we had so Msg can still be used, if desired. -) - -// Id, by default, returns a 16 bits random number to be used as a -// message id. The random provided should be good enough. This being a -// variable the function can be reassigned to a custom function. -// For instance, to make it return a static value: -// -// dns.Id = func() uint16 { return 3 } -var Id func() uint16 = id - -// id returns a 16 bits random number to be used as a -// message id. The random provided should be good enough. -func id() uint16 { - id32 := rand.Uint32() - return uint16(id32) -} - -// MsgHdr is a a manually-unpacked version of (id, bits). -type MsgHdr struct { - Id uint16 - Response bool - Opcode int - Authoritative bool - Truncated bool - RecursionDesired bool - RecursionAvailable bool - Zero bool - AuthenticatedData bool - CheckingDisabled bool - Rcode int -} - -// Msg contains the layout of a DNS message. -type Msg struct { - MsgHdr - Compress bool `json:"-"` // If true, the message will be compressed when converted to wire format. - Question []Question // Holds the RR(s) of the question section. - Answer []RR // Holds the RR(s) of the answer section. - Ns []RR // Holds the RR(s) of the authority section. - Extra []RR // Holds the RR(s) of the additional section. -} - -// ClassToString is a maps Classes to strings for each CLASS wire type. -var ClassToString = map[uint16]string{ - ClassINET: "IN", - ClassCSNET: "CS", - ClassCHAOS: "CH", - ClassHESIOD: "HS", - ClassNONE: "NONE", - ClassANY: "ANY", -} - -// OpcodeToString maps Opcodes to strings. -var OpcodeToString = map[int]string{ - OpcodeQuery: "QUERY", - OpcodeIQuery: "IQUERY", - OpcodeStatus: "STATUS", - OpcodeNotify: "NOTIFY", - OpcodeUpdate: "UPDATE", -} - -// RcodeToString maps Rcodes to strings. -var RcodeToString = map[int]string{ - RcodeSuccess: "NOERROR", - RcodeFormatError: "FORMERR", - RcodeServerFailure: "SERVFAIL", - RcodeNameError: "NXDOMAIN", - RcodeNotImplemented: "NOTIMPL", - RcodeRefused: "REFUSED", - RcodeYXDomain: "YXDOMAIN", // See RFC 2136 - RcodeYXRrset: "YXRRSET", - RcodeNXRrset: "NXRRSET", - RcodeNotAuth: "NOTAUTH", - RcodeNotZone: "NOTZONE", - RcodeBadSig: "BADSIG", // Also known as RcodeBadVers, see RFC 6891 - // RcodeBadVers: "BADVERS", - RcodeBadKey: "BADKEY", - RcodeBadTime: "BADTIME", - RcodeBadMode: "BADMODE", - RcodeBadName: "BADNAME", - RcodeBadAlg: "BADALG", - RcodeBadTrunc: "BADTRUNC", - RcodeBadCookie: "BADCOOKIE", -} - -// Domain names are a sequence of counted strings -// split at the dots. They end with a zero-length string. - -// PackDomainName packs a domain name s into msg[off:]. -// If compression is wanted compress must be true and the compression -// map needs to hold a mapping between domain names and offsets -// pointing into msg. -func PackDomainName(s string, msg []byte, off int, compression map[string]int, compress bool) (off1 int, err error) { - off1, _, err = packDomainName(s, msg, off, compression, compress) - return -} - -func packDomainName(s string, msg []byte, off int, compression map[string]int, compress bool) (off1 int, labels int, err error) { - // special case if msg == nil - lenmsg := 256 - if msg != nil { - lenmsg = len(msg) - } - ls := len(s) - if ls == 0 { // Ok, for instance when dealing with update RR without any rdata. - return off, 0, nil - } - // If not fully qualified, error out, but only if msg == nil #ugly - switch { - case msg == nil: - if s[ls-1] != '.' { - s += "." - ls++ - } - case msg != nil: - if s[ls-1] != '.' { - return lenmsg, 0, ErrFqdn - } - } - // Each dot ends a segment of the name. - // We trade each dot byte for a length byte. - // Except for escaped dots (\.), which are normal dots. - // There is also a trailing zero. - - // Compression - nameoffset := -1 - pointer := -1 - // Emit sequence of counted strings, chopping at dots. - begin := 0 - bs := []byte(s) - roBs, bsFresh, escapedDot := s, true, false - for i := 0; i < ls; i++ { - if bs[i] == '\\' { - for j := i; j < ls-1; j++ { - bs[j] = bs[j+1] - } - ls-- - if off+1 > lenmsg { - return lenmsg, labels, ErrBuf - } - // check for \DDD - if i+2 < ls && isDigit(bs[i]) && isDigit(bs[i+1]) && isDigit(bs[i+2]) { - bs[i] = dddToByte(bs[i:]) - for j := i + 1; j < ls-2; j++ { - bs[j] = bs[j+2] - } - ls -= 2 - } else if bs[i] == 't' { - bs[i] = '\t' - } else if bs[i] == 'r' { - bs[i] = '\r' - } else if bs[i] == 'n' { - bs[i] = '\n' - } - escapedDot = bs[i] == '.' - bsFresh = false - continue - } - - if bs[i] == '.' { - if i > 0 && bs[i-1] == '.' && !escapedDot { - // two dots back to back is not legal - return lenmsg, labels, ErrRdata - } - if i-begin >= 1<<6 { // top two bits of length must be clear - return lenmsg, labels, ErrRdata - } - // off can already (we're in a loop) be bigger than len(msg) - // this happens when a name isn't fully qualified - if off+1 > lenmsg { - return lenmsg, labels, ErrBuf - } - if msg != nil { - msg[off] = byte(i - begin) - } - offset := off - off++ - for j := begin; j < i; j++ { - if off+1 > lenmsg { - return lenmsg, labels, ErrBuf - } - if msg != nil { - msg[off] = bs[j] - } - off++ - } - if compress && !bsFresh { - roBs = string(bs) - bsFresh = true - } - // Don't try to compress '.' - if compress && roBs[begin:] != "." { - if p, ok := compression[roBs[begin:]]; !ok { - // Only offsets smaller than this can be used. - if offset < maxCompressionOffset { - compression[roBs[begin:]] = offset - } - } else { - // The first hit is the longest matching dname - // keep the pointer offset we get back and store - // the offset of the current name, because that's - // where we need to insert the pointer later - - // If compress is true, we're allowed to compress this dname - if pointer == -1 && compress { - pointer = p // Where to point to - nameoffset = offset // Where to point from - break - } - } - } - labels++ - begin = i + 1 - } - escapedDot = false - } - // Root label is special - if len(bs) == 1 && bs[0] == '.' { - return off, labels, nil - } - // If we did compression and we find something add the pointer here - if pointer != -1 { - // We have two bytes (14 bits) to put the pointer in - // if msg == nil, we will never do compression - binary.BigEndian.PutUint16(msg[nameoffset:], uint16(pointer^0xC000)) - off = nameoffset + 1 - goto End - } - if msg != nil && off < len(msg) { - msg[off] = 0 - } -End: - off++ - return off, labels, nil -} - -// Unpack a domain name. -// In addition to the simple sequences of counted strings above, -// domain names are allowed to refer to strings elsewhere in the -// packet, to avoid repeating common suffixes when returning -// many entries in a single domain. The pointers are marked -// by a length byte with the top two bits set. Ignoring those -// two bits, that byte and the next give a 14 bit offset from msg[0] -// where we should pick up the trail. -// Note that if we jump elsewhere in the packet, -// we return off1 == the offset after the first pointer we found, -// which is where the next record will start. -// In theory, the pointers are only allowed to jump backward. -// We let them jump anywhere and stop jumping after a while. - -// UnpackDomainName unpacks a domain name into a string. -func UnpackDomainName(msg []byte, off int) (string, int, error) { - s := make([]byte, 0, 64) - off1 := 0 - lenmsg := len(msg) - ptr := 0 // number of pointers followed -Loop: - for { - if off >= lenmsg { - return "", lenmsg, ErrBuf - } - c := int(msg[off]) - off++ - switch c & 0xC0 { - case 0x00: - if c == 0x00 { - // end of name - break Loop - } - // literal string - if off+c > lenmsg { - return "", lenmsg, ErrBuf - } - for j := off; j < off+c; j++ { - switch b := msg[j]; b { - case '.', '(', ')', ';', ' ', '@': - fallthrough - case '"', '\\': - s = append(s, '\\', b) - case '\t': - s = append(s, '\\', 't') - case '\r': - s = append(s, '\\', 'r') - default: - if b < 32 || b >= 127 { // unprintable use \DDD - var buf [3]byte - bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') - } - for _, r := range bufs { - s = append(s, r) - } - } else { - s = append(s, b) - } - } - } - s = append(s, '.') - off += c - case 0xC0: - // pointer to somewhere else in msg. - // remember location after first ptr, - // since that's how many bytes we consumed. - // also, don't follow too many pointers -- - // maybe there's a loop. - if off >= lenmsg { - return "", lenmsg, ErrBuf - } - c1 := msg[off] - off++ - if ptr == 0 { - off1 = off - } - if ptr++; ptr > 10 { - return "", lenmsg, &Error{err: "too many compression pointers"} - } - off = (c^0xC0)<<8 | int(c1) - default: - // 0x80 and 0x40 are reserved - return "", lenmsg, ErrRdata - } - } - if ptr == 0 { - off1 = off - } - if len(s) == 0 { - s = []byte(".") - } - return string(s), off1, nil -} - -func packTxt(txt []string, msg []byte, offset int, tmp []byte) (int, error) { - if len(txt) == 0 { - if offset >= len(msg) { - return offset, ErrBuf - } - msg[offset] = 0 - return offset, nil - } - var err error - for i := range txt { - if len(txt[i]) > len(tmp) { - return offset, ErrBuf - } - offset, err = packTxtString(txt[i], msg, offset, tmp) - if err != nil { - return offset, err - } - } - return offset, nil -} - -func packTxtString(s string, msg []byte, offset int, tmp []byte) (int, error) { - lenByteOffset := offset - if offset >= len(msg) || len(s) > len(tmp) { - return offset, ErrBuf - } - offset++ - bs := tmp[:len(s)] - copy(bs, s) - for i := 0; i < len(bs); i++ { - if len(msg) <= offset { - return offset, ErrBuf - } - if bs[i] == '\\' { - i++ - if i == len(bs) { - break - } - // check for \DDD - if i+2 < len(bs) && isDigit(bs[i]) && isDigit(bs[i+1]) && isDigit(bs[i+2]) { - msg[offset] = dddToByte(bs[i:]) - i += 2 - } else if bs[i] == 't' { - msg[offset] = '\t' - } else if bs[i] == 'r' { - msg[offset] = '\r' - } else if bs[i] == 'n' { - msg[offset] = '\n' - } else { - msg[offset] = bs[i] - } - } else { - msg[offset] = bs[i] - } - offset++ - } - l := offset - lenByteOffset - 1 - if l > 255 { - return offset, &Error{err: "string exceeded 255 bytes in txt"} - } - msg[lenByteOffset] = byte(l) - return offset, nil -} - -func packOctetString(s string, msg []byte, offset int, tmp []byte) (int, error) { - if offset >= len(msg) || len(s) > len(tmp) { - return offset, ErrBuf - } - bs := tmp[:len(s)] - copy(bs, s) - for i := 0; i < len(bs); i++ { - if len(msg) <= offset { - return offset, ErrBuf - } - if bs[i] == '\\' { - i++ - if i == len(bs) { - break - } - // check for \DDD - if i+2 < len(bs) && isDigit(bs[i]) && isDigit(bs[i+1]) && isDigit(bs[i+2]) { - msg[offset] = dddToByte(bs[i:]) - i += 2 - } else { - msg[offset] = bs[i] - } - } else { - msg[offset] = bs[i] - } - offset++ - } - return offset, nil -} - -func unpackTxt(msg []byte, off0 int) (ss []string, off int, err error) { - off = off0 - var s string - for off < len(msg) && err == nil { - s, off, err = unpackTxtString(msg, off) - if err == nil { - ss = append(ss, s) - } - } - return -} - -func unpackTxtString(msg []byte, offset int) (string, int, error) { - if offset+1 > len(msg) { - return "", offset, &Error{err: "overflow unpacking txt"} - } - l := int(msg[offset]) - if offset+l+1 > len(msg) { - return "", offset, &Error{err: "overflow unpacking txt"} - } - s := make([]byte, 0, l) - for _, b := range msg[offset+1 : offset+1+l] { - switch b { - case '"', '\\': - s = append(s, '\\', b) - case '\t': - s = append(s, `\t`...) - case '\r': - s = append(s, `\r`...) - case '\n': - s = append(s, `\n`...) - default: - if b < 32 || b > 127 { // unprintable - var buf [3]byte - bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') - } - for _, r := range bufs { - s = append(s, r) - } - } else { - s = append(s, b) - } - } - } - offset += 1 + l - return string(s), offset, nil -} - -// Helpers for dealing with escaped bytes -func isDigit(b byte) bool { return b >= '0' && b <= '9' } - -func dddToByte(s []byte) byte { - return byte((s[0]-'0')*100 + (s[1]-'0')*10 + (s[2] - '0')) -} - -// Helper function for packing and unpacking -func intToBytes(i *big.Int, length int) []byte { - buf := i.Bytes() - if len(buf) < length { - b := make([]byte, length) - copy(b[length-len(buf):], buf) - return b - } - return buf -} - -// PackRR packs a resource record rr into msg[off:]. -// See PackDomainName for documentation about the compression. -func PackRR(rr RR, msg []byte, off int, compression map[string]int, compress bool) (off1 int, err error) { - if rr == nil { - return len(msg), &Error{err: "nil rr"} - } - - off1, err = rr.pack(msg, off, compression, compress) - if err != nil { - return len(msg), err - } - // TODO(miek): Not sure if this is needed? If removed we can remove rawmsg.go as well. - if rawSetRdlength(msg, off, off1) { - return off1, nil - } - return off, ErrRdata -} - -// UnpackRR unpacks msg[off:] into an RR. -func UnpackRR(msg []byte, off int) (rr RR, off1 int, err error) { - h, off, msg, err := unpackHeader(msg, off) - if err != nil { - return nil, len(msg), err - } - end := off + int(h.Rdlength) - - if fn, known := typeToUnpack[h.Rrtype]; !known { - rr, off, err = unpackRFC3597(h, msg, off) - } else { - rr, off, err = fn(h, msg, off) - } - if off != end { - return &h, end, &Error{err: "bad rdlength"} - } - return rr, off, err -} - -// unpackRRslice unpacks msg[off:] into an []RR. -// If we cannot unpack the whole array, then it will return nil -func unpackRRslice(l int, msg []byte, off int) (dst1 []RR, off1 int, err error) { - var r RR - // Optimistically make dst be the length that was sent - dst := make([]RR, 0, l) - for i := 0; i < l; i++ { - off1 := off - r, off, err = UnpackRR(msg, off) - if err != nil { - off = len(msg) - break - } - // If offset does not increase anymore, l is a lie - if off1 == off { - l = i - break - } - dst = append(dst, r) - } - if err != nil && off == len(msg) { - dst = nil - } - return dst, off, err -} - -// Convert a MsgHdr to a string, with dig-like headers: -// -//;; opcode: QUERY, status: NOERROR, id: 48404 -// -//;; flags: qr aa rd ra; -func (h *MsgHdr) String() string { - if h == nil { - return " MsgHdr" - } - - s := ";; opcode: " + OpcodeToString[h.Opcode] - s += ", status: " + RcodeToString[h.Rcode] - s += ", id: " + strconv.Itoa(int(h.Id)) + "\n" - - s += ";; flags:" - if h.Response { - s += " qr" - } - if h.Authoritative { - s += " aa" - } - if h.Truncated { - s += " tc" - } - if h.RecursionDesired { - s += " rd" - } - if h.RecursionAvailable { - s += " ra" - } - if h.Zero { // Hmm - s += " z" - } - if h.AuthenticatedData { - s += " ad" - } - if h.CheckingDisabled { - s += " cd" - } - - s += ";" - return s -} - -// Pack packs a Msg: it is converted to to wire format. -// If the dns.Compress is true the message will be in compressed wire format. -func (dns *Msg) Pack() (msg []byte, err error) { - return dns.PackBuffer(nil) -} - -// PackBuffer packs a Msg, using the given buffer buf. If buf is too small -// a new buffer is allocated. -func (dns *Msg) PackBuffer(buf []byte) (msg []byte, err error) { - // We use a similar function in tsig.go's stripTsig. - var ( - dh Header - compression map[string]int - ) - - if dns.Compress { - compression = make(map[string]int) // Compression pointer mappings - } - - if dns.Rcode < 0 || dns.Rcode > 0xFFF { - return nil, ErrRcode - } - if dns.Rcode > 0xF { - // Regular RCODE field is 4 bits - opt := dns.IsEdns0() - if opt == nil { - return nil, ErrExtendedRcode - } - opt.SetExtendedRcode(uint8(dns.Rcode >> 4)) - dns.Rcode &= 0xF - } - - // Convert convenient Msg into wire-like Header. - dh.Id = dns.Id - dh.Bits = uint16(dns.Opcode)<<11 | uint16(dns.Rcode) - if dns.Response { - dh.Bits |= _QR - } - if dns.Authoritative { - dh.Bits |= _AA - } - if dns.Truncated { - dh.Bits |= _TC - } - if dns.RecursionDesired { - dh.Bits |= _RD - } - if dns.RecursionAvailable { - dh.Bits |= _RA - } - if dns.Zero { - dh.Bits |= _Z - } - if dns.AuthenticatedData { - dh.Bits |= _AD - } - if dns.CheckingDisabled { - dh.Bits |= _CD - } - - // Prepare variable sized arrays. - question := dns.Question - answer := dns.Answer - ns := dns.Ns - extra := dns.Extra - - dh.Qdcount = uint16(len(question)) - dh.Ancount = uint16(len(answer)) - dh.Nscount = uint16(len(ns)) - dh.Arcount = uint16(len(extra)) - - // We need the uncompressed length here, because we first pack it and then compress it. - msg = buf - compress := dns.Compress - dns.Compress = false - if packLen := dns.Len() + 1; len(msg) < packLen { - msg = make([]byte, packLen) - } - dns.Compress = compress - - // Pack it in: header and then the pieces. - off := 0 - off, err = dh.pack(msg, off, compression, dns.Compress) - if err != nil { - return nil, err - } - for i := 0; i < len(question); i++ { - off, err = question[i].pack(msg, off, compression, dns.Compress) - if err != nil { - return nil, err - } - } - for i := 0; i < len(answer); i++ { - off, err = PackRR(answer[i], msg, off, compression, dns.Compress) - if err != nil { - return nil, err - } - } - for i := 0; i < len(ns); i++ { - off, err = PackRR(ns[i], msg, off, compression, dns.Compress) - if err != nil { - return nil, err - } - } - for i := 0; i < len(extra); i++ { - off, err = PackRR(extra[i], msg, off, compression, dns.Compress) - if err != nil { - return nil, err - } - } - return msg[:off], nil -} - -// Unpack unpacks a binary message to a Msg structure. -func (dns *Msg) Unpack(msg []byte) (err error) { - var ( - dh Header - off int - ) - if dh, off, err = unpackMsgHdr(msg, off); err != nil { - return err - } - if off == len(msg) { - return ErrTruncated - } - - dns.Id = dh.Id - dns.Response = (dh.Bits & _QR) != 0 - dns.Opcode = int(dh.Bits>>11) & 0xF - dns.Authoritative = (dh.Bits & _AA) != 0 - dns.Truncated = (dh.Bits & _TC) != 0 - dns.RecursionDesired = (dh.Bits & _RD) != 0 - dns.RecursionAvailable = (dh.Bits & _RA) != 0 - dns.Zero = (dh.Bits & _Z) != 0 - dns.AuthenticatedData = (dh.Bits & _AD) != 0 - dns.CheckingDisabled = (dh.Bits & _CD) != 0 - dns.Rcode = int(dh.Bits & 0xF) - - // Optimistically use the count given to us in the header - dns.Question = make([]Question, 0, int(dh.Qdcount)) - - for i := 0; i < int(dh.Qdcount); i++ { - off1 := off - var q Question - q, off, err = unpackQuestion(msg, off) - if err != nil { - // Even if Truncated is set, we only will set ErrTruncated if we - // actually got the questions - return err - } - if off1 == off { // Offset does not increase anymore, dh.Qdcount is a lie! - dh.Qdcount = uint16(i) - break - } - dns.Question = append(dns.Question, q) - } - - dns.Answer, off, err = unpackRRslice(int(dh.Ancount), msg, off) - // The header counts might have been wrong so we need to update it - dh.Ancount = uint16(len(dns.Answer)) - if err == nil { - dns.Ns, off, err = unpackRRslice(int(dh.Nscount), msg, off) - } - // The header counts might have been wrong so we need to update it - dh.Nscount = uint16(len(dns.Ns)) - if err == nil { - dns.Extra, off, err = unpackRRslice(int(dh.Arcount), msg, off) - } - // The header counts might have been wrong so we need to update it - dh.Arcount = uint16(len(dns.Extra)) - - if off != len(msg) { - // TODO(miek) make this an error? - // use PackOpt to let people tell how detailed the error reporting should be? - // println("dns: extra bytes in dns packet", off, "<", len(msg)) - } else if dns.Truncated { - // Whether we ran into a an error or not, we want to return that it - // was truncated - err = ErrTruncated - } - return err -} - -// Convert a complete message to a string with dig-like output. -func (dns *Msg) String() string { - if dns == nil { - return " MsgHdr" - } - s := dns.MsgHdr.String() + " " - s += "QUERY: " + strconv.Itoa(len(dns.Question)) + ", " - s += "ANSWER: " + strconv.Itoa(len(dns.Answer)) + ", " - s += "AUTHORITY: " + strconv.Itoa(len(dns.Ns)) + ", " - s += "ADDITIONAL: " + strconv.Itoa(len(dns.Extra)) + "\n" - if len(dns.Question) > 0 { - s += "\n;; QUESTION SECTION:\n" - for i := 0; i < len(dns.Question); i++ { - s += dns.Question[i].String() + "\n" - } - } - if len(dns.Answer) > 0 { - s += "\n;; ANSWER SECTION:\n" - for i := 0; i < len(dns.Answer); i++ { - if dns.Answer[i] != nil { - s += dns.Answer[i].String() + "\n" - } - } - } - if len(dns.Ns) > 0 { - s += "\n;; AUTHORITY SECTION:\n" - for i := 0; i < len(dns.Ns); i++ { - if dns.Ns[i] != nil { - s += dns.Ns[i].String() + "\n" - } - } - } - if len(dns.Extra) > 0 { - s += "\n;; ADDITIONAL SECTION:\n" - for i := 0; i < len(dns.Extra); i++ { - if dns.Extra[i] != nil { - s += dns.Extra[i].String() + "\n" - } - } - } - return s -} - -// Len returns the message length when in (un)compressed wire format. -// If dns.Compress is true compression it is taken into account. Len() -// is provided to be a faster way to get the size of the resulting packet, -// than packing it, measuring the size and discarding the buffer. -func (dns *Msg) Len() int { - // We always return one more than needed. - l := 12 // Message header is always 12 bytes - var compression map[string]int - if dns.Compress { - compression = make(map[string]int) - } - for i := 0; i < len(dns.Question); i++ { - l += dns.Question[i].len() - if dns.Compress { - compressionLenHelper(compression, dns.Question[i].Name) - } - } - for i := 0; i < len(dns.Answer); i++ { - if dns.Answer[i] == nil { - continue - } - l += dns.Answer[i].len() - if dns.Compress { - k, ok := compressionLenSearch(compression, dns.Answer[i].Header().Name) - if ok { - l += 1 - k - } - compressionLenHelper(compression, dns.Answer[i].Header().Name) - k, ok = compressionLenSearchType(compression, dns.Answer[i]) - if ok { - l += 1 - k - } - compressionLenHelperType(compression, dns.Answer[i]) - } - } - for i := 0; i < len(dns.Ns); i++ { - if dns.Ns[i] == nil { - continue - } - l += dns.Ns[i].len() - if dns.Compress { - k, ok := compressionLenSearch(compression, dns.Ns[i].Header().Name) - if ok { - l += 1 - k - } - compressionLenHelper(compression, dns.Ns[i].Header().Name) - k, ok = compressionLenSearchType(compression, dns.Ns[i]) - if ok { - l += 1 - k - } - compressionLenHelperType(compression, dns.Ns[i]) - } - } - for i := 0; i < len(dns.Extra); i++ { - if dns.Extra[i] == nil { - continue - } - l += dns.Extra[i].len() - if dns.Compress { - k, ok := compressionLenSearch(compression, dns.Extra[i].Header().Name) - if ok { - l += 1 - k - } - compressionLenHelper(compression, dns.Extra[i].Header().Name) - k, ok = compressionLenSearchType(compression, dns.Extra[i]) - if ok { - l += 1 - k - } - compressionLenHelperType(compression, dns.Extra[i]) - } - } - return l -} - -// Put the parts of the name in the compression map. -func compressionLenHelper(c map[string]int, s string) { - pref := "" - lbs := Split(s) - for j := len(lbs) - 1; j >= 0; j-- { - pref = s[lbs[j]:] - if _, ok := c[pref]; !ok { - c[pref] = len(pref) - } - } -} - -// Look for each part in the compression map and returns its length, -// keep on searching so we get the longest match. -func compressionLenSearch(c map[string]int, s string) (int, bool) { - off := 0 - end := false - if s == "" { // don't bork on bogus data - return 0, false - } - for { - if _, ok := c[s[off:]]; ok { - return len(s[off:]), true - } - if end { - break - } - off, end = NextLabel(s, off) - } - return 0, false -} - -// TODO(miek): should add all types, because the all can be *used* for compression. Autogenerate from msg_generate and put in zmsg.go -func compressionLenHelperType(c map[string]int, r RR) { - switch x := r.(type) { - case *NS: - compressionLenHelper(c, x.Ns) - case *MX: - compressionLenHelper(c, x.Mx) - case *CNAME: - compressionLenHelper(c, x.Target) - case *PTR: - compressionLenHelper(c, x.Ptr) - case *SOA: - compressionLenHelper(c, x.Ns) - compressionLenHelper(c, x.Mbox) - case *MB: - compressionLenHelper(c, x.Mb) - case *MG: - compressionLenHelper(c, x.Mg) - case *MR: - compressionLenHelper(c, x.Mr) - case *MF: - compressionLenHelper(c, x.Mf) - case *MD: - compressionLenHelper(c, x.Md) - case *RT: - compressionLenHelper(c, x.Host) - case *RP: - compressionLenHelper(c, x.Mbox) - compressionLenHelper(c, x.Txt) - case *MINFO: - compressionLenHelper(c, x.Rmail) - compressionLenHelper(c, x.Email) - case *AFSDB: - compressionLenHelper(c, x.Hostname) - case *SRV: - compressionLenHelper(c, x.Target) - case *NAPTR: - compressionLenHelper(c, x.Replacement) - case *RRSIG: - compressionLenHelper(c, x.SignerName) - case *NSEC: - compressionLenHelper(c, x.NextDomain) - // HIP? - } -} - -// Only search on compressing these types. -func compressionLenSearchType(c map[string]int, r RR) (int, bool) { - switch x := r.(type) { - case *NS: - return compressionLenSearch(c, x.Ns) - case *MX: - return compressionLenSearch(c, x.Mx) - case *CNAME: - return compressionLenSearch(c, x.Target) - case *DNAME: - return compressionLenSearch(c, x.Target) - case *PTR: - return compressionLenSearch(c, x.Ptr) - case *SOA: - k, ok := compressionLenSearch(c, x.Ns) - k1, ok1 := compressionLenSearch(c, x.Mbox) - if !ok && !ok1 { - return 0, false - } - return k + k1, true - case *MB: - return compressionLenSearch(c, x.Mb) - case *MG: - return compressionLenSearch(c, x.Mg) - case *MR: - return compressionLenSearch(c, x.Mr) - case *MF: - return compressionLenSearch(c, x.Mf) - case *MD: - return compressionLenSearch(c, x.Md) - case *RT: - return compressionLenSearch(c, x.Host) - case *MINFO: - k, ok := compressionLenSearch(c, x.Rmail) - k1, ok1 := compressionLenSearch(c, x.Email) - if !ok && !ok1 { - return 0, false - } - return k + k1, true - case *AFSDB: - return compressionLenSearch(c, x.Hostname) - } - return 0, false -} - -// Copy returns a new RR which is a deep-copy of r. -func Copy(r RR) RR { r1 := r.copy(); return r1 } - -// Len returns the length (in octets) of the uncompressed RR in wire format. -func Len(r RR) int { return r.len() } - -// Copy returns a new *Msg which is a deep-copy of dns. -func (dns *Msg) Copy() *Msg { return dns.CopyTo(new(Msg)) } - -// CopyTo copies the contents to the provided message using a deep-copy and returns the copy. -func (dns *Msg) CopyTo(r1 *Msg) *Msg { - r1.MsgHdr = dns.MsgHdr - r1.Compress = dns.Compress - - if len(dns.Question) > 0 { - r1.Question = make([]Question, len(dns.Question)) - copy(r1.Question, dns.Question) // TODO(miek): Question is an immutable value, ok to do a shallow-copy - } - - rrArr := make([]RR, len(dns.Answer)+len(dns.Ns)+len(dns.Extra)) - var rri int - - if len(dns.Answer) > 0 { - rrbegin := rri - for i := 0; i < len(dns.Answer); i++ { - rrArr[rri] = dns.Answer[i].copy() - rri++ - } - r1.Answer = rrArr[rrbegin:rri:rri] - } - - if len(dns.Ns) > 0 { - rrbegin := rri - for i := 0; i < len(dns.Ns); i++ { - rrArr[rri] = dns.Ns[i].copy() - rri++ - } - r1.Ns = rrArr[rrbegin:rri:rri] - } - - if len(dns.Extra) > 0 { - rrbegin := rri - for i := 0; i < len(dns.Extra); i++ { - rrArr[rri] = dns.Extra[i].copy() - rri++ - } - r1.Extra = rrArr[rrbegin:rri:rri] - } - - return r1 -} - -func (q *Question) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := PackDomainName(q.Name, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = packUint16(q.Qtype, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(q.Qclass, msg, off) - if err != nil { - return off, err - } - return off, nil -} - -func unpackQuestion(msg []byte, off int) (Question, int, error) { - var ( - q Question - err error - ) - q.Name, off, err = UnpackDomainName(msg, off) - if err != nil { - return q, off, err - } - if off == len(msg) { - return q, off, nil - } - q.Qtype, off, err = unpackUint16(msg, off) - if err != nil { - return q, off, err - } - if off == len(msg) { - return q, off, nil - } - q.Qclass, off, err = unpackUint16(msg, off) - if off == len(msg) { - return q, off, nil - } - return q, off, err -} - -func (dh *Header) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := packUint16(dh.Id, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(dh.Bits, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(dh.Qdcount, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(dh.Ancount, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(dh.Nscount, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(dh.Arcount, msg, off) - return off, err -} - -func unpackMsgHdr(msg []byte, off int) (Header, int, error) { - var ( - dh Header - err error - ) - dh.Id, off, err = unpackUint16(msg, off) - if err != nil { - return dh, off, err - } - dh.Bits, off, err = unpackUint16(msg, off) - if err != nil { - return dh, off, err - } - dh.Qdcount, off, err = unpackUint16(msg, off) - if err != nil { - return dh, off, err - } - dh.Ancount, off, err = unpackUint16(msg, off) - if err != nil { - return dh, off, err - } - dh.Nscount, off, err = unpackUint16(msg, off) - if err != nil { - return dh, off, err - } - dh.Arcount, off, err = unpackUint16(msg, off) - return dh, off, err -} diff --git a/vendor/github.com/miekg/dns/msg_generate.go b/vendor/github.com/miekg/dns/msg_generate.go deleted file mode 100644 index 166b3af..0000000 --- a/vendor/github.com/miekg/dns/msg_generate.go +++ /dev/null @@ -1,337 +0,0 @@ -//+build ignore - -// msg_generate.go is meant to run with go generate. It will use -// go/{importer,types} to track down all the RR struct types. Then for each type -// it will generate pack/unpack methods based on the struct tags. The generated source is -// written to zmsg.go, and is meant to be checked into git. -package main - -import ( - "bytes" - "fmt" - "go/format" - "go/importer" - "go/types" - "log" - "os" - "strings" -) - -var packageHdr = ` -// *** DO NOT MODIFY *** -// AUTOGENERATED BY go generate from msg_generate.go - -package dns - -` - -// getTypeStruct will take a type and the package scope, and return the -// (innermost) struct if the type is considered a RR type (currently defined as -// those structs beginning with a RR_Header, could be redefined as implementing -// the RR interface). The bool return value indicates if embedded structs were -// resolved. -func getTypeStruct(t types.Type, scope *types.Scope) (*types.Struct, bool) { - st, ok := t.Underlying().(*types.Struct) - if !ok { - return nil, false - } - if st.Field(0).Type() == scope.Lookup("RR_Header").Type() { - return st, false - } - if st.Field(0).Anonymous() { - st, _ := getTypeStruct(st.Field(0).Type(), scope) - return st, true - } - return nil, false -} - -func main() { - // Import and type-check the package - pkg, err := importer.Default().Import("github.com/miekg/dns") - fatalIfErr(err) - scope := pkg.Scope() - - // Collect actual types (*X) - var namedTypes []string - for _, name := range scope.Names() { - o := scope.Lookup(name) - if o == nil || !o.Exported() { - continue - } - if st, _ := getTypeStruct(o.Type(), scope); st == nil { - continue - } - if name == "PrivateRR" { - continue - } - - // Check if corresponding TypeX exists - if scope.Lookup("Type"+o.Name()) == nil && o.Name() != "RFC3597" { - log.Fatalf("Constant Type%s does not exist.", o.Name()) - } - - namedTypes = append(namedTypes, o.Name()) - } - - b := &bytes.Buffer{} - b.WriteString(packageHdr) - - fmt.Fprint(b, "// pack*() functions\n\n") - for _, name := range namedTypes { - o := scope.Lookup(name) - st, _ := getTypeStruct(o.Type(), scope) - - fmt.Fprintf(b, "func (rr *%s) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) {\n", name) - fmt.Fprint(b, `off, err := rr.Hdr.pack(msg, off, compression, compress) -if err != nil { - return off, err -} -headerEnd := off -`) - for i := 1; i < st.NumFields(); i++ { - o := func(s string) { - fmt.Fprintf(b, s, st.Field(i).Name()) - fmt.Fprint(b, `if err != nil { -return off, err -} -`) - } - - if _, ok := st.Field(i).Type().(*types.Slice); ok { - switch st.Tag(i) { - case `dns:"-"`: // ignored - case `dns:"txt"`: - o("off, err = packStringTxt(rr.%s, msg, off)\n") - case `dns:"opt"`: - o("off, err = packDataOpt(rr.%s, msg, off)\n") - case `dns:"nsec"`: - o("off, err = packDataNsec(rr.%s, msg, off)\n") - case `dns:"domain-name"`: - o("off, err = packDataDomainNames(rr.%s, msg, off, compression, compress)\n") - default: - log.Fatalln(name, st.Field(i).Name(), st.Tag(i)) - } - continue - } - - switch { - case st.Tag(i) == `dns:"-"`: // ignored - case st.Tag(i) == `dns:"cdomain-name"`: - fallthrough - case st.Tag(i) == `dns:"domain-name"`: - o("off, err = PackDomainName(rr.%s, msg, off, compression, compress)\n") - case st.Tag(i) == `dns:"a"`: - o("off, err = packDataA(rr.%s, msg, off)\n") - case st.Tag(i) == `dns:"aaaa"`: - o("off, err = packDataAAAA(rr.%s, msg, off)\n") - case st.Tag(i) == `dns:"uint48"`: - o("off, err = packUint48(rr.%s, msg, off)\n") - case st.Tag(i) == `dns:"txt"`: - o("off, err = packString(rr.%s, msg, off)\n") - - case strings.HasPrefix(st.Tag(i), `dns:"size-base32`): // size-base32 can be packed just like base32 - fallthrough - case st.Tag(i) == `dns:"base32"`: - o("off, err = packStringBase32(rr.%s, msg, off)\n") - - case strings.HasPrefix(st.Tag(i), `dns:"size-base64`): // size-base64 can be packed just like base64 - fallthrough - case st.Tag(i) == `dns:"base64"`: - o("off, err = packStringBase64(rr.%s, msg, off)\n") - - case strings.HasPrefix(st.Tag(i), `dns:"size-hex`): // size-hex can be packed just like hex - fallthrough - case st.Tag(i) == `dns:"hex"`: - o("off, err = packStringHex(rr.%s, msg, off)\n") - - case st.Tag(i) == `dns:"octet"`: - o("off, err = packStringOctet(rr.%s, msg, off)\n") - case st.Tag(i) == "": - switch st.Field(i).Type().(*types.Basic).Kind() { - case types.Uint8: - o("off, err = packUint8(rr.%s, msg, off)\n") - case types.Uint16: - o("off, err = packUint16(rr.%s, msg, off)\n") - case types.Uint32: - o("off, err = packUint32(rr.%s, msg, off)\n") - case types.Uint64: - o("off, err = packUint64(rr.%s, msg, off)\n") - case types.String: - o("off, err = packString(rr.%s, msg, off)\n") - default: - log.Fatalln(name, st.Field(i).Name()) - } - default: - log.Fatalln(name, st.Field(i).Name(), st.Tag(i)) - } - } - // We have packed everything, only now we know the rdlength of this RR - fmt.Fprintln(b, "rr.Header().Rdlength = uint16(off- headerEnd)") - fmt.Fprintln(b, "return off, nil }\n") - } - - fmt.Fprint(b, "// unpack*() functions\n\n") - for _, name := range namedTypes { - o := scope.Lookup(name) - st, _ := getTypeStruct(o.Type(), scope) - - fmt.Fprintf(b, "func unpack%s(h RR_Header, msg []byte, off int) (RR, int, error) {\n", name) - fmt.Fprintf(b, "rr := new(%s)\n", name) - fmt.Fprint(b, "rr.Hdr = h\n") - fmt.Fprint(b, `if noRdata(h) { -return rr, off, nil - } -var err error -rdStart := off -_ = rdStart - -`) - for i := 1; i < st.NumFields(); i++ { - o := func(s string) { - fmt.Fprintf(b, s, st.Field(i).Name()) - fmt.Fprint(b, `if err != nil { -return rr, off, err -} -`) - } - - // size-* are special, because they reference a struct member we should use for the length. - if strings.HasPrefix(st.Tag(i), `dns:"size-`) { - structMember := structMember(st.Tag(i)) - structTag := structTag(st.Tag(i)) - switch structTag { - case "hex": - fmt.Fprintf(b, "rr.%s, off, err = unpackStringHex(msg, off, off + int(rr.%s))\n", st.Field(i).Name(), structMember) - case "base32": - fmt.Fprintf(b, "rr.%s, off, err = unpackStringBase32(msg, off, off + int(rr.%s))\n", st.Field(i).Name(), structMember) - case "base64": - fmt.Fprintf(b, "rr.%s, off, err = unpackStringBase64(msg, off, off + int(rr.%s))\n", st.Field(i).Name(), structMember) - default: - log.Fatalln(name, st.Field(i).Name(), st.Tag(i)) - } - fmt.Fprint(b, `if err != nil { -return rr, off, err -} -`) - continue - } - - if _, ok := st.Field(i).Type().(*types.Slice); ok { - switch st.Tag(i) { - case `dns:"-"`: // ignored - case `dns:"txt"`: - o("rr.%s, off, err = unpackStringTxt(msg, off)\n") - case `dns:"opt"`: - o("rr.%s, off, err = unpackDataOpt(msg, off)\n") - case `dns:"nsec"`: - o("rr.%s, off, err = unpackDataNsec(msg, off)\n") - case `dns:"domain-name"`: - o("rr.%s, off, err = unpackDataDomainNames(msg, off, rdStart + int(rr.Hdr.Rdlength))\n") - default: - log.Fatalln(name, st.Field(i).Name(), st.Tag(i)) - } - continue - } - - switch st.Tag(i) { - case `dns:"-"`: // ignored - case `dns:"cdomain-name"`: - fallthrough - case `dns:"domain-name"`: - o("rr.%s, off, err = UnpackDomainName(msg, off)\n") - case `dns:"a"`: - o("rr.%s, off, err = unpackDataA(msg, off)\n") - case `dns:"aaaa"`: - o("rr.%s, off, err = unpackDataAAAA(msg, off)\n") - case `dns:"uint48"`: - o("rr.%s, off, err = unpackUint48(msg, off)\n") - case `dns:"txt"`: - o("rr.%s, off, err = unpackString(msg, off)\n") - case `dns:"base32"`: - o("rr.%s, off, err = unpackStringBase32(msg, off, rdStart + int(rr.Hdr.Rdlength))\n") - case `dns:"base64"`: - o("rr.%s, off, err = unpackStringBase64(msg, off, rdStart + int(rr.Hdr.Rdlength))\n") - case `dns:"hex"`: - o("rr.%s, off, err = unpackStringHex(msg, off, rdStart + int(rr.Hdr.Rdlength))\n") - case `dns:"octet"`: - o("rr.%s, off, err = unpackStringOctet(msg, off)\n") - case "": - switch st.Field(i).Type().(*types.Basic).Kind() { - case types.Uint8: - o("rr.%s, off, err = unpackUint8(msg, off)\n") - case types.Uint16: - o("rr.%s, off, err = unpackUint16(msg, off)\n") - case types.Uint32: - o("rr.%s, off, err = unpackUint32(msg, off)\n") - case types.Uint64: - o("rr.%s, off, err = unpackUint64(msg, off)\n") - case types.String: - o("rr.%s, off, err = unpackString(msg, off)\n") - default: - log.Fatalln(name, st.Field(i).Name()) - } - default: - log.Fatalln(name, st.Field(i).Name(), st.Tag(i)) - } - // If we've hit len(msg) we return without error. - if i < st.NumFields()-1 { - fmt.Fprintf(b, `if off == len(msg) { -return rr, off, nil - } -`) - } - } - fmt.Fprintf(b, "return rr, off, err }\n\n") - } - // Generate typeToUnpack map - fmt.Fprintln(b, "var typeToUnpack = map[uint16]func(RR_Header, []byte, int) (RR, int, error){") - for _, name := range namedTypes { - if name == "RFC3597" { - continue - } - fmt.Fprintf(b, "Type%s: unpack%s,\n", name, name) - } - fmt.Fprintln(b, "}\n") - - // gofmt - res, err := format.Source(b.Bytes()) - if err != nil { - b.WriteTo(os.Stderr) - log.Fatal(err) - } - - // write result - f, err := os.Create("zmsg.go") - fatalIfErr(err) - defer f.Close() - f.Write(res) -} - -// structMember will take a tag like dns:"size-base32:SaltLength" and return the last part of this string. -func structMember(s string) string { - fields := strings.Split(s, ":") - if len(fields) == 0 { - return "" - } - f := fields[len(fields)-1] - // f should have a closing " - if len(f) > 1 { - return f[:len(f)-1] - } - return f -} - -// structTag will take a tag like dns:"size-base32:SaltLength" and return base32. -func structTag(s string) string { - fields := strings.Split(s, ":") - if len(fields) < 2 { - return "" - } - return fields[1][len("\"size-"):] -} - -func fatalIfErr(err error) { - if err != nil { - log.Fatal(err) - } -} diff --git a/vendor/github.com/miekg/dns/msg_helpers.go b/vendor/github.com/miekg/dns/msg_helpers.go deleted file mode 100644 index e7a9500..0000000 --- a/vendor/github.com/miekg/dns/msg_helpers.go +++ /dev/null @@ -1,630 +0,0 @@ -package dns - -import ( - "encoding/base32" - "encoding/base64" - "encoding/binary" - "encoding/hex" - "net" - "strconv" -) - -// helper functions called from the generated zmsg.go - -// These function are named after the tag to help pack/unpack, if there is no tag it is the name -// of the type they pack/unpack (string, int, etc). We prefix all with unpackData or packData, so packDataA or -// packDataDomainName. - -func unpackDataA(msg []byte, off int) (net.IP, int, error) { - if off+net.IPv4len > len(msg) { - return nil, len(msg), &Error{err: "overflow unpacking a"} - } - a := append(make(net.IP, 0, net.IPv4len), msg[off:off+net.IPv4len]...) - off += net.IPv4len - return a, off, nil -} - -func packDataA(a net.IP, msg []byte, off int) (int, error) { - // It must be a slice of 4, even if it is 16, we encode only the first 4 - if off+net.IPv4len > len(msg) { - return len(msg), &Error{err: "overflow packing a"} - } - switch len(a) { - case net.IPv4len, net.IPv6len: - copy(msg[off:], a.To4()) - off += net.IPv4len - case 0: - // Allowed, for dynamic updates. - default: - return len(msg), &Error{err: "overflow packing a"} - } - return off, nil -} - -func unpackDataAAAA(msg []byte, off int) (net.IP, int, error) { - if off+net.IPv6len > len(msg) { - return nil, len(msg), &Error{err: "overflow unpacking aaaa"} - } - aaaa := append(make(net.IP, 0, net.IPv6len), msg[off:off+net.IPv6len]...) - off += net.IPv6len - return aaaa, off, nil -} - -func packDataAAAA(aaaa net.IP, msg []byte, off int) (int, error) { - if off+net.IPv6len > len(msg) { - return len(msg), &Error{err: "overflow packing aaaa"} - } - - switch len(aaaa) { - case net.IPv6len: - copy(msg[off:], aaaa) - off += net.IPv6len - case 0: - // Allowed, dynamic updates. - default: - return len(msg), &Error{err: "overflow packing aaaa"} - } - return off, nil -} - -// unpackHeader unpacks an RR header, returning the offset to the end of the header and a -// re-sliced msg according to the expected length of the RR. -func unpackHeader(msg []byte, off int) (rr RR_Header, off1 int, truncmsg []byte, err error) { - hdr := RR_Header{} - if off == len(msg) { - return hdr, off, msg, nil - } - - hdr.Name, off, err = UnpackDomainName(msg, off) - if err != nil { - return hdr, len(msg), msg, err - } - hdr.Rrtype, off, err = unpackUint16(msg, off) - if err != nil { - return hdr, len(msg), msg, err - } - hdr.Class, off, err = unpackUint16(msg, off) - if err != nil { - return hdr, len(msg), msg, err - } - hdr.Ttl, off, err = unpackUint32(msg, off) - if err != nil { - return hdr, len(msg), msg, err - } - hdr.Rdlength, off, err = unpackUint16(msg, off) - if err != nil { - return hdr, len(msg), msg, err - } - msg, err = truncateMsgFromRdlength(msg, off, hdr.Rdlength) - return hdr, off, msg, nil -} - -// pack packs an RR header, returning the offset to the end of the header. -// See PackDomainName for documentation about the compression. -func (hdr RR_Header) pack(msg []byte, off int, compression map[string]int, compress bool) (off1 int, err error) { - if off == len(msg) { - return off, nil - } - - off, err = PackDomainName(hdr.Name, msg, off, compression, compress) - if err != nil { - return len(msg), err - } - off, err = packUint16(hdr.Rrtype, msg, off) - if err != nil { - return len(msg), err - } - off, err = packUint16(hdr.Class, msg, off) - if err != nil { - return len(msg), err - } - off, err = packUint32(hdr.Ttl, msg, off) - if err != nil { - return len(msg), err - } - off, err = packUint16(hdr.Rdlength, msg, off) - if err != nil { - return len(msg), err - } - return off, nil -} - -// helper helper functions. - -// truncateMsgFromRdLength truncates msg to match the expected length of the RR. -// Returns an error if msg is smaller than the expected size. -func truncateMsgFromRdlength(msg []byte, off int, rdlength uint16) (truncmsg []byte, err error) { - lenrd := off + int(rdlength) - if lenrd > len(msg) { - return msg, &Error{err: "overflowing header size"} - } - return msg[:lenrd], nil -} - -func fromBase32(s []byte) (buf []byte, err error) { - buflen := base32.HexEncoding.DecodedLen(len(s)) - buf = make([]byte, buflen) - n, err := base32.HexEncoding.Decode(buf, s) - buf = buf[:n] - return -} - -func toBase32(b []byte) string { return base32.HexEncoding.EncodeToString(b) } - -func fromBase64(s []byte) (buf []byte, err error) { - buflen := base64.StdEncoding.DecodedLen(len(s)) - buf = make([]byte, buflen) - n, err := base64.StdEncoding.Decode(buf, s) - buf = buf[:n] - return -} - -func toBase64(b []byte) string { return base64.StdEncoding.EncodeToString(b) } - -// dynamicUpdate returns true if the Rdlength is zero. -func noRdata(h RR_Header) bool { return h.Rdlength == 0 } - -func unpackUint8(msg []byte, off int) (i uint8, off1 int, err error) { - if off+1 > len(msg) { - return 0, len(msg), &Error{err: "overflow unpacking uint8"} - } - return uint8(msg[off]), off + 1, nil -} - -func packUint8(i uint8, msg []byte, off int) (off1 int, err error) { - if off+1 > len(msg) { - return len(msg), &Error{err: "overflow packing uint8"} - } - msg[off] = byte(i) - return off + 1, nil -} - -func unpackUint16(msg []byte, off int) (i uint16, off1 int, err error) { - if off+2 > len(msg) { - return 0, len(msg), &Error{err: "overflow unpacking uint16"} - } - return binary.BigEndian.Uint16(msg[off:]), off + 2, nil -} - -func packUint16(i uint16, msg []byte, off int) (off1 int, err error) { - if off+2 > len(msg) { - return len(msg), &Error{err: "overflow packing uint16"} - } - binary.BigEndian.PutUint16(msg[off:], i) - return off + 2, nil -} - -func unpackUint32(msg []byte, off int) (i uint32, off1 int, err error) { - if off+4 > len(msg) { - return 0, len(msg), &Error{err: "overflow unpacking uint32"} - } - return binary.BigEndian.Uint32(msg[off:]), off + 4, nil -} - -func packUint32(i uint32, msg []byte, off int) (off1 int, err error) { - if off+4 > len(msg) { - return len(msg), &Error{err: "overflow packing uint32"} - } - binary.BigEndian.PutUint32(msg[off:], i) - return off + 4, nil -} - -func unpackUint48(msg []byte, off int) (i uint64, off1 int, err error) { - if off+6 > len(msg) { - return 0, len(msg), &Error{err: "overflow unpacking uint64 as uint48"} - } - // Used in TSIG where the last 48 bits are occupied, so for now, assume a uint48 (6 bytes) - i = (uint64(uint64(msg[off])<<40 | uint64(msg[off+1])<<32 | uint64(msg[off+2])<<24 | uint64(msg[off+3])<<16 | - uint64(msg[off+4])<<8 | uint64(msg[off+5]))) - off += 6 - return i, off, nil -} - -func packUint48(i uint64, msg []byte, off int) (off1 int, err error) { - if off+6 > len(msg) { - return len(msg), &Error{err: "overflow packing uint64 as uint48"} - } - msg[off] = byte(i >> 40) - msg[off+1] = byte(i >> 32) - msg[off+2] = byte(i >> 24) - msg[off+3] = byte(i >> 16) - msg[off+4] = byte(i >> 8) - msg[off+5] = byte(i) - off += 6 - return off, nil -} - -func unpackUint64(msg []byte, off int) (i uint64, off1 int, err error) { - if off+8 > len(msg) { - return 0, len(msg), &Error{err: "overflow unpacking uint64"} - } - return binary.BigEndian.Uint64(msg[off:]), off + 8, nil -} - -func packUint64(i uint64, msg []byte, off int) (off1 int, err error) { - if off+8 > len(msg) { - return len(msg), &Error{err: "overflow packing uint64"} - } - binary.BigEndian.PutUint64(msg[off:], i) - off += 8 - return off, nil -} - -func unpackString(msg []byte, off int) (string, int, error) { - if off+1 > len(msg) { - return "", off, &Error{err: "overflow unpacking txt"} - } - l := int(msg[off]) - if off+l+1 > len(msg) { - return "", off, &Error{err: "overflow unpacking txt"} - } - s := make([]byte, 0, l) - for _, b := range msg[off+1 : off+1+l] { - switch b { - case '"', '\\': - s = append(s, '\\', b) - case '\t', '\r', '\n': - s = append(s, b) - default: - if b < 32 || b > 127 { // unprintable - var buf [3]byte - bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') - } - for _, r := range bufs { - s = append(s, r) - } - } else { - s = append(s, b) - } - } - } - off += 1 + l - return string(s), off, nil -} - -func packString(s string, msg []byte, off int) (int, error) { - txtTmp := make([]byte, 256*4+1) - off, err := packTxtString(s, msg, off, txtTmp) - if err != nil { - return len(msg), err - } - return off, nil -} - -func unpackStringBase32(msg []byte, off, end int) (string, int, error) { - if end > len(msg) { - return "", len(msg), &Error{err: "overflow unpacking base32"} - } - s := toBase32(msg[off:end]) - return s, end, nil -} - -func packStringBase32(s string, msg []byte, off int) (int, error) { - b32, err := fromBase32([]byte(s)) - if err != nil { - return len(msg), err - } - if off+len(b32) > len(msg) { - return len(msg), &Error{err: "overflow packing base32"} - } - copy(msg[off:off+len(b32)], b32) - off += len(b32) - return off, nil -} - -func unpackStringBase64(msg []byte, off, end int) (string, int, error) { - // Rest of the RR is base64 encoded value, so we don't need an explicit length - // to be set. Thus far all RR's that have base64 encoded fields have those as their - // last one. What we do need is the end of the RR! - if end > len(msg) { - return "", len(msg), &Error{err: "overflow unpacking base64"} - } - s := toBase64(msg[off:end]) - return s, end, nil -} - -func packStringBase64(s string, msg []byte, off int) (int, error) { - b64, err := fromBase64([]byte(s)) - if err != nil { - return len(msg), err - } - if off+len(b64) > len(msg) { - return len(msg), &Error{err: "overflow packing base64"} - } - copy(msg[off:off+len(b64)], b64) - off += len(b64) - return off, nil -} - -func unpackStringHex(msg []byte, off, end int) (string, int, error) { - // Rest of the RR is hex encoded value, so we don't need an explicit length - // to be set. NSEC and TSIG have hex fields with a length field. - // What we do need is the end of the RR! - if end > len(msg) { - return "", len(msg), &Error{err: "overflow unpacking hex"} - } - - s := hex.EncodeToString(msg[off:end]) - return s, end, nil -} - -func packStringHex(s string, msg []byte, off int) (int, error) { - h, err := hex.DecodeString(s) - if err != nil { - return len(msg), err - } - if off+(len(h)) > len(msg) { - return len(msg), &Error{err: "overflow packing hex"} - } - copy(msg[off:off+len(h)], h) - off += len(h) - return off, nil -} - -func unpackStringTxt(msg []byte, off int) ([]string, int, error) { - txt, off, err := unpackTxt(msg, off) - if err != nil { - return nil, len(msg), err - } - return txt, off, nil -} - -func packStringTxt(s []string, msg []byte, off int) (int, error) { - txtTmp := make([]byte, 256*4+1) // If the whole string consists out of \DDD we need this many. - off, err := packTxt(s, msg, off, txtTmp) - if err != nil { - return len(msg), err - } - return off, nil -} - -func unpackDataOpt(msg []byte, off int) ([]EDNS0, int, error) { - var edns []EDNS0 -Option: - code := uint16(0) - if off+4 > len(msg) { - return nil, len(msg), &Error{err: "overflow unpacking opt"} - } - code = binary.BigEndian.Uint16(msg[off:]) - off += 2 - optlen := binary.BigEndian.Uint16(msg[off:]) - off += 2 - if off+int(optlen) > len(msg) { - return nil, len(msg), &Error{err: "overflow unpacking opt"} - } - switch code { - case EDNS0NSID: - e := new(EDNS0_NSID) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - case EDNS0SUBNET, EDNS0SUBNETDRAFT: - e := new(EDNS0_SUBNET) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - if code == EDNS0SUBNETDRAFT { - e.DraftOption = true - } - case EDNS0COOKIE: - e := new(EDNS0_COOKIE) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - case EDNS0UL: - e := new(EDNS0_UL) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - case EDNS0LLQ: - e := new(EDNS0_LLQ) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - case EDNS0DAU: - e := new(EDNS0_DAU) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - case EDNS0DHU: - e := new(EDNS0_DHU) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - case EDNS0N3U: - e := new(EDNS0_N3U) - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - default: - e := new(EDNS0_LOCAL) - e.Code = code - if err := e.unpack(msg[off : off+int(optlen)]); err != nil { - return nil, len(msg), err - } - edns = append(edns, e) - off += int(optlen) - } - - if off < len(msg) { - goto Option - } - - return edns, off, nil -} - -func packDataOpt(options []EDNS0, msg []byte, off int) (int, error) { - for _, el := range options { - b, err := el.pack() - if err != nil || off+3 > len(msg) { - return len(msg), &Error{err: "overflow packing opt"} - } - binary.BigEndian.PutUint16(msg[off:], el.Option()) // Option code - binary.BigEndian.PutUint16(msg[off+2:], uint16(len(b))) // Length - off += 4 - if off+len(b) > len(msg) { - copy(msg[off:], b) - off = len(msg) - continue - } - // Actual data - copy(msg[off:off+len(b)], b) - off += len(b) - } - return off, nil -} - -func unpackStringOctet(msg []byte, off int) (string, int, error) { - s := string(msg[off:]) - return s, len(msg), nil -} - -func packStringOctet(s string, msg []byte, off int) (int, error) { - txtTmp := make([]byte, 256*4+1) - off, err := packOctetString(s, msg, off, txtTmp) - if err != nil { - return len(msg), err - } - return off, nil -} - -func unpackDataNsec(msg []byte, off int) ([]uint16, int, error) { - var nsec []uint16 - length, window, lastwindow := 0, 0, -1 - for off < len(msg) { - if off+2 > len(msg) { - return nsec, len(msg), &Error{err: "overflow unpacking nsecx"} - } - window = int(msg[off]) - length = int(msg[off+1]) - off += 2 - if window <= lastwindow { - // RFC 4034: Blocks are present in the NSEC RR RDATA in - // increasing numerical order. - return nsec, len(msg), &Error{err: "out of order NSEC block"} - } - if length == 0 { - // RFC 4034: Blocks with no types present MUST NOT be included. - return nsec, len(msg), &Error{err: "empty NSEC block"} - } - if length > 32 { - return nsec, len(msg), &Error{err: "NSEC block too long"} - } - if off+length > len(msg) { - return nsec, len(msg), &Error{err: "overflowing NSEC block"} - } - - // Walk the bytes in the window and extract the type bits - for j := 0; j < length; j++ { - b := msg[off+j] - // Check the bits one by one, and set the type - if b&0x80 == 0x80 { - nsec = append(nsec, uint16(window*256+j*8+0)) - } - if b&0x40 == 0x40 { - nsec = append(nsec, uint16(window*256+j*8+1)) - } - if b&0x20 == 0x20 { - nsec = append(nsec, uint16(window*256+j*8+2)) - } - if b&0x10 == 0x10 { - nsec = append(nsec, uint16(window*256+j*8+3)) - } - if b&0x8 == 0x8 { - nsec = append(nsec, uint16(window*256+j*8+4)) - } - if b&0x4 == 0x4 { - nsec = append(nsec, uint16(window*256+j*8+5)) - } - if b&0x2 == 0x2 { - nsec = append(nsec, uint16(window*256+j*8+6)) - } - if b&0x1 == 0x1 { - nsec = append(nsec, uint16(window*256+j*8+7)) - } - } - off += length - lastwindow = window - } - return nsec, off, nil -} - -func packDataNsec(bitmap []uint16, msg []byte, off int) (int, error) { - if len(bitmap) == 0 { - return off, nil - } - var lastwindow, lastlength uint16 - for j := 0; j < len(bitmap); j++ { - t := bitmap[j] - window := t / 256 - length := (t-window*256)/8 + 1 - if window > lastwindow && lastlength != 0 { // New window, jump to the new offset - off += int(lastlength) + 2 - lastlength = 0 - } - if window < lastwindow || length < lastlength { - return len(msg), &Error{err: "nsec bits out of order"} - } - if off+2+int(length) > len(msg) { - return len(msg), &Error{err: "overflow packing nsec"} - } - // Setting the window # - msg[off] = byte(window) - // Setting the octets length - msg[off+1] = byte(length) - // Setting the bit value for the type in the right octet - msg[off+1+int(length)] |= byte(1 << (7 - (t % 8))) - lastwindow, lastlength = window, length - } - off += int(lastlength) + 2 - return off, nil -} - -func unpackDataDomainNames(msg []byte, off, end int) ([]string, int, error) { - var ( - servers []string - s string - err error - ) - if end > len(msg) { - return nil, len(msg), &Error{err: "overflow unpacking domain names"} - } - for off < end { - s, off, err = UnpackDomainName(msg, off) - if err != nil { - return servers, len(msg), err - } - servers = append(servers, s) - } - return servers, off, nil -} - -func packDataDomainNames(names []string, msg []byte, off int, compression map[string]int, compress bool) (int, error) { - var err error - for j := 0; j < len(names); j++ { - off, err = PackDomainName(names[j], msg, off, compression, false && compress) - if err != nil { - return len(msg), err - } - } - return off, nil -} diff --git a/vendor/github.com/miekg/dns/nsecx.go b/vendor/github.com/miekg/dns/nsecx.go deleted file mode 100644 index 6f10f3e..0000000 --- a/vendor/github.com/miekg/dns/nsecx.go +++ /dev/null @@ -1,119 +0,0 @@ -package dns - -import ( - "crypto/sha1" - "hash" - "io" - "strings" -) - -type saltWireFmt struct { - Salt string `dns:"size-hex"` -} - -// HashName hashes a string (label) according to RFC 5155. It returns the hashed string in uppercase. -func HashName(label string, ha uint8, iter uint16, salt string) string { - saltwire := new(saltWireFmt) - saltwire.Salt = salt - wire := make([]byte, DefaultMsgSize) - n, err := packSaltWire(saltwire, wire) - if err != nil { - return "" - } - wire = wire[:n] - name := make([]byte, 255) - off, err := PackDomainName(strings.ToLower(label), name, 0, nil, false) - if err != nil { - return "" - } - name = name[:off] - var s hash.Hash - switch ha { - case SHA1: - s = sha1.New() - default: - return "" - } - - // k = 0 - name = append(name, wire...) - io.WriteString(s, string(name)) - nsec3 := s.Sum(nil) - // k > 0 - for k := uint16(0); k < iter; k++ { - s.Reset() - nsec3 = append(nsec3, wire...) - io.WriteString(s, string(nsec3)) - nsec3 = s.Sum(nil) - } - return toBase32(nsec3) -} - -// Denialer is an interface that should be implemented by types that are used to denial -// answers in DNSSEC. -type Denialer interface { - // Cover will check if the (unhashed) name is being covered by this NSEC or NSEC3. - Cover(name string) bool - // Match will check if the ownername matches the (unhashed) name for this NSEC3 or NSEC3. - Match(name string) bool -} - -// Cover implements the Denialer interface. -func (rr *NSEC) Cover(name string) bool { - return true -} - -// Match implements the Denialer interface. -func (rr *NSEC) Match(name string) bool { - return true -} - -// Cover implements the Denialer interface. -func (rr *NSEC3) Cover(name string) bool { - // FIXME(miek): check if the zones match - // FIXME(miek): check if we're not dealing with parent nsec3 - hname := HashName(name, rr.Hash, rr.Iterations, rr.Salt) - labels := Split(rr.Hdr.Name) - if len(labels) < 2 { - return false - } - hash := strings.ToUpper(rr.Hdr.Name[labels[0] : labels[1]-1]) // -1 to remove the dot - if hash == rr.NextDomain { - return false // empty interval - } - if hash > rr.NextDomain { // last name, points to apex - // hname > hash - // hname > rr.NextDomain - // TODO(miek) - } - if hname <= hash { - return false - } - if hname >= rr.NextDomain { - return false - } - return true -} - -// Match implements the Denialer interface. -func (rr *NSEC3) Match(name string) bool { - // FIXME(miek): Check if we are in the same zone - hname := HashName(name, rr.Hash, rr.Iterations, rr.Salt) - labels := Split(rr.Hdr.Name) - if len(labels) < 2 { - return false - } - hash := strings.ToUpper(rr.Hdr.Name[labels[0] : labels[1]-1]) // -1 to remove the . - if hash == hname { - return true - } - return false -} - -func packSaltWire(sw *saltWireFmt, msg []byte) (int, error) { - off, err := packStringHex(sw.Salt, msg, 0) - if err != nil { - return off, err - } - return off, nil -} diff --git a/vendor/github.com/miekg/dns/nsecx_test.go b/vendor/github.com/miekg/dns/nsecx_test.go deleted file mode 100644 index 93e0c63..0000000 --- a/vendor/github.com/miekg/dns/nsecx_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package dns - -import ( - "testing" -) - -func TestPackNsec3(t *testing.T) { - nsec3 := HashName("dnsex.nl.", SHA1, 0, "DEAD") - if nsec3 != "ROCCJAE8BJJU7HN6T7NG3TNM8ACRS87J" { - t.Error(nsec3) - } - - nsec3 = HashName("a.b.c.example.org.", SHA1, 2, "DEAD") - if nsec3 != "6LQ07OAHBTOOEU2R9ANI2AT70K5O0RCG" { - t.Error(nsec3) - } -} - -func TestNsec3(t *testing.T) { - // examples taken from .nl - nsec3, _ := NewRR("39p91242oslggest5e6a7cci4iaeqvnk.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 39P99DCGG0MDLARTCRMCF6OFLLUL7PR6 NS DS RRSIG") - if !nsec3.(*NSEC3).Cover("snasajsksasasa.nl.") { // 39p94jrinub66hnpem8qdpstrec86pg3 - t.Error("39p94jrinub66hnpem8qdpstrec86pg3. should be covered by 39p91242oslggest5e6a7cci4iaeqvnk.nl. - 39P99DCGG0MDLARTCRMCF6OFLLUL7PR6") - } - nsec3, _ = NewRR("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. IN NSEC3 1 1 5 F10E9F7EA83FC8F3 SK4F38CQ0ATIEI8MH3RGD0P5I4II6QAN NS SOA TXT RRSIG DNSKEY NSEC3PARAM") - if !nsec3.(*NSEC3).Match("nl.") { // sk4e8fj94u78smusb40o1n0oltbblu2r.nl. - t.Error("sk4e8fj94u78smusb40o1n0oltbblu2r.nl. should match sk4e8fj94u78smusb40o1n0oltbblu2r.nl.") - } -} diff --git a/vendor/github.com/miekg/dns/parse_test.go b/vendor/github.com/miekg/dns/parse_test.go deleted file mode 100644 index 4e5b567..0000000 --- a/vendor/github.com/miekg/dns/parse_test.go +++ /dev/null @@ -1,1492 +0,0 @@ -package dns - -import ( - "bytes" - "crypto/rsa" - "encoding/hex" - "fmt" - "math/rand" - "net" - "reflect" - "strconv" - "strings" - "testing" - "testing/quick" - "time" -) - -func TestDotInName(t *testing.T) { - buf := make([]byte, 20) - PackDomainName("aa\\.bb.nl.", buf, 0, nil, false) - // index 3 must be a real dot - if buf[3] != '.' { - t.Error("dot should be a real dot") - } - - if buf[6] != 2 { - t.Error("this must have the value 2") - } - dom, _, _ := UnpackDomainName(buf, 0) - // printing it should yield the backspace again - if dom != "aa\\.bb.nl." { - t.Error("dot should have been escaped: ", dom) - } -} - -func TestDotLastInLabel(t *testing.T) { - sample := "aa\\..au." - buf := make([]byte, 20) - _, err := PackDomainName(sample, buf, 0, nil, false) - if err != nil { - t.Fatalf("unexpected error packing domain: %v", err) - } - dom, _, _ := UnpackDomainName(buf, 0) - if dom != sample { - t.Fatalf("unpacked domain `%s' doesn't match packed domain", dom) - } -} - -func TestTooLongDomainName(t *testing.T) { - l := "aaabbbcccdddeeefffggghhhiiijjjkkklllmmmnnnooopppqqqrrrsssttt." - dom := l + l + l + l + l + l + l - _, err := NewRR(dom + " IN A 127.0.0.1") - if err == nil { - t.Error("should be too long") - } else { - t.Logf("error is %v", err) - } - _, err = NewRR("..com. IN A 127.0.0.1") - if err == nil { - t.Error("should fail") - } else { - t.Logf("error is %v", err) - } -} - -func TestDomainName(t *testing.T) { - tests := []string{"r\\.gieben.miek.nl.", "www\\.www.miek.nl.", - "www.*.miek.nl.", "www.*.miek.nl.", - } - dbuff := make([]byte, 40) - - for _, ts := range tests { - if _, err := PackDomainName(ts, dbuff, 0, nil, false); err != nil { - t.Error("not a valid domain name") - continue - } - n, _, err := UnpackDomainName(dbuff, 0) - if err != nil { - t.Error("failed to unpack packed domain name") - continue - } - if ts != n { - t.Errorf("must be equal: in: %s, out: %s", ts, n) - } - } -} - -func TestDomainNameAndTXTEscapes(t *testing.T) { - tests := []byte{'.', '(', ')', ';', ' ', '@', '"', '\\', '\t', '\r', '\n', 0, 255} - for _, b := range tests { - rrbytes := []byte{ - 1, b, 0, // owner - byte(TypeTXT >> 8), byte(TypeTXT), - byte(ClassINET >> 8), byte(ClassINET), - 0, 0, 0, 1, // TTL - 0, 2, 1, b, // Data - } - rr1, _, err := UnpackRR(rrbytes, 0) - if err != nil { - panic(err) - } - s := rr1.String() - rr2, err := NewRR(s) - if err != nil { - t.Errorf("Error parsing unpacked RR's string: %v", err) - t.Errorf(" Bytes: %v", rrbytes) - t.Errorf("String: %v", s) - } - repacked := make([]byte, len(rrbytes)) - if _, err := PackRR(rr2, repacked, 0, nil, false); err != nil { - t.Errorf("error packing parsed RR: %v", err) - t.Errorf(" original Bytes: %v", rrbytes) - t.Errorf("unpacked Struct: %v", rr1) - t.Errorf(" parsed Struct: %v", rr2) - } - if !bytes.Equal(repacked, rrbytes) { - t.Error("packed bytes don't match original bytes") - t.Errorf(" original bytes: %v", rrbytes) - t.Errorf(" packed bytes: %v", repacked) - t.Errorf("unpacked struct: %v", rr1) - t.Errorf(" parsed struct: %v", rr2) - } - } -} - -func TestTXTEscapeParsing(t *testing.T) { - test := [][]string{ - {`";"`, `";"`}, - {`\;`, `";"`}, - {`"\t"`, `"\t"`}, - {`"\r"`, `"\r"`}, - {`"\ "`, `" "`}, - {`"\;"`, `";"`}, - {`"\;\""`, `";\""`}, - {`"\(a\)"`, `"(a)"`}, - {`"\(a)"`, `"(a)"`}, - {`"(a\)"`, `"(a)"`}, - {`"(a)"`, `"(a)"`}, - {`"\048"`, `"0"`}, - {`"\` + "\n" + `"`, `"\n"`}, - {`"\` + "\r" + `"`, `"\r"`}, - {`"\` + "\x11" + `"`, `"\017"`}, - {`"\'"`, `"'"`}, - } - for _, s := range test { - rr, err := NewRR(fmt.Sprintf("example.com. IN TXT %v", s[0])) - if err != nil { - t.Errorf("could not parse %v TXT: %s", s[0], err) - continue - } - - txt := sprintTxt(rr.(*TXT).Txt) - if txt != s[1] { - t.Errorf("mismatch after parsing `%v` TXT record: `%v` != `%v`", s[0], txt, s[1]) - } - } -} - -func GenerateDomain(r *rand.Rand, size int) []byte { - dnLen := size % 70 // artificially limit size so there's less to intrepret if a failure occurs - var dn []byte - done := false - for i := 0; i < dnLen && !done; { - max := dnLen - i - if max > 63 { - max = 63 - } - lLen := max - if lLen != 0 { - lLen = int(r.Int31()) % max - } - done = lLen == 0 - if done { - continue - } - l := make([]byte, lLen+1) - l[0] = byte(lLen) - for j := 0; j < lLen; j++ { - l[j+1] = byte(rand.Int31()) - } - dn = append(dn, l...) - i += 1 + lLen - } - return append(dn, 0) -} - -func TestDomainQuick(t *testing.T) { - r := rand.New(rand.NewSource(0)) - f := func(l int) bool { - db := GenerateDomain(r, l) - ds, _, err := UnpackDomainName(db, 0) - if err != nil { - panic(err) - } - buf := make([]byte, 255) - off, err := PackDomainName(ds, buf, 0, nil, false) - if err != nil { - t.Errorf("error packing domain: %v", err) - t.Errorf(" bytes: %v", db) - t.Errorf("string: %v", ds) - return false - } - if !bytes.Equal(db, buf[:off]) { - t.Errorf("repacked domain doesn't match original:") - t.Errorf("src bytes: %v", db) - t.Errorf(" string: %v", ds) - t.Errorf("out bytes: %v", buf[:off]) - return false - } - return true - } - if err := quick.Check(f, nil); err != nil { - t.Error(err) - } -} - -func GenerateTXT(r *rand.Rand, size int) []byte { - rdLen := size % 300 // artificially limit size so there's less to intrepret if a failure occurs - var rd []byte - for i := 0; i < rdLen; { - max := rdLen - 1 - if max > 255 { - max = 255 - } - sLen := max - if max != 0 { - sLen = int(r.Int31()) % max - } - s := make([]byte, sLen+1) - s[0] = byte(sLen) - for j := 0; j < sLen; j++ { - s[j+1] = byte(rand.Int31()) - } - rd = append(rd, s...) - i += 1 + sLen - } - return rd -} - -// Ok, 2 things. 1) this test breaks with the new functionality of splitting up larger txt -// chunks into 255 byte pieces. 2) I don't like the random nature of this thing, because I can't -// place the quotes where they need to be. -// So either add some code the places the quotes in just the right spots, make this non random -// or do something else. -// Disabled for now. (miek) -func testTXTRRQuick(t *testing.T) { - s := rand.NewSource(0) - r := rand.New(s) - typeAndClass := []byte{ - byte(TypeTXT >> 8), byte(TypeTXT), - byte(ClassINET >> 8), byte(ClassINET), - 0, 0, 0, 1, // TTL - } - f := func(l int) bool { - owner := GenerateDomain(r, l) - rdata := GenerateTXT(r, l) - rrbytes := make([]byte, 0, len(owner)+2+2+4+2+len(rdata)) - rrbytes = append(rrbytes, owner...) - rrbytes = append(rrbytes, typeAndClass...) - rrbytes = append(rrbytes, byte(len(rdata)>>8)) - rrbytes = append(rrbytes, byte(len(rdata))) - rrbytes = append(rrbytes, rdata...) - rr, _, err := UnpackRR(rrbytes, 0) - if err != nil { - panic(err) - } - buf := make([]byte, len(rrbytes)*3) - off, err := PackRR(rr, buf, 0, nil, false) - if err != nil { - t.Errorf("pack Error: %v\nRR: %v", err, rr) - return false - } - buf = buf[:off] - if !bytes.Equal(buf, rrbytes) { - t.Errorf("packed bytes don't match original bytes") - t.Errorf("src bytes: %v", rrbytes) - t.Errorf(" struct: %v", rr) - t.Errorf("out bytes: %v", buf) - return false - } - if len(rdata) == 0 { - // string'ing won't produce any data to parse - return true - } - rrString := rr.String() - rr2, err := NewRR(rrString) - if err != nil { - t.Errorf("error parsing own output: %v", err) - t.Errorf("struct: %v", rr) - t.Errorf("string: %v", rrString) - return false - } - if rr2.String() != rrString { - t.Errorf("parsed rr.String() doesn't match original string") - t.Errorf("original: %v", rrString) - t.Errorf(" parsed: %v", rr2.String()) - return false - } - - buf = make([]byte, len(rrbytes)*3) - off, err = PackRR(rr2, buf, 0, nil, false) - if err != nil { - t.Errorf("error packing parsed rr: %v", err) - t.Errorf("unpacked Struct: %v", rr) - t.Errorf(" string: %v", rrString) - t.Errorf(" parsed Struct: %v", rr2) - return false - } - buf = buf[:off] - if !bytes.Equal(buf, rrbytes) { - t.Errorf("parsed packed bytes don't match original bytes") - t.Errorf(" source bytes: %v", rrbytes) - t.Errorf("unpacked struct: %v", rr) - t.Errorf(" string: %v", rrString) - t.Errorf(" parsed struct: %v", rr2) - t.Errorf(" repacked bytes: %v", buf) - return false - } - return true - } - c := &quick.Config{MaxCountScale: 10} - if err := quick.Check(f, c); err != nil { - t.Error(err) - } -} - -func TestParseDirectiveMisc(t *testing.T) { - tests := map[string]string{ - "$ORIGIN miek.nl.\na IN NS b": "a.miek.nl.\t3600\tIN\tNS\tb.miek.nl.", - "$TTL 2H\nmiek.nl. IN NS b.": "miek.nl.\t7200\tIN\tNS\tb.", - "miek.nl. 1D IN NS b.": "miek.nl.\t86400\tIN\tNS\tb.", - `name. IN SOA a6.nstld.com. hostmaster.nic.name. ( - 203362132 ; serial - 5m ; refresh (5 minutes) - 5m ; retry (5 minutes) - 2w ; expire (2 weeks) - 300 ; minimum (5 minutes) -)`: "name.\t3600\tIN\tSOA\ta6.nstld.com. hostmaster.nic.name. 203362132 300 300 1209600 300", - ". 3600000 IN NS ONE.MY-ROOTS.NET.": ".\t3600000\tIN\tNS\tONE.MY-ROOTS.NET.", - "ONE.MY-ROOTS.NET. 3600000 IN A 192.168.1.1": "ONE.MY-ROOTS.NET.\t3600000\tIN\tA\t192.168.1.1", - } - for i, o := range tests { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestNSEC(t *testing.T) { - nsectests := map[string]string{ - "nl. IN NSEC3PARAM 1 0 5 30923C44C6CBBB8F": "nl.\t3600\tIN\tNSEC3PARAM\t1 0 5 30923C44C6CBBB8F", - "p2209hipbpnm681knjnu0m1febshlv4e.nl. IN NSEC3 1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM": "p2209hipbpnm681knjnu0m1febshlv4e.nl.\t3600\tIN\tNSEC3\t1 1 5 30923C44C6CBBB8F P90DG1KE8QEAN0B01613LHQDG0SOJ0TA NS SOA TXT RRSIG DNSKEY NSEC3PARAM", - "localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSEC": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC", - "localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSEC TYPE65534": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC TYPE65534", - "localhost.dnssex.nl. IN NSEC www.dnssex.nl. A RRSIG NSec Type65534": "localhost.dnssex.nl.\t3600\tIN\tNSEC\twww.dnssex.nl. A RRSIG NSEC TYPE65534", - } - for i, o := range nsectests { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestParseLOC(t *testing.T) { - lt := map[string]string{ - "SW1A2AA.find.me.uk. LOC 51 30 12.748 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m": "SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 30 12.748 N 00 07 39.611 W 0m 0.00m 0.00m 0.00m", - "SW1A2AA.find.me.uk. LOC 51 0 0.0 N 00 07 39.611 W 0.00m 0.00m 0.00m 0.00m": "SW1A2AA.find.me.uk.\t3600\tIN\tLOC\t51 00 0.000 N 00 07 39.611 W 0m 0.00m 0.00m 0.00m", - } - for i, o := range lt { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestParseDS(t *testing.T) { - dt := map[string]string{ - "example.net. 3600 IN DS 40692 12 3 22261A8B0E0D799183E35E24E2AD6BB58533CBA7E3B14D659E9CA09B 2071398F": "example.net.\t3600\tIN\tDS\t40692 12 3 22261A8B0E0D799183E35E24E2AD6BB58533CBA7E3B14D659E9CA09B2071398F", - } - for i, o := range dt { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestQuotes(t *testing.T) { - tests := map[string]string{ - `t.example.com. IN TXT "a bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a bc\"", - `t.example.com. IN TXT "a - bc"`: "t.example.com.\t3600\tIN\tTXT\t\"a\\n bc\"", - `t.example.com. IN TXT ""`: "t.example.com.\t3600\tIN\tTXT\t\"\"", - `t.example.com. IN TXT "a"`: "t.example.com.\t3600\tIN\tTXT\t\"a\"", - `t.example.com. IN TXT "aa"`: "t.example.com.\t3600\tIN\tTXT\t\"aa\"", - `t.example.com. IN TXT "aaa" ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"", - `t.example.com. IN TXT "abc" "DEF"`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"", - `t.example.com. IN TXT "abc" ( "DEF" )`: "t.example.com.\t3600\tIN\tTXT\t\"abc\" \"DEF\"", - `t.example.com. IN TXT aaa ;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa \"", - `t.example.com. IN TXT aaa aaa;`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"", - `t.example.com. IN TXT aaa aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa aaa\"", - `t.example.com. IN TXT aaa`: "t.example.com.\t3600\tIN\tTXT\t\"aaa\"", - "cid.urn.arpa. NAPTR 100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"z3950+I2L+I2C\" \"\" _z3950._tcp.gatech.edu.", - "cid.urn.arpa. NAPTR 100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"rcds+I2C\" \"\" _rcds._udp.gatech.edu.", - "cid.urn.arpa. NAPTR 100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.gatech.edu.": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 50 \"s\" \"http+I2L+I2C+I2R\" \"\" _http._tcp.gatech.edu.", - "cid.urn.arpa. NAPTR 100 10 \"\" \"\" \"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i\" .": "cid.urn.arpa.\t3600\tIN\tNAPTR\t100 10 \"\" \"\" \"/urn:cid:.+@([^\\.]+\\.)(.*)$/\\2/i\" .", - } - for i, o := range tests { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is\n`%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestParseClass(t *testing.T) { - tests := map[string]string{ - "t.example.com. IN A 127.0.0.1": "t.example.com. 3600 IN A 127.0.0.1", - "t.example.com. CS A 127.0.0.1": "t.example.com. 3600 CS A 127.0.0.1", - "t.example.com. CH A 127.0.0.1": "t.example.com. 3600 CH A 127.0.0.1", - // ClassANY can not occur in zone files - // "t.example.com. ANY A 127.0.0.1": "t.example.com. 3600 ANY A 127.0.0.1", - "t.example.com. NONE A 127.0.0.1": "t.example.com. 3600 NONE A 127.0.0.1", - } - for i, o := range tests { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is\n`%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestBrace(t *testing.T) { - tests := map[string]string{ - "(miek.nl.) 3600 IN A 127.0.1.1": "miek.nl.\t3600\tIN\tA\t127.0.1.1", - "miek.nl. (3600) IN MX (10) elektron.atoom.net.": "miek.nl.\t3600\tIN\tMX\t10 elektron.atoom.net.", - `miek.nl. IN ( - 3600 A 127.0.0.1)`: "miek.nl.\t3600\tIN\tA\t127.0.0.1", - "(miek.nl.) (A) (127.0.2.1)": "miek.nl.\t3600\tIN\tA\t127.0.2.1", - "miek.nl A 127.0.3.1": "miek.nl.\t3600\tIN\tA\t127.0.3.1", - "_ssh._tcp.local. 60 IN (PTR) stora._ssh._tcp.local.": "_ssh._tcp.local.\t60\tIN\tPTR\tstora._ssh._tcp.local.", - "miek.nl. NS ns.miek.nl": "miek.nl.\t3600\tIN\tNS\tns.miek.nl.", - `(miek.nl.) ( - (IN) - (AAAA) - (::1) )`: "miek.nl.\t3600\tIN\tAAAA\t::1", - `(miek.nl.) ( - (IN) - (AAAA) - (::1))`: "miek.nl.\t3600\tIN\tAAAA\t::1", - "miek.nl. IN AAAA ::2": "miek.nl.\t3600\tIN\tAAAA\t::2", - `((m)(i)ek.(n)l.) (SOA) (soa.) (soa.) ( - 2009032802 ; serial - 21600 ; refresh (6 hours) - 7(2)00 ; retry (2 hours) - 604()800 ; expire (1 week) - 3600 ; minimum (1 hour) - )`: "miek.nl.\t3600\tIN\tSOA\tsoa. soa. 2009032802 21600 7200 604800 3600", - "miek\\.nl. IN A 127.0.0.10": "miek\\.nl.\t3600\tIN\tA\t127.0.0.10", - "miek.nl. IN A 127.0.0.11": "miek.nl.\t3600\tIN\tA\t127.0.0.11", - "miek.nl. A 127.0.0.12": "miek.nl.\t3600\tIN\tA\t127.0.0.12", - `miek.nl. 86400 IN SOA elektron.atoom.net. miekg.atoom.net. ( - 2009032802 ; serial - 21600 ; refresh (6 hours) - 7200 ; retry (2 hours) - 604800 ; expire (1 week) - 3600 ; minimum (1 hour) - )`: "miek.nl.\t86400\tIN\tSOA\telektron.atoom.net. miekg.atoom.net. 2009032802 21600 7200 604800 3600", - } - for i, o := range tests { - rr, err := NewRR(i) - if err != nil { - t.Errorf("failed to parse RR: %v\n\t%s", err, i) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestParseFailure(t *testing.T) { - tests := []string{"miek.nl. IN A 327.0.0.1", - "miek.nl. IN AAAA ::x", - "miek.nl. IN MX a0 miek.nl.", - "miek.nl aap IN MX mx.miek.nl.", - "miek.nl 200 IN mxx 10 mx.miek.nl.", - "miek.nl. inn MX 10 mx.miek.nl.", - // "miek.nl. IN CNAME ", // actually valid nowadays, zero size rdata - "miek.nl. IN CNAME ..", - "miek.nl. PA MX 10 miek.nl.", - "miek.nl. ) IN MX 10 miek.nl.", - } - - for _, s := range tests { - _, err := NewRR(s) - if err == nil { - t.Errorf("should have triggered an error: \"%s\"", s) - } - } -} - -func TestZoneParsing(t *testing.T) { - // parse_test.db - db := ` -a.example.com. IN A 127.0.0.1 -8db7._openpgpkey.example.com. IN OPENPGPKEY mQCNAzIG -$ORIGIN a.example.com. -test IN A 127.0.0.1 - IN SSHFP 1 2 ( - BC6533CDC95A79078A39A56EA7635984ED655318ADA9 - B6159E30723665DA95BB ) -$ORIGIN b.example.com. -test IN CNAME test.a.example.com. -` - start := time.Now().UnixNano() - to := ParseZone(strings.NewReader(db), "", "parse_test.db") - var i int - for x := range to { - i++ - if x.Error != nil { - t.Error(x.Error) - continue - } - t.Log(x.RR) - } - delta := time.Now().UnixNano() - start - t.Logf("%d RRs parsed in %.2f s (%.2f RR/s)", i, float32(delta)/1e9, float32(i)/(float32(delta)/1e9)) -} - -func ExampleParseZone() { - zone := `$ORIGIN . -$TTL 3600 ; 1 hour -name IN SOA a6.nstld.com. hostmaster.nic.name. ( - 203362132 ; serial - 300 ; refresh (5 minutes) - 300 ; retry (5 minutes) - 1209600 ; expire (2 weeks) - 300 ; minimum (5 minutes) - ) -$TTL 10800 ; 3 hours -name. 10800 IN NS name. - IN NS g6.nstld.com. - 7200 NS h6.nstld.com. - 3600 IN NS j6.nstld.com. - IN 3600 NS k6.nstld.com. - NS l6.nstld.com. - NS a6.nstld.com. - NS c6.nstld.com. - NS d6.nstld.com. - NS f6.nstld.com. - NS m6.nstld.com. -( - NS m7.nstld.com. -) -$ORIGIN name. -0-0onlus NS ns7.ehiweb.it. - NS ns8.ehiweb.it. -0-g MX 10 mx01.nic - MX 10 mx02.nic - MX 10 mx03.nic - MX 10 mx04.nic -$ORIGIN 0-g.name -moutamassey NS ns01.yahoodomains.jp. - NS ns02.yahoodomains.jp. -` - to := ParseZone(strings.NewReader(zone), "", "testzone") - for x := range to { - fmt.Println(x.RR) - } - // Output: - // name. 3600 IN SOA a6.nstld.com. hostmaster.nic.name. 203362132 300 300 1209600 300 - // name. 10800 IN NS name. - // name. 10800 IN NS g6.nstld.com. - // name. 7200 IN NS h6.nstld.com. - // name. 3600 IN NS j6.nstld.com. - // name. 3600 IN NS k6.nstld.com. - // name. 10800 IN NS l6.nstld.com. - // name. 10800 IN NS a6.nstld.com. - // name. 10800 IN NS c6.nstld.com. - // name. 10800 IN NS d6.nstld.com. - // name. 10800 IN NS f6.nstld.com. - // name. 10800 IN NS m6.nstld.com. - // name. 10800 IN NS m7.nstld.com. - // 0-0onlus.name. 10800 IN NS ns7.ehiweb.it. - // 0-0onlus.name. 10800 IN NS ns8.ehiweb.it. - // 0-g.name. 10800 IN MX 10 mx01.nic.name. - // 0-g.name. 10800 IN MX 10 mx02.nic.name. - // 0-g.name. 10800 IN MX 10 mx03.nic.name. - // 0-g.name. 10800 IN MX 10 mx04.nic.name. - // moutamassey.0-g.name.name. 10800 IN NS ns01.yahoodomains.jp. - // moutamassey.0-g.name.name. 10800 IN NS ns02.yahoodomains.jp. -} - -func ExampleHIP() { - h := `www.example.com IN HIP ( 2 200100107B1A74DF365639CC39F1D578 - AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p -9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQ -b1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D - rvs.example.com. )` - if hip, err := NewRR(h); err == nil { - fmt.Println(hip.String()) - } - // Output: - // www.example.com. 3600 IN HIP 2 200100107B1A74DF365639CC39F1D578 AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQb1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D rvs.example.com. -} - -func TestHIP(t *testing.T) { - h := `www.example.com. IN HIP ( 2 200100107B1A74DF365639CC39F1D578 - AwEAAbdxyhNuSutc5EMzxTs9LBPCIkOFH8cIvM4p -9+LrV4e19WzK00+CI6zBCQTdtWsuxKbWIy87UOoJTwkUs7lBu+Upr1gsNrut79ryra+bSRGQ -b1slImA8YVJyuIDsj7kwzG7jnERNqnWxZ48AWkskmdHaVDP4BcelrTI3rMXdXF5D - rvs1.example.com. - rvs2.example.com. )` - rr, err := NewRR(h) - if err != nil { - t.Fatalf("failed to parse RR: %v", err) - } - t.Logf("RR: %s", rr) - msg := new(Msg) - msg.Answer = []RR{rr, rr} - bytes, err := msg.Pack() - if err != nil { - t.Fatalf("failed to pack msg: %v", err) - } - if err := msg.Unpack(bytes); err != nil { - t.Fatalf("failed to unpack msg: %v", err) - } - if len(msg.Answer) != 2 { - t.Fatalf("2 answers expected: %v", msg) - } - for i, rr := range msg.Answer { - rr := rr.(*HIP) - t.Logf("RR: %s", rr) - if l := len(rr.RendezvousServers); l != 2 { - t.Fatalf("2 servers expected, only %d in record %d:\n%v", l, i, msg) - } - for j, s := range []string{"rvs1.example.com.", "rvs2.example.com."} { - if rr.RendezvousServers[j] != s { - t.Fatalf("expected server %d of record %d to be %s:\n%v", j, i, s, msg) - } - } - } -} - -func ExampleSOA() { - s := "example.com. 1000 SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100" - if soa, err := NewRR(s); err == nil { - fmt.Println(soa.String()) - } - // Output: - // example.com. 1000 IN SOA master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100 -} - -func TestLineNumberError(t *testing.T) { - s := "example.com. 1000 SOA master.example.com. admin.example.com. monkey 4294967294 4294967293 4294967295 100" - if _, err := NewRR(s); err != nil { - if err.Error() != "dns: bad SOA zone parameter: \"monkey\" at line: 1:68" { - t.Error("not expecting this error: ", err) - } - } -} - -// Test with no known RR on the line -func TestLineNumberError2(t *testing.T) { - tests := map[string]string{ - "example.com. 1000 SO master.example.com. admin.example.com. 1 4294967294 4294967293 4294967295 100": "dns: expecting RR type or class, not this...: \"SO\" at line: 1:21", - "example.com 1000 IN TALINK a.example.com. b..example.com.": "dns: bad TALINK NextName: \"b..example.com.\" at line: 1:57", - "example.com 1000 IN TALINK ( a.example.com. b..example.com. )": "dns: bad TALINK NextName: \"b..example.com.\" at line: 1:60", - `example.com 1000 IN TALINK ( a.example.com. - bb..example.com. )`: "dns: bad TALINK NextName: \"bb..example.com.\" at line: 2:18", - // This is a bug, it should report an error on line 1, but the new is already processed. - `example.com 1000 IN TALINK ( a.example.com. b...example.com. - )`: "dns: bad TALINK NextName: \"b...example.com.\" at line: 2:1"} - - for in, errStr := range tests { - _, err := NewRR(in) - if err == nil { - t.Error("err is nil") - } else { - if err.Error() != errStr { - t.Errorf("%s: error should be %s is %v", in, errStr, err) - } - } - } -} - -// Test if the calculations are correct -func TestRfc1982(t *testing.T) { - // If the current time and the timestamp are more than 68 years apart - // it means the date has wrapped. 0 is 1970 - - // fall in the current 68 year span - strtests := []string{"20120525134203", "19700101000000", "20380119031408"} - for _, v := range strtests { - if x, _ := StringToTime(v); v != TimeToString(x) { - t.Errorf("1982 arithmetic string failure %s (%s:%d)", v, TimeToString(x), x) - } - } - - inttests := map[uint32]string{0: "19700101000000", - 1 << 31: "20380119031408", - 1<<32 - 1: "21060207062815", - } - for i, v := range inttests { - if TimeToString(i) != v { - t.Errorf("1982 arithmetic int failure %d:%s (%s)", i, v, TimeToString(i)) - } - } - - // Future tests, these dates get parsed to a date within the current 136 year span - future := map[string]string{"22680119031408": "20631123173144", - "19010101121212": "20370206184028", - "19210101121212": "20570206184028", - "19500101121212": "20860206184028", - "19700101000000": "19700101000000", - "19690101000000": "21050207062816", - "29210101121212": "21040522212236", - } - for from, to := range future { - x, _ := StringToTime(from) - y := TimeToString(x) - if y != to { - t.Errorf("1982 arithmetic future failure %s:%s (%s)", from, to, y) - } - } -} - -func TestEmpty(t *testing.T) { - for range ParseZone(strings.NewReader(""), "", "") { - t.Errorf("should be empty") - } -} - -func TestLowercaseTokens(t *testing.T) { - var testrecords = []string{ - "example.org. 300 IN a 1.2.3.4", - "example.org. 300 in A 1.2.3.4", - "example.org. 300 in a 1.2.3.4", - "example.org. 300 a 1.2.3.4", - "example.org. 300 A 1.2.3.4", - "example.org. IN a 1.2.3.4", - "example.org. in A 1.2.3.4", - "example.org. in a 1.2.3.4", - "example.org. a 1.2.3.4", - "example.org. A 1.2.3.4", - "example.org. a 1.2.3.4", - "$ORIGIN example.org.\n a 1.2.3.4", - "$Origin example.org.\n a 1.2.3.4", - "$origin example.org.\n a 1.2.3.4", - "example.org. Class1 Type1 1.2.3.4", - } - for _, testrr := range testrecords { - _, err := NewRR(testrr) - if err != nil { - t.Errorf("failed to parse %#v, got %v", testrr, err) - } - } -} - -func ExampleParseZone_generate() { - // From the manual: http://www.bind9.net/manual/bind/9.3.2/Bv9ARM.ch06.html#id2566761 - zone := "$GENERATE 1-2 0 NS SERVER$.EXAMPLE.\n$GENERATE 1-8 $ CNAME $.0" - to := ParseZone(strings.NewReader(zone), "0.0.192.IN-ADDR.ARPA.", "") - for x := range to { - if x.Error == nil { - fmt.Println(x.RR.String()) - } - } - // Output: - // 0.0.0.192.IN-ADDR.ARPA. 3600 IN NS SERVER1.EXAMPLE. - // 0.0.0.192.IN-ADDR.ARPA. 3600 IN NS SERVER2.EXAMPLE. - // 1.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 1.0.0.0.192.IN-ADDR.ARPA. - // 2.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 2.0.0.0.192.IN-ADDR.ARPA. - // 3.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 3.0.0.0.192.IN-ADDR.ARPA. - // 4.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 4.0.0.0.192.IN-ADDR.ARPA. - // 5.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 5.0.0.0.192.IN-ADDR.ARPA. - // 6.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 6.0.0.0.192.IN-ADDR.ARPA. - // 7.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 7.0.0.0.192.IN-ADDR.ARPA. - // 8.0.0.192.IN-ADDR.ARPA. 3600 IN CNAME 8.0.0.0.192.IN-ADDR.ARPA. -} - -func TestSRVPacking(t *testing.T) { - msg := Msg{} - - things := []string{"1.2.3.4:8484", - "45.45.45.45:8484", - "84.84.84.84:8484", - } - - for i, n := range things { - h, p, err := net.SplitHostPort(n) - if err != nil { - continue - } - port := 8484 - tmp, err := strconv.Atoi(p) - if err == nil { - port = tmp - } - - rr := &SRV{ - Hdr: RR_Header{Name: "somename.", - Rrtype: TypeSRV, - Class: ClassINET, - Ttl: 5}, - Priority: uint16(i), - Weight: 5, - Port: uint16(port), - Target: h + ".", - } - - msg.Answer = append(msg.Answer, rr) - } - - _, err := msg.Pack() - if err != nil { - t.Fatalf("couldn't pack %v: %v", msg, err) - } -} - -func TestParseBackslash(t *testing.T) { - if r, err := NewRR("nul\\000gap.test.globnix.net. 600 IN A 192.0.2.10"); err != nil { - t.Errorf("could not create RR with \\000 in it") - } else { - t.Logf("parsed %s", r.String()) - } - if r, err := NewRR(`nul\000gap.test.globnix.net. 600 IN TXT "Hello\123"`); err != nil { - t.Errorf("could not create RR with \\000 in it") - } else { - t.Logf("parsed %s", r.String()) - } - if r, err := NewRR(`m\ @\ iek.nl. IN 3600 A 127.0.0.1`); err != nil { - t.Errorf("could not create RR with \\ and \\@ in it") - } else { - t.Logf("parsed %s", r.String()) - } -} - -func TestILNP(t *testing.T) { - tests := []string{ - "host1.example.com.\t3600\tIN\tNID\t10 0014:4fff:ff20:ee64", - "host1.example.com.\t3600\tIN\tNID\t20 0015:5fff:ff21:ee65", - "host2.example.com.\t3600\tIN\tNID\t10 0016:6fff:ff22:ee66", - "host1.example.com.\t3600\tIN\tL32\t10 10.1.2.0", - "host1.example.com.\t3600\tIN\tL32\t20 10.1.4.0", - "host2.example.com.\t3600\tIN\tL32\t10 10.1.8.0", - "host1.example.com.\t3600\tIN\tL64\t10 2001:0DB8:1140:1000", - "host1.example.com.\t3600\tIN\tL64\t20 2001:0DB8:2140:2000", - "host2.example.com.\t3600\tIN\tL64\t10 2001:0DB8:4140:4000", - "host1.example.com.\t3600\tIN\tLP\t10 l64-subnet1.example.com.", - "host1.example.com.\t3600\tIN\tLP\t10 l64-subnet2.example.com.", - "host1.example.com.\t3600\tIN\tLP\t20 l32-subnet1.example.com.", - } - for _, t1 := range tests { - r, err := NewRR(t1) - if err != nil { - t.Fatalf("an error occurred: %v", err) - } else { - if t1 != r.String() { - t.Fatalf("strings should be equal %s %s", t1, r.String()) - } - } - } -} - -func TestGposEidNimloc(t *testing.T) { - dt := map[string]string{ - "444433332222111199990123000000ff. NSAP-PTR foo.bar.com.": "444433332222111199990123000000ff.\t3600\tIN\tNSAP-PTR\tfoo.bar.com.", - "lillee. IN GPOS -32.6882 116.8652 10.0": "lillee.\t3600\tIN\tGPOS\t-32.6882 116.8652 10.0", - "hinault. IN GPOS -22.6882 116.8652 250.0": "hinault.\t3600\tIN\tGPOS\t-22.6882 116.8652 250.0", - "VENERA. IN NIMLOC 75234159EAC457800920": "VENERA.\t3600\tIN\tNIMLOC\t75234159EAC457800920", - "VAXA. IN EID 3141592653589793": "VAXA.\t3600\tIN\tEID\t3141592653589793", - } - for i, o := range dt { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestPX(t *testing.T) { - dt := map[string]string{ - "*.net2.it. IN PX 10 net2.it. PRMD-net2.ADMD-p400.C-it.": "*.net2.it.\t3600\tIN\tPX\t10 net2.it. PRMD-net2.ADMD-p400.C-it.", - "ab.net2.it. IN PX 10 ab.net2.it. O-ab.PRMD-net2.ADMDb.C-it.": "ab.net2.it.\t3600\tIN\tPX\t10 ab.net2.it. O-ab.PRMD-net2.ADMDb.C-it.", - } - for i, o := range dt { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestComment(t *testing.T) { - // Comments we must see - comments := map[string]bool{"; this is comment 1": true, - "; this is comment 4": true, "; this is comment 6": true, - "; this is comment 7": true, "; this is comment 8": true} - zone := ` -foo. IN A 10.0.0.1 ; this is comment 1 -foo. IN A ( - 10.0.0.2 ; this is comment2 -) -; this is comment3 -foo. IN A 10.0.0.3 -foo. IN A ( 10.0.0.4 ); this is comment 4 - -foo. IN A 10.0.0.5 -; this is comment5 - -foo. IN A 10.0.0.6 - -foo. IN DNSKEY 256 3 5 AwEAAb+8l ; this is comment 6 -foo. IN NSEC miek.nl. TXT RRSIG NSEC; this is comment 7 -foo. IN TXT "THIS IS TEXT MAN"; this is comment 8 -` - for x := range ParseZone(strings.NewReader(zone), ".", "") { - if x.Error == nil { - if x.Comment != "" { - if _, ok := comments[x.Comment]; !ok { - t.Errorf("wrong comment %s", x.Comment) - } - } - } - } -} - -func TestEUIxx(t *testing.T) { - tests := map[string]string{ - "host.example. IN EUI48 00-00-5e-90-01-2a": "host.example.\t3600\tIN\tEUI48\t00-00-5e-90-01-2a", - "host.example. IN EUI64 00-00-5e-ef-00-00-00-2a": "host.example.\t3600\tIN\tEUI64\t00-00-5e-ef-00-00-00-2a", - } - for i, o := range tests { - r, err := NewRR(i) - if err != nil { - t.Errorf("failed to parse %s: %v", i, err) - } - if r.String() != o { - t.Errorf("want %s, got %s", o, r.String()) - } - } -} - -func TestUserRR(t *testing.T) { - tests := map[string]string{ - "host.example. IN UID 1234": "host.example.\t3600\tIN\tUID\t1234", - "host.example. IN GID 1234556": "host.example.\t3600\tIN\tGID\t1234556", - "host.example. IN UINFO \"Miek Gieben\"": "host.example.\t3600\tIN\tUINFO\t\"Miek Gieben\"", - } - for i, o := range tests { - r, err := NewRR(i) - if err != nil { - t.Errorf("failed to parse %s: %v", i, err) - } - if r.String() != o { - t.Errorf("want %s, got %s", o, r.String()) - } - } -} - -func TestTXT(t *testing.T) { - // Test single entry TXT record - rr, err := NewRR(`_raop._tcp.local. 60 IN TXT "single value"`) - if err != nil { - t.Error("failed to parse single value TXT record", err) - } else if rr, ok := rr.(*TXT); !ok { - t.Error("wrong type, record should be of type TXT") - } else { - if len(rr.Txt) != 1 { - t.Error("bad size of TXT value:", len(rr.Txt)) - } else if rr.Txt[0] != "single value" { - t.Error("bad single value") - } - if rr.String() != `_raop._tcp.local. 60 IN TXT "single value"` { - t.Error("bad representation of TXT record:", rr.String()) - } - if rr.len() != 28+1+12 { - t.Error("bad size of serialized record:", rr.len()) - } - } - - // Test multi entries TXT record - rr, err = NewRR(`_raop._tcp.local. 60 IN TXT "a=1" "b=2" "c=3" "d=4"`) - if err != nil { - t.Error("failed to parse multi-values TXT record", err) - } else if rr, ok := rr.(*TXT); !ok { - t.Error("wrong type, record should be of type TXT") - } else { - if len(rr.Txt) != 4 { - t.Error("bad size of TXT multi-value:", len(rr.Txt)) - } else if rr.Txt[0] != "a=1" || rr.Txt[1] != "b=2" || rr.Txt[2] != "c=3" || rr.Txt[3] != "d=4" { - t.Error("bad values in TXT records") - } - if rr.String() != `_raop._tcp.local. 60 IN TXT "a=1" "b=2" "c=3" "d=4"` { - t.Error("bad representation of TXT multi value record:", rr.String()) - } - if rr.len() != 28+1+3+1+3+1+3+1+3 { - t.Error("bad size of serialized multi value record:", rr.len()) - } - } - - // Test empty-string in TXT record - rr, err = NewRR(`_raop._tcp.local. 60 IN TXT ""`) - if err != nil { - t.Error("failed to parse empty-string TXT record", err) - } else if rr, ok := rr.(*TXT); !ok { - t.Error("wrong type, record should be of type TXT") - } else { - if len(rr.Txt) != 1 { - t.Error("bad size of TXT empty-string value:", len(rr.Txt)) - } else if rr.Txt[0] != "" { - t.Error("bad value for empty-string TXT record") - } - if rr.String() != `_raop._tcp.local. 60 IN TXT ""` { - t.Error("bad representation of empty-string TXT record:", rr.String()) - } - if rr.len() != 28+1 { - t.Error("bad size of serialized record:", rr.len()) - } - } - - // Test TXT record with chunk larger than 255 bytes, they should be split up, by the parser - s := "" - for i := 0; i < 255; i++ { - s += "a" - } - s += "b" - rr, err = NewRR(`test.local. 60 IN TXT "` + s + `"`) - if err != nil { - t.Error("failed to parse empty-string TXT record", err) - } - if rr.(*TXT).Txt[1] != "b" { - t.Errorf("Txt should have two chunk, last one my be 'b', but is %s", rr.(*TXT).Txt[1]) - } - t.Log(rr.String()) -} - -func TestTypeXXXX(t *testing.T) { - _, err := NewRR("example.com IN TYPE1234 \\# 4 aabbccdd") - if err != nil { - t.Errorf("failed to parse TYPE1234 RR: %v", err) - } - _, err = NewRR("example.com IN TYPE655341 \\# 8 aabbccddaabbccdd") - if err == nil { - t.Errorf("this should not work, for TYPE655341") - } - _, err = NewRR("example.com IN TYPE1 \\# 4 0a000001") - if err == nil { - t.Errorf("this should not work") - } -} - -func TestPTR(t *testing.T) { - _, err := NewRR("144.2.0.192.in-addr.arpa. 900 IN PTR ilouse03146p0\\(.example.com.") - if err != nil { - t.Error("failed to parse ", err) - } -} - -func TestDigit(t *testing.T) { - tests := map[string]byte{ - "miek\\000.nl. 100 IN TXT \"A\"": 0, - "miek\\001.nl. 100 IN TXT \"A\"": 1, - "miek\\254.nl. 100 IN TXT \"A\"": 254, - "miek\\255.nl. 100 IN TXT \"A\"": 255, - "miek\\256.nl. 100 IN TXT \"A\"": 0, - "miek\\257.nl. 100 IN TXT \"A\"": 1, - "miek\\004.nl. 100 IN TXT \"A\"": 4, - } - for s, i := range tests { - r, err := NewRR(s) - buf := make([]byte, 40) - if err != nil { - t.Fatalf("failed to parse %v", err) - } - PackRR(r, buf, 0, nil, false) - t.Log(buf) - if buf[5] != i { - t.Fatalf("5 pos must be %d, is %d", i, buf[5]) - } - r1, _, _ := UnpackRR(buf, 0) - if r1.Header().Ttl != 100 { - t.Fatalf("TTL should %d, is %d", 100, r1.Header().Ttl) - } - } -} - -func TestParseRRSIGTimestamp(t *testing.T) { - tests := map[string]bool{ - `miek.nl. IN RRSIG SOA 8 2 43200 20140210031301 20140111031301 12051 miek.nl. MVZUyrYwq0iZhMFDDnVXD2BvuNiUJjSYlJAgzyAE6CF875BMvvZa+Sb0 RlSCL7WODQSQHhCx/fegHhVVF+Iz8N8kOLrmXD1+jO3Bm6Prl5UhcsPx WTBsg/kmxbp8sR1kvH4oZJtVfakG3iDerrxNaf0sQwhZzyfJQAqpC7pcBoc=`: true, - `miek.nl. IN RRSIG SOA 8 2 43200 315565800 4102477800 12051 miek.nl. MVZUyrYwq0iZhMFDDnVXD2BvuNiUJjSYlJAgzyAE6CF875BMvvZa+Sb0 RlSCL7WODQSQHhCx/fegHhVVF+Iz8N8kOLrmXD1+jO3Bm6Prl5UhcsPx WTBsg/kmxbp8sR1kvH4oZJtVfakG3iDerrxNaf0sQwhZzyfJQAqpC7pcBoc=`: true, - } - for r := range tests { - _, err := NewRR(r) - if err != nil { - t.Error(err) - } - } -} - -func TestTxtEqual(t *testing.T) { - rr1 := new(TXT) - rr1.Hdr = RR_Header{Name: ".", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0} - rr1.Txt = []string{"a\"a", "\"", "b"} - rr2, _ := NewRR(rr1.String()) - if rr1.String() != rr2.String() { - // This is not an error, but keep this test. - t.Errorf("these two TXT records should match:\n%s\n%s", rr1.String(), rr2.String()) - } - t.Logf("%s\n%s", rr1.String(), rr2.String()) -} - -func TestTxtLong(t *testing.T) { - rr1 := new(TXT) - rr1.Hdr = RR_Header{Name: ".", Rrtype: TypeTXT, Class: ClassINET, Ttl: 0} - // Make a long txt record, this breaks when sending the packet, - // but not earlier. - rr1.Txt = []string{"start-"} - for i := 0; i < 200; i++ { - rr1.Txt[0] += "start-" - } - str := rr1.String() - if len(str) < len(rr1.Txt[0]) { - t.Error("string conversion should work") - } -} - -// Basically, don't crash. -func TestMalformedPackets(t *testing.T) { - var packets = []string{ - "0021641c0000000100000000000078787878787878787878787303636f6d0000100001", - } - - // com = 63 6f 6d - for _, packet := range packets { - data, _ := hex.DecodeString(packet) - // for _, v := range data { - // t.Log(v) - // } - var msg Msg - msg.Unpack(data) - // println(msg.String()) - } -} - -type algorithm struct { - name uint8 - bits int -} - -func TestNewPrivateKey(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } - algorithms := []algorithm{ - {ECDSAP256SHA256, 256}, - {ECDSAP384SHA384, 384}, - {RSASHA1, 1024}, - {RSASHA256, 2048}, - {DSA, 1024}, - } - - for _, algo := range algorithms { - key := new(DNSKEY) - key.Hdr.Rrtype = TypeDNSKEY - key.Hdr.Name = "miek.nl." - key.Hdr.Class = ClassINET - key.Hdr.Ttl = 14400 - key.Flags = 256 - key.Protocol = 3 - key.Algorithm = algo.name - privkey, err := key.Generate(algo.bits) - if err != nil { - t.Fatal(err) - } - - newPrivKey, err := key.NewPrivateKey(key.PrivateKeyString(privkey)) - if err != nil { - t.Error(key.String()) - t.Error(key.PrivateKeyString(privkey)) - t.Fatal(err) - } - - switch newPrivKey := newPrivKey.(type) { - case *rsa.PrivateKey: - newPrivKey.Precompute() - } - - if !reflect.DeepEqual(privkey, newPrivKey) { - t.Errorf("[%v] Private keys differ:\n%#v\n%#v", AlgorithmToString[algo.name], privkey, newPrivKey) - } - } -} - -// special input test -func TestNewRRSpecial(t *testing.T) { - var ( - rr RR - err error - expect string - ) - - rr, err = NewRR("; comment") - expect = "" - if err != nil { - t.Errorf("unexpected err: %v", err) - } - if rr != nil { - t.Errorf("unexpected result: [%s] != [%s]", rr, expect) - } - - rr, err = NewRR("") - expect = "" - if err != nil { - t.Errorf("unexpected err: %v", err) - } - if rr != nil { - t.Errorf("unexpected result: [%s] != [%s]", rr, expect) - } - - rr, err = NewRR("$ORIGIN foo.") - expect = "" - if err != nil { - t.Errorf("unexpected err: %v", err) - } - if rr != nil { - t.Errorf("unexpected result: [%s] != [%s]", rr, expect) - } - - rr, err = NewRR(" ") - expect = "" - if err != nil { - t.Errorf("unexpected err: %v", err) - } - if rr != nil { - t.Errorf("unexpected result: [%s] != [%s]", rr, expect) - } - - rr, err = NewRR("\n") - expect = "" - if err != nil { - t.Errorf("unexpected err: %v", err) - } - if rr != nil { - t.Errorf("unexpected result: [%s] != [%s]", rr, expect) - } - - rr, err = NewRR("foo. A 1.1.1.1\nbar. A 2.2.2.2") - expect = "foo.\t3600\tIN\tA\t1.1.1.1" - if err != nil { - t.Errorf("unexpected err: %v", err) - } - if rr == nil || rr.String() != expect { - t.Errorf("unexpected result: [%s] != [%s]", rr, expect) - } -} - -func TestPrintfVerbsRdata(t *testing.T) { - x, _ := NewRR("www.miek.nl. IN MX 20 mx.miek.nl.") - if Field(x, 1) != "20" { - t.Errorf("should be 20") - } - if Field(x, 2) != "mx.miek.nl." { - t.Errorf("should be mx.miek.nl.") - } - - x, _ = NewRR("www.miek.nl. IN A 127.0.0.1") - if Field(x, 1) != "127.0.0.1" { - t.Errorf("should be 127.0.0.1") - } - - x, _ = NewRR("www.miek.nl. IN AAAA ::1") - if Field(x, 1) != "::1" { - t.Errorf("should be ::1") - } - - x, _ = NewRR("www.miek.nl. IN NSEC a.miek.nl. A NS SOA MX AAAA") - if Field(x, 1) != "a.miek.nl." { - t.Errorf("should be a.miek.nl.") - } - if Field(x, 2) != "A NS SOA MX AAAA" { - t.Errorf("should be A NS SOA MX AAAA") - } - - x, _ = NewRR("www.miek.nl. IN TXT \"first\" \"second\"") - if Field(x, 1) != "first second" { - t.Errorf("should be first second") - } - if Field(x, 0) != "" { - t.Errorf("should be empty") - } -} - -func TestParseTokenOverflow(t *testing.T) { - _, err := NewRR("_443._tcp.example.org. IN TLSA 0 0 0 308205e8308204d0a00302010202100411de8f53b462f6a5a861b712ec6b59300d06092a864886f70d01010b05003070310b300906035504061302555331153013060355040a130c446967694365727420496e6331193017060355040b13107777772e64696769636572742e636f6d312f302d06035504031326446967694365727420534841322048696768204173737572616e636520536572766572204341301e170d3134313130363030303030305a170d3135313131333132303030305a3081a5310b3009060355040613025553311330110603550408130a43616c69666f726e6961311430120603550407130b4c6f7320416e67656c6573313c303a060355040a1333496e7465726e657420436f72706f726174696f6e20666f722041737369676e6564204e616d657320616e64204e756d6265727331133011060355040b130a546563686e6f6c6f6779311830160603550403130f7777772e6578616d706c652e6f726730820122300d06092a864886f70d01010105000382010f003082010a02820101009e663f52a3d18cb67cdfed547408a4e47e4036538988da2798da3b6655f7240d693ed1cb3fe6d6ad3a9e657ff6efa86b83b0cad24e5d31ff2bf70ec3b78b213f1b4bf61bdc669cbbc07d67154128ca92a9b3cbb4213a836fb823ddd4d7cc04918314d25f06086fa9970ba17e357cca9b458c27eb71760ab95e3f9bc898ae89050ae4d09ba2f7e4259d9ff1e072a6971b18355a8b9e53670c3d5dbdbd283f93a764e71b3a4140ca0746090c08510e2e21078d7d07844bf9c03865b531a0bf2ee766bc401f6451c5a1e6f6fb5d5c1d6a97a0abe91ae8b02e89241e07353909ccd5b41c46de207c06801e08f20713603827f2ae3e68cf15ef881d7e0608f70742e30203010001a382024630820242301f0603551d230418301680145168ff90af0207753cccd9656462a212b859723b301d0603551d0e04160414b000a7f422e9b1ce216117c4c46e7164c8e60c553081810603551d11047a3078820f7777772e6578616d706c652e6f7267820b6578616d706c652e636f6d820b6578616d706c652e656475820b6578616d706c652e6e6574820b6578616d706c652e6f7267820f7777772e6578616d706c652e636f6d820f7777772e6578616d706c652e656475820f7777772e6578616d706c652e6e6574300e0603551d0f0101ff0404030205a0301d0603551d250416301406082b0601050507030106082b0601050507030230750603551d1f046e306c3034a032a030862e687474703a2f2f63726c332e64696769636572742e636f6d2f736861322d68612d7365727665722d67332e63726c3034a032a030862e687474703a2f2f63726c342e64696769636572742e636f6d2f736861322d68612d7365727665722d67332e63726c30420603551d20043b3039303706096086480186fd6c0101302a302806082b06010505070201161c68747470733a2f2f7777772e64696769636572742e636f6d2f43505330818306082b0601050507010104773075302406082b060105050730018618687474703a2f2f6f6373702e64696769636572742e636f6d304d06082b060105050730028641687474703a2f2f636163657274732e64696769636572742e636f6d2f446967694365727453484132486967684173737572616e636553657276657243412e637274300c0603551d130101ff04023000300d06092a864886f70d01010b050003820101005eac2124dedb3978a86ff3608406acb542d3cb54cb83facd63aec88144d6a1bf15dbf1f215c4a73e241e582365cba9ea50dd306541653b3513af1a0756c1b2720e8d112b34fb67181efad9c4609bdc670fb025fa6e6d42188161b026cf3089a08369c2f3609fc84bcc3479140c1922ede430ca8dbac2b2a3cdacb305ba15dc7361c4c3a5e6daa99cb446cb221b28078a7a944efba70d96f31ac143d959bccd2fd50e30c325ea2624fb6b6dbe9344dbcf133bfbd5b4e892d635dbf31596451672c6b65ba5ac9b3cddea92b35dab1065cae3c8cb6bb450a62ea2f72ea7c6bdc7b65fa09b012392543734083c7687d243f8d0375304d99ccd2e148966a8637a6797") - if err == nil { - t.Fatalf("token overflow should return an error") - } - t.Logf("err: %s\n", err) -} - -func TestParseTLSA(t *testing.T) { - lt := []string{ - "_443._tcp.example.org.\t3600\tIN\tTLSA\t1 1 1 c22be239f483c08957bc106219cc2d3ac1a308dfbbdd0a365f17b9351234cf00", - "_443._tcp.example.org.\t3600\tIN\tTLSA\t2 1 2 4e85f45179e9cd6e0e68e2eb5be2e85ec9b92d91c609caf3ef0315213e3f92ece92c38397a607214de95c7fadc0ad0f1c604a469a0387959745032c0d51492f3", - "_443._tcp.example.org.\t3600\tIN\tTLSA\t3 0 2 69ec8d2277360b215d0cd956b0e2747108dff34b27d461a41c800629e38ee6c2d1230cc9e8e36711330adc6766e6ff7c5fbb37f106f248337c1a20ad682888d2", - } - for _, o := range lt { - rr, err := NewRR(o) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", o, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestParseSSHFP(t *testing.T) { - lt := []string{ - "test.example.org.\t300\tSSHFP\t1 2 (\n" + - "\t\t\t\t\tBC6533CDC95A79078A39A56EA7635984ED655318ADA9\n" + - "\t\t\t\t\tB6159E30723665DA95BB )", - "test.example.org.\t300\tSSHFP\t1 2 ( BC6533CDC 95A79078A39A56EA7635984ED655318AD A9B6159E3072366 5DA95BB )", - } - result := "test.example.org.\t300\tIN\tSSHFP\t1 2 BC6533CDC95A79078A39A56EA7635984ED655318ADA9B6159E30723665DA95BB" - for _, o := range lt { - rr, err := NewRR(o) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != result { - t.Errorf("`%s' should be equal to\n\n`%s', but is \n`%s'", o, result, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestParseHINFO(t *testing.T) { - dt := map[string]string{ - "example.net. HINFO A B": "example.net. 3600 IN HINFO \"A\" \"B\"", - "example.net. HINFO \"A\" \"B\"": "example.net. 3600 IN HINFO \"A\" \"B\"", - "example.net. HINFO A B C D E F": "example.net. 3600 IN HINFO \"A\" \"B C D E F\"", - "example.net. HINFO AB": "example.net. 3600 IN HINFO \"AB\" \"\"", - // "example.net. HINFO PC-Intel-700mhz \"Redhat Linux 7.1\"": "example.net. 3600 IN HINFO \"PC-Intel-700mhz\" \"Redhat Linux 7.1\"", - // This one is recommended in Pro Bind book http://www.zytrax.com/books/dns/ch8/hinfo.html - // but effectively, even Bind would replace it to correctly formed text when you AXFR - // TODO: remove this set of comments or figure support for quoted/unquoted combinations in endingToTxtSlice function - } - for i, o := range dt { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestParseCAA(t *testing.T) { - lt := map[string]string{ - "example.net. CAA 0 issue \"symantec.com\"": "example.net.\t3600\tIN\tCAA\t0 issue \"symantec.com\"", - "example.net. CAA 0 issuewild \"symantec.com; stuff\"": "example.net.\t3600\tIN\tCAA\t0 issuewild \"symantec.com; stuff\"", - "example.net. CAA 128 tbs \"critical\"": "example.net.\t3600\tIN\tCAA\t128 tbs \"critical\"", - "example.net. CAA 2 auth \"0>09\\006\\010+\\006\\001\\004\\001\\214y\\002\\003\\001\\006\\009`\\134H\\001e\\003\\004\\002\\001\\004 y\\209\\012\\221r\\220\\156Q\\218\\150\\150{\\166\\245:\\231\\182%\\157:\\133\\179}\\1923r\\238\\151\\255\\128q\\145\\002\\001\\000\"": "example.net.\t3600\tIN\tCAA\t2 auth \"0>09\\006\\010+\\006\\001\\004\\001\\214y\\002\\003\\001\\006\\009`\\134H\\001e\\003\\004\\002\\001\\004 y\\209\\012\\221r\\220\\156Q\\218\\150\\150{\\166\\245:\\231\\182%\\157:\\133\\179}\\1923r\\238\\151\\255\\128q\\145\\002\\001\\000\"", - "example.net. TYPE257 0 issue \"symantec.com\"": "example.net.\t3600\tIN\tCAA\t0 issue \"symantec.com\"", - } - for i, o := range lt { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} - -func TestPackCAA(t *testing.T) { - m := new(Msg) - record := new(CAA) - record.Hdr = RR_Header{Name: "example.com.", Rrtype: TypeCAA, Class: ClassINET, Ttl: 0} - record.Tag = "issue" - record.Value = "symantec.com" - record.Flag = 1 - - m.Answer = append(m.Answer, record) - bytes, err := m.Pack() - if err != nil { - t.Fatalf("failed to pack msg: %v", err) - } - if err := m.Unpack(bytes); err != nil { - t.Fatalf("failed to unpack msg: %v", err) - } - if len(m.Answer) != 1 { - t.Fatalf("incorrect number of answers unpacked") - } - rr := m.Answer[0].(*CAA) - if rr.Tag != "issue" { - t.Fatalf("invalid tag for unpacked answer") - } else if rr.Value != "symantec.com" { - t.Fatalf("invalid value for unpacked answer") - } else if rr.Flag != 1 { - t.Fatalf("invalid flag for unpacked answer") - } -} - -func TestParseURI(t *testing.T) { - lt := map[string]string{ - "_http._tcp. IN URI 10 1 \"http://www.example.com/path\"": "_http._tcp.\t3600\tIN\tURI\t10 1 \"http://www.example.com/path\"", - "_http._tcp. IN URI 10 1 \"\"": "_http._tcp.\t3600\tIN\tURI\t10 1 \"\"", - } - for i, o := range lt { - rr, err := NewRR(i) - if err != nil { - t.Error("failed to parse RR: ", err) - continue - } - if rr.String() != o { - t.Errorf("`%s' should be equal to\n`%s', but is `%s'", i, o, rr.String()) - } else { - t.Logf("RR is OK: `%s'", rr.String()) - } - } -} diff --git a/vendor/github.com/miekg/dns/privaterr.go b/vendor/github.com/miekg/dns/privaterr.go deleted file mode 100644 index 6b08e6e..0000000 --- a/vendor/github.com/miekg/dns/privaterr.go +++ /dev/null @@ -1,149 +0,0 @@ -package dns - -import ( - "fmt" - "strings" -) - -// PrivateRdata is an interface used for implementing "Private Use" RR types, see -// RFC 6895. This allows one to experiment with new RR types, without requesting an -// official type code. Also see dns.PrivateHandle and dns.PrivateHandleRemove. -type PrivateRdata interface { - // String returns the text presentaton of the Rdata of the Private RR. - String() string - // Parse parses the Rdata of the private RR. - Parse([]string) error - // Pack is used when packing a private RR into a buffer. - Pack([]byte) (int, error) - // Unpack is used when unpacking a private RR from a buffer. - // TODO(miek): diff. signature than Pack, see edns0.go for instance. - Unpack([]byte) (int, error) - // Copy copies the Rdata. - Copy(PrivateRdata) error - // Len returns the length in octets of the Rdata. - Len() int -} - -// PrivateRR represents an RR that uses a PrivateRdata user-defined type. -// It mocks normal RRs and implements dns.RR interface. -type PrivateRR struct { - Hdr RR_Header - Data PrivateRdata -} - -func mkPrivateRR(rrtype uint16) *PrivateRR { - // Panics if RR is not an instance of PrivateRR. - rrfunc, ok := TypeToRR[rrtype] - if !ok { - panic(fmt.Sprintf("dns: invalid operation with Private RR type %d", rrtype)) - } - - anyrr := rrfunc() - switch rr := anyrr.(type) { - case *PrivateRR: - return rr - } - panic(fmt.Sprintf("dns: RR is not a PrivateRR, TypeToRR[%d] generator returned %T", rrtype, anyrr)) -} - -// Header return the RR header of r. -func (r *PrivateRR) Header() *RR_Header { return &r.Hdr } - -func (r *PrivateRR) String() string { return r.Hdr.String() + r.Data.String() } - -// Private len and copy parts to satisfy RR interface. -func (r *PrivateRR) len() int { return r.Hdr.len() + r.Data.Len() } -func (r *PrivateRR) copy() RR { - // make new RR like this: - rr := mkPrivateRR(r.Hdr.Rrtype) - newh := r.Hdr.copyHeader() - rr.Hdr = *newh - - err := r.Data.Copy(rr.Data) - if err != nil { - panic("dns: got value that could not be used to copy Private rdata") - } - return rr -} -func (r *PrivateRR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := r.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - n, err := r.Data.Pack(msg[off:]) - if err != nil { - return len(msg), err - } - off += n - r.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -// PrivateHandle registers a private resource record type. It requires -// string and numeric representation of private RR type and generator function as argument. -func PrivateHandle(rtypestr string, rtype uint16, generator func() PrivateRdata) { - rtypestr = strings.ToUpper(rtypestr) - - TypeToRR[rtype] = func() RR { return &PrivateRR{RR_Header{}, generator()} } - TypeToString[rtype] = rtypestr - StringToType[rtypestr] = rtype - - typeToUnpack[rtype] = func(h RR_Header, msg []byte, off int) (RR, int, error) { - if noRdata(h) { - return &h, off, nil - } - var err error - - rr := mkPrivateRR(h.Rrtype) - rr.Hdr = h - - off1, err := rr.Data.Unpack(msg[off:]) - off += off1 - if err != nil { - return rr, off, err - } - return rr, off, err - } - - setPrivateRR := func(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := mkPrivateRR(h.Rrtype) - rr.Hdr = h - - var l lex - text := make([]string, 0, 2) // could be 0..N elements, median is probably 1 - Fetch: - for { - // TODO(miek): we could also be returning _QUOTE, this might or might not - // be an issue (basically parsing TXT becomes hard) - switch l = <-c; l.value { - case zNewline, zEOF: - break Fetch - case zString: - text = append(text, l.token) - } - } - - err := rr.Data.Parse(text) - if err != nil { - return nil, &ParseError{f, err.Error(), l}, "" - } - - return rr, nil, "" - } - - typeToparserFunc[rtype] = parserFunc{setPrivateRR, true} -} - -// PrivateHandleRemove removes defenitions required to support private RR type. -func PrivateHandleRemove(rtype uint16) { - rtypestr, ok := TypeToString[rtype] - if ok { - delete(TypeToRR, rtype) - delete(TypeToString, rtype) - delete(typeToparserFunc, rtype) - delete(StringToType, rtypestr) - delete(typeToUnpack, rtype) - } - return -} diff --git a/vendor/github.com/miekg/dns/privaterr_test.go b/vendor/github.com/miekg/dns/privaterr_test.go deleted file mode 100644 index 5f177aa..0000000 --- a/vendor/github.com/miekg/dns/privaterr_test.go +++ /dev/null @@ -1,171 +0,0 @@ -package dns_test - -import ( - "strings" - "testing" - - "github.com/miekg/dns" -) - -const TypeISBN uint16 = 0x0F01 - -// A crazy new RR type :) -type ISBN struct { - x string // rdata with 10 or 13 numbers, dashes or spaces allowed -} - -func NewISBN() dns.PrivateRdata { return &ISBN{""} } - -func (rd *ISBN) Len() int { return len([]byte(rd.x)) } -func (rd *ISBN) String() string { return rd.x } - -func (rd *ISBN) Parse(txt []string) error { - rd.x = strings.TrimSpace(strings.Join(txt, " ")) - return nil -} - -func (rd *ISBN) Pack(buf []byte) (int, error) { - b := []byte(rd.x) - n := copy(buf, b) - if n != len(b) { - return n, dns.ErrBuf - } - return n, nil -} - -func (rd *ISBN) Unpack(buf []byte) (int, error) { - rd.x = string(buf) - return len(buf), nil -} - -func (rd *ISBN) Copy(dest dns.PrivateRdata) error { - isbn, ok := dest.(*ISBN) - if !ok { - return dns.ErrRdata - } - isbn.x = rd.x - return nil -} - -var testrecord = strings.Join([]string{"example.org.", "3600", "IN", "ISBN", "12-3 456789-0-123"}, "\t") - -func TestPrivateText(t *testing.T) { - dns.PrivateHandle("ISBN", TypeISBN, NewISBN) - defer dns.PrivateHandleRemove(TypeISBN) - - rr, err := dns.NewRR(testrecord) - if err != nil { - t.Fatal(err) - } - if rr.String() != testrecord { - t.Errorf("record string representation did not match original %#v != %#v", rr.String(), testrecord) - } else { - t.Log(rr.String()) - } -} - -func TestPrivateByteSlice(t *testing.T) { - dns.PrivateHandle("ISBN", TypeISBN, NewISBN) - defer dns.PrivateHandleRemove(TypeISBN) - - rr, err := dns.NewRR(testrecord) - if err != nil { - t.Fatal(err) - } - - buf := make([]byte, 100) - off, err := dns.PackRR(rr, buf, 0, nil, false) - if err != nil { - t.Errorf("got error packing ISBN: %v", err) - } - - custrr := rr.(*dns.PrivateRR) - if ln := custrr.Data.Len() + len(custrr.Header().Name) + 11; ln != off { - t.Errorf("offset is not matching to length of Private RR: %d!=%d", off, ln) - } - - rr1, off1, err := dns.UnpackRR(buf[:off], 0) - if err != nil { - t.Errorf("got error unpacking ISBN: %v", err) - return - } - - if off1 != off { - t.Errorf("offset after unpacking differs: %d != %d", off1, off) - } - - if rr1.String() != testrecord { - t.Errorf("record string representation did not match original %#v != %#v", rr1.String(), testrecord) - } else { - t.Log(rr1.String()) - } -} - -const TypeVERSION uint16 = 0x0F02 - -type VERSION struct { - x string -} - -func NewVersion() dns.PrivateRdata { return &VERSION{""} } - -func (rd *VERSION) String() string { return rd.x } -func (rd *VERSION) Parse(txt []string) error { - rd.x = strings.TrimSpace(strings.Join(txt, " ")) - return nil -} - -func (rd *VERSION) Pack(buf []byte) (int, error) { - b := []byte(rd.x) - n := copy(buf, b) - if n != len(b) { - return n, dns.ErrBuf - } - return n, nil -} - -func (rd *VERSION) Unpack(buf []byte) (int, error) { - rd.x = string(buf) - return len(buf), nil -} - -func (rd *VERSION) Copy(dest dns.PrivateRdata) error { - isbn, ok := dest.(*VERSION) - if !ok { - return dns.ErrRdata - } - isbn.x = rd.x - return nil -} - -func (rd *VERSION) Len() int { - return len([]byte(rd.x)) -} - -var smallzone = `$ORIGIN example.org. -@ SOA sns.dns.icann.org. noc.dns.icann.org. ( - 2014091518 7200 3600 1209600 3600 -) - A 1.2.3.4 -ok ISBN 1231-92110-12 -go VERSION ( - 1.3.1 ; comment -) -www ISBN 1231-92110-16 -* CNAME @ -` - -func TestPrivateZoneParser(t *testing.T) { - dns.PrivateHandle("ISBN", TypeISBN, NewISBN) - dns.PrivateHandle("VERSION", TypeVERSION, NewVersion) - defer dns.PrivateHandleRemove(TypeISBN) - defer dns.PrivateHandleRemove(TypeVERSION) - - r := strings.NewReader(smallzone) - for x := range dns.ParseZone(r, ".", "") { - if err := x.Error; err != nil { - t.Fatal(err) - } - t.Log(x.RR) - } -} diff --git a/vendor/github.com/miekg/dns/rawmsg.go b/vendor/github.com/miekg/dns/rawmsg.go deleted file mode 100644 index 6e21fba..0000000 --- a/vendor/github.com/miekg/dns/rawmsg.go +++ /dev/null @@ -1,49 +0,0 @@ -package dns - -import "encoding/binary" - -// rawSetRdlength sets the rdlength in the header of -// the RR. The offset 'off' must be positioned at the -// start of the header of the RR, 'end' must be the -// end of the RR. -func rawSetRdlength(msg []byte, off, end int) bool { - l := len(msg) -Loop: - for { - if off+1 > l { - return false - } - c := int(msg[off]) - off++ - switch c & 0xC0 { - case 0x00: - if c == 0x00 { - // End of the domainname - break Loop - } - if off+c > l { - return false - } - off += c - - case 0xC0: - // pointer, next byte included, ends domainname - off++ - break Loop - } - } - // The domainname has been seen, we at the start of the fixed part in the header. - // Type is 2 bytes, class is 2 bytes, ttl 4 and then 2 bytes for the length. - off += 2 + 2 + 4 - if off+2 > l { - return false - } - //off+1 is the end of the header, 'end' is the end of the rr - //so 'end' - 'off+2' is the length of the rdata - rdatalen := end - (off + 2) - if rdatalen > 0xFFFF { - return false - } - binary.BigEndian.PutUint16(msg[off:], uint16(rdatalen)) - return true -} diff --git a/vendor/github.com/miekg/dns/remote_test.go b/vendor/github.com/miekg/dns/remote_test.go deleted file mode 100644 index 4cf701f..0000000 --- a/vendor/github.com/miekg/dns/remote_test.go +++ /dev/null @@ -1,19 +0,0 @@ -package dns - -import "testing" - -const LinodeAddr = "176.58.119.54:53" - -func TestClientRemote(t *testing.T) { - m := new(Msg) - m.SetQuestion("go.dns.miek.nl.", TypeTXT) - - c := new(Client) - r, _, err := c.Exchange(m, LinodeAddr) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - if r != nil && r.Rcode != RcodeSuccess { - t.Errorf("failed to get an valid answer\n%v", r) - } -} diff --git a/vendor/github.com/miekg/dns/reverse.go b/vendor/github.com/miekg/dns/reverse.go deleted file mode 100644 index 099dac9..0000000 --- a/vendor/github.com/miekg/dns/reverse.go +++ /dev/null @@ -1,38 +0,0 @@ -package dns - -// StringToType is the reverse of TypeToString, needed for string parsing. -var StringToType = reverseInt16(TypeToString) - -// StringToClass is the reverse of ClassToString, needed for string parsing. -var StringToClass = reverseInt16(ClassToString) - -// Map of opcodes strings. -var StringToOpcode = reverseInt(OpcodeToString) - -// Map of rcodes strings. -var StringToRcode = reverseInt(RcodeToString) - -// Reverse a map -func reverseInt8(m map[uint8]string) map[string]uint8 { - n := make(map[string]uint8, len(m)) - for u, s := range m { - n[s] = u - } - return n -} - -func reverseInt16(m map[uint16]string) map[string]uint16 { - n := make(map[string]uint16, len(m)) - for u, s := range m { - n[s] = u - } - return n -} - -func reverseInt(m map[int]string) map[string]int { - n := make(map[string]int, len(m)) - for u, s := range m { - n[s] = u - } - return n -} diff --git a/vendor/github.com/miekg/dns/sanitize.go b/vendor/github.com/miekg/dns/sanitize.go deleted file mode 100644 index b489f3f..0000000 --- a/vendor/github.com/miekg/dns/sanitize.go +++ /dev/null @@ -1,84 +0,0 @@ -package dns - -// Dedup removes identical RRs from rrs. It preserves the original ordering. -// The lowest TTL of any duplicates is used in the remaining one. Dedup modifies -// rrs. -// m is used to store the RRs temporay. If it is nil a new map will be allocated. -func Dedup(rrs []RR, m map[string]RR) []RR { - if m == nil { - m = make(map[string]RR) - } - // Save the keys, so we don't have to call normalizedString twice. - keys := make([]*string, 0, len(rrs)) - - for _, r := range rrs { - key := normalizedString(r) - keys = append(keys, &key) - if _, ok := m[key]; ok { - // Shortest TTL wins. - if m[key].Header().Ttl > r.Header().Ttl { - m[key].Header().Ttl = r.Header().Ttl - } - continue - } - - m[key] = r - } - // If the length of the result map equals the amount of RRs we got, - // it means they were all different. We can then just return the original rrset. - if len(m) == len(rrs) { - return rrs - } - - j := 0 - for i, r := range rrs { - // If keys[i] lives in the map, we should copy and remove it. - if _, ok := m[*keys[i]]; ok { - delete(m, *keys[i]) - rrs[j] = r - j++ - } - - if len(m) == 0 { - break - } - } - - return rrs[:j] -} - -// normalizedString returns a normalized string from r. The TTL -// is removed and the domain name is lowercased. We go from this: -// DomainNameTTLCLASSTYPERDATA to: -// lowercasenameCLASSTYPE... -func normalizedString(r RR) string { - // A string Go DNS makes has: domainnameTTL... - b := []byte(r.String()) - - // find the first non-escaped tab, then another, so we capture where the TTL lives. - esc := false - ttlStart, ttlEnd := 0, 0 - for i := 0; i < len(b) && ttlEnd == 0; i++ { - switch { - case b[i] == '\\': - esc = !esc - case b[i] == '\t' && !esc: - if ttlStart == 0 { - ttlStart = i - continue - } - if ttlEnd == 0 { - ttlEnd = i - } - case b[i] >= 'A' && b[i] <= 'Z' && !esc: - b[i] += 32 - default: - esc = false - } - } - - // remove TTL. - copy(b[ttlStart:], b[ttlEnd:]) - cut := ttlEnd - ttlStart - return string(b[:len(b)-cut]) -} diff --git a/vendor/github.com/miekg/dns/sanitize_test.go b/vendor/github.com/miekg/dns/sanitize_test.go deleted file mode 100644 index c108dc6..0000000 --- a/vendor/github.com/miekg/dns/sanitize_test.go +++ /dev/null @@ -1,84 +0,0 @@ -package dns - -import "testing" - -func TestDedup(t *testing.T) { - // make it []string - testcases := map[[3]RR][]string{ - [...]RR{ - newRR(t, "mIek.nl. IN A 127.0.0.1"), - newRR(t, "mieK.nl. IN A 127.0.0.1"), - newRR(t, "miek.Nl. IN A 127.0.0.1"), - }: {"mIek.nl.\t3600\tIN\tA\t127.0.0.1"}, - [...]RR{ - newRR(t, "miEk.nl. 2000 IN A 127.0.0.1"), - newRR(t, "mieK.Nl. 1000 IN A 127.0.0.1"), - newRR(t, "Miek.nL. 500 IN A 127.0.0.1"), - }: {"miEk.nl.\t500\tIN\tA\t127.0.0.1"}, - [...]RR{ - newRR(t, "miek.nl. IN A 127.0.0.1"), - newRR(t, "miek.nl. CH A 127.0.0.1"), - newRR(t, "miek.nl. IN A 127.0.0.1"), - }: {"miek.nl.\t3600\tIN\tA\t127.0.0.1", - "miek.nl.\t3600\tCH\tA\t127.0.0.1", - }, - [...]RR{ - newRR(t, "miek.nl. CH A 127.0.0.1"), - newRR(t, "miek.nl. IN A 127.0.0.1"), - newRR(t, "miek.de. IN A 127.0.0.1"), - }: {"miek.nl.\t3600\tCH\tA\t127.0.0.1", - "miek.nl.\t3600\tIN\tA\t127.0.0.1", - "miek.de.\t3600\tIN\tA\t127.0.0.1", - }, - [...]RR{ - newRR(t, "miek.de. IN A 127.0.0.1"), - newRR(t, "miek.nl. 200 IN A 127.0.0.1"), - newRR(t, "miek.nl. 300 IN A 127.0.0.1"), - }: {"miek.de.\t3600\tIN\tA\t127.0.0.1", - "miek.nl.\t200\tIN\tA\t127.0.0.1", - }, - } - - for rr, expected := range testcases { - out := Dedup([]RR{rr[0], rr[1], rr[2]}, nil) - for i, o := range out { - if o.String() != expected[i] { - t.Fatalf("expected %v, got %v", expected[i], o.String()) - } - } - } -} - -func BenchmarkDedup(b *testing.B) { - rrs := []RR{ - newRR(nil, "miEk.nl. 2000 IN A 127.0.0.1"), - newRR(nil, "mieK.Nl. 1000 IN A 127.0.0.1"), - newRR(nil, "Miek.nL. 500 IN A 127.0.0.1"), - } - m := make(map[string]RR) - for i := 0; i < b.N; i++ { - Dedup(rrs, m) - } -} - -func TestNormalizedString(t *testing.T) { - tests := map[RR]string{ - newRR(t, "mIEk.Nl. 3600 IN A 127.0.0.1"): "miek.nl.\tIN\tA\t127.0.0.1", - newRR(t, "m\\ iek.nL. 3600 IN A 127.0.0.1"): "m\\ iek.nl.\tIN\tA\t127.0.0.1", - newRR(t, "m\\\tIeK.nl. 3600 in A 127.0.0.1"): "m\\tiek.nl.\tIN\tA\t127.0.0.1", - } - for tc, expected := range tests { - n := normalizedString(tc) - if n != expected { - t.Errorf("expected %s, got %s", expected, n) - } - } -} - -func newRR(t *testing.T, s string) RR { - r, err := NewRR(s) - if err != nil { - t.Logf("newRR: %v", err) - } - return r -} diff --git a/vendor/github.com/miekg/dns/scan.go b/vendor/github.com/miekg/dns/scan.go deleted file mode 100644 index 0e83797..0000000 --- a/vendor/github.com/miekg/dns/scan.go +++ /dev/null @@ -1,974 +0,0 @@ -package dns - -import ( - "io" - "log" - "os" - "strconv" - "strings" -) - -type debugging bool - -const debug debugging = false - -func (d debugging) Printf(format string, args ...interface{}) { - if d { - log.Printf(format, args...) - } -} - -const maxTok = 2048 // Largest token we can return. -const maxUint16 = 1<<16 - 1 - -// Tokinize a RFC 1035 zone file. The tokenizer will normalize it: -// * Add ownernames if they are left blank; -// * Suppress sequences of spaces; -// * Make each RR fit on one line (_NEWLINE is send as last) -// * Handle comments: ; -// * Handle braces - anywhere. -const ( - // Zonefile - zEOF = iota - zString - zBlank - zQuote - zNewline - zRrtpe - zOwner - zClass - zDirOrigin // $ORIGIN - zDirTtl // $TTL - zDirInclude // $INCLUDE - zDirGenerate // $GENERATE - - // Privatekey file - zValue - zKey - - zExpectOwnerDir // Ownername - zExpectOwnerBl // Whitespace after the ownername - zExpectAny // Expect rrtype, ttl or class - zExpectAnyNoClass // Expect rrtype or ttl - zExpectAnyNoClassBl // The whitespace after _EXPECT_ANY_NOCLASS - zExpectAnyNoTtl // Expect rrtype or class - zExpectAnyNoTtlBl // Whitespace after _EXPECT_ANY_NOTTL - zExpectRrtype // Expect rrtype - zExpectRrtypeBl // Whitespace BEFORE rrtype - zExpectRdata // The first element of the rdata - zExpectDirTtlBl // Space after directive $TTL - zExpectDirTtl // Directive $TTL - zExpectDirOriginBl // Space after directive $ORIGIN - zExpectDirOrigin // Directive $ORIGIN - zExpectDirIncludeBl // Space after directive $INCLUDE - zExpectDirInclude // Directive $INCLUDE - zExpectDirGenerate // Directive $GENERATE - zExpectDirGenerateBl // Space after directive $GENERATE -) - -// ParseError is a parsing error. It contains the parse error and the location in the io.Reader -// where the error occurred. -type ParseError struct { - file string - err string - lex lex -} - -func (e *ParseError) Error() (s string) { - if e.file != "" { - s = e.file + ": " - } - s += "dns: " + e.err + ": " + strconv.QuoteToASCII(e.lex.token) + " at line: " + - strconv.Itoa(e.lex.line) + ":" + strconv.Itoa(e.lex.column) - return -} - -type lex struct { - token string // text of the token - tokenUpper string // uppercase text of the token - length int // length of the token - err bool // when true, token text has lexer error - value uint8 // value: zString, _BLANK, etc. - line int // line in the file - column int // column in the file - torc uint16 // type or class as parsed in the lexer, we only need to look this up in the grammar - comment string // any comment text seen -} - -// Token holds the token that are returned when a zone file is parsed. -type Token struct { - // The scanned resource record when error is not nil. - RR - // When an error occurred, this has the error specifics. - Error *ParseError - // A potential comment positioned after the RR and on the same line. - Comment string -} - -// NewRR reads the RR contained in the string s. Only the first RR is -// returned. If s contains no RR, return nil with no error. The class -// defaults to IN and TTL defaults to 3600. The full zone file syntax -// like $TTL, $ORIGIN, etc. is supported. All fields of the returned -// RR are set, except RR.Header().Rdlength which is set to 0. -func NewRR(s string) (RR, error) { - if len(s) > 0 && s[len(s)-1] != '\n' { // We need a closing newline - return ReadRR(strings.NewReader(s+"\n"), "") - } - return ReadRR(strings.NewReader(s), "") -} - -// ReadRR reads the RR contained in q. -// See NewRR for more documentation. -func ReadRR(q io.Reader, filename string) (RR, error) { - r := <-parseZoneHelper(q, ".", filename, 1) - if r == nil { - return nil, nil - } - - if r.Error != nil { - return nil, r.Error - } - return r.RR, nil -} - -// ParseZone reads a RFC 1035 style zonefile from r. It returns *Tokens on the -// returned channel, which consist out the parsed RR, a potential comment or an error. -// If there is an error the RR is nil. The string file is only used -// in error reporting. The string origin is used as the initial origin, as -// if the file would start with: $ORIGIN origin . -// The directives $INCLUDE, $ORIGIN, $TTL and $GENERATE are supported. -// The channel t is closed by ParseZone when the end of r is reached. -// -// Basic usage pattern when reading from a string (z) containing the -// zone data: -// -// for x := range dns.ParseZone(strings.NewReader(z), "", "") { -// if x.Error != nil { -// // log.Println(x.Error) -// } else { -// // Do something with x.RR -// } -// } -// -// Comments specified after an RR (and on the same line!) are returned too: -// -// foo. IN A 10.0.0.1 ; this is a comment -// -// The text "; this is comment" is returned in Token.Comment. Comments inside the -// RR are discarded. Comments on a line by themselves are discarded too. -func ParseZone(r io.Reader, origin, file string) chan *Token { - return parseZoneHelper(r, origin, file, 10000) -} - -func parseZoneHelper(r io.Reader, origin, file string, chansize int) chan *Token { - t := make(chan *Token, chansize) - go parseZone(r, origin, file, t, 0) - return t -} - -func parseZone(r io.Reader, origin, f string, t chan *Token, include int) { - defer func() { - if include == 0 { - close(t) - } - }() - s := scanInit(r) - c := make(chan lex) - // Start the lexer - go zlexer(s, c) - // 6 possible beginnings of a line, _ is a space - // 0. zRRTYPE -> all omitted until the rrtype - // 1. zOwner _ zRrtype -> class/ttl omitted - // 2. zOwner _ zString _ zRrtype -> class omitted - // 3. zOwner _ zString _ zClass _ zRrtype -> ttl/class - // 4. zOwner _ zClass _ zRrtype -> ttl omitted - // 5. zOwner _ zClass _ zString _ zRrtype -> class/ttl (reversed) - // After detecting these, we know the zRrtype so we can jump to functions - // handling the rdata for each of these types. - - if origin == "" { - origin = "." - } - origin = Fqdn(origin) - if _, ok := IsDomainName(origin); !ok { - t <- &Token{Error: &ParseError{f, "bad initial origin name", lex{}}} - return - } - - st := zExpectOwnerDir // initial state - var h RR_Header - var defttl uint32 = defaultTtl - var prevName string - for l := range c { - // Lexer spotted an error already - if l.err == true { - t <- &Token{Error: &ParseError{f, l.token, l}} - return - - } - switch st { - case zExpectOwnerDir: - // We can also expect a directive, like $TTL or $ORIGIN - h.Ttl = defttl - h.Class = ClassINET - switch l.value { - case zNewline: - st = zExpectOwnerDir - case zOwner: - h.Name = l.token - if l.token[0] == '@' { - h.Name = origin - prevName = h.Name - st = zExpectOwnerBl - break - } - if h.Name[l.length-1] != '.' { - h.Name = appendOrigin(h.Name, origin) - } - _, ok := IsDomainName(l.token) - if !ok { - t <- &Token{Error: &ParseError{f, "bad owner name", l}} - return - } - prevName = h.Name - st = zExpectOwnerBl - case zDirTtl: - st = zExpectDirTtlBl - case zDirOrigin: - st = zExpectDirOriginBl - case zDirInclude: - st = zExpectDirIncludeBl - case zDirGenerate: - st = zExpectDirGenerateBl - case zRrtpe: - h.Name = prevName - h.Rrtype = l.torc - st = zExpectRdata - case zClass: - h.Name = prevName - h.Class = l.torc - st = zExpectAnyNoClassBl - case zBlank: - // Discard, can happen when there is nothing on the - // line except the RR type - case zString: - ttl, ok := stringToTtl(l.token) - if !ok { - t <- &Token{Error: &ParseError{f, "not a TTL", l}} - return - } - h.Ttl = ttl - // Don't about the defttl, we should take the $TTL value - // defttl = ttl - st = zExpectAnyNoTtlBl - - default: - t <- &Token{Error: &ParseError{f, "syntax error at beginning", l}} - return - } - case zExpectDirIncludeBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank after $INCLUDE-directive", l}} - return - } - st = zExpectDirInclude - case zExpectDirInclude: - if l.value != zString { - t <- &Token{Error: &ParseError{f, "expecting $INCLUDE value, not this...", l}} - return - } - neworigin := origin // There may be optionally a new origin set after the filename, if not use current one - l := <-c - switch l.value { - case zBlank: - l := <-c - if l.value == zString { - if _, ok := IsDomainName(l.token); !ok || l.length == 0 || l.err { - t <- &Token{Error: &ParseError{f, "bad origin name", l}} - return - } - // a new origin is specified. - if l.token[l.length-1] != '.' { - if origin != "." { // Prevent .. endings - neworigin = l.token + "." + origin - } else { - neworigin = l.token + origin - } - } else { - neworigin = l.token - } - } - case zNewline, zEOF: - // Ok - default: - t <- &Token{Error: &ParseError{f, "garbage after $INCLUDE", l}} - return - } - // Start with the new file - r1, e1 := os.Open(l.token) - if e1 != nil { - t <- &Token{Error: &ParseError{f, "failed to open `" + l.token + "'", l}} - return - } - if include+1 > 7 { - t <- &Token{Error: &ParseError{f, "too deeply nested $INCLUDE", l}} - return - } - parseZone(r1, l.token, neworigin, t, include+1) - st = zExpectOwnerDir - case zExpectDirTtlBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank after $TTL-directive", l}} - return - } - st = zExpectDirTtl - case zExpectDirTtl: - if l.value != zString { - t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}} - return - } - if e, _ := slurpRemainder(c, f); e != nil { - t <- &Token{Error: e} - return - } - ttl, ok := stringToTtl(l.token) - if !ok { - t <- &Token{Error: &ParseError{f, "expecting $TTL value, not this...", l}} - return - } - defttl = ttl - st = zExpectOwnerDir - case zExpectDirOriginBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank after $ORIGIN-directive", l}} - return - } - st = zExpectDirOrigin - case zExpectDirOrigin: - if l.value != zString { - t <- &Token{Error: &ParseError{f, "expecting $ORIGIN value, not this...", l}} - return - } - if e, _ := slurpRemainder(c, f); e != nil { - t <- &Token{Error: e} - } - if _, ok := IsDomainName(l.token); !ok { - t <- &Token{Error: &ParseError{f, "bad origin name", l}} - return - } - if l.token[l.length-1] != '.' { - if origin != "." { // Prevent .. endings - origin = l.token + "." + origin - } else { - origin = l.token + origin - } - } else { - origin = l.token - } - st = zExpectOwnerDir - case zExpectDirGenerateBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank after $GENERATE-directive", l}} - return - } - st = zExpectDirGenerate - case zExpectDirGenerate: - if l.value != zString { - t <- &Token{Error: &ParseError{f, "expecting $GENERATE value, not this...", l}} - return - } - if errMsg := generate(l, c, t, origin); errMsg != "" { - t <- &Token{Error: &ParseError{f, errMsg, l}} - return - } - st = zExpectOwnerDir - case zExpectOwnerBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank after owner", l}} - return - } - st = zExpectAny - case zExpectAny: - switch l.value { - case zRrtpe: - h.Rrtype = l.torc - st = zExpectRdata - case zClass: - h.Class = l.torc - st = zExpectAnyNoClassBl - case zString: - ttl, ok := stringToTtl(l.token) - if !ok { - t <- &Token{Error: &ParseError{f, "not a TTL", l}} - return - } - h.Ttl = ttl - // defttl = ttl // don't set the defttl here - st = zExpectAnyNoTtlBl - default: - t <- &Token{Error: &ParseError{f, "expecting RR type, TTL or class, not this...", l}} - return - } - case zExpectAnyNoClassBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank before class", l}} - return - } - st = zExpectAnyNoClass - case zExpectAnyNoTtlBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank before TTL", l}} - return - } - st = zExpectAnyNoTtl - case zExpectAnyNoTtl: - switch l.value { - case zClass: - h.Class = l.torc - st = zExpectRrtypeBl - case zRrtpe: - h.Rrtype = l.torc - st = zExpectRdata - default: - t <- &Token{Error: &ParseError{f, "expecting RR type or class, not this...", l}} - return - } - case zExpectAnyNoClass: - switch l.value { - case zString: - ttl, ok := stringToTtl(l.token) - if !ok { - t <- &Token{Error: &ParseError{f, "not a TTL", l}} - return - } - h.Ttl = ttl - // defttl = ttl // don't set the def ttl anymore - st = zExpectRrtypeBl - case zRrtpe: - h.Rrtype = l.torc - st = zExpectRdata - default: - t <- &Token{Error: &ParseError{f, "expecting RR type or TTL, not this...", l}} - return - } - case zExpectRrtypeBl: - if l.value != zBlank { - t <- &Token{Error: &ParseError{f, "no blank before RR type", l}} - return - } - st = zExpectRrtype - case zExpectRrtype: - if l.value != zRrtpe { - t <- &Token{Error: &ParseError{f, "unknown RR type", l}} - return - } - h.Rrtype = l.torc - st = zExpectRdata - case zExpectRdata: - r, e, c1 := setRR(h, c, origin, f) - if e != nil { - // If e.lex is nil than we have encounter a unknown RR type - // in that case we substitute our current lex token - if e.lex.token == "" && e.lex.value == 0 { - e.lex = l // Uh, dirty - } - t <- &Token{Error: e} - return - } - t <- &Token{RR: r, Comment: c1} - st = zExpectOwnerDir - } - } - // If we get here, we and the h.Rrtype is still zero, we haven't parsed anything, this - // is not an error, because an empty zone file is still a zone file. -} - -// zlexer scans the sourcefile and returns tokens on the channel c. -func zlexer(s *scan, c chan lex) { - var l lex - str := make([]byte, maxTok) // Should be enough for any token - stri := 0 // Offset in str (0 means empty) - com := make([]byte, maxTok) // Hold comment text - comi := 0 - quote := false - escape := false - space := false - commt := false - rrtype := false - owner := true - brace := 0 - x, err := s.tokenText() - defer close(c) - for err == nil { - l.column = s.position.Column - l.line = s.position.Line - if stri >= maxTok { - l.token = "token length insufficient for parsing" - l.err = true - debug.Printf("[%+v]", l.token) - c <- l - return - } - if comi >= maxTok { - l.token = "comment length insufficient for parsing" - l.err = true - debug.Printf("[%+v]", l.token) - c <- l - return - } - - switch x { - case ' ', '\t': - if escape { - escape = false - str[stri] = x - stri++ - break - } - if quote { - // Inside quotes this is legal - str[stri] = x - stri++ - break - } - if commt { - com[comi] = x - comi++ - break - } - if stri == 0 { - // Space directly in the beginning, handled in the grammar - } else if owner { - // If we have a string and its the first, make it an owner - l.value = zOwner - l.token = string(str[:stri]) - l.tokenUpper = strings.ToUpper(l.token) - l.length = stri - // escape $... start with a \ not a $, so this will work - switch l.tokenUpper { - case "$TTL": - l.value = zDirTtl - case "$ORIGIN": - l.value = zDirOrigin - case "$INCLUDE": - l.value = zDirInclude - case "$GENERATE": - l.value = zDirGenerate - } - debug.Printf("[7 %+v]", l.token) - c <- l - } else { - l.value = zString - l.token = string(str[:stri]) - l.tokenUpper = strings.ToUpper(l.token) - l.length = stri - if !rrtype { - if t, ok := StringToType[l.tokenUpper]; ok { - l.value = zRrtpe - l.torc = t - rrtype = true - } else { - if strings.HasPrefix(l.tokenUpper, "TYPE") { - t, ok := typeToInt(l.token) - if !ok { - l.token = "unknown RR type" - l.err = true - c <- l - return - } - l.value = zRrtpe - l.torc = t - } - } - if t, ok := StringToClass[l.tokenUpper]; ok { - l.value = zClass - l.torc = t - } else { - if strings.HasPrefix(l.tokenUpper, "CLASS") { - t, ok := classToInt(l.token) - if !ok { - l.token = "unknown class" - l.err = true - c <- l - return - } - l.value = zClass - l.torc = t - } - } - } - debug.Printf("[6 %+v]", l.token) - c <- l - } - stri = 0 - // I reverse space stuff here - if !space && !commt { - l.value = zBlank - l.token = " " - l.length = 1 - debug.Printf("[5 %+v]", l.token) - c <- l - } - owner = false - space = true - case ';': - if escape { - escape = false - str[stri] = x - stri++ - break - } - if quote { - // Inside quotes this is legal - str[stri] = x - stri++ - break - } - if stri > 0 { - l.value = zString - l.token = string(str[:stri]) - l.length = stri - debug.Printf("[4 %+v]", l.token) - c <- l - stri = 0 - } - commt = true - com[comi] = ';' - comi++ - case '\r': - escape = false - if quote { - str[stri] = x - stri++ - break - } - // discard if outside of quotes - case '\n': - escape = false - // Escaped newline - if quote { - str[stri] = x - stri++ - break - } - // inside quotes this is legal - if commt { - // Reset a comment - commt = false - rrtype = false - stri = 0 - // If not in a brace this ends the comment AND the RR - if brace == 0 { - owner = true - owner = true - l.value = zNewline - l.token = "\n" - l.length = 1 - l.comment = string(com[:comi]) - debug.Printf("[3 %+v %+v]", l.token, l.comment) - c <- l - l.comment = "" - comi = 0 - break - } - com[comi] = ' ' // convert newline to space - comi++ - break - } - - if brace == 0 { - // If there is previous text, we should output it here - if stri != 0 { - l.value = zString - l.token = string(str[:stri]) - l.tokenUpper = strings.ToUpper(l.token) - - l.length = stri - if !rrtype { - if t, ok := StringToType[l.tokenUpper]; ok { - l.value = zRrtpe - l.torc = t - rrtype = true - } - } - debug.Printf("[2 %+v]", l.token) - c <- l - } - l.value = zNewline - l.token = "\n" - l.length = 1 - debug.Printf("[1 %+v]", l.token) - c <- l - stri = 0 - commt = false - rrtype = false - owner = true - comi = 0 - } - case '\\': - // comments do not get escaped chars, everything is copied - if commt { - com[comi] = x - comi++ - break - } - // something already escaped must be in string - if escape { - str[stri] = x - stri++ - escape = false - break - } - // something escaped outside of string gets added to string - str[stri] = x - stri++ - escape = true - case '"': - if commt { - com[comi] = x - comi++ - break - } - if escape { - str[stri] = x - stri++ - escape = false - break - } - space = false - // send previous gathered text and the quote - if stri != 0 { - l.value = zString - l.token = string(str[:stri]) - l.length = stri - - debug.Printf("[%+v]", l.token) - c <- l - stri = 0 - } - - // send quote itself as separate token - l.value = zQuote - l.token = "\"" - l.length = 1 - c <- l - quote = !quote - case '(', ')': - if commt { - com[comi] = x - comi++ - break - } - if escape { - str[stri] = x - stri++ - escape = false - break - } - if quote { - str[stri] = x - stri++ - break - } - switch x { - case ')': - brace-- - if brace < 0 { - l.token = "extra closing brace" - l.err = true - debug.Printf("[%+v]", l.token) - c <- l - return - } - case '(': - brace++ - } - default: - escape = false - if commt { - com[comi] = x - comi++ - break - } - str[stri] = x - stri++ - space = false - } - x, err = s.tokenText() - } - if stri > 0 { - // Send remainder - l.token = string(str[:stri]) - l.length = stri - l.value = zString - debug.Printf("[%+v]", l.token) - c <- l - } -} - -// Extract the class number from CLASSxx -func classToInt(token string) (uint16, bool) { - offset := 5 - if len(token) < offset+1 { - return 0, false - } - class, ok := strconv.Atoi(token[offset:]) - if ok != nil || class > maxUint16 { - return 0, false - } - return uint16(class), true -} - -// Extract the rr number from TYPExxx -func typeToInt(token string) (uint16, bool) { - offset := 4 - if len(token) < offset+1 { - return 0, false - } - typ, ok := strconv.Atoi(token[offset:]) - if ok != nil || typ > maxUint16 { - return 0, false - } - return uint16(typ), true -} - -// Parse things like 2w, 2m, etc, Return the time in seconds. -func stringToTtl(token string) (uint32, bool) { - s := uint32(0) - i := uint32(0) - for _, c := range token { - switch c { - case 's', 'S': - s += i - i = 0 - case 'm', 'M': - s += i * 60 - i = 0 - case 'h', 'H': - s += i * 60 * 60 - i = 0 - case 'd', 'D': - s += i * 60 * 60 * 24 - i = 0 - case 'w', 'W': - s += i * 60 * 60 * 24 * 7 - i = 0 - case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - i *= 10 - i += uint32(c) - '0' - default: - return 0, false - } - } - return s + i, true -} - -// Parse LOC records' [.][mM] into a -// mantissa exponent format. Token should contain the entire -// string (i.e. no spaces allowed) -func stringToCm(token string) (e, m uint8, ok bool) { - if token[len(token)-1] == 'M' || token[len(token)-1] == 'm' { - token = token[0 : len(token)-1] - } - s := strings.SplitN(token, ".", 2) - var meters, cmeters, val int - var err error - switch len(s) { - case 2: - if cmeters, err = strconv.Atoi(s[1]); err != nil { - return - } - fallthrough - case 1: - if meters, err = strconv.Atoi(s[0]); err != nil { - return - } - case 0: - // huh? - return 0, 0, false - } - ok = true - if meters > 0 { - e = 2 - val = meters - } else { - e = 0 - val = cmeters - } - for val > 10 { - e++ - val /= 10 - } - if e > 9 { - ok = false - } - m = uint8(val) - return -} - -func appendOrigin(name, origin string) string { - if origin == "." { - return name + origin - } - return name + "." + origin -} - -// LOC record helper function -func locCheckNorth(token string, latitude uint32) (uint32, bool) { - switch token { - case "n", "N": - return LOC_EQUATOR + latitude, true - case "s", "S": - return LOC_EQUATOR - latitude, true - } - return latitude, false -} - -// LOC record helper function -func locCheckEast(token string, longitude uint32) (uint32, bool) { - switch token { - case "e", "E": - return LOC_EQUATOR + longitude, true - case "w", "W": - return LOC_EQUATOR - longitude, true - } - return longitude, false -} - -// "Eat" the rest of the "line". Return potential comments -func slurpRemainder(c chan lex, f string) (*ParseError, string) { - l := <-c - com := "" - switch l.value { - case zBlank: - l = <-c - com = l.comment - if l.value != zNewline && l.value != zEOF { - return &ParseError{f, "garbage after rdata", l}, "" - } - case zNewline: - com = l.comment - case zEOF: - default: - return &ParseError{f, "garbage after rdata", l}, "" - } - return nil, com -} - -// Parse a 64 bit-like ipv6 address: "0014:4fff:ff20:ee64" -// Used for NID and L64 record. -func stringToNodeID(l lex) (uint64, *ParseError) { - if len(l.token) < 19 { - return 0, &ParseError{l.token, "bad NID/L64 NodeID/Locator64", l} - } - // There must be three colons at fixes postitions, if not its a parse error - if l.token[4] != ':' && l.token[9] != ':' && l.token[14] != ':' { - return 0, &ParseError{l.token, "bad NID/L64 NodeID/Locator64", l} - } - s := l.token[0:4] + l.token[5:9] + l.token[10:14] + l.token[15:19] - u, err := strconv.ParseUint(s, 16, 64) - if err != nil { - return 0, &ParseError{l.token, "bad NID/L64 NodeID/Locator64", l} - } - return u, nil -} diff --git a/vendor/github.com/miekg/dns/scan_rr.go b/vendor/github.com/miekg/dns/scan_rr.go deleted file mode 100644 index e521dc0..0000000 --- a/vendor/github.com/miekg/dns/scan_rr.go +++ /dev/null @@ -1,2143 +0,0 @@ -package dns - -import ( - "encoding/base64" - "net" - "strconv" - "strings" -) - -type parserFunc struct { - // Func defines the function that parses the tokens and returns the RR - // or an error. The last string contains any comments in the line as - // they returned by the lexer as well. - Func func(h RR_Header, c chan lex, origin string, file string) (RR, *ParseError, string) - // Signals if the RR ending is of variable length, like TXT or records - // that have Hexadecimal or Base64 as their last element in the Rdata. Records - // that have a fixed ending or for instance A, AAAA, SOA and etc. - Variable bool -} - -// Parse the rdata of each rrtype. -// All data from the channel c is either zString or zBlank. -// After the rdata there may come a zBlank and then a zNewline -// or immediately a zNewline. If this is not the case we flag -// an *ParseError: garbage after rdata. -func setRR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - parserfunc, ok := typeToparserFunc[h.Rrtype] - if ok { - r, e, cm := parserfunc.Func(h, c, o, f) - if parserfunc.Variable { - return r, e, cm - } - if e != nil { - return nil, e, "" - } - e, cm = slurpRemainder(c, f) - if e != nil { - return nil, e, "" - } - return r, nil, cm - } - // RFC3957 RR (Unknown RR handling) - return setRFC3597(h, c, o, f) -} - -// A remainder of the rdata with embedded spaces, return the parsed string (sans the spaces) -// or an error -func endingToString(c chan lex, errstr, f string) (string, *ParseError, string) { - s := "" - l := <-c // zString - for l.value != zNewline && l.value != zEOF { - if l.err { - return s, &ParseError{f, errstr, l}, "" - } - switch l.value { - case zString: - s += l.token - case zBlank: // Ok - default: - return "", &ParseError{f, errstr, l}, "" - } - l = <-c - } - return s, nil, l.comment -} - -// A remainder of the rdata with embedded spaces, return the parsed string slice (sans the spaces) -// or an error -func endingToTxtSlice(c chan lex, errstr, f string) ([]string, *ParseError, string) { - // Get the remaining data until we see a zNewline - quote := false - l := <-c - var s []string - if l.err { - return s, &ParseError{f, errstr, l}, "" - } - switch l.value == zQuote { - case true: // A number of quoted string - s = make([]string, 0) - empty := true - for l.value != zNewline && l.value != zEOF { - if l.err { - return nil, &ParseError{f, errstr, l}, "" - } - switch l.value { - case zString: - empty = false - if len(l.token) > 255 { - // split up tokens that are larger than 255 into 255-chunks - sx := []string{} - p, i := 0, 255 - for { - if i <= len(l.token) { - sx = append(sx, l.token[p:i]) - } else { - sx = append(sx, l.token[p:]) - break - - } - p, i = p+255, i+255 - } - s = append(s, sx...) - break - } - - s = append(s, l.token) - case zBlank: - if quote { - // zBlank can only be seen in between txt parts. - return nil, &ParseError{f, errstr, l}, "" - } - case zQuote: - if empty && quote { - s = append(s, "") - } - quote = !quote - empty = true - default: - return nil, &ParseError{f, errstr, l}, "" - } - l = <-c - } - if quote { - return nil, &ParseError{f, errstr, l}, "" - } - case false: // Unquoted text record - s = make([]string, 1) - for l.value != zNewline && l.value != zEOF { - if l.err { - return s, &ParseError{f, errstr, l}, "" - } - s[0] += l.token - l = <-c - } - } - return s, nil, l.comment -} - -func setA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(A) - rr.Hdr = h - - l := <-c - if l.length == 0 { // Dynamic updates. - return rr, nil, "" - } - rr.A = net.ParseIP(l.token) - if rr.A == nil || l.err { - return nil, &ParseError{f, "bad A A", l}, "" - } - return rr, nil, "" -} - -func setAAAA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(AAAA) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - rr.AAAA = net.ParseIP(l.token) - if rr.AAAA == nil || l.err { - return nil, &ParseError{f, "bad AAAA AAAA", l}, "" - } - return rr, nil, "" -} - -func setNS(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NS) - rr.Hdr = h - - l := <-c - rr.Ns = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Ns = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad NS Ns", l}, "" - } - if rr.Ns[l.length-1] != '.' { - rr.Ns = appendOrigin(rr.Ns, o) - } - return rr, nil, "" -} - -func setPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(PTR) - rr.Hdr = h - - l := <-c - rr.Ptr = l.token - if l.length == 0 { // dynamic update rr. - return rr, nil, "" - } - if l.token == "@" { - rr.Ptr = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad PTR Ptr", l}, "" - } - if rr.Ptr[l.length-1] != '.' { - rr.Ptr = appendOrigin(rr.Ptr, o) - } - return rr, nil, "" -} - -func setNSAPPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NSAPPTR) - rr.Hdr = h - - l := <-c - rr.Ptr = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Ptr = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad NSAP-PTR Ptr", l}, "" - } - if rr.Ptr[l.length-1] != '.' { - rr.Ptr = appendOrigin(rr.Ptr, o) - } - return rr, nil, "" -} - -func setRP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(RP) - rr.Hdr = h - - l := <-c - rr.Mbox = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Mbox = o - } else { - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad RP Mbox", l}, "" - } - if rr.Mbox[l.length-1] != '.' { - rr.Mbox = appendOrigin(rr.Mbox, o) - } - } - <-c // zBlank - l = <-c - rr.Txt = l.token - if l.token == "@" { - rr.Txt = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad RP Txt", l}, "" - } - if rr.Txt[l.length-1] != '.' { - rr.Txt = appendOrigin(rr.Txt, o) - } - return rr, nil, "" -} - -func setMR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(MR) - rr.Hdr = h - - l := <-c - rr.Mr = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Mr = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MR Mr", l}, "" - } - if rr.Mr[l.length-1] != '.' { - rr.Mr = appendOrigin(rr.Mr, o) - } - return rr, nil, "" -} - -func setMB(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(MB) - rr.Hdr = h - - l := <-c - rr.Mb = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Mb = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MB Mb", l}, "" - } - if rr.Mb[l.length-1] != '.' { - rr.Mb = appendOrigin(rr.Mb, o) - } - return rr, nil, "" -} - -func setMG(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(MG) - rr.Hdr = h - - l := <-c - rr.Mg = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Mg = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MG Mg", l}, "" - } - if rr.Mg[l.length-1] != '.' { - rr.Mg = appendOrigin(rr.Mg, o) - } - return rr, nil, "" -} - -func setHINFO(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(HINFO) - rr.Hdr = h - - chunks, e, c1 := endingToTxtSlice(c, "bad HINFO Fields", f) - if e != nil { - return nil, e, c1 - } - - if ln := len(chunks); ln == 0 { - return rr, nil, "" - } else if ln == 1 { - // Can we split it? - if out := strings.Fields(chunks[0]); len(out) > 1 { - chunks = out - } else { - chunks = append(chunks, "") - } - } - - rr.Cpu = chunks[0] - rr.Os = strings.Join(chunks[1:], " ") - - return rr, nil, "" -} - -func setMINFO(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(MINFO) - rr.Hdr = h - - l := <-c - rr.Rmail = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Rmail = o - } else { - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MINFO Rmail", l}, "" - } - if rr.Rmail[l.length-1] != '.' { - rr.Rmail = appendOrigin(rr.Rmail, o) - } - } - <-c // zBlank - l = <-c - rr.Email = l.token - if l.token == "@" { - rr.Email = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MINFO Email", l}, "" - } - if rr.Email[l.length-1] != '.' { - rr.Email = appendOrigin(rr.Email, o) - } - return rr, nil, "" -} - -func setMF(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(MF) - rr.Hdr = h - - l := <-c - rr.Mf = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Mf = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MF Mf", l}, "" - } - if rr.Mf[l.length-1] != '.' { - rr.Mf = appendOrigin(rr.Mf, o) - } - return rr, nil, "" -} - -func setMD(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(MD) - rr.Hdr = h - - l := <-c - rr.Md = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Md = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MD Md", l}, "" - } - if rr.Md[l.length-1] != '.' { - rr.Md = appendOrigin(rr.Md, o) - } - return rr, nil, "" -} - -func setMX(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(MX) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad MX Pref", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Mx = l.token - if l.token == "@" { - rr.Mx = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad MX Mx", l}, "" - } - if rr.Mx[l.length-1] != '.' { - rr.Mx = appendOrigin(rr.Mx, o) - } - return rr, nil, "" -} - -func setRT(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(RT) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil { - return nil, &ParseError{f, "bad RT Preference", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Host = l.token - if l.token == "@" { - rr.Host = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad RT Host", l}, "" - } - if rr.Host[l.length-1] != '.' { - rr.Host = appendOrigin(rr.Host, o) - } - return rr, nil, "" -} - -func setAFSDB(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(AFSDB) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad AFSDB Subtype", l}, "" - } - rr.Subtype = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Hostname = l.token - if l.token == "@" { - rr.Hostname = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad AFSDB Hostname", l}, "" - } - if rr.Hostname[l.length-1] != '.' { - rr.Hostname = appendOrigin(rr.Hostname, o) - } - return rr, nil, "" -} - -func setX25(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(X25) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - if l.err { - return nil, &ParseError{f, "bad X25 PSDNAddress", l}, "" - } - rr.PSDNAddress = l.token - return rr, nil, "" -} - -func setKX(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(KX) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad KX Pref", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Exchanger = l.token - if l.token == "@" { - rr.Exchanger = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad KX Exchanger", l}, "" - } - if rr.Exchanger[l.length-1] != '.' { - rr.Exchanger = appendOrigin(rr.Exchanger, o) - } - return rr, nil, "" -} - -func setCNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(CNAME) - rr.Hdr = h - - l := <-c - rr.Target = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Target = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad CNAME Target", l}, "" - } - if rr.Target[l.length-1] != '.' { - rr.Target = appendOrigin(rr.Target, o) - } - return rr, nil, "" -} - -func setDNAME(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(DNAME) - rr.Hdr = h - - l := <-c - rr.Target = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Target = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad CNAME Target", l}, "" - } - if rr.Target[l.length-1] != '.' { - rr.Target = appendOrigin(rr.Target, o) - } - return rr, nil, "" -} - -func setSOA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(SOA) - rr.Hdr = h - - l := <-c - rr.Ns = l.token - if l.length == 0 { - return rr, nil, "" - } - <-c // zBlank - if l.token == "@" { - rr.Ns = o - } else { - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad SOA Ns", l}, "" - } - if rr.Ns[l.length-1] != '.' { - rr.Ns = appendOrigin(rr.Ns, o) - } - } - - l = <-c - rr.Mbox = l.token - if l.token == "@" { - rr.Mbox = o - } else { - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad SOA Mbox", l}, "" - } - if rr.Mbox[l.length-1] != '.' { - rr.Mbox = appendOrigin(rr.Mbox, o) - } - } - <-c // zBlank - - var ( - v uint32 - ok bool - ) - for i := 0; i < 5; i++ { - l = <-c - if l.err { - return nil, &ParseError{f, "bad SOA zone parameter", l}, "" - } - if j, e := strconv.Atoi(l.token); e != nil { - if i == 0 { - // Serial should be a number - return nil, &ParseError{f, "bad SOA zone parameter", l}, "" - } - if v, ok = stringToTtl(l.token); !ok { - return nil, &ParseError{f, "bad SOA zone parameter", l}, "" - - } - } else { - v = uint32(j) - } - switch i { - case 0: - rr.Serial = v - <-c // zBlank - case 1: - rr.Refresh = v - <-c // zBlank - case 2: - rr.Retry = v - <-c // zBlank - case 3: - rr.Expire = v - <-c // zBlank - case 4: - rr.Minttl = v - } - } - return rr, nil, "" -} - -func setSRV(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(SRV) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad SRV Priority", l}, "" - } - rr.Priority = uint16(i) - <-c // zBlank - l = <-c // zString - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad SRV Weight", l}, "" - } - rr.Weight = uint16(i) - <-c // zBlank - l = <-c // zString - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad SRV Port", l}, "" - } - rr.Port = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Target = l.token - if l.token == "@" { - rr.Target = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad SRV Target", l}, "" - } - if rr.Target[l.length-1] != '.' { - rr.Target = appendOrigin(rr.Target, o) - } - return rr, nil, "" -} - -func setNAPTR(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NAPTR) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NAPTR Order", l}, "" - } - rr.Order = uint16(i) - <-c // zBlank - l = <-c // zString - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NAPTR Preference", l}, "" - } - rr.Preference = uint16(i) - // Flags - <-c // zBlank - l = <-c // _QUOTE - if l.value != zQuote { - return nil, &ParseError{f, "bad NAPTR Flags", l}, "" - } - l = <-c // Either String or Quote - if l.value == zString { - rr.Flags = l.token - l = <-c // _QUOTE - if l.value != zQuote { - return nil, &ParseError{f, "bad NAPTR Flags", l}, "" - } - } else if l.value == zQuote { - rr.Flags = "" - } else { - return nil, &ParseError{f, "bad NAPTR Flags", l}, "" - } - - // Service - <-c // zBlank - l = <-c // _QUOTE - if l.value != zQuote { - return nil, &ParseError{f, "bad NAPTR Service", l}, "" - } - l = <-c // Either String or Quote - if l.value == zString { - rr.Service = l.token - l = <-c // _QUOTE - if l.value != zQuote { - return nil, &ParseError{f, "bad NAPTR Service", l}, "" - } - } else if l.value == zQuote { - rr.Service = "" - } else { - return nil, &ParseError{f, "bad NAPTR Service", l}, "" - } - - // Regexp - <-c // zBlank - l = <-c // _QUOTE - if l.value != zQuote { - return nil, &ParseError{f, "bad NAPTR Regexp", l}, "" - } - l = <-c // Either String or Quote - if l.value == zString { - rr.Regexp = l.token - l = <-c // _QUOTE - if l.value != zQuote { - return nil, &ParseError{f, "bad NAPTR Regexp", l}, "" - } - } else if l.value == zQuote { - rr.Regexp = "" - } else { - return nil, &ParseError{f, "bad NAPTR Regexp", l}, "" - } - // After quote no space?? - <-c // zBlank - l = <-c // zString - rr.Replacement = l.token - if l.token == "@" { - rr.Replacement = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad NAPTR Replacement", l}, "" - } - if rr.Replacement[l.length-1] != '.' { - rr.Replacement = appendOrigin(rr.Replacement, o) - } - return rr, nil, "" -} - -func setTALINK(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(TALINK) - rr.Hdr = h - - l := <-c - rr.PreviousName = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.PreviousName = o - } else { - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad TALINK PreviousName", l}, "" - } - if rr.PreviousName[l.length-1] != '.' { - rr.PreviousName = appendOrigin(rr.PreviousName, o) - } - } - <-c // zBlank - l = <-c - rr.NextName = l.token - if l.token == "@" { - rr.NextName = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad TALINK NextName", l}, "" - } - if rr.NextName[l.length-1] != '.' { - rr.NextName = appendOrigin(rr.NextName, o) - } - return rr, nil, "" -} - -func setLOC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(LOC) - rr.Hdr = h - // Non zero defaults for LOC record, see RFC 1876, Section 3. - rr.HorizPre = 165 // 10000 - rr.VertPre = 162 // 10 - rr.Size = 18 // 1 - ok := false - // North - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad LOC Latitude", l}, "" - } - rr.Latitude = 1000 * 60 * 60 * uint32(i) - - <-c // zBlank - // Either number, 'N' or 'S' - l = <-c - if rr.Latitude, ok = locCheckNorth(l.token, rr.Latitude); ok { - goto East - } - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad LOC Latitude minutes", l}, "" - } - rr.Latitude += 1000 * 60 * uint32(i) - - <-c // zBlank - l = <-c - if i, e := strconv.ParseFloat(l.token, 32); e != nil || l.err { - return nil, &ParseError{f, "bad LOC Latitude seconds", l}, "" - } else { - rr.Latitude += uint32(1000 * i) - } - <-c // zBlank - // Either number, 'N' or 'S' - l = <-c - if rr.Latitude, ok = locCheckNorth(l.token, rr.Latitude); ok { - goto East - } - // If still alive, flag an error - return nil, &ParseError{f, "bad LOC Latitude North/South", l}, "" - -East: - // East - <-c // zBlank - l = <-c - if i, e := strconv.Atoi(l.token); e != nil || l.err { - return nil, &ParseError{f, "bad LOC Longitude", l}, "" - } else { - rr.Longitude = 1000 * 60 * 60 * uint32(i) - } - <-c // zBlank - // Either number, 'E' or 'W' - l = <-c - if rr.Longitude, ok = locCheckEast(l.token, rr.Longitude); ok { - goto Altitude - } - if i, e := strconv.Atoi(l.token); e != nil || l.err { - return nil, &ParseError{f, "bad LOC Longitude minutes", l}, "" - } else { - rr.Longitude += 1000 * 60 * uint32(i) - } - <-c // zBlank - l = <-c - if i, e := strconv.ParseFloat(l.token, 32); e != nil || l.err { - return nil, &ParseError{f, "bad LOC Longitude seconds", l}, "" - } else { - rr.Longitude += uint32(1000 * i) - } - <-c // zBlank - // Either number, 'E' or 'W' - l = <-c - if rr.Longitude, ok = locCheckEast(l.token, rr.Longitude); ok { - goto Altitude - } - // If still alive, flag an error - return nil, &ParseError{f, "bad LOC Longitude East/West", l}, "" - -Altitude: - <-c // zBlank - l = <-c - if l.length == 0 || l.err { - return nil, &ParseError{f, "bad LOC Altitude", l}, "" - } - if l.token[len(l.token)-1] == 'M' || l.token[len(l.token)-1] == 'm' { - l.token = l.token[0 : len(l.token)-1] - } - if i, e := strconv.ParseFloat(l.token, 32); e != nil { - return nil, &ParseError{f, "bad LOC Altitude", l}, "" - } else { - rr.Altitude = uint32(i*100.0 + 10000000.0 + 0.5) - } - - // And now optionally the other values - l = <-c - count := 0 - for l.value != zNewline && l.value != zEOF { - switch l.value { - case zString: - switch count { - case 0: // Size - e, m, ok := stringToCm(l.token) - if !ok { - return nil, &ParseError{f, "bad LOC Size", l}, "" - } - rr.Size = (e & 0x0f) | (m << 4 & 0xf0) - case 1: // HorizPre - e, m, ok := stringToCm(l.token) - if !ok { - return nil, &ParseError{f, "bad LOC HorizPre", l}, "" - } - rr.HorizPre = (e & 0x0f) | (m << 4 & 0xf0) - case 2: // VertPre - e, m, ok := stringToCm(l.token) - if !ok { - return nil, &ParseError{f, "bad LOC VertPre", l}, "" - } - rr.VertPre = (e & 0x0f) | (m << 4 & 0xf0) - } - count++ - case zBlank: - // Ok - default: - return nil, &ParseError{f, "bad LOC Size, HorizPre or VertPre", l}, "" - } - l = <-c - } - return rr, nil, "" -} - -func setHIP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(HIP) - rr.Hdr = h - - // HitLength is not represented - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad HIP PublicKeyAlgorithm", l}, "" - } - rr.PublicKeyAlgorithm = uint8(i) - <-c // zBlank - l = <-c // zString - if l.length == 0 || l.err { - return nil, &ParseError{f, "bad HIP Hit", l}, "" - } - rr.Hit = l.token // This can not contain spaces, see RFC 5205 Section 6. - rr.HitLength = uint8(len(rr.Hit)) / 2 - - <-c // zBlank - l = <-c // zString - if l.length == 0 || l.err { - return nil, &ParseError{f, "bad HIP PublicKey", l}, "" - } - rr.PublicKey = l.token // This cannot contain spaces - rr.PublicKeyLength = uint16(base64.StdEncoding.DecodedLen(len(rr.PublicKey))) - - // RendezvousServers (if any) - l = <-c - var xs []string - for l.value != zNewline && l.value != zEOF { - switch l.value { - case zString: - if l.token == "@" { - xs = append(xs, o) - l = <-c - continue - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad HIP RendezvousServers", l}, "" - } - if l.token[l.length-1] != '.' { - l.token = appendOrigin(l.token, o) - } - xs = append(xs, l.token) - case zBlank: - // Ok - default: - return nil, &ParseError{f, "bad HIP RendezvousServers", l}, "" - } - l = <-c - } - rr.RendezvousServers = xs - return rr, nil, l.comment -} - -func setCERT(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(CERT) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - if v, ok := StringToCertType[l.token]; ok { - rr.Type = v - } else if i, e := strconv.Atoi(l.token); e != nil { - return nil, &ParseError{f, "bad CERT Type", l}, "" - } else { - rr.Type = uint16(i) - } - <-c // zBlank - l = <-c // zString - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad CERT KeyTag", l}, "" - } - rr.KeyTag = uint16(i) - <-c // zBlank - l = <-c // zString - if v, ok := StringToAlgorithm[l.token]; ok { - rr.Algorithm = v - } else if i, e := strconv.Atoi(l.token); e != nil { - return nil, &ParseError{f, "bad CERT Algorithm", l}, "" - } else { - rr.Algorithm = uint8(i) - } - s, e1, c1 := endingToString(c, "bad CERT Certificate", f) - if e1 != nil { - return nil, e1, c1 - } - rr.Certificate = s - return rr, nil, c1 -} - -func setOPENPGPKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(OPENPGPKEY) - rr.Hdr = h - - s, e, c1 := endingToString(c, "bad OPENPGPKEY PublicKey", f) - if e != nil { - return nil, e, c1 - } - rr.PublicKey = s - return rr, nil, c1 -} - -func setSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - r, e, s := setRRSIG(h, c, o, f) - if r != nil { - return &SIG{*r.(*RRSIG)}, e, s - } - return nil, e, s -} - -func setRRSIG(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(RRSIG) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - if t, ok := StringToType[l.tokenUpper]; !ok { - if strings.HasPrefix(l.tokenUpper, "TYPE") { - t, ok = typeToInt(l.tokenUpper) - if !ok { - return nil, &ParseError{f, "bad RRSIG Typecovered", l}, "" - } - rr.TypeCovered = t - } else { - return nil, &ParseError{f, "bad RRSIG Typecovered", l}, "" - } - } else { - rr.TypeCovered = t - } - <-c // zBlank - l = <-c - i, err := strconv.Atoi(l.token) - if err != nil || l.err { - return nil, &ParseError{f, "bad RRSIG Algorithm", l}, "" - } - rr.Algorithm = uint8(i) - <-c // zBlank - l = <-c - i, err = strconv.Atoi(l.token) - if err != nil || l.err { - return nil, &ParseError{f, "bad RRSIG Labels", l}, "" - } - rr.Labels = uint8(i) - <-c // zBlank - l = <-c - i, err = strconv.Atoi(l.token) - if err != nil || l.err { - return nil, &ParseError{f, "bad RRSIG OrigTtl", l}, "" - } - rr.OrigTtl = uint32(i) - <-c // zBlank - l = <-c - if i, err := StringToTime(l.token); err != nil { - // Try to see if all numeric and use it as epoch - if i, err := strconv.ParseInt(l.token, 10, 64); err == nil { - // TODO(miek): error out on > MAX_UINT32, same below - rr.Expiration = uint32(i) - } else { - return nil, &ParseError{f, "bad RRSIG Expiration", l}, "" - } - } else { - rr.Expiration = i - } - <-c // zBlank - l = <-c - if i, err := StringToTime(l.token); err != nil { - if i, err := strconv.ParseInt(l.token, 10, 64); err == nil { - rr.Inception = uint32(i) - } else { - return nil, &ParseError{f, "bad RRSIG Inception", l}, "" - } - } else { - rr.Inception = i - } - <-c // zBlank - l = <-c - i, err = strconv.Atoi(l.token) - if err != nil || l.err { - return nil, &ParseError{f, "bad RRSIG KeyTag", l}, "" - } - rr.KeyTag = uint16(i) - <-c // zBlank - l = <-c - rr.SignerName = l.token - if l.token == "@" { - rr.SignerName = o - } else { - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad RRSIG SignerName", l}, "" - } - if rr.SignerName[l.length-1] != '.' { - rr.SignerName = appendOrigin(rr.SignerName, o) - } - } - s, e, c1 := endingToString(c, "bad RRSIG Signature", f) - if e != nil { - return nil, e, c1 - } - rr.Signature = s - return rr, nil, c1 -} - -func setNSEC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NSEC) - rr.Hdr = h - - l := <-c - rr.NextDomain = l.token - if l.length == 0 { - return rr, nil, l.comment - } - if l.token == "@" { - rr.NextDomain = o - } else { - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad NSEC NextDomain", l}, "" - } - if rr.NextDomain[l.length-1] != '.' { - rr.NextDomain = appendOrigin(rr.NextDomain, o) - } - } - - rr.TypeBitMap = make([]uint16, 0) - var ( - k uint16 - ok bool - ) - l = <-c - for l.value != zNewline && l.value != zEOF { - switch l.value { - case zBlank: - // Ok - case zString: - if k, ok = StringToType[l.tokenUpper]; !ok { - if k, ok = typeToInt(l.tokenUpper); !ok { - return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, "" - } - } - rr.TypeBitMap = append(rr.TypeBitMap, k) - default: - return nil, &ParseError{f, "bad NSEC TypeBitMap", l}, "" - } - l = <-c - } - return rr, nil, l.comment -} - -func setNSEC3(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NSEC3) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NSEC3 Hash", l}, "" - } - rr.Hash = uint8(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NSEC3 Flags", l}, "" - } - rr.Flags = uint8(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NSEC3 Iterations", l}, "" - } - rr.Iterations = uint16(i) - <-c - l = <-c - if len(l.token) == 0 || l.err { - return nil, &ParseError{f, "bad NSEC3 Salt", l}, "" - } - rr.SaltLength = uint8(len(l.token)) / 2 - rr.Salt = l.token - - <-c - l = <-c - if len(l.token) == 0 || l.err { - return nil, &ParseError{f, "bad NSEC3 NextDomain", l}, "" - } - rr.HashLength = 20 // Fix for NSEC3 (sha1 160 bits) - rr.NextDomain = l.token - - rr.TypeBitMap = make([]uint16, 0) - var ( - k uint16 - ok bool - ) - l = <-c - for l.value != zNewline && l.value != zEOF { - switch l.value { - case zBlank: - // Ok - case zString: - if k, ok = StringToType[l.tokenUpper]; !ok { - if k, ok = typeToInt(l.tokenUpper); !ok { - return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, "" - } - } - rr.TypeBitMap = append(rr.TypeBitMap, k) - default: - return nil, &ParseError{f, "bad NSEC3 TypeBitMap", l}, "" - } - l = <-c - } - return rr, nil, l.comment -} - -func setNSEC3PARAM(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NSEC3PARAM) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NSEC3PARAM Hash", l}, "" - } - rr.Hash = uint8(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NSEC3PARAM Flags", l}, "" - } - rr.Flags = uint8(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NSEC3PARAM Iterations", l}, "" - } - rr.Iterations = uint16(i) - <-c - l = <-c - rr.SaltLength = uint8(len(l.token)) - rr.Salt = l.token - return rr, nil, "" -} - -func setEUI48(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(EUI48) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - if l.length != 17 || l.err { - return nil, &ParseError{f, "bad EUI48 Address", l}, "" - } - addr := make([]byte, 12) - dash := 0 - for i := 0; i < 10; i += 2 { - addr[i] = l.token[i+dash] - addr[i+1] = l.token[i+1+dash] - dash++ - if l.token[i+1+dash] != '-' { - return nil, &ParseError{f, "bad EUI48 Address", l}, "" - } - } - addr[10] = l.token[15] - addr[11] = l.token[16] - - i, e := strconv.ParseUint(string(addr), 16, 48) - if e != nil { - return nil, &ParseError{f, "bad EUI48 Address", l}, "" - } - rr.Address = i - return rr, nil, "" -} - -func setEUI64(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(EUI64) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - if l.length != 23 || l.err { - return nil, &ParseError{f, "bad EUI64 Address", l}, "" - } - addr := make([]byte, 16) - dash := 0 - for i := 0; i < 14; i += 2 { - addr[i] = l.token[i+dash] - addr[i+1] = l.token[i+1+dash] - dash++ - if l.token[i+1+dash] != '-' { - return nil, &ParseError{f, "bad EUI64 Address", l}, "" - } - } - addr[14] = l.token[21] - addr[15] = l.token[22] - - i, e := strconv.ParseUint(string(addr), 16, 64) - if e != nil { - return nil, &ParseError{f, "bad EUI68 Address", l}, "" - } - rr.Address = uint64(i) - return rr, nil, "" -} - -func setSSHFP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(SSHFP) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad SSHFP Algorithm", l}, "" - } - rr.Algorithm = uint8(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad SSHFP Type", l}, "" - } - rr.Type = uint8(i) - <-c // zBlank - s, e1, c1 := endingToString(c, "bad SSHFP Fingerprint", f) - if e1 != nil { - return nil, e1, c1 - } - rr.FingerPrint = s - return rr, nil, "" -} - -func setDNSKEYs(h RR_Header, c chan lex, o, f, typ string) (RR, *ParseError, string) { - rr := new(DNSKEY) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad " + typ + " Flags", l}, "" - } - rr.Flags = uint16(i) - <-c // zBlank - l = <-c // zString - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad " + typ + " Protocol", l}, "" - } - rr.Protocol = uint8(i) - <-c // zBlank - l = <-c // zString - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad " + typ + " Algorithm", l}, "" - } - rr.Algorithm = uint8(i) - s, e1, c1 := endingToString(c, "bad "+typ+" PublicKey", f) - if e1 != nil { - return nil, e1, c1 - } - rr.PublicKey = s - return rr, nil, c1 -} - -func setKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - r, e, s := setDNSKEYs(h, c, o, f, "KEY") - if r != nil { - return &KEY{*r.(*DNSKEY)}, e, s - } - return nil, e, s -} - -func setDNSKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - r, e, s := setDNSKEYs(h, c, o, f, "DNSKEY") - return r, e, s -} - -func setCDNSKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - r, e, s := setDNSKEYs(h, c, o, f, "CDNSKEY") - if r != nil { - return &CDNSKEY{*r.(*DNSKEY)}, e, s - } - return nil, e, s -} - -func setRKEY(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(RKEY) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad RKEY Flags", l}, "" - } - rr.Flags = uint16(i) - <-c // zBlank - l = <-c // zString - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad RKEY Protocol", l}, "" - } - rr.Protocol = uint8(i) - <-c // zBlank - l = <-c // zString - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad RKEY Algorithm", l}, "" - } - rr.Algorithm = uint8(i) - s, e1, c1 := endingToString(c, "bad RKEY PublicKey", f) - if e1 != nil { - return nil, e1, c1 - } - rr.PublicKey = s - return rr, nil, c1 -} - -func setEID(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(EID) - rr.Hdr = h - s, e, c1 := endingToString(c, "bad EID Endpoint", f) - if e != nil { - return nil, e, c1 - } - rr.Endpoint = s - return rr, nil, c1 -} - -func setNIMLOC(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NIMLOC) - rr.Hdr = h - s, e, c1 := endingToString(c, "bad NIMLOC Locator", f) - if e != nil { - return nil, e, c1 - } - rr.Locator = s - return rr, nil, c1 -} - -func setGPOS(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(GPOS) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, "" - } - _, e := strconv.ParseFloat(l.token, 64) - if e != nil || l.err { - return nil, &ParseError{f, "bad GPOS Longitude", l}, "" - } - rr.Longitude = l.token - <-c // zBlank - l = <-c - _, e = strconv.ParseFloat(l.token, 64) - if e != nil || l.err { - return nil, &ParseError{f, "bad GPOS Latitude", l}, "" - } - rr.Latitude = l.token - <-c // zBlank - l = <-c - _, e = strconv.ParseFloat(l.token, 64) - if e != nil || l.err { - return nil, &ParseError{f, "bad GPOS Altitude", l}, "" - } - rr.Altitude = l.token - return rr, nil, "" -} - -func setDSs(h RR_Header, c chan lex, o, f, typ string) (RR, *ParseError, string) { - rr := new(DS) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad " + typ + " KeyTag", l}, "" - } - rr.KeyTag = uint16(i) - <-c // zBlank - l = <-c - if i, e := strconv.Atoi(l.token); e != nil { - i, ok := StringToAlgorithm[l.tokenUpper] - if !ok || l.err { - return nil, &ParseError{f, "bad " + typ + " Algorithm", l}, "" - } - rr.Algorithm = i - } else { - rr.Algorithm = uint8(i) - } - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad " + typ + " DigestType", l}, "" - } - rr.DigestType = uint8(i) - s, e1, c1 := endingToString(c, "bad "+typ+" Digest", f) - if e1 != nil { - return nil, e1, c1 - } - rr.Digest = s - return rr, nil, c1 -} - -func setDS(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - r, e, s := setDSs(h, c, o, f, "DS") - return r, e, s -} - -func setDLV(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - r, e, s := setDSs(h, c, o, f, "DLV") - if r != nil { - return &DLV{*r.(*DS)}, e, s - } - return nil, e, s -} - -func setCDS(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - r, e, s := setDSs(h, c, o, f, "CDS") - if r != nil { - return &CDS{*r.(*DS)}, e, s - } - return nil, e, s -} - -func setTA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(TA) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad TA KeyTag", l}, "" - } - rr.KeyTag = uint16(i) - <-c // zBlank - l = <-c - if i, e := strconv.Atoi(l.token); e != nil { - i, ok := StringToAlgorithm[l.tokenUpper] - if !ok || l.err { - return nil, &ParseError{f, "bad TA Algorithm", l}, "" - } - rr.Algorithm = i - } else { - rr.Algorithm = uint8(i) - } - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad TA DigestType", l}, "" - } - rr.DigestType = uint8(i) - s, e, c1 := endingToString(c, "bad TA Digest", f) - if e != nil { - return nil, e.(*ParseError), c1 - } - rr.Digest = s - return rr, nil, c1 -} - -func setTLSA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(TLSA) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad TLSA Usage", l}, "" - } - rr.Usage = uint8(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad TLSA Selector", l}, "" - } - rr.Selector = uint8(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad TLSA MatchingType", l}, "" - } - rr.MatchingType = uint8(i) - // So this needs be e2 (i.e. different than e), because...??t - s, e2, c1 := endingToString(c, "bad TLSA Certificate", f) - if e2 != nil { - return nil, e2, c1 - } - rr.Certificate = s - return rr, nil, c1 -} - -func setRFC3597(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(RFC3597) - rr.Hdr = h - l := <-c - if l.token != "\\#" { - return nil, &ParseError{f, "bad RFC3597 Rdata", l}, "" - } - <-c // zBlank - l = <-c - rdlength, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad RFC3597 Rdata ", l}, "" - } - - s, e1, c1 := endingToString(c, "bad RFC3597 Rdata", f) - if e1 != nil { - return nil, e1, c1 - } - if rdlength*2 != len(s) { - return nil, &ParseError{f, "bad RFC3597 Rdata", l}, "" - } - rr.Rdata = s - return rr, nil, c1 -} - -func setSPF(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(SPF) - rr.Hdr = h - - s, e, c1 := endingToTxtSlice(c, "bad SPF Txt", f) - if e != nil { - return nil, e, "" - } - rr.Txt = s - return rr, nil, c1 -} - -func setTXT(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(TXT) - rr.Hdr = h - - // no zBlank reading here, because all this rdata is TXT - s, e, c1 := endingToTxtSlice(c, "bad TXT Txt", f) - if e != nil { - return nil, e, "" - } - rr.Txt = s - return rr, nil, c1 -} - -// identical to setTXT -func setNINFO(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NINFO) - rr.Hdr = h - - s, e, c1 := endingToTxtSlice(c, "bad NINFO ZSData", f) - if e != nil { - return nil, e, "" - } - rr.ZSData = s - return rr, nil, c1 -} - -func setURI(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(URI) - rr.Hdr = h - - l := <-c - if l.length == 0 { // Dynamic updates. - return rr, nil, "" - } - - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad URI Priority", l}, "" - } - rr.Priority = uint16(i) - <-c // zBlank - l = <-c - i, e = strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad URI Weight", l}, "" - } - rr.Weight = uint16(i) - - <-c // zBlank - s, err, c1 := endingToTxtSlice(c, "bad URI Target", f) - if err != nil { - return nil, err, "" - } - if len(s) > 1 { - return nil, &ParseError{f, "bad URI Target", l}, "" - } - rr.Target = s[0] - return rr, nil, c1 -} - -func setDHCID(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - // awesome record to parse! - rr := new(DHCID) - rr.Hdr = h - - s, e, c1 := endingToString(c, "bad DHCID Digest", f) - if e != nil { - return nil, e, c1 - } - rr.Digest = s - return rr, nil, c1 -} - -func setNID(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(NID) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad NID Preference", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - u, err := stringToNodeID(l) - if err != nil || l.err { - return nil, err, "" - } - rr.NodeID = u - return rr, nil, "" -} - -func setL32(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(L32) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad L32 Preference", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Locator32 = net.ParseIP(l.token) - if rr.Locator32 == nil || l.err { - return nil, &ParseError{f, "bad L32 Locator", l}, "" - } - return rr, nil, "" -} - -func setLP(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(LP) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad LP Preference", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Fqdn = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Fqdn = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad LP Fqdn", l}, "" - } - if rr.Fqdn[l.length-1] != '.' { - rr.Fqdn = appendOrigin(rr.Fqdn, o) - } - return rr, nil, "" -} - -func setL64(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(L64) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad L64 Preference", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - u, err := stringToNodeID(l) - if err != nil || l.err { - return nil, err, "" - } - rr.Locator64 = u - return rr, nil, "" -} - -func setUID(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(UID) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad UID Uid", l}, "" - } - rr.Uid = uint32(i) - return rr, nil, "" -} - -func setGID(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(GID) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad GID Gid", l}, "" - } - rr.Gid = uint32(i) - return rr, nil, "" -} - -func setUINFO(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(UINFO) - rr.Hdr = h - s, e, c1 := endingToTxtSlice(c, "bad UINFO Uinfo", f) - if e != nil { - return nil, e, "" - } - rr.Uinfo = s[0] // silently discard anything above - return rr, nil, c1 -} - -func setPX(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(PX) - rr.Hdr = h - - l := <-c - if l.length == 0 { - return rr, nil, "" - } - i, e := strconv.Atoi(l.token) - if e != nil || l.err { - return nil, &ParseError{f, "bad PX Preference", l}, "" - } - rr.Preference = uint16(i) - <-c // zBlank - l = <-c // zString - rr.Map822 = l.token - if l.length == 0 { - return rr, nil, "" - } - if l.token == "@" { - rr.Map822 = o - return rr, nil, "" - } - _, ok := IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad PX Map822", l}, "" - } - if rr.Map822[l.length-1] != '.' { - rr.Map822 = appendOrigin(rr.Map822, o) - } - <-c // zBlank - l = <-c // zString - rr.Mapx400 = l.token - if l.token == "@" { - rr.Mapx400 = o - return rr, nil, "" - } - _, ok = IsDomainName(l.token) - if !ok || l.length == 0 || l.err { - return nil, &ParseError{f, "bad PX Mapx400", l}, "" - } - if rr.Mapx400[l.length-1] != '.' { - rr.Mapx400 = appendOrigin(rr.Mapx400, o) - } - return rr, nil, "" -} - -func setCAA(h RR_Header, c chan lex, o, f string) (RR, *ParseError, string) { - rr := new(CAA) - rr.Hdr = h - l := <-c - if l.length == 0 { - return rr, nil, l.comment - } - i, err := strconv.Atoi(l.token) - if err != nil || l.err { - return nil, &ParseError{f, "bad CAA Flag", l}, "" - } - rr.Flag = uint8(i) - - <-c // zBlank - l = <-c // zString - if l.value != zString { - return nil, &ParseError{f, "bad CAA Tag", l}, "" - } - rr.Tag = l.token - - <-c // zBlank - s, e, c1 := endingToTxtSlice(c, "bad CAA Value", f) - if e != nil { - return nil, e, "" - } - if len(s) > 1 { - return nil, &ParseError{f, "bad CAA Value", l}, "" - } - rr.Value = s[0] - return rr, nil, c1 -} - -var typeToparserFunc = map[uint16]parserFunc{ - TypeAAAA: {setAAAA, false}, - TypeAFSDB: {setAFSDB, false}, - TypeA: {setA, false}, - TypeCAA: {setCAA, true}, - TypeCDS: {setCDS, true}, - TypeCDNSKEY: {setCDNSKEY, true}, - TypeCERT: {setCERT, true}, - TypeCNAME: {setCNAME, false}, - TypeDHCID: {setDHCID, true}, - TypeDLV: {setDLV, true}, - TypeDNAME: {setDNAME, false}, - TypeKEY: {setKEY, true}, - TypeDNSKEY: {setDNSKEY, true}, - TypeDS: {setDS, true}, - TypeEID: {setEID, true}, - TypeEUI48: {setEUI48, false}, - TypeEUI64: {setEUI64, false}, - TypeGID: {setGID, false}, - TypeGPOS: {setGPOS, false}, - TypeHINFO: {setHINFO, true}, - TypeHIP: {setHIP, true}, - TypeKX: {setKX, false}, - TypeL32: {setL32, false}, - TypeL64: {setL64, false}, - TypeLOC: {setLOC, true}, - TypeLP: {setLP, false}, - TypeMB: {setMB, false}, - TypeMD: {setMD, false}, - TypeMF: {setMF, false}, - TypeMG: {setMG, false}, - TypeMINFO: {setMINFO, false}, - TypeMR: {setMR, false}, - TypeMX: {setMX, false}, - TypeNAPTR: {setNAPTR, false}, - TypeNID: {setNID, false}, - TypeNIMLOC: {setNIMLOC, true}, - TypeNINFO: {setNINFO, true}, - TypeNSAPPTR: {setNSAPPTR, false}, - TypeNSEC3PARAM: {setNSEC3PARAM, false}, - TypeNSEC3: {setNSEC3, true}, - TypeNSEC: {setNSEC, true}, - TypeNS: {setNS, false}, - TypeOPENPGPKEY: {setOPENPGPKEY, true}, - TypePTR: {setPTR, false}, - TypePX: {setPX, false}, - TypeSIG: {setSIG, true}, - TypeRKEY: {setRKEY, true}, - TypeRP: {setRP, false}, - TypeRRSIG: {setRRSIG, true}, - TypeRT: {setRT, false}, - TypeSOA: {setSOA, false}, - TypeSPF: {setSPF, true}, - TypeSRV: {setSRV, false}, - TypeSSHFP: {setSSHFP, true}, - TypeTALINK: {setTALINK, false}, - TypeTA: {setTA, true}, - TypeTLSA: {setTLSA, true}, - TypeTXT: {setTXT, true}, - TypeUID: {setUID, false}, - TypeUINFO: {setUINFO, true}, - TypeURI: {setURI, true}, - TypeX25: {setX25, false}, -} diff --git a/vendor/github.com/miekg/dns/scanner.go b/vendor/github.com/miekg/dns/scanner.go deleted file mode 100644 index c29bc2f..0000000 --- a/vendor/github.com/miekg/dns/scanner.go +++ /dev/null @@ -1,43 +0,0 @@ -package dns - -// Implement a simple scanner, return a byte stream from an io reader. - -import ( - "bufio" - "io" - "text/scanner" -) - -type scan struct { - src *bufio.Reader - position scanner.Position - eof bool // Have we just seen a eof -} - -func scanInit(r io.Reader) *scan { - s := new(scan) - s.src = bufio.NewReader(r) - s.position.Line = 1 - return s -} - -// tokenText returns the next byte from the input -func (s *scan) tokenText() (byte, error) { - c, err := s.src.ReadByte() - if err != nil { - return c, err - } - // delay the newline handling until the next token is delivered, - // fixes off-by-one errors when reporting a parse error. - if s.eof == true { - s.position.Line++ - s.position.Column = 0 - s.eof = false - } - if c == '\n' { - s.eof = true - return c, nil - } - s.position.Column++ - return c, nil -} diff --git a/vendor/github.com/miekg/dns/server.go b/vendor/github.com/miekg/dns/server.go deleted file mode 100644 index 2b4bff4..0000000 --- a/vendor/github.com/miekg/dns/server.go +++ /dev/null @@ -1,732 +0,0 @@ -// DNS server implementation. - -package dns - -import ( - "bytes" - "crypto/tls" - "encoding/binary" - "io" - "net" - "sync" - "time" -) - -// Maximum number of TCP queries before we close the socket. -const maxTCPQueries = 128 - -// Handler is implemented by any value that implements ServeDNS. -type Handler interface { - ServeDNS(w ResponseWriter, r *Msg) -} - -// A ResponseWriter interface is used by an DNS handler to -// construct an DNS response. -type ResponseWriter interface { - // LocalAddr returns the net.Addr of the server - LocalAddr() net.Addr - // RemoteAddr returns the net.Addr of the client that sent the current request. - RemoteAddr() net.Addr - // WriteMsg writes a reply back to the client. - WriteMsg(*Msg) error - // Write writes a raw buffer back to the client. - Write([]byte) (int, error) - // Close closes the connection. - Close() error - // TsigStatus returns the status of the Tsig. - TsigStatus() error - // TsigTimersOnly sets the tsig timers only boolean. - TsigTimersOnly(bool) - // Hijack lets the caller take over the connection. - // After a call to Hijack(), the DNS package will not do anything with the connection. - Hijack() -} - -type response struct { - hijacked bool // connection has been hijacked by handler - tsigStatus error - tsigTimersOnly bool - tsigRequestMAC string - tsigSecret map[string]string // the tsig secrets - udp *net.UDPConn // i/o connection if UDP was used - tcp net.Conn // i/o connection if TCP was used - udpSession *SessionUDP // oob data to get egress interface right - remoteAddr net.Addr // address of the client - writer Writer // writer to output the raw DNS bits -} - -// ServeMux is an DNS request multiplexer. It matches the -// zone name of each incoming request against a list of -// registered patterns add calls the handler for the pattern -// that most closely matches the zone name. ServeMux is DNSSEC aware, meaning -// that queries for the DS record are redirected to the parent zone (if that -// is also registered), otherwise the child gets the query. -// ServeMux is also safe for concurrent access from multiple goroutines. -type ServeMux struct { - z map[string]Handler - m *sync.RWMutex -} - -// NewServeMux allocates and returns a new ServeMux. -func NewServeMux() *ServeMux { return &ServeMux{z: make(map[string]Handler), m: new(sync.RWMutex)} } - -// DefaultServeMux is the default ServeMux used by Serve. -var DefaultServeMux = NewServeMux() - -// The HandlerFunc type is an adapter to allow the use of -// ordinary functions as DNS handlers. If f is a function -// with the appropriate signature, HandlerFunc(f) is a -// Handler object that calls f. -type HandlerFunc func(ResponseWriter, *Msg) - -// ServeDNS calls f(w, r). -func (f HandlerFunc) ServeDNS(w ResponseWriter, r *Msg) { - f(w, r) -} - -// HandleFailed returns a HandlerFunc that returns SERVFAIL for every request it gets. -func HandleFailed(w ResponseWriter, r *Msg) { - m := new(Msg) - m.SetRcode(r, RcodeServerFailure) - // does not matter if this write fails - w.WriteMsg(m) -} - -func failedHandler() Handler { return HandlerFunc(HandleFailed) } - -// ListenAndServe Starts a server on address and network specified Invoke handler -// for incoming queries. -func ListenAndServe(addr string, network string, handler Handler) error { - server := &Server{Addr: addr, Net: network, Handler: handler} - return server.ListenAndServe() -} - -// ListenAndServeTLS acts like http.ListenAndServeTLS, more information in -// http://golang.org/pkg/net/http/#ListenAndServeTLS -func ListenAndServeTLS(addr, certFile, keyFile string, handler Handler) error { - cert, err := tls.LoadX509KeyPair(certFile, keyFile) - if err != nil { - return err - } - - config := tls.Config{ - Certificates: []tls.Certificate{cert}, - } - - server := &Server{ - Addr: addr, - Net: "tcp-tls", - TLSConfig: &config, - Handler: handler, - } - - return server.ListenAndServe() -} - -// ActivateAndServe activates a server with a listener from systemd, -// l and p should not both be non-nil. -// If both l and p are not nil only p will be used. -// Invoke handler for incoming queries. -func ActivateAndServe(l net.Listener, p net.PacketConn, handler Handler) error { - server := &Server{Listener: l, PacketConn: p, Handler: handler} - return server.ActivateAndServe() -} - -func (mux *ServeMux) match(q string, t uint16) Handler { - mux.m.RLock() - defer mux.m.RUnlock() - var handler Handler - b := make([]byte, len(q)) // worst case, one label of length q - off := 0 - end := false - for { - l := len(q[off:]) - for i := 0; i < l; i++ { - b[i] = q[off+i] - if b[i] >= 'A' && b[i] <= 'Z' { - b[i] |= ('a' - 'A') - } - } - if h, ok := mux.z[string(b[:l])]; ok { // 'causes garbage, might want to change the map key - if t != TypeDS { - return h - } - // Continue for DS to see if we have a parent too, if so delegeate to the parent - handler = h - } - off, end = NextLabel(q, off) - if end { - break - } - } - // Wildcard match, if we have found nothing try the root zone as a last resort. - if h, ok := mux.z["."]; ok { - return h - } - return handler -} - -// Handle adds a handler to the ServeMux for pattern. -func (mux *ServeMux) Handle(pattern string, handler Handler) { - if pattern == "" { - panic("dns: invalid pattern " + pattern) - } - mux.m.Lock() - mux.z[Fqdn(pattern)] = handler - mux.m.Unlock() -} - -// HandleFunc adds a handler function to the ServeMux for pattern. -func (mux *ServeMux) HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { - mux.Handle(pattern, HandlerFunc(handler)) -} - -// HandleRemove deregistrars the handler specific for pattern from the ServeMux. -func (mux *ServeMux) HandleRemove(pattern string) { - if pattern == "" { - panic("dns: invalid pattern " + pattern) - } - mux.m.Lock() - delete(mux.z, Fqdn(pattern)) - mux.m.Unlock() -} - -// ServeDNS dispatches the request to the handler whose -// pattern most closely matches the request message. If DefaultServeMux -// is used the correct thing for DS queries is done: a possible parent -// is sought. -// If no handler is found a standard SERVFAIL message is returned -// If the request message does not have exactly one question in the -// question section a SERVFAIL is returned, unlesss Unsafe is true. -func (mux *ServeMux) ServeDNS(w ResponseWriter, request *Msg) { - var h Handler - if len(request.Question) < 1 { // allow more than one question - h = failedHandler() - } else { - if h = mux.match(request.Question[0].Name, request.Question[0].Qtype); h == nil { - h = failedHandler() - } - } - h.ServeDNS(w, request) -} - -// Handle registers the handler with the given pattern -// in the DefaultServeMux. The documentation for -// ServeMux explains how patterns are matched. -func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) } - -// HandleRemove deregisters the handle with the given pattern -// in the DefaultServeMux. -func HandleRemove(pattern string) { DefaultServeMux.HandleRemove(pattern) } - -// HandleFunc registers the handler function with the given pattern -// in the DefaultServeMux. -func HandleFunc(pattern string, handler func(ResponseWriter, *Msg)) { - DefaultServeMux.HandleFunc(pattern, handler) -} - -// Writer writes raw DNS messages; each call to Write should send an entire message. -type Writer interface { - io.Writer -} - -// Reader reads raw DNS messages; each call to ReadTCP or ReadUDP should return an entire message. -type Reader interface { - // ReadTCP reads a raw message from a TCP connection. Implementations may alter - // connection properties, for example the read-deadline. - ReadTCP(conn net.Conn, timeout time.Duration) ([]byte, error) - // ReadUDP reads a raw message from a UDP connection. Implementations may alter - // connection properties, for example the read-deadline. - ReadUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error) -} - -// defaultReader is an adapter for the Server struct that implements the Reader interface -// using the readTCP and readUDP func of the embedded Server. -type defaultReader struct { - *Server -} - -func (dr *defaultReader) ReadTCP(conn net.Conn, timeout time.Duration) ([]byte, error) { - return dr.readTCP(conn, timeout) -} - -func (dr *defaultReader) ReadUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error) { - return dr.readUDP(conn, timeout) -} - -// DecorateReader is a decorator hook for extending or supplanting the functionality of a Reader. -// Implementations should never return a nil Reader. -type DecorateReader func(Reader) Reader - -// DecorateWriter is a decorator hook for extending or supplanting the functionality of a Writer. -// Implementations should never return a nil Writer. -type DecorateWriter func(Writer) Writer - -// A Server defines parameters for running an DNS server. -type Server struct { - // Address to listen on, ":dns" if empty. - Addr string - // if "tcp" or "tcp-tls" (DNS over TLS) it will invoke a TCP listener, otherwise an UDP one - Net string - // TCP Listener to use, this is to aid in systemd's socket activation. - Listener net.Listener - // TLS connection configuration - TLSConfig *tls.Config - // UDP "Listener" to use, this is to aid in systemd's socket activation. - PacketConn net.PacketConn - // Handler to invoke, dns.DefaultServeMux if nil. - Handler Handler - // Default buffer size to use to read incoming UDP messages. If not set - // it defaults to MinMsgSize (512 B). - UDPSize int - // The net.Conn.SetReadTimeout value for new connections, defaults to 2 * time.Second. - ReadTimeout time.Duration - // The net.Conn.SetWriteTimeout value for new connections, defaults to 2 * time.Second. - WriteTimeout time.Duration - // TCP idle timeout for multiple queries, if nil, defaults to 8 * time.Second (RFC 5966). - IdleTimeout func() time.Duration - // Secret(s) for Tsig map[]. - TsigSecret map[string]string - // Unsafe instructs the server to disregard any sanity checks and directly hand the message to - // the handler. It will specifically not check if the query has the QR bit not set. - Unsafe bool - // If NotifyStartedFunc is set it is called once the server has started listening. - NotifyStartedFunc func() - // DecorateReader is optional, allows customization of the process that reads raw DNS messages. - DecorateReader DecorateReader - // DecorateWriter is optional, allows customization of the process that writes raw DNS messages. - DecorateWriter DecorateWriter - - // Graceful shutdown handling - - inFlight sync.WaitGroup - - lock sync.RWMutex - started bool -} - -// ListenAndServe starts a nameserver on the configured address in *Server. -func (srv *Server) ListenAndServe() error { - srv.lock.Lock() - defer srv.lock.Unlock() - if srv.started { - return &Error{err: "server already started"} - } - addr := srv.Addr - if addr == "" { - addr = ":domain" - } - if srv.UDPSize == 0 { - srv.UDPSize = MinMsgSize - } - switch srv.Net { - case "tcp", "tcp4", "tcp6": - a, err := net.ResolveTCPAddr(srv.Net, addr) - if err != nil { - return err - } - l, err := net.ListenTCP(srv.Net, a) - if err != nil { - return err - } - srv.Listener = l - srv.started = true - srv.lock.Unlock() - err = srv.serveTCP(l) - srv.lock.Lock() // to satisfy the defer at the top - return err - case "tcp-tls", "tcp4-tls", "tcp6-tls": - network := "tcp" - if srv.Net == "tcp4-tls" { - network = "tcp4" - } else if srv.Net == "tcp6" { - network = "tcp6" - } - - l, err := tls.Listen(network, addr, srv.TLSConfig) - if err != nil { - return err - } - srv.Listener = l - srv.started = true - srv.lock.Unlock() - err = srv.serveTCP(l) - srv.lock.Lock() // to satisfy the defer at the top - return err - case "udp", "udp4", "udp6": - a, err := net.ResolveUDPAddr(srv.Net, addr) - if err != nil { - return err - } - l, err := net.ListenUDP(srv.Net, a) - if err != nil { - return err - } - if e := setUDPSocketOptions(l); e != nil { - return e - } - srv.PacketConn = l - srv.started = true - srv.lock.Unlock() - err = srv.serveUDP(l) - srv.lock.Lock() // to satisfy the defer at the top - return err - } - return &Error{err: "bad network"} -} - -// ActivateAndServe starts a nameserver with the PacketConn or Listener -// configured in *Server. Its main use is to start a server from systemd. -func (srv *Server) ActivateAndServe() error { - srv.lock.Lock() - defer srv.lock.Unlock() - if srv.started { - return &Error{err: "server already started"} - } - pConn := srv.PacketConn - l := srv.Listener - if pConn != nil { - if srv.UDPSize == 0 { - srv.UDPSize = MinMsgSize - } - if t, ok := pConn.(*net.UDPConn); ok { - if e := setUDPSocketOptions(t); e != nil { - return e - } - srv.started = true - srv.lock.Unlock() - e := srv.serveUDP(t) - srv.lock.Lock() // to satisfy the defer at the top - return e - } - } - if l != nil { - srv.started = true - srv.lock.Unlock() - e := srv.serveTCP(l) - srv.lock.Lock() // to satisfy the defer at the top - return e - } - return &Error{err: "bad listeners"} -} - -// Shutdown gracefully shuts down a server. After a call to Shutdown, ListenAndServe and -// ActivateAndServe will return. All in progress queries are completed before the server -// is taken down. If the Shutdown is taking longer than the reading timeout an error -// is returned. -func (srv *Server) Shutdown() error { - srv.lock.Lock() - if !srv.started { - srv.lock.Unlock() - return &Error{err: "server not started"} - } - srv.started = false - srv.lock.Unlock() - - if srv.PacketConn != nil { - srv.PacketConn.Close() - } - if srv.Listener != nil { - srv.Listener.Close() - } - - fin := make(chan bool) - go func() { - srv.inFlight.Wait() - fin <- true - }() - - select { - case <-time.After(srv.getReadTimeout()): - return &Error{err: "server shutdown is pending"} - case <-fin: - return nil - } -} - -// getReadTimeout is a helper func to use system timeout if server did not intend to change it. -func (srv *Server) getReadTimeout() time.Duration { - rtimeout := dnsTimeout - if srv.ReadTimeout != 0 { - rtimeout = srv.ReadTimeout - } - return rtimeout -} - -// serveTCP starts a TCP listener for the server. -// Each request is handled in a separate goroutine. -func (srv *Server) serveTCP(l net.Listener) error { - defer l.Close() - - if srv.NotifyStartedFunc != nil { - srv.NotifyStartedFunc() - } - - reader := Reader(&defaultReader{srv}) - if srv.DecorateReader != nil { - reader = srv.DecorateReader(reader) - } - - handler := srv.Handler - if handler == nil { - handler = DefaultServeMux - } - rtimeout := srv.getReadTimeout() - // deadline is not used here - for { - rw, err := l.Accept() - if err != nil { - if neterr, ok := err.(net.Error); ok && neterr.Temporary() { - continue - } - return err - } - m, err := reader.ReadTCP(rw, rtimeout) - srv.lock.RLock() - if !srv.started { - srv.lock.RUnlock() - return nil - } - srv.lock.RUnlock() - if err != nil { - continue - } - srv.inFlight.Add(1) - go srv.serve(rw.RemoteAddr(), handler, m, nil, nil, rw) - } -} - -// serveUDP starts a UDP listener for the server. -// Each request is handled in a separate goroutine. -func (srv *Server) serveUDP(l *net.UDPConn) error { - defer l.Close() - - if srv.NotifyStartedFunc != nil { - srv.NotifyStartedFunc() - } - - reader := Reader(&defaultReader{srv}) - if srv.DecorateReader != nil { - reader = srv.DecorateReader(reader) - } - - handler := srv.Handler - if handler == nil { - handler = DefaultServeMux - } - rtimeout := srv.getReadTimeout() - // deadline is not used here - for { - m, s, err := reader.ReadUDP(l, rtimeout) - srv.lock.RLock() - if !srv.started { - srv.lock.RUnlock() - return nil - } - srv.lock.RUnlock() - if err != nil { - continue - } - srv.inFlight.Add(1) - go srv.serve(s.RemoteAddr(), handler, m, l, s, nil) - } -} - -// Serve a new connection. -func (srv *Server) serve(a net.Addr, h Handler, m []byte, u *net.UDPConn, s *SessionUDP, t net.Conn) { - defer srv.inFlight.Done() - - w := &response{tsigSecret: srv.TsigSecret, udp: u, tcp: t, remoteAddr: a, udpSession: s} - if srv.DecorateWriter != nil { - w.writer = srv.DecorateWriter(w) - } else { - w.writer = w - } - - q := 0 // counter for the amount of TCP queries we get - - reader := Reader(&defaultReader{srv}) - if srv.DecorateReader != nil { - reader = srv.DecorateReader(reader) - } -Redo: - req := new(Msg) - err := req.Unpack(m) - if err != nil { // Send a FormatError back - x := new(Msg) - x.SetRcodeFormatError(req) - w.WriteMsg(x) - goto Exit - } - if !srv.Unsafe && req.Response { - goto Exit - } - - w.tsigStatus = nil - if w.tsigSecret != nil { - if t := req.IsTsig(); t != nil { - secret := t.Hdr.Name - if _, ok := w.tsigSecret[secret]; !ok { - w.tsigStatus = ErrKeyAlg - } - w.tsigStatus = TsigVerify(m, w.tsigSecret[secret], "", false) - w.tsigTimersOnly = false - w.tsigRequestMAC = req.Extra[len(req.Extra)-1].(*TSIG).MAC - } - } - h.ServeDNS(w, req) // Writes back to the client - -Exit: - if w.tcp == nil { - return - } - // TODO(miek): make this number configurable? - if q > maxTCPQueries { // close socket after this many queries - w.Close() - return - } - - if w.hijacked { - return // client calls Close() - } - if u != nil { // UDP, "close" and return - w.Close() - return - } - idleTimeout := tcpIdleTimeout - if srv.IdleTimeout != nil { - idleTimeout = srv.IdleTimeout() - } - m, err = reader.ReadTCP(w.tcp, idleTimeout) - if err == nil { - q++ - goto Redo - } - w.Close() - return -} - -func (srv *Server) readTCP(conn net.Conn, timeout time.Duration) ([]byte, error) { - conn.SetReadDeadline(time.Now().Add(timeout)) - l := make([]byte, 2) - n, err := conn.Read(l) - if err != nil || n != 2 { - if err != nil { - return nil, err - } - return nil, ErrShortRead - } - length := binary.BigEndian.Uint16(l) - if length == 0 { - return nil, ErrShortRead - } - m := make([]byte, int(length)) - n, err = conn.Read(m[:int(length)]) - if err != nil || n == 0 { - if err != nil { - return nil, err - } - return nil, ErrShortRead - } - i := n - for i < int(length) { - j, err := conn.Read(m[i:int(length)]) - if err != nil { - return nil, err - } - i += j - } - n = i - m = m[:n] - return m, nil -} - -func (srv *Server) readUDP(conn *net.UDPConn, timeout time.Duration) ([]byte, *SessionUDP, error) { - conn.SetReadDeadline(time.Now().Add(timeout)) - m := make([]byte, srv.UDPSize) - n, s, err := ReadFromSessionUDP(conn, m) - if err != nil || n == 0 { - if err != nil { - return nil, nil, err - } - return nil, nil, ErrShortRead - } - m = m[:n] - return m, s, nil -} - -// WriteMsg implements the ResponseWriter.WriteMsg method. -func (w *response) WriteMsg(m *Msg) (err error) { - var data []byte - if w.tsigSecret != nil { // if no secrets, dont check for the tsig (which is a longer check) - if t := m.IsTsig(); t != nil { - data, w.tsigRequestMAC, err = TsigGenerate(m, w.tsigSecret[t.Hdr.Name], w.tsigRequestMAC, w.tsigTimersOnly) - if err != nil { - return err - } - _, err = w.writer.Write(data) - return err - } - } - data, err = m.Pack() - if err != nil { - return err - } - _, err = w.writer.Write(data) - return err -} - -// Write implements the ResponseWriter.Write method. -func (w *response) Write(m []byte) (int, error) { - switch { - case w.udp != nil: - n, err := WriteToSessionUDP(w.udp, m, w.udpSession) - return n, err - case w.tcp != nil: - lm := len(m) - if lm < 2 { - return 0, io.ErrShortBuffer - } - if lm > MaxMsgSize { - return 0, &Error{err: "message too large"} - } - l := make([]byte, 2, 2+lm) - binary.BigEndian.PutUint16(l, uint16(lm)) - m = append(l, m...) - - n, err := io.Copy(w.tcp, bytes.NewReader(m)) - return int(n), err - } - panic("not reached") -} - -// LocalAddr implements the ResponseWriter.LocalAddr method. -func (w *response) LocalAddr() net.Addr { - if w.tcp != nil { - return w.tcp.LocalAddr() - } - return w.udp.LocalAddr() -} - -// RemoteAddr implements the ResponseWriter.RemoteAddr method. -func (w *response) RemoteAddr() net.Addr { return w.remoteAddr } - -// TsigStatus implements the ResponseWriter.TsigStatus method. -func (w *response) TsigStatus() error { return w.tsigStatus } - -// TsigTimersOnly implements the ResponseWriter.TsigTimersOnly method. -func (w *response) TsigTimersOnly(b bool) { w.tsigTimersOnly = b } - -// Hijack implements the ResponseWriter.Hijack method. -func (w *response) Hijack() { w.hijacked = true } - -// Close implements the ResponseWriter.Close method -func (w *response) Close() error { - // Can't close the udp conn, as that is actually the listener. - if w.tcp != nil { - e := w.tcp.Close() - w.tcp = nil - return e - } - return nil -} diff --git a/vendor/github.com/miekg/dns/server_test.go b/vendor/github.com/miekg/dns/server_test.go deleted file mode 100644 index 1b5cbc9..0000000 --- a/vendor/github.com/miekg/dns/server_test.go +++ /dev/null @@ -1,679 +0,0 @@ -package dns - -import ( - "crypto/tls" - "fmt" - "io" - "net" - "runtime" - "sync" - "testing" - "time" -) - -func HelloServer(w ResponseWriter, req *Msg) { - m := new(Msg) - m.SetReply(req) - - m.Extra = make([]RR, 1) - m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} - w.WriteMsg(m) -} - -func HelloServerBadId(w ResponseWriter, req *Msg) { - m := new(Msg) - m.SetReply(req) - m.Id++ - - m.Extra = make([]RR, 1) - m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} - w.WriteMsg(m) -} - -func AnotherHelloServer(w ResponseWriter, req *Msg) { - m := new(Msg) - m.SetReply(req) - - m.Extra = make([]RR, 1) - m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello example"}} - w.WriteMsg(m) -} - -func RunLocalUDPServer(laddr string) (*Server, string, error) { - server, l, _, err := RunLocalUDPServerWithFinChan(laddr) - - return server, l, err -} - -func RunLocalUDPServerWithFinChan(laddr string) (*Server, string, chan struct{}, error) { - pc, err := net.ListenPacket("udp", laddr) - if err != nil { - return nil, "", nil, err - } - server := &Server{PacketConn: pc, ReadTimeout: time.Hour, WriteTimeout: time.Hour} - - waitLock := sync.Mutex{} - waitLock.Lock() - server.NotifyStartedFunc = waitLock.Unlock - - fin := make(chan struct{}, 0) - - go func() { - server.ActivateAndServe() - close(fin) - pc.Close() - }() - - waitLock.Lock() - return server, pc.LocalAddr().String(), fin, nil -} - -func RunLocalUDPServerUnsafe(laddr string) (*Server, string, error) { - pc, err := net.ListenPacket("udp", laddr) - if err != nil { - return nil, "", err - } - server := &Server{PacketConn: pc, Unsafe: true, - ReadTimeout: time.Hour, WriteTimeout: time.Hour} - - waitLock := sync.Mutex{} - waitLock.Lock() - server.NotifyStartedFunc = waitLock.Unlock - - go func() { - server.ActivateAndServe() - pc.Close() - }() - - waitLock.Lock() - return server, pc.LocalAddr().String(), nil -} - -func RunLocalTCPServer(laddr string) (*Server, string, error) { - l, err := net.Listen("tcp", laddr) - if err != nil { - return nil, "", err - } - - server := &Server{Listener: l, ReadTimeout: time.Hour, WriteTimeout: time.Hour} - - waitLock := sync.Mutex{} - waitLock.Lock() - server.NotifyStartedFunc = waitLock.Unlock - - go func() { - server.ActivateAndServe() - l.Close() - }() - - waitLock.Lock() - return server, l.Addr().String(), nil -} - -func RunLocalTLSServer(laddr string, config *tls.Config) (*Server, string, error) { - l, err := tls.Listen("tcp", laddr, config) - if err != nil { - return nil, "", err - } - - server := &Server{Listener: l, ReadTimeout: time.Hour, WriteTimeout: time.Hour} - - waitLock := sync.Mutex{} - waitLock.Lock() - server.NotifyStartedFunc = waitLock.Unlock - - go func() { - server.ActivateAndServe() - l.Close() - }() - - waitLock.Lock() - return server, l.Addr().String(), nil -} - -func TestServing(t *testing.T) { - HandleFunc("miek.nl.", HelloServer) - HandleFunc("example.com.", AnotherHelloServer) - defer HandleRemove("miek.nl.") - defer HandleRemove("example.com.") - - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - c := new(Client) - m := new(Msg) - m.SetQuestion("miek.nl.", TypeTXT) - r, _, err := c.Exchange(m, addrstr) - if err != nil || len(r.Extra) == 0 { - t.Fatal("failed to exchange miek.nl", err) - } - txt := r.Extra[0].(*TXT).Txt[0] - if txt != "Hello world" { - t.Error("unexpected result for miek.nl", txt, "!= Hello world") - } - - m.SetQuestion("example.com.", TypeTXT) - r, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Fatal("failed to exchange example.com", err) - } - txt = r.Extra[0].(*TXT).Txt[0] - if txt != "Hello example" { - t.Error("unexpected result for example.com", txt, "!= Hello example") - } - - // Test Mixes cased as noticed by Ask. - m.SetQuestion("eXaMplE.cOm.", TypeTXT) - r, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Error("failed to exchange eXaMplE.cOm", err) - } - txt = r.Extra[0].(*TXT).Txt[0] - if txt != "Hello example" { - t.Error("unexpected result for example.com", txt, "!= Hello example") - } -} - -func TestServingTLS(t *testing.T) { - HandleFunc("miek.nl.", HelloServer) - HandleFunc("example.com.", AnotherHelloServer) - defer HandleRemove("miek.nl.") - defer HandleRemove("example.com.") - - cert, err := tls.X509KeyPair(CertPEMBlock, KeyPEMBlock) - if err != nil { - t.Fatalf("unable to build certificate: %v", err) - } - - config := tls.Config{ - Certificates: []tls.Certificate{cert}, - } - - s, addrstr, err := RunLocalTLSServer("127.0.0.1:0", &config) - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - c := new(Client) - c.Net = "tcp-tls" - c.TLSConfig = &tls.Config{ - InsecureSkipVerify: true, - } - - m := new(Msg) - m.SetQuestion("miek.nl.", TypeTXT) - r, _, err := c.Exchange(m, addrstr) - if err != nil || len(r.Extra) == 0 { - t.Fatal("failed to exchange miek.nl", err) - } - txt := r.Extra[0].(*TXT).Txt[0] - if txt != "Hello world" { - t.Error("unexpected result for miek.nl", txt, "!= Hello world") - } - - m.SetQuestion("example.com.", TypeTXT) - r, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Fatal("failed to exchange example.com", err) - } - txt = r.Extra[0].(*TXT).Txt[0] - if txt != "Hello example" { - t.Error("unexpected result for example.com", txt, "!= Hello example") - } - - // Test Mixes cased as noticed by Ask. - m.SetQuestion("eXaMplE.cOm.", TypeTXT) - r, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Error("failed to exchange eXaMplE.cOm", err) - } - txt = r.Extra[0].(*TXT).Txt[0] - if txt != "Hello example" { - t.Error("unexpected result for example.com", txt, "!= Hello example") - } -} - -func BenchmarkServe(b *testing.B) { - b.StopTimer() - HandleFunc("miek.nl.", HelloServer) - defer HandleRemove("miek.nl.") - a := runtime.GOMAXPROCS(4) - - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - b.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - c := new(Client) - m := new(Msg) - m.SetQuestion("miek.nl", TypeSOA) - - b.StartTimer() - for i := 0; i < b.N; i++ { - c.Exchange(m, addrstr) - } - runtime.GOMAXPROCS(a) -} - -func benchmarkServe6(b *testing.B) { - b.StopTimer() - HandleFunc("miek.nl.", HelloServer) - defer HandleRemove("miek.nl.") - a := runtime.GOMAXPROCS(4) - s, addrstr, err := RunLocalUDPServer("[::1]:0") - if err != nil { - b.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - c := new(Client) - m := new(Msg) - m.SetQuestion("miek.nl", TypeSOA) - - b.StartTimer() - for i := 0; i < b.N; i++ { - c.Exchange(m, addrstr) - } - runtime.GOMAXPROCS(a) -} - -func HelloServerCompress(w ResponseWriter, req *Msg) { - m := new(Msg) - m.SetReply(req) - m.Extra = make([]RR, 1) - m.Extra[0] = &TXT{Hdr: RR_Header{Name: m.Question[0].Name, Rrtype: TypeTXT, Class: ClassINET, Ttl: 0}, Txt: []string{"Hello world"}} - m.Compress = true - w.WriteMsg(m) -} - -func BenchmarkServeCompress(b *testing.B) { - b.StopTimer() - HandleFunc("miek.nl.", HelloServerCompress) - defer HandleRemove("miek.nl.") - a := runtime.GOMAXPROCS(4) - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - b.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - c := new(Client) - m := new(Msg) - m.SetQuestion("miek.nl", TypeSOA) - b.StartTimer() - for i := 0; i < b.N; i++ { - c.Exchange(m, addrstr) - } - runtime.GOMAXPROCS(a) -} - -func TestDotAsCatchAllWildcard(t *testing.T) { - mux := NewServeMux() - mux.Handle(".", HandlerFunc(HelloServer)) - mux.Handle("example.com.", HandlerFunc(AnotherHelloServer)) - - handler := mux.match("www.miek.nl.", TypeTXT) - if handler == nil { - t.Error("wildcard match failed") - } - - handler = mux.match("www.example.com.", TypeTXT) - if handler == nil { - t.Error("example.com match failed") - } - - handler = mux.match("a.www.example.com.", TypeTXT) - if handler == nil { - t.Error("a.www.example.com match failed") - } - - handler = mux.match("boe.", TypeTXT) - if handler == nil { - t.Error("boe. match failed") - } -} - -func TestCaseFolding(t *testing.T) { - mux := NewServeMux() - mux.Handle("_udp.example.com.", HandlerFunc(HelloServer)) - - handler := mux.match("_dns._udp.example.com.", TypeSRV) - if handler == nil { - t.Error("case sensitive characters folded") - } - - handler = mux.match("_DNS._UDP.EXAMPLE.COM.", TypeSRV) - if handler == nil { - t.Error("case insensitive characters not folded") - } -} - -func TestRootServer(t *testing.T) { - mux := NewServeMux() - mux.Handle(".", HandlerFunc(HelloServer)) - - handler := mux.match(".", TypeNS) - if handler == nil { - t.Error("root match failed") - } -} - -type maxRec struct { - max int - sync.RWMutex -} - -var M = new(maxRec) - -func HelloServerLargeResponse(resp ResponseWriter, req *Msg) { - m := new(Msg) - m.SetReply(req) - m.Authoritative = true - m1 := 0 - M.RLock() - m1 = M.max - M.RUnlock() - for i := 0; i < m1; i++ { - aRec := &A{ - Hdr: RR_Header{ - Name: req.Question[0].Name, - Rrtype: TypeA, - Class: ClassINET, - Ttl: 0, - }, - A: net.ParseIP(fmt.Sprintf("127.0.0.%d", i+1)).To4(), - } - m.Answer = append(m.Answer, aRec) - } - resp.WriteMsg(m) -} - -func TestServingLargeResponses(t *testing.T) { - HandleFunc("example.", HelloServerLargeResponse) - defer HandleRemove("example.") - - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - // Create request - m := new(Msg) - m.SetQuestion("web.service.example.", TypeANY) - - c := new(Client) - c.Net = "udp" - M.Lock() - M.max = 2 - M.Unlock() - _, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } - // This must fail - M.Lock() - M.max = 20 - M.Unlock() - _, _, err = c.Exchange(m, addrstr) - if err == nil { - t.Error("failed to fail exchange, this should generate packet error") - } - // But this must work again - c.UDPSize = 7000 - _, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Errorf("failed to exchange: %v", err) - } -} - -func TestServingResponse(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } - HandleFunc("miek.nl.", HelloServer) - s, addrstr, err := RunLocalUDPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - - c := new(Client) - m := new(Msg) - m.SetQuestion("miek.nl.", TypeTXT) - m.Response = false - _, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Fatal("failed to exchange", err) - } - m.Response = true - _, _, err = c.Exchange(m, addrstr) - if err == nil { - t.Fatal("exchanged response message") - } - - s.Shutdown() - s, addrstr, err = RunLocalUDPServerUnsafe("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - defer s.Shutdown() - - m.Response = true - _, _, err = c.Exchange(m, addrstr) - if err != nil { - t.Fatal("could exchanged response message in Unsafe mode") - } -} - -func TestShutdownTCP(t *testing.T) { - s, _, err := RunLocalTCPServer("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - err = s.Shutdown() - if err != nil { - t.Errorf("could not shutdown test TCP server, %v", err) - } -} - -func TestShutdownTLS(t *testing.T) { - cert, err := tls.X509KeyPair(CertPEMBlock, KeyPEMBlock) - if err != nil { - t.Fatalf("unable to build certificate: %v", err) - } - - config := tls.Config{ - Certificates: []tls.Certificate{cert}, - } - - s, _, err := RunLocalTLSServer("127.0.0.1:0", &config) - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - err = s.Shutdown() - if err != nil { - t.Errorf("could not shutdown test TLS server, %v", err) - } -} - -type trigger struct { - done bool - sync.RWMutex -} - -func (t *trigger) Set() { - t.Lock() - defer t.Unlock() - t.done = true -} -func (t *trigger) Get() bool { - t.RLock() - defer t.RUnlock() - return t.done -} - -func TestHandlerCloseTCP(t *testing.T) { - - ln, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - panic(err) - } - addr := ln.Addr().String() - - server := &Server{Addr: addr, Net: "tcp", Listener: ln} - - hname := "testhandlerclosetcp." - triggered := &trigger{} - HandleFunc(hname, func(w ResponseWriter, r *Msg) { - triggered.Set() - w.Close() - }) - defer HandleRemove(hname) - - go func() { - defer server.Shutdown() - c := &Client{Net: "tcp"} - m := new(Msg).SetQuestion(hname, 1) - tries := 0 - exchange: - _, _, err := c.Exchange(m, addr) - if err != nil && err != io.EOF { - t.Logf("exchange failed: %s\n", err) - if tries == 3 { - return - } - time.Sleep(time.Second / 10) - tries += 1 - goto exchange - } - }() - server.ActivateAndServe() - if !triggered.Get() { - t.Fatalf("handler never called") - } -} - -func TestShutdownUDP(t *testing.T) { - s, _, fin, err := RunLocalUDPServerWithFinChan("127.0.0.1:0") - if err != nil { - t.Fatalf("unable to run test server: %v", err) - } - err = s.Shutdown() - if err != nil { - t.Errorf("could not shutdown test UDP server, %v", err) - } - select { - case <-fin: - case <-time.After(2 * time.Second): - t.Error("Could not shutdown test UDP server. Gave up waiting") - } -} - -type ExampleFrameLengthWriter struct { - Writer -} - -func (e *ExampleFrameLengthWriter) Write(m []byte) (int, error) { - fmt.Println("writing raw DNS message of length", len(m)) - return e.Writer.Write(m) -} - -func ExampleDecorateWriter() { - // instrument raw DNS message writing - wf := DecorateWriter(func(w Writer) Writer { - return &ExampleFrameLengthWriter{w} - }) - - // simple UDP server - pc, err := net.ListenPacket("udp", "127.0.0.1:0") - if err != nil { - fmt.Println(err.Error()) - return - } - server := &Server{ - PacketConn: pc, - DecorateWriter: wf, - ReadTimeout: time.Hour, WriteTimeout: time.Hour, - } - - waitLock := sync.Mutex{} - waitLock.Lock() - server.NotifyStartedFunc = waitLock.Unlock - defer server.Shutdown() - - go func() { - server.ActivateAndServe() - pc.Close() - }() - - waitLock.Lock() - - HandleFunc("miek.nl.", HelloServer) - - c := new(Client) - m := new(Msg) - m.SetQuestion("miek.nl.", TypeTXT) - _, _, err = c.Exchange(m, pc.LocalAddr().String()) - if err != nil { - fmt.Println("failed to exchange", err.Error()) - return - } - // Output: writing raw DNS message of length 56 -} - -var ( - // CertPEMBlock is a X509 data used to test TLS servers (used with tls.X509KeyPair) - CertPEMBlock = []byte(`-----BEGIN CERTIFICATE----- -MIIDAzCCAeugAwIBAgIRAJFYMkcn+b8dpU15wjf++GgwDQYJKoZIhvcNAQELBQAw -EjEQMA4GA1UEChMHQWNtZSBDbzAeFw0xNjAxMDgxMjAzNTNaFw0xNzAxMDcxMjAz -NTNaMBIxEDAOBgNVBAoTB0FjbWUgQ28wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw -ggEKAoIBAQDXjqO6skvP03k58CNjQggd9G/mt+Wa+xRU+WXiKCCHttawM8x+slq5 -yfsHCwxlwsGn79HmJqecNqgHb2GWBXAvVVokFDTcC1hUP4+gp2gu9Ny27UHTjlLm -O0l/xZ5MN8tfKyYlFw18tXu3fkaPyHj8v/D1RDkuo4ARdFvGSe8TqisbhLk2+9ow -xfIGbEM9Fdiw8qByC2+d+FfvzIKz3GfQVwn0VoRom8L6NBIANq1IGrB5JefZB6nv -DnfuxkBmY7F1513HKuEJ8KsLWWZWV9OPU4j4I4Rt+WJNlKjbD2srHxyrS2RDsr91 -8nCkNoWVNO3sZq0XkWKecdc921vL4ginAgMBAAGjVDBSMA4GA1UdDwEB/wQEAwIC -pDATBgNVHSUEDDAKBggrBgEFBQcDATAPBgNVHRMBAf8EBTADAQH/MBoGA1UdEQQT -MBGCCWxvY2FsaG9zdIcEfwAAATANBgkqhkiG9w0BAQsFAAOCAQEAGcU3iyLBIVZj -aDzSvEDHUd1bnLBl1C58Xu/CyKlPqVU7mLfK0JcgEaYQTSX6fCJVNLbbCrcGLsPJ -fbjlBbyeLjTV413fxPVuona62pBFjqdtbli2Qe8FRH2KBdm41JUJGdo+SdsFu7nc -BFOcubdw6LLIXvsTvwndKcHWx1rMX709QU1Vn1GAIsbJV/DWI231Jyyb+lxAUx/C -8vce5uVxiKcGS+g6OjsN3D3TtiEQGSXLh013W6Wsih8td8yMCMZ3w8LQ38br1GUe -ahLIgUJ9l6HDguM17R7kGqxNvbElsMUHfTtXXP7UDQUiYXDakg8xDP6n9DCDhJ8Y -bSt7OLB7NQ== ------END CERTIFICATE-----`) - - // KeyPEMBlock is a X509 data used to test TLS servers (used with tls.X509KeyPair) - KeyPEMBlock = []byte(`-----BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEA146jurJLz9N5OfAjY0IIHfRv5rflmvsUVPll4iggh7bWsDPM -frJaucn7BwsMZcLBp+/R5iannDaoB29hlgVwL1VaJBQ03AtYVD+PoKdoLvTctu1B -045S5jtJf8WeTDfLXysmJRcNfLV7t35Gj8h4/L/w9UQ5LqOAEXRbxknvE6orG4S5 -NvvaMMXyBmxDPRXYsPKgcgtvnfhX78yCs9xn0FcJ9FaEaJvC+jQSADatSBqweSXn -2Qep7w537sZAZmOxdeddxyrhCfCrC1lmVlfTj1OI+COEbfliTZSo2w9rKx8cq0tk -Q7K/dfJwpDaFlTTt7GatF5FinnHXPdtby+IIpwIDAQABAoIBAAJK4RDmPooqTJrC -JA41MJLo+5uvjwCT9QZmVKAQHzByUFw1YNJkITTiognUI0CdzqNzmH7jIFs39ZeG -proKusO2G6xQjrNcZ4cV2fgyb5g4QHStl0qhs94A+WojduiGm2IaumAgm6Mc5wDv -ld6HmknN3Mku/ZCyanVFEIjOVn2WB7ZQLTBs6ZYaebTJG2Xv6p9t2YJW7pPQ9Xce -s9ohAWohyM4X/OvfnfnLtQp2YLw/BxwehBsCR5SXM3ibTKpFNtxJC8hIfTuWtxZu -2ywrmXShYBRB1WgtZt5k04bY/HFncvvcHK3YfI1+w4URKtwdaQgPUQRbVwDwuyBn -flfkCJECgYEA/eWt01iEyE/lXkGn6V9lCocUU7lCU6yk5UT8VXVUc5If4KZKPfCk -p4zJDOqwn2eM673aWz/mG9mtvAvmnugaGjcaVCyXOp/D/GDmKSoYcvW5B/yjfkLy -dK6Yaa5LDRVYlYgyzcdCT5/9Qc626NzFwKCZNI4ncIU8g7ViATRxWJ8CgYEA2Ver -vZ0M606sfgC0H3NtwNBxmuJ+lIF5LNp/wDi07lDfxRR1rnZMX5dnxjcpDr/zvm8J -WtJJX3xMgqjtHuWKL3yKKony9J5ZPjichSbSbhrzfovgYIRZLxLLDy4MP9L3+CX/ -yBXnqMWuSnFX+M5fVGxdDWiYF3V+wmeOv9JvavkCgYEAiXAPDFzaY+R78O3xiu7M -r0o3wqqCMPE/wav6O/hrYrQy9VSO08C0IM6g9pEEUwWmzuXSkZqhYWoQFb8Lc/GI -T7CMXAxXQLDDUpbRgG79FR3Wr3AewHZU8LyiXHKwxcBMV4WGmsXGK3wbh8fyU1NO -6NsGk+BvkQVOoK1LBAPzZ1kCgYEAsBSmD8U33T9s4dxiEYTrqyV0lH3g/SFz8ZHH -pAyNEPI2iC1ONhyjPWKlcWHpAokiyOqeUpVBWnmSZtzC1qAydsxYB6ShT+sl9BHb -RMix/QAauzBJhQhUVJ3OIys0Q1UBDmqCsjCE8SfOT4NKOUnA093C+YT+iyrmmktZ -zDCJkckCgYEAndqM5KXGk5xYo+MAA1paZcbTUXwaWwjLU+XSRSSoyBEi5xMtfvUb -7+a1OMhLwWbuz+pl64wFKrbSUyimMOYQpjVE/1vk/kb99pxbgol27hdKyTH1d+ov -kFsxKCqxAnBVGEWAvVZAiiTOxleQFjz5RnL0BQp9Lg2cQe+dvuUmIAA= ------END RSA PRIVATE KEY-----`) -) diff --git a/vendor/github.com/miekg/dns/sig0.go b/vendor/github.com/miekg/dns/sig0.go deleted file mode 100644 index 2dce06a..0000000 --- a/vendor/github.com/miekg/dns/sig0.go +++ /dev/null @@ -1,219 +0,0 @@ -package dns - -import ( - "crypto" - "crypto/dsa" - "crypto/ecdsa" - "crypto/rsa" - "encoding/binary" - "math/big" - "strings" - "time" -) - -// Sign signs a dns.Msg. It fills the signature with the appropriate data. -// The SIG record should have the SignerName, KeyTag, Algorithm, Inception -// and Expiration set. -func (rr *SIG) Sign(k crypto.Signer, m *Msg) ([]byte, error) { - if k == nil { - return nil, ErrPrivKey - } - if rr.KeyTag == 0 || len(rr.SignerName) == 0 || rr.Algorithm == 0 { - return nil, ErrKey - } - rr.Header().Rrtype = TypeSIG - rr.Header().Class = ClassANY - rr.Header().Ttl = 0 - rr.Header().Name = "." - rr.OrigTtl = 0 - rr.TypeCovered = 0 - rr.Labels = 0 - - buf := make([]byte, m.Len()+rr.len()) - mbuf, err := m.PackBuffer(buf) - if err != nil { - return nil, err - } - if &buf[0] != &mbuf[0] { - return nil, ErrBuf - } - off, err := PackRR(rr, buf, len(mbuf), nil, false) - if err != nil { - return nil, err - } - buf = buf[:off:cap(buf)] - - hash, ok := AlgorithmToHash[rr.Algorithm] - if !ok { - return nil, ErrAlg - } - - hasher := hash.New() - // Write SIG rdata - hasher.Write(buf[len(mbuf)+1+2+2+4+2:]) - // Write message - hasher.Write(buf[:len(mbuf)]) - - signature, err := sign(k, hasher.Sum(nil), hash, rr.Algorithm) - if err != nil { - return nil, err - } - - rr.Signature = toBase64(signature) - sig := string(signature) - - buf = append(buf, sig...) - if len(buf) > int(^uint16(0)) { - return nil, ErrBuf - } - // Adjust sig data length - rdoff := len(mbuf) + 1 + 2 + 2 + 4 - rdlen := binary.BigEndian.Uint16(buf[rdoff:]) - rdlen += uint16(len(sig)) - binary.BigEndian.PutUint16(buf[rdoff:], rdlen) - // Adjust additional count - adc := binary.BigEndian.Uint16(buf[10:]) - adc++ - binary.BigEndian.PutUint16(buf[10:], adc) - return buf, nil -} - -// Verify validates the message buf using the key k. -// It's assumed that buf is a valid message from which rr was unpacked. -func (rr *SIG) Verify(k *KEY, buf []byte) error { - if k == nil { - return ErrKey - } - if rr.KeyTag == 0 || len(rr.SignerName) == 0 || rr.Algorithm == 0 { - return ErrKey - } - - var hash crypto.Hash - switch rr.Algorithm { - case DSA, RSASHA1: - hash = crypto.SHA1 - case RSASHA256, ECDSAP256SHA256: - hash = crypto.SHA256 - case ECDSAP384SHA384: - hash = crypto.SHA384 - case RSASHA512: - hash = crypto.SHA512 - default: - return ErrAlg - } - hasher := hash.New() - - buflen := len(buf) - qdc := binary.BigEndian.Uint16(buf[4:]) - anc := binary.BigEndian.Uint16(buf[6:]) - auc := binary.BigEndian.Uint16(buf[8:]) - adc := binary.BigEndian.Uint16(buf[10:]) - offset := 12 - var err error - for i := uint16(0); i < qdc && offset < buflen; i++ { - _, offset, err = UnpackDomainName(buf, offset) - if err != nil { - return err - } - // Skip past Type and Class - offset += 2 + 2 - } - for i := uint16(1); i < anc+auc+adc && offset < buflen; i++ { - _, offset, err = UnpackDomainName(buf, offset) - if err != nil { - return err - } - // Skip past Type, Class and TTL - offset += 2 + 2 + 4 - if offset+1 >= buflen { - continue - } - var rdlen uint16 - rdlen = binary.BigEndian.Uint16(buf[offset:]) - offset += 2 - offset += int(rdlen) - } - if offset >= buflen { - return &Error{err: "overflowing unpacking signed message"} - } - - // offset should be just prior to SIG - bodyend := offset - // owner name SHOULD be root - _, offset, err = UnpackDomainName(buf, offset) - if err != nil { - return err - } - // Skip Type, Class, TTL, RDLen - offset += 2 + 2 + 4 + 2 - sigstart := offset - // Skip Type Covered, Algorithm, Labels, Original TTL - offset += 2 + 1 + 1 + 4 - if offset+4+4 >= buflen { - return &Error{err: "overflow unpacking signed message"} - } - expire := binary.BigEndian.Uint32(buf[offset:]) - offset += 4 - incept := binary.BigEndian.Uint32(buf[offset:]) - offset += 4 - now := uint32(time.Now().Unix()) - if now < incept || now > expire { - return ErrTime - } - // Skip key tag - offset += 2 - var signername string - signername, offset, err = UnpackDomainName(buf, offset) - if err != nil { - return err - } - // If key has come from the DNS name compression might - // have mangled the case of the name - if strings.ToLower(signername) != strings.ToLower(k.Header().Name) { - return &Error{err: "signer name doesn't match key name"} - } - sigend := offset - hasher.Write(buf[sigstart:sigend]) - hasher.Write(buf[:10]) - hasher.Write([]byte{ - byte((adc - 1) << 8), - byte(adc - 1), - }) - hasher.Write(buf[12:bodyend]) - - hashed := hasher.Sum(nil) - sig := buf[sigend:] - switch k.Algorithm { - case DSA: - pk := k.publicKeyDSA() - sig = sig[1:] - r := big.NewInt(0) - r.SetBytes(sig[:len(sig)/2]) - s := big.NewInt(0) - s.SetBytes(sig[len(sig)/2:]) - if pk != nil { - if dsa.Verify(pk, hashed, r, s) { - return nil - } - return ErrSig - } - case RSASHA1, RSASHA256, RSASHA512: - pk := k.publicKeyRSA() - if pk != nil { - return rsa.VerifyPKCS1v15(pk, hash, hashed, sig) - } - case ECDSAP256SHA256, ECDSAP384SHA384: - pk := k.publicKeyECDSA() - r := big.NewInt(0) - r.SetBytes(sig[:len(sig)/2]) - s := big.NewInt(0) - s.SetBytes(sig[len(sig)/2:]) - if pk != nil { - if ecdsa.Verify(pk, hashed, r, s) { - return nil - } - return ErrSig - } - } - return ErrKeyAlg -} diff --git a/vendor/github.com/miekg/dns/sig0_test.go b/vendor/github.com/miekg/dns/sig0_test.go deleted file mode 100644 index 122de6a..0000000 --- a/vendor/github.com/miekg/dns/sig0_test.go +++ /dev/null @@ -1,89 +0,0 @@ -package dns - -import ( - "crypto" - "testing" - "time" -) - -func TestSIG0(t *testing.T) { - if testing.Short() { - t.Skip("skipping test in short mode.") - } - m := new(Msg) - m.SetQuestion("example.org.", TypeSOA) - for _, alg := range []uint8{ECDSAP256SHA256, ECDSAP384SHA384, RSASHA1, RSASHA256, RSASHA512} { - algstr := AlgorithmToString[alg] - keyrr := new(KEY) - keyrr.Hdr.Name = algstr + "." - keyrr.Hdr.Rrtype = TypeKEY - keyrr.Hdr.Class = ClassINET - keyrr.Algorithm = alg - keysize := 1024 - switch alg { - case ECDSAP256SHA256: - keysize = 256 - case ECDSAP384SHA384: - keysize = 384 - } - pk, err := keyrr.Generate(keysize) - if err != nil { - t.Errorf("failed to generate key for “%sâ€: %v", algstr, err) - continue - } - now := uint32(time.Now().Unix()) - sigrr := new(SIG) - sigrr.Hdr.Name = "." - sigrr.Hdr.Rrtype = TypeSIG - sigrr.Hdr.Class = ClassANY - sigrr.Algorithm = alg - sigrr.Expiration = now + 300 - sigrr.Inception = now - 300 - sigrr.KeyTag = keyrr.KeyTag() - sigrr.SignerName = keyrr.Hdr.Name - mb, err := sigrr.Sign(pk.(crypto.Signer), m) - if err != nil { - t.Errorf("failed to sign message using “%sâ€: %v", algstr, err) - continue - } - m := new(Msg) - if err := m.Unpack(mb); err != nil { - t.Errorf("failed to unpack message signed using “%sâ€: %v", algstr, err) - continue - } - if len(m.Extra) != 1 { - t.Errorf("missing SIG for message signed using “%sâ€", algstr) - continue - } - var sigrrwire *SIG - switch rr := m.Extra[0].(type) { - case *SIG: - sigrrwire = rr - default: - t.Errorf("expected SIG RR, instead: %v", rr) - continue - } - for _, rr := range []*SIG{sigrr, sigrrwire} { - id := "sigrr" - if rr == sigrrwire { - id = "sigrrwire" - } - if err := rr.Verify(keyrr, mb); err != nil { - t.Errorf("failed to verify “%s†signed SIG(%s): %v", algstr, id, err) - continue - } - } - mb[13]++ - if err := sigrr.Verify(keyrr, mb); err == nil { - t.Errorf("verify succeeded on an altered message using “%sâ€", algstr) - continue - } - sigrr.Expiration = 2 - sigrr.Inception = 1 - mb, _ = sigrr.Sign(pk.(crypto.Signer), m) - if err := sigrr.Verify(keyrr, mb); err == nil { - t.Errorf("verify succeeded on an expired message using “%sâ€", algstr) - continue - } - } -} diff --git a/vendor/github.com/miekg/dns/singleinflight.go b/vendor/github.com/miekg/dns/singleinflight.go deleted file mode 100644 index 9573c7d..0000000 --- a/vendor/github.com/miekg/dns/singleinflight.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Adapted for dns package usage by Miek Gieben. - -package dns - -import "sync" -import "time" - -// call is an in-flight or completed singleflight.Do call -type call struct { - wg sync.WaitGroup - val *Msg - rtt time.Duration - err error - dups int -} - -// singleflight represents a class of work and forms a namespace in -// which units of work can be executed with duplicate suppression. -type singleflight struct { - sync.Mutex // protects m - m map[string]*call // lazily initialized -} - -// Do executes and returns the results of the given function, making -// sure that only one execution is in-flight for a given key at a -// time. If a duplicate comes in, the duplicate caller waits for the -// original to complete and receives the same results. -// The return value shared indicates whether v was given to multiple callers. -func (g *singleflight) Do(key string, fn func() (*Msg, time.Duration, error)) (v *Msg, rtt time.Duration, err error, shared bool) { - g.Lock() - if g.m == nil { - g.m = make(map[string]*call) - } - if c, ok := g.m[key]; ok { - c.dups++ - g.Unlock() - c.wg.Wait() - return c.val, c.rtt, c.err, true - } - c := new(call) - c.wg.Add(1) - g.m[key] = c - g.Unlock() - - c.val, c.rtt, c.err = fn() - c.wg.Done() - - g.Lock() - delete(g.m, key) - g.Unlock() - - return c.val, c.rtt, c.err, c.dups > 0 -} diff --git a/vendor/github.com/miekg/dns/tlsa.go b/vendor/github.com/miekg/dns/tlsa.go deleted file mode 100644 index 34fe661..0000000 --- a/vendor/github.com/miekg/dns/tlsa.go +++ /dev/null @@ -1,86 +0,0 @@ -package dns - -import ( - "crypto/sha256" - "crypto/sha512" - "crypto/x509" - "encoding/hex" - "errors" - "io" - "net" - "strconv" -) - -// CertificateToDANE converts a certificate to a hex string as used in the TLSA record. -func CertificateToDANE(selector, matchingType uint8, cert *x509.Certificate) (string, error) { - switch matchingType { - case 0: - switch selector { - case 0: - return hex.EncodeToString(cert.Raw), nil - case 1: - return hex.EncodeToString(cert.RawSubjectPublicKeyInfo), nil - } - case 1: - h := sha256.New() - switch selector { - case 0: - io.WriteString(h, string(cert.Raw)) - return hex.EncodeToString(h.Sum(nil)), nil - case 1: - io.WriteString(h, string(cert.RawSubjectPublicKeyInfo)) - return hex.EncodeToString(h.Sum(nil)), nil - } - case 2: - h := sha512.New() - switch selector { - case 0: - io.WriteString(h, string(cert.Raw)) - return hex.EncodeToString(h.Sum(nil)), nil - case 1: - io.WriteString(h, string(cert.RawSubjectPublicKeyInfo)) - return hex.EncodeToString(h.Sum(nil)), nil - } - } - return "", errors.New("dns: bad TLSA MatchingType or TLSA Selector") -} - -// Sign creates a TLSA record from an SSL certificate. -func (r *TLSA) Sign(usage, selector, matchingType int, cert *x509.Certificate) (err error) { - r.Hdr.Rrtype = TypeTLSA - r.Usage = uint8(usage) - r.Selector = uint8(selector) - r.MatchingType = uint8(matchingType) - - r.Certificate, err = CertificateToDANE(r.Selector, r.MatchingType, cert) - if err != nil { - return err - } - return nil -} - -// Verify verifies a TLSA record against an SSL certificate. If it is OK -// a nil error is returned. -func (r *TLSA) Verify(cert *x509.Certificate) error { - c, err := CertificateToDANE(r.Selector, r.MatchingType, cert) - if err != nil { - return err // Not also ErrSig? - } - if r.Certificate == c { - return nil - } - return ErrSig // ErrSig, really? -} - -// TLSAName returns the ownername of a TLSA resource record as per the -// rules specified in RFC 6698, Section 3. -func TLSAName(name, service, network string) (string, error) { - if !IsFqdn(name) { - return "", ErrFqdn - } - p, err := net.LookupPort(network, service) - if err != nil { - return "", err - } - return "_" + strconv.Itoa(p) + "._" + network + "." + name, nil -} diff --git a/vendor/github.com/miekg/dns/tsig.go b/vendor/github.com/miekg/dns/tsig.go deleted file mode 100644 index 78365e1..0000000 --- a/vendor/github.com/miekg/dns/tsig.go +++ /dev/null @@ -1,384 +0,0 @@ -package dns - -import ( - "crypto/hmac" - "crypto/md5" - "crypto/sha1" - "crypto/sha256" - "crypto/sha512" - "encoding/binary" - "encoding/hex" - "hash" - "io" - "strconv" - "strings" - "time" -) - -// HMAC hashing codes. These are transmitted as domain names. -const ( - HmacMD5 = "hmac-md5.sig-alg.reg.int." - HmacSHA1 = "hmac-sha1." - HmacSHA256 = "hmac-sha256." - HmacSHA512 = "hmac-sha512." -) - -// TSIG is the RR the holds the transaction signature of a message. -// See RFC 2845 and RFC 4635. -type TSIG struct { - Hdr RR_Header - Algorithm string `dns:"domain-name"` - TimeSigned uint64 `dns:"uint48"` - Fudge uint16 - MACSize uint16 - MAC string `dns:"size-hex:MACSize"` - OrigId uint16 - Error uint16 - OtherLen uint16 - OtherData string `dns:"size-hex:OtherLen"` -} - -// TSIG has no official presentation format, but this will suffice. - -func (rr *TSIG) String() string { - s := "\n;; TSIG PSEUDOSECTION:\n" - s += rr.Hdr.String() + - " " + rr.Algorithm + - " " + tsigTimeToString(rr.TimeSigned) + - " " + strconv.Itoa(int(rr.Fudge)) + - " " + strconv.Itoa(int(rr.MACSize)) + - " " + strings.ToUpper(rr.MAC) + - " " + strconv.Itoa(int(rr.OrigId)) + - " " + strconv.Itoa(int(rr.Error)) + // BIND prints NOERROR - " " + strconv.Itoa(int(rr.OtherLen)) + - " " + rr.OtherData - return s -} - -// The following values must be put in wireformat, so that the MAC can be calculated. -// RFC 2845, section 3.4.2. TSIG Variables. -type tsigWireFmt struct { - // From RR_Header - Name string `dns:"domain-name"` - Class uint16 - Ttl uint32 - // Rdata of the TSIG - Algorithm string `dns:"domain-name"` - TimeSigned uint64 `dns:"uint48"` - Fudge uint16 - // MACSize, MAC and OrigId excluded - Error uint16 - OtherLen uint16 - OtherData string `dns:"size-hex:OtherLen"` -} - -// If we have the MAC use this type to convert it to wiredata. Section 3.4.3. Request MAC -type macWireFmt struct { - MACSize uint16 - MAC string `dns:"size-hex:MACSize"` -} - -// 3.3. Time values used in TSIG calculations -type timerWireFmt struct { - TimeSigned uint64 `dns:"uint48"` - Fudge uint16 -} - -// TsigGenerate fills out the TSIG record attached to the message. -// The message should contain -// a "stub" TSIG RR with the algorithm, key name (owner name of the RR), -// time fudge (defaults to 300 seconds) and the current time -// The TSIG MAC is saved in that Tsig RR. -// When TsigGenerate is called for the first time requestMAC is set to the empty string and -// timersOnly is false. -// If something goes wrong an error is returned, otherwise it is nil. -func TsigGenerate(m *Msg, secret, requestMAC string, timersOnly bool) ([]byte, string, error) { - if m.IsTsig() == nil { - panic("dns: TSIG not last RR in additional") - } - // If we barf here, the caller is to blame - rawsecret, err := fromBase64([]byte(secret)) - if err != nil { - return nil, "", err - } - - rr := m.Extra[len(m.Extra)-1].(*TSIG) - m.Extra = m.Extra[0 : len(m.Extra)-1] // kill the TSIG from the msg - mbuf, err := m.Pack() - if err != nil { - return nil, "", err - } - buf := tsigBuffer(mbuf, rr, requestMAC, timersOnly) - - t := new(TSIG) - var h hash.Hash - switch strings.ToLower(rr.Algorithm) { - case HmacMD5: - h = hmac.New(md5.New, []byte(rawsecret)) - case HmacSHA1: - h = hmac.New(sha1.New, []byte(rawsecret)) - case HmacSHA256: - h = hmac.New(sha256.New, []byte(rawsecret)) - case HmacSHA512: - h = hmac.New(sha512.New, []byte(rawsecret)) - default: - return nil, "", ErrKeyAlg - } - io.WriteString(h, string(buf)) - t.MAC = hex.EncodeToString(h.Sum(nil)) - t.MACSize = uint16(len(t.MAC) / 2) // Size is half! - - t.Hdr = RR_Header{Name: rr.Hdr.Name, Rrtype: TypeTSIG, Class: ClassANY, Ttl: 0} - t.Fudge = rr.Fudge - t.TimeSigned = rr.TimeSigned - t.Algorithm = rr.Algorithm - t.OrigId = m.Id - - tbuf := make([]byte, t.len()) - if off, err := PackRR(t, tbuf, 0, nil, false); err == nil { - tbuf = tbuf[:off] // reset to actual size used - } else { - return nil, "", err - } - mbuf = append(mbuf, tbuf...) - // Update the ArCount directly in the buffer. - binary.BigEndian.PutUint16(mbuf[10:], uint16(len(m.Extra)+1)) - - return mbuf, t.MAC, nil -} - -// TsigVerify verifies the TSIG on a message. -// If the signature does not validate err contains the -// error, otherwise it is nil. -func TsigVerify(msg []byte, secret, requestMAC string, timersOnly bool) error { - rawsecret, err := fromBase64([]byte(secret)) - if err != nil { - return err - } - // Strip the TSIG from the incoming msg - stripped, tsig, err := stripTsig(msg) - if err != nil { - return err - } - - msgMAC, err := hex.DecodeString(tsig.MAC) - if err != nil { - return err - } - - buf := tsigBuffer(stripped, tsig, requestMAC, timersOnly) - - // Fudge factor works both ways. A message can arrive before it was signed because - // of clock skew. - now := uint64(time.Now().Unix()) - ti := now - tsig.TimeSigned - if now < tsig.TimeSigned { - ti = tsig.TimeSigned - now - } - if uint64(tsig.Fudge) < ti { - return ErrTime - } - - var h hash.Hash - switch strings.ToLower(tsig.Algorithm) { - case HmacMD5: - h = hmac.New(md5.New, rawsecret) - case HmacSHA1: - h = hmac.New(sha1.New, rawsecret) - case HmacSHA256: - h = hmac.New(sha256.New, rawsecret) - case HmacSHA512: - h = hmac.New(sha512.New, rawsecret) - default: - return ErrKeyAlg - } - h.Write(buf) - if !hmac.Equal(h.Sum(nil), msgMAC) { - return ErrSig - } - return nil -} - -// Create a wiredata buffer for the MAC calculation. -func tsigBuffer(msgbuf []byte, rr *TSIG, requestMAC string, timersOnly bool) []byte { - var buf []byte - if rr.TimeSigned == 0 { - rr.TimeSigned = uint64(time.Now().Unix()) - } - if rr.Fudge == 0 { - rr.Fudge = 300 // Standard (RFC) default. - } - - if requestMAC != "" { - m := new(macWireFmt) - m.MACSize = uint16(len(requestMAC) / 2) - m.MAC = requestMAC - buf = make([]byte, len(requestMAC)) // long enough - n, _ := packMacWire(m, buf) - buf = buf[:n] - } - - tsigvar := make([]byte, DefaultMsgSize) - if timersOnly { - tsig := new(timerWireFmt) - tsig.TimeSigned = rr.TimeSigned - tsig.Fudge = rr.Fudge - n, _ := packTimerWire(tsig, tsigvar) - tsigvar = tsigvar[:n] - } else { - tsig := new(tsigWireFmt) - tsig.Name = strings.ToLower(rr.Hdr.Name) - tsig.Class = ClassANY - tsig.Ttl = rr.Hdr.Ttl - tsig.Algorithm = strings.ToLower(rr.Algorithm) - tsig.TimeSigned = rr.TimeSigned - tsig.Fudge = rr.Fudge - tsig.Error = rr.Error - tsig.OtherLen = rr.OtherLen - tsig.OtherData = rr.OtherData - n, _ := packTsigWire(tsig, tsigvar) - tsigvar = tsigvar[:n] - } - - if requestMAC != "" { - x := append(buf, msgbuf...) - buf = append(x, tsigvar...) - } else { - buf = append(msgbuf, tsigvar...) - } - return buf -} - -// Strip the TSIG from the raw message. -func stripTsig(msg []byte) ([]byte, *TSIG, error) { - // Copied from msg.go's Unpack() Header, but modified. - var ( - dh Header - err error - ) - off, tsigoff := 0, 0 - - if dh, off, err = unpackMsgHdr(msg, off); err != nil { - return nil, nil, err - } - if dh.Arcount == 0 { - return nil, nil, ErrNoSig - } - - // Rcode, see msg.go Unpack() - if int(dh.Bits&0xF) == RcodeNotAuth { - return nil, nil, ErrAuth - } - - for i := 0; i < int(dh.Qdcount); i++ { - _, off, err = unpackQuestion(msg, off) - if err != nil { - return nil, nil, err - } - } - - _, off, err = unpackRRslice(int(dh.Ancount), msg, off) - if err != nil { - return nil, nil, err - } - _, off, err = unpackRRslice(int(dh.Nscount), msg, off) - if err != nil { - return nil, nil, err - } - - rr := new(TSIG) - var extra RR - for i := 0; i < int(dh.Arcount); i++ { - tsigoff = off - extra, off, err = UnpackRR(msg, off) - if err != nil { - return nil, nil, err - } - if extra.Header().Rrtype == TypeTSIG { - rr = extra.(*TSIG) - // Adjust Arcount. - arcount := binary.BigEndian.Uint16(msg[10:]) - binary.BigEndian.PutUint16(msg[10:], arcount-1) - break - } - } - if rr == nil { - return nil, nil, ErrNoSig - } - return msg[:tsigoff], rr, nil -} - -// Translate the TSIG time signed into a date. There is no -// need for RFC1982 calculations as this date is 48 bits. -func tsigTimeToString(t uint64) string { - ti := time.Unix(int64(t), 0).UTC() - return ti.Format("20060102150405") -} - -func packTsigWire(tw *tsigWireFmt, msg []byte) (int, error) { - // copied from zmsg.go TSIG packing - // RR_Header - off, err := PackDomainName(tw.Name, msg, 0, nil, false) - if err != nil { - return off, err - } - off, err = packUint16(tw.Class, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(tw.Ttl, msg, off) - if err != nil { - return off, err - } - - off, err = PackDomainName(tw.Algorithm, msg, off, nil, false) - if err != nil { - return off, err - } - off, err = packUint48(tw.TimeSigned, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(tw.Fudge, msg, off) - if err != nil { - return off, err - } - - off, err = packUint16(tw.Error, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(tw.OtherLen, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(tw.OtherData, msg, off) - if err != nil { - return off, err - } - return off, nil -} - -func packMacWire(mw *macWireFmt, msg []byte) (int, error) { - off, err := packUint16(mw.MACSize, msg, 0) - if err != nil { - return off, err - } - off, err = packStringHex(mw.MAC, msg, off) - if err != nil { - return off, err - } - return off, nil -} - -func packTimerWire(tw *timerWireFmt, msg []byte) (int, error) { - off, err := packUint48(tw.TimeSigned, msg, 0) - if err != nil { - return off, err - } - off, err = packUint16(tw.Fudge, msg, off) - if err != nil { - return off, err - } - return off, nil -} diff --git a/vendor/github.com/miekg/dns/tsig_test.go b/vendor/github.com/miekg/dns/tsig_test.go deleted file mode 100644 index 48b9988..0000000 --- a/vendor/github.com/miekg/dns/tsig_test.go +++ /dev/null @@ -1,37 +0,0 @@ -package dns - -import ( - "testing" - "time" -) - -func newTsig(algo string) *Msg { - m := new(Msg) - m.SetQuestion("example.org.", TypeA) - m.SetTsig("example.", algo, 300, time.Now().Unix()) - return m -} - -func TestTsig(t *testing.T) { - m := newTsig(HmacMD5) - buf, _, err := TsigGenerate(m, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false) - if err != nil { - t.Fatal(err) - } - err = TsigVerify(buf, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false) - if err != nil { - t.Fatal(err) - } -} - -func TestTsigCase(t *testing.T) { - m := newTsig("HmAc-mD5.sig-ALg.rEg.int.") // HmacMD5 - buf, _, err := TsigGenerate(m, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false) - if err != nil { - t.Fatal(err) - } - err = TsigVerify(buf, "pRZgBrBvI4NAHZYhxmhs/Q==", "", false) - if err != nil { - t.Fatal(err) - } -} diff --git a/vendor/github.com/miekg/dns/types.go b/vendor/github.com/miekg/dns/types.go deleted file mode 100644 index e737064..0000000 --- a/vendor/github.com/miekg/dns/types.go +++ /dev/null @@ -1,1250 +0,0 @@ -package dns - -import ( - "fmt" - "net" - "strconv" - "strings" - "time" -) - -type ( - // Type is a DNS type. - Type uint16 - // Class is a DNS class. - Class uint16 - // Name is a DNS domain name. - Name string -) - -// Packet formats - -// Wire constants and supported types. -const ( - // valid RR_Header.Rrtype and Question.qtype - - TypeNone uint16 = 0 - TypeA uint16 = 1 - TypeNS uint16 = 2 - TypeMD uint16 = 3 - TypeMF uint16 = 4 - TypeCNAME uint16 = 5 - TypeSOA uint16 = 6 - TypeMB uint16 = 7 - TypeMG uint16 = 8 - TypeMR uint16 = 9 - TypeNULL uint16 = 10 - TypePTR uint16 = 12 - TypeHINFO uint16 = 13 - TypeMINFO uint16 = 14 - TypeMX uint16 = 15 - TypeTXT uint16 = 16 - TypeRP uint16 = 17 - TypeAFSDB uint16 = 18 - TypeX25 uint16 = 19 - TypeISDN uint16 = 20 - TypeRT uint16 = 21 - TypeNSAPPTR uint16 = 23 - TypeSIG uint16 = 24 - TypeKEY uint16 = 25 - TypePX uint16 = 26 - TypeGPOS uint16 = 27 - TypeAAAA uint16 = 28 - TypeLOC uint16 = 29 - TypeNXT uint16 = 30 - TypeEID uint16 = 31 - TypeNIMLOC uint16 = 32 - TypeSRV uint16 = 33 - TypeATMA uint16 = 34 - TypeNAPTR uint16 = 35 - TypeKX uint16 = 36 - TypeCERT uint16 = 37 - TypeDNAME uint16 = 39 - TypeOPT uint16 = 41 // EDNS - TypeDS uint16 = 43 - TypeSSHFP uint16 = 44 - TypeRRSIG uint16 = 46 - TypeNSEC uint16 = 47 - TypeDNSKEY uint16 = 48 - TypeDHCID uint16 = 49 - TypeNSEC3 uint16 = 50 - TypeNSEC3PARAM uint16 = 51 - TypeTLSA uint16 = 52 - TypeHIP uint16 = 55 - TypeNINFO uint16 = 56 - TypeRKEY uint16 = 57 - TypeTALINK uint16 = 58 - TypeCDS uint16 = 59 - TypeCDNSKEY uint16 = 60 - TypeOPENPGPKEY uint16 = 61 - TypeSPF uint16 = 99 - TypeUINFO uint16 = 100 - TypeUID uint16 = 101 - TypeGID uint16 = 102 - TypeUNSPEC uint16 = 103 - TypeNID uint16 = 104 - TypeL32 uint16 = 105 - TypeL64 uint16 = 106 - TypeLP uint16 = 107 - TypeEUI48 uint16 = 108 - TypeEUI64 uint16 = 109 - TypeURI uint16 = 256 - TypeCAA uint16 = 257 - - TypeTKEY uint16 = 249 - TypeTSIG uint16 = 250 - - // valid Question.Qtype only - TypeIXFR uint16 = 251 - TypeAXFR uint16 = 252 - TypeMAILB uint16 = 253 - TypeMAILA uint16 = 254 - TypeANY uint16 = 255 - - TypeTA uint16 = 32768 - TypeDLV uint16 = 32769 - TypeReserved uint16 = 65535 - - // valid Question.Qclass - ClassINET = 1 - ClassCSNET = 2 - ClassCHAOS = 3 - ClassHESIOD = 4 - ClassNONE = 254 - ClassANY = 255 - - // Message Response Codes. - RcodeSuccess = 0 - RcodeFormatError = 1 - RcodeServerFailure = 2 - RcodeNameError = 3 - RcodeNotImplemented = 4 - RcodeRefused = 5 - RcodeYXDomain = 6 - RcodeYXRrset = 7 - RcodeNXRrset = 8 - RcodeNotAuth = 9 - RcodeNotZone = 10 - RcodeBadSig = 16 // TSIG - RcodeBadVers = 16 // EDNS0 - RcodeBadKey = 17 - RcodeBadTime = 18 - RcodeBadMode = 19 // TKEY - RcodeBadName = 20 - RcodeBadAlg = 21 - RcodeBadTrunc = 22 // TSIG - RcodeBadCookie = 23 // DNS Cookies - - // Message Opcodes. There is no 3. - OpcodeQuery = 0 - OpcodeIQuery = 1 - OpcodeStatus = 2 - OpcodeNotify = 4 - OpcodeUpdate = 5 -) - -// Headers is the wire format for the DNS packet header. -type Header struct { - Id uint16 - Bits uint16 - Qdcount, Ancount, Nscount, Arcount uint16 -} - -const ( - headerSize = 12 - - // Header.Bits - _QR = 1 << 15 // query/response (response=1) - _AA = 1 << 10 // authoritative - _TC = 1 << 9 // truncated - _RD = 1 << 8 // recursion desired - _RA = 1 << 7 // recursion available - _Z = 1 << 6 // Z - _AD = 1 << 5 // authticated data - _CD = 1 << 4 // checking disabled - - LOC_EQUATOR = 1 << 31 // RFC 1876, Section 2. - LOC_PRIMEMERIDIAN = 1 << 31 // RFC 1876, Section 2. - - LOC_HOURS = 60 * 1000 - LOC_DEGREES = 60 * LOC_HOURS - - LOC_ALTITUDEBASE = 100000 -) - -// Different Certificate Types, see RFC 4398, Section 2.1 -const ( - CertPKIX = 1 + iota - CertSPKI - CertPGP - CertIPIX - CertISPKI - CertIPGP - CertACPKIX - CertIACPKIX - CertURI = 253 - CertOID = 254 -) - -// CertTypeToString converts the Cert Type to its string representation. -// See RFC 4398 and RFC 6944. -var CertTypeToString = map[uint16]string{ - CertPKIX: "PKIX", - CertSPKI: "SPKI", - CertPGP: "PGP", - CertIPIX: "IPIX", - CertISPKI: "ISPKI", - CertIPGP: "IPGP", - CertACPKIX: "ACPKIX", - CertIACPKIX: "IACPKIX", - CertURI: "URI", - CertOID: "OID", -} - -// StringToCertType is the reverseof CertTypeToString. -var StringToCertType = reverseInt16(CertTypeToString) - -//go:generate go run types_generate.go - -// Question holds a DNS question. There can be multiple questions in the -// question section of a message. Usually there is just one. -type Question struct { - Name string `dns:"cdomain-name"` // "cdomain-name" specifies encoding (and may be compressed) - Qtype uint16 - Qclass uint16 -} - -func (q *Question) len() int { - return len(q.Name) + 1 + 2 + 2 -} - -func (q *Question) String() (s string) { - // prefix with ; (as in dig) - s = ";" + sprintName(q.Name) + "\t" - s += Class(q.Qclass).String() + "\t" - s += " " + Type(q.Qtype).String() - return s -} - -// ANY is a wildcard record. See RFC 1035, Section 3.2.3. ANY -// is named "*" there. -type ANY struct { - Hdr RR_Header - // Does not have any rdata -} - -func (rr *ANY) String() string { return rr.Hdr.String() } - -type CNAME struct { - Hdr RR_Header - Target string `dns:"cdomain-name"` -} - -func (rr *CNAME) String() string { return rr.Hdr.String() + sprintName(rr.Target) } - -type HINFO struct { - Hdr RR_Header - Cpu string - Os string -} - -func (rr *HINFO) String() string { - return rr.Hdr.String() + sprintTxt([]string{rr.Cpu, rr.Os}) -} - -type MB struct { - Hdr RR_Header - Mb string `dns:"cdomain-name"` -} - -func (rr *MB) String() string { return rr.Hdr.String() + sprintName(rr.Mb) } - -type MG struct { - Hdr RR_Header - Mg string `dns:"cdomain-name"` -} - -func (rr *MG) String() string { return rr.Hdr.String() + sprintName(rr.Mg) } - -type MINFO struct { - Hdr RR_Header - Rmail string `dns:"cdomain-name"` - Email string `dns:"cdomain-name"` -} - -func (rr *MINFO) String() string { - return rr.Hdr.String() + sprintName(rr.Rmail) + " " + sprintName(rr.Email) -} - -type MR struct { - Hdr RR_Header - Mr string `dns:"cdomain-name"` -} - -func (rr *MR) String() string { - return rr.Hdr.String() + sprintName(rr.Mr) -} - -type MF struct { - Hdr RR_Header - Mf string `dns:"cdomain-name"` -} - -func (rr *MF) String() string { - return rr.Hdr.String() + sprintName(rr.Mf) -} - -type MD struct { - Hdr RR_Header - Md string `dns:"cdomain-name"` -} - -func (rr *MD) String() string { - return rr.Hdr.String() + sprintName(rr.Md) -} - -type MX struct { - Hdr RR_Header - Preference uint16 - Mx string `dns:"cdomain-name"` -} - -func (rr *MX) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Mx) -} - -type AFSDB struct { - Hdr RR_Header - Subtype uint16 - Hostname string `dns:"cdomain-name"` -} - -func (rr *AFSDB) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Subtype)) + " " + sprintName(rr.Hostname) -} - -type X25 struct { - Hdr RR_Header - PSDNAddress string -} - -func (rr *X25) String() string { - return rr.Hdr.String() + rr.PSDNAddress -} - -type RT struct { - Hdr RR_Header - Preference uint16 - Host string `dns:"cdomain-name"` -} - -func (rr *RT) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Host) -} - -type NS struct { - Hdr RR_Header - Ns string `dns:"cdomain-name"` -} - -func (rr *NS) String() string { - return rr.Hdr.String() + sprintName(rr.Ns) -} - -type PTR struct { - Hdr RR_Header - Ptr string `dns:"cdomain-name"` -} - -func (rr *PTR) String() string { - return rr.Hdr.String() + sprintName(rr.Ptr) -} - -type RP struct { - Hdr RR_Header - Mbox string `dns:"domain-name"` - Txt string `dns:"domain-name"` -} - -func (rr *RP) String() string { - return rr.Hdr.String() + rr.Mbox + " " + sprintTxt([]string{rr.Txt}) -} - -type SOA struct { - Hdr RR_Header - Ns string `dns:"cdomain-name"` - Mbox string `dns:"cdomain-name"` - Serial uint32 - Refresh uint32 - Retry uint32 - Expire uint32 - Minttl uint32 -} - -func (rr *SOA) String() string { - return rr.Hdr.String() + sprintName(rr.Ns) + " " + sprintName(rr.Mbox) + - " " + strconv.FormatInt(int64(rr.Serial), 10) + - " " + strconv.FormatInt(int64(rr.Refresh), 10) + - " " + strconv.FormatInt(int64(rr.Retry), 10) + - " " + strconv.FormatInt(int64(rr.Expire), 10) + - " " + strconv.FormatInt(int64(rr.Minttl), 10) -} - -type TXT struct { - Hdr RR_Header - Txt []string `dns:"txt"` -} - -func (rr *TXT) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } - -func sprintName(s string) string { - src := []byte(s) - dst := make([]byte, 0, len(src)) - for i := 0; i < len(src); { - if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' { - dst = append(dst, src[i:i+2]...) - i += 2 - } else { - b, n := nextByte(src, i) - if n == 0 { - i++ // dangling back slash - } else if b == '.' { - dst = append(dst, b) - } else { - dst = appendDomainNameByte(dst, b) - } - i += n - } - } - return string(dst) -} - -func sprintTxtOctet(s string) string { - src := []byte(s) - dst := make([]byte, 0, len(src)) - dst = append(dst, '"') - for i := 0; i < len(src); { - if i+1 < len(src) && src[i] == '\\' && src[i+1] == '.' { - dst = append(dst, src[i:i+2]...) - i += 2 - } else { - b, n := nextByte(src, i) - if n == 0 { - i++ // dangling back slash - } else if b == '.' { - dst = append(dst, b) - } else { - if b < ' ' || b > '~' { - dst = appendByte(dst, b) - } else { - dst = append(dst, b) - } - } - i += n - } - } - dst = append(dst, '"') - return string(dst) -} - -func sprintTxt(txt []string) string { - var out []byte - for i, s := range txt { - if i > 0 { - out = append(out, ` "`...) - } else { - out = append(out, '"') - } - bs := []byte(s) - for j := 0; j < len(bs); { - b, n := nextByte(bs, j) - if n == 0 { - break - } - out = appendTXTStringByte(out, b) - j += n - } - out = append(out, '"') - } - return string(out) -} - -func appendDomainNameByte(s []byte, b byte) []byte { - switch b { - case '.', ' ', '\'', '@', ';', '(', ')': // additional chars to escape - return append(s, '\\', b) - } - return appendTXTStringByte(s, b) -} - -func appendTXTStringByte(s []byte, b byte) []byte { - switch b { - case '\t': - return append(s, '\\', 't') - case '\r': - return append(s, '\\', 'r') - case '\n': - return append(s, '\\', 'n') - case '"', '\\': - return append(s, '\\', b) - } - if b < ' ' || b > '~' { - return appendByte(s, b) - } - return append(s, b) -} - -func appendByte(s []byte, b byte) []byte { - var buf [3]byte - bufs := strconv.AppendInt(buf[:0], int64(b), 10) - s = append(s, '\\') - for i := 0; i < 3-len(bufs); i++ { - s = append(s, '0') - } - for _, r := range bufs { - s = append(s, r) - } - return s -} - -func nextByte(b []byte, offset int) (byte, int) { - if offset >= len(b) { - return 0, 0 - } - if b[offset] != '\\' { - // not an escape sequence - return b[offset], 1 - } - switch len(b) - offset { - case 1: // dangling escape - return 0, 0 - case 2, 3: // too short to be \ddd - default: // maybe \ddd - if isDigit(b[offset+1]) && isDigit(b[offset+2]) && isDigit(b[offset+3]) { - return dddToByte(b[offset+1:]), 4 - } - } - // not \ddd, maybe a control char - switch b[offset+1] { - case 't': - return '\t', 2 - case 'r': - return '\r', 2 - case 'n': - return '\n', 2 - default: - return b[offset+1], 2 - } -} - -type SPF struct { - Hdr RR_Header - Txt []string `dns:"txt"` -} - -func (rr *SPF) String() string { return rr.Hdr.String() + sprintTxt(rr.Txt) } - -type SRV struct { - Hdr RR_Header - Priority uint16 - Weight uint16 - Port uint16 - Target string `dns:"domain-name"` -} - -func (rr *SRV) String() string { - return rr.Hdr.String() + - strconv.Itoa(int(rr.Priority)) + " " + - strconv.Itoa(int(rr.Weight)) + " " + - strconv.Itoa(int(rr.Port)) + " " + sprintName(rr.Target) -} - -type NAPTR struct { - Hdr RR_Header - Order uint16 - Preference uint16 - Flags string - Service string - Regexp string - Replacement string `dns:"domain-name"` -} - -func (rr *NAPTR) String() string { - return rr.Hdr.String() + - strconv.Itoa(int(rr.Order)) + " " + - strconv.Itoa(int(rr.Preference)) + " " + - "\"" + rr.Flags + "\" " + - "\"" + rr.Service + "\" " + - "\"" + rr.Regexp + "\" " + - rr.Replacement -} - -// The CERT resource record, see RFC 4398. -type CERT struct { - Hdr RR_Header - Type uint16 - KeyTag uint16 - Algorithm uint8 - Certificate string `dns:"base64"` -} - -func (rr *CERT) String() string { - var ( - ok bool - certtype, algorithm string - ) - if certtype, ok = CertTypeToString[rr.Type]; !ok { - certtype = strconv.Itoa(int(rr.Type)) - } - if algorithm, ok = AlgorithmToString[rr.Algorithm]; !ok { - algorithm = strconv.Itoa(int(rr.Algorithm)) - } - return rr.Hdr.String() + certtype + - " " + strconv.Itoa(int(rr.KeyTag)) + - " " + algorithm + - " " + rr.Certificate -} - -// The DNAME resource record, see RFC 2672. -type DNAME struct { - Hdr RR_Header - Target string `dns:"domain-name"` -} - -func (rr *DNAME) String() string { - return rr.Hdr.String() + sprintName(rr.Target) -} - -type A struct { - Hdr RR_Header - A net.IP `dns:"a"` -} - -func (rr *A) String() string { - if rr.A == nil { - return rr.Hdr.String() - } - return rr.Hdr.String() + rr.A.String() -} - -type AAAA struct { - Hdr RR_Header - AAAA net.IP `dns:"aaaa"` -} - -func (rr *AAAA) String() string { - if rr.AAAA == nil { - return rr.Hdr.String() - } - return rr.Hdr.String() + rr.AAAA.String() -} - -type PX struct { - Hdr RR_Header - Preference uint16 - Map822 string `dns:"domain-name"` - Mapx400 string `dns:"domain-name"` -} - -func (rr *PX) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Map822) + " " + sprintName(rr.Mapx400) -} - -type GPOS struct { - Hdr RR_Header - Longitude string - Latitude string - Altitude string -} - -func (rr *GPOS) String() string { - return rr.Hdr.String() + rr.Longitude + " " + rr.Latitude + " " + rr.Altitude -} - -type LOC struct { - Hdr RR_Header - Version uint8 - Size uint8 - HorizPre uint8 - VertPre uint8 - Latitude uint32 - Longitude uint32 - Altitude uint32 -} - -// cmToM takes a cm value expressed in RFC1876 SIZE mantissa/exponent -// format and returns a string in m (two decimals for the cm) -func cmToM(m, e uint8) string { - if e < 2 { - if e == 1 { - m *= 10 - } - - return fmt.Sprintf("0.%02d", m) - } - - s := fmt.Sprintf("%d", m) - for e > 2 { - s += "0" - e-- - } - return s -} - -func (rr *LOC) String() string { - s := rr.Hdr.String() - - lat := rr.Latitude - ns := "N" - if lat > LOC_EQUATOR { - lat = lat - LOC_EQUATOR - } else { - ns = "S" - lat = LOC_EQUATOR - lat - } - h := lat / LOC_DEGREES - lat = lat % LOC_DEGREES - m := lat / LOC_HOURS - lat = lat % LOC_HOURS - s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float64(lat) / 1000), ns) - - lon := rr.Longitude - ew := "E" - if lon > LOC_PRIMEMERIDIAN { - lon = lon - LOC_PRIMEMERIDIAN - } else { - ew = "W" - lon = LOC_PRIMEMERIDIAN - lon - } - h = lon / LOC_DEGREES - lon = lon % LOC_DEGREES - m = lon / LOC_HOURS - lon = lon % LOC_HOURS - s += fmt.Sprintf("%02d %02d %0.3f %s ", h, m, (float64(lon) / 1000), ew) - - var alt = float64(rr.Altitude) / 100 - alt -= LOC_ALTITUDEBASE - if rr.Altitude%100 != 0 { - s += fmt.Sprintf("%.2fm ", alt) - } else { - s += fmt.Sprintf("%.0fm ", alt) - } - - s += cmToM((rr.Size&0xf0)>>4, rr.Size&0x0f) + "m " - s += cmToM((rr.HorizPre&0xf0)>>4, rr.HorizPre&0x0f) + "m " - s += cmToM((rr.VertPre&0xf0)>>4, rr.VertPre&0x0f) + "m" - - return s -} - -// SIG is identical to RRSIG and nowadays only used for SIG(0), RFC2931. -type SIG struct { - RRSIG -} - -type RRSIG struct { - Hdr RR_Header - TypeCovered uint16 - Algorithm uint8 - Labels uint8 - OrigTtl uint32 - Expiration uint32 - Inception uint32 - KeyTag uint16 - SignerName string `dns:"domain-name"` - Signature string `dns:"base64"` -} - -func (rr *RRSIG) String() string { - s := rr.Hdr.String() - s += Type(rr.TypeCovered).String() - s += " " + strconv.Itoa(int(rr.Algorithm)) + - " " + strconv.Itoa(int(rr.Labels)) + - " " + strconv.FormatInt(int64(rr.OrigTtl), 10) + - " " + TimeToString(rr.Expiration) + - " " + TimeToString(rr.Inception) + - " " + strconv.Itoa(int(rr.KeyTag)) + - " " + sprintName(rr.SignerName) + - " " + rr.Signature - return s -} - -type NSEC struct { - Hdr RR_Header - NextDomain string `dns:"domain-name"` - TypeBitMap []uint16 `dns:"nsec"` -} - -func (rr *NSEC) String() string { - s := rr.Hdr.String() + sprintName(rr.NextDomain) - for i := 0; i < len(rr.TypeBitMap); i++ { - s += " " + Type(rr.TypeBitMap[i]).String() - } - return s -} - -func (rr *NSEC) len() int { - l := rr.Hdr.len() + len(rr.NextDomain) + 1 - lastwindow := uint32(2 ^ 32 + 1) - for _, t := range rr.TypeBitMap { - window := t / 256 - if uint32(window) != lastwindow { - l += 1 + 32 - } - lastwindow = uint32(window) - } - return l -} - -type DLV struct { - DS -} - -type CDS struct { - DS -} - -type DS struct { - Hdr RR_Header - KeyTag uint16 - Algorithm uint8 - DigestType uint8 - Digest string `dns:"hex"` -} - -func (rr *DS) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.KeyTag)) + - " " + strconv.Itoa(int(rr.Algorithm)) + - " " + strconv.Itoa(int(rr.DigestType)) + - " " + strings.ToUpper(rr.Digest) -} - -type KX struct { - Hdr RR_Header - Preference uint16 - Exchanger string `dns:"domain-name"` -} - -func (rr *KX) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + - " " + sprintName(rr.Exchanger) -} - -type TA struct { - Hdr RR_Header - KeyTag uint16 - Algorithm uint8 - DigestType uint8 - Digest string `dns:"hex"` -} - -func (rr *TA) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.KeyTag)) + - " " + strconv.Itoa(int(rr.Algorithm)) + - " " + strconv.Itoa(int(rr.DigestType)) + - " " + strings.ToUpper(rr.Digest) -} - -type TALINK struct { - Hdr RR_Header - PreviousName string `dns:"domain-name"` - NextName string `dns:"domain-name"` -} - -func (rr *TALINK) String() string { - return rr.Hdr.String() + - sprintName(rr.PreviousName) + " " + sprintName(rr.NextName) -} - -type SSHFP struct { - Hdr RR_Header - Algorithm uint8 - Type uint8 - FingerPrint string `dns:"hex"` -} - -func (rr *SSHFP) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Algorithm)) + - " " + strconv.Itoa(int(rr.Type)) + - " " + strings.ToUpper(rr.FingerPrint) -} - -type KEY struct { - DNSKEY -} - -type CDNSKEY struct { - DNSKEY -} - -type DNSKEY struct { - Hdr RR_Header - Flags uint16 - Protocol uint8 - Algorithm uint8 - PublicKey string `dns:"base64"` -} - -func (rr *DNSKEY) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Flags)) + - " " + strconv.Itoa(int(rr.Protocol)) + - " " + strconv.Itoa(int(rr.Algorithm)) + - " " + rr.PublicKey -} - -type RKEY struct { - Hdr RR_Header - Flags uint16 - Protocol uint8 - Algorithm uint8 - PublicKey string `dns:"base64"` -} - -func (rr *RKEY) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Flags)) + - " " + strconv.Itoa(int(rr.Protocol)) + - " " + strconv.Itoa(int(rr.Algorithm)) + - " " + rr.PublicKey -} - -type NSAPPTR struct { - Hdr RR_Header - Ptr string `dns:"domain-name"` -} - -func (rr *NSAPPTR) String() string { return rr.Hdr.String() + sprintName(rr.Ptr) } - -type NSEC3 struct { - Hdr RR_Header - Hash uint8 - Flags uint8 - Iterations uint16 - SaltLength uint8 - Salt string `dns:"size-hex:SaltLength"` - HashLength uint8 - NextDomain string `dns:"size-base32:HashLength"` - TypeBitMap []uint16 `dns:"nsec"` -} - -func (rr *NSEC3) String() string { - s := rr.Hdr.String() - s += strconv.Itoa(int(rr.Hash)) + - " " + strconv.Itoa(int(rr.Flags)) + - " " + strconv.Itoa(int(rr.Iterations)) + - " " + saltToString(rr.Salt) + - " " + rr.NextDomain - for i := 0; i < len(rr.TypeBitMap); i++ { - s += " " + Type(rr.TypeBitMap[i]).String() - } - return s -} - -func (rr *NSEC3) len() int { - l := rr.Hdr.len() + 6 + len(rr.Salt)/2 + 1 + len(rr.NextDomain) + 1 - lastwindow := uint32(2 ^ 32 + 1) - for _, t := range rr.TypeBitMap { - window := t / 256 - if uint32(window) != lastwindow { - l += 1 + 32 - } - lastwindow = uint32(window) - } - return l -} - -type NSEC3PARAM struct { - Hdr RR_Header - Hash uint8 - Flags uint8 - Iterations uint16 - SaltLength uint8 - Salt string `dns:"hex"` -} - -func (rr *NSEC3PARAM) String() string { - s := rr.Hdr.String() - s += strconv.Itoa(int(rr.Hash)) + - " " + strconv.Itoa(int(rr.Flags)) + - " " + strconv.Itoa(int(rr.Iterations)) + - " " + saltToString(rr.Salt) - return s -} - -type TKEY struct { - Hdr RR_Header - Algorithm string `dns:"domain-name"` - Inception uint32 - Expiration uint32 - Mode uint16 - Error uint16 - KeySize uint16 - Key string - OtherLen uint16 - OtherData string -} - -func (rr *TKEY) String() string { - // It has no presentation format - return "" -} - -// RFC3597 represents an unknown/generic RR. -type RFC3597 struct { - Hdr RR_Header - Rdata string `dns:"hex"` -} - -func (rr *RFC3597) String() string { - // Let's call it a hack - s := rfc3597Header(rr.Hdr) - - s += "\\# " + strconv.Itoa(len(rr.Rdata)/2) + " " + rr.Rdata - return s -} - -func rfc3597Header(h RR_Header) string { - var s string - - s += sprintName(h.Name) + "\t" - s += strconv.FormatInt(int64(h.Ttl), 10) + "\t" - s += "CLASS" + strconv.Itoa(int(h.Class)) + "\t" - s += "TYPE" + strconv.Itoa(int(h.Rrtype)) + "\t" - return s -} - -type URI struct { - Hdr RR_Header - Priority uint16 - Weight uint16 - Target string `dns:"octet"` -} - -func (rr *URI) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Priority)) + - " " + strconv.Itoa(int(rr.Weight)) + " " + sprintTxtOctet(rr.Target) -} - -type DHCID struct { - Hdr RR_Header - Digest string `dns:"base64"` -} - -func (rr *DHCID) String() string { return rr.Hdr.String() + rr.Digest } - -type TLSA struct { - Hdr RR_Header - Usage uint8 - Selector uint8 - MatchingType uint8 - Certificate string `dns:"hex"` -} - -func (rr *TLSA) String() string { - return rr.Hdr.String() + - strconv.Itoa(int(rr.Usage)) + - " " + strconv.Itoa(int(rr.Selector)) + - " " + strconv.Itoa(int(rr.MatchingType)) + - " " + rr.Certificate -} - -type HIP struct { - Hdr RR_Header - HitLength uint8 - PublicKeyAlgorithm uint8 - PublicKeyLength uint16 - Hit string `dns:"size-hex:HitLength"` - PublicKey string `dns:"size-base64:PublicKeyLength"` - RendezvousServers []string `dns:"domain-name"` -} - -func (rr *HIP) String() string { - s := rr.Hdr.String() + - strconv.Itoa(int(rr.PublicKeyAlgorithm)) + - " " + rr.Hit + - " " + rr.PublicKey - for _, d := range rr.RendezvousServers { - s += " " + sprintName(d) - } - return s -} - -type NINFO struct { - Hdr RR_Header - ZSData []string `dns:"txt"` -} - -func (rr *NINFO) String() string { return rr.Hdr.String() + sprintTxt(rr.ZSData) } - -type NID struct { - Hdr RR_Header - Preference uint16 - NodeID uint64 -} - -func (rr *NID) String() string { - s := rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) - node := fmt.Sprintf("%0.16x", rr.NodeID) - s += " " + node[0:4] + ":" + node[4:8] + ":" + node[8:12] + ":" + node[12:16] - return s -} - -type L32 struct { - Hdr RR_Header - Preference uint16 - Locator32 net.IP `dns:"a"` -} - -func (rr *L32) String() string { - if rr.Locator32 == nil { - return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) - } - return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + - " " + rr.Locator32.String() -} - -type L64 struct { - Hdr RR_Header - Preference uint16 - Locator64 uint64 -} - -func (rr *L64) String() string { - s := rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) - node := fmt.Sprintf("%0.16X", rr.Locator64) - s += " " + node[0:4] + ":" + node[4:8] + ":" + node[8:12] + ":" + node[12:16] - return s -} - -type LP struct { - Hdr RR_Header - Preference uint16 - Fqdn string `dns:"domain-name"` -} - -func (rr *LP) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Preference)) + " " + sprintName(rr.Fqdn) -} - -type EUI48 struct { - Hdr RR_Header - Address uint64 `dns:"uint48"` -} - -func (rr *EUI48) String() string { return rr.Hdr.String() + euiToString(rr.Address, 48) } - -type EUI64 struct { - Hdr RR_Header - Address uint64 -} - -func (rr *EUI64) String() string { return rr.Hdr.String() + euiToString(rr.Address, 64) } - -type CAA struct { - Hdr RR_Header - Flag uint8 - Tag string - Value string `dns:"octet"` -} - -func (rr *CAA) String() string { - return rr.Hdr.String() + strconv.Itoa(int(rr.Flag)) + " " + rr.Tag + " " + sprintTxtOctet(rr.Value) -} - -type UID struct { - Hdr RR_Header - Uid uint32 -} - -func (rr *UID) String() string { return rr.Hdr.String() + strconv.FormatInt(int64(rr.Uid), 10) } - -type GID struct { - Hdr RR_Header - Gid uint32 -} - -func (rr *GID) String() string { return rr.Hdr.String() + strconv.FormatInt(int64(rr.Gid), 10) } - -type UINFO struct { - Hdr RR_Header - Uinfo string -} - -func (rr *UINFO) String() string { return rr.Hdr.String() + sprintTxt([]string{rr.Uinfo}) } - -type EID struct { - Hdr RR_Header - Endpoint string `dns:"hex"` -} - -func (rr *EID) String() string { return rr.Hdr.String() + strings.ToUpper(rr.Endpoint) } - -type NIMLOC struct { - Hdr RR_Header - Locator string `dns:"hex"` -} - -func (rr *NIMLOC) String() string { return rr.Hdr.String() + strings.ToUpper(rr.Locator) } - -type OPENPGPKEY struct { - Hdr RR_Header - PublicKey string `dns:"base64"` -} - -func (rr *OPENPGPKEY) String() string { return rr.Hdr.String() + rr.PublicKey } - -// TimeToString translates the RRSIG's incep. and expir. times to the -// string representation used when printing the record. -// It takes serial arithmetic (RFC 1982) into account. -func TimeToString(t uint32) string { - mod := ((int64(t) - time.Now().Unix()) / year68) - 1 - if mod < 0 { - mod = 0 - } - ti := time.Unix(int64(t)-(mod*year68), 0).UTC() - return ti.Format("20060102150405") -} - -// StringToTime translates the RRSIG's incep. and expir. times from -// string values like "20110403154150" to an 32 bit integer. -// It takes serial arithmetic (RFC 1982) into account. -func StringToTime(s string) (uint32, error) { - t, err := time.Parse("20060102150405", s) - if err != nil { - return 0, err - } - mod := (t.Unix() / year68) - 1 - if mod < 0 { - mod = 0 - } - return uint32(t.Unix() - (mod * year68)), nil -} - -// saltToString converts a NSECX salt to uppercase and -// returns "-" when it is empty -func saltToString(s string) string { - if len(s) == 0 { - return "-" - } - return strings.ToUpper(s) -} - -func euiToString(eui uint64, bits int) (hex string) { - switch bits { - case 64: - hex = fmt.Sprintf("%16.16x", eui) - hex = hex[0:2] + "-" + hex[2:4] + "-" + hex[4:6] + "-" + hex[6:8] + - "-" + hex[8:10] + "-" + hex[10:12] + "-" + hex[12:14] + "-" + hex[14:16] - case 48: - hex = fmt.Sprintf("%12.12x", eui) - hex = hex[0:2] + "-" + hex[2:4] + "-" + hex[4:6] + "-" + hex[6:8] + - "-" + hex[8:10] + "-" + hex[10:12] - } - return -} - -// copyIP returns a copy of ip. -func copyIP(ip net.IP) net.IP { - p := make(net.IP, len(ip)) - copy(p, ip) - return p -} diff --git a/vendor/github.com/miekg/dns/types_generate.go b/vendor/github.com/miekg/dns/types_generate.go deleted file mode 100644 index bf80da3..0000000 --- a/vendor/github.com/miekg/dns/types_generate.go +++ /dev/null @@ -1,271 +0,0 @@ -//+build ignore - -// types_generate.go is meant to run with go generate. It will use -// go/{importer,types} to track down all the RR struct types. Then for each type -// it will generate conversion tables (TypeToRR and TypeToString) and banal -// methods (len, Header, copy) based on the struct tags. The generated source is -// written to ztypes.go, and is meant to be checked into git. -package main - -import ( - "bytes" - "fmt" - "go/format" - "go/importer" - "go/types" - "log" - "os" - "strings" - "text/template" -) - -var skipLen = map[string]struct{}{ - "NSEC": {}, - "NSEC3": {}, - "OPT": {}, -} - -var packageHdr = ` -// *** DO NOT MODIFY *** -// AUTOGENERATED BY go generate from type_generate.go - -package dns - -import ( - "encoding/base64" - "net" -) - -` - -var TypeToRR = template.Must(template.New("TypeToRR").Parse(` -// TypeToRR is a map of constructors for each RR type. -var TypeToRR = map[uint16]func() RR{ -{{range .}}{{if ne . "RFC3597"}} Type{{.}}: func() RR { return new({{.}}) }, -{{end}}{{end}} } - -`)) - -var typeToString = template.Must(template.New("typeToString").Parse(` -// TypeToString is a map of strings for each RR type. -var TypeToString = map[uint16]string{ -{{range .}}{{if ne . "NSAPPTR"}} Type{{.}}: "{{.}}", -{{end}}{{end}} TypeNSAPPTR: "NSAP-PTR", -} - -`)) - -var headerFunc = template.Must(template.New("headerFunc").Parse(` -// Header() functions -{{range .}} func (rr *{{.}}) Header() *RR_Header { return &rr.Hdr } -{{end}} - -`)) - -// getTypeStruct will take a type and the package scope, and return the -// (innermost) struct if the type is considered a RR type (currently defined as -// those structs beginning with a RR_Header, could be redefined as implementing -// the RR interface). The bool return value indicates if embedded structs were -// resolved. -func getTypeStruct(t types.Type, scope *types.Scope) (*types.Struct, bool) { - st, ok := t.Underlying().(*types.Struct) - if !ok { - return nil, false - } - if st.Field(0).Type() == scope.Lookup("RR_Header").Type() { - return st, false - } - if st.Field(0).Anonymous() { - st, _ := getTypeStruct(st.Field(0).Type(), scope) - return st, true - } - return nil, false -} - -func main() { - // Import and type-check the package - pkg, err := importer.Default().Import("github.com/miekg/dns") - fatalIfErr(err) - scope := pkg.Scope() - - // Collect constants like TypeX - var numberedTypes []string - for _, name := range scope.Names() { - o := scope.Lookup(name) - if o == nil || !o.Exported() { - continue - } - b, ok := o.Type().(*types.Basic) - if !ok || b.Kind() != types.Uint16 { - continue - } - if !strings.HasPrefix(o.Name(), "Type") { - continue - } - name := strings.TrimPrefix(o.Name(), "Type") - if name == "PrivateRR" { - continue - } - numberedTypes = append(numberedTypes, name) - } - - // Collect actual types (*X) - var namedTypes []string - for _, name := range scope.Names() { - o := scope.Lookup(name) - if o == nil || !o.Exported() { - continue - } - if st, _ := getTypeStruct(o.Type(), scope); st == nil { - continue - } - if name == "PrivateRR" { - continue - } - - // Check if corresponding TypeX exists - if scope.Lookup("Type"+o.Name()) == nil && o.Name() != "RFC3597" { - log.Fatalf("Constant Type%s does not exist.", o.Name()) - } - - namedTypes = append(namedTypes, o.Name()) - } - - b := &bytes.Buffer{} - b.WriteString(packageHdr) - - // Generate TypeToRR - fatalIfErr(TypeToRR.Execute(b, namedTypes)) - - // Generate typeToString - fatalIfErr(typeToString.Execute(b, numberedTypes)) - - // Generate headerFunc - fatalIfErr(headerFunc.Execute(b, namedTypes)) - - // Generate len() - fmt.Fprint(b, "// len() functions\n") - for _, name := range namedTypes { - if _, ok := skipLen[name]; ok { - continue - } - o := scope.Lookup(name) - st, isEmbedded := getTypeStruct(o.Type(), scope) - if isEmbedded { - continue - } - fmt.Fprintf(b, "func (rr *%s) len() int {\n", name) - fmt.Fprintf(b, "l := rr.Hdr.len()\n") - for i := 1; i < st.NumFields(); i++ { - o := func(s string) { fmt.Fprintf(b, s, st.Field(i).Name()) } - - if _, ok := st.Field(i).Type().(*types.Slice); ok { - switch st.Tag(i) { - case `dns:"-"`: - // ignored - case `dns:"cdomain-name"`, `dns:"domain-name"`, `dns:"txt"`: - o("for _, x := range rr.%s { l += len(x) + 1 }\n") - default: - log.Fatalln(name, st.Field(i).Name(), st.Tag(i)) - } - continue - } - - switch { - case st.Tag(i) == `dns:"-"`: - // ignored - case st.Tag(i) == `dns:"cdomain-name"`, st.Tag(i) == `dns:"domain-name"`: - o("l += len(rr.%s) + 1\n") - case st.Tag(i) == `dns:"octet"`: - o("l += len(rr.%s)\n") - case strings.HasPrefix(st.Tag(i), `dns:"size-base64`): - fallthrough - case st.Tag(i) == `dns:"base64"`: - o("l += base64.StdEncoding.DecodedLen(len(rr.%s))\n") - case strings.HasPrefix(st.Tag(i), `dns:"size-hex`): - fallthrough - case st.Tag(i) == `dns:"hex"`: - o("l += len(rr.%s)/2 + 1\n") - case st.Tag(i) == `dns:"a"`: - o("l += net.IPv4len // %s\n") - case st.Tag(i) == `dns:"aaaa"`: - o("l += net.IPv6len // %s\n") - case st.Tag(i) == `dns:"txt"`: - o("for _, t := range rr.%s { l += len(t) + 1 }\n") - case st.Tag(i) == `dns:"uint48"`: - o("l += 6 // %s\n") - case st.Tag(i) == "": - switch st.Field(i).Type().(*types.Basic).Kind() { - case types.Uint8: - o("l += 1 // %s\n") - case types.Uint16: - o("l += 2 // %s\n") - case types.Uint32: - o("l += 4 // %s\n") - case types.Uint64: - o("l += 8 // %s\n") - case types.String: - o("l += len(rr.%s) + 1\n") - default: - log.Fatalln(name, st.Field(i).Name()) - } - default: - log.Fatalln(name, st.Field(i).Name(), st.Tag(i)) - } - } - fmt.Fprintf(b, "return l }\n") - } - - // Generate copy() - fmt.Fprint(b, "// copy() functions\n") - for _, name := range namedTypes { - o := scope.Lookup(name) - st, isEmbedded := getTypeStruct(o.Type(), scope) - if isEmbedded { - continue - } - fmt.Fprintf(b, "func (rr *%s) copy() RR {\n", name) - fields := []string{"*rr.Hdr.copyHeader()"} - for i := 1; i < st.NumFields(); i++ { - f := st.Field(i).Name() - if sl, ok := st.Field(i).Type().(*types.Slice); ok { - t := sl.Underlying().String() - t = strings.TrimPrefix(t, "[]") - if strings.Contains(t, ".") { - splits := strings.Split(t, ".") - t = splits[len(splits)-1] - } - fmt.Fprintf(b, "%s := make([]%s, len(rr.%s)); copy(%s, rr.%s)\n", - f, t, f, f, f) - fields = append(fields, f) - continue - } - if st.Field(i).Type().String() == "net.IP" { - fields = append(fields, "copyIP(rr."+f+")") - continue - } - fields = append(fields, "rr."+f) - } - fmt.Fprintf(b, "return &%s{%s}\n", name, strings.Join(fields, ",")) - fmt.Fprintf(b, "}\n") - } - - // gofmt - res, err := format.Source(b.Bytes()) - if err != nil { - b.WriteTo(os.Stderr) - log.Fatal(err) - } - - // write result - f, err := os.Create("ztypes.go") - fatalIfErr(err) - defer f.Close() - f.Write(res) -} - -func fatalIfErr(err error) { - if err != nil { - log.Fatal(err) - } -} diff --git a/vendor/github.com/miekg/dns/types_test.go b/vendor/github.com/miekg/dns/types_test.go deleted file mode 100644 index 1186129..0000000 --- a/vendor/github.com/miekg/dns/types_test.go +++ /dev/null @@ -1,42 +0,0 @@ -package dns - -import ( - "testing" -) - -func TestCmToM(t *testing.T) { - s := cmToM(0, 0) - if s != "0.00" { - t.Error("0, 0") - } - - s = cmToM(1, 0) - if s != "0.01" { - t.Error("1, 0") - } - - s = cmToM(3, 1) - if s != "0.30" { - t.Error("3, 1") - } - - s = cmToM(4, 2) - if s != "4" { - t.Error("4, 2") - } - - s = cmToM(5, 3) - if s != "50" { - t.Error("5, 3") - } - - s = cmToM(7, 5) - if s != "7000" { - t.Error("7, 5") - } - - s = cmToM(9, 9) - if s != "90000000" { - t.Error("9, 9") - } -} diff --git a/vendor/github.com/miekg/dns/udp.go b/vendor/github.com/miekg/dns/udp.go deleted file mode 100644 index c79c6c8..0000000 --- a/vendor/github.com/miekg/dns/udp.go +++ /dev/null @@ -1,58 +0,0 @@ -// +build !windows,!plan9 - -package dns - -import ( - "net" - "syscall" -) - -// SessionUDP holds the remote address and the associated -// out-of-band data. -type SessionUDP struct { - raddr *net.UDPAddr - context []byte -} - -// RemoteAddr returns the remote network address. -func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr } - -// setUDPSocketOptions sets the UDP socket options. -// This function is implemented on a per platform basis. See udp_*.go for more details -func setUDPSocketOptions(conn *net.UDPConn) error { - sa, err := getUDPSocketName(conn) - if err != nil { - return err - } - switch sa.(type) { - case *syscall.SockaddrInet6: - v6only, err := getUDPSocketOptions6Only(conn) - if err != nil { - return err - } - setUDPSocketOptions6(conn) - if !v6only { - setUDPSocketOptions4(conn) - } - case *syscall.SockaddrInet4: - setUDPSocketOptions4(conn) - } - return nil -} - -// ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a -// net.UDPAddr. -func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) { - oob := make([]byte, 40) - n, oobn, _, raddr, err := conn.ReadMsgUDP(b, oob) - if err != nil { - return n, nil, err - } - return n, &SessionUDP{raddr, oob[:oobn]}, err -} - -// WriteToSessionUDP acts just like net.UDPConn.WritetTo(), but uses a *SessionUDP instead of a net.Addr. -func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) { - n, _, err := conn.WriteMsgUDP(b, session.context, session.raddr) - return n, err -} diff --git a/vendor/github.com/miekg/dns/udp_linux.go b/vendor/github.com/miekg/dns/udp_linux.go deleted file mode 100644 index c62d218..0000000 --- a/vendor/github.com/miekg/dns/udp_linux.go +++ /dev/null @@ -1,73 +0,0 @@ -// +build linux - -package dns - -// See: -// * http://stackoverflow.com/questions/3062205/setting-the-source-ip-for-a-udp-socket and -// * http://blog.powerdns.com/2012/10/08/on-binding-datagram-udp-sockets-to-the-any-addresses/ -// -// Why do we need this: When listening on 0.0.0.0 with UDP so kernel decides what is the outgoing -// interface, this might not always be the correct one. This code will make sure the egress -// packet's interface matched the ingress' one. - -import ( - "net" - "syscall" -) - -// setUDPSocketOptions4 prepares the v4 socket for sessions. -func setUDPSocketOptions4(conn *net.UDPConn) error { - file, err := conn.File() - if err != nil { - return err - } - if err := syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IP, syscall.IP_PKTINFO, 1); err != nil { - return err - } - // Calling File() above results in the connection becoming blocking, we must fix that. - // See https://github.com/miekg/dns/issues/279 - err = syscall.SetNonblock(int(file.Fd()), true) - if err != nil { - return err - } - return nil -} - -// setUDPSocketOptions6 prepares the v6 socket for sessions. -func setUDPSocketOptions6(conn *net.UDPConn) error { - file, err := conn.File() - if err != nil { - return err - } - if err := syscall.SetsockoptInt(int(file.Fd()), syscall.IPPROTO_IPV6, syscall.IPV6_RECVPKTINFO, 1); err != nil { - return err - } - err = syscall.SetNonblock(int(file.Fd()), true) - if err != nil { - return err - } - return nil -} - -// getUDPSocketOption6Only return true if the socket is v6 only and false when it is v4/v6 combined -// (dualstack). -func getUDPSocketOptions6Only(conn *net.UDPConn) (bool, error) { - file, err := conn.File() - if err != nil { - return false, err - } - // dual stack. See http://stackoverflow.com/questions/1618240/how-to-support-both-ipv4-and-ipv6-connections - v6only, err := syscall.GetsockoptInt(int(file.Fd()), syscall.IPPROTO_IPV6, syscall.IPV6_V6ONLY) - if err != nil { - return false, err - } - return v6only == 1, nil -} - -func getUDPSocketName(conn *net.UDPConn) (syscall.Sockaddr, error) { - file, err := conn.File() - if err != nil { - return nil, err - } - return syscall.Getsockname(int(file.Fd())) -} diff --git a/vendor/github.com/miekg/dns/udp_other.go b/vendor/github.com/miekg/dns/udp_other.go deleted file mode 100644 index d407324..0000000 --- a/vendor/github.com/miekg/dns/udp_other.go +++ /dev/null @@ -1,17 +0,0 @@ -// +build !linux,!plan9 - -package dns - -import ( - "net" - "syscall" -) - -// These do nothing. See udp_linux.go for an example of how to implement this. - -// We tried to adhire to some kind of naming scheme. - -func setUDPSocketOptions4(conn *net.UDPConn) error { return nil } -func setUDPSocketOptions6(conn *net.UDPConn) error { return nil } -func getUDPSocketOptions6Only(conn *net.UDPConn) (bool, error) { return false, nil } -func getUDPSocketName(conn *net.UDPConn) (syscall.Sockaddr, error) { return nil, nil } diff --git a/vendor/github.com/miekg/dns/udp_plan9.go b/vendor/github.com/miekg/dns/udp_plan9.go deleted file mode 100644 index b794dee..0000000 --- a/vendor/github.com/miekg/dns/udp_plan9.go +++ /dev/null @@ -1,34 +0,0 @@ -package dns - -import ( - "net" -) - -func setUDPSocketOptions(conn *net.UDPConn) error { return nil } - -// SessionUDP holds the remote address and the associated -// out-of-band data. -type SessionUDP struct { - raddr *net.UDPAddr - context []byte -} - -// RemoteAddr returns the remote network address. -func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr } - -// ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a -// net.UDPAddr. -func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) { - oob := make([]byte, 40) - n, oobn, _, raddr, err := conn.ReadMsgUDP(b, oob) - if err != nil { - return n, nil, err - } - return n, &SessionUDP{raddr, oob[:oobn]}, err -} - -// WriteToSessionUDP acts just like net.UDPConn.WritetTo(), but uses a *SessionUDP instead of a net.Addr. -func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) { - n, _, err := conn.WriteMsgUDP(b, session.context, session.raddr) - return n, err -} diff --git a/vendor/github.com/miekg/dns/udp_windows.go b/vendor/github.com/miekg/dns/udp_windows.go deleted file mode 100644 index 2ce4b33..0000000 --- a/vendor/github.com/miekg/dns/udp_windows.go +++ /dev/null @@ -1,34 +0,0 @@ -// +build windows - -package dns - -import "net" - -type SessionUDP struct { - raddr *net.UDPAddr -} - -// ReadFromSessionUDP acts just like net.UDPConn.ReadFrom(), but returns a session object instead of a -// net.UDPAddr. -func ReadFromSessionUDP(conn *net.UDPConn, b []byte) (int, *SessionUDP, error) { - n, raddr, err := conn.ReadFrom(b) - if err != nil { - return n, nil, err - } - session := &SessionUDP{raddr.(*net.UDPAddr)} - return n, session, err -} - -// WriteToSessionUDP acts just like net.UDPConn.WritetTo(), but uses a *SessionUDP instead of a net.Addr. -func WriteToSessionUDP(conn *net.UDPConn, b []byte, session *SessionUDP) (int, error) { - n, err := conn.WriteTo(b, session.raddr) - return n, err -} - -func (s *SessionUDP) RemoteAddr() net.Addr { return s.raddr } - -// setUDPSocketOptions sets the UDP socket options. -// This function is implemented on a per platform basis. See udp_*.go for more details -func setUDPSocketOptions(conn *net.UDPConn) error { - return nil -} diff --git a/vendor/github.com/miekg/dns/update.go b/vendor/github.com/miekg/dns/update.go deleted file mode 100644 index e90c5c9..0000000 --- a/vendor/github.com/miekg/dns/update.go +++ /dev/null @@ -1,106 +0,0 @@ -package dns - -// NameUsed sets the RRs in the prereq section to -// "Name is in use" RRs. RFC 2136 section 2.4.4. -func (u *Msg) NameUsed(rr []RR) { - if u.Answer == nil { - u.Answer = make([]RR, 0, len(rr)) - } - for _, r := range rr { - u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}) - } -} - -// NameNotUsed sets the RRs in the prereq section to -// "Name is in not use" RRs. RFC 2136 section 2.4.5. -func (u *Msg) NameNotUsed(rr []RR) { - if u.Answer == nil { - u.Answer = make([]RR, 0, len(rr)) - } - for _, r := range rr { - u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassNONE}}) - } -} - -// Used sets the RRs in the prereq section to -// "RRset exists (value dependent -- with rdata)" RRs. RFC 2136 section 2.4.2. -func (u *Msg) Used(rr []RR) { - if len(u.Question) == 0 { - panic("dns: empty question section") - } - if u.Answer == nil { - u.Answer = make([]RR, 0, len(rr)) - } - for _, r := range rr { - r.Header().Class = u.Question[0].Qclass - u.Answer = append(u.Answer, r) - } -} - -// RRsetUsed sets the RRs in the prereq section to -// "RRset exists (value independent -- no rdata)" RRs. RFC 2136 section 2.4.1. -func (u *Msg) RRsetUsed(rr []RR) { - if u.Answer == nil { - u.Answer = make([]RR, 0, len(rr)) - } - for _, r := range rr { - u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: r.Header().Rrtype, Class: ClassANY}}) - } -} - -// RRsetNotUsed sets the RRs in the prereq section to -// "RRset does not exist" RRs. RFC 2136 section 2.4.3. -func (u *Msg) RRsetNotUsed(rr []RR) { - if u.Answer == nil { - u.Answer = make([]RR, 0, len(rr)) - } - for _, r := range rr { - u.Answer = append(u.Answer, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: r.Header().Rrtype, Class: ClassNONE}}) - } -} - -// Insert creates a dynamic update packet that adds an complete RRset, see RFC 2136 section 2.5.1. -func (u *Msg) Insert(rr []RR) { - if len(u.Question) == 0 { - panic("dns: empty question section") - } - if u.Ns == nil { - u.Ns = make([]RR, 0, len(rr)) - } - for _, r := range rr { - r.Header().Class = u.Question[0].Qclass - u.Ns = append(u.Ns, r) - } -} - -// RemoveRRset creates a dynamic update packet that deletes an RRset, see RFC 2136 section 2.5.2. -func (u *Msg) RemoveRRset(rr []RR) { - if u.Ns == nil { - u.Ns = make([]RR, 0, len(rr)) - } - for _, r := range rr { - u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: r.Header().Rrtype, Class: ClassANY}}) - } -} - -// RemoveName creates a dynamic update packet that deletes all RRsets of a name, see RFC 2136 section 2.5.3 -func (u *Msg) RemoveName(rr []RR) { - if u.Ns == nil { - u.Ns = make([]RR, 0, len(rr)) - } - for _, r := range rr { - u.Ns = append(u.Ns, &ANY{Hdr: RR_Header{Name: r.Header().Name, Ttl: 0, Rrtype: TypeANY, Class: ClassANY}}) - } -} - -// Remove creates a dynamic update packet deletes RR from a RRSset, see RFC 2136 section 2.5.4 -func (u *Msg) Remove(rr []RR) { - if u.Ns == nil { - u.Ns = make([]RR, 0, len(rr)) - } - for _, r := range rr { - r.Header().Class = ClassNONE - r.Header().Ttl = 0 - u.Ns = append(u.Ns, r) - } -} diff --git a/vendor/github.com/miekg/dns/update_test.go b/vendor/github.com/miekg/dns/update_test.go deleted file mode 100644 index 56602df..0000000 --- a/vendor/github.com/miekg/dns/update_test.go +++ /dev/null @@ -1,145 +0,0 @@ -package dns - -import ( - "bytes" - "testing" -) - -func TestDynamicUpdateParsing(t *testing.T) { - prefix := "example.com. IN " - for _, typ := range TypeToString { - if typ == "OPT" || typ == "AXFR" || typ == "IXFR" || typ == "ANY" || typ == "TKEY" || - typ == "TSIG" || typ == "ISDN" || typ == "UNSPEC" || typ == "NULL" || typ == "ATMA" || - typ == "Reserved" || typ == "None" || typ == "NXT" || typ == "MAILB" || typ == "MAILA" { - continue - } - r, err := NewRR(prefix + typ) - if err != nil { - t.Errorf("failure to parse: %s %s: %v", prefix, typ, err) - } else { - t.Logf("parsed: %s", r.String()) - } - } -} - -func TestDynamicUpdateUnpack(t *testing.T) { - // From https://github.com/miekg/dns/issues/150#issuecomment-62296803 - // It should be an update message for the zone "example.", - // deleting the A RRset "example." and then adding an A record at "example.". - // class ANY, TYPE A - buf := []byte{171, 68, 40, 0, 0, 1, 0, 0, 0, 2, 0, 0, 7, 101, 120, 97, 109, 112, 108, 101, 0, 0, 6, 0, 1, 192, 12, 0, 1, 0, 255, 0, 0, 0, 0, 0, 0, 192, 12, 0, 1, 0, 1, 0, 0, 0, 0, 0, 4, 127, 0, 0, 1} - msg := new(Msg) - err := msg.Unpack(buf) - if err != nil { - t.Errorf("failed to unpack: %v\n%s", err, msg.String()) - } -} - -func TestDynamicUpdateZeroRdataUnpack(t *testing.T) { - m := new(Msg) - rr := &RR_Header{Name: ".", Rrtype: 0, Class: 1, Ttl: ^uint32(0), Rdlength: 0} - m.Answer = []RR{rr, rr, rr, rr, rr} - m.Ns = m.Answer - for n, s := range TypeToString { - rr.Rrtype = n - bytes, err := m.Pack() - if err != nil { - t.Errorf("failed to pack %s: %v", s, err) - continue - } - if err := new(Msg).Unpack(bytes); err != nil { - t.Errorf("failed to unpack %s: %v", s, err) - } - } -} - -func TestRemoveRRset(t *testing.T) { - // Should add a zero data RR in Class ANY with a TTL of 0 - // for each set mentioned in the RRs provided to it. - rr, err := NewRR(". 100 IN A 127.0.0.1") - if err != nil { - t.Fatalf("error constructing RR: %v", err) - } - m := new(Msg) - m.Ns = []RR{&RR_Header{Name: ".", Rrtype: TypeA, Class: ClassANY, Ttl: 0, Rdlength: 0}} - expectstr := m.String() - expect, err := m.Pack() - if err != nil { - t.Fatalf("error packing expected msg: %v", err) - } - - m.Ns = nil - m.RemoveRRset([]RR{rr}) - actual, err := m.Pack() - if err != nil { - t.Fatalf("error packing actual msg: %v", err) - } - if !bytes.Equal(actual, expect) { - tmp := new(Msg) - if err := tmp.Unpack(actual); err != nil { - t.Fatalf("error unpacking actual msg: %v\nexpected: %v\ngot: %v\n", err, expect, actual) - } - t.Errorf("expected msg:\n%s", expectstr) - t.Errorf("actual msg:\n%v", tmp) - } -} - -func TestPreReqAndRemovals(t *testing.T) { - // Build a list of multiple prereqs and then somes removes followed by an insert. - // We should be able to add multiple prereqs and updates. - m := new(Msg) - m.SetUpdate("example.org.") - m.Id = 1234 - - // Use a full set of RRs each time, so we are sure the rdata is stripped. - rr_name1, _ := NewRR("name_used. 3600 IN A 127.0.0.1") - rr_name2, _ := NewRR("name_not_used. 3600 IN A 127.0.0.1") - rr_remove1, _ := NewRR("remove1. 3600 IN A 127.0.0.1") - rr_remove2, _ := NewRR("remove2. 3600 IN A 127.0.0.1") - rr_remove3, _ := NewRR("remove3. 3600 IN A 127.0.0.1") - rr_insert, _ := NewRR("insert. 3600 IN A 127.0.0.1") - rr_rrset1, _ := NewRR("rrset_used1. 3600 IN A 127.0.0.1") - rr_rrset2, _ := NewRR("rrset_used2. 3600 IN A 127.0.0.1") - rr_rrset3, _ := NewRR("rrset_not_used. 3600 IN A 127.0.0.1") - - // Handle the prereqs. - m.NameUsed([]RR{rr_name1}) - m.NameNotUsed([]RR{rr_name2}) - m.RRsetUsed([]RR{rr_rrset1}) - m.Used([]RR{rr_rrset2}) - m.RRsetNotUsed([]RR{rr_rrset3}) - - // and now the updates. - m.RemoveName([]RR{rr_remove1}) - m.RemoveRRset([]RR{rr_remove2}) - m.Remove([]RR{rr_remove3}) - m.Insert([]RR{rr_insert}) - - // This test function isn't a Example function because we print these RR with tabs at the - // end and the Example function trim these, thus they never match. - // TODO(miek): don't print these tabs and make this into an Example function. - expect := `;; opcode: UPDATE, status: NOERROR, id: 1234 -;; flags:; QUERY: 1, ANSWER: 5, AUTHORITY: 4, ADDITIONAL: 0 - -;; QUESTION SECTION: -;example.org. IN SOA - -;; ANSWER SECTION: -name_used. 0 ANY ANY -name_not_used. 0 NONE ANY -rrset_used1. 0 ANY A -rrset_used2. 3600 IN A 127.0.0.1 -rrset_not_used. 0 NONE A - -;; AUTHORITY SECTION: -remove1. 0 ANY ANY -remove2. 0 ANY A -remove3. 0 NONE A 127.0.0.1 -insert. 3600 IN A 127.0.0.1 -` - - if m.String() != expect { - t.Errorf("expected msg:\n%s", expect) - t.Errorf("actual msg:\n%v", m.String()) - } -} diff --git a/vendor/github.com/miekg/dns/xfr.go b/vendor/github.com/miekg/dns/xfr.go deleted file mode 100644 index 7346def..0000000 --- a/vendor/github.com/miekg/dns/xfr.go +++ /dev/null @@ -1,244 +0,0 @@ -package dns - -import ( - "time" -) - -// Envelope is used when doing a zone transfer with a remote server. -type Envelope struct { - RR []RR // The set of RRs in the answer section of the xfr reply message. - Error error // If something went wrong, this contains the error. -} - -// A Transfer defines parameters that are used during a zone transfer. -type Transfer struct { - *Conn - DialTimeout time.Duration // net.DialTimeout, defaults to 2 seconds - ReadTimeout time.Duration // net.Conn.SetReadTimeout value for connections, defaults to 2 seconds - WriteTimeout time.Duration // net.Conn.SetWriteTimeout value for connections, defaults to 2 seconds - TsigSecret map[string]string // Secret(s) for Tsig map[], zonename must be fully qualified - tsigTimersOnly bool -} - -// Think we need to away to stop the transfer - -// In performs an incoming transfer with the server in a. -// If you would like to set the source IP, or some other attribute -// of a Dialer for a Transfer, you can do so by specifying the attributes -// in the Transfer.Conn: -// -// d := net.Dialer{LocalAddr: transfer_source} -// con, err := d.Dial("tcp", master) -// dnscon := &dns.Conn{Conn:con} -// transfer = &dns.Transfer{Conn: dnscon} -// channel, err := transfer.In(message, master) -// -func (t *Transfer) In(q *Msg, a string) (env chan *Envelope, err error) { - timeout := dnsTimeout - if t.DialTimeout != 0 { - timeout = t.DialTimeout - } - if t.Conn == nil { - t.Conn, err = DialTimeout("tcp", a, timeout) - if err != nil { - return nil, err - } - } - if err := t.WriteMsg(q); err != nil { - return nil, err - } - env = make(chan *Envelope) - go func() { - if q.Question[0].Qtype == TypeAXFR { - go t.inAxfr(q.Id, env) - return - } - if q.Question[0].Qtype == TypeIXFR { - go t.inIxfr(q.Id, env) - return - } - }() - return env, nil -} - -func (t *Transfer) inAxfr(id uint16, c chan *Envelope) { - first := true - defer t.Close() - defer close(c) - timeout := dnsTimeout - if t.ReadTimeout != 0 { - timeout = t.ReadTimeout - } - for { - t.Conn.SetReadDeadline(time.Now().Add(timeout)) - in, err := t.ReadMsg() - if err != nil { - c <- &Envelope{nil, err} - return - } - if id != in.Id { - c <- &Envelope{in.Answer, ErrId} - return - } - if first { - if !isSOAFirst(in) { - c <- &Envelope{in.Answer, ErrSoa} - return - } - first = !first - // only one answer that is SOA, receive more - if len(in.Answer) == 1 { - t.tsigTimersOnly = true - c <- &Envelope{in.Answer, nil} - continue - } - } - - if !first { - t.tsigTimersOnly = true // Subsequent envelopes use this. - if isSOALast(in) { - c <- &Envelope{in.Answer, nil} - return - } - c <- &Envelope{in.Answer, nil} - } - } -} - -func (t *Transfer) inIxfr(id uint16, c chan *Envelope) { - serial := uint32(0) // The first serial seen is the current server serial - first := true - defer t.Close() - defer close(c) - timeout := dnsTimeout - if t.ReadTimeout != 0 { - timeout = t.ReadTimeout - } - for { - t.SetReadDeadline(time.Now().Add(timeout)) - in, err := t.ReadMsg() - if err != nil { - c <- &Envelope{nil, err} - return - } - if id != in.Id { - c <- &Envelope{in.Answer, ErrId} - return - } - if first { - // A single SOA RR signals "no changes" - if len(in.Answer) == 1 && isSOAFirst(in) { - c <- &Envelope{in.Answer, nil} - return - } - - // Check if the returned answer is ok - if !isSOAFirst(in) { - c <- &Envelope{in.Answer, ErrSoa} - return - } - // This serial is important - serial = in.Answer[0].(*SOA).Serial - first = !first - } - - // Now we need to check each message for SOA records, to see what we need to do - if !first { - t.tsigTimersOnly = true - // If the last record in the IXFR contains the servers' SOA, we should quit - if v, ok := in.Answer[len(in.Answer)-1].(*SOA); ok { - if v.Serial == serial { - c <- &Envelope{in.Answer, nil} - return - } - } - c <- &Envelope{in.Answer, nil} - } - } -} - -// Out performs an outgoing transfer with the client connecting in w. -// Basic use pattern: -// -// ch := make(chan *dns.Envelope) -// tr := new(dns.Transfer) -// go tr.Out(w, r, ch) -// ch <- &dns.Envelope{RR: []dns.RR{soa, rr1, rr2, rr3, soa}} -// close(ch) -// w.Hijack() -// // w.Close() // Client closes connection -// -// The server is responsible for sending the correct sequence of RRs through the -// channel ch. -func (t *Transfer) Out(w ResponseWriter, q *Msg, ch chan *Envelope) error { - for x := range ch { - r := new(Msg) - // Compress? - r.SetReply(q) - r.Authoritative = true - // assume it fits TODO(miek): fix - r.Answer = append(r.Answer, x.RR...) - if err := w.WriteMsg(r); err != nil { - return err - } - } - w.TsigTimersOnly(true) - return nil -} - -// ReadMsg reads a message from the transfer connection t. -func (t *Transfer) ReadMsg() (*Msg, error) { - m := new(Msg) - p := make([]byte, MaxMsgSize) - n, err := t.Read(p) - if err != nil && n == 0 { - return nil, err - } - p = p[:n] - if err := m.Unpack(p); err != nil { - return nil, err - } - if ts := m.IsTsig(); ts != nil && t.TsigSecret != nil { - if _, ok := t.TsigSecret[ts.Hdr.Name]; !ok { - return m, ErrSecret - } - // Need to work on the original message p, as that was used to calculate the tsig. - err = TsigVerify(p, t.TsigSecret[ts.Hdr.Name], t.tsigRequestMAC, t.tsigTimersOnly) - t.tsigRequestMAC = ts.MAC - } - return m, err -} - -// WriteMsg writes a message through the transfer connection t. -func (t *Transfer) WriteMsg(m *Msg) (err error) { - var out []byte - if ts := m.IsTsig(); ts != nil && t.TsigSecret != nil { - if _, ok := t.TsigSecret[ts.Hdr.Name]; !ok { - return ErrSecret - } - out, t.tsigRequestMAC, err = TsigGenerate(m, t.TsigSecret[ts.Hdr.Name], t.tsigRequestMAC, t.tsigTimersOnly) - } else { - out, err = m.Pack() - } - if err != nil { - return err - } - if _, err = t.Write(out); err != nil { - return err - } - return nil -} - -func isSOAFirst(in *Msg) bool { - if len(in.Answer) > 0 { - return in.Answer[0].Header().Rrtype == TypeSOA - } - return false -} - -func isSOALast(in *Msg) bool { - if len(in.Answer) > 0 { - return in.Answer[len(in.Answer)-1].Header().Rrtype == TypeSOA - } - return false -} diff --git a/vendor/github.com/miekg/dns/xfr_test.go b/vendor/github.com/miekg/dns/xfr_test.go deleted file mode 100644 index 1337eec..0000000 --- a/vendor/github.com/miekg/dns/xfr_test.go +++ /dev/null @@ -1,161 +0,0 @@ -// +build net - -package dns - -import ( - "net" - "testing" - "time" -) - -func getIP(s string) string { - a, err := net.LookupAddr(s) - if err != nil { - return "" - } - return a[0] -} - -// flaky, need to setup local server and test from -// that. -func TestAXFR_Miek(t *testing.T) { - // This test runs against a server maintained by Miek - if testing.Short() { - return - } - m := new(Msg) - m.SetAxfr("miek.nl.") - - server := getIP("linode.atoom.net") - - tr := new(Transfer) - - if a, err := tr.In(m, net.JoinHostPort(server, "53")); err != nil { - t.Fatal("failed to setup axfr: ", err) - } else { - for ex := range a { - if ex.Error != nil { - t.Errorf("error %v", ex.Error) - break - } - for _, rr := range ex.RR { - t.Log(rr.String()) - } - } - } -} - -// fails. -func TestAXFR_NLNL_MultipleEnvelopes(t *testing.T) { - // This test runs against a server maintained by NLnet Labs - if testing.Short() { - return - } - m := new(Msg) - m.SetAxfr("nlnetlabs.nl.") - - server := getIP("open.nlnetlabs.nl.") - - tr := new(Transfer) - if a, err := tr.In(m, net.JoinHostPort(server, "53")); err != nil { - t.Fatalf("failed to setup axfr %v for server: %v", err, server) - } else { - for ex := range a { - if ex.Error != nil { - t.Errorf("error %v", ex.Error) - break - } - } - } -} - -func TestAXFR_Miek_Tsig(t *testing.T) { - // This test runs against a server maintained by Miek - if testing.Short() { - return - } - m := new(Msg) - m.SetAxfr("example.nl.") - m.SetTsig("axfr.", HmacMD5, 300, time.Now().Unix()) - - tr := new(Transfer) - tr.TsigSecret = map[string]string{"axfr.": "so6ZGir4GPAqINNh9U5c3A=="} - - if a, err := tr.In(m, "176.58.119.54:53"); err != nil { - t.Fatal("failed to setup axfr: ", err) - } else { - for ex := range a { - if ex.Error != nil { - t.Errorf("error %v", ex.Error) - break - } - for _, rr := range ex.RR { - t.Log(rr.String()) - } - } - } -} - -func TestAXFR_SIDN_NSD3_NONE(t *testing.T) { testAXFRSIDN(t, "nsd", "") } -func TestAXFR_SIDN_NSD3_MD5(t *testing.T) { testAXFRSIDN(t, "nsd", HmacMD5) } -func TestAXFR_SIDN_NSD3_SHA1(t *testing.T) { testAXFRSIDN(t, "nsd", HmacSHA1) } -func TestAXFR_SIDN_NSD3_SHA256(t *testing.T) { testAXFRSIDN(t, "nsd", HmacSHA256) } - -func TestAXFR_SIDN_NSD4_NONE(t *testing.T) { testAXFRSIDN(t, "nsd4", "") } -func TestAXFR_SIDN_NSD4_MD5(t *testing.T) { testAXFRSIDN(t, "nsd4", HmacMD5) } -func TestAXFR_SIDN_NSD4_SHA1(t *testing.T) { testAXFRSIDN(t, "nsd4", HmacSHA1) } -func TestAXFR_SIDN_NSD4_SHA256(t *testing.T) { testAXFRSIDN(t, "nsd4", HmacSHA256) } - -func TestAXFR_SIDN_BIND9_NONE(t *testing.T) { testAXFRSIDN(t, "bind9", "") } -func TestAXFR_SIDN_BIND9_MD5(t *testing.T) { testAXFRSIDN(t, "bind9", HmacMD5) } -func TestAXFR_SIDN_BIND9_SHA1(t *testing.T) { testAXFRSIDN(t, "bind9", HmacSHA1) } -func TestAXFR_SIDN_BIND9_SHA256(t *testing.T) { testAXFRSIDN(t, "bind9", HmacSHA256) } - -func TestAXFR_SIDN_KNOT_NONE(t *testing.T) { testAXFRSIDN(t, "knot", "") } -func TestAXFR_SIDN_KNOT_MD5(t *testing.T) { testAXFRSIDN(t, "knot", HmacMD5) } -func TestAXFR_SIDN_KNOT_SHA1(t *testing.T) { testAXFRSIDN(t, "knot", HmacSHA1) } -func TestAXFR_SIDN_KNOT_SHA256(t *testing.T) { testAXFRSIDN(t, "knot", HmacSHA256) } - -func TestAXFR_SIDN_POWERDNS_NONE(t *testing.T) { testAXFRSIDN(t, "powerdns", "") } -func TestAXFR_SIDN_POWERDNS_MD5(t *testing.T) { testAXFRSIDN(t, "powerdns", HmacMD5) } -func TestAXFR_SIDN_POWERDNS_SHA1(t *testing.T) { testAXFRSIDN(t, "powerdns", HmacSHA1) } -func TestAXFR_SIDN_POWERDNS_SHA256(t *testing.T) { testAXFRSIDN(t, "powerdns", HmacSHA256) } - -func TestAXFR_SIDN_YADIFA_NONE(t *testing.T) { testAXFRSIDN(t, "yadifa", "") } -func TestAXFR_SIDN_YADIFA_MD5(t *testing.T) { testAXFRSIDN(t, "yadifa", HmacMD5) } -func TestAXFR_SIDN_YADIFA_SHA1(t *testing.T) { testAXFRSIDN(t, "yadifa", HmacSHA1) } -func TestAXFR_SIDN_YADIFA_SHA256(t *testing.T) { testAXFRSIDN(t, "yadifa", HmacSHA256) } - -func testAXFRSIDN(t *testing.T, host, alg string) { - // This tests run against a server maintained by SIDN labs, see: - // https://workbench.sidnlabs.nl/ - if testing.Short() { - return - } - x := new(Transfer) - x.TsigSecret = map[string]string{ - "wb_md5.": "Wu/utSasZUkoeCNku152Zw==", - "wb_sha1_longkey.": "uhMpEhPq/RAD9Bt4mqhfmi+7ZdKmjLQb/lcrqYPXR4s/nnbsqw==", - "wb_sha256.": "npfrIJjt/MJOjGJoBNZtsjftKMhkSpIYMv2RzRZt1f8=", - } - keyname := map[string]string{ - HmacMD5: "wb_md5.", - HmacSHA1: "wb_sha1_longkey.", - HmacSHA256: "wb_sha256.", - }[alg] - - m := new(Msg) - m.SetAxfr("types.wb.sidnlabs.nl.") - if keyname != "" { - m.SetTsig(keyname, alg, 300, time.Now().Unix()) - } - c, err := x.In(m, host+".sidnlabs.nl:53") - if err != nil { - t.Fatal(err) - } - for e := range c { - if e.Error != nil { - t.Fatal(e.Error) - } - } -} diff --git a/vendor/github.com/miekg/dns/zmsg.go b/vendor/github.com/miekg/dns/zmsg.go deleted file mode 100644 index e5f3cf2..0000000 --- a/vendor/github.com/miekg/dns/zmsg.go +++ /dev/null @@ -1,3462 +0,0 @@ -// *** DO NOT MODIFY *** -// AUTOGENERATED BY go generate from msg_generate.go - -package dns - -// pack*() functions - -func (rr *A) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packDataA(rr.A, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *AAAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packDataAAAA(rr.AAAA, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *AFSDB) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Subtype, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Hostname, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *ANY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *CAA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint8(rr.Flag, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Tag, msg, off) - if err != nil { - return off, err - } - off, err = packStringOctet(rr.Value, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *CDNSKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Flags, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Protocol, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.PublicKey, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *CDS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.DigestType, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Digest, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *CERT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Type, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.Certificate, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *CNAME) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Target, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *DHCID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringBase64(rr.Digest, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *DLV) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.DigestType, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Digest, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *DNAME) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Target, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *DNSKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Flags, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Protocol, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.PublicKey, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *DS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.DigestType, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Digest, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *EID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringHex(rr.Endpoint, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *EUI48) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint48(rr.Address, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *EUI64) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint64(rr.Address, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *GID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint32(rr.Gid, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *GPOS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packString(rr.Longitude, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Latitude, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Altitude, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *HINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packString(rr.Cpu, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Os, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *HIP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint8(rr.HitLength, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.PublicKeyAlgorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.PublicKeyLength, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Hit, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.PublicKey, msg, off) - if err != nil { - return off, err - } - off, err = packDataDomainNames(rr.RendezvousServers, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *KEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Flags, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Protocol, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.PublicKey, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *KX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Exchanger, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *L32) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = packDataA(rr.Locator32, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *L64) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = packUint64(rr.Locator64, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *LOC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint8(rr.Version, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Size, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.HorizPre, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.VertPre, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Latitude, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Longitude, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Altitude, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *LP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Fqdn, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *MB) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Mb, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *MD) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Md, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *MF) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Mf, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *MG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Mg, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *MINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Rmail, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Email, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *MR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Mr, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *MX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Mx, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NAPTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Order, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Flags, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Service, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Regexp, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Replacement, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = packUint64(rr.NodeID, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NIMLOC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringHex(rr.Locator, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringTxt(rr.ZSData, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NS) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Ns, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NSAPPTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Ptr, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NSEC) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.NextDomain, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = packDataNsec(rr.TypeBitMap, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NSEC3) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint8(rr.Hash, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Flags, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Iterations, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.SaltLength, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Salt, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.HashLength, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase32(rr.NextDomain, msg, off) - if err != nil { - return off, err - } - off, err = packDataNsec(rr.TypeBitMap, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *NSEC3PARAM) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint8(rr.Hash, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Flags, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Iterations, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.SaltLength, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Salt, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *OPENPGPKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringBase64(rr.PublicKey, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *OPT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packDataOpt(rr.Option, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *PTR) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Ptr, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *PX) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Map822, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Mapx400, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *RFC3597) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringHex(rr.Rdata, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *RKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Flags, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Protocol, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.PublicKey, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *RP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Mbox, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Txt, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *RRSIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.TypeCovered, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Labels, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.OrigTtl, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Expiration, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Inception, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.SignerName, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.Signature, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *RT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Preference, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Host, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *SIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.TypeCovered, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Labels, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.OrigTtl, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Expiration, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Inception, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.SignerName, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = packStringBase64(rr.Signature, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *SOA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Ns, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Mbox, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = packUint32(rr.Serial, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Refresh, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Retry, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Expire, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Minttl, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *SPF) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringTxt(rr.Txt, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *SRV) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Priority, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Weight, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Port, msg, off) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.Target, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *SSHFP) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Type, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.FingerPrint, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *TA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.KeyTag, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Algorithm, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.DigestType, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Digest, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *TALINK) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.PreviousName, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = PackDomainName(rr.NextName, msg, off, compression, compress) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *TKEY) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Algorithm, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = packUint32(rr.Inception, msg, off) - if err != nil { - return off, err - } - off, err = packUint32(rr.Expiration, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Mode, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Error, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.KeySize, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.Key, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.OtherLen, msg, off) - if err != nil { - return off, err - } - off, err = packString(rr.OtherData, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *TLSA) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint8(rr.Usage, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.Selector, msg, off) - if err != nil { - return off, err - } - off, err = packUint8(rr.MatchingType, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.Certificate, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *TSIG) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = PackDomainName(rr.Algorithm, msg, off, compression, compress) - if err != nil { - return off, err - } - off, err = packUint48(rr.TimeSigned, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Fudge, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.MACSize, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.MAC, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.OrigId, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Error, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.OtherLen, msg, off) - if err != nil { - return off, err - } - off, err = packStringHex(rr.OtherData, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *TXT) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packStringTxt(rr.Txt, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *UID) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint32(rr.Uid, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *UINFO) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packString(rr.Uinfo, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *URI) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packUint16(rr.Priority, msg, off) - if err != nil { - return off, err - } - off, err = packUint16(rr.Weight, msg, off) - if err != nil { - return off, err - } - off, err = packStringOctet(rr.Target, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -func (rr *X25) pack(msg []byte, off int, compression map[string]int, compress bool) (int, error) { - off, err := rr.Hdr.pack(msg, off, compression, compress) - if err != nil { - return off, err - } - headerEnd := off - off, err = packString(rr.PSDNAddress, msg, off) - if err != nil { - return off, err - } - rr.Header().Rdlength = uint16(off - headerEnd) - return off, nil -} - -// unpack*() functions - -func unpackA(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(A) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.A, off, err = unpackDataA(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackAAAA(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(AAAA) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.AAAA, off, err = unpackDataAAAA(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackAFSDB(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(AFSDB) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Subtype, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Hostname, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackANY(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(ANY) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - return rr, off, err -} - -func unpackCAA(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(CAA) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Flag, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Tag, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Value, off, err = unpackStringOctet(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackCDNSKEY(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(CDNSKEY) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Flags, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Protocol, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackCDS(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(CDS) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.KeyTag, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.DigestType, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackCERT(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(CERT) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Type, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.KeyTag, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Certificate, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackCNAME(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(CNAME) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Target, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackDHCID(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(DHCID) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Digest, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackDLV(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(DLV) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.KeyTag, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.DigestType, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackDNAME(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(DNAME) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Target, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackDNSKEY(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(DNSKEY) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Flags, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Protocol, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackDS(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(DS) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.KeyTag, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.DigestType, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackEID(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(EID) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Endpoint, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackEUI48(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(EUI48) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Address, off, err = unpackUint48(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackEUI64(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(EUI64) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Address, off, err = unpackUint64(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackGID(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(GID) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Gid, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackGPOS(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(GPOS) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Longitude, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Latitude, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Altitude, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackHINFO(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(HINFO) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Cpu, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Os, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackHIP(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(HIP) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.HitLength, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.PublicKeyAlgorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.PublicKeyLength, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Hit, off, err = unpackStringHex(msg, off, off+int(rr.HitLength)) - if err != nil { - return rr, off, err - } - rr.PublicKey, off, err = unpackStringBase64(msg, off, off+int(rr.PublicKeyLength)) - if err != nil { - return rr, off, err - } - rr.RendezvousServers, off, err = unpackDataDomainNames(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackKEY(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(KEY) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Flags, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Protocol, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackKX(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(KX) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Exchanger, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackL32(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(L32) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Locator32, off, err = unpackDataA(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackL64(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(L64) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Locator64, off, err = unpackUint64(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackLOC(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(LOC) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Version, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Size, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.HorizPre, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.VertPre, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Latitude, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Longitude, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Altitude, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackLP(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(LP) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Fqdn, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackMB(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(MB) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Mb, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackMD(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(MD) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Md, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackMF(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(MF) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Mf, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackMG(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(MG) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Mg, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackMINFO(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(MINFO) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Rmail, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Email, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackMR(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(MR) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Mr, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackMX(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(MX) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Mx, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNAPTR(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NAPTR) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Order, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Flags, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Service, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Regexp, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Replacement, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNID(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NID) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.NodeID, off, err = unpackUint64(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNIMLOC(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NIMLOC) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Locator, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNINFO(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NINFO) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.ZSData, off, err = unpackStringTxt(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNS(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NS) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Ns, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNSAPPTR(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NSAPPTR) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Ptr, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNSEC(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NSEC) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.NextDomain, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.TypeBitMap, off, err = unpackDataNsec(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNSEC3(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NSEC3) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Hash, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Flags, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Iterations, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.SaltLength, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Salt, off, err = unpackStringHex(msg, off, off+int(rr.SaltLength)) - if err != nil { - return rr, off, err - } - rr.HashLength, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.NextDomain, off, err = unpackStringBase32(msg, off, off+int(rr.HashLength)) - if err != nil { - return rr, off, err - } - rr.TypeBitMap, off, err = unpackDataNsec(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackNSEC3PARAM(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(NSEC3PARAM) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Hash, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Flags, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Iterations, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.SaltLength, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Salt, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackOPENPGPKEY(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(OPENPGPKEY) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackOPT(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(OPT) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Option, off, err = unpackDataOpt(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackPTR(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(PTR) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Ptr, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackPX(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(PX) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Map822, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Mapx400, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackRFC3597(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(RFC3597) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Rdata, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackRKEY(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(RKEY) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Flags, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Protocol, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.PublicKey, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackRP(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(RP) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Mbox, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Txt, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackRRSIG(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(RRSIG) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.TypeCovered, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Labels, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.OrigTtl, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Expiration, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Inception, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.KeyTag, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.SignerName, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Signature, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackRT(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(RT) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Preference, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Host, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackSIG(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(SIG) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.TypeCovered, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Labels, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.OrigTtl, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Expiration, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Inception, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.KeyTag, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.SignerName, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Signature, off, err = unpackStringBase64(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackSOA(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(SOA) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Ns, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Mbox, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Serial, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Refresh, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Retry, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Expire, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Minttl, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackSPF(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(SPF) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Txt, off, err = unpackStringTxt(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackSRV(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(SRV) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Priority, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Weight, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Port, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Target, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackSSHFP(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(SSHFP) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Type, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.FingerPrint, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackTA(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(TA) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.KeyTag, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Algorithm, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.DigestType, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Digest, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackTALINK(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(TALINK) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.PreviousName, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.NextName, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackTKEY(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(TKEY) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Algorithm, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Inception, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Expiration, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Mode, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Error, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.KeySize, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Key, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.OtherLen, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.OtherData, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackTLSA(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(TLSA) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Usage, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Selector, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.MatchingType, off, err = unpackUint8(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Certificate, off, err = unpackStringHex(msg, off, rdStart+int(rr.Hdr.Rdlength)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackTSIG(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(TSIG) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Algorithm, off, err = UnpackDomainName(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.TimeSigned, off, err = unpackUint48(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Fudge, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.MACSize, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.MAC, off, err = unpackStringHex(msg, off, off+int(rr.MACSize)) - if err != nil { - return rr, off, err - } - rr.OrigId, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Error, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.OtherLen, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.OtherData, off, err = unpackStringHex(msg, off, off+int(rr.OtherLen)) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackTXT(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(TXT) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Txt, off, err = unpackStringTxt(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackUID(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(UID) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Uid, off, err = unpackUint32(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackUINFO(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(UINFO) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Uinfo, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackURI(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(URI) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.Priority, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Weight, off, err = unpackUint16(msg, off) - if err != nil { - return rr, off, err - } - if off == len(msg) { - return rr, off, nil - } - rr.Target, off, err = unpackStringOctet(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -func unpackX25(h RR_Header, msg []byte, off int) (RR, int, error) { - rr := new(X25) - rr.Hdr = h - if noRdata(h) { - return rr, off, nil - } - var err error - rdStart := off - _ = rdStart - - rr.PSDNAddress, off, err = unpackString(msg, off) - if err != nil { - return rr, off, err - } - return rr, off, err -} - -var typeToUnpack = map[uint16]func(RR_Header, []byte, int) (RR, int, error){ - TypeA: unpackA, - TypeAAAA: unpackAAAA, - TypeAFSDB: unpackAFSDB, - TypeANY: unpackANY, - TypeCAA: unpackCAA, - TypeCDNSKEY: unpackCDNSKEY, - TypeCDS: unpackCDS, - TypeCERT: unpackCERT, - TypeCNAME: unpackCNAME, - TypeDHCID: unpackDHCID, - TypeDLV: unpackDLV, - TypeDNAME: unpackDNAME, - TypeDNSKEY: unpackDNSKEY, - TypeDS: unpackDS, - TypeEID: unpackEID, - TypeEUI48: unpackEUI48, - TypeEUI64: unpackEUI64, - TypeGID: unpackGID, - TypeGPOS: unpackGPOS, - TypeHINFO: unpackHINFO, - TypeHIP: unpackHIP, - TypeKEY: unpackKEY, - TypeKX: unpackKX, - TypeL32: unpackL32, - TypeL64: unpackL64, - TypeLOC: unpackLOC, - TypeLP: unpackLP, - TypeMB: unpackMB, - TypeMD: unpackMD, - TypeMF: unpackMF, - TypeMG: unpackMG, - TypeMINFO: unpackMINFO, - TypeMR: unpackMR, - TypeMX: unpackMX, - TypeNAPTR: unpackNAPTR, - TypeNID: unpackNID, - TypeNIMLOC: unpackNIMLOC, - TypeNINFO: unpackNINFO, - TypeNS: unpackNS, - TypeNSAPPTR: unpackNSAPPTR, - TypeNSEC: unpackNSEC, - TypeNSEC3: unpackNSEC3, - TypeNSEC3PARAM: unpackNSEC3PARAM, - TypeOPENPGPKEY: unpackOPENPGPKEY, - TypeOPT: unpackOPT, - TypePTR: unpackPTR, - TypePX: unpackPX, - TypeRKEY: unpackRKEY, - TypeRP: unpackRP, - TypeRRSIG: unpackRRSIG, - TypeRT: unpackRT, - TypeSIG: unpackSIG, - TypeSOA: unpackSOA, - TypeSPF: unpackSPF, - TypeSRV: unpackSRV, - TypeSSHFP: unpackSSHFP, - TypeTA: unpackTA, - TypeTALINK: unpackTALINK, - TypeTKEY: unpackTKEY, - TypeTLSA: unpackTLSA, - TypeTSIG: unpackTSIG, - TypeTXT: unpackTXT, - TypeUID: unpackUID, - TypeUINFO: unpackUINFO, - TypeURI: unpackURI, - TypeX25: unpackX25, -} diff --git a/vendor/github.com/miekg/dns/ztypes.go b/vendor/github.com/miekg/dns/ztypes.go deleted file mode 100644 index a4ecbb0..0000000 --- a/vendor/github.com/miekg/dns/ztypes.go +++ /dev/null @@ -1,828 +0,0 @@ -// *** DO NOT MODIFY *** -// AUTOGENERATED BY go generate from type_generate.go - -package dns - -import ( - "encoding/base64" - "net" -) - -// TypeToRR is a map of constructors for each RR type. -var TypeToRR = map[uint16]func() RR{ - TypeA: func() RR { return new(A) }, - TypeAAAA: func() RR { return new(AAAA) }, - TypeAFSDB: func() RR { return new(AFSDB) }, - TypeANY: func() RR { return new(ANY) }, - TypeCAA: func() RR { return new(CAA) }, - TypeCDNSKEY: func() RR { return new(CDNSKEY) }, - TypeCDS: func() RR { return new(CDS) }, - TypeCERT: func() RR { return new(CERT) }, - TypeCNAME: func() RR { return new(CNAME) }, - TypeDHCID: func() RR { return new(DHCID) }, - TypeDLV: func() RR { return new(DLV) }, - TypeDNAME: func() RR { return new(DNAME) }, - TypeDNSKEY: func() RR { return new(DNSKEY) }, - TypeDS: func() RR { return new(DS) }, - TypeEID: func() RR { return new(EID) }, - TypeEUI48: func() RR { return new(EUI48) }, - TypeEUI64: func() RR { return new(EUI64) }, - TypeGID: func() RR { return new(GID) }, - TypeGPOS: func() RR { return new(GPOS) }, - TypeHINFO: func() RR { return new(HINFO) }, - TypeHIP: func() RR { return new(HIP) }, - TypeKEY: func() RR { return new(KEY) }, - TypeKX: func() RR { return new(KX) }, - TypeL32: func() RR { return new(L32) }, - TypeL64: func() RR { return new(L64) }, - TypeLOC: func() RR { return new(LOC) }, - TypeLP: func() RR { return new(LP) }, - TypeMB: func() RR { return new(MB) }, - TypeMD: func() RR { return new(MD) }, - TypeMF: func() RR { return new(MF) }, - TypeMG: func() RR { return new(MG) }, - TypeMINFO: func() RR { return new(MINFO) }, - TypeMR: func() RR { return new(MR) }, - TypeMX: func() RR { return new(MX) }, - TypeNAPTR: func() RR { return new(NAPTR) }, - TypeNID: func() RR { return new(NID) }, - TypeNIMLOC: func() RR { return new(NIMLOC) }, - TypeNINFO: func() RR { return new(NINFO) }, - TypeNS: func() RR { return new(NS) }, - TypeNSAPPTR: func() RR { return new(NSAPPTR) }, - TypeNSEC: func() RR { return new(NSEC) }, - TypeNSEC3: func() RR { return new(NSEC3) }, - TypeNSEC3PARAM: func() RR { return new(NSEC3PARAM) }, - TypeOPENPGPKEY: func() RR { return new(OPENPGPKEY) }, - TypeOPT: func() RR { return new(OPT) }, - TypePTR: func() RR { return new(PTR) }, - TypePX: func() RR { return new(PX) }, - TypeRKEY: func() RR { return new(RKEY) }, - TypeRP: func() RR { return new(RP) }, - TypeRRSIG: func() RR { return new(RRSIG) }, - TypeRT: func() RR { return new(RT) }, - TypeSIG: func() RR { return new(SIG) }, - TypeSOA: func() RR { return new(SOA) }, - TypeSPF: func() RR { return new(SPF) }, - TypeSRV: func() RR { return new(SRV) }, - TypeSSHFP: func() RR { return new(SSHFP) }, - TypeTA: func() RR { return new(TA) }, - TypeTALINK: func() RR { return new(TALINK) }, - TypeTKEY: func() RR { return new(TKEY) }, - TypeTLSA: func() RR { return new(TLSA) }, - TypeTSIG: func() RR { return new(TSIG) }, - TypeTXT: func() RR { return new(TXT) }, - TypeUID: func() RR { return new(UID) }, - TypeUINFO: func() RR { return new(UINFO) }, - TypeURI: func() RR { return new(URI) }, - TypeX25: func() RR { return new(X25) }, -} - -// TypeToString is a map of strings for each RR type. -var TypeToString = map[uint16]string{ - TypeA: "A", - TypeAAAA: "AAAA", - TypeAFSDB: "AFSDB", - TypeANY: "ANY", - TypeATMA: "ATMA", - TypeAXFR: "AXFR", - TypeCAA: "CAA", - TypeCDNSKEY: "CDNSKEY", - TypeCDS: "CDS", - TypeCERT: "CERT", - TypeCNAME: "CNAME", - TypeDHCID: "DHCID", - TypeDLV: "DLV", - TypeDNAME: "DNAME", - TypeDNSKEY: "DNSKEY", - TypeDS: "DS", - TypeEID: "EID", - TypeEUI48: "EUI48", - TypeEUI64: "EUI64", - TypeGID: "GID", - TypeGPOS: "GPOS", - TypeHINFO: "HINFO", - TypeHIP: "HIP", - TypeISDN: "ISDN", - TypeIXFR: "IXFR", - TypeKEY: "KEY", - TypeKX: "KX", - TypeL32: "L32", - TypeL64: "L64", - TypeLOC: "LOC", - TypeLP: "LP", - TypeMAILA: "MAILA", - TypeMAILB: "MAILB", - TypeMB: "MB", - TypeMD: "MD", - TypeMF: "MF", - TypeMG: "MG", - TypeMINFO: "MINFO", - TypeMR: "MR", - TypeMX: "MX", - TypeNAPTR: "NAPTR", - TypeNID: "NID", - TypeNIMLOC: "NIMLOC", - TypeNINFO: "NINFO", - TypeNS: "NS", - TypeNSEC: "NSEC", - TypeNSEC3: "NSEC3", - TypeNSEC3PARAM: "NSEC3PARAM", - TypeNULL: "NULL", - TypeNXT: "NXT", - TypeNone: "None", - TypeOPENPGPKEY: "OPENPGPKEY", - TypeOPT: "OPT", - TypePTR: "PTR", - TypePX: "PX", - TypeRKEY: "RKEY", - TypeRP: "RP", - TypeRRSIG: "RRSIG", - TypeRT: "RT", - TypeReserved: "Reserved", - TypeSIG: "SIG", - TypeSOA: "SOA", - TypeSPF: "SPF", - TypeSRV: "SRV", - TypeSSHFP: "SSHFP", - TypeTA: "TA", - TypeTALINK: "TALINK", - TypeTKEY: "TKEY", - TypeTLSA: "TLSA", - TypeTSIG: "TSIG", - TypeTXT: "TXT", - TypeUID: "UID", - TypeUINFO: "UINFO", - TypeUNSPEC: "UNSPEC", - TypeURI: "URI", - TypeX25: "X25", - TypeNSAPPTR: "NSAP-PTR", -} - -// Header() functions -func (rr *A) Header() *RR_Header { return &rr.Hdr } -func (rr *AAAA) Header() *RR_Header { return &rr.Hdr } -func (rr *AFSDB) Header() *RR_Header { return &rr.Hdr } -func (rr *ANY) Header() *RR_Header { return &rr.Hdr } -func (rr *CAA) Header() *RR_Header { return &rr.Hdr } -func (rr *CDNSKEY) Header() *RR_Header { return &rr.Hdr } -func (rr *CDS) Header() *RR_Header { return &rr.Hdr } -func (rr *CERT) Header() *RR_Header { return &rr.Hdr } -func (rr *CNAME) Header() *RR_Header { return &rr.Hdr } -func (rr *DHCID) Header() *RR_Header { return &rr.Hdr } -func (rr *DLV) Header() *RR_Header { return &rr.Hdr } -func (rr *DNAME) Header() *RR_Header { return &rr.Hdr } -func (rr *DNSKEY) Header() *RR_Header { return &rr.Hdr } -func (rr *DS) Header() *RR_Header { return &rr.Hdr } -func (rr *EID) Header() *RR_Header { return &rr.Hdr } -func (rr *EUI48) Header() *RR_Header { return &rr.Hdr } -func (rr *EUI64) Header() *RR_Header { return &rr.Hdr } -func (rr *GID) Header() *RR_Header { return &rr.Hdr } -func (rr *GPOS) Header() *RR_Header { return &rr.Hdr } -func (rr *HINFO) Header() *RR_Header { return &rr.Hdr } -func (rr *HIP) Header() *RR_Header { return &rr.Hdr } -func (rr *KEY) Header() *RR_Header { return &rr.Hdr } -func (rr *KX) Header() *RR_Header { return &rr.Hdr } -func (rr *L32) Header() *RR_Header { return &rr.Hdr } -func (rr *L64) Header() *RR_Header { return &rr.Hdr } -func (rr *LOC) Header() *RR_Header { return &rr.Hdr } -func (rr *LP) Header() *RR_Header { return &rr.Hdr } -func (rr *MB) Header() *RR_Header { return &rr.Hdr } -func (rr *MD) Header() *RR_Header { return &rr.Hdr } -func (rr *MF) Header() *RR_Header { return &rr.Hdr } -func (rr *MG) Header() *RR_Header { return &rr.Hdr } -func (rr *MINFO) Header() *RR_Header { return &rr.Hdr } -func (rr *MR) Header() *RR_Header { return &rr.Hdr } -func (rr *MX) Header() *RR_Header { return &rr.Hdr } -func (rr *NAPTR) Header() *RR_Header { return &rr.Hdr } -func (rr *NID) Header() *RR_Header { return &rr.Hdr } -func (rr *NIMLOC) Header() *RR_Header { return &rr.Hdr } -func (rr *NINFO) Header() *RR_Header { return &rr.Hdr } -func (rr *NS) Header() *RR_Header { return &rr.Hdr } -func (rr *NSAPPTR) Header() *RR_Header { return &rr.Hdr } -func (rr *NSEC) Header() *RR_Header { return &rr.Hdr } -func (rr *NSEC3) Header() *RR_Header { return &rr.Hdr } -func (rr *NSEC3PARAM) Header() *RR_Header { return &rr.Hdr } -func (rr *OPENPGPKEY) Header() *RR_Header { return &rr.Hdr } -func (rr *OPT) Header() *RR_Header { return &rr.Hdr } -func (rr *PTR) Header() *RR_Header { return &rr.Hdr } -func (rr *PX) Header() *RR_Header { return &rr.Hdr } -func (rr *RFC3597) Header() *RR_Header { return &rr.Hdr } -func (rr *RKEY) Header() *RR_Header { return &rr.Hdr } -func (rr *RP) Header() *RR_Header { return &rr.Hdr } -func (rr *RRSIG) Header() *RR_Header { return &rr.Hdr } -func (rr *RT) Header() *RR_Header { return &rr.Hdr } -func (rr *SIG) Header() *RR_Header { return &rr.Hdr } -func (rr *SOA) Header() *RR_Header { return &rr.Hdr } -func (rr *SPF) Header() *RR_Header { return &rr.Hdr } -func (rr *SRV) Header() *RR_Header { return &rr.Hdr } -func (rr *SSHFP) Header() *RR_Header { return &rr.Hdr } -func (rr *TA) Header() *RR_Header { return &rr.Hdr } -func (rr *TALINK) Header() *RR_Header { return &rr.Hdr } -func (rr *TKEY) Header() *RR_Header { return &rr.Hdr } -func (rr *TLSA) Header() *RR_Header { return &rr.Hdr } -func (rr *TSIG) Header() *RR_Header { return &rr.Hdr } -func (rr *TXT) Header() *RR_Header { return &rr.Hdr } -func (rr *UID) Header() *RR_Header { return &rr.Hdr } -func (rr *UINFO) Header() *RR_Header { return &rr.Hdr } -func (rr *URI) Header() *RR_Header { return &rr.Hdr } -func (rr *X25) Header() *RR_Header { return &rr.Hdr } - -// len() functions -func (rr *A) len() int { - l := rr.Hdr.len() - l += net.IPv4len // A - return l -} -func (rr *AAAA) len() int { - l := rr.Hdr.len() - l += net.IPv6len // AAAA - return l -} -func (rr *AFSDB) len() int { - l := rr.Hdr.len() - l += 2 // Subtype - l += len(rr.Hostname) + 1 - return l -} -func (rr *ANY) len() int { - l := rr.Hdr.len() - return l -} -func (rr *CAA) len() int { - l := rr.Hdr.len() - l += 1 // Flag - l += len(rr.Tag) + 1 - l += len(rr.Value) - return l -} -func (rr *CERT) len() int { - l := rr.Hdr.len() - l += 2 // Type - l += 2 // KeyTag - l += 1 // Algorithm - l += base64.StdEncoding.DecodedLen(len(rr.Certificate)) - return l -} -func (rr *CNAME) len() int { - l := rr.Hdr.len() - l += len(rr.Target) + 1 - return l -} -func (rr *DHCID) len() int { - l := rr.Hdr.len() - l += base64.StdEncoding.DecodedLen(len(rr.Digest)) - return l -} -func (rr *DNAME) len() int { - l := rr.Hdr.len() - l += len(rr.Target) + 1 - return l -} -func (rr *DNSKEY) len() int { - l := rr.Hdr.len() - l += 2 // Flags - l += 1 // Protocol - l += 1 // Algorithm - l += base64.StdEncoding.DecodedLen(len(rr.PublicKey)) - return l -} -func (rr *DS) len() int { - l := rr.Hdr.len() - l += 2 // KeyTag - l += 1 // Algorithm - l += 1 // DigestType - l += len(rr.Digest)/2 + 1 - return l -} -func (rr *EID) len() int { - l := rr.Hdr.len() - l += len(rr.Endpoint)/2 + 1 - return l -} -func (rr *EUI48) len() int { - l := rr.Hdr.len() - l += 6 // Address - return l -} -func (rr *EUI64) len() int { - l := rr.Hdr.len() - l += 8 // Address - return l -} -func (rr *GID) len() int { - l := rr.Hdr.len() - l += 4 // Gid - return l -} -func (rr *GPOS) len() int { - l := rr.Hdr.len() - l += len(rr.Longitude) + 1 - l += len(rr.Latitude) + 1 - l += len(rr.Altitude) + 1 - return l -} -func (rr *HINFO) len() int { - l := rr.Hdr.len() - l += len(rr.Cpu) + 1 - l += len(rr.Os) + 1 - return l -} -func (rr *HIP) len() int { - l := rr.Hdr.len() - l += 1 // HitLength - l += 1 // PublicKeyAlgorithm - l += 2 // PublicKeyLength - l += len(rr.Hit)/2 + 1 - l += base64.StdEncoding.DecodedLen(len(rr.PublicKey)) - for _, x := range rr.RendezvousServers { - l += len(x) + 1 - } - return l -} -func (rr *KX) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += len(rr.Exchanger) + 1 - return l -} -func (rr *L32) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += net.IPv4len // Locator32 - return l -} -func (rr *L64) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += 8 // Locator64 - return l -} -func (rr *LOC) len() int { - l := rr.Hdr.len() - l += 1 // Version - l += 1 // Size - l += 1 // HorizPre - l += 1 // VertPre - l += 4 // Latitude - l += 4 // Longitude - l += 4 // Altitude - return l -} -func (rr *LP) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += len(rr.Fqdn) + 1 - return l -} -func (rr *MB) len() int { - l := rr.Hdr.len() - l += len(rr.Mb) + 1 - return l -} -func (rr *MD) len() int { - l := rr.Hdr.len() - l += len(rr.Md) + 1 - return l -} -func (rr *MF) len() int { - l := rr.Hdr.len() - l += len(rr.Mf) + 1 - return l -} -func (rr *MG) len() int { - l := rr.Hdr.len() - l += len(rr.Mg) + 1 - return l -} -func (rr *MINFO) len() int { - l := rr.Hdr.len() - l += len(rr.Rmail) + 1 - l += len(rr.Email) + 1 - return l -} -func (rr *MR) len() int { - l := rr.Hdr.len() - l += len(rr.Mr) + 1 - return l -} -func (rr *MX) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += len(rr.Mx) + 1 - return l -} -func (rr *NAPTR) len() int { - l := rr.Hdr.len() - l += 2 // Order - l += 2 // Preference - l += len(rr.Flags) + 1 - l += len(rr.Service) + 1 - l += len(rr.Regexp) + 1 - l += len(rr.Replacement) + 1 - return l -} -func (rr *NID) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += 8 // NodeID - return l -} -func (rr *NIMLOC) len() int { - l := rr.Hdr.len() - l += len(rr.Locator)/2 + 1 - return l -} -func (rr *NINFO) len() int { - l := rr.Hdr.len() - for _, x := range rr.ZSData { - l += len(x) + 1 - } - return l -} -func (rr *NS) len() int { - l := rr.Hdr.len() - l += len(rr.Ns) + 1 - return l -} -func (rr *NSAPPTR) len() int { - l := rr.Hdr.len() - l += len(rr.Ptr) + 1 - return l -} -func (rr *NSEC3PARAM) len() int { - l := rr.Hdr.len() - l += 1 // Hash - l += 1 // Flags - l += 2 // Iterations - l += 1 // SaltLength - l += len(rr.Salt)/2 + 1 - return l -} -func (rr *OPENPGPKEY) len() int { - l := rr.Hdr.len() - l += base64.StdEncoding.DecodedLen(len(rr.PublicKey)) - return l -} -func (rr *PTR) len() int { - l := rr.Hdr.len() - l += len(rr.Ptr) + 1 - return l -} -func (rr *PX) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += len(rr.Map822) + 1 - l += len(rr.Mapx400) + 1 - return l -} -func (rr *RFC3597) len() int { - l := rr.Hdr.len() - l += len(rr.Rdata)/2 + 1 - return l -} -func (rr *RKEY) len() int { - l := rr.Hdr.len() - l += 2 // Flags - l += 1 // Protocol - l += 1 // Algorithm - l += base64.StdEncoding.DecodedLen(len(rr.PublicKey)) - return l -} -func (rr *RP) len() int { - l := rr.Hdr.len() - l += len(rr.Mbox) + 1 - l += len(rr.Txt) + 1 - return l -} -func (rr *RRSIG) len() int { - l := rr.Hdr.len() - l += 2 // TypeCovered - l += 1 // Algorithm - l += 1 // Labels - l += 4 // OrigTtl - l += 4 // Expiration - l += 4 // Inception - l += 2 // KeyTag - l += len(rr.SignerName) + 1 - l += base64.StdEncoding.DecodedLen(len(rr.Signature)) - return l -} -func (rr *RT) len() int { - l := rr.Hdr.len() - l += 2 // Preference - l += len(rr.Host) + 1 - return l -} -func (rr *SOA) len() int { - l := rr.Hdr.len() - l += len(rr.Ns) + 1 - l += len(rr.Mbox) + 1 - l += 4 // Serial - l += 4 // Refresh - l += 4 // Retry - l += 4 // Expire - l += 4 // Minttl - return l -} -func (rr *SPF) len() int { - l := rr.Hdr.len() - for _, x := range rr.Txt { - l += len(x) + 1 - } - return l -} -func (rr *SRV) len() int { - l := rr.Hdr.len() - l += 2 // Priority - l += 2 // Weight - l += 2 // Port - l += len(rr.Target) + 1 - return l -} -func (rr *SSHFP) len() int { - l := rr.Hdr.len() - l += 1 // Algorithm - l += 1 // Type - l += len(rr.FingerPrint)/2 + 1 - return l -} -func (rr *TA) len() int { - l := rr.Hdr.len() - l += 2 // KeyTag - l += 1 // Algorithm - l += 1 // DigestType - l += len(rr.Digest)/2 + 1 - return l -} -func (rr *TALINK) len() int { - l := rr.Hdr.len() - l += len(rr.PreviousName) + 1 - l += len(rr.NextName) + 1 - return l -} -func (rr *TKEY) len() int { - l := rr.Hdr.len() - l += len(rr.Algorithm) + 1 - l += 4 // Inception - l += 4 // Expiration - l += 2 // Mode - l += 2 // Error - l += 2 // KeySize - l += len(rr.Key) + 1 - l += 2 // OtherLen - l += len(rr.OtherData) + 1 - return l -} -func (rr *TLSA) len() int { - l := rr.Hdr.len() - l += 1 // Usage - l += 1 // Selector - l += 1 // MatchingType - l += len(rr.Certificate)/2 + 1 - return l -} -func (rr *TSIG) len() int { - l := rr.Hdr.len() - l += len(rr.Algorithm) + 1 - l += 6 // TimeSigned - l += 2 // Fudge - l += 2 // MACSize - l += len(rr.MAC)/2 + 1 - l += 2 // OrigId - l += 2 // Error - l += 2 // OtherLen - l += len(rr.OtherData)/2 + 1 - return l -} -func (rr *TXT) len() int { - l := rr.Hdr.len() - for _, x := range rr.Txt { - l += len(x) + 1 - } - return l -} -func (rr *UID) len() int { - l := rr.Hdr.len() - l += 4 // Uid - return l -} -func (rr *UINFO) len() int { - l := rr.Hdr.len() - l += len(rr.Uinfo) + 1 - return l -} -func (rr *URI) len() int { - l := rr.Hdr.len() - l += 2 // Priority - l += 2 // Weight - l += len(rr.Target) - return l -} -func (rr *X25) len() int { - l := rr.Hdr.len() - l += len(rr.PSDNAddress) + 1 - return l -} - -// copy() functions -func (rr *A) copy() RR { - return &A{*rr.Hdr.copyHeader(), copyIP(rr.A)} -} -func (rr *AAAA) copy() RR { - return &AAAA{*rr.Hdr.copyHeader(), copyIP(rr.AAAA)} -} -func (rr *AFSDB) copy() RR { - return &AFSDB{*rr.Hdr.copyHeader(), rr.Subtype, rr.Hostname} -} -func (rr *ANY) copy() RR { - return &ANY{*rr.Hdr.copyHeader()} -} -func (rr *CAA) copy() RR { - return &CAA{*rr.Hdr.copyHeader(), rr.Flag, rr.Tag, rr.Value} -} -func (rr *CERT) copy() RR { - return &CERT{*rr.Hdr.copyHeader(), rr.Type, rr.KeyTag, rr.Algorithm, rr.Certificate} -} -func (rr *CNAME) copy() RR { - return &CNAME{*rr.Hdr.copyHeader(), rr.Target} -} -func (rr *DHCID) copy() RR { - return &DHCID{*rr.Hdr.copyHeader(), rr.Digest} -} -func (rr *DNAME) copy() RR { - return &DNAME{*rr.Hdr.copyHeader(), rr.Target} -} -func (rr *DNSKEY) copy() RR { - return &DNSKEY{*rr.Hdr.copyHeader(), rr.Flags, rr.Protocol, rr.Algorithm, rr.PublicKey} -} -func (rr *DS) copy() RR { - return &DS{*rr.Hdr.copyHeader(), rr.KeyTag, rr.Algorithm, rr.DigestType, rr.Digest} -} -func (rr *EID) copy() RR { - return &EID{*rr.Hdr.copyHeader(), rr.Endpoint} -} -func (rr *EUI48) copy() RR { - return &EUI48{*rr.Hdr.copyHeader(), rr.Address} -} -func (rr *EUI64) copy() RR { - return &EUI64{*rr.Hdr.copyHeader(), rr.Address} -} -func (rr *GID) copy() RR { - return &GID{*rr.Hdr.copyHeader(), rr.Gid} -} -func (rr *GPOS) copy() RR { - return &GPOS{*rr.Hdr.copyHeader(), rr.Longitude, rr.Latitude, rr.Altitude} -} -func (rr *HINFO) copy() RR { - return &HINFO{*rr.Hdr.copyHeader(), rr.Cpu, rr.Os} -} -func (rr *HIP) copy() RR { - RendezvousServers := make([]string, len(rr.RendezvousServers)) - copy(RendezvousServers, rr.RendezvousServers) - return &HIP{*rr.Hdr.copyHeader(), rr.HitLength, rr.PublicKeyAlgorithm, rr.PublicKeyLength, rr.Hit, rr.PublicKey, RendezvousServers} -} -func (rr *KX) copy() RR { - return &KX{*rr.Hdr.copyHeader(), rr.Preference, rr.Exchanger} -} -func (rr *L32) copy() RR { - return &L32{*rr.Hdr.copyHeader(), rr.Preference, copyIP(rr.Locator32)} -} -func (rr *L64) copy() RR { - return &L64{*rr.Hdr.copyHeader(), rr.Preference, rr.Locator64} -} -func (rr *LOC) copy() RR { - return &LOC{*rr.Hdr.copyHeader(), rr.Version, rr.Size, rr.HorizPre, rr.VertPre, rr.Latitude, rr.Longitude, rr.Altitude} -} -func (rr *LP) copy() RR { - return &LP{*rr.Hdr.copyHeader(), rr.Preference, rr.Fqdn} -} -func (rr *MB) copy() RR { - return &MB{*rr.Hdr.copyHeader(), rr.Mb} -} -func (rr *MD) copy() RR { - return &MD{*rr.Hdr.copyHeader(), rr.Md} -} -func (rr *MF) copy() RR { - return &MF{*rr.Hdr.copyHeader(), rr.Mf} -} -func (rr *MG) copy() RR { - return &MG{*rr.Hdr.copyHeader(), rr.Mg} -} -func (rr *MINFO) copy() RR { - return &MINFO{*rr.Hdr.copyHeader(), rr.Rmail, rr.Email} -} -func (rr *MR) copy() RR { - return &MR{*rr.Hdr.copyHeader(), rr.Mr} -} -func (rr *MX) copy() RR { - return &MX{*rr.Hdr.copyHeader(), rr.Preference, rr.Mx} -} -func (rr *NAPTR) copy() RR { - return &NAPTR{*rr.Hdr.copyHeader(), rr.Order, rr.Preference, rr.Flags, rr.Service, rr.Regexp, rr.Replacement} -} -func (rr *NID) copy() RR { - return &NID{*rr.Hdr.copyHeader(), rr.Preference, rr.NodeID} -} -func (rr *NIMLOC) copy() RR { - return &NIMLOC{*rr.Hdr.copyHeader(), rr.Locator} -} -func (rr *NINFO) copy() RR { - ZSData := make([]string, len(rr.ZSData)) - copy(ZSData, rr.ZSData) - return &NINFO{*rr.Hdr.copyHeader(), ZSData} -} -func (rr *NS) copy() RR { - return &NS{*rr.Hdr.copyHeader(), rr.Ns} -} -func (rr *NSAPPTR) copy() RR { - return &NSAPPTR{*rr.Hdr.copyHeader(), rr.Ptr} -} -func (rr *NSEC) copy() RR { - TypeBitMap := make([]uint16, len(rr.TypeBitMap)) - copy(TypeBitMap, rr.TypeBitMap) - return &NSEC{*rr.Hdr.copyHeader(), rr.NextDomain, TypeBitMap} -} -func (rr *NSEC3) copy() RR { - TypeBitMap := make([]uint16, len(rr.TypeBitMap)) - copy(TypeBitMap, rr.TypeBitMap) - return &NSEC3{*rr.Hdr.copyHeader(), rr.Hash, rr.Flags, rr.Iterations, rr.SaltLength, rr.Salt, rr.HashLength, rr.NextDomain, TypeBitMap} -} -func (rr *NSEC3PARAM) copy() RR { - return &NSEC3PARAM{*rr.Hdr.copyHeader(), rr.Hash, rr.Flags, rr.Iterations, rr.SaltLength, rr.Salt} -} -func (rr *OPENPGPKEY) copy() RR { - return &OPENPGPKEY{*rr.Hdr.copyHeader(), rr.PublicKey} -} -func (rr *OPT) copy() RR { - Option := make([]EDNS0, len(rr.Option)) - copy(Option, rr.Option) - return &OPT{*rr.Hdr.copyHeader(), Option} -} -func (rr *PTR) copy() RR { - return &PTR{*rr.Hdr.copyHeader(), rr.Ptr} -} -func (rr *PX) copy() RR { - return &PX{*rr.Hdr.copyHeader(), rr.Preference, rr.Map822, rr.Mapx400} -} -func (rr *RFC3597) copy() RR { - return &RFC3597{*rr.Hdr.copyHeader(), rr.Rdata} -} -func (rr *RKEY) copy() RR { - return &RKEY{*rr.Hdr.copyHeader(), rr.Flags, rr.Protocol, rr.Algorithm, rr.PublicKey} -} -func (rr *RP) copy() RR { - return &RP{*rr.Hdr.copyHeader(), rr.Mbox, rr.Txt} -} -func (rr *RRSIG) copy() RR { - return &RRSIG{*rr.Hdr.copyHeader(), rr.TypeCovered, rr.Algorithm, rr.Labels, rr.OrigTtl, rr.Expiration, rr.Inception, rr.KeyTag, rr.SignerName, rr.Signature} -} -func (rr *RT) copy() RR { - return &RT{*rr.Hdr.copyHeader(), rr.Preference, rr.Host} -} -func (rr *SOA) copy() RR { - return &SOA{*rr.Hdr.copyHeader(), rr.Ns, rr.Mbox, rr.Serial, rr.Refresh, rr.Retry, rr.Expire, rr.Minttl} -} -func (rr *SPF) copy() RR { - Txt := make([]string, len(rr.Txt)) - copy(Txt, rr.Txt) - return &SPF{*rr.Hdr.copyHeader(), Txt} -} -func (rr *SRV) copy() RR { - return &SRV{*rr.Hdr.copyHeader(), rr.Priority, rr.Weight, rr.Port, rr.Target} -} -func (rr *SSHFP) copy() RR { - return &SSHFP{*rr.Hdr.copyHeader(), rr.Algorithm, rr.Type, rr.FingerPrint} -} -func (rr *TA) copy() RR { - return &TA{*rr.Hdr.copyHeader(), rr.KeyTag, rr.Algorithm, rr.DigestType, rr.Digest} -} -func (rr *TALINK) copy() RR { - return &TALINK{*rr.Hdr.copyHeader(), rr.PreviousName, rr.NextName} -} -func (rr *TKEY) copy() RR { - return &TKEY{*rr.Hdr.copyHeader(), rr.Algorithm, rr.Inception, rr.Expiration, rr.Mode, rr.Error, rr.KeySize, rr.Key, rr.OtherLen, rr.OtherData} -} -func (rr *TLSA) copy() RR { - return &TLSA{*rr.Hdr.copyHeader(), rr.Usage, rr.Selector, rr.MatchingType, rr.Certificate} -} -func (rr *TSIG) copy() RR { - return &TSIG{*rr.Hdr.copyHeader(), rr.Algorithm, rr.TimeSigned, rr.Fudge, rr.MACSize, rr.MAC, rr.OrigId, rr.Error, rr.OtherLen, rr.OtherData} -} -func (rr *TXT) copy() RR { - Txt := make([]string, len(rr.Txt)) - copy(Txt, rr.Txt) - return &TXT{*rr.Hdr.copyHeader(), Txt} -} -func (rr *UID) copy() RR { - return &UID{*rr.Hdr.copyHeader(), rr.Uid} -} -func (rr *UINFO) copy() RR { - return &UINFO{*rr.Hdr.copyHeader(), rr.Uinfo} -} -func (rr *URI) copy() RR { - return &URI{*rr.Hdr.copyHeader(), rr.Priority, rr.Weight, rr.Target} -} -func (rr *X25) copy() RR { - return &X25{*rr.Hdr.copyHeader(), rr.PSDNAddress} -} diff --git a/vendor/github.com/russross/blackfriday/.gitignore b/vendor/github.com/russross/blackfriday/.gitignore deleted file mode 100644 index 75623dc..0000000 --- a/vendor/github.com/russross/blackfriday/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -*.out -*.swp -*.8 -*.6 -_obj -_test* -markdown -tags diff --git a/vendor/github.com/russross/blackfriday/.travis.yml b/vendor/github.com/russross/blackfriday/.travis.yml deleted file mode 100644 index a1687f1..0000000 --- a/vendor/github.com/russross/blackfriday/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -sudo: false -language: go -go: - - 1.5.4 - - 1.6.2 - - tip -matrix: - include: - - go: 1.2.2 - script: - - go get -t -v ./... - - go test -v -race ./... - - go: 1.3.3 - script: - - go get -t -v ./... - - go test -v -race ./... - - go: 1.4.3 - script: - - go get -t -v ./... - - go test -v -race ./... - allow_failures: - - go: tip - fast_finish: true -install: - - # Do nothing. This is needed to prevent default install action "go get -t -v ./..." from happening here (we want it to happen inside script step). -script: - - go get -t -v ./... - - diff -u <(echo -n) <(gofmt -d -s .) - - go tool vet . - - go test -v -race ./... diff --git a/vendor/github.com/russross/blackfriday/LICENSE.txt b/vendor/github.com/russross/blackfriday/LICENSE.txt deleted file mode 100644 index 2885af3..0000000 --- a/vendor/github.com/russross/blackfriday/LICENSE.txt +++ /dev/null @@ -1,29 +0,0 @@ -Blackfriday is distributed under the Simplified BSD License: - -> Copyright © 2011 Russ Ross -> All rights reserved. -> -> Redistribution and use in source and binary forms, with or without -> modification, are permitted provided that the following conditions -> are met: -> -> 1. Redistributions of source code must retain the above copyright -> notice, this list of conditions and the following disclaimer. -> -> 2. Redistributions in binary form must reproduce the above -> copyright notice, this list of conditions and the following -> disclaimer in the documentation and/or other materials provided with -> the distribution. -> -> THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -> "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -> LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS -> FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE -> COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -> INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, -> BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -> LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -> CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -> LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN -> ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -> POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/russross/blackfriday/README.md b/vendor/github.com/russross/blackfriday/README.md deleted file mode 100644 index 1879ce7..0000000 --- a/vendor/github.com/russross/blackfriday/README.md +++ /dev/null @@ -1,267 +0,0 @@ -Blackfriday [![Build Status](https://travis-ci.org/russross/blackfriday.svg?branch=master)](https://travis-ci.org/russross/blackfriday) [![GoDoc](https://godoc.org/github.com/russross/blackfriday?status.svg)](https://godoc.org/github.com/russross/blackfriday) -=========== - -Blackfriday is a [Markdown][1] processor implemented in [Go][2]. It -is paranoid about its input (so you can safely feed it user-supplied -data), it is fast, it supports common extensions (tables, smart -punctuation substitutions, etc.), and it is safe for all utf-8 -(unicode) input. - -HTML output is currently supported, along with Smartypants -extensions. An experimental LaTeX output engine is also included. - -It started as a translation from C of [Sundown][3]. - - -Installation ------------- - -Blackfriday is compatible with Go 1. If you are using an older -release of Go, consider using v1.1 of blackfriday, which was based -on the last stable release of Go prior to Go 1. You can find it as a -tagged commit on github. - -With Go 1 and git installed: - - go get github.com/russross/blackfriday - -will download, compile, and install the package into your `$GOPATH` -directory hierarchy. Alternatively, you can achieve the same if you -import it into a project: - - import "github.com/russross/blackfriday" - -and `go get` without parameters. - -Usage ------ - -For basic usage, it is as simple as getting your input into a byte -slice and calling: - - output := blackfriday.MarkdownBasic(input) - -This renders it with no extensions enabled. To get a more useful -feature set, use this instead: - - output := blackfriday.MarkdownCommon(input) - -### Sanitize untrusted content - -Blackfriday itself does nothing to protect against malicious content. If you are -dealing with user-supplied markdown, we recommend running blackfriday's output -through HTML sanitizer such as -[Bluemonday](https://github.com/microcosm-cc/bluemonday). - -Here's an example of simple usage of blackfriday together with bluemonday: - -``` go -import ( - "github.com/microcosm-cc/bluemonday" - "github.com/russross/blackfriday" -) - -// ... -unsafe := blackfriday.MarkdownCommon(input) -html := bluemonday.UGCPolicy().SanitizeBytes(unsafe) -``` - -### Custom options - -If you want to customize the set of options, first get a renderer -(currently either the HTML or LaTeX output engines), then use it to -call the more general `Markdown` function. For examples, see the -implementations of `MarkdownBasic` and `MarkdownCommon` in -`markdown.go`. - -You can also check out `blackfriday-tool` for a more complete example -of how to use it. Download and install it using: - - go get github.com/russross/blackfriday-tool - -This is a simple command-line tool that allows you to process a -markdown file using a standalone program. You can also browse the -source directly on github if you are just looking for some example -code: - -* - -Note that if you have not already done so, installing -`blackfriday-tool` will be sufficient to download and install -blackfriday in addition to the tool itself. The tool binary will be -installed in `$GOPATH/bin`. This is a statically-linked binary that -can be copied to wherever you need it without worrying about -dependencies and library versions. - - -Features --------- - -All features of Sundown are supported, including: - -* **Compatibility**. The Markdown v1.0.3 test suite passes with - the `--tidy` option. Without `--tidy`, the differences are - mostly in whitespace and entity escaping, where blackfriday is - more consistent and cleaner. - -* **Common extensions**, including table support, fenced code - blocks, autolinks, strikethroughs, non-strict emphasis, etc. - -* **Safety**. Blackfriday is paranoid when parsing, making it safe - to feed untrusted user input without fear of bad things - happening. The test suite stress tests this and there are no - known inputs that make it crash. If you find one, please let me - know and send me the input that does it. - - NOTE: "safety" in this context means *runtime safety only*. In order to - protect yourself against JavaScript injection in untrusted content, see - [this example](https://github.com/russross/blackfriday#sanitize-untrusted-content). - -* **Fast processing**. It is fast enough to render on-demand in - most web applications without having to cache the output. - -* **Thread safety**. You can run multiple parsers in different - goroutines without ill effect. There is no dependence on global - shared state. - -* **Minimal dependencies**. Blackfriday only depends on standard - library packages in Go. The source code is pretty - self-contained, so it is easy to add to any project, including - Google App Engine projects. - -* **Standards compliant**. Output successfully validates using the - W3C validation tool for HTML 4.01 and XHTML 1.0 Transitional. - - -Extensions ----------- - -In addition to the standard markdown syntax, this package -implements the following extensions: - -* **Intra-word emphasis supression**. The `_` character is - commonly used inside words when discussing code, so having - markdown interpret it as an emphasis command is usually the - wrong thing. Blackfriday lets you treat all emphasis markers as - normal characters when they occur inside a word. - -* **Tables**. Tables can be created by drawing them in the input - using a simple syntax: - - ``` - Name | Age - --------|------ - Bob | 27 - Alice | 23 - ``` - -* **Fenced code blocks**. In addition to the normal 4-space - indentation to mark code blocks, you can explicitly mark them - and supply a language (to make syntax highlighting simple). Just - mark it like this: - - ``` go - func getTrue() bool { - return true - } - ``` - - You can use 3 or more backticks to mark the beginning of the - block, and the same number to mark the end of the block. - -* **Definition lists**. A simple definition list is made of a single-line - term followed by a colon and the definition for that term. - - Cat - : Fluffy animal everyone likes - - Internet - : Vector of transmission for pictures of cats - - Terms must be separated from the previous definition by a blank line. - -* **Footnotes**. A marker in the text that will become a superscript number; - a footnote definition that will be placed in a list of footnotes at the - end of the document. A footnote looks like this: - - This is a footnote.[^1] - - [^1]: the footnote text. - -* **Autolinking**. Blackfriday can find URLs that have not been - explicitly marked as links and turn them into links. - -* **Strikethrough**. Use two tildes (`~~`) to mark text that - should be crossed out. - -* **Hard line breaks**. With this extension enabled (it is off by - default in the `MarkdownBasic` and `MarkdownCommon` convenience - functions), newlines in the input translate into line breaks in - the output. - -* **Smart quotes**. Smartypants-style punctuation substitution is - supported, turning normal double- and single-quote marks into - curly quotes, etc. - -* **LaTeX-style dash parsing** is an additional option, where `--` - is translated into `–`, and `---` is translated into - `—`. This differs from most smartypants processors, which - turn a single hyphen into an ndash and a double hyphen into an - mdash. - -* **Smart fractions**, where anything that looks like a fraction - is translated into suitable HTML (instead of just a few special - cases like most smartypant processors). For example, `4/5` - becomes `45`, which renders as - 45. - - -Other renderers ---------------- - -Blackfriday is structured to allow alternative rendering engines. Here -are a few of note: - -* [github_flavored_markdown](https://godoc.org/github.com/shurcooL/github_flavored_markdown): - provides a GitHub Flavored Markdown renderer with fenced code block - highlighting, clickable header anchor links. - - It's not customizable, and its goal is to produce HTML output - equivalent to the [GitHub Markdown API endpoint](https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode), - except the rendering is performed locally. - -* [markdownfmt](https://github.com/shurcooL/markdownfmt): like gofmt, - but for markdown. - -* LaTeX output: renders output as LaTeX. This is currently part of the - main Blackfriday repository, but may be split into its own project - in the future. If you are interested in owning and maintaining the - LaTeX output component, please be in touch. - - It renders some basic documents, but is only experimental at this - point. In particular, it does not do any inline escaping, so input - that happens to look like LaTeX code will be passed through without - modification. - -* [Md2Vim](https://github.com/FooSoft/md2vim): transforms markdown files into vimdoc format. - - -Todo ----- - -* More unit testing -* Improve unicode support. It does not understand all unicode - rules (about what constitutes a letter, a punctuation symbol, - etc.), so it may fail to detect word boundaries correctly in - some instances. It is safe on all utf-8 input. - - -License -------- - -[Blackfriday is distributed under the Simplified BSD License](LICENSE.txt) - - - [1]: http://daringfireball.net/projects/markdown/ "Markdown" - [2]: http://golang.org/ "Go Language" - [3]: https://github.com/vmg/sundown "Sundown" diff --git a/vendor/github.com/russross/blackfriday/block.go b/vendor/github.com/russross/blackfriday/block.go deleted file mode 100644 index 3f4af78..0000000 --- a/vendor/github.com/russross/blackfriday/block.go +++ /dev/null @@ -1,1420 +0,0 @@ -// -// Blackfriday Markdown Processor -// Available at http://github.com/russross/blackfriday -// -// Copyright © 2011 Russ Ross . -// Distributed under the Simplified BSD License. -// See README.md for details. -// - -// -// Functions to parse block-level elements. -// - -package blackfriday - -import ( - "bytes" - - "github.com/shurcooL/sanitized_anchor_name" -) - -// Parse block-level data. -// Note: this function and many that it calls assume that -// the input buffer ends with a newline. -func (p *parser) block(out *bytes.Buffer, data []byte) { - if len(data) == 0 || data[len(data)-1] != '\n' { - panic("block input is missing terminating newline") - } - - // this is called recursively: enforce a maximum depth - if p.nesting >= p.maxNesting { - return - } - p.nesting++ - - // parse out one block-level construct at a time - for len(data) > 0 { - // prefixed header: - // - // # Header 1 - // ## Header 2 - // ... - // ###### Header 6 - if p.isPrefixHeader(data) { - data = data[p.prefixHeader(out, data):] - continue - } - - // block of preformatted HTML: - // - //
- // ... - //
- if data[0] == '<' { - if i := p.html(out, data, true); i > 0 { - data = data[i:] - continue - } - } - - // title block - // - // % stuff - // % more stuff - // % even more stuff - if p.flags&EXTENSION_TITLEBLOCK != 0 { - if data[0] == '%' { - if i := p.titleBlock(out, data, true); i > 0 { - data = data[i:] - continue - } - } - } - - // blank lines. note: returns the # of bytes to skip - if i := p.isEmpty(data); i > 0 { - data = data[i:] - continue - } - - // indented code block: - // - // func max(a, b int) int { - // if a > b { - // return a - // } - // return b - // } - if p.codePrefix(data) > 0 { - data = data[p.code(out, data):] - continue - } - - // fenced code block: - // - // ``` go - // func fact(n int) int { - // if n <= 1 { - // return n - // } - // return n * fact(n-1) - // } - // ``` - if p.flags&EXTENSION_FENCED_CODE != 0 { - if i := p.fencedCode(out, data, true); i > 0 { - data = data[i:] - continue - } - } - - // horizontal rule: - // - // ------ - // or - // ****** - // or - // ______ - if p.isHRule(data) { - p.r.HRule(out) - var i int - for i = 0; data[i] != '\n'; i++ { - } - data = data[i:] - continue - } - - // block quote: - // - // > A big quote I found somewhere - // > on the web - if p.quotePrefix(data) > 0 { - data = data[p.quote(out, data):] - continue - } - - // table: - // - // Name | Age | Phone - // ------|-----|--------- - // Bob | 31 | 555-1234 - // Alice | 27 | 555-4321 - if p.flags&EXTENSION_TABLES != 0 { - if i := p.table(out, data); i > 0 { - data = data[i:] - continue - } - } - - // an itemized/unordered list: - // - // * Item 1 - // * Item 2 - // - // also works with + or - - if p.uliPrefix(data) > 0 { - data = data[p.list(out, data, 0):] - continue - } - - // a numbered/ordered list: - // - // 1. Item 1 - // 2. Item 2 - if p.oliPrefix(data) > 0 { - data = data[p.list(out, data, LIST_TYPE_ORDERED):] - continue - } - - // definition lists: - // - // Term 1 - // : Definition a - // : Definition b - // - // Term 2 - // : Definition c - if p.flags&EXTENSION_DEFINITION_LISTS != 0 { - if p.dliPrefix(data) > 0 { - data = data[p.list(out, data, LIST_TYPE_DEFINITION):] - continue - } - } - - // anything else must look like a normal paragraph - // note: this finds underlined headers, too - data = data[p.paragraph(out, data):] - } - - p.nesting-- -} - -func (p *parser) isPrefixHeader(data []byte) bool { - if data[0] != '#' { - return false - } - - if p.flags&EXTENSION_SPACE_HEADERS != 0 { - level := 0 - for level < 6 && data[level] == '#' { - level++ - } - if data[level] != ' ' { - return false - } - } - return true -} - -func (p *parser) prefixHeader(out *bytes.Buffer, data []byte) int { - level := 0 - for level < 6 && data[level] == '#' { - level++ - } - i := skipChar(data, level, ' ') - end := skipUntilChar(data, i, '\n') - skip := end - id := "" - if p.flags&EXTENSION_HEADER_IDS != 0 { - j, k := 0, 0 - // find start/end of header id - for j = i; j < end-1 && (data[j] != '{' || data[j+1] != '#'); j++ { - } - for k = j + 1; k < end && data[k] != '}'; k++ { - } - // extract header id iff found - if j < end && k < end { - id = string(data[j+2 : k]) - end = j - skip = k + 1 - for end > 0 && data[end-1] == ' ' { - end-- - } - } - } - for end > 0 && data[end-1] == '#' { - if isBackslashEscaped(data, end-1) { - break - } - end-- - } - for end > 0 && data[end-1] == ' ' { - end-- - } - if end > i { - if id == "" && p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { - id = sanitized_anchor_name.Create(string(data[i:end])) - } - work := func() bool { - p.inline(out, data[i:end]) - return true - } - p.r.Header(out, work, level, id) - } - return skip -} - -func (p *parser) isUnderlinedHeader(data []byte) int { - // test of level 1 header - if data[0] == '=' { - i := skipChar(data, 1, '=') - i = skipChar(data, i, ' ') - if data[i] == '\n' { - return 1 - } else { - return 0 - } - } - - // test of level 2 header - if data[0] == '-' { - i := skipChar(data, 1, '-') - i = skipChar(data, i, ' ') - if data[i] == '\n' { - return 2 - } else { - return 0 - } - } - - return 0 -} - -func (p *parser) titleBlock(out *bytes.Buffer, data []byte, doRender bool) int { - if data[0] != '%' { - return 0 - } - splitData := bytes.Split(data, []byte("\n")) - var i int - for idx, b := range splitData { - if !bytes.HasPrefix(b, []byte("%")) { - i = idx // - 1 - break - } - } - - data = bytes.Join(splitData[0:i], []byte("\n")) - p.r.TitleBlock(out, data) - - return len(data) -} - -func (p *parser) html(out *bytes.Buffer, data []byte, doRender bool) int { - var i, j int - - // identify the opening tag - if data[0] != '<' { - return 0 - } - curtag, tagfound := p.htmlFindTag(data[1:]) - - // handle special cases - if !tagfound { - // check for an HTML comment - if size := p.htmlComment(out, data, doRender); size > 0 { - return size - } - - // check for an
tag - if size := p.htmlHr(out, data, doRender); size > 0 { - return size - } - - // check for HTML CDATA - if size := p.htmlCDATA(out, data, doRender); size > 0 { - return size - } - - // no special case recognized - return 0 - } - - // look for an unindented matching closing tag - // followed by a blank line - found := false - /* - closetag := []byte("\n") - j = len(curtag) + 1 - for !found { - // scan for a closing tag at the beginning of a line - if skip := bytes.Index(data[j:], closetag); skip >= 0 { - j += skip + len(closetag) - } else { - break - } - - // see if it is the only thing on the line - if skip := p.isEmpty(data[j:]); skip > 0 { - // see if it is followed by a blank line/eof - j += skip - if j >= len(data) { - found = true - i = j - } else { - if skip := p.isEmpty(data[j:]); skip > 0 { - j += skip - found = true - i = j - } - } - } - } - */ - - // if not found, try a second pass looking for indented match - // but not if tag is "ins" or "del" (following original Markdown.pl) - if !found && curtag != "ins" && curtag != "del" { - i = 1 - for i < len(data) { - i++ - for i < len(data) && !(data[i-1] == '<' && data[i] == '/') { - i++ - } - - if i+2+len(curtag) >= len(data) { - break - } - - j = p.htmlFindEnd(curtag, data[i-1:]) - - if j > 0 { - i += j - 1 - found = true - break - } - } - } - - if !found { - return 0 - } - - // the end of the block has been found - if doRender { - // trim newlines - end := i - for end > 0 && data[end-1] == '\n' { - end-- - } - p.r.BlockHtml(out, data[:end]) - } - - return i -} - -func (p *parser) renderHTMLBlock(out *bytes.Buffer, data []byte, start int, doRender bool) int { - // html block needs to end with a blank line - if i := p.isEmpty(data[start:]); i > 0 { - size := start + i - if doRender { - // trim trailing newlines - end := size - for end > 0 && data[end-1] == '\n' { - end-- - } - p.r.BlockHtml(out, data[:end]) - } - return size - } - return 0 -} - -// HTML comment, lax form -func (p *parser) htmlComment(out *bytes.Buffer, data []byte, doRender bool) int { - i := p.inlineHTMLComment(out, data) - return p.renderHTMLBlock(out, data, i, doRender) -} - -// HTML CDATA section -func (p *parser) htmlCDATA(out *bytes.Buffer, data []byte, doRender bool) int { - const cdataTag = "') { - i++ - } - i++ - // no end-of-comment marker - if i >= len(data) { - return 0 - } - return p.renderHTMLBlock(out, data, i, doRender) -} - -// HR, which is the only self-closing block tag considered -func (p *parser) htmlHr(out *bytes.Buffer, data []byte, doRender bool) int { - if data[0] != '<' || (data[1] != 'h' && data[1] != 'H') || (data[2] != 'r' && data[2] != 'R') { - return 0 - } - if data[3] != ' ' && data[3] != '/' && data[3] != '>' { - // not an
tag after all; at least not a valid one - return 0 - } - - i := 3 - for data[i] != '>' && data[i] != '\n' { - i++ - } - - if data[i] == '>' { - return p.renderHTMLBlock(out, data, i+1, doRender) - } - - return 0 -} - -func (p *parser) htmlFindTag(data []byte) (string, bool) { - i := 0 - for isalnum(data[i]) { - i++ - } - key := string(data[:i]) - if _, ok := blockTags[key]; ok { - return key, true - } - return "", false -} - -func (p *parser) htmlFindEnd(tag string, data []byte) int { - // assume data[0] == '<' && data[1] == '/' already tested - - // check if tag is a match - closetag := []byte("") - if !bytes.HasPrefix(data, closetag) { - return 0 - } - i := len(closetag) - - // check that the rest of the line is blank - skip := 0 - if skip = p.isEmpty(data[i:]); skip == 0 { - return 0 - } - i += skip - skip = 0 - - if i >= len(data) { - return i - } - - if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { - return i - } - if skip = p.isEmpty(data[i:]); skip == 0 { - // following line must be blank - return 0 - } - - return i + skip -} - -func (p *parser) isEmpty(data []byte) int { - // it is okay to call isEmpty on an empty buffer - if len(data) == 0 { - return 0 - } - - var i int - for i = 0; i < len(data) && data[i] != '\n'; i++ { - if data[i] != ' ' && data[i] != '\t' { - return 0 - } - } - return i + 1 -} - -func (p *parser) isHRule(data []byte) bool { - i := 0 - - // skip up to three spaces - for i < 3 && data[i] == ' ' { - i++ - } - - // look at the hrule char - if data[i] != '*' && data[i] != '-' && data[i] != '_' { - return false - } - c := data[i] - - // the whole line must be the char or whitespace - n := 0 - for data[i] != '\n' { - switch { - case data[i] == c: - n++ - case data[i] != ' ': - return false - } - i++ - } - - return n >= 3 -} - -func (p *parser) isFencedCode(data []byte, syntax **string, oldmarker string) (skip int, marker string) { - i, size := 0, 0 - skip = 0 - - // skip up to three spaces - for i < len(data) && i < 3 && data[i] == ' ' { - i++ - } - if i >= len(data) { - return - } - - // check for the marker characters: ~ or ` - if data[i] != '~' && data[i] != '`' { - return - } - - c := data[i] - - // the whole line must be the same char or whitespace - for i < len(data) && data[i] == c { - size++ - i++ - } - - if i >= len(data) { - return - } - - // the marker char must occur at least 3 times - if size < 3 { - return - } - marker = string(data[i-size : i]) - - // if this is the end marker, it must match the beginning marker - if oldmarker != "" && marker != oldmarker { - return - } - - if syntax != nil { - syn := 0 - i = skipChar(data, i, ' ') - - if i >= len(data) { - return - } - - syntaxStart := i - - if data[i] == '{' { - i++ - syntaxStart++ - - for i < len(data) && data[i] != '}' && data[i] != '\n' { - syn++ - i++ - } - - if i >= len(data) || data[i] != '}' { - return - } - - // strip all whitespace at the beginning and the end - // of the {} block - for syn > 0 && isspace(data[syntaxStart]) { - syntaxStart++ - syn-- - } - - for syn > 0 && isspace(data[syntaxStart+syn-1]) { - syn-- - } - - i++ - } else { - for i < len(data) && !isspace(data[i]) { - syn++ - i++ - } - } - - language := string(data[syntaxStart : syntaxStart+syn]) - *syntax = &language - } - - i = skipChar(data, i, ' ') - if i >= len(data) || data[i] != '\n' { - return - } - - skip = i + 1 - return -} - -func (p *parser) fencedCode(out *bytes.Buffer, data []byte, doRender bool) int { - var lang *string - beg, marker := p.isFencedCode(data, &lang, "") - if beg == 0 || beg >= len(data) { - return 0 - } - - var work bytes.Buffer - - for { - // safe to assume beg < len(data) - - // check for the end of the code block - fenceEnd, _ := p.isFencedCode(data[beg:], nil, marker) - if fenceEnd != 0 { - beg += fenceEnd - break - } - - // copy the current line - end := skipUntilChar(data, beg, '\n') + 1 - - // did we reach the end of the buffer without a closing marker? - if end >= len(data) { - return 0 - } - - // verbatim copy to the working buffer - if doRender { - work.Write(data[beg:end]) - } - beg = end - } - - syntax := "" - if lang != nil { - syntax = *lang - } - - if doRender { - p.r.BlockCode(out, work.Bytes(), syntax) - } - - return beg -} - -func (p *parser) table(out *bytes.Buffer, data []byte) int { - var header bytes.Buffer - i, columns := p.tableHeader(&header, data) - if i == 0 { - return 0 - } - - var body bytes.Buffer - - for i < len(data) { - pipes, rowStart := 0, i - for ; data[i] != '\n'; i++ { - if data[i] == '|' { - pipes++ - } - } - - if pipes == 0 { - i = rowStart - break - } - - // include the newline in data sent to tableRow - i++ - p.tableRow(&body, data[rowStart:i], columns, false) - } - - p.r.Table(out, header.Bytes(), body.Bytes(), columns) - - return i -} - -// check if the specified position is preceded by an odd number of backslashes -func isBackslashEscaped(data []byte, i int) bool { - backslashes := 0 - for i-backslashes-1 >= 0 && data[i-backslashes-1] == '\\' { - backslashes++ - } - return backslashes&1 == 1 -} - -func (p *parser) tableHeader(out *bytes.Buffer, data []byte) (size int, columns []int) { - i := 0 - colCount := 1 - for i = 0; data[i] != '\n'; i++ { - if data[i] == '|' && !isBackslashEscaped(data, i) { - colCount++ - } - } - - // doesn't look like a table header - if colCount == 1 { - return - } - - // include the newline in the data sent to tableRow - header := data[:i+1] - - // column count ignores pipes at beginning or end of line - if data[0] == '|' { - colCount-- - } - if i > 2 && data[i-1] == '|' && !isBackslashEscaped(data, i-1) { - colCount-- - } - - columns = make([]int, colCount) - - // move on to the header underline - i++ - if i >= len(data) { - return - } - - if data[i] == '|' && !isBackslashEscaped(data, i) { - i++ - } - i = skipChar(data, i, ' ') - - // each column header is of form: / *:?-+:? *|/ with # dashes + # colons >= 3 - // and trailing | optional on last column - col := 0 - for data[i] != '\n' { - dashes := 0 - - if data[i] == ':' { - i++ - columns[col] |= TABLE_ALIGNMENT_LEFT - dashes++ - } - for data[i] == '-' { - i++ - dashes++ - } - if data[i] == ':' { - i++ - columns[col] |= TABLE_ALIGNMENT_RIGHT - dashes++ - } - for data[i] == ' ' { - i++ - } - - // end of column test is messy - switch { - case dashes < 3: - // not a valid column - return - - case data[i] == '|' && !isBackslashEscaped(data, i): - // marker found, now skip past trailing whitespace - col++ - i++ - for data[i] == ' ' { - i++ - } - - // trailing junk found after last column - if col >= colCount && data[i] != '\n' { - return - } - - case (data[i] != '|' || isBackslashEscaped(data, i)) && col+1 < colCount: - // something else found where marker was required - return - - case data[i] == '\n': - // marker is optional for the last column - col++ - - default: - // trailing junk found after last column - return - } - } - if col != colCount { - return - } - - p.tableRow(out, header, columns, true) - size = i + 1 - return -} - -func (p *parser) tableRow(out *bytes.Buffer, data []byte, columns []int, header bool) { - i, col := 0, 0 - var rowWork bytes.Buffer - - if data[i] == '|' && !isBackslashEscaped(data, i) { - i++ - } - - for col = 0; col < len(columns) && i < len(data); col++ { - for data[i] == ' ' { - i++ - } - - cellStart := i - - for (data[i] != '|' || isBackslashEscaped(data, i)) && data[i] != '\n' { - i++ - } - - cellEnd := i - - // skip the end-of-cell marker, possibly taking us past end of buffer - i++ - - for cellEnd > cellStart && data[cellEnd-1] == ' ' { - cellEnd-- - } - - var cellWork bytes.Buffer - p.inline(&cellWork, data[cellStart:cellEnd]) - - if header { - p.r.TableHeaderCell(&rowWork, cellWork.Bytes(), columns[col]) - } else { - p.r.TableCell(&rowWork, cellWork.Bytes(), columns[col]) - } - } - - // pad it out with empty columns to get the right number - for ; col < len(columns); col++ { - if header { - p.r.TableHeaderCell(&rowWork, nil, columns[col]) - } else { - p.r.TableCell(&rowWork, nil, columns[col]) - } - } - - // silently ignore rows with too many cells - - p.r.TableRow(out, rowWork.Bytes()) -} - -// returns blockquote prefix length -func (p *parser) quotePrefix(data []byte) int { - i := 0 - for i < 3 && data[i] == ' ' { - i++ - } - if data[i] == '>' { - if data[i+1] == ' ' { - return i + 2 - } - return i + 1 - } - return 0 -} - -// blockquote ends with at least one blank line -// followed by something without a blockquote prefix -func (p *parser) terminateBlockquote(data []byte, beg, end int) bool { - if p.isEmpty(data[beg:]) <= 0 { - return false - } - if end >= len(data) { - return true - } - return p.quotePrefix(data[end:]) == 0 && p.isEmpty(data[end:]) == 0 -} - -// parse a blockquote fragment -func (p *parser) quote(out *bytes.Buffer, data []byte) int { - var raw bytes.Buffer - beg, end := 0, 0 - for beg < len(data) { - end = beg - // Step over whole lines, collecting them. While doing that, check for - // fenced code and if one's found, incorporate it altogether, - // irregardless of any contents inside it - for data[end] != '\n' { - if p.flags&EXTENSION_FENCED_CODE != 0 { - if i := p.fencedCode(out, data[end:], false); i > 0 { - // -1 to compensate for the extra end++ after the loop: - end += i - 1 - break - } - } - end++ - } - end++ - - if pre := p.quotePrefix(data[beg:]); pre > 0 { - // skip the prefix - beg += pre - } else if p.terminateBlockquote(data, beg, end) { - break - } - - // this line is part of the blockquote - raw.Write(data[beg:end]) - beg = end - } - - var cooked bytes.Buffer - p.block(&cooked, raw.Bytes()) - p.r.BlockQuote(out, cooked.Bytes()) - return end -} - -// returns prefix length for block code -func (p *parser) codePrefix(data []byte) int { - if data[0] == ' ' && data[1] == ' ' && data[2] == ' ' && data[3] == ' ' { - return 4 - } - return 0 -} - -func (p *parser) code(out *bytes.Buffer, data []byte) int { - var work bytes.Buffer - - i := 0 - for i < len(data) { - beg := i - for data[i] != '\n' { - i++ - } - i++ - - blankline := p.isEmpty(data[beg:i]) > 0 - if pre := p.codePrefix(data[beg:i]); pre > 0 { - beg += pre - } else if !blankline { - // non-empty, non-prefixed line breaks the pre - i = beg - break - } - - // verbatim copy to the working buffeu - if blankline { - work.WriteByte('\n') - } else { - work.Write(data[beg:i]) - } - } - - // trim all the \n off the end of work - workbytes := work.Bytes() - eol := len(workbytes) - for eol > 0 && workbytes[eol-1] == '\n' { - eol-- - } - if eol != len(workbytes) { - work.Truncate(eol) - } - - work.WriteByte('\n') - - p.r.BlockCode(out, work.Bytes(), "") - - return i -} - -// returns unordered list item prefix -func (p *parser) uliPrefix(data []byte) int { - i := 0 - - // start with up to 3 spaces - for i < 3 && data[i] == ' ' { - i++ - } - - // need a *, +, or - followed by a space - if (data[i] != '*' && data[i] != '+' && data[i] != '-') || - data[i+1] != ' ' { - return 0 - } - return i + 2 -} - -// returns ordered list item prefix -func (p *parser) oliPrefix(data []byte) int { - i := 0 - - // start with up to 3 spaces - for i < 3 && data[i] == ' ' { - i++ - } - - // count the digits - start := i - for data[i] >= '0' && data[i] <= '9' { - i++ - } - - // we need >= 1 digits followed by a dot and a space - if start == i || data[i] != '.' || data[i+1] != ' ' { - return 0 - } - return i + 2 -} - -// returns definition list item prefix -func (p *parser) dliPrefix(data []byte) int { - i := 0 - - // need a : followed by a spaces - if data[i] != ':' || data[i+1] != ' ' { - return 0 - } - for data[i] == ' ' { - i++ - } - return i + 2 -} - -// parse ordered or unordered list block -func (p *parser) list(out *bytes.Buffer, data []byte, flags int) int { - i := 0 - flags |= LIST_ITEM_BEGINNING_OF_LIST - work := func() bool { - for i < len(data) { - skip := p.listItem(out, data[i:], &flags) - i += skip - - if skip == 0 || flags&LIST_ITEM_END_OF_LIST != 0 { - break - } - flags &= ^LIST_ITEM_BEGINNING_OF_LIST - } - return true - } - - p.r.List(out, work, flags) - return i -} - -// Parse a single list item. -// Assumes initial prefix is already removed if this is a sublist. -func (p *parser) listItem(out *bytes.Buffer, data []byte, flags *int) int { - // keep track of the indentation of the first line - itemIndent := 0 - for itemIndent < 3 && data[itemIndent] == ' ' { - itemIndent++ - } - - i := p.uliPrefix(data) - if i == 0 { - i = p.oliPrefix(data) - } - if i == 0 { - i = p.dliPrefix(data) - // reset definition term flag - if i > 0 { - *flags &= ^LIST_TYPE_TERM - } - } - if i == 0 { - // if in defnition list, set term flag and continue - if *flags&LIST_TYPE_DEFINITION != 0 { - *flags |= LIST_TYPE_TERM - } else { - return 0 - } - } - - // skip leading whitespace on first line - for data[i] == ' ' { - i++ - } - - // find the end of the line - line := i - for i > 0 && data[i-1] != '\n' { - i++ - } - - // get working buffer - var raw bytes.Buffer - - // put the first line into the working buffer - raw.Write(data[line:i]) - line = i - - // process the following lines - containsBlankLine := false - sublist := 0 - -gatherlines: - for line < len(data) { - i++ - - // find the end of this line - for data[i-1] != '\n' { - i++ - } - - // if it is an empty line, guess that it is part of this item - // and move on to the next line - if p.isEmpty(data[line:i]) > 0 { - containsBlankLine = true - raw.Write(data[line:i]) - line = i - continue - } - - // calculate the indentation - indent := 0 - for indent < 4 && line+indent < i && data[line+indent] == ' ' { - indent++ - } - - chunk := data[line+indent : i] - - // evaluate how this line fits in - switch { - // is this a nested list item? - case (p.uliPrefix(chunk) > 0 && !p.isHRule(chunk)) || - p.oliPrefix(chunk) > 0 || - p.dliPrefix(chunk) > 0: - - if containsBlankLine { - // end the list if the type changed after a blank line - if indent <= itemIndent && - ((*flags&LIST_TYPE_ORDERED != 0 && p.uliPrefix(chunk) > 0) || - (*flags&LIST_TYPE_ORDERED == 0 && p.oliPrefix(chunk) > 0)) { - - *flags |= LIST_ITEM_END_OF_LIST - break gatherlines - } - *flags |= LIST_ITEM_CONTAINS_BLOCK - } - - // to be a nested list, it must be indented more - // if not, it is the next item in the same list - if indent <= itemIndent { - break gatherlines - } - - // is this the first item in the nested list? - if sublist == 0 { - sublist = raw.Len() - } - - // is this a nested prefix header? - case p.isPrefixHeader(chunk): - // if the header is not indented, it is not nested in the list - // and thus ends the list - if containsBlankLine && indent < 4 { - *flags |= LIST_ITEM_END_OF_LIST - break gatherlines - } - *flags |= LIST_ITEM_CONTAINS_BLOCK - - // anything following an empty line is only part - // of this item if it is indented 4 spaces - // (regardless of the indentation of the beginning of the item) - case containsBlankLine && indent < 4: - if *flags&LIST_TYPE_DEFINITION != 0 && i < len(data)-1 { - // is the next item still a part of this list? - next := i - for data[next] != '\n' { - next++ - } - for next < len(data)-1 && data[next] == '\n' { - next++ - } - if i < len(data)-1 && data[i] != ':' && data[next] != ':' { - *flags |= LIST_ITEM_END_OF_LIST - } - } else { - *flags |= LIST_ITEM_END_OF_LIST - } - break gatherlines - - // a blank line means this should be parsed as a block - case containsBlankLine: - *flags |= LIST_ITEM_CONTAINS_BLOCK - } - - containsBlankLine = false - - // add the line into the working buffer without prefix - raw.Write(data[line+indent : i]) - - line = i - } - - rawBytes := raw.Bytes() - - // render the contents of the list item - var cooked bytes.Buffer - if *flags&LIST_ITEM_CONTAINS_BLOCK != 0 && *flags&LIST_TYPE_TERM == 0 { - // intermediate render of block item, except for definition term - if sublist > 0 { - p.block(&cooked, rawBytes[:sublist]) - p.block(&cooked, rawBytes[sublist:]) - } else { - p.block(&cooked, rawBytes) - } - } else { - // intermediate render of inline item - if sublist > 0 { - p.inline(&cooked, rawBytes[:sublist]) - p.block(&cooked, rawBytes[sublist:]) - } else { - p.inline(&cooked, rawBytes) - } - } - - // render the actual list item - cookedBytes := cooked.Bytes() - parsedEnd := len(cookedBytes) - - // strip trailing newlines - for parsedEnd > 0 && cookedBytes[parsedEnd-1] == '\n' { - parsedEnd-- - } - p.r.ListItem(out, cookedBytes[:parsedEnd], *flags) - - return line -} - -// render a single paragraph that has already been parsed out -func (p *parser) renderParagraph(out *bytes.Buffer, data []byte) { - if len(data) == 0 { - return - } - - // trim leading spaces - beg := 0 - for data[beg] == ' ' { - beg++ - } - - // trim trailing newline - end := len(data) - 1 - - // trim trailing spaces - for end > beg && data[end-1] == ' ' { - end-- - } - - work := func() bool { - p.inline(out, data[beg:end]) - return true - } - p.r.Paragraph(out, work) -} - -func (p *parser) paragraph(out *bytes.Buffer, data []byte) int { - // prev: index of 1st char of previous line - // line: index of 1st char of current line - // i: index of cursor/end of current line - var prev, line, i int - - // keep going until we find something to mark the end of the paragraph - for i < len(data) { - // mark the beginning of the current line - prev = line - current := data[i:] - line = i - - // did we find a blank line marking the end of the paragraph? - if n := p.isEmpty(current); n > 0 { - // did this blank line followed by a definition list item? - if p.flags&EXTENSION_DEFINITION_LISTS != 0 { - if i < len(data)-1 && data[i+1] == ':' { - return p.list(out, data[prev:], LIST_TYPE_DEFINITION) - } - } - - p.renderParagraph(out, data[:i]) - return i + n - } - - // an underline under some text marks a header, so our paragraph ended on prev line - if i > 0 { - if level := p.isUnderlinedHeader(current); level > 0 { - // render the paragraph - p.renderParagraph(out, data[:prev]) - - // ignore leading and trailing whitespace - eol := i - 1 - for prev < eol && data[prev] == ' ' { - prev++ - } - for eol > prev && data[eol-1] == ' ' { - eol-- - } - - // render the header - // this ugly double closure avoids forcing variables onto the heap - work := func(o *bytes.Buffer, pp *parser, d []byte) func() bool { - return func() bool { - pp.inline(o, d) - return true - } - }(out, p, data[prev:eol]) - - id := "" - if p.flags&EXTENSION_AUTO_HEADER_IDS != 0 { - id = sanitized_anchor_name.Create(string(data[prev:eol])) - } - - p.r.Header(out, work, level, id) - - // find the end of the underline - for data[i] != '\n' { - i++ - } - return i - } - } - - // if the next line starts a block of HTML, then the paragraph ends here - if p.flags&EXTENSION_LAX_HTML_BLOCKS != 0 { - if data[i] == '<' && p.html(out, current, false) > 0 { - // rewind to before the HTML block - p.renderParagraph(out, data[:i]) - return i - } - } - - // if there's a prefixed header or a horizontal rule after this, paragraph is over - if p.isPrefixHeader(current) || p.isHRule(current) { - p.renderParagraph(out, data[:i]) - return i - } - - // if there's a fenced code block, paragraph is over - if p.flags&EXTENSION_FENCED_CODE != 0 { - if p.fencedCode(out, current, false) > 0 { - p.renderParagraph(out, data[:i]) - return i - } - } - - // if there's a definition list item, prev line is a definition term - if p.flags&EXTENSION_DEFINITION_LISTS != 0 { - if p.dliPrefix(current) != 0 { - return p.list(out, data[prev:], LIST_TYPE_DEFINITION) - } - } - - // if there's a list after this, paragraph is over - if p.flags&EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK != 0 { - if p.uliPrefix(current) != 0 || - p.oliPrefix(current) != 0 || - p.quotePrefix(current) != 0 || - p.codePrefix(current) != 0 { - p.renderParagraph(out, data[:i]) - return i - } - } - - // otherwise, scan to the beginning of the next line - for data[i] != '\n' { - i++ - } - i++ - } - - p.renderParagraph(out, data[:i]) - return i -} diff --git a/vendor/github.com/russross/blackfriday/block_test.go b/vendor/github.com/russross/blackfriday/block_test.go deleted file mode 100644 index f3618fe..0000000 --- a/vendor/github.com/russross/blackfriday/block_test.go +++ /dev/null @@ -1,1638 +0,0 @@ -// -// Blackfriday Markdown Processor -// Available at http://github.com/russross/blackfriday -// -// Copyright © 2011 Russ Ross . -// Distributed under the Simplified BSD License. -// See README.md for details. -// - -// -// Unit tests for block parsing -// - -package blackfriday - -import ( - "strings" - "testing" -) - -func runMarkdownBlockWithRenderer(input string, extensions int, renderer Renderer) string { - return string(Markdown([]byte(input), renderer, extensions)) -} - -func runMarkdownBlock(input string, extensions int) string { - htmlFlags := 0 - htmlFlags |= HTML_USE_XHTML - - renderer := HtmlRenderer(htmlFlags, "", "") - - return runMarkdownBlockWithRenderer(input, extensions, renderer) -} - -func runnerWithRendererParameters(parameters HtmlRendererParameters) func(string, int) string { - return func(input string, extensions int) string { - htmlFlags := 0 - htmlFlags |= HTML_USE_XHTML - - renderer := HtmlRendererWithParameters(htmlFlags, "", "", parameters) - - return runMarkdownBlockWithRenderer(input, extensions, renderer) - } -} - -func doTestsBlock(t *testing.T, tests []string, extensions int) { - doTestsBlockWithRunner(t, tests, extensions, runMarkdownBlock) -} - -func doTestsBlockWithRunner(t *testing.T, tests []string, extensions int, runner func(string, int) string) { - // catch and report panics - var candidate string - defer func() { - if err := recover(); err != nil { - t.Errorf("\npanic while processing [%#v]: %s\n", candidate, err) - } - }() - - for i := 0; i+1 < len(tests); i += 2 { - input := tests[i] - candidate = input - expected := tests[i+1] - actual := runner(candidate, extensions) - if actual != expected { - t.Errorf("\nInput [%#v]\nExpected[%#v]\nActual [%#v]", - candidate, expected, actual) - } - - // now test every substring to stress test bounds checking - if !testing.Short() { - for start := 0; start < len(input); start++ { - for end := start + 1; end <= len(input); end++ { - candidate = input[start:end] - _ = runMarkdownBlock(candidate, extensions) - } - } - } - } -} - -func TestPrefixHeaderNoExtensions(t *testing.T) { - var tests = []string{ - "# Header 1\n", - "

Header 1

\n", - - "## Header 2\n", - "

Header 2

\n", - - "### Header 3\n", - "

Header 3

\n", - - "#### Header 4\n", - "

Header 4

\n", - - "##### Header 5\n", - "
Header 5
\n", - - "###### Header 6\n", - "
Header 6
\n", - - "####### Header 7\n", - "
# Header 7
\n", - - "#Header 1\n", - "

Header 1

\n", - - "##Header 2\n", - "

Header 2

\n", - - "###Header 3\n", - "

Header 3

\n", - - "####Header 4\n", - "

Header 4

\n", - - "#####Header 5\n", - "
Header 5
\n", - - "######Header 6\n", - "
Header 6
\n", - - "#######Header 7\n", - "
#Header 7
\n", - - "Hello\n# Header 1\nGoodbye\n", - "

Hello

\n\n

Header 1

\n\n

Goodbye

\n", - - "* List\n# Header\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n#Header\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n * Nested list\n # Nested header\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list

      \n\n" + - "

      Nested header

    • \n
  • \n
\n", - - "#Header 1 \\#\n", - "

Header 1 #

\n", - - "#Header 1 \\# foo\n", - "

Header 1 # foo

\n", - - "#Header 1 #\\##\n", - "

Header 1 ##

\n", - } - doTestsBlock(t, tests, 0) -} - -func TestPrefixHeaderSpaceExtension(t *testing.T) { - var tests = []string{ - "# Header 1\n", - "

Header 1

\n", - - "## Header 2\n", - "

Header 2

\n", - - "### Header 3\n", - "

Header 3

\n", - - "#### Header 4\n", - "

Header 4

\n", - - "##### Header 5\n", - "
Header 5
\n", - - "###### Header 6\n", - "
Header 6
\n", - - "####### Header 7\n", - "

####### Header 7

\n", - - "#Header 1\n", - "

#Header 1

\n", - - "##Header 2\n", - "

##Header 2

\n", - - "###Header 3\n", - "

###Header 3

\n", - - "####Header 4\n", - "

####Header 4

\n", - - "#####Header 5\n", - "

#####Header 5

\n", - - "######Header 6\n", - "

######Header 6

\n", - - "#######Header 7\n", - "

#######Header 7

\n", - - "Hello\n# Header 1\nGoodbye\n", - "

Hello

\n\n

Header 1

\n\n

Goodbye

\n", - - "* List\n# Header\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n#Header\n* List\n", - "
    \n
  • List\n#Header
  • \n
  • List
  • \n
\n", - - "* List\n * Nested list\n # Nested header\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list

      \n\n" + - "

      Nested header

    • \n
  • \n
\n", - } - doTestsBlock(t, tests, EXTENSION_SPACE_HEADERS) -} - -func TestPrefixHeaderIdExtension(t *testing.T) { - var tests = []string{ - "# Header 1 {#someid}\n", - "

Header 1

\n", - - "# Header 1 {#someid} \n", - "

Header 1

\n", - - "# Header 1 {#someid}\n", - "

Header 1

\n", - - "# Header 1 {#someid\n", - "

Header 1 {#someid

\n", - - "# Header 1 {#someid\n", - "

Header 1 {#someid

\n", - - "# Header 1 {#someid}}\n", - "

Header 1

\n\n

}

\n", - - "## Header 2 {#someid}\n", - "

Header 2

\n", - - "### Header 3 {#someid}\n", - "

Header 3

\n", - - "#### Header 4 {#someid}\n", - "

Header 4

\n", - - "##### Header 5 {#someid}\n", - "
Header 5
\n", - - "###### Header 6 {#someid}\n", - "
Header 6
\n", - - "####### Header 7 {#someid}\n", - "
# Header 7
\n", - - "# Header 1 # {#someid}\n", - "

Header 1

\n", - - "## Header 2 ## {#someid}\n", - "

Header 2

\n", - - "Hello\n# Header 1\nGoodbye\n", - "

Hello

\n\n

Header 1

\n\n

Goodbye

\n", - - "* List\n# Header {#someid}\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n#Header {#someid}\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n * Nested list\n # Nested header {#someid}\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list

      \n\n" + - "

      Nested header

    • \n
  • \n
\n", - } - doTestsBlock(t, tests, EXTENSION_HEADER_IDS) -} - -func TestPrefixHeaderIdExtensionWithPrefixAndSuffix(t *testing.T) { - var tests = []string{ - "# header 1 {#someid}\n", - "

header 1

\n", - - "## header 2 {#someid}\n", - "

header 2

\n", - - "### header 3 {#someid}\n", - "

header 3

\n", - - "#### header 4 {#someid}\n", - "

header 4

\n", - - "##### header 5 {#someid}\n", - "
header 5
\n", - - "###### header 6 {#someid}\n", - "
header 6
\n", - - "####### header 7 {#someid}\n", - "
# header 7
\n", - - "# header 1 # {#someid}\n", - "

header 1

\n", - - "## header 2 ## {#someid}\n", - "

header 2

\n", - - "* List\n# Header {#someid}\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n#Header {#someid}\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n * Nested list\n # Nested header {#someid}\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list

      \n\n" + - "

      Nested header

    • \n
  • \n
\n", - } - - parameters := HtmlRendererParameters{ - HeaderIDPrefix: "PRE:", - HeaderIDSuffix: ":POST", - } - - doTestsBlockWithRunner(t, tests, EXTENSION_HEADER_IDS, runnerWithRendererParameters(parameters)) -} - -func TestPrefixAutoHeaderIdExtension(t *testing.T) { - var tests = []string{ - "# Header 1\n", - "

Header 1

\n", - - "# Header 1 \n", - "

Header 1

\n", - - "## Header 2\n", - "

Header 2

\n", - - "### Header 3\n", - "

Header 3

\n", - - "#### Header 4\n", - "

Header 4

\n", - - "##### Header 5\n", - "
Header 5
\n", - - "###### Header 6\n", - "
Header 6
\n", - - "####### Header 7\n", - "
# Header 7
\n", - - "Hello\n# Header 1\nGoodbye\n", - "

Hello

\n\n

Header 1

\n\n

Goodbye

\n", - - "* List\n# Header\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n#Header\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n * Nested list\n # Nested header\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list

      \n\n" + - "

      Nested header

    • \n
  • \n
\n", - - "# Header\n\n# Header\n", - "

Header

\n\n

Header

\n", - - "# Header 1\n\n# Header 1", - "

Header 1

\n\n

Header 1

\n", - - "# Header\n\n# Header 1\n\n# Header\n\n# Header", - "

Header

\n\n

Header 1

\n\n

Header

\n\n

Header

\n", - } - doTestsBlock(t, tests, EXTENSION_AUTO_HEADER_IDS) -} - -func TestPrefixAutoHeaderIdExtensionWithPrefixAndSuffix(t *testing.T) { - var tests = []string{ - "# Header 1\n", - "

Header 1

\n", - - "# Header 1 \n", - "

Header 1

\n", - - "## Header 2\n", - "

Header 2

\n", - - "### Header 3\n", - "

Header 3

\n", - - "#### Header 4\n", - "

Header 4

\n", - - "##### Header 5\n", - "
Header 5
\n", - - "###### Header 6\n", - "
Header 6
\n", - - "####### Header 7\n", - "
# Header 7
\n", - - "Hello\n# Header 1\nGoodbye\n", - "

Hello

\n\n

Header 1

\n\n

Goodbye

\n", - - "* List\n# Header\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n#Header\n* List\n", - "
    \n
  • List

    \n\n

    Header

  • \n\n
  • List

  • \n
\n", - - "* List\n * Nested list\n # Nested header\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list

      \n\n" + - "

      Nested header

    • \n
  • \n
\n", - - "# Header\n\n# Header\n", - "

Header

\n\n

Header

\n", - - "# Header 1\n\n# Header 1", - "

Header 1

\n\n

Header 1

\n", - - "# Header\n\n# Header 1\n\n# Header\n\n# Header", - "

Header

\n\n

Header 1

\n\n

Header

\n\n

Header

\n", - } - - parameters := HtmlRendererParameters{ - HeaderIDPrefix: "PRE:", - HeaderIDSuffix: ":POST", - } - - doTestsBlockWithRunner(t, tests, EXTENSION_AUTO_HEADER_IDS, runnerWithRendererParameters(parameters)) -} - -func TestPrefixMultipleHeaderExtensions(t *testing.T) { - var tests = []string{ - "# Header\n\n# Header {#header}\n\n# Header 1", - "

Header

\n\n

Header

\n\n

Header 1

\n", - } - doTestsBlock(t, tests, EXTENSION_AUTO_HEADER_IDS|EXTENSION_HEADER_IDS) -} - -func TestUnderlineHeaders(t *testing.T) { - var tests = []string{ - "Header 1\n========\n", - "

Header 1

\n", - - "Header 2\n--------\n", - "

Header 2

\n", - - "A\n=\n", - "

A

\n", - - "B\n-\n", - "

B

\n", - - "Paragraph\nHeader\n=\n", - "

Paragraph

\n\n

Header

\n", - - "Header\n===\nParagraph\n", - "

Header

\n\n

Paragraph

\n", - - "Header\n===\nAnother header\n---\n", - "

Header

\n\n

Another header

\n", - - " Header\n======\n", - "

Header

\n", - - " Code\n========\n", - "
Code\n
\n\n

========

\n", - - "Header with *inline*\n=====\n", - "

Header with inline

\n", - - "* List\n * Sublist\n Not a header\n ------\n", - "
    \n
  • List\n\n
      \n
    • Sublist\nNot a header\n------
    • \n
  • \n
\n", - - "Paragraph\n\n\n\n\nHeader\n===\n", - "

Paragraph

\n\n

Header

\n", - - "Trailing space \n==== \n\n", - "

Trailing space

\n", - - "Trailing spaces\n==== \n\n", - "

Trailing spaces

\n", - - "Double underline\n=====\n=====\n", - "

Double underline

\n\n

=====

\n", - } - doTestsBlock(t, tests, 0) -} - -func TestUnderlineHeadersAutoIDs(t *testing.T) { - var tests = []string{ - "Header 1\n========\n", - "

Header 1

\n", - - "Header 2\n--------\n", - "

Header 2

\n", - - "A\n=\n", - "

A

\n", - - "B\n-\n", - "

B

\n", - - "Paragraph\nHeader\n=\n", - "

Paragraph

\n\n

Header

\n", - - "Header\n===\nParagraph\n", - "

Header

\n\n

Paragraph

\n", - - "Header\n===\nAnother header\n---\n", - "

Header

\n\n

Another header

\n", - - " Header\n======\n", - "

Header

\n", - - "Header with *inline*\n=====\n", - "

Header with inline

\n", - - "Paragraph\n\n\n\n\nHeader\n===\n", - "

Paragraph

\n\n

Header

\n", - - "Trailing space \n==== \n\n", - "

Trailing space

\n", - - "Trailing spaces\n==== \n\n", - "

Trailing spaces

\n", - - "Double underline\n=====\n=====\n", - "

Double underline

\n\n

=====

\n", - - "Header\n======\n\nHeader\n======\n", - "

Header

\n\n

Header

\n", - - "Header 1\n========\n\nHeader 1\n========\n", - "

Header 1

\n\n

Header 1

\n", - } - doTestsBlock(t, tests, EXTENSION_AUTO_HEADER_IDS) -} - -func TestHorizontalRule(t *testing.T) { - var tests = []string{ - "-\n", - "

-

\n", - - "--\n", - "

--

\n", - - "---\n", - "
\n", - - "----\n", - "
\n", - - "*\n", - "

*

\n", - - "**\n", - "

**

\n", - - "***\n", - "
\n", - - "****\n", - "
\n", - - "_\n", - "

_

\n", - - "__\n", - "

__

\n", - - "___\n", - "
\n", - - "____\n", - "
\n", - - "-*-\n", - "

-*-

\n", - - "- - -\n", - "
\n", - - "* * *\n", - "
\n", - - "_ _ _\n", - "
\n", - - "-----*\n", - "

-----*

\n", - - " ------ \n", - "
\n", - - "Hello\n***\n", - "

Hello

\n\n
\n", - - "---\n***\n___\n", - "
\n\n
\n\n
\n", - } - doTestsBlock(t, tests, 0) -} - -func TestUnorderedList(t *testing.T) { - var tests = []string{ - "* Hello\n", - "
    \n
  • Hello
  • \n
\n", - - "* Yin\n* Yang\n", - "
    \n
  • Yin
  • \n
  • Yang
  • \n
\n", - - "* Ting\n* Bong\n* Goo\n", - "
    \n
  • Ting
  • \n
  • Bong
  • \n
  • Goo
  • \n
\n", - - "* Yin\n\n* Yang\n", - "
    \n
  • Yin

  • \n\n
  • Yang

  • \n
\n", - - "* Ting\n\n* Bong\n* Goo\n", - "
    \n
  • Ting

  • \n\n
  • Bong

  • \n\n
  • Goo

  • \n
\n", - - "+ Hello\n", - "
    \n
  • Hello
  • \n
\n", - - "+ Yin\n+ Yang\n", - "
    \n
  • Yin
  • \n
  • Yang
  • \n
\n", - - "+ Ting\n+ Bong\n+ Goo\n", - "
    \n
  • Ting
  • \n
  • Bong
  • \n
  • Goo
  • \n
\n", - - "+ Yin\n\n+ Yang\n", - "
    \n
  • Yin

  • \n\n
  • Yang

  • \n
\n", - - "+ Ting\n\n+ Bong\n+ Goo\n", - "
    \n
  • Ting

  • \n\n
  • Bong

  • \n\n
  • Goo

  • \n
\n", - - "- Hello\n", - "
    \n
  • Hello
  • \n
\n", - - "- Yin\n- Yang\n", - "
    \n
  • Yin
  • \n
  • Yang
  • \n
\n", - - "- Ting\n- Bong\n- Goo\n", - "
    \n
  • Ting
  • \n
  • Bong
  • \n
  • Goo
  • \n
\n", - - "- Yin\n\n- Yang\n", - "
    \n
  • Yin

  • \n\n
  • Yang

  • \n
\n", - - "- Ting\n\n- Bong\n- Goo\n", - "
    \n
  • Ting

  • \n\n
  • Bong

  • \n\n
  • Goo

  • \n
\n", - - "*Hello\n", - "

*Hello

\n", - - "* Hello \n", - "
    \n
  • Hello
  • \n
\n", - - "* Hello \n Next line \n", - "
    \n
  • Hello\nNext line
  • \n
\n", - - "Paragraph\n* No linebreak\n", - "

Paragraph\n* No linebreak

\n", - - "Paragraph\n\n* Linebreak\n", - "

Paragraph

\n\n
    \n
  • Linebreak
  • \n
\n", - - "* List\n\n1. Spacer Mixed listing\n", - "
    \n
  • List
  • \n
\n\n
    \n
  1. Spacer Mixed listing
  2. \n
\n", - - "* List\n * Nested list\n", - "
    \n
  • List\n\n
      \n
    • Nested list
    • \n
  • \n
\n", - - "* List\n\n * Nested list\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list
    • \n
  • \n
\n", - - "* List\n Second line\n\n + Nested\n", - "
    \n
  • List\nSecond line

    \n\n
      \n
    • Nested
    • \n
  • \n
\n", - - "* List\n + Nested\n\n Continued\n", - "
    \n
  • List

    \n\n
      \n
    • Nested
    • \n
    \n\n

    Continued

  • \n
\n", - - "* List\n * shallow indent\n", - "
    \n
  • List\n\n
      \n
    • shallow indent
    • \n
  • \n
\n", - - "* List\n" + - " * shallow indent\n" + - " * part of second list\n" + - " * still second\n" + - " * almost there\n" + - " * third level\n", - "
    \n" + - "
  • List\n\n" + - "
      \n" + - "
    • shallow indent
    • \n" + - "
    • part of second list
    • \n" + - "
    • still second
    • \n" + - "
    • almost there\n\n" + - "
        \n" + - "
      • third level
      • \n" + - "
    • \n" + - "
  • \n" + - "
\n", - - "* List\n extra indent, same paragraph\n", - "
    \n
  • List\n extra indent, same paragraph
  • \n
\n", - - "* List\n\n code block\n", - "
    \n
  • List

    \n\n
    code block\n
  • \n
\n", - - "* List\n\n code block with spaces\n", - "
    \n
  • List

    \n\n
      code block with spaces\n
  • \n
\n", - - "* List\n\n * sublist\n\n normal text\n\n * another sublist\n", - "
    \n
  • List

    \n\n
      \n
    • sublist
    • \n
    \n\n

    normal text

    \n\n
      \n
    • another sublist
    • \n
  • \n
\n", - - `* Foo - - bar - - qux -`, - `
    -
  • Foo

    - -
    bar
    -
    -qux
    -
  • -
-`, - } - doTestsBlock(t, tests, 0) -} - -func TestFencedCodeBlockWithinList(t *testing.T) { - doTestsBlock(t, []string{ - "* Foo\n\n ```\n bar\n\n qux\n ```\n", - `
    -
  • Foo

    - -
    bar
    -
    -qux
    -
  • -
-`, - }, EXTENSION_FENCED_CODE) -} - -func TestOrderedList(t *testing.T) { - var tests = []string{ - "1. Hello\n", - "
    \n
  1. Hello
  2. \n
\n", - - "1. Yin\n2. Yang\n", - "
    \n
  1. Yin
  2. \n
  3. Yang
  4. \n
\n", - - "1. Ting\n2. Bong\n3. Goo\n", - "
    \n
  1. Ting
  2. \n
  3. Bong
  4. \n
  5. Goo
  6. \n
\n", - - "1. Yin\n\n2. Yang\n", - "
    \n
  1. Yin

  2. \n\n
  3. Yang

  4. \n
\n", - - "1. Ting\n\n2. Bong\n3. Goo\n", - "
    \n
  1. Ting

  2. \n\n
  3. Bong

  4. \n\n
  5. Goo

  6. \n
\n", - - "1 Hello\n", - "

1 Hello

\n", - - "1.Hello\n", - "

1.Hello

\n", - - "1. Hello \n", - "
    \n
  1. Hello
  2. \n
\n", - - "1. Hello \n Next line \n", - "
    \n
  1. Hello\nNext line
  2. \n
\n", - - "Paragraph\n1. No linebreak\n", - "

Paragraph\n1. No linebreak

\n", - - "Paragraph\n\n1. Linebreak\n", - "

Paragraph

\n\n
    \n
  1. Linebreak
  2. \n
\n", - - "1. List\n 1. Nested list\n", - "
    \n
  1. List\n\n
      \n
    1. Nested list
    2. \n
  2. \n
\n", - - "1. List\n\n 1. Nested list\n", - "
    \n
  1. List

    \n\n
      \n
    1. Nested list
    2. \n
  2. \n
\n", - - "1. List\n Second line\n\n 1. Nested\n", - "
    \n
  1. List\nSecond line

    \n\n
      \n
    1. Nested
    2. \n
  2. \n
\n", - - "1. List\n 1. Nested\n\n Continued\n", - "
    \n
  1. List

    \n\n
      \n
    1. Nested
    2. \n
    \n\n

    Continued

  2. \n
\n", - - "1. List\n 1. shallow indent\n", - "
    \n
  1. List\n\n
      \n
    1. shallow indent
    2. \n
  2. \n
\n", - - "1. List\n" + - " 1. shallow indent\n" + - " 2. part of second list\n" + - " 3. still second\n" + - " 4. almost there\n" + - " 1. third level\n", - "
    \n" + - "
  1. List\n\n" + - "
      \n" + - "
    1. shallow indent
    2. \n" + - "
    3. part of second list
    4. \n" + - "
    5. still second
    6. \n" + - "
    7. almost there\n\n" + - "
        \n" + - "
      1. third level
      2. \n" + - "
    8. \n" + - "
  2. \n" + - "
\n", - - "1. List\n extra indent, same paragraph\n", - "
    \n
  1. List\n extra indent, same paragraph
  2. \n
\n", - - "1. List\n\n code block\n", - "
    \n
  1. List

    \n\n
    code block\n
  2. \n
\n", - - "1. List\n\n code block with spaces\n", - "
    \n
  1. List

    \n\n
      code block with spaces\n
  2. \n
\n", - - "1. List\n\n* Spacer Mixed listing\n", - "
    \n
  1. List
  2. \n
\n\n
    \n
  • Spacer Mixed listing
  • \n
\n", - - "1. List\n* Mixed listing\n", - "
    \n
  1. List
  2. \n
  3. Mixed listing
  4. \n
\n", - - "1. List\n * Mixted list\n", - "
    \n
  1. List\n\n
      \n
    • Mixted list
    • \n
  2. \n
\n", - - "1. List\n * Mixed list\n", - "
    \n
  1. List\n\n
      \n
    • Mixed list
    • \n
  2. \n
\n", - - "* Start with unordered\n 1. Ordered\n", - "
    \n
  • Start with unordered\n\n
      \n
    1. Ordered
    2. \n
  • \n
\n", - - "* Start with unordered\n 1. Ordered\n", - "
    \n
  • Start with unordered\n\n
      \n
    1. Ordered
    2. \n
  • \n
\n", - - "1. numbers\n1. are ignored\n", - "
    \n
  1. numbers
  2. \n
  3. are ignored
  4. \n
\n", - - `1. Foo - - bar - - - - qux -`, - `
    -
  1. Foo

    - -
    bar
    -
    -
    -
    -qux
    -
  2. -
-`, - } - doTestsBlock(t, tests, 0) -} - -func TestDefinitionList(t *testing.T) { - var tests = []string{ - "Term 1\n: Definition a\n", - "
\n
Term 1
\n
Definition a
\n
\n", - - "Term 1\n: Definition a \n", - "
\n
Term 1
\n
Definition a
\n
\n", - - "Term 1\n: Definition a\n: Definition b\n", - "
\n
Term 1
\n
Definition a
\n
Definition b
\n
\n", - - "Term 1\n: Definition a\n\nTerm 2\n: Definition b\n", - "
\n" + - "
Term 1
\n" + - "
Definition a
\n" + - "
Term 2
\n" + - "
Definition b
\n" + - "
\n", - - "Term 1\n: Definition a\n\nTerm 2\n: Definition b\n\nTerm 3\n: Definition c\n", - "
\n" + - "
Term 1
\n" + - "
Definition a
\n" + - "
Term 2
\n" + - "
Definition b
\n" + - "
Term 3
\n" + - "
Definition c
\n" + - "
\n", - - "Term 1\n: Definition a\n: Definition b\n\nTerm 2\n: Definition c\n", - "
\n" + - "
Term 1
\n" + - "
Definition a
\n" + - "
Definition b
\n" + - "
Term 2
\n" + - "
Definition c
\n" + - "
\n", - - "Term 1\n\n: Definition a\n\nTerm 2\n\n: Definition b\n", - "
\n" + - "
Term 1
\n" + - "

Definition a

\n" + - "
Term 2
\n" + - "

Definition b

\n" + - "
\n", - - "Term 1\n\n: Definition a\n\n: Definition b\n\nTerm 2\n\n: Definition c\n", - "
\n" + - "
Term 1
\n" + - "

Definition a

\n" + - "

Definition b

\n" + - "
Term 2
\n" + - "

Definition c

\n" + - "
\n", - - "Term 1\n: Definition a\nNext line\n", - "
\n
Term 1
\n
Definition a\nNext line
\n
\n", - - "Term 1\n: Definition a\n Next line\n", - "
\n
Term 1
\n
Definition a\nNext line
\n
\n", - - "Term 1\n: Definition a \n Next line \n", - "
\n
Term 1
\n
Definition a\nNext line
\n
\n", - - "Term 1\n: Definition a\nNext line\n\nTerm 2\n: Definition b", - "
\n" + - "
Term 1
\n" + - "
Definition a\nNext line
\n" + - "
Term 2
\n" + - "
Definition b
\n" + - "
\n", - - "Term 1\n: Definition a\n", - "
\n
Term 1
\n
Definition a
\n
\n", - - "Term 1\n:Definition a\n", - "

Term 1\n:Definition a

\n", - - "Term 1\n\n: Definition a\n\nTerm 2\n\n: Definition b\n\nText 1", - "
\n" + - "
Term 1
\n" + - "

Definition a

\n" + - "
Term 2
\n" + - "

Definition b

\n" + - "
\n" + - "\n

Text 1

\n", - - "Term 1\n\n: Definition a\n\nText 1\n\nTerm 2\n\n: Definition b\n\nText 2", - "
\n" + - "
Term 1
\n" + - "

Definition a

\n" + - "
\n" + - "\n

Text 1

\n" + - "\n
\n" + - "
Term 2
\n" + - "

Definition b

\n" + - "
\n" + - "\n

Text 2

\n", - - "Term 1\n: Definition a\n\n Text 1\n\n 1. First\n 2. Second", - "
\n" + - "
Term 1
\n" + - "

Definition a

\n\n" + - "

Text 1

\n\n" + - "
    \n
  1. First
  2. \n
  3. Second
  4. \n
\n" + - "
\n", - } - doTestsBlock(t, tests, EXTENSION_DEFINITION_LISTS) -} - -func TestPreformattedHtml(t *testing.T) { - var tests = []string{ - "
\n", - "
\n", - - "
\n
\n", - "
\n
\n", - - "
\n
\nParagraph\n", - "

\n
\nParagraph

\n", - - "
\n
\n", - "
\n
\n", - - "
\nAnything here\n
\n", - "
\nAnything here\n
\n", - - "
\n Anything here\n
\n", - "
\n Anything here\n
\n", - - "
\nAnything here\n
\n", - "
\nAnything here\n
\n", - - "
\nThis is *not* &proceessed\n
\n", - "
\nThis is *not* &proceessed\n
\n", - - "\n Something\n\n", - "

\n Something\n

\n", - - "
\n Something here\n\n", - "

\n Something here\n

\n", - - "Paragraph\n
\nHere? >&<\n
\n", - "

Paragraph\n

\nHere? >&<\n

\n", - - "Paragraph\n\n
\nHow about here? >&<\n
\n", - "

Paragraph

\n\n
\nHow about here? >&<\n
\n", - - "Paragraph\n
\nHere? >&<\n
\nAnd here?\n", - "

Paragraph\n

\nHere? >&<\n
\nAnd here?

\n", - - "Paragraph\n\n
\nHow about here? >&<\n
\nAnd here?\n", - "

Paragraph

\n\n

\nHow about here? >&<\n
\nAnd here?

\n", - - "Paragraph\n
\nHere? >&<\n
\n\nAnd here?\n", - "

Paragraph\n

\nHere? >&<\n

\n\n

And here?

\n", - - "Paragraph\n\n
\nHow about here? >&<\n
\n\nAnd here?\n", - "

Paragraph

\n\n
\nHow about here? >&<\n
\n\n

And here?

\n", - } - doTestsBlock(t, tests, 0) -} - -func TestPreformattedHtmlLax(t *testing.T) { - var tests = []string{ - "Paragraph\n
\nHere? >&<\n
\n", - "

Paragraph

\n\n
\nHere? >&<\n
\n", - - "Paragraph\n\n
\nHow about here? >&<\n
\n", - "

Paragraph

\n\n
\nHow about here? >&<\n
\n", - - "Paragraph\n
\nHere? >&<\n
\nAnd here?\n", - "

Paragraph

\n\n
\nHere? >&<\n
\n\n

And here?

\n", - - "Paragraph\n\n
\nHow about here? >&<\n
\nAnd here?\n", - "

Paragraph

\n\n
\nHow about here? >&<\n
\n\n

And here?

\n", - - "Paragraph\n
\nHere? >&<\n
\n\nAnd here?\n", - "

Paragraph

\n\n
\nHere? >&<\n
\n\n

And here?

\n", - - "Paragraph\n\n
\nHow about here? >&<\n
\n\nAnd here?\n", - "

Paragraph

\n\n
\nHow about here? >&<\n
\n\n

And here?

\n", - } - doTestsBlock(t, tests, EXTENSION_LAX_HTML_BLOCKS) -} - -func TestFencedCodeBlock(t *testing.T) { - var tests = []string{ - "``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n", - "
func foo() bool {\n\treturn true;\n}\n
\n", - - "``` c\n/* special & char < > \" escaping */\n```\n", - "
/* special & char < > " escaping */\n
\n", - - "``` c\nno *inline* processing ~~of text~~\n```\n", - "
no *inline* processing ~~of text~~\n
\n", - - "```\nNo language\n```\n", - "
No language\n
\n", - - "``` {ocaml}\nlanguage in braces\n```\n", - "
language in braces\n
\n", - - "``` {ocaml} \nwith extra whitespace\n```\n", - "
with extra whitespace\n
\n", - - "```{ ocaml }\nwith extra whitespace\n```\n", - "
with extra whitespace\n
\n", - - "~ ~~ java\nWith whitespace\n~~~\n", - "

~ ~~ java\nWith whitespace\n~~~

\n", - - "~~\nonly two\n~~\n", - "

~~\nonly two\n~~

\n", - - "```` python\nextra\n````\n", - "
extra\n
\n", - - "~~~ perl\nthree to start, four to end\n~~~~\n", - "

~~~ perl\nthree to start, four to end\n~~~~

\n", - - "~~~~ perl\nfour to start, three to end\n~~~\n", - "

~~~~ perl\nfour to start, three to end\n~~~

\n", - - "~~~ bash\ntildes\n~~~\n", - "
tildes\n
\n", - - "``` lisp\nno ending\n", - "

``` lisp\nno ending

\n", - - "~~~ lisp\nend with language\n~~~ lisp\n", - "

~~~ lisp\nend with language\n~~~ lisp

\n", - - "```\nmismatched begin and end\n~~~\n", - "

```\nmismatched begin and end\n~~~

\n", - - "~~~\nmismatched begin and end\n```\n", - "

~~~\nmismatched begin and end\n```

\n", - - " ``` oz\nleading spaces\n```\n", - "
leading spaces\n
\n", - - " ``` oz\nleading spaces\n ```\n", - "
leading spaces\n
\n", - - " ``` oz\nleading spaces\n ```\n", - "
leading spaces\n
\n", - - "``` oz\nleading spaces\n ```\n", - "
leading spaces\n
\n", - - " ``` oz\nleading spaces\n ```\n", - "
``` oz\n
\n\n

leading spaces\n ```

\n", - - "Bla bla\n\n``` oz\ncode blocks breakup paragraphs\n```\n\nBla Bla\n", - "

Bla bla

\n\n
code blocks breakup paragraphs\n
\n\n

Bla Bla

\n", - - "Some text before a fenced code block\n``` oz\ncode blocks breakup paragraphs\n```\nAnd some text after a fenced code block", - "

Some text before a fenced code block

\n\n
code blocks breakup paragraphs\n
\n\n

And some text after a fenced code block

\n", - - "`", - "

`

\n", - - "Bla bla\n\n``` oz\ncode blocks breakup paragraphs\n```\n\nBla Bla\n\n``` oz\nmultiple code blocks work okay\n```\n\nBla Bla\n", - "

Bla bla

\n\n
code blocks breakup paragraphs\n
\n\n

Bla Bla

\n\n
multiple code blocks work okay\n
\n\n

Bla Bla

\n", - - "Some text before a fenced code block\n``` oz\ncode blocks breakup paragraphs\n```\nSome text in between\n``` oz\nmultiple code blocks work okay\n```\nAnd some text after a fenced code block", - "

Some text before a fenced code block

\n\n
code blocks breakup paragraphs\n
\n\n

Some text in between

\n\n
multiple code blocks work okay\n
\n\n

And some text after a fenced code block

\n", - } - doTestsBlock(t, tests, EXTENSION_FENCED_CODE) -} - -func TestFencedCodeInsideBlockquotes(t *testing.T) { - cat := func(s ...string) string { return strings.Join(s, "\n") } - var tests = []string{ - cat("> ```go", - "package moo", - "", - "```", - ""), - `
-
package moo
-
-
-
-`, - // ------------------------------------------- - cat("> foo", - "> ", - "> ```go", - "package moo", - "```", - "> ", - "> goo.", - ""), - `
-

foo

- -
package moo
-
- -

goo.

-
-`, - // ------------------------------------------- - cat("> foo", - "> ", - "> quote", - "continues", - "```", - ""), - `
-

foo

- -

quote -continues -` + "```" + `

-
-`, - // ------------------------------------------- - cat("> foo", - "> ", - "> ```go", - "package moo", - "```", - "> ", - "> goo.", - "> ", - "> ```go", - "package zoo", - "```", - "> ", - "> woo.", - ""), - `
-

foo

- -
package moo
-
- -

goo.

- -
package zoo
-
- -

woo.

-
-`, - } - - // These 2 alternative forms of blockquoted fenced code blocks should produce same output. - forms := [2]string{ - cat("> plain quoted text", - "> ```fenced", - "code", - " with leading single space correctly preserved", - "okay", - "```", - "> rest of quoted text"), - cat("> plain quoted text", - "> ```fenced", - "> code", - "> with leading single space correctly preserved", - "> okay", - "> ```", - "> rest of quoted text"), - } - want := `
-

plain quoted text

- -
code
- with leading single space correctly preserved
-okay
-
- -

rest of quoted text

-
-` - tests = append(tests, forms[0], want) - tests = append(tests, forms[1], want) - - doTestsBlock(t, tests, EXTENSION_FENCED_CODE) -} - -func TestTable(t *testing.T) { - var tests = []string{ - "a | b\n---|---\nc | d\n", - "\n\n\n\n\n\n\n\n" + - "\n\n\n\n\n\n
ab
cd
\n", - - "a | b\n---|--\nc | d\n", - "

a | b\n---|--\nc | d

\n", - - "|a|b|c|d|\n|----|----|----|---|\n|e|f|g|h|\n", - "\n\n\n\n\n\n\n\n\n\n" + - "\n\n\n\n\n\n\n\n
abcd
efgh
\n", - - "*a*|__b__|[c](C)|d\n---|---|---|---\ne|f|g|h\n", - "\n\n\n\n\n\n\n\n\n\n" + - "\n\n\n\n\n\n\n\n
abcd
efgh
\n", - - "a|b|c\n---|---|---\nd|e|f\ng|h\ni|j|k|l|m\nn|o|p\n", - "\n\n\n\n\n\n\n\n\n" + - "\n\n\n\n\n\n\n" + - "\n\n\n\n\n\n" + - "\n\n\n\n\n\n" + - "\n\n\n\n\n\n
abc
def
gh
ijk
nop
\n", - - "a|b|c\n---|---|---\n*d*|__e__|f\n", - "\n\n\n\n\n\n\n\n\n" + - "\n\n\n\n\n\n\n
abc
def
\n", - - "a|b|c|d\n:--|--:|:-:|---\ne|f|g|h\n", - "\n\n\n\n\n" + - "\n\n\n\n\n" + - "\n\n\n\n" + - "\n\n\n\n
abcd
efgh
\n", - - "a|b|c\n---|---|---\n", - "\n\n\n\n\n\n\n\n\n\n\n
abc
\n", - - "a| b|c | d | e\n---|---|---|---|---\nf| g|h | i |j\n", - "\n\n\n\n\n\n\n\n\n\n\n" + - "\n\n\n\n\n\n\n\n\n
abcde
fghij
\n", - - "a|b\\|c|d\n---|---|---\nf|g\\|h|i\n", - "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
ab|cd
fg|hi
\n", - } - doTestsBlock(t, tests, EXTENSION_TABLES) -} - -func TestUnorderedListWith_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) { - var tests = []string{ - "* Hello\n", - "
    \n
  • Hello
  • \n
\n", - - "* Yin\n* Yang\n", - "
    \n
  • Yin
  • \n
  • Yang
  • \n
\n", - - "* Ting\n* Bong\n* Goo\n", - "
    \n
  • Ting
  • \n
  • Bong
  • \n
  • Goo
  • \n
\n", - - "* Yin\n\n* Yang\n", - "
    \n
  • Yin

  • \n\n
  • Yang

  • \n
\n", - - "* Ting\n\n* Bong\n* Goo\n", - "
    \n
  • Ting

  • \n\n
  • Bong

  • \n\n
  • Goo

  • \n
\n", - - "+ Hello\n", - "
    \n
  • Hello
  • \n
\n", - - "+ Yin\n+ Yang\n", - "
    \n
  • Yin
  • \n
  • Yang
  • \n
\n", - - "+ Ting\n+ Bong\n+ Goo\n", - "
    \n
  • Ting
  • \n
  • Bong
  • \n
  • Goo
  • \n
\n", - - "+ Yin\n\n+ Yang\n", - "
    \n
  • Yin

  • \n\n
  • Yang

  • \n
\n", - - "+ Ting\n\n+ Bong\n+ Goo\n", - "
    \n
  • Ting

  • \n\n
  • Bong

  • \n\n
  • Goo

  • \n
\n", - - "- Hello\n", - "
    \n
  • Hello
  • \n
\n", - - "- Yin\n- Yang\n", - "
    \n
  • Yin
  • \n
  • Yang
  • \n
\n", - - "- Ting\n- Bong\n- Goo\n", - "
    \n
  • Ting
  • \n
  • Bong
  • \n
  • Goo
  • \n
\n", - - "- Yin\n\n- Yang\n", - "
    \n
  • Yin

  • \n\n
  • Yang

  • \n
\n", - - "- Ting\n\n- Bong\n- Goo\n", - "
    \n
  • Ting

  • \n\n
  • Bong

  • \n\n
  • Goo

  • \n
\n", - - "*Hello\n", - "

*Hello

\n", - - "* Hello \n", - "
    \n
  • Hello
  • \n
\n", - - "* Hello \n Next line \n", - "
    \n
  • Hello\nNext line
  • \n
\n", - - "Paragraph\n* No linebreak\n", - "

Paragraph

\n\n
    \n
  • No linebreak
  • \n
\n", - - "Paragraph\n\n* Linebreak\n", - "

Paragraph

\n\n
    \n
  • Linebreak
  • \n
\n", - - "* List\n * Nested list\n", - "
    \n
  • List\n\n
      \n
    • Nested list
    • \n
  • \n
\n", - - "* List\n\n * Nested list\n", - "
    \n
  • List

    \n\n
      \n
    • Nested list
    • \n
  • \n
\n", - - "* List\n Second line\n\n + Nested\n", - "
    \n
  • List\nSecond line

    \n\n
      \n
    • Nested
    • \n
  • \n
\n", - - "* List\n + Nested\n\n Continued\n", - "
    \n
  • List

    \n\n
      \n
    • Nested
    • \n
    \n\n

    Continued

  • \n
\n", - - "* List\n * shallow indent\n", - "
    \n
  • List\n\n
      \n
    • shallow indent
    • \n
  • \n
\n", - - "* List\n" + - " * shallow indent\n" + - " * part of second list\n" + - " * still second\n" + - " * almost there\n" + - " * third level\n", - "
    \n" + - "
  • List\n\n" + - "
      \n" + - "
    • shallow indent
    • \n" + - "
    • part of second list
    • \n" + - "
    • still second
    • \n" + - "
    • almost there\n\n" + - "
        \n" + - "
      • third level
      • \n" + - "
    • \n" + - "
  • \n" + - "
\n", - - "* List\n extra indent, same paragraph\n", - "
    \n
  • List\n extra indent, same paragraph
  • \n
\n", - - "* List\n\n code block\n", - "
    \n
  • List

    \n\n
    code block\n
  • \n
\n", - - "* List\n\n code block with spaces\n", - "
    \n
  • List

    \n\n
      code block with spaces\n
  • \n
\n", - - "* List\n\n * sublist\n\n normal text\n\n * another sublist\n", - "
    \n
  • List

    \n\n
      \n
    • sublist
    • \n
    \n\n

    normal text

    \n\n
      \n
    • another sublist
    • \n
  • \n
\n", - } - doTestsBlock(t, tests, EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK) -} - -func TestOrderedList_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) { - var tests = []string{ - "1. Hello\n", - "
    \n
  1. Hello
  2. \n
\n", - - "1. Yin\n2. Yang\n", - "
    \n
  1. Yin
  2. \n
  3. Yang
  4. \n
\n", - - "1. Ting\n2. Bong\n3. Goo\n", - "
    \n
  1. Ting
  2. \n
  3. Bong
  4. \n
  5. Goo
  6. \n
\n", - - "1. Yin\n\n2. Yang\n", - "
    \n
  1. Yin

  2. \n\n
  3. Yang

  4. \n
\n", - - "1. Ting\n\n2. Bong\n3. Goo\n", - "
    \n
  1. Ting

  2. \n\n
  3. Bong

  4. \n\n
  5. Goo

  6. \n
\n", - - "1 Hello\n", - "

1 Hello

\n", - - "1.Hello\n", - "

1.Hello

\n", - - "1. Hello \n", - "
    \n
  1. Hello
  2. \n
\n", - - "1. Hello \n Next line \n", - "
    \n
  1. Hello\nNext line
  2. \n
\n", - - "Paragraph\n1. No linebreak\n", - "

Paragraph

\n\n
    \n
  1. No linebreak
  2. \n
\n", - - "Paragraph\n\n1. Linebreak\n", - "

Paragraph

\n\n
    \n
  1. Linebreak
  2. \n
\n", - - "1. List\n 1. Nested list\n", - "
    \n
  1. List\n\n
      \n
    1. Nested list
    2. \n
  2. \n
\n", - - "1. List\n\n 1. Nested list\n", - "
    \n
  1. List

    \n\n
      \n
    1. Nested list
    2. \n
  2. \n
\n", - - "1. List\n Second line\n\n 1. Nested\n", - "
    \n
  1. List\nSecond line

    \n\n
      \n
    1. Nested
    2. \n
  2. \n
\n", - - "1. List\n 1. Nested\n\n Continued\n", - "
    \n
  1. List

    \n\n
      \n
    1. Nested
    2. \n
    \n\n

    Continued

  2. \n
\n", - - "1. List\n 1. shallow indent\n", - "
    \n
  1. List\n\n
      \n
    1. shallow indent
    2. \n
  2. \n
\n", - - "1. List\n" + - " 1. shallow indent\n" + - " 2. part of second list\n" + - " 3. still second\n" + - " 4. almost there\n" + - " 1. third level\n", - "
    \n" + - "
  1. List\n\n" + - "
      \n" + - "
    1. shallow indent
    2. \n" + - "
    3. part of second list
    4. \n" + - "
    5. still second
    6. \n" + - "
    7. almost there\n\n" + - "
        \n" + - "
      1. third level
      2. \n" + - "
    8. \n" + - "
  2. \n" + - "
\n", - - "1. List\n extra indent, same paragraph\n", - "
    \n
  1. List\n extra indent, same paragraph
  2. \n
\n", - - "1. List\n\n code block\n", - "
    \n
  1. List

    \n\n
    code block\n
  2. \n
\n", - - "1. List\n\n code block with spaces\n", - "
    \n
  1. List

    \n\n
      code block with spaces\n
  2. \n
\n", - - "1. List\n * Mixted list\n", - "
    \n
  1. List\n\n
      \n
    • Mixted list
    • \n
  2. \n
\n", - - "1. List\n * Mixed list\n", - "
    \n
  1. List\n\n
      \n
    • Mixed list
    • \n
  2. \n
\n", - - "* Start with unordered\n 1. Ordered\n", - "
    \n
  • Start with unordered\n\n
      \n
    1. Ordered
    2. \n
  • \n
\n", - - "* Start with unordered\n 1. Ordered\n", - "
    \n
  • Start with unordered\n\n
      \n
    1. Ordered
    2. \n
  • \n
\n", - - "1. numbers\n1. are ignored\n", - "
    \n
  1. numbers
  2. \n
  3. are ignored
  4. \n
\n", - } - doTestsBlock(t, tests, EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK) -} - -func TestFencedCodeBlock_EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK(t *testing.T) { - var tests = []string{ - "``` go\nfunc foo() bool {\n\treturn true;\n}\n```\n", - "
func foo() bool {\n\treturn true;\n}\n
\n", - - "``` c\n/* special & char < > \" escaping */\n```\n", - "
/* special & char < > " escaping */\n
\n", - - "``` c\nno *inline* processing ~~of text~~\n```\n", - "
no *inline* processing ~~of text~~\n
\n", - - "```\nNo language\n```\n", - "
No language\n
\n", - - "``` {ocaml}\nlanguage in braces\n```\n", - "
language in braces\n
\n", - - "``` {ocaml} \nwith extra whitespace\n```\n", - "
with extra whitespace\n
\n", - - "```{ ocaml }\nwith extra whitespace\n```\n", - "
with extra whitespace\n
\n", - - "~ ~~ java\nWith whitespace\n~~~\n", - "

~ ~~ java\nWith whitespace\n~~~

\n", - - "~~\nonly two\n~~\n", - "

~~\nonly two\n~~

\n", - - "```` python\nextra\n````\n", - "
extra\n
\n", - - "~~~ perl\nthree to start, four to end\n~~~~\n", - "

~~~ perl\nthree to start, four to end\n~~~~

\n", - - "~~~~ perl\nfour to start, three to end\n~~~\n", - "

~~~~ perl\nfour to start, three to end\n~~~

\n", - - "~~~ bash\ntildes\n~~~\n", - "
tildes\n
\n", - - "``` lisp\nno ending\n", - "

``` lisp\nno ending

\n", - - "~~~ lisp\nend with language\n~~~ lisp\n", - "

~~~ lisp\nend with language\n~~~ lisp

\n", - - "```\nmismatched begin and end\n~~~\n", - "

```\nmismatched begin and end\n~~~

\n", - - "~~~\nmismatched begin and end\n```\n", - "

~~~\nmismatched begin and end\n```

\n", - - " ``` oz\nleading spaces\n```\n", - "
leading spaces\n
\n", - - " ``` oz\nleading spaces\n ```\n", - "
leading spaces\n
\n", - - " ``` oz\nleading spaces\n ```\n", - "
leading spaces\n
\n", - - "``` oz\nleading spaces\n ```\n", - "
leading spaces\n
\n", - - " ``` oz\nleading spaces\n ```\n", - "
``` oz\n
\n\n

leading spaces

\n\n
```\n
\n", - } - doTestsBlock(t, tests, EXTENSION_FENCED_CODE|EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK) -} - -func TestTitleBlock_EXTENSION_TITLEBLOCK(t *testing.T) { - var tests = []string{ - "% Some title\n" + - "% Another title line\n" + - "% Yep, more here too\n", - "

" + - "Some title\n" + - "Another title line\n" + - "Yep, more here too\n" + - "

", - } - doTestsBlock(t, tests, EXTENSION_TITLEBLOCK) -} - -func TestBlockComments(t *testing.T) { - var tests = []string{ - "Some text\n\n\n", - "

Some text

\n\n\n", - - "Some text\n\n\n", - "

Some text

\n\n\n", - - "Some text\n\n\n", - "

Some text

\n\n\n", - } - doTestsBlock(t, tests, 0) -} - -func TestCDATA(t *testing.T) { - var tests = []string{ - "Some text\n\n\n", - "

Some text

\n\n\n", - - "CDATA ]]\n\n\n", - "

CDATA ]]

\n\n\n", - - "CDATA >\n\n]]>\n", - "

CDATA >

\n\n]]>\n", - - "Lots of text\n\n\n", - "

Lots of text

\n\n\n", - - "]]>\n", - "]]>\n", - } - doTestsBlock(t, tests, 0) - doTestsBlock(t, []string{ - "``` html\n\n```\n", - "
<![CDATA[foo]]>\n
\n", - - "\n", - "\n", - - ` def func(): -> pass -]]> -`, - ` def func(): -> pass -]]> -`, - }, EXTENSION_FENCED_CODE) -} diff --git a/vendor/github.com/russross/blackfriday/html.go b/vendor/github.com/russross/blackfriday/html.go deleted file mode 100644 index 74e67ee..0000000 --- a/vendor/github.com/russross/blackfriday/html.go +++ /dev/null @@ -1,949 +0,0 @@ -// -// Blackfriday Markdown Processor -// Available at http://github.com/russross/blackfriday -// -// Copyright © 2011 Russ Ross . -// Distributed under the Simplified BSD License. -// See README.md for details. -// - -// -// -// HTML rendering backend -// -// - -package blackfriday - -import ( - "bytes" - "fmt" - "regexp" - "strconv" - "strings" -) - -// Html renderer configuration options. -const ( - HTML_SKIP_HTML = 1 << iota // skip preformatted HTML blocks - HTML_SKIP_STYLE // skip embedded - - - -

HTTP charset

- - -
- - -
 
- - - - - -
-

The character encoding of a page can be set using the HTTP header charset declaration.

-

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

The only character encoding declaration for this HTML file is in the HTTP header, which sets the encoding to ISO 8859-15.

-
-
-
HTML5
-

the-input-byte-stream-001
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html b/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html deleted file mode 100644 index 26e5d8b..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - HTTP vs UTF-8 BOM - - - - - - - - - - - -

HTTP vs UTF-8 BOM

- - -
- - -
 
- - - - - -
-

A character encoding set in the HTTP header has lower precedence than the UTF-8 signature.

-

The HTTP header attempts to set the character encoding to ISO 8859-15. The page starts with a UTF-8 signature.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

If the test is unsuccessful, the characters  should appear at the top of the page. These represent the bytes that make up the UTF-8 signature when encountered in the ISO 8859-15 encoding.

-
-
-
HTML5
-

the-input-byte-stream-034
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html b/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html deleted file mode 100644 index 2f07e95..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - HTTP vs meta charset - - - - - - - - - - - -

HTTP vs meta charset

- - -
- - -
 
- - - - - -
-

The HTTP header has a higher precedence than an encoding declaration in a meta charset attribute.

-

The HTTP header attempts to set the character encoding to ISO 8859-15. The page contains an encoding declaration in a meta charset attribute that attempts to set the character encoding to ISO 8859-1.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

-
-
-
HTML5
-

the-input-byte-stream-018
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html b/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html deleted file mode 100644 index 6853cdd..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - HTTP vs meta content - - - - - - - - - - - -

HTTP vs meta content

- - -
- - -
 
- - - - - -
-

The HTTP header has a higher precedence than an encoding declaration in a meta content attribute.

-

The HTTP header attempts to set the character encoding to ISO 8859-15. The page contains an encoding declaration in a meta content attribute that attempts to set the character encoding to ISO 8859-1.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

-
-
-
HTML5
-

the-input-byte-stream-016
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html b/vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html deleted file mode 100644 index 612e26c..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - No encoding declaration - - - - - - - - - - - -

No encoding declaration

- - -
- - -
 
- - - - - -
-

A page with no encoding information in HTTP, BOM, XML declaration or meta element will be treated as UTF-8.

-

The test on this page contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

-
-
-
HTML5
-

the-input-byte-stream-015
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/README b/vendor/golang.org/x/net/html/charset/testdata/README deleted file mode 100644 index 38ef0f9..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/README +++ /dev/null @@ -1,9 +0,0 @@ -These test cases come from -http://www.w3.org/International/tests/repository/html5/the-input-byte-stream/results-basics - -Distributed under both the W3C Test Suite License -(http://www.w3.org/Consortium/Legal/2008/04-testsuite-license) -and the W3C 3-clause BSD License -(http://www.w3.org/Consortium/Legal/2008/03-bsd-license). -To contribute to a W3C Test Suite, see the policies and contribution -forms (http://www.w3.org/2004/10/27-testcases). diff --git a/vendor/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html b/vendor/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html deleted file mode 100644 index 3abf7a9343c20518e57dfea58b374fb0f4fb58a1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2670 zcmcJR?QRoS5Qc}JAoU&=BQ-(7b^;2j8i*i3RV1JlO@;VXIsPurV!WHiDdLW}i`*CO z^UnC>tih=KsVr;H&Y7?C&O3AV(?534uG?e##U9y_y|!QNi4``n+D>d{2lky^LnFNx z?9HrarH$>rwQR_$g)Hk0*&STI*EYq|47~&U9sfUB+ji})9eR{QqCUra7oDsZ5obtB zdxP%<)-$4Q;rSHJiM>U(#ZI=;?n^BC?Dp6lu=~_1-lnX3u03&2BlmQIY>L+!Uq7XoytKw^Q#oZSM?3*J?)&ojG&yzQRkC!Ml5JE?ax;lp_NYEcdUht`ZswOviB~L5hmJ|pXI71nn20w;>vG! zQGB$EE9&wC``&J#_Ym~PgRu-Bd>1!pOp0||k`kr=VJ zfH6I6rmRaeHA7U-A^OTsT+|d2a^i(>DePzZ{)ibXoCBvJnuYrd-3kkN$uy{qQK;=*Y;S87ro12aTgu^i*%f8zC3>a}9DIe4cfxOzsCw&(cqvP9{ud{N6f` z#TNDY(B6@Gpr|uN+%&x^XZjBHdc@2vsM(Tyc2=vshHQ5w+obmp>tuWT(t4BTUGAQw zxeI$UGSLUBg=WFbF;4f@4=^P2AgY@CFn8A`bcC=_&~)fiDe)#cUARRBzJ^k|%X)69 z+{Cb`wq}Rsg%B62CC_tK!AV(W{(MV?#mndR46CU#BUN<{8e?*oT+!pE5wF#O#TR#a z$9qRT)tpbw8zAI~QQJg2C3|6$I%(T(;`zOMy6SO+&;pG=c#2P|P-WZn$$DpWJlC3U z3*nvmz zwP{u~r$L?-m3uqp9I1+#3yE|3M$(s-BEtih=LQ>`qYoiktOop(wi%!;yh%+Rm z{e|xntY<{q!1F1Z6MKtngPm-p-4|H&+3m4AVE3_AyiHm6Tzlf4M(*ht*%YrezJ6kr zHGj45pc?64*$Cm%-zseWMA`x;)v*~jA=i}szqts9xmQkS`M11|(H7bTXAycsXU53+ zJ?120SRZeyiFjW7enPN`bxk$IaWV3o48oJF7D&2ysoY;6(s6%6vVfaYd&mC=erK!) zNGI^7upQgN)53OHe_VE<@J+G8*Y|p*)zB2Thdi}+YR<5QWHm!|a_*AoZXuv7)$xe| zm3Q$D7{|#}{m4X&UY!6(ZhyYi2(5JLzGE$H)W6BQklnjPMwn<Yvv7Z*TVWwD*=E3QpH37* z#lqXJA0A~J9T_<^W5smspmDg2p6ac5Bjn+~LAoow%1TCdZ*$K8`O zw_$HaCi+0N&@7la#_7KL5r$+QL{)Pi=I&aDjt~|Knht#`CEi4*3%97i_fSfASlwUz0=3V0GCxY}z81UC-nP=CGt2OqYV$ zoRCo+qM9YX*3FFORLC=E3B~S@+KROyk4r5 yX7?DaslDfIebqXgC!KKp4IYy+W~X?ddE6o=`A+x#x0AK&6MF#W&AXxbRrv+SX}PNa diff --git a/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html b/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html deleted file mode 100644 index 83de433..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - UTF-8 BOM vs meta charset - - - - - - - - - - - -

UTF-8 BOM vs meta charset

- - -
- - -
 
- - - - - -
-

A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta charset attribute declares a different encoding.

-

The page contains an encoding declaration in a meta charset attribute that attempts to set the character encoding to ISO 8859-15, but the file starts with a UTF-8 signature.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

-
-
-
HTML5
-

the-input-byte-stream-038
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html b/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html deleted file mode 100644 index 501aac2..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - UTF-8 BOM vs meta content - - - - - - - - - - - -

UTF-8 BOM vs meta content

- - -
- - -
 
- - - - - -
-

A page with a UTF-8 BOM will be recognized as UTF-8 even if the meta content attribute declares a different encoding.

-

The page contains an encoding declaration in a meta content attribute that attempts to set the character encoding to ISO 8859-15, but the file starts with a UTF-8 signature.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ýäè. This matches the sequence of bytes above when they are interpreted as UTF-8. If the class name matches the selector then the test will pass.

-
-
-
HTML5
-

the-input-byte-stream-037
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html b/vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html deleted file mode 100644 index 2d7d25a..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - meta charset attribute - - - - - - - - - - - -

meta charset attribute

- - -
- - -
 
- - - - - -
-

The character encoding of the page can be set by a meta element with charset attribute.

-

The only character encoding declaration for this HTML file is in the charset attribute of the meta element, which declares the encoding to be ISO 8859-15.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

-
-
-
HTML5
-

the-input-byte-stream-009
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html b/vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html deleted file mode 100644 index 1c3f228..0000000 --- a/vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - meta content attribute - - - - - - - - - - - -

meta content attribute

- - -
- - -
 
- - - - - -
-

The character encoding of the page can be set by a meta element with http-equiv and content attributes.

-

The only character encoding declaration for this HTML file is in the content attribute of the meta element, which declares the encoding to be ISO 8859-15.

The test contains a div with a class name that contains the following sequence of bytes: 0xC3 0xBD 0xC3 0xA4 0xC3 0xA8. These represent different sequences of characters in ISO 8859-15, ISO 8859-1 and UTF-8. The external, UTF-8-encoded stylesheet contains a selector .test div.ÜÀÚ. This matches the sequence of bytes above when they are interpreted as ISO 8859-15. If the class name matches the selector then the test will pass.

-
-
-
HTML5
-

the-input-byte-stream-007
Result summary & related tests
Detailed results for this test
Link to spec

-
Assumptions:
  • The default encoding for the browser you are testing is not set to ISO 8859-15.
  • -
  • The test is read from a server that supports HTTP.
-
- - - - - - diff --git a/vendor/golang.org/x/net/html/const.go b/vendor/golang.org/x/net/html/const.go deleted file mode 100644 index 52f651f..0000000 --- a/vendor/golang.org/x/net/html/const.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright 2011 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 html - -// Section 12.2.3.2 of the HTML5 specification says "The following elements -// have varying levels of special parsing rules". -// https://html.spec.whatwg.org/multipage/syntax.html#the-stack-of-open-elements -var isSpecialElementMap = map[string]bool{ - "address": true, - "applet": true, - "area": true, - "article": true, - "aside": true, - "base": true, - "basefont": true, - "bgsound": true, - "blockquote": true, - "body": true, - "br": true, - "button": true, - "caption": true, - "center": true, - "col": true, - "colgroup": true, - "dd": true, - "details": true, - "dir": true, - "div": true, - "dl": true, - "dt": true, - "embed": true, - "fieldset": true, - "figcaption": true, - "figure": true, - "footer": true, - "form": true, - "frame": true, - "frameset": true, - "h1": true, - "h2": true, - "h3": true, - "h4": true, - "h5": true, - "h6": true, - "head": true, - "header": true, - "hgroup": true, - "hr": true, - "html": true, - "iframe": true, - "img": true, - "input": true, - "isindex": true, - "li": true, - "link": true, - "listing": true, - "marquee": true, - "menu": true, - "meta": true, - "nav": true, - "noembed": true, - "noframes": true, - "noscript": true, - "object": true, - "ol": true, - "p": true, - "param": true, - "plaintext": true, - "pre": true, - "script": true, - "section": true, - "select": true, - "source": true, - "style": true, - "summary": true, - "table": true, - "tbody": true, - "td": true, - "template": true, - "textarea": true, - "tfoot": true, - "th": true, - "thead": true, - "title": true, - "tr": true, - "track": true, - "ul": true, - "wbr": true, - "xmp": true, -} - -func isSpecialElement(element *Node) bool { - switch element.Namespace { - case "", "html": - return isSpecialElementMap[element.Data] - case "svg": - return element.Data == "foreignObject" - } - return false -} diff --git a/vendor/golang.org/x/net/html/doc.go b/vendor/golang.org/x/net/html/doc.go deleted file mode 100644 index 94f4968..0000000 --- a/vendor/golang.org/x/net/html/doc.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2010 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 html implements an HTML5-compliant tokenizer and parser. - -Tokenization is done by creating a Tokenizer for an io.Reader r. It is the -caller's responsibility to ensure that r provides UTF-8 encoded HTML. - - z := html.NewTokenizer(r) - -Given a Tokenizer z, the HTML is tokenized by repeatedly calling z.Next(), -which parses the next token and returns its type, or an error: - - for { - tt := z.Next() - if tt == html.ErrorToken { - // ... - return ... - } - // Process the current token. - } - -There are two APIs for retrieving the current token. The high-level API is to -call Token; the low-level API is to call Text or TagName / TagAttr. Both APIs -allow optionally calling Raw after Next but before Token, Text, TagName, or -TagAttr. In EBNF notation, the valid call sequence per token is: - - Next {Raw} [ Token | Text | TagName {TagAttr} ] - -Token returns an independent data structure that completely describes a token. -Entities (such as "<") are unescaped, tag names and attribute keys are -lower-cased, and attributes are collected into a []Attribute. For example: - - for { - if z.Next() == html.ErrorToken { - // Returning io.EOF indicates success. - return z.Err() - } - emitToken(z.Token()) - } - -The low-level API performs fewer allocations and copies, but the contents of -the []byte values returned by Text, TagName and TagAttr may change on the next -call to Next. For example, to extract an HTML page's anchor text: - - depth := 0 - for { - tt := z.Next() - switch tt { - case ErrorToken: - return z.Err() - case TextToken: - if depth > 0 { - // emitBytes should copy the []byte it receives, - // if it doesn't process it immediately. - emitBytes(z.Text()) - } - case StartTagToken, EndTagToken: - tn, _ := z.TagName() - if len(tn) == 1 && tn[0] == 'a' { - if tt == StartTagToken { - depth++ - } else { - depth-- - } - } - } - } - -Parsing is done by calling Parse with an io.Reader, which returns the root of -the parse tree (the document element) as a *Node. It is the caller's -responsibility to ensure that the Reader provides UTF-8 encoded HTML. For -example, to process each anchor node in depth-first order: - - doc, err := html.Parse(r) - if err != nil { - // ... - } - var f func(*html.Node) - f = func(n *html.Node) { - if n.Type == html.ElementNode && n.Data == "a" { - // Do something with n... - } - for c := n.FirstChild; c != nil; c = c.NextSibling { - f(c) - } - } - f(doc) - -The relevant specifications include: -https://html.spec.whatwg.org/multipage/syntax.html and -https://html.spec.whatwg.org/multipage/syntax.html#tokenization -*/ -package html // import "golang.org/x/net/html" - -// The tokenization algorithm implemented by this package is not a line-by-line -// transliteration of the relatively verbose state-machine in the WHATWG -// specification. A more direct approach is used instead, where the program -// counter implies the state, such as whether it is tokenizing a tag or a text -// node. Specification compliance is verified by checking expected and actual -// outputs over a test suite rather than aiming for algorithmic fidelity. - -// TODO(nigeltao): Does a DOM API belong in this package or a separate one? -// TODO(nigeltao): How does parsing interact with a JavaScript engine? diff --git a/vendor/golang.org/x/net/html/doctype.go b/vendor/golang.org/x/net/html/doctype.go deleted file mode 100644 index c484e5a..0000000 --- a/vendor/golang.org/x/net/html/doctype.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright 2011 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 html - -import ( - "strings" -) - -// parseDoctype parses the data from a DoctypeToken into a name, -// public identifier, and system identifier. It returns a Node whose Type -// is DoctypeNode, whose Data is the name, and which has attributes -// named "system" and "public" for the two identifiers if they were present. -// quirks is whether the document should be parsed in "quirks mode". -func parseDoctype(s string) (n *Node, quirks bool) { - n = &Node{Type: DoctypeNode} - - // Find the name. - space := strings.IndexAny(s, whitespace) - if space == -1 { - space = len(s) - } - n.Data = s[:space] - // The comparison to "html" is case-sensitive. - if n.Data != "html" { - quirks = true - } - n.Data = strings.ToLower(n.Data) - s = strings.TrimLeft(s[space:], whitespace) - - if len(s) < 6 { - // It can't start with "PUBLIC" or "SYSTEM". - // Ignore the rest of the string. - return n, quirks || s != "" - } - - key := strings.ToLower(s[:6]) - s = s[6:] - for key == "public" || key == "system" { - s = strings.TrimLeft(s, whitespace) - if s == "" { - break - } - quote := s[0] - if quote != '"' && quote != '\'' { - break - } - s = s[1:] - q := strings.IndexRune(s, rune(quote)) - var id string - if q == -1 { - id = s - s = "" - } else { - id = s[:q] - s = s[q+1:] - } - n.Attr = append(n.Attr, Attribute{Key: key, Val: id}) - if key == "public" { - key = "system" - } else { - key = "" - } - } - - if key != "" || s != "" { - quirks = true - } else if len(n.Attr) > 0 { - if n.Attr[0].Key == "public" { - public := strings.ToLower(n.Attr[0].Val) - switch public { - case "-//w3o//dtd w3 html strict 3.0//en//", "-/w3d/dtd html 4.0 transitional/en", "html": - quirks = true - default: - for _, q := range quirkyIDs { - if strings.HasPrefix(public, q) { - quirks = true - break - } - } - } - // The following two public IDs only cause quirks mode if there is no system ID. - if len(n.Attr) == 1 && (strings.HasPrefix(public, "-//w3c//dtd html 4.01 frameset//") || - strings.HasPrefix(public, "-//w3c//dtd html 4.01 transitional//")) { - quirks = true - } - } - if lastAttr := n.Attr[len(n.Attr)-1]; lastAttr.Key == "system" && - strings.ToLower(lastAttr.Val) == "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd" { - quirks = true - } - } - - return n, quirks -} - -// quirkyIDs is a list of public doctype identifiers that cause a document -// to be interpreted in quirks mode. The identifiers should be in lower case. -var quirkyIDs = []string{ - "+//silmaril//dtd html pro v0r11 19970101//", - "-//advasoft ltd//dtd html 3.0 aswedit + extensions//", - "-//as//dtd html 3.0 aswedit + extensions//", - "-//ietf//dtd html 2.0 level 1//", - "-//ietf//dtd html 2.0 level 2//", - "-//ietf//dtd html 2.0 strict level 1//", - "-//ietf//dtd html 2.0 strict level 2//", - "-//ietf//dtd html 2.0 strict//", - "-//ietf//dtd html 2.0//", - "-//ietf//dtd html 2.1e//", - "-//ietf//dtd html 3.0//", - "-//ietf//dtd html 3.2 final//", - "-//ietf//dtd html 3.2//", - "-//ietf//dtd html 3//", - "-//ietf//dtd html level 0//", - "-//ietf//dtd html level 1//", - "-//ietf//dtd html level 2//", - "-//ietf//dtd html level 3//", - "-//ietf//dtd html strict level 0//", - "-//ietf//dtd html strict level 1//", - "-//ietf//dtd html strict level 2//", - "-//ietf//dtd html strict level 3//", - "-//ietf//dtd html strict//", - "-//ietf//dtd html//", - "-//metrius//dtd metrius presentational//", - "-//microsoft//dtd internet explorer 2.0 html strict//", - "-//microsoft//dtd internet explorer 2.0 html//", - "-//microsoft//dtd internet explorer 2.0 tables//", - "-//microsoft//dtd internet explorer 3.0 html strict//", - "-//microsoft//dtd internet explorer 3.0 html//", - "-//microsoft//dtd internet explorer 3.0 tables//", - "-//netscape comm. corp.//dtd html//", - "-//netscape comm. corp.//dtd strict html//", - "-//o'reilly and associates//dtd html 2.0//", - "-//o'reilly and associates//dtd html extended 1.0//", - "-//o'reilly and associates//dtd html extended relaxed 1.0//", - "-//softquad software//dtd hotmetal pro 6.0::19990601::extensions to html 4.0//", - "-//softquad//dtd hotmetal pro 4.0::19971010::extensions to html 4.0//", - "-//spyglass//dtd html 2.0 extended//", - "-//sq//dtd html 2.0 hotmetal + extensions//", - "-//sun microsystems corp.//dtd hotjava html//", - "-//sun microsystems corp.//dtd hotjava strict html//", - "-//w3c//dtd html 3 1995-03-24//", - "-//w3c//dtd html 3.2 draft//", - "-//w3c//dtd html 3.2 final//", - "-//w3c//dtd html 3.2//", - "-//w3c//dtd html 3.2s draft//", - "-//w3c//dtd html 4.0 frameset//", - "-//w3c//dtd html 4.0 transitional//", - "-//w3c//dtd html experimental 19960712//", - "-//w3c//dtd html experimental 970421//", - "-//w3c//dtd w3 html//", - "-//w3o//dtd w3 html 3.0//", - "-//webtechs//dtd mozilla html 2.0//", - "-//webtechs//dtd mozilla html//", -} diff --git a/vendor/golang.org/x/net/html/entity.go b/vendor/golang.org/x/net/html/entity.go deleted file mode 100644 index a50c04c..0000000 --- a/vendor/golang.org/x/net/html/entity.go +++ /dev/null @@ -1,2253 +0,0 @@ -// Copyright 2010 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 html - -// All entities that do not end with ';' are 6 or fewer bytes long. -const longestEntityWithoutSemicolon = 6 - -// entity is a map from HTML entity names to their values. The semicolon matters: -// https://html.spec.whatwg.org/multipage/syntax.html#named-character-references -// lists both "amp" and "amp;" as two separate entries. -// -// Note that the HTML5 list is larger than the HTML4 list at -// http://www.w3.org/TR/html4/sgml/entities.html -var entity = map[string]rune{ - "AElig;": '\U000000C6', - "AMP;": '\U00000026', - "Aacute;": '\U000000C1', - "Abreve;": '\U00000102', - "Acirc;": '\U000000C2', - "Acy;": '\U00000410', - "Afr;": '\U0001D504', - "Agrave;": '\U000000C0', - "Alpha;": '\U00000391', - "Amacr;": '\U00000100', - "And;": '\U00002A53', - "Aogon;": '\U00000104', - "Aopf;": '\U0001D538', - "ApplyFunction;": '\U00002061', - "Aring;": '\U000000C5', - "Ascr;": '\U0001D49C', - "Assign;": '\U00002254', - "Atilde;": '\U000000C3', - "Auml;": '\U000000C4', - "Backslash;": '\U00002216', - "Barv;": '\U00002AE7', - "Barwed;": '\U00002306', - "Bcy;": '\U00000411', - "Because;": '\U00002235', - "Bernoullis;": '\U0000212C', - "Beta;": '\U00000392', - "Bfr;": '\U0001D505', - "Bopf;": '\U0001D539', - "Breve;": '\U000002D8', - "Bscr;": '\U0000212C', - "Bumpeq;": '\U0000224E', - "CHcy;": '\U00000427', - "COPY;": '\U000000A9', - "Cacute;": '\U00000106', - "Cap;": '\U000022D2', - "CapitalDifferentialD;": '\U00002145', - "Cayleys;": '\U0000212D', - "Ccaron;": '\U0000010C', - "Ccedil;": '\U000000C7', - "Ccirc;": '\U00000108', - "Cconint;": '\U00002230', - "Cdot;": '\U0000010A', - "Cedilla;": '\U000000B8', - "CenterDot;": '\U000000B7', - "Cfr;": '\U0000212D', - "Chi;": '\U000003A7', - "CircleDot;": '\U00002299', - "CircleMinus;": '\U00002296', - "CirclePlus;": '\U00002295', - "CircleTimes;": '\U00002297', - "ClockwiseContourIntegral;": '\U00002232', - "CloseCurlyDoubleQuote;": '\U0000201D', - "CloseCurlyQuote;": '\U00002019', - "Colon;": '\U00002237', - "Colone;": '\U00002A74', - "Congruent;": '\U00002261', - "Conint;": '\U0000222F', - "ContourIntegral;": '\U0000222E', - "Copf;": '\U00002102', - "Coproduct;": '\U00002210', - "CounterClockwiseContourIntegral;": '\U00002233', - "Cross;": '\U00002A2F', - "Cscr;": '\U0001D49E', - "Cup;": '\U000022D3', - "CupCap;": '\U0000224D', - "DD;": '\U00002145', - "DDotrahd;": '\U00002911', - "DJcy;": '\U00000402', - "DScy;": '\U00000405', - "DZcy;": '\U0000040F', - "Dagger;": '\U00002021', - "Darr;": '\U000021A1', - "Dashv;": '\U00002AE4', - "Dcaron;": '\U0000010E', - "Dcy;": '\U00000414', - "Del;": '\U00002207', - "Delta;": '\U00000394', - "Dfr;": '\U0001D507', - "DiacriticalAcute;": '\U000000B4', - "DiacriticalDot;": '\U000002D9', - "DiacriticalDoubleAcute;": '\U000002DD', - "DiacriticalGrave;": '\U00000060', - "DiacriticalTilde;": '\U000002DC', - "Diamond;": '\U000022C4', - "DifferentialD;": '\U00002146', - "Dopf;": '\U0001D53B', - "Dot;": '\U000000A8', - "DotDot;": '\U000020DC', - "DotEqual;": '\U00002250', - "DoubleContourIntegral;": '\U0000222F', - "DoubleDot;": '\U000000A8', - "DoubleDownArrow;": '\U000021D3', - "DoubleLeftArrow;": '\U000021D0', - "DoubleLeftRightArrow;": '\U000021D4', - "DoubleLeftTee;": '\U00002AE4', - "DoubleLongLeftArrow;": '\U000027F8', - "DoubleLongLeftRightArrow;": '\U000027FA', - "DoubleLongRightArrow;": '\U000027F9', - "DoubleRightArrow;": '\U000021D2', - "DoubleRightTee;": '\U000022A8', - "DoubleUpArrow;": '\U000021D1', - "DoubleUpDownArrow;": '\U000021D5', - "DoubleVerticalBar;": '\U00002225', - "DownArrow;": '\U00002193', - "DownArrowBar;": '\U00002913', - "DownArrowUpArrow;": '\U000021F5', - "DownBreve;": '\U00000311', - "DownLeftRightVector;": '\U00002950', - "DownLeftTeeVector;": '\U0000295E', - "DownLeftVector;": '\U000021BD', - "DownLeftVectorBar;": '\U00002956', - "DownRightTeeVector;": '\U0000295F', - "DownRightVector;": '\U000021C1', - "DownRightVectorBar;": '\U00002957', - "DownTee;": '\U000022A4', - "DownTeeArrow;": '\U000021A7', - "Downarrow;": '\U000021D3', - "Dscr;": '\U0001D49F', - "Dstrok;": '\U00000110', - "ENG;": '\U0000014A', - "ETH;": '\U000000D0', - "Eacute;": '\U000000C9', - "Ecaron;": '\U0000011A', - "Ecirc;": '\U000000CA', - "Ecy;": '\U0000042D', - "Edot;": '\U00000116', - "Efr;": '\U0001D508', - "Egrave;": '\U000000C8', - "Element;": '\U00002208', - "Emacr;": '\U00000112', - "EmptySmallSquare;": '\U000025FB', - "EmptyVerySmallSquare;": '\U000025AB', - "Eogon;": '\U00000118', - "Eopf;": '\U0001D53C', - "Epsilon;": '\U00000395', - "Equal;": '\U00002A75', - "EqualTilde;": '\U00002242', - "Equilibrium;": '\U000021CC', - "Escr;": '\U00002130', - "Esim;": '\U00002A73', - "Eta;": '\U00000397', - "Euml;": '\U000000CB', - "Exists;": '\U00002203', - "ExponentialE;": '\U00002147', - "Fcy;": '\U00000424', - "Ffr;": '\U0001D509', - "FilledSmallSquare;": '\U000025FC', - "FilledVerySmallSquare;": '\U000025AA', - "Fopf;": '\U0001D53D', - "ForAll;": '\U00002200', - "Fouriertrf;": '\U00002131', - "Fscr;": '\U00002131', - "GJcy;": '\U00000403', - "GT;": '\U0000003E', - "Gamma;": '\U00000393', - "Gammad;": '\U000003DC', - "Gbreve;": '\U0000011E', - "Gcedil;": '\U00000122', - "Gcirc;": '\U0000011C', - "Gcy;": '\U00000413', - "Gdot;": '\U00000120', - "Gfr;": '\U0001D50A', - "Gg;": '\U000022D9', - "Gopf;": '\U0001D53E', - "GreaterEqual;": '\U00002265', - "GreaterEqualLess;": '\U000022DB', - "GreaterFullEqual;": '\U00002267', - "GreaterGreater;": '\U00002AA2', - "GreaterLess;": '\U00002277', - "GreaterSlantEqual;": '\U00002A7E', - "GreaterTilde;": '\U00002273', - "Gscr;": '\U0001D4A2', - "Gt;": '\U0000226B', - "HARDcy;": '\U0000042A', - "Hacek;": '\U000002C7', - "Hat;": '\U0000005E', - "Hcirc;": '\U00000124', - "Hfr;": '\U0000210C', - "HilbertSpace;": '\U0000210B', - "Hopf;": '\U0000210D', - "HorizontalLine;": '\U00002500', - "Hscr;": '\U0000210B', - "Hstrok;": '\U00000126', - "HumpDownHump;": '\U0000224E', - "HumpEqual;": '\U0000224F', - "IEcy;": '\U00000415', - "IJlig;": '\U00000132', - "IOcy;": '\U00000401', - "Iacute;": '\U000000CD', - "Icirc;": '\U000000CE', - "Icy;": '\U00000418', - "Idot;": '\U00000130', - "Ifr;": '\U00002111', - "Igrave;": '\U000000CC', - "Im;": '\U00002111', - "Imacr;": '\U0000012A', - "ImaginaryI;": '\U00002148', - "Implies;": '\U000021D2', - "Int;": '\U0000222C', - "Integral;": '\U0000222B', - "Intersection;": '\U000022C2', - "InvisibleComma;": '\U00002063', - "InvisibleTimes;": '\U00002062', - "Iogon;": '\U0000012E', - "Iopf;": '\U0001D540', - "Iota;": '\U00000399', - "Iscr;": '\U00002110', - "Itilde;": '\U00000128', - "Iukcy;": '\U00000406', - "Iuml;": '\U000000CF', - "Jcirc;": '\U00000134', - "Jcy;": '\U00000419', - "Jfr;": '\U0001D50D', - "Jopf;": '\U0001D541', - "Jscr;": '\U0001D4A5', - "Jsercy;": '\U00000408', - "Jukcy;": '\U00000404', - "KHcy;": '\U00000425', - "KJcy;": '\U0000040C', - "Kappa;": '\U0000039A', - "Kcedil;": '\U00000136', - "Kcy;": '\U0000041A', - "Kfr;": '\U0001D50E', - "Kopf;": '\U0001D542', - "Kscr;": '\U0001D4A6', - "LJcy;": '\U00000409', - "LT;": '\U0000003C', - "Lacute;": '\U00000139', - "Lambda;": '\U0000039B', - "Lang;": '\U000027EA', - "Laplacetrf;": '\U00002112', - "Larr;": '\U0000219E', - "Lcaron;": '\U0000013D', - "Lcedil;": '\U0000013B', - "Lcy;": '\U0000041B', - "LeftAngleBracket;": '\U000027E8', - "LeftArrow;": '\U00002190', - "LeftArrowBar;": '\U000021E4', - "LeftArrowRightArrow;": '\U000021C6', - "LeftCeiling;": '\U00002308', - "LeftDoubleBracket;": '\U000027E6', - "LeftDownTeeVector;": '\U00002961', - "LeftDownVector;": '\U000021C3', - "LeftDownVectorBar;": '\U00002959', - "LeftFloor;": '\U0000230A', - "LeftRightArrow;": '\U00002194', - "LeftRightVector;": '\U0000294E', - "LeftTee;": '\U000022A3', - "LeftTeeArrow;": '\U000021A4', - "LeftTeeVector;": '\U0000295A', - "LeftTriangle;": '\U000022B2', - "LeftTriangleBar;": '\U000029CF', - "LeftTriangleEqual;": '\U000022B4', - "LeftUpDownVector;": '\U00002951', - "LeftUpTeeVector;": '\U00002960', - "LeftUpVector;": '\U000021BF', - "LeftUpVectorBar;": '\U00002958', - "LeftVector;": '\U000021BC', - "LeftVectorBar;": '\U00002952', - "Leftarrow;": '\U000021D0', - "Leftrightarrow;": '\U000021D4', - "LessEqualGreater;": '\U000022DA', - "LessFullEqual;": '\U00002266', - "LessGreater;": '\U00002276', - "LessLess;": '\U00002AA1', - "LessSlantEqual;": '\U00002A7D', - "LessTilde;": '\U00002272', - "Lfr;": '\U0001D50F', - "Ll;": '\U000022D8', - "Lleftarrow;": '\U000021DA', - "Lmidot;": '\U0000013F', - "LongLeftArrow;": '\U000027F5', - "LongLeftRightArrow;": '\U000027F7', - "LongRightArrow;": '\U000027F6', - "Longleftarrow;": '\U000027F8', - "Longleftrightarrow;": '\U000027FA', - "Longrightarrow;": '\U000027F9', - "Lopf;": '\U0001D543', - "LowerLeftArrow;": '\U00002199', - "LowerRightArrow;": '\U00002198', - "Lscr;": '\U00002112', - "Lsh;": '\U000021B0', - "Lstrok;": '\U00000141', - "Lt;": '\U0000226A', - "Map;": '\U00002905', - "Mcy;": '\U0000041C', - "MediumSpace;": '\U0000205F', - "Mellintrf;": '\U00002133', - "Mfr;": '\U0001D510', - "MinusPlus;": '\U00002213', - "Mopf;": '\U0001D544', - "Mscr;": '\U00002133', - "Mu;": '\U0000039C', - "NJcy;": '\U0000040A', - "Nacute;": '\U00000143', - "Ncaron;": '\U00000147', - "Ncedil;": '\U00000145', - "Ncy;": '\U0000041D', - "NegativeMediumSpace;": '\U0000200B', - "NegativeThickSpace;": '\U0000200B', - "NegativeThinSpace;": '\U0000200B', - "NegativeVeryThinSpace;": '\U0000200B', - "NestedGreaterGreater;": '\U0000226B', - "NestedLessLess;": '\U0000226A', - "NewLine;": '\U0000000A', - "Nfr;": '\U0001D511', - "NoBreak;": '\U00002060', - "NonBreakingSpace;": '\U000000A0', - "Nopf;": '\U00002115', - "Not;": '\U00002AEC', - "NotCongruent;": '\U00002262', - "NotCupCap;": '\U0000226D', - "NotDoubleVerticalBar;": '\U00002226', - "NotElement;": '\U00002209', - "NotEqual;": '\U00002260', - "NotExists;": '\U00002204', - "NotGreater;": '\U0000226F', - "NotGreaterEqual;": '\U00002271', - "NotGreaterLess;": '\U00002279', - "NotGreaterTilde;": '\U00002275', - "NotLeftTriangle;": '\U000022EA', - "NotLeftTriangleEqual;": '\U000022EC', - "NotLess;": '\U0000226E', - "NotLessEqual;": '\U00002270', - "NotLessGreater;": '\U00002278', - "NotLessTilde;": '\U00002274', - "NotPrecedes;": '\U00002280', - "NotPrecedesSlantEqual;": '\U000022E0', - "NotReverseElement;": '\U0000220C', - "NotRightTriangle;": '\U000022EB', - "NotRightTriangleEqual;": '\U000022ED', - "NotSquareSubsetEqual;": '\U000022E2', - "NotSquareSupersetEqual;": '\U000022E3', - "NotSubsetEqual;": '\U00002288', - "NotSucceeds;": '\U00002281', - "NotSucceedsSlantEqual;": '\U000022E1', - "NotSupersetEqual;": '\U00002289', - "NotTilde;": '\U00002241', - "NotTildeEqual;": '\U00002244', - "NotTildeFullEqual;": '\U00002247', - "NotTildeTilde;": '\U00002249', - "NotVerticalBar;": '\U00002224', - "Nscr;": '\U0001D4A9', - "Ntilde;": '\U000000D1', - "Nu;": '\U0000039D', - "OElig;": '\U00000152', - "Oacute;": '\U000000D3', - "Ocirc;": '\U000000D4', - "Ocy;": '\U0000041E', - "Odblac;": '\U00000150', - "Ofr;": '\U0001D512', - "Ograve;": '\U000000D2', - "Omacr;": '\U0000014C', - "Omega;": '\U000003A9', - "Omicron;": '\U0000039F', - "Oopf;": '\U0001D546', - "OpenCurlyDoubleQuote;": '\U0000201C', - "OpenCurlyQuote;": '\U00002018', - "Or;": '\U00002A54', - "Oscr;": '\U0001D4AA', - "Oslash;": '\U000000D8', - "Otilde;": '\U000000D5', - "Otimes;": '\U00002A37', - "Ouml;": '\U000000D6', - "OverBar;": '\U0000203E', - "OverBrace;": '\U000023DE', - "OverBracket;": '\U000023B4', - "OverParenthesis;": '\U000023DC', - "PartialD;": '\U00002202', - "Pcy;": '\U0000041F', - "Pfr;": '\U0001D513', - "Phi;": '\U000003A6', - "Pi;": '\U000003A0', - "PlusMinus;": '\U000000B1', - "Poincareplane;": '\U0000210C', - "Popf;": '\U00002119', - "Pr;": '\U00002ABB', - "Precedes;": '\U0000227A', - "PrecedesEqual;": '\U00002AAF', - "PrecedesSlantEqual;": '\U0000227C', - "PrecedesTilde;": '\U0000227E', - "Prime;": '\U00002033', - "Product;": '\U0000220F', - "Proportion;": '\U00002237', - "Proportional;": '\U0000221D', - "Pscr;": '\U0001D4AB', - "Psi;": '\U000003A8', - "QUOT;": '\U00000022', - "Qfr;": '\U0001D514', - "Qopf;": '\U0000211A', - "Qscr;": '\U0001D4AC', - "RBarr;": '\U00002910', - "REG;": '\U000000AE', - "Racute;": '\U00000154', - "Rang;": '\U000027EB', - "Rarr;": '\U000021A0', - "Rarrtl;": '\U00002916', - "Rcaron;": '\U00000158', - "Rcedil;": '\U00000156', - "Rcy;": '\U00000420', - "Re;": '\U0000211C', - "ReverseElement;": '\U0000220B', - "ReverseEquilibrium;": '\U000021CB', - "ReverseUpEquilibrium;": '\U0000296F', - "Rfr;": '\U0000211C', - "Rho;": '\U000003A1', - "RightAngleBracket;": '\U000027E9', - "RightArrow;": '\U00002192', - "RightArrowBar;": '\U000021E5', - "RightArrowLeftArrow;": '\U000021C4', - "RightCeiling;": '\U00002309', - "RightDoubleBracket;": '\U000027E7', - "RightDownTeeVector;": '\U0000295D', - "RightDownVector;": '\U000021C2', - "RightDownVectorBar;": '\U00002955', - "RightFloor;": '\U0000230B', - "RightTee;": '\U000022A2', - "RightTeeArrow;": '\U000021A6', - "RightTeeVector;": '\U0000295B', - "RightTriangle;": '\U000022B3', - "RightTriangleBar;": '\U000029D0', - "RightTriangleEqual;": '\U000022B5', - "RightUpDownVector;": '\U0000294F', - "RightUpTeeVector;": '\U0000295C', - "RightUpVector;": '\U000021BE', - "RightUpVectorBar;": '\U00002954', - "RightVector;": '\U000021C0', - "RightVectorBar;": '\U00002953', - "Rightarrow;": '\U000021D2', - "Ropf;": '\U0000211D', - "RoundImplies;": '\U00002970', - "Rrightarrow;": '\U000021DB', - "Rscr;": '\U0000211B', - "Rsh;": '\U000021B1', - "RuleDelayed;": '\U000029F4', - "SHCHcy;": '\U00000429', - "SHcy;": '\U00000428', - "SOFTcy;": '\U0000042C', - "Sacute;": '\U0000015A', - "Sc;": '\U00002ABC', - "Scaron;": '\U00000160', - "Scedil;": '\U0000015E', - "Scirc;": '\U0000015C', - "Scy;": '\U00000421', - "Sfr;": '\U0001D516', - "ShortDownArrow;": '\U00002193', - "ShortLeftArrow;": '\U00002190', - "ShortRightArrow;": '\U00002192', - "ShortUpArrow;": '\U00002191', - "Sigma;": '\U000003A3', - "SmallCircle;": '\U00002218', - "Sopf;": '\U0001D54A', - "Sqrt;": '\U0000221A', - "Square;": '\U000025A1', - "SquareIntersection;": '\U00002293', - "SquareSubset;": '\U0000228F', - "SquareSubsetEqual;": '\U00002291', - "SquareSuperset;": '\U00002290', - "SquareSupersetEqual;": '\U00002292', - "SquareUnion;": '\U00002294', - "Sscr;": '\U0001D4AE', - "Star;": '\U000022C6', - "Sub;": '\U000022D0', - "Subset;": '\U000022D0', - "SubsetEqual;": '\U00002286', - "Succeeds;": '\U0000227B', - "SucceedsEqual;": '\U00002AB0', - "SucceedsSlantEqual;": '\U0000227D', - "SucceedsTilde;": '\U0000227F', - "SuchThat;": '\U0000220B', - "Sum;": '\U00002211', - "Sup;": '\U000022D1', - "Superset;": '\U00002283', - "SupersetEqual;": '\U00002287', - "Supset;": '\U000022D1', - "THORN;": '\U000000DE', - "TRADE;": '\U00002122', - "TSHcy;": '\U0000040B', - "TScy;": '\U00000426', - "Tab;": '\U00000009', - "Tau;": '\U000003A4', - "Tcaron;": '\U00000164', - "Tcedil;": '\U00000162', - "Tcy;": '\U00000422', - "Tfr;": '\U0001D517', - "Therefore;": '\U00002234', - "Theta;": '\U00000398', - "ThinSpace;": '\U00002009', - "Tilde;": '\U0000223C', - "TildeEqual;": '\U00002243', - "TildeFullEqual;": '\U00002245', - "TildeTilde;": '\U00002248', - "Topf;": '\U0001D54B', - "TripleDot;": '\U000020DB', - "Tscr;": '\U0001D4AF', - "Tstrok;": '\U00000166', - "Uacute;": '\U000000DA', - "Uarr;": '\U0000219F', - "Uarrocir;": '\U00002949', - "Ubrcy;": '\U0000040E', - "Ubreve;": '\U0000016C', - "Ucirc;": '\U000000DB', - "Ucy;": '\U00000423', - "Udblac;": '\U00000170', - "Ufr;": '\U0001D518', - "Ugrave;": '\U000000D9', - "Umacr;": '\U0000016A', - "UnderBar;": '\U0000005F', - "UnderBrace;": '\U000023DF', - "UnderBracket;": '\U000023B5', - "UnderParenthesis;": '\U000023DD', - "Union;": '\U000022C3', - "UnionPlus;": '\U0000228E', - "Uogon;": '\U00000172', - "Uopf;": '\U0001D54C', - "UpArrow;": '\U00002191', - "UpArrowBar;": '\U00002912', - "UpArrowDownArrow;": '\U000021C5', - "UpDownArrow;": '\U00002195', - "UpEquilibrium;": '\U0000296E', - "UpTee;": '\U000022A5', - "UpTeeArrow;": '\U000021A5', - "Uparrow;": '\U000021D1', - "Updownarrow;": '\U000021D5', - "UpperLeftArrow;": '\U00002196', - "UpperRightArrow;": '\U00002197', - "Upsi;": '\U000003D2', - "Upsilon;": '\U000003A5', - "Uring;": '\U0000016E', - "Uscr;": '\U0001D4B0', - "Utilde;": '\U00000168', - "Uuml;": '\U000000DC', - "VDash;": '\U000022AB', - "Vbar;": '\U00002AEB', - "Vcy;": '\U00000412', - "Vdash;": '\U000022A9', - "Vdashl;": '\U00002AE6', - "Vee;": '\U000022C1', - "Verbar;": '\U00002016', - "Vert;": '\U00002016', - "VerticalBar;": '\U00002223', - "VerticalLine;": '\U0000007C', - "VerticalSeparator;": '\U00002758', - "VerticalTilde;": '\U00002240', - "VeryThinSpace;": '\U0000200A', - "Vfr;": '\U0001D519', - "Vopf;": '\U0001D54D', - "Vscr;": '\U0001D4B1', - "Vvdash;": '\U000022AA', - "Wcirc;": '\U00000174', - "Wedge;": '\U000022C0', - "Wfr;": '\U0001D51A', - "Wopf;": '\U0001D54E', - "Wscr;": '\U0001D4B2', - "Xfr;": '\U0001D51B', - "Xi;": '\U0000039E', - "Xopf;": '\U0001D54F', - "Xscr;": '\U0001D4B3', - "YAcy;": '\U0000042F', - "YIcy;": '\U00000407', - "YUcy;": '\U0000042E', - "Yacute;": '\U000000DD', - "Ycirc;": '\U00000176', - "Ycy;": '\U0000042B', - "Yfr;": '\U0001D51C', - "Yopf;": '\U0001D550', - "Yscr;": '\U0001D4B4', - "Yuml;": '\U00000178', - "ZHcy;": '\U00000416', - "Zacute;": '\U00000179', - "Zcaron;": '\U0000017D', - "Zcy;": '\U00000417', - "Zdot;": '\U0000017B', - "ZeroWidthSpace;": '\U0000200B', - "Zeta;": '\U00000396', - "Zfr;": '\U00002128', - "Zopf;": '\U00002124', - "Zscr;": '\U0001D4B5', - "aacute;": '\U000000E1', - "abreve;": '\U00000103', - "ac;": '\U0000223E', - "acd;": '\U0000223F', - "acirc;": '\U000000E2', - "acute;": '\U000000B4', - "acy;": '\U00000430', - "aelig;": '\U000000E6', - "af;": '\U00002061', - "afr;": '\U0001D51E', - "agrave;": '\U000000E0', - "alefsym;": '\U00002135', - "aleph;": '\U00002135', - "alpha;": '\U000003B1', - "amacr;": '\U00000101', - "amalg;": '\U00002A3F', - "amp;": '\U00000026', - "and;": '\U00002227', - "andand;": '\U00002A55', - "andd;": '\U00002A5C', - "andslope;": '\U00002A58', - "andv;": '\U00002A5A', - "ang;": '\U00002220', - "ange;": '\U000029A4', - "angle;": '\U00002220', - "angmsd;": '\U00002221', - "angmsdaa;": '\U000029A8', - "angmsdab;": '\U000029A9', - "angmsdac;": '\U000029AA', - "angmsdad;": '\U000029AB', - "angmsdae;": '\U000029AC', - "angmsdaf;": '\U000029AD', - "angmsdag;": '\U000029AE', - "angmsdah;": '\U000029AF', - "angrt;": '\U0000221F', - "angrtvb;": '\U000022BE', - "angrtvbd;": '\U0000299D', - "angsph;": '\U00002222', - "angst;": '\U000000C5', - "angzarr;": '\U0000237C', - "aogon;": '\U00000105', - "aopf;": '\U0001D552', - "ap;": '\U00002248', - "apE;": '\U00002A70', - "apacir;": '\U00002A6F', - "ape;": '\U0000224A', - "apid;": '\U0000224B', - "apos;": '\U00000027', - "approx;": '\U00002248', - "approxeq;": '\U0000224A', - "aring;": '\U000000E5', - "ascr;": '\U0001D4B6', - "ast;": '\U0000002A', - "asymp;": '\U00002248', - "asympeq;": '\U0000224D', - "atilde;": '\U000000E3', - "auml;": '\U000000E4', - "awconint;": '\U00002233', - "awint;": '\U00002A11', - "bNot;": '\U00002AED', - "backcong;": '\U0000224C', - "backepsilon;": '\U000003F6', - "backprime;": '\U00002035', - "backsim;": '\U0000223D', - "backsimeq;": '\U000022CD', - "barvee;": '\U000022BD', - "barwed;": '\U00002305', - "barwedge;": '\U00002305', - "bbrk;": '\U000023B5', - "bbrktbrk;": '\U000023B6', - "bcong;": '\U0000224C', - "bcy;": '\U00000431', - "bdquo;": '\U0000201E', - "becaus;": '\U00002235', - "because;": '\U00002235', - "bemptyv;": '\U000029B0', - "bepsi;": '\U000003F6', - "bernou;": '\U0000212C', - "beta;": '\U000003B2', - "beth;": '\U00002136', - "between;": '\U0000226C', - "bfr;": '\U0001D51F', - "bigcap;": '\U000022C2', - "bigcirc;": '\U000025EF', - "bigcup;": '\U000022C3', - "bigodot;": '\U00002A00', - "bigoplus;": '\U00002A01', - "bigotimes;": '\U00002A02', - "bigsqcup;": '\U00002A06', - "bigstar;": '\U00002605', - "bigtriangledown;": '\U000025BD', - "bigtriangleup;": '\U000025B3', - "biguplus;": '\U00002A04', - "bigvee;": '\U000022C1', - "bigwedge;": '\U000022C0', - "bkarow;": '\U0000290D', - "blacklozenge;": '\U000029EB', - "blacksquare;": '\U000025AA', - "blacktriangle;": '\U000025B4', - "blacktriangledown;": '\U000025BE', - "blacktriangleleft;": '\U000025C2', - "blacktriangleright;": '\U000025B8', - "blank;": '\U00002423', - "blk12;": '\U00002592', - "blk14;": '\U00002591', - "blk34;": '\U00002593', - "block;": '\U00002588', - "bnot;": '\U00002310', - "bopf;": '\U0001D553', - "bot;": '\U000022A5', - "bottom;": '\U000022A5', - "bowtie;": '\U000022C8', - "boxDL;": '\U00002557', - "boxDR;": '\U00002554', - "boxDl;": '\U00002556', - "boxDr;": '\U00002553', - "boxH;": '\U00002550', - "boxHD;": '\U00002566', - "boxHU;": '\U00002569', - "boxHd;": '\U00002564', - "boxHu;": '\U00002567', - "boxUL;": '\U0000255D', - "boxUR;": '\U0000255A', - "boxUl;": '\U0000255C', - "boxUr;": '\U00002559', - "boxV;": '\U00002551', - "boxVH;": '\U0000256C', - "boxVL;": '\U00002563', - "boxVR;": '\U00002560', - "boxVh;": '\U0000256B', - "boxVl;": '\U00002562', - "boxVr;": '\U0000255F', - "boxbox;": '\U000029C9', - "boxdL;": '\U00002555', - "boxdR;": '\U00002552', - "boxdl;": '\U00002510', - "boxdr;": '\U0000250C', - "boxh;": '\U00002500', - "boxhD;": '\U00002565', - "boxhU;": '\U00002568', - "boxhd;": '\U0000252C', - "boxhu;": '\U00002534', - "boxminus;": '\U0000229F', - "boxplus;": '\U0000229E', - "boxtimes;": '\U000022A0', - "boxuL;": '\U0000255B', - "boxuR;": '\U00002558', - "boxul;": '\U00002518', - "boxur;": '\U00002514', - "boxv;": '\U00002502', - "boxvH;": '\U0000256A', - "boxvL;": '\U00002561', - "boxvR;": '\U0000255E', - "boxvh;": '\U0000253C', - "boxvl;": '\U00002524', - "boxvr;": '\U0000251C', - "bprime;": '\U00002035', - "breve;": '\U000002D8', - "brvbar;": '\U000000A6', - "bscr;": '\U0001D4B7', - "bsemi;": '\U0000204F', - "bsim;": '\U0000223D', - "bsime;": '\U000022CD', - "bsol;": '\U0000005C', - "bsolb;": '\U000029C5', - "bsolhsub;": '\U000027C8', - "bull;": '\U00002022', - "bullet;": '\U00002022', - "bump;": '\U0000224E', - "bumpE;": '\U00002AAE', - "bumpe;": '\U0000224F', - "bumpeq;": '\U0000224F', - "cacute;": '\U00000107', - "cap;": '\U00002229', - "capand;": '\U00002A44', - "capbrcup;": '\U00002A49', - "capcap;": '\U00002A4B', - "capcup;": '\U00002A47', - "capdot;": '\U00002A40', - "caret;": '\U00002041', - "caron;": '\U000002C7', - "ccaps;": '\U00002A4D', - "ccaron;": '\U0000010D', - "ccedil;": '\U000000E7', - "ccirc;": '\U00000109', - "ccups;": '\U00002A4C', - "ccupssm;": '\U00002A50', - "cdot;": '\U0000010B', - "cedil;": '\U000000B8', - "cemptyv;": '\U000029B2', - "cent;": '\U000000A2', - "centerdot;": '\U000000B7', - "cfr;": '\U0001D520', - "chcy;": '\U00000447', - "check;": '\U00002713', - "checkmark;": '\U00002713', - "chi;": '\U000003C7', - "cir;": '\U000025CB', - "cirE;": '\U000029C3', - "circ;": '\U000002C6', - "circeq;": '\U00002257', - "circlearrowleft;": '\U000021BA', - "circlearrowright;": '\U000021BB', - "circledR;": '\U000000AE', - "circledS;": '\U000024C8', - "circledast;": '\U0000229B', - "circledcirc;": '\U0000229A', - "circleddash;": '\U0000229D', - "cire;": '\U00002257', - "cirfnint;": '\U00002A10', - "cirmid;": '\U00002AEF', - "cirscir;": '\U000029C2', - "clubs;": '\U00002663', - "clubsuit;": '\U00002663', - "colon;": '\U0000003A', - "colone;": '\U00002254', - "coloneq;": '\U00002254', - "comma;": '\U0000002C', - "commat;": '\U00000040', - "comp;": '\U00002201', - "compfn;": '\U00002218', - "complement;": '\U00002201', - "complexes;": '\U00002102', - "cong;": '\U00002245', - "congdot;": '\U00002A6D', - "conint;": '\U0000222E', - "copf;": '\U0001D554', - "coprod;": '\U00002210', - "copy;": '\U000000A9', - "copysr;": '\U00002117', - "crarr;": '\U000021B5', - "cross;": '\U00002717', - "cscr;": '\U0001D4B8', - "csub;": '\U00002ACF', - "csube;": '\U00002AD1', - "csup;": '\U00002AD0', - "csupe;": '\U00002AD2', - "ctdot;": '\U000022EF', - "cudarrl;": '\U00002938', - "cudarrr;": '\U00002935', - "cuepr;": '\U000022DE', - "cuesc;": '\U000022DF', - "cularr;": '\U000021B6', - "cularrp;": '\U0000293D', - "cup;": '\U0000222A', - "cupbrcap;": '\U00002A48', - "cupcap;": '\U00002A46', - "cupcup;": '\U00002A4A', - "cupdot;": '\U0000228D', - "cupor;": '\U00002A45', - "curarr;": '\U000021B7', - "curarrm;": '\U0000293C', - "curlyeqprec;": '\U000022DE', - "curlyeqsucc;": '\U000022DF', - "curlyvee;": '\U000022CE', - "curlywedge;": '\U000022CF', - "curren;": '\U000000A4', - "curvearrowleft;": '\U000021B6', - "curvearrowright;": '\U000021B7', - "cuvee;": '\U000022CE', - "cuwed;": '\U000022CF', - "cwconint;": '\U00002232', - "cwint;": '\U00002231', - "cylcty;": '\U0000232D', - "dArr;": '\U000021D3', - "dHar;": '\U00002965', - "dagger;": '\U00002020', - "daleth;": '\U00002138', - "darr;": '\U00002193', - "dash;": '\U00002010', - "dashv;": '\U000022A3', - "dbkarow;": '\U0000290F', - "dblac;": '\U000002DD', - "dcaron;": '\U0000010F', - "dcy;": '\U00000434', - "dd;": '\U00002146', - "ddagger;": '\U00002021', - "ddarr;": '\U000021CA', - "ddotseq;": '\U00002A77', - "deg;": '\U000000B0', - "delta;": '\U000003B4', - "demptyv;": '\U000029B1', - "dfisht;": '\U0000297F', - "dfr;": '\U0001D521', - "dharl;": '\U000021C3', - "dharr;": '\U000021C2', - "diam;": '\U000022C4', - "diamond;": '\U000022C4', - "diamondsuit;": '\U00002666', - "diams;": '\U00002666', - "die;": '\U000000A8', - "digamma;": '\U000003DD', - "disin;": '\U000022F2', - "div;": '\U000000F7', - "divide;": '\U000000F7', - "divideontimes;": '\U000022C7', - "divonx;": '\U000022C7', - "djcy;": '\U00000452', - "dlcorn;": '\U0000231E', - "dlcrop;": '\U0000230D', - "dollar;": '\U00000024', - "dopf;": '\U0001D555', - "dot;": '\U000002D9', - "doteq;": '\U00002250', - "doteqdot;": '\U00002251', - "dotminus;": '\U00002238', - "dotplus;": '\U00002214', - "dotsquare;": '\U000022A1', - "doublebarwedge;": '\U00002306', - "downarrow;": '\U00002193', - "downdownarrows;": '\U000021CA', - "downharpoonleft;": '\U000021C3', - "downharpoonright;": '\U000021C2', - "drbkarow;": '\U00002910', - "drcorn;": '\U0000231F', - "drcrop;": '\U0000230C', - "dscr;": '\U0001D4B9', - "dscy;": '\U00000455', - "dsol;": '\U000029F6', - "dstrok;": '\U00000111', - "dtdot;": '\U000022F1', - "dtri;": '\U000025BF', - "dtrif;": '\U000025BE', - "duarr;": '\U000021F5', - "duhar;": '\U0000296F', - "dwangle;": '\U000029A6', - "dzcy;": '\U0000045F', - "dzigrarr;": '\U000027FF', - "eDDot;": '\U00002A77', - "eDot;": '\U00002251', - "eacute;": '\U000000E9', - "easter;": '\U00002A6E', - "ecaron;": '\U0000011B', - "ecir;": '\U00002256', - "ecirc;": '\U000000EA', - "ecolon;": '\U00002255', - "ecy;": '\U0000044D', - "edot;": '\U00000117', - "ee;": '\U00002147', - "efDot;": '\U00002252', - "efr;": '\U0001D522', - "eg;": '\U00002A9A', - "egrave;": '\U000000E8', - "egs;": '\U00002A96', - "egsdot;": '\U00002A98', - "el;": '\U00002A99', - "elinters;": '\U000023E7', - "ell;": '\U00002113', - "els;": '\U00002A95', - "elsdot;": '\U00002A97', - "emacr;": '\U00000113', - "empty;": '\U00002205', - "emptyset;": '\U00002205', - "emptyv;": '\U00002205', - "emsp;": '\U00002003', - "emsp13;": '\U00002004', - "emsp14;": '\U00002005', - "eng;": '\U0000014B', - "ensp;": '\U00002002', - "eogon;": '\U00000119', - "eopf;": '\U0001D556', - "epar;": '\U000022D5', - "eparsl;": '\U000029E3', - "eplus;": '\U00002A71', - "epsi;": '\U000003B5', - "epsilon;": '\U000003B5', - "epsiv;": '\U000003F5', - "eqcirc;": '\U00002256', - "eqcolon;": '\U00002255', - "eqsim;": '\U00002242', - "eqslantgtr;": '\U00002A96', - "eqslantless;": '\U00002A95', - "equals;": '\U0000003D', - "equest;": '\U0000225F', - "equiv;": '\U00002261', - "equivDD;": '\U00002A78', - "eqvparsl;": '\U000029E5', - "erDot;": '\U00002253', - "erarr;": '\U00002971', - "escr;": '\U0000212F', - "esdot;": '\U00002250', - "esim;": '\U00002242', - "eta;": '\U000003B7', - "eth;": '\U000000F0', - "euml;": '\U000000EB', - "euro;": '\U000020AC', - "excl;": '\U00000021', - "exist;": '\U00002203', - "expectation;": '\U00002130', - "exponentiale;": '\U00002147', - "fallingdotseq;": '\U00002252', - "fcy;": '\U00000444', - "female;": '\U00002640', - "ffilig;": '\U0000FB03', - "fflig;": '\U0000FB00', - "ffllig;": '\U0000FB04', - "ffr;": '\U0001D523', - "filig;": '\U0000FB01', - "flat;": '\U0000266D', - "fllig;": '\U0000FB02', - "fltns;": '\U000025B1', - "fnof;": '\U00000192', - "fopf;": '\U0001D557', - "forall;": '\U00002200', - "fork;": '\U000022D4', - "forkv;": '\U00002AD9', - "fpartint;": '\U00002A0D', - "frac12;": '\U000000BD', - "frac13;": '\U00002153', - "frac14;": '\U000000BC', - "frac15;": '\U00002155', - "frac16;": '\U00002159', - "frac18;": '\U0000215B', - "frac23;": '\U00002154', - "frac25;": '\U00002156', - "frac34;": '\U000000BE', - "frac35;": '\U00002157', - "frac38;": '\U0000215C', - "frac45;": '\U00002158', - "frac56;": '\U0000215A', - "frac58;": '\U0000215D', - "frac78;": '\U0000215E', - "frasl;": '\U00002044', - "frown;": '\U00002322', - "fscr;": '\U0001D4BB', - "gE;": '\U00002267', - "gEl;": '\U00002A8C', - "gacute;": '\U000001F5', - "gamma;": '\U000003B3', - "gammad;": '\U000003DD', - "gap;": '\U00002A86', - "gbreve;": '\U0000011F', - "gcirc;": '\U0000011D', - "gcy;": '\U00000433', - "gdot;": '\U00000121', - "ge;": '\U00002265', - "gel;": '\U000022DB', - "geq;": '\U00002265', - "geqq;": '\U00002267', - "geqslant;": '\U00002A7E', - "ges;": '\U00002A7E', - "gescc;": '\U00002AA9', - "gesdot;": '\U00002A80', - "gesdoto;": '\U00002A82', - "gesdotol;": '\U00002A84', - "gesles;": '\U00002A94', - "gfr;": '\U0001D524', - "gg;": '\U0000226B', - "ggg;": '\U000022D9', - "gimel;": '\U00002137', - "gjcy;": '\U00000453', - "gl;": '\U00002277', - "glE;": '\U00002A92', - "gla;": '\U00002AA5', - "glj;": '\U00002AA4', - "gnE;": '\U00002269', - "gnap;": '\U00002A8A', - "gnapprox;": '\U00002A8A', - "gne;": '\U00002A88', - "gneq;": '\U00002A88', - "gneqq;": '\U00002269', - "gnsim;": '\U000022E7', - "gopf;": '\U0001D558', - "grave;": '\U00000060', - "gscr;": '\U0000210A', - "gsim;": '\U00002273', - "gsime;": '\U00002A8E', - "gsiml;": '\U00002A90', - "gt;": '\U0000003E', - "gtcc;": '\U00002AA7', - "gtcir;": '\U00002A7A', - "gtdot;": '\U000022D7', - "gtlPar;": '\U00002995', - "gtquest;": '\U00002A7C', - "gtrapprox;": '\U00002A86', - "gtrarr;": '\U00002978', - "gtrdot;": '\U000022D7', - "gtreqless;": '\U000022DB', - "gtreqqless;": '\U00002A8C', - "gtrless;": '\U00002277', - "gtrsim;": '\U00002273', - "hArr;": '\U000021D4', - "hairsp;": '\U0000200A', - "half;": '\U000000BD', - "hamilt;": '\U0000210B', - "hardcy;": '\U0000044A', - "harr;": '\U00002194', - "harrcir;": '\U00002948', - "harrw;": '\U000021AD', - "hbar;": '\U0000210F', - "hcirc;": '\U00000125', - "hearts;": '\U00002665', - "heartsuit;": '\U00002665', - "hellip;": '\U00002026', - "hercon;": '\U000022B9', - "hfr;": '\U0001D525', - "hksearow;": '\U00002925', - "hkswarow;": '\U00002926', - "hoarr;": '\U000021FF', - "homtht;": '\U0000223B', - "hookleftarrow;": '\U000021A9', - "hookrightarrow;": '\U000021AA', - "hopf;": '\U0001D559', - "horbar;": '\U00002015', - "hscr;": '\U0001D4BD', - "hslash;": '\U0000210F', - "hstrok;": '\U00000127', - "hybull;": '\U00002043', - "hyphen;": '\U00002010', - "iacute;": '\U000000ED', - "ic;": '\U00002063', - "icirc;": '\U000000EE', - "icy;": '\U00000438', - "iecy;": '\U00000435', - "iexcl;": '\U000000A1', - "iff;": '\U000021D4', - "ifr;": '\U0001D526', - "igrave;": '\U000000EC', - "ii;": '\U00002148', - "iiiint;": '\U00002A0C', - "iiint;": '\U0000222D', - "iinfin;": '\U000029DC', - "iiota;": '\U00002129', - "ijlig;": '\U00000133', - "imacr;": '\U0000012B', - "image;": '\U00002111', - "imagline;": '\U00002110', - "imagpart;": '\U00002111', - "imath;": '\U00000131', - "imof;": '\U000022B7', - "imped;": '\U000001B5', - "in;": '\U00002208', - "incare;": '\U00002105', - "infin;": '\U0000221E', - "infintie;": '\U000029DD', - "inodot;": '\U00000131', - "int;": '\U0000222B', - "intcal;": '\U000022BA', - "integers;": '\U00002124', - "intercal;": '\U000022BA', - "intlarhk;": '\U00002A17', - "intprod;": '\U00002A3C', - "iocy;": '\U00000451', - "iogon;": '\U0000012F', - "iopf;": '\U0001D55A', - "iota;": '\U000003B9', - "iprod;": '\U00002A3C', - "iquest;": '\U000000BF', - "iscr;": '\U0001D4BE', - "isin;": '\U00002208', - "isinE;": '\U000022F9', - "isindot;": '\U000022F5', - "isins;": '\U000022F4', - "isinsv;": '\U000022F3', - "isinv;": '\U00002208', - "it;": '\U00002062', - "itilde;": '\U00000129', - "iukcy;": '\U00000456', - "iuml;": '\U000000EF', - "jcirc;": '\U00000135', - "jcy;": '\U00000439', - "jfr;": '\U0001D527', - "jmath;": '\U00000237', - "jopf;": '\U0001D55B', - "jscr;": '\U0001D4BF', - "jsercy;": '\U00000458', - "jukcy;": '\U00000454', - "kappa;": '\U000003BA', - "kappav;": '\U000003F0', - "kcedil;": '\U00000137', - "kcy;": '\U0000043A', - "kfr;": '\U0001D528', - "kgreen;": '\U00000138', - "khcy;": '\U00000445', - "kjcy;": '\U0000045C', - "kopf;": '\U0001D55C', - "kscr;": '\U0001D4C0', - "lAarr;": '\U000021DA', - "lArr;": '\U000021D0', - "lAtail;": '\U0000291B', - "lBarr;": '\U0000290E', - "lE;": '\U00002266', - "lEg;": '\U00002A8B', - "lHar;": '\U00002962', - "lacute;": '\U0000013A', - "laemptyv;": '\U000029B4', - "lagran;": '\U00002112', - "lambda;": '\U000003BB', - "lang;": '\U000027E8', - "langd;": '\U00002991', - "langle;": '\U000027E8', - "lap;": '\U00002A85', - "laquo;": '\U000000AB', - "larr;": '\U00002190', - "larrb;": '\U000021E4', - "larrbfs;": '\U0000291F', - "larrfs;": '\U0000291D', - "larrhk;": '\U000021A9', - "larrlp;": '\U000021AB', - "larrpl;": '\U00002939', - "larrsim;": '\U00002973', - "larrtl;": '\U000021A2', - "lat;": '\U00002AAB', - "latail;": '\U00002919', - "late;": '\U00002AAD', - "lbarr;": '\U0000290C', - "lbbrk;": '\U00002772', - "lbrace;": '\U0000007B', - "lbrack;": '\U0000005B', - "lbrke;": '\U0000298B', - "lbrksld;": '\U0000298F', - "lbrkslu;": '\U0000298D', - "lcaron;": '\U0000013E', - "lcedil;": '\U0000013C', - "lceil;": '\U00002308', - "lcub;": '\U0000007B', - "lcy;": '\U0000043B', - "ldca;": '\U00002936', - "ldquo;": '\U0000201C', - "ldquor;": '\U0000201E', - "ldrdhar;": '\U00002967', - "ldrushar;": '\U0000294B', - "ldsh;": '\U000021B2', - "le;": '\U00002264', - "leftarrow;": '\U00002190', - "leftarrowtail;": '\U000021A2', - "leftharpoondown;": '\U000021BD', - "leftharpoonup;": '\U000021BC', - "leftleftarrows;": '\U000021C7', - "leftrightarrow;": '\U00002194', - "leftrightarrows;": '\U000021C6', - "leftrightharpoons;": '\U000021CB', - "leftrightsquigarrow;": '\U000021AD', - "leftthreetimes;": '\U000022CB', - "leg;": '\U000022DA', - "leq;": '\U00002264', - "leqq;": '\U00002266', - "leqslant;": '\U00002A7D', - "les;": '\U00002A7D', - "lescc;": '\U00002AA8', - "lesdot;": '\U00002A7F', - "lesdoto;": '\U00002A81', - "lesdotor;": '\U00002A83', - "lesges;": '\U00002A93', - "lessapprox;": '\U00002A85', - "lessdot;": '\U000022D6', - "lesseqgtr;": '\U000022DA', - "lesseqqgtr;": '\U00002A8B', - "lessgtr;": '\U00002276', - "lesssim;": '\U00002272', - "lfisht;": '\U0000297C', - "lfloor;": '\U0000230A', - "lfr;": '\U0001D529', - "lg;": '\U00002276', - "lgE;": '\U00002A91', - "lhard;": '\U000021BD', - "lharu;": '\U000021BC', - "lharul;": '\U0000296A', - "lhblk;": '\U00002584', - "ljcy;": '\U00000459', - "ll;": '\U0000226A', - "llarr;": '\U000021C7', - "llcorner;": '\U0000231E', - "llhard;": '\U0000296B', - "lltri;": '\U000025FA', - "lmidot;": '\U00000140', - "lmoust;": '\U000023B0', - "lmoustache;": '\U000023B0', - "lnE;": '\U00002268', - "lnap;": '\U00002A89', - "lnapprox;": '\U00002A89', - "lne;": '\U00002A87', - "lneq;": '\U00002A87', - "lneqq;": '\U00002268', - "lnsim;": '\U000022E6', - "loang;": '\U000027EC', - "loarr;": '\U000021FD', - "lobrk;": '\U000027E6', - "longleftarrow;": '\U000027F5', - "longleftrightarrow;": '\U000027F7', - "longmapsto;": '\U000027FC', - "longrightarrow;": '\U000027F6', - "looparrowleft;": '\U000021AB', - "looparrowright;": '\U000021AC', - "lopar;": '\U00002985', - "lopf;": '\U0001D55D', - "loplus;": '\U00002A2D', - "lotimes;": '\U00002A34', - "lowast;": '\U00002217', - "lowbar;": '\U0000005F', - "loz;": '\U000025CA', - "lozenge;": '\U000025CA', - "lozf;": '\U000029EB', - "lpar;": '\U00000028', - "lparlt;": '\U00002993', - "lrarr;": '\U000021C6', - "lrcorner;": '\U0000231F', - "lrhar;": '\U000021CB', - "lrhard;": '\U0000296D', - "lrm;": '\U0000200E', - "lrtri;": '\U000022BF', - "lsaquo;": '\U00002039', - "lscr;": '\U0001D4C1', - "lsh;": '\U000021B0', - "lsim;": '\U00002272', - "lsime;": '\U00002A8D', - "lsimg;": '\U00002A8F', - "lsqb;": '\U0000005B', - "lsquo;": '\U00002018', - "lsquor;": '\U0000201A', - "lstrok;": '\U00000142', - "lt;": '\U0000003C', - "ltcc;": '\U00002AA6', - "ltcir;": '\U00002A79', - "ltdot;": '\U000022D6', - "lthree;": '\U000022CB', - "ltimes;": '\U000022C9', - "ltlarr;": '\U00002976', - "ltquest;": '\U00002A7B', - "ltrPar;": '\U00002996', - "ltri;": '\U000025C3', - "ltrie;": '\U000022B4', - "ltrif;": '\U000025C2', - "lurdshar;": '\U0000294A', - "luruhar;": '\U00002966', - "mDDot;": '\U0000223A', - "macr;": '\U000000AF', - "male;": '\U00002642', - "malt;": '\U00002720', - "maltese;": '\U00002720', - "map;": '\U000021A6', - "mapsto;": '\U000021A6', - "mapstodown;": '\U000021A7', - "mapstoleft;": '\U000021A4', - "mapstoup;": '\U000021A5', - "marker;": '\U000025AE', - "mcomma;": '\U00002A29', - "mcy;": '\U0000043C', - "mdash;": '\U00002014', - "measuredangle;": '\U00002221', - "mfr;": '\U0001D52A', - "mho;": '\U00002127', - "micro;": '\U000000B5', - "mid;": '\U00002223', - "midast;": '\U0000002A', - "midcir;": '\U00002AF0', - "middot;": '\U000000B7', - "minus;": '\U00002212', - "minusb;": '\U0000229F', - "minusd;": '\U00002238', - "minusdu;": '\U00002A2A', - "mlcp;": '\U00002ADB', - "mldr;": '\U00002026', - "mnplus;": '\U00002213', - "models;": '\U000022A7', - "mopf;": '\U0001D55E', - "mp;": '\U00002213', - "mscr;": '\U0001D4C2', - "mstpos;": '\U0000223E', - "mu;": '\U000003BC', - "multimap;": '\U000022B8', - "mumap;": '\U000022B8', - "nLeftarrow;": '\U000021CD', - "nLeftrightarrow;": '\U000021CE', - "nRightarrow;": '\U000021CF', - "nVDash;": '\U000022AF', - "nVdash;": '\U000022AE', - "nabla;": '\U00002207', - "nacute;": '\U00000144', - "nap;": '\U00002249', - "napos;": '\U00000149', - "napprox;": '\U00002249', - "natur;": '\U0000266E', - "natural;": '\U0000266E', - "naturals;": '\U00002115', - "nbsp;": '\U000000A0', - "ncap;": '\U00002A43', - "ncaron;": '\U00000148', - "ncedil;": '\U00000146', - "ncong;": '\U00002247', - "ncup;": '\U00002A42', - "ncy;": '\U0000043D', - "ndash;": '\U00002013', - "ne;": '\U00002260', - "neArr;": '\U000021D7', - "nearhk;": '\U00002924', - "nearr;": '\U00002197', - "nearrow;": '\U00002197', - "nequiv;": '\U00002262', - "nesear;": '\U00002928', - "nexist;": '\U00002204', - "nexists;": '\U00002204', - "nfr;": '\U0001D52B', - "nge;": '\U00002271', - "ngeq;": '\U00002271', - "ngsim;": '\U00002275', - "ngt;": '\U0000226F', - "ngtr;": '\U0000226F', - "nhArr;": '\U000021CE', - "nharr;": '\U000021AE', - "nhpar;": '\U00002AF2', - "ni;": '\U0000220B', - "nis;": '\U000022FC', - "nisd;": '\U000022FA', - "niv;": '\U0000220B', - "njcy;": '\U0000045A', - "nlArr;": '\U000021CD', - "nlarr;": '\U0000219A', - "nldr;": '\U00002025', - "nle;": '\U00002270', - "nleftarrow;": '\U0000219A', - "nleftrightarrow;": '\U000021AE', - "nleq;": '\U00002270', - "nless;": '\U0000226E', - "nlsim;": '\U00002274', - "nlt;": '\U0000226E', - "nltri;": '\U000022EA', - "nltrie;": '\U000022EC', - "nmid;": '\U00002224', - "nopf;": '\U0001D55F', - "not;": '\U000000AC', - "notin;": '\U00002209', - "notinva;": '\U00002209', - "notinvb;": '\U000022F7', - "notinvc;": '\U000022F6', - "notni;": '\U0000220C', - "notniva;": '\U0000220C', - "notnivb;": '\U000022FE', - "notnivc;": '\U000022FD', - "npar;": '\U00002226', - "nparallel;": '\U00002226', - "npolint;": '\U00002A14', - "npr;": '\U00002280', - "nprcue;": '\U000022E0', - "nprec;": '\U00002280', - "nrArr;": '\U000021CF', - "nrarr;": '\U0000219B', - "nrightarrow;": '\U0000219B', - "nrtri;": '\U000022EB', - "nrtrie;": '\U000022ED', - "nsc;": '\U00002281', - "nsccue;": '\U000022E1', - "nscr;": '\U0001D4C3', - "nshortmid;": '\U00002224', - "nshortparallel;": '\U00002226', - "nsim;": '\U00002241', - "nsime;": '\U00002244', - "nsimeq;": '\U00002244', - "nsmid;": '\U00002224', - "nspar;": '\U00002226', - "nsqsube;": '\U000022E2', - "nsqsupe;": '\U000022E3', - "nsub;": '\U00002284', - "nsube;": '\U00002288', - "nsubseteq;": '\U00002288', - "nsucc;": '\U00002281', - "nsup;": '\U00002285', - "nsupe;": '\U00002289', - "nsupseteq;": '\U00002289', - "ntgl;": '\U00002279', - "ntilde;": '\U000000F1', - "ntlg;": '\U00002278', - "ntriangleleft;": '\U000022EA', - "ntrianglelefteq;": '\U000022EC', - "ntriangleright;": '\U000022EB', - "ntrianglerighteq;": '\U000022ED', - "nu;": '\U000003BD', - "num;": '\U00000023', - "numero;": '\U00002116', - "numsp;": '\U00002007', - "nvDash;": '\U000022AD', - "nvHarr;": '\U00002904', - "nvdash;": '\U000022AC', - "nvinfin;": '\U000029DE', - "nvlArr;": '\U00002902', - "nvrArr;": '\U00002903', - "nwArr;": '\U000021D6', - "nwarhk;": '\U00002923', - "nwarr;": '\U00002196', - "nwarrow;": '\U00002196', - "nwnear;": '\U00002927', - "oS;": '\U000024C8', - "oacute;": '\U000000F3', - "oast;": '\U0000229B', - "ocir;": '\U0000229A', - "ocirc;": '\U000000F4', - "ocy;": '\U0000043E', - "odash;": '\U0000229D', - "odblac;": '\U00000151', - "odiv;": '\U00002A38', - "odot;": '\U00002299', - "odsold;": '\U000029BC', - "oelig;": '\U00000153', - "ofcir;": '\U000029BF', - "ofr;": '\U0001D52C', - "ogon;": '\U000002DB', - "ograve;": '\U000000F2', - "ogt;": '\U000029C1', - "ohbar;": '\U000029B5', - "ohm;": '\U000003A9', - "oint;": '\U0000222E', - "olarr;": '\U000021BA', - "olcir;": '\U000029BE', - "olcross;": '\U000029BB', - "oline;": '\U0000203E', - "olt;": '\U000029C0', - "omacr;": '\U0000014D', - "omega;": '\U000003C9', - "omicron;": '\U000003BF', - "omid;": '\U000029B6', - "ominus;": '\U00002296', - "oopf;": '\U0001D560', - "opar;": '\U000029B7', - "operp;": '\U000029B9', - "oplus;": '\U00002295', - "or;": '\U00002228', - "orarr;": '\U000021BB', - "ord;": '\U00002A5D', - "order;": '\U00002134', - "orderof;": '\U00002134', - "ordf;": '\U000000AA', - "ordm;": '\U000000BA', - "origof;": '\U000022B6', - "oror;": '\U00002A56', - "orslope;": '\U00002A57', - "orv;": '\U00002A5B', - "oscr;": '\U00002134', - "oslash;": '\U000000F8', - "osol;": '\U00002298', - "otilde;": '\U000000F5', - "otimes;": '\U00002297', - "otimesas;": '\U00002A36', - "ouml;": '\U000000F6', - "ovbar;": '\U0000233D', - "par;": '\U00002225', - "para;": '\U000000B6', - "parallel;": '\U00002225', - "parsim;": '\U00002AF3', - "parsl;": '\U00002AFD', - "part;": '\U00002202', - "pcy;": '\U0000043F', - "percnt;": '\U00000025', - "period;": '\U0000002E', - "permil;": '\U00002030', - "perp;": '\U000022A5', - "pertenk;": '\U00002031', - "pfr;": '\U0001D52D', - "phi;": '\U000003C6', - "phiv;": '\U000003D5', - "phmmat;": '\U00002133', - "phone;": '\U0000260E', - "pi;": '\U000003C0', - "pitchfork;": '\U000022D4', - "piv;": '\U000003D6', - "planck;": '\U0000210F', - "planckh;": '\U0000210E', - "plankv;": '\U0000210F', - "plus;": '\U0000002B', - "plusacir;": '\U00002A23', - "plusb;": '\U0000229E', - "pluscir;": '\U00002A22', - "plusdo;": '\U00002214', - "plusdu;": '\U00002A25', - "pluse;": '\U00002A72', - "plusmn;": '\U000000B1', - "plussim;": '\U00002A26', - "plustwo;": '\U00002A27', - "pm;": '\U000000B1', - "pointint;": '\U00002A15', - "popf;": '\U0001D561', - "pound;": '\U000000A3', - "pr;": '\U0000227A', - "prE;": '\U00002AB3', - "prap;": '\U00002AB7', - "prcue;": '\U0000227C', - "pre;": '\U00002AAF', - "prec;": '\U0000227A', - "precapprox;": '\U00002AB7', - "preccurlyeq;": '\U0000227C', - "preceq;": '\U00002AAF', - "precnapprox;": '\U00002AB9', - "precneqq;": '\U00002AB5', - "precnsim;": '\U000022E8', - "precsim;": '\U0000227E', - "prime;": '\U00002032', - "primes;": '\U00002119', - "prnE;": '\U00002AB5', - "prnap;": '\U00002AB9', - "prnsim;": '\U000022E8', - "prod;": '\U0000220F', - "profalar;": '\U0000232E', - "profline;": '\U00002312', - "profsurf;": '\U00002313', - "prop;": '\U0000221D', - "propto;": '\U0000221D', - "prsim;": '\U0000227E', - "prurel;": '\U000022B0', - "pscr;": '\U0001D4C5', - "psi;": '\U000003C8', - "puncsp;": '\U00002008', - "qfr;": '\U0001D52E', - "qint;": '\U00002A0C', - "qopf;": '\U0001D562', - "qprime;": '\U00002057', - "qscr;": '\U0001D4C6', - "quaternions;": '\U0000210D', - "quatint;": '\U00002A16', - "quest;": '\U0000003F', - "questeq;": '\U0000225F', - "quot;": '\U00000022', - "rAarr;": '\U000021DB', - "rArr;": '\U000021D2', - "rAtail;": '\U0000291C', - "rBarr;": '\U0000290F', - "rHar;": '\U00002964', - "racute;": '\U00000155', - "radic;": '\U0000221A', - "raemptyv;": '\U000029B3', - "rang;": '\U000027E9', - "rangd;": '\U00002992', - "range;": '\U000029A5', - "rangle;": '\U000027E9', - "raquo;": '\U000000BB', - "rarr;": '\U00002192', - "rarrap;": '\U00002975', - "rarrb;": '\U000021E5', - "rarrbfs;": '\U00002920', - "rarrc;": '\U00002933', - "rarrfs;": '\U0000291E', - "rarrhk;": '\U000021AA', - "rarrlp;": '\U000021AC', - "rarrpl;": '\U00002945', - "rarrsim;": '\U00002974', - "rarrtl;": '\U000021A3', - "rarrw;": '\U0000219D', - "ratail;": '\U0000291A', - "ratio;": '\U00002236', - "rationals;": '\U0000211A', - "rbarr;": '\U0000290D', - "rbbrk;": '\U00002773', - "rbrace;": '\U0000007D', - "rbrack;": '\U0000005D', - "rbrke;": '\U0000298C', - "rbrksld;": '\U0000298E', - "rbrkslu;": '\U00002990', - "rcaron;": '\U00000159', - "rcedil;": '\U00000157', - "rceil;": '\U00002309', - "rcub;": '\U0000007D', - "rcy;": '\U00000440', - "rdca;": '\U00002937', - "rdldhar;": '\U00002969', - "rdquo;": '\U0000201D', - "rdquor;": '\U0000201D', - "rdsh;": '\U000021B3', - "real;": '\U0000211C', - "realine;": '\U0000211B', - "realpart;": '\U0000211C', - "reals;": '\U0000211D', - "rect;": '\U000025AD', - "reg;": '\U000000AE', - "rfisht;": '\U0000297D', - "rfloor;": '\U0000230B', - "rfr;": '\U0001D52F', - "rhard;": '\U000021C1', - "rharu;": '\U000021C0', - "rharul;": '\U0000296C', - "rho;": '\U000003C1', - "rhov;": '\U000003F1', - "rightarrow;": '\U00002192', - "rightarrowtail;": '\U000021A3', - "rightharpoondown;": '\U000021C1', - "rightharpoonup;": '\U000021C0', - "rightleftarrows;": '\U000021C4', - "rightleftharpoons;": '\U000021CC', - "rightrightarrows;": '\U000021C9', - "rightsquigarrow;": '\U0000219D', - "rightthreetimes;": '\U000022CC', - "ring;": '\U000002DA', - "risingdotseq;": '\U00002253', - "rlarr;": '\U000021C4', - "rlhar;": '\U000021CC', - "rlm;": '\U0000200F', - "rmoust;": '\U000023B1', - "rmoustache;": '\U000023B1', - "rnmid;": '\U00002AEE', - "roang;": '\U000027ED', - "roarr;": '\U000021FE', - "robrk;": '\U000027E7', - "ropar;": '\U00002986', - "ropf;": '\U0001D563', - "roplus;": '\U00002A2E', - "rotimes;": '\U00002A35', - "rpar;": '\U00000029', - "rpargt;": '\U00002994', - "rppolint;": '\U00002A12', - "rrarr;": '\U000021C9', - "rsaquo;": '\U0000203A', - "rscr;": '\U0001D4C7', - "rsh;": '\U000021B1', - "rsqb;": '\U0000005D', - "rsquo;": '\U00002019', - "rsquor;": '\U00002019', - "rthree;": '\U000022CC', - "rtimes;": '\U000022CA', - "rtri;": '\U000025B9', - "rtrie;": '\U000022B5', - "rtrif;": '\U000025B8', - "rtriltri;": '\U000029CE', - "ruluhar;": '\U00002968', - "rx;": '\U0000211E', - "sacute;": '\U0000015B', - "sbquo;": '\U0000201A', - "sc;": '\U0000227B', - "scE;": '\U00002AB4', - "scap;": '\U00002AB8', - "scaron;": '\U00000161', - "sccue;": '\U0000227D', - "sce;": '\U00002AB0', - "scedil;": '\U0000015F', - "scirc;": '\U0000015D', - "scnE;": '\U00002AB6', - "scnap;": '\U00002ABA', - "scnsim;": '\U000022E9', - "scpolint;": '\U00002A13', - "scsim;": '\U0000227F', - "scy;": '\U00000441', - "sdot;": '\U000022C5', - "sdotb;": '\U000022A1', - "sdote;": '\U00002A66', - "seArr;": '\U000021D8', - "searhk;": '\U00002925', - "searr;": '\U00002198', - "searrow;": '\U00002198', - "sect;": '\U000000A7', - "semi;": '\U0000003B', - "seswar;": '\U00002929', - "setminus;": '\U00002216', - "setmn;": '\U00002216', - "sext;": '\U00002736', - "sfr;": '\U0001D530', - "sfrown;": '\U00002322', - "sharp;": '\U0000266F', - "shchcy;": '\U00000449', - "shcy;": '\U00000448', - "shortmid;": '\U00002223', - "shortparallel;": '\U00002225', - "shy;": '\U000000AD', - "sigma;": '\U000003C3', - "sigmaf;": '\U000003C2', - "sigmav;": '\U000003C2', - "sim;": '\U0000223C', - "simdot;": '\U00002A6A', - "sime;": '\U00002243', - "simeq;": '\U00002243', - "simg;": '\U00002A9E', - "simgE;": '\U00002AA0', - "siml;": '\U00002A9D', - "simlE;": '\U00002A9F', - "simne;": '\U00002246', - "simplus;": '\U00002A24', - "simrarr;": '\U00002972', - "slarr;": '\U00002190', - "smallsetminus;": '\U00002216', - "smashp;": '\U00002A33', - "smeparsl;": '\U000029E4', - "smid;": '\U00002223', - "smile;": '\U00002323', - "smt;": '\U00002AAA', - "smte;": '\U00002AAC', - "softcy;": '\U0000044C', - "sol;": '\U0000002F', - "solb;": '\U000029C4', - "solbar;": '\U0000233F', - "sopf;": '\U0001D564', - "spades;": '\U00002660', - "spadesuit;": '\U00002660', - "spar;": '\U00002225', - "sqcap;": '\U00002293', - "sqcup;": '\U00002294', - "sqsub;": '\U0000228F', - "sqsube;": '\U00002291', - "sqsubset;": '\U0000228F', - "sqsubseteq;": '\U00002291', - "sqsup;": '\U00002290', - "sqsupe;": '\U00002292', - "sqsupset;": '\U00002290', - "sqsupseteq;": '\U00002292', - "squ;": '\U000025A1', - "square;": '\U000025A1', - "squarf;": '\U000025AA', - "squf;": '\U000025AA', - "srarr;": '\U00002192', - "sscr;": '\U0001D4C8', - "ssetmn;": '\U00002216', - "ssmile;": '\U00002323', - "sstarf;": '\U000022C6', - "star;": '\U00002606', - "starf;": '\U00002605', - "straightepsilon;": '\U000003F5', - "straightphi;": '\U000003D5', - "strns;": '\U000000AF', - "sub;": '\U00002282', - "subE;": '\U00002AC5', - "subdot;": '\U00002ABD', - "sube;": '\U00002286', - "subedot;": '\U00002AC3', - "submult;": '\U00002AC1', - "subnE;": '\U00002ACB', - "subne;": '\U0000228A', - "subplus;": '\U00002ABF', - "subrarr;": '\U00002979', - "subset;": '\U00002282', - "subseteq;": '\U00002286', - "subseteqq;": '\U00002AC5', - "subsetneq;": '\U0000228A', - "subsetneqq;": '\U00002ACB', - "subsim;": '\U00002AC7', - "subsub;": '\U00002AD5', - "subsup;": '\U00002AD3', - "succ;": '\U0000227B', - "succapprox;": '\U00002AB8', - "succcurlyeq;": '\U0000227D', - "succeq;": '\U00002AB0', - "succnapprox;": '\U00002ABA', - "succneqq;": '\U00002AB6', - "succnsim;": '\U000022E9', - "succsim;": '\U0000227F', - "sum;": '\U00002211', - "sung;": '\U0000266A', - "sup;": '\U00002283', - "sup1;": '\U000000B9', - "sup2;": '\U000000B2', - "sup3;": '\U000000B3', - "supE;": '\U00002AC6', - "supdot;": '\U00002ABE', - "supdsub;": '\U00002AD8', - "supe;": '\U00002287', - "supedot;": '\U00002AC4', - "suphsol;": '\U000027C9', - "suphsub;": '\U00002AD7', - "suplarr;": '\U0000297B', - "supmult;": '\U00002AC2', - "supnE;": '\U00002ACC', - "supne;": '\U0000228B', - "supplus;": '\U00002AC0', - "supset;": '\U00002283', - "supseteq;": '\U00002287', - "supseteqq;": '\U00002AC6', - "supsetneq;": '\U0000228B', - "supsetneqq;": '\U00002ACC', - "supsim;": '\U00002AC8', - "supsub;": '\U00002AD4', - "supsup;": '\U00002AD6', - "swArr;": '\U000021D9', - "swarhk;": '\U00002926', - "swarr;": '\U00002199', - "swarrow;": '\U00002199', - "swnwar;": '\U0000292A', - "szlig;": '\U000000DF', - "target;": '\U00002316', - "tau;": '\U000003C4', - "tbrk;": '\U000023B4', - "tcaron;": '\U00000165', - "tcedil;": '\U00000163', - "tcy;": '\U00000442', - "tdot;": '\U000020DB', - "telrec;": '\U00002315', - "tfr;": '\U0001D531', - "there4;": '\U00002234', - "therefore;": '\U00002234', - "theta;": '\U000003B8', - "thetasym;": '\U000003D1', - "thetav;": '\U000003D1', - "thickapprox;": '\U00002248', - "thicksim;": '\U0000223C', - "thinsp;": '\U00002009', - "thkap;": '\U00002248', - "thksim;": '\U0000223C', - "thorn;": '\U000000FE', - "tilde;": '\U000002DC', - "times;": '\U000000D7', - "timesb;": '\U000022A0', - "timesbar;": '\U00002A31', - "timesd;": '\U00002A30', - "tint;": '\U0000222D', - "toea;": '\U00002928', - "top;": '\U000022A4', - "topbot;": '\U00002336', - "topcir;": '\U00002AF1', - "topf;": '\U0001D565', - "topfork;": '\U00002ADA', - "tosa;": '\U00002929', - "tprime;": '\U00002034', - "trade;": '\U00002122', - "triangle;": '\U000025B5', - "triangledown;": '\U000025BF', - "triangleleft;": '\U000025C3', - "trianglelefteq;": '\U000022B4', - "triangleq;": '\U0000225C', - "triangleright;": '\U000025B9', - "trianglerighteq;": '\U000022B5', - "tridot;": '\U000025EC', - "trie;": '\U0000225C', - "triminus;": '\U00002A3A', - "triplus;": '\U00002A39', - "trisb;": '\U000029CD', - "tritime;": '\U00002A3B', - "trpezium;": '\U000023E2', - "tscr;": '\U0001D4C9', - "tscy;": '\U00000446', - "tshcy;": '\U0000045B', - "tstrok;": '\U00000167', - "twixt;": '\U0000226C', - "twoheadleftarrow;": '\U0000219E', - "twoheadrightarrow;": '\U000021A0', - "uArr;": '\U000021D1', - "uHar;": '\U00002963', - "uacute;": '\U000000FA', - "uarr;": '\U00002191', - "ubrcy;": '\U0000045E', - "ubreve;": '\U0000016D', - "ucirc;": '\U000000FB', - "ucy;": '\U00000443', - "udarr;": '\U000021C5', - "udblac;": '\U00000171', - "udhar;": '\U0000296E', - "ufisht;": '\U0000297E', - "ufr;": '\U0001D532', - "ugrave;": '\U000000F9', - "uharl;": '\U000021BF', - "uharr;": '\U000021BE', - "uhblk;": '\U00002580', - "ulcorn;": '\U0000231C', - "ulcorner;": '\U0000231C', - "ulcrop;": '\U0000230F', - "ultri;": '\U000025F8', - "umacr;": '\U0000016B', - "uml;": '\U000000A8', - "uogon;": '\U00000173', - "uopf;": '\U0001D566', - "uparrow;": '\U00002191', - "updownarrow;": '\U00002195', - "upharpoonleft;": '\U000021BF', - "upharpoonright;": '\U000021BE', - "uplus;": '\U0000228E', - "upsi;": '\U000003C5', - "upsih;": '\U000003D2', - "upsilon;": '\U000003C5', - "upuparrows;": '\U000021C8', - "urcorn;": '\U0000231D', - "urcorner;": '\U0000231D', - "urcrop;": '\U0000230E', - "uring;": '\U0000016F', - "urtri;": '\U000025F9', - "uscr;": '\U0001D4CA', - "utdot;": '\U000022F0', - "utilde;": '\U00000169', - "utri;": '\U000025B5', - "utrif;": '\U000025B4', - "uuarr;": '\U000021C8', - "uuml;": '\U000000FC', - "uwangle;": '\U000029A7', - "vArr;": '\U000021D5', - "vBar;": '\U00002AE8', - "vBarv;": '\U00002AE9', - "vDash;": '\U000022A8', - "vangrt;": '\U0000299C', - "varepsilon;": '\U000003F5', - "varkappa;": '\U000003F0', - "varnothing;": '\U00002205', - "varphi;": '\U000003D5', - "varpi;": '\U000003D6', - "varpropto;": '\U0000221D', - "varr;": '\U00002195', - "varrho;": '\U000003F1', - "varsigma;": '\U000003C2', - "vartheta;": '\U000003D1', - "vartriangleleft;": '\U000022B2', - "vartriangleright;": '\U000022B3', - "vcy;": '\U00000432', - "vdash;": '\U000022A2', - "vee;": '\U00002228', - "veebar;": '\U000022BB', - "veeeq;": '\U0000225A', - "vellip;": '\U000022EE', - "verbar;": '\U0000007C', - "vert;": '\U0000007C', - "vfr;": '\U0001D533', - "vltri;": '\U000022B2', - "vopf;": '\U0001D567', - "vprop;": '\U0000221D', - "vrtri;": '\U000022B3', - "vscr;": '\U0001D4CB', - "vzigzag;": '\U0000299A', - "wcirc;": '\U00000175', - "wedbar;": '\U00002A5F', - "wedge;": '\U00002227', - "wedgeq;": '\U00002259', - "weierp;": '\U00002118', - "wfr;": '\U0001D534', - "wopf;": '\U0001D568', - "wp;": '\U00002118', - "wr;": '\U00002240', - "wreath;": '\U00002240', - "wscr;": '\U0001D4CC', - "xcap;": '\U000022C2', - "xcirc;": '\U000025EF', - "xcup;": '\U000022C3', - "xdtri;": '\U000025BD', - "xfr;": '\U0001D535', - "xhArr;": '\U000027FA', - "xharr;": '\U000027F7', - "xi;": '\U000003BE', - "xlArr;": '\U000027F8', - "xlarr;": '\U000027F5', - "xmap;": '\U000027FC', - "xnis;": '\U000022FB', - "xodot;": '\U00002A00', - "xopf;": '\U0001D569', - "xoplus;": '\U00002A01', - "xotime;": '\U00002A02', - "xrArr;": '\U000027F9', - "xrarr;": '\U000027F6', - "xscr;": '\U0001D4CD', - "xsqcup;": '\U00002A06', - "xuplus;": '\U00002A04', - "xutri;": '\U000025B3', - "xvee;": '\U000022C1', - "xwedge;": '\U000022C0', - "yacute;": '\U000000FD', - "yacy;": '\U0000044F', - "ycirc;": '\U00000177', - "ycy;": '\U0000044B', - "yen;": '\U000000A5', - "yfr;": '\U0001D536', - "yicy;": '\U00000457', - "yopf;": '\U0001D56A', - "yscr;": '\U0001D4CE', - "yucy;": '\U0000044E', - "yuml;": '\U000000FF', - "zacute;": '\U0000017A', - "zcaron;": '\U0000017E', - "zcy;": '\U00000437', - "zdot;": '\U0000017C', - "zeetrf;": '\U00002128', - "zeta;": '\U000003B6', - "zfr;": '\U0001D537', - "zhcy;": '\U00000436', - "zigrarr;": '\U000021DD', - "zopf;": '\U0001D56B', - "zscr;": '\U0001D4CF', - "zwj;": '\U0000200D', - "zwnj;": '\U0000200C', - "AElig": '\U000000C6', - "AMP": '\U00000026', - "Aacute": '\U000000C1', - "Acirc": '\U000000C2', - "Agrave": '\U000000C0', - "Aring": '\U000000C5', - "Atilde": '\U000000C3', - "Auml": '\U000000C4', - "COPY": '\U000000A9', - "Ccedil": '\U000000C7', - "ETH": '\U000000D0', - "Eacute": '\U000000C9', - "Ecirc": '\U000000CA', - "Egrave": '\U000000C8', - "Euml": '\U000000CB', - "GT": '\U0000003E', - "Iacute": '\U000000CD', - "Icirc": '\U000000CE', - "Igrave": '\U000000CC', - "Iuml": '\U000000CF', - "LT": '\U0000003C', - "Ntilde": '\U000000D1', - "Oacute": '\U000000D3', - "Ocirc": '\U000000D4', - "Ograve": '\U000000D2', - "Oslash": '\U000000D8', - "Otilde": '\U000000D5', - "Ouml": '\U000000D6', - "QUOT": '\U00000022', - "REG": '\U000000AE', - "THORN": '\U000000DE', - "Uacute": '\U000000DA', - "Ucirc": '\U000000DB', - "Ugrave": '\U000000D9', - "Uuml": '\U000000DC', - "Yacute": '\U000000DD', - "aacute": '\U000000E1', - "acirc": '\U000000E2', - "acute": '\U000000B4', - "aelig": '\U000000E6', - "agrave": '\U000000E0', - "amp": '\U00000026', - "aring": '\U000000E5', - "atilde": '\U000000E3', - "auml": '\U000000E4', - "brvbar": '\U000000A6', - "ccedil": '\U000000E7', - "cedil": '\U000000B8', - "cent": '\U000000A2', - "copy": '\U000000A9', - "curren": '\U000000A4', - "deg": '\U000000B0', - "divide": '\U000000F7', - "eacute": '\U000000E9', - "ecirc": '\U000000EA', - "egrave": '\U000000E8', - "eth": '\U000000F0', - "euml": '\U000000EB', - "frac12": '\U000000BD', - "frac14": '\U000000BC', - "frac34": '\U000000BE', - "gt": '\U0000003E', - "iacute": '\U000000ED', - "icirc": '\U000000EE', - "iexcl": '\U000000A1', - "igrave": '\U000000EC', - "iquest": '\U000000BF', - "iuml": '\U000000EF', - "laquo": '\U000000AB', - "lt": '\U0000003C', - "macr": '\U000000AF', - "micro": '\U000000B5', - "middot": '\U000000B7', - "nbsp": '\U000000A0', - "not": '\U000000AC', - "ntilde": '\U000000F1', - "oacute": '\U000000F3', - "ocirc": '\U000000F4', - "ograve": '\U000000F2', - "ordf": '\U000000AA', - "ordm": '\U000000BA', - "oslash": '\U000000F8', - "otilde": '\U000000F5', - "ouml": '\U000000F6', - "para": '\U000000B6', - "plusmn": '\U000000B1', - "pound": '\U000000A3', - "quot": '\U00000022', - "raquo": '\U000000BB', - "reg": '\U000000AE', - "sect": '\U000000A7', - "shy": '\U000000AD', - "sup1": '\U000000B9', - "sup2": '\U000000B2', - "sup3": '\U000000B3', - "szlig": '\U000000DF', - "thorn": '\U000000FE', - "times": '\U000000D7', - "uacute": '\U000000FA', - "ucirc": '\U000000FB', - "ugrave": '\U000000F9', - "uml": '\U000000A8', - "uuml": '\U000000FC', - "yacute": '\U000000FD', - "yen": '\U000000A5', - "yuml": '\U000000FF', -} - -// HTML entities that are two unicode codepoints. -var entity2 = map[string][2]rune{ - // TODO(nigeltao): Handle replacements that are wider than their names. - // "nLt;": {'\u226A', '\u20D2'}, - // "nGt;": {'\u226B', '\u20D2'}, - "NotEqualTilde;": {'\u2242', '\u0338'}, - "NotGreaterFullEqual;": {'\u2267', '\u0338'}, - "NotGreaterGreater;": {'\u226B', '\u0338'}, - "NotGreaterSlantEqual;": {'\u2A7E', '\u0338'}, - "NotHumpDownHump;": {'\u224E', '\u0338'}, - "NotHumpEqual;": {'\u224F', '\u0338'}, - "NotLeftTriangleBar;": {'\u29CF', '\u0338'}, - "NotLessLess;": {'\u226A', '\u0338'}, - "NotLessSlantEqual;": {'\u2A7D', '\u0338'}, - "NotNestedGreaterGreater;": {'\u2AA2', '\u0338'}, - "NotNestedLessLess;": {'\u2AA1', '\u0338'}, - "NotPrecedesEqual;": {'\u2AAF', '\u0338'}, - "NotRightTriangleBar;": {'\u29D0', '\u0338'}, - "NotSquareSubset;": {'\u228F', '\u0338'}, - "NotSquareSuperset;": {'\u2290', '\u0338'}, - "NotSubset;": {'\u2282', '\u20D2'}, - "NotSucceedsEqual;": {'\u2AB0', '\u0338'}, - "NotSucceedsTilde;": {'\u227F', '\u0338'}, - "NotSuperset;": {'\u2283', '\u20D2'}, - "ThickSpace;": {'\u205F', '\u200A'}, - "acE;": {'\u223E', '\u0333'}, - "bne;": {'\u003D', '\u20E5'}, - "bnequiv;": {'\u2261', '\u20E5'}, - "caps;": {'\u2229', '\uFE00'}, - "cups;": {'\u222A', '\uFE00'}, - "fjlig;": {'\u0066', '\u006A'}, - "gesl;": {'\u22DB', '\uFE00'}, - "gvertneqq;": {'\u2269', '\uFE00'}, - "gvnE;": {'\u2269', '\uFE00'}, - "lates;": {'\u2AAD', '\uFE00'}, - "lesg;": {'\u22DA', '\uFE00'}, - "lvertneqq;": {'\u2268', '\uFE00'}, - "lvnE;": {'\u2268', '\uFE00'}, - "nGg;": {'\u22D9', '\u0338'}, - "nGtv;": {'\u226B', '\u0338'}, - "nLl;": {'\u22D8', '\u0338'}, - "nLtv;": {'\u226A', '\u0338'}, - "nang;": {'\u2220', '\u20D2'}, - "napE;": {'\u2A70', '\u0338'}, - "napid;": {'\u224B', '\u0338'}, - "nbump;": {'\u224E', '\u0338'}, - "nbumpe;": {'\u224F', '\u0338'}, - "ncongdot;": {'\u2A6D', '\u0338'}, - "nedot;": {'\u2250', '\u0338'}, - "nesim;": {'\u2242', '\u0338'}, - "ngE;": {'\u2267', '\u0338'}, - "ngeqq;": {'\u2267', '\u0338'}, - "ngeqslant;": {'\u2A7E', '\u0338'}, - "nges;": {'\u2A7E', '\u0338'}, - "nlE;": {'\u2266', '\u0338'}, - "nleqq;": {'\u2266', '\u0338'}, - "nleqslant;": {'\u2A7D', '\u0338'}, - "nles;": {'\u2A7D', '\u0338'}, - "notinE;": {'\u22F9', '\u0338'}, - "notindot;": {'\u22F5', '\u0338'}, - "nparsl;": {'\u2AFD', '\u20E5'}, - "npart;": {'\u2202', '\u0338'}, - "npre;": {'\u2AAF', '\u0338'}, - "npreceq;": {'\u2AAF', '\u0338'}, - "nrarrc;": {'\u2933', '\u0338'}, - "nrarrw;": {'\u219D', '\u0338'}, - "nsce;": {'\u2AB0', '\u0338'}, - "nsubE;": {'\u2AC5', '\u0338'}, - "nsubset;": {'\u2282', '\u20D2'}, - "nsubseteqq;": {'\u2AC5', '\u0338'}, - "nsucceq;": {'\u2AB0', '\u0338'}, - "nsupE;": {'\u2AC6', '\u0338'}, - "nsupset;": {'\u2283', '\u20D2'}, - "nsupseteqq;": {'\u2AC6', '\u0338'}, - "nvap;": {'\u224D', '\u20D2'}, - "nvge;": {'\u2265', '\u20D2'}, - "nvgt;": {'\u003E', '\u20D2'}, - "nvle;": {'\u2264', '\u20D2'}, - "nvlt;": {'\u003C', '\u20D2'}, - "nvltrie;": {'\u22B4', '\u20D2'}, - "nvrtrie;": {'\u22B5', '\u20D2'}, - "nvsim;": {'\u223C', '\u20D2'}, - "race;": {'\u223D', '\u0331'}, - "smtes;": {'\u2AAC', '\uFE00'}, - "sqcaps;": {'\u2293', '\uFE00'}, - "sqcups;": {'\u2294', '\uFE00'}, - "varsubsetneq;": {'\u228A', '\uFE00'}, - "varsubsetneqq;": {'\u2ACB', '\uFE00'}, - "varsupsetneq;": {'\u228B', '\uFE00'}, - "varsupsetneqq;": {'\u2ACC', '\uFE00'}, - "vnsub;": {'\u2282', '\u20D2'}, - "vnsup;": {'\u2283', '\u20D2'}, - "vsubnE;": {'\u2ACB', '\uFE00'}, - "vsubne;": {'\u228A', '\uFE00'}, - "vsupnE;": {'\u2ACC', '\uFE00'}, - "vsupne;": {'\u228B', '\uFE00'}, -} diff --git a/vendor/golang.org/x/net/html/entity_test.go b/vendor/golang.org/x/net/html/entity_test.go deleted file mode 100644 index b53f866..0000000 --- a/vendor/golang.org/x/net/html/entity_test.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2010 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 html - -import ( - "testing" - "unicode/utf8" -) - -func TestEntityLength(t *testing.T) { - // We verify that the length of UTF-8 encoding of each value is <= 1 + len(key). - // The +1 comes from the leading "&". This property implies that the length of - // unescaped text is <= the length of escaped text. - for k, v := range entity { - if 1+len(k) < utf8.RuneLen(v) { - t.Error("escaped entity &" + k + " is shorter than its UTF-8 encoding " + string(v)) - } - if len(k) > longestEntityWithoutSemicolon && k[len(k)-1] != ';' { - t.Errorf("entity name %s is %d characters, but longestEntityWithoutSemicolon=%d", k, len(k), longestEntityWithoutSemicolon) - } - } - for k, v := range entity2 { - if 1+len(k) < utf8.RuneLen(v[0])+utf8.RuneLen(v[1]) { - t.Error("escaped entity &" + k + " is shorter than its UTF-8 encoding " + string(v[0]) + string(v[1])) - } - } -} diff --git a/vendor/golang.org/x/net/html/escape.go b/vendor/golang.org/x/net/html/escape.go deleted file mode 100644 index d856139..0000000 --- a/vendor/golang.org/x/net/html/escape.go +++ /dev/null @@ -1,258 +0,0 @@ -// Copyright 2010 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 html - -import ( - "bytes" - "strings" - "unicode/utf8" -) - -// These replacements permit compatibility with old numeric entities that -// assumed Windows-1252 encoding. -// https://html.spec.whatwg.org/multipage/syntax.html#consume-a-character-reference -var replacementTable = [...]rune{ - '\u20AC', // First entry is what 0x80 should be replaced with. - '\u0081', - '\u201A', - '\u0192', - '\u201E', - '\u2026', - '\u2020', - '\u2021', - '\u02C6', - '\u2030', - '\u0160', - '\u2039', - '\u0152', - '\u008D', - '\u017D', - '\u008F', - '\u0090', - '\u2018', - '\u2019', - '\u201C', - '\u201D', - '\u2022', - '\u2013', - '\u2014', - '\u02DC', - '\u2122', - '\u0161', - '\u203A', - '\u0153', - '\u009D', - '\u017E', - '\u0178', // Last entry is 0x9F. - // 0x00->'\uFFFD' is handled programmatically. - // 0x0D->'\u000D' is a no-op. -} - -// unescapeEntity reads an entity like "<" from b[src:] and writes the -// corresponding "<" to b[dst:], returning the incremented dst and src cursors. -// Precondition: b[src] == '&' && dst <= src. -// attribute should be true if parsing an attribute value. -func unescapeEntity(b []byte, dst, src int, attribute bool) (dst1, src1 int) { - // https://html.spec.whatwg.org/multipage/syntax.html#consume-a-character-reference - - // i starts at 1 because we already know that s[0] == '&'. - i, s := 1, b[src:] - - if len(s) <= 1 { - b[dst] = b[src] - return dst + 1, src + 1 - } - - if s[i] == '#' { - if len(s) <= 3 { // We need to have at least "&#.". - b[dst] = b[src] - return dst + 1, src + 1 - } - i++ - c := s[i] - hex := false - if c == 'x' || c == 'X' { - hex = true - i++ - } - - x := '\x00' - for i < len(s) { - c = s[i] - i++ - if hex { - if '0' <= c && c <= '9' { - x = 16*x + rune(c) - '0' - continue - } else if 'a' <= c && c <= 'f' { - x = 16*x + rune(c) - 'a' + 10 - continue - } else if 'A' <= c && c <= 'F' { - x = 16*x + rune(c) - 'A' + 10 - continue - } - } else if '0' <= c && c <= '9' { - x = 10*x + rune(c) - '0' - continue - } - if c != ';' { - i-- - } - break - } - - if i <= 3 { // No characters matched. - b[dst] = b[src] - return dst + 1, src + 1 - } - - if 0x80 <= x && x <= 0x9F { - // Replace characters from Windows-1252 with UTF-8 equivalents. - x = replacementTable[x-0x80] - } else if x == 0 || (0xD800 <= x && x <= 0xDFFF) || x > 0x10FFFF { - // Replace invalid characters with the replacement character. - x = '\uFFFD' - } - - return dst + utf8.EncodeRune(b[dst:], x), src + i - } - - // Consume the maximum number of characters possible, with the - // consumed characters matching one of the named references. - - for i < len(s) { - c := s[i] - i++ - // Lower-cased characters are more common in entities, so we check for them first. - if 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || '0' <= c && c <= '9' { - continue - } - if c != ';' { - i-- - } - break - } - - entityName := string(s[1:i]) - if entityName == "" { - // No-op. - } else if attribute && entityName[len(entityName)-1] != ';' && len(s) > i && s[i] == '=' { - // No-op. - } else if x := entity[entityName]; x != 0 { - return dst + utf8.EncodeRune(b[dst:], x), src + i - } else if x := entity2[entityName]; x[0] != 0 { - dst1 := dst + utf8.EncodeRune(b[dst:], x[0]) - return dst1 + utf8.EncodeRune(b[dst1:], x[1]), src + i - } else if !attribute { - maxLen := len(entityName) - 1 - if maxLen > longestEntityWithoutSemicolon { - maxLen = longestEntityWithoutSemicolon - } - for j := maxLen; j > 1; j-- { - if x := entity[entityName[:j]]; x != 0 { - return dst + utf8.EncodeRune(b[dst:], x), src + j + 1 - } - } - } - - dst1, src1 = dst+i, src+i - copy(b[dst:dst1], b[src:src1]) - return dst1, src1 -} - -// unescape unescapes b's entities in-place, so that "a<b" becomes "a': - esc = ">" - case '"': - // """ is shorter than """. - esc = """ - case '\r': - esc = " " - default: - panic("unrecognized escape character") - } - s = s[i+1:] - if _, err := w.WriteString(esc); err != nil { - return err - } - i = strings.IndexAny(s, escapedChars) - } - _, err := w.WriteString(s) - return err -} - -// EscapeString escapes special characters like "<" to become "<". It -// escapes only five such characters: <, >, &, ' and ". -// UnescapeString(EscapeString(s)) == s always holds, but the converse isn't -// always true. -func EscapeString(s string) string { - if strings.IndexAny(s, escapedChars) == -1 { - return s - } - var buf bytes.Buffer - escape(&buf, s) - return buf.String() -} - -// UnescapeString unescapes entities like "<" to become "<". It unescapes a -// larger range of entities than EscapeString escapes. For example, "á" -// unescapes to "á", as does "á" and "&xE1;". -// UnescapeString(EscapeString(s)) == s always holds, but the converse isn't -// always true. -func UnescapeString(s string) string { - for _, c := range s { - if c == '&' { - return string(unescape([]byte(s), false)) - } - } - return s -} diff --git a/vendor/golang.org/x/net/html/escape_test.go b/vendor/golang.org/x/net/html/escape_test.go deleted file mode 100644 index b405d4b..0000000 --- a/vendor/golang.org/x/net/html/escape_test.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package html - -import "testing" - -type unescapeTest struct { - // A short description of the test case. - desc string - // The HTML text. - html string - // The unescaped text. - unescaped string -} - -var unescapeTests = []unescapeTest{ - // Handle no entities. - { - "copy", - "A\ttext\nstring", - "A\ttext\nstring", - }, - // Handle simple named entities. - { - "simple", - "& > <", - "& > <", - }, - // Handle hitting the end of the string. - { - "stringEnd", - "& &", - "& &", - }, - // Handle entities with two codepoints. - { - "multiCodepoint", - "text ⋛︀ blah", - "text \u22db\ufe00 blah", - }, - // Handle decimal numeric entities. - { - "decimalEntity", - "Delta = Δ ", - "Delta = Δ ", - }, - // Handle hexadecimal numeric entities. - { - "hexadecimalEntity", - "Lambda = λ = λ ", - "Lambda = λ = λ ", - }, - // Handle numeric early termination. - { - "numericEnds", - "&# &#x €43 © = ©f = ©", - "&# &#x €43 © = ©f = ©", - }, - // Handle numeric ISO-8859-1 entity replacements. - { - "numericReplacements", - "Footnote‡", - "Footnote‡", - }, -} - -func TestUnescape(t *testing.T) { - for _, tt := range unescapeTests { - unescaped := UnescapeString(tt.html) - if unescaped != tt.unescaped { - t.Errorf("TestUnescape %s: want %q, got %q", tt.desc, tt.unescaped, unescaped) - } - } -} - -func TestUnescapeEscape(t *testing.T) { - ss := []string{ - ``, - `abc def`, - `a & b`, - `a&b`, - `a & b`, - `"`, - `"`, - `"<&>"`, - `"<&>"`, - `3&5==1 && 0<1, "0<1", a+acute=á`, - `The special characters are: <, >, &, ' and "`, - } - for _, s := range ss { - if got := UnescapeString(EscapeString(s)); got != s { - t.Errorf("got %q want %q", got, s) - } - } -} diff --git a/vendor/golang.org/x/net/html/example_test.go b/vendor/golang.org/x/net/html/example_test.go deleted file mode 100644 index 0b06ed7..0000000 --- a/vendor/golang.org/x/net/html/example_test.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// This example demonstrates parsing HTML data and walking the resulting tree. -package html_test - -import ( - "fmt" - "log" - "strings" - - "golang.org/x/net/html" -) - -func ExampleParse() { - s := `

Links:

` - doc, err := html.Parse(strings.NewReader(s)) - if err != nil { - log.Fatal(err) - } - var f func(*html.Node) - f = func(n *html.Node) { - if n.Type == html.ElementNode && n.Data == "a" { - for _, a := range n.Attr { - if a.Key == "href" { - fmt.Println(a.Val) - break - } - } - } - for c := n.FirstChild; c != nil; c = c.NextSibling { - f(c) - } - } - f(doc) - // Output: - // foo - // /bar/baz -} diff --git a/vendor/golang.org/x/net/html/foreign.go b/vendor/golang.org/x/net/html/foreign.go deleted file mode 100644 index d3b3844..0000000 --- a/vendor/golang.org/x/net/html/foreign.go +++ /dev/null @@ -1,226 +0,0 @@ -// Copyright 2011 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 html - -import ( - "strings" -) - -func adjustAttributeNames(aa []Attribute, nameMap map[string]string) { - for i := range aa { - if newName, ok := nameMap[aa[i].Key]; ok { - aa[i].Key = newName - } - } -} - -func adjustForeignAttributes(aa []Attribute) { - for i, a := range aa { - if a.Key == "" || a.Key[0] != 'x' { - continue - } - switch a.Key { - case "xlink:actuate", "xlink:arcrole", "xlink:href", "xlink:role", "xlink:show", - "xlink:title", "xlink:type", "xml:base", "xml:lang", "xml:space", "xmlns:xlink": - j := strings.Index(a.Key, ":") - aa[i].Namespace = a.Key[:j] - aa[i].Key = a.Key[j+1:] - } - } -} - -func htmlIntegrationPoint(n *Node) bool { - if n.Type != ElementNode { - return false - } - switch n.Namespace { - case "math": - if n.Data == "annotation-xml" { - for _, a := range n.Attr { - if a.Key == "encoding" { - val := strings.ToLower(a.Val) - if val == "text/html" || val == "application/xhtml+xml" { - return true - } - } - } - } - case "svg": - switch n.Data { - case "desc", "foreignObject", "title": - return true - } - } - return false -} - -func mathMLTextIntegrationPoint(n *Node) bool { - if n.Namespace != "math" { - return false - } - switch n.Data { - case "mi", "mo", "mn", "ms", "mtext": - return true - } - return false -} - -// Section 12.2.5.5. -var breakout = map[string]bool{ - "b": true, - "big": true, - "blockquote": true, - "body": true, - "br": true, - "center": true, - "code": true, - "dd": true, - "div": true, - "dl": true, - "dt": true, - "em": true, - "embed": true, - "h1": true, - "h2": true, - "h3": true, - "h4": true, - "h5": true, - "h6": true, - "head": true, - "hr": true, - "i": true, - "img": true, - "li": true, - "listing": true, - "menu": true, - "meta": true, - "nobr": true, - "ol": true, - "p": true, - "pre": true, - "ruby": true, - "s": true, - "small": true, - "span": true, - "strong": true, - "strike": true, - "sub": true, - "sup": true, - "table": true, - "tt": true, - "u": true, - "ul": true, - "var": true, -} - -// Section 12.2.5.5. -var svgTagNameAdjustments = map[string]string{ - "altglyph": "altGlyph", - "altglyphdef": "altGlyphDef", - "altglyphitem": "altGlyphItem", - "animatecolor": "animateColor", - "animatemotion": "animateMotion", - "animatetransform": "animateTransform", - "clippath": "clipPath", - "feblend": "feBlend", - "fecolormatrix": "feColorMatrix", - "fecomponenttransfer": "feComponentTransfer", - "fecomposite": "feComposite", - "feconvolvematrix": "feConvolveMatrix", - "fediffuselighting": "feDiffuseLighting", - "fedisplacementmap": "feDisplacementMap", - "fedistantlight": "feDistantLight", - "feflood": "feFlood", - "fefunca": "feFuncA", - "fefuncb": "feFuncB", - "fefuncg": "feFuncG", - "fefuncr": "feFuncR", - "fegaussianblur": "feGaussianBlur", - "feimage": "feImage", - "femerge": "feMerge", - "femergenode": "feMergeNode", - "femorphology": "feMorphology", - "feoffset": "feOffset", - "fepointlight": "fePointLight", - "fespecularlighting": "feSpecularLighting", - "fespotlight": "feSpotLight", - "fetile": "feTile", - "feturbulence": "feTurbulence", - "foreignobject": "foreignObject", - "glyphref": "glyphRef", - "lineargradient": "linearGradient", - "radialgradient": "radialGradient", - "textpath": "textPath", -} - -// Section 12.2.5.1 -var mathMLAttributeAdjustments = map[string]string{ - "definitionurl": "definitionURL", -} - -var svgAttributeAdjustments = map[string]string{ - "attributename": "attributeName", - "attributetype": "attributeType", - "basefrequency": "baseFrequency", - "baseprofile": "baseProfile", - "calcmode": "calcMode", - "clippathunits": "clipPathUnits", - "contentscripttype": "contentScriptType", - "contentstyletype": "contentStyleType", - "diffuseconstant": "diffuseConstant", - "edgemode": "edgeMode", - "externalresourcesrequired": "externalResourcesRequired", - "filterres": "filterRes", - "filterunits": "filterUnits", - "glyphref": "glyphRef", - "gradienttransform": "gradientTransform", - "gradientunits": "gradientUnits", - "kernelmatrix": "kernelMatrix", - "kernelunitlength": "kernelUnitLength", - "keypoints": "keyPoints", - "keysplines": "keySplines", - "keytimes": "keyTimes", - "lengthadjust": "lengthAdjust", - "limitingconeangle": "limitingConeAngle", - "markerheight": "markerHeight", - "markerunits": "markerUnits", - "markerwidth": "markerWidth", - "maskcontentunits": "maskContentUnits", - "maskunits": "maskUnits", - "numoctaves": "numOctaves", - "pathlength": "pathLength", - "patterncontentunits": "patternContentUnits", - "patterntransform": "patternTransform", - "patternunits": "patternUnits", - "pointsatx": "pointsAtX", - "pointsaty": "pointsAtY", - "pointsatz": "pointsAtZ", - "preservealpha": "preserveAlpha", - "preserveaspectratio": "preserveAspectRatio", - "primitiveunits": "primitiveUnits", - "refx": "refX", - "refy": "refY", - "repeatcount": "repeatCount", - "repeatdur": "repeatDur", - "requiredextensions": "requiredExtensions", - "requiredfeatures": "requiredFeatures", - "specularconstant": "specularConstant", - "specularexponent": "specularExponent", - "spreadmethod": "spreadMethod", - "startoffset": "startOffset", - "stddeviation": "stdDeviation", - "stitchtiles": "stitchTiles", - "surfacescale": "surfaceScale", - "systemlanguage": "systemLanguage", - "tablevalues": "tableValues", - "targetx": "targetX", - "targety": "targetY", - "textlength": "textLength", - "viewbox": "viewBox", - "viewtarget": "viewTarget", - "xchannelselector": "xChannelSelector", - "ychannelselector": "yChannelSelector", - "zoomandpan": "zoomAndPan", -} diff --git a/vendor/golang.org/x/net/html/node.go b/vendor/golang.org/x/net/html/node.go deleted file mode 100644 index 26b657a..0000000 --- a/vendor/golang.org/x/net/html/node.go +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright 2011 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 html - -import ( - "golang.org/x/net/html/atom" -) - -// A NodeType is the type of a Node. -type NodeType uint32 - -const ( - ErrorNode NodeType = iota - TextNode - DocumentNode - ElementNode - CommentNode - DoctypeNode - scopeMarkerNode -) - -// Section 12.2.3.3 says "scope markers are inserted when entering applet -// elements, buttons, object elements, marquees, table cells, and table -// captions, and are used to prevent formatting from 'leaking'". -var scopeMarker = Node{Type: scopeMarkerNode} - -// A Node consists of a NodeType and some Data (tag name for element nodes, -// content for text) and are part of a tree of Nodes. Element nodes may also -// have a Namespace and contain a slice of Attributes. Data is unescaped, so -// that it looks like "a 0 { - return (*s)[i-1] - } - return nil -} - -// index returns the index of the top-most occurrence of n in the stack, or -1 -// if n is not present. -func (s *nodeStack) index(n *Node) int { - for i := len(*s) - 1; i >= 0; i-- { - if (*s)[i] == n { - return i - } - } - return -1 -} - -// insert inserts a node at the given index. -func (s *nodeStack) insert(i int, n *Node) { - (*s) = append(*s, nil) - copy((*s)[i+1:], (*s)[i:]) - (*s)[i] = n -} - -// remove removes a node from the stack. It is a no-op if n is not present. -func (s *nodeStack) remove(n *Node) { - i := s.index(n) - if i == -1 { - return - } - copy((*s)[i:], (*s)[i+1:]) - j := len(*s) - 1 - (*s)[j] = nil - *s = (*s)[:j] -} diff --git a/vendor/golang.org/x/net/html/node_test.go b/vendor/golang.org/x/net/html/node_test.go deleted file mode 100644 index 471102f..0000000 --- a/vendor/golang.org/x/net/html/node_test.go +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright 2010 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 html - -import ( - "fmt" -) - -// checkTreeConsistency checks that a node and its descendants are all -// consistent in their parent/child/sibling relationships. -func checkTreeConsistency(n *Node) error { - return checkTreeConsistency1(n, 0) -} - -func checkTreeConsistency1(n *Node, depth int) error { - if depth == 1e4 { - return fmt.Errorf("html: tree looks like it contains a cycle") - } - if err := checkNodeConsistency(n); err != nil { - return err - } - for c := n.FirstChild; c != nil; c = c.NextSibling { - if err := checkTreeConsistency1(c, depth+1); err != nil { - return err - } - } - return nil -} - -// checkNodeConsistency checks that a node's parent/child/sibling relationships -// are consistent. -func checkNodeConsistency(n *Node) error { - if n == nil { - return nil - } - - nParent := 0 - for p := n.Parent; p != nil; p = p.Parent { - nParent++ - if nParent == 1e4 { - return fmt.Errorf("html: parent list looks like an infinite loop") - } - } - - nForward := 0 - for c := n.FirstChild; c != nil; c = c.NextSibling { - nForward++ - if nForward == 1e6 { - return fmt.Errorf("html: forward list of children looks like an infinite loop") - } - if c.Parent != n { - return fmt.Errorf("html: inconsistent child/parent relationship") - } - } - - nBackward := 0 - for c := n.LastChild; c != nil; c = c.PrevSibling { - nBackward++ - if nBackward == 1e6 { - return fmt.Errorf("html: backward list of children looks like an infinite loop") - } - if c.Parent != n { - return fmt.Errorf("html: inconsistent child/parent relationship") - } - } - - if n.Parent != nil { - if n.Parent == n { - return fmt.Errorf("html: inconsistent parent relationship") - } - if n.Parent == n.FirstChild { - return fmt.Errorf("html: inconsistent parent/first relationship") - } - if n.Parent == n.LastChild { - return fmt.Errorf("html: inconsistent parent/last relationship") - } - if n.Parent == n.PrevSibling { - return fmt.Errorf("html: inconsistent parent/prev relationship") - } - if n.Parent == n.NextSibling { - return fmt.Errorf("html: inconsistent parent/next relationship") - } - - parentHasNAsAChild := false - for c := n.Parent.FirstChild; c != nil; c = c.NextSibling { - if c == n { - parentHasNAsAChild = true - break - } - } - if !parentHasNAsAChild { - return fmt.Errorf("html: inconsistent parent/child relationship") - } - } - - if n.PrevSibling != nil && n.PrevSibling.NextSibling != n { - return fmt.Errorf("html: inconsistent prev/next relationship") - } - if n.NextSibling != nil && n.NextSibling.PrevSibling != n { - return fmt.Errorf("html: inconsistent next/prev relationship") - } - - if (n.FirstChild == nil) != (n.LastChild == nil) { - return fmt.Errorf("html: inconsistent first/last relationship") - } - if n.FirstChild != nil && n.FirstChild == n.LastChild { - // We have a sole child. - if n.FirstChild.PrevSibling != nil || n.FirstChild.NextSibling != nil { - return fmt.Errorf("html: inconsistent sole child's sibling relationship") - } - } - - seen := map[*Node]bool{} - - var last *Node - for c := n.FirstChild; c != nil; c = c.NextSibling { - if seen[c] { - return fmt.Errorf("html: inconsistent repeated child") - } - seen[c] = true - last = c - } - if last != n.LastChild { - return fmt.Errorf("html: inconsistent last relationship") - } - - var first *Node - for c := n.LastChild; c != nil; c = c.PrevSibling { - if !seen[c] { - return fmt.Errorf("html: inconsistent missing child") - } - delete(seen, c) - first = c - } - if first != n.FirstChild { - return fmt.Errorf("html: inconsistent first relationship") - } - - if len(seen) != 0 { - return fmt.Errorf("html: inconsistent forwards/backwards child list") - } - - return nil -} diff --git a/vendor/golang.org/x/net/html/parse.go b/vendor/golang.org/x/net/html/parse.go deleted file mode 100644 index be4b2bf..0000000 --- a/vendor/golang.org/x/net/html/parse.go +++ /dev/null @@ -1,2094 +0,0 @@ -// Copyright 2010 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 html - -import ( - "errors" - "fmt" - "io" - "strings" - - a "golang.org/x/net/html/atom" -) - -// A parser implements the HTML5 parsing algorithm: -// https://html.spec.whatwg.org/multipage/syntax.html#tree-construction -type parser struct { - // tokenizer provides the tokens for the parser. - tokenizer *Tokenizer - // tok is the most recently read token. - tok Token - // Self-closing tags like
are treated as start tags, except that - // hasSelfClosingToken is set while they are being processed. - hasSelfClosingToken bool - // doc is the document root element. - doc *Node - // The stack of open elements (section 12.2.3.2) and active formatting - // elements (section 12.2.3.3). - oe, afe nodeStack - // Element pointers (section 12.2.3.4). - head, form *Node - // Other parsing state flags (section 12.2.3.5). - scripting, framesetOK bool - // im is the current insertion mode. - im insertionMode - // originalIM is the insertion mode to go back to after completing a text - // or inTableText insertion mode. - originalIM insertionMode - // fosterParenting is whether new elements should be inserted according to - // the foster parenting rules (section 12.2.5.3). - fosterParenting bool - // quirks is whether the parser is operating in "quirks mode." - quirks bool - // fragment is whether the parser is parsing an HTML fragment. - fragment bool - // context is the context element when parsing an HTML fragment - // (section 12.4). - context *Node -} - -func (p *parser) top() *Node { - if n := p.oe.top(); n != nil { - return n - } - return p.doc -} - -// Stop tags for use in popUntil. These come from section 12.2.3.2. -var ( - defaultScopeStopTags = map[string][]a.Atom{ - "": {a.Applet, a.Caption, a.Html, a.Table, a.Td, a.Th, a.Marquee, a.Object, a.Template}, - "math": {a.AnnotationXml, a.Mi, a.Mn, a.Mo, a.Ms, a.Mtext}, - "svg": {a.Desc, a.ForeignObject, a.Title}, - } -) - -type scope int - -const ( - defaultScope scope = iota - listItemScope - buttonScope - tableScope - tableRowScope - tableBodyScope - selectScope -) - -// popUntil pops the stack of open elements at the highest element whose tag -// is in matchTags, provided there is no higher element in the scope's stop -// tags (as defined in section 12.2.3.2). It returns whether or not there was -// such an element. If there was not, popUntil leaves the stack unchanged. -// -// For example, the set of stop tags for table scope is: "html", "table". If -// the stack was: -// ["html", "body", "font", "table", "b", "i", "u"] -// then popUntil(tableScope, "font") would return false, but -// popUntil(tableScope, "i") would return true and the stack would become: -// ["html", "body", "font", "table", "b"] -// -// If an element's tag is in both the stop tags and matchTags, then the stack -// will be popped and the function returns true (provided, of course, there was -// no higher element in the stack that was also in the stop tags). For example, -// popUntil(tableScope, "table") returns true and leaves: -// ["html", "body", "font"] -func (p *parser) popUntil(s scope, matchTags ...a.Atom) bool { - if i := p.indexOfElementInScope(s, matchTags...); i != -1 { - p.oe = p.oe[:i] - return true - } - return false -} - -// indexOfElementInScope returns the index in p.oe of the highest element whose -// tag is in matchTags that is in scope. If no matching element is in scope, it -// returns -1. -func (p *parser) indexOfElementInScope(s scope, matchTags ...a.Atom) int { - for i := len(p.oe) - 1; i >= 0; i-- { - tagAtom := p.oe[i].DataAtom - if p.oe[i].Namespace == "" { - for _, t := range matchTags { - if t == tagAtom { - return i - } - } - switch s { - case defaultScope: - // No-op. - case listItemScope: - if tagAtom == a.Ol || tagAtom == a.Ul { - return -1 - } - case buttonScope: - if tagAtom == a.Button { - return -1 - } - case tableScope: - if tagAtom == a.Html || tagAtom == a.Table { - return -1 - } - case selectScope: - if tagAtom != a.Optgroup && tagAtom != a.Option { - return -1 - } - default: - panic("unreachable") - } - } - switch s { - case defaultScope, listItemScope, buttonScope: - for _, t := range defaultScopeStopTags[p.oe[i].Namespace] { - if t == tagAtom { - return -1 - } - } - } - } - return -1 -} - -// elementInScope is like popUntil, except that it doesn't modify the stack of -// open elements. -func (p *parser) elementInScope(s scope, matchTags ...a.Atom) bool { - return p.indexOfElementInScope(s, matchTags...) != -1 -} - -// clearStackToContext pops elements off the stack of open elements until a -// scope-defined element is found. -func (p *parser) clearStackToContext(s scope) { - for i := len(p.oe) - 1; i >= 0; i-- { - tagAtom := p.oe[i].DataAtom - switch s { - case tableScope: - if tagAtom == a.Html || tagAtom == a.Table { - p.oe = p.oe[:i+1] - return - } - case tableRowScope: - if tagAtom == a.Html || tagAtom == a.Tr { - p.oe = p.oe[:i+1] - return - } - case tableBodyScope: - if tagAtom == a.Html || tagAtom == a.Tbody || tagAtom == a.Tfoot || tagAtom == a.Thead { - p.oe = p.oe[:i+1] - return - } - default: - panic("unreachable") - } - } -} - -// generateImpliedEndTags pops nodes off the stack of open elements as long as -// the top node has a tag name of dd, dt, li, option, optgroup, p, rp, or rt. -// If exceptions are specified, nodes with that name will not be popped off. -func (p *parser) generateImpliedEndTags(exceptions ...string) { - var i int -loop: - for i = len(p.oe) - 1; i >= 0; i-- { - n := p.oe[i] - if n.Type == ElementNode { - switch n.DataAtom { - case a.Dd, a.Dt, a.Li, a.Option, a.Optgroup, a.P, a.Rp, a.Rt: - for _, except := range exceptions { - if n.Data == except { - break loop - } - } - continue - } - } - break - } - - p.oe = p.oe[:i+1] -} - -// addChild adds a child node n to the top element, and pushes n onto the stack -// of open elements if it is an element node. -func (p *parser) addChild(n *Node) { - if p.shouldFosterParent() { - p.fosterParent(n) - } else { - p.top().AppendChild(n) - } - - if n.Type == ElementNode { - p.oe = append(p.oe, n) - } -} - -// shouldFosterParent returns whether the next node to be added should be -// foster parented. -func (p *parser) shouldFosterParent() bool { - if p.fosterParenting { - switch p.top().DataAtom { - case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr: - return true - } - } - return false -} - -// fosterParent adds a child node according to the foster parenting rules. -// Section 12.2.5.3, "foster parenting". -func (p *parser) fosterParent(n *Node) { - var table, parent, prev *Node - var i int - for i = len(p.oe) - 1; i >= 0; i-- { - if p.oe[i].DataAtom == a.Table { - table = p.oe[i] - break - } - } - - if table == nil { - // The foster parent is the html element. - parent = p.oe[0] - } else { - parent = table.Parent - } - if parent == nil { - parent = p.oe[i-1] - } - - if table != nil { - prev = table.PrevSibling - } else { - prev = parent.LastChild - } - if prev != nil && prev.Type == TextNode && n.Type == TextNode { - prev.Data += n.Data - return - } - - parent.InsertBefore(n, table) -} - -// addText adds text to the preceding node if it is a text node, or else it -// calls addChild with a new text node. -func (p *parser) addText(text string) { - if text == "" { - return - } - - if p.shouldFosterParent() { - p.fosterParent(&Node{ - Type: TextNode, - Data: text, - }) - return - } - - t := p.top() - if n := t.LastChild; n != nil && n.Type == TextNode { - n.Data += text - return - } - p.addChild(&Node{ - Type: TextNode, - Data: text, - }) -} - -// addElement adds a child element based on the current token. -func (p *parser) addElement() { - p.addChild(&Node{ - Type: ElementNode, - DataAtom: p.tok.DataAtom, - Data: p.tok.Data, - Attr: p.tok.Attr, - }) -} - -// Section 12.2.3.3. -func (p *parser) addFormattingElement() { - tagAtom, attr := p.tok.DataAtom, p.tok.Attr - p.addElement() - - // Implement the Noah's Ark clause, but with three per family instead of two. - identicalElements := 0 -findIdenticalElements: - for i := len(p.afe) - 1; i >= 0; i-- { - n := p.afe[i] - if n.Type == scopeMarkerNode { - break - } - if n.Type != ElementNode { - continue - } - if n.Namespace != "" { - continue - } - if n.DataAtom != tagAtom { - continue - } - if len(n.Attr) != len(attr) { - continue - } - compareAttributes: - for _, t0 := range n.Attr { - for _, t1 := range attr { - if t0.Key == t1.Key && t0.Namespace == t1.Namespace && t0.Val == t1.Val { - // Found a match for this attribute, continue with the next attribute. - continue compareAttributes - } - } - // If we get here, there is no attribute that matches a. - // Therefore the element is not identical to the new one. - continue findIdenticalElements - } - - identicalElements++ - if identicalElements >= 3 { - p.afe.remove(n) - } - } - - p.afe = append(p.afe, p.top()) -} - -// Section 12.2.3.3. -func (p *parser) clearActiveFormattingElements() { - for { - n := p.afe.pop() - if len(p.afe) == 0 || n.Type == scopeMarkerNode { - return - } - } -} - -// Section 12.2.3.3. -func (p *parser) reconstructActiveFormattingElements() { - n := p.afe.top() - if n == nil { - return - } - if n.Type == scopeMarkerNode || p.oe.index(n) != -1 { - return - } - i := len(p.afe) - 1 - for n.Type != scopeMarkerNode && p.oe.index(n) == -1 { - if i == 0 { - i = -1 - break - } - i-- - n = p.afe[i] - } - for { - i++ - clone := p.afe[i].clone() - p.addChild(clone) - p.afe[i] = clone - if i == len(p.afe)-1 { - break - } - } -} - -// Section 12.2.4. -func (p *parser) acknowledgeSelfClosingTag() { - p.hasSelfClosingToken = false -} - -// An insertion mode (section 12.2.3.1) is the state transition function from -// a particular state in the HTML5 parser's state machine. It updates the -// parser's fields depending on parser.tok (where ErrorToken means EOF). -// It returns whether the token was consumed. -type insertionMode func(*parser) bool - -// setOriginalIM sets the insertion mode to return to after completing a text or -// inTableText insertion mode. -// Section 12.2.3.1, "using the rules for". -func (p *parser) setOriginalIM() { - if p.originalIM != nil { - panic("html: bad parser state: originalIM was set twice") - } - p.originalIM = p.im -} - -// Section 12.2.3.1, "reset the insertion mode". -func (p *parser) resetInsertionMode() { - for i := len(p.oe) - 1; i >= 0; i-- { - n := p.oe[i] - if i == 0 && p.context != nil { - n = p.context - } - - switch n.DataAtom { - case a.Select: - p.im = inSelectIM - case a.Td, a.Th: - p.im = inCellIM - case a.Tr: - p.im = inRowIM - case a.Tbody, a.Thead, a.Tfoot: - p.im = inTableBodyIM - case a.Caption: - p.im = inCaptionIM - case a.Colgroup: - p.im = inColumnGroupIM - case a.Table: - p.im = inTableIM - case a.Head: - p.im = inBodyIM - case a.Body: - p.im = inBodyIM - case a.Frameset: - p.im = inFramesetIM - case a.Html: - p.im = beforeHeadIM - default: - continue - } - return - } - p.im = inBodyIM -} - -const whitespace = " \t\r\n\f" - -// Section 12.2.5.4.1. -func initialIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace) - if len(p.tok.Data) == 0 { - // It was all whitespace, so ignore it. - return true - } - case CommentToken: - p.doc.AppendChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - n, quirks := parseDoctype(p.tok.Data) - p.doc.AppendChild(n) - p.quirks = quirks - p.im = beforeHTMLIM - return true - } - p.quirks = true - p.im = beforeHTMLIM - return false -} - -// Section 12.2.5.4.2. -func beforeHTMLIM(p *parser) bool { - switch p.tok.Type { - case DoctypeToken: - // Ignore the token. - return true - case TextToken: - p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace) - if len(p.tok.Data) == 0 { - // It was all whitespace, so ignore it. - return true - } - case StartTagToken: - if p.tok.DataAtom == a.Html { - p.addElement() - p.im = beforeHeadIM - return true - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Head, a.Body, a.Html, a.Br: - p.parseImpliedToken(StartTagToken, a.Html, a.Html.String()) - return false - default: - // Ignore the token. - return true - } - case CommentToken: - p.doc.AppendChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - } - p.parseImpliedToken(StartTagToken, a.Html, a.Html.String()) - return false -} - -// Section 12.2.5.4.3. -func beforeHeadIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace) - if len(p.tok.Data) == 0 { - // It was all whitespace, so ignore it. - return true - } - case StartTagToken: - switch p.tok.DataAtom { - case a.Head: - p.addElement() - p.head = p.top() - p.im = inHeadIM - return true - case a.Html: - return inBodyIM(p) - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Head, a.Body, a.Html, a.Br: - p.parseImpliedToken(StartTagToken, a.Head, a.Head.String()) - return false - default: - // Ignore the token. - return true - } - case CommentToken: - p.addChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - // Ignore the token. - return true - } - - p.parseImpliedToken(StartTagToken, a.Head, a.Head.String()) - return false -} - -// Section 12.2.5.4.4. -func inHeadIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - s := strings.TrimLeft(p.tok.Data, whitespace) - if len(s) < len(p.tok.Data) { - // Add the initial whitespace to the current node. - p.addText(p.tok.Data[:len(p.tok.Data)-len(s)]) - if s == "" { - return true - } - p.tok.Data = s - } - case StartTagToken: - switch p.tok.DataAtom { - case a.Html: - return inBodyIM(p) - case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta: - p.addElement() - p.oe.pop() - p.acknowledgeSelfClosingTag() - return true - case a.Script, a.Title, a.Noscript, a.Noframes, a.Style: - p.addElement() - p.setOriginalIM() - p.im = textIM - return true - case a.Head: - // Ignore the token. - return true - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Head: - n := p.oe.pop() - if n.DataAtom != a.Head { - panic("html: bad parser state: element not found, in the in-head insertion mode") - } - p.im = afterHeadIM - return true - case a.Body, a.Html, a.Br: - p.parseImpliedToken(EndTagToken, a.Head, a.Head.String()) - return false - default: - // Ignore the token. - return true - } - case CommentToken: - p.addChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - // Ignore the token. - return true - } - - p.parseImpliedToken(EndTagToken, a.Head, a.Head.String()) - return false -} - -// Section 12.2.5.4.6. -func afterHeadIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - s := strings.TrimLeft(p.tok.Data, whitespace) - if len(s) < len(p.tok.Data) { - // Add the initial whitespace to the current node. - p.addText(p.tok.Data[:len(p.tok.Data)-len(s)]) - if s == "" { - return true - } - p.tok.Data = s - } - case StartTagToken: - switch p.tok.DataAtom { - case a.Html: - return inBodyIM(p) - case a.Body: - p.addElement() - p.framesetOK = false - p.im = inBodyIM - return true - case a.Frameset: - p.addElement() - p.im = inFramesetIM - return true - case a.Base, a.Basefont, a.Bgsound, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Title: - p.oe = append(p.oe, p.head) - defer p.oe.remove(p.head) - return inHeadIM(p) - case a.Head: - // Ignore the token. - return true - } - case EndTagToken: - switch p.tok.DataAtom { - case a.Body, a.Html, a.Br: - // Drop down to creating an implied tag. - default: - // Ignore the token. - return true - } - case CommentToken: - p.addChild(&Node{ - Type: CommentNode, - Data: p.tok.Data, - }) - return true - case DoctypeToken: - // Ignore the token. - return true - } - - p.parseImpliedToken(StartTagToken, a.Body, a.Body.String()) - p.framesetOK = true - return false -} - -// copyAttributes copies attributes of src not found on dst to dst. -func copyAttributes(dst *Node, src Token) { - if len(src.Attr) == 0 { - return - } - attr := map[string]string{} - for _, t := range dst.Attr { - attr[t.Key] = t.Val - } - for _, t := range src.Attr { - if _, ok := attr[t.Key]; !ok { - dst.Attr = append(dst.Attr, t) - attr[t.Key] = t.Val - } - } -} - -// Section 12.2.5.4.7. -func inBodyIM(p *parser) bool { - switch p.tok.Type { - case TextToken: - d := p.tok.Data - switch n := p.oe.top(); n.DataAtom { - case a.Pre, a.Listing: - if n.FirstChild == nil { - // Ignore a newline at the start of a
 block.
-				if d != "" && d[0] == '\r' {
-					d = d[1:]
-				}
-				if d != "" && d[0] == '\n' {
-					d = d[1:]
-				}
-			}
-		}
-		d = strings.Replace(d, "\x00", "", -1)
-		if d == "" {
-			return true
-		}
-		p.reconstructActiveFormattingElements()
-		p.addText(d)
-		if p.framesetOK && strings.TrimLeft(d, whitespace) != "" {
-			// There were non-whitespace characters inserted.
-			p.framesetOK = false
-		}
-	case StartTagToken:
-		switch p.tok.DataAtom {
-		case a.Html:
-			copyAttributes(p.oe[0], p.tok)
-		case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Title:
-			return inHeadIM(p)
-		case a.Body:
-			if len(p.oe) >= 2 {
-				body := p.oe[1]
-				if body.Type == ElementNode && body.DataAtom == a.Body {
-					p.framesetOK = false
-					copyAttributes(body, p.tok)
-				}
-			}
-		case a.Frameset:
-			if !p.framesetOK || len(p.oe) < 2 || p.oe[1].DataAtom != a.Body {
-				// Ignore the token.
-				return true
-			}
-			body := p.oe[1]
-			if body.Parent != nil {
-				body.Parent.RemoveChild(body)
-			}
-			p.oe = p.oe[:1]
-			p.addElement()
-			p.im = inFramesetIM
-			return true
-		case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
-			p.popUntil(buttonScope, a.P)
-			switch n := p.top(); n.DataAtom {
-			case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
-				p.oe.pop()
-			}
-			p.addElement()
-		case a.Pre, a.Listing:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-			// The newline, if any, will be dealt with by the TextToken case.
-			p.framesetOK = false
-		case a.Form:
-			if p.form == nil {
-				p.popUntil(buttonScope, a.P)
-				p.addElement()
-				p.form = p.top()
-			}
-		case a.Li:
-			p.framesetOK = false
-			for i := len(p.oe) - 1; i >= 0; i-- {
-				node := p.oe[i]
-				switch node.DataAtom {
-				case a.Li:
-					p.oe = p.oe[:i]
-				case a.Address, a.Div, a.P:
-					continue
-				default:
-					if !isSpecialElement(node) {
-						continue
-					}
-				}
-				break
-			}
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.Dd, a.Dt:
-			p.framesetOK = false
-			for i := len(p.oe) - 1; i >= 0; i-- {
-				node := p.oe[i]
-				switch node.DataAtom {
-				case a.Dd, a.Dt:
-					p.oe = p.oe[:i]
-				case a.Address, a.Div, a.P:
-					continue
-				default:
-					if !isSpecialElement(node) {
-						continue
-					}
-				}
-				break
-			}
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.Plaintext:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-		case a.Button:
-			p.popUntil(defaultScope, a.Button)
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.framesetOK = false
-		case a.A:
-			for i := len(p.afe) - 1; i >= 0 && p.afe[i].Type != scopeMarkerNode; i-- {
-				if n := p.afe[i]; n.Type == ElementNode && n.DataAtom == a.A {
-					p.inBodyEndTagFormatting(a.A)
-					p.oe.remove(n)
-					p.afe.remove(n)
-					break
-				}
-			}
-			p.reconstructActiveFormattingElements()
-			p.addFormattingElement()
-		case a.B, a.Big, a.Code, a.Em, a.Font, a.I, a.S, a.Small, a.Strike, a.Strong, a.Tt, a.U:
-			p.reconstructActiveFormattingElements()
-			p.addFormattingElement()
-		case a.Nobr:
-			p.reconstructActiveFormattingElements()
-			if p.elementInScope(defaultScope, a.Nobr) {
-				p.inBodyEndTagFormatting(a.Nobr)
-				p.reconstructActiveFormattingElements()
-			}
-			p.addFormattingElement()
-		case a.Applet, a.Marquee, a.Object:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.afe = append(p.afe, &scopeMarker)
-			p.framesetOK = false
-		case a.Table:
-			if !p.quirks {
-				p.popUntil(buttonScope, a.P)
-			}
-			p.addElement()
-			p.framesetOK = false
-			p.im = inTableIM
-			return true
-		case a.Area, a.Br, a.Embed, a.Img, a.Input, a.Keygen, a.Wbr:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.oe.pop()
-			p.acknowledgeSelfClosingTag()
-			if p.tok.DataAtom == a.Input {
-				for _, t := range p.tok.Attr {
-					if t.Key == "type" {
-						if strings.ToLower(t.Val) == "hidden" {
-							// Skip setting framesetOK = false
-							return true
-						}
-					}
-				}
-			}
-			p.framesetOK = false
-		case a.Param, a.Source, a.Track:
-			p.addElement()
-			p.oe.pop()
-			p.acknowledgeSelfClosingTag()
-		case a.Hr:
-			p.popUntil(buttonScope, a.P)
-			p.addElement()
-			p.oe.pop()
-			p.acknowledgeSelfClosingTag()
-			p.framesetOK = false
-		case a.Image:
-			p.tok.DataAtom = a.Img
-			p.tok.Data = a.Img.String()
-			return false
-		case a.Isindex:
-			if p.form != nil {
-				// Ignore the token.
-				return true
-			}
-			action := ""
-			prompt := "This is a searchable index. Enter search keywords: "
-			attr := []Attribute{{Key: "name", Val: "isindex"}}
-			for _, t := range p.tok.Attr {
-				switch t.Key {
-				case "action":
-					action = t.Val
-				case "name":
-					// Ignore the attribute.
-				case "prompt":
-					prompt = t.Val
-				default:
-					attr = append(attr, t)
-				}
-			}
-			p.acknowledgeSelfClosingTag()
-			p.popUntil(buttonScope, a.P)
-			p.parseImpliedToken(StartTagToken, a.Form, a.Form.String())
-			if action != "" {
-				p.form.Attr = []Attribute{{Key: "action", Val: action}}
-			}
-			p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
-			p.parseImpliedToken(StartTagToken, a.Label, a.Label.String())
-			p.addText(prompt)
-			p.addChild(&Node{
-				Type:     ElementNode,
-				DataAtom: a.Input,
-				Data:     a.Input.String(),
-				Attr:     attr,
-			})
-			p.oe.pop()
-			p.parseImpliedToken(EndTagToken, a.Label, a.Label.String())
-			p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
-			p.parseImpliedToken(EndTagToken, a.Form, a.Form.String())
-		case a.Textarea:
-			p.addElement()
-			p.setOriginalIM()
-			p.framesetOK = false
-			p.im = textIM
-		case a.Xmp:
-			p.popUntil(buttonScope, a.P)
-			p.reconstructActiveFormattingElements()
-			p.framesetOK = false
-			p.addElement()
-			p.setOriginalIM()
-			p.im = textIM
-		case a.Iframe:
-			p.framesetOK = false
-			p.addElement()
-			p.setOriginalIM()
-			p.im = textIM
-		case a.Noembed, a.Noscript:
-			p.addElement()
-			p.setOriginalIM()
-			p.im = textIM
-		case a.Select:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-			p.framesetOK = false
-			p.im = inSelectIM
-			return true
-		case a.Optgroup, a.Option:
-			if p.top().DataAtom == a.Option {
-				p.oe.pop()
-			}
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-		case a.Rp, a.Rt:
-			if p.elementInScope(defaultScope, a.Ruby) {
-				p.generateImpliedEndTags()
-			}
-			p.addElement()
-		case a.Math, a.Svg:
-			p.reconstructActiveFormattingElements()
-			if p.tok.DataAtom == a.Math {
-				adjustAttributeNames(p.tok.Attr, mathMLAttributeAdjustments)
-			} else {
-				adjustAttributeNames(p.tok.Attr, svgAttributeAdjustments)
-			}
-			adjustForeignAttributes(p.tok.Attr)
-			p.addElement()
-			p.top().Namespace = p.tok.Data
-			if p.hasSelfClosingToken {
-				p.oe.pop()
-				p.acknowledgeSelfClosingTag()
-			}
-			return true
-		case a.Caption, a.Col, a.Colgroup, a.Frame, a.Head, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
-			// Ignore the token.
-		default:
-			p.reconstructActiveFormattingElements()
-			p.addElement()
-		}
-	case EndTagToken:
-		switch p.tok.DataAtom {
-		case a.Body:
-			if p.elementInScope(defaultScope, a.Body) {
-				p.im = afterBodyIM
-			}
-		case a.Html:
-			if p.elementInScope(defaultScope, a.Body) {
-				p.parseImpliedToken(EndTagToken, a.Body, a.Body.String())
-				return false
-			}
-			return true
-		case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul:
-			p.popUntil(defaultScope, p.tok.DataAtom)
-		case a.Form:
-			node := p.form
-			p.form = nil
-			i := p.indexOfElementInScope(defaultScope, a.Form)
-			if node == nil || i == -1 || p.oe[i] != node {
-				// Ignore the token.
-				return true
-			}
-			p.generateImpliedEndTags()
-			p.oe.remove(node)
-		case a.P:
-			if !p.elementInScope(buttonScope, a.P) {
-				p.parseImpliedToken(StartTagToken, a.P, a.P.String())
-			}
-			p.popUntil(buttonScope, a.P)
-		case a.Li:
-			p.popUntil(listItemScope, a.Li)
-		case a.Dd, a.Dt:
-			p.popUntil(defaultScope, p.tok.DataAtom)
-		case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
-			p.popUntil(defaultScope, a.H1, a.H2, a.H3, a.H4, a.H5, a.H6)
-		case a.A, a.B, a.Big, a.Code, a.Em, a.Font, a.I, a.Nobr, a.S, a.Small, a.Strike, a.Strong, a.Tt, a.U:
-			p.inBodyEndTagFormatting(p.tok.DataAtom)
-		case a.Applet, a.Marquee, a.Object:
-			if p.popUntil(defaultScope, p.tok.DataAtom) {
-				p.clearActiveFormattingElements()
-			}
-		case a.Br:
-			p.tok.Type = StartTagToken
-			return false
-		default:
-			p.inBodyEndTagOther(p.tok.DataAtom)
-		}
-	case CommentToken:
-		p.addChild(&Node{
-			Type: CommentNode,
-			Data: p.tok.Data,
-		})
-	}
-
-	return true
-}
-
-func (p *parser) inBodyEndTagFormatting(tagAtom a.Atom) {
-	// This is the "adoption agency" algorithm, described at
-	// https://html.spec.whatwg.org/multipage/syntax.html#adoptionAgency
-
-	// TODO: this is a fairly literal line-by-line translation of that algorithm.
-	// Once the code successfully parses the comprehensive test suite, we should
-	// refactor this code to be more idiomatic.
-
-	// Steps 1-4. The outer loop.
-	for i := 0; i < 8; i++ {
-		// Step 5. Find the formatting element.
-		var formattingElement *Node
-		for j := len(p.afe) - 1; j >= 0; j-- {
-			if p.afe[j].Type == scopeMarkerNode {
-				break
-			}
-			if p.afe[j].DataAtom == tagAtom {
-				formattingElement = p.afe[j]
-				break
-			}
-		}
-		if formattingElement == nil {
-			p.inBodyEndTagOther(tagAtom)
-			return
-		}
-		feIndex := p.oe.index(formattingElement)
-		if feIndex == -1 {
-			p.afe.remove(formattingElement)
-			return
-		}
-		if !p.elementInScope(defaultScope, tagAtom) {
-			// Ignore the tag.
-			return
-		}
-
-		// Steps 9-10. Find the furthest block.
-		var furthestBlock *Node
-		for _, e := range p.oe[feIndex:] {
-			if isSpecialElement(e) {
-				furthestBlock = e
-				break
-			}
-		}
-		if furthestBlock == nil {
-			e := p.oe.pop()
-			for e != formattingElement {
-				e = p.oe.pop()
-			}
-			p.afe.remove(e)
-			return
-		}
-
-		// Steps 11-12. Find the common ancestor and bookmark node.
-		commonAncestor := p.oe[feIndex-1]
-		bookmark := p.afe.index(formattingElement)
-
-		// Step 13. The inner loop. Find the lastNode to reparent.
-		lastNode := furthestBlock
-		node := furthestBlock
-		x := p.oe.index(node)
-		// Steps 13.1-13.2
-		for j := 0; j < 3; j++ {
-			// Step 13.3.
-			x--
-			node = p.oe[x]
-			// Step 13.4 - 13.5.
-			if p.afe.index(node) == -1 {
-				p.oe.remove(node)
-				continue
-			}
-			// Step 13.6.
-			if node == formattingElement {
-				break
-			}
-			// Step 13.7.
-			clone := node.clone()
-			p.afe[p.afe.index(node)] = clone
-			p.oe[p.oe.index(node)] = clone
-			node = clone
-			// Step 13.8.
-			if lastNode == furthestBlock {
-				bookmark = p.afe.index(node) + 1
-			}
-			// Step 13.9.
-			if lastNode.Parent != nil {
-				lastNode.Parent.RemoveChild(lastNode)
-			}
-			node.AppendChild(lastNode)
-			// Step 13.10.
-			lastNode = node
-		}
-
-		// Step 14. Reparent lastNode to the common ancestor,
-		// or for misnested table nodes, to the foster parent.
-		if lastNode.Parent != nil {
-			lastNode.Parent.RemoveChild(lastNode)
-		}
-		switch commonAncestor.DataAtom {
-		case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr:
-			p.fosterParent(lastNode)
-		default:
-			commonAncestor.AppendChild(lastNode)
-		}
-
-		// Steps 15-17. Reparent nodes from the furthest block's children
-		// to a clone of the formatting element.
-		clone := formattingElement.clone()
-		reparentChildren(clone, furthestBlock)
-		furthestBlock.AppendChild(clone)
-
-		// Step 18. Fix up the list of active formatting elements.
-		if oldLoc := p.afe.index(formattingElement); oldLoc != -1 && oldLoc < bookmark {
-			// Move the bookmark with the rest of the list.
-			bookmark--
-		}
-		p.afe.remove(formattingElement)
-		p.afe.insert(bookmark, clone)
-
-		// Step 19. Fix up the stack of open elements.
-		p.oe.remove(formattingElement)
-		p.oe.insert(p.oe.index(furthestBlock)+1, clone)
-	}
-}
-
-// inBodyEndTagOther performs the "any other end tag" algorithm for inBodyIM.
-// "Any other end tag" handling from 12.2.5.5 The rules for parsing tokens in foreign content
-// https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inforeign
-func (p *parser) inBodyEndTagOther(tagAtom a.Atom) {
-	for i := len(p.oe) - 1; i >= 0; i-- {
-		if p.oe[i].DataAtom == tagAtom {
-			p.oe = p.oe[:i]
-			break
-		}
-		if isSpecialElement(p.oe[i]) {
-			break
-		}
-	}
-}
-
-// Section 12.2.5.4.8.
-func textIM(p *parser) bool {
-	switch p.tok.Type {
-	case ErrorToken:
-		p.oe.pop()
-	case TextToken:
-		d := p.tok.Data
-		if n := p.oe.top(); n.DataAtom == a.Textarea && n.FirstChild == nil {
-			// Ignore a newline at the start of a -->
-#errors
-#document
-| 
-|   
-|   
-|     -->
-#errors
-#document
-| 
-|   
-|   
-|     
-#errors
-Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE.
-#document
-| 
-|   
-|   
-|     
-#errors
-Line: 1 Col: 9 Unexpected end tag (strong). Expected DOCTYPE.
-Line: 1 Col: 9 Unexpected end tag (strong) after the (implied) root element.
-Line: 1 Col: 13 Unexpected end tag (b) after the (implied) root element.
-Line: 1 Col: 18 Unexpected end tag (em) after the (implied) root element.
-Line: 1 Col: 22 Unexpected end tag (i) after the (implied) root element.
-Line: 1 Col: 26 Unexpected end tag (u) after the (implied) root element.
-Line: 1 Col: 35 Unexpected end tag (strike) after the (implied) root element.
-Line: 1 Col: 39 Unexpected end tag (s) after the (implied) root element.
-Line: 1 Col: 47 Unexpected end tag (blink) after the (implied) root element.
-Line: 1 Col: 52 Unexpected end tag (tt) after the (implied) root element.
-Line: 1 Col: 58 Unexpected end tag (pre) after the (implied) root element.
-Line: 1 Col: 64 Unexpected end tag (big) after the (implied) root element.
-Line: 1 Col: 72 Unexpected end tag (small) after the (implied) root element.
-Line: 1 Col: 79 Unexpected end tag (font) after the (implied) root element.
-Line: 1 Col: 88 Unexpected end tag (select) after the (implied) root element.
-Line: 1 Col: 93 Unexpected end tag (h1) after the (implied) root element.
-Line: 1 Col: 98 Unexpected end tag (h2) after the (implied) root element.
-Line: 1 Col: 103 Unexpected end tag (h3) after the (implied) root element.
-Line: 1 Col: 108 Unexpected end tag (h4) after the (implied) root element.
-Line: 1 Col: 113 Unexpected end tag (h5) after the (implied) root element.
-Line: 1 Col: 118 Unexpected end tag (h6) after the (implied) root element.
-Line: 1 Col: 125 Unexpected end tag (body) after the (implied) root element.
-Line: 1 Col: 130 Unexpected end tag (br). Treated as br element.
-Line: 1 Col: 134 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 140 This element (img) has no end tag.
-Line: 1 Col: 148 Unexpected end tag (title). Ignored.
-Line: 1 Col: 155 Unexpected end tag (span). Ignored.
-Line: 1 Col: 163 Unexpected end tag (style). Ignored.
-Line: 1 Col: 172 Unexpected end tag (script). Ignored.
-Line: 1 Col: 180 Unexpected end tag (table). Ignored.
-Line: 1 Col: 185 Unexpected end tag (th). Ignored.
-Line: 1 Col: 190 Unexpected end tag (td). Ignored.
-Line: 1 Col: 195 Unexpected end tag (tr). Ignored.
-Line: 1 Col: 203 This element (frame) has no end tag.
-Line: 1 Col: 210 This element (area) has no end tag.
-Line: 1 Col: 217 Unexpected end tag (link). Ignored.
-Line: 1 Col: 225 This element (param) has no end tag.
-Line: 1 Col: 230 This element (hr) has no end tag.
-Line: 1 Col: 238 This element (input) has no end tag.
-Line: 1 Col: 244 Unexpected end tag (col). Ignored.
-Line: 1 Col: 251 Unexpected end tag (base). Ignored.
-Line: 1 Col: 258 Unexpected end tag (meta). Ignored.
-Line: 1 Col: 269 This element (basefont) has no end tag.
-Line: 1 Col: 279 This element (bgsound) has no end tag.
-Line: 1 Col: 287 This element (embed) has no end tag.
-Line: 1 Col: 296 This element (spacer) has no end tag.
-Line: 1 Col: 300 Unexpected end tag (p). Ignored.
-Line: 1 Col: 305 End tag (dd) seen too early. Expected other end tag.
-Line: 1 Col: 310 End tag (dt) seen too early. Expected other end tag.
-Line: 1 Col: 320 Unexpected end tag (caption). Ignored.
-Line: 1 Col: 331 Unexpected end tag (colgroup). Ignored.
-Line: 1 Col: 339 Unexpected end tag (tbody). Ignored.
-Line: 1 Col: 347 Unexpected end tag (tfoot). Ignored.
-Line: 1 Col: 355 Unexpected end tag (thead). Ignored.
-Line: 1 Col: 365 End tag (address) seen too early. Expected other end tag.
-Line: 1 Col: 378 End tag (blockquote) seen too early. Expected other end tag.
-Line: 1 Col: 387 End tag (center) seen too early. Expected other end tag.
-Line: 1 Col: 393 Unexpected end tag (dir). Ignored.
-Line: 1 Col: 399 End tag (div) seen too early. Expected other end tag.
-Line: 1 Col: 404 End tag (dl) seen too early. Expected other end tag.
-Line: 1 Col: 415 End tag (fieldset) seen too early. Expected other end tag.
-Line: 1 Col: 425 End tag (listing) seen too early. Expected other end tag.
-Line: 1 Col: 432 End tag (menu) seen too early. Expected other end tag.
-Line: 1 Col: 437 End tag (ol) seen too early. Expected other end tag.
-Line: 1 Col: 442 End tag (ul) seen too early. Expected other end tag.
-Line: 1 Col: 447 End tag (li) seen too early. Expected other end tag.
-Line: 1 Col: 454 End tag (nobr) violates step 1, paragraph 1 of the adoption agency algorithm.
-Line: 1 Col: 460 This element (wbr) has no end tag.
-Line: 1 Col: 476 End tag (button) seen too early. Expected other end tag.
-Line: 1 Col: 486 End tag (marquee) seen too early. Expected other end tag.
-Line: 1 Col: 495 End tag (object) seen too early. Expected other end tag.
-Line: 1 Col: 513 Unexpected end tag (html). Ignored.
-Line: 1 Col: 513 Unexpected end tag (frameset). Ignored.
-Line: 1 Col: 520 Unexpected end tag (head). Ignored.
-Line: 1 Col: 529 Unexpected end tag (iframe). Ignored.
-Line: 1 Col: 537 This element (image) has no end tag.
-Line: 1 Col: 547 This element (isindex) has no end tag.
-Line: 1 Col: 557 Unexpected end tag (noembed). Ignored.
-Line: 1 Col: 568 Unexpected end tag (noframes). Ignored.
-Line: 1 Col: 579 Unexpected end tag (noscript). Ignored.
-Line: 1 Col: 590 Unexpected end tag (optgroup). Ignored.
-Line: 1 Col: 599 Unexpected end tag (option). Ignored.
-Line: 1 Col: 611 Unexpected end tag (plaintext). Ignored.
-Line: 1 Col: 622 Unexpected end tag (textarea). Ignored.
-#document
-| 
-|   
-|   
-|     
-|

- -#data -

-#errors -Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE. -Line: 1 Col: 20 Unexpected end tag (strong) in table context caused voodoo mode. -Line: 1 Col: 20 End tag (strong) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 24 Unexpected end tag (b) in table context caused voodoo mode. -Line: 1 Col: 24 End tag (b) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 29 Unexpected end tag (em) in table context caused voodoo mode. -Line: 1 Col: 29 End tag (em) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 33 Unexpected end tag (i) in table context caused voodoo mode. -Line: 1 Col: 33 End tag (i) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 37 Unexpected end tag (u) in table context caused voodoo mode. -Line: 1 Col: 37 End tag (u) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 46 Unexpected end tag (strike) in table context caused voodoo mode. -Line: 1 Col: 46 End tag (strike) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 50 Unexpected end tag (s) in table context caused voodoo mode. -Line: 1 Col: 50 End tag (s) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 58 Unexpected end tag (blink) in table context caused voodoo mode. -Line: 1 Col: 58 Unexpected end tag (blink). Ignored. -Line: 1 Col: 63 Unexpected end tag (tt) in table context caused voodoo mode. -Line: 1 Col: 63 End tag (tt) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 69 Unexpected end tag (pre) in table context caused voodoo mode. -Line: 1 Col: 69 End tag (pre) seen too early. Expected other end tag. -Line: 1 Col: 75 Unexpected end tag (big) in table context caused voodoo mode. -Line: 1 Col: 75 End tag (big) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 83 Unexpected end tag (small) in table context caused voodoo mode. -Line: 1 Col: 83 End tag (small) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 90 Unexpected end tag (font) in table context caused voodoo mode. -Line: 1 Col: 90 End tag (font) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 99 Unexpected end tag (select) in table context caused voodoo mode. -Line: 1 Col: 99 Unexpected end tag (select). Ignored. -Line: 1 Col: 104 Unexpected end tag (h1) in table context caused voodoo mode. -Line: 1 Col: 104 End tag (h1) seen too early. Expected other end tag. -Line: 1 Col: 109 Unexpected end tag (h2) in table context caused voodoo mode. -Line: 1 Col: 109 End tag (h2) seen too early. Expected other end tag. -Line: 1 Col: 114 Unexpected end tag (h3) in table context caused voodoo mode. -Line: 1 Col: 114 End tag (h3) seen too early. Expected other end tag. -Line: 1 Col: 119 Unexpected end tag (h4) in table context caused voodoo mode. -Line: 1 Col: 119 End tag (h4) seen too early. Expected other end tag. -Line: 1 Col: 124 Unexpected end tag (h5) in table context caused voodoo mode. -Line: 1 Col: 124 End tag (h5) seen too early. Expected other end tag. -Line: 1 Col: 129 Unexpected end tag (h6) in table context caused voodoo mode. -Line: 1 Col: 129 End tag (h6) seen too early. Expected other end tag. -Line: 1 Col: 136 Unexpected end tag (body) in the table row phase. Ignored. -Line: 1 Col: 141 Unexpected end tag (br) in table context caused voodoo mode. -Line: 1 Col: 141 Unexpected end tag (br). Treated as br element. -Line: 1 Col: 145 Unexpected end tag (a) in table context caused voodoo mode. -Line: 1 Col: 145 End tag (a) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 151 Unexpected end tag (img) in table context caused voodoo mode. -Line: 1 Col: 151 This element (img) has no end tag. -Line: 1 Col: 159 Unexpected end tag (title) in table context caused voodoo mode. -Line: 1 Col: 159 Unexpected end tag (title). Ignored. -Line: 1 Col: 166 Unexpected end tag (span) in table context caused voodoo mode. -Line: 1 Col: 166 Unexpected end tag (span). Ignored. -Line: 1 Col: 174 Unexpected end tag (style) in table context caused voodoo mode. -Line: 1 Col: 174 Unexpected end tag (style). Ignored. -Line: 1 Col: 183 Unexpected end tag (script) in table context caused voodoo mode. -Line: 1 Col: 183 Unexpected end tag (script). Ignored. -Line: 1 Col: 196 Unexpected end tag (th). Ignored. -Line: 1 Col: 201 Unexpected end tag (td). Ignored. -Line: 1 Col: 206 Unexpected end tag (tr). Ignored. -Line: 1 Col: 214 This element (frame) has no end tag. -Line: 1 Col: 221 This element (area) has no end tag. -Line: 1 Col: 228 Unexpected end tag (link). Ignored. -Line: 1 Col: 236 This element (param) has no end tag. -Line: 1 Col: 241 This element (hr) has no end tag. -Line: 1 Col: 249 This element (input) has no end tag. -Line: 1 Col: 255 Unexpected end tag (col). Ignored. -Line: 1 Col: 262 Unexpected end tag (base). Ignored. -Line: 1 Col: 269 Unexpected end tag (meta). Ignored. -Line: 1 Col: 280 This element (basefont) has no end tag. -Line: 1 Col: 290 This element (bgsound) has no end tag. -Line: 1 Col: 298 This element (embed) has no end tag. -Line: 1 Col: 307 This element (spacer) has no end tag. -Line: 1 Col: 311 Unexpected end tag (p). Ignored. -Line: 1 Col: 316 End tag (dd) seen too early. Expected other end tag. -Line: 1 Col: 321 End tag (dt) seen too early. Expected other end tag. -Line: 1 Col: 331 Unexpected end tag (caption). Ignored. -Line: 1 Col: 342 Unexpected end tag (colgroup). Ignored. -Line: 1 Col: 350 Unexpected end tag (tbody). Ignored. -Line: 1 Col: 358 Unexpected end tag (tfoot). Ignored. -Line: 1 Col: 366 Unexpected end tag (thead). Ignored. -Line: 1 Col: 376 End tag (address) seen too early. Expected other end tag. -Line: 1 Col: 389 End tag (blockquote) seen too early. Expected other end tag. -Line: 1 Col: 398 End tag (center) seen too early. Expected other end tag. -Line: 1 Col: 404 Unexpected end tag (dir). Ignored. -Line: 1 Col: 410 End tag (div) seen too early. Expected other end tag. -Line: 1 Col: 415 End tag (dl) seen too early. Expected other end tag. -Line: 1 Col: 426 End tag (fieldset) seen too early. Expected other end tag. -Line: 1 Col: 436 End tag (listing) seen too early. Expected other end tag. -Line: 1 Col: 443 End tag (menu) seen too early. Expected other end tag. -Line: 1 Col: 448 End tag (ol) seen too early. Expected other end tag. -Line: 1 Col: 453 End tag (ul) seen too early. Expected other end tag. -Line: 1 Col: 458 End tag (li) seen too early. Expected other end tag. -Line: 1 Col: 465 End tag (nobr) violates step 1, paragraph 1 of the adoption agency algorithm. -Line: 1 Col: 471 This element (wbr) has no end tag. -Line: 1 Col: 487 End tag (button) seen too early. Expected other end tag. -Line: 1 Col: 497 End tag (marquee) seen too early. Expected other end tag. -Line: 1 Col: 506 End tag (object) seen too early. Expected other end tag. -Line: 1 Col: 524 Unexpected end tag (html). Ignored. -Line: 1 Col: 524 Unexpected end tag (frameset). Ignored. -Line: 1 Col: 531 Unexpected end tag (head). Ignored. -Line: 1 Col: 540 Unexpected end tag (iframe). Ignored. -Line: 1 Col: 548 This element (image) has no end tag. -Line: 1 Col: 558 This element (isindex) has no end tag. -Line: 1 Col: 568 Unexpected end tag (noembed). Ignored. -Line: 1 Col: 579 Unexpected end tag (noframes). Ignored. -Line: 1 Col: 590 Unexpected end tag (noscript). Ignored. -Line: 1 Col: 601 Unexpected end tag (optgroup). Ignored. -Line: 1 Col: 610 Unexpected end tag (option). Ignored. -Line: 1 Col: 622 Unexpected end tag (plaintext). Ignored. -Line: 1 Col: 633 Unexpected end tag (textarea). Ignored. -#document -| -| -| -|
-| -| -| -|

- -#data - -#errors -Line: 1 Col: 10 Unexpected start tag (frameset). Expected DOCTYPE. -Line: 1 Col: 10 Expected closing tag. Unexpected end of file. -#document -| -| -| diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests10.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests10.dat deleted file mode 100644 index 4f8df86..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests10.dat +++ /dev/null @@ -1,799 +0,0 @@ -#data - -#errors -#document -| -| -| -| -| - -#data -a -#errors -29: Bogus comment -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| - -#data - -#errors -35: Stray “svg†start tag. -42: Stray end tag “svg†-#document -| -| -| -| -| -#errors -43: Stray “svg†start tag. -50: Stray end tag “svg†-#document -| -| -| -| -|

-#errors -34: Start tag “svg†seen in “tableâ€. -41: Stray end tag “svgâ€. -#document -| -| -| -| -| -| - -#data -
foo
-#errors -34: Start tag “svg†seen in “tableâ€. -46: Stray end tag “gâ€. -53: Stray end tag “svgâ€. -#document -| -| -| -| -| -| -| "foo" -| - -#data -
foobar
-#errors -34: Start tag “svg†seen in “tableâ€. -46: Stray end tag “gâ€. -58: Stray end tag “gâ€. -65: Stray end tag “svgâ€. -#document -| -| -| -| -| -| -| "foo" -| -| "bar" -| - -#data -
foobar
-#errors -41: Start tag “svg†seen in “tableâ€. -53: Stray end tag “gâ€. -65: Stray end tag “gâ€. -72: Stray end tag “svgâ€. -#document -| -| -| -| -| -| -| "foo" -| -| "bar" -| -| - -#data -
foobar
-#errors -45: Start tag “svg†seen in “tableâ€. -57: Stray end tag “gâ€. -69: Stray end tag “gâ€. -76: Stray end tag “svgâ€. -#document -| -| -| -| -| -| -| "foo" -| -| "bar" -| -| -| - -#data -
foobar
-#errors -#document -| -| -| -| -| -| -| -|
-| -| -| "foo" -| -| "bar" - -#data -
foobar

baz

-#errors -#document -| -| -| -| -| -| -| -|
-| -| -| "foo" -| -| "bar" -|

-| "baz" - -#data -
foobar

baz

-#errors -#document -| -| -| -| -| -|
-| -| -| "foo" -| -| "bar" -|

-| "baz" - -#data -
foobar

baz

quux -#errors -70: HTML start tag “p†in a foreign namespace context. -81: “table†closed but “caption†was still open. -#document -| -| -| -| -| -|
-| -| -| "foo" -| -| "bar" -|

-| "baz" -|

-| "quux" - -#data -
foobarbaz

quux -#errors -78: “table†closed but “caption†was still open. -78: Unclosed elements on stack. -#document -| -| -| -| -| -|
-| -| -| "foo" -| -| "bar" -| "baz" -|

-| "quux" - -#data -foobar

baz

quux -#errors -44: Start tag “svg†seen in “tableâ€. -56: Stray end tag “gâ€. -68: Stray end tag “gâ€. -71: HTML start tag “p†in a foreign namespace context. -71: Start tag “p†seen in “tableâ€. -#document -| -| -| -| -| -| -| "foo" -| -| "bar" -|

-| "baz" -| -| -|

-| "quux" - -#data -

quux -#errors -50: Stray “svg†start tag. -54: Stray “g†start tag. -62: Stray end tag “g†-66: Stray “g†start tag. -74: Stray end tag “g†-77: Stray “p†start tag. -88: “table†end tag with “select†open. -#document -| -| -| -| -| -| -| -|
-|

quux -#errors -36: Start tag “select†seen in “tableâ€. -42: Stray “svg†start tag. -46: Stray “g†start tag. -54: Stray end tag “g†-58: Stray “g†start tag. -66: Stray end tag “g†-69: Stray “p†start tag. -80: “table†end tag with “select†open. -#document -| -| -| -| -| -|

-| "quux" - -#data -foobar

baz -#errors -41: Stray “svg†start tag. -68: HTML start tag “p†in a foreign namespace context. -#document -| -| -| -| -| -| -| "foo" -| -| "bar" -|

-| "baz" - -#data -foobar

baz -#errors -34: Stray “svg†start tag. -61: HTML start tag “p†in a foreign namespace context. -#document -| -| -| -| -| -| -| "foo" -| -| "bar" -|

-| "baz" - -#data -

-#errors -31: Stray “svg†start tag. -35: Stray “g†start tag. -40: Stray end tag “g†-44: Stray “g†start tag. -49: Stray end tag “g†-52: Stray “p†start tag. -58: Stray “span†start tag. -58: End of file seen and there were open elements. -#document -| -| -| -| - -#data -

-#errors -42: Stray “svg†start tag. -46: Stray “g†start tag. -51: Stray end tag “g†-55: Stray “g†start tag. -60: Stray end tag “g†-63: Stray “p†start tag. -69: Stray “span†start tag. -#document -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| xlink:href="foo" -| -| xlink href="foo" - -#data - -#errors -#document -| -| -| -| -| xlink:href="foo" -| xml:lang="en" -| -| -| xlink href="foo" -| xml lang="en" - -#data - -#errors -#document -| -| -| -| -| xlink:href="foo" -| xml:lang="en" -| -| -| xlink href="foo" -| xml lang="en" - -#data -bar -#errors -#document -| -| -| -| -| xlink:href="foo" -| xml:lang="en" -| -| -| xlink href="foo" -| xml lang="en" -| "bar" - -#data - -#errors -#document -| -| -| -| - -#data -

a -#errors -#document -| -| -| -|
-| -| "a" - -#data -
a -#errors -#document -| -| -| -|
-| -| -| "a" - -#data -
-#errors -#document -| -| -| -|
-| -| -| - -#data -
a -#errors -#document -| -| -| -|
-| -| -| -| -| "a" - -#data -

a -#errors -#document -| -| -| -|

-| -| -| -|

-| "a" - -#data -
    a -#errors -40: HTML start tag “ul†in a foreign namespace context. -41: End of file in a foreign namespace context. -#document -| -| -| -| -| -| -|
    -| -|
      -| "a" - -#data -
        a -#errors -35: HTML start tag “ul†in a foreign namespace context. -36: End of file in a foreign namespace context. -#document -| -| -| -| -| -| -| -|
          -| "a" - -#data -

          -#errors -#document -| -| -| -| -|

          -| -| -|

          - -#data -

          -#errors -#document -| -| -| -| -|

          -| -| -|

          - -#data -

          -#errors -#document -| -| -| -|

          -| -| -| -|

          -|

          - -#data -
          -#errors -#document -| -| -| -| -| -|
          -| -|
          -| -| - -#data -
          -#errors -#document -| -| -| -| -| -| -| -|
          -|
          -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data -

-#errors -#document -| -| -| -| -|
-| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| -| - -#data -
-#errors -#document -| -| -| -| -| -| -| -|
-| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| -| -| -| -| -| -| -| -| diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests11.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests11.dat deleted file mode 100644 index 638cde4..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests11.dat +++ /dev/null @@ -1,482 +0,0 @@ -#data - -#errors -#document -| -| -| -| -| -| attributeName="" -| attributeType="" -| baseFrequency="" -| baseProfile="" -| calcMode="" -| clipPathUnits="" -| contentScriptType="" -| contentStyleType="" -| diffuseConstant="" -| edgeMode="" -| externalResourcesRequired="" -| filterRes="" -| filterUnits="" -| glyphRef="" -| gradientTransform="" -| gradientUnits="" -| kernelMatrix="" -| kernelUnitLength="" -| keyPoints="" -| keySplines="" -| keyTimes="" -| lengthAdjust="" -| limitingConeAngle="" -| markerHeight="" -| markerUnits="" -| markerWidth="" -| maskContentUnits="" -| maskUnits="" -| numOctaves="" -| pathLength="" -| patternContentUnits="" -| patternTransform="" -| patternUnits="" -| pointsAtX="" -| pointsAtY="" -| pointsAtZ="" -| preserveAlpha="" -| preserveAspectRatio="" -| primitiveUnits="" -| refX="" -| refY="" -| repeatCount="" -| repeatDur="" -| requiredExtensions="" -| requiredFeatures="" -| specularConstant="" -| specularExponent="" -| spreadMethod="" -| startOffset="" -| stdDeviation="" -| stitchTiles="" -| surfaceScale="" -| systemLanguage="" -| tableValues="" -| targetX="" -| targetY="" -| textLength="" -| viewBox="" -| viewTarget="" -| xChannelSelector="" -| yChannelSelector="" -| zoomAndPan="" - -#data - -#errors -#document -| -| -| -| -| -| attributeName="" -| attributeType="" -| baseFrequency="" -| baseProfile="" -| calcMode="" -| clipPathUnits="" -| contentScriptType="" -| contentStyleType="" -| diffuseConstant="" -| edgeMode="" -| externalResourcesRequired="" -| filterRes="" -| filterUnits="" -| glyphRef="" -| gradientTransform="" -| gradientUnits="" -| kernelMatrix="" -| kernelUnitLength="" -| keyPoints="" -| keySplines="" -| keyTimes="" -| lengthAdjust="" -| limitingConeAngle="" -| markerHeight="" -| markerUnits="" -| markerWidth="" -| maskContentUnits="" -| maskUnits="" -| numOctaves="" -| pathLength="" -| patternContentUnits="" -| patternTransform="" -| patternUnits="" -| pointsAtX="" -| pointsAtY="" -| pointsAtZ="" -| preserveAlpha="" -| preserveAspectRatio="" -| primitiveUnits="" -| refX="" -| refY="" -| repeatCount="" -| repeatDur="" -| requiredExtensions="" -| requiredFeatures="" -| specularConstant="" -| specularExponent="" -| spreadMethod="" -| startOffset="" -| stdDeviation="" -| stitchTiles="" -| surfaceScale="" -| systemLanguage="" -| tableValues="" -| targetX="" -| targetY="" -| textLength="" -| viewBox="" -| viewTarget="" -| xChannelSelector="" -| yChannelSelector="" -| zoomAndPan="" - -#data - -#errors -#document -| -| -| -| -| -| attributeName="" -| attributeType="" -| baseFrequency="" -| baseProfile="" -| calcMode="" -| clipPathUnits="" -| contentScriptType="" -| contentStyleType="" -| diffuseConstant="" -| edgeMode="" -| externalResourcesRequired="" -| filterRes="" -| filterUnits="" -| glyphRef="" -| gradientTransform="" -| gradientUnits="" -| kernelMatrix="" -| kernelUnitLength="" -| keyPoints="" -| keySplines="" -| keyTimes="" -| lengthAdjust="" -| limitingConeAngle="" -| markerHeight="" -| markerUnits="" -| markerWidth="" -| maskContentUnits="" -| maskUnits="" -| numOctaves="" -| pathLength="" -| patternContentUnits="" -| patternTransform="" -| patternUnits="" -| pointsAtX="" -| pointsAtY="" -| pointsAtZ="" -| preserveAlpha="" -| preserveAspectRatio="" -| primitiveUnits="" -| refX="" -| refY="" -| repeatCount="" -| repeatDur="" -| requiredExtensions="" -| requiredFeatures="" -| specularConstant="" -| specularExponent="" -| spreadMethod="" -| startOffset="" -| stdDeviation="" -| stitchTiles="" -| surfaceScale="" -| systemLanguage="" -| tableValues="" -| targetX="" -| targetY="" -| textLength="" -| viewBox="" -| viewTarget="" -| xChannelSelector="" -| yChannelSelector="" -| zoomAndPan="" - -#data - -#errors -#document -| -| -| -| -| -| attributename="" -| attributetype="" -| basefrequency="" -| baseprofile="" -| calcmode="" -| clippathunits="" -| contentscripttype="" -| contentstyletype="" -| diffuseconstant="" -| edgemode="" -| externalresourcesrequired="" -| filterres="" -| filterunits="" -| glyphref="" -| gradienttransform="" -| gradientunits="" -| kernelmatrix="" -| kernelunitlength="" -| keypoints="" -| keysplines="" -| keytimes="" -| lengthadjust="" -| limitingconeangle="" -| markerheight="" -| markerunits="" -| markerwidth="" -| maskcontentunits="" -| maskunits="" -| numoctaves="" -| pathlength="" -| patterncontentunits="" -| patterntransform="" -| patternunits="" -| pointsatx="" -| pointsaty="" -| pointsatz="" -| preservealpha="" -| preserveaspectratio="" -| primitiveunits="" -| refx="" -| refy="" -| repeatcount="" -| repeatdur="" -| requiredextensions="" -| requiredfeatures="" -| specularconstant="" -| specularexponent="" -| spreadmethod="" -| startoffset="" -| stddeviation="" -| stitchtiles="" -| surfacescale="" -| systemlanguage="" -| tablevalues="" -| targetx="" -| targety="" -| textlength="" -| viewbox="" -| viewtarget="" -| xchannelselector="" -| ychannelselector="" -| zoomandpan="" - -#data - -#errors -#document -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests12.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests12.dat deleted file mode 100644 index 63107d2..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests12.dat +++ /dev/null @@ -1,62 +0,0 @@ -#data -

foobazeggs

spam

quuxbar -#errors -#document -| -| -| -| -|

-| "foo" -| -| -| -| "baz" -| -| -| -| -| "eggs" -| -| -|

-| "spam" -| -| -| -|
-| -| -| "quux" -| "bar" - -#data -foobazeggs

spam
quuxbar -#errors -#document -| -| -| -| -| "foo" -| -| -| -| "baz" -| -| -| -| -| "eggs" -| -| -|

-| "spam" -| -| -| -|
-| -| -| "quux" -| "bar" diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests14.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests14.dat deleted file mode 100644 index b8713f8..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests14.dat +++ /dev/null @@ -1,74 +0,0 @@ -#data - -#errors -#document -| -| -| -| -| - -#data - -#errors -#document -| -| -| -| -| -| - -#data - -#errors -15: Unexpected start tag html -#document -| -| -| abc:def="gh" -| -| -| - -#data - -#errors -15: Unexpected start tag html -#document -| -| -| xml:lang="bar" -| -| - -#data - -#errors -#document -| -| -| 123="456" -| -| - -#data - -#errors -#document -| -| -| 123="456" -| 789="012" -| -| - -#data - -#errors -#document -| -| -| -| -| 789="012" diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests15.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests15.dat deleted file mode 100644 index 6ce1c0d..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests15.dat +++ /dev/null @@ -1,208 +0,0 @@ -#data -

X -#errors -Line: 1 Col: 31 Unexpected end tag (p). Ignored. -Line: 1 Col: 36 Expected closing tag. Unexpected end of file. -#document -| -| -| -| -|

-| -| -| -| -| -| -| " " -|

-| "X" - -#data -

-

X -#errors -Line: 1 Col: 3 Unexpected start tag (p). Expected DOCTYPE. -Line: 1 Col: 16 Unexpected end tag (p). Ignored. -Line: 2 Col: 4 Expected closing tag. Unexpected end of file. -#document -| -| -| -|

-| -| -| -| -| -| -| " -" -|

-| "X" - -#data - -#errors -Line: 1 Col: 22 Unexpected end tag (html) after the (implied) root element. -#document -| -| -| -| -| " " - -#data - -#errors -Line: 1 Col: 22 Unexpected end tag (body) after the (implied) root element. -#document -| -| -| -| -| - -#data - -#errors -Line: 1 Col: 6 Unexpected start tag (html). Expected DOCTYPE. -Line: 1 Col: 13 Unexpected end tag (html) after the (implied) root element. -#document -| -| -| -| - -#data -X -#errors -Line: 1 Col: 22 Unexpected end tag (body) after the (implied) root element. -#document -| -| -| -| -| -| "X" - -#data -<!doctype html><table> X<meta></table> -#errors -Line: 1 Col: 24 Unexpected non-space characters in table context caused voodoo mode. -Line: 1 Col: 30 Unexpected start tag (meta) in table context caused voodoo mode. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| " X" -| <meta> -| <table> - -#data -<!doctype html><table> x</table> -#errors -Line: 1 Col: 24 Unexpected non-space characters in table context caused voodoo mode. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| " x" -| <table> - -#data -<!doctype html><table> x </table> -#errors -Line: 1 Col: 25 Unexpected non-space characters in table context caused voodoo mode. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| " x " -| <table> - -#data -<!doctype html><table><tr> x</table> -#errors -Line: 1 Col: 28 Unexpected non-space characters in table context caused voodoo mode. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| " x" -| <table> -| <tbody> -| <tr> - -#data -<!doctype html><table>X<style> <tr>x </style> </table> -#errors -Line: 1 Col: 23 Unexpected non-space characters in table context caused voodoo mode. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "X" -| <table> -| <style> -| " <tr>x " -| " " - -#data -<!doctype html><div><table><a>foo</a> <tr><td>bar</td> </tr></table></div> -#errors -Line: 1 Col: 30 Unexpected start tag (a) in table context caused voodoo mode. -Line: 1 Col: 37 Unexpected end tag (a) in table context caused voodoo mode. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <div> -| <a> -| "foo" -| <table> -| " " -| <tbody> -| <tr> -| <td> -| "bar" -| " " - -#data -<frame></frame></frame><frameset><frame><frameset><frame></frameset><noframes></frameset><noframes> -#errors -6: Start tag seen without seeing a doctype first. Expected “<!DOCTYPE html>â€. -13: Stray start tag “frameâ€. -21: Stray end tag “frameâ€. -29: Stray end tag “frameâ€. -39: “frameset†start tag after “body†already open. -105: End of file seen inside an [R]CDATA element. -105: End of file seen and there were open elements. -XXX: These errors are wrong, please fix me! -#document -| <html> -| <head> -| <frameset> -| <frame> -| <frameset> -| <frame> -| <noframes> -| "</frameset><noframes>" - -#data -<!DOCTYPE html><object></html> -#errors -1: Expected closing tag. Unexpected end of file -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <object> diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests16.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests16.dat deleted file mode 100644 index c8ef66f..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests16.dat +++ /dev/null @@ -1,2299 +0,0 @@ -#data -<!doctype html><script> -#errors -Line: 1 Col: 23 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| <body> - -#data -<!doctype html><script>a -#errors -Line: 1 Col: 24 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "a" -| <body> - -#data -<!doctype html><script>< -#errors -Line: 1 Col: 24 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<" -| <body> - -#data -<!doctype html><script></ -#errors -Line: 1 Col: 25 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</" -| <body> - -#data -<!doctype html><script></S -#errors -Line: 1 Col: 26 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</S" -| <body> - -#data -<!doctype html><script></SC -#errors -Line: 1 Col: 27 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</SC" -| <body> - -#data -<!doctype html><script></SCR -#errors -Line: 1 Col: 28 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</SCR" -| <body> - -#data -<!doctype html><script></SCRI -#errors -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</SCRI" -| <body> - -#data -<!doctype html><script></SCRIP -#errors -Line: 1 Col: 30 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</SCRIP" -| <body> - -#data -<!doctype html><script></SCRIPT -#errors -Line: 1 Col: 31 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</SCRIPT" -| <body> - -#data -<!doctype html><script></SCRIPT -#errors -Line: 1 Col: 32 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| <body> - -#data -<!doctype html><script></s -#errors -Line: 1 Col: 26 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</s" -| <body> - -#data -<!doctype html><script></sc -#errors -Line: 1 Col: 27 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</sc" -| <body> - -#data -<!doctype html><script></scr -#errors -Line: 1 Col: 28 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</scr" -| <body> - -#data -<!doctype html><script></scri -#errors -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</scri" -| <body> - -#data -<!doctype html><script></scrip -#errors -Line: 1 Col: 30 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</scrip" -| <body> - -#data -<!doctype html><script></script -#errors -Line: 1 Col: 31 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "</script" -| <body> - -#data -<!doctype html><script></script -#errors -Line: 1 Col: 32 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| <body> - -#data -<!doctype html><script><! -#errors -Line: 1 Col: 25 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!" -| <body> - -#data -<!doctype html><script><!a -#errors -Line: 1 Col: 26 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!a" -| <body> - -#data -<!doctype html><script><!- -#errors -Line: 1 Col: 26 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!-" -| <body> - -#data -<!doctype html><script><!-a -#errors -Line: 1 Col: 27 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!-a" -| <body> - -#data -<!doctype html><script><!-- -#errors -Line: 1 Col: 27 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--" -| <body> - -#data -<!doctype html><script><!--a -#errors -Line: 1 Col: 28 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--a" -| <body> - -#data -<!doctype html><script><!--< -#errors -Line: 1 Col: 28 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<" -| <body> - -#data -<!doctype html><script><!--<a -#errors -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<a" -| <body> - -#data -<!doctype html><script><!--</ -#errors -Line: 1 Col: 27 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--</" -| <body> - -#data -<!doctype html><script><!--</script -#errors -Line: 1 Col: 35 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--</script" -| <body> - -#data -<!doctype html><script><!--</script -#errors -Line: 1 Col: 36 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--" -| <body> - -#data -<!doctype html><script><!--<s -#errors -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<s" -| <body> - -#data -<!doctype html><script><!--<script -#errors -Line: 1 Col: 34 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script" -| <body> - -#data -<!doctype html><script><!--<script -#errors -Line: 1 Col: 35 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script " -| <body> - -#data -<!doctype html><script><!--<script < -#errors -Line: 1 Col: 36 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script <" -| <body> - -#data -<!doctype html><script><!--<script <a -#errors -Line: 1 Col: 37 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script <a" -| <body> - -#data -<!doctype html><script><!--<script </ -#errors -Line: 1 Col: 37 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </" -| <body> - -#data -<!doctype html><script><!--<script </s -#errors -Line: 1 Col: 38 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </s" -| <body> - -#data -<!doctype html><script><!--<script </script -#errors -Line: 1 Col: 43 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script" -| <body> - -#data -<!doctype html><script><!--<script </scripta -#errors -Line: 1 Col: 44 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </scripta" -| <body> - -#data -<!doctype html><script><!--<script </script -#errors -Line: 1 Col: 44 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<!doctype html><script><!--<script </script> -#errors -Line: 1 Col: 44 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script>" -| <body> - -#data -<!doctype html><script><!--<script </script/ -#errors -Line: 1 Col: 44 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script/" -| <body> - -#data -<!doctype html><script><!--<script </script < -#errors -Line: 1 Col: 45 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script <" -| <body> - -#data -<!doctype html><script><!--<script </script <a -#errors -Line: 1 Col: 46 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script <a" -| <body> - -#data -<!doctype html><script><!--<script </script </ -#errors -Line: 1 Col: 46 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script </" -| <body> - -#data -<!doctype html><script><!--<script </script </script -#errors -Line: 1 Col: 52 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script </script" -| <body> - -#data -<!doctype html><script><!--<script </script </script -#errors -Line: 1 Col: 53 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<!doctype html><script><!--<script </script </script/ -#errors -Line: 1 Col: 53 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<!doctype html><script><!--<script </script </script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<!doctype html><script><!--<script - -#errors -Line: 1 Col: 36 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script -" -| <body> - -#data -<!doctype html><script><!--<script -a -#errors -Line: 1 Col: 37 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script -a" -| <body> - -#data -<!doctype html><script><!--<script -< -#errors -Line: 1 Col: 37 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script -<" -| <body> - -#data -<!doctype html><script><!--<script -- -#errors -Line: 1 Col: 37 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script --" -| <body> - -#data -<!doctype html><script><!--<script --a -#errors -Line: 1 Col: 38 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script --a" -| <body> - -#data -<!doctype html><script><!--<script --< -#errors -Line: 1 Col: 38 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script --<" -| <body> - -#data -<!doctype html><script><!--<script --> -#errors -Line: 1 Col: 38 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<!doctype html><script><!--<script -->< -#errors -Line: 1 Col: 39 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script --><" -| <body> - -#data -<!doctype html><script><!--<script --></ -#errors -Line: 1 Col: 40 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script --></" -| <body> - -#data -<!doctype html><script><!--<script --></script -#errors -Line: 1 Col: 46 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script --></script" -| <body> - -#data -<!doctype html><script><!--<script --></script -#errors -Line: 1 Col: 47 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<!doctype html><script><!--<script --></script/ -#errors -Line: 1 Col: 47 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<!doctype html><script><!--<script --></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<!doctype html><script><!--<script><\/script>--></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script><\/script>-->" -| <body> - -#data -<!doctype html><script><!--<script></scr'+'ipt>--></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></scr'+'ipt>-->" -| <body> - -#data -<!doctype html><script><!--<script></script><script></script></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>" -| <body> - -#data -<!doctype html><script><!--<script></script><script></script>--><!--</script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>--><!--" -| <body> - -#data -<!doctype html><script><!--<script></script><script></script>-- ></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>-- >" -| <body> - -#data -<!doctype html><script><!--<script></script><script></script>- -></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>- ->" -| <body> - -#data -<!doctype html><script><!--<script></script><script></script>- - ></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>- - >" -| <body> - -#data -<!doctype html><script><!--<script></script><script></script>-></script> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>->" -| <body> - -#data -<!doctype html><script><!--<script>--!></script>X -#errors -Line: 1 Col: 49 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script>--!></script>X" -| <body> - -#data -<!doctype html><script><!--<scr'+'ipt></script>--></script> -#errors -Line: 1 Col: 59 Unexpected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<scr'+'ipt>" -| <body> -| "-->" - -#data -<!doctype html><script><!--<script></scr'+'ipt></script>X -#errors -Line: 1 Col: 57 Unexpected end of file. Expected end tag (script). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| "<!--<script></scr'+'ipt></script>X" -| <body> - -#data -<!doctype html><style><!--<style></style>--></style> -#errors -Line: 1 Col: 52 Unexpected end tag (style). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "<!--<style>" -| <body> -| "-->" - -#data -<!doctype html><style><!--</style>X -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "<!--" -| <body> -| "X" - -#data -<!doctype html><style><!--...</style>...--></style> -#errors -Line: 1 Col: 51 Unexpected end tag (style). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "<!--..." -| <body> -| "...-->" - -#data -<!doctype html><style><!--<br><html xmlns:v="urn:schemas-microsoft-com:vml"><!--[if !mso]><style></style>X -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "<!--<br><html xmlns:v="urn:schemas-microsoft-com:vml"><!--[if !mso]><style>" -| <body> -| "X" - -#data -<!doctype html><style><!--...<style><!--...--!></style>--></style> -#errors -Line: 1 Col: 66 Unexpected end tag (style). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "<!--...<style><!--...--!>" -| <body> -| "-->" - -#data -<!doctype html><style><!--...</style><!-- --><style>@import ...</style> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "<!--..." -| <!-- --> -| <style> -| "@import ..." -| <body> - -#data -<!doctype html><style>...<style><!--...</style><!-- --></style> -#errors -Line: 1 Col: 63 Unexpected end tag (style). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "...<style><!--..." -| <!-- --> -| <body> - -#data -<!doctype html><style>...<!--[if IE]><style>...</style>X -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <style> -| "...<!--[if IE]><style>..." -| <body> -| "X" - -#data -<!doctype html><title><!--<title>--> -#errors -Line: 1 Col: 52 Unexpected end tag (title). -#document -| -| -| -| -| "<!--<title>" -| <body> -| "-->" - -#data -<!doctype html><title></title> -#errors -#document -| -| -| -| -| "" -| - -#data -foo/title><link></head><body>X -#errors -Line: 1 Col: 52 Unexpected end of file. Expected end tag (title). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <title> -| "foo/title><link></head><body>X" -| <body> - -#data -<!doctype html><noscript><!--<noscript></noscript>--></noscript> -#errors -Line: 1 Col: 64 Unexpected end tag (noscript). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <noscript> -| "<!--<noscript>" -| <body> -| "-->" - -#data -<!doctype html><noscript><!--</noscript>X<noscript>--></noscript> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <noscript> -| "<!--" -| <body> -| "X" -| <noscript> -| "-->" - -#data -<!doctype html><noscript><iframe></noscript>X -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <noscript> -| "<iframe>" -| <body> -| "X" - -#data -<!doctype html><noframes><!--<noframes></noframes>--></noframes> -#errors -Line: 1 Col: 64 Unexpected end tag (noframes). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <noframes> -| "<!--<noframes>" -| <body> -| "-->" - -#data -<!doctype html><noframes><body><script><!--...</script></body></noframes></html> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <noframes> -| "<body><script><!--...</script></body>" -| <body> - -#data -<!doctype html><textarea><!--<textarea></textarea>--></textarea> -#errors -Line: 1 Col: 64 Unexpected end tag (textarea). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <textarea> -| "<!--<textarea>" -| "-->" - -#data -<!doctype html><textarea></textarea></textarea> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <textarea> -| "</textarea>" - -#data -<!doctype html><textarea><</textarea> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <textarea> -| "<" - -#data -<!doctype html><textarea>a<b</textarea> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <textarea> -| "a<b" - -#data -<!doctype html><iframe><!--<iframe></iframe>--></iframe> -#errors -Line: 1 Col: 56 Unexpected end tag (iframe). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <iframe> -| "<!--<iframe>" -| "-->" - -#data -<!doctype html><iframe>...<!--X->...<!--/X->...</iframe> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <iframe> -| "...<!--X->...<!--/X->..." - -#data -<!doctype html><xmp><!--<xmp></xmp>--></xmp> -#errors -Line: 1 Col: 44 Unexpected end tag (xmp). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <xmp> -| "<!--<xmp>" -| "-->" - -#data -<!doctype html><noembed><!--<noembed></noembed>--></noembed> -#errors -Line: 1 Col: 60 Unexpected end tag (noembed). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <noembed> -| "<!--<noembed>" -| "-->" - -#data -<script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 8 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| <body> - -#data -<script>a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 9 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "a" -| <body> - -#data -<script>< -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 9 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<" -| <body> - -#data -<script></ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 10 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</" -| <body> - -#data -<script></S -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 11 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</S" -| <body> - -#data -<script></SC -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 12 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</SC" -| <body> - -#data -<script></SCR -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 13 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</SCR" -| <body> - -#data -<script></SCRI -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 14 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</SCRI" -| <body> - -#data -<script></SCRIP -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 15 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</SCRIP" -| <body> - -#data -<script></SCRIPT -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 16 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</SCRIPT" -| <body> - -#data -<script></SCRIPT -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 17 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| <body> - -#data -<script></s -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 11 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</s" -| <body> - -#data -<script></sc -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 12 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</sc" -| <body> - -#data -<script></scr -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 13 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</scr" -| <body> - -#data -<script></scri -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 14 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</scri" -| <body> - -#data -<script></scrip -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 15 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</scrip" -| <body> - -#data -<script></script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 16 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</script" -| <body> - -#data -<script></script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 17 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| <body> - -#data -<script><! -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 10 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!" -| <body> - -#data -<script><!a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 11 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!a" -| <body> - -#data -<script><!- -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 11 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!-" -| <body> - -#data -<script><!-a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 12 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!-a" -| <body> - -#data -<script><!-- -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 12 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--" -| <body> - -#data -<script><!--a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 13 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--a" -| <body> - -#data -<script><!--< -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 13 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<" -| <body> - -#data -<script><!--<a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 14 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<a" -| <body> - -#data -<script><!--</ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 14 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--</" -| <body> - -#data -<script><!--</script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 20 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--</script" -| <body> - -#data -<script><!--</script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 21 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--" -| <body> - -#data -<script><!--<s -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 14 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<s" -| <body> - -#data -<script><!--<script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 19 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script" -| <body> - -#data -<script><!--<script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 20 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script " -| <body> - -#data -<script><!--<script < -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 21 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script <" -| <body> - -#data -<script><!--<script <a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 22 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script <a" -| <body> - -#data -<script><!--<script </ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 22 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </" -| <body> - -#data -<script><!--<script </s -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 23 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </s" -| <body> - -#data -<script><!--<script </script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 28 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script" -| <body> - -#data -<script><!--<script </scripta -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </scripta" -| <body> - -#data -<script><!--<script </script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<script><!--<script </script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script>" -| <body> - -#data -<script><!--<script </script/ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 29 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script/" -| <body> - -#data -<script><!--<script </script < -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 30 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script <" -| <body> - -#data -<script><!--<script </script <a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 31 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script <a" -| <body> - -#data -<script><!--<script </script </ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 31 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script </" -| <body> - -#data -<script><!--<script </script </script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 38 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script </script" -| <body> - -#data -<script><!--<script </script </script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 38 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<script><!--<script </script </script/ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 38 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<script><!--<script </script </script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script </script " -| <body> - -#data -<script><!--<script - -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 21 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script -" -| <body> - -#data -<script><!--<script -a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 22 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script -a" -| <body> - -#data -<script><!--<script -- -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 22 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script --" -| <body> - -#data -<script><!--<script --a -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 23 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script --a" -| <body> - -#data -<script><!--<script --> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 23 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<script><!--<script -->< -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 24 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script --><" -| <body> - -#data -<script><!--<script --></ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 25 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script --></" -| <body> - -#data -<script><!--<script --></script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 31 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script --></script" -| <body> - -#data -<script><!--<script --></script -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 32 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<script><!--<script --></script/ -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 32 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<script><!--<script --></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script -->" -| <body> - -#data -<script><!--<script><\/script>--></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script><\/script>-->" -| <body> - -#data -<script><!--<script></scr'+'ipt>--></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script></scr'+'ipt>-->" -| <body> - -#data -<script><!--<script></script><script></script></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>" -| <body> - -#data -<script><!--<script></script><script></script>--><!--</script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>--><!--" -| <body> - -#data -<script><!--<script></script><script></script>-- ></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>-- >" -| <body> - -#data -<script><!--<script></script><script></script>- -></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>- ->" -| <body> - -#data -<script><!--<script></script><script></script>- - ></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>- - >" -| <body> - -#data -<script><!--<script></script><script></script>-></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -#document -| <html> -| <head> -| <script> -| "<!--<script></script><script></script>->" -| <body> - -#data -<script><!--<script>--!></script>X -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 34 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script>--!></script>X" -| <body> - -#data -<script><!--<scr'+'ipt></script>--></script> -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 44 Unexpected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<scr'+'ipt>" -| <body> -| "-->" - -#data -<script><!--<script></scr'+'ipt></script>X -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 42 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "<!--<script></scr'+'ipt></script>X" -| <body> - -#data -<style><!--<style></style>--></style> -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -Line: 1 Col: 37 Unexpected end tag (style). -#document -| <html> -| <head> -| <style> -| "<!--<style>" -| <body> -| "-->" - -#data -<style><!--</style>X -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| <html> -| <head> -| <style> -| "<!--" -| <body> -| "X" - -#data -<style><!--...</style>...--></style> -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -Line: 1 Col: 36 Unexpected end tag (style). -#document -| <html> -| <head> -| <style> -| "<!--..." -| <body> -| "...-->" - -#data -<style><!--<br><html xmlns:v="urn:schemas-microsoft-com:vml"><!--[if !mso]><style></style>X -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| <html> -| <head> -| <style> -| "<!--<br><html xmlns:v="urn:schemas-microsoft-com:vml"><!--[if !mso]><style>" -| <body> -| "X" - -#data -<style><!--...<style><!--...--!></style>--></style> -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -Line: 1 Col: 51 Unexpected end tag (style). -#document -| <html> -| <head> -| <style> -| "<!--...<style><!--...--!>" -| <body> -| "-->" - -#data -<style><!--...</style><!-- --><style>@import ...</style> -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| <html> -| <head> -| <style> -| "<!--..." -| <!-- --> -| <style> -| "@import ..." -| <body> - -#data -<style>...<style><!--...</style><!-- --></style> -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -Line: 1 Col: 48 Unexpected end tag (style). -#document -| <html> -| <head> -| <style> -| "...<style><!--..." -| <!-- --> -| <body> - -#data -<style>...<!--[if IE]><style>...</style>X -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| <html> -| <head> -| <style> -| "...<!--[if IE]><style>..." -| <body> -| "X" - -#data -<title><!--<title>--> -#errors -Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE. -Line: 1 Col: 37 Unexpected end tag (title). -#document -| -| -| -| "<!--<title>" -| <body> -| "-->" - -#data -<title></title> -#errors -Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE. -#document -| -| -| -| "" -| - -#data -foo/title><link></head><body>X -#errors -Line: 1 Col: 7 Unexpected start tag (title). Expected DOCTYPE. -Line: 1 Col: 37 Unexpected end of file. Expected end tag (title). -#document -| <html> -| <head> -| <title> -| "foo/title><link></head><body>X" -| <body> - -#data -<noscript><!--<noscript></noscript>--></noscript> -#errors -Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE. -Line: 1 Col: 49 Unexpected end tag (noscript). -#document -| <html> -| <head> -| <noscript> -| "<!--<noscript>" -| <body> -| "-->" - -#data -<noscript><!--</noscript>X<noscript>--></noscript> -#errors -Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE. -#document -| <html> -| <head> -| <noscript> -| "<!--" -| <body> -| "X" -| <noscript> -| "-->" - -#data -<noscript><iframe></noscript>X -#errors -Line: 1 Col: 10 Unexpected start tag (noscript). Expected DOCTYPE. -#document -| <html> -| <head> -| <noscript> -| "<iframe>" -| <body> -| "X" - -#data -<noframes><!--<noframes></noframes>--></noframes> -#errors -Line: 1 Col: 10 Unexpected start tag (noframes). Expected DOCTYPE. -Line: 1 Col: 49 Unexpected end tag (noframes). -#document -| <html> -| <head> -| <noframes> -| "<!--<noframes>" -| <body> -| "-->" - -#data -<noframes><body><script><!--...</script></body></noframes></html> -#errors -Line: 1 Col: 10 Unexpected start tag (noframes). Expected DOCTYPE. -#document -| <html> -| <head> -| <noframes> -| "<body><script><!--...</script></body>" -| <body> - -#data -<textarea><!--<textarea></textarea>--></textarea> -#errors -Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE. -Line: 1 Col: 49 Unexpected end tag (textarea). -#document -| <html> -| <head> -| <body> -| <textarea> -| "<!--<textarea>" -| "-->" - -#data -<textarea></textarea></textarea> -#errors -Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| <textarea> -| "</textarea>" - -#data -<iframe><!--<iframe></iframe>--></iframe> -#errors -Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE. -Line: 1 Col: 41 Unexpected end tag (iframe). -#document -| <html> -| <head> -| <body> -| <iframe> -| "<!--<iframe>" -| "-->" - -#data -<iframe>...<!--X->...<!--/X->...</iframe> -#errors -Line: 1 Col: 8 Unexpected start tag (iframe). Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| <iframe> -| "...<!--X->...<!--/X->..." - -#data -<xmp><!--<xmp></xmp>--></xmp> -#errors -Line: 1 Col: 5 Unexpected start tag (xmp). Expected DOCTYPE. -Line: 1 Col: 29 Unexpected end tag (xmp). -#document -| <html> -| <head> -| <body> -| <xmp> -| "<!--<xmp>" -| "-->" - -#data -<noembed><!--<noembed></noembed>--></noembed> -#errors -Line: 1 Col: 9 Unexpected start tag (noembed). Expected DOCTYPE. -Line: 1 Col: 45 Unexpected end tag (noembed). -#document -| <html> -| <head> -| <body> -| <noembed> -| "<!--<noembed>" -| "-->" - -#data -<!doctype html><table> - -#errors -Line 2 Col 0 Unexpected end of file. Expected table content. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| " -" - -#data -<!doctype html><table><td><span><font></span><span> -#errors -Line 1 Col 26 Unexpected table cell start tag (td) in the table body phase. -Line 1 Col 45 Unexpected end tag (span). -Line 1 Col 51 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> -| <span> -| <font> -| <font> -| <span> - -#data -<!doctype html><form><table></form><form></table></form> -#errors -35: Stray end tag “formâ€. -41: Start tag “form†seen in “tableâ€. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <form> -| <table> -| <form> diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests17.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests17.dat deleted file mode 100644 index 7b555f8..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests17.dat +++ /dev/null @@ -1,153 +0,0 @@ -#data -<!doctype html><table><tbody><select><tr> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <table> -| <tbody> -| <tr> - -#data -<!doctype html><table><tr><select><td> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <table> -| <tbody> -| <tr> -| <td> - -#data -<!doctype html><table><tr><td><select><td> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> -| <select> -| <td> - -#data -<!doctype html><table><tr><th><select><td> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <th> -| <select> -| <td> - -#data -<!doctype html><table><caption><select><tr> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <caption> -| <select> -| <tbody> -| <tr> - -#data -<!doctype html><select><tr> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><select><td> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><select><th> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><select><tbody> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><select><thead> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><select><tfoot> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><select><caption> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><table><tr></table>a -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| "a" diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests18.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests18.dat deleted file mode 100644 index 680e1f0..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests18.dat +++ /dev/null @@ -1,269 +0,0 @@ -#data -<!doctype html><plaintext></plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <plaintext> -| "</plaintext>" - -#data -<!doctype html><table><plaintext></plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <plaintext> -| "</plaintext>" -| <table> - -#data -<!doctype html><table><tbody><plaintext></plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <plaintext> -| "</plaintext>" -| <table> -| <tbody> - -#data -<!doctype html><table><tbody><tr><plaintext></plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <plaintext> -| "</plaintext>" -| <table> -| <tbody> -| <tr> - -#data -<!doctype html><table><tbody><tr><plaintext></plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <plaintext> -| "</plaintext>" -| <table> -| <tbody> -| <tr> - -#data -<!doctype html><table><td><plaintext></plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> -| <plaintext> -| "</plaintext>" - -#data -<!doctype html><table><caption><plaintext></plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <caption> -| <plaintext> -| "</plaintext>" - -#data -<!doctype html><table><tr><style></script></style>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "abc" -| <table> -| <tbody> -| <tr> -| <style> -| "</script>" - -#data -<!doctype html><table><tr><script></style></script>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "abc" -| <table> -| <tbody> -| <tr> -| <script> -| "</style>" - -#data -<!doctype html><table><caption><style></script></style>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <caption> -| <style> -| "</script>" -| "abc" - -#data -<!doctype html><table><td><style></script></style>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> -| <style> -| "</script>" -| "abc" - -#data -<!doctype html><select><script></style></script>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <script> -| "</style>" -| "abc" - -#data -<!doctype html><table><select><script></style></script>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <script> -| "</style>" -| "abc" -| <table> - -#data -<!doctype html><table><tr><select><script></style></script>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <script> -| "</style>" -| "abc" -| <table> -| <tbody> -| <tr> - -#data -<!doctype html><frameset></frameset><noframes>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <noframes> -| "abc" - -#data -<!doctype html><frameset></frameset><noframes>abc</noframes><!--abc--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <noframes> -| "abc" -| <!-- abc --> - -#data -<!doctype html><frameset></frameset></html><noframes>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <noframes> -| "abc" - -#data -<!doctype html><frameset></frameset></html><noframes>abc</noframes><!--abc--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <noframes> -| "abc" -| <!-- abc --> - -#data -<!doctype html><table><tr></tbody><tfoot> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <tfoot> - -#data -<!doctype html><table><td><svg></svg>abc<td> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> -| <svg svg> -| "abc" -| <td> diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests19.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests19.dat deleted file mode 100644 index 0d62f5a..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests19.dat +++ /dev/null @@ -1,1237 +0,0 @@ -#data -<!doctype html><math><mn DefinitionUrl="foo"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <math math> -| <math mn> -| definitionURL="foo" - -#data -<!doctype html><html></p><!--foo--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <!-- foo --> -| <head> -| <body> - -#data -<!doctype html><head></head></p><!--foo--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <!-- foo --> -| <body> - -#data -<!doctype html><body><p><pre> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <pre> - -#data -<!doctype html><body><p><listing> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <listing> - -#data -<!doctype html><p><plaintext> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <plaintext> - -#data -<!doctype html><p><h1> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <h1> - -#data -<!doctype html><form><isindex> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <form> - -#data -<!doctype html><isindex action="POST"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <form> -| action="POST" -| <hr> -| <label> -| "This is a searchable index. Enter search keywords: " -| <input> -| name="isindex" -| <hr> - -#data -<!doctype html><isindex prompt="this is isindex"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <form> -| <hr> -| <label> -| "this is isindex" -| <input> -| name="isindex" -| <hr> - -#data -<!doctype html><isindex type="hidden"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <form> -| <hr> -| <label> -| "This is a searchable index. Enter search keywords: " -| <input> -| name="isindex" -| type="hidden" -| <hr> - -#data -<!doctype html><isindex name="foo"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <form> -| <hr> -| <label> -| "This is a searchable index. Enter search keywords: " -| <input> -| name="isindex" -| <hr> - -#data -<!doctype html><ruby><p><rp> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <ruby> -| <p> -| <rp> - -#data -<!doctype html><ruby><div><span><rp> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <ruby> -| <div> -| <span> -| <rp> - -#data -<!doctype html><ruby><div><p><rp> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <ruby> -| <div> -| <p> -| <rp> - -#data -<!doctype html><ruby><p><rt> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <ruby> -| <p> -| <rt> - -#data -<!doctype html><ruby><div><span><rt> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <ruby> -| <div> -| <span> -| <rt> - -#data -<!doctype html><ruby><div><p><rt> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <ruby> -| <div> -| <p> -| <rt> - -#data -<!doctype html><math/><foo> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <math math> -| <foo> - -#data -<!doctype html><svg/><foo> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <svg svg> -| <foo> - -#data -<!doctype html><div></body><!--foo--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <div> -| <!-- foo --> - -#data -<!doctype html><h1><div><h3><span></h1>foo -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <h1> -| <div> -| <h3> -| <span> -| "foo" - -#data -<!doctype html><p></h3>foo -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| "foo" - -#data -<!doctype html><h3><li>abc</h2>foo -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <h3> -| <li> -| "abc" -| "foo" - -#data -<!doctype html><table>abc<!--foo--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "abc" -| <table> -| <!-- foo --> - -#data -<!doctype html><table> <!--foo--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| " " -| <!-- foo --> - -#data -<!doctype html><table> b <!--foo--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| " b " -| <table> -| <!-- foo --> - -#data -<!doctype html><select><option><option> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <option> -| <option> - -#data -<!doctype html><select><option></optgroup> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <option> - -#data -<!doctype html><select><option></optgroup> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <option> - -#data -<!doctype html><p><math><mi><p><h1> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <math math> -| <math mi> -| <p> -| <h1> - -#data -<!doctype html><p><math><mo><p><h1> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <math math> -| <math mo> -| <p> -| <h1> - -#data -<!doctype html><p><math><mn><p><h1> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <math math> -| <math mn> -| <p> -| <h1> - -#data -<!doctype html><p><math><ms><p><h1> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <math math> -| <math ms> -| <p> -| <h1> - -#data -<!doctype html><p><math><mtext><p><h1> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <math math> -| <math mtext> -| <p> -| <h1> - -#data -<!doctype html><frameset></noframes> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> - -#data -<!doctype html><html c=d><body></html><html a=b> -#errors -#document -| <!DOCTYPE html> -| <html> -| a="b" -| c="d" -| <head> -| <body> - -#data -<!doctype html><html c=d><frameset></frameset></html><html a=b> -#errors -#document -| <!DOCTYPE html> -| <html> -| a="b" -| c="d" -| <head> -| <frameset> - -#data -<!doctype html><html><frameset></frameset></html><!--foo--> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <!-- foo --> - -#data -<!doctype html><html><frameset></frameset></html> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| " " - -#data -<!doctype html><html><frameset></frameset></html>abc -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> - -#data -<!doctype html><html><frameset></frameset></html><p> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> - -#data -<!doctype html><html><frameset></frameset></html></p> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> - -#data -<html><frameset></frameset></html><!doctype html> -#errors -#document -| <html> -| <head> -| <frameset> - -#data -<!doctype html><body><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> - -#data -<!doctype html><p><frameset><frame> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <frame> - -#data -<!doctype html><p>a<frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| "a" - -#data -<!doctype html><p> <frameset><frame> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <frame> - -#data -<!doctype html><pre><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <pre> - -#data -<!doctype html><listing><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <listing> - -#data -<!doctype html><li><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <li> - -#data -<!doctype html><dd><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <dd> - -#data -<!doctype html><dt><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <dt> - -#data -<!doctype html><button><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <button> - -#data -<!doctype html><applet><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <applet> - -#data -<!doctype html><marquee><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <marquee> - -#data -<!doctype html><object><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <object> - -#data -<!doctype html><table><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> - -#data -<!doctype html><area><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <area> - -#data -<!doctype html><basefont><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <basefont> -| <frameset> - -#data -<!doctype html><bgsound><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <bgsound> -| <frameset> - -#data -<!doctype html><br><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <br> - -#data -<!doctype html><embed><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <embed> - -#data -<!doctype html><img><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <img> - -#data -<!doctype html><input><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <input> - -#data -<!doctype html><keygen><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <keygen> - -#data -<!doctype html><wbr><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <wbr> - -#data -<!doctype html><hr><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <hr> - -#data -<!doctype html><textarea></textarea><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <textarea> - -#data -<!doctype html><xmp></xmp><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <xmp> - -#data -<!doctype html><iframe></iframe><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <iframe> - -#data -<!doctype html><select></select><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> - -#data -<!doctype html><svg></svg><frameset><frame> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <frame> - -#data -<!doctype html><math></math><frameset><frame> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <frame> - -#data -<!doctype html><svg><foreignObject><div> <frameset><frame> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <frame> - -#data -<!doctype html><svg>a</svg><frameset><frame> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <svg svg> -| "a" - -#data -<!doctype html><svg> </svg><frameset><frame> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> -| <frame> - -#data -<html>aaa<frameset></frameset> -#errors -#document -| <html> -| <head> -| <body> -| "aaa" - -#data -<html> a <frameset></frameset> -#errors -#document -| <html> -| <head> -| <body> -| "a " - -#data -<!doctype html><div><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> - -#data -<!doctype html><div><body><frameset> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <div> - -#data -<!doctype html><p><math></p>a -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <math math> -| "a" - -#data -<!doctype html><p><math><mn><span></p>a -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <math math> -| <math mn> -| <span> -| <p> -| "a" - -#data -<!doctype html><math></html> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <math math> - -#data -<!doctype html><meta charset="ascii"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <meta> -| charset="ascii" -| <body> - -#data -<!doctype html><meta http-equiv="content-type" content="text/html;charset=ascii"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <meta> -| content="text/html;charset=ascii" -| http-equiv="content-type" -| <body> - -#data -<!doctype html><head><!--aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa--><meta charset="utf8"> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <!-- aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --> -| <meta> -| charset="utf8" -| <body> - -#data -<!doctype html><html a=b><head></head><html c=d> -#errors -#document -| <!DOCTYPE html> -| <html> -| a="b" -| c="d" -| <head> -| <body> - -#data -<!doctype html><image/> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <img> - -#data -<!doctype html>a<i>b<table>c<b>d</i>e</b>f -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "a" -| <i> -| "bc" -| <b> -| "de" -| "f" -| <table> - -#data -<!doctype html><table><i>a<b>b<div>c<a>d</i>e</b>f -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <i> -| "a" -| <b> -| "b" -| <b> -| <div> -| <b> -| <i> -| "c" -| <a> -| "d" -| <a> -| "e" -| <a> -| "f" -| <table> - -#data -<!doctype html><i>a<b>b<div>c<a>d</i>e</b>f -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <i> -| "a" -| <b> -| "b" -| <b> -| <div> -| <b> -| <i> -| "c" -| <a> -| "d" -| <a> -| "e" -| <a> -| "f" - -#data -<!doctype html><table><i>a<b>b<div>c</i> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <i> -| "a" -| <b> -| "b" -| <b> -| <div> -| <i> -| "c" -| <table> - -#data -<!doctype html><table><i>a<b>b<div>c<a>d</i>e</b>f -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <i> -| "a" -| <b> -| "b" -| <b> -| <div> -| <b> -| <i> -| "c" -| <a> -| "d" -| <a> -| "e" -| <a> -| "f" -| <table> - -#data -<!doctype html><table><i>a<div>b<tr>c<b>d</i>e -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <i> -| "a" -| <div> -| "b" -| <i> -| "c" -| <b> -| "d" -| <b> -| "e" -| <table> -| <tbody> -| <tr> - -#data -<!doctype html><table><td><table><i>a<div>b<b>c</i>d -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> -| <i> -| "a" -| <div> -| <i> -| "b" -| <b> -| "c" -| <b> -| "d" -| <table> - -#data -<!doctype html><body><bgsound> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <bgsound> - -#data -<!doctype html><body><basefont> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <basefont> - -#data -<!doctype html><a><b></a><basefont> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <a> -| <b> -| <basefont> - -#data -<!doctype html><a><b></a><bgsound> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <a> -| <b> -| <bgsound> - -#data -<!doctype html><figcaption><article></figcaption>a -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <figcaption> -| <article> -| "a" - -#data -<!doctype html><summary><article></summary>a -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <summary> -| <article> -| "a" - -#data -<!doctype html><p><a><plaintext>b -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <a> -| <plaintext> -| <a> -| "b" - -#data -<!DOCTYPE html><div>a<a></div>b<p>c</p>d -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <div> -| "a" -| <a> -| <a> -| "b" -| <p> -| "c" -| "d" diff --git a/vendor/golang.org/x/net/html/testdata/webkit/tests2.dat b/vendor/golang.org/x/net/html/testdata/webkit/tests2.dat deleted file mode 100644 index 60d8592..0000000 --- a/vendor/golang.org/x/net/html/testdata/webkit/tests2.dat +++ /dev/null @@ -1,763 +0,0 @@ -#data -<!DOCTYPE html>Test -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "Test" - -#data -<textarea>test</div>test -#errors -Line: 1 Col: 10 Unexpected start tag (textarea). Expected DOCTYPE. -Line: 1 Col: 24 Expected closing tag. Unexpected end of file. -#document -| <html> -| <head> -| <body> -| <textarea> -| "test</div>test" - -#data -<table><td> -#errors -Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE. -Line: 1 Col: 11 Unexpected table cell start tag (td) in the table body phase. -Line: 1 Col: 11 Expected closing tag. Unexpected end of file. -#document -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> - -#data -<table><td>test</tbody></table> -#errors -Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE. -Line: 1 Col: 11 Unexpected table cell start tag (td) in the table body phase. -#document -| <html> -| <head> -| <body> -| <table> -| <tbody> -| <tr> -| <td> -| "test" - -#data -<frame>test -#errors -Line: 1 Col: 7 Unexpected start tag (frame). Expected DOCTYPE. -Line: 1 Col: 7 Unexpected start tag frame. Ignored. -#document -| <html> -| <head> -| <body> -| "test" - -#data -<!DOCTYPE html><frameset>test -#errors -Line: 1 Col: 29 Unepxected characters in the frameset phase. Characters ignored. -Line: 1 Col: 29 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> - -#data -<!DOCTYPE html><frameset><!DOCTYPE html> -#errors -Line: 1 Col: 40 Unexpected DOCTYPE. Ignored. -Line: 1 Col: 40 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <frameset> - -#data -<!DOCTYPE html><font><p><b>test</font> -#errors -Line: 1 Col: 38 End tag (font) violates step 1, paragraph 3 of the adoption agency algorithm. -Line: 1 Col: 38 End tag (font) violates step 1, paragraph 3 of the adoption agency algorithm. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <font> -| <p> -| <font> -| <b> -| "test" - -#data -<!DOCTYPE html><dt><div><dd> -#errors -Line: 1 Col: 28 Missing end tag (div, dt). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <dt> -| <div> -| <dd> - -#data -<script></x -#errors -Line: 1 Col: 8 Unexpected start tag (script). Expected DOCTYPE. -Line: 1 Col: 11 Unexpected end of file. Expected end tag (script). -#document -| <html> -| <head> -| <script> -| "</x" -| <body> - -#data -<table><plaintext><td> -#errors -Line: 1 Col: 7 Unexpected start tag (table). Expected DOCTYPE. -Line: 1 Col: 18 Unexpected start tag (plaintext) in table context caused voodoo mode. -Line: 1 Col: 22 Unexpected end of file. Expected table content. -#document -| <html> -| <head> -| <body> -| <plaintext> -| "<td>" -| <table> - -#data -<plaintext></plaintext> -#errors -Line: 1 Col: 11 Unexpected start tag (plaintext). Expected DOCTYPE. -Line: 1 Col: 23 Expected closing tag. Unexpected end of file. -#document -| <html> -| <head> -| <body> -| <plaintext> -| "</plaintext>" - -#data -<!DOCTYPE html><table><tr>TEST -#errors -Line: 1 Col: 30 Unexpected non-space characters in table context caused voodoo mode. -Line: 1 Col: 30 Unexpected end of file. Expected table content. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "TEST" -| <table> -| <tbody> -| <tr> - -#data -<!DOCTYPE html><body t1=1><body t2=2><body t3=3 t4=4> -#errors -Line: 1 Col: 37 Unexpected start tag (body). -Line: 1 Col: 53 Unexpected start tag (body). -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| t1="1" -| t2="2" -| t3="3" -| t4="4" - -#data -</b test -#errors -Line: 1 Col: 8 Unexpected end of file in attribute name. -Line: 1 Col: 8 End tag contains unexpected attributes. -Line: 1 Col: 8 Unexpected end tag (b). Expected DOCTYPE. -Line: 1 Col: 8 Unexpected end tag (b) after the (implied) root element. -#document -| <html> -| <head> -| <body> - -#data -<!DOCTYPE html></b test<b &=&>X -#errors -Line: 1 Col: 32 Named entity didn't end with ';'. -Line: 1 Col: 33 End tag contains unexpected attributes. -Line: 1 Col: 33 Unexpected end tag (b) after the (implied) root element. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "X" - -#data -<!doctypehtml><scrIPt type=text/x-foobar;baz>X</SCRipt -#errors -Line: 1 Col: 9 No space after literal string 'DOCTYPE'. -Line: 1 Col: 54 Unexpected end of file in the tag name. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <script> -| type="text/x-foobar;baz" -| "X</SCRipt" -| <body> - -#data -& -#errors -Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "&" - -#data -&# -#errors -Line: 1 Col: 1 Numeric entity expected. Got end of file instead. -Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "&#" - -#data -&#X -#errors -Line: 1 Col: 3 Numeric entity expected but none found. -Line: 1 Col: 3 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "&#X" - -#data -&#x -#errors -Line: 1 Col: 3 Numeric entity expected but none found. -Line: 1 Col: 3 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "&#x" - -#data -- -#errors -Line: 1 Col: 4 Numeric entity didn't end with ';'. -Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "-" - -#data -&x-test -#errors -Line: 1 Col: 1 Named entity expected. Got none. -Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "&x-test" - -#data -<!doctypehtml><p><li> -#errors -Line: 1 Col: 9 No space after literal string 'DOCTYPE'. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <li> - -#data -<!doctypehtml><p><dt> -#errors -Line: 1 Col: 9 No space after literal string 'DOCTYPE'. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <dt> - -#data -<!doctypehtml><p><dd> -#errors -Line: 1 Col: 9 No space after literal string 'DOCTYPE'. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <dd> - -#data -<!doctypehtml><p><form> -#errors -Line: 1 Col: 9 No space after literal string 'DOCTYPE'. -Line: 1 Col: 23 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| <form> - -#data -<!DOCTYPE html><p></P>X -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <p> -| "X" - -#data -& -#errors -Line: 1 Col: 4 Named entity didn't end with ';'. -Line: 1 Col: 4 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "&" - -#data -&AMp; -#errors -Line: 1 Col: 1 Named entity expected. Got none. -Line: 1 Col: 1 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "&AMp;" - -#data -<!DOCTYPE html><html><head></head><body><thisISasillyTESTelementNameToMakeSureCrazyTagNamesArePARSEDcorrectLY> -#errors -Line: 1 Col: 110 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <thisisasillytestelementnametomakesurecrazytagnamesareparsedcorrectly> - -#data -<!DOCTYPE html>X</body>X -#errors -Line: 1 Col: 24 Unexpected non-space characters in the after body phase. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| "XX" - -#data -<!DOCTYPE html><!-- X -#errors -Line: 1 Col: 21 Unexpected end of file in comment. -#document -| <!DOCTYPE html> -| <!-- X --> -| <html> -| <head> -| <body> - -#data -<!DOCTYPE html><table><caption>test TEST</caption><td>test -#errors -Line: 1 Col: 54 Unexpected table cell start tag (td) in the table body phase. -Line: 1 Col: 58 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <table> -| <caption> -| "test TEST" -| <tbody> -| <tr> -| <td> -| "test" - -#data -<!DOCTYPE html><select><option><optgroup> -#errors -Line: 1 Col: 41 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <option> -| <optgroup> - -#data -<!DOCTYPE html><select><optgroup><option></optgroup><option><select><option> -#errors -Line: 1 Col: 68 Unexpected select start tag in the select phase treated as select end tag. -Line: 1 Col: 76 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <optgroup> -| <option> -| <option> -| <option> - -#data -<!DOCTYPE html><select><optgroup><option><optgroup> -#errors -Line: 1 Col: 51 Expected closing tag. Unexpected end of file. -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <optgroup> -| <option> -| <optgroup> - -#data -<!DOCTYPE html><datalist><option>foo</datalist>bar -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <datalist> -| <option> -| "foo" -| "bar" - -#data -<!DOCTYPE html><font><input><input></font> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <font> -| <input> -| <input> - -#data -<!DOCTYPE html><!-- XXX - XXX --> -#errors -#document -| <!DOCTYPE html> -| <!-- XXX - XXX --> -| <html> -| <head> -| <body> - -#data -<!DOCTYPE html><!-- XXX - XXX -#errors -Line: 1 Col: 29 Unexpected end of file in comment (-) -#document -| <!DOCTYPE html> -| <!-- XXX - XXX --> -| <html> -| <head> -| <body> - -#data -<!DOCTYPE html><!-- XXX - XXX - XXX --> -#errors -#document -| <!DOCTYPE html> -| <!-- XXX - XXX - XXX --> -| <html> -| <head> -| <body> - -#data -<isindex test=x name=x> -#errors -Line: 1 Col: 23 Unexpected start tag (isindex). Expected DOCTYPE. -Line: 1 Col: 23 Unexpected start tag isindex. Don't use it! -#document -| <html> -| <head> -| <body> -| <form> -| <hr> -| <label> -| "This is a searchable index. Enter search keywords: " -| <input> -| name="isindex" -| test="x" -| <hr> - -#data -test -test -#errors -Line: 2 Col: 4 Unexpected non-space characters. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> -| "test -test" - -#data -<!DOCTYPE html><body><title>test</body> -#errors -#document -| -| -| -| -| -| "test</body>" - -#data -<!DOCTYPE html><body><title>X -#errors -#document -| -| -| -| -| -| "X" -| <meta> -| name="z" -| <link> -| rel="foo" -| <style> -| " -x { content:"</style" } " - -#data -<!DOCTYPE html><select><optgroup></optgroup></select> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> -| <select> -| <optgroup> - -#data - - -#errors -Line: 2 Col: 1 Unexpected End of file. Expected DOCTYPE. -#document -| <html> -| <head> -| <body> - -#data -<!DOCTYPE html> <html> -#errors -#document -| <!DOCTYPE html> -| <html> -| <head> -| <body> - -#data -<!DOCTYPE html><script> -</script> <title>x -#errors -#document -| -| -| -| -#errors -Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE. -Line: 1 Col: 21 Unexpected start tag (script) that can be in head. Moved. -#document -| -| -| -#errors -Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE. -Line: 1 Col: 28 Unexpected start tag (style) that can be in head. Moved. -#document -| -| -| -#errors -Line: 1 Col: 6 Unexpected start tag (head). Expected DOCTYPE. -#document -| -| -| -| -| "x" -| x -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -Line: 1 Col: 22 Unexpected end of file. Expected end tag (style). -#document -| -| -| --> x -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| -| -| x -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| -| -| x -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| -| -| x -#errors -Line: 1 Col: 7 Unexpected start tag (style). Expected DOCTYPE. -#document -| -| -|

-#errors -#document -| -| -| -| -| -| ddd -#errors -#document -| -| -| -#errors -#document -| -| -| -| -|
  • -| -| ", - " -
    << Back to Go HTTP/2 demo server`) - }) -} - -func httpsHost() string { - if *hostHTTPS != "" { - return *hostHTTPS - } - if v := *httpsAddr; strings.HasPrefix(v, ":") { - return "localhost" + v - } else { - return v - } -} - -func httpHost() string { - if *hostHTTP != "" { - return *hostHTTP - } - if v := *httpAddr; strings.HasPrefix(v, ":") { - return "localhost" + v - } else { - return v - } -} - -func serveProdTLS() error { - c, err := googlestorage.NewServiceClient() - if err != nil { - return err - } - slurp := func(key string) ([]byte, error) { - const bucket = "http2-demo-server-tls" - rc, _, err := c.GetObject(&googlestorage.Object{ - Bucket: bucket, - Key: key, - }) - if err != nil { - return nil, fmt.Errorf("Error fetching GCS object %q in bucket %q: %v", key, bucket, err) - } - defer rc.Close() - return ioutil.ReadAll(rc) - } - certPem, err := slurp("http2.golang.org.chained.pem") - if err != nil { - return err - } - keyPem, err := slurp("http2.golang.org.key") - if err != nil { - return err - } - cert, err := tls.X509KeyPair(certPem, keyPem) - if err != nil { - return err - } - srv := &http.Server{ - TLSConfig: &tls.Config{ - Certificates: []tls.Certificate{cert}, - }, - } - http2.ConfigureServer(srv, &http2.Server{}) - ln, err := net.Listen("tcp", ":443") - if err != nil { - return err - } - return srv.Serve(tls.NewListener(tcpKeepAliveListener{ln.(*net.TCPListener)}, srv.TLSConfig)) -} - -type tcpKeepAliveListener struct { - *net.TCPListener -} - -func (ln tcpKeepAliveListener) Accept() (c net.Conn, err error) { - tc, err := ln.AcceptTCP() - if err != nil { - return - } - tc.SetKeepAlive(true) - tc.SetKeepAlivePeriod(3 * time.Minute) - return tc, nil -} - -func serveProd() error { - errc := make(chan error, 2) - go func() { errc <- http.ListenAndServe(":80", nil) }() - go func() { errc <- serveProdTLS() }() - return <-errc -} - -const idleTimeout = 5 * time.Minute -const activeTimeout = 10 * time.Minute - -// TODO: put this into the standard library and actually send -// PING frames and GOAWAY, etc: golang.org/issue/14204 -func idleTimeoutHook() func(net.Conn, http.ConnState) { - var mu sync.Mutex - m := map[net.Conn]*time.Timer{} - return func(c net.Conn, cs http.ConnState) { - mu.Lock() - defer mu.Unlock() - if t, ok := m[c]; ok { - delete(m, c) - t.Stop() - } - var d time.Duration - switch cs { - case http.StateNew, http.StateIdle: - d = idleTimeout - case http.StateActive: - d = activeTimeout - default: - return - } - m[c] = time.AfterFunc(d, func() { - log.Printf("closing idle conn %v after %v", c.RemoteAddr(), d) - go c.Close() - }) - } -} - -func main() { - var srv http.Server - flag.BoolVar(&http2.VerboseLogs, "verbose", false, "Verbose HTTP/2 debugging.") - flag.Parse() - srv.Addr = *httpsAddr - srv.ConnState = idleTimeoutHook() - - registerHandlers() - - if *prod { - *hostHTTP = "http2.golang.org" - *hostHTTPS = "http2.golang.org" - log.Fatal(serveProd()) - } - - url := "https://" + httpsHost() + "/" - log.Printf("Listening on " + url) - http2.ConfigureServer(&srv, &http2.Server{}) - - if *httpAddr != "" { - go func() { - log.Printf("Listening on http://" + httpHost() + "/ (for unencrypted HTTP/1)") - log.Fatal(http.ListenAndServe(*httpAddr, nil)) - }() - } - - go func() { - log.Fatal(srv.ListenAndServeTLS("server.crt", "server.key")) - }() - select {} -} diff --git a/vendor/golang.org/x/net/http2/h2demo/launch.go b/vendor/golang.org/x/net/http2/h2demo/launch.go deleted file mode 100644 index df0866a..0000000 --- a/vendor/golang.org/x/net/http2/h2demo/launch.go +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -import ( - "bufio" - "bytes" - "encoding/json" - "flag" - "fmt" - "io" - "io/ioutil" - "log" - "net/http" - "os" - "strings" - "time" - - "golang.org/x/oauth2" - "golang.org/x/oauth2/google" - compute "google.golang.org/api/compute/v1" -) - -var ( - proj = flag.String("project", "symbolic-datum-552", "name of Project") - zone = flag.String("zone", "us-central1-a", "GCE zone") - mach = flag.String("machinetype", "n1-standard-1", "Machine type") - instName = flag.String("instance_name", "http2-demo", "Name of VM instance.") - sshPub = flag.String("ssh_public_key", "", "ssh public key file to authorize. Can modify later in Google's web UI anyway.") - staticIP = flag.String("static_ip", "130.211.116.44", "Static IP to use. If empty, automatic.") - - writeObject = flag.String("write_object", "", "If non-empty, a VM isn't created and the flag value is Google Cloud Storage bucket/object to write. The contents from stdin.") - publicObject = flag.Bool("write_object_is_public", false, "Whether the object created by --write_object should be public.") -) - -func readFile(v string) string { - slurp, err := ioutil.ReadFile(v) - if err != nil { - log.Fatalf("Error reading %s: %v", v, err) - } - return strings.TrimSpace(string(slurp)) -} - -var config = &oauth2.Config{ - // The client-id and secret should be for an "Installed Application" when using - // the CLI. Later we'll use a web application with a callback. - ClientID: readFile("client-id.dat"), - ClientSecret: readFile("client-secret.dat"), - Endpoint: google.Endpoint, - Scopes: []string{ - compute.DevstorageFullControlScope, - compute.ComputeScope, - "https://www.googleapis.com/auth/sqlservice", - "https://www.googleapis.com/auth/sqlservice.admin", - }, - RedirectURL: "urn:ietf:wg:oauth:2.0:oob", -} - -const baseConfig = `#cloud-config -coreos: - units: - - name: h2demo.service - command: start - content: | - [Unit] - Description=HTTP2 Demo - - [Service] - ExecStartPre=/bin/bash -c 'mkdir -p /opt/bin && curl -s -o /opt/bin/h2demo http://storage.googleapis.com/http2-demo-server-tls/h2demo && chmod +x /opt/bin/h2demo' - ExecStart=/opt/bin/h2demo --prod - RestartSec=5s - Restart=always - Type=simple - - [Install] - WantedBy=multi-user.target -` - -func main() { - flag.Parse() - if *proj == "" { - log.Fatalf("Missing --project flag") - } - prefix := "https://www.googleapis.com/compute/v1/projects/" + *proj - machType := prefix + "/zones/" + *zone + "/machineTypes/" + *mach - - const tokenFileName = "token.dat" - tokenFile := tokenCacheFile(tokenFileName) - tokenSource := oauth2.ReuseTokenSource(nil, tokenFile) - token, err := tokenSource.Token() - if err != nil { - if *writeObject != "" { - log.Fatalf("Can't use --write_object without a valid token.dat file already cached.") - } - log.Printf("Error getting token from %s: %v", tokenFileName, err) - log.Printf("Get auth code from %v", config.AuthCodeURL("my-state")) - fmt.Print("\nEnter auth code: ") - sc := bufio.NewScanner(os.Stdin) - sc.Scan() - authCode := strings.TrimSpace(sc.Text()) - token, err = config.Exchange(oauth2.NoContext, authCode) - if err != nil { - log.Fatalf("Error exchanging auth code for a token: %v", err) - } - if err := tokenFile.WriteToken(token); err != nil { - log.Fatalf("Error writing to %s: %v", tokenFileName, err) - } - tokenSource = oauth2.ReuseTokenSource(token, nil) - } - - oauthClient := oauth2.NewClient(oauth2.NoContext, tokenSource) - - if *writeObject != "" { - writeCloudStorageObject(oauthClient) - return - } - - computeService, _ := compute.New(oauthClient) - - natIP := *staticIP - if natIP == "" { - // Try to find it by name. - aggAddrList, err := computeService.Addresses.AggregatedList(*proj).Do() - if err != nil { - log.Fatal(err) - } - // http://godoc.org/code.google.com/p/google-api-go-client/compute/v1#AddressAggregatedList - IPLoop: - for _, asl := range aggAddrList.Items { - for _, addr := range asl.Addresses { - if addr.Name == *instName+"-ip" && addr.Status == "RESERVED" { - natIP = addr.Address - break IPLoop - } - } - } - } - - cloudConfig := baseConfig - if *sshPub != "" { - key := strings.TrimSpace(readFile(*sshPub)) - cloudConfig += fmt.Sprintf("\nssh_authorized_keys:\n - %s\n", key) - } - if os.Getenv("USER") == "bradfitz" { - cloudConfig += fmt.Sprintf("\nssh_authorized_keys:\n - %s\n", "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAwks9dwWKlRC+73gRbvYtVg0vdCwDSuIlyt4z6xa/YU/jTDynM4R4W10hm2tPjy8iR1k8XhDv4/qdxe6m07NjG/By1tkmGpm1mGwho4Pr5kbAAy/Qg+NLCSdAYnnE00FQEcFOC15GFVMOW2AzDGKisReohwH9eIzHPzdYQNPRWXE= bradfitz@papag.bradfitz.com") - } - const maxCloudConfig = 32 << 10 // per compute API docs - if len(cloudConfig) > maxCloudConfig { - log.Fatalf("cloud config length of %d bytes is over %d byte limit", len(cloudConfig), maxCloudConfig) - } - - instance := &compute.Instance{ - Name: *instName, - Description: "Go Builder", - MachineType: machType, - Disks: []*compute.AttachedDisk{instanceDisk(computeService)}, - Tags: &compute.Tags{ - Items: []string{"http-server", "https-server"}, - }, - Metadata: &compute.Metadata{ - Items: []*compute.MetadataItems{ - { - Key: "user-data", - Value: &cloudConfig, - }, - }, - }, - NetworkInterfaces: []*compute.NetworkInterface{ - { - AccessConfigs: []*compute.AccessConfig{ - { - Type: "ONE_TO_ONE_NAT", - Name: "External NAT", - NatIP: natIP, - }, - }, - Network: prefix + "/global/networks/default", - }, - }, - ServiceAccounts: []*compute.ServiceAccount{ - { - Email: "default", - Scopes: []string{ - compute.DevstorageFullControlScope, - compute.ComputeScope, - }, - }, - }, - } - - log.Printf("Creating instance...") - op, err := computeService.Instances.Insert(*proj, *zone, instance).Do() - if err != nil { - log.Fatalf("Failed to create instance: %v", err) - } - opName := op.Name - log.Printf("Created. Waiting on operation %v", opName) -OpLoop: - for { - time.Sleep(2 * time.Second) - op, err := computeService.ZoneOperations.Get(*proj, *zone, opName).Do() - if err != nil { - log.Fatalf("Failed to get op %s: %v", opName, err) - } - switch op.Status { - case "PENDING", "RUNNING": - log.Printf("Waiting on operation %v", opName) - continue - case "DONE": - if op.Error != nil { - for _, operr := range op.Error.Errors { - log.Printf("Error: %+v", operr) - } - log.Fatalf("Failed to start.") - } - log.Printf("Success. %+v", op) - break OpLoop - default: - log.Fatalf("Unknown status %q: %+v", op.Status, op) - } - } - - inst, err := computeService.Instances.Get(*proj, *zone, *instName).Do() - if err != nil { - log.Fatalf("Error getting instance after creation: %v", err) - } - ij, _ := json.MarshalIndent(inst, "", " ") - log.Printf("Instance: %s", ij) -} - -func instanceDisk(svc *compute.Service) *compute.AttachedDisk { - const imageURL = "https://www.googleapis.com/compute/v1/projects/coreos-cloud/global/images/coreos-stable-444-5-0-v20141016" - diskName := *instName + "-disk" - - return &compute.AttachedDisk{ - AutoDelete: true, - Boot: true, - Type: "PERSISTENT", - InitializeParams: &compute.AttachedDiskInitializeParams{ - DiskName: diskName, - SourceImage: imageURL, - DiskSizeGb: 50, - }, - } -} - -func writeCloudStorageObject(httpClient *http.Client) { - content := os.Stdin - const maxSlurp = 1 << 20 - var buf bytes.Buffer - n, err := io.CopyN(&buf, content, maxSlurp) - if err != nil && err != io.EOF { - log.Fatalf("Error reading from stdin: %v, %v", n, err) - } - contentType := http.DetectContentType(buf.Bytes()) - - req, err := http.NewRequest("PUT", "https://storage.googleapis.com/"+*writeObject, io.MultiReader(&buf, content)) - if err != nil { - log.Fatal(err) - } - req.Header.Set("x-goog-api-version", "2") - if *publicObject { - req.Header.Set("x-goog-acl", "public-read") - } - req.Header.Set("Content-Type", contentType) - res, err := httpClient.Do(req) - if err != nil { - log.Fatal(err) - } - if res.StatusCode != 200 { - res.Write(os.Stderr) - log.Fatalf("Failed.") - } - log.Printf("Success.") - os.Exit(0) -} - -type tokenCacheFile string - -func (f tokenCacheFile) Token() (*oauth2.Token, error) { - slurp, err := ioutil.ReadFile(string(f)) - if err != nil { - return nil, err - } - t := new(oauth2.Token) - if err := json.Unmarshal(slurp, t); err != nil { - return nil, err - } - return t, nil -} - -func (f tokenCacheFile) WriteToken(t *oauth2.Token) error { - jt, err := json.Marshal(t) - if err != nil { - return err - } - return ioutil.WriteFile(string(f), jt, 0600) -} diff --git a/vendor/golang.org/x/net/http2/h2demo/rootCA.key b/vendor/golang.org/x/net/http2/h2demo/rootCA.key deleted file mode 100644 index a15a6ab..0000000 --- a/vendor/golang.org/x/net/http2/h2demo/rootCA.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAt5fAjp4fTcekWUTfzsp0kyih1OYbsGL0KX1eRbSSR8Od0+9Q -62Hyny+GFwMTb4A/KU8mssoHvcceSAAbwfbxFK/+s51TobqUnORZrOoTZjkUygby -XDSK99YBbcR1Pip8vwMTm4XKuLtCigeBBdjjAQdgUO28LENGlsMnmeYkJfODVGnV -mr5Ltb9ANA8IKyTfsnHJ4iOCS/PlPbUj2q7YnoVLposUBMlgUb/CykX3mOoLb4yJ -JQyA/iST6ZxiIEj36D4yWZ5lg7YJl+UiiBQHGCnPdGyipqV06ex0heYWcaiW8LWZ -SUQ93jQ+WVCH8hT7DQO1dmsvUmXlq/JeAlwQ/QIDAQABAoIBAFFHV7JMAqPWnMYA -nezY6J81v9+XN+7xABNWM2Q8uv4WdksbigGLTXR3/680Z2hXqJ7LMeC5XJACFT/e -/Gr0vmpgOCygnCPfjGehGKpavtfksXV3edikUlnCXsOP1C//c1bFL+sMYmFCVgTx -qYdDK8yKzXNGrKYT6q5YG7IglyRNV1rsQa8lM/5taFYiD1Ck/3tQi3YIq8Lcuser -hrxsMABcQ6mi+EIvG6Xr4mfJug0dGJMHG4RG1UGFQn6RXrQq2+q53fC8ZbVUSi0j -NQ918aKFzktwv+DouKU0ME4I9toks03gM860bAL7zCbKGmwR3hfgX/TqzVCWpG9E -LDVfvekCgYEA8fk9N53jbBRmULUGEf4qWypcLGiZnNU0OeXWpbPV9aa3H0VDytA7 -8fCN2dPAVDPqlthMDdVe983NCNwp2Yo8ZimDgowyIAKhdC25s1kejuaiH9OAPj3c -0f8KbriYX4n8zNHxFwK6Ae3pQ6EqOLJVCUsziUaZX9nyKY5aZlyX6xcCgYEAwjws -K62PjC64U5wYddNLp+kNdJ4edx+a7qBb3mEgPvSFT2RO3/xafJyG8kQB30Mfstjd -bRxyUV6N0vtX1zA7VQtRUAvfGCecpMo+VQZzcHXKzoRTnQ7eZg4Lmj5fQ9tOAKAo -QCVBoSW/DI4PZL26CAMDcAba4Pa22ooLapoRIQsCgYA6pIfkkbxLNkpxpt2YwLtt -Kr/590O7UaR9n6k8sW/aQBRDXNsILR1KDl2ifAIxpf9lnXgZJiwE7HiTfCAcW7c1 -nzwDCI0hWuHcMTS/NYsFYPnLsstyyjVZI3FY0h4DkYKV9Q9z3zJLQ2hz/nwoD3gy -b2pHC7giFcTts1VPV4Nt8wKBgHeFn4ihHJweg76vZz3Z78w7VNRWGFklUalVdDK7 -gaQ7w2y/ROn/146mo0OhJaXFIFRlrpvdzVrU3GDf2YXJYDlM5ZRkObwbZADjksev -WInzcgDy3KDg7WnPasRXbTfMU4t/AkW2p1QKbi3DnSVYuokDkbH2Beo45vxDxhKr -C69RAoGBAIyo3+OJenoZmoNzNJl2WPW5MeBUzSh8T/bgyjFTdqFHF5WiYRD/lfHj -x9Glyw2nutuT4hlOqHvKhgTYdDMsF2oQ72fe3v8Q5FU7FuKndNPEAyvKNXZaShVA -hnlhv5DjXKb0wFWnt5PCCiQLtzG0yyHaITrrEme7FikkIcTxaX/Y ------END RSA PRIVATE KEY----- diff --git a/vendor/golang.org/x/net/http2/h2demo/rootCA.pem b/vendor/golang.org/x/net/http2/h2demo/rootCA.pem deleted file mode 100644 index 3a323e7..0000000 --- a/vendor/golang.org/x/net/http2/h2demo/rootCA.pem +++ /dev/null @@ -1,26 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIEWjCCA0KgAwIBAgIJALfRlWsI8YQHMA0GCSqGSIb3DQEBBQUAMHsxCzAJBgNV -BAYTAlVTMQswCQYDVQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEUMBIG -A1UEChMLQnJhZGZpdHppbmMxEjAQBgNVBAMTCWxvY2FsaG9zdDEdMBsGCSqGSIb3 -DQEJARYOYnJhZEBkYW5nYS5jb20wHhcNMTQwNzE1MjA0NjA1WhcNMTcwNTA0MjA0 -NjA1WjB7MQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBG -cmFuY2lzY28xFDASBgNVBAoTC0JyYWRmaXR6aW5jMRIwEAYDVQQDEwlsb2NhbGhv -c3QxHTAbBgkqhkiG9w0BCQEWDmJyYWRAZGFuZ2EuY29tMIIBIjANBgkqhkiG9w0B -AQEFAAOCAQ8AMIIBCgKCAQEAt5fAjp4fTcekWUTfzsp0kyih1OYbsGL0KX1eRbSS -R8Od0+9Q62Hyny+GFwMTb4A/KU8mssoHvcceSAAbwfbxFK/+s51TobqUnORZrOoT -ZjkUygbyXDSK99YBbcR1Pip8vwMTm4XKuLtCigeBBdjjAQdgUO28LENGlsMnmeYk -JfODVGnVmr5Ltb9ANA8IKyTfsnHJ4iOCS/PlPbUj2q7YnoVLposUBMlgUb/CykX3 -mOoLb4yJJQyA/iST6ZxiIEj36D4yWZ5lg7YJl+UiiBQHGCnPdGyipqV06ex0heYW -caiW8LWZSUQ93jQ+WVCH8hT7DQO1dmsvUmXlq/JeAlwQ/QIDAQABo4HgMIHdMB0G -A1UdDgQWBBRcAROthS4P4U7vTfjByC569R7E6DCBrQYDVR0jBIGlMIGigBRcAROt -hS4P4U7vTfjByC569R7E6KF/pH0wezELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNB -MRYwFAYDVQQHEw1TYW4gRnJhbmNpc2NvMRQwEgYDVQQKEwtCcmFkZml0emluYzES -MBAGA1UEAxMJbG9jYWxob3N0MR0wGwYJKoZIhvcNAQkBFg5icmFkQGRhbmdhLmNv -bYIJALfRlWsI8YQHMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAG6h -U9f9sNH0/6oBbGGy2EVU0UgITUQIrFWo9rFkrW5k/XkDjQm+3lzjT0iGR4IxE/Ao -eU6sQhua7wrWeFEn47GL98lnCsJdD7oZNhFmQ95Tb/LnDUjs5Yj9brP0NWzXfYU4 -UK2ZnINJRcJpB8iRCaCxE8DdcUF0XqIEq6pA272snoLmiXLMvNl3kYEdm+je6voD -58SNVEUsztzQyXmJEhCpwVI0A6QCjzXj+qvpmw3ZZHi8JwXei8ZZBLTSFBki8Z7n -sH9BBH38/SzUmAN4QHSPy1gjqm00OAE8NaYDkh/bzE4d7mLGGMWp/WE3KPSu82HF -kPe6XoSbiLm/kxk32T0= ------END CERTIFICATE----- diff --git a/vendor/golang.org/x/net/http2/h2demo/rootCA.srl b/vendor/golang.org/x/net/http2/h2demo/rootCA.srl deleted file mode 100644 index 6db3891..0000000 --- a/vendor/golang.org/x/net/http2/h2demo/rootCA.srl +++ /dev/null @@ -1 +0,0 @@ -E2CE26BF3285059C diff --git a/vendor/golang.org/x/net/http2/h2demo/server.crt b/vendor/golang.org/x/net/http2/h2demo/server.crt deleted file mode 100644 index c59059b..0000000 --- a/vendor/golang.org/x/net/http2/h2demo/server.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDPjCCAiYCCQDizia/MoUFnDANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJV -UzELMAkGA1UECBMCQ0ExFjAUBgNVBAcTDVNhbiBGcmFuY2lzY28xFDASBgNVBAoT -C0JyYWRmaXR6aW5jMRIwEAYDVQQDEwlsb2NhbGhvc3QxHTAbBgkqhkiG9w0BCQEW -DmJyYWRAZGFuZ2EuY29tMB4XDTE0MDcxNTIwNTAyN1oXDTE1MTEyNzIwNTAyN1ow -RzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQHEwJTRjEeMBwGA1UE -ChMVYnJhZGZpdHogaHR0cDIgc2VydmVyMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A -MIIBCgKCAQEAs1Y9CyLFrdL8VQWN1WaifDqaZFnoqjHhCMlc1TfG2zA+InDifx2l -gZD3o8FeNnAcfM2sPlk3+ZleOYw9P/CklFVDlvqmpCv9ss/BEp/dDaWvy1LmJ4c2 -dbQJfmTxn7CV1H3TsVJvKdwFmdoABb41NoBp6+NNO7OtDyhbIMiCI0pL3Nefb3HL -A7hIMo3DYbORTtJLTIH9W8YKrEWL0lwHLrYFx/UdutZnv+HjdmO6vCN4na55mjws -/vjKQUmc7xeY7Xe20xDEG2oDKVkL2eD7FfyrYMS3rO1ExP2KSqlXYG/1S9I/fz88 -F0GK7HX55b5WjZCl2J3ERVdnv/0MQv+sYQIDAQABMA0GCSqGSIb3DQEBBQUAA4IB -AQC0zL+n/YpRZOdulSu9tS8FxrstXqGWoxfe+vIUgqfMZ5+0MkjJ/vW0FqlLDl2R -rn4XaR3e7FmWkwdDVbq/UB6lPmoAaFkCgh9/5oapMaclNVNnfF3fjCJfRr+qj/iD -EmJStTIN0ZuUjAlpiACmfnpEU55PafT5Zx+i1yE4FGjw8bJpFoyD4Hnm54nGjX19 -KeCuvcYFUPnBm3lcL0FalF2AjqV02WTHYNQk7YF/oeO7NKBoEgvGvKG3x+xaOeBI -dwvdq175ZsGul30h+QjrRlXhH/twcuaT3GSdoysDl9cCYE8f1Mk8PD6gan3uBCJU -90p6/CbU71bGbfpM2PHot2fm ------END CERTIFICATE----- diff --git a/vendor/golang.org/x/net/http2/h2demo/server.key b/vendor/golang.org/x/net/http2/h2demo/server.key deleted file mode 100644 index f329c14..0000000 --- a/vendor/golang.org/x/net/http2/h2demo/server.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEowIBAAKCAQEAs1Y9CyLFrdL8VQWN1WaifDqaZFnoqjHhCMlc1TfG2zA+InDi -fx2lgZD3o8FeNnAcfM2sPlk3+ZleOYw9P/CklFVDlvqmpCv9ss/BEp/dDaWvy1Lm -J4c2dbQJfmTxn7CV1H3TsVJvKdwFmdoABb41NoBp6+NNO7OtDyhbIMiCI0pL3Nef -b3HLA7hIMo3DYbORTtJLTIH9W8YKrEWL0lwHLrYFx/UdutZnv+HjdmO6vCN4na55 -mjws/vjKQUmc7xeY7Xe20xDEG2oDKVkL2eD7FfyrYMS3rO1ExP2KSqlXYG/1S9I/ -fz88F0GK7HX55b5WjZCl2J3ERVdnv/0MQv+sYQIDAQABAoIBADQ2spUwbY+bcz4p -3M66ECrNQTBggP40gYl2XyHxGGOu2xhZ94f9ELf1hjRWU2DUKWco1rJcdZClV6q3 -qwmXvcM2Q/SMS8JW0ImkNVl/0/NqPxGatEnj8zY30d/L8hGFb0orzFu/XYA5gCP4 -NbN2WrXgk3ZLeqwcNxHHtSiJWGJ/fPyeDWAu/apy75u9Xf2GlzBZmV6HYD9EfK80 -LTlI60f5FO487CrJnboL7ovPJrIHn+k05xRQqwma4orpz932rTXnTjs9Lg6KtbQN -a7PrqfAntIISgr11a66Mng3IYH1lYqJsWJJwX/xHT4WLEy0EH4/0+PfYemJekz2+ -Co62drECgYEA6O9zVJZXrLSDsIi54cfxA7nEZWm5CAtkYWeAHa4EJ+IlZ7gIf9sL -W8oFcEfFGpvwVqWZ+AsQ70dsjXAv3zXaG0tmg9FtqWp7pzRSMPidifZcQwWkKeTO -gJnFmnVyed8h6GfjTEu4gxo1/S5U0V+mYSha01z5NTnN6ltKx1Or3b0CgYEAxRgm -S30nZxnyg/V7ys61AZhst1DG2tkZXEMcA7dYhabMoXPJAP/EfhlWwpWYYUs/u0gS -Wwmf5IivX5TlYScgmkvb/NYz0u4ZmOXkLTnLPtdKKFXhjXJcHjUP67jYmOxNlJLp -V4vLRnFxTpffAV+OszzRxsXX6fvruwZBANYJeXUCgYBVouLFsFgfWGYp2rpr9XP4 -KK25kvrBqF6JKOIDB1zjxNJ3pUMKrl8oqccCFoCyXa4oTM2kUX0yWxHfleUjrMq4 -yimwQKiOZmV7fVLSSjSw6e/VfBd0h3gb82ygcplZkN0IclkwTY5SNKqwn/3y07V5 -drqdhkrgdJXtmQ6O5YYECQKBgATERcDToQ1USlI4sKrB/wyv1AlG8dg/IebiVJ4e -ZAyvcQmClFzq0qS+FiQUnB/WQw9TeeYrwGs1hxBHuJh16srwhLyDrbMvQP06qh8R -48F8UXXSRec22dV9MQphaROhu2qZdv1AC0WD3tqov6L33aqmEOi+xi8JgbT/PLk5 -c/c1AoGBAI1A/02ryksW6/wc7/6SP2M2rTy4m1sD/GnrTc67EHnRcVBdKO6qH2RY -nqC8YcveC2ZghgPTDsA3VGuzuBXpwY6wTyV99q6jxQJ6/xcrD9/NUG6Uwv/xfCxl -IJLeBYEqQundSSny3VtaAUK8Ul1nxpTvVRNwtcyWTo8RHAAyNPWd ------END RSA PRIVATE KEY----- diff --git a/vendor/golang.org/x/net/http2/h2i/README.md b/vendor/golang.org/x/net/http2/h2i/README.md deleted file mode 100644 index fb5c5ef..0000000 --- a/vendor/golang.org/x/net/http2/h2i/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# h2i - -**h2i** is an interactive HTTP/2 ("h2") console debugger. Miss the good ol' -days of telnetting to your HTTP/1.n servers? We're bringing you -back. - -Features: -- send raw HTTP/2 frames - - PING - - SETTINGS - - HEADERS - - etc -- type in HTTP/1.n and have it auto-HPACK/frame-ify it for HTTP/2 -- pretty print all received HTTP/2 frames from the peer (including HPACK decoding) -- tab completion of commands, options - -Not yet features, but soon: -- unnecessary CONTINUATION frames on short boundaries, to test peer implementations -- request bodies (DATA frames) -- send invalid frames for testing server implementations (supported by underlying Framer) - -Later: -- act like a server - -## Installation - -``` -$ go get golang.org/x/net/http2/h2i -$ h2i -``` - -## Demo - -``` -$ h2i -Usage: h2i - - -insecure - Whether to skip TLS cert validation - -nextproto string - Comma-separated list of NPN/ALPN protocol names to negotiate. (default "h2,h2-14") - -$ h2i google.com -Connecting to google.com:443 ... -Connected to 74.125.224.41:443 -Negotiated protocol "h2-14" -[FrameHeader SETTINGS len=18] - [MAX_CONCURRENT_STREAMS = 100] - [INITIAL_WINDOW_SIZE = 1048576] - [MAX_FRAME_SIZE = 16384] -[FrameHeader WINDOW_UPDATE len=4] - Window-Increment = 983041 - -h2i> PING h2iSayHI -[FrameHeader PING flags=ACK len=8] - Data = "h2iSayHI" -h2i> headers -(as HTTP/1.1)> GET / HTTP/1.1 -(as HTTP/1.1)> Host: ip.appspot.com -(as HTTP/1.1)> User-Agent: h2i/brad-n-blake -(as HTTP/1.1)> -Opening Stream-ID 1: - :authority = ip.appspot.com - :method = GET - :path = / - :scheme = https - user-agent = h2i/brad-n-blake -[FrameHeader HEADERS flags=END_HEADERS stream=1 len=77] - :status = "200" - alternate-protocol = "443:quic,p=1" - content-length = "15" - content-type = "text/html" - date = "Fri, 01 May 2015 23:06:56 GMT" - server = "Google Frontend" -[FrameHeader DATA flags=END_STREAM stream=1 len=15] - "173.164.155.78\n" -[FrameHeader PING len=8] - Data = "\x00\x00\x00\x00\x00\x00\x00\x00" -h2i> ping -[FrameHeader PING flags=ACK len=8] - Data = "h2i_ping" -h2i> ping -[FrameHeader PING flags=ACK len=8] - Data = "h2i_ping" -h2i> ping -[FrameHeader GOAWAY len=22] - Last-Stream-ID = 1; Error-Code = PROTOCOL_ERROR (1) - -ReadFrame: EOF -``` - -## Status - -Quick few hour hack. So much yet to do. Feel free to file issues for -bugs or wishlist items, but [@bmizerany](https://github.com/bmizerany/) -and I aren't yet accepting pull requests until things settle down. - diff --git a/vendor/golang.org/x/net/http2/h2i/h2i.go b/vendor/golang.org/x/net/http2/h2i/h2i.go deleted file mode 100644 index b70976f..0000000 --- a/vendor/golang.org/x/net/http2/h2i/h2i.go +++ /dev/null @@ -1,501 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !plan9,!solaris - -/* -The h2i command is an interactive HTTP/2 console. - -Usage: - $ h2i [flags] - -Interactive commands in the console: (all parts case-insensitive) - - ping [data] - settings ack - settings FOO=n BAR=z - headers (open a new stream by typing HTTP/1.1) -*/ -package main - -import ( - "bufio" - "bytes" - "crypto/tls" - "errors" - "flag" - "fmt" - "io" - "log" - "net" - "net/http" - "os" - "regexp" - "strconv" - "strings" - - "golang.org/x/crypto/ssh/terminal" - "golang.org/x/net/http2" - "golang.org/x/net/http2/hpack" -) - -// Flags -var ( - flagNextProto = flag.String("nextproto", "h2,h2-14", "Comma-separated list of NPN/ALPN protocol names to negotiate.") - flagInsecure = flag.Bool("insecure", false, "Whether to skip TLS cert validation") - flagSettings = flag.String("settings", "empty", "comma-separated list of KEY=value settings for the initial SETTINGS frame. The magic value 'empty' sends an empty initial settings frame, and the magic value 'omit' causes no initial settings frame to be sent.") -) - -type command struct { - run func(*h2i, []string) error // required - - // complete optionally specifies tokens (case-insensitive) which are - // valid for this subcommand. - complete func() []string -} - -var commands = map[string]command{ - "ping": {run: (*h2i).cmdPing}, - "settings": { - run: (*h2i).cmdSettings, - complete: func() []string { - return []string{ - "ACK", - http2.SettingHeaderTableSize.String(), - http2.SettingEnablePush.String(), - http2.SettingMaxConcurrentStreams.String(), - http2.SettingInitialWindowSize.String(), - http2.SettingMaxFrameSize.String(), - http2.SettingMaxHeaderListSize.String(), - } - }, - }, - "quit": {run: (*h2i).cmdQuit}, - "headers": {run: (*h2i).cmdHeaders}, -} - -func usage() { - fmt.Fprintf(os.Stderr, "Usage: h2i \n\n") - flag.PrintDefaults() -} - -// withPort adds ":443" if another port isn't already present. -func withPort(host string) string { - if _, _, err := net.SplitHostPort(host); err != nil { - return net.JoinHostPort(host, "443") - } - return host -} - -// h2i is the app's state. -type h2i struct { - host string - tc *tls.Conn - framer *http2.Framer - term *terminal.Terminal - - // owned by the command loop: - streamID uint32 - hbuf bytes.Buffer - henc *hpack.Encoder - - // owned by the readFrames loop: - peerSetting map[http2.SettingID]uint32 - hdec *hpack.Decoder -} - -func main() { - flag.Usage = usage - flag.Parse() - if flag.NArg() != 1 { - usage() - os.Exit(2) - } - log.SetFlags(0) - - host := flag.Arg(0) - app := &h2i{ - host: host, - peerSetting: make(map[http2.SettingID]uint32), - } - app.henc = hpack.NewEncoder(&app.hbuf) - - if err := app.Main(); err != nil { - if app.term != nil { - app.logf("%v\n", err) - } else { - fmt.Fprintf(os.Stderr, "%v\n", err) - } - os.Exit(1) - } - fmt.Fprintf(os.Stdout, "\n") -} - -func (app *h2i) Main() error { - cfg := &tls.Config{ - ServerName: app.host, - NextProtos: strings.Split(*flagNextProto, ","), - InsecureSkipVerify: *flagInsecure, - } - - hostAndPort := withPort(app.host) - log.Printf("Connecting to %s ...", hostAndPort) - tc, err := tls.Dial("tcp", hostAndPort, cfg) - if err != nil { - return fmt.Errorf("Error dialing %s: %v", withPort(app.host), err) - } - log.Printf("Connected to %v", tc.RemoteAddr()) - defer tc.Close() - - if err := tc.Handshake(); err != nil { - return fmt.Errorf("TLS handshake: %v", err) - } - if !*flagInsecure { - if err := tc.VerifyHostname(app.host); err != nil { - return fmt.Errorf("VerifyHostname: %v", err) - } - } - state := tc.ConnectionState() - log.Printf("Negotiated protocol %q", state.NegotiatedProtocol) - if !state.NegotiatedProtocolIsMutual || state.NegotiatedProtocol == "" { - return fmt.Errorf("Could not negotiate protocol mutually") - } - - if _, err := io.WriteString(tc, http2.ClientPreface); err != nil { - return err - } - - app.framer = http2.NewFramer(tc, tc) - - oldState, err := terminal.MakeRaw(0) - if err != nil { - return err - } - defer terminal.Restore(0, oldState) - - var screen = struct { - io.Reader - io.Writer - }{os.Stdin, os.Stdout} - - app.term = terminal.NewTerminal(screen, "h2i> ") - lastWord := regexp.MustCompile(`.+\W(\w+)$`) - app.term.AutoCompleteCallback = func(line string, pos int, key rune) (newLine string, newPos int, ok bool) { - if key != '\t' { - return - } - if pos != len(line) { - // TODO: we're being lazy for now, only supporting tab completion at the end. - return - } - // Auto-complete for the command itself. - if !strings.Contains(line, " ") { - var name string - name, _, ok = lookupCommand(line) - if !ok { - return - } - return name, len(name), true - } - _, c, ok := lookupCommand(line[:strings.IndexByte(line, ' ')]) - if !ok || c.complete == nil { - return - } - if strings.HasSuffix(line, " ") { - app.logf("%s", strings.Join(c.complete(), " ")) - return line, pos, true - } - m := lastWord.FindStringSubmatch(line) - if m == nil { - return line, len(line), true - } - soFar := m[1] - var match []string - for _, cand := range c.complete() { - if len(soFar) > len(cand) || !strings.EqualFold(cand[:len(soFar)], soFar) { - continue - } - match = append(match, cand) - } - if len(match) == 0 { - return - } - if len(match) > 1 { - // TODO: auto-complete any common prefix - app.logf("%s", strings.Join(match, " ")) - return line, pos, true - } - newLine = line[:len(line)-len(soFar)] + match[0] - return newLine, len(newLine), true - - } - - errc := make(chan error, 2) - go func() { errc <- app.readFrames() }() - go func() { errc <- app.readConsole() }() - return <-errc -} - -func (app *h2i) logf(format string, args ...interface{}) { - fmt.Fprintf(app.term, format+"\n", args...) -} - -func (app *h2i) readConsole() error { - if s := *flagSettings; s != "omit" { - var args []string - if s != "empty" { - args = strings.Split(s, ",") - } - _, c, ok := lookupCommand("settings") - if !ok { - panic("settings command not found") - } - c.run(app, args) - } - - for { - line, err := app.term.ReadLine() - if err == io.EOF { - return nil - } - if err != nil { - return fmt.Errorf("terminal.ReadLine: %v", err) - } - f := strings.Fields(line) - if len(f) == 0 { - continue - } - cmd, args := f[0], f[1:] - if _, c, ok := lookupCommand(cmd); ok { - err = c.run(app, args) - } else { - app.logf("Unknown command %q", line) - } - if err == errExitApp { - return nil - } - if err != nil { - return err - } - } -} - -func lookupCommand(prefix string) (name string, c command, ok bool) { - prefix = strings.ToLower(prefix) - if c, ok = commands[prefix]; ok { - return prefix, c, ok - } - - for full, candidate := range commands { - if strings.HasPrefix(full, prefix) { - if c.run != nil { - return "", command{}, false // ambiguous - } - c = candidate - name = full - } - } - return name, c, c.run != nil -} - -var errExitApp = errors.New("internal sentinel error value to quit the console reading loop") - -func (a *h2i) cmdQuit(args []string) error { - if len(args) > 0 { - a.logf("the QUIT command takes no argument") - return nil - } - return errExitApp -} - -func (a *h2i) cmdSettings(args []string) error { - if len(args) == 1 && strings.EqualFold(args[0], "ACK") { - return a.framer.WriteSettingsAck() - } - var settings []http2.Setting - for _, arg := range args { - if strings.EqualFold(arg, "ACK") { - a.logf("Error: ACK must be only argument with the SETTINGS command") - return nil - } - eq := strings.Index(arg, "=") - if eq == -1 { - a.logf("Error: invalid argument %q (expected SETTING_NAME=nnnn)", arg) - return nil - } - sid, ok := settingByName(arg[:eq]) - if !ok { - a.logf("Error: unknown setting name %q", arg[:eq]) - return nil - } - val, err := strconv.ParseUint(arg[eq+1:], 10, 32) - if err != nil { - a.logf("Error: invalid argument %q (expected SETTING_NAME=nnnn)", arg) - return nil - } - settings = append(settings, http2.Setting{ - ID: sid, - Val: uint32(val), - }) - } - a.logf("Sending: %v", settings) - return a.framer.WriteSettings(settings...) -} - -func settingByName(name string) (http2.SettingID, bool) { - for _, sid := range [...]http2.SettingID{ - http2.SettingHeaderTableSize, - http2.SettingEnablePush, - http2.SettingMaxConcurrentStreams, - http2.SettingInitialWindowSize, - http2.SettingMaxFrameSize, - http2.SettingMaxHeaderListSize, - } { - if strings.EqualFold(sid.String(), name) { - return sid, true - } - } - return 0, false -} - -func (app *h2i) cmdPing(args []string) error { - if len(args) > 1 { - app.logf("invalid PING usage: only accepts 0 or 1 args") - return nil // nil means don't end the program - } - var data [8]byte - if len(args) == 1 { - copy(data[:], args[0]) - } else { - copy(data[:], "h2i_ping") - } - return app.framer.WritePing(false, data) -} - -func (app *h2i) cmdHeaders(args []string) error { - if len(args) > 0 { - app.logf("Error: HEADERS doesn't yet take arguments.") - // TODO: flags for restricting window size, to force CONTINUATION - // frames. - return nil - } - var h1req bytes.Buffer - app.term.SetPrompt("(as HTTP/1.1)> ") - defer app.term.SetPrompt("h2i> ") - for { - line, err := app.term.ReadLine() - if err != nil { - return err - } - h1req.WriteString(line) - h1req.WriteString("\r\n") - if line == "" { - break - } - } - req, err := http.ReadRequest(bufio.NewReader(&h1req)) - if err != nil { - app.logf("Invalid HTTP/1.1 request: %v", err) - return nil - } - if app.streamID == 0 { - app.streamID = 1 - } else { - app.streamID += 2 - } - app.logf("Opening Stream-ID %d:", app.streamID) - hbf := app.encodeHeaders(req) - if len(hbf) > 16<<10 { - app.logf("TODO: h2i doesn't yet write CONTINUATION frames. Copy it from transport.go") - return nil - } - return app.framer.WriteHeaders(http2.HeadersFrameParam{ - StreamID: app.streamID, - BlockFragment: hbf, - EndStream: req.Method == "GET" || req.Method == "HEAD", // good enough for now - EndHeaders: true, // for now - }) -} - -func (app *h2i) readFrames() error { - for { - f, err := app.framer.ReadFrame() - if err != nil { - return fmt.Errorf("ReadFrame: %v", err) - } - app.logf("%v", f) - switch f := f.(type) { - case *http2.PingFrame: - app.logf(" Data = %q", f.Data) - case *http2.SettingsFrame: - f.ForeachSetting(func(s http2.Setting) error { - app.logf(" %v", s) - app.peerSetting[s.ID] = s.Val - return nil - }) - case *http2.WindowUpdateFrame: - app.logf(" Window-Increment = %v\n", f.Increment) - case *http2.GoAwayFrame: - app.logf(" Last-Stream-ID = %d; Error-Code = %v (%d)\n", f.LastStreamID, f.ErrCode, f.ErrCode) - case *http2.DataFrame: - app.logf(" %q", f.Data()) - case *http2.HeadersFrame: - if f.HasPriority() { - app.logf(" PRIORITY = %v", f.Priority) - } - if app.hdec == nil { - // TODO: if the user uses h2i to send a SETTINGS frame advertising - // something larger, we'll need to respect SETTINGS_HEADER_TABLE_SIZE - // and stuff here instead of using the 4k default. But for now: - tableSize := uint32(4 << 10) - app.hdec = hpack.NewDecoder(tableSize, app.onNewHeaderField) - } - app.hdec.Write(f.HeaderBlockFragment()) - } - } -} - -// called from readLoop -func (app *h2i) onNewHeaderField(f hpack.HeaderField) { - if f.Sensitive { - app.logf(" %s = %q (SENSITIVE)", f.Name, f.Value) - } - app.logf(" %s = %q", f.Name, f.Value) -} - -func (app *h2i) encodeHeaders(req *http.Request) []byte { - app.hbuf.Reset() - - // TODO(bradfitz): figure out :authority-vs-Host stuff between http2 and Go - host := req.Host - if host == "" { - host = req.URL.Host - } - - path := req.URL.Path - if path == "" { - path = "/" - } - - app.writeHeader(":authority", host) // probably not right for all sites - app.writeHeader(":method", req.Method) - app.writeHeader(":path", path) - app.writeHeader(":scheme", "https") - - for k, vv := range req.Header { - lowKey := strings.ToLower(k) - if lowKey == "host" { - continue - } - for _, v := range vv { - app.writeHeader(lowKey, v) - } - } - return app.hbuf.Bytes() -} - -func (app *h2i) writeHeader(name, value string) { - app.henc.WriteField(hpack.HeaderField{Name: name, Value: value}) - app.logf(" %s = %s", name, value) -} diff --git a/vendor/golang.org/x/net/http2/headermap.go b/vendor/golang.org/x/net/http2/headermap.go deleted file mode 100644 index c2805f6..0000000 --- a/vendor/golang.org/x/net/http2/headermap.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "net/http" - "strings" -) - -var ( - commonLowerHeader = map[string]string{} // Go-Canonical-Case -> lower-case - commonCanonHeader = map[string]string{} // lower-case -> Go-Canonical-Case -) - -func init() { - for _, v := range []string{ - "accept", - "accept-charset", - "accept-encoding", - "accept-language", - "accept-ranges", - "age", - "access-control-allow-origin", - "allow", - "authorization", - "cache-control", - "content-disposition", - "content-encoding", - "content-language", - "content-length", - "content-location", - "content-range", - "content-type", - "cookie", - "date", - "etag", - "expect", - "expires", - "from", - "host", - "if-match", - "if-modified-since", - "if-none-match", - "if-unmodified-since", - "last-modified", - "link", - "location", - "max-forwards", - "proxy-authenticate", - "proxy-authorization", - "range", - "referer", - "refresh", - "retry-after", - "server", - "set-cookie", - "strict-transport-security", - "trailer", - "transfer-encoding", - "user-agent", - "vary", - "via", - "www-authenticate", - } { - chk := http.CanonicalHeaderKey(v) - commonLowerHeader[chk] = v - commonCanonHeader[v] = chk - } -} - -func lowerHeader(v string) string { - if s, ok := commonLowerHeader[v]; ok { - return s - } - return strings.ToLower(v) -} diff --git a/vendor/golang.org/x/net/http2/hpack/encode.go b/vendor/golang.org/x/net/http2/hpack/encode.go deleted file mode 100644 index f9bb033..0000000 --- a/vendor/golang.org/x/net/http2/hpack/encode.go +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "io" -) - -const ( - uint32Max = ^uint32(0) - initialHeaderTableSize = 4096 -) - -type Encoder struct { - dynTab dynamicTable - // minSize is the minimum table size set by - // SetMaxDynamicTableSize after the previous Header Table Size - // Update. - minSize uint32 - // maxSizeLimit is the maximum table size this encoder - // supports. This will protect the encoder from too large - // size. - maxSizeLimit uint32 - // tableSizeUpdate indicates whether "Header Table Size - // Update" is required. - tableSizeUpdate bool - w io.Writer - buf []byte -} - -// NewEncoder returns a new Encoder which performs HPACK encoding. An -// encoded data is written to w. -func NewEncoder(w io.Writer) *Encoder { - e := &Encoder{ - minSize: uint32Max, - maxSizeLimit: initialHeaderTableSize, - tableSizeUpdate: false, - w: w, - } - e.dynTab.setMaxSize(initialHeaderTableSize) - return e -} - -// WriteField encodes f into a single Write to e's underlying Writer. -// This function may also produce bytes for "Header Table Size Update" -// if necessary. If produced, it is done before encoding f. -func (e *Encoder) WriteField(f HeaderField) error { - e.buf = e.buf[:0] - - if e.tableSizeUpdate { - e.tableSizeUpdate = false - if e.minSize < e.dynTab.maxSize { - e.buf = appendTableSize(e.buf, e.minSize) - } - e.minSize = uint32Max - e.buf = appendTableSize(e.buf, e.dynTab.maxSize) - } - - idx, nameValueMatch := e.searchTable(f) - if nameValueMatch { - e.buf = appendIndexed(e.buf, idx) - } else { - indexing := e.shouldIndex(f) - if indexing { - e.dynTab.add(f) - } - - if idx == 0 { - e.buf = appendNewName(e.buf, f, indexing) - } else { - e.buf = appendIndexedName(e.buf, f, idx, indexing) - } - } - n, err := e.w.Write(e.buf) - if err == nil && n != len(e.buf) { - err = io.ErrShortWrite - } - return err -} - -// searchTable searches f in both stable and dynamic header tables. -// The static header table is searched first. Only when there is no -// exact match for both name and value, the dynamic header table is -// then searched. If there is no match, i is 0. If both name and value -// match, i is the matched index and nameValueMatch becomes true. If -// only name matches, i points to that index and nameValueMatch -// becomes false. -func (e *Encoder) searchTable(f HeaderField) (i uint64, nameValueMatch bool) { - for idx, hf := range staticTable { - if !constantTimeStringCompare(hf.Name, f.Name) { - continue - } - if i == 0 { - i = uint64(idx + 1) - } - if f.Sensitive { - continue - } - if !constantTimeStringCompare(hf.Value, f.Value) { - continue - } - i = uint64(idx + 1) - nameValueMatch = true - return - } - - j, nameValueMatch := e.dynTab.search(f) - if nameValueMatch || (i == 0 && j != 0) { - i = j + uint64(len(staticTable)) - } - return -} - -// SetMaxDynamicTableSize changes the dynamic header table size to v. -// The actual size is bounded by the value passed to -// SetMaxDynamicTableSizeLimit. -func (e *Encoder) SetMaxDynamicTableSize(v uint32) { - if v > e.maxSizeLimit { - v = e.maxSizeLimit - } - if v < e.minSize { - e.minSize = v - } - e.tableSizeUpdate = true - e.dynTab.setMaxSize(v) -} - -// SetMaxDynamicTableSizeLimit changes the maximum value that can be -// specified in SetMaxDynamicTableSize to v. By default, it is set to -// 4096, which is the same size of the default dynamic header table -// size described in HPACK specification. If the current maximum -// dynamic header table size is strictly greater than v, "Header Table -// Size Update" will be done in the next WriteField call and the -// maximum dynamic header table size is truncated to v. -func (e *Encoder) SetMaxDynamicTableSizeLimit(v uint32) { - e.maxSizeLimit = v - if e.dynTab.maxSize > v { - e.tableSizeUpdate = true - e.dynTab.setMaxSize(v) - } -} - -// shouldIndex reports whether f should be indexed. -func (e *Encoder) shouldIndex(f HeaderField) bool { - return !f.Sensitive && f.Size() <= e.dynTab.maxSize -} - -// appendIndexed appends index i, as encoded in "Indexed Header Field" -// representation, to dst and returns the extended buffer. -func appendIndexed(dst []byte, i uint64) []byte { - first := len(dst) - dst = appendVarInt(dst, 7, i) - dst[first] |= 0x80 - return dst -} - -// appendNewName appends f, as encoded in one of "Literal Header field -// - New Name" representation variants, to dst and returns the -// extended buffer. -// -// If f.Sensitive is true, "Never Indexed" representation is used. If -// f.Sensitive is false and indexing is true, "Inremental Indexing" -// representation is used. -func appendNewName(dst []byte, f HeaderField, indexing bool) []byte { - dst = append(dst, encodeTypeByte(indexing, f.Sensitive)) - dst = appendHpackString(dst, f.Name) - return appendHpackString(dst, f.Value) -} - -// appendIndexedName appends f and index i referring indexed name -// entry, as encoded in one of "Literal Header field - Indexed Name" -// representation variants, to dst and returns the extended buffer. -// -// If f.Sensitive is true, "Never Indexed" representation is used. If -// f.Sensitive is false and indexing is true, "Incremental Indexing" -// representation is used. -func appendIndexedName(dst []byte, f HeaderField, i uint64, indexing bool) []byte { - first := len(dst) - var n byte - if indexing { - n = 6 - } else { - n = 4 - } - dst = appendVarInt(dst, n, i) - dst[first] |= encodeTypeByte(indexing, f.Sensitive) - return appendHpackString(dst, f.Value) -} - -// appendTableSize appends v, as encoded in "Header Table Size Update" -// representation, to dst and returns the extended buffer. -func appendTableSize(dst []byte, v uint32) []byte { - first := len(dst) - dst = appendVarInt(dst, 5, uint64(v)) - dst[first] |= 0x20 - return dst -} - -// appendVarInt appends i, as encoded in variable integer form using n -// bit prefix, to dst and returns the extended buffer. -// -// See -// http://http2.github.io/http2-spec/compression.html#integer.representation -func appendVarInt(dst []byte, n byte, i uint64) []byte { - k := uint64((1 << n) - 1) - if i < k { - return append(dst, byte(i)) - } - dst = append(dst, byte(k)) - i -= k - for ; i >= 128; i >>= 7 { - dst = append(dst, byte(0x80|(i&0x7f))) - } - return append(dst, byte(i)) -} - -// appendHpackString appends s, as encoded in "String Literal" -// representation, to dst and returns the the extended buffer. -// -// s will be encoded in Huffman codes only when it produces strictly -// shorter byte string. -func appendHpackString(dst []byte, s string) []byte { - huffmanLength := HuffmanEncodeLength(s) - if huffmanLength < uint64(len(s)) { - first := len(dst) - dst = appendVarInt(dst, 7, huffmanLength) - dst = AppendHuffmanString(dst, s) - dst[first] |= 0x80 - } else { - dst = appendVarInt(dst, 7, uint64(len(s))) - dst = append(dst, s...) - } - return dst -} - -// encodeTypeByte returns type byte. If sensitive is true, type byte -// for "Never Indexed" representation is returned. If sensitive is -// false and indexing is true, type byte for "Incremental Indexing" -// representation is returned. Otherwise, type byte for "Without -// Indexing" is returned. -func encodeTypeByte(indexing, sensitive bool) byte { - if sensitive { - return 0x10 - } - if indexing { - return 0x40 - } - return 0 -} diff --git a/vendor/golang.org/x/net/http2/hpack/encode_test.go b/vendor/golang.org/x/net/http2/hpack/encode_test.go deleted file mode 100644 index 92286f3..0000000 --- a/vendor/golang.org/x/net/http2/hpack/encode_test.go +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "bytes" - "encoding/hex" - "reflect" - "strings" - "testing" -) - -func TestEncoderTableSizeUpdate(t *testing.T) { - tests := []struct { - size1, size2 uint32 - wantHex string - }{ - // Should emit 2 table size updates (2048 and 4096) - {2048, 4096, "3fe10f 3fe11f 82"}, - - // Should emit 1 table size update (2048) - {16384, 2048, "3fe10f 82"}, - } - for _, tt := range tests { - var buf bytes.Buffer - e := NewEncoder(&buf) - e.SetMaxDynamicTableSize(tt.size1) - e.SetMaxDynamicTableSize(tt.size2) - if err := e.WriteField(pair(":method", "GET")); err != nil { - t.Fatal(err) - } - want := removeSpace(tt.wantHex) - if got := hex.EncodeToString(buf.Bytes()); got != want { - t.Errorf("e.SetDynamicTableSize %v, %v = %q; want %q", tt.size1, tt.size2, got, want) - } - } -} - -func TestEncoderWriteField(t *testing.T) { - var buf bytes.Buffer - e := NewEncoder(&buf) - var got []HeaderField - d := NewDecoder(4<<10, func(f HeaderField) { - got = append(got, f) - }) - - tests := []struct { - hdrs []HeaderField - }{ - {[]HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - }}, - {[]HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - pair("cache-control", "no-cache"), - }}, - {[]HeaderField{ - pair(":method", "GET"), - pair(":scheme", "https"), - pair(":path", "/index.html"), - pair(":authority", "www.example.com"), - pair("custom-key", "custom-value"), - }}, - } - for i, tt := range tests { - buf.Reset() - got = got[:0] - for _, hf := range tt.hdrs { - if err := e.WriteField(hf); err != nil { - t.Fatal(err) - } - } - _, err := d.Write(buf.Bytes()) - if err != nil { - t.Errorf("%d. Decoder Write = %v", i, err) - } - if !reflect.DeepEqual(got, tt.hdrs) { - t.Errorf("%d. Decoded %+v; want %+v", i, got, tt.hdrs) - } - } -} - -func TestEncoderSearchTable(t *testing.T) { - e := NewEncoder(nil) - - e.dynTab.add(pair("foo", "bar")) - e.dynTab.add(pair("blake", "miz")) - e.dynTab.add(pair(":method", "GET")) - - tests := []struct { - hf HeaderField - wantI uint64 - wantMatch bool - }{ - // Name and Value match - {pair("foo", "bar"), uint64(len(staticTable) + 3), true}, - {pair("blake", "miz"), uint64(len(staticTable) + 2), true}, - {pair(":method", "GET"), 2, true}, - - // Only name match because Sensitive == true - {HeaderField{":method", "GET", true}, 2, false}, - - // Only Name matches - {pair("foo", "..."), uint64(len(staticTable) + 3), false}, - {pair("blake", "..."), uint64(len(staticTable) + 2), false}, - {pair(":method", "..."), 2, false}, - - // None match - {pair("foo-", "bar"), 0, false}, - } - for _, tt := range tests { - if gotI, gotMatch := e.searchTable(tt.hf); gotI != tt.wantI || gotMatch != tt.wantMatch { - t.Errorf("d.search(%+v) = %v, %v; want %v, %v", tt.hf, gotI, gotMatch, tt.wantI, tt.wantMatch) - } - } -} - -func TestAppendVarInt(t *testing.T) { - tests := []struct { - n byte - i uint64 - want []byte - }{ - // Fits in a byte: - {1, 0, []byte{0}}, - {2, 2, []byte{2}}, - {3, 6, []byte{6}}, - {4, 14, []byte{14}}, - {5, 30, []byte{30}}, - {6, 62, []byte{62}}, - {7, 126, []byte{126}}, - {8, 254, []byte{254}}, - - // Multiple bytes: - {5, 1337, []byte{31, 154, 10}}, - } - for _, tt := range tests { - got := appendVarInt(nil, tt.n, tt.i) - if !bytes.Equal(got, tt.want) { - t.Errorf("appendVarInt(nil, %v, %v) = %v; want %v", tt.n, tt.i, got, tt.want) - } - } -} - -func TestAppendHpackString(t *testing.T) { - tests := []struct { - s, wantHex string - }{ - // Huffman encoded - {"www.example.com", "8c f1e3 c2e5 f23a 6ba0 ab90 f4ff"}, - - // Not Huffman encoded - {"a", "01 61"}, - - // zero length - {"", "00"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendHpackString(nil, tt.s) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendHpackString(nil, %q) = %q; want %q", tt.s, got, want) - } - } -} - -func TestAppendIndexed(t *testing.T) { - tests := []struct { - i uint64 - wantHex string - }{ - // 1 byte - {1, "81"}, - {126, "fe"}, - - // 2 bytes - {127, "ff00"}, - {128, "ff01"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendIndexed(nil, tt.i) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendIndex(nil, %v) = %q; want %q", tt.i, got, want) - } - } -} - -func TestAppendNewName(t *testing.T) { - tests := []struct { - f HeaderField - indexing bool - wantHex string - }{ - // Incremental indexing - {HeaderField{"custom-key", "custom-value", false}, true, "40 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - - // Without indexing - {HeaderField{"custom-key", "custom-value", false}, false, "00 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - - // Never indexed - {HeaderField{"custom-key", "custom-value", true}, true, "10 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - {HeaderField{"custom-key", "custom-value", true}, false, "10 88 25a8 49e9 5ba9 7d7f 89 25a8 49e9 5bb8 e8b4 bf"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendNewName(nil, tt.f, tt.indexing) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendNewName(nil, %+v, %v) = %q; want %q", tt.f, tt.indexing, got, want) - } - } -} - -func TestAppendIndexedName(t *testing.T) { - tests := []struct { - f HeaderField - i uint64 - indexing bool - wantHex string - }{ - // Incremental indexing - {HeaderField{":status", "302", false}, 8, true, "48 82 6402"}, - - // Without indexing - {HeaderField{":status", "302", false}, 8, false, "08 82 6402"}, - - // Never indexed - {HeaderField{":status", "302", true}, 8, true, "18 82 6402"}, - {HeaderField{":status", "302", true}, 8, false, "18 82 6402"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendIndexedName(nil, tt.f, tt.i, tt.indexing) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendIndexedName(nil, %+v, %v) = %q; want %q", tt.f, tt.indexing, got, want) - } - } -} - -func TestAppendTableSize(t *testing.T) { - tests := []struct { - i uint32 - wantHex string - }{ - // Fits into 1 byte - {30, "3e"}, - - // Extra byte - {31, "3f00"}, - {32, "3f01"}, - } - for _, tt := range tests { - want := removeSpace(tt.wantHex) - buf := appendTableSize(nil, tt.i) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("appendTableSize(nil, %v) = %q; want %q", tt.i, got, want) - } - } -} - -func TestEncoderSetMaxDynamicTableSize(t *testing.T) { - var buf bytes.Buffer - e := NewEncoder(&buf) - tests := []struct { - v uint32 - wantUpdate bool - wantMinSize uint32 - wantMaxSize uint32 - }{ - // Set new table size to 2048 - {2048, true, 2048, 2048}, - - // Set new table size to 16384, but still limited to - // 4096 - {16384, true, 2048, 4096}, - } - for _, tt := range tests { - e.SetMaxDynamicTableSize(tt.v) - if got := e.tableSizeUpdate; tt.wantUpdate != got { - t.Errorf("e.tableSizeUpdate = %v; want %v", got, tt.wantUpdate) - } - if got := e.minSize; tt.wantMinSize != got { - t.Errorf("e.minSize = %v; want %v", got, tt.wantMinSize) - } - if got := e.dynTab.maxSize; tt.wantMaxSize != got { - t.Errorf("e.maxSize = %v; want %v", got, tt.wantMaxSize) - } - } -} - -func TestEncoderSetMaxDynamicTableSizeLimit(t *testing.T) { - e := NewEncoder(nil) - // 4095 < initialHeaderTableSize means maxSize is truncated to - // 4095. - e.SetMaxDynamicTableSizeLimit(4095) - if got, want := e.dynTab.maxSize, uint32(4095); got != want { - t.Errorf("e.dynTab.maxSize = %v; want %v", got, want) - } - if got, want := e.maxSizeLimit, uint32(4095); got != want { - t.Errorf("e.maxSizeLimit = %v; want %v", got, want) - } - if got, want := e.tableSizeUpdate, true; got != want { - t.Errorf("e.tableSizeUpdate = %v; want %v", got, want) - } - // maxSize will be truncated to maxSizeLimit - e.SetMaxDynamicTableSize(16384) - if got, want := e.dynTab.maxSize, uint32(4095); got != want { - t.Errorf("e.dynTab.maxSize = %v; want %v", got, want) - } - // 8192 > current maxSizeLimit, so maxSize does not change. - e.SetMaxDynamicTableSizeLimit(8192) - if got, want := e.dynTab.maxSize, uint32(4095); got != want { - t.Errorf("e.dynTab.maxSize = %v; want %v", got, want) - } - if got, want := e.maxSizeLimit, uint32(8192); got != want { - t.Errorf("e.maxSizeLimit = %v; want %v", got, want) - } -} - -func removeSpace(s string) string { - return strings.Replace(s, " ", "", -1) -} diff --git a/vendor/golang.org/x/net/http2/hpack/hpack.go b/vendor/golang.org/x/net/http2/hpack/hpack.go deleted file mode 100644 index 8aa197a..0000000 --- a/vendor/golang.org/x/net/http2/hpack/hpack.go +++ /dev/null @@ -1,542 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package hpack implements HPACK, a compression format for -// efficiently representing HTTP header fields in the context of HTTP/2. -// -// See http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-09 -package hpack - -import ( - "bytes" - "errors" - "fmt" -) - -// A DecodingError is something the spec defines as a decoding error. -type DecodingError struct { - Err error -} - -func (de DecodingError) Error() string { - return fmt.Sprintf("decoding error: %v", de.Err) -} - -// An InvalidIndexError is returned when an encoder references a table -// entry before the static table or after the end of the dynamic table. -type InvalidIndexError int - -func (e InvalidIndexError) Error() string { - return fmt.Sprintf("invalid indexed representation index %d", int(e)) -} - -// A HeaderField is a name-value pair. Both the name and value are -// treated as opaque sequences of octets. -type HeaderField struct { - Name, Value string - - // Sensitive means that this header field should never be - // indexed. - Sensitive bool -} - -// IsPseudo reports whether the header field is an http2 pseudo header. -// That is, it reports whether it starts with a colon. -// It is not otherwise guaranteed to be a valid pseudo header field, -// though. -func (hf HeaderField) IsPseudo() bool { - return len(hf.Name) != 0 && hf.Name[0] == ':' -} - -func (hf HeaderField) String() string { - var suffix string - if hf.Sensitive { - suffix = " (sensitive)" - } - return fmt.Sprintf("header field %q = %q%s", hf.Name, hf.Value, suffix) -} - -// Size returns the size of an entry per RFC 7540 section 5.2. -func (hf HeaderField) Size() uint32 { - // http://http2.github.io/http2-spec/compression.html#rfc.section.4.1 - // "The size of the dynamic table is the sum of the size of - // its entries. The size of an entry is the sum of its name's - // length in octets (as defined in Section 5.2), its value's - // length in octets (see Section 5.2), plus 32. The size of - // an entry is calculated using the length of the name and - // value without any Huffman encoding applied." - - // This can overflow if somebody makes a large HeaderField - // Name and/or Value by hand, but we don't care, because that - // won't happen on the wire because the encoding doesn't allow - // it. - return uint32(len(hf.Name) + len(hf.Value) + 32) -} - -// A Decoder is the decoding context for incremental processing of -// header blocks. -type Decoder struct { - dynTab dynamicTable - emit func(f HeaderField) - - emitEnabled bool // whether calls to emit are enabled - maxStrLen int // 0 means unlimited - - // buf is the unparsed buffer. It's only written to - // saveBuf if it was truncated in the middle of a header - // block. Because it's usually not owned, we can only - // process it under Write. - buf []byte // not owned; only valid during Write - - // saveBuf is previous data passed to Write which we weren't able - // to fully parse before. Unlike buf, we own this data. - saveBuf bytes.Buffer -} - -// NewDecoder returns a new decoder with the provided maximum dynamic -// table size. The emitFunc will be called for each valid field -// parsed, in the same goroutine as calls to Write, before Write returns. -func NewDecoder(maxDynamicTableSize uint32, emitFunc func(f HeaderField)) *Decoder { - d := &Decoder{ - emit: emitFunc, - emitEnabled: true, - } - d.dynTab.allowedMaxSize = maxDynamicTableSize - d.dynTab.setMaxSize(maxDynamicTableSize) - return d -} - -// ErrStringLength is returned by Decoder.Write when the max string length -// (as configured by Decoder.SetMaxStringLength) would be violated. -var ErrStringLength = errors.New("hpack: string too long") - -// SetMaxStringLength sets the maximum size of a HeaderField name or -// value string. If a string exceeds this length (even after any -// decompression), Write will return ErrStringLength. -// A value of 0 means unlimited and is the default from NewDecoder. -func (d *Decoder) SetMaxStringLength(n int) { - d.maxStrLen = n -} - -// SetEmitFunc changes the callback used when new header fields -// are decoded. -// It must be non-nil. It does not affect EmitEnabled. -func (d *Decoder) SetEmitFunc(emitFunc func(f HeaderField)) { - d.emit = emitFunc -} - -// SetEmitEnabled controls whether the emitFunc provided to NewDecoder -// should be called. The default is true. -// -// This facility exists to let servers enforce MAX_HEADER_LIST_SIZE -// while still decoding and keeping in-sync with decoder state, but -// without doing unnecessary decompression or generating unnecessary -// garbage for header fields past the limit. -func (d *Decoder) SetEmitEnabled(v bool) { d.emitEnabled = v } - -// EmitEnabled reports whether calls to the emitFunc provided to NewDecoder -// are currently enabled. The default is true. -func (d *Decoder) EmitEnabled() bool { return d.emitEnabled } - -// TODO: add method *Decoder.Reset(maxSize, emitFunc) to let callers re-use Decoders and their -// underlying buffers for garbage reasons. - -func (d *Decoder) SetMaxDynamicTableSize(v uint32) { - d.dynTab.setMaxSize(v) -} - -// SetAllowedMaxDynamicTableSize sets the upper bound that the encoded -// stream (via dynamic table size updates) may set the maximum size -// to. -func (d *Decoder) SetAllowedMaxDynamicTableSize(v uint32) { - d.dynTab.allowedMaxSize = v -} - -type dynamicTable struct { - // ents is the FIFO described at - // http://http2.github.io/http2-spec/compression.html#rfc.section.2.3.2 - // The newest (low index) is append at the end, and items are - // evicted from the front. - ents []HeaderField - size uint32 - maxSize uint32 // current maxSize - allowedMaxSize uint32 // maxSize may go up to this, inclusive -} - -func (dt *dynamicTable) setMaxSize(v uint32) { - dt.maxSize = v - dt.evict() -} - -// TODO: change dynamicTable to be a struct with a slice and a size int field, -// per http://http2.github.io/http2-spec/compression.html#rfc.section.4.1: -// -// -// Then make add increment the size. maybe the max size should move from Decoder to -// dynamicTable and add should return an ok bool if there was enough space. -// -// Later we'll need a remove operation on dynamicTable. - -func (dt *dynamicTable) add(f HeaderField) { - dt.ents = append(dt.ents, f) - dt.size += f.Size() - dt.evict() -} - -// If we're too big, evict old stuff (front of the slice) -func (dt *dynamicTable) evict() { - base := dt.ents // keep base pointer of slice - for dt.size > dt.maxSize { - dt.size -= dt.ents[0].Size() - dt.ents = dt.ents[1:] - } - - // Shift slice contents down if we evicted things. - if len(dt.ents) != len(base) { - copy(base, dt.ents) - dt.ents = base[:len(dt.ents)] - } -} - -// constantTimeStringCompare compares string a and b in a constant -// time manner. -func constantTimeStringCompare(a, b string) bool { - if len(a) != len(b) { - return false - } - - c := byte(0) - - for i := 0; i < len(a); i++ { - c |= a[i] ^ b[i] - } - - return c == 0 -} - -// Search searches f in the table. The return value i is 0 if there is -// no name match. If there is name match or name/value match, i is the -// index of that entry (1-based). If both name and value match, -// nameValueMatch becomes true. -func (dt *dynamicTable) search(f HeaderField) (i uint64, nameValueMatch bool) { - l := len(dt.ents) - for j := l - 1; j >= 0; j-- { - ent := dt.ents[j] - if !constantTimeStringCompare(ent.Name, f.Name) { - continue - } - if i == 0 { - i = uint64(l - j) - } - if f.Sensitive { - continue - } - if !constantTimeStringCompare(ent.Value, f.Value) { - continue - } - i = uint64(l - j) - nameValueMatch = true - return - } - return -} - -func (d *Decoder) maxTableIndex() int { - return len(d.dynTab.ents) + len(staticTable) -} - -func (d *Decoder) at(i uint64) (hf HeaderField, ok bool) { - if i < 1 { - return - } - if i > uint64(d.maxTableIndex()) { - return - } - if i <= uint64(len(staticTable)) { - return staticTable[i-1], true - } - dents := d.dynTab.ents - return dents[len(dents)-(int(i)-len(staticTable))], true -} - -// Decode decodes an entire block. -// -// TODO: remove this method and make it incremental later? This is -// easier for debugging now. -func (d *Decoder) DecodeFull(p []byte) ([]HeaderField, error) { - var hf []HeaderField - saveFunc := d.emit - defer func() { d.emit = saveFunc }() - d.emit = func(f HeaderField) { hf = append(hf, f) } - if _, err := d.Write(p); err != nil { - return nil, err - } - if err := d.Close(); err != nil { - return nil, err - } - return hf, nil -} - -func (d *Decoder) Close() error { - if d.saveBuf.Len() > 0 { - d.saveBuf.Reset() - return DecodingError{errors.New("truncated headers")} - } - return nil -} - -func (d *Decoder) Write(p []byte) (n int, err error) { - if len(p) == 0 { - // Prevent state machine CPU attacks (making us redo - // work up to the point of finding out we don't have - // enough data) - return - } - // Only copy the data if we have to. Optimistically assume - // that p will contain a complete header block. - if d.saveBuf.Len() == 0 { - d.buf = p - } else { - d.saveBuf.Write(p) - d.buf = d.saveBuf.Bytes() - d.saveBuf.Reset() - } - - for len(d.buf) > 0 { - err = d.parseHeaderFieldRepr() - if err == errNeedMore { - // Extra paranoia, making sure saveBuf won't - // get too large. All the varint and string - // reading code earlier should already catch - // overlong things and return ErrStringLength, - // but keep this as a last resort. - const varIntOverhead = 8 // conservative - if d.maxStrLen != 0 && int64(len(d.buf)) > 2*(int64(d.maxStrLen)+varIntOverhead) { - return 0, ErrStringLength - } - d.saveBuf.Write(d.buf) - return len(p), nil - } - if err != nil { - break - } - } - return len(p), err -} - -// errNeedMore is an internal sentinel error value that means the -// buffer is truncated and we need to read more data before we can -// continue parsing. -var errNeedMore = errors.New("need more data") - -type indexType int - -const ( - indexedTrue indexType = iota - indexedFalse - indexedNever -) - -func (v indexType) indexed() bool { return v == indexedTrue } -func (v indexType) sensitive() bool { return v == indexedNever } - -// returns errNeedMore if there isn't enough data available. -// any other error is fatal. -// consumes d.buf iff it returns nil. -// precondition: must be called with len(d.buf) > 0 -func (d *Decoder) parseHeaderFieldRepr() error { - b := d.buf[0] - switch { - case b&128 != 0: - // Indexed representation. - // High bit set? - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.1 - return d.parseFieldIndexed() - case b&192 == 64: - // 6.2.1 Literal Header Field with Incremental Indexing - // 0b10xxxxxx: top two bits are 10 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.1 - return d.parseFieldLiteral(6, indexedTrue) - case b&240 == 0: - // 6.2.2 Literal Header Field without Indexing - // 0b0000xxxx: top four bits are 0000 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.2 - return d.parseFieldLiteral(4, indexedFalse) - case b&240 == 16: - // 6.2.3 Literal Header Field never Indexed - // 0b0001xxxx: top four bits are 0001 - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.2.3 - return d.parseFieldLiteral(4, indexedNever) - case b&224 == 32: - // 6.3 Dynamic Table Size Update - // Top three bits are '001'. - // http://http2.github.io/http2-spec/compression.html#rfc.section.6.3 - return d.parseDynamicTableSizeUpdate() - } - - return DecodingError{errors.New("invalid encoding")} -} - -// (same invariants and behavior as parseHeaderFieldRepr) -func (d *Decoder) parseFieldIndexed() error { - buf := d.buf - idx, buf, err := readVarInt(7, buf) - if err != nil { - return err - } - hf, ok := d.at(idx) - if !ok { - return DecodingError{InvalidIndexError(idx)} - } - d.buf = buf - return d.callEmit(HeaderField{Name: hf.Name, Value: hf.Value}) -} - -// (same invariants and behavior as parseHeaderFieldRepr) -func (d *Decoder) parseFieldLiteral(n uint8, it indexType) error { - buf := d.buf - nameIdx, buf, err := readVarInt(n, buf) - if err != nil { - return err - } - - var hf HeaderField - wantStr := d.emitEnabled || it.indexed() - if nameIdx > 0 { - ihf, ok := d.at(nameIdx) - if !ok { - return DecodingError{InvalidIndexError(nameIdx)} - } - hf.Name = ihf.Name - } else { - hf.Name, buf, err = d.readString(buf, wantStr) - if err != nil { - return err - } - } - hf.Value, buf, err = d.readString(buf, wantStr) - if err != nil { - return err - } - d.buf = buf - if it.indexed() { - d.dynTab.add(hf) - } - hf.Sensitive = it.sensitive() - return d.callEmit(hf) -} - -func (d *Decoder) callEmit(hf HeaderField) error { - if d.maxStrLen != 0 { - if len(hf.Name) > d.maxStrLen || len(hf.Value) > d.maxStrLen { - return ErrStringLength - } - } - if d.emitEnabled { - d.emit(hf) - } - return nil -} - -// (same invariants and behavior as parseHeaderFieldRepr) -func (d *Decoder) parseDynamicTableSizeUpdate() error { - buf := d.buf - size, buf, err := readVarInt(5, buf) - if err != nil { - return err - } - if size > uint64(d.dynTab.allowedMaxSize) { - return DecodingError{errors.New("dynamic table size update too large")} - } - d.dynTab.setMaxSize(uint32(size)) - d.buf = buf - return nil -} - -var errVarintOverflow = DecodingError{errors.New("varint integer overflow")} - -// readVarInt reads an unsigned variable length integer off the -// beginning of p. n is the parameter as described in -// http://http2.github.io/http2-spec/compression.html#rfc.section.5.1. -// -// n must always be between 1 and 8. -// -// The returned remain buffer is either a smaller suffix of p, or err != nil. -// The error is errNeedMore if p doesn't contain a complete integer. -func readVarInt(n byte, p []byte) (i uint64, remain []byte, err error) { - if n < 1 || n > 8 { - panic("bad n") - } - if len(p) == 0 { - return 0, p, errNeedMore - } - i = uint64(p[0]) - if n < 8 { - i &= (1 << uint64(n)) - 1 - } - if i < (1< 0 { - b := p[0] - p = p[1:] - i += uint64(b&127) << m - if b&128 == 0 { - return i, p, nil - } - m += 7 - if m >= 63 { // TODO: proper overflow check. making this up. - return 0, origP, errVarintOverflow - } - } - return 0, origP, errNeedMore -} - -// readString decodes an hpack string from p. -// -// wantStr is whether s will be used. If false, decompression and -// []byte->string garbage are skipped if s will be ignored -// anyway. This does mean that huffman decoding errors for non-indexed -// strings past the MAX_HEADER_LIST_SIZE are ignored, but the server -// is returning an error anyway, and because they're not indexed, the error -// won't affect the decoding state. -func (d *Decoder) readString(p []byte, wantStr bool) (s string, remain []byte, err error) { - if len(p) == 0 { - return "", p, errNeedMore - } - isHuff := p[0]&128 != 0 - strLen, p, err := readVarInt(7, p) - if err != nil { - return "", p, err - } - if d.maxStrLen != 0 && strLen > uint64(d.maxStrLen) { - return "", nil, ErrStringLength - } - if uint64(len(p)) < strLen { - return "", p, errNeedMore - } - if !isHuff { - if wantStr { - s = string(p[:strLen]) - } - return s, p[strLen:], nil - } - - if wantStr { - buf := bufPool.Get().(*bytes.Buffer) - buf.Reset() // don't trust others - defer bufPool.Put(buf) - if err := huffmanDecode(buf, d.maxStrLen, p[:strLen]); err != nil { - buf.Reset() - return "", nil, err - } - s = buf.String() - buf.Reset() // be nice to GC - } - return s, p[strLen:], nil -} diff --git a/vendor/golang.org/x/net/http2/hpack/hpack_test.go b/vendor/golang.org/x/net/http2/hpack/hpack_test.go deleted file mode 100644 index 4c7b17b..0000000 --- a/vendor/golang.org/x/net/http2/hpack/hpack_test.go +++ /dev/null @@ -1,854 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "bufio" - "bytes" - "encoding/hex" - "fmt" - "math/rand" - "reflect" - "regexp" - "strconv" - "strings" - "testing" - "time" -) - -func TestStaticTable(t *testing.T) { - fromSpec := ` - +-------+-----------------------------+---------------+ - | 1 | :authority | | - | 2 | :method | GET | - | 3 | :method | POST | - | 4 | :path | / | - | 5 | :path | /index.html | - | 6 | :scheme | http | - | 7 | :scheme | https | - | 8 | :status | 200 | - | 9 | :status | 204 | - | 10 | :status | 206 | - | 11 | :status | 304 | - | 12 | :status | 400 | - | 13 | :status | 404 | - | 14 | :status | 500 | - | 15 | accept-charset | | - | 16 | accept-encoding | gzip, deflate | - | 17 | accept-language | | - | 18 | accept-ranges | | - | 19 | accept | | - | 20 | access-control-allow-origin | | - | 21 | age | | - | 22 | allow | | - | 23 | authorization | | - | 24 | cache-control | | - | 25 | content-disposition | | - | 26 | content-encoding | | - | 27 | content-language | | - | 28 | content-length | | - | 29 | content-location | | - | 30 | content-range | | - | 31 | content-type | | - | 32 | cookie | | - | 33 | date | | - | 34 | etag | | - | 35 | expect | | - | 36 | expires | | - | 37 | from | | - | 38 | host | | - | 39 | if-match | | - | 40 | if-modified-since | | - | 41 | if-none-match | | - | 42 | if-range | | - | 43 | if-unmodified-since | | - | 44 | last-modified | | - | 45 | link | | - | 46 | location | | - | 47 | max-forwards | | - | 48 | proxy-authenticate | | - | 49 | proxy-authorization | | - | 50 | range | | - | 51 | referer | | - | 52 | refresh | | - | 53 | retry-after | | - | 54 | server | | - | 55 | set-cookie | | - | 56 | strict-transport-security | | - | 57 | transfer-encoding | | - | 58 | user-agent | | - | 59 | vary | | - | 60 | via | | - | 61 | www-authenticate | | - +-------+-----------------------------+---------------+ -` - bs := bufio.NewScanner(strings.NewReader(fromSpec)) - re := regexp.MustCompile(`\| (\d+)\s+\| (\S+)\s*\| (\S(.*\S)?)?\s+\|`) - for bs.Scan() { - l := bs.Text() - if !strings.Contains(l, "|") { - continue - } - m := re.FindStringSubmatch(l) - if m == nil { - continue - } - i, err := strconv.Atoi(m[1]) - if err != nil { - t.Errorf("Bogus integer on line %q", l) - continue - } - if i < 1 || i > len(staticTable) { - t.Errorf("Bogus index %d on line %q", i, l) - continue - } - if got, want := staticTable[i-1].Name, m[2]; got != want { - t.Errorf("header index %d name = %q; want %q", i, got, want) - } - if got, want := staticTable[i-1].Value, m[3]; got != want { - t.Errorf("header index %d value = %q; want %q", i, got, want) - } - } - if err := bs.Err(); err != nil { - t.Error(err) - } -} - -func (d *Decoder) mustAt(idx int) HeaderField { - if hf, ok := d.at(uint64(idx)); !ok { - panic(fmt.Sprintf("bogus index %d", idx)) - } else { - return hf - } -} - -func TestDynamicTableAt(t *testing.T) { - d := NewDecoder(4096, nil) - at := d.mustAt - if got, want := at(2), (pair(":method", "GET")); got != want { - t.Errorf("at(2) = %v; want %v", got, want) - } - d.dynTab.add(pair("foo", "bar")) - d.dynTab.add(pair("blake", "miz")) - if got, want := at(len(staticTable)+1), (pair("blake", "miz")); got != want { - t.Errorf("at(dyn 1) = %v; want %v", got, want) - } - if got, want := at(len(staticTable)+2), (pair("foo", "bar")); got != want { - t.Errorf("at(dyn 2) = %v; want %v", got, want) - } - if got, want := at(3), (pair(":method", "POST")); got != want { - t.Errorf("at(3) = %v; want %v", got, want) - } -} - -func TestDynamicTableSearch(t *testing.T) { - dt := dynamicTable{} - dt.setMaxSize(4096) - - dt.add(pair("foo", "bar")) - dt.add(pair("blake", "miz")) - dt.add(pair(":method", "GET")) - - tests := []struct { - hf HeaderField - wantI uint64 - wantMatch bool - }{ - // Name and Value match - {pair("foo", "bar"), 3, true}, - {pair(":method", "GET"), 1, true}, - - // Only name match because of Sensitive == true - {HeaderField{"blake", "miz", true}, 2, false}, - - // Only Name matches - {pair("foo", "..."), 3, false}, - {pair("blake", "..."), 2, false}, - {pair(":method", "..."), 1, false}, - - // None match - {pair("foo-", "bar"), 0, false}, - } - for _, tt := range tests { - if gotI, gotMatch := dt.search(tt.hf); gotI != tt.wantI || gotMatch != tt.wantMatch { - t.Errorf("d.search(%+v) = %v, %v; want %v, %v", tt.hf, gotI, gotMatch, tt.wantI, tt.wantMatch) - } - } -} - -func TestDynamicTableSizeEvict(t *testing.T) { - d := NewDecoder(4096, nil) - if want := uint32(0); d.dynTab.size != want { - t.Fatalf("size = %d; want %d", d.dynTab.size, want) - } - add := d.dynTab.add - add(pair("blake", "eats pizza")) - if want := uint32(15 + 32); d.dynTab.size != want { - t.Fatalf("after pizza, size = %d; want %d", d.dynTab.size, want) - } - add(pair("foo", "bar")) - if want := uint32(15 + 32 + 6 + 32); d.dynTab.size != want { - t.Fatalf("after foo bar, size = %d; want %d", d.dynTab.size, want) - } - d.dynTab.setMaxSize(15 + 32 + 1 /* slop */) - if want := uint32(6 + 32); d.dynTab.size != want { - t.Fatalf("after setMaxSize, size = %d; want %d", d.dynTab.size, want) - } - if got, want := d.mustAt(len(staticTable)+1), (pair("foo", "bar")); got != want { - t.Errorf("at(dyn 1) = %v; want %v", got, want) - } - add(pair("long", strings.Repeat("x", 500))) - if want := uint32(0); d.dynTab.size != want { - t.Fatalf("after big one, size = %d; want %d", d.dynTab.size, want) - } -} - -func TestDecoderDecode(t *testing.T) { - tests := []struct { - name string - in []byte - want []HeaderField - wantDynTab []HeaderField // newest entry first - }{ - // C.2.1 Literal Header Field with Indexing - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.1 - {"C.2.1", dehex("400a 6375 7374 6f6d 2d6b 6579 0d63 7573 746f 6d2d 6865 6164 6572"), - []HeaderField{pair("custom-key", "custom-header")}, - []HeaderField{pair("custom-key", "custom-header")}, - }, - - // C.2.2 Literal Header Field without Indexing - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.2 - {"C.2.2", dehex("040c 2f73 616d 706c 652f 7061 7468"), - []HeaderField{pair(":path", "/sample/path")}, - []HeaderField{}}, - - // C.2.3 Literal Header Field never Indexed - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.3 - {"C.2.3", dehex("1008 7061 7373 776f 7264 0673 6563 7265 74"), - []HeaderField{{"password", "secret", true}}, - []HeaderField{}}, - - // C.2.4 Indexed Header Field - // http://http2.github.io/http2-spec/compression.html#rfc.section.C.2.4 - {"C.2.4", []byte("\x82"), - []HeaderField{pair(":method", "GET")}, - []HeaderField{}}, - } - for _, tt := range tests { - d := NewDecoder(4096, nil) - hf, err := d.DecodeFull(tt.in) - if err != nil { - t.Errorf("%s: %v", tt.name, err) - continue - } - if !reflect.DeepEqual(hf, tt.want) { - t.Errorf("%s: Got %v; want %v", tt.name, hf, tt.want) - } - gotDynTab := d.dynTab.reverseCopy() - if !reflect.DeepEqual(gotDynTab, tt.wantDynTab) { - t.Errorf("%s: dynamic table after = %v; want %v", tt.name, gotDynTab, tt.wantDynTab) - } - } -} - -func (dt *dynamicTable) reverseCopy() (hf []HeaderField) { - hf = make([]HeaderField, len(dt.ents)) - for i := range hf { - hf[i] = dt.ents[len(dt.ents)-1-i] - } - return -} - -type encAndWant struct { - enc []byte - want []HeaderField - wantDynTab []HeaderField - wantDynSize uint32 -} - -// C.3 Request Examples without Huffman Coding -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.3 -func TestDecodeC3_NoHuffman(t *testing.T) { - testDecodeSeries(t, 4096, []encAndWant{ - {dehex("8286 8441 0f77 7777 2e65 7861 6d70 6c65 2e63 6f6d"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - }, - []HeaderField{ - pair(":authority", "www.example.com"), - }, - 57, - }, - {dehex("8286 84be 5808 6e6f 2d63 6163 6865"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - pair("cache-control", "no-cache"), - }, - []HeaderField{ - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 110, - }, - {dehex("8287 85bf 400a 6375 7374 6f6d 2d6b 6579 0c63 7573 746f 6d2d 7661 6c75 65"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "https"), - pair(":path", "/index.html"), - pair(":authority", "www.example.com"), - pair("custom-key", "custom-value"), - }, - []HeaderField{ - pair("custom-key", "custom-value"), - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 164, - }, - }) -} - -// C.4 Request Examples with Huffman Coding -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.4 -func TestDecodeC4_Huffman(t *testing.T) { - testDecodeSeries(t, 4096, []encAndWant{ - {dehex("8286 8441 8cf1 e3c2 e5f2 3a6b a0ab 90f4 ff"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - }, - []HeaderField{ - pair(":authority", "www.example.com"), - }, - 57, - }, - {dehex("8286 84be 5886 a8eb 1064 9cbf"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "http"), - pair(":path", "/"), - pair(":authority", "www.example.com"), - pair("cache-control", "no-cache"), - }, - []HeaderField{ - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 110, - }, - {dehex("8287 85bf 4088 25a8 49e9 5ba9 7d7f 8925 a849 e95b b8e8 b4bf"), - []HeaderField{ - pair(":method", "GET"), - pair(":scheme", "https"), - pair(":path", "/index.html"), - pair(":authority", "www.example.com"), - pair("custom-key", "custom-value"), - }, - []HeaderField{ - pair("custom-key", "custom-value"), - pair("cache-control", "no-cache"), - pair(":authority", "www.example.com"), - }, - 164, - }, - }) -} - -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.5 -// "This section shows several consecutive header lists, corresponding -// to HTTP responses, on the same connection. The HTTP/2 setting -// parameter SETTINGS_HEADER_TABLE_SIZE is set to the value of 256 -// octets, causing some evictions to occur." -func TestDecodeC5_ResponsesNoHuff(t *testing.T) { - testDecodeSeries(t, 256, []encAndWant{ - {dehex(` -4803 3330 3258 0770 7269 7661 7465 611d -4d6f 6e2c 2032 3120 4f63 7420 3230 3133 -2032 303a 3133 3a32 3120 474d 546e 1768 -7474 7073 3a2f 2f77 7777 2e65 7861 6d70 -6c65 2e63 6f6d -`), - []HeaderField{ - pair(":status", "302"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - pair(":status", "302"), - }, - 222, - }, - {dehex("4803 3330 37c1 c0bf"), - []HeaderField{ - pair(":status", "307"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair(":status", "307"), - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - }, - 222, - }, - {dehex(` -88c1 611d 4d6f 6e2c 2032 3120 4f63 7420 -3230 3133 2032 303a 3133 3a32 3220 474d -54c0 5a04 677a 6970 7738 666f 6f3d 4153 -444a 4b48 514b 425a 584f 5157 454f 5049 -5541 5851 5745 4f49 553b 206d 6178 2d61 -6765 3d33 3630 303b 2076 6572 7369 6f6e -3d31 -`), - []HeaderField{ - pair(":status", "200"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - pair("location", "https://www.example.com"), - pair("content-encoding", "gzip"), - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - }, - []HeaderField{ - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - pair("content-encoding", "gzip"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - }, - 215, - }, - }) -} - -// http://http2.github.io/http2-spec/compression.html#rfc.section.C.6 -// "This section shows the same examples as the previous section, but -// using Huffman encoding for the literal values. The HTTP/2 setting -// parameter SETTINGS_HEADER_TABLE_SIZE is set to the value of 256 -// octets, causing some evictions to occur. The eviction mechanism -// uses the length of the decoded literal values, so the same -// evictions occurs as in the previous section." -func TestDecodeC6_ResponsesHuffman(t *testing.T) { - testDecodeSeries(t, 256, []encAndWant{ - {dehex(` -4882 6402 5885 aec3 771a 4b61 96d0 7abe -9410 54d4 44a8 2005 9504 0b81 66e0 82a6 -2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8 -e9ae 82ae 43d3 -`), - []HeaderField{ - pair(":status", "302"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - pair(":status", "302"), - }, - 222, - }, - {dehex("4883 640e ffc1 c0bf"), - []HeaderField{ - pair(":status", "307"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("location", "https://www.example.com"), - }, - []HeaderField{ - pair(":status", "307"), - pair("location", "https://www.example.com"), - pair("date", "Mon, 21 Oct 2013 20:13:21 GMT"), - pair("cache-control", "private"), - }, - 222, - }, - {dehex(` -88c1 6196 d07a be94 1054 d444 a820 0595 -040b 8166 e084 a62d 1bff c05a 839b d9ab -77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b -3960 d5af 2708 7f36 72c1 ab27 0fb5 291f -9587 3160 65c0 03ed 4ee5 b106 3d50 07 -`), - []HeaderField{ - pair(":status", "200"), - pair("cache-control", "private"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - pair("location", "https://www.example.com"), - pair("content-encoding", "gzip"), - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - }, - []HeaderField{ - pair("set-cookie", "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"), - pair("content-encoding", "gzip"), - pair("date", "Mon, 21 Oct 2013 20:13:22 GMT"), - }, - 215, - }, - }) -} - -func testDecodeSeries(t *testing.T, size uint32, steps []encAndWant) { - d := NewDecoder(size, nil) - for i, step := range steps { - hf, err := d.DecodeFull(step.enc) - if err != nil { - t.Fatalf("Error at step index %d: %v", i, err) - } - if !reflect.DeepEqual(hf, step.want) { - t.Fatalf("At step index %d: Got headers %v; want %v", i, hf, step.want) - } - gotDynTab := d.dynTab.reverseCopy() - if !reflect.DeepEqual(gotDynTab, step.wantDynTab) { - t.Errorf("After step index %d, dynamic table = %v; want %v", i, gotDynTab, step.wantDynTab) - } - if d.dynTab.size != step.wantDynSize { - t.Errorf("After step index %d, dynamic table size = %v; want %v", i, d.dynTab.size, step.wantDynSize) - } - } -} - -func TestHuffmanDecodeExcessPadding(t *testing.T) { - tests := [][]byte{ - {0xff}, // Padding Exceeds 7 bits - {0x1f, 0xff}, // {"a", 1 byte excess padding} - {0x1f, 0xff, 0xff}, // {"a", 2 byte excess padding} - {0x1f, 0xff, 0xff, 0xff}, // {"a", 3 byte excess padding} - {0xff, 0x9f, 0xff, 0xff, 0xff}, // {"a", 29 bit excess padding} - {'R', 0xbc, '0', 0xff, 0xff, 0xff, 0xff}, // Padding ends on partial symbol. - } - for i, in := range tests { - var buf bytes.Buffer - if _, err := HuffmanDecode(&buf, in); err != ErrInvalidHuffman { - t.Errorf("test-%d: decode(%q) = %v; want ErrInvalidHuffman", i, in, err) - } - } -} - -func TestHuffmanDecodeEOS(t *testing.T) { - in := []byte{0xff, 0xff, 0xff, 0xff, 0xfc} // {EOS, "?"} - var buf bytes.Buffer - if _, err := HuffmanDecode(&buf, in); err != ErrInvalidHuffman { - t.Errorf("error = %v; want ErrInvalidHuffman", err) - } -} - -func TestHuffmanDecodeMaxLengthOnTrailingByte(t *testing.T) { - in := []byte{0x00, 0x01} // {"0", "0", "0"} - var buf bytes.Buffer - if err := huffmanDecode(&buf, 2, in); err != ErrStringLength { - t.Errorf("error = %v; want ErrStringLength", err) - } -} - -func TestHuffmanDecodeCorruptPadding(t *testing.T) { - in := []byte{0x00} - var buf bytes.Buffer - if _, err := HuffmanDecode(&buf, in); err != ErrInvalidHuffman { - t.Errorf("error = %v; want ErrInvalidHuffman", err) - } -} - -func TestHuffmanDecode(t *testing.T) { - tests := []struct { - inHex, want string - }{ - {"f1e3 c2e5 f23a 6ba0 ab90 f4ff", "www.example.com"}, - {"a8eb 1064 9cbf", "no-cache"}, - {"25a8 49e9 5ba9 7d7f", "custom-key"}, - {"25a8 49e9 5bb8 e8b4 bf", "custom-value"}, - {"6402", "302"}, - {"aec3 771a 4b", "private"}, - {"d07a be94 1054 d444 a820 0595 040b 8166 e082 a62d 1bff", "Mon, 21 Oct 2013 20:13:21 GMT"}, - {"9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 d3", "https://www.example.com"}, - {"9bd9 ab", "gzip"}, - {"94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 3160 65c0 03ed 4ee5 b106 3d50 07", - "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1"}, - } - for i, tt := range tests { - var buf bytes.Buffer - in, err := hex.DecodeString(strings.Replace(tt.inHex, " ", "", -1)) - if err != nil { - t.Errorf("%d. hex input error: %v", i, err) - continue - } - if _, err := HuffmanDecode(&buf, in); err != nil { - t.Errorf("%d. decode error: %v", i, err) - continue - } - if got := buf.String(); tt.want != got { - t.Errorf("%d. decode = %q; want %q", i, got, tt.want) - } - } -} - -func TestAppendHuffmanString(t *testing.T) { - tests := []struct { - in, want string - }{ - {"www.example.com", "f1e3 c2e5 f23a 6ba0 ab90 f4ff"}, - {"no-cache", "a8eb 1064 9cbf"}, - {"custom-key", "25a8 49e9 5ba9 7d7f"}, - {"custom-value", "25a8 49e9 5bb8 e8b4 bf"}, - {"302", "6402"}, - {"private", "aec3 771a 4b"}, - {"Mon, 21 Oct 2013 20:13:21 GMT", "d07a be94 1054 d444 a820 0595 040b 8166 e082 a62d 1bff"}, - {"https://www.example.com", "9d29 ad17 1863 c78f 0b97 c8e9 ae82 ae43 d3"}, - {"gzip", "9bd9 ab"}, - {"foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1", - "94e7 821d d7f2 e6c7 b335 dfdf cd5b 3960 d5af 2708 7f36 72c1 ab27 0fb5 291f 9587 3160 65c0 03ed 4ee5 b106 3d50 07"}, - } - for i, tt := range tests { - buf := []byte{} - want := strings.Replace(tt.want, " ", "", -1) - buf = AppendHuffmanString(buf, tt.in) - if got := hex.EncodeToString(buf); want != got { - t.Errorf("%d. encode = %q; want %q", i, got, want) - } - } -} - -func TestHuffmanMaxStrLen(t *testing.T) { - const msg = "Some string" - huff := AppendHuffmanString(nil, msg) - - testGood := func(max int) { - var out bytes.Buffer - if err := huffmanDecode(&out, max, huff); err != nil { - t.Errorf("For maxLen=%d, unexpected error: %v", max, err) - } - if out.String() != msg { - t.Errorf("For maxLen=%d, out = %q; want %q", max, out.String(), msg) - } - } - testGood(0) - testGood(len(msg)) - testGood(len(msg) + 1) - - var out bytes.Buffer - if err := huffmanDecode(&out, len(msg)-1, huff); err != ErrStringLength { - t.Errorf("err = %v; want ErrStringLength", err) - } -} - -func TestHuffmanRoundtripStress(t *testing.T) { - const Len = 50 // of uncompressed string - input := make([]byte, Len) - var output bytes.Buffer - var huff []byte - - n := 5000 - if testing.Short() { - n = 100 - } - seed := time.Now().UnixNano() - t.Logf("Seed = %v", seed) - src := rand.New(rand.NewSource(seed)) - var encSize int64 - for i := 0; i < n; i++ { - for l := range input { - input[l] = byte(src.Intn(256)) - } - huff = AppendHuffmanString(huff[:0], string(input)) - encSize += int64(len(huff)) - output.Reset() - if err := huffmanDecode(&output, 0, huff); err != nil { - t.Errorf("Failed to decode %q -> %q -> error %v", input, huff, err) - continue - } - if !bytes.Equal(output.Bytes(), input) { - t.Errorf("Roundtrip failure on %q -> %q -> %q", input, huff, output.Bytes()) - } - } - t.Logf("Compressed size of original: %0.02f%% (%v -> %v)", 100*(float64(encSize)/(Len*float64(n))), Len*n, encSize) -} - -func TestHuffmanDecodeFuzz(t *testing.T) { - const Len = 50 // of compressed - var buf, zbuf bytes.Buffer - - n := 5000 - if testing.Short() { - n = 100 - } - seed := time.Now().UnixNano() - t.Logf("Seed = %v", seed) - src := rand.New(rand.NewSource(seed)) - numFail := 0 - for i := 0; i < n; i++ { - zbuf.Reset() - if i == 0 { - // Start with at least one invalid one. - zbuf.WriteString("00\x91\xff\xff\xff\xff\xc8") - } else { - for l := 0; l < Len; l++ { - zbuf.WriteByte(byte(src.Intn(256))) - } - } - - buf.Reset() - if err := huffmanDecode(&buf, 0, zbuf.Bytes()); err != nil { - if err == ErrInvalidHuffman { - numFail++ - continue - } - t.Errorf("Failed to decode %q: %v", zbuf.Bytes(), err) - continue - } - } - t.Logf("%0.02f%% are invalid (%d / %d)", 100*float64(numFail)/float64(n), numFail, n) - if numFail < 1 { - t.Error("expected at least one invalid huffman encoding (test starts with one)") - } -} - -func TestReadVarInt(t *testing.T) { - type res struct { - i uint64 - consumed int - err error - } - tests := []struct { - n byte - p []byte - want res - }{ - // Fits in a byte: - {1, []byte{0}, res{0, 1, nil}}, - {2, []byte{2}, res{2, 1, nil}}, - {3, []byte{6}, res{6, 1, nil}}, - {4, []byte{14}, res{14, 1, nil}}, - {5, []byte{30}, res{30, 1, nil}}, - {6, []byte{62}, res{62, 1, nil}}, - {7, []byte{126}, res{126, 1, nil}}, - {8, []byte{254}, res{254, 1, nil}}, - - // Doesn't fit in a byte: - {1, []byte{1}, res{0, 0, errNeedMore}}, - {2, []byte{3}, res{0, 0, errNeedMore}}, - {3, []byte{7}, res{0, 0, errNeedMore}}, - {4, []byte{15}, res{0, 0, errNeedMore}}, - {5, []byte{31}, res{0, 0, errNeedMore}}, - {6, []byte{63}, res{0, 0, errNeedMore}}, - {7, []byte{127}, res{0, 0, errNeedMore}}, - {8, []byte{255}, res{0, 0, errNeedMore}}, - - // Ignoring top bits: - {5, []byte{255, 154, 10}, res{1337, 3, nil}}, // high dummy three bits: 111 - {5, []byte{159, 154, 10}, res{1337, 3, nil}}, // high dummy three bits: 100 - {5, []byte{191, 154, 10}, res{1337, 3, nil}}, // high dummy three bits: 101 - - // Extra byte: - {5, []byte{191, 154, 10, 2}, res{1337, 3, nil}}, // extra byte - - // Short a byte: - {5, []byte{191, 154}, res{0, 0, errNeedMore}}, - - // integer overflow: - {1, []byte{255, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128}, res{0, 0, errVarintOverflow}}, - } - for _, tt := range tests { - i, remain, err := readVarInt(tt.n, tt.p) - consumed := len(tt.p) - len(remain) - got := res{i, consumed, err} - if got != tt.want { - t.Errorf("readVarInt(%d, %v ~ %x) = %+v; want %+v", tt.n, tt.p, tt.p, got, tt.want) - } - } -} - -// Fuzz crash, originally reported at https://github.com/bradfitz/http2/issues/56 -func TestHuffmanFuzzCrash(t *testing.T) { - got, err := HuffmanDecodeToString([]byte("00\x91\xff\xff\xff\xff\xc8")) - if got != "" { - t.Errorf("Got %q; want empty string", got) - } - if err != ErrInvalidHuffman { - t.Errorf("Err = %v; want ErrInvalidHuffman", err) - } -} - -func dehex(s string) []byte { - s = strings.Replace(s, " ", "", -1) - s = strings.Replace(s, "\n", "", -1) - b, err := hex.DecodeString(s) - if err != nil { - panic(err) - } - return b -} - -func TestEmitEnabled(t *testing.T) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - enc.WriteField(HeaderField{Name: "foo", Value: "bar"}) - enc.WriteField(HeaderField{Name: "foo", Value: "bar"}) - - numCallback := 0 - var dec *Decoder - dec = NewDecoder(8<<20, func(HeaderField) { - numCallback++ - dec.SetEmitEnabled(false) - }) - if !dec.EmitEnabled() { - t.Errorf("initial emit enabled = false; want true") - } - if _, err := dec.Write(buf.Bytes()); err != nil { - t.Error(err) - } - if numCallback != 1 { - t.Errorf("num callbacks = %d; want 1", numCallback) - } - if dec.EmitEnabled() { - t.Errorf("emit enabled = true; want false") - } -} - -func TestSaveBufLimit(t *testing.T) { - const maxStr = 1 << 10 - var got []HeaderField - dec := NewDecoder(initialHeaderTableSize, func(hf HeaderField) { - got = append(got, hf) - }) - dec.SetMaxStringLength(maxStr) - var frag []byte - frag = append(frag[:0], encodeTypeByte(false, false)) - frag = appendVarInt(frag, 7, 3) - frag = append(frag, "foo"...) - frag = appendVarInt(frag, 7, 3) - frag = append(frag, "bar"...) - - if _, err := dec.Write(frag); err != nil { - t.Fatal(err) - } - - want := []HeaderField{{Name: "foo", Value: "bar"}} - if !reflect.DeepEqual(got, want) { - t.Errorf("After small writes, got %v; want %v", got, want) - } - - frag = append(frag[:0], encodeTypeByte(false, false)) - frag = appendVarInt(frag, 7, maxStr*3) - frag = append(frag, make([]byte, maxStr*3)...) - - _, err := dec.Write(frag) - if err != ErrStringLength { - t.Fatalf("Write error = %v; want ErrStringLength", err) - } -} diff --git a/vendor/golang.org/x/net/http2/hpack/huffman.go b/vendor/golang.org/x/net/http2/hpack/huffman.go deleted file mode 100644 index 8850e39..0000000 --- a/vendor/golang.org/x/net/http2/hpack/huffman.go +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -import ( - "bytes" - "errors" - "io" - "sync" -) - -var bufPool = sync.Pool{ - New: func() interface{} { return new(bytes.Buffer) }, -} - -// HuffmanDecode decodes the string in v and writes the expanded -// result to w, returning the number of bytes written to w and the -// Write call's return value. At most one Write call is made. -func HuffmanDecode(w io.Writer, v []byte) (int, error) { - buf := bufPool.Get().(*bytes.Buffer) - buf.Reset() - defer bufPool.Put(buf) - if err := huffmanDecode(buf, 0, v); err != nil { - return 0, err - } - return w.Write(buf.Bytes()) -} - -// HuffmanDecodeToString decodes the string in v. -func HuffmanDecodeToString(v []byte) (string, error) { - buf := bufPool.Get().(*bytes.Buffer) - buf.Reset() - defer bufPool.Put(buf) - if err := huffmanDecode(buf, 0, v); err != nil { - return "", err - } - return buf.String(), nil -} - -// ErrInvalidHuffman is returned for errors found decoding -// Huffman-encoded strings. -var ErrInvalidHuffman = errors.New("hpack: invalid Huffman-encoded data") - -// huffmanDecode decodes v to buf. -// If maxLen is greater than 0, attempts to write more to buf than -// maxLen bytes will return ErrStringLength. -func huffmanDecode(buf *bytes.Buffer, maxLen int, v []byte) error { - n := rootHuffmanNode - // cur is the bit buffer that has not been fed into n. - // cbits is the number of low order bits in cur that are valid. - // sbits is the number of bits of the symbol prefix being decoded. - cur, cbits, sbits := uint(0), uint8(0), uint8(0) - for _, b := range v { - cur = cur<<8 | uint(b) - cbits += 8 - sbits += 8 - for cbits >= 8 { - idx := byte(cur >> (cbits - 8)) - n = n.children[idx] - if n == nil { - return ErrInvalidHuffman - } - if n.children == nil { - if maxLen != 0 && buf.Len() == maxLen { - return ErrStringLength - } - buf.WriteByte(n.sym) - cbits -= n.codeLen - n = rootHuffmanNode - sbits = cbits - } else { - cbits -= 8 - } - } - } - for cbits > 0 { - n = n.children[byte(cur<<(8-cbits))] - if n == nil { - return ErrInvalidHuffman - } - if n.children != nil || n.codeLen > cbits { - break - } - if maxLen != 0 && buf.Len() == maxLen { - return ErrStringLength - } - buf.WriteByte(n.sym) - cbits -= n.codeLen - n = rootHuffmanNode - sbits = cbits - } - if sbits > 7 { - // Either there was an incomplete symbol, or overlong padding. - // Both are decoding errors per RFC 7541 section 5.2. - return ErrInvalidHuffman - } - if mask := uint(1< 8 { - codeLen -= 8 - i := uint8(code >> codeLen) - if cur.children[i] == nil { - cur.children[i] = newInternalNode() - } - cur = cur.children[i] - } - shift := 8 - codeLen - start, end := int(uint8(code<> (nbits - rembits)) - dst[len(dst)-1] |= t - } - - return dst -} - -// HuffmanEncodeLength returns the number of bytes required to encode -// s in Huffman codes. The result is round up to byte boundary. -func HuffmanEncodeLength(s string) uint64 { - n := uint64(0) - for i := 0; i < len(s); i++ { - n += uint64(huffmanCodeLen[s[i]]) - } - return (n + 7) / 8 -} - -// appendByteToHuffmanCode appends Huffman code for c to dst and -// returns the extended buffer and the remaining bits in the last -// element. The appending is not byte aligned and the remaining bits -// in the last element of dst is given in rembits. -func appendByteToHuffmanCode(dst []byte, rembits uint8, c byte) ([]byte, uint8) { - code := huffmanCodes[c] - nbits := huffmanCodeLen[c] - - for { - if rembits > nbits { - t := uint8(code << (rembits - nbits)) - dst[len(dst)-1] |= t - rembits -= nbits - break - } - - t := uint8(code >> (nbits - rembits)) - dst[len(dst)-1] |= t - - nbits -= rembits - rembits = 8 - - if nbits == 0 { - break - } - - dst = append(dst, 0) - } - - return dst, rembits -} diff --git a/vendor/golang.org/x/net/http2/hpack/tables.go b/vendor/golang.org/x/net/http2/hpack/tables.go deleted file mode 100644 index b9283a0..0000000 --- a/vendor/golang.org/x/net/http2/hpack/tables.go +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package hpack - -func pair(name, value string) HeaderField { - return HeaderField{Name: name, Value: value} -} - -// http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07#appendix-B -var staticTable = [...]HeaderField{ - pair(":authority", ""), // index 1 (1-based) - pair(":method", "GET"), - pair(":method", "POST"), - pair(":path", "/"), - pair(":path", "/index.html"), - pair(":scheme", "http"), - pair(":scheme", "https"), - pair(":status", "200"), - pair(":status", "204"), - pair(":status", "206"), - pair(":status", "304"), - pair(":status", "400"), - pair(":status", "404"), - pair(":status", "500"), - pair("accept-charset", ""), - pair("accept-encoding", "gzip, deflate"), - pair("accept-language", ""), - pair("accept-ranges", ""), - pair("accept", ""), - pair("access-control-allow-origin", ""), - pair("age", ""), - pair("allow", ""), - pair("authorization", ""), - pair("cache-control", ""), - pair("content-disposition", ""), - pair("content-encoding", ""), - pair("content-language", ""), - pair("content-length", ""), - pair("content-location", ""), - pair("content-range", ""), - pair("content-type", ""), - pair("cookie", ""), - pair("date", ""), - pair("etag", ""), - pair("expect", ""), - pair("expires", ""), - pair("from", ""), - pair("host", ""), - pair("if-match", ""), - pair("if-modified-since", ""), - pair("if-none-match", ""), - pair("if-range", ""), - pair("if-unmodified-since", ""), - pair("last-modified", ""), - pair("link", ""), - pair("location", ""), - pair("max-forwards", ""), - pair("proxy-authenticate", ""), - pair("proxy-authorization", ""), - pair("range", ""), - pair("referer", ""), - pair("refresh", ""), - pair("retry-after", ""), - pair("server", ""), - pair("set-cookie", ""), - pair("strict-transport-security", ""), - pair("transfer-encoding", ""), - pair("user-agent", ""), - pair("vary", ""), - pair("via", ""), - pair("www-authenticate", ""), -} - -var huffmanCodes = [256]uint32{ - 0x1ff8, - 0x7fffd8, - 0xfffffe2, - 0xfffffe3, - 0xfffffe4, - 0xfffffe5, - 0xfffffe6, - 0xfffffe7, - 0xfffffe8, - 0xffffea, - 0x3ffffffc, - 0xfffffe9, - 0xfffffea, - 0x3ffffffd, - 0xfffffeb, - 0xfffffec, - 0xfffffed, - 0xfffffee, - 0xfffffef, - 0xffffff0, - 0xffffff1, - 0xffffff2, - 0x3ffffffe, - 0xffffff3, - 0xffffff4, - 0xffffff5, - 0xffffff6, - 0xffffff7, - 0xffffff8, - 0xffffff9, - 0xffffffa, - 0xffffffb, - 0x14, - 0x3f8, - 0x3f9, - 0xffa, - 0x1ff9, - 0x15, - 0xf8, - 0x7fa, - 0x3fa, - 0x3fb, - 0xf9, - 0x7fb, - 0xfa, - 0x16, - 0x17, - 0x18, - 0x0, - 0x1, - 0x2, - 0x19, - 0x1a, - 0x1b, - 0x1c, - 0x1d, - 0x1e, - 0x1f, - 0x5c, - 0xfb, - 0x7ffc, - 0x20, - 0xffb, - 0x3fc, - 0x1ffa, - 0x21, - 0x5d, - 0x5e, - 0x5f, - 0x60, - 0x61, - 0x62, - 0x63, - 0x64, - 0x65, - 0x66, - 0x67, - 0x68, - 0x69, - 0x6a, - 0x6b, - 0x6c, - 0x6d, - 0x6e, - 0x6f, - 0x70, - 0x71, - 0x72, - 0xfc, - 0x73, - 0xfd, - 0x1ffb, - 0x7fff0, - 0x1ffc, - 0x3ffc, - 0x22, - 0x7ffd, - 0x3, - 0x23, - 0x4, - 0x24, - 0x5, - 0x25, - 0x26, - 0x27, - 0x6, - 0x74, - 0x75, - 0x28, - 0x29, - 0x2a, - 0x7, - 0x2b, - 0x76, - 0x2c, - 0x8, - 0x9, - 0x2d, - 0x77, - 0x78, - 0x79, - 0x7a, - 0x7b, - 0x7ffe, - 0x7fc, - 0x3ffd, - 0x1ffd, - 0xffffffc, - 0xfffe6, - 0x3fffd2, - 0xfffe7, - 0xfffe8, - 0x3fffd3, - 0x3fffd4, - 0x3fffd5, - 0x7fffd9, - 0x3fffd6, - 0x7fffda, - 0x7fffdb, - 0x7fffdc, - 0x7fffdd, - 0x7fffde, - 0xffffeb, - 0x7fffdf, - 0xffffec, - 0xffffed, - 0x3fffd7, - 0x7fffe0, - 0xffffee, - 0x7fffe1, - 0x7fffe2, - 0x7fffe3, - 0x7fffe4, - 0x1fffdc, - 0x3fffd8, - 0x7fffe5, - 0x3fffd9, - 0x7fffe6, - 0x7fffe7, - 0xffffef, - 0x3fffda, - 0x1fffdd, - 0xfffe9, - 0x3fffdb, - 0x3fffdc, - 0x7fffe8, - 0x7fffe9, - 0x1fffde, - 0x7fffea, - 0x3fffdd, - 0x3fffde, - 0xfffff0, - 0x1fffdf, - 0x3fffdf, - 0x7fffeb, - 0x7fffec, - 0x1fffe0, - 0x1fffe1, - 0x3fffe0, - 0x1fffe2, - 0x7fffed, - 0x3fffe1, - 0x7fffee, - 0x7fffef, - 0xfffea, - 0x3fffe2, - 0x3fffe3, - 0x3fffe4, - 0x7ffff0, - 0x3fffe5, - 0x3fffe6, - 0x7ffff1, - 0x3ffffe0, - 0x3ffffe1, - 0xfffeb, - 0x7fff1, - 0x3fffe7, - 0x7ffff2, - 0x3fffe8, - 0x1ffffec, - 0x3ffffe2, - 0x3ffffe3, - 0x3ffffe4, - 0x7ffffde, - 0x7ffffdf, - 0x3ffffe5, - 0xfffff1, - 0x1ffffed, - 0x7fff2, - 0x1fffe3, - 0x3ffffe6, - 0x7ffffe0, - 0x7ffffe1, - 0x3ffffe7, - 0x7ffffe2, - 0xfffff2, - 0x1fffe4, - 0x1fffe5, - 0x3ffffe8, - 0x3ffffe9, - 0xffffffd, - 0x7ffffe3, - 0x7ffffe4, - 0x7ffffe5, - 0xfffec, - 0xfffff3, - 0xfffed, - 0x1fffe6, - 0x3fffe9, - 0x1fffe7, - 0x1fffe8, - 0x7ffff3, - 0x3fffea, - 0x3fffeb, - 0x1ffffee, - 0x1ffffef, - 0xfffff4, - 0xfffff5, - 0x3ffffea, - 0x7ffff4, - 0x3ffffeb, - 0x7ffffe6, - 0x3ffffec, - 0x3ffffed, - 0x7ffffe7, - 0x7ffffe8, - 0x7ffffe9, - 0x7ffffea, - 0x7ffffeb, - 0xffffffe, - 0x7ffffec, - 0x7ffffed, - 0x7ffffee, - 0x7ffffef, - 0x7fffff0, - 0x3ffffee, -} - -var huffmanCodeLen = [256]uint8{ - 13, 23, 28, 28, 28, 28, 28, 28, 28, 24, 30, 28, 28, 30, 28, 28, - 28, 28, 28, 28, 28, 28, 30, 28, 28, 28, 28, 28, 28, 28, 28, 28, - 6, 10, 10, 12, 13, 6, 8, 11, 10, 10, 8, 11, 8, 6, 6, 6, - 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 8, 15, 6, 12, 10, - 13, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 7, 7, 7, 7, 7, 8, 7, 8, 13, 19, 13, 14, 6, - 15, 5, 6, 5, 6, 5, 6, 6, 6, 5, 7, 7, 6, 6, 6, 5, - 6, 7, 6, 5, 5, 6, 7, 7, 7, 7, 7, 15, 11, 14, 13, 28, - 20, 22, 20, 20, 22, 22, 22, 23, 22, 23, 23, 23, 23, 23, 24, 23, - 24, 24, 22, 23, 24, 23, 23, 23, 23, 21, 22, 23, 22, 23, 23, 24, - 22, 21, 20, 22, 22, 23, 23, 21, 23, 22, 22, 24, 21, 22, 23, 23, - 21, 21, 22, 21, 23, 22, 23, 23, 20, 22, 22, 22, 23, 22, 22, 23, - 26, 26, 20, 19, 22, 23, 22, 25, 26, 26, 26, 27, 27, 26, 24, 25, - 19, 21, 26, 27, 27, 26, 27, 24, 21, 21, 26, 26, 28, 27, 27, 27, - 20, 24, 20, 21, 22, 21, 21, 23, 22, 22, 25, 25, 24, 24, 26, 23, - 26, 27, 26, 26, 27, 27, 27, 27, 27, 28, 27, 27, 27, 27, 27, 26, -} diff --git a/vendor/golang.org/x/net/http2/http2.go b/vendor/golang.org/x/net/http2/http2.go deleted file mode 100644 index 0173aed..0000000 --- a/vendor/golang.org/x/net/http2/http2.go +++ /dev/null @@ -1,351 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package http2 implements the HTTP/2 protocol. -// -// This package is low-level and intended to be used directly by very -// few people. Most users will use it indirectly through the automatic -// use by the net/http package (from Go 1.6 and later). -// For use in earlier Go versions see ConfigureServer. (Transport support -// requires Go 1.6 or later) -// -// See https://http2.github.io/ for more information on HTTP/2. -// -// See https://http2.golang.org/ for a test server running this code. -package http2 - -import ( - "bufio" - "crypto/tls" - "errors" - "fmt" - "io" - "net/http" - "os" - "sort" - "strconv" - "strings" - "sync" - - "golang.org/x/net/lex/httplex" -) - -var ( - VerboseLogs bool - logFrameWrites bool - logFrameReads bool -) - -func init() { - e := os.Getenv("GODEBUG") - if strings.Contains(e, "http2debug=1") { - VerboseLogs = true - } - if strings.Contains(e, "http2debug=2") { - VerboseLogs = true - logFrameWrites = true - logFrameReads = true - } -} - -const ( - // ClientPreface is the string that must be sent by new - // connections from clients. - ClientPreface = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" - - // SETTINGS_MAX_FRAME_SIZE default - // http://http2.github.io/http2-spec/#rfc.section.6.5.2 - initialMaxFrameSize = 16384 - - // NextProtoTLS is the NPN/ALPN protocol negotiated during - // HTTP/2's TLS setup. - NextProtoTLS = "h2" - - // http://http2.github.io/http2-spec/#SettingValues - initialHeaderTableSize = 4096 - - initialWindowSize = 65535 // 6.9.2 Initial Flow Control Window Size - - defaultMaxReadFrameSize = 1 << 20 -) - -var ( - clientPreface = []byte(ClientPreface) -) - -type streamState int - -const ( - stateIdle streamState = iota - stateOpen - stateHalfClosedLocal - stateHalfClosedRemote - stateResvLocal - stateResvRemote - stateClosed -) - -var stateName = [...]string{ - stateIdle: "Idle", - stateOpen: "Open", - stateHalfClosedLocal: "HalfClosedLocal", - stateHalfClosedRemote: "HalfClosedRemote", - stateResvLocal: "ResvLocal", - stateResvRemote: "ResvRemote", - stateClosed: "Closed", -} - -func (st streamState) String() string { - return stateName[st] -} - -// Setting is a setting parameter: which setting it is, and its value. -type Setting struct { - // ID is which setting is being set. - // See http://http2.github.io/http2-spec/#SettingValues - ID SettingID - - // Val is the value. - Val uint32 -} - -func (s Setting) String() string { - return fmt.Sprintf("[%v = %d]", s.ID, s.Val) -} - -// Valid reports whether the setting is valid. -func (s Setting) Valid() error { - // Limits and error codes from 6.5.2 Defined SETTINGS Parameters - switch s.ID { - case SettingEnablePush: - if s.Val != 1 && s.Val != 0 { - return ConnectionError(ErrCodeProtocol) - } - case SettingInitialWindowSize: - if s.Val > 1<<31-1 { - return ConnectionError(ErrCodeFlowControl) - } - case SettingMaxFrameSize: - if s.Val < 16384 || s.Val > 1<<24-1 { - return ConnectionError(ErrCodeProtocol) - } - } - return nil -} - -// A SettingID is an HTTP/2 setting as defined in -// http://http2.github.io/http2-spec/#iana-settings -type SettingID uint16 - -const ( - SettingHeaderTableSize SettingID = 0x1 - SettingEnablePush SettingID = 0x2 - SettingMaxConcurrentStreams SettingID = 0x3 - SettingInitialWindowSize SettingID = 0x4 - SettingMaxFrameSize SettingID = 0x5 - SettingMaxHeaderListSize SettingID = 0x6 -) - -var settingName = map[SettingID]string{ - SettingHeaderTableSize: "HEADER_TABLE_SIZE", - SettingEnablePush: "ENABLE_PUSH", - SettingMaxConcurrentStreams: "MAX_CONCURRENT_STREAMS", - SettingInitialWindowSize: "INITIAL_WINDOW_SIZE", - SettingMaxFrameSize: "MAX_FRAME_SIZE", - SettingMaxHeaderListSize: "MAX_HEADER_LIST_SIZE", -} - -func (s SettingID) String() string { - if v, ok := settingName[s]; ok { - return v - } - return fmt.Sprintf("UNKNOWN_SETTING_%d", uint16(s)) -} - -var ( - errInvalidHeaderFieldName = errors.New("http2: invalid header field name") - errInvalidHeaderFieldValue = errors.New("http2: invalid header field value") -) - -// validWireHeaderFieldName reports whether v is a valid header field -// name (key). See httplex.ValidHeaderName for the base rules. -// -// Further, http2 says: -// "Just as in HTTP/1.x, header field names are strings of ASCII -// characters that are compared in a case-insensitive -// fashion. However, header field names MUST be converted to -// lowercase prior to their encoding in HTTP/2. " -func validWireHeaderFieldName(v string) bool { - if len(v) == 0 { - return false - } - for _, r := range v { - if !httplex.IsTokenRune(r) { - return false - } - if 'A' <= r && r <= 'Z' { - return false - } - } - return true -} - -var httpCodeStringCommon = map[int]string{} // n -> strconv.Itoa(n) - -func init() { - for i := 100; i <= 999; i++ { - if v := http.StatusText(i); v != "" { - httpCodeStringCommon[i] = strconv.Itoa(i) - } - } -} - -func httpCodeString(code int) string { - if s, ok := httpCodeStringCommon[code]; ok { - return s - } - return strconv.Itoa(code) -} - -// from pkg io -type stringWriter interface { - WriteString(s string) (n int, err error) -} - -// A gate lets two goroutines coordinate their activities. -type gate chan struct{} - -func (g gate) Done() { g <- struct{}{} } -func (g gate) Wait() { <-g } - -// A closeWaiter is like a sync.WaitGroup but only goes 1 to 0 (open to closed). -type closeWaiter chan struct{} - -// Init makes a closeWaiter usable. -// It exists because so a closeWaiter value can be placed inside a -// larger struct and have the Mutex and Cond's memory in the same -// allocation. -func (cw *closeWaiter) Init() { - *cw = make(chan struct{}) -} - -// Close marks the closeWaiter as closed and unblocks any waiters. -func (cw closeWaiter) Close() { - close(cw) -} - -// Wait waits for the closeWaiter to become closed. -func (cw closeWaiter) Wait() { - <-cw -} - -// bufferedWriter is a buffered writer that writes to w. -// Its buffered writer is lazily allocated as needed, to minimize -// idle memory usage with many connections. -type bufferedWriter struct { - w io.Writer // immutable - bw *bufio.Writer // non-nil when data is buffered -} - -func newBufferedWriter(w io.Writer) *bufferedWriter { - return &bufferedWriter{w: w} -} - -var bufWriterPool = sync.Pool{ - New: func() interface{} { - // TODO: pick something better? this is a bit under - // (3 x typical 1500 byte MTU) at least. - return bufio.NewWriterSize(nil, 4<<10) - }, -} - -func (w *bufferedWriter) Write(p []byte) (n int, err error) { - if w.bw == nil { - bw := bufWriterPool.Get().(*bufio.Writer) - bw.Reset(w.w) - w.bw = bw - } - return w.bw.Write(p) -} - -func (w *bufferedWriter) Flush() error { - bw := w.bw - if bw == nil { - return nil - } - err := bw.Flush() - bw.Reset(nil) - bufWriterPool.Put(bw) - w.bw = nil - return err -} - -func mustUint31(v int32) uint32 { - if v < 0 || v > 2147483647 { - panic("out of range") - } - return uint32(v) -} - -// bodyAllowedForStatus reports whether a given response status code -// permits a body. See RFC 2616, section 4.4. -func bodyAllowedForStatus(status int) bool { - switch { - case status >= 100 && status <= 199: - return false - case status == 204: - return false - case status == 304: - return false - } - return true -} - -type httpError struct { - msg string - timeout bool -} - -func (e *httpError) Error() string { return e.msg } -func (e *httpError) Timeout() bool { return e.timeout } -func (e *httpError) Temporary() bool { return true } - -var errTimeout error = &httpError{msg: "http2: timeout awaiting response headers", timeout: true} - -type connectionStater interface { - ConnectionState() tls.ConnectionState -} - -var sorterPool = sync.Pool{New: func() interface{} { return new(sorter) }} - -type sorter struct { - v []string // owned by sorter -} - -func (s *sorter) Len() int { return len(s.v) } -func (s *sorter) Swap(i, j int) { s.v[i], s.v[j] = s.v[j], s.v[i] } -func (s *sorter) Less(i, j int) bool { return s.v[i] < s.v[j] } - -// Keys returns the sorted keys of h. -// -// The returned slice is only valid until s used again or returned to -// its pool. -func (s *sorter) Keys(h http.Header) []string { - keys := s.v[:0] - for k := range h { - keys = append(keys, k) - } - s.v = keys - sort.Sort(s) - return keys -} - -func (s *sorter) SortStrings(ss []string) { - // Our sorter works on s.v, which sorter owners, so - // stash it away while we sort the user's buffer. - save := s.v - s.v = ss - sort.Sort(s) - s.v = save -} diff --git a/vendor/golang.org/x/net/http2/http2_test.go b/vendor/golang.org/x/net/http2/http2_test.go deleted file mode 100644 index 549ff5e..0000000 --- a/vendor/golang.org/x/net/http2/http2_test.go +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "errors" - "flag" - "fmt" - "net/http" - "os/exec" - "strconv" - "strings" - "testing" - - "golang.org/x/net/http2/hpack" -) - -var knownFailing = flag.Bool("known_failing", false, "Run known-failing tests.") - -func condSkipFailingTest(t *testing.T) { - if !*knownFailing { - t.Skip("Skipping known-failing test without --known_failing") - } -} - -func init() { - DebugGoroutines = true - flag.BoolVar(&VerboseLogs, "verboseh2", false, "Verbose HTTP/2 debug logging") -} - -func TestSettingString(t *testing.T) { - tests := []struct { - s Setting - want string - }{ - {Setting{SettingMaxFrameSize, 123}, "[MAX_FRAME_SIZE = 123]"}, - {Setting{1<<16 - 1, 123}, "[UNKNOWN_SETTING_65535 = 123]"}, - } - for i, tt := range tests { - got := fmt.Sprint(tt.s) - if got != tt.want { - t.Errorf("%d. for %#v, string = %q; want %q", i, tt.s, got, tt.want) - } - } -} - -type twriter struct { - t testing.TB - st *serverTester // optional -} - -func (w twriter) Write(p []byte) (n int, err error) { - if w.st != nil { - ps := string(p) - for _, phrase := range w.st.logFilter { - if strings.Contains(ps, phrase) { - return len(p), nil // no logging - } - } - } - w.t.Logf("%s", p) - return len(p), nil -} - -// like encodeHeader, but don't add implicit pseudo headers. -func encodeHeaderNoImplicit(t *testing.T, headers ...string) []byte { - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - for len(headers) > 0 { - k, v := headers[0], headers[1] - headers = headers[2:] - if err := enc.WriteField(hpack.HeaderField{Name: k, Value: v}); err != nil { - t.Fatalf("HPACK encoding error for %q/%q: %v", k, v, err) - } - } - return buf.Bytes() -} - -// Verify that curl has http2. -func requireCurl(t *testing.T) { - out, err := dockerLogs(curl(t, "--version")) - if err != nil { - t.Skipf("failed to determine curl features; skipping test") - } - if !strings.Contains(string(out), "HTTP2") { - t.Skip("curl doesn't support HTTP2; skipping test") - } -} - -func curl(t *testing.T, args ...string) (container string) { - out, err := exec.Command("docker", append([]string{"run", "-d", "--net=host", "gohttp2/curl"}, args...)...).Output() - if err != nil { - t.Skipf("Failed to run curl in docker: %v, %s", err, out) - } - return strings.TrimSpace(string(out)) -} - -// Verify that h2load exists. -func requireH2load(t *testing.T) { - out, err := dockerLogs(h2load(t, "--version")) - if err != nil { - t.Skipf("failed to probe h2load; skipping test: %s", out) - } - if !strings.Contains(string(out), "h2load nghttp2/") { - t.Skipf("h2load not present; skipping test. (Output=%q)", out) - } -} - -func h2load(t *testing.T, args ...string) (container string) { - out, err := exec.Command("docker", append([]string{"run", "-d", "--net=host", "--entrypoint=/usr/local/bin/h2load", "gohttp2/curl"}, args...)...).Output() - if err != nil { - t.Skipf("Failed to run h2load in docker: %v, %s", err, out) - } - return strings.TrimSpace(string(out)) -} - -type puppetCommand struct { - fn func(w http.ResponseWriter, r *http.Request) - done chan<- bool -} - -type handlerPuppet struct { - ch chan puppetCommand -} - -func newHandlerPuppet() *handlerPuppet { - return &handlerPuppet{ - ch: make(chan puppetCommand), - } -} - -func (p *handlerPuppet) act(w http.ResponseWriter, r *http.Request) { - for cmd := range p.ch { - cmd.fn(w, r) - cmd.done <- true - } -} - -func (p *handlerPuppet) done() { close(p.ch) } -func (p *handlerPuppet) do(fn func(http.ResponseWriter, *http.Request)) { - done := make(chan bool) - p.ch <- puppetCommand{fn, done} - <-done -} -func dockerLogs(container string) ([]byte, error) { - out, err := exec.Command("docker", "wait", container).CombinedOutput() - if err != nil { - return out, err - } - exitStatus, err := strconv.Atoi(strings.TrimSpace(string(out))) - if err != nil { - return out, errors.New("unexpected exit status from docker wait") - } - out, err = exec.Command("docker", "logs", container).CombinedOutput() - exec.Command("docker", "rm", container).Run() - if err == nil && exitStatus != 0 { - err = fmt.Errorf("exit status %d: %s", exitStatus, out) - } - return out, err -} - -func kill(container string) { - exec.Command("docker", "kill", container).Run() - exec.Command("docker", "rm", container).Run() -} - -func cleanDate(res *http.Response) { - if d := res.Header["Date"]; len(d) == 1 { - d[0] = "XXX" - } -} - -func TestSorterPoolAllocs(t *testing.T) { - ss := []string{"a", "b", "c"} - h := http.Header{ - "a": nil, - "b": nil, - "c": nil, - } - sorter := new(sorter) - - if allocs := testing.AllocsPerRun(100, func() { - sorter.SortStrings(ss) - }); allocs >= 1 { - t.Logf("SortStrings allocs = %v; want <1", allocs) - } - - if allocs := testing.AllocsPerRun(5, func() { - if len(sorter.Keys(h)) != 3 { - t.Fatal("wrong result") - } - }); allocs > 0 { - t.Logf("Keys allocs = %v; want <1", allocs) - } -} diff --git a/vendor/golang.org/x/net/http2/not_go16.go b/vendor/golang.org/x/net/http2/not_go16.go deleted file mode 100644 index 51a7f19..0000000 --- a/vendor/golang.org/x/net/http2/not_go16.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.6 - -package http2 - -import ( - "net/http" - "time" -) - -func configureTransport(t1 *http.Transport) (*Transport, error) { - return nil, errTransportVersion -} - -func transportExpectContinueTimeout(t1 *http.Transport) time.Duration { - return 0 -} diff --git a/vendor/golang.org/x/net/http2/not_go17.go b/vendor/golang.org/x/net/http2/not_go17.go deleted file mode 100644 index 28df0c1..0000000 --- a/vendor/golang.org/x/net/http2/not_go17.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.7 - -package http2 - -import ( - "net" - "net/http" -) - -type contextContext interface{} - -type fakeContext struct{} - -func (fakeContext) Done() <-chan struct{} { return nil } -func (fakeContext) Err() error { panic("should not be called") } - -func reqContext(r *http.Request) fakeContext { - return fakeContext{} -} - -func setResponseUncompressed(res *http.Response) { - // Nothing. -} - -type clientTrace struct{} - -func requestTrace(*http.Request) *clientTrace { return nil } -func traceGotConn(*http.Request, *ClientConn) {} -func traceFirstResponseByte(*clientTrace) {} -func traceWroteHeaders(*clientTrace) {} -func traceWroteRequest(*clientTrace, error) {} -func traceGot100Continue(trace *clientTrace) {} -func traceWait100Continue(trace *clientTrace) {} - -func nop() {} - -func serverConnBaseContext(c net.Conn, opts *ServeConnOpts) (ctx contextContext, cancel func()) { - return nil, nop -} - -func contextWithCancel(ctx contextContext) (_ contextContext, cancel func()) { - return ctx, nop -} - -func requestWithContext(req *http.Request, ctx contextContext) *http.Request { - return req -} diff --git a/vendor/golang.org/x/net/http2/pipe.go b/vendor/golang.org/x/net/http2/pipe.go deleted file mode 100644 index 53b7a1d..0000000 --- a/vendor/golang.org/x/net/http2/pipe.go +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "errors" - "io" - "sync" -) - -// pipe is a goroutine-safe io.Reader/io.Writer pair. It's like -// io.Pipe except there are no PipeReader/PipeWriter halves, and the -// underlying buffer is an interface. (io.Pipe is always unbuffered) -type pipe struct { - mu sync.Mutex - c sync.Cond // c.L lazily initialized to &p.mu - b pipeBuffer - err error // read error once empty. non-nil means closed. - breakErr error // immediate read error (caller doesn't see rest of b) - donec chan struct{} // closed on error - readFn func() // optional code to run in Read before error -} - -type pipeBuffer interface { - Len() int - io.Writer - io.Reader -} - -func (p *pipe) Len() int { - p.mu.Lock() - defer p.mu.Unlock() - return p.b.Len() -} - -// Read waits until data is available and copies bytes -// from the buffer into p. -func (p *pipe) Read(d []byte) (n int, err error) { - p.mu.Lock() - defer p.mu.Unlock() - if p.c.L == nil { - p.c.L = &p.mu - } - for { - if p.breakErr != nil { - return 0, p.breakErr - } - if p.b.Len() > 0 { - return p.b.Read(d) - } - if p.err != nil { - if p.readFn != nil { - p.readFn() // e.g. copy trailers - p.readFn = nil // not sticky like p.err - } - return 0, p.err - } - p.c.Wait() - } -} - -var errClosedPipeWrite = errors.New("write on closed buffer") - -// Write copies bytes from p into the buffer and wakes a reader. -// It is an error to write more data than the buffer can hold. -func (p *pipe) Write(d []byte) (n int, err error) { - p.mu.Lock() - defer p.mu.Unlock() - if p.c.L == nil { - p.c.L = &p.mu - } - defer p.c.Signal() - if p.err != nil { - return 0, errClosedPipeWrite - } - return p.b.Write(d) -} - -// CloseWithError causes the next Read (waking up a current blocked -// Read if needed) to return the provided err after all data has been -// read. -// -// The error must be non-nil. -func (p *pipe) CloseWithError(err error) { p.closeWithError(&p.err, err, nil) } - -// BreakWithError causes the next Read (waking up a current blocked -// Read if needed) to return the provided err immediately, without -// waiting for unread data. -func (p *pipe) BreakWithError(err error) { p.closeWithError(&p.breakErr, err, nil) } - -// closeWithErrorAndCode is like CloseWithError but also sets some code to run -// in the caller's goroutine before returning the error. -func (p *pipe) closeWithErrorAndCode(err error, fn func()) { p.closeWithError(&p.err, err, fn) } - -func (p *pipe) closeWithError(dst *error, err error, fn func()) { - if err == nil { - panic("err must be non-nil") - } - p.mu.Lock() - defer p.mu.Unlock() - if p.c.L == nil { - p.c.L = &p.mu - } - defer p.c.Signal() - if *dst != nil { - // Already been done. - return - } - p.readFn = fn - *dst = err - p.closeDoneLocked() -} - -// requires p.mu be held. -func (p *pipe) closeDoneLocked() { - if p.donec == nil { - return - } - // Close if unclosed. This isn't racy since we always - // hold p.mu while closing. - select { - case <-p.donec: - default: - close(p.donec) - } -} - -// Err returns the error (if any) first set by BreakWithError or CloseWithError. -func (p *pipe) Err() error { - p.mu.Lock() - defer p.mu.Unlock() - if p.breakErr != nil { - return p.breakErr - } - return p.err -} - -// Done returns a channel which is closed if and when this pipe is closed -// with CloseWithError. -func (p *pipe) Done() <-chan struct{} { - p.mu.Lock() - defer p.mu.Unlock() - if p.donec == nil { - p.donec = make(chan struct{}) - if p.err != nil || p.breakErr != nil { - // Already hit an error. - p.closeDoneLocked() - } - } - return p.donec -} diff --git a/vendor/golang.org/x/net/http2/pipe_test.go b/vendor/golang.org/x/net/http2/pipe_test.go deleted file mode 100644 index 7632299..0000000 --- a/vendor/golang.org/x/net/http2/pipe_test.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "errors" - "io" - "io/ioutil" - "testing" -) - -func TestPipeClose(t *testing.T) { - var p pipe - p.b = new(bytes.Buffer) - a := errors.New("a") - b := errors.New("b") - p.CloseWithError(a) - p.CloseWithError(b) - _, err := p.Read(make([]byte, 1)) - if err != a { - t.Errorf("err = %v want %v", err, a) - } -} - -func TestPipeDoneChan(t *testing.T) { - var p pipe - done := p.Done() - select { - case <-done: - t.Fatal("done too soon") - default: - } - p.CloseWithError(io.EOF) - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeDoneChan_ErrFirst(t *testing.T) { - var p pipe - p.CloseWithError(io.EOF) - done := p.Done() - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeDoneChan_Break(t *testing.T) { - var p pipe - done := p.Done() - select { - case <-done: - t.Fatal("done too soon") - default: - } - p.BreakWithError(io.EOF) - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeDoneChan_Break_ErrFirst(t *testing.T) { - var p pipe - p.BreakWithError(io.EOF) - done := p.Done() - select { - case <-done: - default: - t.Fatal("should be done") - } -} - -func TestPipeCloseWithError(t *testing.T) { - p := &pipe{b: new(bytes.Buffer)} - const body = "foo" - io.WriteString(p, body) - a := errors.New("test error") - p.CloseWithError(a) - all, err := ioutil.ReadAll(p) - if string(all) != body { - t.Errorf("read bytes = %q; want %q", all, body) - } - if err != a { - t.Logf("read error = %v, %v", err, a) - } -} - -func TestPipeBreakWithError(t *testing.T) { - p := &pipe{b: new(bytes.Buffer)} - io.WriteString(p, "foo") - a := errors.New("test err") - p.BreakWithError(a) - all, err := ioutil.ReadAll(p) - if string(all) != "" { - t.Errorf("read bytes = %q; want empty string", all) - } - if err != a { - t.Logf("read error = %v, %v", err, a) - } -} diff --git a/vendor/golang.org/x/net/http2/priority_test.go b/vendor/golang.org/x/net/http2/priority_test.go deleted file mode 100644 index a3fe2bb..0000000 --- a/vendor/golang.org/x/net/http2/priority_test.go +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "testing" -) - -func TestPriority(t *testing.T) { - // A -> B - // move A's parent to B - streams := make(map[uint32]*stream) - a := &stream{ - parent: nil, - weight: 16, - } - streams[1] = a - b := &stream{ - parent: a, - weight: 16, - } - streams[2] = b - adjustStreamPriority(streams, 1, PriorityParam{ - Weight: 20, - StreamDep: 2, - }) - if a.parent != b { - t.Errorf("Expected A's parent to be B") - } - if a.weight != 20 { - t.Errorf("Expected A's weight to be 20; got %d", a.weight) - } - if b.parent != nil { - t.Errorf("Expected B to have no parent") - } - if b.weight != 16 { - t.Errorf("Expected B's weight to be 16; got %d", b.weight) - } -} - -func TestPriorityExclusiveZero(t *testing.T) { - // A B and C are all children of the 0 stream. - // Exclusive reprioritization to any of the streams - // should bring the rest of the streams under the - // reprioritized stream - streams := make(map[uint32]*stream) - a := &stream{ - parent: nil, - weight: 16, - } - streams[1] = a - b := &stream{ - parent: nil, - weight: 16, - } - streams[2] = b - c := &stream{ - parent: nil, - weight: 16, - } - streams[3] = c - adjustStreamPriority(streams, 3, PriorityParam{ - Weight: 20, - StreamDep: 0, - Exclusive: true, - }) - if a.parent != c { - t.Errorf("Expected A's parent to be C") - } - if a.weight != 16 { - t.Errorf("Expected A's weight to be 16; got %d", a.weight) - } - if b.parent != c { - t.Errorf("Expected B's parent to be C") - } - if b.weight != 16 { - t.Errorf("Expected B's weight to be 16; got %d", b.weight) - } - if c.parent != nil { - t.Errorf("Expected C to have no parent") - } - if c.weight != 20 { - t.Errorf("Expected C's weight to be 20; got %d", b.weight) - } -} - -func TestPriorityOwnParent(t *testing.T) { - streams := make(map[uint32]*stream) - a := &stream{ - parent: nil, - weight: 16, - } - streams[1] = a - b := &stream{ - parent: a, - weight: 16, - } - streams[2] = b - adjustStreamPriority(streams, 1, PriorityParam{ - Weight: 20, - StreamDep: 1, - }) - if a.parent != nil { - t.Errorf("Expected A's parent to be nil") - } - if a.weight != 20 { - t.Errorf("Expected A's weight to be 20; got %d", a.weight) - } - if b.parent != a { - t.Errorf("Expected B's parent to be A") - } - if b.weight != 16 { - t.Errorf("Expected B's weight to be 16; got %d", b.weight) - } - -} diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go deleted file mode 100644 index 1de8146..0000000 --- a/vendor/golang.org/x/net/http2/server.go +++ /dev/null @@ -1,2287 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// TODO: replace all <-sc.doneServing with reads from the stream's cw -// instead, and make sure that on close we close all open -// streams. then remove doneServing? - -// TODO: re-audit GOAWAY support. Consider each incoming frame type and -// whether it should be ignored during graceful shutdown. - -// TODO: disconnect idle clients. GFE seems to do 4 minutes. make -// configurable? or maximum number of idle clients and remove the -// oldest? - -// TODO: turn off the serve goroutine when idle, so -// an idle conn only has the readFrames goroutine active. (which could -// also be optimized probably to pin less memory in crypto/tls). This -// would involve tracking when the serve goroutine is active (atomic -// int32 read/CAS probably?) and starting it up when frames arrive, -// and shutting it down when all handlers exit. the occasional PING -// packets could use time.AfterFunc to call sc.wakeStartServeLoop() -// (which is a no-op if already running) and then queue the PING write -// as normal. The serve loop would then exit in most cases (if no -// Handlers running) and not be woken up again until the PING packet -// returns. - -// TODO (maybe): add a mechanism for Handlers to going into -// half-closed-local mode (rw.(io.Closer) test?) but not exit their -// handler, and continue to be able to read from the -// Request.Body. This would be a somewhat semantic change from HTTP/1 -// (or at least what we expose in net/http), so I'd probably want to -// add it there too. For now, this package says that returning from -// the Handler ServeHTTP function means you're both done reading and -// done writing, without a way to stop just one or the other. - -package http2 - -import ( - "bufio" - "bytes" - "crypto/tls" - "errors" - "fmt" - "io" - "log" - "net" - "net/http" - "net/textproto" - "net/url" - "os" - "reflect" - "runtime" - "strconv" - "strings" - "sync" - "time" - - "golang.org/x/net/http2/hpack" -) - -const ( - prefaceTimeout = 10 * time.Second - firstSettingsTimeout = 2 * time.Second // should be in-flight with preface anyway - handlerChunkWriteSize = 4 << 10 - defaultMaxStreams = 250 // TODO: make this 100 as the GFE seems to? -) - -var ( - errClientDisconnected = errors.New("client disconnected") - errClosedBody = errors.New("body closed by handler") - errHandlerComplete = errors.New("http2: request body closed due to handler exiting") - errStreamClosed = errors.New("http2: stream closed") -) - -var responseWriterStatePool = sync.Pool{ - New: func() interface{} { - rws := &responseWriterState{} - rws.bw = bufio.NewWriterSize(chunkWriter{rws}, handlerChunkWriteSize) - return rws - }, -} - -// Test hooks. -var ( - testHookOnConn func() - testHookGetServerConn func(*serverConn) - testHookOnPanicMu *sync.Mutex // nil except in tests - testHookOnPanic func(sc *serverConn, panicVal interface{}) (rePanic bool) -) - -// Server is an HTTP/2 server. -type Server struct { - // MaxHandlers limits the number of http.Handler ServeHTTP goroutines - // which may run at a time over all connections. - // Negative or zero no limit. - // TODO: implement - MaxHandlers int - - // MaxConcurrentStreams optionally specifies the number of - // concurrent streams that each client may have open at a - // time. This is unrelated to the number of http.Handler goroutines - // which may be active globally, which is MaxHandlers. - // If zero, MaxConcurrentStreams defaults to at least 100, per - // the HTTP/2 spec's recommendations. - MaxConcurrentStreams uint32 - - // MaxReadFrameSize optionally specifies the largest frame - // this server is willing to read. A valid value is between - // 16k and 16M, inclusive. If zero or otherwise invalid, a - // default value is used. - MaxReadFrameSize uint32 - - // PermitProhibitedCipherSuites, if true, permits the use of - // cipher suites prohibited by the HTTP/2 spec. - PermitProhibitedCipherSuites bool -} - -func (s *Server) maxReadFrameSize() uint32 { - if v := s.MaxReadFrameSize; v >= minMaxFrameSize && v <= maxFrameSize { - return v - } - return defaultMaxReadFrameSize -} - -func (s *Server) maxConcurrentStreams() uint32 { - if v := s.MaxConcurrentStreams; v > 0 { - return v - } - return defaultMaxStreams -} - -// ConfigureServer adds HTTP/2 support to a net/http Server. -// -// The configuration conf may be nil. -// -// ConfigureServer must be called before s begins serving. -func ConfigureServer(s *http.Server, conf *Server) error { - if conf == nil { - conf = new(Server) - } - - if s.TLSConfig == nil { - s.TLSConfig = new(tls.Config) - } else if s.TLSConfig.CipherSuites != nil { - // If they already provided a CipherSuite list, return - // an error if it has a bad order or is missing - // ECDHE_RSA_WITH_AES_128_GCM_SHA256. - const requiredCipher = tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - haveRequired := false - sawBad := false - for i, cs := range s.TLSConfig.CipherSuites { - if cs == requiredCipher { - haveRequired = true - } - if isBadCipher(cs) { - sawBad = true - } else if sawBad { - return fmt.Errorf("http2: TLSConfig.CipherSuites index %d contains an HTTP/2-approved cipher suite (%#04x), but it comes after unapproved cipher suites. With this configuration, clients that don't support previous, approved cipher suites may be given an unapproved one and reject the connection.", i, cs) - } - } - if !haveRequired { - return fmt.Errorf("http2: TLSConfig.CipherSuites is missing HTTP/2-required TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256") - } - } - - // Note: not setting MinVersion to tls.VersionTLS12, - // as we don't want to interfere with HTTP/1.1 traffic - // on the user's server. We enforce TLS 1.2 later once - // we accept a connection. Ideally this should be done - // during next-proto selection, but using TLS <1.2 with - // HTTP/2 is still the client's bug. - - s.TLSConfig.PreferServerCipherSuites = true - - haveNPN := false - for _, p := range s.TLSConfig.NextProtos { - if p == NextProtoTLS { - haveNPN = true - break - } - } - if !haveNPN { - s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, NextProtoTLS) - } - // h2-14 is temporary (as of 2015-03-05) while we wait for all browsers - // to switch to "h2". - s.TLSConfig.NextProtos = append(s.TLSConfig.NextProtos, "h2-14") - - if s.TLSNextProto == nil { - s.TLSNextProto = map[string]func(*http.Server, *tls.Conn, http.Handler){} - } - protoHandler := func(hs *http.Server, c *tls.Conn, h http.Handler) { - if testHookOnConn != nil { - testHookOnConn() - } - conf.ServeConn(c, &ServeConnOpts{ - Handler: h, - BaseConfig: hs, - }) - } - s.TLSNextProto[NextProtoTLS] = protoHandler - s.TLSNextProto["h2-14"] = protoHandler // temporary; see above. - return nil -} - -// ServeConnOpts are options for the Server.ServeConn method. -type ServeConnOpts struct { - // BaseConfig optionally sets the base configuration - // for values. If nil, defaults are used. - BaseConfig *http.Server - - // Handler specifies which handler to use for processing - // requests. If nil, BaseConfig.Handler is used. If BaseConfig - // or BaseConfig.Handler is nil, http.DefaultServeMux is used. - Handler http.Handler -} - -func (o *ServeConnOpts) baseConfig() *http.Server { - if o != nil && o.BaseConfig != nil { - return o.BaseConfig - } - return new(http.Server) -} - -func (o *ServeConnOpts) handler() http.Handler { - if o != nil { - if o.Handler != nil { - return o.Handler - } - if o.BaseConfig != nil && o.BaseConfig.Handler != nil { - return o.BaseConfig.Handler - } - } - return http.DefaultServeMux -} - -// ServeConn serves HTTP/2 requests on the provided connection and -// blocks until the connection is no longer readable. -// -// ServeConn starts speaking HTTP/2 assuming that c has not had any -// reads or writes. It writes its initial settings frame and expects -// to be able to read the preface and settings frame from the -// client. If c has a ConnectionState method like a *tls.Conn, the -// ConnectionState is used to verify the TLS ciphersuite and to set -// the Request.TLS field in Handlers. -// -// ServeConn does not support h2c by itself. Any h2c support must be -// implemented in terms of providing a suitably-behaving net.Conn. -// -// The opts parameter is optional. If nil, default values are used. -func (s *Server) ServeConn(c net.Conn, opts *ServeConnOpts) { - baseCtx, cancel := serverConnBaseContext(c, opts) - defer cancel() - - sc := &serverConn{ - srv: s, - hs: opts.baseConfig(), - conn: c, - baseCtx: baseCtx, - remoteAddrStr: c.RemoteAddr().String(), - bw: newBufferedWriter(c), - handler: opts.handler(), - streams: make(map[uint32]*stream), - readFrameCh: make(chan readFrameResult), - wantWriteFrameCh: make(chan frameWriteMsg, 8), - wroteFrameCh: make(chan frameWriteResult, 1), // buffered; one send in writeFrameAsync - bodyReadCh: make(chan bodyReadMsg), // buffering doesn't matter either way - doneServing: make(chan struct{}), - advMaxStreams: s.maxConcurrentStreams(), - writeSched: writeScheduler{ - maxFrameSize: initialMaxFrameSize, - }, - initialWindowSize: initialWindowSize, - headerTableSize: initialHeaderTableSize, - serveG: newGoroutineLock(), - pushEnabled: true, - } - - sc.flow.add(initialWindowSize) - sc.inflow.add(initialWindowSize) - sc.hpackEncoder = hpack.NewEncoder(&sc.headerWriteBuf) - - fr := NewFramer(sc.bw, c) - fr.ReadMetaHeaders = hpack.NewDecoder(initialHeaderTableSize, nil) - fr.MaxHeaderListSize = sc.maxHeaderListSize() - fr.SetMaxReadFrameSize(s.maxReadFrameSize()) - sc.framer = fr - - if tc, ok := c.(connectionStater); ok { - sc.tlsState = new(tls.ConnectionState) - *sc.tlsState = tc.ConnectionState() - // 9.2 Use of TLS Features - // An implementation of HTTP/2 over TLS MUST use TLS - // 1.2 or higher with the restrictions on feature set - // and cipher suite described in this section. Due to - // implementation limitations, it might not be - // possible to fail TLS negotiation. An endpoint MUST - // immediately terminate an HTTP/2 connection that - // does not meet the TLS requirements described in - // this section with a connection error (Section - // 5.4.1) of type INADEQUATE_SECURITY. - if sc.tlsState.Version < tls.VersionTLS12 { - sc.rejectConn(ErrCodeInadequateSecurity, "TLS version too low") - return - } - - if sc.tlsState.ServerName == "" { - // Client must use SNI, but we don't enforce that anymore, - // since it was causing problems when connecting to bare IP - // addresses during development. - // - // TODO: optionally enforce? Or enforce at the time we receive - // a new request, and verify the the ServerName matches the :authority? - // But that precludes proxy situations, perhaps. - // - // So for now, do nothing here again. - } - - if !s.PermitProhibitedCipherSuites && isBadCipher(sc.tlsState.CipherSuite) { - // "Endpoints MAY choose to generate a connection error - // (Section 5.4.1) of type INADEQUATE_SECURITY if one of - // the prohibited cipher suites are negotiated." - // - // We choose that. In my opinion, the spec is weak - // here. It also says both parties must support at least - // TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 so there's no - // excuses here. If we really must, we could allow an - // "AllowInsecureWeakCiphers" option on the server later. - // Let's see how it plays out first. - sc.rejectConn(ErrCodeInadequateSecurity, fmt.Sprintf("Prohibited TLS 1.2 Cipher Suite: %x", sc.tlsState.CipherSuite)) - return - } - } - - if hook := testHookGetServerConn; hook != nil { - hook(sc) - } - sc.serve() -} - -// isBadCipher reports whether the cipher is blacklisted by the HTTP/2 spec. -func isBadCipher(cipher uint16) bool { - switch cipher { - case tls.TLS_RSA_WITH_RC4_128_SHA, - tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA: - // Reject cipher suites from Appendix A. - // "This list includes those cipher suites that do not - // offer an ephemeral key exchange and those that are - // based on the TLS null, stream or block cipher type" - return true - default: - return false - } -} - -func (sc *serverConn) rejectConn(err ErrCode, debug string) { - sc.vlogf("http2: server rejecting conn: %v, %s", err, debug) - // ignoring errors. hanging up anyway. - sc.framer.WriteGoAway(0, err, []byte(debug)) - sc.bw.Flush() - sc.conn.Close() -} - -type serverConn struct { - // Immutable: - srv *Server - hs *http.Server - conn net.Conn - bw *bufferedWriter // writing to conn - handler http.Handler - baseCtx contextContext - framer *Framer - doneServing chan struct{} // closed when serverConn.serve ends - readFrameCh chan readFrameResult // written by serverConn.readFrames - wantWriteFrameCh chan frameWriteMsg // from handlers -> serve - wroteFrameCh chan frameWriteResult // from writeFrameAsync -> serve, tickles more frame writes - bodyReadCh chan bodyReadMsg // from handlers -> serve - testHookCh chan func(int) // code to run on the serve loop - flow flow // conn-wide (not stream-specific) outbound flow control - inflow flow // conn-wide inbound flow control - tlsState *tls.ConnectionState // shared by all handlers, like net/http - remoteAddrStr string - - // Everything following is owned by the serve loop; use serveG.check(): - serveG goroutineLock // used to verify funcs are on serve() - pushEnabled bool - sawFirstSettings bool // got the initial SETTINGS frame after the preface - needToSendSettingsAck bool - unackedSettings int // how many SETTINGS have we sent without ACKs? - clientMaxStreams uint32 // SETTINGS_MAX_CONCURRENT_STREAMS from client (our PUSH_PROMISE limit) - advMaxStreams uint32 // our SETTINGS_MAX_CONCURRENT_STREAMS advertised the client - curOpenStreams uint32 // client's number of open streams - maxStreamID uint32 // max ever seen - streams map[uint32]*stream - initialWindowSize int32 - headerTableSize uint32 - peerMaxHeaderListSize uint32 // zero means unknown (default) - canonHeader map[string]string // http2-lower-case -> Go-Canonical-Case - writingFrame bool // started write goroutine but haven't heard back on wroteFrameCh - needsFrameFlush bool // last frame write wasn't a flush - writeSched writeScheduler - inGoAway bool // we've started to or sent GOAWAY - needToSendGoAway bool // we need to schedule a GOAWAY frame write - goAwayCode ErrCode - shutdownTimerCh <-chan time.Time // nil until used - shutdownTimer *time.Timer // nil until used - freeRequestBodyBuf []byte // if non-nil, a free initialWindowSize buffer for getRequestBodyBuf - - // Owned by the writeFrameAsync goroutine: - headerWriteBuf bytes.Buffer - hpackEncoder *hpack.Encoder -} - -func (sc *serverConn) maxHeaderListSize() uint32 { - n := sc.hs.MaxHeaderBytes - if n <= 0 { - n = http.DefaultMaxHeaderBytes - } - // http2's count is in a slightly different unit and includes 32 bytes per pair. - // So, take the net/http.Server value and pad it up a bit, assuming 10 headers. - const perFieldOverhead = 32 // per http2 spec - const typicalHeaders = 10 // conservative - return uint32(n + typicalHeaders*perFieldOverhead) -} - -// stream represents a stream. This is the minimal metadata needed by -// the serve goroutine. Most of the actual stream state is owned by -// the http.Handler's goroutine in the responseWriter. Because the -// responseWriter's responseWriterState is recycled at the end of a -// handler, this struct intentionally has no pointer to the -// *responseWriter{,State} itself, as the Handler ending nils out the -// responseWriter's state field. -type stream struct { - // immutable: - sc *serverConn - id uint32 - body *pipe // non-nil if expecting DATA frames - cw closeWaiter // closed wait stream transitions to closed state - ctx contextContext - cancelCtx func() - - // owned by serverConn's serve loop: - bodyBytes int64 // body bytes seen so far - declBodyBytes int64 // or -1 if undeclared - flow flow // limits writing from Handler to client - inflow flow // what the client is allowed to POST/etc to us - parent *stream // or nil - numTrailerValues int64 - weight uint8 - state streamState - sentReset bool // only true once detached from streams map - gotReset bool // only true once detacted from streams map - gotTrailerHeader bool // HEADER frame for trailers was seen - wroteHeaders bool // whether we wrote headers (not status 100) - reqBuf []byte - - trailer http.Header // accumulated trailers - reqTrailer http.Header // handler's Request.Trailer -} - -func (sc *serverConn) Framer() *Framer { return sc.framer } -func (sc *serverConn) CloseConn() error { return sc.conn.Close() } -func (sc *serverConn) Flush() error { return sc.bw.Flush() } -func (sc *serverConn) HeaderEncoder() (*hpack.Encoder, *bytes.Buffer) { - return sc.hpackEncoder, &sc.headerWriteBuf -} - -func (sc *serverConn) state(streamID uint32) (streamState, *stream) { - sc.serveG.check() - // http://http2.github.io/http2-spec/#rfc.section.5.1 - if st, ok := sc.streams[streamID]; ok { - return st.state, st - } - // "The first use of a new stream identifier implicitly closes all - // streams in the "idle" state that might have been initiated by - // that peer with a lower-valued stream identifier. For example, if - // a client sends a HEADERS frame on stream 7 without ever sending a - // frame on stream 5, then stream 5 transitions to the "closed" - // state when the first frame for stream 7 is sent or received." - if streamID <= sc.maxStreamID { - return stateClosed, nil - } - return stateIdle, nil -} - -// setConnState calls the net/http ConnState hook for this connection, if configured. -// Note that the net/http package does StateNew and StateClosed for us. -// There is currently no plan for StateHijacked or hijacking HTTP/2 connections. -func (sc *serverConn) setConnState(state http.ConnState) { - if sc.hs.ConnState != nil { - sc.hs.ConnState(sc.conn, state) - } -} - -func (sc *serverConn) vlogf(format string, args ...interface{}) { - if VerboseLogs { - sc.logf(format, args...) - } -} - -func (sc *serverConn) logf(format string, args ...interface{}) { - if lg := sc.hs.ErrorLog; lg != nil { - lg.Printf(format, args...) - } else { - log.Printf(format, args...) - } -} - -// errno returns v's underlying uintptr, else 0. -// -// TODO: remove this helper function once http2 can use build -// tags. See comment in isClosedConnError. -func errno(v error) uintptr { - if rv := reflect.ValueOf(v); rv.Kind() == reflect.Uintptr { - return uintptr(rv.Uint()) - } - return 0 -} - -// isClosedConnError reports whether err is an error from use of a closed -// network connection. -func isClosedConnError(err error) bool { - if err == nil { - return false - } - - // TODO: remove this string search and be more like the Windows - // case below. That might involve modifying the standard library - // to return better error types. - str := err.Error() - if strings.Contains(str, "use of closed network connection") { - return true - } - - // TODO(bradfitz): x/tools/cmd/bundle doesn't really support - // build tags, so I can't make an http2_windows.go file with - // Windows-specific stuff. Fix that and move this, once we - // have a way to bundle this into std's net/http somehow. - if runtime.GOOS == "windows" { - if oe, ok := err.(*net.OpError); ok && oe.Op == "read" { - if se, ok := oe.Err.(*os.SyscallError); ok && se.Syscall == "wsarecv" { - const WSAECONNABORTED = 10053 - const WSAECONNRESET = 10054 - if n := errno(se.Err); n == WSAECONNRESET || n == WSAECONNABORTED { - return true - } - } - } - } - return false -} - -func (sc *serverConn) condlogf(err error, format string, args ...interface{}) { - if err == nil { - return - } - if err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err) { - // Boring, expected errors. - sc.vlogf(format, args...) - } else { - sc.logf(format, args...) - } -} - -func (sc *serverConn) canonicalHeader(v string) string { - sc.serveG.check() - cv, ok := commonCanonHeader[v] - if ok { - return cv - } - cv, ok = sc.canonHeader[v] - if ok { - return cv - } - if sc.canonHeader == nil { - sc.canonHeader = make(map[string]string) - } - cv = http.CanonicalHeaderKey(v) - sc.canonHeader[v] = cv - return cv -} - -type readFrameResult struct { - f Frame // valid until readMore is called - err error - - // readMore should be called once the consumer no longer needs or - // retains f. After readMore, f is invalid and more frames can be - // read. - readMore func() -} - -// readFrames is the loop that reads incoming frames. -// It takes care to only read one frame at a time, blocking until the -// consumer is done with the frame. -// It's run on its own goroutine. -func (sc *serverConn) readFrames() { - gate := make(gate) - gateDone := gate.Done - for { - f, err := sc.framer.ReadFrame() - select { - case sc.readFrameCh <- readFrameResult{f, err, gateDone}: - case <-sc.doneServing: - return - } - select { - case <-gate: - case <-sc.doneServing: - return - } - if terminalReadFrameError(err) { - return - } - } -} - -// frameWriteResult is the message passed from writeFrameAsync to the serve goroutine. -type frameWriteResult struct { - wm frameWriteMsg // what was written (or attempted) - err error // result of the writeFrame call -} - -// writeFrameAsync runs in its own goroutine and writes a single frame -// and then reports when it's done. -// At most one goroutine can be running writeFrameAsync at a time per -// serverConn. -func (sc *serverConn) writeFrameAsync(wm frameWriteMsg) { - err := wm.write.writeFrame(sc) - sc.wroteFrameCh <- frameWriteResult{wm, err} -} - -func (sc *serverConn) closeAllStreamsOnConnClose() { - sc.serveG.check() - for _, st := range sc.streams { - sc.closeStream(st, errClientDisconnected) - } -} - -func (sc *serverConn) stopShutdownTimer() { - sc.serveG.check() - if t := sc.shutdownTimer; t != nil { - t.Stop() - } -} - -func (sc *serverConn) notePanic() { - // Note: this is for serverConn.serve panicking, not http.Handler code. - if testHookOnPanicMu != nil { - testHookOnPanicMu.Lock() - defer testHookOnPanicMu.Unlock() - } - if testHookOnPanic != nil { - if e := recover(); e != nil { - if testHookOnPanic(sc, e) { - panic(e) - } - } - } -} - -func (sc *serverConn) serve() { - sc.serveG.check() - defer sc.notePanic() - defer sc.conn.Close() - defer sc.closeAllStreamsOnConnClose() - defer sc.stopShutdownTimer() - defer close(sc.doneServing) // unblocks handlers trying to send - - if VerboseLogs { - sc.vlogf("http2: server connection from %v on %p", sc.conn.RemoteAddr(), sc.hs) - } - - sc.writeFrame(frameWriteMsg{ - write: writeSettings{ - {SettingMaxFrameSize, sc.srv.maxReadFrameSize()}, - {SettingMaxConcurrentStreams, sc.advMaxStreams}, - {SettingMaxHeaderListSize, sc.maxHeaderListSize()}, - - // TODO: more actual settings, notably - // SettingInitialWindowSize, but then we also - // want to bump up the conn window size the - // same amount here right after the settings - }, - }) - sc.unackedSettings++ - - if err := sc.readPreface(); err != nil { - sc.condlogf(err, "http2: server: error reading preface from client %v: %v", sc.conn.RemoteAddr(), err) - return - } - // Now that we've got the preface, get us out of the - // "StateNew" state. We can't go directly to idle, though. - // Active means we read some data and anticipate a request. We'll - // do another Active when we get a HEADERS frame. - sc.setConnState(http.StateActive) - sc.setConnState(http.StateIdle) - - go sc.readFrames() // closed by defer sc.conn.Close above - - settingsTimer := time.NewTimer(firstSettingsTimeout) - loopNum := 0 - for { - loopNum++ - select { - case wm := <-sc.wantWriteFrameCh: - sc.writeFrame(wm) - case res := <-sc.wroteFrameCh: - sc.wroteFrame(res) - case res := <-sc.readFrameCh: - if !sc.processFrameFromReader(res) { - return - } - res.readMore() - if settingsTimer.C != nil { - settingsTimer.Stop() - settingsTimer.C = nil - } - case m := <-sc.bodyReadCh: - sc.noteBodyRead(m.st, m.n) - case <-settingsTimer.C: - sc.logf("timeout waiting for SETTINGS frames from %v", sc.conn.RemoteAddr()) - return - case <-sc.shutdownTimerCh: - sc.vlogf("GOAWAY close timer fired; closing conn from %v", sc.conn.RemoteAddr()) - return - case fn := <-sc.testHookCh: - fn(loopNum) - } - } -} - -// readPreface reads the ClientPreface greeting from the peer -// or returns an error on timeout or an invalid greeting. -func (sc *serverConn) readPreface() error { - errc := make(chan error, 1) - go func() { - // Read the client preface - buf := make([]byte, len(ClientPreface)) - if _, err := io.ReadFull(sc.conn, buf); err != nil { - errc <- err - } else if !bytes.Equal(buf, clientPreface) { - errc <- fmt.Errorf("bogus greeting %q", buf) - } else { - errc <- nil - } - }() - timer := time.NewTimer(prefaceTimeout) // TODO: configurable on *Server? - defer timer.Stop() - select { - case <-timer.C: - return errors.New("timeout waiting for client preface") - case err := <-errc: - if err == nil { - if VerboseLogs { - sc.vlogf("http2: server: client %v said hello", sc.conn.RemoteAddr()) - } - } - return err - } -} - -var errChanPool = sync.Pool{ - New: func() interface{} { return make(chan error, 1) }, -} - -var writeDataPool = sync.Pool{ - New: func() interface{} { return new(writeData) }, -} - -// writeDataFromHandler writes DATA response frames from a handler on -// the given stream. -func (sc *serverConn) writeDataFromHandler(stream *stream, data []byte, endStream bool) error { - ch := errChanPool.Get().(chan error) - writeArg := writeDataPool.Get().(*writeData) - *writeArg = writeData{stream.id, data, endStream} - err := sc.writeFrameFromHandler(frameWriteMsg{ - write: writeArg, - stream: stream, - done: ch, - }) - if err != nil { - return err - } - var frameWriteDone bool // the frame write is done (successfully or not) - select { - case err = <-ch: - frameWriteDone = true - case <-sc.doneServing: - return errClientDisconnected - case <-stream.cw: - // If both ch and stream.cw were ready (as might - // happen on the final Write after an http.Handler - // ends), prefer the write result. Otherwise this - // might just be us successfully closing the stream. - // The writeFrameAsync and serve goroutines guarantee - // that the ch send will happen before the stream.cw - // close. - select { - case err = <-ch: - frameWriteDone = true - default: - return errStreamClosed - } - } - errChanPool.Put(ch) - if frameWriteDone { - writeDataPool.Put(writeArg) - } - return err -} - -// writeFrameFromHandler sends wm to sc.wantWriteFrameCh, but aborts -// if the connection has gone away. -// -// This must not be run from the serve goroutine itself, else it might -// deadlock writing to sc.wantWriteFrameCh (which is only mildly -// buffered and is read by serve itself). If you're on the serve -// goroutine, call writeFrame instead. -func (sc *serverConn) writeFrameFromHandler(wm frameWriteMsg) error { - sc.serveG.checkNotOn() // NOT - select { - case sc.wantWriteFrameCh <- wm: - return nil - case <-sc.doneServing: - // Serve loop is gone. - // Client has closed their connection to the server. - return errClientDisconnected - } -} - -// writeFrame schedules a frame to write and sends it if there's nothing -// already being written. -// -// There is no pushback here (the serve goroutine never blocks). It's -// the http.Handlers that block, waiting for their previous frames to -// make it onto the wire -// -// If you're not on the serve goroutine, use writeFrameFromHandler instead. -func (sc *serverConn) writeFrame(wm frameWriteMsg) { - sc.serveG.check() - - var ignoreWrite bool - - // Don't send a 100-continue response if we've already sent headers. - // See golang.org/issue/14030. - switch wm.write.(type) { - case *writeResHeaders: - wm.stream.wroteHeaders = true - case write100ContinueHeadersFrame: - if wm.stream.wroteHeaders { - ignoreWrite = true - } - } - - if !ignoreWrite { - sc.writeSched.add(wm) - } - sc.scheduleFrameWrite() -} - -// startFrameWrite starts a goroutine to write wm (in a separate -// goroutine since that might block on the network), and updates the -// serve goroutine's state about the world, updated from info in wm. -func (sc *serverConn) startFrameWrite(wm frameWriteMsg) { - sc.serveG.check() - if sc.writingFrame { - panic("internal error: can only be writing one frame at a time") - } - - st := wm.stream - if st != nil { - switch st.state { - case stateHalfClosedLocal: - panic("internal error: attempt to send frame on half-closed-local stream") - case stateClosed: - if st.sentReset || st.gotReset { - // Skip this frame. - sc.scheduleFrameWrite() - return - } - panic(fmt.Sprintf("internal error: attempt to send a write %v on a closed stream", wm)) - } - } - - sc.writingFrame = true - sc.needsFrameFlush = true - go sc.writeFrameAsync(wm) -} - -// errHandlerPanicked is the error given to any callers blocked in a read from -// Request.Body when the main goroutine panics. Since most handlers read in the -// the main ServeHTTP goroutine, this will show up rarely. -var errHandlerPanicked = errors.New("http2: handler panicked") - -// wroteFrame is called on the serve goroutine with the result of -// whatever happened on writeFrameAsync. -func (sc *serverConn) wroteFrame(res frameWriteResult) { - sc.serveG.check() - if !sc.writingFrame { - panic("internal error: expected to be already writing a frame") - } - sc.writingFrame = false - - wm := res.wm - st := wm.stream - - closeStream := endsStream(wm.write) - - if _, ok := wm.write.(handlerPanicRST); ok { - sc.closeStream(st, errHandlerPanicked) - } - - // Reply (if requested) to the blocked ServeHTTP goroutine. - if ch := wm.done; ch != nil { - select { - case ch <- res.err: - default: - panic(fmt.Sprintf("unbuffered done channel passed in for type %T", wm.write)) - } - } - wm.write = nil // prevent use (assume it's tainted after wm.done send) - - if closeStream { - if st == nil { - panic("internal error: expecting non-nil stream") - } - switch st.state { - case stateOpen: - // Here we would go to stateHalfClosedLocal in - // theory, but since our handler is done and - // the net/http package provides no mechanism - // for finishing writing to a ResponseWriter - // while still reading data (see possible TODO - // at top of this file), we go into closed - // state here anyway, after telling the peer - // we're hanging up on them. - st.state = stateHalfClosedLocal // won't last long, but necessary for closeStream via resetStream - errCancel := StreamError{st.id, ErrCodeCancel} - sc.resetStream(errCancel) - case stateHalfClosedRemote: - sc.closeStream(st, errHandlerComplete) - } - } - - sc.scheduleFrameWrite() -} - -// scheduleFrameWrite tickles the frame writing scheduler. -// -// If a frame is already being written, nothing happens. This will be called again -// when the frame is done being written. -// -// If a frame isn't being written we need to send one, the best frame -// to send is selected, preferring first things that aren't -// stream-specific (e.g. ACKing settings), and then finding the -// highest priority stream. -// -// If a frame isn't being written and there's nothing else to send, we -// flush the write buffer. -func (sc *serverConn) scheduleFrameWrite() { - sc.serveG.check() - if sc.writingFrame { - return - } - if sc.needToSendGoAway { - sc.needToSendGoAway = false - sc.startFrameWrite(frameWriteMsg{ - write: &writeGoAway{ - maxStreamID: sc.maxStreamID, - code: sc.goAwayCode, - }, - }) - return - } - if sc.needToSendSettingsAck { - sc.needToSendSettingsAck = false - sc.startFrameWrite(frameWriteMsg{write: writeSettingsAck{}}) - return - } - if !sc.inGoAway { - if wm, ok := sc.writeSched.take(); ok { - sc.startFrameWrite(wm) - return - } - } - if sc.needsFrameFlush { - sc.startFrameWrite(frameWriteMsg{write: flushFrameWriter{}}) - sc.needsFrameFlush = false // after startFrameWrite, since it sets this true - return - } -} - -func (sc *serverConn) goAway(code ErrCode) { - sc.serveG.check() - if sc.inGoAway { - return - } - if code != ErrCodeNo { - sc.shutDownIn(250 * time.Millisecond) - } else { - // TODO: configurable - sc.shutDownIn(1 * time.Second) - } - sc.inGoAway = true - sc.needToSendGoAway = true - sc.goAwayCode = code - sc.scheduleFrameWrite() -} - -func (sc *serverConn) shutDownIn(d time.Duration) { - sc.serveG.check() - sc.shutdownTimer = time.NewTimer(d) - sc.shutdownTimerCh = sc.shutdownTimer.C -} - -func (sc *serverConn) resetStream(se StreamError) { - sc.serveG.check() - sc.writeFrame(frameWriteMsg{write: se}) - if st, ok := sc.streams[se.StreamID]; ok { - st.sentReset = true - sc.closeStream(st, se) - } -} - -// processFrameFromReader processes the serve loop's read from readFrameCh from the -// frame-reading goroutine. -// processFrameFromReader returns whether the connection should be kept open. -func (sc *serverConn) processFrameFromReader(res readFrameResult) bool { - sc.serveG.check() - err := res.err - if err != nil { - if err == ErrFrameTooLarge { - sc.goAway(ErrCodeFrameSize) - return true // goAway will close the loop - } - clientGone := err == io.EOF || err == io.ErrUnexpectedEOF || isClosedConnError(err) - if clientGone { - // TODO: could we also get into this state if - // the peer does a half close - // (e.g. CloseWrite) because they're done - // sending frames but they're still wanting - // our open replies? Investigate. - // TODO: add CloseWrite to crypto/tls.Conn first - // so we have a way to test this? I suppose - // just for testing we could have a non-TLS mode. - return false - } - } else { - f := res.f - if VerboseLogs { - sc.vlogf("http2: server read frame %v", summarizeFrame(f)) - } - err = sc.processFrame(f) - if err == nil { - return true - } - } - - switch ev := err.(type) { - case StreamError: - sc.resetStream(ev) - return true - case goAwayFlowError: - sc.goAway(ErrCodeFlowControl) - return true - case ConnectionError: - sc.logf("http2: server connection error from %v: %v", sc.conn.RemoteAddr(), ev) - sc.goAway(ErrCode(ev)) - return true // goAway will handle shutdown - default: - if res.err != nil { - sc.vlogf("http2: server closing client connection; error reading frame from client %s: %v", sc.conn.RemoteAddr(), err) - } else { - sc.logf("http2: server closing client connection: %v", err) - } - return false - } -} - -func (sc *serverConn) processFrame(f Frame) error { - sc.serveG.check() - - // First frame received must be SETTINGS. - if !sc.sawFirstSettings { - if _, ok := f.(*SettingsFrame); !ok { - return ConnectionError(ErrCodeProtocol) - } - sc.sawFirstSettings = true - } - - switch f := f.(type) { - case *SettingsFrame: - return sc.processSettings(f) - case *MetaHeadersFrame: - return sc.processHeaders(f) - case *WindowUpdateFrame: - return sc.processWindowUpdate(f) - case *PingFrame: - return sc.processPing(f) - case *DataFrame: - return sc.processData(f) - case *RSTStreamFrame: - return sc.processResetStream(f) - case *PriorityFrame: - return sc.processPriority(f) - case *PushPromiseFrame: - // A client cannot push. Thus, servers MUST treat the receipt of a PUSH_PROMISE - // frame as a connection error (Section 5.4.1) of type PROTOCOL_ERROR. - return ConnectionError(ErrCodeProtocol) - default: - sc.vlogf("http2: server ignoring frame: %v", f.Header()) - return nil - } -} - -func (sc *serverConn) processPing(f *PingFrame) error { - sc.serveG.check() - if f.IsAck() { - // 6.7 PING: " An endpoint MUST NOT respond to PING frames - // containing this flag." - return nil - } - if f.StreamID != 0 { - // "PING frames are not associated with any individual - // stream. If a PING frame is received with a stream - // identifier field value other than 0x0, the recipient MUST - // respond with a connection error (Section 5.4.1) of type - // PROTOCOL_ERROR." - return ConnectionError(ErrCodeProtocol) - } - sc.writeFrame(frameWriteMsg{write: writePingAck{f}}) - return nil -} - -func (sc *serverConn) processWindowUpdate(f *WindowUpdateFrame) error { - sc.serveG.check() - switch { - case f.StreamID != 0: // stream-level flow control - st := sc.streams[f.StreamID] - if st == nil { - // "WINDOW_UPDATE can be sent by a peer that has sent a - // frame bearing the END_STREAM flag. This means that a - // receiver could receive a WINDOW_UPDATE frame on a "half - // closed (remote)" or "closed" stream. A receiver MUST - // NOT treat this as an error, see Section 5.1." - return nil - } - if !st.flow.add(int32(f.Increment)) { - return StreamError{f.StreamID, ErrCodeFlowControl} - } - default: // connection-level flow control - if !sc.flow.add(int32(f.Increment)) { - return goAwayFlowError{} - } - } - sc.scheduleFrameWrite() - return nil -} - -func (sc *serverConn) processResetStream(f *RSTStreamFrame) error { - sc.serveG.check() - - state, st := sc.state(f.StreamID) - if state == stateIdle { - // 6.4 "RST_STREAM frames MUST NOT be sent for a - // stream in the "idle" state. If a RST_STREAM frame - // identifying an idle stream is received, the - // recipient MUST treat this as a connection error - // (Section 5.4.1) of type PROTOCOL_ERROR. - return ConnectionError(ErrCodeProtocol) - } - if st != nil { - st.gotReset = true - st.cancelCtx() - sc.closeStream(st, StreamError{f.StreamID, f.ErrCode}) - } - return nil -} - -func (sc *serverConn) closeStream(st *stream, err error) { - sc.serveG.check() - if st.state == stateIdle || st.state == stateClosed { - panic(fmt.Sprintf("invariant; can't close stream in state %v", st.state)) - } - st.state = stateClosed - sc.curOpenStreams-- - if sc.curOpenStreams == 0 { - sc.setConnState(http.StateIdle) - } - delete(sc.streams, st.id) - if p := st.body; p != nil { - p.CloseWithError(err) - } - st.cw.Close() // signals Handler's CloseNotifier, unblocks writes, etc - sc.writeSched.forgetStream(st.id) - if st.reqBuf != nil { - // Stash this request body buffer (64k) away for reuse - // by a future POST/PUT/etc. - // - // TODO(bradfitz): share on the server? sync.Pool? - // Server requires locks and might hurt contention. - // sync.Pool might work, or might be worse, depending - // on goroutine CPU migrations. (get and put on - // separate CPUs). Maybe a mix of strategies. But - // this is an easy win for now. - sc.freeRequestBodyBuf = st.reqBuf - } -} - -func (sc *serverConn) processSettings(f *SettingsFrame) error { - sc.serveG.check() - if f.IsAck() { - sc.unackedSettings-- - if sc.unackedSettings < 0 { - // Why is the peer ACKing settings we never sent? - // The spec doesn't mention this case, but - // hang up on them anyway. - return ConnectionError(ErrCodeProtocol) - } - return nil - } - if err := f.ForeachSetting(sc.processSetting); err != nil { - return err - } - sc.needToSendSettingsAck = true - sc.scheduleFrameWrite() - return nil -} - -func (sc *serverConn) processSetting(s Setting) error { - sc.serveG.check() - if err := s.Valid(); err != nil { - return err - } - if VerboseLogs { - sc.vlogf("http2: server processing setting %v", s) - } - switch s.ID { - case SettingHeaderTableSize: - sc.headerTableSize = s.Val - sc.hpackEncoder.SetMaxDynamicTableSize(s.Val) - case SettingEnablePush: - sc.pushEnabled = s.Val != 0 - case SettingMaxConcurrentStreams: - sc.clientMaxStreams = s.Val - case SettingInitialWindowSize: - return sc.processSettingInitialWindowSize(s.Val) - case SettingMaxFrameSize: - sc.writeSched.maxFrameSize = s.Val - case SettingMaxHeaderListSize: - sc.peerMaxHeaderListSize = s.Val - default: - // Unknown setting: "An endpoint that receives a SETTINGS - // frame with any unknown or unsupported identifier MUST - // ignore that setting." - if VerboseLogs { - sc.vlogf("http2: server ignoring unknown setting %v", s) - } - } - return nil -} - -func (sc *serverConn) processSettingInitialWindowSize(val uint32) error { - sc.serveG.check() - // Note: val already validated to be within range by - // processSetting's Valid call. - - // "A SETTINGS frame can alter the initial flow control window - // size for all current streams. When the value of - // SETTINGS_INITIAL_WINDOW_SIZE changes, a receiver MUST - // adjust the size of all stream flow control windows that it - // maintains by the difference between the new value and the - // old value." - old := sc.initialWindowSize - sc.initialWindowSize = int32(val) - growth := sc.initialWindowSize - old // may be negative - for _, st := range sc.streams { - if !st.flow.add(growth) { - // 6.9.2 Initial Flow Control Window Size - // "An endpoint MUST treat a change to - // SETTINGS_INITIAL_WINDOW_SIZE that causes any flow - // control window to exceed the maximum size as a - // connection error (Section 5.4.1) of type - // FLOW_CONTROL_ERROR." - return ConnectionError(ErrCodeFlowControl) - } - } - return nil -} - -func (sc *serverConn) processData(f *DataFrame) error { - sc.serveG.check() - // "If a DATA frame is received whose stream is not in "open" - // or "half closed (local)" state, the recipient MUST respond - // with a stream error (Section 5.4.2) of type STREAM_CLOSED." - id := f.Header().StreamID - st, ok := sc.streams[id] - if !ok || st.state != stateOpen || st.gotTrailerHeader { - // This includes sending a RST_STREAM if the stream is - // in stateHalfClosedLocal (which currently means that - // the http.Handler returned, so it's done reading & - // done writing). Try to stop the client from sending - // more DATA. - return StreamError{id, ErrCodeStreamClosed} - } - if st.body == nil { - panic("internal error: should have a body in this state") - } - data := f.Data() - - // Sender sending more than they'd declared? - if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes { - st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes)) - return StreamError{id, ErrCodeStreamClosed} - } - if len(data) > 0 { - // Check whether the client has flow control quota. - if int(st.inflow.available()) < len(data) { - return StreamError{id, ErrCodeFlowControl} - } - st.inflow.take(int32(len(data))) - wrote, err := st.body.Write(data) - if err != nil { - return StreamError{id, ErrCodeStreamClosed} - } - if wrote != len(data) { - panic("internal error: bad Writer") - } - st.bodyBytes += int64(len(data)) - } - if f.StreamEnded() { - st.endStream() - } - return nil -} - -// endStream closes a Request.Body's pipe. It is called when a DATA -// frame says a request body is over (or after trailers). -func (st *stream) endStream() { - sc := st.sc - sc.serveG.check() - - if st.declBodyBytes != -1 && st.declBodyBytes != st.bodyBytes { - st.body.CloseWithError(fmt.Errorf("request declared a Content-Length of %d but only wrote %d bytes", - st.declBodyBytes, st.bodyBytes)) - } else { - st.body.closeWithErrorAndCode(io.EOF, st.copyTrailersToHandlerRequest) - st.body.CloseWithError(io.EOF) - } - st.state = stateHalfClosedRemote -} - -// copyTrailersToHandlerRequest is run in the Handler's goroutine in -// its Request.Body.Read just before it gets io.EOF. -func (st *stream) copyTrailersToHandlerRequest() { - for k, vv := range st.trailer { - if _, ok := st.reqTrailer[k]; ok { - // Only copy it over it was pre-declared. - st.reqTrailer[k] = vv - } - } -} - -func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { - sc.serveG.check() - id := f.Header().StreamID - if sc.inGoAway { - // Ignore. - return nil - } - // http://http2.github.io/http2-spec/#rfc.section.5.1.1 - // Streams initiated by a client MUST use odd-numbered stream - // identifiers. [...] An endpoint that receives an unexpected - // stream identifier MUST respond with a connection error - // (Section 5.4.1) of type PROTOCOL_ERROR. - if id%2 != 1 { - return ConnectionError(ErrCodeProtocol) - } - // A HEADERS frame can be used to create a new stream or - // send a trailer for an open one. If we already have a stream - // open, let it process its own HEADERS frame (trailers at this - // point, if it's valid). - st := sc.streams[f.Header().StreamID] - if st != nil { - return st.processTrailerHeaders(f) - } - - // [...] The identifier of a newly established stream MUST be - // numerically greater than all streams that the initiating - // endpoint has opened or reserved. [...] An endpoint that - // receives an unexpected stream identifier MUST respond with - // a connection error (Section 5.4.1) of type PROTOCOL_ERROR. - if id <= sc.maxStreamID { - return ConnectionError(ErrCodeProtocol) - } - sc.maxStreamID = id - - ctx, cancelCtx := contextWithCancel(sc.baseCtx) - st = &stream{ - sc: sc, - id: id, - state: stateOpen, - ctx: ctx, - cancelCtx: cancelCtx, - } - if f.StreamEnded() { - st.state = stateHalfClosedRemote - } - st.cw.Init() - - st.flow.conn = &sc.flow // link to conn-level counter - st.flow.add(sc.initialWindowSize) - st.inflow.conn = &sc.inflow // link to conn-level counter - st.inflow.add(initialWindowSize) // TODO: update this when we send a higher initial window size in the initial settings - - sc.streams[id] = st - if f.HasPriority() { - adjustStreamPriority(sc.streams, st.id, f.Priority) - } - sc.curOpenStreams++ - if sc.curOpenStreams == 1 { - sc.setConnState(http.StateActive) - } - if sc.curOpenStreams > sc.advMaxStreams { - // "Endpoints MUST NOT exceed the limit set by their - // peer. An endpoint that receives a HEADERS frame - // that causes their advertised concurrent stream - // limit to be exceeded MUST treat this as a stream - // error (Section 5.4.2) of type PROTOCOL_ERROR or - // REFUSED_STREAM." - if sc.unackedSettings == 0 { - // They should know better. - return StreamError{st.id, ErrCodeProtocol} - } - // Assume it's a network race, where they just haven't - // received our last SETTINGS update. But actually - // this can't happen yet, because we don't yet provide - // a way for users to adjust server parameters at - // runtime. - return StreamError{st.id, ErrCodeRefusedStream} - } - - rw, req, err := sc.newWriterAndRequest(st, f) - if err != nil { - return err - } - st.reqTrailer = req.Trailer - if st.reqTrailer != nil { - st.trailer = make(http.Header) - } - st.body = req.Body.(*requestBody).pipe // may be nil - st.declBodyBytes = req.ContentLength - - handler := sc.handler.ServeHTTP - if f.Truncated { - // Their header list was too long. Send a 431 error. - handler = handleHeaderListTooLong - } else if err := checkValidHTTP2Request(req); err != nil { - handler = new400Handler(err) - } - - go sc.runHandler(rw, req, handler) - return nil -} - -func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { - sc := st.sc - sc.serveG.check() - if st.gotTrailerHeader { - return ConnectionError(ErrCodeProtocol) - } - st.gotTrailerHeader = true - if !f.StreamEnded() { - return StreamError{st.id, ErrCodeProtocol} - } - - if len(f.PseudoFields()) > 0 { - return StreamError{st.id, ErrCodeProtocol} - } - if st.trailer != nil { - for _, hf := range f.RegularFields() { - key := sc.canonicalHeader(hf.Name) - if !ValidTrailerHeader(key) { - // TODO: send more details to the peer somehow. But http2 has - // no way to send debug data at a stream level. Discuss with - // HTTP folk. - return StreamError{st.id, ErrCodeProtocol} - } - st.trailer[key] = append(st.trailer[key], hf.Value) - } - } - st.endStream() - return nil -} - -func (sc *serverConn) processPriority(f *PriorityFrame) error { - adjustStreamPriority(sc.streams, f.StreamID, f.PriorityParam) - return nil -} - -func adjustStreamPriority(streams map[uint32]*stream, streamID uint32, priority PriorityParam) { - st, ok := streams[streamID] - if !ok { - // TODO: not quite correct (this streamID might - // already exist in the dep tree, but be closed), but - // close enough for now. - return - } - st.weight = priority.Weight - parent := streams[priority.StreamDep] // might be nil - if parent == st { - // if client tries to set this stream to be the parent of itself - // ignore and keep going - return - } - - // section 5.3.3: If a stream is made dependent on one of its - // own dependencies, the formerly dependent stream is first - // moved to be dependent on the reprioritized stream's previous - // parent. The moved dependency retains its weight. - for piter := parent; piter != nil; piter = piter.parent { - if piter == st { - parent.parent = st.parent - break - } - } - st.parent = parent - if priority.Exclusive && (st.parent != nil || priority.StreamDep == 0) { - for _, openStream := range streams { - if openStream != st && openStream.parent == st.parent { - openStream.parent = st - } - } - } -} - -func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*responseWriter, *http.Request, error) { - sc.serveG.check() - - method := f.PseudoValue("method") - path := f.PseudoValue("path") - scheme := f.PseudoValue("scheme") - authority := f.PseudoValue("authority") - - isConnect := method == "CONNECT" - if isConnect { - if path != "" || scheme != "" || authority == "" { - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} - } - } else if method == "" || path == "" || - (scheme != "https" && scheme != "http") { - // See 8.1.2.6 Malformed Requests and Responses: - // - // Malformed requests or responses that are detected - // MUST be treated as a stream error (Section 5.4.2) - // of type PROTOCOL_ERROR." - // - // 8.1.2.3 Request Pseudo-Header Fields - // "All HTTP/2 requests MUST include exactly one valid - // value for the :method, :scheme, and :path - // pseudo-header fields" - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} - } - - bodyOpen := !f.StreamEnded() - if method == "HEAD" && bodyOpen { - // HEAD requests can't have bodies - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} - } - var tlsState *tls.ConnectionState // nil if not scheme https - - if scheme == "https" { - tlsState = sc.tlsState - } - - header := make(http.Header) - for _, hf := range f.RegularFields() { - header.Add(sc.canonicalHeader(hf.Name), hf.Value) - } - - if authority == "" { - authority = header.Get("Host") - } - needsContinue := header.Get("Expect") == "100-continue" - if needsContinue { - header.Del("Expect") - } - // Merge Cookie headers into one "; "-delimited value. - if cookies := header["Cookie"]; len(cookies) > 1 { - header.Set("Cookie", strings.Join(cookies, "; ")) - } - - // Setup Trailers - var trailer http.Header - for _, v := range header["Trailer"] { - for _, key := range strings.Split(v, ",") { - key = http.CanonicalHeaderKey(strings.TrimSpace(key)) - switch key { - case "Transfer-Encoding", "Trailer", "Content-Length": - // Bogus. (copy of http1 rules) - // Ignore. - default: - if trailer == nil { - trailer = make(http.Header) - } - trailer[key] = nil - } - } - } - delete(header, "Trailer") - - body := &requestBody{ - conn: sc, - stream: st, - needsContinue: needsContinue, - } - var url_ *url.URL - var requestURI string - if isConnect { - url_ = &url.URL{Host: authority} - requestURI = authority // mimic HTTP/1 server behavior - } else { - var err error - url_, err = url.ParseRequestURI(path) - if err != nil { - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} - } - requestURI = path - } - req := &http.Request{ - Method: method, - URL: url_, - RemoteAddr: sc.remoteAddrStr, - Header: header, - RequestURI: requestURI, - Proto: "HTTP/2.0", - ProtoMajor: 2, - ProtoMinor: 0, - TLS: tlsState, - Host: authority, - Body: body, - Trailer: trailer, - } - req = requestWithContext(req, st.ctx) - if bodyOpen { - // Disabled, per golang.org/issue/14960: - // st.reqBuf = sc.getRequestBodyBuf() - // TODO: remove this 64k of garbage per request (again, but without a data race): - buf := make([]byte, initialWindowSize) - - body.pipe = &pipe{ - b: &fixedBuffer{buf: buf}, - } - - if vv, ok := header["Content-Length"]; ok { - req.ContentLength, _ = strconv.ParseInt(vv[0], 10, 64) - } else { - req.ContentLength = -1 - } - } - - rws := responseWriterStatePool.Get().(*responseWriterState) - bwSave := rws.bw - *rws = responseWriterState{} // zero all the fields - rws.conn = sc - rws.bw = bwSave - rws.bw.Reset(chunkWriter{rws}) - rws.stream = st - rws.req = req - rws.body = body - - rw := &responseWriter{rws: rws} - return rw, req, nil -} - -func (sc *serverConn) getRequestBodyBuf() []byte { - sc.serveG.check() - if buf := sc.freeRequestBodyBuf; buf != nil { - sc.freeRequestBodyBuf = nil - return buf - } - return make([]byte, initialWindowSize) -} - -// Run on its own goroutine. -func (sc *serverConn) runHandler(rw *responseWriter, req *http.Request, handler func(http.ResponseWriter, *http.Request)) { - didPanic := true - defer func() { - rw.rws.stream.cancelCtx() - if didPanic { - e := recover() - // Same as net/http: - const size = 64 << 10 - buf := make([]byte, size) - buf = buf[:runtime.Stack(buf, false)] - sc.writeFrameFromHandler(frameWriteMsg{ - write: handlerPanicRST{rw.rws.stream.id}, - stream: rw.rws.stream, - }) - sc.logf("http2: panic serving %v: %v\n%s", sc.conn.RemoteAddr(), e, buf) - return - } - rw.handlerDone() - }() - handler(rw, req) - didPanic = false -} - -func handleHeaderListTooLong(w http.ResponseWriter, r *http.Request) { - // 10.5.1 Limits on Header Block Size: - // .. "A server that receives a larger header block than it is - // willing to handle can send an HTTP 431 (Request Header Fields Too - // Large) status code" - const statusRequestHeaderFieldsTooLarge = 431 // only in Go 1.6+ - w.WriteHeader(statusRequestHeaderFieldsTooLarge) - io.WriteString(w, "

    HTTP Error 431

    Request Header Field(s) Too Large

    ") -} - -// called from handler goroutines. -// h may be nil. -func (sc *serverConn) writeHeaders(st *stream, headerData *writeResHeaders) error { - sc.serveG.checkNotOn() // NOT on - var errc chan error - if headerData.h != nil { - // If there's a header map (which we don't own), so we have to block on - // waiting for this frame to be written, so an http.Flush mid-handler - // writes out the correct value of keys, before a handler later potentially - // mutates it. - errc = errChanPool.Get().(chan error) - } - if err := sc.writeFrameFromHandler(frameWriteMsg{ - write: headerData, - stream: st, - done: errc, - }); err != nil { - return err - } - if errc != nil { - select { - case err := <-errc: - errChanPool.Put(errc) - return err - case <-sc.doneServing: - return errClientDisconnected - case <-st.cw: - return errStreamClosed - } - } - return nil -} - -// called from handler goroutines. -func (sc *serverConn) write100ContinueHeaders(st *stream) { - sc.writeFrameFromHandler(frameWriteMsg{ - write: write100ContinueHeadersFrame{st.id}, - stream: st, - }) -} - -// A bodyReadMsg tells the server loop that the http.Handler read n -// bytes of the DATA from the client on the given stream. -type bodyReadMsg struct { - st *stream - n int -} - -// called from handler goroutines. -// Notes that the handler for the given stream ID read n bytes of its body -// and schedules flow control tokens to be sent. -func (sc *serverConn) noteBodyReadFromHandler(st *stream, n int) { - sc.serveG.checkNotOn() // NOT on - select { - case sc.bodyReadCh <- bodyReadMsg{st, n}: - case <-sc.doneServing: - } -} - -func (sc *serverConn) noteBodyRead(st *stream, n int) { - sc.serveG.check() - sc.sendWindowUpdate(nil, n) // conn-level - if st.state != stateHalfClosedRemote && st.state != stateClosed { - // Don't send this WINDOW_UPDATE if the stream is closed - // remotely. - sc.sendWindowUpdate(st, n) - } -} - -// st may be nil for conn-level -func (sc *serverConn) sendWindowUpdate(st *stream, n int) { - sc.serveG.check() - // "The legal range for the increment to the flow control - // window is 1 to 2^31-1 (2,147,483,647) octets." - // A Go Read call on 64-bit machines could in theory read - // a larger Read than this. Very unlikely, but we handle it here - // rather than elsewhere for now. - const maxUint31 = 1<<31 - 1 - for n >= maxUint31 { - sc.sendWindowUpdate32(st, maxUint31) - n -= maxUint31 - } - sc.sendWindowUpdate32(st, int32(n)) -} - -// st may be nil for conn-level -func (sc *serverConn) sendWindowUpdate32(st *stream, n int32) { - sc.serveG.check() - if n == 0 { - return - } - if n < 0 { - panic("negative update") - } - var streamID uint32 - if st != nil { - streamID = st.id - } - sc.writeFrame(frameWriteMsg{ - write: writeWindowUpdate{streamID: streamID, n: uint32(n)}, - stream: st, - }) - var ok bool - if st == nil { - ok = sc.inflow.add(n) - } else { - ok = st.inflow.add(n) - } - if !ok { - panic("internal error; sent too many window updates without decrements?") - } -} - -type requestBody struct { - stream *stream - conn *serverConn - closed bool - pipe *pipe // non-nil if we have a HTTP entity message body - needsContinue bool // need to send a 100-continue -} - -func (b *requestBody) Close() error { - if b.pipe != nil { - b.pipe.BreakWithError(errClosedBody) - } - b.closed = true - return nil -} - -func (b *requestBody) Read(p []byte) (n int, err error) { - if b.needsContinue { - b.needsContinue = false - b.conn.write100ContinueHeaders(b.stream) - } - if b.pipe == nil { - return 0, io.EOF - } - n, err = b.pipe.Read(p) - if n > 0 { - b.conn.noteBodyReadFromHandler(b.stream, n) - } - return -} - -// responseWriter is the http.ResponseWriter implementation. It's -// intentionally small (1 pointer wide) to minimize garbage. The -// responseWriterState pointer inside is zeroed at the end of a -// request (in handlerDone) and calls on the responseWriter thereafter -// simply crash (caller's mistake), but the much larger responseWriterState -// and buffers are reused between multiple requests. -type responseWriter struct { - rws *responseWriterState -} - -// Optional http.ResponseWriter interfaces implemented. -var ( - _ http.CloseNotifier = (*responseWriter)(nil) - _ http.Flusher = (*responseWriter)(nil) - _ stringWriter = (*responseWriter)(nil) -) - -type responseWriterState struct { - // immutable within a request: - stream *stream - req *http.Request - body *requestBody // to close at end of request, if DATA frames didn't - conn *serverConn - - // TODO: adjust buffer writing sizes based on server config, frame size updates from peer, etc - bw *bufio.Writer // writing to a chunkWriter{this *responseWriterState} - - // mutated by http.Handler goroutine: - handlerHeader http.Header // nil until called - snapHeader http.Header // snapshot of handlerHeader at WriteHeader time - trailers []string // set in writeChunk - status int // status code passed to WriteHeader - wroteHeader bool // WriteHeader called (explicitly or implicitly). Not necessarily sent to user yet. - sentHeader bool // have we sent the header frame? - handlerDone bool // handler has finished - - sentContentLen int64 // non-zero if handler set a Content-Length header - wroteBytes int64 - - closeNotifierMu sync.Mutex // guards closeNotifierCh - closeNotifierCh chan bool // nil until first used -} - -type chunkWriter struct{ rws *responseWriterState } - -func (cw chunkWriter) Write(p []byte) (n int, err error) { return cw.rws.writeChunk(p) } - -func (rws *responseWriterState) hasTrailers() bool { return len(rws.trailers) != 0 } - -// declareTrailer is called for each Trailer header when the -// response header is written. It notes that a header will need to be -// written in the trailers at the end of the response. -func (rws *responseWriterState) declareTrailer(k string) { - k = http.CanonicalHeaderKey(k) - if !ValidTrailerHeader(k) { - // Forbidden by RFC 2616 14.40. - rws.conn.logf("ignoring invalid trailer %q", k) - return - } - if !strSliceContains(rws.trailers, k) { - rws.trailers = append(rws.trailers, k) - } -} - -// writeChunk writes chunks from the bufio.Writer. But because -// bufio.Writer may bypass its chunking, sometimes p may be -// arbitrarily large. -// -// writeChunk is also responsible (on the first chunk) for sending the -// HEADER response. -func (rws *responseWriterState) writeChunk(p []byte) (n int, err error) { - if !rws.wroteHeader { - rws.writeHeader(200) - } - - isHeadResp := rws.req.Method == "HEAD" - if !rws.sentHeader { - rws.sentHeader = true - var ctype, clen string - if clen = rws.snapHeader.Get("Content-Length"); clen != "" { - rws.snapHeader.Del("Content-Length") - clen64, err := strconv.ParseInt(clen, 10, 64) - if err == nil && clen64 >= 0 { - rws.sentContentLen = clen64 - } else { - clen = "" - } - } - if clen == "" && rws.handlerDone && bodyAllowedForStatus(rws.status) && (len(p) > 0 || !isHeadResp) { - clen = strconv.Itoa(len(p)) - } - _, hasContentType := rws.snapHeader["Content-Type"] - if !hasContentType && bodyAllowedForStatus(rws.status) { - ctype = http.DetectContentType(p) - } - var date string - if _, ok := rws.snapHeader["Date"]; !ok { - // TODO(bradfitz): be faster here, like net/http? measure. - date = time.Now().UTC().Format(http.TimeFormat) - } - - for _, v := range rws.snapHeader["Trailer"] { - foreachHeaderElement(v, rws.declareTrailer) - } - - endStream := (rws.handlerDone && !rws.hasTrailers() && len(p) == 0) || isHeadResp - err = rws.conn.writeHeaders(rws.stream, &writeResHeaders{ - streamID: rws.stream.id, - httpResCode: rws.status, - h: rws.snapHeader, - endStream: endStream, - contentType: ctype, - contentLength: clen, - date: date, - }) - if err != nil { - return 0, err - } - if endStream { - return 0, nil - } - } - if isHeadResp { - return len(p), nil - } - if len(p) == 0 && !rws.handlerDone { - return 0, nil - } - - if rws.handlerDone { - rws.promoteUndeclaredTrailers() - } - - endStream := rws.handlerDone && !rws.hasTrailers() - if len(p) > 0 || endStream { - // only send a 0 byte DATA frame if we're ending the stream. - if err := rws.conn.writeDataFromHandler(rws.stream, p, endStream); err != nil { - return 0, err - } - } - - if rws.handlerDone && rws.hasTrailers() { - err = rws.conn.writeHeaders(rws.stream, &writeResHeaders{ - streamID: rws.stream.id, - h: rws.handlerHeader, - trailers: rws.trailers, - endStream: true, - }) - return len(p), err - } - return len(p), nil -} - -// TrailerPrefix is a magic prefix for ResponseWriter.Header map keys -// that, if present, signals that the map entry is actually for -// the response trailers, and not the response headers. The prefix -// is stripped after the ServeHTTP call finishes and the values are -// sent in the trailers. -// -// This mechanism is intended only for trailers that are not known -// prior to the headers being written. If the set of trailers is fixed -// or known before the header is written, the normal Go trailers mechanism -// is preferred: -// https://golang.org/pkg/net/http/#ResponseWriter -// https://golang.org/pkg/net/http/#example_ResponseWriter_trailers -const TrailerPrefix = "Trailer:" - -// promoteUndeclaredTrailers permits http.Handlers to set trailers -// after the header has already been flushed. Because the Go -// ResponseWriter interface has no way to set Trailers (only the -// Header), and because we didn't want to expand the ResponseWriter -// interface, and because nobody used trailers, and because RFC 2616 -// says you SHOULD (but not must) predeclare any trailers in the -// header, the official ResponseWriter rules said trailers in Go must -// be predeclared, and then we reuse the same ResponseWriter.Header() -// map to mean both Headers and Trailers. When it's time to write the -// Trailers, we pick out the fields of Headers that were declared as -// trailers. That worked for a while, until we found the first major -// user of Trailers in the wild: gRPC (using them only over http2), -// and gRPC libraries permit setting trailers mid-stream without -// predeclarnig them. So: change of plans. We still permit the old -// way, but we also permit this hack: if a Header() key begins with -// "Trailer:", the suffix of that key is a Trailer. Because ':' is an -// invalid token byte anyway, there is no ambiguity. (And it's already -// filtered out) It's mildly hacky, but not terrible. -// -// This method runs after the Handler is done and promotes any Header -// fields to be trailers. -func (rws *responseWriterState) promoteUndeclaredTrailers() { - for k, vv := range rws.handlerHeader { - if !strings.HasPrefix(k, TrailerPrefix) { - continue - } - trailerKey := strings.TrimPrefix(k, TrailerPrefix) - rws.declareTrailer(trailerKey) - rws.handlerHeader[http.CanonicalHeaderKey(trailerKey)] = vv - } - - if len(rws.trailers) > 1 { - sorter := sorterPool.Get().(*sorter) - sorter.SortStrings(rws.trailers) - sorterPool.Put(sorter) - } -} - -func (w *responseWriter) Flush() { - rws := w.rws - if rws == nil { - panic("Header called after Handler finished") - } - if rws.bw.Buffered() > 0 { - if err := rws.bw.Flush(); err != nil { - // Ignore the error. The frame writer already knows. - return - } - } else { - // The bufio.Writer won't call chunkWriter.Write - // (writeChunk with zero bytes, so we have to do it - // ourselves to force the HTTP response header and/or - // final DATA frame (with END_STREAM) to be sent. - rws.writeChunk(nil) - } -} - -func (w *responseWriter) CloseNotify() <-chan bool { - rws := w.rws - if rws == nil { - panic("CloseNotify called after Handler finished") - } - rws.closeNotifierMu.Lock() - ch := rws.closeNotifierCh - if ch == nil { - ch = make(chan bool, 1) - rws.closeNotifierCh = ch - go func() { - rws.stream.cw.Wait() // wait for close - ch <- true - }() - } - rws.closeNotifierMu.Unlock() - return ch -} - -func (w *responseWriter) Header() http.Header { - rws := w.rws - if rws == nil { - panic("Header called after Handler finished") - } - if rws.handlerHeader == nil { - rws.handlerHeader = make(http.Header) - } - return rws.handlerHeader -} - -func (w *responseWriter) WriteHeader(code int) { - rws := w.rws - if rws == nil { - panic("WriteHeader called after Handler finished") - } - rws.writeHeader(code) -} - -func (rws *responseWriterState) writeHeader(code int) { - if !rws.wroteHeader { - rws.wroteHeader = true - rws.status = code - if len(rws.handlerHeader) > 0 { - rws.snapHeader = cloneHeader(rws.handlerHeader) - } - } -} - -func cloneHeader(h http.Header) http.Header { - h2 := make(http.Header, len(h)) - for k, vv := range h { - vv2 := make([]string, len(vv)) - copy(vv2, vv) - h2[k] = vv2 - } - return h2 -} - -// The Life Of A Write is like this: -// -// * Handler calls w.Write or w.WriteString -> -// * -> rws.bw (*bufio.Writer) -> -// * (Handler migth call Flush) -// * -> chunkWriter{rws} -// * -> responseWriterState.writeChunk(p []byte) -// * -> responseWriterState.writeChunk (most of the magic; see comment there) -func (w *responseWriter) Write(p []byte) (n int, err error) { - return w.write(len(p), p, "") -} - -func (w *responseWriter) WriteString(s string) (n int, err error) { - return w.write(len(s), nil, s) -} - -// either dataB or dataS is non-zero. -func (w *responseWriter) write(lenData int, dataB []byte, dataS string) (n int, err error) { - rws := w.rws - if rws == nil { - panic("Write called after Handler finished") - } - if !rws.wroteHeader { - w.WriteHeader(200) - } - if !bodyAllowedForStatus(rws.status) { - return 0, http.ErrBodyNotAllowed - } - rws.wroteBytes += int64(len(dataB)) + int64(len(dataS)) // only one can be set - if rws.sentContentLen != 0 && rws.wroteBytes > rws.sentContentLen { - // TODO: send a RST_STREAM - return 0, errors.New("http2: handler wrote more than declared Content-Length") - } - - if dataB != nil { - return rws.bw.Write(dataB) - } else { - return rws.bw.WriteString(dataS) - } -} - -func (w *responseWriter) handlerDone() { - rws := w.rws - rws.handlerDone = true - w.Flush() - w.rws = nil - responseWriterStatePool.Put(rws) -} - -// foreachHeaderElement splits v according to the "#rule" construction -// in RFC 2616 section 2.1 and calls fn for each non-empty element. -func foreachHeaderElement(v string, fn func(string)) { - v = textproto.TrimString(v) - if v == "" { - return - } - if !strings.Contains(v, ",") { - fn(v) - return - } - for _, f := range strings.Split(v, ",") { - if f = textproto.TrimString(f); f != "" { - fn(f) - } - } -} - -// From http://httpwg.org/specs/rfc7540.html#rfc.section.8.1.2.2 -var connHeaders = []string{ - "Connection", - "Keep-Alive", - "Proxy-Connection", - "Transfer-Encoding", - "Upgrade", -} - -// checkValidHTTP2Request checks whether req is a valid HTTP/2 request, -// per RFC 7540 Section 8.1.2.2. -// The returned error is reported to users. -func checkValidHTTP2Request(req *http.Request) error { - for _, h := range connHeaders { - if _, ok := req.Header[h]; ok { - return fmt.Errorf("request header %q is not valid in HTTP/2", h) - } - } - te := req.Header["Te"] - if len(te) > 0 && (len(te) > 1 || (te[0] != "trailers" && te[0] != "")) { - return errors.New(`request header "TE" may only be "trailers" in HTTP/2`) - } - return nil -} - -func new400Handler(err error) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - http.Error(w, err.Error(), http.StatusBadRequest) - } -} - -// ValidTrailerHeader reports whether name is a valid header field name to appear -// in trailers. -// See: http://tools.ietf.org/html/rfc7230#section-4.1.2 -func ValidTrailerHeader(name string) bool { - name = http.CanonicalHeaderKey(name) - if strings.HasPrefix(name, "If-") || badTrailer[name] { - return false - } - return true -} - -var badTrailer = map[string]bool{ - "Authorization": true, - "Cache-Control": true, - "Connection": true, - "Content-Encoding": true, - "Content-Length": true, - "Content-Range": true, - "Content-Type": true, - "Expect": true, - "Host": true, - "Keep-Alive": true, - "Max-Forwards": true, - "Pragma": true, - "Proxy-Authenticate": true, - "Proxy-Authorization": true, - "Proxy-Connection": true, - "Range": true, - "Realm": true, - "Te": true, - "Trailer": true, - "Transfer-Encoding": true, - "Www-Authenticate": true, -} diff --git a/vendor/golang.org/x/net/http2/server_test.go b/vendor/golang.org/x/net/http2/server_test.go deleted file mode 100644 index 61a7f9d..0000000 --- a/vendor/golang.org/x/net/http2/server_test.go +++ /dev/null @@ -1,3301 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "crypto/tls" - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - "net/http/httptest" - "os" - "os/exec" - "reflect" - "runtime" - "strconv" - "strings" - "sync" - "sync/atomic" - "testing" - "time" - - "golang.org/x/net/http2/hpack" -) - -var stderrVerbose = flag.Bool("stderr_verbose", false, "Mirror verbosity to stderr, unbuffered") - -func stderrv() io.Writer { - if *stderrVerbose { - return os.Stderr - } - - return ioutil.Discard -} - -type serverTester struct { - cc net.Conn // client conn - t testing.TB - ts *httptest.Server - fr *Framer - logBuf *bytes.Buffer - logFilter []string // substrings to filter out - scMu sync.Mutex // guards sc - sc *serverConn - hpackDec *hpack.Decoder - decodedHeaders [][2]string - - // writing headers: - headerBuf bytes.Buffer - hpackEnc *hpack.Encoder - - // reading frames: - frc chan Frame - frErrc chan error - readTimer *time.Timer -} - -func init() { - testHookOnPanicMu = new(sync.Mutex) -} - -func resetHooks() { - testHookOnPanicMu.Lock() - testHookOnPanic = nil - testHookOnPanicMu.Unlock() -} - -type serverTesterOpt string - -var optOnlyServer = serverTesterOpt("only_server") -var optQuiet = serverTesterOpt("quiet_logging") - -func newServerTester(t testing.TB, handler http.HandlerFunc, opts ...interface{}) *serverTester { - resetHooks() - - logBuf := new(bytes.Buffer) - ts := httptest.NewUnstartedServer(handler) - - tlsConfig := &tls.Config{ - InsecureSkipVerify: true, - // The h2-14 is temporary, until curl is updated. (as used by unit tests - // in Docker) - NextProtos: []string{NextProtoTLS, "h2-14"}, - } - - var onlyServer, quiet bool - for _, opt := range opts { - switch v := opt.(type) { - case func(*tls.Config): - v(tlsConfig) - case func(*httptest.Server): - v(ts) - case serverTesterOpt: - switch v { - case optOnlyServer: - onlyServer = true - case optQuiet: - quiet = true - } - default: - t.Fatalf("unknown newServerTester option type %T", v) - } - } - - ConfigureServer(ts.Config, &Server{}) - - st := &serverTester{ - t: t, - ts: ts, - logBuf: logBuf, - frc: make(chan Frame, 1), - frErrc: make(chan error, 1), - } - st.hpackEnc = hpack.NewEncoder(&st.headerBuf) - st.hpackDec = hpack.NewDecoder(initialHeaderTableSize, st.onHeaderField) - - ts.TLS = ts.Config.TLSConfig // the httptest.Server has its own copy of this TLS config - if quiet { - ts.Config.ErrorLog = log.New(ioutil.Discard, "", 0) - } else { - ts.Config.ErrorLog = log.New(io.MultiWriter(stderrv(), twriter{t: t, st: st}, logBuf), "", log.LstdFlags) - } - ts.StartTLS() - - if VerboseLogs { - t.Logf("Running test server at: %s", ts.URL) - } - testHookGetServerConn = func(v *serverConn) { - st.scMu.Lock() - defer st.scMu.Unlock() - st.sc = v - st.sc.testHookCh = make(chan func(int)) - } - log.SetOutput(io.MultiWriter(stderrv(), twriter{t: t, st: st})) - if !onlyServer { - cc, err := tls.Dial("tcp", ts.Listener.Addr().String(), tlsConfig) - if err != nil { - t.Fatal(err) - } - st.cc = cc - st.fr = NewFramer(cc, cc) - } - return st -} - -func (st *serverTester) closeConn() { - st.scMu.Lock() - defer st.scMu.Unlock() - st.sc.conn.Close() -} - -func (st *serverTester) addLogFilter(phrase string) { - st.logFilter = append(st.logFilter, phrase) -} - -func (st *serverTester) stream(id uint32) *stream { - ch := make(chan *stream, 1) - st.sc.testHookCh <- func(int) { - ch <- st.sc.streams[id] - } - return <-ch -} - -func (st *serverTester) streamState(id uint32) streamState { - ch := make(chan streamState, 1) - st.sc.testHookCh <- func(int) { - state, _ := st.sc.state(id) - ch <- state - } - return <-ch -} - -// loopNum reports how many times this conn's select loop has gone around. -func (st *serverTester) loopNum() int { - lastc := make(chan int, 1) - st.sc.testHookCh <- func(loopNum int) { - lastc <- loopNum - } - return <-lastc -} - -// awaitIdle heuristically awaits for the server conn's select loop to be idle. -// The heuristic is that the server connection's serve loop must schedule -// 50 times in a row without any channel sends or receives occurring. -func (st *serverTester) awaitIdle() { - remain := 50 - last := st.loopNum() - for remain > 0 { - n := st.loopNum() - if n == last+1 { - remain-- - } else { - remain = 50 - } - last = n - } -} - -func (st *serverTester) Close() { - if st.t.Failed() { - // If we failed already (and are likely in a Fatal, - // unwindowing), force close the connection, so the - // httptest.Server doesn't wait forever for the conn - // to close. - if st.cc != nil { - st.cc.Close() - } - } - st.ts.Close() - if st.cc != nil { - st.cc.Close() - } - log.SetOutput(os.Stderr) -} - -// greet initiates the client's HTTP/2 connection into a state where -// frames may be sent. -func (st *serverTester) greet() { - st.writePreface() - st.writeInitialSettings() - st.wantSettings() - st.writeSettingsAck() - st.wantSettingsAck() -} - -func (st *serverTester) writePreface() { - n, err := st.cc.Write(clientPreface) - if err != nil { - st.t.Fatalf("Error writing client preface: %v", err) - } - if n != len(clientPreface) { - st.t.Fatalf("Writing client preface, wrote %d bytes; want %d", n, len(clientPreface)) - } -} - -func (st *serverTester) writeInitialSettings() { - if err := st.fr.WriteSettings(); err != nil { - st.t.Fatalf("Error writing initial SETTINGS frame from client to server: %v", err) - } -} - -func (st *serverTester) writeSettingsAck() { - if err := st.fr.WriteSettingsAck(); err != nil { - st.t.Fatalf("Error writing ACK of server's SETTINGS: %v", err) - } -} - -func (st *serverTester) writeHeaders(p HeadersFrameParam) { - if err := st.fr.WriteHeaders(p); err != nil { - st.t.Fatalf("Error writing HEADERS: %v", err) - } -} - -func (st *serverTester) encodeHeaderField(k, v string) { - err := st.hpackEnc.WriteField(hpack.HeaderField{Name: k, Value: v}) - if err != nil { - st.t.Fatalf("HPACK encoding error for %q/%q: %v", k, v, err) - } -} - -// encodeHeaderRaw is the magic-free version of encodeHeader. -// It takes 0 or more (k, v) pairs and encodes them. -func (st *serverTester) encodeHeaderRaw(headers ...string) []byte { - if len(headers)%2 == 1 { - panic("odd number of kv args") - } - st.headerBuf.Reset() - for len(headers) > 0 { - k, v := headers[0], headers[1] - st.encodeHeaderField(k, v) - headers = headers[2:] - } - return st.headerBuf.Bytes() -} - -// encodeHeader encodes headers and returns their HPACK bytes. headers -// must contain an even number of key/value pairs. There may be -// multiple pairs for keys (e.g. "cookie"). The :method, :path, and -// :scheme headers default to GET, / and https. -func (st *serverTester) encodeHeader(headers ...string) []byte { - if len(headers)%2 == 1 { - panic("odd number of kv args") - } - - st.headerBuf.Reset() - - if len(headers) == 0 { - // Fast path, mostly for benchmarks, so test code doesn't pollute - // profiles when we're looking to improve server allocations. - st.encodeHeaderField(":method", "GET") - st.encodeHeaderField(":path", "/") - st.encodeHeaderField(":scheme", "https") - return st.headerBuf.Bytes() - } - - if len(headers) == 2 && headers[0] == ":method" { - // Another fast path for benchmarks. - st.encodeHeaderField(":method", headers[1]) - st.encodeHeaderField(":path", "/") - st.encodeHeaderField(":scheme", "https") - return st.headerBuf.Bytes() - } - - pseudoCount := map[string]int{} - keys := []string{":method", ":path", ":scheme"} - vals := map[string][]string{ - ":method": {"GET"}, - ":path": {"/"}, - ":scheme": {"https"}, - } - for len(headers) > 0 { - k, v := headers[0], headers[1] - headers = headers[2:] - if _, ok := vals[k]; !ok { - keys = append(keys, k) - } - if strings.HasPrefix(k, ":") { - pseudoCount[k]++ - if pseudoCount[k] == 1 { - vals[k] = []string{v} - } else { - // Allows testing of invalid headers w/ dup pseudo fields. - vals[k] = append(vals[k], v) - } - } else { - vals[k] = append(vals[k], v) - } - } - for _, k := range keys { - for _, v := range vals[k] { - st.encodeHeaderField(k, v) - } - } - return st.headerBuf.Bytes() -} - -// bodylessReq1 writes a HEADERS frames with StreamID 1 and EndStream and EndHeaders set. -func (st *serverTester) bodylessReq1(headers ...string) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(headers...), - EndStream: true, - EndHeaders: true, - }) -} - -func (st *serverTester) writeData(streamID uint32, endStream bool, data []byte) { - if err := st.fr.WriteData(streamID, endStream, data); err != nil { - st.t.Fatalf("Error writing DATA: %v", err) - } -} - -func (st *serverTester) readFrame() (Frame, error) { - go func() { - fr, err := st.fr.ReadFrame() - if err != nil { - st.frErrc <- err - } else { - st.frc <- fr - } - }() - t := st.readTimer - if t == nil { - t = time.NewTimer(2 * time.Second) - st.readTimer = t - } - t.Reset(2 * time.Second) - defer t.Stop() - select { - case f := <-st.frc: - return f, nil - case err := <-st.frErrc: - return nil, err - case <-t.C: - return nil, errors.New("timeout waiting for frame") - } -} - -func (st *serverTester) wantHeaders() *HeadersFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a HEADERS frame: %v", err) - } - hf, ok := f.(*HeadersFrame) - if !ok { - st.t.Fatalf("got a %T; want *HeadersFrame", f) - } - return hf -} - -func (st *serverTester) wantContinuation() *ContinuationFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a CONTINUATION frame: %v", err) - } - cf, ok := f.(*ContinuationFrame) - if !ok { - st.t.Fatalf("got a %T; want *ContinuationFrame", f) - } - return cf -} - -func (st *serverTester) wantData() *DataFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a DATA frame: %v", err) - } - df, ok := f.(*DataFrame) - if !ok { - st.t.Fatalf("got a %T; want *DataFrame", f) - } - return df -} - -func (st *serverTester) wantSettings() *SettingsFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a SETTINGS frame: %v", err) - } - sf, ok := f.(*SettingsFrame) - if !ok { - st.t.Fatalf("got a %T; want *SettingsFrame", f) - } - return sf -} - -func (st *serverTester) wantPing() *PingFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a PING frame: %v", err) - } - pf, ok := f.(*PingFrame) - if !ok { - st.t.Fatalf("got a %T; want *PingFrame", f) - } - return pf -} - -func (st *serverTester) wantGoAway() *GoAwayFrame { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a GOAWAY frame: %v", err) - } - gf, ok := f.(*GoAwayFrame) - if !ok { - st.t.Fatalf("got a %T; want *GoAwayFrame", f) - } - return gf -} - -func (st *serverTester) wantRSTStream(streamID uint32, errCode ErrCode) { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting an RSTStream frame: %v", err) - } - rs, ok := f.(*RSTStreamFrame) - if !ok { - st.t.Fatalf("got a %T; want *RSTStreamFrame", f) - } - if rs.FrameHeader.StreamID != streamID { - st.t.Fatalf("RSTStream StreamID = %d; want %d", rs.FrameHeader.StreamID, streamID) - } - if rs.ErrCode != errCode { - st.t.Fatalf("RSTStream ErrCode = %d (%s); want %d (%s)", rs.ErrCode, rs.ErrCode, errCode, errCode) - } -} - -func (st *serverTester) wantWindowUpdate(streamID, incr uint32) { - f, err := st.readFrame() - if err != nil { - st.t.Fatalf("Error while expecting a WINDOW_UPDATE frame: %v", err) - } - wu, ok := f.(*WindowUpdateFrame) - if !ok { - st.t.Fatalf("got a %T; want *WindowUpdateFrame", f) - } - if wu.FrameHeader.StreamID != streamID { - st.t.Fatalf("WindowUpdate StreamID = %d; want %d", wu.FrameHeader.StreamID, streamID) - } - if wu.Increment != incr { - st.t.Fatalf("WindowUpdate increment = %d; want %d", wu.Increment, incr) - } -} - -func (st *serverTester) wantSettingsAck() { - f, err := st.readFrame() - if err != nil { - st.t.Fatal(err) - } - sf, ok := f.(*SettingsFrame) - if !ok { - st.t.Fatalf("Wanting a settings ACK, received a %T", f) - } - if !sf.Header().Flags.Has(FlagSettingsAck) { - st.t.Fatal("Settings Frame didn't have ACK set") - } - -} - -func TestServer(t *testing.T) { - gotReq := make(chan bool, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Foo", "Bar") - gotReq <- true - }) - defer st.Close() - - covers("3.5", ` - The server connection preface consists of a potentially empty - SETTINGS frame ([SETTINGS]) that MUST be the first frame the - server sends in the HTTP/2 connection. - `) - - st.writePreface() - st.writeInitialSettings() - st.wantSettings() - st.writeSettingsAck() - st.wantSettingsAck() - - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(), - EndStream: true, // no DATA frames - EndHeaders: true, - }) - - select { - case <-gotReq: - case <-time.After(2 * time.Second): - t.Error("timeout waiting for request") - } -} - -func TestServer_Request_Get(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader("foo-bar", "some-value"), - EndStream: true, // no DATA frames - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Method != "GET" { - t.Errorf("Method = %q; want GET", r.Method) - } - if r.URL.Path != "/" { - t.Errorf("URL.Path = %q; want /", r.URL.Path) - } - if r.ContentLength != 0 { - t.Errorf("ContentLength = %v; want 0", r.ContentLength) - } - if r.Close { - t.Error("Close = true; want false") - } - if !strings.Contains(r.RemoteAddr, ":") { - t.Errorf("RemoteAddr = %q; want something with a colon", r.RemoteAddr) - } - if r.Proto != "HTTP/2.0" || r.ProtoMajor != 2 || r.ProtoMinor != 0 { - t.Errorf("Proto = %q Major=%v,Minor=%v; want HTTP/2.0", r.Proto, r.ProtoMajor, r.ProtoMinor) - } - wantHeader := http.Header{ - "Foo-Bar": []string{"some-value"}, - } - if !reflect.DeepEqual(r.Header, wantHeader) { - t.Errorf("Header = %#v; want %#v", r.Header, wantHeader) - } - if n, err := r.Body.Read([]byte(" ")); err != io.EOF || n != 0 { - t.Errorf("Read = %d, %v; want 0, EOF", n, err) - } - }) -} - -func TestServer_Request_Get_PathSlashes(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":path", "/%2f/"), - EndStream: true, // no DATA frames - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.RequestURI != "/%2f/" { - t.Errorf("RequestURI = %q; want /%%2f/", r.RequestURI) - } - if r.URL.Path != "///" { - t.Errorf("URL.Path = %q; want ///", r.URL.Path) - } - }) -} - -// TODO: add a test with EndStream=true on the HEADERS but setting a -// Content-Length anyway. Should we just omit it and force it to -// zero? - -func TestServer_Request_Post_NoContentLength_EndStream(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Method != "POST" { - t.Errorf("Method = %q; want POST", r.Method) - } - if r.ContentLength != 0 { - t.Errorf("ContentLength = %v; want 0", r.ContentLength) - } - if n, err := r.Body.Read([]byte(" ")); err != io.EOF || n != 0 { - t.Errorf("Read = %d, %v; want 0, EOF", n, err) - } - }) -} - -func TestServer_Request_Post_Body_ImmediateEOF(t *testing.T) { - testBodyContents(t, -1, "", func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, nil) // just kidding. empty body. - }) -} - -func TestServer_Request_Post_Body_OneData(t *testing.T) { - const content = "Some content" - testBodyContents(t, -1, content, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte(content)) - }) -} - -func TestServer_Request_Post_Body_TwoData(t *testing.T) { - const content = "Some content" - testBodyContents(t, -1, content, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, false, []byte(content[:5])) - st.writeData(1, true, []byte(content[5:])) - }) -} - -func TestServer_Request_Post_Body_ContentLength_Correct(t *testing.T) { - const content = "Some content" - testBodyContents(t, int64(len(content)), content, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader( - ":method", "POST", - "content-length", strconv.Itoa(len(content)), - ), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte(content)) - }) -} - -func TestServer_Request_Post_Body_ContentLength_TooLarge(t *testing.T) { - testBodyContentsFail(t, 3, "request declared a Content-Length of 3 but only wrote 2 bytes", - func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader( - ":method", "POST", - "content-length", "3", - ), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte("12")) - }) -} - -func TestServer_Request_Post_Body_ContentLength_TooSmall(t *testing.T) { - testBodyContentsFail(t, 4, "sender tried to send more than declared Content-Length of 4 bytes", - func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader( - ":method", "POST", - "content-length", "4", - ), - EndStream: false, // to say DATA frames are coming - EndHeaders: true, - }) - st.writeData(1, true, []byte("12345")) - }) -} - -func testBodyContents(t *testing.T, wantContentLength int64, wantBody string, write func(st *serverTester)) { - testServerRequest(t, write, func(r *http.Request) { - if r.Method != "POST" { - t.Errorf("Method = %q; want POST", r.Method) - } - if r.ContentLength != wantContentLength { - t.Errorf("ContentLength = %v; want %d", r.ContentLength, wantContentLength) - } - all, err := ioutil.ReadAll(r.Body) - if err != nil { - t.Fatal(err) - } - if string(all) != wantBody { - t.Errorf("Read = %q; want %q", all, wantBody) - } - if err := r.Body.Close(); err != nil { - t.Fatalf("Close: %v", err) - } - }) -} - -func testBodyContentsFail(t *testing.T, wantContentLength int64, wantReadError string, write func(st *serverTester)) { - testServerRequest(t, write, func(r *http.Request) { - if r.Method != "POST" { - t.Errorf("Method = %q; want POST", r.Method) - } - if r.ContentLength != wantContentLength { - t.Errorf("ContentLength = %v; want %d", r.ContentLength, wantContentLength) - } - all, err := ioutil.ReadAll(r.Body) - if err == nil { - t.Fatalf("expected an error (%q) reading from the body. Successfully read %q instead.", - wantReadError, all) - } - if !strings.Contains(err.Error(), wantReadError) { - t.Fatalf("Body.Read = %v; want substring %q", err, wantReadError) - } - if err := r.Body.Close(); err != nil { - t.Fatalf("Close: %v", err) - } - }) -} - -// Using a Host header, instead of :authority -func TestServer_Request_Get_Host(t *testing.T) { - const host = "example.com" - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader("host", host), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Host != host { - t.Errorf("Host = %q; want %q", r.Host, host) - } - }) -} - -// Using an :authority pseudo-header, instead of Host -func TestServer_Request_Get_Authority(t *testing.T) { - const host = "example.com" - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":authority", host), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if r.Host != host { - t.Errorf("Host = %q; want %q", r.Host, host) - } - }) -} - -func TestServer_Request_WithContinuation(t *testing.T) { - wantHeader := http.Header{ - "Foo-One": []string{"value-one"}, - "Foo-Two": []string{"value-two"}, - "Foo-Three": []string{"value-three"}, - } - testServerRequest(t, func(st *serverTester) { - fullHeaders := st.encodeHeader( - "foo-one", "value-one", - "foo-two", "value-two", - "foo-three", "value-three", - ) - remain := fullHeaders - chunks := 0 - for len(remain) > 0 { - const maxChunkSize = 5 - chunk := remain - if len(chunk) > maxChunkSize { - chunk = chunk[:maxChunkSize] - } - remain = remain[len(chunk):] - - if chunks == 0 { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: chunk, - EndStream: true, // no DATA frames - EndHeaders: false, // we'll have continuation frames - }) - } else { - err := st.fr.WriteContinuation(1, len(remain) == 0, chunk) - if err != nil { - t.Fatal(err) - } - } - chunks++ - } - if chunks < 2 { - t.Fatal("too few chunks") - } - }, func(r *http.Request) { - if !reflect.DeepEqual(r.Header, wantHeader) { - t.Errorf("Header = %#v; want %#v", r.Header, wantHeader) - } - }) -} - -// Concatenated cookie headers. ("8.1.2.5 Compressing the Cookie Header Field") -func TestServer_Request_CookieConcat(t *testing.T) { - const host = "example.com" - testServerRequest(t, func(st *serverTester) { - st.bodylessReq1( - ":authority", host, - "cookie", "a=b", - "cookie", "c=d", - "cookie", "e=f", - ) - }, func(r *http.Request) { - const want = "a=b; c=d; e=f" - if got := r.Header.Get("Cookie"); got != want { - t.Errorf("Cookie = %q; want %q", got, want) - } - }) -} - -func TestServer_Request_Reject_CapitalHeader(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("UPPER", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldNameColon(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("has:colon", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldNameNULL(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("has\x00null", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldNameEmpty(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("", "v") }) -} - -func TestServer_Request_Reject_HeaderFieldValueNewline(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("foo", "has\nnewline") }) -} - -func TestServer_Request_Reject_HeaderFieldValueCR(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("foo", "has\rcarriage") }) -} - -func TestServer_Request_Reject_HeaderFieldValueDEL(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1("foo", "has\x7fdel") }) -} - -func TestServer_Request_Reject_Pseudo_Missing_method(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":method", "") }) -} - -func TestServer_Request_Reject_Pseudo_ExactlyOne(t *testing.T) { - // 8.1.2.3 Request Pseudo-Header Fields - // "All HTTP/2 requests MUST include exactly one valid value" ... - testRejectRequest(t, func(st *serverTester) { - st.addLogFilter("duplicate pseudo-header") - st.bodylessReq1(":method", "GET", ":method", "POST") - }) -} - -func TestServer_Request_Reject_Pseudo_AfterRegular(t *testing.T) { - // 8.1.2.3 Request Pseudo-Header Fields - // "All pseudo-header fields MUST appear in the header block - // before regular header fields. Any request or response that - // contains a pseudo-header field that appears in a header - // block after a regular header field MUST be treated as - // malformed (Section 8.1.2.6)." - testRejectRequest(t, func(st *serverTester) { - st.addLogFilter("pseudo-header after regular header") - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - enc.WriteField(hpack.HeaderField{Name: ":method", Value: "GET"}) - enc.WriteField(hpack.HeaderField{Name: "regular", Value: "foobar"}) - enc.WriteField(hpack.HeaderField{Name: ":path", Value: "/"}) - enc.WriteField(hpack.HeaderField{Name: ":scheme", Value: "https"}) - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: buf.Bytes(), - EndStream: true, - EndHeaders: true, - }) - }) -} - -func TestServer_Request_Reject_Pseudo_Missing_path(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":path", "") }) -} - -func TestServer_Request_Reject_Pseudo_Missing_scheme(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":scheme", "") }) -} - -func TestServer_Request_Reject_Pseudo_scheme_invalid(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { st.bodylessReq1(":scheme", "bogus") }) -} - -func TestServer_Request_Reject_Pseudo_Unknown(t *testing.T) { - testRejectRequest(t, func(st *serverTester) { - st.addLogFilter(`invalid pseudo-header ":unknown_thing"`) - st.bodylessReq1(":unknown_thing", "") - }) -} - -func testRejectRequest(t *testing.T, send func(*serverTester)) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - t.Fatal("server request made it to handler; should've been rejected") - }) - defer st.Close() - - st.greet() - send(st) - st.wantRSTStream(1, ErrCodeProtocol) -} - -func TestServer_Request_Connect(t *testing.T) { - testServerRequest(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeaderRaw( - ":method", "CONNECT", - ":authority", "example.com:123", - ), - EndStream: true, - EndHeaders: true, - }) - }, func(r *http.Request) { - if g, w := r.Method, "CONNECT"; g != w { - t.Errorf("Method = %q; want %q", g, w) - } - if g, w := r.RequestURI, "example.com:123"; g != w { - t.Errorf("RequestURI = %q; want %q", g, w) - } - if g, w := r.URL.Host, "example.com:123"; g != w { - t.Errorf("URL.Host = %q; want %q", g, w) - } - }) -} - -func TestServer_Request_Connect_InvalidPath(t *testing.T) { - testServerRejectsStream(t, ErrCodeProtocol, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeaderRaw( - ":method", "CONNECT", - ":authority", "example.com:123", - ":path", "/bogus", - ), - EndStream: true, - EndHeaders: true, - }) - }) -} - -func TestServer_Request_Connect_InvalidScheme(t *testing.T) { - testServerRejectsStream(t, ErrCodeProtocol, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeaderRaw( - ":method", "CONNECT", - ":authority", "example.com:123", - ":scheme", "https", - ), - EndStream: true, - EndHeaders: true, - }) - }) -} - -func TestServer_Ping(t *testing.T) { - st := newServerTester(t, nil) - defer st.Close() - st.greet() - - // Server should ignore this one, since it has ACK set. - ackPingData := [8]byte{1, 2, 4, 8, 16, 32, 64, 128} - if err := st.fr.WritePing(true, ackPingData); err != nil { - t.Fatal(err) - } - - // But the server should reply to this one, since ACK is false. - pingData := [8]byte{1, 2, 3, 4, 5, 6, 7, 8} - if err := st.fr.WritePing(false, pingData); err != nil { - t.Fatal(err) - } - - pf := st.wantPing() - if !pf.Flags.Has(FlagPingAck) { - t.Error("response ping doesn't have ACK set") - } - if pf.Data != pingData { - t.Errorf("response ping has data %q; want %q", pf.Data, pingData) - } -} - -func TestServer_RejectsLargeFrames(t *testing.T) { - if runtime.GOOS == "windows" { - t.Skip("see golang.org/issue/13434") - } - - st := newServerTester(t, nil) - defer st.Close() - st.greet() - - // Write too large of a frame (too large by one byte) - // We ignore the return value because it's expected that the server - // will only read the first 9 bytes (the headre) and then disconnect. - st.fr.WriteRawFrame(0xff, 0, 0, make([]byte, defaultMaxReadFrameSize+1)) - - gf := st.wantGoAway() - if gf.ErrCode != ErrCodeFrameSize { - t.Errorf("GOAWAY err = %v; want %v", gf.ErrCode, ErrCodeFrameSize) - } - if st.logBuf.Len() != 0 { - // Previously we spun here for a bit until the GOAWAY disconnect - // timer fired, logging while we fired. - t.Errorf("unexpected server output: %.500s\n", st.logBuf.Bytes()) - } -} - -func TestServer_Handler_Sends_WindowUpdate(t *testing.T) { - puppet := newHandlerPuppet() - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - puppet.act(w, r) - }) - defer st.Close() - defer puppet.done() - - st.greet() - - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // data coming - EndHeaders: true, - }) - st.writeData(1, false, []byte("abcdef")) - puppet.do(readBodyHandler(t, "abc")) - st.wantWindowUpdate(0, 3) - st.wantWindowUpdate(1, 3) - - puppet.do(readBodyHandler(t, "def")) - st.wantWindowUpdate(0, 3) - st.wantWindowUpdate(1, 3) - - st.writeData(1, true, []byte("ghijkl")) // END_STREAM here - puppet.do(readBodyHandler(t, "ghi")) - puppet.do(readBodyHandler(t, "jkl")) - st.wantWindowUpdate(0, 3) - st.wantWindowUpdate(0, 3) // no more stream-level, since END_STREAM -} - -func TestServer_Send_GoAway_After_Bogus_WindowUpdate(t *testing.T) { - st := newServerTester(t, nil) - defer st.Close() - st.greet() - if err := st.fr.WriteWindowUpdate(0, 1<<31-1); err != nil { - t.Fatal(err) - } - gf := st.wantGoAway() - if gf.ErrCode != ErrCodeFlowControl { - t.Errorf("GOAWAY err = %v; want %v", gf.ErrCode, ErrCodeFlowControl) - } - if gf.LastStreamID != 0 { - t.Errorf("GOAWAY last stream ID = %v; want %v", gf.LastStreamID, 0) - } -} - -func TestServer_Send_RstStream_After_Bogus_WindowUpdate(t *testing.T) { - inHandler := make(chan bool) - blockHandler := make(chan bool) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - <-blockHandler - }) - defer st.Close() - defer close(blockHandler) - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - // Send a bogus window update: - if err := st.fr.WriteWindowUpdate(1, 1<<31-1); err != nil { - t.Fatal(err) - } - st.wantRSTStream(1, ErrCodeFlowControl) -} - -// testServerPostUnblock sends a hanging POST with unsent data to handler, -// then runs fn once in the handler, and verifies that the error returned from -// handler is acceptable. It fails if takes over 5 seconds for handler to exit. -func testServerPostUnblock(t *testing.T, - handler func(http.ResponseWriter, *http.Request) error, - fn func(*serverTester), - checkErr func(error), - otherHeaders ...string) { - inHandler := make(chan bool) - errc := make(chan error, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - errc <- handler(w, r) - }) - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(append([]string{":method", "POST"}, otherHeaders...)...), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - fn(st) - select { - case err := <-errc: - if checkErr != nil { - checkErr(err) - } - case <-time.After(5 * time.Second): - t.Fatal("timeout waiting for Handler to return") - } - st.Close() -} - -func TestServer_RSTStream_Unblocks_Read(t *testing.T) { - testServerPostUnblock(t, - func(w http.ResponseWriter, r *http.Request) (err error) { - _, err = r.Body.Read(make([]byte, 1)) - return - }, - func(st *serverTester) { - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - }, - func(err error) { - want := StreamError{StreamID: 0x1, Code: 0x8} - if !reflect.DeepEqual(err, want) { - t.Errorf("Read error = %v; want %v", err, want) - } - }, - ) -} - -func TestServer_RSTStream_Unblocks_Header_Write(t *testing.T) { - // Run this test a bunch, because it doesn't always - // deadlock. But with a bunch, it did. - n := 50 - if testing.Short() { - n = 5 - } - for i := 0; i < n; i++ { - testServer_RSTStream_Unblocks_Header_Write(t) - } -} - -func testServer_RSTStream_Unblocks_Header_Write(t *testing.T) { - inHandler := make(chan bool, 1) - unblockHandler := make(chan bool, 1) - headerWritten := make(chan bool, 1) - wroteRST := make(chan bool, 1) - - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - <-wroteRST - w.Header().Set("foo", "bar") - w.WriteHeader(200) - w.(http.Flusher).Flush() - headerWritten <- true - <-unblockHandler - }) - defer st.Close() - - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - wroteRST <- true - st.awaitIdle() - select { - case <-headerWritten: - case <-time.After(2 * time.Second): - t.Error("timeout waiting for header write") - } - unblockHandler <- true -} - -func TestServer_DeadConn_Unblocks_Read(t *testing.T) { - testServerPostUnblock(t, - func(w http.ResponseWriter, r *http.Request) (err error) { - _, err = r.Body.Read(make([]byte, 1)) - return - }, - func(st *serverTester) { st.cc.Close() }, - func(err error) { - if err == nil { - t.Error("unexpected nil error from Request.Body.Read") - } - }, - ) -} - -var blockUntilClosed = func(w http.ResponseWriter, r *http.Request) error { - <-w.(http.CloseNotifier).CloseNotify() - return nil -} - -func TestServer_CloseNotify_After_RSTStream(t *testing.T) { - testServerPostUnblock(t, blockUntilClosed, func(st *serverTester) { - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - }, nil) -} - -func TestServer_CloseNotify_After_ConnClose(t *testing.T) { - testServerPostUnblock(t, blockUntilClosed, func(st *serverTester) { st.cc.Close() }, nil) -} - -// that CloseNotify unblocks after a stream error due to the client's -// problem that's unrelated to them explicitly canceling it (which is -// TestServer_CloseNotify_After_RSTStream above) -func TestServer_CloseNotify_After_StreamError(t *testing.T) { - testServerPostUnblock(t, blockUntilClosed, func(st *serverTester) { - // data longer than declared Content-Length => stream error - st.writeData(1, true, []byte("1234")) - }, nil, "content-length", "3") -} - -func TestServer_StateTransitions(t *testing.T) { - var st *serverTester - inHandler := make(chan bool) - writeData := make(chan bool) - leaveHandler := make(chan bool) - st = newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - inHandler <- true - if st.stream(1) == nil { - t.Errorf("nil stream 1 in handler") - } - if got, want := st.streamState(1), stateOpen; got != want { - t.Errorf("in handler, state is %v; want %v", got, want) - } - writeData <- true - if n, err := r.Body.Read(make([]byte, 1)); n != 0 || err != io.EOF { - t.Errorf("body read = %d, %v; want 0, EOF", n, err) - } - if got, want := st.streamState(1), stateHalfClosedRemote; got != want { - t.Errorf("in handler, state is %v; want %v", got, want) - } - - <-leaveHandler - }) - st.greet() - if st.stream(1) != nil { - t.Fatal("stream 1 should be empty") - } - if got := st.streamState(1); got != stateIdle { - t.Fatalf("stream 1 should be idle; got %v", got) - } - - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, // keep it open - EndHeaders: true, - }) - <-inHandler - <-writeData - st.writeData(1, true, nil) - - leaveHandler <- true - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Fatal("expected END_STREAM flag") - } - - if got, want := st.streamState(1), stateClosed; got != want { - t.Errorf("at end, state is %v; want %v", got, want) - } - if st.stream(1) != nil { - t.Fatal("at end, stream 1 should be gone") - } -} - -// test HEADERS w/o EndHeaders + another HEADERS (should get rejected) -func TestServer_Rejects_HeadersNoEnd_Then_Headers(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: false, - }) - st.writeHeaders(HeadersFrameParam{ // Not a continuation. - StreamID: 3, // different stream. - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - }) -} - -// test HEADERS w/o EndHeaders + PING (should get rejected) -func TestServer_Rejects_HeadersNoEnd_Then_Ping(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: false, - }) - if err := st.fr.WritePing(false, [8]byte{}); err != nil { - t.Fatal(err) - } - }) -} - -// test HEADERS w/ EndHeaders + a continuation HEADERS (should get rejected) -func TestServer_Rejects_HeadersEnd_Then_Continuation(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - st.wantHeaders() - if err := st.fr.WriteContinuation(1, true, encodeHeaderNoImplicit(t, "foo", "bar")); err != nil { - t.Fatal(err) - } - }) -} - -// test HEADERS w/o EndHeaders + a continuation HEADERS on wrong stream ID -func TestServer_Rejects_HeadersNoEnd_Then_ContinuationWrongStream(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: false, - }) - if err := st.fr.WriteContinuation(3, true, encodeHeaderNoImplicit(t, "foo", "bar")); err != nil { - t.Fatal(err) - } - }) -} - -// No HEADERS on stream 0. -func TestServer_Rejects_Headers0(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.fr.AllowIllegalWrites = true - st.writeHeaders(HeadersFrameParam{ - StreamID: 0, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - }) -} - -// No CONTINUATION on stream 0. -func TestServer_Rejects_Continuation0(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - st.fr.AllowIllegalWrites = true - if err := st.fr.WriteContinuation(0, true, st.encodeHeader()); err != nil { - t.Fatal(err) - } - }) -} - -func TestServer_Rejects_PushPromise(t *testing.T) { - testServerRejectsConn(t, func(st *serverTester) { - pp := PushPromiseParam{ - StreamID: 1, - PromiseID: 3, - } - if err := st.fr.WritePushPromise(pp); err != nil { - t.Fatal(err) - } - }) -} - -// testServerRejectsConn tests that the server hangs up with a GOAWAY -// frame and a server close after the client does something -// deserving a CONNECTION_ERROR. -func testServerRejectsConn(t *testing.T, writeReq func(*serverTester)) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}) - st.addLogFilter("connection error: PROTOCOL_ERROR") - defer st.Close() - st.greet() - writeReq(st) - - st.wantGoAway() - errc := make(chan error, 1) - go func() { - fr, err := st.fr.ReadFrame() - if err == nil { - err = fmt.Errorf("got frame of type %T", fr) - } - errc <- err - }() - select { - case err := <-errc: - if err != io.EOF { - t.Errorf("ReadFrame = %v; want io.EOF", err) - } - case <-time.After(2 * time.Second): - t.Error("timeout waiting for disconnect") - } -} - -// testServerRejectsStream tests that the server sends a RST_STREAM with the provided -// error code after a client sends a bogus request. -func testServerRejectsStream(t *testing.T, code ErrCode, writeReq func(*serverTester)) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}) - defer st.Close() - st.greet() - writeReq(st) - st.wantRSTStream(1, code) -} - -// testServerRequest sets up an idle HTTP/2 connection and lets you -// write a single request with writeReq, and then verify that the -// *http.Request is built correctly in checkReq. -func testServerRequest(t *testing.T, writeReq func(*serverTester), checkReq func(*http.Request)) { - gotReq := make(chan bool, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - if r.Body == nil { - t.Fatal("nil Body") - } - checkReq(r) - gotReq <- true - }) - defer st.Close() - - st.greet() - writeReq(st) - - select { - case <-gotReq: - case <-time.After(2 * time.Second): - t.Error("timeout waiting for request") - } -} - -func getSlash(st *serverTester) { st.bodylessReq1() } - -func TestServer_Response_NoData(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - // Nothing. - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Fatal("want END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - }) -} - -func TestServer_Response_NoData_Header_FooBar(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Foo-Bar", "some-value") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Fatal("want END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"foo-bar", "some-value"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", "0"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -func TestServer_Response_Data_Sniff_DoesntOverride(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Content-Type", "foo/bar") - io.WriteString(w, msg) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("don't want END_STREAM, expecting data") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "foo/bar"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - df := st.wantData() - if !df.StreamEnded() { - t.Error("expected DATA to have END_STREAM flag") - } - if got := string(df.Data()); got != msg { - t.Errorf("got DATA %q; want %q", got, msg) - } - }) -} - -func TestServer_Response_TransferEncoding_chunked(t *testing.T) { - const msg = "hi" - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Transfer-Encoding", "chunked") // should be stripped - io.WriteString(w, msg) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -// Header accessed only after the initial write. -func TestServer_Response_Data_IgnoreHeaderAfterWrite_After(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - io.WriteString(w, msg) - w.Header().Set("foo", "should be ignored") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -// Header accessed before the initial write and later mutated. -func TestServer_Response_Data_IgnoreHeaderAfterWrite_Overwrite(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("foo", "proper value") - io.WriteString(w, msg) - w.Header().Set("foo", "should be ignored") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"foo", "proper value"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -func TestServer_Response_Data_SniffLenType(t *testing.T) { - const msg = "this is HTML." - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - io.WriteString(w, msg) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("don't want END_STREAM, expecting data") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", strconv.Itoa(len(msg))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - df := st.wantData() - if !df.StreamEnded() { - t.Error("expected DATA to have END_STREAM flag") - } - if got := string(df.Data()); got != msg { - t.Errorf("got DATA %q; want %q", got, msg) - } - }) -} - -func TestServer_Response_Header_Flush_MidWrite(t *testing.T) { - const msg = "this is HTML" - const msg2 = ", and this is the next chunk" - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - io.WriteString(w, msg) - w.(http.Flusher).Flush() - io.WriteString(w, msg2) - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/html; charset=utf-8"}, // sniffed - // and no content-length - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - { - df := st.wantData() - if df.StreamEnded() { - t.Error("unexpected END_STREAM flag") - } - if got := string(df.Data()); got != msg { - t.Errorf("got DATA %q; want %q", got, msg) - } - } - { - df := st.wantData() - if !df.StreamEnded() { - t.Error("wanted END_STREAM flag on last data chunk") - } - if got := string(df.Data()); got != msg2 { - t.Errorf("got DATA %q; want %q", got, msg2) - } - } - }) -} - -func TestServer_Response_LargeWrite(t *testing.T) { - const size = 1 << 20 - const maxFrameSize = 16 << 10 - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - n, err := w.Write(bytes.Repeat([]byte("a"), size)) - if err != nil { - return fmt.Errorf("Write error: %v", err) - } - if n != size { - return fmt.Errorf("wrong size %d from Write", n) - } - return nil - }, func(st *serverTester) { - if err := st.fr.WriteSettings( - Setting{SettingInitialWindowSize, 0}, - Setting{SettingMaxFrameSize, maxFrameSize}, - ); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - - // Give the handler quota to write: - if err := st.fr.WriteWindowUpdate(1, size); err != nil { - t.Fatal(err) - } - // Give the handler quota to write to connection-level - // window as well - if err := st.fr.WriteWindowUpdate(0, size); err != nil { - t.Fatal(err) - } - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, // sniffed - // and no content-length - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - var bytes, frames int - for { - df := st.wantData() - bytes += len(df.Data()) - frames++ - for _, b := range df.Data() { - if b != 'a' { - t.Fatal("non-'a' byte seen in DATA") - } - } - if df.StreamEnded() { - break - } - } - if bytes != size { - t.Errorf("Got %d bytes; want %d", bytes, size) - } - if want := int(size / maxFrameSize); frames < want || frames > want*2 { - t.Errorf("Got %d frames; want %d", frames, size) - } - }) -} - -// Test that the handler can't write more than the client allows -func TestServer_Response_LargeWrite_FlowControlled(t *testing.T) { - const size = 1 << 20 - const maxFrameSize = 16 << 10 - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.(http.Flusher).Flush() - n, err := w.Write(bytes.Repeat([]byte("a"), size)) - if err != nil { - return fmt.Errorf("Write error: %v", err) - } - if n != size { - return fmt.Errorf("wrong size %d from Write", n) - } - return nil - }, func(st *serverTester) { - // Set the window size to something explicit for this test. - // It's also how much initial data we expect. - const initWindowSize = 123 - if err := st.fr.WriteSettings( - Setting{SettingInitialWindowSize, initWindowSize}, - Setting{SettingMaxFrameSize, maxFrameSize}, - ); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - defer func() { st.fr.WriteRSTStream(1, ErrCodeCancel) }() - - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - - df := st.wantData() - if got := len(df.Data()); got != initWindowSize { - t.Fatalf("Initial window size = %d but got DATA with %d bytes", initWindowSize, got) - } - - for _, quota := range []int{1, 13, 127} { - if err := st.fr.WriteWindowUpdate(1, uint32(quota)); err != nil { - t.Fatal(err) - } - df := st.wantData() - if int(quota) != len(df.Data()) { - t.Fatalf("read %d bytes after giving %d quota", len(df.Data()), quota) - } - } - - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - }) -} - -// Test that the handler blocked in a Write is unblocked if the server sends a RST_STREAM. -func TestServer_Response_RST_Unblocks_LargeWrite(t *testing.T) { - const size = 1 << 20 - const maxFrameSize = 16 << 10 - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.(http.Flusher).Flush() - errc := make(chan error, 1) - go func() { - _, err := w.Write(bytes.Repeat([]byte("a"), size)) - errc <- err - }() - select { - case err := <-errc: - if err == nil { - return errors.New("unexpected nil error from Write in handler") - } - return nil - case <-time.After(2 * time.Second): - return errors.New("timeout waiting for Write in handler") - } - }, func(st *serverTester) { - if err := st.fr.WriteSettings( - Setting{SettingInitialWindowSize, 0}, - Setting{SettingMaxFrameSize, maxFrameSize}, - ); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - - if err := st.fr.WriteRSTStream(1, ErrCodeCancel); err != nil { - t.Fatal(err) - } - }) -} - -func TestServer_Response_Empty_Data_Not_FlowControlled(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.(http.Flusher).Flush() - // Nothing; send empty DATA - return nil - }, func(st *serverTester) { - // Handler gets no data quota: - if err := st.fr.WriteSettings(Setting{SettingInitialWindowSize, 0}); err != nil { - t.Fatal(err) - } - st.wantSettingsAck() - - getSlash(st) // make the single request - - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - - df := st.wantData() - if got := len(df.Data()); got != 0 { - t.Fatalf("unexpected %d DATA bytes; want 0", got) - } - if !df.StreamEnded() { - t.Fatal("DATA didn't have END_STREAM") - } - }) -} - -func TestServer_Response_Automatic100Continue(t *testing.T) { - const msg = "foo" - const reply = "bar" - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - if v := r.Header.Get("Expect"); v != "" { - t.Errorf("Expect header = %q; want empty", v) - } - buf := make([]byte, len(msg)) - // This read should trigger the 100-continue being sent. - if n, err := io.ReadFull(r.Body, buf); err != nil || n != len(msg) || string(buf) != msg { - return fmt.Errorf("ReadFull = %q, %v; want %q, nil", buf[:n], err, msg) - } - _, err := io.WriteString(w, reply) - return err - }, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "POST", "expect", "100-continue"), - EndStream: false, - EndHeaders: true, - }) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "100"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Fatalf("Got headers %v; want %v", goth, wanth) - } - - // Okay, they sent status 100, so we can send our - // gigantic and/or sensitive "foo" payload now. - st.writeData(1, true, []byte(msg)) - - st.wantWindowUpdate(0, uint32(len(msg))) - - hf = st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("expected data to follow") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - goth = st.decodeHeader(hf.HeaderBlockFragment()) - wanth = [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", strconv.Itoa(len(reply))}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - - df := st.wantData() - if string(df.Data()) != reply { - t.Errorf("Client read %q; want %q", df.Data(), reply) - } - if !df.StreamEnded() { - t.Errorf("expect data stream end") - } - }) -} - -func TestServer_HandlerWriteErrorOnDisconnect(t *testing.T) { - errc := make(chan error, 1) - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - p := []byte("some data.\n") - for { - _, err := w.Write(p) - if err != nil { - errc <- err - return nil - } - } - }, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: false, - EndHeaders: true, - }) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("unexpected END_STREAM flag") - } - if !hf.HeadersEnded() { - t.Fatal("want END_HEADERS flag") - } - // Close the connection and wait for the handler to (hopefully) notice. - st.cc.Close() - select { - case <-errc: - case <-time.After(5 * time.Second): - t.Error("timeout") - } - }) -} - -func TestServer_Rejects_Too_Many_Streams(t *testing.T) { - const testPath = "/some/path" - - inHandler := make(chan uint32) - leaveHandler := make(chan bool) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - id := w.(*responseWriter).rws.stream.id - inHandler <- id - if id == 1+(defaultMaxStreams+1)*2 && r.URL.Path != testPath { - t.Errorf("decoded final path as %q; want %q", r.URL.Path, testPath) - } - <-leaveHandler - }) - defer st.Close() - st.greet() - nextStreamID := uint32(1) - streamID := func() uint32 { - defer func() { nextStreamID += 2 }() - return nextStreamID - } - sendReq := func(id uint32, headers ...string) { - st.writeHeaders(HeadersFrameParam{ - StreamID: id, - BlockFragment: st.encodeHeader(headers...), - EndStream: true, - EndHeaders: true, - }) - } - for i := 0; i < defaultMaxStreams; i++ { - sendReq(streamID()) - <-inHandler - } - defer func() { - for i := 0; i < defaultMaxStreams; i++ { - leaveHandler <- true - } - }() - - // And this one should cross the limit: - // (It's also sent as a CONTINUATION, to verify we still track the decoder context, - // even if we're rejecting it) - rejectID := streamID() - headerBlock := st.encodeHeader(":path", testPath) - frag1, frag2 := headerBlock[:3], headerBlock[3:] - st.writeHeaders(HeadersFrameParam{ - StreamID: rejectID, - BlockFragment: frag1, - EndStream: true, - EndHeaders: false, // CONTINUATION coming - }) - if err := st.fr.WriteContinuation(rejectID, true, frag2); err != nil { - t.Fatal(err) - } - st.wantRSTStream(rejectID, ErrCodeProtocol) - - // But let a handler finish: - leaveHandler <- true - st.wantHeaders() - - // And now another stream should be able to start: - goodID := streamID() - sendReq(goodID, ":path", testPath) - select { - case got := <-inHandler: - if got != goodID { - t.Errorf("Got stream %d; want %d", got, goodID) - } - case <-time.After(3 * time.Second): - t.Error("timeout waiting for handler") - } -} - -// So many response headers that the server needs to use CONTINUATION frames: -func TestServer_Response_ManyHeaders_With_Continuation(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - h := w.Header() - for i := 0; i < 5000; i++ { - h.Set(fmt.Sprintf("x-header-%d", i), fmt.Sprintf("x-value-%d", i)) - } - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.HeadersEnded() { - t.Fatal("got unwanted END_HEADERS flag") - } - n := 0 - for { - n++ - cf := st.wantContinuation() - if cf.HeadersEnded() { - break - } - } - if n < 5 { - t.Errorf("Only got %d CONTINUATION frames; expected 5+ (currently 6)", n) - } - }) -} - -// This previously crashed (reported by Mathieu Lonjaret as observed -// while using Camlistore) because we got a DATA frame from the client -// after the handler exited and our logic at the time was wrong, -// keeping a stream in the map in stateClosed, which tickled an -// invariant check later when we tried to remove that stream (via -// defer sc.closeAllStreamsOnConnClose) when the serverConn serve loop -// ended. -func TestServer_NoCrash_HandlerClose_Then_ClientClose(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - // nothing - return nil - }, func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: false, // DATA is coming - EndHeaders: true, - }) - hf := st.wantHeaders() - if !hf.HeadersEnded() || !hf.StreamEnded() { - t.Fatalf("want END_HEADERS+END_STREAM, got %v", hf) - } - - // Sent when the a Handler closes while a client has - // indicated it's still sending DATA: - st.wantRSTStream(1, ErrCodeCancel) - - // Now the handler has ended, so it's ended its - // stream, but the client hasn't closed its side - // (stateClosedLocal). So send more data and verify - // it doesn't crash with an internal invariant panic, like - // it did before. - st.writeData(1, true, []byte("foo")) - - // Sent after a peer sends data anyway (admittedly the - // previous RST_STREAM might've still been in-flight), - // but they'll get the more friendly 'cancel' code - // first. - st.wantRSTStream(1, ErrCodeStreamClosed) - - // Set up a bunch of machinery to record the panic we saw - // previously. - var ( - panMu sync.Mutex - panicVal interface{} - ) - - testHookOnPanicMu.Lock() - testHookOnPanic = func(sc *serverConn, pv interface{}) bool { - panMu.Lock() - panicVal = pv - panMu.Unlock() - return true - } - testHookOnPanicMu.Unlock() - - // Now force the serve loop to end, via closing the connection. - st.cc.Close() - select { - case <-st.sc.doneServing: - // Loop has exited. - panMu.Lock() - got := panicVal - panMu.Unlock() - if got != nil { - t.Errorf("Got panic: %v", got) - } - case <-time.After(5 * time.Second): - t.Error("timeout") - } - }) -} - -func TestServer_Rejects_TLS10(t *testing.T) { testRejectTLS(t, tls.VersionTLS10) } -func TestServer_Rejects_TLS11(t *testing.T) { testRejectTLS(t, tls.VersionTLS11) } - -func testRejectTLS(t *testing.T, max uint16) { - st := newServerTester(t, nil, func(c *tls.Config) { - c.MaxVersion = max - }) - defer st.Close() - gf := st.wantGoAway() - if got, want := gf.ErrCode, ErrCodeInadequateSecurity; got != want { - t.Errorf("Got error code %v; want %v", got, want) - } -} - -func TestServer_Rejects_TLSBadCipher(t *testing.T) { - st := newServerTester(t, nil, func(c *tls.Config) { - // Only list bad ones: - c.CipherSuites = []uint16{ - tls.TLS_RSA_WITH_RC4_128_SHA, - tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_RSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA, - tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, - tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, - } - }) - defer st.Close() - gf := st.wantGoAway() - if got, want := gf.ErrCode, ErrCodeInadequateSecurity; got != want { - t.Errorf("Got error code %v; want %v", got, want) - } -} - -func TestServer_Advertises_Common_Cipher(t *testing.T) { - const requiredSuite = tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 - st := newServerTester(t, nil, func(c *tls.Config) { - // Have the client only support the one required by the spec. - c.CipherSuites = []uint16{requiredSuite} - }, func(ts *httptest.Server) { - var srv *http.Server = ts.Config - // Have the server configured with no specific cipher suites. - // This tests that Go's defaults include the required one. - srv.TLSConfig = nil - }) - defer st.Close() - st.greet() -} - -func (st *serverTester) onHeaderField(f hpack.HeaderField) { - if f.Name == "date" { - return - } - st.decodedHeaders = append(st.decodedHeaders, [2]string{f.Name, f.Value}) -} - -func (st *serverTester) decodeHeader(headerBlock []byte) (pairs [][2]string) { - st.decodedHeaders = nil - if _, err := st.hpackDec.Write(headerBlock); err != nil { - st.t.Fatalf("hpack decoding error: %v", err) - } - if err := st.hpackDec.Close(); err != nil { - st.t.Fatalf("hpack decoding error: %v", err) - } - return st.decodedHeaders -} - -// testServerResponse sets up an idle HTTP/2 connection and lets you -// write a single request with writeReq, and then reply to it in some way with the provided handler, -// and then verify the output with the serverTester again (assuming the handler returns nil) -func testServerResponse(t testing.TB, - handler func(http.ResponseWriter, *http.Request) error, - client func(*serverTester), -) { - errc := make(chan error, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - if r.Body == nil { - t.Fatal("nil Body") - } - errc <- handler(w, r) - }) - defer st.Close() - - donec := make(chan bool) - go func() { - defer close(donec) - st.greet() - client(st) - }() - - select { - case <-donec: - return - case <-time.After(5 * time.Second): - t.Fatal("timeout") - } - - select { - case err := <-errc: - if err != nil { - t.Fatalf("Error in handler: %v", err) - } - case <-time.After(2 * time.Second): - t.Error("timeout waiting for handler to finish") - } -} - -// readBodyHandler returns an http Handler func that reads len(want) -// bytes from r.Body and fails t if the contents read were not -// the value of want. -func readBodyHandler(t *testing.T, want string) func(w http.ResponseWriter, r *http.Request) { - return func(w http.ResponseWriter, r *http.Request) { - buf := make([]byte, len(want)) - _, err := io.ReadFull(r.Body, buf) - if err != nil { - t.Error(err) - return - } - if string(buf) != want { - t.Errorf("read %q; want %q", buf, want) - } - } -} - -// TestServerWithCurl currently fails, hence the LenientCipherSuites test. See: -// https://github.com/tatsuhiro-t/nghttp2/issues/140 & -// http://sourceforge.net/p/curl/bugs/1472/ -func TestServerWithCurl(t *testing.T) { testServerWithCurl(t, false) } -func TestServerWithCurl_LenientCipherSuites(t *testing.T) { testServerWithCurl(t, true) } - -func testServerWithCurl(t *testing.T, permitProhibitedCipherSuites bool) { - if runtime.GOOS != "linux" { - t.Skip("skipping Docker test when not on Linux; requires --net which won't work with boot2docker anyway") - } - if testing.Short() { - t.Skip("skipping curl test in short mode") - } - requireCurl(t) - var gotConn int32 - testHookOnConn = func() { atomic.StoreInt32(&gotConn, 1) } - - const msg = "Hello from curl!\n" - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Header().Set("Foo", "Bar") - w.Header().Set("Client-Proto", r.Proto) - io.WriteString(w, msg) - })) - ConfigureServer(ts.Config, &Server{ - PermitProhibitedCipherSuites: permitProhibitedCipherSuites, - }) - ts.TLS = ts.Config.TLSConfig // the httptest.Server has its own copy of this TLS config - ts.StartTLS() - defer ts.Close() - - t.Logf("Running test server for curl to hit at: %s", ts.URL) - container := curl(t, "--silent", "--http2", "--insecure", "-v", ts.URL) - defer kill(container) - resc := make(chan interface{}, 1) - go func() { - res, err := dockerLogs(container) - if err != nil { - resc <- err - } else { - resc <- res - } - }() - select { - case res := <-resc: - if err, ok := res.(error); ok { - t.Fatal(err) - } - body := string(res.([]byte)) - // Search for both "key: value" and "key:value", since curl changed their format - // Our Dockerfile contains the latest version (no space), but just in case people - // didn't rebuild, check both. - if !strings.Contains(body, "foo: Bar") && !strings.Contains(body, "foo:Bar") { - t.Errorf("didn't see foo: Bar header") - t.Logf("Got: %s", body) - } - if !strings.Contains(body, "client-proto: HTTP/2") && !strings.Contains(body, "client-proto:HTTP/2") { - t.Errorf("didn't see client-proto: HTTP/2 header") - t.Logf("Got: %s", res) - } - if !strings.Contains(string(res.([]byte)), msg) { - t.Errorf("didn't see %q content", msg) - t.Logf("Got: %s", res) - } - case <-time.After(3 * time.Second): - t.Errorf("timeout waiting for curl") - } - - if atomic.LoadInt32(&gotConn) == 0 { - t.Error("never saw an http2 connection") - } -} - -var doh2load = flag.Bool("h2load", false, "Run h2load test") - -func TestServerWithH2Load(t *testing.T) { - if !*doh2load { - t.Skip("Skipping without --h2load flag.") - } - if runtime.GOOS != "linux" { - t.Skip("skipping Docker test when not on Linux; requires --net which won't work with boot2docker anyway") - } - requireH2load(t) - - msg := strings.Repeat("Hello, h2load!\n", 5000) - ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, msg) - w.(http.Flusher).Flush() - io.WriteString(w, msg) - })) - ts.StartTLS() - defer ts.Close() - - cmd := exec.Command("docker", "run", "--net=host", "--entrypoint=/usr/local/bin/h2load", "gohttp2/curl", - "-n100000", "-c100", "-m100", ts.URL) - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - if err := cmd.Run(); err != nil { - t.Fatal(err) - } -} - -// Issue 12843 -func TestServerDoS_MaxHeaderListSize(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}) - defer st.Close() - - // shake hands - st.writePreface() - st.writeInitialSettings() - frameSize := defaultMaxReadFrameSize - var advHeaderListSize *uint32 - st.wantSettings().ForeachSetting(func(s Setting) error { - switch s.ID { - case SettingMaxFrameSize: - if s.Val < minMaxFrameSize { - frameSize = minMaxFrameSize - } else if s.Val > maxFrameSize { - frameSize = maxFrameSize - } else { - frameSize = int(s.Val) - } - case SettingMaxHeaderListSize: - advHeaderListSize = &s.Val - } - return nil - }) - st.writeSettingsAck() - st.wantSettingsAck() - - if advHeaderListSize == nil { - t.Errorf("server didn't advertise a max header list size") - } else if *advHeaderListSize == 0 { - t.Errorf("server advertised a max header list size of 0") - } - - st.encodeHeaderField(":method", "GET") - st.encodeHeaderField(":path", "/") - st.encodeHeaderField(":scheme", "https") - cookie := strings.Repeat("*", 4058) - st.encodeHeaderField("cookie", cookie) - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.headerBuf.Bytes(), - EndStream: true, - EndHeaders: false, - }) - - // Capture the short encoding of a duplicate ~4K cookie, now - // that we've already sent it once. - st.headerBuf.Reset() - st.encodeHeaderField("cookie", cookie) - - // Now send 1MB of it. - const size = 1 << 20 - b := bytes.Repeat(st.headerBuf.Bytes(), size/st.headerBuf.Len()) - for len(b) > 0 { - chunk := b - if len(chunk) > frameSize { - chunk = chunk[:frameSize] - } - b = b[len(chunk):] - st.fr.WriteContinuation(1, len(b) == 0, chunk) - } - - h := st.wantHeaders() - if !h.HeadersEnded() { - t.Fatalf("Got HEADERS without END_HEADERS set: %v", h) - } - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "431"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", "63"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } -} - -func TestCompressionErrorOnWrite(t *testing.T) { - const maxStrLen = 8 << 10 - var serverConfig *http.Server - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. - }, func(ts *httptest.Server) { - serverConfig = ts.Config - serverConfig.MaxHeaderBytes = maxStrLen - }) - st.addLogFilter("connection error: COMPRESSION_ERROR") - defer st.Close() - st.greet() - - maxAllowed := st.sc.framer.maxHeaderStringLen() - - // Crank this up, now that we have a conn connected with the - // hpack.Decoder's max string length set has been initialized - // from the earlier low ~8K value. We want this higher so don't - // hit the max header list size. We only want to test hitting - // the max string size. - serverConfig.MaxHeaderBytes = 1 << 20 - - // First a request with a header that's exactly the max allowed size - // for the hpack compression. It's still too long for the header list - // size, so we'll get the 431 error, but that keeps the compression - // context still valid. - hbf := st.encodeHeader("foo", strings.Repeat("a", maxAllowed)) - - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - h := st.wantHeaders() - if !h.HeadersEnded() { - t.Fatalf("Got HEADERS without END_HEADERS set: %v", h) - } - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "431"}, - {"content-type", "text/html; charset=utf-8"}, - {"content-length", "63"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } - df := st.wantData() - if !strings.Contains(string(df.Data()), "HTTP Error 431") { - t.Errorf("Unexpected data body: %q", df.Data()) - } - if !df.StreamEnded() { - t.Fatalf("expect data stream end") - } - - // And now send one that's just one byte too big. - hbf = st.encodeHeader("bar", strings.Repeat("b", maxAllowed+1)) - st.writeHeaders(HeadersFrameParam{ - StreamID: 3, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - ga := st.wantGoAway() - if ga.ErrCode != ErrCodeCompression { - t.Errorf("GOAWAY err = %v; want ErrCodeCompression", ga.ErrCode) - } -} - -func TestCompressionErrorOnClose(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. - }) - st.addLogFilter("connection error: COMPRESSION_ERROR") - defer st.Close() - st.greet() - - hbf := st.encodeHeader("foo", "bar") - hbf = hbf[:len(hbf)-1] // truncate one byte from the end, so hpack.Decoder.Close fails. - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - ga := st.wantGoAway() - if ga.ErrCode != ErrCodeCompression { - t.Errorf("GOAWAY err = %v; want ErrCodeCompression", ga.ErrCode) - } -} - -// test that a server handler can read trailers from a client -func TestServerReadsTrailers(t *testing.T) { - const testBody = "some test body" - writeReq := func(st *serverTester) { - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader("trailer", "Foo, Bar", "trailer", "Baz"), - EndStream: false, - EndHeaders: true, - }) - st.writeData(1, false, []byte(testBody)) - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeaderRaw( - "foo", "foov", - "bar", "barv", - "baz", "bazv", - "surprise", "wasn't declared; shouldn't show up", - ), - EndStream: true, - EndHeaders: true, - }) - } - checkReq := func(r *http.Request) { - wantTrailer := http.Header{ - "Foo": nil, - "Bar": nil, - "Baz": nil, - } - if !reflect.DeepEqual(r.Trailer, wantTrailer) { - t.Errorf("initial Trailer = %v; want %v", r.Trailer, wantTrailer) - } - slurp, err := ioutil.ReadAll(r.Body) - if string(slurp) != testBody { - t.Errorf("read body %q; want %q", slurp, testBody) - } - if err != nil { - t.Fatalf("Body slurp: %v", err) - } - wantTrailerAfter := http.Header{ - "Foo": {"foov"}, - "Bar": {"barv"}, - "Baz": {"bazv"}, - } - if !reflect.DeepEqual(r.Trailer, wantTrailerAfter) { - t.Errorf("final Trailer = %v; want %v", r.Trailer, wantTrailerAfter) - } - } - testServerRequest(t, writeReq, checkReq) -} - -// test that a server handler can send trailers -func TestServerWritesTrailers_WithFlush(t *testing.T) { testServerWritesTrailers(t, true) } -func TestServerWritesTrailers_WithoutFlush(t *testing.T) { testServerWritesTrailers(t, false) } - -func testServerWritesTrailers(t *testing.T, withFlush bool) { - // See https://httpwg.github.io/specs/rfc7540.html#rfc.section.8.1.3 - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Set("Trailer", "Server-Trailer-A, Server-Trailer-B") - w.Header().Add("Trailer", "Server-Trailer-C") - w.Header().Add("Trailer", "Transfer-Encoding, Content-Length, Trailer") // filtered - - // Regular headers: - w.Header().Set("Foo", "Bar") - w.Header().Set("Content-Length", "5") // len("Hello") - - io.WriteString(w, "Hello") - if withFlush { - w.(http.Flusher).Flush() - } - w.Header().Set("Server-Trailer-A", "valuea") - w.Header().Set("Server-Trailer-C", "valuec") // skipping B - // After a flush, random keys like Server-Surprise shouldn't show up: - w.Header().Set("Server-Surpise", "surprise! this isn't predeclared!") - // But we do permit promoting keys to trailers after a - // flush if they start with the magic - // otherwise-invalid "Trailer:" prefix: - w.Header().Set("Trailer:Post-Header-Trailer", "hi1") - w.Header().Set("Trailer:post-header-trailer2", "hi2") - w.Header().Set("Trailer:Range", "invalid") - w.Header().Set("Trailer:Foo\x01Bogus", "invalid") - w.Header().Set("Transfer-Encoding", "should not be included; Forbidden by RFC 2616 14.40") - w.Header().Set("Content-Length", "should not be included; Forbidden by RFC 2616 14.40") - w.Header().Set("Trailer", "should not be included; Forbidden by RFC 2616 14.40") - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if hf.StreamEnded() { - t.Fatal("response HEADERS had END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("response HEADERS didn't have END_HEADERS") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"foo", "Bar"}, - {"trailer", "Server-Trailer-A, Server-Trailer-B"}, - {"trailer", "Server-Trailer-C"}, - {"trailer", "Transfer-Encoding, Content-Length, Trailer"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", "5"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Header mismatch.\n got: %v\nwant: %v", goth, wanth) - } - df := st.wantData() - if string(df.Data()) != "Hello" { - t.Fatalf("Client read %q; want Hello", df.Data()) - } - if df.StreamEnded() { - t.Fatalf("data frame had STREAM_ENDED") - } - tf := st.wantHeaders() // for the trailers - if !tf.StreamEnded() { - t.Fatalf("trailers HEADERS lacked END_STREAM") - } - if !tf.HeadersEnded() { - t.Fatalf("trailers HEADERS lacked END_HEADERS") - } - wanth = [][2]string{ - {"post-header-trailer", "hi1"}, - {"post-header-trailer2", "hi2"}, - {"server-trailer-a", "valuea"}, - {"server-trailer-c", "valuec"}, - } - goth = st.decodeHeader(tf.HeaderBlockFragment()) - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Header mismatch.\n got: %v\nwant: %v", goth, wanth) - } - }) -} - -// validate transmitted header field names & values -// golang.org/issue/14048 -func TestServerDoesntWriteInvalidHeaders(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - w.Header().Add("OK1", "x") - w.Header().Add("Bad:Colon", "x") // colon (non-token byte) in key - w.Header().Add("Bad1\x00", "x") // null in key - w.Header().Add("Bad2", "x\x00y") // null in value - return nil - }, func(st *serverTester) { - getSlash(st) - hf := st.wantHeaders() - if !hf.StreamEnded() { - t.Error("response HEADERS lacked END_STREAM") - } - if !hf.HeadersEnded() { - t.Fatal("response HEADERS didn't have END_HEADERS") - } - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "200"}, - {"ok1", "x"}, - {"content-type", "text/plain; charset=utf-8"}, - {"content-length", "0"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Header mismatch.\n got: %v\nwant: %v", goth, wanth) - } - }) -} - -func BenchmarkServerGets(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - - const msg = "Hello, world" - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, msg) - }) - defer st.Close() - st.greet() - - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - - for i := 0; i < b.N; i++ { - id := 1 + uint32(i)*2 - st.writeHeaders(HeadersFrameParam{ - StreamID: id, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - st.wantHeaders() - df := st.wantData() - if !df.StreamEnded() { - b.Fatalf("DATA didn't have END_STREAM; got %v", df) - } - } -} - -func BenchmarkServerPosts(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - - const msg = "Hello, world" - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, msg) - }) - defer st.Close() - st.greet() - - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - - for i := 0; i < b.N; i++ { - id := 1 + uint32(i)*2 - st.writeHeaders(HeadersFrameParam{ - StreamID: id, - BlockFragment: st.encodeHeader(":method", "POST"), - EndStream: false, - EndHeaders: true, - }) - st.writeData(id, true, nil) - st.wantHeaders() - df := st.wantData() - if !df.StreamEnded() { - b.Fatalf("DATA didn't have END_STREAM; got %v", df) - } - } -} - -// go-fuzz bug, originally reported at https://github.com/bradfitz/http2/issues/53 -// Verify we don't hang. -func TestIssue53(t *testing.T) { - const data = "PRI * HTTP/2.0\r\n\r\nSM" + - "\r\n\r\n\x00\x00\x00\x01\ainfinfin\ad" - s := &http.Server{ - ErrorLog: log.New(io.MultiWriter(stderrv(), twriter{t: t}), "", log.LstdFlags), - Handler: http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { - w.Write([]byte("hello")) - }), - } - s2 := &Server{ - MaxReadFrameSize: 1 << 16, - PermitProhibitedCipherSuites: true, - } - c := &issue53Conn{[]byte(data), false, false} - s2.ServeConn(c, &ServeConnOpts{BaseConfig: s}) - if !c.closed { - t.Fatal("connection is not closed") - } -} - -type issue53Conn struct { - data []byte - closed bool - written bool -} - -func (c *issue53Conn) Read(b []byte) (n int, err error) { - if len(c.data) == 0 { - return 0, io.EOF - } - n = copy(b, c.data) - c.data = c.data[n:] - return -} - -func (c *issue53Conn) Write(b []byte) (n int, err error) { - c.written = true - return len(b), nil -} - -func (c *issue53Conn) Close() error { - c.closed = true - return nil -} - -func (c *issue53Conn) LocalAddr() net.Addr { - return &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 49706} -} -func (c *issue53Conn) RemoteAddr() net.Addr { - return &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 49706} -} -func (c *issue53Conn) SetDeadline(t time.Time) error { return nil } -func (c *issue53Conn) SetReadDeadline(t time.Time) error { return nil } -func (c *issue53Conn) SetWriteDeadline(t time.Time) error { return nil } - -// golang.org/issue/12895 -func TestConfigureServer(t *testing.T) { - tests := []struct { - name string - in http.Server - wantErr string - }{ - { - name: "empty server", - in: http.Server{}, - }, - { - name: "just the required cipher suite", - in: http.Server{ - TLSConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, - }, - }, - }, - { - name: "missing required cipher suite", - in: http.Server{ - TLSConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384}, - }, - }, - wantErr: "is missing HTTP/2-required TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", - }, - { - name: "required after bad", - in: http.Server{ - TLSConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_RSA_WITH_RC4_128_SHA, tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256}, - }, - }, - wantErr: "contains an HTTP/2-approved cipher suite (0xc02f), but it comes after", - }, - { - name: "bad after required", - in: http.Server{ - TLSConfig: &tls.Config{ - CipherSuites: []uint16{tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, tls.TLS_RSA_WITH_RC4_128_SHA}, - }, - }, - }, - } - for _, tt := range tests { - err := ConfigureServer(&tt.in, nil) - if (err != nil) != (tt.wantErr != "") { - if tt.wantErr != "" { - t.Errorf("%s: success, but want error", tt.name) - } else { - t.Errorf("%s: unexpected error: %v", tt.name, err) - } - } - if err != nil && tt.wantErr != "" && !strings.Contains(err.Error(), tt.wantErr) { - t.Errorf("%s: err = %v; want substring %q", tt.name, err, tt.wantErr) - } - if err == nil && !tt.in.TLSConfig.PreferServerCipherSuites { - t.Errorf("%s: PreferServerCipherSuite is false; want true", tt.name) - } - } -} - -func TestServerRejectHeadWithBody(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. - }) - defer st.Close() - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "HEAD"), - EndStream: false, // what we're testing, a bogus HEAD request with body - EndHeaders: true, - }) - st.wantRSTStream(1, ErrCodeProtocol) -} - -func TestServerNoAutoContentLengthOnHead(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - // No response body. (or smaller than one frame) - }) - defer st.Close() - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, // clients send odd numbers - BlockFragment: st.encodeHeader(":method", "HEAD"), - EndStream: true, - EndHeaders: true, - }) - h := st.wantHeaders() - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "200"}, - {"content-type", "text/plain; charset=utf-8"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } -} - -// golang.org/issue/13495 -func TestServerNoDuplicateContentType(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - w.Header()["Content-Type"] = []string{""} - fmt.Fprintf(w, "hi") - }) - defer st.Close() - st.greet() - st.writeHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: st.encodeHeader(), - EndStream: true, - EndHeaders: true, - }) - h := st.wantHeaders() - headers := st.decodeHeader(h.HeaderBlockFragment()) - want := [][2]string{ - {":status", "200"}, - {"content-type", ""}, - {"content-length", "41"}, - } - if !reflect.DeepEqual(headers, want) { - t.Errorf("Headers mismatch.\n got: %q\nwant: %q\n", headers, want) - } -} - -func disableGoroutineTracking() (restore func()) { - old := DebugGoroutines - DebugGoroutines = false - return func() { DebugGoroutines = old } -} - -func BenchmarkServer_GetRequest(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - const msg = "Hello, world." - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - n, err := io.Copy(ioutil.Discard, r.Body) - if err != nil || n > 0 { - b.Errorf("Read %d bytes, error %v; want 0 bytes.", n, err) - } - io.WriteString(w, msg) - }) - defer st.Close() - - st.greet() - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - hbf := st.encodeHeader(":method", "GET") - for i := 0; i < b.N; i++ { - streamID := uint32(1 + 2*i) - st.writeHeaders(HeadersFrameParam{ - StreamID: streamID, - BlockFragment: hbf, - EndStream: true, - EndHeaders: true, - }) - st.wantHeaders() - st.wantData() - } -} - -func BenchmarkServer_PostRequest(b *testing.B) { - defer disableGoroutineTracking()() - b.ReportAllocs() - const msg = "Hello, world." - st := newServerTester(b, func(w http.ResponseWriter, r *http.Request) { - n, err := io.Copy(ioutil.Discard, r.Body) - if err != nil || n > 0 { - b.Errorf("Read %d bytes, error %v; want 0 bytes.", n, err) - } - io.WriteString(w, msg) - }) - defer st.Close() - st.greet() - // Give the server quota to reply. (plus it has the the 64KB) - if err := st.fr.WriteWindowUpdate(0, uint32(b.N*len(msg))); err != nil { - b.Fatal(err) - } - hbf := st.encodeHeader(":method", "POST") - for i := 0; i < b.N; i++ { - streamID := uint32(1 + 2*i) - st.writeHeaders(HeadersFrameParam{ - StreamID: streamID, - BlockFragment: hbf, - EndStream: false, - EndHeaders: true, - }) - st.writeData(streamID, true, nil) - st.wantHeaders() - st.wantData() - } -} - -type connStateConn struct { - net.Conn - cs tls.ConnectionState -} - -func (c connStateConn) ConnectionState() tls.ConnectionState { return c.cs } - -// golang.org/issue/12737 -- handle any net.Conn, not just -// *tls.Conn. -func TestServerHandleCustomConn(t *testing.T) { - var s Server - c1, c2 := net.Pipe() - clientDone := make(chan struct{}) - handlerDone := make(chan struct{}) - var req *http.Request - go func() { - defer close(clientDone) - defer c2.Close() - fr := NewFramer(c2, c2) - io.WriteString(c2, ClientPreface) - fr.WriteSettings() - fr.WriteSettingsAck() - f, err := fr.ReadFrame() - if err != nil { - t.Error(err) - return - } - if sf, ok := f.(*SettingsFrame); !ok || sf.IsAck() { - t.Errorf("Got %v; want non-ACK SettingsFrame", summarizeFrame(f)) - return - } - f, err = fr.ReadFrame() - if err != nil { - t.Error(err) - return - } - if sf, ok := f.(*SettingsFrame); !ok || !sf.IsAck() { - t.Errorf("Got %v; want ACK SettingsFrame", summarizeFrame(f)) - return - } - var henc hpackEncoder - fr.WriteHeaders(HeadersFrameParam{ - StreamID: 1, - BlockFragment: henc.encodeHeaderRaw(t, ":method", "GET", ":path", "/", ":scheme", "https", ":authority", "foo.com"), - EndStream: true, - EndHeaders: true, - }) - go io.Copy(ioutil.Discard, c2) - <-handlerDone - }() - const testString = "my custom ConnectionState" - fakeConnState := tls.ConnectionState{ - ServerName: testString, - Version: tls.VersionTLS12, - } - go s.ServeConn(connStateConn{c1, fakeConnState}, &ServeConnOpts{ - BaseConfig: &http.Server{ - Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - defer close(handlerDone) - req = r - }), - }}) - select { - case <-clientDone: - case <-time.After(5 * time.Second): - t.Fatal("timeout waiting for handler") - } - if req.TLS == nil { - t.Fatalf("Request.TLS is nil. Got: %#v", req) - } - if req.TLS.ServerName != testString { - t.Fatalf("Request.TLS = %+v; want ServerName of %q", req.TLS, testString) - } -} - -// golang.org/issue/14214 -func TestServer_Rejects_ConnHeaders(t *testing.T) { - testServerResponse(t, func(w http.ResponseWriter, r *http.Request) error { - t.Errorf("should not get to Handler") - return nil - }, func(st *serverTester) { - st.bodylessReq1("connection", "foo") - hf := st.wantHeaders() - goth := st.decodeHeader(hf.HeaderBlockFragment()) - wanth := [][2]string{ - {":status", "400"}, - {"content-type", "text/plain; charset=utf-8"}, - {"x-content-type-options", "nosniff"}, - {"content-length", "51"}, - } - if !reflect.DeepEqual(goth, wanth) { - t.Errorf("Got headers %v; want %v", goth, wanth) - } - }) -} - -type hpackEncoder struct { - enc *hpack.Encoder - buf bytes.Buffer -} - -func (he *hpackEncoder) encodeHeaderRaw(t *testing.T, headers ...string) []byte { - if len(headers)%2 == 1 { - panic("odd number of kv args") - } - he.buf.Reset() - if he.enc == nil { - he.enc = hpack.NewEncoder(&he.buf) - } - for len(headers) > 0 { - k, v := headers[0], headers[1] - err := he.enc.WriteField(hpack.HeaderField{Name: k, Value: v}) - if err != nil { - t.Fatalf("HPACK encoding error for %q/%q: %v", k, v, err) - } - headers = headers[2:] - } - return he.buf.Bytes() -} - -func TestCheckValidHTTP2Request(t *testing.T) { - tests := []struct { - req *http.Request - want error - }{ - { - req: &http.Request{Header: http.Header{"Te": {"trailers"}}}, - want: nil, - }, - { - req: &http.Request{Header: http.Header{"Te": {"trailers", "bogus"}}}, - want: errors.New(`request header "TE" may only be "trailers" in HTTP/2`), - }, - { - req: &http.Request{Header: http.Header{"Foo": {""}}}, - want: nil, - }, - { - req: &http.Request{Header: http.Header{"Connection": {""}}}, - want: errors.New(`request header "Connection" is not valid in HTTP/2`), - }, - { - req: &http.Request{Header: http.Header{"Proxy-Connection": {""}}}, - want: errors.New(`request header "Proxy-Connection" is not valid in HTTP/2`), - }, - { - req: &http.Request{Header: http.Header{"Keep-Alive": {""}}}, - want: errors.New(`request header "Keep-Alive" is not valid in HTTP/2`), - }, - { - req: &http.Request{Header: http.Header{"Upgrade": {""}}}, - want: errors.New(`request header "Upgrade" is not valid in HTTP/2`), - }, - } - for i, tt := range tests { - got := checkValidHTTP2Request(tt.req) - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("%d. checkValidHTTP2Request = %v; want %v", i, got, tt.want) - } - } -} - -// golang.org/issue/14030 -func TestExpect100ContinueAfterHandlerWrites(t *testing.T) { - const msg = "Hello" - const msg2 = "World" - - doRead := make(chan bool, 1) - defer close(doRead) // fallback cleanup - - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, msg) - w.(http.Flusher).Flush() - - // Do a read, which might force a 100-continue status to be sent. - <-doRead - r.Body.Read(make([]byte, 10)) - - io.WriteString(w, msg2) - - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - req, _ := http.NewRequest("POST", st.ts.URL, io.LimitReader(neverEnding('A'), 2<<20)) - req.Header.Set("Expect", "100-continue") - - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - - buf := make([]byte, len(msg)) - if _, err := io.ReadFull(res.Body, buf); err != nil { - t.Fatal(err) - } - if string(buf) != msg { - t.Fatalf("msg = %q; want %q", buf, msg) - } - - doRead <- true - - if _, err := io.ReadFull(res.Body, buf); err != nil { - t.Fatal(err) - } - if string(buf) != msg2 { - t.Fatalf("second msg = %q; want %q", buf, msg2) - } -} diff --git a/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml b/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml deleted file mode 100644 index 31a84be..0000000 --- a/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml +++ /dev/null @@ -1,5021 +0,0 @@ - - - - - - - - - - - - - - - - - - - Hypertext Transfer Protocol version 2 - - - Twist -
    - mbelshe@chromium.org -
    -
    - - - Google, Inc -
    - fenix@google.com -
    -
    - - - Mozilla -
    - - 331 E Evelyn Street - Mountain View - CA - 94041 - US - - martin.thomson@gmail.com -
    -
    - - - Applications - HTTPbis - HTTP - SPDY - Web - - - - This specification describes an optimized expression of the semantics of the Hypertext - Transfer Protocol (HTTP). HTTP/2 enables a more efficient use of network resources and a - reduced perception of latency by introducing header field compression and allowing multiple - concurrent messages on the same connection. It also introduces unsolicited push of - representations from servers to clients. - - - This specification is an alternative to, but does not obsolete, the HTTP/1.1 message syntax. - HTTP's existing semantics remain unchanged. - - - - - - Discussion of this draft takes place on the HTTPBIS working group mailing list - (ietf-http-wg@w3.org), which is archived at . - - - Working Group information can be found at ; that specific to HTTP/2 are at . - - - The changes in this draft are summarized in . - - - -
    - - -
    - - - The Hypertext Transfer Protocol (HTTP) is a wildly successful protocol. However, the - HTTP/1.1 message format () has - several characteristics that have a negative overall effect on application performance - today. - - - In particular, HTTP/1.0 allowed only one request to be outstanding at a time on a given - TCP connection. HTTP/1.1 added request pipelining, but this only partially addressed - request concurrency and still suffers from head-of-line blocking. Therefore, HTTP/1.1 - clients that need to make many requests typically use multiple connections to a server in - order to achieve concurrency and thereby reduce latency. - - - Furthermore, HTTP header fields are often repetitive and verbose, causing unnecessary - network traffic, as well as causing the initial TCP congestion - window to quickly fill. This can result in excessive latency when multiple requests are - made on a new TCP connection. - - - HTTP/2 addresses these issues by defining an optimized mapping of HTTP's semantics to an - underlying connection. Specifically, it allows interleaving of request and response - messages on the same connection and uses an efficient coding for HTTP header fields. It - also allows prioritization of requests, letting more important requests complete more - quickly, further improving performance. - - - The resulting protocol is more friendly to the network, because fewer TCP connections can - be used in comparison to HTTP/1.x. This means less competition with other flows, and - longer-lived connections, which in turn leads to better utilization of available network - capacity. - - - Finally, HTTP/2 also enables more efficient processing of messages through use of binary - message framing. - -
    - -
    - - HTTP/2 provides an optimized transport for HTTP semantics. HTTP/2 supports all of the core - features of HTTP/1.1, but aims to be more efficient in several ways. - - - The basic protocol unit in HTTP/2 is a frame. Each frame - type serves a different purpose. For example, HEADERS and - DATA frames form the basis of HTTP requests and - responses; other frame types like SETTINGS, - WINDOW_UPDATE, and PUSH_PROMISE are used in support of other - HTTP/2 features. - - - Multiplexing of requests is achieved by having each HTTP request-response exchange - associated with its own stream. Streams are largely - independent of each other, so a blocked or stalled request or response does not prevent - progress on other streams. - - - Flow control and prioritization ensure that it is possible to efficiently use multiplexed - streams. Flow control helps to ensure that only data that - can be used by a receiver is transmitted. Prioritization ensures that limited resources can be directed - to the most important streams first. - - - HTTP/2 adds a new interaction mode, whereby a server can push - responses to a client. Server push allows a server to speculatively send a client - data that the server anticipates the client will need, trading off some network usage - against a potential latency gain. The server does this by synthesizing a request, which it - sends as a PUSH_PROMISE frame. The server is then able to send a response to - the synthetic request on a separate stream. - - - Frames that contain HTTP header fields are compressed. - HTTP requests can be highly redundant, so compression can reduce the size of requests and - responses significantly. - - -
    - - The HTTP/2 specification is split into four parts: - - - Starting HTTP/2 covers how an HTTP/2 connection is - initiated. - - - The framing and streams layers describe the way HTTP/2 frames are - structured and formed into multiplexed streams. - - - Frame and error - definitions include details of the frame and error types used in HTTP/2. - - - HTTP mappings and additional - requirements describe how HTTP semantics are expressed using frames and - streams. - - - - - While some of the frame and stream layer concepts are isolated from HTTP, this - specification does not define a completely generic framing layer. The framing and streams - layers are tailored to the needs of the HTTP protocol and server push. - -
    - -
    - - The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD - NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as - described in RFC 2119. - - - All numeric values are in network byte order. Values are unsigned unless otherwise - indicated. Literal values are provided in decimal or hexadecimal as appropriate. - Hexadecimal literals are prefixed with 0x to distinguish them - from decimal literals. - - - The following terms are used: - - - The endpoint initiating the HTTP/2 connection. - - - A transport-layer connection between two endpoints. - - - An error that affects the entire HTTP/2 connection. - - - Either the client or server of the connection. - - - The smallest unit of communication within an HTTP/2 connection, consisting of a header - and a variable-length sequence of octets structured according to the frame type. - - - An endpoint. When discussing a particular endpoint, "peer" refers to the endpoint - that is remote to the primary subject of discussion. - - - An endpoint that is receiving frames. - - - An endpoint that is transmitting frames. - - - The endpoint which did not initiate the HTTP/2 connection. - - - A bi-directional flow of frames across a virtual channel within the HTTP/2 connection. - - - An error on the individual HTTP/2 stream. - - - - - Finally, the terms "gateway", "intermediary", "proxy", and "tunnel" are defined - in . - -
    -
    - -
    - - An HTTP/2 connection is an application layer protocol running on top of a TCP connection - (). The client is the TCP connection initiator. - - - HTTP/2 uses the same "http" and "https" URI schemes used by HTTP/1.1. HTTP/2 shares the same - default port numbers: 80 for "http" URIs and 443 for "https" URIs. As a result, - implementations processing requests for target resource URIs like http://example.org/foo or https://example.com/bar are required to first discover whether the - upstream server (the immediate peer to which the client wishes to establish a connection) - supports HTTP/2. - - - - The means by which support for HTTP/2 is determined is different for "http" and "https" - URIs. Discovery for "http" URIs is described in . Discovery - for "https" URIs is described in . - - -
    - - The protocol defined in this document has two identifiers. - - - - The string "h2" identifies the protocol where HTTP/2 uses TLS. This identifier is used in the TLS application layer protocol negotiation extension (ALPN) - field and any place that HTTP/2 over TLS is identified. - - - The "h2" string is serialized into an ALPN protocol identifier as the two octet - sequence: 0x68, 0x32. - - - - - The string "h2c" identifies the protocol where HTTP/2 is run over cleartext TCP. - This identifier is used in the HTTP/1.1 Upgrade header field and any place that - HTTP/2 over TCP is identified. - - - - - - Negotiating "h2" or "h2c" implies the use of the transport, security, framing and message - semantics described in this document. - - - RFC Editor's Note: please remove the remainder of this section prior to the - publication of a final version of this document. - - - Only implementations of the final, published RFC can identify themselves as "h2" or "h2c". - Until such an RFC exists, implementations MUST NOT identify themselves using these - strings. - - - Examples and text throughout the rest of this document use "h2" as a matter of - editorial convenience only. Implementations of draft versions MUST NOT identify using - this string. - - - Implementations of draft versions of the protocol MUST add the string "-" and the - corresponding draft number to the identifier. For example, draft-ietf-httpbis-http2-11 - over TLS is identified using the string "h2-11". - - - Non-compatible experiments that are based on these draft versions MUST append the string - "-" and an experiment name to the identifier. For example, an experimental implementation - of packet mood-based encoding based on draft-ietf-httpbis-http2-09 might identify itself - as "h2-09-emo". Note that any label MUST conform to the "token" syntax defined in - . Experimenters are - encouraged to coordinate their experiments on the ietf-http-wg@w3.org mailing list. - -
    - -
    - - A client that makes a request for an "http" URI without prior knowledge about support for - HTTP/2 uses the HTTP Upgrade mechanism (). The client makes an HTTP/1.1 request that includes an Upgrade - header field identifying HTTP/2 with the "h2c" token. The HTTP/1.1 request MUST include - exactly one HTTP2-Settings header field. - -
    - For example: - - -]]> -
    - - Requests that contain an entity body MUST be sent in their entirety before the client can - send HTTP/2 frames. This means that a large request entity can block the use of the - connection until it is completely sent. - - - If concurrency of an initial request with subsequent requests is important, an OPTIONS - request can be used to perform the upgrade to HTTP/2, at the cost of an additional - round-trip. - - - A server that does not support HTTP/2 can respond to the request as though the Upgrade - header field were absent: - -
    - -HTTP/1.1 200 OK -Content-Length: 243 -Content-Type: text/html - -... - -
    - - A server MUST ignore a "h2" token in an Upgrade header field. Presence of a token with - "h2" implies HTTP/2 over TLS, which is instead negotiated as described in . - - - A server that supports HTTP/2 can accept the upgrade with a 101 (Switching Protocols) - response. After the empty line that terminates the 101 response, the server can begin - sending HTTP/2 frames. These frames MUST include a response to the request that initiated - the Upgrade. - - -
    - - For example: - - -HTTP/1.1 101 Switching Protocols -Connection: Upgrade -Upgrade: h2c - -[ HTTP/2 connection ... - -
    - - The first HTTP/2 frame sent by the server is a SETTINGS frame () as the server connection preface (). Upon receiving the 101 response, the client sends a connection preface, which includes a - SETTINGS frame. - - - The HTTP/1.1 request that is sent prior to upgrade is assigned stream identifier 1 and is - assigned default priority values. Stream 1 is - implicitly half closed from the client toward the server, since the request is completed - as an HTTP/1.1 request. After commencing the HTTP/2 connection, stream 1 is used for the - response. - - -
    - - A request that upgrades from HTTP/1.1 to HTTP/2 MUST include exactly one HTTP2-Settings header field. The HTTP2-Settings header field is a connection-specific header field - that includes parameters that govern the HTTP/2 connection, provided in anticipation of - the server accepting the request to upgrade. - -
    - -
    - - A server MUST NOT upgrade the connection to HTTP/2 if this header field is not present, - or if more than one is present. A server MUST NOT send this header field. - - - - The content of the HTTP2-Settings header field is the - payload of a SETTINGS frame (), encoded as a - base64url string (that is, the URL- and filename-safe Base64 encoding described in , with any trailing '=' characters omitted). The - ABNF production for token68 is - defined in . - - - Since the upgrade is only intended to apply to the immediate connection, a client - sending HTTP2-Settings MUST also send HTTP2-Settings as a connection option in the Connection header field to prevent it from being forwarded - downstream. - - - A server decodes and interprets these values as it would any other - SETTINGS frame. Acknowledgement of the - SETTINGS parameters is not necessary, since a 101 response serves as implicit - acknowledgment. Providing these values in the Upgrade request gives a client an - opportunity to provide parameters prior to receiving any frames from the server. - -
    -
    - -
    - - A client that makes a request to an "https" URI uses TLS - with the application layer protocol negotiation extension. - - - HTTP/2 over TLS uses the "h2" application token. The "h2c" token MUST NOT be sent by a - client or selected by a server. - - - Once TLS negotiation is complete, both the client and the server send a connection preface. - -
    - -
    - - A client can learn that a particular server supports HTTP/2 by other means. For example, - describes a mechanism for advertising this capability. - - - A client MAY immediately send HTTP/2 frames to a server that is known to support HTTP/2, - after the connection preface; a server can - identify such a connection by the presence of the connection preface. This only affects - the establishment of HTTP/2 connections over cleartext TCP; implementations that support - HTTP/2 over TLS MUST use protocol negotiation in TLS. - - - Without additional information, prior support for HTTP/2 is not a strong signal that a - given server will support HTTP/2 for future connections. For example, it is possible for - server configurations to change, for configurations to differ between instances in - clustered servers, or for network conditions to change. - -
    - -
    - - Upon establishment of a TCP connection and determination that HTTP/2 will be used by both - peers, each endpoint MUST send a connection preface as a final confirmation and to - establish the initial SETTINGS parameters for the HTTP/2 connection. The client and - server each send a different connection preface. - - - The client connection preface starts with a sequence of 24 octets, which in hex notation - are: - -
    - -
    - - (the string PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n). This sequence - is followed by a SETTINGS frame (). The - SETTINGS frame MAY be empty. The client sends the client connection - preface immediately upon receipt of a 101 Switching Protocols response (indicating a - successful upgrade), or as the first application data octets of a TLS connection. If - starting an HTTP/2 connection with prior knowledge of server support for the protocol, the - client connection preface is sent upon connection establishment. - - - - - The client connection preface is selected so that a large proportion of HTTP/1.1 or - HTTP/1.0 servers and intermediaries do not attempt to process further frames. Note - that this does not address the concerns raised in . - - - - - The server connection preface consists of a potentially empty SETTINGS - frame () that MUST be the first frame the server sends in the - HTTP/2 connection. - - - The SETTINGS frames received from a peer as part of the connection preface - MUST be acknowledged (see ) after sending the connection - preface. - - - To avoid unnecessary latency, clients are permitted to send additional frames to the - server immediately after sending the client connection preface, without waiting to receive - the server connection preface. It is important to note, however, that the server - connection preface SETTINGS frame might include parameters that necessarily - alter how a client is expected to communicate with the server. Upon receiving the - SETTINGS frame, the client is expected to honor any parameters established. - In some configurations, it is possible for the server to transmit SETTINGS - before the client sends additional frames, providing an opportunity to avoid this issue. - - - Clients and servers MUST treat an invalid connection preface as a connection error of type - PROTOCOL_ERROR. A GOAWAY frame () - MAY be omitted in this case, since an invalid preface indicates that the peer is not using - HTTP/2. - -
    -
    - -
    - - Once the HTTP/2 connection is established, endpoints can begin exchanging frames. - - -
    - - All frames begin with a fixed 9-octet header followed by a variable-length payload. - -
    - -
    - - The fields of the frame header are defined as: - - - - The length of the frame payload expressed as an unsigned 24-bit integer. Values - greater than 214 (16,384) MUST NOT be sent unless the receiver has - set a larger value for SETTINGS_MAX_FRAME_SIZE. - - - The 9 octets of the frame header are not included in this value. - - - - - The 8-bit type of the frame. The frame type determines the format and semantics of - the frame. Implementations MUST ignore and discard any frame that has a type that - is unknown. - - - - - An 8-bit field reserved for frame-type specific boolean flags. - - - Flags are assigned semantics specific to the indicated frame type. Flags that have - no defined semantics for a particular frame type MUST be ignored, and MUST be left - unset (0) when sending. - - - - - A reserved 1-bit field. The semantics of this bit are undefined and the bit MUST - remain unset (0) when sending and MUST be ignored when receiving. - - - - - A 31-bit stream identifier (see ). The value 0 is - reserved for frames that are associated with the connection as a whole as opposed to - an individual stream. - - - - - - The structure and content of the frame payload is dependent entirely on the frame type. - -
    - -
    - - The size of a frame payload is limited by the maximum size that a receiver advertises in - the SETTINGS_MAX_FRAME_SIZE setting. This setting can have any value - between 214 (16,384) and 224-1 (16,777,215) octets, - inclusive. - - - All implementations MUST be capable of receiving and minimally processing frames up to - 214 octets in length, plus the 9 octet frame - header. The size of the frame header is not included when describing frame sizes. - - - Certain frame types, such as PING, impose additional limits - on the amount of payload data allowed. - - - - - If a frame size exceeds any defined limit, or is too small to contain mandatory frame - data, the endpoint MUST send a FRAME_SIZE_ERROR error. A frame size error - in a frame that could alter the state of the entire connection MUST be treated as a connection error; this includes any frame carrying - a header block (that is, HEADERS, - PUSH_PROMISE, and CONTINUATION), SETTINGS, - and any WINDOW_UPDATE frame with a stream identifier of 0. - - - Endpoints are not obligated to use all available space in a frame. Responsiveness can be - improved by using frames that are smaller than the permitted maximum size. Sending large - frames can result in delays in sending time-sensitive frames (such - RST_STREAM, WINDOW_UPDATE, or PRIORITY) - which if blocked by the transmission of a large frame, could affect performance. - -
    - -
    - - Just as in HTTP/1, a header field in HTTP/2 is a name with one or more associated values. - They are used within HTTP request and response messages as well as server push operations - (see ). - - - Header lists are collections of zero or more header fields. When transmitted over a - connection, a header list is serialized into a header block using HTTP Header Compression. The serialized header block is then - divided into one or more octet sequences, called header block fragments, and transmitted - within the payload of HEADERS, PUSH_PROMISE or CONTINUATION frames. - - - The Cookie header field is treated specially by the HTTP - mapping (see ). - - - A receiving endpoint reassembles the header block by concatenating its fragments, then - decompresses the block to reconstruct the header list. - - - A complete header block consists of either: - - - a single HEADERS or PUSH_PROMISE frame, - with the END_HEADERS flag set, or - - - a HEADERS or PUSH_PROMISE frame with the END_HEADERS - flag cleared and one or more CONTINUATION frames, - where the last CONTINUATION frame has the END_HEADERS flag set. - - - - - Header compression is stateful. One compression context and one decompression context is - used for the entire connection. Each header block is processed as a discrete unit. - Header blocks MUST be transmitted as a contiguous sequence of frames, with no interleaved - frames of any other type or from any other stream. The last frame in a sequence of - HEADERS or CONTINUATION frames MUST have the END_HEADERS - flag set. The last frame in a sequence of PUSH_PROMISE or - CONTINUATION frames MUST have the END_HEADERS flag set. This allows a - header block to be logically equivalent to a single frame. - - - Header block fragments can only be sent as the payload of HEADERS, - PUSH_PROMISE or CONTINUATION frames, because these frames - carry data that can modify the compression context maintained by a receiver. An endpoint - receiving HEADERS, PUSH_PROMISE or - CONTINUATION frames MUST reassemble header blocks and perform decompression - even if the frames are to be discarded. A receiver MUST terminate the connection with a - connection error of type - COMPRESSION_ERROR if it does not decompress a header block. - -
    -
    - -
    - - A "stream" is an independent, bi-directional sequence of frames exchanged between the client - and server within an HTTP/2 connection. Streams have several important characteristics: - - - A single HTTP/2 connection can contain multiple concurrently open streams, with either - endpoint interleaving frames from multiple streams. - - - Streams can be established and used unilaterally or shared by either the client or - server. - - - Streams can be closed by either endpoint. - - - The order in which frames are sent on a stream is significant. Recipients process frames - in the order they are received. In particular, the order of HEADERS, - and DATA frames is semantically significant. - - - Streams are identified by an integer. Stream identifiers are assigned to streams by the - endpoint initiating the stream. - - - - -
    - - The lifecycle of a stream is shown in . - - -
    - - | |<-----------' | - | R | closed | R | - `-------------------->| |<--------------------' - +--------+ - - H: HEADERS frame (with implied CONTINUATIONs) - PP: PUSH_PROMISE frame (with implied CONTINUATIONs) - ES: END_STREAM flag - R: RST_STREAM frame -]]> - -
    - - - Note that this diagram shows stream state transitions and the frames and flags that affect - those transitions only. In this regard, CONTINUATION frames do not result - in state transitions; they are effectively part of the HEADERS or - PUSH_PROMISE that they follow. For this purpose, the END_STREAM flag is - processed as a separate event to the frame that bears it; a HEADERS frame - with the END_STREAM flag set can cause two state transitions. - - - Both endpoints have a subjective view of the state of a stream that could be different - when frames are in transit. Endpoints do not coordinate the creation of streams; they are - created unilaterally by either endpoint. The negative consequences of a mismatch in - states are limited to the "closed" state after sending RST_STREAM, where - frames might be received for some time after closing. - - - Streams have the following states: - - - - - - All streams start in the "idle" state. In this state, no frames have been - exchanged. - - - The following transitions are valid from this state: - - - Sending or receiving a HEADERS frame causes the stream to become - "open". The stream identifier is selected as described in . The same HEADERS frame can also - cause a stream to immediately become "half closed". - - - Sending a PUSH_PROMISE frame marks the associated stream for - later use. The stream state for the reserved stream transitions to "reserved - (local)". - - - Receiving a PUSH_PROMISE frame marks the associated stream as - reserved by the remote peer. The state of the stream becomes "reserved - (remote)". - - - - - Receiving any frames other than HEADERS or - PUSH_PROMISE on a stream in this state MUST be treated as a connection error of type - PROTOCOL_ERROR. - - - - - - - A stream in the "reserved (local)" state is one that has been promised by sending a - PUSH_PROMISE frame. A PUSH_PROMISE frame reserves an - idle stream by associating the stream with an open stream that was initiated by the - remote peer (see ). - - - In this state, only the following transitions are possible: - - - The endpoint can send a HEADERS frame. This causes the stream to - open in a "half closed (remote)" state. - - - Either endpoint can send a RST_STREAM frame to cause the stream - to become "closed". This releases the stream reservation. - - - - - An endpoint MUST NOT send any type of frame other than HEADERS or - RST_STREAM in this state. - - - A PRIORITY frame MAY be received in this state. Receiving any type - of frame other than RST_STREAM or PRIORITY on a stream - in this state MUST be treated as a connection - error of type PROTOCOL_ERROR. - - - - - - - A stream in the "reserved (remote)" state has been reserved by a remote peer. - - - In this state, only the following transitions are possible: - - - Receiving a HEADERS frame causes the stream to transition to - "half closed (local)". - - - Either endpoint can send a RST_STREAM frame to cause the stream - to become "closed". This releases the stream reservation. - - - - - An endpoint MAY send a PRIORITY frame in this state to reprioritize - the reserved stream. An endpoint MUST NOT send any type of frame other than - RST_STREAM, WINDOW_UPDATE, or PRIORITY - in this state. - - - Receiving any type of frame other than HEADERS or - RST_STREAM on a stream in this state MUST be treated as a connection error of type - PROTOCOL_ERROR. - - - - - - - A stream in the "open" state may be used by both peers to send frames of any type. - In this state, sending peers observe advertised stream - level flow control limits. - - - From this state either endpoint can send a frame with an END_STREAM flag set, which - causes the stream to transition into one of the "half closed" states: an endpoint - sending an END_STREAM flag causes the stream state to become "half closed (local)"; - an endpoint receiving an END_STREAM flag causes the stream state to become "half - closed (remote)". - - - Either endpoint can send a RST_STREAM frame from this state, causing - it to transition immediately to "closed". - - - - - - - A stream that is in the "half closed (local)" state cannot be used for sending - frames. Only WINDOW_UPDATE, PRIORITY and - RST_STREAM frames can be sent in this state. - - - A stream transitions from this state to "closed" when a frame that contains an - END_STREAM flag is received, or when either peer sends a RST_STREAM - frame. - - - A receiver can ignore WINDOW_UPDATE frames in this state, which might - arrive for a short period after a frame bearing the END_STREAM flag is sent. - - - PRIORITY frames received in this state are used to reprioritize - streams that depend on the current stream. - - - - - - - A stream that is "half closed (remote)" is no longer being used by the peer to send - frames. In this state, an endpoint is no longer obligated to maintain a receiver - flow control window if it performs flow control. - - - If an endpoint receives additional frames for a stream that is in this state, other - than WINDOW_UPDATE, PRIORITY or - RST_STREAM, it MUST respond with a stream error of type - STREAM_CLOSED. - - - A stream that is "half closed (remote)" can be used by the endpoint to send frames - of any type. In this state, the endpoint continues to observe advertised stream level flow control limits. - - - A stream can transition from this state to "closed" by sending a frame that contains - an END_STREAM flag, or when either peer sends a RST_STREAM frame. - - - - - - - The "closed" state is the terminal state. - - - An endpoint MUST NOT send frames other than PRIORITY on a closed - stream. An endpoint that receives any frame other than PRIORITY - after receiving a RST_STREAM MUST treat that as a stream error of type - STREAM_CLOSED. Similarly, an endpoint that receives any frames after - receiving a frame with the END_STREAM flag set MUST treat that as a connection error of type - STREAM_CLOSED, unless the frame is permitted as described below. - - - WINDOW_UPDATE or RST_STREAM frames can be received in - this state for a short period after a DATA or HEADERS - frame containing an END_STREAM flag is sent. Until the remote peer receives and - processes RST_STREAM or the frame bearing the END_STREAM flag, it - might send frames of these types. Endpoints MUST ignore - WINDOW_UPDATE or RST_STREAM frames received in this - state, though endpoints MAY choose to treat frames that arrive a significant time - after sending END_STREAM as a connection - error of type PROTOCOL_ERROR. - - - PRIORITY frames can be sent on closed streams to prioritize streams - that are dependent on the closed stream. Endpoints SHOULD process - PRIORITY frame, though they can be ignored if the stream has been - removed from the dependency tree (see ). - - - If this state is reached as a result of sending a RST_STREAM frame, - the peer that receives the RST_STREAM might have already sent - or - enqueued for sending - frames on the stream that cannot be withdrawn. An endpoint - MUST ignore frames that it receives on closed streams after it has sent a - RST_STREAM frame. An endpoint MAY choose to limit the period over - which it ignores frames and treat frames that arrive after this time as being in - error. - - - Flow controlled frames (i.e., DATA) received after sending - RST_STREAM are counted toward the connection flow control window. - Even though these frames might be ignored, because they are sent before the sender - receives the RST_STREAM, the sender will consider the frames to count - against the flow control window. - - - An endpoint might receive a PUSH_PROMISE frame after it sends - RST_STREAM. PUSH_PROMISE causes a stream to become - "reserved" even if the associated stream has been reset. Therefore, a - RST_STREAM is needed to close an unwanted promised stream. - - - - - - In the absence of more specific guidance elsewhere in this document, implementations - SHOULD treat the receipt of a frame that is not expressly permitted in the description of - a state as a connection error of type - PROTOCOL_ERROR. Frame of unknown types are ignored. - - - An example of the state transitions for an HTTP request/response exchange can be found in - . An example of the state transitions for server push can be - found in and . - - -
    - - Streams are identified with an unsigned 31-bit integer. Streams initiated by a client - MUST use odd-numbered stream identifiers; those initiated by the server MUST use - even-numbered stream identifiers. A stream identifier of zero (0x0) is used for - connection control messages; the stream identifier zero cannot be used to establish a - new stream. - - - HTTP/1.1 requests that are upgraded to HTTP/2 (see ) are - responded to with a stream identifier of one (0x1). After the upgrade - completes, stream 0x1 is "half closed (local)" to the client. Therefore, stream 0x1 - cannot be selected as a new stream identifier by a client that upgrades from HTTP/1.1. - - - The identifier of a newly established stream MUST be numerically greater than all - streams that the initiating endpoint has opened or reserved. This governs streams that - are opened using a HEADERS frame and streams that are reserved using - PUSH_PROMISE. An endpoint that receives an unexpected stream identifier - MUST respond with a connection error of - type PROTOCOL_ERROR. - - - The first use of a new stream identifier implicitly closes all streams in the "idle" - state that might have been initiated by that peer with a lower-valued stream identifier. - For example, if a client sends a HEADERS frame on stream 7 without ever - sending a frame on stream 5, then stream 5 transitions to the "closed" state when the - first frame for stream 7 is sent or received. - - - Stream identifiers cannot be reused. Long-lived connections can result in an endpoint - exhausting the available range of stream identifiers. A client that is unable to - establish a new stream identifier can establish a new connection for new streams. A - server that is unable to establish a new stream identifier can send a - GOAWAY frame so that the client is forced to open a new connection for - new streams. - -
    - -
    - - A peer can limit the number of concurrently active streams using the - SETTINGS_MAX_CONCURRENT_STREAMS parameter (see ) within a SETTINGS frame. The maximum concurrent - streams setting is specific to each endpoint and applies only to the peer that receives - the setting. That is, clients specify the maximum number of concurrent streams the - server can initiate, and servers specify the maximum number of concurrent streams the - client can initiate. - - - Streams that are in the "open" state, or either of the "half closed" states count toward - the maximum number of streams that an endpoint is permitted to open. Streams in any of - these three states count toward the limit advertised in the - SETTINGS_MAX_CONCURRENT_STREAMS setting. Streams in either of the - "reserved" states do not count toward the stream limit. - - - Endpoints MUST NOT exceed the limit set by their peer. An endpoint that receives a - HEADERS frame that causes their advertised concurrent stream limit to be - exceeded MUST treat this as a stream error. An - endpoint that wishes to reduce the value of - SETTINGS_MAX_CONCURRENT_STREAMS to a value that is below the current - number of open streams can either close streams that exceed the new value or allow - streams to complete. - -
    -
    - -
    - - Using streams for multiplexing introduces contention over use of the TCP connection, - resulting in blocked streams. A flow control scheme ensures that streams on the same - connection do not destructively interfere with each other. Flow control is used for both - individual streams and for the connection as a whole. - - - HTTP/2 provides for flow control through use of the WINDOW_UPDATE frame. - - -
    - - HTTP/2 stream flow control aims to allow a variety of flow control algorithms to be - used without requiring protocol changes. Flow control in HTTP/2 has the following - characteristics: - - - Flow control is specific to a connection; i.e., it is "hop-by-hop", not - "end-to-end". - - - Flow control is based on window update frames. Receivers advertise how many octets - they are prepared to receive on a stream and for the entire connection. This is a - credit-based scheme. - - - Flow control is directional with overall control provided by the receiver. A - receiver MAY choose to set any window size that it desires for each stream and for - the entire connection. A sender MUST respect flow control limits imposed by a - receiver. Clients, servers and intermediaries all independently advertise their - flow control window as a receiver and abide by the flow control limits set by - their peer when sending. - - - The initial value for the flow control window is 65,535 octets for both new streams - and the overall connection. - - - The frame type determines whether flow control applies to a frame. Of the frames - specified in this document, only DATA frames are subject to flow - control; all other frame types do not consume space in the advertised flow control - window. This ensures that important control frames are not blocked by flow control. - - - Flow control cannot be disabled. - - - HTTP/2 defines only the format and semantics of the WINDOW_UPDATE - frame (). This document does not stipulate how a - receiver decides when to send this frame or the value that it sends, nor does it - specify how a sender chooses to send packets. Implementations are able to select - any algorithm that suits their needs. - - - - - Implementations are also responsible for managing how requests and responses are sent - based on priority; choosing how to avoid head of line blocking for requests; and - managing the creation of new streams. Algorithm choices for these could interact with - any flow control algorithm. - -
    - -
    - - Flow control is defined to protect endpoints that are operating under resource - constraints. For example, a proxy needs to share memory between many connections, and - also might have a slow upstream connection and a fast downstream one. Flow control - addresses cases where the receiver is unable process data on one stream, yet wants to - continue to process other streams in the same connection. - - - Deployments that do not require this capability can advertise a flow control window of - the maximum size, incrementing the available space when new data is received. This - effectively disables flow control for that receiver. Conversely, a sender is always - subject to the flow control window advertised by the receiver. - - - Deployments with constrained resources (for example, memory) can employ flow control to - limit the amount of memory a peer can consume. Note, however, that this can lead to - suboptimal use of available network resources if flow control is enabled without - knowledge of the bandwidth-delay product (see ). - - - Even with full awareness of the current bandwidth-delay product, implementation of flow - control can be difficult. When using flow control, the receiver MUST read from the TCP - receive buffer in a timely fashion. Failure to do so could lead to a deadlock when - critical frames, such as WINDOW_UPDATE, are not read and acted upon. - -
    -
    - -
    - - A client can assign a priority for a new stream by including prioritization information in - the HEADERS frame that opens the stream. For an existing - stream, the PRIORITY frame can be used to change the - priority. - - - The purpose of prioritization is to allow an endpoint to express how it would prefer its - peer allocate resources when managing concurrent streams. Most importantly, priority can - be used to select streams for transmitting frames when there is limited capacity for - sending. - - - Streams can be prioritized by marking them as dependent on the completion of other streams - (). Each dependency is assigned a relative weight, a number - that is used to determine the relative proportion of available resources that are assigned - to streams dependent on the same stream. - - - - Explicitly setting the priority for a stream is input to a prioritization process. It - does not guarantee any particular processing or transmission order for the stream relative - to any other stream. An endpoint cannot force a peer to process concurrent streams in a - particular order using priority. Expressing priority is therefore only ever a suggestion. - - - Providing prioritization information is optional, so default values are used if no - explicit indicator is provided (). - - -
    - - Each stream can be given an explicit dependency on another stream. Including a - dependency expresses a preference to allocate resources to the identified stream rather - than to the dependent stream. - - - A stream that is not dependent on any other stream is given a stream dependency of 0x0. - In other words, the non-existent stream 0 forms the root of the tree. - - - A stream that depends on another stream is a dependent stream. The stream upon which a - stream is dependent is a parent stream. A dependency on a stream that is not currently - in the tree - such as a stream in the "idle" state - results in that stream being given - a default priority. - - - When assigning a dependency on another stream, the stream is added as a new dependency - of the parent stream. Dependent streams that share the same parent are not ordered with - respect to each other. For example, if streams B and C are dependent on stream A, and - if stream D is created with a dependency on stream A, this results in a dependency order - of A followed by B, C, and D in any order. - -
    - /|\ - B C B D C -]]> -
    - - An exclusive flag allows for the insertion of a new level of dependencies. The - exclusive flag causes the stream to become the sole dependency of its parent stream, - causing other dependencies to become dependent on the exclusive stream. In the - previous example, if stream D is created with an exclusive dependency on stream A, this - results in D becoming the dependency parent of B and C. - -
    - D - B C / \ - B C -]]> -
    - - Inside the dependency tree, a dependent stream SHOULD only be allocated resources if all - of the streams that it depends on (the chain of parent streams up to 0x0) are either - closed, or it is not possible to make progress on them. - - - A stream cannot depend on itself. An endpoint MUST treat this as a stream error of type PROTOCOL_ERROR. - -
    - -
    - - All dependent streams are allocated an integer weight between 1 and 256 (inclusive). - - - Streams with the same parent SHOULD be allocated resources proportionally based on their - weight. Thus, if stream B depends on stream A with weight 4, and C depends on stream A - with weight 12, and if no progress can be made on A, stream B ideally receives one third - of the resources allocated to stream C. - -
    - -
    - - Stream priorities are changed using the PRIORITY frame. Setting a - dependency causes a stream to become dependent on the identified parent stream. - - - Dependent streams move with their parent stream if the parent is reprioritized. Setting - a dependency with the exclusive flag for a reprioritized stream moves all the - dependencies of the new parent stream to become dependent on the reprioritized stream. - - - If a stream is made dependent on one of its own dependencies, the formerly dependent - stream is first moved to be dependent on the reprioritized stream's previous parent. - The moved dependency retains its weight. - -
    - - For example, consider an original dependency tree where B and C depend on A, D and E - depend on C, and F depends on D. If A is made dependent on D, then D takes the place - of A. All other dependency relationships stay the same, except for F, which becomes - dependent on A if the reprioritization is exclusive. - - F B C ==> F A OR A - / \ | / \ /|\ - D E E B C B C F - | | | - F E E - (intermediate) (non-exclusive) (exclusive) -]]> -
    -
    - -
    - - When a stream is removed from the dependency tree, its dependencies can be moved to - become dependent on the parent of the closed stream. The weights of new dependencies - are recalculated by distributing the weight of the dependency of the closed stream - proportionally based on the weights of its dependencies. - - - Streams that are removed from the dependency tree cause some prioritization information - to be lost. Resources are shared between streams with the same parent stream, which - means that if a stream in that set closes or becomes blocked, any spare capacity - allocated to a stream is distributed to the immediate neighbors of the stream. However, - if the common dependency is removed from the tree, those streams share resources with - streams at the next highest level. - - - For example, assume streams A and B share a parent, and streams C and D both depend on - stream A. Prior to the removal of stream A, if streams A and D are unable to proceed, - then stream C receives all the resources dedicated to stream A. If stream A is removed - from the tree, the weight of stream A is divided between streams C and D. If stream D - is still unable to proceed, this results in stream C receiving a reduced proportion of - resources. For equal starting weights, C receives one third, rather than one half, of - available resources. - - - It is possible for a stream to become closed while prioritization information that - creates a dependency on that stream is in transit. If a stream identified in a - dependency has no associated priority information, then the dependent stream is instead - assigned a default priority. This potentially creates - suboptimal prioritization, since the stream could be given a priority that is different - to what is intended. - - - To avoid these problems, an endpoint SHOULD retain stream prioritization state for a - period after streams become closed. The longer state is retained, the lower the chance - that streams are assigned incorrect or default priority values. - - - This could create a large state burden for an endpoint, so this state MAY be limited. - An endpoint MAY apply a fixed upper limit on the number of closed streams for which - prioritization state is tracked to limit state exposure. The amount of additional state - an endpoint maintains could be dependent on load; under high load, prioritization state - can be discarded to limit resource commitments. In extreme cases, an endpoint could - even discard prioritization state for active or reserved streams. If a fixed limit is - applied, endpoints SHOULD maintain state for at least as many streams as allowed by - their setting for SETTINGS_MAX_CONCURRENT_STREAMS. - - - An endpoint receiving a PRIORITY frame that changes the priority of a - closed stream SHOULD alter the dependencies of the streams that depend on it, if it has - retained enough state to do so. - -
    - -
    - - Providing priority information is optional. Streams are assigned a non-exclusive - dependency on stream 0x0 by default. Pushed streams - initially depend on their associated stream. In both cases, streams are assigned a - default weight of 16. - -
    -
    - -
    - - HTTP/2 framing permits two classes of error: - - - An error condition that renders the entire connection unusable is a connection error. - - - An error in an individual stream is a stream error. - - - - - A list of error codes is included in . - - -
    - - A connection error is any error which prevents further processing of the framing layer, - or which corrupts any connection state. - - - An endpoint that encounters a connection error SHOULD first send a GOAWAY - frame () with the stream identifier of the last stream that it - successfully received from its peer. The GOAWAY frame includes an error - code that indicates why the connection is terminating. After sending the - GOAWAY frame, the endpoint MUST close the TCP connection. - - - It is possible that the GOAWAY will not be reliably received by the - receiving endpoint (see ). In the event of a connection error, - GOAWAY only provides a best effort attempt to communicate with the peer - about why the connection is being terminated. - - - An endpoint can end a connection at any time. In particular, an endpoint MAY choose to - treat a stream error as a connection error. Endpoints SHOULD send a - GOAWAY frame when ending a connection, providing that circumstances - permit it. - -
    - -
    - - A stream error is an error related to a specific stream that does not affect processing - of other streams. - - - An endpoint that detects a stream error sends a RST_STREAM frame () that contains the stream identifier of the stream where the error - occurred. The RST_STREAM frame includes an error code that indicates the - type of error. - - - A RST_STREAM is the last frame that an endpoint can send on a stream. - The peer that sends the RST_STREAM frame MUST be prepared to receive any - frames that were sent or enqueued for sending by the remote peer. These frames can be - ignored, except where they modify connection state (such as the state maintained for - header compression, or flow control). - - - Normally, an endpoint SHOULD NOT send more than one RST_STREAM frame for - any stream. However, an endpoint MAY send additional RST_STREAM frames if - it receives frames on a closed stream after more than a round-trip time. This behavior - is permitted to deal with misbehaving implementations. - - - An endpoint MUST NOT send a RST_STREAM in response to an - RST_STREAM frame, to avoid looping. - -
    - -
    - - If the TCP connection is closed or reset while streams remain in open or half closed - states, then the endpoint MUST assume that those streams were abnormally interrupted and - could be incomplete. - -
    -
    - -
    - - HTTP/2 permits extension of the protocol. Protocol extensions can be used to provide - additional services or alter any aspect of the protocol, within the limitations described - in this section. Extensions are effective only within the scope of a single HTTP/2 - connection. - - - Extensions are permitted to use new frame types, new - settings, or new error - codes. Registries are established for managing these extension points: frame types, settings and - error codes. - - - Implementations MUST ignore unknown or unsupported values in all extensible protocol - elements. Implementations MUST discard frames that have unknown or unsupported types. - This means that any of these extension points can be safely used by extensions without - prior arrangement or negotiation. However, extension frames that appear in the middle of - a header block are not permitted; these MUST be treated - as a connection error of type - PROTOCOL_ERROR. - - - However, extensions that could change the semantics of existing protocol components MUST - be negotiated before being used. For example, an extension that changes the layout of the - HEADERS frame cannot be used until the peer has given a positive signal - that this is acceptable. In this case, it could also be necessary to coordinate when the - revised layout comes into effect. Note that treating any frame other than - DATA frames as flow controlled is such a change in semantics, and can only - be done through negotiation. - - - This document doesn't mandate a specific method for negotiating the use of an extension, - but notes that a setting could be used for that - purpose. If both peers set a value that indicates willingness to use the extension, then - the extension can be used. If a setting is used for extension negotiation, the initial - value MUST be defined so that the extension is initially disabled. - -
    -
    - -
    - - This specification defines a number of frame types, each identified by a unique 8-bit type - code. Each frame type serves a distinct purpose either in the establishment and management - of the connection as a whole, or of individual streams. - - - The transmission of specific frame types can alter the state of a connection. If endpoints - fail to maintain a synchronized view of the connection state, successful communication - within the connection will no longer be possible. Therefore, it is important that endpoints - have a shared comprehension of how the state is affected by the use any given frame. - - -
    - - DATA frames (type=0x0) convey arbitrary, variable-length sequences of octets associated - with a stream. One or more DATA frames are used, for instance, to carry HTTP request or - response payloads. - - - DATA frames MAY also contain arbitrary padding. Padding can be added to DATA frames to - obscure the size of messages. - -
    - -
    - - The DATA frame contains the following fields: - - - An 8-bit field containing the length of the frame padding in units of octets. This - field is optional and is only present if the PADDED flag is set. - - - Application data. The amount of data is the remainder of the frame payload after - subtracting the length of the other fields that are present. - - - Padding octets that contain no application semantic value. Padding octets MUST be set - to zero when sending and ignored when receiving. - - - - - - The DATA frame defines the following flags: - - - Bit 1 being set indicates that this frame is the last that the endpoint will send for - the identified stream. Setting this flag causes the stream to enter one of the "half closed" states or the "closed" state. - - - Bit 4 being set indicates that the Pad Length field and any padding that it describes - is present. - - - - - DATA frames MUST be associated with a stream. If a DATA frame is received whose stream - identifier field is 0x0, the recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - DATA frames are subject to flow control and can only be sent when a stream is in the - "open" or "half closed (remote)" states. The entire DATA frame payload is included in flow - control, including Pad Length and Padding fields if present. If a DATA frame is received - whose stream is not in "open" or "half closed (local)" state, the recipient MUST respond - with a stream error of type - STREAM_CLOSED. - - - The total number of padding octets is determined by the value of the Pad Length field. If - the length of the padding is greater than the length of the frame payload, the recipient - MUST treat this as a connection error of - type PROTOCOL_ERROR. - - - A frame can be increased in size by one octet by including a Pad Length field with a - value of zero. - - - - - Padding is a security feature; see . - -
    - -
    - - The HEADERS frame (type=0x1) is used to open a stream, - and additionally carries a header block fragment. HEADERS frames can be sent on a stream - in the "open" or "half closed (remote)" states. - -
    - -
    - - The HEADERS frame payload has the following fields: - - - An 8-bit field containing the length of the frame padding in units of octets. This - field is only present if the PADDED flag is set. - - - A single bit flag indicates that the stream dependency is exclusive, see . This field is only present if the PRIORITY flag is set. - - - A 31-bit stream identifier for the stream that this stream depends on, see . This field is only present if the PRIORITY flag is set. - - - An 8-bit weight for the stream, see . Add one to the - value to obtain a weight between 1 and 256. This field is only present if the - PRIORITY flag is set. - - - A header block fragment. - - - Padding octets that contain no application semantic value. Padding octets MUST be set - to zero when sending and ignored when receiving. - - - - - - The HEADERS frame defines the following flags: - - - - Bit 1 being set indicates that the header block is - the last that the endpoint will send for the identified stream. Setting this flag - causes the stream to enter one of "half closed" - states. - - - A HEADERS frame carries the END_STREAM flag that signals the end of a stream. - However, a HEADERS frame with the END_STREAM flag set can be followed by - CONTINUATION frames on the same stream. Logically, the - CONTINUATION frames are part of the HEADERS frame. - - - - - Bit 3 being set indicates that this frame contains an entire header block and is not followed by any - CONTINUATION frames. - - - A HEADERS frame without the END_HEADERS flag set MUST be followed by a - CONTINUATION frame for the same stream. A receiver MUST treat the - receipt of any other type of frame or a frame on a different stream as a connection error of type - PROTOCOL_ERROR. - - - - - Bit 4 being set indicates that the Pad Length field and any padding that it - describes is present. - - - - - Bit 6 being set indicates that the Exclusive Flag (E), Stream Dependency, and Weight - fields are present; see . - - - - - - - The payload of a HEADERS frame contains a header block - fragment. A header block that does not fit within a HEADERS frame is continued in - a CONTINUATION frame. - - - - HEADERS frames MUST be associated with a stream. If a HEADERS frame is received whose - stream identifier field is 0x0, the recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - - The HEADERS frame changes the connection state as described in . - - - - The HEADERS frame includes optional padding. Padding fields and flags are identical to - those defined for DATA frames. - - - Prioritization information in a HEADERS frame is logically equivalent to a separate - PRIORITY frame, but inclusion in HEADERS avoids the potential for churn in - stream prioritization when new streams are created. Priorization fields in HEADERS frames - subsequent to the first on a stream reprioritize the - stream. - -
    - -
    - - The PRIORITY frame (type=0x2) specifies the sender-advised - priority of a stream. It can be sent at any time for an existing stream, including - closed streams. This enables reprioritization of existing streams. - -
    - -
    - - The payload of a PRIORITY frame contains the following fields: - - - A single bit flag indicates that the stream dependency is exclusive, see . - - - A 31-bit stream identifier for the stream that this stream depends on, see . - - - An 8-bit weight for the identified stream dependency, see . Add one to the value to obtain a weight between 1 and 256. - - - - - - The PRIORITY frame does not define any flags. - - - - The PRIORITY frame is associated with an existing stream. If a PRIORITY frame is received - with a stream identifier of 0x0, the recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - The PRIORITY frame can be sent on a stream in any of the "reserved (remote)", "open", - "half closed (local)", "half closed (remote)", or "closed" states, though it cannot be - sent between consecutive frames that comprise a single header - block. Note that this frame could arrive after processing or frame sending has - completed, which would cause it to have no effect on the current stream. For a stream - that is in the "half closed (remote)" or "closed" - state, this frame can only affect - processing of the current stream and not frame transmission. - - - The PRIORITY frame is the only frame that can be sent for a stream in the "closed" state. - This allows for the reprioritization of a group of dependent streams by altering the - priority of a parent stream, which might be closed. However, a PRIORITY frame sent on a - closed stream risks being ignored due to the peer having discarded priority state - information for that stream. - -
    - -
    - - The RST_STREAM frame (type=0x3) allows for abnormal termination of a stream. When sent by - the initiator of a stream, it indicates that they wish to cancel the stream or that an - error condition has occurred. When sent by the receiver of a stream, it indicates that - either the receiver is rejecting the stream, requesting that the stream be cancelled, or - that an error condition has occurred. - -
    - -
    - - - The RST_STREAM frame contains a single unsigned, 32-bit integer identifying the error code. The error code indicates why the stream is being - terminated. - - - - The RST_STREAM frame does not define any flags. - - - - The RST_STREAM frame fully terminates the referenced stream and causes it to enter the - closed state. After receiving a RST_STREAM on a stream, the receiver MUST NOT send - additional frames for that stream, with the exception of PRIORITY. However, - after sending the RST_STREAM, the sending endpoint MUST be prepared to receive and process - additional frames sent on the stream that might have been sent by the peer prior to the - arrival of the RST_STREAM. - - - - RST_STREAM frames MUST be associated with a stream. If a RST_STREAM frame is received - with a stream identifier of 0x0, the recipient MUST treat this as a connection error of type - PROTOCOL_ERROR. - - - - RST_STREAM frames MUST NOT be sent for a stream in the "idle" state. If a RST_STREAM - frame identifying an idle stream is received, the recipient MUST treat this as a connection error of type - PROTOCOL_ERROR. - - -
    - -
    - - The SETTINGS frame (type=0x4) conveys configuration parameters that affect how endpoints - communicate, such as preferences and constraints on peer behavior. The SETTINGS frame is - also used to acknowledge the receipt of those parameters. Individually, a SETTINGS - parameter can also be referred to as a "setting". - - - SETTINGS parameters are not negotiated; they describe characteristics of the sending peer, - which are used by the receiving peer. Different values for the same parameter can be - advertised by each peer. For example, a client might set a high initial flow control - window, whereas a server might set a lower value to conserve resources. - - - - A SETTINGS frame MUST be sent by both endpoints at the start of a connection, and MAY be - sent at any other time by either endpoint over the lifetime of the connection. - Implementations MUST support all of the parameters defined by this specification. - - - - Each parameter in a SETTINGS frame replaces any existing value for that parameter. - Parameters are processed in the order in which they appear, and a receiver of a SETTINGS - frame does not need to maintain any state other than the current value of its - parameters. Therefore, the value of a SETTINGS parameter is the last value that is seen by - a receiver. - - - SETTINGS parameters are acknowledged by the receiving peer. To enable this, the SETTINGS - frame defines the following flag: - - - Bit 1 being set indicates that this frame acknowledges receipt and application of the - peer's SETTINGS frame. When this bit is set, the payload of the SETTINGS frame MUST - be empty. Receipt of a SETTINGS frame with the ACK flag set and a length field value - other than 0 MUST be treated as a connection - error of type FRAME_SIZE_ERROR. For more info, see Settings Synchronization. - - - - - SETTINGS frames always apply to a connection, never a single stream. The stream - identifier for a SETTINGS frame MUST be zero (0x0). If an endpoint receives a SETTINGS - frame whose stream identifier field is anything other than 0x0, the endpoint MUST respond - with a connection error of type - PROTOCOL_ERROR. - - - The SETTINGS frame affects connection state. A badly formed or incomplete SETTINGS frame - MUST be treated as a connection error of type - PROTOCOL_ERROR. - - -
    - - The payload of a SETTINGS frame consists of zero or more parameters, each consisting of - an unsigned 16-bit setting identifier and an unsigned 32-bit value. - - -
    - -
    -
    - -
    - - The following parameters are defined: - - - - Allows the sender to inform the remote endpoint of the maximum size of the header - compression table used to decode header blocks, in octets. The encoder can select - any size equal to or less than this value by using signaling specific to the - header compression format inside a header block. The initial value is 4,096 - octets. - - - - - This setting can be use to disable server - push. An endpoint MUST NOT send a PUSH_PROMISE frame if it - receives this parameter set to a value of 0. An endpoint that has both set this - parameter to 0 and had it acknowledged MUST treat the receipt of a - PUSH_PROMISE frame as a connection error of type - PROTOCOL_ERROR. - - - The initial value is 1, which indicates that server push is permitted. Any value - other than 0 or 1 MUST be treated as a connection error of type - PROTOCOL_ERROR. - - - - - Indicates the maximum number of concurrent streams that the sender will allow. - This limit is directional: it applies to the number of streams that the sender - permits the receiver to create. Initially there is no limit to this value. It is - recommended that this value be no smaller than 100, so as to not unnecessarily - limit parallelism. - - - A value of 0 for SETTINGS_MAX_CONCURRENT_STREAMS SHOULD NOT be treated as special - by endpoints. A zero value does prevent the creation of new streams, however this - can also happen for any limit that is exhausted with active streams. Servers - SHOULD only set a zero value for short durations; if a server does not wish to - accept requests, closing the connection could be preferable. - - - - - Indicates the sender's initial window size (in octets) for stream level flow - control. The initial value is 216-1 (65,535) octets. - - - This setting affects the window size of all streams, including existing streams, - see . - - - Values above the maximum flow control window size of 231-1 MUST - be treated as a connection error of - type FLOW_CONTROL_ERROR. - - - - - Indicates the size of the largest frame payload that the sender is willing to - receive, in octets. - - - The initial value is 214 (16,384) octets. The value advertised by - an endpoint MUST be between this initial value and the maximum allowed frame size - (224-1 or 16,777,215 octets), inclusive. Values outside this range - MUST be treated as a connection error - of type PROTOCOL_ERROR. - - - - - This advisory setting informs a peer of the maximum size of header list that the - sender is prepared to accept, in octets. The value is based on the uncompressed - size of header fields, including the length of the name and value in octets plus - an overhead of 32 octets for each header field. - - - For any given request, a lower limit than what is advertised MAY be enforced. The - initial value of this setting is unlimited. - - - - - - An endpoint that receives a SETTINGS frame with any unknown or unsupported identifier - MUST ignore that setting. - -
    - -
    - - Most values in SETTINGS benefit from or require an understanding of when the peer has - received and applied the changed parameter values. In order to provide - such synchronization timepoints, the recipient of a SETTINGS frame in which the ACK flag - is not set MUST apply the updated parameters as soon as possible upon receipt. - - - The values in the SETTINGS frame MUST be processed in the order they appear, with no - other frame processing between values. Unsupported parameters MUST be ignored. Once - all values have been processed, the recipient MUST immediately emit a SETTINGS frame - with the ACK flag set. Upon receiving a SETTINGS frame with the ACK flag set, the sender - of the altered parameters can rely on the setting having been applied. - - - If the sender of a SETTINGS frame does not receive an acknowledgement within a - reasonable amount of time, it MAY issue a connection error of type - SETTINGS_TIMEOUT. - -
    -
    - -
    - - The PUSH_PROMISE frame (type=0x5) is used to notify the peer endpoint in advance of - streams the sender intends to initiate. The PUSH_PROMISE frame includes the unsigned - 31-bit identifier of the stream the endpoint plans to create along with a set of headers - that provide additional context for the stream. contains a - thorough description of the use of PUSH_PROMISE frames. - - -
    - -
    - - The PUSH_PROMISE frame payload has the following fields: - - - An 8-bit field containing the length of the frame padding in units of octets. This - field is only present if the PADDED flag is set. - - - A single reserved bit. - - - An unsigned 31-bit integer that identifies the stream that is reserved by the - PUSH_PROMISE. The promised stream identifier MUST be a valid choice for the next - stream sent by the sender (see new stream - identifier). - - - A header block fragment containing request header - fields. - - - Padding octets. - - - - - - The PUSH_PROMISE frame defines the following flags: - - - - Bit 3 being set indicates that this frame contains an entire header block and is not followed by any - CONTINUATION frames. - - - A PUSH_PROMISE frame without the END_HEADERS flag set MUST be followed by a - CONTINUATION frame for the same stream. A receiver MUST treat the receipt of any - other type of frame or a frame on a different stream as a connection error of type - PROTOCOL_ERROR. - - - - - Bit 4 being set indicates that the Pad Length field and any padding that it - describes is present. - - - - - - - PUSH_PROMISE frames MUST be associated with an existing, peer-initiated stream. The stream - identifier of a PUSH_PROMISE frame indicates the stream it is associated with. If the - stream identifier field specifies the value 0x0, a recipient MUST respond with a connection error of type - PROTOCOL_ERROR. - - - - Promised streams are not required to be used in the order they are promised. The - PUSH_PROMISE only reserves stream identifiers for later use. - - - - PUSH_PROMISE MUST NOT be sent if the SETTINGS_ENABLE_PUSH setting of the - peer endpoint is set to 0. An endpoint that has set this setting and has received - acknowledgement MUST treat the receipt of a PUSH_PROMISE frame as a connection error of type - PROTOCOL_ERROR. - - - Recipients of PUSH_PROMISE frames can choose to reject promised streams by returning a - RST_STREAM referencing the promised stream identifier back to the sender of - the PUSH_PROMISE. - - - - A PUSH_PROMISE frame modifies the connection state in two ways. The inclusion of a header block potentially modifies the state maintained for - header compression. PUSH_PROMISE also reserves a stream for later use, causing the - promised stream to enter the "reserved" state. A sender MUST NOT send a PUSH_PROMISE on a - stream unless that stream is either "open" or "half closed (remote)"; the sender MUST - ensure that the promised stream is a valid choice for a new stream identifier (that is, the promised stream MUST - be in the "idle" state). - - - Since PUSH_PROMISE reserves a stream, ignoring a PUSH_PROMISE frame causes the stream - state to become indeterminate. A receiver MUST treat the receipt of a PUSH_PROMISE on a - stream that is neither "open" nor "half closed (local)" as a connection error of type - PROTOCOL_ERROR. However, an endpoint that has sent - RST_STREAM on the associated stream MUST handle PUSH_PROMISE frames that - might have been created before the RST_STREAM frame is received and - processed. - - - A receiver MUST treat the receipt of a PUSH_PROMISE that promises an illegal stream identifier (that is, an identifier for a - stream that is not currently in the "idle" state) as a connection error of type - PROTOCOL_ERROR. - - - - The PUSH_PROMISE frame includes optional padding. Padding fields and flags are identical - to those defined for DATA frames. - -
    - -
    - - The PING frame (type=0x6) is a mechanism for measuring a minimal round trip time from the - sender, as well as determining whether an idle connection is still functional. PING - frames can be sent from any endpoint. - -
    - -
    - - - In addition to the frame header, PING frames MUST contain 8 octets of data in the payload. - A sender can include any value it chooses and use those bytes in any fashion. - - - Receivers of a PING frame that does not include an ACK flag MUST send a PING frame with - the ACK flag set in response, with an identical payload. PING responses SHOULD be given - higher priority than any other frame. - - - - The PING frame defines the following flags: - - - Bit 1 being set indicates that this PING frame is a PING response. An endpoint MUST - set this flag in PING responses. An endpoint MUST NOT respond to PING frames - containing this flag. - - - - - PING frames are not associated with any individual stream. If a PING frame is received - with a stream identifier field value other than 0x0, the recipient MUST respond with a - connection error of type - PROTOCOL_ERROR. - - - Receipt of a PING frame with a length field value other than 8 MUST be treated as a connection error of type - FRAME_SIZE_ERROR. - - -
    - -
    - - The GOAWAY frame (type=0x7) informs the remote peer to stop creating streams on this - connection. GOAWAY can be sent by either the client or the server. Once sent, the sender - will ignore frames sent on any new streams with identifiers higher than the included last - stream identifier. Receivers of a GOAWAY frame MUST NOT open additional streams on the - connection, although a new connection can be established for new streams. - - - The purpose of this frame is to allow an endpoint to gracefully stop accepting new - streams, while still finishing processing of previously established streams. This enables - administrative actions, like server maintainance. - - - There is an inherent race condition between an endpoint starting new streams and the - remote sending a GOAWAY frame. To deal with this case, the GOAWAY contains the stream - identifier of the last peer-initiated stream which was or might be processed on the - sending endpoint in this connection. For instance, if the server sends a GOAWAY frame, - the identified stream is the highest numbered stream initiated by the client. - - - If the receiver of the GOAWAY has sent data on streams with a higher stream identifier - than what is indicated in the GOAWAY frame, those streams are not or will not be - processed. The receiver of the GOAWAY frame can treat the streams as though they had - never been created at all, thereby allowing those streams to be retried later on a new - connection. - - - Endpoints SHOULD always send a GOAWAY frame before closing a connection so that the remote - can know whether a stream has been partially processed or not. For example, if an HTTP - client sends a POST at the same time that a server closes a connection, the client cannot - know if the server started to process that POST request if the server does not send a - GOAWAY frame to indicate what streams it might have acted on. - - - An endpoint might choose to close a connection without sending GOAWAY for misbehaving - peers. - - -
    - -
    - - The GOAWAY frame does not define any flags. - - - The GOAWAY frame applies to the connection, not a specific stream. An endpoint MUST treat - a GOAWAY frame with a stream identifier other than 0x0 as a connection error of type - PROTOCOL_ERROR. - - - The last stream identifier in the GOAWAY frame contains the highest numbered stream - identifier for which the sender of the GOAWAY frame might have taken some action on, or - might yet take action on. All streams up to and including the identified stream might - have been processed in some way. The last stream identifier can be set to 0 if no streams - were processed. - - - In this context, "processed" means that some data from the stream was passed to some - higher layer of software that might have taken some action as a result. - - - If a connection terminates without a GOAWAY frame, the last stream identifier is - effectively the highest possible stream identifier. - - - On streams with lower or equal numbered identifiers that were not closed completely prior - to the connection being closed, re-attempting requests, transactions, or any protocol - activity is not possible, with the exception of idempotent actions like HTTP GET, PUT, or - DELETE. Any protocol activity that uses higher numbered streams can be safely retried - using a new connection. - - - Activity on streams numbered lower or equal to the last stream identifier might still - complete successfully. The sender of a GOAWAY frame might gracefully shut down a - connection by sending a GOAWAY frame, maintaining the connection in an open state until - all in-progress streams complete. - - - An endpoint MAY send multiple GOAWAY frames if circumstances change. For instance, an - endpoint that sends GOAWAY with NO_ERROR during graceful shutdown could - subsequently encounter an condition that requires immediate termination of the connection. - The last stream identifier from the last GOAWAY frame received indicates which streams - could have been acted upon. Endpoints MUST NOT increase the value they send in the last - stream identifier, since the peers might already have retried unprocessed requests on - another connection. - - - A client that is unable to retry requests loses all requests that are in flight when the - server closes the connection. This is especially true for intermediaries that might - not be serving clients using HTTP/2. A server that is attempting to gracefully shut down - a connection SHOULD send an initial GOAWAY frame with the last stream identifier set to - 231-1 and a NO_ERROR code. This signals to the client that - a shutdown is imminent and that no further requests can be initiated. After waiting at - least one round trip time, the server can send another GOAWAY frame with an updated last - stream identifier. This ensures that a connection can be cleanly shut down without losing - requests. - - - - After sending a GOAWAY frame, the sender can discard frames for streams with identifiers - higher than the identified last stream. However, any frames that alter connection state - cannot be completely ignored. For instance, HEADERS, - PUSH_PROMISE and CONTINUATION frames MUST be minimally - processed to ensure the state maintained for header compression is consistent (see ); similarly DATA frames MUST be counted toward the connection flow - control window. Failure to process these frames can cause flow control or header - compression state to become unsynchronized. - - - - The GOAWAY frame also contains a 32-bit error code that - contains the reason for closing the connection. - - - Endpoints MAY append opaque data to the payload of any GOAWAY frame. Additional debug - data is intended for diagnostic purposes only and carries no semantic value. Debug - information could contain security- or privacy-sensitive data. Logged or otherwise - persistently stored debug data MUST have adequate safeguards to prevent unauthorized - access. - -
    - -
    - - The WINDOW_UPDATE frame (type=0x8) is used to implement flow control; see for an overview. - - - Flow control operates at two levels: on each individual stream and on the entire - connection. - - - Both types of flow control are hop-by-hop; that is, only between the two endpoints. - Intermediaries do not forward WINDOW_UPDATE frames between dependent connections. - However, throttling of data transfer by any receiver can indirectly cause the propagation - of flow control information toward the original sender. - - - Flow control only applies to frames that are identified as being subject to flow control. - Of the frame types defined in this document, this includes only DATA frames. - Frames that are exempt from flow control MUST be accepted and processed, unless the - receiver is unable to assign resources to handling the frame. A receiver MAY respond with - a stream error or connection error of type - FLOW_CONTROL_ERROR if it is unable to accept a frame. - -
    - -
    - - The payload of a WINDOW_UPDATE frame is one reserved bit, plus an unsigned 31-bit integer - indicating the number of octets that the sender can transmit in addition to the existing - flow control window. The legal range for the increment to the flow control window is 1 to - 231-1 (0x7fffffff) octets. - - - The WINDOW_UPDATE frame does not define any flags. - - - The WINDOW_UPDATE frame can be specific to a stream or to the entire connection. In the - former case, the frame's stream identifier indicates the affected stream; in the latter, - the value "0" indicates that the entire connection is the subject of the frame. - - - A receiver MUST treat the receipt of a WINDOW_UPDATE frame with an flow control window - increment of 0 as a stream error of type - PROTOCOL_ERROR; errors on the connection flow control window MUST be - treated as a connection error. - - - WINDOW_UPDATE can be sent by a peer that has sent a frame bearing the END_STREAM flag. - This means that a receiver could receive a WINDOW_UPDATE frame on a "half closed (remote)" - or "closed" stream. A receiver MUST NOT treat this as an error, see . - - - A receiver that receives a flow controlled frame MUST always account for its contribution - against the connection flow control window, unless the receiver treats this as a connection error. This is necessary even if the - frame is in error. Since the sender counts the frame toward the flow control window, if - the receiver does not, the flow control window at sender and receiver can become - different. - - -
    - - Flow control in HTTP/2 is implemented using a window kept by each sender on every - stream. The flow control window is a simple integer value that indicates how many octets - of data the sender is permitted to transmit; as such, its size is a measure of the - buffering capacity of the receiver. - - - Two flow control windows are applicable: the stream flow control window and the - connection flow control window. The sender MUST NOT send a flow controlled frame with a - length that exceeds the space available in either of the flow control windows advertised - by the receiver. Frames with zero length with the END_STREAM flag set (that is, an - empty DATA frame) MAY be sent if there is no available space in either - flow control window. - - - For flow control calculations, the 9 octet frame header is not counted. - - - After sending a flow controlled frame, the sender reduces the space available in both - windows by the length of the transmitted frame. - - - The receiver of a frame sends a WINDOW_UPDATE frame as it consumes data and frees up - space in flow control windows. Separate WINDOW_UPDATE frames are sent for the stream - and connection level flow control windows. - - - A sender that receives a WINDOW_UPDATE frame updates the corresponding window by the - amount specified in the frame. - - - A sender MUST NOT allow a flow control window to exceed 231-1 octets. - If a sender receives a WINDOW_UPDATE that causes a flow control window to exceed this - maximum it MUST terminate either the stream or the connection, as appropriate. For - streams, the sender sends a RST_STREAM with the error code of - FLOW_CONTROL_ERROR code; for the connection, a GOAWAY - frame with a FLOW_CONTROL_ERROR code. - - - Flow controlled frames from the sender and WINDOW_UPDATE frames from the receiver are - completely asynchronous with respect to each other. This property allows a receiver to - aggressively update the window size kept by the sender to prevent streams from stalling. - -
    - -
    - - When an HTTP/2 connection is first established, new streams are created with an initial - flow control window size of 65,535 octets. The connection flow control window is 65,535 - octets. Both endpoints can adjust the initial window size for new streams by including - a value for SETTINGS_INITIAL_WINDOW_SIZE in the SETTINGS - frame that forms part of the connection preface. The connection flow control window can - only be changed using WINDOW_UPDATE frames. - - - Prior to receiving a SETTINGS frame that sets a value for - SETTINGS_INITIAL_WINDOW_SIZE, an endpoint can only use the default - initial window size when sending flow controlled frames. Similarly, the connection flow - control window is set to the default initial window size until a WINDOW_UPDATE frame is - received. - - - A SETTINGS frame can alter the initial flow control window size for all - current streams. When the value of SETTINGS_INITIAL_WINDOW_SIZE changes, - a receiver MUST adjust the size of all stream flow control windows that it maintains by - the difference between the new value and the old value. - - - A change to SETTINGS_INITIAL_WINDOW_SIZE can cause the available space in - a flow control window to become negative. A sender MUST track the negative flow control - window, and MUST NOT send new flow controlled frames until it receives WINDOW_UPDATE - frames that cause the flow control window to become positive. - - - For example, if the client sends 60KB immediately on connection establishment, and the - server sets the initial window size to be 16KB, the client will recalculate the - available flow control window to be -44KB on receipt of the SETTINGS - frame. The client retains a negative flow control window until WINDOW_UPDATE frames - restore the window to being positive, after which the client can resume sending. - - - A SETTINGS frame cannot alter the connection flow control window. - - - An endpoint MUST treat a change to SETTINGS_INITIAL_WINDOW_SIZE that - causes any flow control window to exceed the maximum size as a connection error of type - FLOW_CONTROL_ERROR. - -
    - -
    - - A receiver that wishes to use a smaller flow control window than the current size can - send a new SETTINGS frame. However, the receiver MUST be prepared to - receive data that exceeds this window size, since the sender might send data that - exceeds the lower limit prior to processing the SETTINGS frame. - - - After sending a SETTINGS frame that reduces the initial flow control window size, a - receiver has two options for handling streams that exceed flow control limits: - - - The receiver can immediately send RST_STREAM with - FLOW_CONTROL_ERROR error code for the affected streams. - - - The receiver can accept the streams and tolerate the resulting head of line - blocking, sending WINDOW_UPDATE frames as it consumes data. - - - -
    -
    - -
    - - The CONTINUATION frame (type=0x9) is used to continue a sequence of header block fragments. Any number of CONTINUATION frames can - be sent on an existing stream, as long as the preceding frame is on the same stream and is - a HEADERS, PUSH_PROMISE or CONTINUATION frame without the - END_HEADERS flag set. - - -
    - -
    - - The CONTINUATION frame payload contains a header block - fragment. - - - - The CONTINUATION frame defines the following flag: - - - - Bit 3 being set indicates that this frame ends a header - block. - - - If the END_HEADERS bit is not set, this frame MUST be followed by another - CONTINUATION frame. A receiver MUST treat the receipt of any other type of frame or - a frame on a different stream as a connection - error of type PROTOCOL_ERROR. - - - - - - - The CONTINUATION frame changes the connection state as defined in . - - - - CONTINUATION frames MUST be associated with a stream. If a CONTINUATION frame is received - whose stream identifier field is 0x0, the recipient MUST respond with a connection error of type PROTOCOL_ERROR. - - - - A CONTINUATION frame MUST be preceded by a HEADERS, - PUSH_PROMISE or CONTINUATION frame without the END_HEADERS flag set. A - recipient that observes violation of this rule MUST respond with a connection error of type - PROTOCOL_ERROR. - -
    -
    - -
    - - Error codes are 32-bit fields that are used in RST_STREAM and - GOAWAY frames to convey the reasons for the stream or connection error. - - - - Error codes share a common code space. Some error codes apply only to either streams or the - entire connection and have no defined semantics in the other context. - - - - The following error codes are defined: - - - The associated condition is not as a result of an error. For example, a - GOAWAY might include this code to indicate graceful shutdown of a - connection. - - - The endpoint detected an unspecific protocol error. This error is for use when a more - specific error code is not available. - - - The endpoint encountered an unexpected internal error. - - - The endpoint detected that its peer violated the flow control protocol. - - - The endpoint sent a SETTINGS frame, but did not receive a response in a - timely manner. See Settings Synchronization. - - - The endpoint received a frame after a stream was half closed. - - - The endpoint received a frame with an invalid size. - - - The endpoint refuses the stream prior to performing any application processing, see - for details. - - - Used by the endpoint to indicate that the stream is no longer needed. - - - The endpoint is unable to maintain the header compression context for the connection. - - - The connection established in response to a CONNECT - request was reset or abnormally closed. - - - The endpoint detected that its peer is exhibiting a behavior that might be generating - excessive load. - - - The underlying transport has properties that do not meet minimum security - requirements (see ). - - - - - Unknown or unsupported error codes MUST NOT trigger any special behavior. These MAY be - treated by an implementation as being equivalent to INTERNAL_ERROR. - -
    - -
    - - HTTP/2 is intended to be as compatible as possible with current uses of HTTP. This means - that, from the application perspective, the features of the protocol are largely - unchanged. To achieve this, all request and response semantics are preserved, although the - syntax of conveying those semantics has changed. - - - Thus, the specification and requirements of HTTP/1.1 Semantics and Content , Conditional Requests , Range Requests , Caching and Authentication are applicable to HTTP/2. Selected portions of HTTP/1.1 Message Syntax - and Routing , such as the HTTP and HTTPS URI schemes, are also - applicable in HTTP/2, but the expression of those semantics for this protocol are defined - in the sections below. - - -
    - - A client sends an HTTP request on a new stream, using a previously unused stream identifier. A server sends an HTTP response on - the same stream as the request. - - - An HTTP message (request or response) consists of: - - - for a response only, zero or more HEADERS frames (each followed by zero - or more CONTINUATION frames) containing the message headers of - informational (1xx) HTTP responses (see and ), - and - - - one HEADERS frame (followed by zero or more CONTINUATION - frames) containing the message headers (see ), and - - - zero or more DATA frames containing the message payload (see ), and - - - optionally, one HEADERS frame, followed by zero or more - CONTINUATION frames containing the trailer-part, if present (see ). - - - The last frame in the sequence bears an END_STREAM flag, noting that a - HEADERS frame bearing the END_STREAM flag can be followed by - CONTINUATION frames that carry any remaining portions of the header block. - - - Other frames (from any stream) MUST NOT occur between either HEADERS frame - and any CONTINUATION frames that might follow. - - - - Trailing header fields are carried in a header block that also terminates the stream. - That is, a sequence starting with a HEADERS frame, followed by zero or more - CONTINUATION frames, where the HEADERS frame bears an - END_STREAM flag. Header blocks after the first that do not terminate the stream are not - part of an HTTP request or response. - - - A HEADERS frame (and associated CONTINUATION frames) can - only appear at the start or end of a stream. An endpoint that receives a - HEADERS frame without the END_STREAM flag set after receiving a final - (non-informational) status code MUST treat the corresponding request or response as malformed. - - - - An HTTP request/response exchange fully consumes a single stream. A request starts with - the HEADERS frame that puts the stream into an "open" state. The request - ends with a frame bearing END_STREAM, which causes the stream to become "half closed - (local)" for the client and "half closed (remote)" for the server. A response starts with - a HEADERS frame and ends with a frame bearing END_STREAM, which places the - stream in the "closed" state. - - - -
    - - HTTP/2 removes support for the 101 (Switching Protocols) informational status code - (). - - - The semantics of 101 (Switching Protocols) aren't applicable to a multiplexed protocol. - Alternative protocols are able to use the same mechanisms that HTTP/2 uses to negotiate - their use (see ). - -
    - -
    - - HTTP header fields carry information as a series of key-value pairs. For a listing of - registered HTTP headers, see the Message Header Field Registry maintained at . - - -
    - - While HTTP/1.x used the message start-line (see ) to convey the target URI and method of the request, and the - status code for the response, HTTP/2 uses special pseudo-header fields beginning with - ':' character (ASCII 0x3a) for this purpose. - - - Pseudo-header fields are not HTTP header fields. Endpoints MUST NOT generate - pseudo-header fields other than those defined in this document. - - - Pseudo-header fields are only valid in the context in which they are defined. - Pseudo-header fields defined for requests MUST NOT appear in responses; pseudo-header - fields defined for responses MUST NOT appear in requests. Pseudo-header fields MUST - NOT appear in trailers. Endpoints MUST treat a request or response that contains - undefined or invalid pseudo-header fields as malformed. - - - Just as in HTTP/1.x, header field names are strings of ASCII characters that are - compared in a case-insensitive fashion. However, header field names MUST be converted - to lowercase prior to their encoding in HTTP/2. A request or response containing - uppercase header field names MUST be treated as malformed. - - - All pseudo-header fields MUST appear in the header block before regular header fields. - Any request or response that contains a pseudo-header field that appears in a header - block after a regular header field MUST be treated as malformed. - -
    - -
    - - HTTP/2 does not use the Connection header field to - indicate connection-specific header fields; in this protocol, connection-specific - metadata is conveyed by other means. An endpoint MUST NOT generate a HTTP/2 message - containing connection-specific header fields; any message containing - connection-specific header fields MUST be treated as malformed. - - - This means that an intermediary transforming an HTTP/1.x message to HTTP/2 will need - to remove any header fields nominated by the Connection header field, along with the - Connection header field itself. Such intermediaries SHOULD also remove other - connection-specific header fields, such as Keep-Alive, Proxy-Connection, - Transfer-Encoding and Upgrade, even if they are not nominated by Connection. - - - One exception to this is the TE header field, which MAY be present in an HTTP/2 - request, but when it is MUST NOT contain any value other than "trailers". - - - - - HTTP/2 purposefully does not support upgrade to another protocol. The handshake - methods described in are believed sufficient to - negotiate the use of alternative protocols. - - - -
    - -
    - - The following pseudo-header fields are defined for HTTP/2 requests: - - - - The :method pseudo-header field includes the HTTP - method (). - - - - - The :scheme pseudo-header field includes the scheme - portion of the target URI (). - - - :scheme is not restricted to http and https schemed URIs. A - proxy or gateway can translate requests for non-HTTP schemes, enabling the use - of HTTP to interact with non-HTTP services. - - - - - The :authority pseudo-header field includes the - authority portion of the target URI (). The authority MUST NOT include the deprecated userinfo subcomponent for http - or https schemed URIs. - - - To ensure that the HTTP/1.1 request line can be reproduced accurately, this - pseudo-header field MUST be omitted when translating from an HTTP/1.1 request - that has a request target in origin or asterisk form (see ). Clients that generate - HTTP/2 requests directly SHOULD use the :authority pseudo-header - field instead of the Host header field. An - intermediary that converts an HTTP/2 request to HTTP/1.1 MUST create a Host header field if one is not present in a request by - copying the value of the :authority pseudo-header - field. - - - - - The :path pseudo-header field includes the path and - query parts of the target URI (the path-absolute - production from and optionally a '?' character - followed by the query production, see and ). A request in asterisk form includes the value '*' for the - :path pseudo-header field. - - - This pseudo-header field MUST NOT be empty for http - or https URIs; http or - https URIs that do not contain a path component - MUST include a value of '/'. The exception to this rule is an OPTIONS request - for an http or https - URI that does not include a path component; these MUST include a :path pseudo-header field with a value of '*' (see ). - - - - - - All HTTP/2 requests MUST include exactly one valid value for the :method, :scheme, and :path pseudo-header fields, unless it is a CONNECT request. An HTTP request that omits mandatory - pseudo-header fields is malformed. - - - HTTP/2 does not define a way to carry the version identifier that is included in the - HTTP/1.1 request line. - -
    - -
    - - For HTTP/2 responses, a single :status pseudo-header - field is defined that carries the HTTP status code field (see ). This pseudo-header field MUST be included in all - responses, otherwise the response is malformed. - - - HTTP/2 does not define a way to carry the version or reason phrase that is included in - an HTTP/1.1 status line. - -
    - -
    - - The Cookie header field can carry a significant amount of - redundant data. - - - The Cookie header field uses a semi-colon (";") to delimit cookie-pairs (or "crumbs"). - This header field doesn't follow the list construction rules in HTTP (see ), which prevents cookie-pairs from - being separated into different name-value pairs. This can significantly reduce - compression efficiency as individual cookie-pairs are updated. - - - To allow for better compression efficiency, the Cookie header field MAY be split into - separate header fields, each with one or more cookie-pairs. If there are multiple - Cookie header fields after decompression, these MUST be concatenated into a single - octet string using the two octet delimiter of 0x3B, 0x20 (the ASCII string "; ") - before being passed into a non-HTTP/2 context, such as an HTTP/1.1 connection, or a - generic HTTP server application. - -
    - - Therefore, the following two lists of Cookie header fields are semantically - equivalent. - - -
    -
    - -
    - - A malformed request or response is one that is an otherwise valid sequence of HTTP/2 - frames, but is otherwise invalid due to the presence of extraneous frames, prohibited - header fields, the absence of mandatory header fields, or the inclusion of uppercase - header field names. - - - A request or response that includes an entity body can include a content-length header field. A request or response is also - malformed if the value of a content-length header field - does not equal the sum of the DATA frame payload lengths that form the - body. A response that is defined to have no payload, as described in , can have a non-zero - content-length header field, even though no content is - included in DATA frames. - - - Intermediaries that process HTTP requests or responses (i.e., any intermediary not - acting as a tunnel) MUST NOT forward a malformed request or response. Malformed - requests or responses that are detected MUST be treated as a stream error of type PROTOCOL_ERROR. - - - For malformed requests, a server MAY send an HTTP response prior to closing or - resetting the stream. Clients MUST NOT accept a malformed response. Note that these - requirements are intended to protect against several types of common attacks against - HTTP; they are deliberately strict, because being permissive can expose - implementations to these vulnerabilities. - -
    -
    - -
    - - This section shows HTTP/1.1 requests and responses, with illustrations of equivalent - HTTP/2 requests and responses. - - - An HTTP GET request includes request header fields and no body and is therefore - transmitted as a single HEADERS frame, followed by zero or more - CONTINUATION frames containing the serialized block of request header - fields. The HEADERS frame in the following has both the END_HEADERS and - END_STREAM flags set; no CONTINUATION frames are sent: - - -
    - + END_STREAM - Accept: image/jpeg + END_HEADERS - :method = GET - :scheme = https - :path = /resource - host = example.org - accept = image/jpeg -]]> -
    - - - Similarly, a response that includes only response header fields is transmitted as a - HEADERS frame (again, followed by zero or more - CONTINUATION frames) containing the serialized block of response header - fields. - - -
    - + END_STREAM - Expires: Thu, 23 Jan ... + END_HEADERS - :status = 304 - etag = "xyzzy" - expires = Thu, 23 Jan ... -]]> -
    - - - An HTTP POST request that includes request header fields and payload data is transmitted - as one HEADERS frame, followed by zero or more - CONTINUATION frames containing the request header fields, followed by one - or more DATA frames, with the last CONTINUATION (or - HEADERS) frame having the END_HEADERS flag set and the final - DATA frame having the END_STREAM flag set: - - -
    - - END_STREAM - Content-Type: image/jpeg - END_HEADERS - Content-Length: 123 :method = POST - :path = /resource - {binary data} :scheme = https - - CONTINUATION - + END_HEADERS - content-type = image/jpeg - host = example.org - content-length = 123 - - DATA - + END_STREAM - {binary data} -]]> - - Note that data contributing to any given header field could be spread between header - block fragments. The allocation of header fields to frames in this example is - illustrative only. - -
    - - - A response that includes header fields and payload data is transmitted as a - HEADERS frame, followed by zero or more CONTINUATION - frames, followed by one or more DATA frames, with the last - DATA frame in the sequence having the END_STREAM flag set: - - -
    - - END_STREAM - Content-Length: 123 + END_HEADERS - :status = 200 - {binary data} content-type = image/jpeg - content-length = 123 - - DATA - + END_STREAM - {binary data} -]]> -
    - - - Trailing header fields are sent as a header block after both the request or response - header block and all the DATA frames have been sent. The - HEADERS frame starting the trailers header block has the END_STREAM flag - set. - - -
    - - END_STREAM - Transfer-Encoding: chunked + END_HEADERS - Trailer: Foo :status = 200 - content-length = 123 - 123 content-type = image/jpeg - {binary data} trailer = Foo - 0 - Foo: bar DATA - - END_STREAM - {binary data} - - HEADERS - + END_STREAM - + END_HEADERS - foo = bar -]]> -
    - - -
    - - An informational response using a 1xx status code other than 101 is transmitted as a - HEADERS frame, followed by zero or more CONTINUATION - frames: - - - END_STREAM - + END_HEADERS - :status = 103 - extension-field = bar -]]> -
    -
    - -
    - - In HTTP/1.1, an HTTP client is unable to retry a non-idempotent request when an error - occurs, because there is no means to determine the nature of the error. It is possible - that some server processing occurred prior to the error, which could result in - undesirable effects if the request were reattempted. - - - HTTP/2 provides two mechanisms for providing a guarantee to a client that a request has - not been processed: - - - The GOAWAY frame indicates the highest stream number that might have - been processed. Requests on streams with higher numbers are therefore guaranteed to - be safe to retry. - - - The REFUSED_STREAM error code can be included in a - RST_STREAM frame to indicate that the stream is being closed prior to - any processing having occurred. Any request that was sent on the reset stream can - be safely retried. - - - - - Requests that have not been processed have not failed; clients MAY automatically retry - them, even those with non-idempotent methods. - - - A server MUST NOT indicate that a stream has not been processed unless it can guarantee - that fact. If frames that are on a stream are passed to the application layer for any - stream, then REFUSED_STREAM MUST NOT be used for that stream, and a - GOAWAY frame MUST include a stream identifier that is greater than or - equal to the given stream identifier. - - - In addition to these mechanisms, the PING frame provides a way for a - client to easily test a connection. Connections that remain idle can become broken as - some middleboxes (for instance, network address translators, or load balancers) silently - discard connection bindings. The PING frame allows a client to safely - test whether a connection is still active without sending a request. - -
    -
    - -
    - - HTTP/2 allows a server to pre-emptively send (or "push") responses (along with - corresponding "promised" requests) to a client in association with a previous - client-initiated request. This can be useful when the server knows the client will need - to have those responses available in order to fully process the response to the original - request. - - - - Pushing additional message exchanges in this fashion is optional, and is negotiated - between individual endpoints. The SETTINGS_ENABLE_PUSH setting can be set - to 0 to indicate that server push is disabled. - - - Promised requests MUST be cacheable (see ), MUST be safe (see ) and MUST NOT include a request body. Clients that receive a - promised request that is not cacheable, unsafe or that includes a request body MUST - reset the stream with a stream error of type - PROTOCOL_ERROR. - - - Pushed responses that are cacheable (see ) can be stored by the client, if it implements a HTTP - cache. Pushed responses are considered successfully validated on the origin server (e.g., - if the "no-cache" cache response directive is present) while the stream identified by the - promised stream ID is still open. - - - Pushed responses that are not cacheable MUST NOT be stored by any HTTP cache. They MAY - be made available to the application separately. - - - An intermediary can receive pushes from the server and choose not to forward them on to - the client. In other words, how to make use of the pushed information is up to that - intermediary. Equally, the intermediary might choose to make additional pushes to the - client, without any action taken by the server. - - - A client cannot push. Thus, servers MUST treat the receipt of a - PUSH_PROMISE frame as a connection - error of type PROTOCOL_ERROR. Clients MUST reject any attempt to - change the SETTINGS_ENABLE_PUSH setting to a value other than 0 by treating - the message as a connection error of type - PROTOCOL_ERROR. - - -
    - - Server push is semantically equivalent to a server responding to a request; however, in - this case that request is also sent by the server, as a PUSH_PROMISE - frame. - - - The PUSH_PROMISE frame includes a header block that contains a complete - set of request header fields that the server attributes to the request. It is not - possible to push a response to a request that includes a request body. - - - - Pushed responses are always associated with an explicit request from the client. The - PUSH_PROMISE frames sent by the server are sent on that explicit - request's stream. The PUSH_PROMISE frame also includes a promised stream - identifier, chosen from the stream identifiers available to the server (see ). - - - - The header fields in PUSH_PROMISE and any subsequent - CONTINUATION frames MUST be a valid and complete set of request header fields. The server MUST include a method in - the :method header field that is safe and cacheable. If a - client receives a PUSH_PROMISE that does not include a complete and valid - set of header fields, or the :method header field identifies - a method that is not safe, it MUST respond with a stream error of type PROTOCOL_ERROR. - - - - The server SHOULD send PUSH_PROMISE () - frames prior to sending any frames that reference the promised responses. This avoids a - race where clients issue requests prior to receiving any PUSH_PROMISE - frames. - - - For example, if the server receives a request for a document containing embedded links - to multiple image files, and the server chooses to push those additional images to the - client, sending push promises before the DATA frames that contain the - image links ensures that the client is able to see the promises before discovering - embedded links. Similarly, if the server pushes responses referenced by the header block - (for instance, in Link header fields), sending the push promises before sending the - header block ensures that clients do not request them. - - - - PUSH_PROMISE frames MUST NOT be sent by the client. - - - PUSH_PROMISE frames can be sent by the server in response to any - client-initiated stream, but the stream MUST be in either the "open" or "half closed - (remote)" state with respect to the server. PUSH_PROMISE frames are - interspersed with the frames that comprise a response, though they cannot be - interspersed with HEADERS and CONTINUATION frames that - comprise a single header block. - - - Sending a PUSH_PROMISE frame creates a new stream and puts the stream - into the “reserved (local)†state for the server and the “reserved (remote)†state for - the client. - -
    - -
    - - After sending the PUSH_PROMISE frame, the server can begin delivering the - pushed response as a response on a server-initiated - stream that uses the promised stream identifier. The server uses this stream to - transmit an HTTP response, using the same sequence of frames as defined in . This stream becomes "half closed" - to the client after the initial HEADERS frame is sent. - - - - Once a client receives a PUSH_PROMISE frame and chooses to accept the - pushed response, the client SHOULD NOT issue any requests for the promised response - until after the promised stream has closed. - - - - If the client determines, for any reason, that it does not wish to receive the pushed - response from the server, or if the server takes too long to begin sending the promised - response, the client can send an RST_STREAM frame, using either the - CANCEL or REFUSED_STREAM codes, and referencing the pushed - stream's identifier. - - - A client can use the SETTINGS_MAX_CONCURRENT_STREAMS setting to limit the - number of responses that can be concurrently pushed by a server. Advertising a - SETTINGS_MAX_CONCURRENT_STREAMS value of zero disables server push by - preventing the server from creating the necessary streams. This does not prohibit a - server from sending PUSH_PROMISE frames; clients need to reset any - promised streams that are not wanted. - - - - Clients receiving a pushed response MUST validate that either the server is - authoritative (see ), or the proxy that provided the pushed - response is configured for the corresponding request. For example, a server that offers - a certificate for only the example.com DNS-ID or Common Name - is not permitted to push a response for https://www.example.org/doc. - - - The response for a PUSH_PROMISE stream begins with a - HEADERS frame, which immediately puts the stream into the “half closed - (remote)†state for the server and “half closed (local)†state for the client, and ends - with a frame bearing END_STREAM, which places the stream in the "closed" state. - - - The client never sends a frame with the END_STREAM flag for a server push. - - - -
    - -
    - -
    - - In HTTP/1.x, the pseudo-method CONNECT () is used to convert an HTTP connection into a tunnel to a remote host. - CONNECT is primarily used with HTTP proxies to establish a TLS session with an origin - server for the purposes of interacting with https resources. - - - In HTTP/2, the CONNECT method is used to establish a tunnel over a single HTTP/2 stream to - a remote host, for similar purposes. The HTTP header field mapping works as defined in - Request Header Fields, with a few - differences. Specifically: - - - The :method header field is set to CONNECT. - - - The :scheme and :path header - fields MUST be omitted. - - - The :authority header field contains the host and port to - connect to (equivalent to the authority-form of the request-target of CONNECT - requests, see ). - - - - - A proxy that supports CONNECT establishes a TCP connection to - the server identified in the :authority header field. Once - this connection is successfully established, the proxy sends a HEADERS - frame containing a 2xx series status code to the client, as defined in . - - - After the initial HEADERS frame sent by each peer, all subsequent - DATA frames correspond to data sent on the TCP connection. The payload of - any DATA frames sent by the client is transmitted by the proxy to the TCP - server; data received from the TCP server is assembled into DATA frames by - the proxy. Frame types other than DATA or stream management frames - (RST_STREAM, WINDOW_UPDATE, and PRIORITY) - MUST NOT be sent on a connected stream, and MUST be treated as a stream error if received. - - - The TCP connection can be closed by either peer. The END_STREAM flag on a - DATA frame is treated as being equivalent to the TCP FIN bit. A client is - expected to send a DATA frame with the END_STREAM flag set after receiving - a frame bearing the END_STREAM flag. A proxy that receives a DATA frame - with the END_STREAM flag set sends the attached data with the FIN bit set on the last TCP - segment. A proxy that receives a TCP segment with the FIN bit set sends a - DATA frame with the END_STREAM flag set. Note that the final TCP segment - or DATA frame could be empty. - - - A TCP connection error is signaled with RST_STREAM. A proxy treats any - error in the TCP connection, which includes receiving a TCP segment with the RST bit set, - as a stream error of type - CONNECT_ERROR. Correspondingly, a proxy MUST send a TCP segment with the - RST bit set if it detects an error with the stream or the HTTP/2 connection. - -
    -
    - -
    - - This section outlines attributes of the HTTP protocol that improve interoperability, reduce - exposure to known security vulnerabilities, or reduce the potential for implementation - variation. - - -
    - - HTTP/2 connections are persistent. For best performance, it is expected clients will not - close connections until it is determined that no further communication with a server is - necessary (for example, when a user navigates away from a particular web page), or until - the server closes the connection. - - - Clients SHOULD NOT open more than one HTTP/2 connection to a given host and port pair, - where host is derived from a URI, a selected alternative - service, or a configured proxy. - - - A client can create additional connections as replacements, either to replace connections - that are near to exhausting the available stream - identifier space, to refresh the keying material for a TLS connection, or to - replace connections that have encountered errors. - - - A client MAY open multiple connections to the same IP address and TCP port using different - Server Name Indication values or to provide different TLS - client certificates, but SHOULD avoid creating multiple connections with the same - configuration. - - - Servers are encouraged to maintain open connections for as long as possible, but are - permitted to terminate idle connections if necessary. When either endpoint chooses to - close the transport-layer TCP connection, the terminating endpoint SHOULD first send a - GOAWAY () frame so that both endpoints can reliably - determine whether previously sent frames have been processed and gracefully complete or - terminate any necessary remaining tasks. - - -
    - - Connections that are made to an origin servers, either directly or through a tunnel - created using the CONNECT method MAY be reused for - requests with multiple different URI authority components. A connection can be reused - as long as the origin server is authoritative. For - http resources, this depends on the host having resolved to - the same IP address. - - - For https resources, connection reuse additionally depends - on having a certificate that is valid for the host in the URI. An origin server might - offer a certificate with multiple subjectAltName attributes, - or names with wildcards, one of which is valid for the authority in the URI. For - example, a certificate with a subjectAltName of *.example.com might permit the use of the same connection for - requests to URIs starting with https://a.example.com/ and - https://b.example.com/. - - - In some deployments, reusing a connection for multiple origins can result in requests - being directed to the wrong origin server. For example, TLS termination might be - performed by a middlebox that uses the TLS Server Name Indication - (SNI) extension to select an origin server. This means that it is possible - for clients to send confidential information to servers that might not be the intended - target for the request, even though the server is otherwise authoritative. - - - A server that does not wish clients to reuse connections can indicate that it is not - authoritative for a request by sending a 421 (Misdirected Request) status code in response - to the request (see ). - - - A client that is configured to use a proxy over HTTP/2 directs requests to that proxy - through a single connection. That is, all requests sent via a proxy reuse the - connection to the proxy. - -
    - -
    - - The 421 (Misdirected Request) status code indicates that the request was directed at a - server that is not able to produce a response. This can be sent by a server that is not - configured to produce responses for the combination of scheme and authority that are - included in the request URI. - - - Clients receiving a 421 (Misdirected Request) response from a server MAY retry the - request - whether the request method is idempotent or not - over a different connection. - This is possible if a connection is reused () or if an alternative - service is selected (). - - - This status code MUST NOT be generated by proxies. - - - A 421 response is cacheable by default; i.e., unless otherwise indicated by the method - definition or explicit cache controls (see ). - -
    -
    - -
    - - Implementations of HTTP/2 MUST support TLS 1.2 for HTTP/2 over - TLS. The general TLS usage guidance in SHOULD be followed, with - some additional restrictions that are specific to HTTP/2. - - - - An implementation of HTTP/2 over TLS MUST use TLS 1.2 or higher with the restrictions on - feature set and cipher suite described in this section. Due to implementation - limitations, it might not be possible to fail TLS negotiation. An endpoint MUST - immediately terminate an HTTP/2 connection that does not meet these minimum requirements - with a connection error of type - INADEQUATE_SECURITY. - - -
    - - The TLS implementation MUST support the Server Name Indication - (SNI) extension to TLS. HTTP/2 clients MUST indicate the target domain name when - negotiating TLS. - - - The TLS implementation MUST disable compression. TLS compression can lead to the - exposure of information that would not otherwise be revealed . - Generic compression is unnecessary since HTTP/2 provides compression features that are - more aware of context and therefore likely to be more appropriate for use for - performance, security or other reasons. - - - The TLS implementation MUST disable renegotiation. An endpoint MUST treat a TLS - renegotiation as a connection error of type - PROTOCOL_ERROR. Note that disabling renegotiation can result in - long-lived connections becoming unusable due to limits on the number of messages the - underlying cipher suite can encipher. - - - A client MAY use renegotiation to provide confidentiality protection for client - credentials offered in the handshake, but any renegotiation MUST occur prior to sending - the connection preface. A server SHOULD request a client certificate if it sees a - renegotiation request immediately after establishing a connection. - - - This effectively prevents the use of renegotiation in response to a request for a - specific protected resource. A future specification might provide a way to support this - use case. - -
    - -
    - - The set of TLS cipher suites that are permitted in HTTP/2 is restricted. HTTP/2 MUST - only be used with cipher suites that have ephemeral key exchange, such as the ephemeral Diffie-Hellman (DHE) or the elliptic curve variant (ECDHE). Ephemeral key exchange MUST - have a minimum size of 2048 bits for DHE or security level of 128 bits for ECDHE. - Clients MUST accept DHE sizes of up to 4096 bits. HTTP MUST NOT be used with cipher - suites that use stream or block ciphers. Authenticated Encryption with Additional Data - (AEAD) modes, such as the Galois Counter Model (GCM) mode for - AES are acceptable. - - - The effect of these restrictions is that TLS 1.2 implementations could have - non-intersecting sets of available cipher suites, since these prevent the use of the - cipher suite that TLS 1.2 makes mandatory. To avoid this problem, implementations of - HTTP/2 that use TLS 1.2 MUST support TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 with P256 . - - - Clients MAY advertise support of cipher suites that are prohibited by the above - restrictions in order to allow for connection to servers that do not support HTTP/2. - This enables a fallback to protocols without these constraints without the additional - latency imposed by using a separate connection for fallback. - -
    -
    -
    - -
    -
    - - HTTP/2 relies on the HTTP/1.1 definition of authority for determining whether a server is - authoritative in providing a given response, see . This relies on local name resolution for the "http" - URI scheme, and the authenticated server identity for the "https" scheme (see ). - -
    - -
    - - In a cross-protocol attack, an attacker causes a client to initiate a transaction in one - protocol toward a server that understands a different protocol. An attacker might be able - to cause the transaction to appear as valid transaction in the second protocol. In - combination with the capabilities of the web context, this can be used to interact with - poorly protected servers in private networks. - - - Completing a TLS handshake with an ALPN identifier for HTTP/2 can be considered sufficient - protection against cross protocol attacks. ALPN provides a positive indication that a - server is willing to proceed with HTTP/2, which prevents attacks on other TLS-based - protocols. - - - The encryption in TLS makes it difficult for attackers to control the data which could be - used in a cross-protocol attack on a cleartext protocol. - - - The cleartext version of HTTP/2 has minimal protection against cross-protocol attacks. - The connection preface contains a string that is - designed to confuse HTTP/1.1 servers, but no special protection is offered for other - protocols. A server that is willing to ignore parts of an HTTP/1.1 request containing an - Upgrade header field in addition to the client connection preface could be exposed to a - cross-protocol attack. - -
    - -
    - - HTTP/2 header field names and values are encoded as sequences of octets with a length - prefix. This enables HTTP/2 to carry any string of octets as the name or value of a - header field. An intermediary that translates HTTP/2 requests or responses into HTTP/1.1 - directly could permit the creation of corrupted HTTP/1.1 messages. An attacker might - exploit this behavior to cause the intermediary to create HTTP/1.1 messages with illegal - header fields, extra header fields, or even new messages that are entirely falsified. - - - Header field names or values that contain characters not permitted by HTTP/1.1, including - carriage return (ASCII 0xd) or line feed (ASCII 0xa) MUST NOT be translated verbatim by an - intermediary, as stipulated in . - - - Translation from HTTP/1.x to HTTP/2 does not produce the same opportunity to an attacker. - Intermediaries that perform translation to HTTP/2 MUST remove any instances of the obs-fold production from header field values. - -
    - -
    - - Pushed responses do not have an explicit request from the client; the request - is provided by the server in the PUSH_PROMISE frame. - - - Caching responses that are pushed is possible based on the guidance provided by the origin - server in the Cache-Control header field. However, this can cause issues if a single - server hosts more than one tenant. For example, a server might offer multiple users each - a small portion of its URI space. - - - Where multiple tenants share space on the same server, that server MUST ensure that - tenants are not able to push representations of resources that they do not have authority - over. Failure to enforce this would allow a tenant to provide a representation that would - be served out of cache, overriding the actual representation that the authoritative tenant - provides. - - - Pushed responses for which an origin server is not authoritative (see - ) are never cached or used. - -
    - -
    - - An HTTP/2 connection can demand a greater commitment of resources to operate than a - HTTP/1.1 connection. The use of header compression and flow control depend on a - commitment of resources for storing a greater amount of state. Settings for these - features ensure that memory commitments for these features are strictly bounded. - - - The number of PUSH_PROMISE frames is not constrained in the same fashion. - A client that accepts server push SHOULD limit the number of streams it allows to be in - the "reserved (remote)" state. Excessive number of server push streams can be treated as - a stream error of type - ENHANCE_YOUR_CALM. - - - Processing capacity cannot be guarded as effectively as state capacity. - - - The SETTINGS frame can be abused to cause a peer to expend additional - processing time. This might be done by pointlessly changing SETTINGS parameters, setting - multiple undefined parameters, or changing the same setting multiple times in the same - frame. WINDOW_UPDATE or PRIORITY frames can be abused to - cause an unnecessary waste of resources. - - - Large numbers of small or empty frames can be abused to cause a peer to expend time - processing frame headers. Note however that some uses are entirely legitimate, such as - the sending of an empty DATA frame to end a stream. - - - Header compression also offers some opportunities to waste processing resources; see for more details on potential abuses. - - - Limits in SETTINGS parameters cannot be reduced instantaneously, which - leaves an endpoint exposed to behavior from a peer that could exceed the new limits. In - particular, immediately after establishing a connection, limits set by a server are not - known to clients and could be exceeded without being an obvious protocol violation. - - - All these features - i.e., SETTINGS changes, small frames, header - compression - have legitimate uses. These features become a burden only when they are - used unnecessarily or to excess. - - - An endpoint that doesn't monitor this behavior exposes itself to a risk of denial of - service attack. Implementations SHOULD track the use of these features and set limits on - their use. An endpoint MAY treat activity that is suspicious as a connection error of type - ENHANCE_YOUR_CALM. - - -
    - - A large header block can cause an implementation to - commit a large amount of state. Header fields that are critical for routing can appear - toward the end of a header block, which prevents streaming of header fields to their - ultimate destination. For this an other reasons, such as ensuring cache correctness, - means that an endpoint might need to buffer the entire header block. Since there is no - hard limit to the size of a header block, some endpoints could be forced commit a large - amount of available memory for header fields. - - - An endpoint can use the SETTINGS_MAX_HEADER_LIST_SIZE to advise peers of - limits that might apply on the size of header blocks. This setting is only advisory, so - endpoints MAY choose to send header blocks that exceed this limit and risk having the - request or response being treated as malformed. This setting specific to a connection, - so any request or response could encounter a hop with a lower, unknown limit. An - intermediary can attempt to avoid this problem by passing on values presented by - different peers, but they are not obligated to do so. - - - A server that receives a larger header block than it is willing to handle can send an - HTTP 431 (Request Header Fields Too Large) status code . A - client can discard responses that it cannot process. The header block MUST be processed - to ensure a consistent connection state, unless the connection is closed. - -
    -
    - -
    - - HTTP/2 enables greater use of compression for both header fields () and entity bodies. Compression can allow an attacker to recover - secret data when it is compressed in the same context as data under attacker control. - - - There are demonstrable attacks on compression that exploit the characteristics of the web - (e.g., ). The attacker induces multiple requests containing - varying plaintext, observing the length of the resulting ciphertext in each, which - reveals a shorter length when a guess about the secret is correct. - - - Implementations communicating on a secure channel MUST NOT compress content that includes - both confidential and attacker-controlled data unless separate compression dictionaries - are used for each source of data. Compression MUST NOT be used if the source of data - cannot be reliably determined. Generic stream compression, such as that provided by TLS - MUST NOT be used with HTTP/2 (). - - - Further considerations regarding the compression of header fields are described in . - -
    - -
    - - Padding within HTTP/2 is not intended as a replacement for general purpose padding, such - as might be provided by TLS. Redundant padding could even be - counterproductive. Correct application can depend on having specific knowledge of the - data that is being padded. - - - To mitigate attacks that rely on compression, disabling or limiting compression might be - preferable to padding as a countermeasure. - - - Padding can be used to obscure the exact size of frame content, and is provided to - mitigate specific attacks within HTTP. For example, attacks where compressed content - includes both attacker-controlled plaintext and secret data (see for example, ). - - - Use of padding can result in less protection than might seem immediately obvious. At - best, padding only makes it more difficult for an attacker to infer length information by - increasing the number of frames an attacker has to observe. Incorrectly implemented - padding schemes can be easily defeated. In particular, randomized padding with a - predictable distribution provides very little protection; similarly, padding payloads to a - fixed size exposes information as payload sizes cross the fixed size boundary, which could - be possible if an attacker can control plaintext. - - - Intermediaries SHOULD retain padding for DATA frames, but MAY drop padding - for HEADERS and PUSH_PROMISE frames. A valid reason for an - intermediary to change the amount of padding of frames is to improve the protections that - padding provides. - -
    - -
    - - Several characteristics of HTTP/2 provide an observer an opportunity to correlate actions - of a single client or server over time. This includes the value of settings, the manner - in which flow control windows are managed, the way priorities are allocated to streams, - timing of reactions to stimulus, and handling of any optional features. - - - As far as this creates observable differences in behavior, they could be used as a basis - for fingerprinting a specific client, as defined in . - -
    -
    - -
    - - A string for identifying HTTP/2 is entered into the "Application Layer Protocol Negotiation - (ALPN) Protocol IDs" registry established in . - - - This document establishes a registry for frame types, settings, and error codes. These new - registries are entered into a new "Hypertext Transfer Protocol (HTTP) 2 Parameters" section. - - - This document registers the HTTP2-Settings header field for - use in HTTP; and the 421 (Misdirected Request) status code. - - - This document registers the PRI method for use in HTTP, to avoid - collisions with the connection preface. - - -
    - - This document creates two registrations for the identification of HTTP/2 in the - "Application Layer Protocol Negotiation (ALPN) Protocol IDs" registry established in . - - - The "h2" string identifies HTTP/2 when used over TLS: - - HTTP/2 over TLS - 0x68 0x32 ("h2") - This document - - - - The "h2c" string identifies HTTP/2 when used over cleartext TCP: - - HTTP/2 over TCP - 0x68 0x32 0x63 ("h2c") - This document - - -
    - -
    - - This document establishes a registry for HTTP/2 frame type codes. The "HTTP/2 Frame - Type" registry manages an 8-bit space. The "HTTP/2 Frame Type" registry operates under - either of the "IETF Review" or "IESG Approval" policies for - values between 0x00 and 0xef, with values between 0xf0 and 0xff being reserved for - experimental use. - - - New entries in this registry require the following information: - - - A name or label for the frame type. - - - The 8-bit code assigned to the frame type. - - - A reference to a specification that includes a description of the frame layout, - it's semantics and flags that the frame type uses, including any parts of the frame - that are conditionally present based on the value of flags. - - - - - The entries in the following table are registered by this document. - - - Frame Type - Code - Section - DATA0x0 - HEADERS0x1 - PRIORITY0x2 - RST_STREAM0x3 - SETTINGS0x4 - PUSH_PROMISE0x5 - PING0x6 - GOAWAY0x7 - WINDOW_UPDATE0x8 - CONTINUATION0x9 - -
    - -
    - - This document establishes a registry for HTTP/2 settings. The "HTTP/2 Settings" registry - manages a 16-bit space. The "HTTP/2 Settings" registry operates under the "Expert Review" policy for values in the range from 0x0000 to - 0xefff, with values between and 0xf000 and 0xffff being reserved for experimental use. - - - New registrations are advised to provide the following information: - - - A symbolic name for the setting. Specifying a setting name is optional. - - - The 16-bit code assigned to the setting. - - - An initial value for the setting. - - - An optional reference to a specification that describes the use of the setting. - - - - - An initial set of setting registrations can be found in . - - - Name - Code - Initial Value - Specification - HEADER_TABLE_SIZE - 0x14096 - ENABLE_PUSH - 0x21 - MAX_CONCURRENT_STREAMS - 0x3(infinite) - INITIAL_WINDOW_SIZE - 0x465535 - MAX_FRAME_SIZE - 0x516384 - MAX_HEADER_LIST_SIZE - 0x6(infinite) - - -
    - -
    - - This document establishes a registry for HTTP/2 error codes. The "HTTP/2 Error Code" - registry manages a 32-bit space. The "HTTP/2 Error Code" registry operates under the - "Expert Review" policy. - - - Registrations for error codes are required to include a description of the error code. An - expert reviewer is advised to examine new registrations for possible duplication with - existing error codes. Use of existing registrations is to be encouraged, but not - mandated. - - - New registrations are advised to provide the following information: - - - A name for the error code. Specifying an error code name is optional. - - - The 32-bit error code value. - - - A brief description of the error code semantics, longer if no detailed specification - is provided. - - - An optional reference for a specification that defines the error code. - - - - - The entries in the following table are registered by this document. - - - Name - Code - Description - Specification - NO_ERROR0x0 - Graceful shutdown - - PROTOCOL_ERROR0x1 - Protocol error detected - - INTERNAL_ERROR0x2 - Implementation fault - - FLOW_CONTROL_ERROR0x3 - Flow control limits exceeded - - SETTINGS_TIMEOUT0x4 - Settings not acknowledged - - STREAM_CLOSED0x5 - Frame received for closed stream - - FRAME_SIZE_ERROR0x6 - Frame size incorrect - - REFUSED_STREAM0x7 - Stream not processed - - CANCEL0x8 - Stream cancelled - - COMPRESSION_ERROR0x9 - Compression state not updated - - CONNECT_ERROR0xa - TCP connection error for CONNECT method - - ENHANCE_YOUR_CALM0xb - Processing capacity exceeded - - INADEQUATE_SECURITY0xc - Negotiated TLS parameters not acceptable - - - -
    - -
    - - This section registers the HTTP2-Settings header field in the - Permanent Message Header Field Registry. - - - HTTP2-Settings - - - http - - - standard - - - IETF - - - of this document - - - This header field is only used by an HTTP/2 client for Upgrade-based negotiation. - - - -
    - -
    - - This section registers the PRI method in the HTTP Method - Registry (). - - - PRI - - - No - - - No - - - of this document - - - This method is never used by an actual client. This method will appear to be used - when an HTTP/1.1 server or intermediary attempts to parse an HTTP/2 connection - preface. - - - -
    - -
    - - This document registers the 421 (Misdirected Request) HTTP Status code in the Hypertext - Transfer Protocol (HTTP) Status Code Registry (). - - - - - 421 - - - Misdirected Request - - - of this document - - - -
    - -
    - -
    - - This document includes substantial input from the following individuals: - - - Adam Langley, Wan-Teh Chang, Jim Morrison, Mark Nottingham, Alyssa Wilk, Costin - Manolache, William Chan, Vitaliy Lvin, Joe Chan, Adam Barth, Ryan Hamilton, Gavin - Peters, Kent Alstad, Kevin Lindsay, Paul Amer, Fan Yang, Jonathan Leighton (SPDY - contributors). - - - Gabriel Montenegro and Willy Tarreau (Upgrade mechanism). - - - William Chan, Salvatore Loreto, Osama Mazahir, Gabriel Montenegro, Jitu Padhye, Roberto - Peon, Rob Trace (Flow control). - - - Mike Bishop (Extensibility). - - - Mark Nottingham, Julian Reschke, James Snell, Jeff Pinner, Mike Bishop, Herve Ruellan - (Substantial editorial contributions). - - - Kari Hurtta, Tatsuhiro Tsujikawa, Greg Wilkins, Poul-Henning Kamp. - - - Alexey Melnikov was an editor of this document during 2013. - - - A substantial proportion of Martin's contribution was supported by Microsoft during his - employment there. - - - -
    -
    - - - - - - HPACK - Header Compression for HTTP/2 - - - - - - - - - - - - Transmission Control Protocol - - - University of Southern California (USC)/Information Sciences - Institute - - - - - - - - - - - Key words for use in RFCs to Indicate Requirement Levels - - - Harvard University -
    sob@harvard.edu
    -
    - -
    - - -
    - - - - - HTTP Over TLS - - - - - - - - - - Uniform Resource Identifier (URI): Generic - Syntax - - - - - - - - - - - - The Base16, Base32, and Base64 Data Encodings - - - - - - - - - Guidelines for Writing an IANA Considerations Section in RFCs - - - - - - - - - - - Augmented BNF for Syntax Specifications: ABNF - - - - - - - - - - - The Transport Layer Security (TLS) Protocol Version 1.2 - - - - - - - - - - - Transport Layer Security (TLS) Extensions: Extension Definitions - - - - - - - - - - Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension - - - - - - - - - - - - - TLS Elliptic Curve Cipher Suites with SHA-256/384 and AES Galois - Counter Mode (GCM) - - - - - - - - - - - Digital Signature Standard (DSS) - - NIST - - - - - - - - - Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - - Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Range Requests - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - World Wide Web Consortium -
    ylafon@w3.org
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Caching - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - Akamai -
    mnot@mnot.net
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - Hypertext Transfer Protocol (HTTP/1.1): Authentication - - Adobe Systems Incorporated -
    fielding@gbiv.com
    -
    - - greenbytes GmbH -
    julian.reschke@greenbytes.de
    -
    - -
    - - -
    - - - - HTTP State Management Mechanism - - - - - -
    - - - - - - TCP Extensions for High Performance - - - - - - - - - - - - Transport Layer Security Protocol Compression Methods - - - - - - - - - Additional HTTP Status Codes - - - - - - - - - - - Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer Security (TLS) - - - - - - - - - - - - - - - AES Galois Counter Mode (GCM) Cipher Suites for TLS - - - - - - - - - - - - HTML5 - - - - - - - - - - - Latest version available at - . - - - - - - - Talking to Yourself for Fun and Profit - - - - - - - - - - - - - - BREACH: Reviving the CRIME Attack - - - - - - - - - - - Registration Procedures for Message Header Fields - - Nine by Nine -
    GK-IETF@ninebynine.org
    -
    - - BEA Systems -
    mnot@pobox.com
    -
    - - HP Labs -
    JeffMogul@acm.org
    -
    - -
    - - -
    - - - - Recommendations for Secure Use of TLS and DTLS - - - - - - - - - - - - - - - - - - HTTP Alternative Services - - - Akamai - - - Mozilla - - - greenbytes - - - - - - -
    - -
    - - This section is to be removed by RFC Editor before publication. - - -
    - - Renamed Not Authoritative status code to Misdirected Request. - -
    - -
    - - Pseudo-header fields are now required to appear strictly before regular ones. - - - Restored 1xx series status codes, except 101. - - - Changed frame length field 24-bits. Expanded frame header to 9 octets. Added a setting - to limit the damage. - - - Added a setting to advise peers of header set size limits. - - - Removed segments. - - - Made non-semantic-bearing HEADERS frames illegal in the HTTP mapping. - -
    - -
    - - Restored extensibility options. - - - Restricting TLS cipher suites to AEAD only. - - - Removing Content-Encoding requirements. - - - Permitting the use of PRIORITY after stream close. - - - Removed ALTSVC frame. - - - Removed BLOCKED frame. - - - Reducing the maximum padding size to 256 octets; removing padding from - CONTINUATION frames. - - - Removed per-frame GZIP compression. - -
    - -
    - - Added BLOCKED frame (at risk). - - - Simplified priority scheme. - - - Added DATA per-frame GZIP compression. - -
    - -
    - - Changed "connection header" to "connection preface" to avoid confusion. - - - Added dependency-based stream prioritization. - - - Added "h2c" identifier to distinguish between cleartext and secured HTTP/2. - - - Adding missing padding to PUSH_PROMISE. - - - Integrate ALTSVC frame and supporting text. - - - Dropping requirement on "deflate" Content-Encoding. - - - Improving security considerations around use of compression. - -
    - -
    - - Adding padding for data frames. - - - Renumbering frame types, error codes, and settings. - - - Adding INADEQUATE_SECURITY error code. - - - Updating TLS usage requirements to 1.2; forbidding TLS compression. - - - Removing extensibility for frames and settings. - - - Changing setting identifier size. - - - Removing the ability to disable flow control. - - - Changing the protocol identification token to "h2". - - - Changing the use of :authority to make it optional and to allow userinfo in non-HTTP - cases. - - - Allowing split on 0x0 for Cookie. - - - Reserved PRI method in HTTP/1.1 to avoid possible future collisions. - -
    - -
    - - Added cookie crumbling for more efficient header compression. - - - Added header field ordering with the value-concatenation mechanism. - -
    - -
    - - Marked draft for implementation. - -
    - -
    - - Adding definition for CONNECT method. - - - Constraining the use of push to safe, cacheable methods with no request body. - - - Changing from :host to :authority to remove any potential confusion. - - - Adding setting for header compression table size. - - - Adding settings acknowledgement. - - - Removing unnecessary and potentially problematic flags from CONTINUATION. - - - Added denial of service considerations. - -
    -
    - - Marking the draft ready for implementation. - - - Renumbering END_PUSH_PROMISE flag. - - - Editorial clarifications and changes. - -
    - -
    - - Added CONTINUATION frame for HEADERS and PUSH_PROMISE. - - - PUSH_PROMISE is no longer implicitly prohibited if SETTINGS_MAX_CONCURRENT_STREAMS is - zero. - - - Push expanded to allow all safe methods without a request body. - - - Clarified the use of HTTP header fields in requests and responses. Prohibited HTTP/1.1 - hop-by-hop header fields. - - - Requiring that intermediaries not forward requests with missing or illegal routing - :-headers. - - - Clarified requirements around handling different frames after stream close, stream reset - and GOAWAY. - - - Added more specific prohibitions for sending of different frame types in various stream - states. - - - Making the last received setting value the effective value. - - - Clarified requirements on TLS version, extension and ciphers. - -
    - -
    - - Committed major restructuring atrocities. - - - Added reference to first header compression draft. - - - Added more formal description of frame lifecycle. - - - Moved END_STREAM (renamed from FINAL) back to HEADERS/DATA. - - - Removed HEADERS+PRIORITY, added optional priority to HEADERS frame. - - - Added PRIORITY frame. - -
    - -
    - - Added continuations to frames carrying header blocks. - - - Replaced use of "session" with "connection" to avoid confusion with other HTTP stateful - concepts, like cookies. - - - Removed "message". - - - Switched to TLS ALPN from NPN. - - - Editorial changes. - -
    - -
    - - Added IANA considerations section for frame types, error codes and settings. - - - Removed data frame compression. - - - Added PUSH_PROMISE. - - - Added globally applicable flags to framing. - - - Removed zlib-based header compression mechanism. - - - Updated references. - - - Clarified stream identifier reuse. - - - Removed CREDENTIALS frame and associated mechanisms. - - - Added advice against naive implementation of flow control. - - - Added session header section. - - - Restructured frame header. Removed distinction between data and control frames. - - - Altered flow control properties to include session-level limits. - - - Added note on cacheability of pushed resources and multiple tenant servers. - - - Changed protocol label form based on discussions. - -
    - -
    - - Changed title throughout. - - - Removed section on Incompatibilities with SPDY draft#2. - - - Changed INTERNAL_ERROR on GOAWAY to have a value of 2 . - - - Replaced abstract and introduction. - - - Added section on starting HTTP/2.0, including upgrade mechanism. - - - Removed unused references. - - - Added flow control principles based on . - -
    - -
    - - Adopted as base for draft-ietf-httpbis-http2. - - - Updated authors/editors list. - - - Added status note. - -
    -
    - -
    -
    - diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go deleted file mode 100644 index 060471e..0000000 --- a/vendor/golang.org/x/net/http2/transport.go +++ /dev/null @@ -1,1832 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Transport code. - -package http2 - -import ( - "bufio" - "bytes" - "compress/gzip" - "crypto/tls" - "errors" - "fmt" - "io" - "io/ioutil" - "log" - "net" - "net/http" - "sort" - "strconv" - "strings" - "sync" - "time" - - "golang.org/x/net/http2/hpack" - "golang.org/x/net/lex/httplex" -) - -const ( - // transportDefaultConnFlow is how many connection-level flow control - // tokens we give the server at start-up, past the default 64k. - transportDefaultConnFlow = 1 << 30 - - // transportDefaultStreamFlow is how many stream-level flow - // control tokens we announce to the peer, and how many bytes - // we buffer per stream. - transportDefaultStreamFlow = 4 << 20 - - // transportDefaultStreamMinRefresh is the minimum number of bytes we'll send - // a stream-level WINDOW_UPDATE for at a time. - transportDefaultStreamMinRefresh = 4 << 10 - - defaultUserAgent = "Go-http-client/2.0" -) - -// Transport is an HTTP/2 Transport. -// -// A Transport internally caches connections to servers. It is safe -// for concurrent use by multiple goroutines. -type Transport struct { - // DialTLS specifies an optional dial function for creating - // TLS connections for requests. - // - // If DialTLS is nil, tls.Dial is used. - // - // If the returned net.Conn has a ConnectionState method like tls.Conn, - // it will be used to set http.Response.TLS. - DialTLS func(network, addr string, cfg *tls.Config) (net.Conn, error) - - // TLSClientConfig specifies the TLS configuration to use with - // tls.Client. If nil, the default configuration is used. - TLSClientConfig *tls.Config - - // ConnPool optionally specifies an alternate connection pool to use. - // If nil, the default is used. - ConnPool ClientConnPool - - // DisableCompression, if true, prevents the Transport from - // requesting compression with an "Accept-Encoding: gzip" - // request header when the Request contains no existing - // Accept-Encoding value. If the Transport requests gzip on - // its own and gets a gzipped response, it's transparently - // decoded in the Response.Body. However, if the user - // explicitly requested gzip it is not automatically - // uncompressed. - DisableCompression bool - - // AllowHTTP, if true, permits HTTP/2 requests using the insecure, - // plain-text "http" scheme. Note that this does not enable h2c support. - AllowHTTP bool - - // MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to - // send in the initial settings frame. It is how many bytes - // of response headers are allow. Unlike the http2 spec, zero here - // means to use a default limit (currently 10MB). If you actually - // want to advertise an ulimited value to the peer, Transport - // interprets the highest possible value here (0xffffffff or 1<<32-1) - // to mean no limit. - MaxHeaderListSize uint32 - - // t1, if non-nil, is the standard library Transport using - // this transport. Its settings are used (but not its - // RoundTrip method, etc). - t1 *http.Transport - - connPoolOnce sync.Once - connPoolOrDef ClientConnPool // non-nil version of ConnPool -} - -func (t *Transport) maxHeaderListSize() uint32 { - if t.MaxHeaderListSize == 0 { - return 10 << 20 - } - if t.MaxHeaderListSize == 0xffffffff { - return 0 - } - return t.MaxHeaderListSize -} - -func (t *Transport) disableCompression() bool { - return t.DisableCompression || (t.t1 != nil && t.t1.DisableCompression) -} - -var errTransportVersion = errors.New("http2: ConfigureTransport is only supported starting at Go 1.6") - -// ConfigureTransport configures a net/http HTTP/1 Transport to use HTTP/2. -// It requires Go 1.6 or later and returns an error if the net/http package is too old -// or if t1 has already been HTTP/2-enabled. -func ConfigureTransport(t1 *http.Transport) error { - _, err := configureTransport(t1) // in configure_transport.go (go1.6) or not_go16.go - return err -} - -func (t *Transport) connPool() ClientConnPool { - t.connPoolOnce.Do(t.initConnPool) - return t.connPoolOrDef -} - -func (t *Transport) initConnPool() { - if t.ConnPool != nil { - t.connPoolOrDef = t.ConnPool - } else { - t.connPoolOrDef = &clientConnPool{t: t} - } -} - -// ClientConn is the state of a single HTTP/2 client connection to an -// HTTP/2 server. -type ClientConn struct { - t *Transport - tconn net.Conn // usually *tls.Conn, except specialized impls - tlsState *tls.ConnectionState // nil only for specialized impls - - // readLoop goroutine fields: - readerDone chan struct{} // closed on error - readerErr error // set before readerDone is closed - - mu sync.Mutex // guards following - cond *sync.Cond // hold mu; broadcast on flow/closed changes - flow flow // our conn-level flow control quota (cs.flow is per stream) - inflow flow // peer's conn-level flow control - closed bool - goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received - streams map[uint32]*clientStream // client-initiated - nextStreamID uint32 - bw *bufio.Writer - br *bufio.Reader - fr *Framer - lastActive time.Time - - // Settings from peer: - maxFrameSize uint32 - maxConcurrentStreams uint32 - initialWindowSize uint32 - hbuf bytes.Buffer // HPACK encoder writes into this - henc *hpack.Encoder - freeBuf [][]byte - - wmu sync.Mutex // held while writing; acquire AFTER mu if holding both - werr error // first write error that has occurred -} - -// clientStream is the state for a single HTTP/2 stream. One of these -// is created for each Transport.RoundTrip call. -type clientStream struct { - cc *ClientConn - req *http.Request - trace *clientTrace // or nil - ID uint32 - resc chan resAndError - bufPipe pipe // buffered pipe with the flow-controlled response payload - requestedGzip bool - on100 func() // optional code to run if get a 100 continue response - - flow flow // guarded by cc.mu - inflow flow // guarded by cc.mu - bytesRemain int64 // -1 means unknown; owned by transportResponseBody.Read - readErr error // sticky read error; owned by transportResponseBody.Read - stopReqBody error // if non-nil, stop writing req body; guarded by cc.mu - - peerReset chan struct{} // closed on peer reset - resetErr error // populated before peerReset is closed - - done chan struct{} // closed when stream remove from cc.streams map; close calls guarded by cc.mu - - // owned by clientConnReadLoop: - firstByte bool // got the first response byte - pastHeaders bool // got first MetaHeadersFrame (actual headers) - pastTrailers bool // got optional second MetaHeadersFrame (trailers) - - trailer http.Header // accumulated trailers - resTrailer *http.Header // client's Response.Trailer -} - -// awaitRequestCancel runs in its own goroutine and waits for the user -// to cancel a RoundTrip request, its context to expire, or for the -// request to be done (any way it might be removed from the cc.streams -// map: peer reset, successful completion, TCP connection breakage, -// etc) -func (cs *clientStream) awaitRequestCancel(req *http.Request) { - ctx := reqContext(req) - if req.Cancel == nil && ctx.Done() == nil { - return - } - select { - case <-req.Cancel: - cs.bufPipe.CloseWithError(errRequestCanceled) - cs.cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - case <-ctx.Done(): - cs.bufPipe.CloseWithError(ctx.Err()) - cs.cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - case <-cs.done: - } -} - -// checkResetOrDone reports any error sent in a RST_STREAM frame by the -// server, or errStreamClosed if the stream is complete. -func (cs *clientStream) checkResetOrDone() error { - select { - case <-cs.peerReset: - return cs.resetErr - case <-cs.done: - return errStreamClosed - default: - return nil - } -} - -func (cs *clientStream) abortRequestBodyWrite(err error) { - if err == nil { - panic("nil error") - } - cc := cs.cc - cc.mu.Lock() - cs.stopReqBody = err - cc.cond.Broadcast() - cc.mu.Unlock() -} - -type stickyErrWriter struct { - w io.Writer - err *error -} - -func (sew stickyErrWriter) Write(p []byte) (n int, err error) { - if *sew.err != nil { - return 0, *sew.err - } - n, err = sew.w.Write(p) - *sew.err = err - return -} - -var ErrNoCachedConn = errors.New("http2: no cached connection was available") - -// RoundTripOpt are options for the Transport.RoundTripOpt method. -type RoundTripOpt struct { - // OnlyCachedConn controls whether RoundTripOpt may - // create a new TCP connection. If set true and - // no cached connection is available, RoundTripOpt - // will return ErrNoCachedConn. - OnlyCachedConn bool -} - -func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) { - return t.RoundTripOpt(req, RoundTripOpt{}) -} - -// authorityAddr returns a given authority (a host/IP, or host:port / ip:port) -// and returns a host:port. The port 443 is added if needed. -func authorityAddr(scheme string, authority string) (addr string) { - if _, _, err := net.SplitHostPort(authority); err == nil { - return authority - } - port := "443" - if scheme == "http" { - port = "80" - } - return net.JoinHostPort(authority, port) -} - -// RoundTripOpt is like RoundTrip, but takes options. -func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Response, error) { - if !(req.URL.Scheme == "https" || (req.URL.Scheme == "http" && t.AllowHTTP)) { - return nil, errors.New("http2: unsupported scheme") - } - - addr := authorityAddr(req.URL.Scheme, req.URL.Host) - for { - cc, err := t.connPool().GetClientConn(req, addr) - if err != nil { - t.vlogf("http2: Transport failed to get client conn for %s: %v", addr, err) - return nil, err - } - traceGotConn(req, cc) - res, err := cc.RoundTrip(req) - if shouldRetryRequest(req, err) { - continue - } - if err != nil { - t.vlogf("RoundTrip failure: %v", err) - return nil, err - } - return res, nil - } -} - -// CloseIdleConnections closes any connections which were previously -// connected from previous requests but are now sitting idle. -// It does not interrupt any connections currently in use. -func (t *Transport) CloseIdleConnections() { - if cp, ok := t.connPool().(clientConnPoolIdleCloser); ok { - cp.closeIdleConnections() - } -} - -var ( - errClientConnClosed = errors.New("http2: client conn is closed") - errClientConnUnusable = errors.New("http2: client conn not usable") -) - -func shouldRetryRequest(req *http.Request, err error) bool { - // TODO: retry GET requests (no bodies) more aggressively, if shutdown - // before response. - return err == errClientConnUnusable -} - -func (t *Transport) dialClientConn(addr string) (*ClientConn, error) { - host, _, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - tconn, err := t.dialTLS()("tcp", addr, t.newTLSConfig(host)) - if err != nil { - return nil, err - } - return t.NewClientConn(tconn) -} - -func (t *Transport) newTLSConfig(host string) *tls.Config { - cfg := new(tls.Config) - if t.TLSClientConfig != nil { - *cfg = *t.TLSClientConfig - } - if !strSliceContains(cfg.NextProtos, NextProtoTLS) { - cfg.NextProtos = append([]string{NextProtoTLS}, cfg.NextProtos...) - } - if cfg.ServerName == "" { - cfg.ServerName = host - } - return cfg -} - -func (t *Transport) dialTLS() func(string, string, *tls.Config) (net.Conn, error) { - if t.DialTLS != nil { - return t.DialTLS - } - return t.dialTLSDefault -} - -func (t *Transport) dialTLSDefault(network, addr string, cfg *tls.Config) (net.Conn, error) { - cn, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - if err := cn.Handshake(); err != nil { - return nil, err - } - if !cfg.InsecureSkipVerify { - if err := cn.VerifyHostname(cfg.ServerName); err != nil { - return nil, err - } - } - state := cn.ConnectionState() - if p := state.NegotiatedProtocol; p != NextProtoTLS { - return nil, fmt.Errorf("http2: unexpected ALPN protocol %q; want %q", p, NextProtoTLS) - } - if !state.NegotiatedProtocolIsMutual { - return nil, errors.New("http2: could not negotiate protocol mutually") - } - return cn, nil -} - -// disableKeepAlives reports whether connections should be closed as -// soon as possible after handling the first request. -func (t *Transport) disableKeepAlives() bool { - return t.t1 != nil && t.t1.DisableKeepAlives -} - -func (t *Transport) expectContinueTimeout() time.Duration { - if t.t1 == nil { - return 0 - } - return transportExpectContinueTimeout(t.t1) -} - -func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { - if VerboseLogs { - t.vlogf("http2: Transport creating client conn to %v", c.RemoteAddr()) - } - if _, err := c.Write(clientPreface); err != nil { - t.vlogf("client preface write error: %v", err) - return nil, err - } - - cc := &ClientConn{ - t: t, - tconn: c, - readerDone: make(chan struct{}), - nextStreamID: 1, - maxFrameSize: 16 << 10, // spec default - initialWindowSize: 65535, // spec default - maxConcurrentStreams: 1000, // "infinite", per spec. 1000 seems good enough. - streams: make(map[uint32]*clientStream), - } - cc.cond = sync.NewCond(&cc.mu) - cc.flow.add(int32(initialWindowSize)) - - // TODO: adjust this writer size to account for frame size + - // MTU + crypto/tls record padding. - cc.bw = bufio.NewWriter(stickyErrWriter{c, &cc.werr}) - cc.br = bufio.NewReader(c) - cc.fr = NewFramer(cc.bw, cc.br) - cc.fr.ReadMetaHeaders = hpack.NewDecoder(initialHeaderTableSize, nil) - cc.fr.MaxHeaderListSize = t.maxHeaderListSize() - - // TODO: SetMaxDynamicTableSize, SetMaxDynamicTableSizeLimit on - // henc in response to SETTINGS frames? - cc.henc = hpack.NewEncoder(&cc.hbuf) - - if cs, ok := c.(connectionStater); ok { - state := cs.ConnectionState() - cc.tlsState = &state - } - - initialSettings := []Setting{ - {ID: SettingEnablePush, Val: 0}, - {ID: SettingInitialWindowSize, Val: transportDefaultStreamFlow}, - } - if max := t.maxHeaderListSize(); max != 0 { - initialSettings = append(initialSettings, Setting{ID: SettingMaxHeaderListSize, Val: max}) - } - cc.fr.WriteSettings(initialSettings...) - cc.fr.WriteWindowUpdate(0, transportDefaultConnFlow) - cc.inflow.add(transportDefaultConnFlow + initialWindowSize) - cc.bw.Flush() - if cc.werr != nil { - return nil, cc.werr - } - - // Read the obligatory SETTINGS frame - f, err := cc.fr.ReadFrame() - if err != nil { - return nil, err - } - sf, ok := f.(*SettingsFrame) - if !ok { - return nil, fmt.Errorf("expected settings frame, got: %T", f) - } - cc.fr.WriteSettingsAck() - cc.bw.Flush() - - sf.ForeachSetting(func(s Setting) error { - switch s.ID { - case SettingMaxFrameSize: - cc.maxFrameSize = s.Val - case SettingMaxConcurrentStreams: - cc.maxConcurrentStreams = s.Val - case SettingInitialWindowSize: - cc.initialWindowSize = s.Val - default: - // TODO(bradfitz): handle more; at least SETTINGS_HEADER_TABLE_SIZE? - t.vlogf("Unhandled Setting: %v", s) - } - return nil - }) - - go cc.readLoop() - return cc, nil -} - -func (cc *ClientConn) setGoAway(f *GoAwayFrame) { - cc.mu.Lock() - defer cc.mu.Unlock() - cc.goAway = f -} - -func (cc *ClientConn) CanTakeNewRequest() bool { - cc.mu.Lock() - defer cc.mu.Unlock() - return cc.canTakeNewRequestLocked() -} - -func (cc *ClientConn) canTakeNewRequestLocked() bool { - return cc.goAway == nil && !cc.closed && - int64(len(cc.streams)+1) < int64(cc.maxConcurrentStreams) && - cc.nextStreamID < 2147483647 -} - -func (cc *ClientConn) closeIfIdle() { - cc.mu.Lock() - if len(cc.streams) > 0 { - cc.mu.Unlock() - return - } - cc.closed = true - // TODO: do clients send GOAWAY too? maybe? Just Close: - cc.mu.Unlock() - - cc.tconn.Close() -} - -const maxAllocFrameSize = 512 << 10 - -// frameBuffer returns a scratch buffer suitable for writing DATA frames. -// They're capped at the min of the peer's max frame size or 512KB -// (kinda arbitrarily), but definitely capped so we don't allocate 4GB -// bufers. -func (cc *ClientConn) frameScratchBuffer() []byte { - cc.mu.Lock() - size := cc.maxFrameSize - if size > maxAllocFrameSize { - size = maxAllocFrameSize - } - for i, buf := range cc.freeBuf { - if len(buf) >= int(size) { - cc.freeBuf[i] = nil - cc.mu.Unlock() - return buf[:size] - } - } - cc.mu.Unlock() - return make([]byte, size) -} - -func (cc *ClientConn) putFrameScratchBuffer(buf []byte) { - cc.mu.Lock() - defer cc.mu.Unlock() - const maxBufs = 4 // arbitrary; 4 concurrent requests per conn? investigate. - if len(cc.freeBuf) < maxBufs { - cc.freeBuf = append(cc.freeBuf, buf) - return - } - for i, old := range cc.freeBuf { - if old == nil { - cc.freeBuf[i] = buf - return - } - } - // forget about it. -} - -// errRequestCanceled is a copy of net/http's errRequestCanceled because it's not -// exported. At least they'll be DeepEqual for h1-vs-h2 comparisons tests. -var errRequestCanceled = errors.New("net/http: request canceled") - -func commaSeparatedTrailers(req *http.Request) (string, error) { - keys := make([]string, 0, len(req.Trailer)) - for k := range req.Trailer { - k = http.CanonicalHeaderKey(k) - switch k { - case "Transfer-Encoding", "Trailer", "Content-Length": - return "", &badStringError{"invalid Trailer key", k} - } - keys = append(keys, k) - } - if len(keys) > 0 { - sort.Strings(keys) - // TODO: could do better allocation-wise here, but trailers are rare, - // so being lazy for now. - return strings.Join(keys, ","), nil - } - return "", nil -} - -func (cc *ClientConn) responseHeaderTimeout() time.Duration { - if cc.t.t1 != nil { - return cc.t.t1.ResponseHeaderTimeout - } - // No way to do this (yet?) with just an http2.Transport. Probably - // no need. Request.Cancel this is the new way. We only need to support - // this for compatibility with the old http.Transport fields when - // we're doing transparent http2. - return 0 -} - -// checkConnHeaders checks whether req has any invalid connection-level headers. -// per RFC 7540 section 8.1.2.2: Connection-Specific Header Fields. -// Certain headers are special-cased as okay but not transmitted later. -func checkConnHeaders(req *http.Request) error { - if v := req.Header.Get("Upgrade"); v != "" { - return errors.New("http2: invalid Upgrade request header") - } - if v := req.Header.Get("Transfer-Encoding"); (v != "" && v != "chunked") || len(req.Header["Transfer-Encoding"]) > 1 { - return errors.New("http2: invalid Transfer-Encoding request header") - } - if v := req.Header.Get("Connection"); (v != "" && v != "close" && v != "keep-alive") || len(req.Header["Connection"]) > 1 { - return errors.New("http2: invalid Connection request header") - } - return nil -} - -func bodyAndLength(req *http.Request) (body io.Reader, contentLen int64) { - body = req.Body - if body == nil { - return nil, 0 - } - if req.ContentLength != 0 { - return req.Body, req.ContentLength - } - - // We have a body but a zero content length. Test to see if - // it's actually zero or just unset. - var buf [1]byte - n, rerr := io.ReadFull(body, buf[:]) - if rerr != nil && rerr != io.EOF { - return errorReader{rerr}, -1 - } - if n == 1 { - // Oh, guess there is data in this Body Reader after all. - // The ContentLength field just wasn't set. - // Stich the Body back together again, re-attaching our - // consumed byte. - return io.MultiReader(bytes.NewReader(buf[:]), body), -1 - } - // Body is actually zero bytes. - return nil, 0 -} - -func (cc *ClientConn) RoundTrip(req *http.Request) (*http.Response, error) { - if err := checkConnHeaders(req); err != nil { - return nil, err - } - - trailers, err := commaSeparatedTrailers(req) - if err != nil { - return nil, err - } - hasTrailers := trailers != "" - - body, contentLen := bodyAndLength(req) - hasBody := body != nil - - cc.mu.Lock() - cc.lastActive = time.Now() - if cc.closed || !cc.canTakeNewRequestLocked() { - cc.mu.Unlock() - return nil, errClientConnUnusable - } - - // TODO(bradfitz): this is a copy of the logic in net/http. Unify somewhere? - var requestedGzip bool - if !cc.t.disableCompression() && - req.Header.Get("Accept-Encoding") == "" && - req.Header.Get("Range") == "" && - req.Method != "HEAD" { - // Request gzip only, not deflate. Deflate is ambiguous and - // not as universally supported anyway. - // See: http://www.gzip.org/zlib/zlib_faq.html#faq38 - // - // Note that we don't request this for HEAD requests, - // due to a bug in nginx: - // http://trac.nginx.org/nginx/ticket/358 - // https://golang.org/issue/5522 - // - // We don't request gzip if the request is for a range, since - // auto-decoding a portion of a gzipped document will just fail - // anyway. See https://golang.org/issue/8923 - requestedGzip = true - } - - // we send: HEADERS{1}, CONTINUATION{0,} + DATA{0,} (DATA is - // sent by writeRequestBody below, along with any Trailers, - // again in form HEADERS{1}, CONTINUATION{0,}) - hdrs, err := cc.encodeHeaders(req, requestedGzip, trailers, contentLen) - if err != nil { - cc.mu.Unlock() - return nil, err - } - - cs := cc.newStream() - cs.req = req - cs.trace = requestTrace(req) - cs.requestedGzip = requestedGzip - bodyWriter := cc.t.getBodyWriterState(cs, body) - cs.on100 = bodyWriter.on100 - - cc.wmu.Lock() - endStream := !hasBody && !hasTrailers - werr := cc.writeHeaders(cs.ID, endStream, hdrs) - cc.wmu.Unlock() - traceWroteHeaders(cs.trace) - cc.mu.Unlock() - - if werr != nil { - if hasBody { - req.Body.Close() // per RoundTripper contract - bodyWriter.cancel() - } - cc.forgetStreamID(cs.ID) - // Don't bother sending a RST_STREAM (our write already failed; - // no need to keep writing) - traceWroteRequest(cs.trace, werr) - return nil, werr - } - - var respHeaderTimer <-chan time.Time - if hasBody { - bodyWriter.scheduleBodyWrite() - } else { - traceWroteRequest(cs.trace, nil) - if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) - defer timer.Stop() - respHeaderTimer = timer.C - } - } - - readLoopResCh := cs.resc - bodyWritten := false - ctx := reqContext(req) - - for { - select { - case re := <-readLoopResCh: - res := re.res - if re.err != nil || res.StatusCode > 299 { - // On error or status code 3xx, 4xx, 5xx, etc abort any - // ongoing write, assuming that the server doesn't care - // about our request body. If the server replied with 1xx or - // 2xx, however, then assume the server DOES potentially - // want our body (e.g. full-duplex streaming: - // golang.org/issue/13444). If it turns out the server - // doesn't, they'll RST_STREAM us soon enough. This is a - // heuristic to avoid adding knobs to Transport. Hopefully - // we can keep it. - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWrite) - } - if re.err != nil { - cc.forgetStreamID(cs.ID) - return nil, re.err - } - res.Request = req - res.TLS = cc.tlsState - return res, nil - case <-respHeaderTimer: - cc.forgetStreamID(cs.ID) - if !hasBody || bodyWritten { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) - } - return nil, errTimeout - case <-ctx.Done(): - cc.forgetStreamID(cs.ID) - if !hasBody || bodyWritten { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) - } - return nil, ctx.Err() - case <-req.Cancel: - cc.forgetStreamID(cs.ID) - if !hasBody || bodyWritten { - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } else { - bodyWriter.cancel() - cs.abortRequestBodyWrite(errStopReqBodyWriteAndCancel) - } - return nil, errRequestCanceled - case <-cs.peerReset: - // processResetStream already removed the - // stream from the streams map; no need for - // forgetStreamID. - return nil, cs.resetErr - case err := <-bodyWriter.resc: - if err != nil { - return nil, err - } - bodyWritten = true - if d := cc.responseHeaderTimeout(); d != 0 { - timer := time.NewTimer(d) - defer timer.Stop() - respHeaderTimer = timer.C - } - } - } -} - -// requires cc.wmu be held -func (cc *ClientConn) writeHeaders(streamID uint32, endStream bool, hdrs []byte) error { - first := true // first frame written (HEADERS is first, then CONTINUATION) - frameSize := int(cc.maxFrameSize) - for len(hdrs) > 0 && cc.werr == nil { - chunk := hdrs - if len(chunk) > frameSize { - chunk = chunk[:frameSize] - } - hdrs = hdrs[len(chunk):] - endHeaders := len(hdrs) == 0 - if first { - cc.fr.WriteHeaders(HeadersFrameParam{ - StreamID: streamID, - BlockFragment: chunk, - EndStream: endStream, - EndHeaders: endHeaders, - }) - first = false - } else { - cc.fr.WriteContinuation(streamID, endHeaders, chunk) - } - } - // TODO(bradfitz): this Flush could potentially block (as - // could the WriteHeaders call(s) above), which means they - // wouldn't respond to Request.Cancel being readable. That's - // rare, but this should probably be in a goroutine. - cc.bw.Flush() - return cc.werr -} - -// internal error values; they don't escape to callers -var ( - // abort request body write; don't send cancel - errStopReqBodyWrite = errors.New("http2: aborting request body write") - - // abort request body write, but send stream reset of cancel. - errStopReqBodyWriteAndCancel = errors.New("http2: canceling request") -) - -func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) (err error) { - cc := cs.cc - sentEnd := false // whether we sent the final DATA frame w/ END_STREAM - buf := cc.frameScratchBuffer() - defer cc.putFrameScratchBuffer(buf) - - defer func() { - traceWroteRequest(cs.trace, err) - // TODO: write h12Compare test showing whether - // Request.Body is closed by the Transport, - // and in multiple cases: server replies <=299 and >299 - // while still writing request body - cerr := bodyCloser.Close() - if err == nil { - err = cerr - } - }() - - req := cs.req - hasTrailers := req.Trailer != nil - - var sawEOF bool - for !sawEOF { - n, err := body.Read(buf) - if err == io.EOF { - sawEOF = true - err = nil - } else if err != nil { - return err - } - - remain := buf[:n] - for len(remain) > 0 && err == nil { - var allowed int32 - allowed, err = cs.awaitFlowControl(len(remain)) - switch { - case err == errStopReqBodyWrite: - return err - case err == errStopReqBodyWriteAndCancel: - cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - return err - case err != nil: - return err - } - cc.wmu.Lock() - data := remain[:allowed] - remain = remain[allowed:] - sentEnd = sawEOF && len(remain) == 0 && !hasTrailers - err = cc.fr.WriteData(cs.ID, sentEnd, data) - if err == nil { - // TODO(bradfitz): this flush is for latency, not bandwidth. - // Most requests won't need this. Make this opt-in or opt-out? - // Use some heuristic on the body type? Nagel-like timers? - // Based on 'n'? Only last chunk of this for loop, unless flow control - // tokens are low? For now, always: - err = cc.bw.Flush() - } - cc.wmu.Unlock() - } - if err != nil { - return err - } - } - - cc.wmu.Lock() - if !sentEnd { - var trls []byte - if hasTrailers { - cc.mu.Lock() - trls = cc.encodeTrailers(req) - cc.mu.Unlock() - } - - // Avoid forgetting to send an END_STREAM if the encoded - // trailers are 0 bytes. Both results produce and END_STREAM. - if len(trls) > 0 { - err = cc.writeHeaders(cs.ID, true, trls) - } else { - err = cc.fr.WriteData(cs.ID, true, nil) - } - } - if ferr := cc.bw.Flush(); ferr != nil && err == nil { - err = ferr - } - cc.wmu.Unlock() - - return err -} - -// awaitFlowControl waits for [1, min(maxBytes, cc.cs.maxFrameSize)] flow -// control tokens from the server. -// It returns either the non-zero number of tokens taken or an error -// if the stream is dead. -func (cs *clientStream) awaitFlowControl(maxBytes int) (taken int32, err error) { - cc := cs.cc - cc.mu.Lock() - defer cc.mu.Unlock() - for { - if cc.closed { - return 0, errClientConnClosed - } - if cs.stopReqBody != nil { - return 0, cs.stopReqBody - } - if err := cs.checkResetOrDone(); err != nil { - return 0, err - } - if a := cs.flow.available(); a > 0 { - take := a - if int(take) > maxBytes { - - take = int32(maxBytes) // can't truncate int; take is int32 - } - if take > int32(cc.maxFrameSize) { - take = int32(cc.maxFrameSize) - } - cs.flow.take(take) - return take, nil - } - cc.cond.Wait() - } -} - -type badStringError struct { - what string - str string -} - -func (e *badStringError) Error() string { return fmt.Sprintf("%s %q", e.what, e.str) } - -// requires cc.mu be held. -func (cc *ClientConn) encodeHeaders(req *http.Request, addGzipHeader bool, trailers string, contentLength int64) ([]byte, error) { - cc.hbuf.Reset() - - host := req.Host - if host == "" { - host = req.URL.Host - } - - // Check for any invalid headers and return an error before we - // potentially pollute our hpack state. (We want to be able to - // continue to reuse the hpack encoder for future requests) - for k, vv := range req.Header { - if !httplex.ValidHeaderFieldName(k) { - return nil, fmt.Errorf("invalid HTTP header name %q", k) - } - for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { - return nil, fmt.Errorf("invalid HTTP header value %q for header %q", v, k) - } - } - } - - // 8.1.2.3 Request Pseudo-Header Fields - // The :path pseudo-header field includes the path and query parts of the - // target URI (the path-absolute production and optionally a '?' character - // followed by the query production (see Sections 3.3 and 3.4 of - // [RFC3986]). - cc.writeHeader(":authority", host) - cc.writeHeader(":method", req.Method) - if req.Method != "CONNECT" { - cc.writeHeader(":path", req.URL.RequestURI()) - cc.writeHeader(":scheme", "https") - } - if trailers != "" { - cc.writeHeader("trailer", trailers) - } - - var didUA bool - for k, vv := range req.Header { - lowKey := strings.ToLower(k) - switch lowKey { - case "host", "content-length": - // Host is :authority, already sent. - // Content-Length is automatic, set below. - continue - case "connection", "proxy-connection", "transfer-encoding", "upgrade", "keep-alive": - // Per 8.1.2.2 Connection-Specific Header - // Fields, don't send connection-specific - // fields. We have already checked if any - // are error-worthy so just ignore the rest. - continue - case "user-agent": - // Match Go's http1 behavior: at most one - // User-Agent. If set to nil or empty string, - // then omit it. Otherwise if not mentioned, - // include the default (below). - didUA = true - if len(vv) < 1 { - continue - } - vv = vv[:1] - if vv[0] == "" { - continue - } - } - for _, v := range vv { - cc.writeHeader(lowKey, v) - } - } - if shouldSendReqContentLength(req.Method, contentLength) { - cc.writeHeader("content-length", strconv.FormatInt(contentLength, 10)) - } - if addGzipHeader { - cc.writeHeader("accept-encoding", "gzip") - } - if !didUA { - cc.writeHeader("user-agent", defaultUserAgent) - } - return cc.hbuf.Bytes(), nil -} - -// shouldSendReqContentLength reports whether the http2.Transport should send -// a "content-length" request header. This logic is basically a copy of the net/http -// transferWriter.shouldSendContentLength. -// The contentLength is the corrected contentLength (so 0 means actually 0, not unknown). -// -1 means unknown. -func shouldSendReqContentLength(method string, contentLength int64) bool { - if contentLength > 0 { - return true - } - if contentLength < 0 { - return false - } - // For zero bodies, whether we send a content-length depends on the method. - // It also kinda doesn't matter for http2 either way, with END_STREAM. - switch method { - case "POST", "PUT", "PATCH": - return true - default: - return false - } -} - -// requires cc.mu be held. -func (cc *ClientConn) encodeTrailers(req *http.Request) []byte { - cc.hbuf.Reset() - for k, vv := range req.Trailer { - // Transfer-Encoding, etc.. have already been filter at the - // start of RoundTrip - lowKey := strings.ToLower(k) - for _, v := range vv { - cc.writeHeader(lowKey, v) - } - } - return cc.hbuf.Bytes() -} - -func (cc *ClientConn) writeHeader(name, value string) { - if VerboseLogs { - log.Printf("http2: Transport encoding header %q = %q", name, value) - } - cc.henc.WriteField(hpack.HeaderField{Name: name, Value: value}) -} - -type resAndError struct { - res *http.Response - err error -} - -// requires cc.mu be held. -func (cc *ClientConn) newStream() *clientStream { - cs := &clientStream{ - cc: cc, - ID: cc.nextStreamID, - resc: make(chan resAndError, 1), - peerReset: make(chan struct{}), - done: make(chan struct{}), - } - cs.flow.add(int32(cc.initialWindowSize)) - cs.flow.setConnFlow(&cc.flow) - cs.inflow.add(transportDefaultStreamFlow) - cs.inflow.setConnFlow(&cc.inflow) - cc.nextStreamID += 2 - cc.streams[cs.ID] = cs - return cs -} - -func (cc *ClientConn) forgetStreamID(id uint32) { - cc.streamByID(id, true) -} - -func (cc *ClientConn) streamByID(id uint32, andRemove bool) *clientStream { - cc.mu.Lock() - defer cc.mu.Unlock() - cs := cc.streams[id] - if andRemove && cs != nil && !cc.closed { - cc.lastActive = time.Now() - delete(cc.streams, id) - close(cs.done) - cc.cond.Broadcast() // wake up checkResetOrDone via clientStream.awaitFlowControl - } - return cs -} - -// clientConnReadLoop is the state owned by the clientConn's frame-reading readLoop. -type clientConnReadLoop struct { - cc *ClientConn - activeRes map[uint32]*clientStream // keyed by streamID - closeWhenIdle bool -} - -// readLoop runs in its own goroutine and reads and dispatches frames. -func (cc *ClientConn) readLoop() { - rl := &clientConnReadLoop{ - cc: cc, - activeRes: make(map[uint32]*clientStream), - } - - defer rl.cleanup() - cc.readerErr = rl.run() - if ce, ok := cc.readerErr.(ConnectionError); ok { - cc.wmu.Lock() - cc.fr.WriteGoAway(0, ErrCode(ce), nil) - cc.wmu.Unlock() - } -} - -func (rl *clientConnReadLoop) cleanup() { - cc := rl.cc - defer cc.tconn.Close() - defer cc.t.connPool().MarkDead(cc) - defer close(cc.readerDone) - - // Close any response bodies if the server closes prematurely. - // TODO: also do this if we've written the headers but not - // gotten a response yet. - err := cc.readerErr - if err == io.EOF { - err = io.ErrUnexpectedEOF - } - cc.mu.Lock() - for _, cs := range rl.activeRes { - cs.bufPipe.CloseWithError(err) - } - for _, cs := range cc.streams { - select { - case cs.resc <- resAndError{err: err}: - default: - } - close(cs.done) - } - cc.closed = true - cc.cond.Broadcast() - cc.mu.Unlock() -} - -func (rl *clientConnReadLoop) run() error { - cc := rl.cc - rl.closeWhenIdle = cc.t.disableKeepAlives() - gotReply := false // ever saw a reply - for { - f, err := cc.fr.ReadFrame() - if err != nil { - cc.vlogf("Transport readFrame error: (%T) %v", err, err) - } - if se, ok := err.(StreamError); ok { - if cs := cc.streamByID(se.StreamID, true /*ended; remove it*/); cs != nil { - rl.endStreamError(cs, cc.fr.errDetail) - } - continue - } else if err != nil { - return err - } - if VerboseLogs { - cc.vlogf("http2: Transport received %s", summarizeFrame(f)) - } - maybeIdle := false // whether frame might transition us to idle - - switch f := f.(type) { - case *MetaHeadersFrame: - err = rl.processHeaders(f) - maybeIdle = true - gotReply = true - case *DataFrame: - err = rl.processData(f) - maybeIdle = true - case *GoAwayFrame: - err = rl.processGoAway(f) - maybeIdle = true - case *RSTStreamFrame: - err = rl.processResetStream(f) - maybeIdle = true - case *SettingsFrame: - err = rl.processSettings(f) - case *PushPromiseFrame: - err = rl.processPushPromise(f) - case *WindowUpdateFrame: - err = rl.processWindowUpdate(f) - case *PingFrame: - err = rl.processPing(f) - default: - cc.logf("Transport: unhandled response frame type %T", f) - } - if err != nil { - return err - } - if rl.closeWhenIdle && gotReply && maybeIdle && len(rl.activeRes) == 0 { - cc.closeIfIdle() - } - } -} - -func (rl *clientConnReadLoop) processHeaders(f *MetaHeadersFrame) error { - cc := rl.cc - cs := cc.streamByID(f.StreamID, f.StreamEnded()) - if cs == nil { - // We'd get here if we canceled a request while the - // server had its response still in flight. So if this - // was just something we canceled, ignore it. - return nil - } - if !cs.firstByte { - if cs.trace != nil { - // TODO(bradfitz): move first response byte earlier, - // when we first read the 9 byte header, not waiting - // until all the HEADERS+CONTINUATION frames have been - // merged. This works for now. - traceFirstResponseByte(cs.trace) - } - cs.firstByte = true - } - if !cs.pastHeaders { - cs.pastHeaders = true - } else { - return rl.processTrailers(cs, f) - } - - res, err := rl.handleResponse(cs, f) - if err != nil { - if _, ok := err.(ConnectionError); ok { - return err - } - // Any other error type is a stream error. - cs.cc.writeStreamReset(f.StreamID, ErrCodeProtocol, err) - cs.resc <- resAndError{err: err} - return nil // return nil from process* funcs to keep conn alive - } - if res == nil { - // (nil, nil) special case. See handleResponse docs. - return nil - } - if res.Body != noBody { - rl.activeRes[cs.ID] = cs - } - cs.resTrailer = &res.Trailer - cs.resc <- resAndError{res: res} - return nil -} - -// may return error types nil, or ConnectionError. Any other error value -// is a StreamError of type ErrCodeProtocol. The returned error in that case -// is the detail. -// -// As a special case, handleResponse may return (nil, nil) to skip the -// frame (currently only used for 100 expect continue). This special -// case is going away after Issue 13851 is fixed. -func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) { - if f.Truncated { - return nil, errResponseHeaderListSize - } - - status := f.PseudoValue("status") - if status == "" { - return nil, errors.New("missing status pseudo header") - } - statusCode, err := strconv.Atoi(status) - if err != nil { - return nil, errors.New("malformed non-numeric status pseudo header") - } - - if statusCode == 100 { - traceGot100Continue(cs.trace) - if cs.on100 != nil { - cs.on100() // forces any write delay timer to fire - } - cs.pastHeaders = false // do it all again - return nil, nil - } - - header := make(http.Header) - res := &http.Response{ - Proto: "HTTP/2.0", - ProtoMajor: 2, - Header: header, - StatusCode: statusCode, - Status: status + " " + http.StatusText(statusCode), - } - for _, hf := range f.RegularFields() { - key := http.CanonicalHeaderKey(hf.Name) - if key == "Trailer" { - t := res.Trailer - if t == nil { - t = make(http.Header) - res.Trailer = t - } - foreachHeaderElement(hf.Value, func(v string) { - t[http.CanonicalHeaderKey(v)] = nil - }) - } else { - header[key] = append(header[key], hf.Value) - } - } - - streamEnded := f.StreamEnded() - isHead := cs.req.Method == "HEAD" - if !streamEnded || isHead { - res.ContentLength = -1 - if clens := res.Header["Content-Length"]; len(clens) == 1 { - if clen64, err := strconv.ParseInt(clens[0], 10, 64); err == nil { - res.ContentLength = clen64 - } else { - // TODO: care? unlike http/1, it won't mess up our framing, so it's - // more safe smuggling-wise to ignore. - } - } else if len(clens) > 1 { - // TODO: care? unlike http/1, it won't mess up our framing, so it's - // more safe smuggling-wise to ignore. - } - } - - if streamEnded || isHead { - res.Body = noBody - return res, nil - } - - buf := new(bytes.Buffer) // TODO(bradfitz): recycle this garbage - cs.bufPipe = pipe{b: buf} - cs.bytesRemain = res.ContentLength - res.Body = transportResponseBody{cs} - go cs.awaitRequestCancel(cs.req) - - if cs.requestedGzip && res.Header.Get("Content-Encoding") == "gzip" { - res.Header.Del("Content-Encoding") - res.Header.Del("Content-Length") - res.ContentLength = -1 - res.Body = &gzipReader{body: res.Body} - setResponseUncompressed(res) - } - return res, nil -} - -func (rl *clientConnReadLoop) processTrailers(cs *clientStream, f *MetaHeadersFrame) error { - if cs.pastTrailers { - // Too many HEADERS frames for this stream. - return ConnectionError(ErrCodeProtocol) - } - cs.pastTrailers = true - if !f.StreamEnded() { - // We expect that any headers for trailers also - // has END_STREAM. - return ConnectionError(ErrCodeProtocol) - } - if len(f.PseudoFields()) > 0 { - // No pseudo header fields are defined for trailers. - // TODO: ConnectionError might be overly harsh? Check. - return ConnectionError(ErrCodeProtocol) - } - - trailer := make(http.Header) - for _, hf := range f.RegularFields() { - key := http.CanonicalHeaderKey(hf.Name) - trailer[key] = append(trailer[key], hf.Value) - } - cs.trailer = trailer - - rl.endStream(cs) - return nil -} - -// transportResponseBody is the concrete type of Transport.RoundTrip's -// Response.Body. It is an io.ReadCloser. On Read, it reads from cs.body. -// On Close it sends RST_STREAM if EOF wasn't already seen. -type transportResponseBody struct { - cs *clientStream -} - -func (b transportResponseBody) Read(p []byte) (n int, err error) { - cs := b.cs - cc := cs.cc - - if cs.readErr != nil { - return 0, cs.readErr - } - n, err = b.cs.bufPipe.Read(p) - if cs.bytesRemain != -1 { - if int64(n) > cs.bytesRemain { - n = int(cs.bytesRemain) - if err == nil { - err = errors.New("net/http: server replied with more than declared Content-Length; truncated") - cc.writeStreamReset(cs.ID, ErrCodeProtocol, err) - } - cs.readErr = err - return int(cs.bytesRemain), err - } - cs.bytesRemain -= int64(n) - if err == io.EOF && cs.bytesRemain > 0 { - err = io.ErrUnexpectedEOF - cs.readErr = err - return n, err - } - } - if n == 0 { - // No flow control tokens to send back. - return - } - - cc.mu.Lock() - defer cc.mu.Unlock() - - var connAdd, streamAdd int32 - // Check the conn-level first, before the stream-level. - if v := cc.inflow.available(); v < transportDefaultConnFlow/2 { - connAdd = transportDefaultConnFlow - v - cc.inflow.add(connAdd) - } - if err == nil { // No need to refresh if the stream is over or failed. - // Consider any buffered body data (read from the conn but not - // consumed by the client) when computing flow control for this - // stream. - v := int(cs.inflow.available()) + cs.bufPipe.Len() - if v < transportDefaultStreamFlow-transportDefaultStreamMinRefresh { - streamAdd = int32(transportDefaultStreamFlow - v) - cs.inflow.add(streamAdd) - } - } - if connAdd != 0 || streamAdd != 0 { - cc.wmu.Lock() - defer cc.wmu.Unlock() - if connAdd != 0 { - cc.fr.WriteWindowUpdate(0, mustUint31(connAdd)) - } - if streamAdd != 0 { - cc.fr.WriteWindowUpdate(cs.ID, mustUint31(streamAdd)) - } - cc.bw.Flush() - } - return -} - -var errClosedResponseBody = errors.New("http2: response body closed") - -func (b transportResponseBody) Close() error { - cs := b.cs - if cs.bufPipe.Err() != io.EOF { - // TODO: write test for this - cs.cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) - } - cs.bufPipe.BreakWithError(errClosedResponseBody) - return nil -} - -func (rl *clientConnReadLoop) processData(f *DataFrame) error { - cc := rl.cc - cs := cc.streamByID(f.StreamID, f.StreamEnded()) - if cs == nil { - cc.mu.Lock() - neverSent := cc.nextStreamID - cc.mu.Unlock() - if f.StreamID >= neverSent { - // We never asked for this. - cc.logf("http2: Transport received unsolicited DATA frame; closing connection") - return ConnectionError(ErrCodeProtocol) - } - // We probably did ask for this, but canceled. Just ignore it. - // TODO: be stricter here? only silently ignore things which - // we canceled, but not things which were closed normally - // by the peer? Tough without accumulating too much state. - return nil - } - if data := f.Data(); len(data) > 0 { - if cs.bufPipe.b == nil { - // Data frame after it's already closed? - cc.logf("http2: Transport received DATA frame for closed stream; closing connection") - return ConnectionError(ErrCodeProtocol) - } - - // Check connection-level flow control. - cc.mu.Lock() - if cs.inflow.available() >= int32(len(data)) { - cs.inflow.take(int32(len(data))) - } else { - cc.mu.Unlock() - return ConnectionError(ErrCodeFlowControl) - } - cc.mu.Unlock() - - if _, err := cs.bufPipe.Write(data); err != nil { - rl.endStreamError(cs, err) - return err - } - } - - if f.StreamEnded() { - rl.endStream(cs) - } - return nil -} - -var errInvalidTrailers = errors.New("http2: invalid trailers") - -func (rl *clientConnReadLoop) endStream(cs *clientStream) { - // TODO: check that any declared content-length matches, like - // server.go's (*stream).endStream method. - rl.endStreamError(cs, nil) -} - -func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) { - var code func() - if err == nil { - err = io.EOF - code = cs.copyTrailers - } - cs.bufPipe.closeWithErrorAndCode(err, code) - delete(rl.activeRes, cs.ID) - if cs.req.Close || cs.req.Header.Get("Connection") == "close" { - rl.closeWhenIdle = true - } -} - -func (cs *clientStream) copyTrailers() { - for k, vv := range cs.trailer { - t := cs.resTrailer - if *t == nil { - *t = make(http.Header) - } - (*t)[k] = vv - } -} - -func (rl *clientConnReadLoop) processGoAway(f *GoAwayFrame) error { - cc := rl.cc - cc.t.connPool().MarkDead(cc) - if f.ErrCode != 0 { - // TODO: deal with GOAWAY more. particularly the error code - cc.vlogf("transport got GOAWAY with error code = %v", f.ErrCode) - } - cc.setGoAway(f) - return nil -} - -func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { - cc := rl.cc - cc.mu.Lock() - defer cc.mu.Unlock() - return f.ForeachSetting(func(s Setting) error { - switch s.ID { - case SettingMaxFrameSize: - cc.maxFrameSize = s.Val - case SettingMaxConcurrentStreams: - cc.maxConcurrentStreams = s.Val - case SettingInitialWindowSize: - // TODO: error if this is too large. - - // TODO: adjust flow control of still-open - // frames by the difference of the old initial - // window size and this one. - cc.initialWindowSize = s.Val - default: - // TODO(bradfitz): handle more settings? SETTINGS_HEADER_TABLE_SIZE probably. - cc.vlogf("Unhandled Setting: %v", s) - } - return nil - }) -} - -func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error { - cc := rl.cc - cs := cc.streamByID(f.StreamID, false) - if f.StreamID != 0 && cs == nil { - return nil - } - - cc.mu.Lock() - defer cc.mu.Unlock() - - fl := &cc.flow - if cs != nil { - fl = &cs.flow - } - if !fl.add(int32(f.Increment)) { - return ConnectionError(ErrCodeFlowControl) - } - cc.cond.Broadcast() - return nil -} - -func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error { - cs := rl.cc.streamByID(f.StreamID, true) - if cs == nil { - // TODO: return error if server tries to RST_STEAM an idle stream - return nil - } - select { - case <-cs.peerReset: - // Already reset. - // This is the only goroutine - // which closes this, so there - // isn't a race. - default: - err := StreamError{cs.ID, f.ErrCode} - cs.resetErr = err - close(cs.peerReset) - cs.bufPipe.CloseWithError(err) - cs.cc.cond.Broadcast() // wake up checkResetOrDone via clientStream.awaitFlowControl - } - delete(rl.activeRes, cs.ID) - return nil -} - -func (rl *clientConnReadLoop) processPing(f *PingFrame) error { - if f.IsAck() { - // 6.7 PING: " An endpoint MUST NOT respond to PING frames - // containing this flag." - return nil - } - cc := rl.cc - cc.wmu.Lock() - defer cc.wmu.Unlock() - if err := cc.fr.WritePing(true, f.Data); err != nil { - return err - } - return cc.bw.Flush() -} - -func (rl *clientConnReadLoop) processPushPromise(f *PushPromiseFrame) error { - // We told the peer we don't want them. - // Spec says: - // "PUSH_PROMISE MUST NOT be sent if the SETTINGS_ENABLE_PUSH - // setting of the peer endpoint is set to 0. An endpoint that - // has set this setting and has received acknowledgement MUST - // treat the receipt of a PUSH_PROMISE frame as a connection - // error (Section 5.4.1) of type PROTOCOL_ERROR." - return ConnectionError(ErrCodeProtocol) -} - -func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error) { - // TODO: do something with err? send it as a debug frame to the peer? - // But that's only in GOAWAY. Invent a new frame type? Is there one already? - cc.wmu.Lock() - cc.fr.WriteRSTStream(streamID, code) - cc.bw.Flush() - cc.wmu.Unlock() -} - -var ( - errResponseHeaderListSize = errors.New("http2: response header list larger than advertised limit") - errPseudoTrailers = errors.New("http2: invalid pseudo header in trailers") -) - -func (cc *ClientConn) logf(format string, args ...interface{}) { - cc.t.logf(format, args...) -} - -func (cc *ClientConn) vlogf(format string, args ...interface{}) { - cc.t.vlogf(format, args...) -} - -func (t *Transport) vlogf(format string, args ...interface{}) { - if VerboseLogs { - t.logf(format, args...) - } -} - -func (t *Transport) logf(format string, args ...interface{}) { - log.Printf(format, args...) -} - -var noBody io.ReadCloser = ioutil.NopCloser(bytes.NewReader(nil)) - -func strSliceContains(ss []string, s string) bool { - for _, v := range ss { - if v == s { - return true - } - } - return false -} - -type erringRoundTripper struct{ err error } - -func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) { return nil, rt.err } - -// gzipReader wraps a response body so it can lazily -// call gzip.NewReader on the first call to Read -type gzipReader struct { - body io.ReadCloser // underlying Response.Body - zr *gzip.Reader // lazily-initialized gzip reader - zerr error // sticky error -} - -func (gz *gzipReader) Read(p []byte) (n int, err error) { - if gz.zerr != nil { - return 0, gz.zerr - } - if gz.zr == nil { - gz.zr, err = gzip.NewReader(gz.body) - if err != nil { - gz.zerr = err - return 0, err - } - } - return gz.zr.Read(p) -} - -func (gz *gzipReader) Close() error { - return gz.body.Close() -} - -type errorReader struct{ err error } - -func (r errorReader) Read(p []byte) (int, error) { return 0, r.err } - -// bodyWriterState encapsulates various state around the Transport's writing -// of the request body, particularly regarding doing delayed writes of the body -// when the request contains "Expect: 100-continue". -type bodyWriterState struct { - cs *clientStream - timer *time.Timer // if non-nil, we're doing a delayed write - fnonce *sync.Once // to call fn with - fn func() // the code to run in the goroutine, writing the body - resc chan error // result of fn's execution - delay time.Duration // how long we should delay a delayed write for -} - -func (t *Transport) getBodyWriterState(cs *clientStream, body io.Reader) (s bodyWriterState) { - s.cs = cs - if body == nil { - return - } - resc := make(chan error, 1) - s.resc = resc - s.fn = func() { - resc <- cs.writeRequestBody(body, cs.req.Body) - } - s.delay = t.expectContinueTimeout() - if s.delay == 0 || - !httplex.HeaderValuesContainsToken( - cs.req.Header["Expect"], - "100-continue") { - return - } - s.fnonce = new(sync.Once) - - // Arm the timer with a very large duration, which we'll - // intentionally lower later. It has to be large now because - // we need a handle to it before writing the headers, but the - // s.delay value is defined to not start until after the - // request headers were written. - const hugeDuration = 365 * 24 * time.Hour - s.timer = time.AfterFunc(hugeDuration, func() { - s.fnonce.Do(s.fn) - }) - return -} - -func (s bodyWriterState) cancel() { - if s.timer != nil { - s.timer.Stop() - } -} - -func (s bodyWriterState) on100() { - if s.timer == nil { - // If we didn't do a delayed write, ignore the server's - // bogus 100 continue response. - return - } - s.timer.Stop() - go func() { s.fnonce.Do(s.fn) }() -} - -// scheduleBodyWrite starts writing the body, either immediately (in -// the common case) or after the delay timeout. It should not be -// called until after the headers have been written. -func (s bodyWriterState) scheduleBodyWrite() { - if s.timer == nil { - // We're not doing a delayed write (see - // getBodyWriterState), so just start the writing - // goroutine immediately. - go s.fn() - return - } - traceWait100Continue(s.cs.trace) - if s.timer.Stop() { - s.timer.Reset(s.delay) - } -} diff --git a/vendor/golang.org/x/net/http2/transport_test.go b/vendor/golang.org/x/net/http2/transport_test.go deleted file mode 100644 index 631a04b..0000000 --- a/vendor/golang.org/x/net/http2/transport_test.go +++ /dev/null @@ -1,2013 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bufio" - "bytes" - "crypto/tls" - "errors" - "flag" - "fmt" - "io" - "io/ioutil" - "math/rand" - "net" - "net/http" - "net/url" - "os" - "reflect" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "sync/atomic" - "testing" - "time" - - "golang.org/x/net/http2/hpack" -) - -var ( - extNet = flag.Bool("extnet", false, "do external network tests") - transportHost = flag.String("transporthost", "http2.golang.org", "hostname to use for TestTransport") - insecure = flag.Bool("insecure", false, "insecure TLS dials") // TODO: dead code. remove? -) - -var tlsConfigInsecure = &tls.Config{InsecureSkipVerify: true} - -func TestTransportExternal(t *testing.T) { - if !*extNet { - t.Skip("skipping external network test") - } - req, _ := http.NewRequest("GET", "https://"+*transportHost+"/", nil) - rt := &Transport{TLSClientConfig: tlsConfigInsecure} - res, err := rt.RoundTrip(req) - if err != nil { - t.Fatalf("%v", err) - } - res.Write(os.Stdout) -} - -func startH2cServer(t *testing.T) net.Listener { - h2Server := &Server{} - l := newLocalListener(t) - go func() { - conn, err := l.Accept() - if err != nil { - t.Error(err) - return - } - h2Server.ServeConn(conn, &ServeConnOpts{Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - fmt.Fprintf(w, "Hello, %v", r.URL.Path) - })}) - }() - return l -} - -func TestTransportH2c(t *testing.T) { - l := startH2cServer(t) - defer l.Close() - req, err := http.NewRequest("GET", "http://"+l.Addr().String()+"/foobar", nil) - if err != nil { - t.Fatal(err) - } - tr := &Transport{ - AllowHTTP: true, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - return net.Dial(network, addr) - }, - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - if res.ProtoMajor != 2 { - t.Fatal("proto not h2c") - } - body, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if got, want := string(body), "Hello, /foobar"; got != want { - t.Fatalf("response got %v, want %v", got, want) - } -} - -func TestTransport(t *testing.T) { - const body = "sup" - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, body) - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - - t.Logf("Got res: %+v", res) - if g, w := res.StatusCode, 200; g != w { - t.Errorf("StatusCode = %v; want %v", g, w) - } - if g, w := res.Status, "200 OK"; g != w { - t.Errorf("Status = %q; want %q", g, w) - } - wantHeader := http.Header{ - "Content-Length": []string{"3"}, - "Content-Type": []string{"text/plain; charset=utf-8"}, - "Date": []string{"XXX"}, // see cleanDate - } - cleanDate(res) - if !reflect.DeepEqual(res.Header, wantHeader) { - t.Errorf("res Header = %v; want %v", res.Header, wantHeader) - } - if res.Request != req { - t.Errorf("Response.Request = %p; want %p", res.Request, req) - } - if res.TLS == nil { - t.Error("Response.TLS = nil; want non-nil") - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Errorf("Body read: %v", err) - } else if string(slurp) != body { - t.Errorf("Body = %q; want %q", slurp, body) - } -} - -func onSameConn(t *testing.T, modReq func(*http.Request)) bool { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, r.RemoteAddr) - }, optOnlyServer) - defer st.Close() - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - get := func() string { - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - modReq(req) - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatalf("Body read: %v", err) - } - addr := strings.TrimSpace(string(slurp)) - if addr == "" { - t.Fatalf("didn't get an addr in response") - } - return addr - } - first := get() - second := get() - return first == second -} - -func TestTransportReusesConns(t *testing.T) { - if !onSameConn(t, func(*http.Request) {}) { - t.Errorf("first and second responses were on different connections") - } -} - -func TestTransportReusesConn_RequestClose(t *testing.T) { - if onSameConn(t, func(r *http.Request) { r.Close = true }) { - t.Errorf("first and second responses were not on different connections") - } -} - -func TestTransportReusesConn_ConnClose(t *testing.T) { - if onSameConn(t, func(r *http.Request) { r.Header.Set("Connection", "close") }) { - t.Errorf("first and second responses were not on different connections") - } -} - -// Tests that the Transport only keeps one pending dial open per destination address. -// https://golang.org/issue/13397 -func TestTransportGroupsPendingDials(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, r.RemoteAddr) - }, optOnlyServer) - defer st.Close() - tr := &Transport{ - TLSClientConfig: tlsConfigInsecure, - } - defer tr.CloseIdleConnections() - var ( - mu sync.Mutex - dials = map[string]int{} - ) - var wg sync.WaitGroup - for i := 0; i < 10; i++ { - wg.Add(1) - go func() { - defer wg.Done() - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Error(err) - return - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Error(err) - return - } - defer res.Body.Close() - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Errorf("Body read: %v", err) - } - addr := strings.TrimSpace(string(slurp)) - if addr == "" { - t.Errorf("didn't get an addr in response") - } - mu.Lock() - dials[addr]++ - mu.Unlock() - }() - } - wg.Wait() - if len(dials) != 1 { - t.Errorf("saw %d dials; want 1: %v", len(dials), dials) - } - tr.CloseIdleConnections() - if err := retry(50, 10*time.Millisecond, func() error { - cp, ok := tr.connPool().(*clientConnPool) - if !ok { - return fmt.Errorf("Conn pool is %T; want *clientConnPool", tr.connPool()) - } - cp.mu.Lock() - defer cp.mu.Unlock() - if len(cp.dialing) != 0 { - return fmt.Errorf("dialing map = %v; want empty", cp.dialing) - } - if len(cp.conns) != 0 { - return fmt.Errorf("conns = %v; want empty", cp.conns) - } - if len(cp.keys) != 0 { - return fmt.Errorf("keys = %v; want empty", cp.keys) - } - return nil - }); err != nil { - t.Errorf("State of pool after CloseIdleConnections: %v", err) - } -} - -func retry(tries int, delay time.Duration, fn func() error) error { - var err error - for i := 0; i < tries; i++ { - err = fn() - if err == nil { - return nil - } - time.Sleep(delay) - } - return err -} - -func TestTransportAbortClosesPipes(t *testing.T) { - shutdown := make(chan struct{}) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - w.(http.Flusher).Flush() - <-shutdown - }, - optOnlyServer, - ) - defer st.Close() - defer close(shutdown) // we must shutdown before st.Close() to avoid hanging - - done := make(chan struct{}) - requestMade := make(chan struct{}) - go func() { - defer close(done) - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - close(requestMade) - _, err = ioutil.ReadAll(res.Body) - if err == nil { - t.Error("expected error from res.Body.Read") - } - }() - - <-requestMade - // Now force the serve loop to end, via closing the connection. - st.closeConn() - // deadlock? that's a bug. - select { - case <-done: - case <-time.After(3 * time.Second): - t.Fatal("timeout") - } -} - -// TODO: merge this with TestTransportBody to make TestTransportRequest? This -// could be a table-driven test with extra goodies. -func TestTransportPath(t *testing.T) { - gotc := make(chan *url.URL, 1) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - gotc <- r.URL - }, - optOnlyServer, - ) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - const ( - path = "/testpath" - query = "q=1" - ) - surl := st.ts.URL + path + "?" + query - req, err := http.NewRequest("POST", surl, nil) - if err != nil { - t.Fatal(err) - } - c := &http.Client{Transport: tr} - res, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - got := <-gotc - if got.Path != path { - t.Errorf("Read Path = %q; want %q", got.Path, path) - } - if got.RawQuery != query { - t.Errorf("Read RawQuery = %q; want %q", got.RawQuery, query) - } -} - -func randString(n int) string { - rnd := rand.New(rand.NewSource(int64(n))) - b := make([]byte, n) - for i := range b { - b[i] = byte(rnd.Intn(256)) - } - return string(b) -} - -func TestTransportBody(t *testing.T) { - bodyTests := []struct { - body string - noContentLen bool - }{ - {body: "some message"}, - {body: "some message", noContentLen: true}, - {body: ""}, - {body: "", noContentLen: true}, - {body: strings.Repeat("a", 1<<20), noContentLen: true}, - {body: strings.Repeat("a", 1<<20)}, - {body: randString(16<<10 - 1)}, - {body: randString(16 << 10)}, - {body: randString(16<<10 + 1)}, - {body: randString(512<<10 - 1)}, - {body: randString(512 << 10)}, - {body: randString(512<<10 + 1)}, - {body: randString(1<<20 - 1)}, - {body: randString(1 << 20)}, - {body: randString(1<<20 + 2)}, - } - - type reqInfo struct { - req *http.Request - slurp []byte - err error - } - gotc := make(chan reqInfo, 1) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - slurp, err := ioutil.ReadAll(r.Body) - if err != nil { - gotc <- reqInfo{err: err} - } else { - gotc <- reqInfo{req: r, slurp: slurp} - } - }, - optOnlyServer, - ) - defer st.Close() - - for i, tt := range bodyTests { - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - var body io.Reader = strings.NewReader(tt.body) - if tt.noContentLen { - body = struct{ io.Reader }{body} // just a Reader, hiding concrete type and other methods - } - req, err := http.NewRequest("POST", st.ts.URL, body) - if err != nil { - t.Fatalf("#%d: %v", i, err) - } - c := &http.Client{Transport: tr} - res, err := c.Do(req) - if err != nil { - t.Fatalf("#%d: %v", i, err) - } - defer res.Body.Close() - ri := <-gotc - if ri.err != nil { - t.Errorf("#%d: read error: %v", i, ri.err) - continue - } - if got := string(ri.slurp); got != tt.body { - t.Errorf("#%d: Read body mismatch.\n got: %q (len %d)\nwant: %q (len %d)", i, shortString(got), len(got), shortString(tt.body), len(tt.body)) - } - wantLen := int64(len(tt.body)) - if tt.noContentLen && tt.body != "" { - wantLen = -1 - } - if ri.req.ContentLength != wantLen { - t.Errorf("#%d. handler got ContentLength = %v; want %v", i, ri.req.ContentLength, wantLen) - } - } -} - -func shortString(v string) string { - const maxLen = 100 - if len(v) <= maxLen { - return v - } - return fmt.Sprintf("%v[...%d bytes omitted...]%v", v[:maxLen/2], len(v)-maxLen, v[len(v)-maxLen/2:]) -} - -func TestTransportDialTLS(t *testing.T) { - var mu sync.Mutex // guards following - var gotReq, didDial bool - - ts := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - mu.Lock() - gotReq = true - mu.Unlock() - }, - optOnlyServer, - ) - defer ts.Close() - tr := &Transport{ - DialTLS: func(netw, addr string, cfg *tls.Config) (net.Conn, error) { - mu.Lock() - didDial = true - mu.Unlock() - cfg.InsecureSkipVerify = true - c, err := tls.Dial(netw, addr, cfg) - if err != nil { - return nil, err - } - return c, c.Handshake() - }, - } - defer tr.CloseIdleConnections() - client := &http.Client{Transport: tr} - res, err := client.Get(ts.ts.URL) - if err != nil { - t.Fatal(err) - } - res.Body.Close() - mu.Lock() - if !gotReq { - t.Error("didn't get request") - } - if !didDial { - t.Error("didn't use dial hook") - } -} - -func TestConfigureTransport(t *testing.T) { - t1 := &http.Transport{} - err := ConfigureTransport(t1) - if err == errTransportVersion { - t.Skip(err) - } - if err != nil { - t.Fatal(err) - } - if got := fmt.Sprintf("%#v", *t1); !strings.Contains(got, `"h2"`) { - // Laziness, to avoid buildtags. - t.Errorf("stringification of HTTP/1 transport didn't contain \"h2\": %v", got) - } - wantNextProtos := []string{"h2", "http/1.1"} - if t1.TLSClientConfig == nil { - t.Errorf("nil t1.TLSClientConfig") - } else if !reflect.DeepEqual(t1.TLSClientConfig.NextProtos, wantNextProtos) { - t.Errorf("TLSClientConfig.NextProtos = %q; want %q", t1.TLSClientConfig.NextProtos, wantNextProtos) - } - if err := ConfigureTransport(t1); err == nil { - t.Error("unexpected success on second call to ConfigureTransport") - } - - // And does it work? - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, r.Proto) - }, optOnlyServer) - defer st.Close() - - t1.TLSClientConfig.InsecureSkipVerify = true - c := &http.Client{Transport: t1} - res, err := c.Get(st.ts.URL) - if err != nil { - t.Fatal(err) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - t.Fatal(err) - } - if got, want := string(slurp), "HTTP/2.0"; got != want { - t.Errorf("body = %q; want %q", got, want) - } -} - -type capitalizeReader struct { - r io.Reader -} - -func (cr capitalizeReader) Read(p []byte) (n int, err error) { - n, err = cr.r.Read(p) - for i, b := range p[:n] { - if b >= 'a' && b <= 'z' { - p[i] = b - ('a' - 'A') - } - } - return -} - -type flushWriter struct { - w io.Writer -} - -func (fw flushWriter) Write(p []byte) (n int, err error) { - n, err = fw.w.Write(p) - if f, ok := fw.w.(http.Flusher); ok { - f.Flush() - } - return -} - -type clientTester struct { - t *testing.T - tr *Transport - sc, cc net.Conn // server and client conn - fr *Framer // server's framer - client func() error - server func() error -} - -func newClientTester(t *testing.T) *clientTester { - var dialOnce struct { - sync.Mutex - dialed bool - } - ct := &clientTester{ - t: t, - } - ct.tr = &Transport{ - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - dialOnce.Lock() - defer dialOnce.Unlock() - if dialOnce.dialed { - return nil, errors.New("only one dial allowed in test mode") - } - dialOnce.dialed = true - return ct.cc, nil - }, - } - - ln := newLocalListener(t) - cc, err := net.Dial("tcp", ln.Addr().String()) - if err != nil { - t.Fatal(err) - - } - sc, err := ln.Accept() - if err != nil { - t.Fatal(err) - } - ln.Close() - ct.cc = cc - ct.sc = sc - ct.fr = NewFramer(sc, sc) - return ct -} - -func newLocalListener(t *testing.T) net.Listener { - ln, err := net.Listen("tcp4", "127.0.0.1:0") - if err == nil { - return ln - } - ln, err = net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - return ln -} - -func (ct *clientTester) greet() { - buf := make([]byte, len(ClientPreface)) - _, err := io.ReadFull(ct.sc, buf) - if err != nil { - ct.t.Fatalf("reading client preface: %v", err) - } - f, err := ct.fr.ReadFrame() - if err != nil { - ct.t.Fatalf("Reading client settings frame: %v", err) - } - if sf, ok := f.(*SettingsFrame); !ok { - ct.t.Fatalf("Wanted client settings frame; got %v", f) - _ = sf // stash it away? - } - if err := ct.fr.WriteSettings(); err != nil { - ct.t.Fatal(err) - } - if err := ct.fr.WriteSettingsAck(); err != nil { - ct.t.Fatal(err) - } -} - -func (ct *clientTester) cleanup() { - ct.tr.CloseIdleConnections() -} - -func (ct *clientTester) run() { - errc := make(chan error, 2) - ct.start("client", errc, ct.client) - ct.start("server", errc, ct.server) - defer ct.cleanup() - for i := 0; i < 2; i++ { - if err := <-errc; err != nil { - ct.t.Error(err) - return - } - } -} - -func (ct *clientTester) start(which string, errc chan<- error, fn func() error) { - go func() { - finished := false - var err error - defer func() { - if !finished { - err = fmt.Errorf("%s goroutine didn't finish.", which) - } else if err != nil { - err = fmt.Errorf("%s: %v", which, err) - } - errc <- err - }() - err = fn() - finished = true - }() -} - -type countingReader struct { - n *int64 -} - -func (r countingReader) Read(p []byte) (n int, err error) { - for i := range p { - p[i] = byte(i) - } - atomic.AddInt64(r.n, int64(len(p))) - return len(p), err -} - -func TestTransportReqBodyAfterResponse_200(t *testing.T) { testTransportReqBodyAfterResponse(t, 200) } -func TestTransportReqBodyAfterResponse_403(t *testing.T) { testTransportReqBodyAfterResponse(t, 403) } - -func testTransportReqBodyAfterResponse(t *testing.T, status int) { - const bodySize = 10 << 20 - ct := newClientTester(t) - ct.client = func() error { - var n int64 // atomic - req, err := http.NewRequest("PUT", "https://dummy.tld/", io.LimitReader(countingReader{&n}, bodySize)) - if err != nil { - return err - } - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != status { - return fmt.Errorf("status code = %v; want %v", res.StatusCode, status) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("Slurp: %v", err) - } - if len(slurp) > 0 { - return fmt.Errorf("unexpected body: %q", slurp) - } - if status == 200 { - if got := atomic.LoadInt64(&n); got != bodySize { - return fmt.Errorf("For 200 response, Transport wrote %d bytes; want %d", got, bodySize) - } - } else { - if got := atomic.LoadInt64(&n); got == 0 || got >= bodySize { - return fmt.Errorf("For %d response, Transport wrote %d bytes; want (0,%d) exclusive", status, got, bodySize) - } - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - var dataRecv int64 - var closed bool - for { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - //println(fmt.Sprintf("server got frame: %v", f)) - switch f := f.(type) { - case *WindowUpdateFrame, *SettingsFrame: - case *HeadersFrame: - if !f.HeadersEnded() { - return fmt.Errorf("headers should have END_HEADERS be ended: %v", f) - } - if f.StreamEnded() { - return fmt.Errorf("headers contains END_STREAM unexpectedly: %v", f) - } - time.Sleep(50 * time.Millisecond) // let client send body - enc.WriteField(hpack.HeaderField{Name: ":status", Value: strconv.Itoa(status)}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: false, - BlockFragment: buf.Bytes(), - }) - case *DataFrame: - dataLen := len(f.Data()) - dataRecv += int64(dataLen) - if dataLen > 0 { - if err := ct.fr.WriteWindowUpdate(0, uint32(dataLen)); err != nil { - return err - } - if err := ct.fr.WriteWindowUpdate(f.StreamID, uint32(dataLen)); err != nil { - return err - } - } - if !closed && ((status != 200 && dataRecv > 0) || - (status == 200 && dataRecv == bodySize)) { - closed = true - if err := ct.fr.WriteData(f.StreamID, true, nil); err != nil { - return err - } - return nil - } - default: - return fmt.Errorf("Unexpected client frame %v", f) - } - } - } - ct.run() -} - -// See golang.org/issue/13444 -func TestTransportFullDuplex(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(200) // redundant but for clarity - w.(http.Flusher).Flush() - io.Copy(flushWriter{w}, capitalizeReader{r.Body}) - fmt.Fprintf(w, "bye.\n") - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - - pr, pw := io.Pipe() - req, err := http.NewRequest("PUT", st.ts.URL, ioutil.NopCloser(pr)) - if err != nil { - t.Fatal(err) - } - req.ContentLength = -1 - res, err := c.Do(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - t.Fatalf("StatusCode = %v; want %v", res.StatusCode, 200) - } - bs := bufio.NewScanner(res.Body) - want := func(v string) { - if !bs.Scan() { - t.Fatalf("wanted to read %q but Scan() = false, err = %v", v, bs.Err()) - } - } - write := func(v string) { - _, err := io.WriteString(pw, v) - if err != nil { - t.Fatalf("pipe write: %v", err) - } - } - write("foo\n") - want("FOO") - write("bar\n") - want("BAR") - pw.Close() - want("bye.") - if err := bs.Err(); err != nil { - t.Fatal(err) - } -} - -func TestTransportConnectRequest(t *testing.T) { - gotc := make(chan *http.Request, 1) - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - gotc <- r - }, optOnlyServer) - defer st.Close() - - u, err := url.Parse(st.ts.URL) - if err != nil { - t.Fatal(err) - } - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - - tests := []struct { - req *http.Request - want string - }{ - { - req: &http.Request{ - Method: "CONNECT", - Header: http.Header{}, - URL: u, - }, - want: u.Host, - }, - { - req: &http.Request{ - Method: "CONNECT", - Header: http.Header{}, - URL: u, - Host: "example.com:123", - }, - want: "example.com:123", - }, - } - - for i, tt := range tests { - res, err := c.Do(tt.req) - if err != nil { - t.Errorf("%d. RoundTrip = %v", i, err) - continue - } - res.Body.Close() - req := <-gotc - if req.Method != "CONNECT" { - t.Errorf("method = %q; want CONNECT", req.Method) - } - if req.Host != tt.want { - t.Errorf("Host = %q; want %q", req.Host, tt.want) - } - if req.URL.Host != tt.want { - t.Errorf("URL.Host = %q; want %q", req.URL.Host, tt.want) - } - } -} - -type headerType int - -const ( - noHeader headerType = iota // omitted - oneHeader - splitHeader // broken into continuation on purpose -) - -const ( - f0 = noHeader - f1 = oneHeader - f2 = splitHeader - d0 = false - d1 = true -) - -// Test all 36 combinations of response frame orders: -// (3 ways of 100-continue) * (2 ways of headers) * (2 ways of data) * (3 ways of trailers):func TestTransportResponsePattern_00f0(t *testing.T) { testTransportResponsePattern(h0, h1, false, h0) } -// Generated by http://play.golang.org/p/SScqYKJYXd -func TestTransportResPattern_c0h1d0t0(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f0) } -func TestTransportResPattern_c0h1d0t1(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f1) } -func TestTransportResPattern_c0h1d0t2(t *testing.T) { testTransportResPattern(t, f0, f1, d0, f2) } -func TestTransportResPattern_c0h1d1t0(t *testing.T) { testTransportResPattern(t, f0, f1, d1, f0) } -func TestTransportResPattern_c0h1d1t1(t *testing.T) { testTransportResPattern(t, f0, f1, d1, f1) } -func TestTransportResPattern_c0h1d1t2(t *testing.T) { testTransportResPattern(t, f0, f1, d1, f2) } -func TestTransportResPattern_c0h2d0t0(t *testing.T) { testTransportResPattern(t, f0, f2, d0, f0) } -func TestTransportResPattern_c0h2d0t1(t *testing.T) { testTransportResPattern(t, f0, f2, d0, f1) } -func TestTransportResPattern_c0h2d0t2(t *testing.T) { testTransportResPattern(t, f0, f2, d0, f2) } -func TestTransportResPattern_c0h2d1t0(t *testing.T) { testTransportResPattern(t, f0, f2, d1, f0) } -func TestTransportResPattern_c0h2d1t1(t *testing.T) { testTransportResPattern(t, f0, f2, d1, f1) } -func TestTransportResPattern_c0h2d1t2(t *testing.T) { testTransportResPattern(t, f0, f2, d1, f2) } -func TestTransportResPattern_c1h1d0t0(t *testing.T) { testTransportResPattern(t, f1, f1, d0, f0) } -func TestTransportResPattern_c1h1d0t1(t *testing.T) { testTransportResPattern(t, f1, f1, d0, f1) } -func TestTransportResPattern_c1h1d0t2(t *testing.T) { testTransportResPattern(t, f1, f1, d0, f2) } -func TestTransportResPattern_c1h1d1t0(t *testing.T) { testTransportResPattern(t, f1, f1, d1, f0) } -func TestTransportResPattern_c1h1d1t1(t *testing.T) { testTransportResPattern(t, f1, f1, d1, f1) } -func TestTransportResPattern_c1h1d1t2(t *testing.T) { testTransportResPattern(t, f1, f1, d1, f2) } -func TestTransportResPattern_c1h2d0t0(t *testing.T) { testTransportResPattern(t, f1, f2, d0, f0) } -func TestTransportResPattern_c1h2d0t1(t *testing.T) { testTransportResPattern(t, f1, f2, d0, f1) } -func TestTransportResPattern_c1h2d0t2(t *testing.T) { testTransportResPattern(t, f1, f2, d0, f2) } -func TestTransportResPattern_c1h2d1t0(t *testing.T) { testTransportResPattern(t, f1, f2, d1, f0) } -func TestTransportResPattern_c1h2d1t1(t *testing.T) { testTransportResPattern(t, f1, f2, d1, f1) } -func TestTransportResPattern_c1h2d1t2(t *testing.T) { testTransportResPattern(t, f1, f2, d1, f2) } -func TestTransportResPattern_c2h1d0t0(t *testing.T) { testTransportResPattern(t, f2, f1, d0, f0) } -func TestTransportResPattern_c2h1d0t1(t *testing.T) { testTransportResPattern(t, f2, f1, d0, f1) } -func TestTransportResPattern_c2h1d0t2(t *testing.T) { testTransportResPattern(t, f2, f1, d0, f2) } -func TestTransportResPattern_c2h1d1t0(t *testing.T) { testTransportResPattern(t, f2, f1, d1, f0) } -func TestTransportResPattern_c2h1d1t1(t *testing.T) { testTransportResPattern(t, f2, f1, d1, f1) } -func TestTransportResPattern_c2h1d1t2(t *testing.T) { testTransportResPattern(t, f2, f1, d1, f2) } -func TestTransportResPattern_c2h2d0t0(t *testing.T) { testTransportResPattern(t, f2, f2, d0, f0) } -func TestTransportResPattern_c2h2d0t1(t *testing.T) { testTransportResPattern(t, f2, f2, d0, f1) } -func TestTransportResPattern_c2h2d0t2(t *testing.T) { testTransportResPattern(t, f2, f2, d0, f2) } -func TestTransportResPattern_c2h2d1t0(t *testing.T) { testTransportResPattern(t, f2, f2, d1, f0) } -func TestTransportResPattern_c2h2d1t1(t *testing.T) { testTransportResPattern(t, f2, f2, d1, f1) } -func TestTransportResPattern_c2h2d1t2(t *testing.T) { testTransportResPattern(t, f2, f2, d1, f2) } - -func testTransportResPattern(t *testing.T, expect100Continue, resHeader headerType, withData bool, trailers headerType) { - const reqBody = "some request body" - const resBody = "some response body" - - if resHeader == noHeader { - // TODO: test 100-continue followed by immediate - // server stream reset, without headers in the middle? - panic("invalid combination") - } - - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("POST", "https://dummy.tld/", strings.NewReader(reqBody)) - if expect100Continue != noHeader { - req.Header.Set("Expect", "100-continue") - } - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - return fmt.Errorf("status code = %v; want 200", res.StatusCode) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("Slurp: %v", err) - } - wantBody := resBody - if !withData { - wantBody = "" - } - if string(slurp) != wantBody { - return fmt.Errorf("body = %q; want %q", slurp, wantBody) - } - if trailers == noHeader { - if len(res.Trailer) > 0 { - t.Errorf("Trailer = %v; want none", res.Trailer) - } - } else { - want := http.Header{"Some-Trailer": {"some-value"}} - if !reflect.DeepEqual(res.Trailer, want) { - t.Errorf("Trailer = %v; want %v", res.Trailer, want) - } - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - for { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - switch f := f.(type) { - case *WindowUpdateFrame, *SettingsFrame: - case *DataFrame: - // ignore for now. - case *HeadersFrame: - endStream := false - send := func(mode headerType) { - hbf := buf.Bytes() - switch mode { - case oneHeader: - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: endStream, - BlockFragment: hbf, - }) - case splitHeader: - if len(hbf) < 2 { - panic("too small") - } - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: false, - EndStream: endStream, - BlockFragment: hbf[:1], - }) - ct.fr.WriteContinuation(f.StreamID, true, hbf[1:]) - default: - panic("bogus mode") - } - } - if expect100Continue != noHeader { - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "100"}) - send(expect100Continue) - } - // Response headers (1+ frames; 1 or 2 in this test, but never 0) - { - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "x-foo", Value: "blah"}) - enc.WriteField(hpack.HeaderField{Name: "x-bar", Value: "more"}) - if trailers != noHeader { - enc.WriteField(hpack.HeaderField{Name: "trailer", Value: "some-trailer"}) - } - endStream = withData == false && trailers == noHeader - send(resHeader) - } - if withData { - endStream = trailers == noHeader - ct.fr.WriteData(f.StreamID, endStream, []byte(resBody)) - } - if trailers != noHeader { - endStream = true - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: "some-trailer", Value: "some-value"}) - send(trailers) - } - return nil - } - } - } - ct.run() -} - -func TestTransportReceiveUndeclaredTrailer(t *testing.T) { - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - return fmt.Errorf("status code = %v; want 200", res.StatusCode) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("res.Body ReadAll error = %q, %v; want %v", slurp, err, nil) - } - if len(slurp) > 0 { - return fmt.Errorf("body = %q; want nothing", slurp) - } - if _, ok := res.Trailer["Some-Trailer"]; !ok { - return fmt.Errorf("expected Some-Trailer") - } - return nil - } - ct.server = func() error { - ct.greet() - - var n int - var hf *HeadersFrame - for hf == nil && n < 10 { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - hf, _ = f.(*HeadersFrame) - n++ - } - - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - // send headers without Trailer header - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: false, - BlockFragment: buf.Bytes(), - }) - - // send trailers - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: "some-trailer", Value: "I'm an undeclared Trailer!"}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: true, - BlockFragment: buf.Bytes(), - }) - return nil - } - ct.run() -} - -func TestTransportInvalidTrailer_Pseudo1(t *testing.T) { - testTransportInvalidTrailer_Pseudo(t, oneHeader) -} -func TestTransportInvalidTrailer_Pseudo2(t *testing.T) { - testTransportInvalidTrailer_Pseudo(t, splitHeader) -} -func testTransportInvalidTrailer_Pseudo(t *testing.T, trailers headerType) { - testInvalidTrailer(t, trailers, pseudoHeaderError(":colon"), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: ":colon", Value: "foo"}) - enc.WriteField(hpack.HeaderField{Name: "foo", Value: "bar"}) - }) -} - -func TestTransportInvalidTrailer_Capital1(t *testing.T) { - testTransportInvalidTrailer_Capital(t, oneHeader) -} -func TestTransportInvalidTrailer_Capital2(t *testing.T) { - testTransportInvalidTrailer_Capital(t, splitHeader) -} -func testTransportInvalidTrailer_Capital(t *testing.T, trailers headerType) { - testInvalidTrailer(t, trailers, headerFieldNameError("Capital"), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: "foo", Value: "bar"}) - enc.WriteField(hpack.HeaderField{Name: "Capital", Value: "bad"}) - }) -} -func TestTransportInvalidTrailer_EmptyFieldName(t *testing.T) { - testInvalidTrailer(t, oneHeader, headerFieldNameError(""), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: "", Value: "bad"}) - }) -} -func TestTransportInvalidTrailer_BinaryFieldValue(t *testing.T) { - testInvalidTrailer(t, oneHeader, headerFieldValueError("has\nnewline"), func(enc *hpack.Encoder) { - enc.WriteField(hpack.HeaderField{Name: "x", Value: "has\nnewline"}) - }) -} - -func testInvalidTrailer(t *testing.T, trailers headerType, wantErr error, writeTrailer func(*hpack.Encoder)) { - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != nil { - return fmt.Errorf("RoundTrip: %v", err) - } - defer res.Body.Close() - if res.StatusCode != 200 { - return fmt.Errorf("status code = %v; want 200", res.StatusCode) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != wantErr { - return fmt.Errorf("res.Body ReadAll error = %q, %#v; want %T of %#v", slurp, err, wantErr, wantErr) - } - if len(slurp) > 0 { - return fmt.Errorf("body = %q; want nothing", slurp) - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - for { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - switch f := f.(type) { - case *HeadersFrame: - var endStream bool - send := func(mode headerType) { - hbf := buf.Bytes() - switch mode { - case oneHeader: - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: endStream, - BlockFragment: hbf, - }) - case splitHeader: - if len(hbf) < 2 { - panic("too small") - } - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: false, - EndStream: endStream, - BlockFragment: hbf[:1], - }) - ct.fr.WriteContinuation(f.StreamID, true, hbf[1:]) - default: - panic("bogus mode") - } - } - // Response headers (1+ frames; 1 or 2 in this test, but never 0) - { - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "trailer", Value: "declared"}) - endStream = false - send(oneHeader) - } - // Trailers: - { - endStream = true - buf.Reset() - writeTrailer(enc) - send(trailers) - } - return nil - } - } - } - ct.run() -} - -func TestTransportChecksResponseHeaderListSize(t *testing.T) { - ct := newClientTester(t) - ct.client = func() error { - req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != errResponseHeaderListSize { - if res != nil { - res.Body.Close() - } - size := int64(0) - for k, vv := range res.Header { - for _, v := range vv { - size += int64(len(k)) + int64(len(v)) + 32 - } - } - return fmt.Errorf("RoundTrip Error = %v (and %d bytes of response headers); want errResponseHeaderListSize", err, size) - } - return nil - } - ct.server = func() error { - ct.greet() - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - - for { - f, err := ct.fr.ReadFrame() - if err != nil { - return err - } - switch f := f.(type) { - case *HeadersFrame: - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - large := strings.Repeat("a", 1<<10) - for i := 0; i < 5042; i++ { - enc.WriteField(hpack.HeaderField{Name: large, Value: large}) - } - if size, want := buf.Len(), 6329; size != want { - // Note: this number might change if - // our hpack implementation - // changes. That's fine. This is - // just a sanity check that our - // response can fit in a single - // header block fragment frame. - return fmt.Errorf("encoding over 10MB of duplicate keypairs took %d bytes; expected %d", size, want) - } - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: true, - BlockFragment: buf.Bytes(), - }) - return nil - } - } - } - ct.run() -} - -// Test that the the Transport returns a typed error from Response.Body.Read calls -// when the server sends an error. (here we use a panic, since that should generate -// a stream error, but others like cancel should be similar) -func TestTransportBodyReadErrorType(t *testing.T) { - doPanic := make(chan bool, 1) - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - w.(http.Flusher).Flush() // force headers out - <-doPanic - panic("boom") - }, - optOnlyServer, - optQuiet, - ) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - - res, err := c.Get(st.ts.URL) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() - doPanic <- true - buf := make([]byte, 100) - n, err := res.Body.Read(buf) - want := StreamError{StreamID: 0x1, Code: 0x2} - if !reflect.DeepEqual(want, err) { - t.Errorf("Read = %v, %#v; want error %#v", n, err, want) - } -} - -// golang.org/issue/13924 -// This used to fail after many iterations, especially with -race: -// go test -v -run=TestTransportDoubleCloseOnWriteError -count=500 -race -func TestTransportDoubleCloseOnWriteError(t *testing.T) { - var ( - mu sync.Mutex - conn net.Conn // to close if set - ) - - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - mu.Lock() - defer mu.Unlock() - if conn != nil { - conn.Close() - } - }, - optOnlyServer, - ) - defer st.Close() - - tr := &Transport{ - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - tc, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - mu.Lock() - defer mu.Unlock() - conn = tc - return tc, nil - }, - } - defer tr.CloseIdleConnections() - c := &http.Client{Transport: tr} - c.Get(st.ts.URL) -} - -// Test that the http1 Transport.DisableKeepAlives option is respected -// and connections are closed as soon as idle. -// See golang.org/issue/14008 -func TestTransportDisableKeepAlives(t *testing.T) { - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, "hi") - }, - optOnlyServer, - ) - defer st.Close() - - connClosed := make(chan struct{}) // closed on tls.Conn.Close - tr := &Transport{ - t1: &http.Transport{ - DisableKeepAlives: true, - }, - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - tc, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - return ¬eCloseConn{Conn: tc, closefn: func() { close(connClosed) }}, nil - }, - } - c := &http.Client{Transport: tr} - res, err := c.Get(st.ts.URL) - if err != nil { - t.Fatal(err) - } - if _, err := ioutil.ReadAll(res.Body); err != nil { - t.Fatal(err) - } - defer res.Body.Close() - - select { - case <-connClosed: - case <-time.After(1 * time.Second): - t.Errorf("timeout") - } - -} - -// Test concurrent requests with Transport.DisableKeepAlives. We can share connections, -// but when things are totally idle, it still needs to close. -func TestTransportDisableKeepAlives_Concurrency(t *testing.T) { - const D = 25 * time.Millisecond - st := newServerTester(t, - func(w http.ResponseWriter, r *http.Request) { - time.Sleep(D) - io.WriteString(w, "hi") - }, - optOnlyServer, - ) - defer st.Close() - - var dials int32 - var conns sync.WaitGroup - tr := &Transport{ - t1: &http.Transport{ - DisableKeepAlives: true, - }, - TLSClientConfig: tlsConfigInsecure, - DialTLS: func(network, addr string, cfg *tls.Config) (net.Conn, error) { - tc, err := tls.Dial(network, addr, cfg) - if err != nil { - return nil, err - } - atomic.AddInt32(&dials, 1) - conns.Add(1) - return ¬eCloseConn{Conn: tc, closefn: func() { conns.Done() }}, nil - }, - } - c := &http.Client{Transport: tr} - var reqs sync.WaitGroup - const N = 20 - for i := 0; i < N; i++ { - reqs.Add(1) - if i == N-1 { - // For the final request, try to make all the - // others close. This isn't verified in the - // count, other than the Log statement, since - // it's so timing dependent. This test is - // really to make sure we don't interrupt a - // valid request. - time.Sleep(D * 2) - } - go func() { - defer reqs.Done() - res, err := c.Get(st.ts.URL) - if err != nil { - t.Error(err) - return - } - if _, err := ioutil.ReadAll(res.Body); err != nil { - t.Error(err) - return - } - res.Body.Close() - }() - } - reqs.Wait() - conns.Wait() - t.Logf("did %d dials, %d requests", atomic.LoadInt32(&dials), N) -} - -type noteCloseConn struct { - net.Conn - onceClose sync.Once - closefn func() -} - -func (c *noteCloseConn) Close() error { - c.onceClose.Do(c.closefn) - return c.Conn.Close() -} - -func isTimeout(err error) bool { - switch err := err.(type) { - case nil: - return false - case *url.Error: - return isTimeout(err.Err) - case net.Error: - return err.Timeout() - } - return false -} - -// Test that the http1 Transport.ResponseHeaderTimeout option and cancel is sent. -func TestTransportResponseHeaderTimeout_NoBody(t *testing.T) { - testTransportResponseHeaderTimeout(t, false) -} -func TestTransportResponseHeaderTimeout_Body(t *testing.T) { - testTransportResponseHeaderTimeout(t, true) -} - -func testTransportResponseHeaderTimeout(t *testing.T, body bool) { - ct := newClientTester(t) - ct.tr.t1 = &http.Transport{ - ResponseHeaderTimeout: 5 * time.Millisecond, - } - ct.client = func() error { - c := &http.Client{Transport: ct.tr} - var err error - var n int64 - const bodySize = 4 << 20 - if body { - _, err = c.Post("https://dummy.tld/", "text/foo", io.LimitReader(countingReader{&n}, bodySize)) - } else { - _, err = c.Get("https://dummy.tld/") - } - if !isTimeout(err) { - t.Errorf("client expected timeout error; got %#v", err) - } - if body && n != bodySize { - t.Errorf("only read %d bytes of body; want %d", n, bodySize) - } - return nil - } - ct.server = func() error { - ct.greet() - for { - f, err := ct.fr.ReadFrame() - if err != nil { - t.Logf("ReadFrame: %v", err) - return nil - } - switch f := f.(type) { - case *DataFrame: - dataLen := len(f.Data()) - if dataLen > 0 { - if err := ct.fr.WriteWindowUpdate(0, uint32(dataLen)); err != nil { - return err - } - if err := ct.fr.WriteWindowUpdate(f.StreamID, uint32(dataLen)); err != nil { - return err - } - } - case *RSTStreamFrame: - if f.StreamID == 1 && f.ErrCode == ErrCodeCancel { - return nil - } - } - } - } - ct.run() -} - -func TestTransportDisableCompression(t *testing.T) { - const body = "sup" - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - want := http.Header{ - "User-Agent": []string{"Go-http-client/2.0"}, - } - if !reflect.DeepEqual(r.Header, want) { - t.Errorf("request headers = %v; want %v", r.Header, want) - } - }, optOnlyServer) - defer st.Close() - - tr := &Transport{ - TLSClientConfig: tlsConfigInsecure, - t1: &http.Transport{ - DisableCompression: true, - }, - } - defer tr.CloseIdleConnections() - - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - defer res.Body.Close() -} - -// RFC 7540 section 8.1.2.2 -func TestTransportRejectsConnHeaders(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - var got []string - for k := range r.Header { - got = append(got, k) - } - sort.Strings(got) - w.Header().Set("Got-Header", strings.Join(got, ",")) - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - tests := []struct { - key string - value []string - want string - }{ - { - key: "Upgrade", - value: []string{"anything"}, - want: "ERROR: http2: invalid Upgrade request header", - }, - { - key: "Connection", - value: []string{"foo"}, - want: "ERROR: http2: invalid Connection request header", - }, - { - key: "Connection", - value: []string{"close"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Connection", - value: []string{"close", "something-else"}, - want: "ERROR: http2: invalid Connection request header", - }, - { - key: "Connection", - value: []string{"keep-alive"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Proxy-Connection", // just deleted and ignored - value: []string{"keep-alive"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Transfer-Encoding", - value: []string{""}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Transfer-Encoding", - value: []string{"foo"}, - want: "ERROR: http2: invalid Transfer-Encoding request header", - }, - { - key: "Transfer-Encoding", - value: []string{"chunked"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Transfer-Encoding", - value: []string{"chunked", "other"}, - want: "ERROR: http2: invalid Transfer-Encoding request header", - }, - { - key: "Content-Length", - value: []string{"123"}, - want: "Accept-Encoding,User-Agent", - }, - { - key: "Keep-Alive", - value: []string{"doop"}, - want: "Accept-Encoding,User-Agent", - }, - } - - for _, tt := range tests { - req, _ := http.NewRequest("GET", st.ts.URL, nil) - req.Header[tt.key] = tt.value - res, err := tr.RoundTrip(req) - var got string - if err != nil { - got = fmt.Sprintf("ERROR: %v", err) - } else { - got = res.Header.Get("Got-Header") - res.Body.Close() - } - if got != tt.want { - t.Errorf("For key %q, value %q, got = %q; want %q", tt.key, tt.value, got, tt.want) - } - } -} - -// golang.org/issue/14048 -func TestTransportFailsOnInvalidHeaders(t *testing.T) { - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - var got []string - for k := range r.Header { - got = append(got, k) - } - sort.Strings(got) - w.Header().Set("Got-Header", strings.Join(got, ",")) - }, optOnlyServer) - defer st.Close() - - tests := [...]struct { - h http.Header - wantErr string - }{ - 0: { - h: http.Header{"with space": {"foo"}}, - wantErr: `invalid HTTP header name "with space"`, - }, - 1: { - h: http.Header{"name": {"БрÑд"}}, - wantErr: "", // okay - }, - 2: { - h: http.Header{"имÑ": {"Brad"}}, - wantErr: `invalid HTTP header name "имÑ"`, - }, - 3: { - h: http.Header{"foo": {"foo\x01bar"}}, - wantErr: `invalid HTTP header value "foo\x01bar" for header "foo"`, - }, - } - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - for i, tt := range tests { - req, _ := http.NewRequest("GET", st.ts.URL, nil) - req.Header = tt.h - res, err := tr.RoundTrip(req) - var bad bool - if tt.wantErr == "" { - if err != nil { - bad = true - t.Errorf("case %d: error = %v; want no error", i, err) - } - } else { - if !strings.Contains(fmt.Sprint(err), tt.wantErr) { - bad = true - t.Errorf("case %d: error = %v; want error %q", i, err, tt.wantErr) - } - } - if err == nil { - if bad { - t.Logf("case %d: server got headers %q", i, res.Header.Get("Got-Header")) - } - res.Body.Close() - } - } -} - -// Tests that gzipReader doesn't crash on a second Read call following -// the first Read call's gzip.NewReader returning an error. -func TestGzipReader_DoubleReadCrash(t *testing.T) { - gz := &gzipReader{ - body: ioutil.NopCloser(strings.NewReader("0123456789")), - } - var buf [1]byte - n, err1 := gz.Read(buf[:]) - if n != 0 || !strings.Contains(fmt.Sprint(err1), "invalid header") { - t.Fatalf("Read = %v, %v; want 0, invalid header", n, err1) - } - n, err2 := gz.Read(buf[:]) - if n != 0 || err2 != err1 { - t.Fatalf("second Read = %v, %v; want 0, %v", n, err2, err1) - } -} - -func TestTransportNewTLSConfig(t *testing.T) { - tests := [...]struct { - conf *tls.Config - host string - want *tls.Config - }{ - // Normal case. - 0: { - conf: nil, - host: "foo.com", - want: &tls.Config{ - ServerName: "foo.com", - NextProtos: []string{NextProtoTLS}, - }, - }, - - // User-provided name (bar.com) takes precedence: - 1: { - conf: &tls.Config{ - ServerName: "bar.com", - }, - host: "foo.com", - want: &tls.Config{ - ServerName: "bar.com", - NextProtos: []string{NextProtoTLS}, - }, - }, - - // NextProto is prepended: - 2: { - conf: &tls.Config{ - NextProtos: []string{"foo", "bar"}, - }, - host: "example.com", - want: &tls.Config{ - ServerName: "example.com", - NextProtos: []string{NextProtoTLS, "foo", "bar"}, - }, - }, - - // NextProto is not duplicated: - 3: { - conf: &tls.Config{ - NextProtos: []string{"foo", "bar", NextProtoTLS}, - }, - host: "example.com", - want: &tls.Config{ - ServerName: "example.com", - NextProtos: []string{"foo", "bar", NextProtoTLS}, - }, - }, - } - for i, tt := range tests { - tr := &Transport{TLSClientConfig: tt.conf} - got := tr.newTLSConfig(tt.host) - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("%d. got %#v; want %#v", i, got, tt.want) - } - } -} - -// The Google GFE responds to HEAD requests with a HEADERS frame -// without END_STREAM, followed by a 0-length DATA frame with -// END_STREAM. Make sure we don't get confused by that. (We did.) -func TestTransportReadHeadResponse(t *testing.T) { - ct := newClientTester(t) - clientDone := make(chan struct{}) - ct.client = func() error { - defer close(clientDone) - req, _ := http.NewRequest("HEAD", "https://dummy.tld/", nil) - res, err := ct.tr.RoundTrip(req) - if err != nil { - return err - } - if res.ContentLength != 123 { - return fmt.Errorf("Content-Length = %d; want 123", res.ContentLength) - } - slurp, err := ioutil.ReadAll(res.Body) - if err != nil { - return fmt.Errorf("ReadAll: %v", err) - } - if len(slurp) > 0 { - return fmt.Errorf("Unexpected non-empty ReadAll body: %q", slurp) - } - return nil - } - ct.server = func() error { - ct.greet() - for { - f, err := ct.fr.ReadFrame() - if err != nil { - t.Logf("ReadFrame: %v", err) - return nil - } - hf, ok := f.(*HeadersFrame) - if !ok { - continue - } - var buf bytes.Buffer - enc := hpack.NewEncoder(&buf) - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) - enc.WriteField(hpack.HeaderField{Name: "content-length", Value: "123"}) - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: hf.StreamID, - EndHeaders: true, - EndStream: false, // as the GFE does - BlockFragment: buf.Bytes(), - }) - ct.fr.WriteData(hf.StreamID, true, nil) - - <-clientDone - return nil - } - } - ct.run() -} - -type neverEnding byte - -func (b neverEnding) Read(p []byte) (int, error) { - for i := range p { - p[i] = byte(b) - } - return len(p), nil -} - -// golang.org/issue/15425: test that a handler closing the request -// body doesn't terminate the stream to the peer. (It just stops -// readability from the handler's side, and eventually the client -// runs out of flow control tokens) -func TestTransportHandlerBodyClose(t *testing.T) { - const bodySize = 10 << 20 - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - r.Body.Close() - io.Copy(w, io.LimitReader(neverEnding('A'), bodySize)) - }, optOnlyServer) - defer st.Close() - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - - g0 := runtime.NumGoroutine() - - const numReq = 10 - for i := 0; i < numReq; i++ { - req, err := http.NewRequest("POST", st.ts.URL, struct{ io.Reader }{io.LimitReader(neverEnding('A'), bodySize)}) - if err != nil { - t.Fatal(err) - } - res, err := tr.RoundTrip(req) - if err != nil { - t.Fatal(err) - } - n, err := io.Copy(ioutil.Discard, res.Body) - res.Body.Close() - if n != bodySize || err != nil { - t.Fatalf("req#%d: Copy = %d, %v; want %d, nil", i, n, err, bodySize) - } - } - tr.CloseIdleConnections() - - gd := runtime.NumGoroutine() - g0 - if gd > numReq/2 { - t.Errorf("appeared to leak goroutines") - } - -} - -// https://golang.org/issue/15930 -func TestTransportFlowControl(t *testing.T) { - const ( - total = 100 << 20 // 100MB - bufLen = 1 << 16 - ) - - var wrote int64 // updated atomically - st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { - b := make([]byte, bufLen) - for wrote < total { - n, err := w.Write(b) - atomic.AddInt64(&wrote, int64(n)) - if err != nil { - t.Errorf("ResponseWriter.Write error: %v", err) - break - } - w.(http.Flusher).Flush() - } - }, optOnlyServer) - - tr := &Transport{TLSClientConfig: tlsConfigInsecure} - defer tr.CloseIdleConnections() - req, err := http.NewRequest("GET", st.ts.URL, nil) - if err != nil { - t.Fatal("NewRequest error:", err) - } - resp, err := tr.RoundTrip(req) - if err != nil { - t.Fatal("RoundTrip error:", err) - } - defer resp.Body.Close() - - var read int64 - b := make([]byte, bufLen) - for { - n, err := resp.Body.Read(b) - if err == io.EOF { - break - } - if err != nil { - t.Fatal("Read error:", err) - } - read += int64(n) - - const max = transportDefaultStreamFlow - if w := atomic.LoadInt64(&wrote); -max > read-w || read-w > max { - t.Fatalf("Too much data inflight: server wrote %v bytes but client only received %v", w, read) - } - - // Let the server get ahead of the client. - time.Sleep(1 * time.Millisecond) - } -} diff --git a/vendor/golang.org/x/net/http2/write.go b/vendor/golang.org/x/net/http2/write.go deleted file mode 100644 index 27ef0dd..0000000 --- a/vendor/golang.org/x/net/http2/write.go +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "fmt" - "log" - "net/http" - "time" - - "golang.org/x/net/http2/hpack" - "golang.org/x/net/lex/httplex" -) - -// writeFramer is implemented by any type that is used to write frames. -type writeFramer interface { - writeFrame(writeContext) error -} - -// writeContext is the interface needed by the various frame writer -// types below. All the writeFrame methods below are scheduled via the -// frame writing scheduler (see writeScheduler in writesched.go). -// -// This interface is implemented by *serverConn. -// -// TODO: decide whether to a) use this in the client code (which didn't -// end up using this yet, because it has a simpler design, not -// currently implementing priorities), or b) delete this and -// make the server code a bit more concrete. -type writeContext interface { - Framer() *Framer - Flush() error - CloseConn() error - // HeaderEncoder returns an HPACK encoder that writes to the - // returned buffer. - HeaderEncoder() (*hpack.Encoder, *bytes.Buffer) -} - -// endsStream reports whether the given frame writer w will locally -// close the stream. -func endsStream(w writeFramer) bool { - switch v := w.(type) { - case *writeData: - return v.endStream - case *writeResHeaders: - return v.endStream - case nil: - // This can only happen if the caller reuses w after it's - // been intentionally nil'ed out to prevent use. Keep this - // here to catch future refactoring breaking it. - panic("endsStream called on nil writeFramer") - } - return false -} - -type flushFrameWriter struct{} - -func (flushFrameWriter) writeFrame(ctx writeContext) error { - return ctx.Flush() -} - -type writeSettings []Setting - -func (s writeSettings) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteSettings([]Setting(s)...) -} - -type writeGoAway struct { - maxStreamID uint32 - code ErrCode -} - -func (p *writeGoAway) writeFrame(ctx writeContext) error { - err := ctx.Framer().WriteGoAway(p.maxStreamID, p.code, nil) - if p.code != 0 { - ctx.Flush() // ignore error: we're hanging up on them anyway - time.Sleep(50 * time.Millisecond) - ctx.CloseConn() - } - return err -} - -type writeData struct { - streamID uint32 - p []byte - endStream bool -} - -func (w *writeData) String() string { - return fmt.Sprintf("writeData(stream=%d, p=%d, endStream=%v)", w.streamID, len(w.p), w.endStream) -} - -func (w *writeData) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteData(w.streamID, w.endStream, w.p) -} - -// handlerPanicRST is the message sent from handler goroutines when -// the handler panics. -type handlerPanicRST struct { - StreamID uint32 -} - -func (hp handlerPanicRST) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteRSTStream(hp.StreamID, ErrCodeInternal) -} - -func (se StreamError) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteRSTStream(se.StreamID, se.Code) -} - -type writePingAck struct{ pf *PingFrame } - -func (w writePingAck) writeFrame(ctx writeContext) error { - return ctx.Framer().WritePing(true, w.pf.Data) -} - -type writeSettingsAck struct{} - -func (writeSettingsAck) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteSettingsAck() -} - -// writeResHeaders is a request to write a HEADERS and 0+ CONTINUATION frames -// for HTTP response headers or trailers from a server handler. -type writeResHeaders struct { - streamID uint32 - httpResCode int // 0 means no ":status" line - h http.Header // may be nil - trailers []string // if non-nil, which keys of h to write. nil means all. - endStream bool - - date string - contentType string - contentLength string -} - -func encKV(enc *hpack.Encoder, k, v string) { - if VerboseLogs { - log.Printf("http2: server encoding header %q = %q", k, v) - } - enc.WriteField(hpack.HeaderField{Name: k, Value: v}) -} - -func (w *writeResHeaders) writeFrame(ctx writeContext) error { - enc, buf := ctx.HeaderEncoder() - buf.Reset() - - if w.httpResCode != 0 { - encKV(enc, ":status", httpCodeString(w.httpResCode)) - } - - encodeHeaders(enc, w.h, w.trailers) - - if w.contentType != "" { - encKV(enc, "content-type", w.contentType) - } - if w.contentLength != "" { - encKV(enc, "content-length", w.contentLength) - } - if w.date != "" { - encKV(enc, "date", w.date) - } - - headerBlock := buf.Bytes() - if len(headerBlock) == 0 && w.trailers == nil { - panic("unexpected empty hpack") - } - - // For now we're lazy and just pick the minimum MAX_FRAME_SIZE - // that all peers must support (16KB). Later we could care - // more and send larger frames if the peer advertised it, but - // there's little point. Most headers are small anyway (so we - // generally won't have CONTINUATION frames), and extra frames - // only waste 9 bytes anyway. - const maxFrameSize = 16384 - - first := true - for len(headerBlock) > 0 { - frag := headerBlock - if len(frag) > maxFrameSize { - frag = frag[:maxFrameSize] - } - headerBlock = headerBlock[len(frag):] - endHeaders := len(headerBlock) == 0 - var err error - if first { - first = false - err = ctx.Framer().WriteHeaders(HeadersFrameParam{ - StreamID: w.streamID, - BlockFragment: frag, - EndStream: w.endStream, - EndHeaders: endHeaders, - }) - } else { - err = ctx.Framer().WriteContinuation(w.streamID, endHeaders, frag) - } - if err != nil { - return err - } - } - return nil -} - -type write100ContinueHeadersFrame struct { - streamID uint32 -} - -func (w write100ContinueHeadersFrame) writeFrame(ctx writeContext) error { - enc, buf := ctx.HeaderEncoder() - buf.Reset() - encKV(enc, ":status", "100") - return ctx.Framer().WriteHeaders(HeadersFrameParam{ - StreamID: w.streamID, - BlockFragment: buf.Bytes(), - EndStream: false, - EndHeaders: true, - }) -} - -type writeWindowUpdate struct { - streamID uint32 // or 0 for conn-level - n uint32 -} - -func (wu writeWindowUpdate) writeFrame(ctx writeContext) error { - return ctx.Framer().WriteWindowUpdate(wu.streamID, wu.n) -} - -func encodeHeaders(enc *hpack.Encoder, h http.Header, keys []string) { - if keys == nil { - sorter := sorterPool.Get().(*sorter) - // Using defer here, since the returned keys from the - // sorter.Keys method is only valid until the sorter - // is returned: - defer sorterPool.Put(sorter) - keys = sorter.Keys(h) - } - for _, k := range keys { - vv := h[k] - k = lowerHeader(k) - if !validWireHeaderFieldName(k) { - // Skip it as backup paranoia. Per - // golang.org/issue/14048, these should - // already be rejected at a higher level. - continue - } - isTE := k == "transfer-encoding" - for _, v := range vv { - if !httplex.ValidHeaderFieldValue(v) { - // TODO: return an error? golang.org/issue/14048 - // For now just omit it. - continue - } - // TODO: more of "8.1.2.2 Connection-Specific Header Fields" - if isTE && v != "trailers" { - continue - } - encKV(enc, k, v) - } - } -} diff --git a/vendor/golang.org/x/net/http2/writesched.go b/vendor/golang.org/x/net/http2/writesched.go deleted file mode 100644 index c24316c..0000000 --- a/vendor/golang.org/x/net/http2/writesched.go +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import "fmt" - -// frameWriteMsg is a request to write a frame. -type frameWriteMsg struct { - // write is the interface value that does the writing, once the - // writeScheduler (below) has decided to select this frame - // to write. The write functions are all defined in write.go. - write writeFramer - - stream *stream // used for prioritization. nil for non-stream frames. - - // done, if non-nil, must be a buffered channel with space for - // 1 message and is sent the return value from write (or an - // earlier error) when the frame has been written. - done chan error -} - -// for debugging only: -func (wm frameWriteMsg) String() string { - var streamID uint32 - if wm.stream != nil { - streamID = wm.stream.id - } - var des string - if s, ok := wm.write.(fmt.Stringer); ok { - des = s.String() - } else { - des = fmt.Sprintf("%T", wm.write) - } - return fmt.Sprintf("[frameWriteMsg stream=%d, ch=%v, type: %v]", streamID, wm.done != nil, des) -} - -// writeScheduler tracks pending frames to write, priorities, and decides -// the next one to use. It is not thread-safe. -type writeScheduler struct { - // zero are frames not associated with a specific stream. - // They're sent before any stream-specific freams. - zero writeQueue - - // maxFrameSize is the maximum size of a DATA frame - // we'll write. Must be non-zero and between 16K-16M. - maxFrameSize uint32 - - // sq contains the stream-specific queues, keyed by stream ID. - // when a stream is idle, it's deleted from the map. - sq map[uint32]*writeQueue - - // canSend is a slice of memory that's reused between frame - // scheduling decisions to hold the list of writeQueues (from sq) - // which have enough flow control data to send. After canSend is - // built, the best is selected. - canSend []*writeQueue - - // pool of empty queues for reuse. - queuePool []*writeQueue -} - -func (ws *writeScheduler) putEmptyQueue(q *writeQueue) { - if len(q.s) != 0 { - panic("queue must be empty") - } - ws.queuePool = append(ws.queuePool, q) -} - -func (ws *writeScheduler) getEmptyQueue() *writeQueue { - ln := len(ws.queuePool) - if ln == 0 { - return new(writeQueue) - } - q := ws.queuePool[ln-1] - ws.queuePool = ws.queuePool[:ln-1] - return q -} - -func (ws *writeScheduler) empty() bool { return ws.zero.empty() && len(ws.sq) == 0 } - -func (ws *writeScheduler) add(wm frameWriteMsg) { - st := wm.stream - if st == nil { - ws.zero.push(wm) - } else { - ws.streamQueue(st.id).push(wm) - } -} - -func (ws *writeScheduler) streamQueue(streamID uint32) *writeQueue { - if q, ok := ws.sq[streamID]; ok { - return q - } - if ws.sq == nil { - ws.sq = make(map[uint32]*writeQueue) - } - q := ws.getEmptyQueue() - ws.sq[streamID] = q - return q -} - -// take returns the most important frame to write and removes it from the scheduler. -// It is illegal to call this if the scheduler is empty or if there are no connection-level -// flow control bytes available. -func (ws *writeScheduler) take() (wm frameWriteMsg, ok bool) { - if ws.maxFrameSize == 0 { - panic("internal error: ws.maxFrameSize not initialized or invalid") - } - - // If there any frames not associated with streams, prefer those first. - // These are usually SETTINGS, etc. - if !ws.zero.empty() { - return ws.zero.shift(), true - } - if len(ws.sq) == 0 { - return - } - - // Next, prioritize frames on streams that aren't DATA frames (no cost). - for id, q := range ws.sq { - if q.firstIsNoCost() { - return ws.takeFrom(id, q) - } - } - - // Now, all that remains are DATA frames with non-zero bytes to - // send. So pick the best one. - if len(ws.canSend) != 0 { - panic("should be empty") - } - for _, q := range ws.sq { - if n := ws.streamWritableBytes(q); n > 0 { - ws.canSend = append(ws.canSend, q) - } - } - if len(ws.canSend) == 0 { - return - } - defer ws.zeroCanSend() - - // TODO: find the best queue - q := ws.canSend[0] - - return ws.takeFrom(q.streamID(), q) -} - -// zeroCanSend is defered from take. -func (ws *writeScheduler) zeroCanSend() { - for i := range ws.canSend { - ws.canSend[i] = nil - } - ws.canSend = ws.canSend[:0] -} - -// streamWritableBytes returns the number of DATA bytes we could write -// from the given queue's stream, if this stream/queue were -// selected. It is an error to call this if q's head isn't a -// *writeData. -func (ws *writeScheduler) streamWritableBytes(q *writeQueue) int32 { - wm := q.head() - ret := wm.stream.flow.available() // max we can write - if ret == 0 { - return 0 - } - if int32(ws.maxFrameSize) < ret { - ret = int32(ws.maxFrameSize) - } - if ret == 0 { - panic("internal error: ws.maxFrameSize not initialized or invalid") - } - wd := wm.write.(*writeData) - if len(wd.p) < int(ret) { - ret = int32(len(wd.p)) - } - return ret -} - -func (ws *writeScheduler) takeFrom(id uint32, q *writeQueue) (wm frameWriteMsg, ok bool) { - wm = q.head() - // If the first item in this queue costs flow control tokens - // and we don't have enough, write as much as we can. - if wd, ok := wm.write.(*writeData); ok && len(wd.p) > 0 { - allowed := wm.stream.flow.available() // max we can write - if allowed == 0 { - // No quota available. Caller can try the next stream. - return frameWriteMsg{}, false - } - if int32(ws.maxFrameSize) < allowed { - allowed = int32(ws.maxFrameSize) - } - // TODO: further restrict the allowed size, because even if - // the peer says it's okay to write 16MB data frames, we might - // want to write smaller ones to properly weight competing - // streams' priorities. - - if len(wd.p) > int(allowed) { - wm.stream.flow.take(allowed) - chunk := wd.p[:allowed] - wd.p = wd.p[allowed:] - // Make up a new write message of a valid size, rather - // than shifting one off the queue. - return frameWriteMsg{ - stream: wm.stream, - write: &writeData{ - streamID: wd.streamID, - p: chunk, - // even if the original had endStream set, there - // arebytes remaining because len(wd.p) > allowed, - // so we know endStream is false: - endStream: false, - }, - // our caller is blocking on the final DATA frame, not - // these intermediates, so no need to wait: - done: nil, - }, true - } - wm.stream.flow.take(int32(len(wd.p))) - } - - q.shift() - if q.empty() { - ws.putEmptyQueue(q) - delete(ws.sq, id) - } - return wm, true -} - -func (ws *writeScheduler) forgetStream(id uint32) { - q, ok := ws.sq[id] - if !ok { - return - } - delete(ws.sq, id) - - // But keep it for others later. - for i := range q.s { - q.s[i] = frameWriteMsg{} - } - q.s = q.s[:0] - ws.putEmptyQueue(q) -} - -type writeQueue struct { - s []frameWriteMsg -} - -// streamID returns the stream ID for a non-empty stream-specific queue. -func (q *writeQueue) streamID() uint32 { return q.s[0].stream.id } - -func (q *writeQueue) empty() bool { return len(q.s) == 0 } - -func (q *writeQueue) push(wm frameWriteMsg) { - q.s = append(q.s, wm) -} - -// head returns the next item that would be removed by shift. -func (q *writeQueue) head() frameWriteMsg { - if len(q.s) == 0 { - panic("invalid use of queue") - } - return q.s[0] -} - -func (q *writeQueue) shift() frameWriteMsg { - if len(q.s) == 0 { - panic("invalid use of queue") - } - wm := q.s[0] - // TODO: less copy-happy queue. - copy(q.s, q.s[1:]) - q.s[len(q.s)-1] = frameWriteMsg{} - q.s = q.s[:len(q.s)-1] - return wm -} - -func (q *writeQueue) firstIsNoCost() bool { - if df, ok := q.s[0].write.(*writeData); ok { - return len(df.p) == 0 - } - return true -} diff --git a/vendor/golang.org/x/net/http2/z_spec_test.go b/vendor/golang.org/x/net/http2/z_spec_test.go deleted file mode 100644 index 0590cfd..0000000 --- a/vendor/golang.org/x/net/http2/z_spec_test.go +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package http2 - -import ( - "bytes" - "encoding/xml" - "flag" - "fmt" - "io" - "os" - "reflect" - "regexp" - "sort" - "strconv" - "strings" - "sync" - "testing" -) - -var coverSpec = flag.Bool("coverspec", false, "Run spec coverage tests") - -// The global map of sentence coverage for the http2 spec. -var defaultSpecCoverage specCoverage - -var loadSpecOnce sync.Once - -func loadSpec() { - if f, err := os.Open("testdata/draft-ietf-httpbis-http2.xml"); err != nil { - panic(err) - } else { - defaultSpecCoverage = readSpecCov(f) - f.Close() - } -} - -// covers marks all sentences for section sec in defaultSpecCoverage. Sentences not -// "covered" will be included in report outputted by TestSpecCoverage. -func covers(sec, sentences string) { - loadSpecOnce.Do(loadSpec) - defaultSpecCoverage.cover(sec, sentences) -} - -type specPart struct { - section string - sentence string -} - -func (ss specPart) Less(oo specPart) bool { - atoi := func(s string) int { - n, err := strconv.Atoi(s) - if err != nil { - panic(err) - } - return n - } - a := strings.Split(ss.section, ".") - b := strings.Split(oo.section, ".") - for len(a) > 0 { - if len(b) == 0 { - return false - } - x, y := atoi(a[0]), atoi(b[0]) - if x == y { - a, b = a[1:], b[1:] - continue - } - return x < y - } - if len(b) > 0 { - return true - } - return false -} - -type bySpecSection []specPart - -func (a bySpecSection) Len() int { return len(a) } -func (a bySpecSection) Less(i, j int) bool { return a[i].Less(a[j]) } -func (a bySpecSection) Swap(i, j int) { a[i], a[j] = a[j], a[i] } - -type specCoverage struct { - coverage map[specPart]bool - d *xml.Decoder -} - -func joinSection(sec []int) string { - s := fmt.Sprintf("%d", sec[0]) - for _, n := range sec[1:] { - s = fmt.Sprintf("%s.%d", s, n) - } - return s -} - -func (sc specCoverage) readSection(sec []int) { - var ( - buf = new(bytes.Buffer) - sub = 0 - ) - for { - tk, err := sc.d.Token() - if err != nil { - if err == io.EOF { - return - } - panic(err) - } - switch v := tk.(type) { - case xml.StartElement: - if skipElement(v) { - if err := sc.d.Skip(); err != nil { - panic(err) - } - if v.Name.Local == "section" { - sub++ - } - break - } - switch v.Name.Local { - case "section": - sub++ - sc.readSection(append(sec, sub)) - case "xref": - buf.Write(sc.readXRef(v)) - } - case xml.CharData: - if len(sec) == 0 { - break - } - buf.Write(v) - case xml.EndElement: - if v.Name.Local == "section" { - sc.addSentences(joinSection(sec), buf.String()) - return - } - } - } -} - -func (sc specCoverage) readXRef(se xml.StartElement) []byte { - var b []byte - for { - tk, err := sc.d.Token() - if err != nil { - panic(err) - } - switch v := tk.(type) { - case xml.CharData: - if b != nil { - panic("unexpected CharData") - } - b = []byte(string(v)) - case xml.EndElement: - if v.Name.Local != "xref" { - panic("expected ") - } - if b != nil { - return b - } - sig := attrSig(se) - switch sig { - case "target": - return []byte(fmt.Sprintf("[%s]", attrValue(se, "target"))) - case "fmt-of,rel,target", "fmt-,,rel,target": - return []byte(fmt.Sprintf("[%s, %s]", attrValue(se, "target"), attrValue(se, "rel"))) - case "fmt-of,sec,target", "fmt-,,sec,target": - return []byte(fmt.Sprintf("[section %s of %s]", attrValue(se, "sec"), attrValue(se, "target"))) - case "fmt-of,rel,sec,target": - return []byte(fmt.Sprintf("[section %s of %s, %s]", attrValue(se, "sec"), attrValue(se, "target"), attrValue(se, "rel"))) - default: - panic(fmt.Sprintf("unknown attribute signature %q in %#v", sig, fmt.Sprintf("%#v", se))) - } - default: - panic(fmt.Sprintf("unexpected tag %q", v)) - } - } -} - -var skipAnchor = map[string]bool{ - "intro": true, - "Overview": true, -} - -var skipTitle = map[string]bool{ - "Acknowledgements": true, - "Change Log": true, - "Document Organization": true, - "Conventions and Terminology": true, -} - -func skipElement(s xml.StartElement) bool { - switch s.Name.Local { - case "artwork": - return true - case "section": - for _, attr := range s.Attr { - switch attr.Name.Local { - case "anchor": - if skipAnchor[attr.Value] || strings.HasPrefix(attr.Value, "changes.since.") { - return true - } - case "title": - if skipTitle[attr.Value] { - return true - } - } - } - } - return false -} - -func readSpecCov(r io.Reader) specCoverage { - sc := specCoverage{ - coverage: map[specPart]bool{}, - d: xml.NewDecoder(r)} - sc.readSection(nil) - return sc -} - -func (sc specCoverage) addSentences(sec string, sentence string) { - for _, s := range parseSentences(sentence) { - sc.coverage[specPart{sec, s}] = false - } -} - -func (sc specCoverage) cover(sec string, sentence string) { - for _, s := range parseSentences(sentence) { - p := specPart{sec, s} - if _, ok := sc.coverage[p]; !ok { - panic(fmt.Sprintf("Not found in spec: %q, %q", sec, s)) - } - sc.coverage[specPart{sec, s}] = true - } - -} - -var whitespaceRx = regexp.MustCompile(`\s+`) - -func parseSentences(sens string) []string { - sens = strings.TrimSpace(sens) - if sens == "" { - return nil - } - ss := strings.Split(whitespaceRx.ReplaceAllString(sens, " "), ". ") - for i, s := range ss { - s = strings.TrimSpace(s) - if !strings.HasSuffix(s, ".") { - s += "." - } - ss[i] = s - } - return ss -} - -func TestSpecParseSentences(t *testing.T) { - tests := []struct { - ss string - want []string - }{ - {"Sentence 1. Sentence 2.", - []string{ - "Sentence 1.", - "Sentence 2.", - }}, - {"Sentence 1. \nSentence 2.\tSentence 3.", - []string{ - "Sentence 1.", - "Sentence 2.", - "Sentence 3.", - }}, - } - - for i, tt := range tests { - got := parseSentences(tt.ss) - if !reflect.DeepEqual(got, tt.want) { - t.Errorf("%d: got = %q, want %q", i, got, tt.want) - } - } -} - -func TestSpecCoverage(t *testing.T) { - if !*coverSpec { - t.Skip() - } - - loadSpecOnce.Do(loadSpec) - - var ( - list []specPart - cv = defaultSpecCoverage.coverage - total = len(cv) - complete = 0 - ) - - for sp, touched := range defaultSpecCoverage.coverage { - if touched { - complete++ - } else { - list = append(list, sp) - } - } - sort.Stable(bySpecSection(list)) - - if testing.Short() && len(list) > 5 { - list = list[:5] - } - - for _, p := range list { - t.Errorf("\tSECTION %s: %s", p.section, p.sentence) - } - - t.Logf("%d/%d (%d%%) sentances covered", complete, total, (complete/total)*100) -} - -func attrSig(se xml.StartElement) string { - var names []string - for _, attr := range se.Attr { - if attr.Name.Local == "fmt" { - names = append(names, "fmt-"+attr.Value) - } else { - names = append(names, attr.Name.Local) - } - } - sort.Strings(names) - return strings.Join(names, ",") -} - -func attrValue(se xml.StartElement, attr string) string { - for _, a := range se.Attr { - if a.Name.Local == attr { - return a.Value - } - } - panic("unknown attribute " + attr) -} - -func TestSpecPartLess(t *testing.T) { - tests := []struct { - sec1, sec2 string - want bool - }{ - {"6.2.1", "6.2", false}, - {"6.2", "6.2.1", true}, - {"6.10", "6.10.1", true}, - {"6.10", "6.1.1", false}, // 10, not 1 - {"6.1", "6.1", false}, // equal, so not less - } - for _, tt := range tests { - got := (specPart{tt.sec1, "foo"}).Less(specPart{tt.sec2, "foo"}) - if got != tt.want { - t.Errorf("Less(%q, %q) = %v; want %v", tt.sec1, tt.sec2, got, tt.want) - } - } -} diff --git a/vendor/golang.org/x/net/icmp/dstunreach.go b/vendor/golang.org/x/net/icmp/dstunreach.go deleted file mode 100644 index 75db991..0000000 --- a/vendor/golang.org/x/net/icmp/dstunreach.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -// A DstUnreach represents an ICMP destination unreachable message -// body. -type DstUnreach struct { - Data []byte // data, known as original datagram field - Extensions []Extension // extensions -} - -// Len implements the Len method of MessageBody interface. -func (p *DstUnreach) Len(proto int) int { - if p == nil { - return 0 - } - l, _ := multipartMessageBodyDataLen(proto, p.Data, p.Extensions) - return 4 + l -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *DstUnreach) Marshal(proto int) ([]byte, error) { - return marshalMultipartMessageBody(proto, p.Data, p.Extensions) -} - -// parseDstUnreach parses b as an ICMP destination unreachable message -// body. -func parseDstUnreach(proto int, b []byte) (MessageBody, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - p := &DstUnreach{} - var err error - p.Data, p.Extensions, err = parseMultipartMessageBody(proto, b) - if err != nil { - return nil, err - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/echo.go b/vendor/golang.org/x/net/icmp/echo.go deleted file mode 100644 index dd55181..0000000 --- a/vendor/golang.org/x/net/icmp/echo.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// An Echo represents an ICMP echo request or reply message body. -type Echo struct { - ID int // identifier - Seq int // sequence number - Data []byte // data -} - -// Len implements the Len method of MessageBody interface. -func (p *Echo) Len(proto int) int { - if p == nil { - return 0 - } - return 4 + len(p.Data) -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *Echo) Marshal(proto int) ([]byte, error) { - b := make([]byte, 4+len(p.Data)) - binary.BigEndian.PutUint16(b[:2], uint16(p.ID)) - binary.BigEndian.PutUint16(b[2:4], uint16(p.Seq)) - copy(b[4:], p.Data) - return b, nil -} - -// parseEcho parses b as an ICMP echo request or reply message body. -func parseEcho(proto int, b []byte) (MessageBody, error) { - bodyLen := len(b) - if bodyLen < 4 { - return nil, errMessageTooShort - } - p := &Echo{ID: int(binary.BigEndian.Uint16(b[:2])), Seq: int(binary.BigEndian.Uint16(b[2:4]))} - if bodyLen > 4 { - p.Data = make([]byte, bodyLen-4) - copy(p.Data, b[4:]) - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/endpoint.go b/vendor/golang.org/x/net/icmp/endpoint.go deleted file mode 100644 index a68bfb0..0000000 --- a/vendor/golang.org/x/net/icmp/endpoint.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "net" - "runtime" - "syscall" - "time" - - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -var _ net.PacketConn = &PacketConn{} - -// A PacketConn represents a packet network endpoint that uses either -// ICMPv4 or ICMPv6. -type PacketConn struct { - c net.PacketConn - p4 *ipv4.PacketConn - p6 *ipv6.PacketConn -} - -func (c *PacketConn) ok() bool { return c != nil && c.c != nil } - -// IPv4PacketConn returns the ipv4.PacketConn of c. -// It returns nil when c is not created as the endpoint for ICMPv4. -func (c *PacketConn) IPv4PacketConn() *ipv4.PacketConn { - if !c.ok() { - return nil - } - return c.p4 -} - -// IPv6PacketConn returns the ipv6.PacketConn of c. -// It returns nil when c is not created as the endpoint for ICMPv6. -func (c *PacketConn) IPv6PacketConn() *ipv6.PacketConn { - if !c.ok() { - return nil - } - return c.p6 -} - -// ReadFrom reads an ICMP message from the connection. -func (c *PacketConn) ReadFrom(b []byte) (int, net.Addr, error) { - if !c.ok() { - return 0, nil, syscall.EINVAL - } - // Please be informed that ipv4.NewPacketConn enables - // IP_STRIPHDR option by default on Darwin. - // See golang.org/issue/9395 for further information. - if runtime.GOOS == "darwin" && c.p4 != nil { - n, _, peer, err := c.p4.ReadFrom(b) - return n, peer, err - } - return c.c.ReadFrom(b) -} - -// WriteTo writes the ICMP message b to dst. -// Dst must be net.UDPAddr when c is a non-privileged -// datagram-oriented ICMP endpoint. Otherwise it must be net.IPAddr. -func (c *PacketConn) WriteTo(b []byte, dst net.Addr) (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - return c.c.WriteTo(b, dst) -} - -// Close closes the endpoint. -func (c *PacketConn) Close() error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.Close() -} - -// LocalAddr returns the local network address. -func (c *PacketConn) LocalAddr() net.Addr { - if !c.ok() { - return nil - } - return c.c.LocalAddr() -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *PacketConn) SetDeadline(t time.Time) error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *PacketConn) SetReadDeadline(t time.Time) error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *PacketConn) SetWriteDeadline(t time.Time) error { - if !c.ok() { - return syscall.EINVAL - } - return c.c.SetWriteDeadline(t) -} diff --git a/vendor/golang.org/x/net/icmp/example_test.go b/vendor/golang.org/x/net/icmp/example_test.go deleted file mode 100644 index 1df4cec..0000000 --- a/vendor/golang.org/x/net/icmp/example_test.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "log" - "net" - "os" - "runtime" - - "golang.org/x/net/icmp" - "golang.org/x/net/ipv6" -) - -func ExamplePacketConn_nonPrivilegedPing() { - switch runtime.GOOS { - case "darwin": - case "linux": - log.Println("you may need to adjust the net.ipv4.ping_group_range kernel state") - default: - log.Println("not supported on", runtime.GOOS) - return - } - - c, err := icmp.ListenPacket("udp6", "fe80::1%en0") - if err != nil { - log.Fatal(err) - } - defer c.Close() - - wm := icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: 1, - Data: []byte("HELLO-R-U-THERE"), - }, - } - wb, err := wm.Marshal(nil) - if err != nil { - log.Fatal(err) - } - if _, err := c.WriteTo(wb, &net.UDPAddr{IP: net.ParseIP("ff02::1"), Zone: "en0"}); err != nil { - log.Fatal(err) - } - - rb := make([]byte, 1500) - n, peer, err := c.ReadFrom(rb) - if err != nil { - log.Fatal(err) - } - rm, err := icmp.ParseMessage(58, rb[:n]) - if err != nil { - log.Fatal(err) - } - switch rm.Type { - case ipv6.ICMPTypeEchoReply: - log.Printf("got reflection from %v", peer) - default: - log.Printf("got %+v; want echo reply", rm) - } -} diff --git a/vendor/golang.org/x/net/icmp/extension.go b/vendor/golang.org/x/net/icmp/extension.go deleted file mode 100644 index 402a751..0000000 --- a/vendor/golang.org/x/net/icmp/extension.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// An Extension represents an ICMP extension. -type Extension interface { - // Len returns the length of ICMP extension. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Len(proto int) int - - // Marshal returns the binary encoding of ICMP extension. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Marshal(proto int) ([]byte, error) -} - -const extensionVersion = 2 - -func validExtensionHeader(b []byte) bool { - v := int(b[0]&0xf0) >> 4 - s := binary.BigEndian.Uint16(b[2:4]) - if s != 0 { - s = checksum(b) - } - if v != extensionVersion || s != 0 { - return false - } - return true -} - -// parseExtensions parses b as a list of ICMP extensions. -// The length attribute l must be the length attribute field in -// received icmp messages. -// -// It will return a list of ICMP extensions and an adjusted length -// attribute that represents the length of the padded original -// datagram field. Otherwise, it returns an error. -func parseExtensions(b []byte, l int) ([]Extension, int, error) { - // Still a lot of non-RFC 4884 compliant implementations are - // out there. Set the length attribute l to 128 when it looks - // inappropriate for backwards compatibility. - // - // A minimal extension at least requires 8 octets; 4 octets - // for an extension header, and 4 octets for a single object - // header. - // - // See RFC 4884 for further information. - if 128 > l || l+8 > len(b) { - l = 128 - } - if l+8 > len(b) { - return nil, -1, errNoExtension - } - if !validExtensionHeader(b[l:]) { - if l == 128 { - return nil, -1, errNoExtension - } - l = 128 - if !validExtensionHeader(b[l:]) { - return nil, -1, errNoExtension - } - } - var exts []Extension - for b = b[l+4:]; len(b) >= 4; { - ol := int(binary.BigEndian.Uint16(b[:2])) - if 4 > ol || ol > len(b) { - break - } - switch b[2] { - case classMPLSLabelStack: - ext, err := parseMPLSLabelStack(b[:ol]) - if err != nil { - return nil, -1, err - } - exts = append(exts, ext) - case classInterfaceInfo: - ext, err := parseInterfaceInfo(b[:ol]) - if err != nil { - return nil, -1, err - } - exts = append(exts, ext) - } - b = b[ol:] - } - return exts, l, nil -} diff --git a/vendor/golang.org/x/net/icmp/extension_test.go b/vendor/golang.org/x/net/icmp/extension_test.go deleted file mode 100644 index 0b3f7b9..0000000 --- a/vendor/golang.org/x/net/icmp/extension_test.go +++ /dev/null @@ -1,259 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "net" - "reflect" - "testing" - - "golang.org/x/net/internal/iana" -) - -var marshalAndParseExtensionTests = []struct { - proto int - hdr []byte - obj []byte - exts []Extension -}{ - // MPLS label stack with no label - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x04, 0x01, 0x01, - }, - exts: []Extension{ - &MPLSLabelStack{ - Class: classMPLSLabelStack, - Type: typeIncomingMPLSLabelStack, - }, - }, - }, - // MPLS label stack with a single label - { - proto: iana.ProtocolIPv6ICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x08, 0x01, 0x01, - 0x03, 0xe8, 0xe9, 0xff, - }, - exts: []Extension{ - &MPLSLabelStack{ - Class: classMPLSLabelStack, - Type: typeIncomingMPLSLabelStack, - Labels: []MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - }, - }, - // MPLS label stack with multiple labels - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x0c, 0x01, 0x01, - 0x03, 0xe8, 0xde, 0xfe, - 0x03, 0xe8, 0xe1, 0xff, - }, - exts: []Extension{ - &MPLSLabelStack{ - Class: classMPLSLabelStack, - Type: typeIncomingMPLSLabelStack, - Labels: []MPLSLabel{ - { - Label: 16013, - TC: 0x7, - S: false, - TTL: 254, - }, - { - Label: 16014, - TC: 0, - S: true, - TTL: 255, - }, - }, - }, - }, - }, - // Interface information with no attribute - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x04, 0x02, 0x00, - }, - exts: []Extension{ - &InterfaceInfo{ - Class: classInterfaceInfo, - }, - }, - }, - // Interface information with ifIndex and name - { - proto: iana.ProtocolICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x10, 0x02, 0x0a, - 0x00, 0x00, 0x00, 0x10, - 0x08, byte('e'), byte('n'), byte('1'), - byte('0'), byte('1'), 0x00, 0x00, - }, - exts: []Extension{ - &InterfaceInfo{ - Class: classInterfaceInfo, - Type: 0x0a, - Interface: &net.Interface{ - Index: 16, - Name: "en101", - }, - }, - }, - }, - // Interface information with ifIndex, IPAddr, name and MTU - { - proto: iana.ProtocolIPv6ICMP, - hdr: []byte{ - 0x20, 0x00, 0x00, 0x00, - }, - obj: []byte{ - 0x00, 0x28, 0x02, 0x0f, - 0x00, 0x00, 0x00, 0x0f, - 0x00, 0x02, 0x00, 0x00, - 0xfe, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x08, byte('e'), byte('n'), byte('1'), - byte('0'), byte('1'), 0x00, 0x00, - 0x00, 0x00, 0x20, 0x00, - }, - exts: []Extension{ - &InterfaceInfo{ - Class: classInterfaceInfo, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en101", - }, - }, - }, - }, -} - -func TestMarshalAndParseExtension(t *testing.T) { - for i, tt := range marshalAndParseExtensionTests { - for j, ext := range tt.exts { - var err error - var b []byte - switch ext := ext.(type) { - case *MPLSLabelStack: - b, err = ext.Marshal(tt.proto) - if err != nil { - t.Errorf("#%v/%v: %v", i, j, err) - continue - } - case *InterfaceInfo: - b, err = ext.Marshal(tt.proto) - if err != nil { - t.Errorf("#%v/%v: %v", i, j, err) - continue - } - } - if !reflect.DeepEqual(b, tt.obj) { - t.Errorf("#%v/%v: got %#v; want %#v", i, j, b, tt.obj) - continue - } - } - - for j, wire := range []struct { - data []byte // original datagram - inlattr int // length of padded original datagram, a hint - outlattr int // length of padded original datagram, a want - err error - }{ - {nil, 0, -1, errNoExtension}, - {make([]byte, 127), 128, -1, errNoExtension}, - - {make([]byte, 128), 127, -1, errNoExtension}, - {make([]byte, 128), 128, -1, errNoExtension}, - {make([]byte, 128), 129, -1, errNoExtension}, - - {append(make([]byte, 128), append(tt.hdr, tt.obj...)...), 127, 128, nil}, - {append(make([]byte, 128), append(tt.hdr, tt.obj...)...), 128, 128, nil}, - {append(make([]byte, 128), append(tt.hdr, tt.obj...)...), 129, 128, nil}, - - {append(make([]byte, 512), append(tt.hdr, tt.obj...)...), 511, -1, errNoExtension}, - {append(make([]byte, 512), append(tt.hdr, tt.obj...)...), 512, 512, nil}, - {append(make([]byte, 512), append(tt.hdr, tt.obj...)...), 513, -1, errNoExtension}, - } { - exts, l, err := parseExtensions(wire.data, wire.inlattr) - if err != wire.err { - t.Errorf("#%v/%v: got %v; want %v", i, j, err, wire.err) - continue - } - if wire.err != nil { - continue - } - if l != wire.outlattr { - t.Errorf("#%v/%v: got %v; want %v", i, j, l, wire.outlattr) - } - if !reflect.DeepEqual(exts, tt.exts) { - for j, ext := range exts { - switch ext := ext.(type) { - case *MPLSLabelStack: - want := tt.exts[j].(*MPLSLabelStack) - t.Errorf("#%v/%v: got %#v; want %#v", i, j, ext, want) - case *InterfaceInfo: - want := tt.exts[j].(*InterfaceInfo) - t.Errorf("#%v/%v: got %#v; want %#v", i, j, ext, want) - } - } - continue - } - } - } -} - -var parseInterfaceNameTests = []struct { - b []byte - error -}{ - {[]byte{0, 'e', 'n', '0'}, errInvalidExtension}, - {[]byte{4, 'e', 'n', '0'}, nil}, - {[]byte{7, 'e', 'n', '0', 0xff, 0xff, 0xff, 0xff}, errInvalidExtension}, - {[]byte{8, 'e', 'n', '0', 0xff, 0xff, 0xff}, errMessageTooShort}, -} - -func TestParseInterfaceName(t *testing.T) { - ifi := InterfaceInfo{Interface: &net.Interface{}} - for i, tt := range parseInterfaceNameTests { - if _, err := ifi.parseName(tt.b); err != tt.error { - t.Errorf("#%d: got %v; want %v", i, err, tt.error) - } - } -} diff --git a/vendor/golang.org/x/net/icmp/helper.go b/vendor/golang.org/x/net/icmp/helper.go deleted file mode 100644 index 6c4e633..0000000 --- a/vendor/golang.org/x/net/icmp/helper.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "unsafe" -) - -var ( - // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html. - freebsdVersion uint32 - - nativeEndian binary.ByteOrder -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = binary.LittleEndian - } else { - nativeEndian = binary.BigEndian - } -} diff --git a/vendor/golang.org/x/net/icmp/helper_posix.go b/vendor/golang.org/x/net/icmp/helper_posix.go deleted file mode 100644 index 398fd38..0000000 --- a/vendor/golang.org/x/net/icmp/helper_posix.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package icmp - -import ( - "net" - "strconv" - "syscall" -) - -func sockaddr(family int, address string) (syscall.Sockaddr, error) { - switch family { - case syscall.AF_INET: - a, err := net.ResolveIPAddr("ip4", address) - if err != nil { - return nil, err - } - if len(a.IP) == 0 { - a.IP = net.IPv4zero - } - if a.IP = a.IP.To4(); a.IP == nil { - return nil, net.InvalidAddrError("non-ipv4 address") - } - sa := &syscall.SockaddrInet4{} - copy(sa.Addr[:], a.IP) - return sa, nil - case syscall.AF_INET6: - a, err := net.ResolveIPAddr("ip6", address) - if err != nil { - return nil, err - } - if len(a.IP) == 0 { - a.IP = net.IPv6unspecified - } - if a.IP.Equal(net.IPv4zero) { - a.IP = net.IPv6unspecified - } - if a.IP = a.IP.To16(); a.IP == nil || a.IP.To4() != nil { - return nil, net.InvalidAddrError("non-ipv6 address") - } - sa := &syscall.SockaddrInet6{ZoneId: zoneToUint32(a.Zone)} - copy(sa.Addr[:], a.IP) - return sa, nil - default: - return nil, net.InvalidAddrError("unexpected family") - } -} - -func zoneToUint32(zone string) uint32 { - if zone == "" { - return 0 - } - if ifi, err := net.InterfaceByName(zone); err == nil { - return uint32(ifi.Index) - } - n, err := strconv.Atoi(zone) - if err != nil { - return 0 - } - return uint32(n) -} - -func last(s string, b byte) int { - i := len(s) - for i--; i >= 0; i-- { - if s[i] == b { - break - } - } - return i -} diff --git a/vendor/golang.org/x/net/icmp/interface.go b/vendor/golang.org/x/net/icmp/interface.go deleted file mode 100644 index 78b5b98..0000000 --- a/vendor/golang.org/x/net/icmp/interface.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "net" - "strings" - - "golang.org/x/net/internal/iana" -) - -const ( - classInterfaceInfo = 2 - - afiIPv4 = 1 - afiIPv6 = 2 -) - -const ( - attrMTU = 1 << iota - attrName - attrIPAddr - attrIfIndex -) - -// An InterfaceInfo represents interface and next-hop identification. -type InterfaceInfo struct { - Class int // extension object class number - Type int // extension object sub-type - Interface *net.Interface - Addr *net.IPAddr -} - -func (ifi *InterfaceInfo) nameLen() int { - if len(ifi.Interface.Name) > 63 { - return 64 - } - l := 1 + len(ifi.Interface.Name) - return (l + 3) &^ 3 -} - -func (ifi *InterfaceInfo) attrsAndLen(proto int) (attrs, l int) { - l = 4 - if ifi.Interface != nil && ifi.Interface.Index > 0 { - attrs |= attrIfIndex - l += 4 - if len(ifi.Interface.Name) > 0 { - attrs |= attrName - l += ifi.nameLen() - } - if ifi.Interface.MTU > 0 { - attrs |= attrMTU - l += 4 - } - } - if ifi.Addr != nil { - switch proto { - case iana.ProtocolICMP: - if ifi.Addr.IP.To4() != nil { - attrs |= attrIPAddr - l += 4 + net.IPv4len - } - case iana.ProtocolIPv6ICMP: - if ifi.Addr.IP.To16() != nil && ifi.Addr.IP.To4() == nil { - attrs |= attrIPAddr - l += 4 + net.IPv6len - } - } - } - return -} - -// Len implements the Len method of Extension interface. -func (ifi *InterfaceInfo) Len(proto int) int { - _, l := ifi.attrsAndLen(proto) - return l -} - -// Marshal implements the Marshal method of Extension interface. -func (ifi *InterfaceInfo) Marshal(proto int) ([]byte, error) { - attrs, l := ifi.attrsAndLen(proto) - b := make([]byte, l) - if err := ifi.marshal(proto, b, attrs, l); err != nil { - return nil, err - } - return b, nil -} - -func (ifi *InterfaceInfo) marshal(proto int, b []byte, attrs, l int) error { - binary.BigEndian.PutUint16(b[:2], uint16(l)) - b[2], b[3] = classInterfaceInfo, byte(ifi.Type) - for b = b[4:]; len(b) > 0 && attrs != 0; { - switch { - case attrs&attrIfIndex != 0: - b = ifi.marshalIfIndex(proto, b) - attrs &^= attrIfIndex - case attrs&attrIPAddr != 0: - b = ifi.marshalIPAddr(proto, b) - attrs &^= attrIPAddr - case attrs&attrName != 0: - b = ifi.marshalName(proto, b) - attrs &^= attrName - case attrs&attrMTU != 0: - b = ifi.marshalMTU(proto, b) - attrs &^= attrMTU - } - } - return nil -} - -func (ifi *InterfaceInfo) marshalIfIndex(proto int, b []byte) []byte { - binary.BigEndian.PutUint32(b[:4], uint32(ifi.Interface.Index)) - return b[4:] -} - -func (ifi *InterfaceInfo) parseIfIndex(b []byte) ([]byte, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - ifi.Interface.Index = int(binary.BigEndian.Uint32(b[:4])) - return b[4:], nil -} - -func (ifi *InterfaceInfo) marshalIPAddr(proto int, b []byte) []byte { - switch proto { - case iana.ProtocolICMP: - binary.BigEndian.PutUint16(b[:2], uint16(afiIPv4)) - copy(b[4:4+net.IPv4len], ifi.Addr.IP.To4()) - b = b[4+net.IPv4len:] - case iana.ProtocolIPv6ICMP: - binary.BigEndian.PutUint16(b[:2], uint16(afiIPv6)) - copy(b[4:4+net.IPv6len], ifi.Addr.IP.To16()) - b = b[4+net.IPv6len:] - } - return b -} - -func (ifi *InterfaceInfo) parseIPAddr(b []byte) ([]byte, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - afi := int(binary.BigEndian.Uint16(b[:2])) - b = b[4:] - switch afi { - case afiIPv4: - if len(b) < net.IPv4len { - return nil, errMessageTooShort - } - ifi.Addr.IP = make(net.IP, net.IPv4len) - copy(ifi.Addr.IP, b[:net.IPv4len]) - b = b[net.IPv4len:] - case afiIPv6: - if len(b) < net.IPv6len { - return nil, errMessageTooShort - } - ifi.Addr.IP = make(net.IP, net.IPv6len) - copy(ifi.Addr.IP, b[:net.IPv6len]) - b = b[net.IPv6len:] - } - return b, nil -} - -func (ifi *InterfaceInfo) marshalName(proto int, b []byte) []byte { - l := byte(ifi.nameLen()) - b[0] = l - copy(b[1:], []byte(ifi.Interface.Name)) - return b[l:] -} - -func (ifi *InterfaceInfo) parseName(b []byte) ([]byte, error) { - if 4 > len(b) || len(b) < int(b[0]) { - return nil, errMessageTooShort - } - l := int(b[0]) - if l%4 != 0 || 4 > l || l > 64 { - return nil, errInvalidExtension - } - var name [63]byte - copy(name[:], b[1:l]) - ifi.Interface.Name = strings.Trim(string(name[:]), "\000") - return b[l:], nil -} - -func (ifi *InterfaceInfo) marshalMTU(proto int, b []byte) []byte { - binary.BigEndian.PutUint32(b[:4], uint32(ifi.Interface.MTU)) - return b[4:] -} - -func (ifi *InterfaceInfo) parseMTU(b []byte) ([]byte, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - ifi.Interface.MTU = int(binary.BigEndian.Uint32(b[:4])) - return b[4:], nil -} - -func parseInterfaceInfo(b []byte) (Extension, error) { - ifi := &InterfaceInfo{ - Class: int(b[2]), - Type: int(b[3]), - } - if ifi.Type&(attrIfIndex|attrName|attrMTU) != 0 { - ifi.Interface = &net.Interface{} - } - if ifi.Type&attrIPAddr != 0 { - ifi.Addr = &net.IPAddr{} - } - attrs := ifi.Type & (attrIfIndex | attrIPAddr | attrName | attrMTU) - for b = b[4:]; len(b) > 0 && attrs != 0; { - var err error - switch { - case attrs&attrIfIndex != 0: - b, err = ifi.parseIfIndex(b) - attrs &^= attrIfIndex - case attrs&attrIPAddr != 0: - b, err = ifi.parseIPAddr(b) - attrs &^= attrIPAddr - case attrs&attrName != 0: - b, err = ifi.parseName(b) - attrs &^= attrName - case attrs&attrMTU != 0: - b, err = ifi.parseMTU(b) - attrs &^= attrMTU - } - if err != nil { - return nil, err - } - } - if ifi.Interface != nil && ifi.Interface.Name != "" && ifi.Addr != nil && ifi.Addr.IP.To16() != nil && ifi.Addr.IP.To4() == nil { - ifi.Addr.Zone = ifi.Interface.Name - } - return ifi, nil -} diff --git a/vendor/golang.org/x/net/icmp/ipv4.go b/vendor/golang.org/x/net/icmp/ipv4.go deleted file mode 100644 index 729ddc9..0000000 --- a/vendor/golang.org/x/net/icmp/ipv4.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "net" - "runtime" - - "golang.org/x/net/ipv4" -) - -// ParseIPv4Header parses b as an IPv4 header of ICMP error message -// invoking packet, which is contained in ICMP error message. -func ParseIPv4Header(b []byte) (*ipv4.Header, error) { - if len(b) < ipv4.HeaderLen { - return nil, errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - if hdrlen > len(b) { - return nil, errBufferTooShort - } - h := &ipv4.Header{ - Version: int(b[0] >> 4), - Len: hdrlen, - TOS: int(b[1]), - ID: int(binary.BigEndian.Uint16(b[4:6])), - FragOff: int(binary.BigEndian.Uint16(b[6:8])), - TTL: int(b[8]), - Protocol: int(b[9]), - Checksum: int(binary.BigEndian.Uint16(b[10:12])), - Src: net.IPv4(b[12], b[13], b[14], b[15]), - Dst: net.IPv4(b[16], b[17], b[18], b[19]), - } - switch runtime.GOOS { - case "darwin": - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) - case "freebsd": - if freebsdVersion >= 1000000 { - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - } else { - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) - } - default: - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - } - h.Flags = ipv4.HeaderFlags(h.FragOff&0xe000) >> 13 - h.FragOff = h.FragOff & 0x1fff - if hdrlen-ipv4.HeaderLen > 0 { - h.Options = make([]byte, hdrlen-ipv4.HeaderLen) - copy(h.Options, b[ipv4.HeaderLen:]) - } - return h, nil -} diff --git a/vendor/golang.org/x/net/icmp/ipv4_test.go b/vendor/golang.org/x/net/icmp/ipv4_test.go deleted file mode 100644 index 47cc00d..0000000 --- a/vendor/golang.org/x/net/icmp/ipv4_test.go +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "net" - "reflect" - "runtime" - "testing" - - "golang.org/x/net/ipv4" -) - -type ipv4HeaderTest struct { - wireHeaderFromKernel [ipv4.HeaderLen]byte - wireHeaderFromTradBSDKernel [ipv4.HeaderLen]byte - Header *ipv4.Header -} - -var ipv4HeaderLittleEndianTest = ipv4HeaderTest{ - // TODO(mikio): Add platform dependent wire header formats when - // we support new platforms. - wireHeaderFromKernel: [ipv4.HeaderLen]byte{ - 0x45, 0x01, 0xbe, 0xef, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderFromTradBSDKernel: [ipv4.HeaderLen]byte{ - 0x45, 0x01, 0xef, 0xbe, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - Header: &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: 1, - TotalLen: 0xbeef, - ID: 0xcafe, - Flags: ipv4.DontFragment, - FragOff: 1500, - TTL: 255, - Protocol: 1, - Checksum: 0xdead, - Src: net.IPv4(172, 16, 254, 254), - Dst: net.IPv4(192, 168, 0, 1), - }, -} - -func TestParseIPv4Header(t *testing.T) { - tt := &ipv4HeaderLittleEndianTest - if nativeEndian != binary.LittleEndian { - t.Skip("no test for non-little endian machine yet") - } - - var wh []byte - switch runtime.GOOS { - case "darwin": - wh = tt.wireHeaderFromTradBSDKernel[:] - case "freebsd": - if freebsdVersion >= 1000000 { - wh = tt.wireHeaderFromKernel[:] - } else { - wh = tt.wireHeaderFromTradBSDKernel[:] - } - default: - wh = tt.wireHeaderFromKernel[:] - } - h, err := ParseIPv4Header(wh) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(h, tt.Header) { - t.Fatalf("got %#v; want %#v", h, tt.Header) - } -} diff --git a/vendor/golang.org/x/net/icmp/ipv6.go b/vendor/golang.org/x/net/icmp/ipv6.go deleted file mode 100644 index 58eaa77..0000000 --- a/vendor/golang.org/x/net/icmp/ipv6.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "net" - - "golang.org/x/net/internal/iana" -) - -const ipv6PseudoHeaderLen = 2*net.IPv6len + 8 - -// IPv6PseudoHeader returns an IPv6 pseudo header for checksum -// calculation. -func IPv6PseudoHeader(src, dst net.IP) []byte { - b := make([]byte, ipv6PseudoHeaderLen) - copy(b, src.To16()) - copy(b[net.IPv6len:], dst.To16()) - b[len(b)-1] = byte(iana.ProtocolIPv6ICMP) - return b -} diff --git a/vendor/golang.org/x/net/icmp/listen_posix.go b/vendor/golang.org/x/net/icmp/listen_posix.go deleted file mode 100644 index b9f2607..0000000 --- a/vendor/golang.org/x/net/icmp/listen_posix.go +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package icmp - -import ( - "net" - "os" - "runtime" - "syscall" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -const sysIP_STRIPHDR = 0x17 // for now only darwin supports this option - -// ListenPacket listens for incoming ICMP packets addressed to -// address. See net.Dial for the syntax of address. -// -// For non-privileged datagram-oriented ICMP endpoints, network must -// be "udp4" or "udp6". The endpoint allows to read, write a few -// limited ICMP messages such as echo request and echo reply. -// Currently only Darwin and Linux support this. -// -// Examples: -// ListenPacket("udp4", "192.168.0.1") -// ListenPacket("udp4", "0.0.0.0") -// ListenPacket("udp6", "fe80::1%en0") -// ListenPacket("udp6", "::") -// -// For privileged raw ICMP endpoints, network must be "ip4" or "ip6" -// followed by a colon and an ICMP protocol number or name. -// -// Examples: -// ListenPacket("ip4:icmp", "192.168.0.1") -// ListenPacket("ip4:1", "0.0.0.0") -// ListenPacket("ip6:ipv6-icmp", "fe80::1%en0") -// ListenPacket("ip6:58", "::") -func ListenPacket(network, address string) (*PacketConn, error) { - var family, proto int - switch network { - case "udp4": - family, proto = syscall.AF_INET, iana.ProtocolICMP - case "udp6": - family, proto = syscall.AF_INET6, iana.ProtocolIPv6ICMP - default: - i := last(network, ':') - switch network[:i] { - case "ip4": - proto = iana.ProtocolICMP - case "ip6": - proto = iana.ProtocolIPv6ICMP - } - } - var cerr error - var c net.PacketConn - switch family { - case syscall.AF_INET, syscall.AF_INET6: - s, err := syscall.Socket(family, syscall.SOCK_DGRAM, proto) - if err != nil { - return nil, os.NewSyscallError("socket", err) - } - defer syscall.Close(s) - if runtime.GOOS == "darwin" && family == syscall.AF_INET { - if err := syscall.SetsockoptInt(s, iana.ProtocolIP, sysIP_STRIPHDR, 1); err != nil { - return nil, os.NewSyscallError("setsockopt", err) - } - } - sa, err := sockaddr(family, address) - if err != nil { - return nil, err - } - if err := syscall.Bind(s, sa); err != nil { - return nil, os.NewSyscallError("bind", err) - } - f := os.NewFile(uintptr(s), "datagram-oriented icmp") - defer f.Close() - c, cerr = net.FilePacketConn(f) - default: - c, cerr = net.ListenPacket(network, address) - } - if cerr != nil { - return nil, cerr - } - switch proto { - case iana.ProtocolICMP: - return &PacketConn{c: c, p4: ipv4.NewPacketConn(c)}, nil - case iana.ProtocolIPv6ICMP: - return &PacketConn{c: c, p6: ipv6.NewPacketConn(c)}, nil - default: - return &PacketConn{c: c}, nil - } -} diff --git a/vendor/golang.org/x/net/icmp/listen_stub.go b/vendor/golang.org/x/net/icmp/listen_stub.go deleted file mode 100644 index 668728d..0000000 --- a/vendor/golang.org/x/net/icmp/listen_stub.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package icmp - -// ListenPacket listens for incoming ICMP packets addressed to -// address. See net.Dial for the syntax of address. -// -// For non-privileged datagram-oriented ICMP endpoints, network must -// be "udp4" or "udp6". The endpoint allows to read, write a few -// limited ICMP messages such as echo request and echo reply. -// Currently only Darwin and Linux support this. -// -// Examples: -// ListenPacket("udp4", "192.168.0.1") -// ListenPacket("udp4", "0.0.0.0") -// ListenPacket("udp6", "fe80::1%en0") -// ListenPacket("udp6", "::") -// -// For privileged raw ICMP endpoints, network must be "ip4" or "ip6" -// followed by a colon and an ICMP protocol number or name. -// -// Examples: -// ListenPacket("ip4:icmp", "192.168.0.1") -// ListenPacket("ip4:1", "0.0.0.0") -// ListenPacket("ip6:ipv6-icmp", "fe80::1%en0") -// ListenPacket("ip6:58", "::") -func ListenPacket(network, address string) (*PacketConn, error) { - return nil, errOpNoSupport -} diff --git a/vendor/golang.org/x/net/icmp/message.go b/vendor/golang.org/x/net/icmp/message.go deleted file mode 100644 index 42d6df2..0000000 --- a/vendor/golang.org/x/net/icmp/message.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package icmp provides basic functions for the manipulation of -// messages used in the Internet Control Message Protocols, -// ICMPv4 and ICMPv6. -// -// ICMPv4 and ICMPv6 are defined in RFC 792 and RFC 4443. -// Multi-part message support for ICMP is defined in RFC 4884. -// ICMP extensions for MPLS are defined in RFC 4950. -// ICMP extensions for interface and next-hop identification are -// defined in RFC 5837. -package icmp // import "golang.org/x/net/icmp" - -import ( - "encoding/binary" - "errors" - "net" - "syscall" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -var ( - errMessageTooShort = errors.New("message too short") - errHeaderTooShort = errors.New("header too short") - errBufferTooShort = errors.New("buffer too short") - errOpNoSupport = errors.New("operation not supported") - errNoExtension = errors.New("no extension") - errInvalidExtension = errors.New("invalid extension") -) - -func checksum(b []byte) uint16 { - csumcv := len(b) - 1 // checksum coverage - s := uint32(0) - for i := 0; i < csumcv; i += 2 { - s += uint32(b[i+1])<<8 | uint32(b[i]) - } - if csumcv&1 == 0 { - s += uint32(b[csumcv]) - } - s = s>>16 + s&0xffff - s = s + s>>16 - return ^uint16(s) -} - -// A Type represents an ICMP message type. -type Type interface { - Protocol() int -} - -// A Message represents an ICMP message. -type Message struct { - Type Type // type, either ipv4.ICMPType or ipv6.ICMPType - Code int // code - Checksum int // checksum - Body MessageBody // body -} - -// Marshal returns the binary encoding of the ICMP message m. -// -// For an ICMPv4 message, the returned message always contains the -// calculated checksum field. -// -// For an ICMPv6 message, the returned message contains the calculated -// checksum field when psh is not nil, otherwise the kernel will -// compute the checksum field during the message transmission. -// When psh is not nil, it must be the pseudo header for IPv6. -func (m *Message) Marshal(psh []byte) ([]byte, error) { - var mtype int - switch typ := m.Type.(type) { - case ipv4.ICMPType: - mtype = int(typ) - case ipv6.ICMPType: - mtype = int(typ) - default: - return nil, syscall.EINVAL - } - b := []byte{byte(mtype), byte(m.Code), 0, 0} - if m.Type.Protocol() == iana.ProtocolIPv6ICMP && psh != nil { - b = append(psh, b...) - } - if m.Body != nil && m.Body.Len(m.Type.Protocol()) != 0 { - mb, err := m.Body.Marshal(m.Type.Protocol()) - if err != nil { - return nil, err - } - b = append(b, mb...) - } - if m.Type.Protocol() == iana.ProtocolIPv6ICMP { - if psh == nil { // cannot calculate checksum here - return b, nil - } - off, l := 2*net.IPv6len, len(b)-len(psh) - binary.BigEndian.PutUint32(b[off:off+4], uint32(l)) - } - s := checksum(b) - // Place checksum back in header; using ^= avoids the - // assumption the checksum bytes are zero. - b[len(psh)+2] ^= byte(s) - b[len(psh)+3] ^= byte(s >> 8) - return b[len(psh):], nil -} - -var parseFns = map[Type]func(int, []byte) (MessageBody, error){ - ipv4.ICMPTypeDestinationUnreachable: parseDstUnreach, - ipv4.ICMPTypeTimeExceeded: parseTimeExceeded, - ipv4.ICMPTypeParameterProblem: parseParamProb, - - ipv4.ICMPTypeEcho: parseEcho, - ipv4.ICMPTypeEchoReply: parseEcho, - - ipv6.ICMPTypeDestinationUnreachable: parseDstUnreach, - ipv6.ICMPTypePacketTooBig: parsePacketTooBig, - ipv6.ICMPTypeTimeExceeded: parseTimeExceeded, - ipv6.ICMPTypeParameterProblem: parseParamProb, - - ipv6.ICMPTypeEchoRequest: parseEcho, - ipv6.ICMPTypeEchoReply: parseEcho, -} - -// ParseMessage parses b as an ICMP message. -// Proto must be either the ICMPv4 or ICMPv6 protocol number. -func ParseMessage(proto int, b []byte) (*Message, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - var err error - m := &Message{Code: int(b[1]), Checksum: int(binary.BigEndian.Uint16(b[2:4]))} - switch proto { - case iana.ProtocolICMP: - m.Type = ipv4.ICMPType(b[0]) - case iana.ProtocolIPv6ICMP: - m.Type = ipv6.ICMPType(b[0]) - default: - return nil, syscall.EINVAL - } - if fn, ok := parseFns[m.Type]; !ok { - m.Body, err = parseDefaultMessageBody(proto, b[4:]) - } else { - m.Body, err = fn(proto, b[4:]) - } - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/icmp/message_test.go b/vendor/golang.org/x/net/icmp/message_test.go deleted file mode 100644 index 5d2605f..0000000 --- a/vendor/golang.org/x/net/icmp/message_test.go +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "net" - "reflect" - "testing" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -var marshalAndParseMessageForIPv4Tests = []icmp.Message{ - { - Type: ipv4.ICMPTypeDestinationUnreachable, Code: 15, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv4.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv4.ICMPTypeParameterProblem, Code: 2, - Body: &icmp.ParamProb{ - Pointer: 8, - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: 1, Seq: 2, - Data: []byte("HELLO-R-U-THERE"), - }, - }, - { - Type: ipv4.ICMPTypePhoturis, - Body: &icmp.DefaultMessageBody{ - Data: []byte{0x80, 0x40, 0x20, 0x10}, - }, - }, -} - -func TestMarshalAndParseMessageForIPv4(t *testing.T) { - for i, tt := range marshalAndParseMessageForIPv4Tests { - b, err := tt.Marshal(nil) - if err != nil { - t.Fatal(err) - } - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - if !reflect.DeepEqual(m.Body, tt.Body) { - t.Errorf("#%v: got %v; want %v", i, m.Body, tt.Body) - } - } -} - -var marshalAndParseMessageForIPv6Tests = []icmp.Message{ - { - Type: ipv6.ICMPTypeDestinationUnreachable, Code: 6, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypePacketTooBig, Code: 0, - Body: &icmp.PacketTooBig{ - MTU: 1<<16 - 1, - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypeParameterProblem, Code: 2, - Body: &icmp.ParamProb{ - Pointer: 8, - Data: []byte("ERROR-INVOKING-PACKET"), - }, - }, - { - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: 1, Seq: 2, - Data: []byte("HELLO-R-U-THERE"), - }, - }, - { - Type: ipv6.ICMPTypeDuplicateAddressConfirmation, - Body: &icmp.DefaultMessageBody{ - Data: []byte{0x80, 0x40, 0x20, 0x10}, - }, - }, -} - -func TestMarshalAndParseMessageForIPv6(t *testing.T) { - pshicmp := icmp.IPv6PseudoHeader(net.ParseIP("fe80::1"), net.ParseIP("ff02::1")) - for i, tt := range marshalAndParseMessageForIPv6Tests { - for _, psh := range [][]byte{pshicmp, nil} { - b, err := tt.Marshal(psh) - if err != nil { - t.Fatal(err) - } - m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - if !reflect.DeepEqual(m.Body, tt.Body) { - t.Errorf("#%v: got %v; want %v", i, m.Body, tt.Body) - } - } - } -} diff --git a/vendor/golang.org/x/net/icmp/messagebody.go b/vendor/golang.org/x/net/icmp/messagebody.go deleted file mode 100644 index 2121a17..0000000 --- a/vendor/golang.org/x/net/icmp/messagebody.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -// A MessageBody represents an ICMP message body. -type MessageBody interface { - // Len returns the length of ICMP message body. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Len(proto int) int - - // Marshal returns the binary encoding of ICMP message body. - // Proto must be either the ICMPv4 or ICMPv6 protocol number. - Marshal(proto int) ([]byte, error) -} - -// A DefaultMessageBody represents the default message body. -type DefaultMessageBody struct { - Data []byte // data -} - -// Len implements the Len method of MessageBody interface. -func (p *DefaultMessageBody) Len(proto int) int { - if p == nil { - return 0 - } - return len(p.Data) -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *DefaultMessageBody) Marshal(proto int) ([]byte, error) { - return p.Data, nil -} - -// parseDefaultMessageBody parses b as an ICMP message body. -func parseDefaultMessageBody(proto int, b []byte) (MessageBody, error) { - p := &DefaultMessageBody{Data: make([]byte, len(b))} - copy(p.Data, b) - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/mpls.go b/vendor/golang.org/x/net/icmp/mpls.go deleted file mode 100644 index c314917..0000000 --- a/vendor/golang.org/x/net/icmp/mpls.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// A MPLSLabel represents a MPLS label stack entry. -type MPLSLabel struct { - Label int // label value - TC int // traffic class; formerly experimental use - S bool // bottom of stack - TTL int // time to live -} - -const ( - classMPLSLabelStack = 1 - typeIncomingMPLSLabelStack = 1 -) - -// A MPLSLabelStack represents a MPLS label stack. -type MPLSLabelStack struct { - Class int // extension object class number - Type int // extension object sub-type - Labels []MPLSLabel -} - -// Len implements the Len method of Extension interface. -func (ls *MPLSLabelStack) Len(proto int) int { - return 4 + (4 * len(ls.Labels)) -} - -// Marshal implements the Marshal method of Extension interface. -func (ls *MPLSLabelStack) Marshal(proto int) ([]byte, error) { - b := make([]byte, ls.Len(proto)) - if err := ls.marshal(proto, b); err != nil { - return nil, err - } - return b, nil -} - -func (ls *MPLSLabelStack) marshal(proto int, b []byte) error { - l := ls.Len(proto) - binary.BigEndian.PutUint16(b[:2], uint16(l)) - b[2], b[3] = classMPLSLabelStack, typeIncomingMPLSLabelStack - off := 4 - for _, ll := range ls.Labels { - b[off], b[off+1], b[off+2] = byte(ll.Label>>12), byte(ll.Label>>4&0xff), byte(ll.Label<<4&0xf0) - b[off+2] |= byte(ll.TC << 1 & 0x0e) - if ll.S { - b[off+2] |= 0x1 - } - b[off+3] = byte(ll.TTL) - off += 4 - } - return nil -} - -func parseMPLSLabelStack(b []byte) (Extension, error) { - ls := &MPLSLabelStack{ - Class: int(b[2]), - Type: int(b[3]), - } - for b = b[4:]; len(b) >= 4; b = b[4:] { - ll := MPLSLabel{ - Label: int(b[0])<<12 | int(b[1])<<4 | int(b[2])>>4, - TC: int(b[2]&0x0e) >> 1, - TTL: int(b[3]), - } - if b[2]&0x1 != 0 { - ll.S = true - } - ls.Labels = append(ls.Labels, ll) - } - return ls, nil -} diff --git a/vendor/golang.org/x/net/icmp/multipart.go b/vendor/golang.org/x/net/icmp/multipart.go deleted file mode 100644 index f271356..0000000 --- a/vendor/golang.org/x/net/icmp/multipart.go +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "golang.org/x/net/internal/iana" - -// multipartMessageBodyDataLen takes b as an original datagram and -// exts as extensions, and returns a required length for message body -// and a required length for a padded original datagram in wire -// format. -func multipartMessageBodyDataLen(proto int, b []byte, exts []Extension) (bodyLen, dataLen int) { - for _, ext := range exts { - bodyLen += ext.Len(proto) - } - if bodyLen > 0 { - dataLen = multipartMessageOrigDatagramLen(proto, b) - bodyLen += 4 // length of extension header - } else { - dataLen = len(b) - } - bodyLen += dataLen - return bodyLen, dataLen -} - -// multipartMessageOrigDatagramLen takes b as an original datagram, -// and returns a required length for a padded orignal datagram in wire -// format. -func multipartMessageOrigDatagramLen(proto int, b []byte) int { - roundup := func(b []byte, align int) int { - // According to RFC 4884, the padded original datagram - // field must contain at least 128 octets. - if len(b) < 128 { - return 128 - } - r := len(b) - return (r + align - 1) & ^(align - 1) - } - switch proto { - case iana.ProtocolICMP: - return roundup(b, 4) - case iana.ProtocolIPv6ICMP: - return roundup(b, 8) - default: - return len(b) - } -} - -// marshalMultipartMessageBody takes data as an original datagram and -// exts as extesnsions, and returns a binary encoding of message body. -// It can be used for non-multipart message bodies when exts is nil. -func marshalMultipartMessageBody(proto int, data []byte, exts []Extension) ([]byte, error) { - bodyLen, dataLen := multipartMessageBodyDataLen(proto, data, exts) - b := make([]byte, 4+bodyLen) - copy(b[4:], data) - off := dataLen + 4 - if len(exts) > 0 { - b[dataLen+4] = byte(extensionVersion << 4) - off += 4 // length of object header - for _, ext := range exts { - switch ext := ext.(type) { - case *MPLSLabelStack: - if err := ext.marshal(proto, b[off:]); err != nil { - return nil, err - } - off += ext.Len(proto) - case *InterfaceInfo: - attrs, l := ext.attrsAndLen(proto) - if err := ext.marshal(proto, b[off:], attrs, l); err != nil { - return nil, err - } - off += ext.Len(proto) - } - } - s := checksum(b[dataLen+4:]) - b[dataLen+4+2] ^= byte(s) - b[dataLen+4+3] ^= byte(s >> 8) - switch proto { - case iana.ProtocolICMP: - b[1] = byte(dataLen / 4) - case iana.ProtocolIPv6ICMP: - b[0] = byte(dataLen / 8) - } - } - return b, nil -} - -// parseMultipartMessageBody parses b as either a non-multipart -// message body or a multipart message body. -func parseMultipartMessageBody(proto int, b []byte) ([]byte, []Extension, error) { - var l int - switch proto { - case iana.ProtocolICMP: - l = 4 * int(b[1]) - case iana.ProtocolIPv6ICMP: - l = 8 * int(b[0]) - } - if len(b) == 4 { - return nil, nil, nil - } - exts, l, err := parseExtensions(b[4:], l) - if err != nil { - l = len(b) - 4 - } - data := make([]byte, l) - copy(data, b[4:]) - return data, exts, nil -} diff --git a/vendor/golang.org/x/net/icmp/multipart_test.go b/vendor/golang.org/x/net/icmp/multipart_test.go deleted file mode 100644 index 966ccb8..0000000 --- a/vendor/golang.org/x/net/icmp/multipart_test.go +++ /dev/null @@ -1,442 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "fmt" - "net" - "reflect" - "testing" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -var marshalAndParseMultipartMessageForIPv4Tests = []icmp.Message{ - { - Type: ipv4.ICMPTypeDestinationUnreachable, Code: 15, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 1).To4(), - }, - }, - }, - }, - }, - { - Type: ipv4.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 1).To4(), - }, - }, - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - }, - }, - }, - { - Type: ipv4.ICMPTypeParameterProblem, Code: 2, - Body: &icmp.ParamProb{ - Pointer: 8, - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 1).To4(), - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x2f, - Interface: &net.Interface{ - Index: 16, - Name: "en102", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.IPv4(192, 168, 0, 2).To4(), - }, - }, - }, - }, - }, -} - -func TestMarshalAndParseMultipartMessageForIPv4(t *testing.T) { - for i, tt := range marshalAndParseMultipartMessageForIPv4Tests { - b, err := tt.Marshal(nil) - if err != nil { - t.Fatal(err) - } - if b[5] != 32 { - t.Errorf("#%v: got %v; want 32", i, b[5]) - } - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - switch m.Type { - case ipv4.ICMPTypeDestinationUnreachable: - got, want := m.Body.(*icmp.DstUnreach), tt.Body.(*icmp.DstUnreach) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - case ipv4.ICMPTypeTimeExceeded: - got, want := m.Body.(*icmp.TimeExceeded), tt.Body.(*icmp.TimeExceeded) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - case ipv4.ICMPTypeParameterProblem: - got, want := m.Body.(*icmp.ParamProb), tt.Body.(*icmp.ParamProb) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - } - } -} - -var marshalAndParseMultipartMessageForIPv6Tests = []icmp.Message{ - { - Type: ipv6.ICMPTypeDestinationUnreachable, Code: 6, - Body: &icmp.DstUnreach{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en101", - }, - }, - }, - }, - }, - { - Type: ipv6.ICMPTypeTimeExceeded, Code: 1, - Body: &icmp.TimeExceeded{ - Data: []byte("ERROR-INVOKING-PACKET"), - Extensions: []icmp.Extension{ - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x0f, - Interface: &net.Interface{ - Index: 15, - Name: "en101", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en101", - }, - }, - &icmp.MPLSLabelStack{ - Class: 1, - Type: 1, - Labels: []icmp.MPLSLabel{ - { - Label: 16014, - TC: 0x4, - S: true, - TTL: 255, - }, - }, - }, - &icmp.InterfaceInfo{ - Class: 2, - Type: 0x2f, - Interface: &net.Interface{ - Index: 16, - Name: "en102", - MTU: 8192, - }, - Addr: &net.IPAddr{ - IP: net.ParseIP("fe80::1"), - Zone: "en102", - }, - }, - }, - }, - }, -} - -func TestMarshalAndParseMultipartMessageForIPv6(t *testing.T) { - pshicmp := icmp.IPv6PseudoHeader(net.ParseIP("fe80::1"), net.ParseIP("ff02::1")) - for i, tt := range marshalAndParseMultipartMessageForIPv6Tests { - for _, psh := range [][]byte{pshicmp, nil} { - b, err := tt.Marshal(psh) - if err != nil { - t.Fatal(err) - } - if b[4] != 16 { - t.Errorf("#%v: got %v; want 16", i, b[4]) - } - m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, b) - if err != nil { - t.Fatal(err) - } - if m.Type != tt.Type || m.Code != tt.Code { - t.Errorf("#%v: got %v; want %v", i, m, &tt) - } - switch m.Type { - case ipv6.ICMPTypeDestinationUnreachable: - got, want := m.Body.(*icmp.DstUnreach), tt.Body.(*icmp.DstUnreach) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - case ipv6.ICMPTypeTimeExceeded: - got, want := m.Body.(*icmp.TimeExceeded), tt.Body.(*icmp.TimeExceeded) - if !reflect.DeepEqual(got.Extensions, want.Extensions) { - t.Error(dumpExtensions(i, got.Extensions, want.Extensions)) - } - if len(got.Data) != 128 { - t.Errorf("#%v: got %v; want 128", i, len(got.Data)) - } - } - } - } -} - -func dumpExtensions(i int, gotExts, wantExts []icmp.Extension) string { - var s string - for j, got := range gotExts { - switch got := got.(type) { - case *icmp.MPLSLabelStack: - want := wantExts[j].(*icmp.MPLSLabelStack) - if !reflect.DeepEqual(got, want) { - s += fmt.Sprintf("#%v/%v: got %#v; want %#v\n", i, j, got, want) - } - case *icmp.InterfaceInfo: - want := wantExts[j].(*icmp.InterfaceInfo) - if !reflect.DeepEqual(got, want) { - s += fmt.Sprintf("#%v/%v: got %#v, %#v, %#v; want %#v, %#v, %#v\n", i, j, got, got.Interface, got.Addr, want, want.Interface, want.Addr) - } - } - } - return s[:len(s)-1] -} - -var multipartMessageBodyLenTests = []struct { - proto int - in icmp.MessageBody - out int -}{ - { - iana.ProtocolICMP, - &icmp.DstUnreach{ - Data: make([]byte, ipv4.HeaderLen), - }, - 4 + ipv4.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolICMP, - &icmp.TimeExceeded{ - Data: make([]byte, ipv4.HeaderLen), - }, - 4 + ipv4.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, ipv4.HeaderLen), - }, - 4 + ipv4.HeaderLen, // [pointer, unused] and original datagram - }, - - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, ipv4.HeaderLen), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [pointer, length, unused], extension header, object header, object payload, original datagram - }, - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, 128), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [pointer, length, unused], extension header, object header, object payload and original datagram - }, - { - iana.ProtocolICMP, - &icmp.ParamProb{ - Data: make([]byte, 129), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 132, // [pointer, length, unused], extension header, object header, object payload and original datagram - }, - - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.PacketTooBig{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // mtu and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.TimeExceeded{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // unused and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.ParamProb{ - Data: make([]byte, ipv6.HeaderLen), - }, - 4 + ipv6.HeaderLen, // pointer and original datagram - }, - - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, 127), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [length, unused], extension header, object header, object payload and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, 128), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 128, // [length, unused], extension header, object header, object payload and original datagram - }, - { - iana.ProtocolIPv6ICMP, - &icmp.DstUnreach{ - Data: make([]byte, 129), - Extensions: []icmp.Extension{ - &icmp.MPLSLabelStack{}, - }, - }, - 4 + 4 + 4 + 0 + 136, // [length, unused], extension header, object header, object payload and original datagram - }, -} - -func TestMultipartMessageBodyLen(t *testing.T) { - for i, tt := range multipartMessageBodyLenTests { - if out := tt.in.Len(tt.proto); out != tt.out { - t.Errorf("#%d: got %d; want %d", i, out, tt.out) - } - } -} diff --git a/vendor/golang.org/x/net/icmp/packettoobig.go b/vendor/golang.org/x/net/icmp/packettoobig.go deleted file mode 100644 index a1c9df7..0000000 --- a/vendor/golang.org/x/net/icmp/packettoobig.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "encoding/binary" - -// A PacketTooBig represents an ICMP packet too big message body. -type PacketTooBig struct { - MTU int // maximum transmission unit of the nexthop link - Data []byte // data, known as original datagram field -} - -// Len implements the Len method of MessageBody interface. -func (p *PacketTooBig) Len(proto int) int { - if p == nil { - return 0 - } - return 4 + len(p.Data) -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *PacketTooBig) Marshal(proto int) ([]byte, error) { - b := make([]byte, 4+len(p.Data)) - binary.BigEndian.PutUint32(b[:4], uint32(p.MTU)) - copy(b[4:], p.Data) - return b, nil -} - -// parsePacketTooBig parses b as an ICMP packet too big message body. -func parsePacketTooBig(proto int, b []byte) (MessageBody, error) { - bodyLen := len(b) - if bodyLen < 4 { - return nil, errMessageTooShort - } - p := &PacketTooBig{MTU: int(binary.BigEndian.Uint32(b[:4]))} - if bodyLen > 4 { - p.Data = make([]byte, bodyLen-4) - copy(p.Data, b[4:]) - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/paramprob.go b/vendor/golang.org/x/net/icmp/paramprob.go deleted file mode 100644 index 0a2548d..0000000 --- a/vendor/golang.org/x/net/icmp/paramprob.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import ( - "encoding/binary" - "golang.org/x/net/internal/iana" -) - -// A ParamProb represents an ICMP parameter problem message body. -type ParamProb struct { - Pointer uintptr // offset within the data where the error was detected - Data []byte // data, known as original datagram field - Extensions []Extension // extensions -} - -// Len implements the Len method of MessageBody interface. -func (p *ParamProb) Len(proto int) int { - if p == nil { - return 0 - } - l, _ := multipartMessageBodyDataLen(proto, p.Data, p.Extensions) - return 4 + l -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *ParamProb) Marshal(proto int) ([]byte, error) { - if proto == iana.ProtocolIPv6ICMP { - b := make([]byte, p.Len(proto)) - binary.BigEndian.PutUint32(b[:4], uint32(p.Pointer)) - copy(b[4:], p.Data) - return b, nil - } - b, err := marshalMultipartMessageBody(proto, p.Data, p.Extensions) - if err != nil { - return nil, err - } - b[0] = byte(p.Pointer) - return b, nil -} - -// parseParamProb parses b as an ICMP parameter problem message body. -func parseParamProb(proto int, b []byte) (MessageBody, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - p := &ParamProb{} - if proto == iana.ProtocolIPv6ICMP { - p.Pointer = uintptr(binary.BigEndian.Uint32(b[:4])) - p.Data = make([]byte, len(b)-4) - copy(p.Data, b[4:]) - return p, nil - } - p.Pointer = uintptr(b[0]) - var err error - p.Data, p.Extensions, err = parseMultipartMessageBody(proto, b) - if err != nil { - return nil, err - } - return p, nil -} diff --git a/vendor/golang.org/x/net/icmp/ping_test.go b/vendor/golang.org/x/net/icmp/ping_test.go deleted file mode 100644 index 4ec2692..0000000 --- a/vendor/golang.org/x/net/icmp/ping_test.go +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp_test - -import ( - "errors" - "fmt" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" - "golang.org/x/net/ipv6" -) - -func googleAddr(c *icmp.PacketConn, protocol int) (net.Addr, error) { - const host = "www.google.com" - ips, err := net.LookupIP(host) - if err != nil { - return nil, err - } - netaddr := func(ip net.IP) (net.Addr, error) { - switch c.LocalAddr().(type) { - case *net.UDPAddr: - return &net.UDPAddr{IP: ip}, nil - case *net.IPAddr: - return &net.IPAddr{IP: ip}, nil - default: - return nil, errors.New("neither UDPAddr nor IPAddr") - } - } - for _, ip := range ips { - switch protocol { - case iana.ProtocolICMP: - if ip.To4() != nil { - return netaddr(ip) - } - case iana.ProtocolIPv6ICMP: - if ip.To16() != nil && ip.To4() == nil { - return netaddr(ip) - } - } - } - return nil, errors.New("no A or AAAA record") -} - -type pingTest struct { - network, address string - protocol int - mtype icmp.Type -} - -var nonPrivilegedPingTests = []pingTest{ - {"udp4", "0.0.0.0", iana.ProtocolICMP, ipv4.ICMPTypeEcho}, - - {"udp6", "::", iana.ProtocolIPv6ICMP, ipv6.ICMPTypeEchoRequest}, -} - -func TestNonPrivilegedPing(t *testing.T) { - if testing.Short() { - t.Skip("avoid external network") - } - switch runtime.GOOS { - case "darwin": - case "linux": - t.Log("you may need to adjust the net.ipv4.ping_group_range kernel state") - default: - t.Skipf("not supported on %s", runtime.GOOS) - } - - for i, tt := range nonPrivilegedPingTests { - if err := doPing(tt, i); err != nil { - t.Error(err) - } - } -} - -var privilegedPingTests = []pingTest{ - {"ip4:icmp", "0.0.0.0", iana.ProtocolICMP, ipv4.ICMPTypeEcho}, - - {"ip6:ipv6-icmp", "::", iana.ProtocolIPv6ICMP, ipv6.ICMPTypeEchoRequest}, -} - -func TestPrivilegedPing(t *testing.T) { - if testing.Short() { - t.Skip("avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - for i, tt := range privilegedPingTests { - if err := doPing(tt, i); err != nil { - t.Error(err) - } - } -} - -func doPing(tt pingTest, seq int) error { - c, err := icmp.ListenPacket(tt.network, tt.address) - if err != nil { - return err - } - defer c.Close() - - dst, err := googleAddr(c, tt.protocol) - if err != nil { - return err - } - - if tt.network != "udp6" && tt.protocol == iana.ProtocolIPv6ICMP { - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeDestinationUnreachable) - f.Accept(ipv6.ICMPTypePacketTooBig) - f.Accept(ipv6.ICMPTypeTimeExceeded) - f.Accept(ipv6.ICMPTypeParameterProblem) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := c.IPv6PacketConn().SetICMPFilter(&f); err != nil { - return err - } - } - - wm := icmp.Message{ - Type: tt.mtype, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: 1 << uint(seq), - Data: []byte("HELLO-R-U-THERE"), - }, - } - wb, err := wm.Marshal(nil) - if err != nil { - return err - } - if n, err := c.WriteTo(wb, dst); err != nil { - return err - } else if n != len(wb) { - return fmt.Errorf("got %v; want %v", n, len(wb)) - } - - rb := make([]byte, 1500) - if err := c.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil { - return err - } - n, peer, err := c.ReadFrom(rb) - if err != nil { - return err - } - rm, err := icmp.ParseMessage(tt.protocol, rb[:n]) - if err != nil { - return err - } - switch rm.Type { - case ipv4.ICMPTypeEchoReply, ipv6.ICMPTypeEchoReply: - return nil - default: - return fmt.Errorf("got %+v from %v; want echo reply", rm, peer) - } -} diff --git a/vendor/golang.org/x/net/icmp/sys_freebsd.go b/vendor/golang.org/x/net/icmp/sys_freebsd.go deleted file mode 100644 index c75f3dd..0000000 --- a/vendor/golang.org/x/net/icmp/sys_freebsd.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -import "syscall" - -func init() { - freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate") -} diff --git a/vendor/golang.org/x/net/icmp/timeexceeded.go b/vendor/golang.org/x/net/icmp/timeexceeded.go deleted file mode 100644 index 344e158..0000000 --- a/vendor/golang.org/x/net/icmp/timeexceeded.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package icmp - -// A TimeExceeded represents an ICMP time exceeded message body. -type TimeExceeded struct { - Data []byte // data, known as original datagram field - Extensions []Extension // extensions -} - -// Len implements the Len method of MessageBody interface. -func (p *TimeExceeded) Len(proto int) int { - if p == nil { - return 0 - } - l, _ := multipartMessageBodyDataLen(proto, p.Data, p.Extensions) - return 4 + l -} - -// Marshal implements the Marshal method of MessageBody interface. -func (p *TimeExceeded) Marshal(proto int) ([]byte, error) { - return marshalMultipartMessageBody(proto, p.Data, p.Extensions) -} - -// parseTimeExceeded parses b as an ICMP time exceeded message body. -func parseTimeExceeded(proto int, b []byte) (MessageBody, error) { - if len(b) < 4 { - return nil, errMessageTooShort - } - p := &TimeExceeded{} - var err error - p.Data, p.Extensions, err = parseMultipartMessageBody(proto, b) - if err != nil { - return nil, err - } - return p, nil -} diff --git a/vendor/golang.org/x/net/idna/idna.go b/vendor/golang.org/x/net/idna/idna.go deleted file mode 100644 index 3daa897..0000000 --- a/vendor/golang.org/x/net/idna/idna.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package idna implements IDNA2008 (Internationalized Domain Names for -// Applications), defined in RFC 5890, RFC 5891, RFC 5892, RFC 5893 and -// RFC 5894. -package idna // import "golang.org/x/net/idna" - -import ( - "strings" - "unicode/utf8" -) - -// TODO(nigeltao): specify when errors occur. For example, is ToASCII(".") or -// ToASCII("foo\x00") an error? See also http://www.unicode.org/faq/idn.html#11 - -// acePrefix is the ASCII Compatible Encoding prefix. -const acePrefix = "xn--" - -// ToASCII converts a domain or domain label to its ASCII form. For example, -// ToASCII("bücher.example.com") is "xn--bcher-kva.example.com", and -// ToASCII("golang") is "golang". -func ToASCII(s string) (string, error) { - if ascii(s) { - return s, nil - } - labels := strings.Split(s, ".") - for i, label := range labels { - if !ascii(label) { - a, err := encode(acePrefix, label) - if err != nil { - return "", err - } - labels[i] = a - } - } - return strings.Join(labels, "."), nil -} - -// ToUnicode converts a domain or domain label to its Unicode form. For example, -// ToUnicode("xn--bcher-kva.example.com") is "bücher.example.com", and -// ToUnicode("golang") is "golang". -func ToUnicode(s string) (string, error) { - if !strings.Contains(s, acePrefix) { - return s, nil - } - labels := strings.Split(s, ".") - for i, label := range labels { - if strings.HasPrefix(label, acePrefix) { - u, err := decode(label[len(acePrefix):]) - if err != nil { - return "", err - } - labels[i] = u - } - } - return strings.Join(labels, "."), nil -} - -func ascii(s string) bool { - for i := 0; i < len(s); i++ { - if s[i] >= utf8.RuneSelf { - return false - } - } - return true -} diff --git a/vendor/golang.org/x/net/idna/idna_test.go b/vendor/golang.org/x/net/idna/idna_test.go deleted file mode 100644 index b1bc6fa..0000000 --- a/vendor/golang.org/x/net/idna/idna_test.go +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -import ( - "testing" -) - -var idnaTestCases = [...]struct { - ascii, unicode string -}{ - // Labels. - {"books", "books"}, - {"xn--bcher-kva", "bücher"}, - - // Domains. - {"foo--xn--bar.org", "foo--xn--bar.org"}, - {"golang.org", "golang.org"}, - {"example.xn--p1ai", "example.рф"}, - {"xn--czrw28b.tw", "商業.tw"}, - {"www.xn--mller-kva.de", "www.müller.de"}, -} - -func TestIDNA(t *testing.T) { - for _, tc := range idnaTestCases { - if a, err := ToASCII(tc.unicode); err != nil { - t.Errorf("ToASCII(%q): %v", tc.unicode, err) - } else if a != tc.ascii { - t.Errorf("ToASCII(%q): got %q, want %q", tc.unicode, a, tc.ascii) - } - - if u, err := ToUnicode(tc.ascii); err != nil { - t.Errorf("ToUnicode(%q): %v", tc.ascii, err) - } else if u != tc.unicode { - t.Errorf("ToUnicode(%q): got %q, want %q", tc.ascii, u, tc.unicode) - } - } -} - -// TODO(nigeltao): test errors, once we've specified when ToASCII and ToUnicode -// return errors. diff --git a/vendor/golang.org/x/net/idna/punycode.go b/vendor/golang.org/x/net/idna/punycode.go deleted file mode 100644 index 92e733f..0000000 --- a/vendor/golang.org/x/net/idna/punycode.go +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -// This file implements the Punycode algorithm from RFC 3492. - -import ( - "fmt" - "math" - "strings" - "unicode/utf8" -) - -// These parameter values are specified in section 5. -// -// All computation is done with int32s, so that overflow behavior is identical -// regardless of whether int is 32-bit or 64-bit. -const ( - base int32 = 36 - damp int32 = 700 - initialBias int32 = 72 - initialN int32 = 128 - skew int32 = 38 - tmax int32 = 26 - tmin int32 = 1 -) - -// decode decodes a string as specified in section 6.2. -func decode(encoded string) (string, error) { - if encoded == "" { - return "", nil - } - pos := 1 + strings.LastIndex(encoded, "-") - if pos == 1 { - return "", fmt.Errorf("idna: invalid label %q", encoded) - } - if pos == len(encoded) { - return encoded[:len(encoded)-1], nil - } - output := make([]rune, 0, len(encoded)) - if pos != 0 { - for _, r := range encoded[:pos-1] { - output = append(output, r) - } - } - i, n, bias := int32(0), initialN, initialBias - for pos < len(encoded) { - oldI, w := i, int32(1) - for k := base; ; k += base { - if pos == len(encoded) { - return "", fmt.Errorf("idna: invalid label %q", encoded) - } - digit, ok := decodeDigit(encoded[pos]) - if !ok { - return "", fmt.Errorf("idna: invalid label %q", encoded) - } - pos++ - i += digit * w - if i < 0 { - return "", fmt.Errorf("idna: invalid label %q", encoded) - } - t := k - bias - if t < tmin { - t = tmin - } else if t > tmax { - t = tmax - } - if digit < t { - break - } - w *= base - t - if w >= math.MaxInt32/base { - return "", fmt.Errorf("idna: invalid label %q", encoded) - } - } - x := int32(len(output) + 1) - bias = adapt(i-oldI, x, oldI == 0) - n += i / x - i %= x - if n > utf8.MaxRune || len(output) >= 1024 { - return "", fmt.Errorf("idna: invalid label %q", encoded) - } - output = append(output, 0) - copy(output[i+1:], output[i:]) - output[i] = n - i++ - } - return string(output), nil -} - -// encode encodes a string as specified in section 6.3 and prepends prefix to -// the result. -// -// The "while h < length(input)" line in the specification becomes "for -// remaining != 0" in the Go code, because len(s) in Go is in bytes, not runes. -func encode(prefix, s string) (string, error) { - output := make([]byte, len(prefix), len(prefix)+1+2*len(s)) - copy(output, prefix) - delta, n, bias := int32(0), initialN, initialBias - b, remaining := int32(0), int32(0) - for _, r := range s { - if r < 0x80 { - b++ - output = append(output, byte(r)) - } else { - remaining++ - } - } - h := b - if b > 0 { - output = append(output, '-') - } - for remaining != 0 { - m := int32(0x7fffffff) - for _, r := range s { - if m > r && r >= n { - m = r - } - } - delta += (m - n) * (h + 1) - if delta < 0 { - return "", fmt.Errorf("idna: invalid label %q", s) - } - n = m - for _, r := range s { - if r < n { - delta++ - if delta < 0 { - return "", fmt.Errorf("idna: invalid label %q", s) - } - continue - } - if r > n { - continue - } - q := delta - for k := base; ; k += base { - t := k - bias - if t < tmin { - t = tmin - } else if t > tmax { - t = tmax - } - if q < t { - break - } - output = append(output, encodeDigit(t+(q-t)%(base-t))) - q = (q - t) / (base - t) - } - output = append(output, encodeDigit(q)) - bias = adapt(delta, h+1, h == b) - delta = 0 - h++ - remaining-- - } - delta++ - n++ - } - return string(output), nil -} - -func decodeDigit(x byte) (digit int32, ok bool) { - switch { - case '0' <= x && x <= '9': - return int32(x - ('0' - 26)), true - case 'A' <= x && x <= 'Z': - return int32(x - 'A'), true - case 'a' <= x && x <= 'z': - return int32(x - 'a'), true - } - return 0, false -} - -func encodeDigit(digit int32) byte { - switch { - case 0 <= digit && digit < 26: - return byte(digit + 'a') - case 26 <= digit && digit < 36: - return byte(digit + ('0' - 26)) - } - panic("idna: internal error in punycode encoding") -} - -// adapt is the bias adaptation function specified in section 6.1. -func adapt(delta, numPoints int32, firstTime bool) int32 { - if firstTime { - delta /= damp - } else { - delta /= 2 - } - delta += delta / numPoints - k := int32(0) - for delta > ((base-tmin)*tmax)/2 { - delta /= base - tmin - k += base - } - return k + (base-tmin+1)*delta/(delta+skew) -} diff --git a/vendor/golang.org/x/net/idna/punycode_test.go b/vendor/golang.org/x/net/idna/punycode_test.go deleted file mode 100644 index bfec81d..0000000 --- a/vendor/golang.org/x/net/idna/punycode_test.go +++ /dev/null @@ -1,198 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package idna - -import ( - "strings" - "testing" -) - -var punycodeTestCases = [...]struct { - s, encoded string -}{ - {"", ""}, - {"-", "--"}, - {"-a", "-a-"}, - {"-a-", "-a--"}, - {"a", "a-"}, - {"a-", "a--"}, - {"a-b", "a-b-"}, - {"books", "books-"}, - {"bücher", "bcher-kva"}, - {"Hello世界", "Hello-ck1hg65u"}, - {"ü", "tda"}, - {"üý", "tdac"}, - - // The test cases below come from RFC 3492 section 7.1 with Errata 3026. - { - // (A) Arabic (Egyptian). - "\u0644\u064A\u0647\u0645\u0627\u0628\u062A\u0643\u0644" + - "\u0645\u0648\u0634\u0639\u0631\u0628\u064A\u061F", - "egbpdaj6bu4bxfgehfvwxn", - }, - { - // (B) Chinese (simplified). - "\u4ED6\u4EEC\u4E3A\u4EC0\u4E48\u4E0D\u8BF4\u4E2D\u6587", - "ihqwcrb4cv8a8dqg056pqjye", - }, - { - // (C) Chinese (traditional). - "\u4ED6\u5011\u7232\u4EC0\u9EBD\u4E0D\u8AAA\u4E2D\u6587", - "ihqwctvzc91f659drss3x8bo0yb", - }, - { - // (D) Czech. - "\u0050\u0072\u006F\u010D\u0070\u0072\u006F\u0073\u0074" + - "\u011B\u006E\u0065\u006D\u006C\u0075\u0076\u00ED\u010D" + - "\u0065\u0073\u006B\u0079", - "Proprostnemluvesky-uyb24dma41a", - }, - { - // (E) Hebrew. - "\u05DC\u05DE\u05D4\u05D4\u05DD\u05E4\u05E9\u05D5\u05D8" + - "\u05DC\u05D0\u05DE\u05D3\u05D1\u05E8\u05D9\u05DD\u05E2" + - "\u05D1\u05E8\u05D9\u05EA", - "4dbcagdahymbxekheh6e0a7fei0b", - }, - { - // (F) Hindi (Devanagari). - "\u092F\u0939\u0932\u094B\u0917\u0939\u093F\u0928\u094D" + - "\u0926\u0940\u0915\u094D\u092F\u094B\u0902\u0928\u0939" + - "\u0940\u0902\u092C\u094B\u0932\u0938\u0915\u0924\u0947" + - "\u0939\u0948\u0902", - "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd", - }, - { - // (G) Japanese (kanji and hiragana). - "\u306A\u305C\u307F\u3093\u306A\u65E5\u672C\u8A9E\u3092" + - "\u8A71\u3057\u3066\u304F\u308C\u306A\u3044\u306E\u304B", - "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa", - }, - { - // (H) Korean (Hangul syllables). - "\uC138\uACC4\uC758\uBAA8\uB4E0\uC0AC\uB78C\uB4E4\uC774" + - "\uD55C\uAD6D\uC5B4\uB97C\uC774\uD574\uD55C\uB2E4\uBA74" + - "\uC5BC\uB9C8\uB098\uC88B\uC744\uAE4C", - "989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5j" + - "psd879ccm6fea98c", - }, - { - // (I) Russian (Cyrillic). - "\u043F\u043E\u0447\u0435\u043C\u0443\u0436\u0435\u043E" + - "\u043D\u0438\u043D\u0435\u0433\u043E\u0432\u043E\u0440" + - "\u044F\u0442\u043F\u043E\u0440\u0443\u0441\u0441\u043A" + - "\u0438", - "b1abfaaepdrnnbgefbadotcwatmq2g4l", - }, - { - // (J) Spanish. - "\u0050\u006F\u0072\u0071\u0075\u00E9\u006E\u006F\u0070" + - "\u0075\u0065\u0064\u0065\u006E\u0073\u0069\u006D\u0070" + - "\u006C\u0065\u006D\u0065\u006E\u0074\u0065\u0068\u0061" + - "\u0062\u006C\u0061\u0072\u0065\u006E\u0045\u0073\u0070" + - "\u0061\u00F1\u006F\u006C", - "PorqunopuedensimplementehablarenEspaol-fmd56a", - }, - { - // (K) Vietnamese. - "\u0054\u1EA1\u0069\u0073\u0061\u006F\u0068\u1ECD\u006B" + - "\u0068\u00F4\u006E\u0067\u0074\u0068\u1EC3\u0063\u0068" + - "\u1EC9\u006E\u00F3\u0069\u0074\u0069\u1EBF\u006E\u0067" + - "\u0056\u0069\u1EC7\u0074", - "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g", - }, - { - // (L) 3B. - "\u0033\u5E74\u0042\u7D44\u91D1\u516B\u5148\u751F", - "3B-ww4c5e180e575a65lsy2b", - }, - { - // (M) -with-SUPER-MONKEYS. - "\u5B89\u5BA4\u5948\u7F8E\u6075\u002D\u0077\u0069\u0074" + - "\u0068\u002D\u0053\u0055\u0050\u0045\u0052\u002D\u004D" + - "\u004F\u004E\u004B\u0045\u0059\u0053", - "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n", - }, - { - // (N) Hello-Another-Way-. - "\u0048\u0065\u006C\u006C\u006F\u002D\u0041\u006E\u006F" + - "\u0074\u0068\u0065\u0072\u002D\u0057\u0061\u0079\u002D" + - "\u305D\u308C\u305E\u308C\u306E\u5834\u6240", - "Hello-Another-Way--fc4qua05auwb3674vfr0b", - }, - { - // (O) 2. - "\u3072\u3068\u3064\u5C4B\u6839\u306E\u4E0B\u0032", - "2-u9tlzr9756bt3uc0v", - }, - { - // (P) MajiKoi5 - "\u004D\u0061\u006A\u0069\u3067\u004B\u006F\u0069\u3059" + - "\u308B\u0035\u79D2\u524D", - "MajiKoi5-783gue6qz075azm5e", - }, - { - // (Q) de - "\u30D1\u30D5\u30A3\u30FC\u0064\u0065\u30EB\u30F3\u30D0", - "de-jg4avhby1noc0d", - }, - { - // (R) - "\u305D\u306E\u30B9\u30D4\u30FC\u30C9\u3067", - "d9juau41awczczp", - }, - { - // (S) -> $1.00 <- - "\u002D\u003E\u0020\u0024\u0031\u002E\u0030\u0030\u0020" + - "\u003C\u002D", - "-> $1.00 <--", - }, -} - -func TestPunycode(t *testing.T) { - for _, tc := range punycodeTestCases { - if got, err := decode(tc.encoded); err != nil { - t.Errorf("decode(%q): %v", tc.encoded, err) - } else if got != tc.s { - t.Errorf("decode(%q): got %q, want %q", tc.encoded, got, tc.s) - } - - if got, err := encode("", tc.s); err != nil { - t.Errorf(`encode("", %q): %v`, tc.s, err) - } else if got != tc.encoded { - t.Errorf(`encode("", %q): got %q, want %q`, tc.s, got, tc.encoded) - } - } -} - -var punycodeErrorTestCases = [...]string{ - "decode -", // A sole '-' is invalid. - "decode foo\x00bar", // '\x00' is not in [0-9A-Za-z]. - "decode foo#bar", // '#' is not in [0-9A-Za-z]. - "decode foo\u00A3bar", // '\u00A3' is not in [0-9A-Za-z]. - "decode 9", // "9a" decodes to codepoint \u00A3; "9" is truncated. - "decode 99999a", // "99999a" decodes to codepoint \U0048A3C1, which is > \U0010FFFF. - "decode 9999999999a", // "9999999999a" overflows the int32 calculation. - - "encode " + strings.Repeat("x", 65536) + "\uff00", // int32 overflow. -} - -func TestPunycodeErrors(t *testing.T) { - for _, tc := range punycodeErrorTestCases { - var err error - switch { - case strings.HasPrefix(tc, "decode "): - _, err = decode(tc[7:]) - case strings.HasPrefix(tc, "encode "): - _, err = encode("", tc[7:]) - } - if err == nil { - if len(tc) > 256 { - tc = tc[:100] + "..." + tc[len(tc)-100:] - } - t.Errorf("no error for %s", tc) - } - } -} diff --git a/vendor/golang.org/x/net/internal/iana/const.go b/vendor/golang.org/x/net/internal/iana/const.go deleted file mode 100644 index 3438a27..0000000 --- a/vendor/golang.org/x/net/internal/iana/const.go +++ /dev/null @@ -1,180 +0,0 @@ -// go generate gen.go -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA). -package iana // import "golang.org/x/net/internal/iana" - -// Differentiated Services Field Codepoints (DSCP), Updated: 2013-06-25 -const ( - DiffServCS0 = 0x0 // CS0 - DiffServCS1 = 0x20 // CS1 - DiffServCS2 = 0x40 // CS2 - DiffServCS3 = 0x60 // CS3 - DiffServCS4 = 0x80 // CS4 - DiffServCS5 = 0xa0 // CS5 - DiffServCS6 = 0xc0 // CS6 - DiffServCS7 = 0xe0 // CS7 - DiffServAF11 = 0x28 // AF11 - DiffServAF12 = 0x30 // AF12 - DiffServAF13 = 0x38 // AF13 - DiffServAF21 = 0x48 // AF21 - DiffServAF22 = 0x50 // AF22 - DiffServAF23 = 0x58 // AF23 - DiffServAF31 = 0x68 // AF31 - DiffServAF32 = 0x70 // AF32 - DiffServAF33 = 0x78 // AF33 - DiffServAF41 = 0x88 // AF41 - DiffServAF42 = 0x90 // AF42 - DiffServAF43 = 0x98 // AF43 - DiffServEFPHB = 0xb8 // EF PHB - DiffServVOICEADMIT = 0xb0 // VOICE-ADMIT -) - -// IPv4 TOS Byte and IPv6 Traffic Class Octet, Updated: 2001-09-06 -const ( - NotECNTransport = 0x0 // Not-ECT (Not ECN-Capable Transport) - ECNTransport1 = 0x1 // ECT(1) (ECN-Capable Transport(1)) - ECNTransport0 = 0x2 // ECT(0) (ECN-Capable Transport(0)) - CongestionExperienced = 0x3 // CE (Congestion Experienced) -) - -// Protocol Numbers, Updated: 2015-10-06 -const ( - ProtocolIP = 0 // IPv4 encapsulation, pseudo protocol number - ProtocolHOPOPT = 0 // IPv6 Hop-by-Hop Option - ProtocolICMP = 1 // Internet Control Message - ProtocolIGMP = 2 // Internet Group Management - ProtocolGGP = 3 // Gateway-to-Gateway - ProtocolIPv4 = 4 // IPv4 encapsulation - ProtocolST = 5 // Stream - ProtocolTCP = 6 // Transmission Control - ProtocolCBT = 7 // CBT - ProtocolEGP = 8 // Exterior Gateway Protocol - ProtocolIGP = 9 // any private interior gateway (used by Cisco for their IGRP) - ProtocolBBNRCCMON = 10 // BBN RCC Monitoring - ProtocolNVPII = 11 // Network Voice Protocol - ProtocolPUP = 12 // PUP - ProtocolEMCON = 14 // EMCON - ProtocolXNET = 15 // Cross Net Debugger - ProtocolCHAOS = 16 // Chaos - ProtocolUDP = 17 // User Datagram - ProtocolMUX = 18 // Multiplexing - ProtocolDCNMEAS = 19 // DCN Measurement Subsystems - ProtocolHMP = 20 // Host Monitoring - ProtocolPRM = 21 // Packet Radio Measurement - ProtocolXNSIDP = 22 // XEROX NS IDP - ProtocolTRUNK1 = 23 // Trunk-1 - ProtocolTRUNK2 = 24 // Trunk-2 - ProtocolLEAF1 = 25 // Leaf-1 - ProtocolLEAF2 = 26 // Leaf-2 - ProtocolRDP = 27 // Reliable Data Protocol - ProtocolIRTP = 28 // Internet Reliable Transaction - ProtocolISOTP4 = 29 // ISO Transport Protocol Class 4 - ProtocolNETBLT = 30 // Bulk Data Transfer Protocol - ProtocolMFENSP = 31 // MFE Network Services Protocol - ProtocolMERITINP = 32 // MERIT Internodal Protocol - ProtocolDCCP = 33 // Datagram Congestion Control Protocol - Protocol3PC = 34 // Third Party Connect Protocol - ProtocolIDPR = 35 // Inter-Domain Policy Routing Protocol - ProtocolXTP = 36 // XTP - ProtocolDDP = 37 // Datagram Delivery Protocol - ProtocolIDPRCMTP = 38 // IDPR Control Message Transport Proto - ProtocolTPPP = 39 // TP++ Transport Protocol - ProtocolIL = 40 // IL Transport Protocol - ProtocolIPv6 = 41 // IPv6 encapsulation - ProtocolSDRP = 42 // Source Demand Routing Protocol - ProtocolIPv6Route = 43 // Routing Header for IPv6 - ProtocolIPv6Frag = 44 // Fragment Header for IPv6 - ProtocolIDRP = 45 // Inter-Domain Routing Protocol - ProtocolRSVP = 46 // Reservation Protocol - ProtocolGRE = 47 // Generic Routing Encapsulation - ProtocolDSR = 48 // Dynamic Source Routing Protocol - ProtocolBNA = 49 // BNA - ProtocolESP = 50 // Encap Security Payload - ProtocolAH = 51 // Authentication Header - ProtocolINLSP = 52 // Integrated Net Layer Security TUBA - ProtocolNARP = 54 // NBMA Address Resolution Protocol - ProtocolMOBILE = 55 // IP Mobility - ProtocolTLSP = 56 // Transport Layer Security Protocol using Kryptonet key management - ProtocolSKIP = 57 // SKIP - ProtocolIPv6ICMP = 58 // ICMP for IPv6 - ProtocolIPv6NoNxt = 59 // No Next Header for IPv6 - ProtocolIPv6Opts = 60 // Destination Options for IPv6 - ProtocolCFTP = 62 // CFTP - ProtocolSATEXPAK = 64 // SATNET and Backroom EXPAK - ProtocolKRYPTOLAN = 65 // Kryptolan - ProtocolRVD = 66 // MIT Remote Virtual Disk Protocol - ProtocolIPPC = 67 // Internet Pluribus Packet Core - ProtocolSATMON = 69 // SATNET Monitoring - ProtocolVISA = 70 // VISA Protocol - ProtocolIPCV = 71 // Internet Packet Core Utility - ProtocolCPNX = 72 // Computer Protocol Network Executive - ProtocolCPHB = 73 // Computer Protocol Heart Beat - ProtocolWSN = 74 // Wang Span Network - ProtocolPVP = 75 // Packet Video Protocol - ProtocolBRSATMON = 76 // Backroom SATNET Monitoring - ProtocolSUNND = 77 // SUN ND PROTOCOL-Temporary - ProtocolWBMON = 78 // WIDEBAND Monitoring - ProtocolWBEXPAK = 79 // WIDEBAND EXPAK - ProtocolISOIP = 80 // ISO Internet Protocol - ProtocolVMTP = 81 // VMTP - ProtocolSECUREVMTP = 82 // SECURE-VMTP - ProtocolVINES = 83 // VINES - ProtocolTTP = 84 // Transaction Transport Protocol - ProtocolIPTM = 84 // Internet Protocol Traffic Manager - ProtocolNSFNETIGP = 85 // NSFNET-IGP - ProtocolDGP = 86 // Dissimilar Gateway Protocol - ProtocolTCF = 87 // TCF - ProtocolEIGRP = 88 // EIGRP - ProtocolOSPFIGP = 89 // OSPFIGP - ProtocolSpriteRPC = 90 // Sprite RPC Protocol - ProtocolLARP = 91 // Locus Address Resolution Protocol - ProtocolMTP = 92 // Multicast Transport Protocol - ProtocolAX25 = 93 // AX.25 Frames - ProtocolIPIP = 94 // IP-within-IP Encapsulation Protocol - ProtocolSCCSP = 96 // Semaphore Communications Sec. Pro. - ProtocolETHERIP = 97 // Ethernet-within-IP Encapsulation - ProtocolENCAP = 98 // Encapsulation Header - ProtocolGMTP = 100 // GMTP - ProtocolIFMP = 101 // Ipsilon Flow Management Protocol - ProtocolPNNI = 102 // PNNI over IP - ProtocolPIM = 103 // Protocol Independent Multicast - ProtocolARIS = 104 // ARIS - ProtocolSCPS = 105 // SCPS - ProtocolQNX = 106 // QNX - ProtocolAN = 107 // Active Networks - ProtocolIPComp = 108 // IP Payload Compression Protocol - ProtocolSNP = 109 // Sitara Networks Protocol - ProtocolCompaqPeer = 110 // Compaq Peer Protocol - ProtocolIPXinIP = 111 // IPX in IP - ProtocolVRRP = 112 // Virtual Router Redundancy Protocol - ProtocolPGM = 113 // PGM Reliable Transport Protocol - ProtocolL2TP = 115 // Layer Two Tunneling Protocol - ProtocolDDX = 116 // D-II Data Exchange (DDX) - ProtocolIATP = 117 // Interactive Agent Transfer Protocol - ProtocolSTP = 118 // Schedule Transfer Protocol - ProtocolSRP = 119 // SpectraLink Radio Protocol - ProtocolUTI = 120 // UTI - ProtocolSMP = 121 // Simple Message Protocol - ProtocolPTP = 123 // Performance Transparency Protocol - ProtocolISIS = 124 // ISIS over IPv4 - ProtocolFIRE = 125 // FIRE - ProtocolCRTP = 126 // Combat Radio Transport Protocol - ProtocolCRUDP = 127 // Combat Radio User Datagram - ProtocolSSCOPMCE = 128 // SSCOPMCE - ProtocolIPLT = 129 // IPLT - ProtocolSPS = 130 // Secure Packet Shield - ProtocolPIPE = 131 // Private IP Encapsulation within IP - ProtocolSCTP = 132 // Stream Control Transmission Protocol - ProtocolFC = 133 // Fibre Channel - ProtocolRSVPE2EIGNORE = 134 // RSVP-E2E-IGNORE - ProtocolMobilityHeader = 135 // Mobility Header - ProtocolUDPLite = 136 // UDPLite - ProtocolMPLSinIP = 137 // MPLS-in-IP - ProtocolMANET = 138 // MANET Protocols - ProtocolHIP = 139 // Host Identity Protocol - ProtocolShim6 = 140 // Shim6 Protocol - ProtocolWESP = 141 // Wrapped Encapsulating Security Payload - ProtocolROHC = 142 // Robust Header Compression - ProtocolReserved = 255 // Reserved -) diff --git a/vendor/golang.org/x/net/internal/iana/gen.go b/vendor/golang.org/x/net/internal/iana/gen.go deleted file mode 100644 index 2d8c07c..0000000 --- a/vendor/golang.org/x/net/internal/iana/gen.go +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates internet protocol constants and tables by -// reading IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "strconv" - "strings" -) - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "http://www.iana.org/assignments/dscp-registry/dscp-registry.xml", - parseDSCPRegistry, - }, - { - "http://www.iana.org/assignments/ipv4-tos-byte/ipv4-tos-byte.xml", - parseTOSTCByte, - }, - { - "http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml", - parseProtocolNumbers, - }, -} - -func main() { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n") - fmt.Fprintf(&bb, "// Package iana provides protocol number resources managed by the Internet Assigned Numbers Authority (IANA).\n") - fmt.Fprintf(&bb, `package iana // import "golang.org/x/net/internal/iana"`+"\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - fmt.Fprintf(os.Stderr, "got HTTP status code %v for %v\n", resp.StatusCode, r.url) - os.Exit(1) - } - if err := r.parse(&bb, resp.Body); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := ioutil.WriteFile("const.go", b, 0644); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func parseDSCPRegistry(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var dr dscpRegistry - if err := dec.Decode(&dr); err != nil { - return err - } - drs := dr.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", dr.Title, dr.Updated) - fmt.Fprintf(w, "const (\n") - for _, dr := range drs { - fmt.Fprintf(w, "DiffServ%s = %#x", dr.Name, dr.Value) - fmt.Fprintf(w, "// %s\n", dr.OrigName) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type dscpRegistry struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Note string `xml:"note"` - RegTitle string `xml:"registry>title"` - PoolRecords []struct { - Name string `xml:"name"` - Space string `xml:"space"` - } `xml:"registry>record"` - Records []struct { - Name string `xml:"name"` - Space string `xml:"space"` - } `xml:"registry>registry>record"` -} - -type canonDSCPRecord struct { - OrigName string - Name string - Value int -} - -func (drr *dscpRegistry) escape() []canonDSCPRecord { - drs := make([]canonDSCPRecord, len(drr.Records)) - sr := strings.NewReplacer( - "+", "", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, dr := range drr.Records { - s := strings.TrimSpace(dr.Name) - drs[i].OrigName = s - drs[i].Name = sr.Replace(s) - n, err := strconv.ParseUint(dr.Space, 2, 8) - if err != nil { - continue - } - drs[i].Value = int(n) << 2 - } - return drs -} - -func parseTOSTCByte(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var ttb tosTCByte - if err := dec.Decode(&ttb); err != nil { - return err - } - trs := ttb.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", ttb.Title, ttb.Updated) - fmt.Fprintf(w, "const (\n") - for _, tr := range trs { - fmt.Fprintf(w, "%s = %#x", tr.Keyword, tr.Value) - fmt.Fprintf(w, "// %s\n", tr.OrigKeyword) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type tosTCByte struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Note string `xml:"note"` - RegTitle string `xml:"registry>title"` - Records []struct { - Binary string `xml:"binary"` - Keyword string `xml:"keyword"` - } `xml:"registry>record"` -} - -type canonTOSTCByteRecord struct { - OrigKeyword string - Keyword string - Value int -} - -func (ttb *tosTCByte) escape() []canonTOSTCByteRecord { - trs := make([]canonTOSTCByteRecord, len(ttb.Records)) - sr := strings.NewReplacer( - "Capable", "", - "(", "", - ")", "", - "+", "", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, tr := range ttb.Records { - s := strings.TrimSpace(tr.Keyword) - trs[i].OrigKeyword = s - ss := strings.Split(s, " ") - if len(ss) > 1 { - trs[i].Keyword = strings.Join(ss[1:], " ") - } else { - trs[i].Keyword = ss[0] - } - trs[i].Keyword = sr.Replace(trs[i].Keyword) - n, err := strconv.ParseUint(tr.Binary, 2, 8) - if err != nil { - continue - } - trs[i].Value = int(n) - } - return trs -} - -func parseProtocolNumbers(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var pn protocolNumbers - if err := dec.Decode(&pn); err != nil { - return err - } - prs := pn.escape() - prs = append([]canonProtocolRecord{{ - Name: "IP", - Descr: "IPv4 encapsulation, pseudo protocol number", - Value: 0, - }}, prs...) - fmt.Fprintf(w, "// %s, Updated: %s\n", pn.Title, pn.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Name == "" { - continue - } - fmt.Fprintf(w, "Protocol%s = %d", pr.Name, pr.Value) - s := pr.Descr - if s == "" { - s = pr.OrigName - } - fmt.Fprintf(w, "// %s\n", s) - } - fmt.Fprintf(w, ")\n") - return nil -} - -type protocolNumbers struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - RegTitle string `xml:"registry>title"` - Note string `xml:"registry>note"` - Records []struct { - Value string `xml:"value"` - Name string `xml:"name"` - Descr string `xml:"description"` - } `xml:"registry>record"` -} - -type canonProtocolRecord struct { - OrigName string - Name string - Descr string - Value int -} - -func (pn *protocolNumbers) escape() []canonProtocolRecord { - prs := make([]canonProtocolRecord, len(pn.Records)) - sr := strings.NewReplacer( - "-in-", "in", - "-within-", "within", - "-over-", "over", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range pn.Records { - if strings.Contains(pr.Name, "Deprecated") || - strings.Contains(pr.Name, "deprecated") { - continue - } - prs[i].OrigName = pr.Name - s := strings.TrimSpace(pr.Name) - switch pr.Name { - case "ISIS over IPv4": - prs[i].Name = "ISIS" - case "manet": - prs[i].Name = "MANET" - default: - prs[i].Name = sr.Replace(s) - } - ss := strings.Split(pr.Descr, "\n") - for i := range ss { - ss[i] = strings.TrimSpace(ss[i]) - } - if len(ss) > 1 { - prs[i].Descr = strings.Join(ss, " ") - } else { - prs[i].Descr = ss[0] - } - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} diff --git a/vendor/golang.org/x/net/internal/nettest/error_posix.go b/vendor/golang.org/x/net/internal/nettest/error_posix.go deleted file mode 100644 index 963ed99..0000000 --- a/vendor/golang.org/x/net/internal/nettest/error_posix.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows - -package nettest - -import ( - "os" - "syscall" -) - -func protocolNotSupported(err error) bool { - switch err := err.(type) { - case syscall.Errno: - switch err { - case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT: - return true - } - case *os.SyscallError: - switch err := err.Err.(type) { - case syscall.Errno: - switch err { - case syscall.EPROTONOSUPPORT, syscall.ENOPROTOOPT: - return true - } - } - } - return false -} diff --git a/vendor/golang.org/x/net/internal/nettest/error_stub.go b/vendor/golang.org/x/net/internal/nettest/error_stub.go deleted file mode 100644 index 3c74d81..0000000 --- a/vendor/golang.org/x/net/internal/nettest/error_stub.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package nettest - -func protocolNotSupported(err error) bool { - return false -} diff --git a/vendor/golang.org/x/net/internal/nettest/interface.go b/vendor/golang.org/x/net/internal/nettest/interface.go deleted file mode 100644 index 53ae13a..0000000 --- a/vendor/golang.org/x/net/internal/nettest/interface.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package nettest - -import "net" - -// IsMulticastCapable reports whether ifi is an IP multicast-capable -// network interface. Network must be "ip", "ip4" or "ip6". -func IsMulticastCapable(network string, ifi *net.Interface) (net.IP, bool) { - switch network { - case "ip", "ip4", "ip6": - default: - return nil, false - } - if ifi == nil || ifi.Flags&net.FlagUp == 0 || ifi.Flags&net.FlagMulticast == 0 { - return nil, false - } - return hasRoutableIP(network, ifi) -} - -// RoutedInterface returns a network interface that can route IP -// traffic and satisfies flags. It returns nil when an appropriate -// network interface is not found. Network must be "ip", "ip4" or -// "ip6". -func RoutedInterface(network string, flags net.Flags) *net.Interface { - switch network { - case "ip", "ip4", "ip6": - default: - return nil - } - ift, err := net.Interfaces() - if err != nil { - return nil - } - for _, ifi := range ift { - if ifi.Flags&flags != flags { - continue - } - if _, ok := hasRoutableIP(network, &ifi); !ok { - continue - } - return &ifi - } - return nil -} - -func hasRoutableIP(network string, ifi *net.Interface) (net.IP, bool) { - ifat, err := ifi.Addrs() - if err != nil { - return nil, false - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := routableIP(network, ifa.IP); ip != nil { - return ip, true - } - case *net.IPNet: - if ip := routableIP(network, ifa.IP); ip != nil { - return ip, true - } - } - } - return nil, false -} - -func routableIP(network string, ip net.IP) net.IP { - if !ip.IsLoopback() && !ip.IsLinkLocalUnicast() && !ip.IsGlobalUnicast() { - return nil - } - switch network { - case "ip4": - if ip := ip.To4(); ip != nil { - return ip - } - case "ip6": - if ip.IsLoopback() { // addressing scope of the loopback address depends on each implementation - return nil - } - if ip := ip.To16(); ip != nil && ip.To4() == nil { - return ip - } - default: - if ip := ip.To4(); ip != nil { - return ip - } - if ip := ip.To16(); ip != nil { - return ip - } - } - return nil -} diff --git a/vendor/golang.org/x/net/internal/nettest/rlimit.go b/vendor/golang.org/x/net/internal/nettest/rlimit.go deleted file mode 100644 index bb34aec..0000000 --- a/vendor/golang.org/x/net/internal/nettest/rlimit.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package nettest - -const defaultMaxOpenFiles = 256 - -// MaxOpenFiles returns the maximum number of open files for the -// caller's process. -func MaxOpenFiles() int { return maxOpenFiles() } diff --git a/vendor/golang.org/x/net/internal/nettest/rlimit_stub.go b/vendor/golang.org/x/net/internal/nettest/rlimit_stub.go deleted file mode 100644 index 102bef9..0000000 --- a/vendor/golang.org/x/net/internal/nettest/rlimit_stub.go +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package nettest - -func maxOpenFiles() int { return defaultMaxOpenFiles } diff --git a/vendor/golang.org/x/net/internal/nettest/rlimit_unix.go b/vendor/golang.org/x/net/internal/nettest/rlimit_unix.go deleted file mode 100644 index eb4312c..0000000 --- a/vendor/golang.org/x/net/internal/nettest/rlimit_unix.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package nettest - -import "syscall" - -func maxOpenFiles() int { - var rlim syscall.Rlimit - if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil { - return defaultMaxOpenFiles - } - return int(rlim.Cur) -} diff --git a/vendor/golang.org/x/net/internal/nettest/rlimit_windows.go b/vendor/golang.org/x/net/internal/nettest/rlimit_windows.go deleted file mode 100644 index de927b5..0000000 --- a/vendor/golang.org/x/net/internal/nettest/rlimit_windows.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package nettest - -func maxOpenFiles() int { return 4 * defaultMaxOpenFiles /* actually it's 16581375 */ } diff --git a/vendor/golang.org/x/net/internal/nettest/stack.go b/vendor/golang.org/x/net/internal/nettest/stack.go deleted file mode 100644 index e07c015..0000000 --- a/vendor/golang.org/x/net/internal/nettest/stack.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package nettest provides utilities for IP testing. -package nettest // import "golang.org/x/net/internal/nettest" - -import "net" - -// SupportsIPv4 reports whether the platform supports IPv4 networking -// functionality. -func SupportsIPv4() bool { - ln, err := net.Listen("tcp4", "127.0.0.1:0") - if err != nil { - return false - } - ln.Close() - return true -} - -// SupportsIPv6 reports whether the platform supports IPv6 networking -// functionality. -func SupportsIPv6() bool { - ln, err := net.Listen("tcp6", "[::1]:0") - if err != nil { - return false - } - ln.Close() - return true -} - -// ProtocolNotSupported reports whether err is a protocol not -// supported error. -func ProtocolNotSupported(err error) bool { - return protocolNotSupported(err) -} diff --git a/vendor/golang.org/x/net/internal/nettest/stack_stub.go b/vendor/golang.org/x/net/internal/nettest/stack_stub.go deleted file mode 100644 index 1b5fde1..0000000 --- a/vendor/golang.org/x/net/internal/nettest/stack_stub.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package nettest - -import ( - "fmt" - "runtime" -) - -// SupportsRawIPSocket reports whether the platform supports raw IP -// sockets. -func SupportsRawIPSocket() (string, bool) { - return fmt.Sprintf("not supported on %s", runtime.GOOS), false -} diff --git a/vendor/golang.org/x/net/internal/nettest/stack_unix.go b/vendor/golang.org/x/net/internal/nettest/stack_unix.go deleted file mode 100644 index af89229..0000000 --- a/vendor/golang.org/x/net/internal/nettest/stack_unix.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd solaris - -package nettest - -import ( - "fmt" - "os" - "runtime" -) - -// SupportsRawIPSocket reports whether the platform supports raw IP -// sockets. -func SupportsRawIPSocket() (string, bool) { - if os.Getuid() != 0 { - return fmt.Sprintf("must be root on %s", runtime.GOOS), false - } - return "", true -} diff --git a/vendor/golang.org/x/net/internal/nettest/stack_windows.go b/vendor/golang.org/x/net/internal/nettest/stack_windows.go deleted file mode 100644 index a21f499..0000000 --- a/vendor/golang.org/x/net/internal/nettest/stack_windows.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package nettest - -import ( - "fmt" - "runtime" - "syscall" -) - -// SupportsRawIPSocket reports whether the platform supports raw IP -// sockets. -func SupportsRawIPSocket() (string, bool) { - // From http://msdn.microsoft.com/en-us/library/windows/desktop/ms740548.aspx: - // Note: To use a socket of type SOCK_RAW requires administrative privileges. - // Users running Winsock applications that use raw sockets must be a member of - // the Administrators group on the local computer, otherwise raw socket calls - // will fail with an error code of WSAEACCES. On Windows Vista and later, access - // for raw sockets is enforced at socket creation. In earlier versions of Windows, - // access for raw sockets is enforced during other socket operations. - s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, 0) - if err == syscall.WSAEACCES { - return fmt.Sprintf("no access to raw socket allowed on %s", runtime.GOOS), false - } - if err != nil { - return err.Error(), false - } - syscall.Closesocket(s) - return "", true -} diff --git a/vendor/golang.org/x/net/internal/timeseries/timeseries.go b/vendor/golang.org/x/net/internal/timeseries/timeseries.go deleted file mode 100644 index 1119f34..0000000 --- a/vendor/golang.org/x/net/internal/timeseries/timeseries.go +++ /dev/null @@ -1,525 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package timeseries implements a time series structure for stats collection. -package timeseries // import "golang.org/x/net/internal/timeseries" - -import ( - "fmt" - "log" - "time" -) - -const ( - timeSeriesNumBuckets = 64 - minuteHourSeriesNumBuckets = 60 -) - -var timeSeriesResolutions = []time.Duration{ - 1 * time.Second, - 10 * time.Second, - 1 * time.Minute, - 10 * time.Minute, - 1 * time.Hour, - 6 * time.Hour, - 24 * time.Hour, // 1 day - 7 * 24 * time.Hour, // 1 week - 4 * 7 * 24 * time.Hour, // 4 weeks - 16 * 7 * 24 * time.Hour, // 16 weeks -} - -var minuteHourSeriesResolutions = []time.Duration{ - 1 * time.Second, - 1 * time.Minute, -} - -// An Observable is a kind of data that can be aggregated in a time series. -type Observable interface { - Multiply(ratio float64) // Multiplies the data in self by a given ratio - Add(other Observable) // Adds the data from a different observation to self - Clear() // Clears the observation so it can be reused. - CopyFrom(other Observable) // Copies the contents of a given observation to self -} - -// Float attaches the methods of Observable to a float64. -type Float float64 - -// NewFloat returns a Float. -func NewFloat() Observable { - f := Float(0) - return &f -} - -// String returns the float as a string. -func (f *Float) String() string { return fmt.Sprintf("%g", f.Value()) } - -// Value returns the float's value. -func (f *Float) Value() float64 { return float64(*f) } - -func (f *Float) Multiply(ratio float64) { *f *= Float(ratio) } - -func (f *Float) Add(other Observable) { - o := other.(*Float) - *f += *o -} - -func (f *Float) Clear() { *f = 0 } - -func (f *Float) CopyFrom(other Observable) { - o := other.(*Float) - *f = *o -} - -// A Clock tells the current time. -type Clock interface { - Time() time.Time -} - -type defaultClock int - -var defaultClockInstance defaultClock - -func (defaultClock) Time() time.Time { return time.Now() } - -// Information kept per level. Each level consists of a circular list of -// observations. The start of the level may be derived from end and the -// len(buckets) * sizeInMillis. -type tsLevel struct { - oldest int // index to oldest bucketed Observable - newest int // index to newest bucketed Observable - end time.Time // end timestamp for this level - size time.Duration // duration of the bucketed Observable - buckets []Observable // collections of observations - provider func() Observable // used for creating new Observable -} - -func (l *tsLevel) Clear() { - l.oldest = 0 - l.newest = len(l.buckets) - 1 - l.end = time.Time{} - for i := range l.buckets { - if l.buckets[i] != nil { - l.buckets[i].Clear() - l.buckets[i] = nil - } - } -} - -func (l *tsLevel) InitLevel(size time.Duration, numBuckets int, f func() Observable) { - l.size = size - l.provider = f - l.buckets = make([]Observable, numBuckets) -} - -// Keeps a sequence of levels. Each level is responsible for storing data at -// a given resolution. For example, the first level stores data at a one -// minute resolution while the second level stores data at a one hour -// resolution. - -// Each level is represented by a sequence of buckets. Each bucket spans an -// interval equal to the resolution of the level. New observations are added -// to the last bucket. -type timeSeries struct { - provider func() Observable // make more Observable - numBuckets int // number of buckets in each level - levels []*tsLevel // levels of bucketed Observable - lastAdd time.Time // time of last Observable tracked - total Observable // convenient aggregation of all Observable - clock Clock // Clock for getting current time - pending Observable // observations not yet bucketed - pendingTime time.Time // what time are we keeping in pending - dirty bool // if there are pending observations -} - -// init initializes a level according to the supplied criteria. -func (ts *timeSeries) init(resolutions []time.Duration, f func() Observable, numBuckets int, clock Clock) { - ts.provider = f - ts.numBuckets = numBuckets - ts.clock = clock - ts.levels = make([]*tsLevel, len(resolutions)) - - for i := range resolutions { - if i > 0 && resolutions[i-1] >= resolutions[i] { - log.Print("timeseries: resolutions must be monotonically increasing") - break - } - newLevel := new(tsLevel) - newLevel.InitLevel(resolutions[i], ts.numBuckets, ts.provider) - ts.levels[i] = newLevel - } - - ts.Clear() -} - -// Clear removes all observations from the time series. -func (ts *timeSeries) Clear() { - ts.lastAdd = time.Time{} - ts.total = ts.resetObservation(ts.total) - ts.pending = ts.resetObservation(ts.pending) - ts.pendingTime = time.Time{} - ts.dirty = false - - for i := range ts.levels { - ts.levels[i].Clear() - } -} - -// Add records an observation at the current time. -func (ts *timeSeries) Add(observation Observable) { - ts.AddWithTime(observation, ts.clock.Time()) -} - -// AddWithTime records an observation at the specified time. -func (ts *timeSeries) AddWithTime(observation Observable, t time.Time) { - - smallBucketDuration := ts.levels[0].size - - if t.After(ts.lastAdd) { - ts.lastAdd = t - } - - if t.After(ts.pendingTime) { - ts.advance(t) - ts.mergePendingUpdates() - ts.pendingTime = ts.levels[0].end - ts.pending.CopyFrom(observation) - ts.dirty = true - } else if t.After(ts.pendingTime.Add(-1 * smallBucketDuration)) { - // The observation is close enough to go into the pending bucket. - // This compensates for clock skewing and small scheduling delays - // by letting the update stay in the fast path. - ts.pending.Add(observation) - ts.dirty = true - } else { - ts.mergeValue(observation, t) - } -} - -// mergeValue inserts the observation at the specified time in the past into all levels. -func (ts *timeSeries) mergeValue(observation Observable, t time.Time) { - for _, level := range ts.levels { - index := (ts.numBuckets - 1) - int(level.end.Sub(t)/level.size) - if 0 <= index && index < ts.numBuckets { - bucketNumber := (level.oldest + index) % ts.numBuckets - if level.buckets[bucketNumber] == nil { - level.buckets[bucketNumber] = level.provider() - } - level.buckets[bucketNumber].Add(observation) - } - } - ts.total.Add(observation) -} - -// mergePendingUpdates applies the pending updates into all levels. -func (ts *timeSeries) mergePendingUpdates() { - if ts.dirty { - ts.mergeValue(ts.pending, ts.pendingTime) - ts.pending = ts.resetObservation(ts.pending) - ts.dirty = false - } -} - -// advance cycles the buckets at each level until the latest bucket in -// each level can hold the time specified. -func (ts *timeSeries) advance(t time.Time) { - if !t.After(ts.levels[0].end) { - return - } - for i := 0; i < len(ts.levels); i++ { - level := ts.levels[i] - if !level.end.Before(t) { - break - } - - // If the time is sufficiently far, just clear the level and advance - // directly. - if !t.Before(level.end.Add(level.size * time.Duration(ts.numBuckets))) { - for _, b := range level.buckets { - ts.resetObservation(b) - } - level.end = time.Unix(0, (t.UnixNano()/level.size.Nanoseconds())*level.size.Nanoseconds()) - } - - for t.After(level.end) { - level.end = level.end.Add(level.size) - level.newest = level.oldest - level.oldest = (level.oldest + 1) % ts.numBuckets - ts.resetObservation(level.buckets[level.newest]) - } - - t = level.end - } -} - -// Latest returns the sum of the num latest buckets from the level. -func (ts *timeSeries) Latest(level, num int) Observable { - now := ts.clock.Time() - if ts.levels[0].end.Before(now) { - ts.advance(now) - } - - ts.mergePendingUpdates() - - result := ts.provider() - l := ts.levels[level] - index := l.newest - - for i := 0; i < num; i++ { - if l.buckets[index] != nil { - result.Add(l.buckets[index]) - } - if index == 0 { - index = ts.numBuckets - } - index-- - } - - return result -} - -// LatestBuckets returns a copy of the num latest buckets from level. -func (ts *timeSeries) LatestBuckets(level, num int) []Observable { - if level < 0 || level > len(ts.levels) { - log.Print("timeseries: bad level argument: ", level) - return nil - } - if num < 0 || num >= ts.numBuckets { - log.Print("timeseries: bad num argument: ", num) - return nil - } - - results := make([]Observable, num) - now := ts.clock.Time() - if ts.levels[0].end.Before(now) { - ts.advance(now) - } - - ts.mergePendingUpdates() - - l := ts.levels[level] - index := l.newest - - for i := 0; i < num; i++ { - result := ts.provider() - results[i] = result - if l.buckets[index] != nil { - result.CopyFrom(l.buckets[index]) - } - - if index == 0 { - index = ts.numBuckets - } - index -= 1 - } - return results -} - -// ScaleBy updates observations by scaling by factor. -func (ts *timeSeries) ScaleBy(factor float64) { - for _, l := range ts.levels { - for i := 0; i < ts.numBuckets; i++ { - l.buckets[i].Multiply(factor) - } - } - - ts.total.Multiply(factor) - ts.pending.Multiply(factor) -} - -// Range returns the sum of observations added over the specified time range. -// If start or finish times don't fall on bucket boundaries of the same -// level, then return values are approximate answers. -func (ts *timeSeries) Range(start, finish time.Time) Observable { - return ts.ComputeRange(start, finish, 1)[0] -} - -// Recent returns the sum of observations from the last delta. -func (ts *timeSeries) Recent(delta time.Duration) Observable { - now := ts.clock.Time() - return ts.Range(now.Add(-delta), now) -} - -// Total returns the total of all observations. -func (ts *timeSeries) Total() Observable { - ts.mergePendingUpdates() - return ts.total -} - -// ComputeRange computes a specified number of values into a slice using -// the observations recorded over the specified time period. The return -// values are approximate if the start or finish times don't fall on the -// bucket boundaries at the same level or if the number of buckets spanning -// the range is not an integral multiple of num. -func (ts *timeSeries) ComputeRange(start, finish time.Time, num int) []Observable { - if start.After(finish) { - log.Printf("timeseries: start > finish, %v>%v", start, finish) - return nil - } - - if num < 0 { - log.Printf("timeseries: num < 0, %v", num) - return nil - } - - results := make([]Observable, num) - - for _, l := range ts.levels { - if !start.Before(l.end.Add(-l.size * time.Duration(ts.numBuckets))) { - ts.extract(l, start, finish, num, results) - return results - } - } - - // Failed to find a level that covers the desired range. So just - // extract from the last level, even if it doesn't cover the entire - // desired range. - ts.extract(ts.levels[len(ts.levels)-1], start, finish, num, results) - - return results -} - -// RecentList returns the specified number of values in slice over the most -// recent time period of the specified range. -func (ts *timeSeries) RecentList(delta time.Duration, num int) []Observable { - if delta < 0 { - return nil - } - now := ts.clock.Time() - return ts.ComputeRange(now.Add(-delta), now, num) -} - -// extract returns a slice of specified number of observations from a given -// level over a given range. -func (ts *timeSeries) extract(l *tsLevel, start, finish time.Time, num int, results []Observable) { - ts.mergePendingUpdates() - - srcInterval := l.size - dstInterval := finish.Sub(start) / time.Duration(num) - dstStart := start - srcStart := l.end.Add(-srcInterval * time.Duration(ts.numBuckets)) - - srcIndex := 0 - - // Where should scanning start? - if dstStart.After(srcStart) { - advance := dstStart.Sub(srcStart) / srcInterval - srcIndex += int(advance) - srcStart = srcStart.Add(advance * srcInterval) - } - - // The i'th value is computed as show below. - // interval = (finish/start)/num - // i'th value = sum of observation in range - // [ start + i * interval, - // start + (i + 1) * interval ) - for i := 0; i < num; i++ { - results[i] = ts.resetObservation(results[i]) - dstEnd := dstStart.Add(dstInterval) - for srcIndex < ts.numBuckets && srcStart.Before(dstEnd) { - srcEnd := srcStart.Add(srcInterval) - if srcEnd.After(ts.lastAdd) { - srcEnd = ts.lastAdd - } - - if !srcEnd.Before(dstStart) { - srcValue := l.buckets[(srcIndex+l.oldest)%ts.numBuckets] - if !srcStart.Before(dstStart) && !srcEnd.After(dstEnd) { - // dst completely contains src. - if srcValue != nil { - results[i].Add(srcValue) - } - } else { - // dst partially overlaps src. - overlapStart := maxTime(srcStart, dstStart) - overlapEnd := minTime(srcEnd, dstEnd) - base := srcEnd.Sub(srcStart) - fraction := overlapEnd.Sub(overlapStart).Seconds() / base.Seconds() - - used := ts.provider() - if srcValue != nil { - used.CopyFrom(srcValue) - } - used.Multiply(fraction) - results[i].Add(used) - } - - if srcEnd.After(dstEnd) { - break - } - } - srcIndex++ - srcStart = srcStart.Add(srcInterval) - } - dstStart = dstStart.Add(dstInterval) - } -} - -// resetObservation clears the content so the struct may be reused. -func (ts *timeSeries) resetObservation(observation Observable) Observable { - if observation == nil { - observation = ts.provider() - } else { - observation.Clear() - } - return observation -} - -// TimeSeries tracks data at granularities from 1 second to 16 weeks. -type TimeSeries struct { - timeSeries -} - -// NewTimeSeries creates a new TimeSeries using the function provided for creating new Observable. -func NewTimeSeries(f func() Observable) *TimeSeries { - return NewTimeSeriesWithClock(f, defaultClockInstance) -} - -// NewTimeSeriesWithClock creates a new TimeSeries using the function provided for creating new Observable and the clock for -// assigning timestamps. -func NewTimeSeriesWithClock(f func() Observable, clock Clock) *TimeSeries { - ts := new(TimeSeries) - ts.timeSeries.init(timeSeriesResolutions, f, timeSeriesNumBuckets, clock) - return ts -} - -// MinuteHourSeries tracks data at granularities of 1 minute and 1 hour. -type MinuteHourSeries struct { - timeSeries -} - -// NewMinuteHourSeries creates a new MinuteHourSeries using the function provided for creating new Observable. -func NewMinuteHourSeries(f func() Observable) *MinuteHourSeries { - return NewMinuteHourSeriesWithClock(f, defaultClockInstance) -} - -// NewMinuteHourSeriesWithClock creates a new MinuteHourSeries using the function provided for creating new Observable and the clock for -// assigning timestamps. -func NewMinuteHourSeriesWithClock(f func() Observable, clock Clock) *MinuteHourSeries { - ts := new(MinuteHourSeries) - ts.timeSeries.init(minuteHourSeriesResolutions, f, - minuteHourSeriesNumBuckets, clock) - return ts -} - -func (ts *MinuteHourSeries) Minute() Observable { - return ts.timeSeries.Latest(0, 60) -} - -func (ts *MinuteHourSeries) Hour() Observable { - return ts.timeSeries.Latest(1, 60) -} - -func minTime(a, b time.Time) time.Time { - if a.Before(b) { - return a - } - return b -} - -func maxTime(a, b time.Time) time.Time { - if a.After(b) { - return a - } - return b -} diff --git a/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go b/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go deleted file mode 100644 index 66325a9..0000000 --- a/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go +++ /dev/null @@ -1,170 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package timeseries - -import ( - "math" - "testing" - "time" -) - -func isNear(x *Float, y float64, tolerance float64) bool { - return math.Abs(x.Value()-y) < tolerance -} - -func isApproximate(x *Float, y float64) bool { - return isNear(x, y, 1e-2) -} - -func checkApproximate(t *testing.T, o Observable, y float64) { - x := o.(*Float) - if !isApproximate(x, y) { - t.Errorf("Wanted %g, got %g", y, x.Value()) - } -} - -func checkNear(t *testing.T, o Observable, y, tolerance float64) { - x := o.(*Float) - if !isNear(x, y, tolerance) { - t.Errorf("Wanted %g +- %g, got %g", y, tolerance, x.Value()) - } -} - -var baseTime = time.Date(2013, 1, 1, 0, 0, 0, 0, time.UTC) - -func tu(s int64) time.Time { - return baseTime.Add(time.Duration(s) * time.Second) -} - -func tu2(s int64, ns int64) time.Time { - return baseTime.Add(time.Duration(s)*time.Second + time.Duration(ns)*time.Nanosecond) -} - -func TestBasicTimeSeries(t *testing.T) { - ts := NewTimeSeries(NewFloat) - fo := new(Float) - *fo = Float(10) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - checkApproximate(t, ts.Range(tu(0), tu(1)), 40) - checkApproximate(t, ts.Total(), 40) - ts.AddWithTime(fo, tu(3)) - ts.AddWithTime(fo, tu(3)) - ts.AddWithTime(fo, tu(3)) - checkApproximate(t, ts.Range(tu(0), tu(2)), 40) - checkApproximate(t, ts.Range(tu(2), tu(4)), 30) - checkApproximate(t, ts.Total(), 70) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - checkApproximate(t, ts.Range(tu(0), tu(2)), 60) - checkApproximate(t, ts.Range(tu(2), tu(4)), 30) - checkApproximate(t, ts.Total(), 90) - *fo = Float(100) - ts.AddWithTime(fo, tu(100)) - checkApproximate(t, ts.Range(tu(99), tu(100)), 100) - checkApproximate(t, ts.Range(tu(0), tu(4)), 36) - checkApproximate(t, ts.Total(), 190) - *fo = Float(10) - ts.AddWithTime(fo, tu(1)) - ts.AddWithTime(fo, tu(1)) - checkApproximate(t, ts.Range(tu(0), tu(4)), 44) - checkApproximate(t, ts.Range(tu(37), tu2(100, 100e6)), 100) - checkApproximate(t, ts.Range(tu(50), tu2(100, 100e6)), 100) - checkApproximate(t, ts.Range(tu(99), tu2(100, 100e6)), 100) - checkApproximate(t, ts.Total(), 210) - - for i, l := range ts.ComputeRange(tu(36), tu(100), 64) { - if i == 63 { - checkApproximate(t, l, 100) - } else { - checkApproximate(t, l, 0) - } - } - - checkApproximate(t, ts.Range(tu(0), tu(100)), 210) - checkApproximate(t, ts.Range(tu(10), tu(100)), 100) - - for i, l := range ts.ComputeRange(tu(0), tu(100), 100) { - if i < 10 { - checkApproximate(t, l, 11) - } else if i >= 90 { - checkApproximate(t, l, 10) - } else { - checkApproximate(t, l, 0) - } - } -} - -func TestFloat(t *testing.T) { - f := Float(1) - if g, w := f.String(), "1"; g != w { - t.Errorf("Float(1).String = %q; want %q", g, w) - } - f2 := Float(2) - var o Observable = &f2 - f.Add(o) - if g, w := f.Value(), 3.0; g != w { - t.Errorf("Float post-add = %v; want %v", g, w) - } - f.Multiply(2) - if g, w := f.Value(), 6.0; g != w { - t.Errorf("Float post-multiply = %v; want %v", g, w) - } - f.Clear() - if g, w := f.Value(), 0.0; g != w { - t.Errorf("Float post-clear = %v; want %v", g, w) - } - f.CopyFrom(&f2) - if g, w := f.Value(), 2.0; g != w { - t.Errorf("Float post-CopyFrom = %v; want %v", g, w) - } -} - -type mockClock struct { - time time.Time -} - -func (m *mockClock) Time() time.Time { return m.time } -func (m *mockClock) Set(t time.Time) { m.time = t } - -const buckets = 6 - -var testResolutions = []time.Duration{ - 10 * time.Second, // level holds one minute of observations - 100 * time.Second, // level holds ten minutes of observations - 10 * time.Minute, // level holds one hour of observations -} - -// TestTimeSeries uses a small number of buckets to force a higher -// error rate on approximations from the timeseries. -type TestTimeSeries struct { - timeSeries -} - -func TestExpectedErrorRate(t *testing.T) { - ts := new(TestTimeSeries) - fake := new(mockClock) - fake.Set(time.Now()) - ts.timeSeries.init(testResolutions, NewFloat, buckets, fake) - for i := 1; i <= 61*61; i++ { - fake.Set(fake.Time().Add(1 * time.Second)) - ob := Float(1) - ts.AddWithTime(&ob, fake.Time()) - - // The results should be accurate within one missing bucket (1/6) of the observations recorded. - checkNear(t, ts.Latest(0, buckets), min(float64(i), 60), 10) - checkNear(t, ts.Latest(1, buckets), min(float64(i), 600), 100) - checkNear(t, ts.Latest(2, buckets), min(float64(i), 3600), 600) - } -} - -func min(a, b float64) float64 { - if a < b { - return a - } - return b -} diff --git a/vendor/golang.org/x/net/ipv4/bpf_test.go b/vendor/golang.org/x/net/ipv4/bpf_test.go deleted file mode 100644 index b44da90..0000000 --- a/vendor/golang.org/x/net/ipv4/bpf_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - "time" - - "golang.org/x/net/bpf" - "golang.org/x/net/ipv4" -) - -func TestBPF(t *testing.T) { - if runtime.GOOS != "linux" { - t.Skipf("not supported on %s", runtime.GOOS) - } - - l, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - p := ipv4.NewPacketConn(l) - - // This filter accepts UDP packets whose first payload byte is - // even. - prog, err := bpf.Assemble([]bpf.Instruction{ - // Load the first byte of the payload (skipping UDP header). - bpf.LoadAbsolute{Off: 8, Size: 1}, - // Select LSB of the byte. - bpf.ALUOpConstant{Op: bpf.ALUOpAnd, Val: 1}, - // Byte is even? - bpf.JumpIf{Cond: bpf.JumpEqual, Val: 0, SkipFalse: 1}, - // Accept. - bpf.RetConstant{Val: 4096}, - // Ignore. - bpf.RetConstant{Val: 0}, - }) - if err != nil { - t.Fatalf("compiling BPF: %s", err) - } - - if err = p.SetBPF(prog); err != nil { - t.Fatalf("attaching filter to Conn: %s", err) - } - - s, err := net.Dial("udp4", l.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - defer s.Close() - go func() { - for i := byte(0); i < 10; i++ { - s.Write([]byte{i}) - } - }() - - l.SetDeadline(time.Now().Add(2 * time.Second)) - seen := make([]bool, 5) - for { - var b [512]byte - n, _, err := l.ReadFrom(b[:]) - if err != nil { - t.Fatalf("reading from listener: %s", err) - } - if n != 1 { - t.Fatalf("unexpected packet length, want 1, got %d", n) - } - if b[0] >= 10 { - t.Fatalf("unexpected byte, want 0-9, got %d", b[0]) - } - if b[0]%2 != 0 { - t.Fatalf("got odd byte %d, wanted only even bytes", b[0]) - } - seen[b[0]/2] = true - - seenAll := true - for _, v := range seen { - if !v { - seenAll = false - break - } - } - if seenAll { - break - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/bpfopt_linux.go b/vendor/golang.org/x/net/ipv4/bpfopt_linux.go deleted file mode 100644 index f2d00b4..0000000 --- a/vendor/golang.org/x/net/ipv4/bpfopt_linux.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "os" - "unsafe" - - "golang.org/x/net/bpf" -) - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - fd, err := c.sysfd() - if err != nil { - return err - } - prog := sysSockFProg{ - Len: uint16(len(filter)), - Filter: (*sysSockFilter)(unsafe.Pointer(&filter[0])), - } - return os.NewSyscallError("setsockopt", setsockopt(fd, sysSOL_SOCKET, sysSO_ATTACH_FILTER, unsafe.Pointer(&prog), uint32(unsafe.Sizeof(prog)))) -} diff --git a/vendor/golang.org/x/net/ipv4/bpfopt_stub.go b/vendor/golang.org/x/net/ipv4/bpfopt_stub.go deleted file mode 100644 index c4a8481..0000000 --- a/vendor/golang.org/x/net/ipv4/bpfopt_stub.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv4 - -import "golang.org/x/net/bpf" - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/control.go b/vendor/golang.org/x/net/ipv4/control.go deleted file mode 100644 index 8cadfd7..0000000 --- a/vendor/golang.org/x/net/ipv4/control.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "fmt" - "net" - "sync" -) - -type rawOpt struct { - sync.RWMutex - cflags ControlFlags -} - -func (c *rawOpt) set(f ControlFlags) { c.cflags |= f } -func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f } -func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 } - -type ControlFlags uint - -const ( - FlagTTL ControlFlags = 1 << iota // pass the TTL on the received packet - FlagSrc // pass the source address on the received packet - FlagDst // pass the destination address on the received packet - FlagInterface // pass the interface index on the received packet -) - -// A ControlMessage represents per packet basis IP-level socket options. -type ControlMessage struct { - // Receiving socket options: SetControlMessage allows to - // receive the options from the protocol stack using ReadFrom - // method of PacketConn or RawConn. - // - // Specifying socket options: ControlMessage for WriteTo - // method of PacketConn or RawConn allows to send the options - // to the protocol stack. - // - TTL int // time-to-live, receiving only - Src net.IP // source address, specifying only - Dst net.IP // destination address, receiving only - IfIndex int // interface index, must be 1 <= value when specifying -} - -func (cm *ControlMessage) String() string { - if cm == nil { - return "" - } - return fmt.Sprintf("ttl=%d src=%v dst=%v ifindex=%d", cm.TTL, cm.Src, cm.Dst, cm.IfIndex) -} - -// Ancillary data socket options -const ( - ctlTTL = iota // header field - ctlSrc // header field - ctlDst // header field - ctlInterface // inbound or outbound interface - ctlPacketInfo // inbound or outbound packet path - ctlMax -) - -// A ctlOpt represents a binding for ancillary data socket option. -type ctlOpt struct { - name int // option name, must be equal or greater than 1 - length int // option length - marshal func([]byte, *ControlMessage) []byte - parse func(*ControlMessage, []byte) -} diff --git a/vendor/golang.org/x/net/ipv4/control_bsd.go b/vendor/golang.org/x/net/ipv4/control_bsd.go deleted file mode 100644 index 33d8bc8..0000000 --- a/vendor/golang.org/x/net/ipv4/control_bsd.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshalDst(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_RECVDSTADDR - m.SetLen(syscall.CmsgLen(net.IPv4len)) - return b[syscall.CmsgSpace(net.IPv4len):] -} - -func parseDst(cm *ControlMessage, b []byte) { - cm.Dst = b[:net.IPv4len] -} - -func marshalInterface(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_RECVIF - m.SetLen(syscall.CmsgLen(syscall.SizeofSockaddrDatalink)) - return b[syscall.CmsgSpace(syscall.SizeofSockaddrDatalink):] -} - -func parseInterface(cm *ControlMessage, b []byte) { - sadl := (*syscall.SockaddrDatalink)(unsafe.Pointer(&b[0])) - cm.IfIndex = int(sadl.Index) -} diff --git a/vendor/golang.org/x/net/ipv4/control_pktinfo.go b/vendor/golang.org/x/net/ipv4/control_pktinfo.go deleted file mode 100644 index 444782f..0000000 --- a/vendor/golang.org/x/net/ipv4/control_pktinfo.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin linux - -package ipv4 - -import ( - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_PKTINFO - m.SetLen(syscall.CmsgLen(sysSizeofInetPktinfo)) - if cm != nil { - pi := (*sysInetPktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - if ip := cm.Src.To4(); ip != nil { - copy(pi.Spec_dst[:], ip) - } - if cm.IfIndex > 0 { - pi.setIfindex(cm.IfIndex) - } - } - return b[syscall.CmsgSpace(sysSizeofInetPktinfo):] -} - -func parsePacketInfo(cm *ControlMessage, b []byte) { - pi := (*sysInetPktinfo)(unsafe.Pointer(&b[0])) - cm.IfIndex = int(pi.Ifindex) - cm.Dst = pi.Addr[:] -} diff --git a/vendor/golang.org/x/net/ipv4/control_stub.go b/vendor/golang.org/x/net/ipv4/control_stub.go deleted file mode 100644 index 4d85071..0000000 --- a/vendor/golang.org/x/net/ipv4/control_stub.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv4 - -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error { - return errOpNoSupport -} - -func newControlMessage(opt *rawOpt) []byte { - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - return nil, errOpNoSupport -} - -func marshalControlMessage(cm *ControlMessage) []byte { - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/control_unix.go b/vendor/golang.org/x/net/ipv4/control_unix.go deleted file mode 100644 index 3000c52..0000000 --- a/vendor/golang.org/x/net/ipv4/control_unix.go +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv4 - -import ( - "os" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error { - opt.Lock() - defer opt.Unlock() - if cf&FlagTTL != 0 && sockOpts[ssoReceiveTTL].name > 0 { - if err := setInt(fd, &sockOpts[ssoReceiveTTL], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagTTL) - } else { - opt.clear(FlagTTL) - } - } - if sockOpts[ssoPacketInfo].name > 0 { - if cf&(FlagSrc|FlagDst|FlagInterface) != 0 { - if err := setInt(fd, &sockOpts[ssoPacketInfo], boolint(on)); err != nil { - return err - } - if on { - opt.set(cf & (FlagSrc | FlagDst | FlagInterface)) - } else { - opt.clear(cf & (FlagSrc | FlagDst | FlagInterface)) - } - } - } else { - if cf&FlagDst != 0 && sockOpts[ssoReceiveDst].name > 0 { - if err := setInt(fd, &sockOpts[ssoReceiveDst], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagDst) - } else { - opt.clear(FlagDst) - } - } - if cf&FlagInterface != 0 && sockOpts[ssoReceiveInterface].name > 0 { - if err := setInt(fd, &sockOpts[ssoReceiveInterface], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagInterface) - } else { - opt.clear(FlagInterface) - } - } - } - return nil -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - opt.RLock() - var l int - if opt.isset(FlagTTL) && ctlOpts[ctlTTL].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlTTL].length) - } - if ctlOpts[ctlPacketInfo].name > 0 { - if opt.isset(FlagSrc | FlagDst | FlagInterface) { - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - } else { - if opt.isset(FlagDst) && ctlOpts[ctlDst].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlDst].length) - } - if opt.isset(FlagInterface) && ctlOpts[ctlInterface].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlInterface].length) - } - } - if l > 0 { - oob = make([]byte, l) - b := oob - if opt.isset(FlagTTL) && ctlOpts[ctlTTL].name > 0 { - b = ctlOpts[ctlTTL].marshal(b, nil) - } - if ctlOpts[ctlPacketInfo].name > 0 { - if opt.isset(FlagSrc | FlagDst | FlagInterface) { - b = ctlOpts[ctlPacketInfo].marshal(b, nil) - } - } else { - if opt.isset(FlagDst) && ctlOpts[ctlDst].name > 0 { - b = ctlOpts[ctlDst].marshal(b, nil) - } - if opt.isset(FlagInterface) && ctlOpts[ctlInterface].name > 0 { - b = ctlOpts[ctlInterface].marshal(b, nil) - } - } - } - opt.RUnlock() - return -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - if len(b) == 0 { - return nil, nil - } - cmsgs, err := syscall.ParseSocketControlMessage(b) - if err != nil { - return nil, os.NewSyscallError("parse socket control message", err) - } - cm := &ControlMessage{} - for _, m := range cmsgs { - if m.Header.Level != iana.ProtocolIP { - continue - } - switch int(m.Header.Type) { - case ctlOpts[ctlTTL].name: - ctlOpts[ctlTTL].parse(cm, m.Data[:]) - case ctlOpts[ctlDst].name: - ctlOpts[ctlDst].parse(cm, m.Data[:]) - case ctlOpts[ctlInterface].name: - ctlOpts[ctlInterface].parse(cm, m.Data[:]) - case ctlOpts[ctlPacketInfo].name: - ctlOpts[ctlPacketInfo].parse(cm, m.Data[:]) - } - } - return cm, nil -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - if cm == nil { - return nil - } - var l int - pktinfo := false - if ctlOpts[ctlPacketInfo].name > 0 && (cm.Src.To4() != nil || cm.IfIndex > 0) { - pktinfo = true - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - if l > 0 { - oob = make([]byte, l) - b := oob - if pktinfo { - b = ctlOpts[ctlPacketInfo].marshal(b, cm) - } - } - return -} - -func marshalTTL(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIP - m.Type = sysIP_RECVTTL - m.SetLen(syscall.CmsgLen(1)) - return b[syscall.CmsgSpace(1):] -} - -func parseTTL(cm *ControlMessage, b []byte) { - cm.TTL = int(*(*byte)(unsafe.Pointer(&b[:1][0]))) -} diff --git a/vendor/golang.org/x/net/ipv4/control_windows.go b/vendor/golang.org/x/net/ipv4/control_windows.go deleted file mode 100644 index 800f637..0000000 --- a/vendor/golang.org/x/net/ipv4/control_windows.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "syscall" - -func setControlMessage(fd syscall.Handle, opt *rawOpt, cf ControlFlags, on bool) error { - // TODO(mikio): implement this - return syscall.EWINDOWS -} - -func newControlMessage(opt *rawOpt) []byte { - // TODO(mikio): implement this - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - // TODO(mikio): implement this - return nil, syscall.EWINDOWS -} - -func marshalControlMessage(cm *ControlMessage) []byte { - // TODO(mikio): implement this - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/defs_darwin.go b/vendor/golang.org/x/net/ipv4/defs_darwin.go deleted file mode 100644 index 731d56a..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_darwin.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_STRIPHDR = C.IP_STRIPHDR - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_BOUND_IF = C.IP_BOUND_IF - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_MULTICAST_IFINDEX = C.IP_MULTICAST_IFINDEX - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo - - sysSizeofIPMreq = C.sizeof_struct_ip_mreq - sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sysSizeofGroupReq = C.sizeof_struct_group_req - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sysSockaddrStorage C.struct_sockaddr_storage - -type sysSockaddrInet C.struct_sockaddr_in - -type sysInetPktinfo C.struct_in_pktinfo - -type sysIPMreq C.struct_ip_mreq - -type sysIPMreqn C.struct_ip_mreqn - -type sysIPMreqSource C.struct_ip_mreq_source - -type sysGroupReq C.struct_group_req - -type sysGroupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/defs_dragonfly.go b/vendor/golang.org/x/net/ipv4/defs_dragonfly.go deleted file mode 100644 index 08e3b85..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_dragonfly.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sysSizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type sysIPMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_freebsd.go b/vendor/golang.org/x/net/ipv4/defs_freebsd.go deleted file mode 100644 index f12ca32..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_freebsd.go +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_SENDSRCADDR = C.IP_SENDSRCADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_ONESBCAST = C.IP_ONESBCAST - sysIP_BINDANY = C.IP_BINDANY - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_MINTTL = C.IP_MINTTL - sysIP_DONTFRAG = C.IP_DONTFRAG - sysIP_RECVTOS = C.IP_RECVTOS - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_MULTICAST_VIF = C.IP_MULTICAST_VIF - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in - - sysSizeofIPMreq = C.sizeof_struct_ip_mreq - sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sysSizeofGroupReq = C.sizeof_struct_group_req - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req -) - -type sysSockaddrStorage C.struct_sockaddr_storage - -type sysSockaddrInet C.struct_sockaddr_in - -type sysIPMreq C.struct_ip_mreq - -type sysIPMreqn C.struct_ip_mreqn - -type sysIPMreqSource C.struct_ip_mreq_source - -type sysGroupReq C.struct_group_req - -type sysGroupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv4/defs_linux.go b/vendor/golang.org/x/net/ipv4/defs_linux.go deleted file mode 100644 index c4042eb..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_linux.go +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include - -#include -#include -#include -#include -#include -*/ -import "C" - -const ( - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_ROUTER_ALERT = C.IP_ROUTER_ALERT - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_PKTOPTIONS = C.IP_PKTOPTIONS - sysIP_MTU_DISCOVER = C.IP_MTU_DISCOVER - sysIP_RECVERR = C.IP_RECVERR - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_RECVTOS = C.IP_RECVTOS - sysIP_MTU = C.IP_MTU - sysIP_FREEBIND = C.IP_FREEBIND - sysIP_TRANSPARENT = C.IP_TRANSPARENT - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_ORIGDSTADDR = C.IP_ORIGDSTADDR - sysIP_RECVORIGDSTADDR = C.IP_RECVORIGDSTADDR - sysIP_MINTTL = C.IP_MINTTL - sysIP_NODEFRAG = C.IP_NODEFRAG - sysIP_UNICAST_IF = C.IP_UNICAST_IF - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - sysIP_MSFILTER = C.IP_MSFILTER - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_MSFILTER = C.MCAST_MSFILTER - sysIP_MULTICAST_ALL = C.IP_MULTICAST_ALL - - //sysIP_PMTUDISC_DONT = C.IP_PMTUDISC_DONT - //sysIP_PMTUDISC_WANT = C.IP_PMTUDISC_WANT - //sysIP_PMTUDISC_DO = C.IP_PMTUDISC_DO - //sysIP_PMTUDISC_PROBE = C.IP_PMTUDISC_PROBE - //sysIP_PMTUDISC_INTERFACE = C.IP_PMTUDISC_INTERFACE - //sysIP_PMTUDISC_OMIT = C.IP_PMTUDISC_OMIT - - sysICMP_FILTER = C.ICMP_FILTER - - sysSO_EE_ORIGIN_NONE = C.SO_EE_ORIGIN_NONE - sysSO_EE_ORIGIN_LOCAL = C.SO_EE_ORIGIN_LOCAL - sysSO_EE_ORIGIN_ICMP = C.SO_EE_ORIGIN_ICMP - sysSO_EE_ORIGIN_ICMP6 = C.SO_EE_ORIGIN_ICMP6 - sysSO_EE_ORIGIN_TXSTATUS = C.SO_EE_ORIGIN_TXSTATUS - sysSO_EE_ORIGIN_TIMESTAMPING = C.SO_EE_ORIGIN_TIMESTAMPING - - sysSOL_SOCKET = C.SOL_SOCKET - sysSO_ATTACH_FILTER = C.SO_ATTACH_FILTER - - sysSizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage - sysSizeofSockaddrInet = C.sizeof_struct_sockaddr_in - sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo - sysSizeofSockExtendedErr = C.sizeof_struct_sock_extended_err - - sysSizeofIPMreq = C.sizeof_struct_ip_mreq - sysSizeofIPMreqn = C.sizeof_struct_ip_mreqn - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source - sysSizeofGroupReq = C.sizeof_struct_group_req - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sysSizeofICMPFilter = C.sizeof_struct_icmp_filter -) - -type sysKernelSockaddrStorage C.struct___kernel_sockaddr_storage - -type sysSockaddrInet C.struct_sockaddr_in - -type sysInetPktinfo C.struct_in_pktinfo - -type sysSockExtendedErr C.struct_sock_extended_err - -type sysIPMreq C.struct_ip_mreq - -type sysIPMreqn C.struct_ip_mreqn - -type sysIPMreqSource C.struct_ip_mreq_source - -type sysGroupReq C.struct_group_req - -type sysGroupSourceReq C.struct_group_source_req - -type sysICMPFilter C.struct_icmp_filter - -type sysSockFProg C.struct_sock_fprog - -type sysSockFilter C.struct_sock_filter diff --git a/vendor/golang.org/x/net/ipv4/defs_netbsd.go b/vendor/golang.org/x/net/ipv4/defs_netbsd.go deleted file mode 100644 index 8642354..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_netbsd.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sysSizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type sysIPMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_openbsd.go b/vendor/golang.org/x/net/ipv4/defs_openbsd.go deleted file mode 100644 index 8642354..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_openbsd.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVTTL = C.IP_RECVTTL - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - - sysSizeofIPMreq = C.sizeof_struct_ip_mreq -) - -type sysIPMreq C.struct_ip_mreq diff --git a/vendor/golang.org/x/net/ipv4/defs_solaris.go b/vendor/golang.org/x/net/ipv4/defs_solaris.go deleted file mode 100644 index bb74afa..0000000 --- a/vendor/golang.org/x/net/ipv4/defs_solaris.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in_addr [4]byte /* in_addr */ - -package ipv4 - -/* -#include -*/ -import "C" - -const ( - sysIP_OPTIONS = C.IP_OPTIONS - sysIP_HDRINCL = C.IP_HDRINCL - sysIP_TOS = C.IP_TOS - sysIP_TTL = C.IP_TTL - sysIP_RECVOPTS = C.IP_RECVOPTS - sysIP_RECVRETOPTS = C.IP_RECVRETOPTS - sysIP_RECVDSTADDR = C.IP_RECVDSTADDR - sysIP_RETOPTS = C.IP_RETOPTS - sysIP_RECVIF = C.IP_RECVIF - sysIP_RECVSLLA = C.IP_RECVSLLA - sysIP_RECVTTL = C.IP_RECVTTL - sysIP_NEXTHOP = C.IP_NEXTHOP - sysIP_PKTINFO = C.IP_PKTINFO - sysIP_RECVPKTINFO = C.IP_RECVPKTINFO - sysIP_DONTFRAG = C.IP_DONTFRAG - sysIP_BOUND_IF = C.IP_BOUND_IF - sysIP_UNSPEC_SRC = C.IP_UNSPEC_SRC - sysIP_BROADCAST_TTL = C.IP_BROADCAST_TTL - sysIP_DHCPINIT_IF = C.IP_DHCPINIT_IF - - sysIP_MULTICAST_IF = C.IP_MULTICAST_IF - sysIP_MULTICAST_TTL = C.IP_MULTICAST_TTL - sysIP_MULTICAST_LOOP = C.IP_MULTICAST_LOOP - sysIP_ADD_MEMBERSHIP = C.IP_ADD_MEMBERSHIP - sysIP_DROP_MEMBERSHIP = C.IP_DROP_MEMBERSHIP - sysIP_BLOCK_SOURCE = C.IP_BLOCK_SOURCE - sysIP_UNBLOCK_SOURCE = C.IP_UNBLOCK_SOURCE - sysIP_ADD_SOURCE_MEMBERSHIP = C.IP_ADD_SOURCE_MEMBERSHIP - sysIP_DROP_SOURCE_MEMBERSHIP = C.IP_DROP_SOURCE_MEMBERSHIP - - sysSizeofInetPktinfo = C.sizeof_struct_in_pktinfo - - sysSizeofIPMreq = C.sizeof_struct_ip_mreq - sysSizeofIPMreqSource = C.sizeof_struct_ip_mreq_source -) - -type sysInetPktinfo C.struct_in_pktinfo - -type sysIPMreq C.struct_ip_mreq - -type sysIPMreqSource C.struct_ip_mreq_source diff --git a/vendor/golang.org/x/net/ipv4/dgramopt_posix.go b/vendor/golang.org/x/net/ipv4/dgramopt_posix.go deleted file mode 100644 index 103c4f6..0000000 --- a/vendor/golang.org/x/net/ipv4/dgramopt_posix.go +++ /dev/null @@ -1,251 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd windows - -package ipv4 - -import ( - "net" - "syscall" -) - -// MulticastTTL returns the time-to-live field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastTTL() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return 0, err - } - return getInt(fd, &sockOpts[ssoMulticastTTL]) -} - -// SetMulticastTTL sets the time-to-live field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastTTL(ttl int) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoMulticastTTL], ttl) -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return nil, err - } - return getInterface(fd, &sockOpts[ssoMulticastInterface]) -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInterface(fd, &sockOpts[ssoMulticastInterface], ifi) -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - if !c.ok() { - return false, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return false, err - } - on, err := getInt(fd, &sockOpts[ssoMulticastLoopback]) - if err != nil { - return false, err - } - return on == 1, nil -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoMulticastLoopback], boolint(on)) -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - return setGroup(fd, &sockOpts[ssoJoinGroup], ifi, grp) -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - return setGroup(fd, &sockOpts[ssoLeaveGroup], ifi, grp) -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoJoinSourceGroup], ifi, grp, src) -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoLeaveSourceGroup], ifi, grp, src) -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoBlockSourceGroup], ifi, grp, src) -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP4(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP4(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoUnblockSourceGroup], ifi, grp, src) -} - -// ICMPFilter returns an ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return nil, err - } - return getICMPFilter(fd, &sockOpts[ssoICMPFilter]) -} - -// SetICMPFilter deploys the ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setICMPFilter(fd, &sockOpts[ssoICMPFilter], f) -} diff --git a/vendor/golang.org/x/net/ipv4/dgramopt_stub.go b/vendor/golang.org/x/net/ipv4/dgramopt_stub.go deleted file mode 100644 index b74df69..0000000 --- a/vendor/golang.org/x/net/ipv4/dgramopt_stub.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv4 - -import "net" - -// MulticastTTL returns the time-to-live field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastTTL() (int, error) { - return 0, errOpNoSupport -} - -// SetMulticastTTL sets the time-to-live field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastTTL(ttl int) error { - return errOpNoSupport -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - return nil, errOpNoSupport -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - return errOpNoSupport -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - return false, errOpNoSupport -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - return errOpNoSupport -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// ICMPFilter returns an ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -// SetICMPFilter deploys the ICMP filter. -// Currently only Linux supports this. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/doc.go b/vendor/golang.org/x/net/ipv4/doc.go deleted file mode 100644 index 9a79bad..0000000 --- a/vendor/golang.org/x/net/ipv4/doc.go +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ipv4 implements IP-level socket options for the Internet -// Protocol version 4. -// -// The package provides IP-level socket options that allow -// manipulation of IPv4 facilities. -// -// The IPv4 protocol and basic host requirements for IPv4 are defined -// in RFC 791 and RFC 1122. -// Host extensions for multicasting and socket interface extensions -// for multicast source filters are defined in RFC 1112 and RFC 3678. -// IGMPv1, IGMPv2 and IGMPv3 are defined in RFC 1112, RFC 2236 and RFC -// 3376. -// Source-specific multicast is defined in RFC 4607. -// -// -// Unicasting -// -// The options for unicasting are available for net.TCPConn, -// net.UDPConn and net.IPConn which are created as network connections -// that use the IPv4 transport. When a single TCP connection carrying -// a data flow of multiple packets needs to indicate the flow is -// important, ipv4.Conn is used to set the type-of-service field on -// the IPv4 header for each packet. -// -// ln, err := net.Listen("tcp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer ln.Close() -// for { -// c, err := ln.Accept() -// if err != nil { -// // error handling -// } -// go func(c net.Conn) { -// defer c.Close() -// -// The outgoing packets will be labeled DiffServ assured forwarding -// class 1 low drop precedence, known as AF11 packets. -// -// if err := ipv4.NewConn(c).SetTOS(0x28); err != nil { -// // error handling -// } -// if _, err := c.Write(data); err != nil { -// // error handling -// } -// }(c) -// } -// -// -// Multicasting -// -// The options for multicasting are available for net.UDPConn and -// net.IPconn which are created as network connections that use the -// IPv4 transport. A few network facilities must be prepared before -// you begin multicasting, at a minimum joining network interfaces and -// multicast groups. -// -// en0, err := net.InterfaceByName("en0") -// if err != nil { -// // error handling -// } -// en1, err := net.InterfaceByIndex(911) -// if err != nil { -// // error handling -// } -// group := net.IPv4(224, 0, 0, 250) -// -// First, an application listens to an appropriate address with an -// appropriate service port. -// -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// -// Second, the application joins multicast groups, starts listening to -// the groups on the specified network interfaces. Note that the -// service port for transport layer protocol does not matter with this -// operation as joining groups affects only network and link layer -// protocols, such as IPv4 and Ethernet. -// -// p := ipv4.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// -// The application might set per packet control message transmissions -// between the protocol stack within the kernel. When the application -// needs a destination address on an incoming packet, -// SetControlMessage of ipv4.PacketConn is used to enable control -// message transmissons. -// -// if err := p.SetControlMessage(ipv4.FlagDst, true); err != nil { -// // error handling -// } -// -// The application could identify whether the received packets are -// of interest by using the control message that contains the -// destination address of the received packet. -// -// b := make([]byte, 1500) -// for { -// n, cm, src, err := p.ReadFrom(b) -// if err != nil { -// // error handling -// } -// if cm.Dst.IsMulticast() { -// if cm.Dst.Equal(group) { -// // joined group, do something -// } else { -// // unknown group, discard -// continue -// } -// } -// -// The application can also send both unicast and multicast packets. -// -// p.SetTOS(0x0) -// p.SetTTL(16) -// if _, err := p.WriteTo(data, nil, src); err != nil { -// // error handling -// } -// dst := &net.UDPAddr{IP: group, Port: 1024} -// for _, ifi := range []*net.Interface{en0, en1} { -// if err := p.SetMulticastInterface(ifi); err != nil { -// // error handling -// } -// p.SetMulticastTTL(2) -// if _, err := p.WriteTo(data, nil, dst); err != nil { -// // error handling -// } -// } -// } -// -// -// More multicasting -// -// An application that uses PacketConn or RawConn may join multiple -// multicast groups. For example, a UDP listener with port 1024 might -// join two different groups across over two different network -// interfaces by using: -// -// c, err := net.ListenPacket("udp4", "0.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// p := ipv4.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}); err != nil { -// // error handling -// } -// -// It is possible for multiple UDP listeners that listen on the same -// UDP port to join the same multicast group. The net package will -// provide a socket that listens to a wildcard address with reusable -// UDP port when an appropriate multicast address prefix is passed to -// the net.ListenPacket or net.ListenUDP. -// -// c1, err := net.ListenPacket("udp4", "224.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c1.Close() -// c2, err := net.ListenPacket("udp4", "224.0.0.0:1024") -// if err != nil { -// // error handling -// } -// defer c2.Close() -// p1 := ipv4.NewPacketConn(c1) -// if err := p1.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// p2 := ipv4.NewPacketConn(c2) -// if err := p2.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// -// Also it is possible for the application to leave or rejoin a -// multicast group on the network interface. -// -// if err := p.LeaveGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 248)}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.IPv4(224, 0, 0, 250)}); err != nil { -// // error handling -// } -// -// -// Source-specific multicasting -// -// An application that uses PacketConn or RawConn on IGMPv3 supported -// platform is able to join source-specific multicast groups. -// The application may use JoinSourceSpecificGroup and -// LeaveSourceSpecificGroup for the operation known as "include" mode, -// -// ssmgroup := net.UDPAddr{IP: net.IPv4(232, 7, 8, 9)} -// ssmsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 1)}) -// if err := p.JoinSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// if err := p.LeaveSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// -// or JoinGroup, ExcludeSourceSpecificGroup, -// IncludeSourceSpecificGroup and LeaveGroup for the operation known -// as "exclude" mode. -// -// exclsource := net.UDPAddr{IP: net.IPv4(192, 168, 0, 254)} -// if err := p.JoinGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// if err := p.ExcludeSourceSpecificGroup(en0, &ssmgroup, &exclsource); err != nil { -// // error handling -// } -// if err := p.LeaveGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// -// Note that it depends on each platform implementation what happens -// when an application which runs on IGMPv3 unsupported platform uses -// JoinSourceSpecificGroup and LeaveSourceSpecificGroup. -// In general the platform tries to fall back to conversations using -// IGMPv1 or IGMPv2 and starts to listen to multicast traffic. -// In the fallback case, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup may return an error. -package ipv4 // import "golang.org/x/net/ipv4" diff --git a/vendor/golang.org/x/net/ipv4/endpoint.go b/vendor/golang.org/x/net/ipv4/endpoint.go deleted file mode 100644 index bc45bf0..0000000 --- a/vendor/golang.org/x/net/ipv4/endpoint.go +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "time" -) - -// A Conn represents a network endpoint that uses the IPv4 transport. -// It is used to control basic IP-level socket options such as TOS and -// TTL. -type Conn struct { - genericOpt -} - -type genericOpt struct { - net.Conn -} - -func (c *genericOpt) ok() bool { return c != nil && c.Conn != nil } - -// NewConn returns a new Conn. -func NewConn(c net.Conn) *Conn { - return &Conn{ - genericOpt: genericOpt{Conn: c}, - } -} - -// A PacketConn represents a packet network endpoint that uses the -// IPv4 transport. It is used to control several IP-level socket -// options including multicasting. It also provides datagram based -// network I/O methods specific to the IPv4 and higher layer protocols -// such as UDP. -type PacketConn struct { - genericOpt - dgramOpt - payloadHandler -} - -type dgramOpt struct { - net.PacketConn -} - -func (c *dgramOpt) ok() bool { return c != nil && c.PacketConn != nil } - -// SetControlMessage sets the per packet IP-level socket options. -func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - fd, err := c.payloadHandler.sysfd() - if err != nil { - return err - } - return setControlMessage(fd, &c.payloadHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *PacketConn) SetDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *PacketConn) SetReadDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *PacketConn) SetWriteDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *PacketConn) Close() error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.PacketConn.Close() -} - -// NewPacketConn returns a new PacketConn using c as its underlying -// transport. -func NewPacketConn(c net.PacketConn) *PacketConn { - p := &PacketConn{ - genericOpt: genericOpt{Conn: c.(net.Conn)}, - dgramOpt: dgramOpt{PacketConn: c}, - payloadHandler: payloadHandler{PacketConn: c}, - } - if _, ok := c.(*net.IPConn); ok && sockOpts[ssoStripHeader].name > 0 { - if fd, err := p.payloadHandler.sysfd(); err == nil { - setInt(fd, &sockOpts[ssoStripHeader], boolint(true)) - } - } - return p -} - -// A RawConn represents a packet network endpoint that uses the IPv4 -// transport. It is used to control several IP-level socket options -// including IPv4 header manipulation. It also provides datagram -// based network I/O methods specific to the IPv4 and higher layer -// protocols that handle IPv4 datagram directly such as OSPF, GRE. -type RawConn struct { - genericOpt - dgramOpt - packetHandler -} - -// SetControlMessage sets the per packet IP-level socket options. -func (c *RawConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - fd, err := c.packetHandler.sysfd() - if err != nil { - return err - } - return setControlMessage(fd, &c.packetHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *RawConn) SetDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *RawConn) SetReadDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *RawConn) SetWriteDeadline(t time.Time) error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *RawConn) Close() error { - if !c.packetHandler.ok() { - return syscall.EINVAL - } - return c.packetHandler.c.Close() -} - -// NewRawConn returns a new RawConn using c as its underlying -// transport. -func NewRawConn(c net.PacketConn) (*RawConn, error) { - r := &RawConn{ - genericOpt: genericOpt{Conn: c.(net.Conn)}, - dgramOpt: dgramOpt{PacketConn: c}, - packetHandler: packetHandler{c: c.(*net.IPConn)}, - } - fd, err := r.packetHandler.sysfd() - if err != nil { - return nil, err - } - if err := setInt(fd, &sockOpts[ssoHeaderPrepend], boolint(true)); err != nil { - return nil, err - } - return r, nil -} diff --git a/vendor/golang.org/x/net/ipv4/example_test.go b/vendor/golang.org/x/net/ipv4/example_test.go deleted file mode 100644 index 4f5e2f3..0000000 --- a/vendor/golang.org/x/net/ipv4/example_test.go +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "fmt" - "log" - "net" - "os" - "runtime" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/ipv4" -) - -func ExampleConn_markingTCP() { - ln, err := net.Listen("tcp", "0.0.0.0:1024") - if err != nil { - log.Fatal(err) - } - defer ln.Close() - - for { - c, err := ln.Accept() - if err != nil { - log.Fatal(err) - } - go func(c net.Conn) { - defer c.Close() - if c.RemoteAddr().(*net.TCPAddr).IP.To4() != nil { - p := ipv4.NewConn(c) - if err := p.SetTOS(0x28); err != nil { // DSCP AF11 - log.Fatal(err) - } - if err := p.SetTTL(128); err != nil { - log.Fatal(err) - } - } - if _, err := c.Write([]byte("HELLO-R-U-THERE-ACK")); err != nil { - log.Fatal(err) - } - }(c) - } -} - -func ExamplePacketConn_servingOneShotMulticastDNS() { - c, err := net.ListenPacket("udp4", "0.0.0.0:5353") // mDNS over UDP - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - mDNSLinkLocal := net.UDPAddr{IP: net.IPv4(224, 0, 0, 251)} - if err := p.JoinGroup(en0, &mDNSLinkLocal); err != nil { - log.Fatal(err) - } - defer p.LeaveGroup(en0, &mDNSLinkLocal) - if err := p.SetControlMessage(ipv4.FlagDst, true); err != nil { - log.Fatal(err) - } - - b := make([]byte, 1500) - for { - _, cm, peer, err := p.ReadFrom(b) - if err != nil { - log.Fatal(err) - } - if !cm.Dst.IsMulticast() || !cm.Dst.Equal(mDNSLinkLocal.IP) { - continue - } - answers := []byte("FAKE-MDNS-ANSWERS") // fake mDNS answers, you need to implement this - if _, err := p.WriteTo(answers, nil, peer); err != nil { - log.Fatal(err) - } - } -} - -func ExamplePacketConn_tracingIPPacketRoute() { - // Tracing an IP packet route to www.google.com. - - const host = "www.google.com" - ips, err := net.LookupIP(host) - if err != nil { - log.Fatal(err) - } - var dst net.IPAddr - for _, ip := range ips { - if ip.To4() != nil { - dst.IP = ip - fmt.Printf("using %v for tracing an IP packet route to %s\n", dst.IP, host) - break - } - } - if dst.IP == nil { - log.Fatal("no A record found") - } - - c, err := net.ListenPacket("ip4:1", "0.0.0.0") // ICMP for IPv4 - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - - if err := p.SetControlMessage(ipv4.FlagTTL|ipv4.FlagSrc|ipv4.FlagDst|ipv4.FlagInterface, true); err != nil { - log.Fatal(err) - } - wm := icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, - Data: []byte("HELLO-R-U-THERE"), - }, - } - - rb := make([]byte, 1500) - for i := 1; i <= 64; i++ { // up to 64 hops - wm.Body.(*icmp.Echo).Seq = i - wb, err := wm.Marshal(nil) - if err != nil { - log.Fatal(err) - } - if err := p.SetTTL(i); err != nil { - log.Fatal(err) - } - - // In the real world usually there are several - // multiple traffic-engineered paths for each hop. - // You may need to probe a few times to each hop. - begin := time.Now() - if _, err := p.WriteTo(wb, nil, &dst); err != nil { - log.Fatal(err) - } - if err := p.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil { - log.Fatal(err) - } - n, cm, peer, err := p.ReadFrom(rb) - if err != nil { - if err, ok := err.(net.Error); ok && err.Timeout() { - fmt.Printf("%v\t*\n", i) - continue - } - log.Fatal(err) - } - rm, err := icmp.ParseMessage(1, rb[:n]) - if err != nil { - log.Fatal(err) - } - rtt := time.Since(begin) - - // In the real world you need to determine whether the - // received message is yours using ControlMessage.Src, - // ControlMessage.Dst, icmp.Echo.ID and icmp.Echo.Seq. - switch rm.Type { - case ipv4.ICMPTypeTimeExceeded: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, cm) - case ipv4.ICMPTypeEchoReply: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, cm) - return - default: - log.Printf("unknown ICMP message: %+v\n", rm) - } - } -} - -func ExampleRawConn_advertisingOSPFHello() { - c, err := net.ListenPacket("ip4:89", "0.0.0.0") // OSPF for IPv4 - if err != nil { - log.Fatal(err) - } - defer c.Close() - r, err := ipv4.NewRawConn(c) - if err != nil { - log.Fatal(err) - } - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - allSPFRouters := net.IPAddr{IP: net.IPv4(224, 0, 0, 5)} - if err := r.JoinGroup(en0, &allSPFRouters); err != nil { - log.Fatal(err) - } - defer r.LeaveGroup(en0, &allSPFRouters) - - hello := make([]byte, 24) // fake hello data, you need to implement this - ospf := make([]byte, 24) // fake ospf header, you need to implement this - ospf[0] = 2 // version 2 - ospf[1] = 1 // hello packet - ospf = append(ospf, hello...) - iph := &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: 0xc0, // DSCP CS6 - TotalLen: ipv4.HeaderLen + len(ospf), - TTL: 1, - Protocol: 89, - Dst: allSPFRouters.IP.To4(), - } - - var cm *ipv4.ControlMessage - switch runtime.GOOS { - case "darwin", "linux": - cm = &ipv4.ControlMessage{IfIndex: en0.Index} - default: - if err := r.SetMulticastInterface(en0); err != nil { - log.Fatal(err) - } - } - if err := r.WriteTo(iph, ospf, cm); err != nil { - log.Fatal(err) - } -} diff --git a/vendor/golang.org/x/net/ipv4/gen.go b/vendor/golang.org/x/net/ipv4/gen.go deleted file mode 100644 index fb72cdc..0000000 --- a/vendor/golang.org/x/net/ipv4/gen.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates system adaptation constants and types, -// internet protocol constants and tables by reading template files -// and IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "os/exec" - "runtime" - "strconv" - "strings" -) - -func main() { - if err := genzsys(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := geniana(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func genzsys() error { - defs := "defs_" + runtime.GOOS + ".go" - f, err := os.Open(defs) - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - f.Close() - cmd := exec.Command("go", "tool", "cgo", "-godefs", defs) - b, err := cmd.Output() - if err != nil { - return err - } - // The ipv4 package still supports go1.2, and so we need to - // take care of additional platforms in go1.3 and above for - // working with go1.2. - switch { - case runtime.GOOS == "dragonfly" || runtime.GOOS == "solaris": - b = bytes.Replace(b, []byte("package ipv4\n"), []byte("// +build "+runtime.GOOS+"\n\npackage ipv4\n"), 1) - case runtime.GOOS == "linux" && (runtime.GOARCH == "arm64" || runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" || runtime.GOARCH == "s390x"): - b = bytes.Replace(b, []byte("package ipv4\n"), []byte("// +build "+runtime.GOOS+","+runtime.GOARCH+"\n\npackage ipv4\n"), 1) - } - b, err = format.Source(b) - if err != nil { - return err - } - zsys := "zsys_" + runtime.GOOS + ".go" - switch runtime.GOOS { - case "freebsd", "linux": - zsys = "zsys_" + runtime.GOOS + "_" + runtime.GOARCH + ".go" - } - if err := ioutil.WriteFile(zsys, b, 0644); err != nil { - return err - } - return nil -} - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "http://www.iana.org/assignments/icmp-parameters/icmp-parameters.xml", - parseICMPv4Parameters, - }, -} - -func geniana() error { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n") - fmt.Fprintf(&bb, "package ipv4\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("got HTTP status code %v for %v\n", resp.StatusCode, r.url) - } - if err := r.parse(&bb, resp.Body); err != nil { - return err - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - return err - } - if err := ioutil.WriteFile("iana.go", b, 0644); err != nil { - return err - } - return nil -} - -func parseICMPv4Parameters(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var icp icmpv4Parameters - if err := dec.Decode(&icp); err != nil { - return err - } - prs := icp.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Descr == "" { - continue - } - fmt.Fprintf(w, "ICMPType%s ICMPType = %d", pr.Descr, pr.Value) - fmt.Fprintf(w, "// %s\n", pr.OrigDescr) - } - fmt.Fprintf(w, ")\n\n") - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "var icmpTypes = map[ICMPType]string{\n") - for _, pr := range prs { - if pr.Descr == "" { - continue - } - fmt.Fprintf(w, "%d: %q,\n", pr.Value, strings.ToLower(pr.OrigDescr)) - } - fmt.Fprintf(w, "}\n") - return nil -} - -type icmpv4Parameters struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Registries []struct { - Title string `xml:"title"` - Records []struct { - Value string `xml:"value"` - Descr string `xml:"description"` - } `xml:"record"` - } `xml:"registry"` -} - -type canonICMPv4ParamRecord struct { - OrigDescr string - Descr string - Value int -} - -func (icp *icmpv4Parameters) escape() []canonICMPv4ParamRecord { - id := -1 - for i, r := range icp.Registries { - if strings.Contains(r.Title, "Type") || strings.Contains(r.Title, "type") { - id = i - break - } - } - if id < 0 { - return nil - } - prs := make([]canonICMPv4ParamRecord, len(icp.Registries[id].Records)) - sr := strings.NewReplacer( - "Messages", "", - "Message", "", - "ICMP", "", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range icp.Registries[id].Records { - if strings.Contains(pr.Descr, "Reserved") || - strings.Contains(pr.Descr, "Unassigned") || - strings.Contains(pr.Descr, "Deprecated") || - strings.Contains(pr.Descr, "Experiment") || - strings.Contains(pr.Descr, "experiment") { - continue - } - ss := strings.Split(pr.Descr, "\n") - if len(ss) > 1 { - prs[i].Descr = strings.Join(ss, " ") - } else { - prs[i].Descr = ss[0] - } - s := strings.TrimSpace(prs[i].Descr) - prs[i].OrigDescr = s - prs[i].Descr = sr.Replace(s) - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} diff --git a/vendor/golang.org/x/net/ipv4/genericopt_posix.go b/vendor/golang.org/x/net/ipv4/genericopt_posix.go deleted file mode 100644 index fefa0be..0000000 --- a/vendor/golang.org/x/net/ipv4/genericopt_posix.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd windows - -package ipv4 - -import "syscall" - -// TOS returns the type-of-service field value for outgoing packets. -func (c *genericOpt) TOS() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return 0, err - } - return getInt(fd, &sockOpts[ssoTOS]) -} - -// SetTOS sets the type-of-service field value for future outgoing -// packets. -func (c *genericOpt) SetTOS(tos int) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoTOS], tos) -} - -// TTL returns the time-to-live field value for outgoing packets. -func (c *genericOpt) TTL() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return 0, err - } - return getInt(fd, &sockOpts[ssoTTL]) -} - -// SetTTL sets the time-to-live field value for future outgoing -// packets. -func (c *genericOpt) SetTTL(ttl int) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoTTL], ttl) -} diff --git a/vendor/golang.org/x/net/ipv4/genericopt_stub.go b/vendor/golang.org/x/net/ipv4/genericopt_stub.go deleted file mode 100644 index 1817bad..0000000 --- a/vendor/golang.org/x/net/ipv4/genericopt_stub.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv4 - -// TOS returns the type-of-service field value for outgoing packets. -func (c *genericOpt) TOS() (int, error) { - return 0, errOpNoSupport -} - -// SetTOS sets the type-of-service field value for future outgoing -// packets. -func (c *genericOpt) SetTOS(tos int) error { - return errOpNoSupport -} - -// TTL returns the time-to-live field value for outgoing packets. -func (c *genericOpt) TTL() (int, error) { - return 0, errOpNoSupport -} - -// SetTTL sets the time-to-live field value for future outgoing -// packets. -func (c *genericOpt) SetTTL(ttl int) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/header.go b/vendor/golang.org/x/net/ipv4/header.go deleted file mode 100644 index 363d9c2..0000000 --- a/vendor/golang.org/x/net/ipv4/header.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "encoding/binary" - "fmt" - "net" - "runtime" - "syscall" -) - -const ( - Version = 4 // protocol version - HeaderLen = 20 // header length without extension headers - maxHeaderLen = 60 // sensible default, revisit if later RFCs define new usage of version and header length fields -) - -type HeaderFlags int - -const ( - MoreFragments HeaderFlags = 1 << iota // more fragments flag - DontFragment // don't fragment flag -) - -// A Header represents an IPv4 header. -type Header struct { - Version int // protocol version - Len int // header length - TOS int // type-of-service - TotalLen int // packet total length - ID int // identification - Flags HeaderFlags // flags - FragOff int // fragment offset - TTL int // time-to-live - Protocol int // next protocol - Checksum int // checksum - Src net.IP // source address - Dst net.IP // destination address - Options []byte // options, extension headers -} - -func (h *Header) String() string { - if h == nil { - return "" - } - return fmt.Sprintf("ver=%d hdrlen=%d tos=%#x totallen=%d id=%#x flags=%#x fragoff=%#x ttl=%d proto=%d cksum=%#x src=%v dst=%v", h.Version, h.Len, h.TOS, h.TotalLen, h.ID, h.Flags, h.FragOff, h.TTL, h.Protocol, h.Checksum, h.Src, h.Dst) -} - -// Marshal returns the binary encoding of the IPv4 header h. -func (h *Header) Marshal() ([]byte, error) { - if h == nil { - return nil, syscall.EINVAL - } - if h.Len < HeaderLen { - return nil, errHeaderTooShort - } - hdrlen := HeaderLen + len(h.Options) - b := make([]byte, hdrlen) - b[0] = byte(Version<<4 | (hdrlen >> 2 & 0x0f)) - b[1] = byte(h.TOS) - flagsAndFragOff := (h.FragOff & 0x1fff) | int(h.Flags<<13) - switch runtime.GOOS { - case "darwin", "dragonfly", "freebsd", "netbsd": - nativeEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - nativeEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - default: - binary.BigEndian.PutUint16(b[2:4], uint16(h.TotalLen)) - binary.BigEndian.PutUint16(b[6:8], uint16(flagsAndFragOff)) - } - binary.BigEndian.PutUint16(b[4:6], uint16(h.ID)) - b[8] = byte(h.TTL) - b[9] = byte(h.Protocol) - binary.BigEndian.PutUint16(b[10:12], uint16(h.Checksum)) - if ip := h.Src.To4(); ip != nil { - copy(b[12:16], ip[:net.IPv4len]) - } - if ip := h.Dst.To4(); ip != nil { - copy(b[16:20], ip[:net.IPv4len]) - } else { - return nil, errMissingAddress - } - if len(h.Options) > 0 { - copy(b[HeaderLen:], h.Options) - } - return b, nil -} - -// ParseHeader parses b as an IPv4 header. -func ParseHeader(b []byte) (*Header, error) { - if len(b) < HeaderLen { - return nil, errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - if hdrlen > len(b) { - return nil, errBufferTooShort - } - h := &Header{ - Version: int(b[0] >> 4), - Len: hdrlen, - TOS: int(b[1]), - ID: int(binary.BigEndian.Uint16(b[4:6])), - TTL: int(b[8]), - Protocol: int(b[9]), - Checksum: int(binary.BigEndian.Uint16(b[10:12])), - Src: net.IPv4(b[12], b[13], b[14], b[15]), - Dst: net.IPv4(b[16], b[17], b[18], b[19]), - } - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) + hdrlen - h.FragOff = int(nativeEndian.Uint16(b[6:8])) - case "freebsd": - h.TotalLen = int(nativeEndian.Uint16(b[2:4])) - if freebsdVersion < 1000000 { - h.TotalLen += hdrlen - } - h.FragOff = int(nativeEndian.Uint16(b[6:8])) - default: - h.TotalLen = int(binary.BigEndian.Uint16(b[2:4])) - h.FragOff = int(binary.BigEndian.Uint16(b[6:8])) - } - h.Flags = HeaderFlags(h.FragOff&0xe000) >> 13 - h.FragOff = h.FragOff & 0x1fff - if hdrlen-HeaderLen > 0 { - h.Options = make([]byte, hdrlen-HeaderLen) - copy(h.Options, b[HeaderLen:]) - } - return h, nil -} diff --git a/vendor/golang.org/x/net/ipv4/header_test.go b/vendor/golang.org/x/net/ipv4/header_test.go deleted file mode 100644 index 85cb9c4..0000000 --- a/vendor/golang.org/x/net/ipv4/header_test.go +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "bytes" - "encoding/binary" - "net" - "reflect" - "runtime" - "strings" - "testing" -) - -type headerTest struct { - wireHeaderFromKernel [HeaderLen]byte - wireHeaderToKernel [HeaderLen]byte - wireHeaderFromTradBSDKernel [HeaderLen]byte - wireHeaderFromFreeBSD10Kernel [HeaderLen]byte - wireHeaderToTradBSDKernel [HeaderLen]byte - *Header -} - -var headerLittleEndianTest = headerTest{ - // TODO(mikio): Add platform dependent wire header formats when - // we support new platforms. - wireHeaderFromKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xbe, 0xef, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderToKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xbe, 0xef, - 0xca, 0xfe, 0x45, 0xdc, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderFromTradBSDKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xdb, 0xbe, - 0xca, 0xfe, 0xdc, 0x45, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderFromFreeBSD10Kernel: [HeaderLen]byte{ - 0x45, 0x01, 0xef, 0xbe, - 0xca, 0xfe, 0xdc, 0x45, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - wireHeaderToTradBSDKernel: [HeaderLen]byte{ - 0x45, 0x01, 0xef, 0xbe, - 0xca, 0xfe, 0xdc, 0x45, - 0xff, 0x01, 0xde, 0xad, - 172, 16, 254, 254, - 192, 168, 0, 1, - }, - Header: &Header{ - Version: Version, - Len: HeaderLen, - TOS: 1, - TotalLen: 0xbeef, - ID: 0xcafe, - Flags: DontFragment, - FragOff: 1500, - TTL: 255, - Protocol: 1, - Checksum: 0xdead, - Src: net.IPv4(172, 16, 254, 254), - Dst: net.IPv4(192, 168, 0, 1), - }, -} - -func TestMarshalHeader(t *testing.T) { - tt := &headerLittleEndianTest - if nativeEndian != binary.LittleEndian { - t.Skip("no test for non-little endian machine yet") - } - - b, err := tt.Header.Marshal() - if err != nil { - t.Fatal(err) - } - var wh []byte - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - wh = tt.wireHeaderToTradBSDKernel[:] - case "freebsd": - if freebsdVersion < 1000000 { - wh = tt.wireHeaderToTradBSDKernel[:] - } else { - wh = tt.wireHeaderFromFreeBSD10Kernel[:] - } - default: - wh = tt.wireHeaderToKernel[:] - } - if !bytes.Equal(b, wh) { - t.Fatalf("got %#v; want %#v", b, wh) - } -} - -func TestParseHeader(t *testing.T) { - tt := &headerLittleEndianTest - if nativeEndian != binary.LittleEndian { - t.Skip("no test for big endian machine yet") - } - - var wh []byte - switch runtime.GOOS { - case "darwin", "dragonfly", "netbsd": - wh = tt.wireHeaderFromTradBSDKernel[:] - case "freebsd": - if freebsdVersion < 1000000 { - wh = tt.wireHeaderFromTradBSDKernel[:] - } else { - wh = tt.wireHeaderFromFreeBSD10Kernel[:] - } - default: - wh = tt.wireHeaderFromKernel[:] - } - h, err := ParseHeader(wh) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(h, tt.Header) { - t.Fatalf("got %#v; want %#v", h, tt.Header) - } - s := h.String() - if strings.Contains(s, ",") { - t.Fatalf("should be space-separated values: %s", s) - } -} diff --git a/vendor/golang.org/x/net/ipv4/helper.go b/vendor/golang.org/x/net/ipv4/helper.go deleted file mode 100644 index acecfd0..0000000 --- a/vendor/golang.org/x/net/ipv4/helper.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "encoding/binary" - "errors" - "net" - "unsafe" -) - -var ( - errMissingAddress = errors.New("missing address") - errMissingHeader = errors.New("missing header") - errHeaderTooShort = errors.New("header too short") - errBufferTooShort = errors.New("buffer too short") - errInvalidConnType = errors.New("invalid conn type") - errOpNoSupport = errors.New("operation not supported") - errNoSuchInterface = errors.New("no such interface") - errNoSuchMulticastInterface = errors.New("no such multicast interface") - - // See http://www.freebsd.org/doc/en/books/porters-handbook/freebsd-versions.html. - freebsdVersion uint32 - - nativeEndian binary.ByteOrder -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = binary.LittleEndian - } else { - nativeEndian = binary.BigEndian - } -} - -func boolint(b bool) int { - if b { - return 1 - } - return 0 -} - -func netAddrToIP4(a net.Addr) net.IP { - switch v := a.(type) { - case *net.UDPAddr: - if ip := v.IP.To4(); ip != nil { - return ip - } - case *net.IPAddr: - if ip := v.IP.To4(); ip != nil { - return ip - } - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/helper_stub.go b/vendor/golang.org/x/net/ipv4/helper_stub.go deleted file mode 100644 index dc2120c..0000000 --- a/vendor/golang.org/x/net/ipv4/helper_stub.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv4 - -func (c *genericOpt) sysfd() (int, error) { - return 0, errOpNoSupport -} - -func (c *dgramOpt) sysfd() (int, error) { - return 0, errOpNoSupport -} - -func (c *payloadHandler) sysfd() (int, error) { - return 0, errOpNoSupport -} - -func (c *packetHandler) sysfd() (int, error) { - return 0, errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/helper_unix.go b/vendor/golang.org/x/net/ipv4/helper_unix.go deleted file mode 100644 index 345ca7d..0000000 --- a/vendor/golang.org/x/net/ipv4/helper_unix.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv4 - -import ( - "net" - "reflect" -) - -func (c *genericOpt) sysfd() (int, error) { - switch p := c.Conn.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn: - return sysfd(p) - } - return 0, errInvalidConnType -} - -func (c *dgramOpt) sysfd() (int, error) { - switch p := c.PacketConn.(type) { - case *net.UDPConn, *net.IPConn: - return sysfd(p.(net.Conn)) - } - return 0, errInvalidConnType -} - -func (c *payloadHandler) sysfd() (int, error) { - return sysfd(c.PacketConn.(net.Conn)) -} - -func (c *packetHandler) sysfd() (int, error) { - return sysfd(c.c) -} - -func sysfd(c net.Conn) (int, error) { - cv := reflect.ValueOf(c) - switch ce := cv.Elem(); ce.Kind() { - case reflect.Struct: - netfd := ce.FieldByName("conn").FieldByName("fd") - switch fe := netfd.Elem(); fe.Kind() { - case reflect.Struct: - fd := fe.FieldByName("sysfd") - return int(fd.Int()), nil - } - } - return 0, errInvalidConnType -} diff --git a/vendor/golang.org/x/net/ipv4/helper_windows.go b/vendor/golang.org/x/net/ipv4/helper_windows.go deleted file mode 100644 index 322b2a5..0000000 --- a/vendor/golang.org/x/net/ipv4/helper_windows.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "reflect" - "syscall" -) - -func (c *genericOpt) sysfd() (syscall.Handle, error) { - switch p := c.Conn.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn: - return sysfd(p) - } - return syscall.InvalidHandle, errInvalidConnType -} - -func (c *dgramOpt) sysfd() (syscall.Handle, error) { - switch p := c.PacketConn.(type) { - case *net.UDPConn, *net.IPConn: - return sysfd(p.(net.Conn)) - } - return syscall.InvalidHandle, errInvalidConnType -} - -func (c *payloadHandler) sysfd() (syscall.Handle, error) { - return sysfd(c.PacketConn.(net.Conn)) -} - -func (c *packetHandler) sysfd() (syscall.Handle, error) { - return sysfd(c.c) -} - -func sysfd(c net.Conn) (syscall.Handle, error) { - cv := reflect.ValueOf(c) - switch ce := cv.Elem(); ce.Kind() { - case reflect.Struct: - netfd := ce.FieldByName("conn").FieldByName("fd") - switch fe := netfd.Elem(); fe.Kind() { - case reflect.Struct: - fd := fe.FieldByName("sysfd") - return syscall.Handle(fd.Uint()), nil - } - } - return syscall.InvalidHandle, errInvalidConnType -} diff --git a/vendor/golang.org/x/net/ipv4/iana.go b/vendor/golang.org/x/net/ipv4/iana.go deleted file mode 100644 index be10c94..0000000 --- a/vendor/golang.org/x/net/ipv4/iana.go +++ /dev/null @@ -1,34 +0,0 @@ -// go generate gen.go -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -package ipv4 - -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19 -const ( - ICMPTypeEchoReply ICMPType = 0 // Echo Reply - ICMPTypeDestinationUnreachable ICMPType = 3 // Destination Unreachable - ICMPTypeRedirect ICMPType = 5 // Redirect - ICMPTypeEcho ICMPType = 8 // Echo - ICMPTypeRouterAdvertisement ICMPType = 9 // Router Advertisement - ICMPTypeRouterSolicitation ICMPType = 10 // Router Solicitation - ICMPTypeTimeExceeded ICMPType = 11 // Time Exceeded - ICMPTypeParameterProblem ICMPType = 12 // Parameter Problem - ICMPTypeTimestamp ICMPType = 13 // Timestamp - ICMPTypeTimestampReply ICMPType = 14 // Timestamp Reply - ICMPTypePhoturis ICMPType = 40 // Photuris -) - -// Internet Control Message Protocol (ICMP) Parameters, Updated: 2013-04-19 -var icmpTypes = map[ICMPType]string{ - 0: "echo reply", - 3: "destination unreachable", - 5: "redirect", - 8: "echo", - 9: "router advertisement", - 10: "router solicitation", - 11: "time exceeded", - 12: "parameter problem", - 13: "timestamp", - 14: "timestamp reply", - 40: "photuris", -} diff --git a/vendor/golang.org/x/net/ipv4/icmp.go b/vendor/golang.org/x/net/ipv4/icmp.go deleted file mode 100644 index dbd05cf..0000000 --- a/vendor/golang.org/x/net/ipv4/icmp.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "golang.org/x/net/internal/iana" - -// An ICMPType represents a type of ICMP message. -type ICMPType int - -func (typ ICMPType) String() string { - s, ok := icmpTypes[typ] - if !ok { - return "" - } - return s -} - -// Protocol returns the ICMPv4 protocol number. -func (typ ICMPType) Protocol() int { - return iana.ProtocolICMP -} - -// An ICMPFilter represents an ICMP message filter for incoming -// packets. The filter belongs to a packet delivery path on a host and -// it cannot interact with forwarding packets or tunnel-outer packets. -// -// Note: RFC 2460 defines a reasonable role model and it works not -// only for IPv6 but IPv4. A node means a device that implements IP. -// A router means a node that forwards IP packets not explicitly -// addressed to itself, and a host means a node that is not a router. -type ICMPFilter struct { - sysICMPFilter -} - -// Accept accepts incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Accept(typ ICMPType) { - f.accept(typ) -} - -// Block blocks incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Block(typ ICMPType) { - f.block(typ) -} - -// SetAll sets the filter action to the filter. -func (f *ICMPFilter) SetAll(block bool) { - f.setAll(block) -} - -// WillBlock reports whether the ICMP type will be blocked. -func (f *ICMPFilter) WillBlock(typ ICMPType) bool { - return f.willBlock(typ) -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_linux.go b/vendor/golang.org/x/net/ipv4/icmp_linux.go deleted file mode 100644 index c912253..0000000 --- a/vendor/golang.org/x/net/ipv4/icmp_linux.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -func (f *sysICMPFilter) accept(typ ICMPType) { - f.Data &^= 1 << (uint32(typ) & 31) -} - -func (f *sysICMPFilter) block(typ ICMPType) { - f.Data |= 1 << (uint32(typ) & 31) -} - -func (f *sysICMPFilter) setAll(block bool) { - if block { - f.Data = 1<<32 - 1 - } else { - f.Data = 0 - } -} - -func (f *sysICMPFilter) willBlock(typ ICMPType) bool { - return f.Data&(1<<(uint32(typ)&31)) != 0 -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_stub.go b/vendor/golang.org/x/net/ipv4/icmp_stub.go deleted file mode 100644 index 9ee9b6a..0000000 --- a/vendor/golang.org/x/net/ipv4/icmp_stub.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv4 - -const sysSizeofICMPFilter = 0x0 - -type sysICMPFilter struct { -} - -func (f *sysICMPFilter) accept(typ ICMPType) { -} - -func (f *sysICMPFilter) block(typ ICMPType) { -} - -func (f *sysICMPFilter) setAll(block bool) { -} - -func (f *sysICMPFilter) willBlock(typ ICMPType) bool { - return false -} diff --git a/vendor/golang.org/x/net/ipv4/icmp_test.go b/vendor/golang.org/x/net/ipv4/icmp_test.go deleted file mode 100644 index 3324b54..0000000 --- a/vendor/golang.org/x/net/ipv4/icmp_test.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "reflect" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var icmpStringTests = []struct { - in ipv4.ICMPType - out string -}{ - {ipv4.ICMPTypeDestinationUnreachable, "destination unreachable"}, - - {256, ""}, -} - -func TestICMPString(t *testing.T) { - for _, tt := range icmpStringTests { - s := tt.in.String() - if s != tt.out { - t.Errorf("got %s; want %s", s, tt.out) - } - } -} - -func TestICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "linux": - default: - t.Skipf("not supported on %s", runtime.GOOS) - } - - var f ipv4.ICMPFilter - for _, toggle := range []bool{false, true} { - f.SetAll(toggle) - for _, typ := range []ipv4.ICMPType{ - ipv4.ICMPTypeDestinationUnreachable, - ipv4.ICMPTypeEchoReply, - ipv4.ICMPTypeTimeExceeded, - ipv4.ICMPTypeParameterProblem, - } { - f.Accept(typ) - if f.WillBlock(typ) { - t.Errorf("ipv4.ICMPFilter.Set(%v, false) failed", typ) - } - f.Block(typ) - if !f.WillBlock(typ) { - t.Errorf("ipv4.ICMPFilter.Set(%v, true) failed", typ) - } - } - } -} - -func TestSetICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "linux": - default: - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip4:icmp", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - - var f ipv4.ICMPFilter - f.SetAll(true) - f.Accept(ipv4.ICMPTypeEcho) - f.Accept(ipv4.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - kf, err := p.ICMPFilter() - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(kf, &f) { - t.Fatalf("got %#v; want %#v", kf, f) - } -} diff --git a/vendor/golang.org/x/net/ipv4/mocktransponder_test.go b/vendor/golang.org/x/net/ipv4/mocktransponder_test.go deleted file mode 100644 index e55aaee..0000000 --- a/vendor/golang.org/x/net/ipv4/mocktransponder_test.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "testing" -) - -func acceptor(t *testing.T, ln net.Listener, done chan<- bool) { - defer func() { done <- true }() - - c, err := ln.Accept() - if err != nil { - t.Error(err) - return - } - c.Close() -} diff --git a/vendor/golang.org/x/net/ipv4/multicast_test.go b/vendor/golang.org/x/net/ipv4/multicast_test.go deleted file mode 100644 index d2bcf85..0000000 --- a/vendor/golang.org/x/net/ipv4/multicast_test.go +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var packetConnReadWriteMulticastUDPTests = []struct { - addr string - grp, src *net.UDPAddr -}{ - {"224.0.0.0:0", &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727 - - {"232.0.1.0:0", &net.UDPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastUDPTests { - c, err := net.ListenPacket("udp4", tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - grp := *tt.grp - grp.Port = c.LocalAddr().(*net.UDPAddr).Port - p := ipv4.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, &grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, &grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, &grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, &grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - p.SetMulticastTTL(i + 1) - if n, err := p.WriteTo(wb, nil, &grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } - } -} - -var packetConnReadWriteMulticastICMPTests = []struct { - grp, src *net.IPAddr -}{ - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastICMPTests { - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, tt.grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, tt.grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - p.SetMulticastTTL(i + 1) - if n, err := p.WriteTo(wb, nil, tt.grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, rb[:n]) - if err != nil { - t.Fatal(err) - } - switch { - case m.Type == ipv4.ICMPTypeEchoReply && m.Code == 0: // net.inet.icmp.bmcastecho=1 - case m.Type == ipv4.ICMPTypeEcho && m.Code == 0: // net.inet.icmp.bmcastecho=0 - default: - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } - } -} - -var rawConnReadWriteMulticastICMPTests = []struct { - grp, src *net.IPAddr -}{ - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 254)}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 254)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestRawConnReadWriteMulticastICMP(t *testing.T) { - if testing.Short() { - t.Skip("to avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range rawConnReadWriteMulticastICMPTests { - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - defer r.Close() - if tt.src == nil { - if err := r.JoinGroup(ifi, tt.grp); err != nil { - t.Fatal(err) - } - defer r.LeaveGroup(ifi, tt.grp) - } else { - if err := r.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer r.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src) - } - if err := r.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := r.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := r.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := r.MulticastLoopback(); err != nil { - t.Fatal(err) - } - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - wh := &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: i + 1, - TotalLen: ipv4.HeaderLen + len(wb), - Protocol: 1, - Dst: tt.grp.IP, - } - if err := r.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := r.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - r.SetMulticastTTL(i + 1) - if err := r.WriteTo(wh, wb, nil); err != nil { - t.Fatal(err) - } - rb := make([]byte, ipv4.HeaderLen+128) - if rh, b, _, err := r.ReadFrom(rb); err != nil { - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - switch { - case (rh.Dst.IsLoopback() || rh.Dst.IsLinkLocalUnicast() || rh.Dst.IsGlobalUnicast()) && m.Type == ipv4.ICMPTypeEchoReply && m.Code == 0: // net.inet.icmp.bmcastecho=1 - case rh.Dst.IsMulticast() && m.Type == ipv4.ICMPTypeEcho && m.Code == 0: // net.inet.icmp.bmcastecho=0 - default: - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/multicastlistener_test.go b/vendor/golang.org/x/net/ipv4/multicastlistener_test.go deleted file mode 100644 index e342bf1..0000000 --- a/vendor/golang.org/x/net/ipv4/multicastlistener_test.go +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var udpMultipleGroupListenerTests = []net.Addr{ - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}, // see RFC 4727 - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 250)}, - &net.UDPAddr{IP: net.IPv4(224, 0, 0, 254)}, -} - -func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c, err := net.ListenPacket("udp4", "0.0.0.0:0") // wildcard address with no reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok { - continue - } - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } -} - -func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c1, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c1.Close() - - c2, err := net.ListenPacket("udp4", "224.0.0.0:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c2.Close() - - var ps [2]*ipv4.PacketConn - ps[0] = ipv4.NewPacketConn(c1) - ps[1] = ipv4.NewPacketConn(c2) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok { - continue - } - for _, p := range ps { - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - for _, p := range ps { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } - } -} - -func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727 - type ml struct { - c *ipv4.PacketConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip4", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("udp4", ip.String()+":"+"1024") // unicast address with non-reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{p, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPSingleRawConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") // wildcard address - if err != nil { - t.Fatal(err) - } - defer c.Close() - - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727 - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip4", &ifi); !ok { - continue - } - if err := r.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := r.LeaveGroup(ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPPerInterfaceSingleRawConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if testing.Short() { - t.Skip("to avoid external network") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - gaddr := net.IPAddr{IP: net.IPv4(224, 0, 0, 254)} // see RFC 4727 - type ml struct { - c *ipv4.RawConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip4", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("ip4:253", ip.String()) // unicast address - if err != nil { - t.Fatal(err) - } - defer c.Close() - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - if err := r.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{r, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go b/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go deleted file mode 100644 index c76dbe4..0000000 --- a/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -var packetConnMulticastSocketOptionTests = []struct { - net, proto, addr string - grp, src net.Addr -}{ - {"udp4", "", "224.0.0.0:0", &net.UDPAddr{IP: net.IPv4(224, 0, 0, 249)}, nil}, // see RFC 4727 - {"ip4", ":icmp", "0.0.0.0", &net.IPAddr{IP: net.IPv4(224, 0, 0, 250)}, nil}, // see RFC 4727 - - {"udp4", "", "232.0.0.0:0", &net.UDPAddr{IP: net.IPv4(232, 0, 1, 249)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 - {"ip4", ":icmp", "0.0.0.0", &net.IPAddr{IP: net.IPv4(232, 0, 1, 250)}, &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestPacketConnMulticastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnMulticastSocketOptionTests { - if tt.net == "ip4" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - defer p.Close() - - if tt.src == nil { - testMulticastSocketOptions(t, p, ifi, tt.grp) - } else { - testSourceSpecificMulticastSocketOptions(t, p, ifi, tt.grp, tt.src) - } - } -} - -var rawConnMulticastSocketOptionTests = []struct { - grp, src net.Addr -}{ - {&net.IPAddr{IP: net.IPv4(224, 0, 0, 250)}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.IPv4(232, 0, 1, 250)}, &net.IPAddr{IP: net.IPv4(127, 0, 0, 1)}}, // see RFC 5771 -} - -func TestRawConnMulticastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range rawConnMulticastSocketOptionTests { - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - defer r.Close() - - if tt.src == nil { - testMulticastSocketOptions(t, r, ifi, tt.grp) - } else { - testSourceSpecificMulticastSocketOptions(t, r, ifi, tt.grp, tt.src) - } - } -} - -type testIPv4MulticastConn interface { - MulticastTTL() (int, error) - SetMulticastTTL(ttl int) error - MulticastLoopback() (bool, error) - SetMulticastLoopback(bool) error - JoinGroup(*net.Interface, net.Addr) error - LeaveGroup(*net.Interface, net.Addr) error - JoinSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - LeaveSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - ExcludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - IncludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error -} - -func testMulticastSocketOptions(t *testing.T, c testIPv4MulticastConn, ifi *net.Interface, grp net.Addr) { - const ttl = 255 - if err := c.SetMulticastTTL(ttl); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastTTL(); err != nil { - t.Error(err) - return - } else if v != ttl { - t.Errorf("got %v; want %v", v, ttl) - return - } - - for _, toggle := range []bool{true, false} { - if err := c.SetMulticastLoopback(toggle); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastLoopback(); err != nil { - t.Error(err) - return - } else if v != toggle { - t.Errorf("got %v; want %v", v, toggle) - return - } - } - - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} - -func testSourceSpecificMulticastSocketOptions(t *testing.T, c testIPv4MulticastConn, ifi *net.Interface, grp, src net.Addr) { - // MCAST_JOIN_GROUP -> MCAST_BLOCK_SOURCE -> MCAST_UNBLOCK_SOURCE -> MCAST_LEAVE_GROUP - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.ExcludeSourceSpecificGroup(ifi, grp, src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support IGMPv2/3 fail here - t.Logf("not supported on %s", runtime.GOOS) - return - } - t.Error(err) - return - } - if err := c.IncludeSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_SOURCE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} diff --git a/vendor/golang.org/x/net/ipv4/packet.go b/vendor/golang.org/x/net/ipv4/packet.go deleted file mode 100644 index 0986431..0000000 --- a/vendor/golang.org/x/net/ipv4/packet.go +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" -) - -// A packetHandler represents the IPv4 datagram handler. -type packetHandler struct { - c *net.IPConn - rawOpt -} - -func (c *packetHandler) ok() bool { return c != nil && c.c != nil } - -// ReadFrom reads an IPv4 datagram from the endpoint c, copying the -// datagram into b. It returns the received datagram as the IPv4 -// header h, the payload p and the control message cm. -func (c *packetHandler) ReadFrom(b []byte) (h *Header, p []byte, cm *ControlMessage, err error) { - if !c.ok() { - return nil, nil, nil, syscall.EINVAL - } - oob := newControlMessage(&c.rawOpt) - n, oobn, _, src, err := c.c.ReadMsgIP(b, oob) - if err != nil { - return nil, nil, nil, err - } - var hs []byte - if hs, p, err = slicePacket(b[:n]); err != nil { - return nil, nil, nil, err - } - if h, err = ParseHeader(hs); err != nil { - return nil, nil, nil, err - } - if cm, err = parseControlMessage(oob[:oobn]); err != nil { - return nil, nil, nil, err - } - if src != nil && cm != nil { - cm.Src = src.IP - } - return -} - -func slicePacket(b []byte) (h, p []byte, err error) { - if len(b) < HeaderLen { - return nil, nil, errHeaderTooShort - } - hdrlen := int(b[0]&0x0f) << 2 - return b[:hdrlen], b[hdrlen:], nil -} - -// WriteTo writes an IPv4 datagram through the endpoint c, copying the -// datagram from the IPv4 header h and the payload p. The control -// message cm allows the datagram path and the outgoing interface to be -// specified. Currently only Darwin and Linux support this. The cm -// may be nil if control of the outgoing datagram is not required. -// -// The IPv4 header h must contain appropriate fields that include: -// -// Version = ipv4.Version -// Len = -// TOS = -// TotalLen = -// ID = platform sets an appropriate value if ID is zero -// FragOff = -// TTL = -// Protocol = -// Checksum = platform sets an appropriate value if Checksum is zero -// Src = platform sets an appropriate value if Src is nil -// Dst = -// Options = optional -func (c *packetHandler) WriteTo(h *Header, p []byte, cm *ControlMessage) error { - if !c.ok() { - return syscall.EINVAL - } - oob := marshalControlMessage(cm) - wh, err := h.Marshal() - if err != nil { - return err - } - dst := &net.IPAddr{} - if cm != nil { - if ip := cm.Dst.To4(); ip != nil { - dst.IP = ip - } - } - if dst.IP == nil { - dst.IP = h.Dst - } - wh = append(wh, p...) - _, _, err = c.c.WriteMsgIP(wh, oob, dst) - return err -} diff --git a/vendor/golang.org/x/net/ipv4/payload.go b/vendor/golang.org/x/net/ipv4/payload.go deleted file mode 100644 index d7698cb..0000000 --- a/vendor/golang.org/x/net/ipv4/payload.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import "net" - -// A payloadHandler represents the IPv4 datagram payload handler. -type payloadHandler struct { - net.PacketConn - rawOpt -} - -func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil } diff --git a/vendor/golang.org/x/net/ipv4/payload_cmsg.go b/vendor/golang.org/x/net/ipv4/payload_cmsg.go deleted file mode 100644 index d358fc3..0000000 --- a/vendor/golang.org/x/net/ipv4/payload_cmsg.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !plan9,!solaris,!windows - -package ipv4 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv4 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - oob := newControlMessage(&c.rawOpt) - var oobn int - switch c := c.PacketConn.(type) { - case *net.UDPConn: - if n, oobn, _, src, err = c.ReadMsgUDP(b, oob); err != nil { - return 0, nil, nil, err - } - case *net.IPConn: - if sockOpts[ssoStripHeader].name > 0 { - if n, oobn, _, src, err = c.ReadMsgIP(b, oob); err != nil { - return 0, nil, nil, err - } - } else { - nb := make([]byte, maxHeaderLen+len(b)) - if n, oobn, _, src, err = c.ReadMsgIP(nb, oob); err != nil { - return 0, nil, nil, err - } - hdrlen := int(nb[0]&0x0f) << 2 - copy(b, nb[hdrlen:]) - n -= hdrlen - } - default: - return 0, nil, nil, errInvalidConnType - } - if cm, err = parseControlMessage(oob[:oobn]); err != nil { - return 0, nil, nil, err - } - if cm != nil { - cm.Src = netAddrToIP4(src) - } - return -} - -// WriteTo writes a payload of the IPv4 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the datagram path and the outgoing interface to be specified. -// Currently only Darwin and Linux support this. The cm may be nil if -// control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - oob := marshalControlMessage(cm) - if dst == nil { - return 0, errMissingAddress - } - switch c := c.PacketConn.(type) { - case *net.UDPConn: - n, _, err = c.WriteMsgUDP(b, oob, dst.(*net.UDPAddr)) - case *net.IPConn: - n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr)) - default: - return 0, errInvalidConnType - } - if err != nil { - return 0, err - } - return -} diff --git a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go b/vendor/golang.org/x/net/ipv4/payload_nocmsg.go deleted file mode 100644 index d128c9c..0000000 --- a/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build plan9 solaris windows - -package ipv4 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv4 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - if n, src, err = c.PacketConn.ReadFrom(b); err != nil { - return 0, nil, nil, err - } - return -} - -// WriteTo writes a payload of the IPv4 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the datagram path and the outgoing interface to be specified. -// Currently only Darwin and Linux support this. The cm may be nil if -// control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - if dst == nil { - return 0, errMissingAddress - } - return c.PacketConn.WriteTo(b, dst) -} diff --git a/vendor/golang.org/x/net/ipv4/readwrite_test.go b/vendor/golang.org/x/net/ipv4/readwrite_test.go deleted file mode 100644 index 247d06c..0000000 --- a/vendor/golang.org/x/net/ipv4/readwrite_test.go +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "bytes" - "net" - "runtime" - "strings" - "sync" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -func benchmarkUDPListener() (net.PacketConn, net.Addr, error) { - c, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - return nil, nil, err - } - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String()) - if err != nil { - c.Close() - return nil, nil, err - } - return c, dst, nil -} - -func BenchmarkReadWriteNetUDP(b *testing.B) { - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteNetUDP(b, c, wb, rb, dst) - } -} - -func benchmarkReadWriteNetUDP(b *testing.B, c net.PacketConn, wb, rb []byte, dst net.Addr) { - if _, err := c.WriteTo(wb, dst); err != nil { - b.Fatal(err) - } - if _, _, err := c.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func BenchmarkReadWriteIPv4UDP(b *testing.B) { - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - p := ipv4.NewPacketConn(c) - defer p.Close() - cf := ipv4.FlagTTL | ipv4.FlagInterface - if err := p.SetControlMessage(cf, true); err != nil { - b.Fatal(err) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteIPv4UDP(b, p, wb, rb, dst, ifi) - } -} - -func benchmarkReadWriteIPv4UDP(b *testing.B, p *ipv4.PacketConn, wb, rb []byte, dst net.Addr, ifi *net.Interface) { - cm := ipv4.ControlMessage{TTL: 1} - if ifi != nil { - cm.IfIndex = ifi.Index - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - b.Fatal(err) - } else if n != len(wb) { - b.Fatalf("got %v; want %v", n, len(wb)) - } - if _, _, _, err := p.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func TestPacketConnConcurrentReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv4.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - cf := ipv4.FlagTTL | ipv4.FlagSrc | ipv4.FlagDst | ipv4.FlagInterface - wb := []byte("HELLO-R-U-THERE") - - if err := p.SetControlMessage(cf, true); err != nil { // probe before test - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - - var wg sync.WaitGroup - reader := func() { - defer wg.Done() - rb := make([]byte, 128) - if n, cm, _, err := p.ReadFrom(rb); err != nil { - t.Error(err) - return - } else if !bytes.Equal(rb[:n], wb) { - t.Errorf("got %v; want %v", rb[:n], wb) - return - } else { - s := cm.String() - if strings.Contains(s, ",") { - t.Errorf("should be space-separated values: %s", s) - } - } - } - writer := func(toggle bool) { - defer wg.Done() - cm := ipv4.ControlMessage{ - Src: net.IPv4(127, 0, 0, 1), - } - if ifi != nil { - cm.IfIndex = ifi.Index - } - if err := p.SetControlMessage(cf, toggle); err != nil { - t.Error(err) - return - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Error(err) - return - } else if n != len(wb) { - t.Errorf("short write: %v", n) - return - } - } - - const N = 10 - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Add(2 * N) - for i := 0; i < 2*N; i++ { - go writer(i%2 != 0) - } - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Wait() -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt.go b/vendor/golang.org/x/net/ipv4/sockopt.go deleted file mode 100644 index ace37d3..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -// Sticky socket options -const ( - ssoTOS = iota // header field for unicast packet - ssoTTL // header field for unicast packet - ssoMulticastTTL // header field for multicast packet - ssoMulticastInterface // outbound interface for multicast packet - ssoMulticastLoopback // loopback for multicast packet - ssoReceiveTTL // header field on received packet - ssoReceiveDst // header field on received packet - ssoReceiveInterface // inbound interface on received packet - ssoPacketInfo // incbound or outbound packet path - ssoHeaderPrepend // ipv4 header prepend - ssoStripHeader // strip ipv4 header - ssoICMPFilter // icmp filter - ssoJoinGroup // any-source multicast - ssoLeaveGroup // any-source multicast - ssoJoinSourceGroup // source-specific multicast - ssoLeaveSourceGroup // source-specific multicast - ssoBlockSourceGroup // any-source or source-specific multicast - ssoUnblockSourceGroup // any-source or source-specific multicast - ssoMax -) - -// Sticky socket option value types -const ( - ssoTypeByte = iota + 1 - ssoTypeInt - ssoTypeInterface - ssoTypeICMPFilter - ssoTypeIPMreq - ssoTypeIPMreqn - ssoTypeGroupReq - ssoTypeGroupSourceReq -) - -// A sockOpt represents a binding for sticky socket option. -type sockOpt struct { - name int // option name, must be equal or greater than 1 - typ int // option value type, must be equal or greater than 1 -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreq.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreq.go deleted file mode 100644 index 4a6aa78..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreq.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd windows - -package ipv4 - -import "net" - -func setIPMreqInterface(mreq *sysIPMreq, ifi *net.Interface) error { - if ifi == nil { - return nil - } - ifat, err := ifi.Addrs() - if err != nil { - return err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := ifa.IP.To4(); ip != nil { - copy(mreq.Interface[:], ip) - return nil - } - case *net.IPNet: - if ip := ifa.IP.To4(); ip != nil { - copy(mreq.Interface[:], ip) - return nil - } - } - } - return errNoSuchInterface -} - -func netIP4ToInterface(ip net.IP) (*net.Interface, error) { - ift, err := net.Interfaces() - if err != nil { - return nil, err - } - for _, ifi := range ift { - ifat, err := ifi.Addrs() - if err != nil { - return nil, err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip.Equal(ifa.IP) { - return &ifi, nil - } - case *net.IPNet: - if ip.Equal(ifa.IP) { - return &ifi, nil - } - } - } - } - return nil, errNoSuchInterface -} - -func netInterfaceToIP4(ifi *net.Interface) (net.IP, error) { - if ifi == nil { - return net.IPv4zero.To4(), nil - } - ifat, err := ifi.Addrs() - if err != nil { - return nil, err - } - for _, ifa := range ifat { - switch ifa := ifa.(type) { - case *net.IPAddr: - if ip := ifa.IP.To4(); ip != nil { - return ip, nil - } - case *net.IPNet: - if ip := ifa.IP.To4(); ip != nil { - return ip, nil - } - } - } - return nil, errNoSuchInterface -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go deleted file mode 100644 index 4555152..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_stub.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!dragonfly,!freebsd,!netbsd,!openbsd,!windows - -package ipv4 - -import "net" - -func setsockoptIPMreq(fd, name int, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func getsockoptInterface(fd, name int) (*net.Interface, error) { - return nil, errOpNoSupport -} - -func setsockoptInterface(fd, name int, ifi *net.Interface) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_unix.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreq_unix.go deleted file mode 100644 index 7b5c329..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_unix.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func setsockoptIPMreq(fd, name int, ifi *net.Interface, grp net.IP) error { - mreq := sysIPMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}} - if err := setIPMreqInterface(&mreq, ifi); err != nil { - return err - } - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&mreq), sysSizeofIPMreq)) -} - -func getsockoptInterface(fd, name int) (*net.Interface, error) { - var b [4]byte - l := uint32(4) - if err := getsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3])) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setsockoptInterface(fd, name int, ifi *net.Interface) error { - ip, err := netInterfaceToIP4(ifi) - if err != nil { - return err - } - var b [4]byte - copy(b[:], ip) - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&b[0]), uint32(4))) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_windows.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreq_windows.go deleted file mode 100644 index 431930d..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreq_windows.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "os" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func setsockoptIPMreq(fd syscall.Handle, name int, ifi *net.Interface, grp net.IP) error { - mreq := sysIPMreq{Multiaddr: [4]byte{grp[0], grp[1], grp[2], grp[3]}} - if err := setIPMreqInterface(&mreq, ifi); err != nil { - return err - } - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, iana.ProtocolIP, int32(name), (*byte)(unsafe.Pointer(&mreq)), int32(sysSizeofIPMreq))) -} - -func getsockoptInterface(fd syscall.Handle, name int) (*net.Interface, error) { - var b [4]byte - l := int32(4) - if err := syscall.Getsockopt(fd, iana.ProtocolIP, int32(name), (*byte)(unsafe.Pointer(&b[0])), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - ifi, err := netIP4ToInterface(net.IPv4(b[0], b[1], b[2], b[3])) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setsockoptInterface(fd syscall.Handle, name int, ifi *net.Interface) error { - ip, err := netInterfaceToIP4(ifi) - if err != nil { - return err - } - var b [4]byte - copy(b[:], ip) - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, iana.ProtocolIP, int32(name), (*byte)(unsafe.Pointer(&b[0])), 4)) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go deleted file mode 100644 index 332f403..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_stub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux,!windows - -package ipv4 - -import "net" - -func getsockoptIPMreqn(fd, name int) (*net.Interface, error) { - return nil, errOpNoSupport -} - -func setsockoptIPMreqn(fd, name int, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go b/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go deleted file mode 100644 index 1f2b9a1..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_asmreqn_unix.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func getsockoptIPMreqn(fd, name int) (*net.Interface, error) { - var mreqn sysIPMreqn - l := uint32(sysSizeofIPMreqn) - if err := getsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - if mreqn.Ifindex == 0 { - return nil, nil - } - ifi, err := net.InterfaceByIndex(int(mreqn.Ifindex)) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setsockoptIPMreqn(fd, name int, ifi *net.Interface, grp net.IP) error { - var mreqn sysIPMreqn - if ifi != nil { - mreqn.Ifindex = int32(ifi.Index) - } - if grp != nil { - mreqn.Multiaddr = [4]byte{grp[0], grp[1], grp[2], grp[3]} - } - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, unsafe.Pointer(&mreqn), sysSizeofIPMreqn)) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go deleted file mode 100644 index 8546524..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_stub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux - -package ipv4 - -import "net" - -func setsockoptGroupReq(fd, name int, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func setsockoptGroupSourceReq(fd, name int, ifi *net.Interface, grp, src net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go b/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go deleted file mode 100644 index 0a672b6..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_ssmreq_unix.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var freebsd32o64 bool - -func setsockoptGroupReq(fd, name int, ifi *net.Interface, grp net.IP) error { - var gr sysGroupReq - if ifi != nil { - gr.Interface = uint32(ifi.Index) - } - gr.setGroup(grp) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sysSizeofGroupReq + 4]byte - s := (*[sysSizeofGroupReq]byte)(unsafe.Pointer(&gr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sysSizeofGroupReq + 4 - } else { - p = unsafe.Pointer(&gr) - l = sysSizeofGroupReq - } - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, p, l)) -} - -func setsockoptGroupSourceReq(fd, name int, ifi *net.Interface, grp, src net.IP) error { - var gsr sysGroupSourceReq - if ifi != nil { - gsr.Interface = uint32(ifi.Index) - } - gsr.setSourceGroup(grp, src) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sysSizeofGroupSourceReq + 4]byte - s := (*[sysSizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sysSizeofGroupSourceReq + 4 - } else { - p = unsafe.Pointer(&gsr) - l = sysSizeofGroupSourceReq - } - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, name, p, l)) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_stub.go b/vendor/golang.org/x/net/ipv4/sockopt_stub.go deleted file mode 100644 index 9d19f5d..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_stub.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv4 - -func setInt(fd int, opt *sockOpt, v int) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_unix.go b/vendor/golang.org/x/net/ipv4/sockopt_unix.go deleted file mode 100644 index f7acc6b..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_unix.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv4 - -import ( - "net" - "os" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func getInt(fd int, opt *sockOpt) (int, error) { - if opt.name < 1 || (opt.typ != ssoTypeByte && opt.typ != ssoTypeInt) { - return 0, errOpNoSupport - } - var i int32 - var b byte - p := unsafe.Pointer(&i) - l := uint32(4) - if opt.typ == ssoTypeByte { - p = unsafe.Pointer(&b) - l = 1 - } - if err := getsockopt(fd, iana.ProtocolIP, opt.name, p, &l); err != nil { - return 0, os.NewSyscallError("getsockopt", err) - } - if opt.typ == ssoTypeByte { - return int(b), nil - } - return int(i), nil -} - -func setInt(fd int, opt *sockOpt, v int) error { - if opt.name < 1 || (opt.typ != ssoTypeByte && opt.typ != ssoTypeInt) { - return errOpNoSupport - } - i := int32(v) - var b byte - p := unsafe.Pointer(&i) - l := uint32(4) - if opt.typ == ssoTypeByte { - b = byte(v) - p = unsafe.Pointer(&b) - l = 1 - } - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolIP, opt.name, p, l)) -} - -func getInterface(fd int, opt *sockOpt) (*net.Interface, error) { - if opt.name < 1 { - return nil, errOpNoSupport - } - switch opt.typ { - case ssoTypeInterface: - return getsockoptInterface(fd, opt.name) - case ssoTypeIPMreqn: - return getsockoptIPMreqn(fd, opt.name) - default: - return nil, errOpNoSupport - } -} - -func setInterface(fd int, opt *sockOpt, ifi *net.Interface) error { - if opt.name < 1 { - return errOpNoSupport - } - switch opt.typ { - case ssoTypeInterface: - return setsockoptInterface(fd, opt.name, ifi) - case ssoTypeIPMreqn: - return setsockoptIPMreqn(fd, opt.name, ifi, nil) - default: - return errOpNoSupport - } -} - -func getICMPFilter(fd int, opt *sockOpt) (*ICMPFilter, error) { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return nil, errOpNoSupport - } - var f ICMPFilter - l := uint32(sysSizeofICMPFilter) - if err := getsockopt(fd, iana.ProtocolReserved, opt.name, unsafe.Pointer(&f.sysICMPFilter), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - return &f, nil -} - -func setICMPFilter(fd int, opt *sockOpt, f *ICMPFilter) error { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return errOpNoSupport - } - return os.NewSyscallError("setsockopt", setsockopt(fd, iana.ProtocolReserved, opt.name, unsafe.Pointer(&f.sysICMPFilter), sysSizeofICMPFilter)) -} - -func setGroup(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - if opt.name < 1 { - return errOpNoSupport - } - switch opt.typ { - case ssoTypeIPMreq: - return setsockoptIPMreq(fd, opt.name, ifi, grp) - case ssoTypeIPMreqn: - return setsockoptIPMreqn(fd, opt.name, ifi, grp) - case ssoTypeGroupReq: - return setsockoptGroupReq(fd, opt.name, ifi, grp) - default: - return errOpNoSupport - } -} - -func setSourceGroup(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - if opt.name < 1 || opt.typ != ssoTypeGroupSourceReq { - return errOpNoSupport - } - return setsockoptGroupSourceReq(fd, opt.name, ifi, grp, src) -} diff --git a/vendor/golang.org/x/net/ipv4/sockopt_windows.go b/vendor/golang.org/x/net/ipv4/sockopt_windows.go deleted file mode 100644 index c4c2441..0000000 --- a/vendor/golang.org/x/net/ipv4/sockopt_windows.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "os" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func getInt(fd syscall.Handle, opt *sockOpt) (int, error) { - if opt.name < 1 || opt.typ != ssoTypeInt { - return 0, errOpNoSupport - } - var i int32 - l := int32(4) - if err := syscall.Getsockopt(fd, iana.ProtocolIP, int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil { - return 0, os.NewSyscallError("getsockopt", err) - } - return int(i), nil -} - -func setInt(fd syscall.Handle, opt *sockOpt, v int) error { - if opt.name < 1 || opt.typ != ssoTypeInt { - return errOpNoSupport - } - i := int32(v) - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, iana.ProtocolIP, int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4)) -} - -func getInterface(fd syscall.Handle, opt *sockOpt) (*net.Interface, error) { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return nil, errOpNoSupport - } - return getsockoptInterface(fd, opt.name) -} - -func setInterface(fd syscall.Handle, opt *sockOpt, ifi *net.Interface) error { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return errOpNoSupport - } - return setsockoptInterface(fd, opt.name, ifi) -} - -func getICMPFilter(fd syscall.Handle, opt *sockOpt) (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -func setICMPFilter(fd syscall.Handle, opt *sockOpt, f *ICMPFilter) error { - return errOpNoSupport -} - -func setGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - if opt.name < 1 || opt.typ != ssoTypeIPMreq { - return errOpNoSupport - } - return setsockoptIPMreq(fd, opt.name, ifi, grp) -} - -func setSourceGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - // TODO(mikio): implement this - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv4/sys_bsd.go b/vendor/golang.org/x/net/ipv4/sys_bsd.go deleted file mode 100644 index 203033d..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_bsd.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build dragonfly netbsd - -package ipv4 - -import ( - "net" - "syscall" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) diff --git a/vendor/golang.org/x/net/ipv4/sys_darwin.go b/vendor/golang.org/x/net/ipv4/sys_darwin.go deleted file mode 100644 index b5f5bd5..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_darwin.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoStripHeader: {sysIP_STRIPHDR, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) - -func init() { - // Seems like kern.osreldate is veiled on latest OS X. We use - // kern.osrelease instead. - osver, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return - } - var i int - for i = range osver { - if osver[i] == '.' { - break - } - } - // The IP_PKTINFO and protocol-independent multicast API were - // introduced in OS X 10.7 (Darwin 11.0.0). But it looks like - // those features require OS X 10.8 (Darwin 12.0.0) and above. - // See http://support.apple.com/kb/HT1633. - if i > 2 || i == 2 && osver[0] >= '1' && osver[1] >= '2' { - ctlOpts[ctlPacketInfo].name = sysIP_PKTINFO - ctlOpts[ctlPacketInfo].length = sysSizeofInetPktinfo - ctlOpts[ctlPacketInfo].marshal = marshalPacketInfo - ctlOpts[ctlPacketInfo].parse = parsePacketInfo - sockOpts[ssoPacketInfo].name = sysIP_RECVPKTINFO - sockOpts[ssoPacketInfo].typ = ssoTypeInt - sockOpts[ssoMulticastInterface].typ = ssoTypeIPMreqn - sockOpts[ssoJoinGroup].name = sysMCAST_JOIN_GROUP - sockOpts[ssoJoinGroup].typ = ssoTypeGroupReq - sockOpts[ssoLeaveGroup].name = sysMCAST_LEAVE_GROUP - sockOpts[ssoLeaveGroup].typ = ssoTypeGroupReq - sockOpts[ssoJoinSourceGroup].name = sysMCAST_JOIN_SOURCE_GROUP - sockOpts[ssoJoinSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoLeaveSourceGroup].name = sysMCAST_LEAVE_SOURCE_GROUP - sockOpts[ssoLeaveSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoBlockSourceGroup].name = sysMCAST_BLOCK_SOURCE - sockOpts[ssoBlockSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoUnblockSourceGroup].name = sysMCAST_UNBLOCK_SOURCE - sockOpts[ssoUnblockSourceGroup].typ = ssoTypeGroupSourceReq - } -} - -func (pi *sysInetPktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (gr *sysGroupReq) setGroup(grp net.IP) { - sa := (*sysSockaddrInet)(unsafe.Pointer(&gr.Pad_cgo_0[0])) - sa.Len = sysSizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sysSockaddrInet)(unsafe.Pointer(&gsr.Pad_cgo_0[0])) - sa.Len = sysSizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sysSockaddrInet)(unsafe.Pointer(&gsr.Pad_cgo_1[0])) - sa.Len = sysSizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_freebsd.go b/vendor/golang.org/x/net/ipv4/sys_freebsd.go deleted file mode 100644 index 163ff9a..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_freebsd.go +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "runtime" - "strings" - "syscall" - "unsafe" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func init() { - freebsdVersion, _ = syscall.SysctlUint32("kern.osreldate") - if freebsdVersion >= 1000000 { - sockOpts[ssoMulticastInterface].typ = ssoTypeIPMreqn - } - if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" { - archs, _ := syscall.Sysctl("kern.supported_archs") - for _, s := range strings.Fields(archs) { - if s == "amd64" { - freebsd32o64 = true - break - } - } - } -} - -func (gr *sysGroupReq) setGroup(grp net.IP) { - sa := (*sysSockaddrInet)(unsafe.Pointer(&gr.Group)) - sa.Len = sysSizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sysSockaddrInet)(unsafe.Pointer(&gsr.Group)) - sa.Len = sysSizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sysSockaddrInet)(unsafe.Pointer(&gsr.Source)) - sa.Len = sysSizeofSockaddrInet - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_linux.go b/vendor/golang.org/x/net/ipv4/sys_linux.go deleted file mode 100644 index 73e0d46..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_linux.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" - "unsafe" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_TTL, 1, marshalTTL, parseTTL}, - ctlPacketInfo: {sysIP_PKTINFO, sysSizeofInetPktinfo, marshalPacketInfo, parsePacketInfo}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeIPMreqn}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoPacketInfo: {sysIP_PKTINFO, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoICMPFilter: {sysICMP_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func (pi *sysInetPktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} - -func (gr *sysGroupReq) setGroup(grp net.IP) { - sa := (*sysSockaddrInet)(unsafe.Pointer(&gr.Group)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) -} - -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sysSockaddrInet)(unsafe.Pointer(&gsr.Group)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], grp) - sa = (*sysSockaddrInet)(unsafe.Pointer(&gsr.Source)) - sa.Family = syscall.AF_INET - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv4/sys_openbsd.go b/vendor/golang.org/x/net/ipv4/sys_openbsd.go deleted file mode 100644 index d78083a..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_openbsd.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "net" - "syscall" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTTL: {sysIP_RECVTTL, 1, marshalTTL, parseTTL}, - ctlDst: {sysIP_RECVDSTADDR, net.IPv4len, marshalDst, parseDst}, - ctlInterface: {sysIP_RECVIF, syscall.SizeofSockaddrDatalink, marshalInterface, parseInterface}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeByte}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeByte}, - ssoReceiveTTL: {sysIP_RECVTTL, ssoTypeInt}, - ssoReceiveDst: {sysIP_RECVDSTADDR, ssoTypeInt}, - ssoReceiveInterface: {sysIP_RECVIF, ssoTypeInt}, - ssoHeaderPrepend: {sysIP_HDRINCL, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) diff --git a/vendor/golang.org/x/net/ipv4/sys_stub.go b/vendor/golang.org/x/net/ipv4/sys_stub.go deleted file mode 100644 index c8e55cb..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv4 - -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{} -) diff --git a/vendor/golang.org/x/net/ipv4/sys_windows.go b/vendor/golang.org/x/net/ipv4/sys_windows.go deleted file mode 100644 index 466489f..0000000 --- a/vendor/golang.org/x/net/ipv4/sys_windows.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -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 - - sysSizeofInetPktinfo = 0x8 - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqSource = 0xc -) - -type sysInetPktinfo struct { - Addr [4]byte - Ifindex int32 -} - -type sysIPMreq struct { - Multiaddr [4]byte - Interface [4]byte -} - -type sysIPMreqSource struct { - Multiaddr [4]byte - Sourceaddr [4]byte - Interface [4]byte -} - -// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms738586(v=vs.85).aspx -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{ - ssoTOS: {sysIP_TOS, ssoTypeInt}, - ssoTTL: {sysIP_TTL, ssoTypeInt}, - ssoMulticastTTL: {sysIP_MULTICAST_TTL, ssoTypeInt}, - ssoMulticastInterface: {sysIP_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastLoopback: {sysIP_MULTICAST_LOOP, ssoTypeInt}, - ssoJoinGroup: {sysIP_ADD_MEMBERSHIP, ssoTypeIPMreq}, - ssoLeaveGroup: {sysIP_DROP_MEMBERSHIP, ssoTypeIPMreq}, - } -) - -func (pi *sysInetPktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} diff --git a/vendor/golang.org/x/net/ipv4/syscall_linux_386.go b/vendor/golang.org/x/net/ipv4/syscall_linux_386.go deleted file mode 100644 index 07a3a28..0000000 --- a/vendor/golang.org/x/net/ipv4/syscall_linux_386.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4 - -import ( - "syscall" - "unsafe" -) - -const ( - sysGETSOCKOPT = 0xf - sysSETSOCKOPT = 0xe -) - -func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) - -func getsockopt(fd, level, name int, v unsafe.Pointer, l *uint32) error { - if _, errno := socketcall(sysGETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(fd, level, name int, v unsafe.Pointer, l uint32) error { - if _, errno := socketcall(sysSETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/syscall_unix.go b/vendor/golang.org/x/net/ipv4/syscall_unix.go deleted file mode 100644 index 88a41b0..0000000 --- a/vendor/golang.org/x/net/ipv4/syscall_unix.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux,!386 netbsd openbsd - -package ipv4 - -import ( - "syscall" - "unsafe" -) - -func getsockopt(fd, level, name int, v unsafe.Pointer, l *uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(fd, level, name int, v unsafe.Pointer, l uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv4/thunk_linux_386.s b/vendor/golang.org/x/net/ipv4/thunk_linux_386.s deleted file mode 100644 index daa78bc..0000000 --- a/vendor/golang.org/x/net/ipv4/thunk_linux_386.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.2 - -TEXT ·socketcall(SB),4,$0-36 - JMP syscall·socketcall(SB) diff --git a/vendor/golang.org/x/net/ipv4/unicast_test.go b/vendor/golang.org/x/net/ipv4/unicast_test.go deleted file mode 100644 index 9c632cd..0000000 --- a/vendor/golang.org/x/net/ipv4/unicast_test.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -func TestPacketConnReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("udp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - dst, err := net.ResolveUDPAddr("udp4", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - p := ipv4.NewPacketConn(c) - defer p.Close() - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - p.SetTTL(i + 1) - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, nil, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } -} - -func TestPacketConnReadWriteUnicastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - dst, err := net.ResolveIPAddr("ip4", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - p := ipv4.NewPacketConn(c) - defer p.Close() - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - p.SetTTL(i + 1) - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, nil, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - loop: - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, rb[:n]) - if err != nil { - t.Fatal(err) - } - if runtime.GOOS == "linux" && m.Type == ipv4.ICMPTypeEcho { - // On Linux we must handle own sent packets. - goto loop - } - if m.Type != ipv4.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } -} - -func TestRawConnReadWriteUnicastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("ip4:icmp", "0.0.0.0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - dst, err := net.ResolveIPAddr("ip4", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - defer r.Close() - cf := ipv4.FlagTTL | ipv4.FlagDst | ipv4.FlagInterface - - for i, toggle := range []bool{true, false, true} { - wb, err := (&icmp.Message{ - Type: ipv4.ICMPTypeEcho, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(nil) - if err != nil { - t.Fatal(err) - } - wh := &ipv4.Header{ - Version: ipv4.Version, - Len: ipv4.HeaderLen, - TOS: i + 1, - TotalLen: ipv4.HeaderLen + len(wb), - TTL: i + 1, - Protocol: 1, - Dst: dst.IP, - } - if err := r.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := r.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if err := r.WriteTo(wh, wb, nil); err != nil { - t.Fatal(err) - } - rb := make([]byte, ipv4.HeaderLen+128) - loop: - if err := r.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if _, b, _, err := r.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - m, err := icmp.ParseMessage(iana.ProtocolICMP, b) - if err != nil { - t.Fatal(err) - } - if runtime.GOOS == "linux" && m.Type == ipv4.ICMPTypeEcho { - // On Linux we must handle own sent packets. - goto loop - } - if m.Type != ipv4.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv4.ICMPTypeEchoReply, 0) - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go b/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go deleted file mode 100644 index 25606f2..0000000 --- a/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv4_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv4" -) - -func TestConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - ln, err := net.Listen("tcp4", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - done := make(chan bool) - go acceptor(t, ln, done) - - c, err := net.Dial("tcp4", ln.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv4.NewConn(c)) - - <-done -} - -var packetConnUnicastSocketOptionTests = []struct { - net, proto, addr string -}{ - {"udp4", "", "127.0.0.1:0"}, - {"ip4", ":icmp", "127.0.0.1"}, -} - -func TestPacketConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris": - t.Skipf("not supported on %s", runtime.GOOS) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnUnicastSocketOptionTests { - if tt.net == "ip4" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv4.NewPacketConn(c)) - } -} - -func TestRawConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris": - t.Skipf("not supported on %s", runtime.GOOS) - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip4", net.FlagUp|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - c, err := net.ListenPacket("ip4:icmp", "127.0.0.1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - r, err := ipv4.NewRawConn(c) - if err != nil { - t.Fatal(err) - } - - testUnicastSocketOptions(t, r) -} - -type testIPv4UnicastConn interface { - TOS() (int, error) - SetTOS(int) error - TTL() (int, error) - SetTTL(int) error -} - -func testUnicastSocketOptions(t *testing.T, c testIPv4UnicastConn) { - tos := iana.DiffServCS0 | iana.NotECNTransport - switch runtime.GOOS { - case "windows": - // IP_TOS option is supported on Windows 8 and beyond. - t.Skipf("not supported on %s", runtime.GOOS) - } - - if err := c.SetTOS(tos); err != nil { - t.Fatal(err) - } - if v, err := c.TOS(); err != nil { - t.Fatal(err) - } else if v != tos { - t.Fatalf("got %v; want %v", v, tos) - } - const ttl = 255 - if err := c.SetTTL(ttl); err != nil { - t.Fatal(err) - } - if v, err := c.TTL(); err != nil { - t.Fatal(err) - } else if v != ttl { - t.Fatalf("got %v; want %v", v, ttl) - } -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_darwin.go b/vendor/golang.org/x/net/ipv4/zsys_darwin.go deleted file mode 100644 index 087c639..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_darwin.go +++ /dev/null @@ -1,99 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_STRIPHDR = 0x17 - sysIP_RECVTTL = 0x18 - sysIP_BOUND_IF = 0x19 - sysIP_PKTINFO = 0x1a - sysIP_RECVPKTINFO = 0x1a - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_MULTICAST_IFINDEX = 0x42 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sysInetPktinfo struct { - Ifindex uint32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [128]byte -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [128]byte - Pad_cgo_1 [128]byte -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go b/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go deleted file mode 100644 index f5c9cce..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +++ /dev/null @@ -1,33 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -// +build dragonfly - -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 - - sysSizeofIPMreq = 0x8 -) - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go deleted file mode 100644 index 6fd67e1..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +++ /dev/null @@ -1,93 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysGroupReq struct { - Interface uint32 - Group sysSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Group sysSockaddrStorage - Source sysSockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go deleted file mode 100644 index ebac6d7..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +++ /dev/null @@ -1,95 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage - Source sysSockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go b/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go deleted file mode 100644 index ebac6d7..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +++ /dev/null @@ -1,95 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_SENDSRCADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_ONESBCAST = 0x17 - sysIP_BINDANY = 0x18 - sysIP_RECVTTL = 0x41 - sysIP_MINTTL = 0x42 - sysIP_DONTFRAG = 0x43 - sysIP_RECVTOS = 0x44 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - sysIP_MULTICAST_VIF = 0xe - sysIP_ADD_SOURCE_MEMBERSHIP = 0x46 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x47 - sysIP_BLOCK_SOURCE = 0x48 - sysIP_UNBLOCK_SOURCE = 0x49 - sysMCAST_JOIN_GROUP = 0x50 - sysMCAST_LEAVE_GROUP = 0x51 - sysMCAST_JOIN_SOURCE_GROUP = 0x52 - sysMCAST_LEAVE_SOURCE_GROUP = 0x53 - sysMCAST_BLOCK_SOURCE = 0x54 - sysMCAST_UNBLOCK_SOURCE = 0x55 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet struct { - Len uint8 - Family uint8 - Port uint16 - Addr [4]byte /* in_addr */ - Zero [8]int8 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage - Source sysSockaddrStorage -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_386.go b/vendor/golang.org/x/net/ipv4/zsys_linux_386.go deleted file mode 100644 index 3733152..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +++ /dev/null @@ -1,146 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go deleted file mode 100644 index afa4519..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +++ /dev/null @@ -1,148 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go b/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go deleted file mode 100644 index 3733152..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +++ /dev/null @@ -1,146 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go deleted file mode 100644 index 129a20a..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,arm64 - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go deleted file mode 100644 index 7ed9368..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,mips64 - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go b/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go deleted file mode 100644 index 19fadae..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,mips64le - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go deleted file mode 100644 index beaadd5..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,ppc64 - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go b/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go deleted file mode 100644 index 0eb2623..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,ppc64le - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go b/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go deleted file mode 100644 index 90fe99e..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +++ /dev/null @@ -1,150 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,s390x - -package ipv4 - -const ( - sysIP_TOS = 0x1 - sysIP_TTL = 0x2 - sysIP_HDRINCL = 0x3 - sysIP_OPTIONS = 0x4 - sysIP_ROUTER_ALERT = 0x5 - sysIP_RECVOPTS = 0x6 - sysIP_RETOPTS = 0x7 - sysIP_PKTINFO = 0x8 - sysIP_PKTOPTIONS = 0x9 - sysIP_MTU_DISCOVER = 0xa - sysIP_RECVERR = 0xb - sysIP_RECVTTL = 0xc - sysIP_RECVTOS = 0xd - sysIP_MTU = 0xe - sysIP_FREEBIND = 0xf - sysIP_TRANSPARENT = 0x13 - sysIP_RECVRETOPTS = 0x7 - sysIP_ORIGDSTADDR = 0x14 - sysIP_RECVORIGDSTADDR = 0x14 - sysIP_MINTTL = 0x15 - sysIP_NODEFRAG = 0x16 - sysIP_UNICAST_IF = 0x32 - - sysIP_MULTICAST_IF = 0x20 - sysIP_MULTICAST_TTL = 0x21 - sysIP_MULTICAST_LOOP = 0x22 - sysIP_ADD_MEMBERSHIP = 0x23 - sysIP_DROP_MEMBERSHIP = 0x24 - sysIP_UNBLOCK_SOURCE = 0x25 - sysIP_BLOCK_SOURCE = 0x26 - sysIP_ADD_SOURCE_MEMBERSHIP = 0x27 - sysIP_DROP_SOURCE_MEMBERSHIP = 0x28 - sysIP_MSFILTER = 0x29 - sysMCAST_JOIN_GROUP = 0x2a - sysMCAST_LEAVE_GROUP = 0x2d - sysMCAST_JOIN_SOURCE_GROUP = 0x2e - sysMCAST_LEAVE_SOURCE_GROUP = 0x2f - sysMCAST_BLOCK_SOURCE = 0x2b - sysMCAST_UNBLOCK_SOURCE = 0x2c - sysMCAST_MSFILTER = 0x30 - sysIP_MULTICAST_ALL = 0x31 - - sysICMP_FILTER = 0x1 - - sysSO_EE_ORIGIN_NONE = 0x0 - sysSO_EE_ORIGIN_LOCAL = 0x1 - sysSO_EE_ORIGIN_ICMP = 0x2 - sysSO_EE_ORIGIN_ICMP6 = 0x3 - sysSO_EE_ORIGIN_TXSTATUS = 0x4 - sysSO_EE_ORIGIN_TIMESTAMPING = 0x4 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet = 0x10 - sysSizeofInetPktinfo = 0xc - sysSizeofSockExtendedErr = 0x10 - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqn = 0xc - sysSizeofIPMreqSource = 0xc - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPFilter = 0x4 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet struct { - Family uint16 - Port uint16 - Addr [4]byte /* in_addr */ - X__pad [8]uint8 -} - -type sysInetPktinfo struct { - Ifindex int32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysSockExtendedErr struct { - Errno uint32 - Origin uint8 - Type uint8 - Code uint8 - Pad uint8 - Info uint32 - Data uint32 -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqn struct { - Multiaddr [4]byte /* in_addr */ - Address [4]byte /* in_addr */ - Ifindex int32 -} - -type sysIPMreqSource struct { - Multiaddr uint32 - Interface uint32 - Sourceaddr uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPFilter struct { - Data uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_netbsd.go b/vendor/golang.org/x/net/ipv4/zsys_netbsd.go deleted file mode 100644 index 8a440eb..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +++ /dev/null @@ -1,30 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x14 - sysIP_RECVTTL = 0x17 - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sysSizeofIPMreq = 0x8 -) - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_openbsd.go b/vendor/golang.org/x/net/ipv4/zsys_openbsd.go deleted file mode 100644 index fd522b5..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +++ /dev/null @@ -1,30 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package ipv4 - -const ( - sysIP_OPTIONS = 0x1 - sysIP_HDRINCL = 0x2 - sysIP_TOS = 0x3 - sysIP_TTL = 0x4 - sysIP_RECVOPTS = 0x5 - sysIP_RECVRETOPTS = 0x6 - sysIP_RECVDSTADDR = 0x7 - sysIP_RETOPTS = 0x8 - sysIP_RECVIF = 0x1e - sysIP_RECVTTL = 0x1f - - sysIP_MULTICAST_IF = 0x9 - sysIP_MULTICAST_TTL = 0xa - sysIP_MULTICAST_LOOP = 0xb - sysIP_ADD_MEMBERSHIP = 0xc - sysIP_DROP_MEMBERSHIP = 0xd - - sysSizeofIPMreq = 0x8 -) - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv4/zsys_solaris.go b/vendor/golang.org/x/net/ipv4/zsys_solaris.go deleted file mode 100644 index d7c2334..0000000 --- a/vendor/golang.org/x/net/ipv4/zsys_solaris.go +++ /dev/null @@ -1,60 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_solaris.go - -// +build solaris - -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_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_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 - - sysSizeofInetPktinfo = 0xc - - sysSizeofIPMreq = 0x8 - sysSizeofIPMreqSource = 0xc -) - -type sysInetPktinfo struct { - Ifindex uint32 - Spec_dst [4]byte /* in_addr */ - Addr [4]byte /* in_addr */ -} - -type sysIPMreq struct { - Multiaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} - -type sysIPMreqSource struct { - Multiaddr [4]byte /* in_addr */ - Sourceaddr [4]byte /* in_addr */ - Interface [4]byte /* in_addr */ -} diff --git a/vendor/golang.org/x/net/ipv6/bpf_test.go b/vendor/golang.org/x/net/ipv6/bpf_test.go deleted file mode 100644 index 03d478d..0000000 --- a/vendor/golang.org/x/net/ipv6/bpf_test.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "runtime" - "testing" - "time" - - "golang.org/x/net/bpf" - "golang.org/x/net/ipv6" -) - -func TestBPF(t *testing.T) { - if runtime.GOOS != "linux" { - t.Skipf("not supported on %s", runtime.GOOS) - } - - l, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - - p := ipv6.NewPacketConn(l) - - // This filter accepts UDP packets whose first payload byte is - // even. - prog, err := bpf.Assemble([]bpf.Instruction{ - // Load the first byte of the payload (skipping UDP header). - bpf.LoadAbsolute{Off: 8, Size: 1}, - // Select LSB of the byte. - bpf.ALUOpConstant{Op: bpf.ALUOpAnd, Val: 1}, - // Byte is even? - bpf.JumpIf{Cond: bpf.JumpEqual, Val: 0, SkipFalse: 1}, - // Accept. - bpf.RetConstant{Val: 4096}, - // Ignore. - bpf.RetConstant{Val: 0}, - }) - if err != nil { - t.Fatalf("compiling BPF: %s", err) - } - - if err = p.SetBPF(prog); err != nil { - t.Fatalf("attaching filter to Conn: %s", err) - } - - s, err := net.Dial("udp6", l.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - defer s.Close() - go func() { - for i := byte(0); i < 10; i++ { - s.Write([]byte{i}) - } - }() - - l.SetDeadline(time.Now().Add(2 * time.Second)) - seen := make([]bool, 5) - for { - var b [512]byte - n, _, err := l.ReadFrom(b[:]) - if err != nil { - t.Fatalf("reading from listener: %s", err) - } - if n != 1 { - t.Fatalf("unexpected packet length, want 1, got %d", n) - } - if b[0] >= 10 { - t.Fatalf("unexpected byte, want 0-9, got %d", b[0]) - } - if b[0]%2 != 0 { - t.Fatalf("got odd byte %d, wanted only even bytes", b[0]) - } - seen[b[0]/2] = true - - seenAll := true - for _, v := range seen { - if !v { - seenAll = false - break - } - } - if seenAll { - break - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/bpfopt_linux.go b/vendor/golang.org/x/net/ipv6/bpfopt_linux.go deleted file mode 100644 index 066ef20..0000000 --- a/vendor/golang.org/x/net/ipv6/bpfopt_linux.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "os" - "unsafe" - - "golang.org/x/net/bpf" -) - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - fd, err := c.sysfd() - if err != nil { - return err - } - prog := sysSockFProg{ - Len: uint16(len(filter)), - Filter: (*sysSockFilter)(unsafe.Pointer(&filter[0])), - } - return os.NewSyscallError("setsockopt", setsockopt(fd, sysSOL_SOCKET, sysSO_ATTACH_FILTER, unsafe.Pointer(&prog), uint32(unsafe.Sizeof(prog)))) -} diff --git a/vendor/golang.org/x/net/ipv6/bpfopt_stub.go b/vendor/golang.org/x/net/ipv6/bpfopt_stub.go deleted file mode 100644 index 2e4de5f..0000000 --- a/vendor/golang.org/x/net/ipv6/bpfopt_stub.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !linux - -package ipv6 - -import "golang.org/x/net/bpf" - -// SetBPF attaches a BPF program to the connection. -// -// Only supported on Linux. -func (c *dgramOpt) SetBPF(filter []bpf.RawInstruction) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/control.go b/vendor/golang.org/x/net/ipv6/control.go deleted file mode 100644 index b7362aa..0000000 --- a/vendor/golang.org/x/net/ipv6/control.go +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "fmt" - "net" - "sync" -) - -// Note that RFC 3542 obsoletes RFC 2292 but OS X Snow Leopard and the -// former still support RFC 2292 only. Please be aware that almost -// all protocol implementations prohibit using a combination of RFC -// 2292 and RFC 3542 for some practical reasons. - -type rawOpt struct { - sync.RWMutex - cflags ControlFlags -} - -func (c *rawOpt) set(f ControlFlags) { c.cflags |= f } -func (c *rawOpt) clear(f ControlFlags) { c.cflags &^= f } -func (c *rawOpt) isset(f ControlFlags) bool { return c.cflags&f != 0 } - -// A ControlFlags represents per packet basis IP-level socket option -// control flags. -type ControlFlags uint - -const ( - FlagTrafficClass ControlFlags = 1 << iota // pass the traffic class on the received packet - FlagHopLimit // pass the hop limit on the received packet - FlagSrc // pass the source address on the received packet - FlagDst // pass the destination address on the received packet - FlagInterface // pass the interface index on the received packet - FlagPathMTU // pass the path MTU on the received packet path -) - -const flagPacketInfo = FlagDst | FlagInterface - -// A ControlMessage represents per packet basis IP-level socket -// options. -type ControlMessage struct { - // Receiving socket options: SetControlMessage allows to - // receive the options from the protocol stack using ReadFrom - // method of PacketConn. - // - // Specifying socket options: ControlMessage for WriteTo - // method of PacketConn allows to send the options to the - // protocol stack. - // - TrafficClass int // traffic class, must be 1 <= value <= 255 when specifying - HopLimit int // hop limit, must be 1 <= value <= 255 when specifying - Src net.IP // source address, specifying only - Dst net.IP // destination address, receiving only - IfIndex int // interface index, must be 1 <= value when specifying - NextHop net.IP // next hop address, specifying only - MTU int // path MTU, receiving only -} - -func (cm *ControlMessage) String() string { - if cm == nil { - return "" - } - return fmt.Sprintf("tclass=%#x hoplim=%d src=%v dst=%v ifindex=%d nexthop=%v mtu=%d", cm.TrafficClass, cm.HopLimit, cm.Src, cm.Dst, cm.IfIndex, cm.NextHop, cm.MTU) -} - -// Ancillary data socket options -const ( - ctlTrafficClass = iota // header field - ctlHopLimit // header field - ctlPacketInfo // inbound or outbound packet path - ctlNextHop // nexthop - ctlPathMTU // path mtu - ctlMax -) - -// A ctlOpt represents a binding for ancillary data socket option. -type ctlOpt struct { - name int // option name, must be equal or greater than 1 - length int // option length - marshal func([]byte, *ControlMessage) []byte - parse func(*ControlMessage, []byte) -} diff --git a/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go b/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go deleted file mode 100644 index 80ec2e2..0000000 --- a/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin - -package ipv6 - -import ( - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshal2292HopLimit(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_2292HOPLIMIT - m.SetLen(syscall.CmsgLen(4)) - if cm != nil { - data := b[syscall.CmsgLen(0):] - nativeEndian.PutUint32(data[:4], uint32(cm.HopLimit)) - } - return b[syscall.CmsgSpace(4):] -} - -func marshal2292PacketInfo(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_2292PKTINFO - m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo)) - if cm != nil { - pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - if ip := cm.Src.To16(); ip != nil && ip.To4() == nil { - copy(pi.Addr[:], ip) - } - if cm.IfIndex > 0 { - pi.setIfindex(cm.IfIndex) - } - } - return b[syscall.CmsgSpace(sysSizeofInet6Pktinfo):] -} - -func marshal2292NextHop(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_2292NEXTHOP - m.SetLen(syscall.CmsgLen(sysSizeofSockaddrInet6)) - if cm != nil { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - sa.setSockaddr(cm.NextHop, cm.IfIndex) - } - return b[syscall.CmsgSpace(sysSizeofSockaddrInet6):] -} diff --git a/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go b/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go deleted file mode 100644 index f344d16..0000000 --- a/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv6 - -import ( - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -func marshalTrafficClass(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_TCLASS - m.SetLen(syscall.CmsgLen(4)) - if cm != nil { - data := b[syscall.CmsgLen(0):] - nativeEndian.PutUint32(data[:4], uint32(cm.TrafficClass)) - } - return b[syscall.CmsgSpace(4):] -} - -func parseTrafficClass(cm *ControlMessage, b []byte) { - cm.TrafficClass = int(nativeEndian.Uint32(b[:4])) -} - -func marshalHopLimit(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_HOPLIMIT - m.SetLen(syscall.CmsgLen(4)) - if cm != nil { - data := b[syscall.CmsgLen(0):] - nativeEndian.PutUint32(data[:4], uint32(cm.HopLimit)) - } - return b[syscall.CmsgSpace(4):] -} - -func parseHopLimit(cm *ControlMessage, b []byte) { - cm.HopLimit = int(nativeEndian.Uint32(b[:4])) -} - -func marshalPacketInfo(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_PKTINFO - m.SetLen(syscall.CmsgLen(sysSizeofInet6Pktinfo)) - if cm != nil { - pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - if ip := cm.Src.To16(); ip != nil && ip.To4() == nil { - copy(pi.Addr[:], ip) - } - if cm.IfIndex > 0 { - pi.setIfindex(cm.IfIndex) - } - } - return b[syscall.CmsgSpace(sysSizeofInet6Pktinfo):] -} - -func parsePacketInfo(cm *ControlMessage, b []byte) { - pi := (*sysInet6Pktinfo)(unsafe.Pointer(&b[0])) - cm.Dst = pi.Addr[:] - cm.IfIndex = int(pi.Ifindex) -} - -func marshalNextHop(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_NEXTHOP - m.SetLen(syscall.CmsgLen(sysSizeofSockaddrInet6)) - if cm != nil { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&b[syscall.CmsgLen(0)])) - sa.setSockaddr(cm.NextHop, cm.IfIndex) - } - return b[syscall.CmsgSpace(sysSizeofSockaddrInet6):] -} - -func parseNextHop(cm *ControlMessage, b []byte) { -} - -func marshalPathMTU(b []byte, cm *ControlMessage) []byte { - m := (*syscall.Cmsghdr)(unsafe.Pointer(&b[0])) - m.Level = iana.ProtocolIPv6 - m.Type = sysIPV6_PATHMTU - m.SetLen(syscall.CmsgLen(sysSizeofIPv6Mtuinfo)) - return b[syscall.CmsgSpace(sysSizeofIPv6Mtuinfo):] -} - -func parsePathMTU(cm *ControlMessage, b []byte) { - mi := (*sysIPv6Mtuinfo)(unsafe.Pointer(&b[0])) - cm.Dst = mi.Addr.Addr[:] - cm.IfIndex = int(mi.Addr.Scope_id) - cm.MTU = int(mi.Mtu) -} diff --git a/vendor/golang.org/x/net/ipv6/control_stub.go b/vendor/golang.org/x/net/ipv6/control_stub.go deleted file mode 100644 index 2fecf7e..0000000 --- a/vendor/golang.org/x/net/ipv6/control_stub.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv6 - -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error { - return errOpNoSupport -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - return nil, errOpNoSupport -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/control_unix.go b/vendor/golang.org/x/net/ipv6/control_unix.go deleted file mode 100644 index 2af5beb..0000000 --- a/vendor/golang.org/x/net/ipv6/control_unix.go +++ /dev/null @@ -1,166 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv6 - -import ( - "os" - "syscall" - - "golang.org/x/net/internal/iana" -) - -func setControlMessage(fd int, opt *rawOpt, cf ControlFlags, on bool) error { - opt.Lock() - defer opt.Unlock() - if cf&FlagTrafficClass != 0 && sockOpts[ssoReceiveTrafficClass].name > 0 { - if err := setInt(fd, &sockOpts[ssoReceiveTrafficClass], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagTrafficClass) - } else { - opt.clear(FlagTrafficClass) - } - } - if cf&FlagHopLimit != 0 && sockOpts[ssoReceiveHopLimit].name > 0 { - if err := setInt(fd, &sockOpts[ssoReceiveHopLimit], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagHopLimit) - } else { - opt.clear(FlagHopLimit) - } - } - if cf&flagPacketInfo != 0 && sockOpts[ssoReceivePacketInfo].name > 0 { - if err := setInt(fd, &sockOpts[ssoReceivePacketInfo], boolint(on)); err != nil { - return err - } - if on { - opt.set(cf & flagPacketInfo) - } else { - opt.clear(cf & flagPacketInfo) - } - } - if cf&FlagPathMTU != 0 && sockOpts[ssoReceivePathMTU].name > 0 { - if err := setInt(fd, &sockOpts[ssoReceivePathMTU], boolint(on)); err != nil { - return err - } - if on { - opt.set(FlagPathMTU) - } else { - opt.clear(FlagPathMTU) - } - } - return nil -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - opt.RLock() - var l int - if opt.isset(FlagTrafficClass) && ctlOpts[ctlTrafficClass].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlTrafficClass].length) - } - if opt.isset(FlagHopLimit) && ctlOpts[ctlHopLimit].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlHopLimit].length) - } - if opt.isset(flagPacketInfo) && ctlOpts[ctlPacketInfo].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - if opt.isset(FlagPathMTU) && ctlOpts[ctlPathMTU].name > 0 { - l += syscall.CmsgSpace(ctlOpts[ctlPathMTU].length) - } - if l > 0 { - oob = make([]byte, l) - b := oob - if opt.isset(FlagTrafficClass) && ctlOpts[ctlTrafficClass].name > 0 { - b = ctlOpts[ctlTrafficClass].marshal(b, nil) - } - if opt.isset(FlagHopLimit) && ctlOpts[ctlHopLimit].name > 0 { - b = ctlOpts[ctlHopLimit].marshal(b, nil) - } - if opt.isset(flagPacketInfo) && ctlOpts[ctlPacketInfo].name > 0 { - b = ctlOpts[ctlPacketInfo].marshal(b, nil) - } - if opt.isset(FlagPathMTU) && ctlOpts[ctlPathMTU].name > 0 { - b = ctlOpts[ctlPathMTU].marshal(b, nil) - } - } - opt.RUnlock() - return -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - if len(b) == 0 { - return nil, nil - } - cmsgs, err := syscall.ParseSocketControlMessage(b) - if err != nil { - return nil, os.NewSyscallError("parse socket control message", err) - } - cm := &ControlMessage{} - for _, m := range cmsgs { - if m.Header.Level != iana.ProtocolIPv6 { - continue - } - switch int(m.Header.Type) { - case ctlOpts[ctlTrafficClass].name: - ctlOpts[ctlTrafficClass].parse(cm, m.Data[:]) - case ctlOpts[ctlHopLimit].name: - ctlOpts[ctlHopLimit].parse(cm, m.Data[:]) - case ctlOpts[ctlPacketInfo].name: - ctlOpts[ctlPacketInfo].parse(cm, m.Data[:]) - case ctlOpts[ctlPathMTU].name: - ctlOpts[ctlPathMTU].parse(cm, m.Data[:]) - } - } - return cm, nil -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - if cm == nil { - return - } - var l int - tclass := false - if ctlOpts[ctlTrafficClass].name > 0 && cm.TrafficClass > 0 { - tclass = true - l += syscall.CmsgSpace(ctlOpts[ctlTrafficClass].length) - } - hoplimit := false - if ctlOpts[ctlHopLimit].name > 0 && cm.HopLimit > 0 { - hoplimit = true - l += syscall.CmsgSpace(ctlOpts[ctlHopLimit].length) - } - pktinfo := false - if ctlOpts[ctlPacketInfo].name > 0 && (cm.Src.To16() != nil && cm.Src.To4() == nil || cm.IfIndex > 0) { - pktinfo = true - l += syscall.CmsgSpace(ctlOpts[ctlPacketInfo].length) - } - nexthop := false - if ctlOpts[ctlNextHop].name > 0 && cm.NextHop.To16() != nil && cm.NextHop.To4() == nil { - nexthop = true - l += syscall.CmsgSpace(ctlOpts[ctlNextHop].length) - } - if l > 0 { - oob = make([]byte, l) - b := oob - if tclass { - b = ctlOpts[ctlTrafficClass].marshal(b, cm) - } - if hoplimit { - b = ctlOpts[ctlHopLimit].marshal(b, cm) - } - if pktinfo { - b = ctlOpts[ctlPacketInfo].marshal(b, cm) - } - if nexthop { - b = ctlOpts[ctlNextHop].marshal(b, cm) - } - } - return -} diff --git a/vendor/golang.org/x/net/ipv6/control_windows.go b/vendor/golang.org/x/net/ipv6/control_windows.go deleted file mode 100644 index 72fdc1b..0000000 --- a/vendor/golang.org/x/net/ipv6/control_windows.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import "syscall" - -func setControlMessage(fd syscall.Handle, opt *rawOpt, cf ControlFlags, on bool) error { - // TODO(mikio): implement this - return syscall.EWINDOWS -} - -func newControlMessage(opt *rawOpt) (oob []byte) { - // TODO(mikio): implement this - return nil -} - -func parseControlMessage(b []byte) (*ControlMessage, error) { - // TODO(mikio): implement this - return nil, syscall.EWINDOWS -} - -func marshalControlMessage(cm *ControlMessage) (oob []byte) { - // TODO(mikio): implement this - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/defs_darwin.go b/vendor/golang.org/x/net/ipv6/defs_darwin.go deleted file mode 100644 index 4c7f476..0000000 --- a/vendor/golang.org/x/net/ipv6/defs_darwin.go +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#define __APPLE_USE_RFC_3542 -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - sysIPV6_2292PKTINFO = C.IPV6_2292PKTINFO - sysIPV6_2292HOPLIMIT = C.IPV6_2292HOPLIMIT - sysIPV6_2292NEXTHOP = C.IPV6_2292NEXTHOP - sysIPV6_2292HOPOPTS = C.IPV6_2292HOPOPTS - sysIPV6_2292DSTOPTS = C.IPV6_2292DSTOPTS - sysIPV6_2292RTHDR = C.IPV6_2292RTHDR - - sysIPV6_2292PKTOPTIONS = C.IPV6_2292PKTOPTIONS - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - sysIPV6_TCLASS = C.IPV6_TCLASS - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR - - sysIPV6_MSFILTER = C.IPV6_MSFILTER - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sysIPV6_BOUND_IF = C.IPV6_BOUND_IF - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - sysSizeofGroupReq = C.sizeof_struct_group_req - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sysSockaddrStorage C.struct_sockaddr_storage - -type sysSockaddrInet6 C.struct_sockaddr_in6 - -type sysInet6Pktinfo C.struct_in6_pktinfo - -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo - -type sysIPv6Mreq C.struct_ipv6_mreq - -type sysICMPv6Filter C.struct_icmp6_filter - -type sysGroupReq C.struct_group_req - -type sysGroupSourceReq C.struct_group_source_req diff --git a/vendor/golang.org/x/net/ipv6/defs_dragonfly.go b/vendor/golang.org/x/net/ipv6/defs_dragonfly.go deleted file mode 100644 index c72487c..0000000 --- a/vendor/golang.org/x/net/ipv6/defs_dragonfly.go +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sysSockaddrInet6 C.struct_sockaddr_in6 - -type sysInet6Pktinfo C.struct_in6_pktinfo - -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo - -type sysIPv6Mreq C.struct_ipv6_mreq - -type sysICMPv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_freebsd.go b/vendor/golang.org/x/net/ipv6/defs_freebsd.go deleted file mode 100644 index de199ec..0000000 --- a/vendor/golang.org/x/net/ipv6/defs_freebsd.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PREFER_TEMPADDR = C.IPV6_PREFER_TEMPADDR - - sysIPV6_BINDANY = C.IPV6_BINDANY - - sysIPV6_MSFILTER = C.IPV6_MSFILTER - - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sysSizeofSockaddrStorage = C.sizeof_struct_sockaddr_storage - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - sysSizeofGroupReq = C.sizeof_struct_group_req - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sysSockaddrStorage C.struct_sockaddr_storage - -type sysSockaddrInet6 C.struct_sockaddr_in6 - -type sysInet6Pktinfo C.struct_in6_pktinfo - -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo - -type sysIPv6Mreq C.struct_ipv6_mreq - -type sysGroupReq C.struct_group_req - -type sysGroupSourceReq C.struct_group_source_req - -type sysICMPv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_linux.go b/vendor/golang.org/x/net/ipv6/defs_linux.go deleted file mode 100644 index 664305d..0000000 --- a/vendor/golang.org/x/net/ipv6/defs_linux.go +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include -#include -#include -#include -#include -*/ -import "C" - -const ( - sysIPV6_ADDRFORM = C.IPV6_ADDRFORM - sysIPV6_2292PKTINFO = C.IPV6_2292PKTINFO - sysIPV6_2292HOPOPTS = C.IPV6_2292HOPOPTS - sysIPV6_2292DSTOPTS = C.IPV6_2292DSTOPTS - sysIPV6_2292RTHDR = C.IPV6_2292RTHDR - sysIPV6_2292PKTOPTIONS = C.IPV6_2292PKTOPTIONS - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_2292HOPLIMIT = C.IPV6_2292HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_FLOWINFO = C.IPV6_FLOWINFO - - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_ADD_MEMBERSHIP = C.IPV6_ADD_MEMBERSHIP - sysIPV6_DROP_MEMBERSHIP = C.IPV6_DROP_MEMBERSHIP - sysMCAST_JOIN_GROUP = C.MCAST_JOIN_GROUP - sysMCAST_LEAVE_GROUP = C.MCAST_LEAVE_GROUP - sysMCAST_JOIN_SOURCE_GROUP = C.MCAST_JOIN_SOURCE_GROUP - sysMCAST_LEAVE_SOURCE_GROUP = C.MCAST_LEAVE_SOURCE_GROUP - sysMCAST_BLOCK_SOURCE = C.MCAST_BLOCK_SOURCE - sysMCAST_UNBLOCK_SOURCE = C.MCAST_UNBLOCK_SOURCE - sysMCAST_MSFILTER = C.MCAST_MSFILTER - sysIPV6_ROUTER_ALERT = C.IPV6_ROUTER_ALERT - sysIPV6_MTU_DISCOVER = C.IPV6_MTU_DISCOVER - sysIPV6_MTU = C.IPV6_MTU - sysIPV6_RECVERR = C.IPV6_RECVERR - sysIPV6_V6ONLY = C.IPV6_V6ONLY - sysIPV6_JOIN_ANYCAST = C.IPV6_JOIN_ANYCAST - sysIPV6_LEAVE_ANYCAST = C.IPV6_LEAVE_ANYCAST - - //sysIPV6_PMTUDISC_DONT = C.IPV6_PMTUDISC_DONT - //sysIPV6_PMTUDISC_WANT = C.IPV6_PMTUDISC_WANT - //sysIPV6_PMTUDISC_DO = C.IPV6_PMTUDISC_DO - //sysIPV6_PMTUDISC_PROBE = C.IPV6_PMTUDISC_PROBE - //sysIPV6_PMTUDISC_INTERFACE = C.IPV6_PMTUDISC_INTERFACE - //sysIPV6_PMTUDISC_OMIT = C.IPV6_PMTUDISC_OMIT - - sysIPV6_FLOWLABEL_MGR = C.IPV6_FLOWLABEL_MGR - sysIPV6_FLOWINFO_SEND = C.IPV6_FLOWINFO_SEND - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - sysIPV6_XFRM_POLICY = C.IPV6_XFRM_POLICY - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RTHDR = C.IPV6_RTHDR - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - sysIPV6_PATHMTU = C.IPV6_PATHMTU - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - sysIPV6_TCLASS = C.IPV6_TCLASS - - sysIPV6_ADDR_PREFERENCES = C.IPV6_ADDR_PREFERENCES - - sysIPV6_PREFER_SRC_TMP = C.IPV6_PREFER_SRC_TMP - sysIPV6_PREFER_SRC_PUBLIC = C.IPV6_PREFER_SRC_PUBLIC - sysIPV6_PREFER_SRC_PUBTMP_DEFAULT = C.IPV6_PREFER_SRC_PUBTMP_DEFAULT - sysIPV6_PREFER_SRC_COA = C.IPV6_PREFER_SRC_COA - sysIPV6_PREFER_SRC_HOME = C.IPV6_PREFER_SRC_HOME - sysIPV6_PREFER_SRC_CGA = C.IPV6_PREFER_SRC_CGA - sysIPV6_PREFER_SRC_NONCGA = C.IPV6_PREFER_SRC_NONCGA - - sysIPV6_MINHOPCOUNT = C.IPV6_MINHOPCOUNT - - sysIPV6_ORIGDSTADDR = C.IPV6_ORIGDSTADDR - sysIPV6_RECVORIGDSTADDR = C.IPV6_RECVORIGDSTADDR - sysIPV6_TRANSPARENT = C.IPV6_TRANSPARENT - sysIPV6_UNICAST_IF = C.IPV6_UNICAST_IF - - sysICMPV6_FILTER = C.ICMPV6_FILTER - - sysICMPV6_FILTER_BLOCK = C.ICMPV6_FILTER_BLOCK - sysICMPV6_FILTER_PASS = C.ICMPV6_FILTER_PASS - sysICMPV6_FILTER_BLOCKOTHERS = C.ICMPV6_FILTER_BLOCKOTHERS - sysICMPV6_FILTER_PASSONLY = C.ICMPV6_FILTER_PASSONLY - - sysSOL_SOCKET = C.SOL_SOCKET - sysSO_ATTACH_FILTER = C.SO_ATTACH_FILTER - - sysSizeofKernelSockaddrStorage = C.sizeof_struct___kernel_sockaddr_storage - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - sysSizeofIPv6FlowlabelReq = C.sizeof_struct_in6_flowlabel_req - - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - sysSizeofGroupReq = C.sizeof_struct_group_req - sysSizeofGroupSourceReq = C.sizeof_struct_group_source_req - - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sysKernelSockaddrStorage C.struct___kernel_sockaddr_storage - -type sysSockaddrInet6 C.struct_sockaddr_in6 - -type sysInet6Pktinfo C.struct_in6_pktinfo - -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo - -type sysIPv6FlowlabelReq C.struct_in6_flowlabel_req - -type sysIPv6Mreq C.struct_ipv6_mreq - -type sysGroupReq C.struct_group_req - -type sysGroupSourceReq C.struct_group_source_req - -type sysICMPv6Filter C.struct_icmp6_filter - -type sysSockFProg C.struct_sock_fprog - -type sysSockFilter C.struct_sock_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_netbsd.go b/vendor/golang.org/x/net/ipv6/defs_netbsd.go deleted file mode 100644 index 7bd09e8..0000000 --- a/vendor/golang.org/x/net/ipv6/defs_netbsd.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_IPSEC_POLICY = C.IPV6_IPSEC_POLICY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sysSockaddrInet6 C.struct_sockaddr_in6 - -type sysInet6Pktinfo C.struct_in6_pktinfo - -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo - -type sysIPv6Mreq C.struct_ipv6_mreq - -type sysICMPv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_openbsd.go b/vendor/golang.org/x/net/ipv6/defs_openbsd.go deleted file mode 100644 index 6796d9b..0000000 --- a/vendor/golang.org/x/net/ipv6/defs_openbsd.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include - -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - sysIPV6_PORTRANGE = C.IPV6_PORTRANGE - sysICMP6_FILTER = C.ICMP6_FILTER - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - - sysIPV6_PATHMTU = C.IPV6_PATHMTU - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - sysIPV6_RTHDR = C.IPV6_RTHDR - - sysIPV6_AUTH_LEVEL = C.IPV6_AUTH_LEVEL - sysIPV6_ESP_TRANS_LEVEL = C.IPV6_ESP_TRANS_LEVEL - sysIPV6_ESP_NETWORK_LEVEL = C.IPV6_ESP_NETWORK_LEVEL - sysIPSEC6_OUTSA = C.IPSEC6_OUTSA - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - - sysIPV6_AUTOFLOWLABEL = C.IPV6_AUTOFLOWLABEL - sysIPV6_IPCOMP_LEVEL = C.IPV6_IPCOMP_LEVEL - - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - sysIPV6_PIPEX = C.IPV6_PIPEX - - sysIPV6_RTABLE = C.IPV6_RTABLE - - sysIPV6_PORTRANGE_DEFAULT = C.IPV6_PORTRANGE_DEFAULT - sysIPV6_PORTRANGE_HIGH = C.IPV6_PORTRANGE_HIGH - sysIPV6_PORTRANGE_LOW = C.IPV6_PORTRANGE_LOW - - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sysSockaddrInet6 C.struct_sockaddr_in6 - -type sysInet6Pktinfo C.struct_in6_pktinfo - -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo - -type sysIPv6Mreq C.struct_ipv6_mreq - -type sysICMPv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/defs_solaris.go b/vendor/golang.org/x/net/ipv6/defs_solaris.go deleted file mode 100644 index 972b171..0000000 --- a/vendor/golang.org/x/net/ipv6/defs_solaris.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -// +godefs map struct_in6_addr [16]byte /* in6_addr */ - -package ipv6 - -/* -#include -#include -*/ -import "C" - -const ( - sysIPV6_UNICAST_HOPS = C.IPV6_UNICAST_HOPS - sysIPV6_MULTICAST_IF = C.IPV6_MULTICAST_IF - sysIPV6_MULTICAST_HOPS = C.IPV6_MULTICAST_HOPS - sysIPV6_MULTICAST_LOOP = C.IPV6_MULTICAST_LOOP - sysIPV6_JOIN_GROUP = C.IPV6_JOIN_GROUP - sysIPV6_LEAVE_GROUP = C.IPV6_LEAVE_GROUP - - sysIPV6_PKTINFO = C.IPV6_PKTINFO - - sysIPV6_HOPLIMIT = C.IPV6_HOPLIMIT - sysIPV6_NEXTHOP = C.IPV6_NEXTHOP - sysIPV6_HOPOPTS = C.IPV6_HOPOPTS - sysIPV6_DSTOPTS = C.IPV6_DSTOPTS - - sysIPV6_RTHDR = C.IPV6_RTHDR - sysIPV6_RTHDRDSTOPTS = C.IPV6_RTHDRDSTOPTS - - sysIPV6_RECVPKTINFO = C.IPV6_RECVPKTINFO - sysIPV6_RECVHOPLIMIT = C.IPV6_RECVHOPLIMIT - sysIPV6_RECVHOPOPTS = C.IPV6_RECVHOPOPTS - - sysIPV6_RECVRTHDR = C.IPV6_RECVRTHDR - - sysIPV6_RECVRTHDRDSTOPTS = C.IPV6_RECVRTHDRDSTOPTS - - sysIPV6_CHECKSUM = C.IPV6_CHECKSUM - sysIPV6_RECVTCLASS = C.IPV6_RECVTCLASS - sysIPV6_USE_MIN_MTU = C.IPV6_USE_MIN_MTU - sysIPV6_DONTFRAG = C.IPV6_DONTFRAG - sysIPV6_SEC_OPT = C.IPV6_SEC_OPT - sysIPV6_SRC_PREFERENCES = C.IPV6_SRC_PREFERENCES - sysIPV6_RECVPATHMTU = C.IPV6_RECVPATHMTU - sysIPV6_PATHMTU = C.IPV6_PATHMTU - sysIPV6_TCLASS = C.IPV6_TCLASS - sysIPV6_V6ONLY = C.IPV6_V6ONLY - - sysIPV6_RECVDSTOPTS = C.IPV6_RECVDSTOPTS - - sysIPV6_PREFER_SRC_HOME = C.IPV6_PREFER_SRC_HOME - sysIPV6_PREFER_SRC_COA = C.IPV6_PREFER_SRC_COA - sysIPV6_PREFER_SRC_PUBLIC = C.IPV6_PREFER_SRC_PUBLIC - sysIPV6_PREFER_SRC_TMP = C.IPV6_PREFER_SRC_TMP - sysIPV6_PREFER_SRC_NONCGA = C.IPV6_PREFER_SRC_NONCGA - sysIPV6_PREFER_SRC_CGA = C.IPV6_PREFER_SRC_CGA - - sysIPV6_PREFER_SRC_MIPMASK = C.IPV6_PREFER_SRC_MIPMASK - sysIPV6_PREFER_SRC_MIPDEFAULT = C.IPV6_PREFER_SRC_MIPDEFAULT - sysIPV6_PREFER_SRC_TMPMASK = C.IPV6_PREFER_SRC_TMPMASK - sysIPV6_PREFER_SRC_TMPDEFAULT = C.IPV6_PREFER_SRC_TMPDEFAULT - sysIPV6_PREFER_SRC_CGAMASK = C.IPV6_PREFER_SRC_CGAMASK - sysIPV6_PREFER_SRC_CGADEFAULT = C.IPV6_PREFER_SRC_CGADEFAULT - - sysIPV6_PREFER_SRC_MASK = C.IPV6_PREFER_SRC_MASK - - sysIPV6_PREFER_SRC_DEFAULT = C.IPV6_PREFER_SRC_DEFAULT - - sysIPV6_BOUND_IF = C.IPV6_BOUND_IF - sysIPV6_UNSPEC_SRC = C.IPV6_UNSPEC_SRC - - sysICMP6_FILTER = C.ICMP6_FILTER - - sysSizeofSockaddrInet6 = C.sizeof_struct_sockaddr_in6 - sysSizeofInet6Pktinfo = C.sizeof_struct_in6_pktinfo - sysSizeofIPv6Mtuinfo = C.sizeof_struct_ip6_mtuinfo - - sysSizeofIPv6Mreq = C.sizeof_struct_ipv6_mreq - - sysSizeofICMPv6Filter = C.sizeof_struct_icmp6_filter -) - -type sysSockaddrInet6 C.struct_sockaddr_in6 - -type sysInet6Pktinfo C.struct_in6_pktinfo - -type sysIPv6Mtuinfo C.struct_ip6_mtuinfo - -type sysIPv6Mreq C.struct_ipv6_mreq - -type sysICMPv6Filter C.struct_icmp6_filter diff --git a/vendor/golang.org/x/net/ipv6/dgramopt_posix.go b/vendor/golang.org/x/net/ipv6/dgramopt_posix.go deleted file mode 100644 index 93ff2f1..0000000 --- a/vendor/golang.org/x/net/ipv6/dgramopt_posix.go +++ /dev/null @@ -1,288 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd windows - -package ipv6 - -import ( - "net" - "syscall" -) - -// MulticastHopLimit returns the hop limit field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastHopLimit() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return 0, err - } - return getInt(fd, &sockOpts[ssoMulticastHopLimit]) -} - -// SetMulticastHopLimit sets the hop limit field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastHopLimit(hoplim int) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoMulticastHopLimit], hoplim) -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return nil, err - } - return getInterface(fd, &sockOpts[ssoMulticastInterface]) -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInterface(fd, &sockOpts[ssoMulticastInterface], ifi) -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - if !c.ok() { - return false, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return false, err - } - on, err := getInt(fd, &sockOpts[ssoMulticastLoopback]) - if err != nil { - return false, err - } - return on == 1, nil -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoMulticastLoopback], boolint(on)) -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - return setGroup(fd, &sockOpts[ssoJoinGroup], ifi, grp) -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - return setGroup(fd, &sockOpts[ssoLeaveGroup], ifi, grp) -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoJoinSourceGroup], ifi, grp, src) -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoLeaveSourceGroup], ifi, grp, src) -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoBlockSourceGroup], ifi, grp, src) -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - grp := netAddrToIP16(group) - if grp == nil { - return errMissingAddress - } - src := netAddrToIP16(source) - if src == nil { - return errMissingAddress - } - return setSourceGroup(fd, &sockOpts[ssoUnblockSourceGroup], ifi, grp, src) -} - -// Checksum reports whether the kernel will compute, store or verify a -// checksum for both incoming and outgoing packets. If on is true, it -// returns an offset in bytes into the data of where the checksum -// field is located. -func (c *dgramOpt) Checksum() (on bool, offset int, err error) { - if !c.ok() { - return false, 0, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return false, 0, err - } - offset, err = getInt(fd, &sockOpts[ssoChecksum]) - if err != nil { - return false, 0, err - } - if offset < 0 { - return false, 0, nil - } - return true, offset, nil -} - -// SetChecksum enables the kernel checksum processing. If on is ture, -// the offset should be an offset in bytes into the data of where the -// checksum field is located. -func (c *dgramOpt) SetChecksum(on bool, offset int) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - if !on { - offset = -1 - } - return setInt(fd, &sockOpts[ssoChecksum], offset) -} - -// ICMPFilter returns an ICMP filter. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - if !c.ok() { - return nil, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return nil, err - } - return getICMPFilter(fd, &sockOpts[ssoICMPFilter]) -} - -// SetICMPFilter deploys the ICMP filter. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setICMPFilter(fd, &sockOpts[ssoICMPFilter], f) -} diff --git a/vendor/golang.org/x/net/ipv6/dgramopt_stub.go b/vendor/golang.org/x/net/ipv6/dgramopt_stub.go deleted file mode 100644 index fb067fb..0000000 --- a/vendor/golang.org/x/net/ipv6/dgramopt_stub.go +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv6 - -import "net" - -// MulticastHopLimit returns the hop limit field value for outgoing -// multicast packets. -func (c *dgramOpt) MulticastHopLimit() (int, error) { - return 0, errOpNoSupport -} - -// SetMulticastHopLimit sets the hop limit field value for future -// outgoing multicast packets. -func (c *dgramOpt) SetMulticastHopLimit(hoplim int) error { - return errOpNoSupport -} - -// MulticastInterface returns the default interface for multicast -// packet transmissions. -func (c *dgramOpt) MulticastInterface() (*net.Interface, error) { - return nil, errOpNoSupport -} - -// SetMulticastInterface sets the default interface for future -// multicast packet transmissions. -func (c *dgramOpt) SetMulticastInterface(ifi *net.Interface) error { - return errOpNoSupport -} - -// MulticastLoopback reports whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) MulticastLoopback() (bool, error) { - return false, errOpNoSupport -} - -// SetMulticastLoopback sets whether transmitted multicast packets -// should be copied and send back to the originator. -func (c *dgramOpt) SetMulticastLoopback(on bool) error { - return errOpNoSupport -} - -// JoinGroup joins the group address group on the interface ifi. -// By default all sources that can cast data to group are accepted. -// It's possible to mute and unmute data transmission from a specific -// source by using ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup. -// JoinGroup uses the system assigned multicast interface when ifi is -// nil, although this is not recommended because the assignment -// depends on platforms and sometimes it might require routing -// configuration. -func (c *dgramOpt) JoinGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// LeaveGroup leaves the group address group on the interface ifi -// regardless of whether the group is any-source group or -// source-specific group. -func (c *dgramOpt) LeaveGroup(ifi *net.Interface, group net.Addr) error { - return errOpNoSupport -} - -// JoinSourceSpecificGroup joins the source-specific group comprising -// group and source on the interface ifi. -// JoinSourceSpecificGroup uses the system assigned multicast -// interface when ifi is nil, although this is not recommended because -// the assignment depends on platforms and sometimes it might require -// routing configuration. -func (c *dgramOpt) JoinSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// LeaveSourceSpecificGroup leaves the source-specific group on the -// interface ifi. -func (c *dgramOpt) LeaveSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// ExcludeSourceSpecificGroup excludes the source-specific group from -// the already joined any-source groups by JoinGroup on the interface -// ifi. -func (c *dgramOpt) ExcludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// IncludeSourceSpecificGroup includes the excluded source-specific -// group by ExcludeSourceSpecificGroup again on the interface ifi. -func (c *dgramOpt) IncludeSourceSpecificGroup(ifi *net.Interface, group, source net.Addr) error { - return errOpNoSupport -} - -// Checksum reports whether the kernel will compute, store or verify a -// checksum for both incoming and outgoing packets. If on is true, it -// returns an offset in bytes into the data of where the checksum -// field is located. -func (c *dgramOpt) Checksum() (on bool, offset int, err error) { - return false, 0, errOpNoSupport -} - -// SetChecksum enables the kernel checksum processing. If on is ture, -// the offset should be an offset in bytes into the data of where the -// checksum field is located. -func (c *dgramOpt) SetChecksum(on bool, offset int) error { - return errOpNoSupport -} - -// ICMPFilter returns an ICMP filter. -func (c *dgramOpt) ICMPFilter() (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -// SetICMPFilter deploys the ICMP filter. -func (c *dgramOpt) SetICMPFilter(f *ICMPFilter) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/doc.go b/vendor/golang.org/x/net/ipv6/doc.go deleted file mode 100644 index dd13aa2..0000000 --- a/vendor/golang.org/x/net/ipv6/doc.go +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package ipv6 implements IP-level socket options for the Internet -// Protocol version 6. -// -// The package provides IP-level socket options that allow -// manipulation of IPv6 facilities. -// -// The IPv6 protocol is defined in RFC 2460. -// Basic and advanced socket interface extensions are defined in RFC -// 3493 and RFC 3542. -// Socket interface extensions for multicast source filters are -// defined in RFC 3678. -// MLDv1 and MLDv2 are defined in RFC 2710 and RFC 3810. -// Source-specific multicast is defined in RFC 4607. -// -// -// Unicasting -// -// The options for unicasting are available for net.TCPConn, -// net.UDPConn and net.IPConn which are created as network connections -// that use the IPv6 transport. When a single TCP connection carrying -// a data flow of multiple packets needs to indicate the flow is -// important, ipv6.Conn is used to set the traffic class field on the -// IPv6 header for each packet. -// -// ln, err := net.Listen("tcp6", "[::]:1024") -// if err != nil { -// // error handling -// } -// defer ln.Close() -// for { -// c, err := ln.Accept() -// if err != nil { -// // error handling -// } -// go func(c net.Conn) { -// defer c.Close() -// -// The outgoing packets will be labeled DiffServ assured forwarding -// class 1 low drop precedence, known as AF11 packets. -// -// if err := ipv6.NewConn(c).SetTrafficClass(0x28); err != nil { -// // error handling -// } -// if _, err := c.Write(data); err != nil { -// // error handling -// } -// }(c) -// } -// -// -// Multicasting -// -// The options for multicasting are available for net.UDPConn and -// net.IPconn which are created as network connections that use the -// IPv6 transport. A few network facilities must be prepared before -// you begin multicasting, at a minimum joining network interfaces and -// multicast groups. -// -// en0, err := net.InterfaceByName("en0") -// if err != nil { -// // error handling -// } -// en1, err := net.InterfaceByIndex(911) -// if err != nil { -// // error handling -// } -// group := net.ParseIP("ff02::114") -// -// First, an application listens to an appropriate address with an -// appropriate service port. -// -// c, err := net.ListenPacket("udp6", "[::]:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// -// Second, the application joins multicast groups, starts listening to -// the groups on the specified network interfaces. Note that the -// service port for transport layer protocol does not matter with this -// operation as joining groups affects only network and link layer -// protocols, such as IPv6 and Ethernet. -// -// p := ipv6.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: group}); err != nil { -// // error handling -// } -// -// The application might set per packet control message transmissions -// between the protocol stack within the kernel. When the application -// needs a destination address on an incoming packet, -// SetControlMessage of ipv6.PacketConn is used to enable control -// message transmissons. -// -// if err := p.SetControlMessage(ipv6.FlagDst, true); err != nil { -// // error handling -// } -// -// The application could identify whether the received packets are -// of interest by using the control message that contains the -// destination address of the received packet. -// -// b := make([]byte, 1500) -// for { -// n, rcm, src, err := p.ReadFrom(b) -// if err != nil { -// // error handling -// } -// if rcm.Dst.IsMulticast() { -// if rcm.Dst.Equal(group) { -// // joined group, do something -// } else { -// // unknown group, discard -// continue -// } -// } -// -// The application can also send both unicast and multicast packets. -// -// p.SetTrafficClass(0x0) -// p.SetHopLimit(16) -// if _, err := p.WriteTo(data[:n], nil, src); err != nil { -// // error handling -// } -// dst := &net.UDPAddr{IP: group, Port: 1024} -// wcm := ipv6.ControlMessage{TrafficClass: 0xe0, HopLimit: 1} -// for _, ifi := range []*net.Interface{en0, en1} { -// wcm.IfIndex = ifi.Index -// if _, err := p.WriteTo(data[:n], &wcm, dst); err != nil { -// // error handling -// } -// } -// } -// -// -// More multicasting -// -// An application that uses PacketConn may join multiple multicast -// groups. For example, a UDP listener with port 1024 might join two -// different groups across over two different network interfaces by -// using: -// -// c, err := net.ListenPacket("udp6", "[::]:1024") -// if err != nil { -// // error handling -// } -// defer c.Close() -// p := ipv6.NewPacketConn(c) -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::1:114")}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en1, &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}); err != nil { -// // error handling -// } -// -// It is possible for multiple UDP listeners that listen on the same -// UDP port to join the same multicast group. The net package will -// provide a socket that listens to a wildcard address with reusable -// UDP port when an appropriate multicast address prefix is passed to -// the net.ListenPacket or net.ListenUDP. -// -// c1, err := net.ListenPacket("udp6", "[ff02::]:1024") -// if err != nil { -// // error handling -// } -// defer c1.Close() -// c2, err := net.ListenPacket("udp6", "[ff02::]:1024") -// if err != nil { -// // error handling -// } -// defer c2.Close() -// p1 := ipv6.NewPacketConn(c1) -// if err := p1.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil { -// // error handling -// } -// p2 := ipv6.NewPacketConn(c2) -// if err := p2.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil { -// // error handling -// } -// -// Also it is possible for the application to leave or rejoin a -// multicast group on the network interface. -// -// if err := p.LeaveGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff02::114")}); err != nil { -// // error handling -// } -// if err := p.JoinGroup(en0, &net.UDPAddr{IP: net.ParseIP("ff01::114")}); err != nil { -// // error handling -// } -// -// -// Source-specific multicasting -// -// An application that uses PacketConn on MLDv2 supported platform is -// able to join source-specific multicast groups. -// The application may use JoinSourceSpecificGroup and -// LeaveSourceSpecificGroup for the operation known as "include" mode, -// -// ssmgroup := net.UDPAddr{IP: net.ParseIP("ff32::8000:9")} -// ssmsource := net.UDPAddr{IP: net.ParseIP("fe80::cafe")} -// if err := p.JoinSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// if err := p.LeaveSourceSpecificGroup(en0, &ssmgroup, &ssmsource); err != nil { -// // error handling -// } -// -// or JoinGroup, ExcludeSourceSpecificGroup, -// IncludeSourceSpecificGroup and LeaveGroup for the operation known -// as "exclude" mode. -// -// exclsource := net.UDPAddr{IP: net.ParseIP("fe80::dead")} -// if err := p.JoinGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// if err := p.ExcludeSourceSpecificGroup(en0, &ssmgroup, &exclsource); err != nil { -// // error handling -// } -// if err := p.LeaveGroup(en0, &ssmgroup); err != nil { -// // error handling -// } -// -// Note that it depends on each platform implementation what happens -// when an application which runs on MLDv2 unsupported platform uses -// JoinSourceSpecificGroup and LeaveSourceSpecificGroup. -// In general the platform tries to fall back to conversations using -// MLDv1 and starts to listen to multicast traffic. -// In the fallback case, ExcludeSourceSpecificGroup and -// IncludeSourceSpecificGroup may return an error. -package ipv6 // import "golang.org/x/net/ipv6" diff --git a/vendor/golang.org/x/net/ipv6/endpoint.go b/vendor/golang.org/x/net/ipv6/endpoint.go deleted file mode 100644 index 966eaa8..0000000 --- a/vendor/golang.org/x/net/ipv6/endpoint.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - "time" -) - -// A Conn represents a network endpoint that uses IPv6 transport. -// It allows to set basic IP-level socket options such as traffic -// class and hop limit. -type Conn struct { - genericOpt -} - -type genericOpt struct { - net.Conn -} - -func (c *genericOpt) ok() bool { return c != nil && c.Conn != nil } - -// PathMTU returns a path MTU value for the destination associated -// with the endpoint. -func (c *Conn) PathMTU() (int, error) { - if !c.genericOpt.ok() { - return 0, syscall.EINVAL - } - fd, err := c.genericOpt.sysfd() - if err != nil { - return 0, err - } - _, mtu, err := getMTUInfo(fd, &sockOpts[ssoPathMTU]) - if err != nil { - return 0, err - } - return mtu, nil -} - -// NewConn returns a new Conn. -func NewConn(c net.Conn) *Conn { - return &Conn{ - genericOpt: genericOpt{Conn: c}, - } -} - -// A PacketConn represents a packet network endpoint that uses IPv6 -// transport. It is used to control several IP-level socket options -// including IPv6 header manipulation. It also provides datagram -// based network I/O methods specific to the IPv6 and higher layer -// protocols such as OSPF, GRE, and UDP. -type PacketConn struct { - genericOpt - dgramOpt - payloadHandler -} - -type dgramOpt struct { - net.PacketConn -} - -func (c *dgramOpt) ok() bool { return c != nil && c.PacketConn != nil } - -// SetControlMessage allows to receive the per packet basis IP-level -// socket options. -func (c *PacketConn) SetControlMessage(cf ControlFlags, on bool) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - fd, err := c.payloadHandler.sysfd() - if err != nil { - return err - } - return setControlMessage(fd, &c.payloadHandler.rawOpt, cf, on) -} - -// SetDeadline sets the read and write deadlines associated with the -// endpoint. -func (c *PacketConn) SetDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.SetDeadline(t) -} - -// SetReadDeadline sets the read deadline associated with the -// endpoint. -func (c *PacketConn) SetReadDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.SetReadDeadline(t) -} - -// SetWriteDeadline sets the write deadline associated with the -// endpoint. -func (c *PacketConn) SetWriteDeadline(t time.Time) error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.SetWriteDeadline(t) -} - -// Close closes the endpoint. -func (c *PacketConn) Close() error { - if !c.payloadHandler.ok() { - return syscall.EINVAL - } - return c.payloadHandler.Close() -} - -// NewPacketConn returns a new PacketConn using c as its underlying -// transport. -func NewPacketConn(c net.PacketConn) *PacketConn { - return &PacketConn{ - genericOpt: genericOpt{Conn: c.(net.Conn)}, - dgramOpt: dgramOpt{PacketConn: c}, - payloadHandler: payloadHandler{PacketConn: c}, - } -} diff --git a/vendor/golang.org/x/net/ipv6/example_test.go b/vendor/golang.org/x/net/ipv6/example_test.go deleted file mode 100644 index e761aa2..0000000 --- a/vendor/golang.org/x/net/ipv6/example_test.go +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "fmt" - "log" - "net" - "os" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/ipv6" -) - -func ExampleConn_markingTCP() { - ln, err := net.Listen("tcp", "[::]:1024") - if err != nil { - log.Fatal(err) - } - defer ln.Close() - - for { - c, err := ln.Accept() - if err != nil { - log.Fatal(err) - } - go func(c net.Conn) { - defer c.Close() - if c.RemoteAddr().(*net.TCPAddr).IP.To16() != nil && c.RemoteAddr().(*net.TCPAddr).IP.To4() == nil { - p := ipv6.NewConn(c) - if err := p.SetTrafficClass(0x28); err != nil { // DSCP AF11 - log.Fatal(err) - } - if err := p.SetHopLimit(128); err != nil { - log.Fatal(err) - } - } - if _, err := c.Write([]byte("HELLO-R-U-THERE-ACK")); err != nil { - log.Fatal(err) - } - }(c) - } -} - -func ExamplePacketConn_servingOneShotMulticastDNS() { - c, err := net.ListenPacket("udp6", "[::]:5353") // mDNS over UDP - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - mDNSLinkLocal := net.UDPAddr{IP: net.ParseIP("ff02::fb")} - if err := p.JoinGroup(en0, &mDNSLinkLocal); err != nil { - log.Fatal(err) - } - defer p.LeaveGroup(en0, &mDNSLinkLocal) - if err := p.SetControlMessage(ipv6.FlagDst|ipv6.FlagInterface, true); err != nil { - log.Fatal(err) - } - - var wcm ipv6.ControlMessage - b := make([]byte, 1500) - for { - _, rcm, peer, err := p.ReadFrom(b) - if err != nil { - log.Fatal(err) - } - if !rcm.Dst.IsMulticast() || !rcm.Dst.Equal(mDNSLinkLocal.IP) { - continue - } - wcm.IfIndex = rcm.IfIndex - answers := []byte("FAKE-MDNS-ANSWERS") // fake mDNS answers, you need to implement this - if _, err := p.WriteTo(answers, &wcm, peer); err != nil { - log.Fatal(err) - } - } -} - -func ExamplePacketConn_tracingIPPacketRoute() { - // Tracing an IP packet route to www.google.com. - - const host = "www.google.com" - ips, err := net.LookupIP(host) - if err != nil { - log.Fatal(err) - } - var dst net.IPAddr - for _, ip := range ips { - if ip.To16() != nil && ip.To4() == nil { - dst.IP = ip - fmt.Printf("using %v for tracing an IP packet route to %s\n", dst.IP, host) - break - } - } - if dst.IP == nil { - log.Fatal("no AAAA record found") - } - - c, err := net.ListenPacket("ip6:58", "::") // ICMP for IPv6 - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - - if err := p.SetControlMessage(ipv6.FlagHopLimit|ipv6.FlagSrc|ipv6.FlagDst|ipv6.FlagInterface, true); err != nil { - log.Fatal(err) - } - wm := icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, - Data: []byte("HELLO-R-U-THERE"), - }, - } - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeTimeExceeded) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - log.Fatal(err) - } - - var wcm ipv6.ControlMessage - rb := make([]byte, 1500) - for i := 1; i <= 64; i++ { // up to 64 hops - wm.Body.(*icmp.Echo).Seq = i - wb, err := wm.Marshal(nil) - if err != nil { - log.Fatal(err) - } - - // In the real world usually there are several - // multiple traffic-engineered paths for each hop. - // You may need to probe a few times to each hop. - begin := time.Now() - wcm.HopLimit = i - if _, err := p.WriteTo(wb, &wcm, &dst); err != nil { - log.Fatal(err) - } - if err := p.SetReadDeadline(time.Now().Add(3 * time.Second)); err != nil { - log.Fatal(err) - } - n, rcm, peer, err := p.ReadFrom(rb) - if err != nil { - if err, ok := err.(net.Error); ok && err.Timeout() { - fmt.Printf("%v\t*\n", i) - continue - } - log.Fatal(err) - } - rm, err := icmp.ParseMessage(58, rb[:n]) - if err != nil { - log.Fatal(err) - } - rtt := time.Since(begin) - - // In the real world you need to determine whether the - // received message is yours using ControlMessage.Src, - // ControlMesage.Dst, icmp.Echo.ID and icmp.Echo.Seq. - switch rm.Type { - case ipv6.ICMPTypeTimeExceeded: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, rcm) - case ipv6.ICMPTypeEchoReply: - names, _ := net.LookupAddr(peer.String()) - fmt.Printf("%d\t%v %+v %v\n\t%+v\n", i, peer, names, rtt, rcm) - return - } - } -} - -func ExamplePacketConn_advertisingOSPFHello() { - c, err := net.ListenPacket("ip6:89", "::") // OSPF for IPv6 - if err != nil { - log.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - - en0, err := net.InterfaceByName("en0") - if err != nil { - log.Fatal(err) - } - allSPFRouters := net.IPAddr{IP: net.ParseIP("ff02::5")} - if err := p.JoinGroup(en0, &allSPFRouters); err != nil { - log.Fatal(err) - } - defer p.LeaveGroup(en0, &allSPFRouters) - - hello := make([]byte, 24) // fake hello data, you need to implement this - ospf := make([]byte, 16) // fake ospf header, you need to implement this - ospf[0] = 3 // version 3 - ospf[1] = 1 // hello packet - ospf = append(ospf, hello...) - if err := p.SetChecksum(true, 12); err != nil { - log.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: 0xc0, // DSCP CS6 - HopLimit: 1, - IfIndex: en0.Index, - } - if _, err := p.WriteTo(ospf, &cm, &allSPFRouters); err != nil { - log.Fatal(err) - } -} diff --git a/vendor/golang.org/x/net/ipv6/gen.go b/vendor/golang.org/x/net/ipv6/gen.go deleted file mode 100644 index 4e7ca78..0000000 --- a/vendor/golang.org/x/net/ipv6/gen.go +++ /dev/null @@ -1,208 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -//go:generate go run gen.go - -// This program generates system adaptation constants and types, -// internet protocol constants and tables by reading template files -// and IANA protocol registries. -package main - -import ( - "bytes" - "encoding/xml" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "os/exec" - "runtime" - "strconv" - "strings" -) - -func main() { - if err := genzsys(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } - if err := geniana(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func genzsys() error { - defs := "defs_" + runtime.GOOS + ".go" - f, err := os.Open(defs) - if err != nil { - if os.IsNotExist(err) { - return nil - } - return err - } - f.Close() - cmd := exec.Command("go", "tool", "cgo", "-godefs", defs) - b, err := cmd.Output() - if err != nil { - return err - } - // The ipv6 package still supports go1.2, and so we need to - // take care of additional platforms in go1.3 and above for - // working with go1.2. - switch { - case runtime.GOOS == "dragonfly" || runtime.GOOS == "solaris": - b = bytes.Replace(b, []byte("package ipv6\n"), []byte("// +build "+runtime.GOOS+"\n\npackage ipv6\n"), 1) - case runtime.GOOS == "linux" && (runtime.GOARCH == "arm64" || runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le" || runtime.GOARCH == "ppc64" || runtime.GOARCH == "ppc64le" || runtime.GOARCH == "s390x"): - b = bytes.Replace(b, []byte("package ipv6\n"), []byte("// +build "+runtime.GOOS+","+runtime.GOARCH+"\n\npackage ipv6\n"), 1) - } - b, err = format.Source(b) - if err != nil { - return err - } - zsys := "zsys_" + runtime.GOOS + ".go" - switch runtime.GOOS { - case "freebsd", "linux": - zsys = "zsys_" + runtime.GOOS + "_" + runtime.GOARCH + ".go" - } - if err := ioutil.WriteFile(zsys, b, 0644); err != nil { - return err - } - return nil -} - -var registries = []struct { - url string - parse func(io.Writer, io.Reader) error -}{ - { - "http://www.iana.org/assignments/icmpv6-parameters/icmpv6-parameters.xml", - parseICMPv6Parameters, - }, -} - -func geniana() error { - var bb bytes.Buffer - fmt.Fprintf(&bb, "// go generate gen.go\n") - fmt.Fprintf(&bb, "// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT\n\n") - fmt.Fprintf(&bb, "package ipv6\n\n") - for _, r := range registries { - resp, err := http.Get(r.url) - if err != nil { - return err - } - defer resp.Body.Close() - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("got HTTP status code %v for %v\n", resp.StatusCode, r.url) - } - if err := r.parse(&bb, resp.Body); err != nil { - return err - } - fmt.Fprintf(&bb, "\n") - } - b, err := format.Source(bb.Bytes()) - if err != nil { - return err - } - if err := ioutil.WriteFile("iana.go", b, 0644); err != nil { - return err - } - return nil -} - -func parseICMPv6Parameters(w io.Writer, r io.Reader) error { - dec := xml.NewDecoder(r) - var icp icmpv6Parameters - if err := dec.Decode(&icp); err != nil { - return err - } - prs := icp.escape() - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "const (\n") - for _, pr := range prs { - if pr.Name == "" { - continue - } - fmt.Fprintf(w, "ICMPType%s ICMPType = %d", pr.Name, pr.Value) - fmt.Fprintf(w, "// %s\n", pr.OrigName) - } - fmt.Fprintf(w, ")\n\n") - fmt.Fprintf(w, "// %s, Updated: %s\n", icp.Title, icp.Updated) - fmt.Fprintf(w, "var icmpTypes = map[ICMPType]string{\n") - for _, pr := range prs { - if pr.Name == "" { - continue - } - fmt.Fprintf(w, "%d: %q,\n", pr.Value, strings.ToLower(pr.OrigName)) - } - fmt.Fprintf(w, "}\n") - return nil -} - -type icmpv6Parameters struct { - XMLName xml.Name `xml:"registry"` - Title string `xml:"title"` - Updated string `xml:"updated"` - Registries []struct { - Title string `xml:"title"` - Records []struct { - Value string `xml:"value"` - Name string `xml:"name"` - } `xml:"record"` - } `xml:"registry"` -} - -type canonICMPv6ParamRecord struct { - OrigName string - Name string - Value int -} - -func (icp *icmpv6Parameters) escape() []canonICMPv6ParamRecord { - id := -1 - for i, r := range icp.Registries { - if strings.Contains(r.Title, "Type") || strings.Contains(r.Title, "type") { - id = i - break - } - } - if id < 0 { - return nil - } - prs := make([]canonICMPv6ParamRecord, len(icp.Registries[id].Records)) - sr := strings.NewReplacer( - "Messages", "", - "Message", "", - "ICMP", "", - "+", "P", - "-", "", - "/", "", - ".", "", - " ", "", - ) - for i, pr := range icp.Registries[id].Records { - if strings.Contains(pr.Name, "Reserved") || - strings.Contains(pr.Name, "Unassigned") || - strings.Contains(pr.Name, "Deprecated") || - strings.Contains(pr.Name, "Experiment") || - strings.Contains(pr.Name, "experiment") { - continue - } - ss := strings.Split(pr.Name, "\n") - if len(ss) > 1 { - prs[i].Name = strings.Join(ss, " ") - } else { - prs[i].Name = ss[0] - } - s := strings.TrimSpace(prs[i].Name) - prs[i].OrigName = s - prs[i].Name = sr.Replace(s) - prs[i].Value, _ = strconv.Atoi(pr.Value) - } - return prs -} diff --git a/vendor/golang.org/x/net/ipv6/genericopt_posix.go b/vendor/golang.org/x/net/ipv6/genericopt_posix.go deleted file mode 100644 index dd77a01..0000000 --- a/vendor/golang.org/x/net/ipv6/genericopt_posix.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd windows - -package ipv6 - -import "syscall" - -// TrafficClass returns the traffic class field value for outgoing -// packets. -func (c *genericOpt) TrafficClass() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return 0, err - } - return getInt(fd, &sockOpts[ssoTrafficClass]) -} - -// SetTrafficClass sets the traffic class field value for future -// outgoing packets. -func (c *genericOpt) SetTrafficClass(tclass int) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoTrafficClass], tclass) -} - -// HopLimit returns the hop limit field value for outgoing packets. -func (c *genericOpt) HopLimit() (int, error) { - if !c.ok() { - return 0, syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return 0, err - } - return getInt(fd, &sockOpts[ssoHopLimit]) -} - -// SetHopLimit sets the hop limit field value for future outgoing -// packets. -func (c *genericOpt) SetHopLimit(hoplim int) error { - if !c.ok() { - return syscall.EINVAL - } - fd, err := c.sysfd() - if err != nil { - return err - } - return setInt(fd, &sockOpts[ssoHopLimit], hoplim) -} diff --git a/vendor/golang.org/x/net/ipv6/genericopt_stub.go b/vendor/golang.org/x/net/ipv6/genericopt_stub.go deleted file mode 100644 index f5c3722..0000000 --- a/vendor/golang.org/x/net/ipv6/genericopt_stub.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv6 - -// TrafficClass returns the traffic class field value for outgoing -// packets. -func (c *genericOpt) TrafficClass() (int, error) { - return 0, errOpNoSupport -} - -// SetTrafficClass sets the traffic class field value for future -// outgoing packets. -func (c *genericOpt) SetTrafficClass(tclass int) error { - return errOpNoSupport -} - -// HopLimit returns the hop limit field value for outgoing packets. -func (c *genericOpt) HopLimit() (int, error) { - return 0, errOpNoSupport -} - -// SetHopLimit sets the hop limit field value for future outgoing -// packets. -func (c *genericOpt) SetHopLimit(hoplim int) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/header.go b/vendor/golang.org/x/net/ipv6/header.go deleted file mode 100644 index e05cb08..0000000 --- a/vendor/golang.org/x/net/ipv6/header.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "encoding/binary" - "fmt" - "net" -) - -const ( - Version = 6 // protocol version - HeaderLen = 40 // header length -) - -// A Header represents an IPv6 base header. -type Header struct { - Version int // protocol version - TrafficClass int // traffic class - FlowLabel int // flow label - PayloadLen int // payload length - NextHeader int // next header - HopLimit int // hop limit - Src net.IP // source address - Dst net.IP // destination address -} - -func (h *Header) String() string { - if h == nil { - return "" - } - return fmt.Sprintf("ver=%d tclass=%#x flowlbl=%#x payloadlen=%d nxthdr=%d hoplim=%d src=%v dst=%v", h.Version, h.TrafficClass, h.FlowLabel, h.PayloadLen, h.NextHeader, h.HopLimit, h.Src, h.Dst) -} - -// ParseHeader parses b as an IPv6 base header. -func ParseHeader(b []byte) (*Header, error) { - if len(b) < HeaderLen { - return nil, errHeaderTooShort - } - h := &Header{ - Version: int(b[0]) >> 4, - TrafficClass: int(b[0]&0x0f)<<4 | int(b[1])>>4, - FlowLabel: int(b[1]&0x0f)<<16 | int(b[2])<<8 | int(b[3]), - PayloadLen: int(binary.BigEndian.Uint16(b[4:6])), - NextHeader: int(b[6]), - HopLimit: int(b[7]), - } - h.Src = make(net.IP, net.IPv6len) - copy(h.Src, b[8:24]) - h.Dst = make(net.IP, net.IPv6len) - copy(h.Dst, b[24:40]) - return h, nil -} diff --git a/vendor/golang.org/x/net/ipv6/header_test.go b/vendor/golang.org/x/net/ipv6/header_test.go deleted file mode 100644 index ca11dc2..0000000 --- a/vendor/golang.org/x/net/ipv6/header_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "reflect" - "strings" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/ipv6" -) - -var ( - wireHeaderFromKernel = [ipv6.HeaderLen]byte{ - 0x69, 0x8b, 0xee, 0xf1, - 0xca, 0xfe, 0x2c, 0x01, - 0x20, 0x01, 0x0d, 0xb8, - 0x00, 0x01, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - 0x20, 0x01, 0x0d, 0xb8, - 0x00, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01, - } - - testHeader = &ipv6.Header{ - Version: ipv6.Version, - TrafficClass: iana.DiffServAF43, - FlowLabel: 0xbeef1, - PayloadLen: 0xcafe, - NextHeader: iana.ProtocolIPv6Frag, - HopLimit: 1, - Src: net.ParseIP("2001:db8:1::1"), - Dst: net.ParseIP("2001:db8:2::1"), - } -) - -func TestParseHeader(t *testing.T) { - h, err := ipv6.ParseHeader(wireHeaderFromKernel[:]) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(h, testHeader) { - t.Fatalf("got %#v; want %#v", h, testHeader) - } - s := h.String() - if strings.Contains(s, ",") { - t.Fatalf("should be space-separated values: %s", s) - } -} diff --git a/vendor/golang.org/x/net/ipv6/helper.go b/vendor/golang.org/x/net/ipv6/helper.go deleted file mode 100644 index 53b9999..0000000 --- a/vendor/golang.org/x/net/ipv6/helper.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "encoding/binary" - "errors" - "net" - "unsafe" -) - -var ( - errMissingAddress = errors.New("missing address") - errHeaderTooShort = errors.New("header too short") - errInvalidConnType = errors.New("invalid conn type") - errOpNoSupport = errors.New("operation not supported") - errNoSuchInterface = errors.New("no such interface") - - nativeEndian binary.ByteOrder -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = binary.LittleEndian - } else { - nativeEndian = binary.BigEndian - } -} - -func boolint(b bool) int { - if b { - return 1 - } - return 0 -} - -func netAddrToIP16(a net.Addr) net.IP { - switch v := a.(type) { - case *net.UDPAddr: - if ip := v.IP.To16(); ip != nil && ip.To4() == nil { - return ip - } - case *net.IPAddr: - if ip := v.IP.To16(); ip != nil && ip.To4() == nil { - return ip - } - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/helper_stub.go b/vendor/golang.org/x/net/ipv6/helper_stub.go deleted file mode 100644 index 20354ab..0000000 --- a/vendor/golang.org/x/net/ipv6/helper_stub.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv6 - -func (c *genericOpt) sysfd() (int, error) { - return 0, errOpNoSupport -} - -func (c *dgramOpt) sysfd() (int, error) { - return 0, errOpNoSupport -} - -func (c *payloadHandler) sysfd() (int, error) { - return 0, errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/helper_unix.go b/vendor/golang.org/x/net/ipv6/helper_unix.go deleted file mode 100644 index 92868ed..0000000 --- a/vendor/golang.org/x/net/ipv6/helper_unix.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv6 - -import ( - "net" - "reflect" -) - -func (c *genericOpt) sysfd() (int, error) { - switch p := c.Conn.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn: - return sysfd(p) - } - return 0, errInvalidConnType -} - -func (c *dgramOpt) sysfd() (int, error) { - switch p := c.PacketConn.(type) { - case *net.UDPConn, *net.IPConn: - return sysfd(p.(net.Conn)) - } - return 0, errInvalidConnType -} - -func (c *payloadHandler) sysfd() (int, error) { - return sysfd(c.PacketConn.(net.Conn)) -} - -func sysfd(c net.Conn) (int, error) { - cv := reflect.ValueOf(c) - switch ce := cv.Elem(); ce.Kind() { - case reflect.Struct: - nfd := ce.FieldByName("conn").FieldByName("fd") - switch fe := nfd.Elem(); fe.Kind() { - case reflect.Struct: - fd := fe.FieldByName("sysfd") - return int(fd.Int()), nil - } - } - return 0, errInvalidConnType -} diff --git a/vendor/golang.org/x/net/ipv6/helper_windows.go b/vendor/golang.org/x/net/ipv6/helper_windows.go deleted file mode 100644 index 28c401b..0000000 --- a/vendor/golang.org/x/net/ipv6/helper_windows.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "reflect" - "syscall" -) - -func (c *genericOpt) sysfd() (syscall.Handle, error) { - switch p := c.Conn.(type) { - case *net.TCPConn, *net.UDPConn, *net.IPConn: - return sysfd(p) - } - return syscall.InvalidHandle, errInvalidConnType -} - -func (c *dgramOpt) sysfd() (syscall.Handle, error) { - switch p := c.PacketConn.(type) { - case *net.UDPConn, *net.IPConn: - return sysfd(p.(net.Conn)) - } - return syscall.InvalidHandle, errInvalidConnType -} - -func (c *payloadHandler) sysfd() (syscall.Handle, error) { - return sysfd(c.PacketConn.(net.Conn)) -} - -func sysfd(c net.Conn) (syscall.Handle, error) { - cv := reflect.ValueOf(c) - switch ce := cv.Elem(); ce.Kind() { - case reflect.Struct: - netfd := ce.FieldByName("conn").FieldByName("fd") - switch fe := netfd.Elem(); fe.Kind() { - case reflect.Struct: - fd := fe.FieldByName("sysfd") - return syscall.Handle(fd.Uint()), nil - } - } - return syscall.InvalidHandle, errInvalidConnType -} diff --git a/vendor/golang.org/x/net/ipv6/iana.go b/vendor/golang.org/x/net/ipv6/iana.go deleted file mode 100644 index 3c6214f..0000000 --- a/vendor/golang.org/x/net/ipv6/iana.go +++ /dev/null @@ -1,82 +0,0 @@ -// go generate gen.go -// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT - -package ipv6 - -// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2015-07-07 -const ( - ICMPTypeDestinationUnreachable ICMPType = 1 // Destination Unreachable - ICMPTypePacketTooBig ICMPType = 2 // Packet Too Big - ICMPTypeTimeExceeded ICMPType = 3 // Time Exceeded - ICMPTypeParameterProblem ICMPType = 4 // Parameter Problem - ICMPTypeEchoRequest ICMPType = 128 // Echo Request - ICMPTypeEchoReply ICMPType = 129 // Echo Reply - ICMPTypeMulticastListenerQuery ICMPType = 130 // Multicast Listener Query - ICMPTypeMulticastListenerReport ICMPType = 131 // Multicast Listener Report - ICMPTypeMulticastListenerDone ICMPType = 132 // Multicast Listener Done - ICMPTypeRouterSolicitation ICMPType = 133 // Router Solicitation - ICMPTypeRouterAdvertisement ICMPType = 134 // Router Advertisement - ICMPTypeNeighborSolicitation ICMPType = 135 // Neighbor Solicitation - ICMPTypeNeighborAdvertisement ICMPType = 136 // Neighbor Advertisement - ICMPTypeRedirect ICMPType = 137 // Redirect Message - ICMPTypeRouterRenumbering ICMPType = 138 // Router Renumbering - ICMPTypeNodeInformationQuery ICMPType = 139 // ICMP Node Information Query - ICMPTypeNodeInformationResponse ICMPType = 140 // ICMP Node Information Response - ICMPTypeInverseNeighborDiscoverySolicitation ICMPType = 141 // Inverse Neighbor Discovery Solicitation Message - ICMPTypeInverseNeighborDiscoveryAdvertisement ICMPType = 142 // Inverse Neighbor Discovery Advertisement Message - ICMPTypeVersion2MulticastListenerReport ICMPType = 143 // Version 2 Multicast Listener Report - ICMPTypeHomeAgentAddressDiscoveryRequest ICMPType = 144 // Home Agent Address Discovery Request Message - ICMPTypeHomeAgentAddressDiscoveryReply ICMPType = 145 // Home Agent Address Discovery Reply Message - ICMPTypeMobilePrefixSolicitation ICMPType = 146 // Mobile Prefix Solicitation - ICMPTypeMobilePrefixAdvertisement ICMPType = 147 // Mobile Prefix Advertisement - ICMPTypeCertificationPathSolicitation ICMPType = 148 // Certification Path Solicitation Message - ICMPTypeCertificationPathAdvertisement ICMPType = 149 // Certification Path Advertisement Message - ICMPTypeMulticastRouterAdvertisement ICMPType = 151 // Multicast Router Advertisement - ICMPTypeMulticastRouterSolicitation ICMPType = 152 // Multicast Router Solicitation - ICMPTypeMulticastRouterTermination ICMPType = 153 // Multicast Router Termination - ICMPTypeFMIPv6 ICMPType = 154 // FMIPv6 Messages - ICMPTypeRPLControl ICMPType = 155 // RPL Control Message - ICMPTypeILNPv6LocatorUpdate ICMPType = 156 // ILNPv6 Locator Update Message - ICMPTypeDuplicateAddressRequest ICMPType = 157 // Duplicate Address Request - ICMPTypeDuplicateAddressConfirmation ICMPType = 158 // Duplicate Address Confirmation - ICMPTypeMPLControl ICMPType = 159 // MPL Control Message -) - -// Internet Control Message Protocol version 6 (ICMPv6) Parameters, Updated: 2015-07-07 -var icmpTypes = map[ICMPType]string{ - 1: "destination unreachable", - 2: "packet too big", - 3: "time exceeded", - 4: "parameter problem", - 128: "echo request", - 129: "echo reply", - 130: "multicast listener query", - 131: "multicast listener report", - 132: "multicast listener done", - 133: "router solicitation", - 134: "router advertisement", - 135: "neighbor solicitation", - 136: "neighbor advertisement", - 137: "redirect message", - 138: "router renumbering", - 139: "icmp node information query", - 140: "icmp node information response", - 141: "inverse neighbor discovery solicitation message", - 142: "inverse neighbor discovery advertisement message", - 143: "version 2 multicast listener report", - 144: "home agent address discovery request message", - 145: "home agent address discovery reply message", - 146: "mobile prefix solicitation", - 147: "mobile prefix advertisement", - 148: "certification path solicitation message", - 149: "certification path advertisement message", - 151: "multicast router advertisement", - 152: "multicast router solicitation", - 153: "multicast router termination", - 154: "fmipv6 messages", - 155: "rpl control message", - 156: "ilnpv6 locator update message", - 157: "duplicate address request", - 158: "duplicate address confirmation", - 159: "mpl control message", -} diff --git a/vendor/golang.org/x/net/ipv6/icmp.go b/vendor/golang.org/x/net/ipv6/icmp.go deleted file mode 100644 index a2de65a..0000000 --- a/vendor/golang.org/x/net/ipv6/icmp.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import "golang.org/x/net/internal/iana" - -// An ICMPType represents a type of ICMP message. -type ICMPType int - -func (typ ICMPType) String() string { - s, ok := icmpTypes[typ] - if !ok { - return "" - } - return s -} - -// Protocol returns the ICMPv6 protocol number. -func (typ ICMPType) Protocol() int { - return iana.ProtocolIPv6ICMP -} - -// An ICMPFilter represents an ICMP message filter for incoming -// packets. The filter belongs to a packet delivery path on a host and -// it cannot interact with forwarding packets or tunnel-outer packets. -// -// Note: RFC 2460 defines a reasonable role model. A node means a -// device that implements IP. A router means a node that forwards IP -// packets not explicitly addressed to itself, and a host means a node -// that is not a router. -type ICMPFilter struct { - sysICMPv6Filter -} - -// Accept accepts incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Accept(typ ICMPType) { - f.accept(typ) -} - -// Block blocks incoming ICMP packets including the type field value -// typ. -func (f *ICMPFilter) Block(typ ICMPType) { - f.block(typ) -} - -// SetAll sets the filter action to the filter. -func (f *ICMPFilter) SetAll(block bool) { - f.setAll(block) -} - -// WillBlock reports whether the ICMP type will be blocked. -func (f *ICMPFilter) WillBlock(typ ICMPType) bool { - return f.willBlock(typ) -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_bsd.go b/vendor/golang.org/x/net/ipv6/icmp_bsd.go deleted file mode 100644 index 30e3ce4..0000000 --- a/vendor/golang.org/x/net/ipv6/icmp_bsd.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package ipv6 - -func (f *sysICMPv6Filter) accept(typ ICMPType) { - f.Filt[typ>>5] |= 1 << (uint32(typ) & 31) -} - -func (f *sysICMPv6Filter) block(typ ICMPType) { - f.Filt[typ>>5] &^= 1 << (uint32(typ) & 31) -} - -func (f *sysICMPv6Filter) setAll(block bool) { - for i := range f.Filt { - if block { - f.Filt[i] = 0 - } else { - f.Filt[i] = 1<<32 - 1 - } - } -} - -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool { - return f.Filt[typ>>5]&(1<<(uint32(typ)&31)) == 0 -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_linux.go b/vendor/golang.org/x/net/ipv6/icmp_linux.go deleted file mode 100644 index a67ecf6..0000000 --- a/vendor/golang.org/x/net/ipv6/icmp_linux.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -func (f *sysICMPv6Filter) accept(typ ICMPType) { - f.Data[typ>>5] &^= 1 << (uint32(typ) & 31) -} - -func (f *sysICMPv6Filter) block(typ ICMPType) { - f.Data[typ>>5] |= 1 << (uint32(typ) & 31) -} - -func (f *sysICMPv6Filter) setAll(block bool) { - for i := range f.Data { - if block { - f.Data[i] = 1<<32 - 1 - } else { - f.Data[i] = 0 - } - } -} - -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool { - return f.Data[typ>>5]&(1<<(uint32(typ)&31)) != 0 -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_solaris.go b/vendor/golang.org/x/net/ipv6/icmp_solaris.go deleted file mode 100644 index a942f35..0000000 --- a/vendor/golang.org/x/net/ipv6/icmp_solaris.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build solaris - -package ipv6 - -func (f *sysICMPv6Filter) accept(typ ICMPType) { - // TODO(mikio): implement this -} - -func (f *sysICMPv6Filter) block(typ ICMPType) { - // TODO(mikio): implement this -} - -func (f *sysICMPv6Filter) setAll(block bool) { - // TODO(mikio): implement this -} - -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool { - // TODO(mikio): implement this - return false -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_stub.go b/vendor/golang.org/x/net/ipv6/icmp_stub.go deleted file mode 100644 index c1263ec..0000000 --- a/vendor/golang.org/x/net/ipv6/icmp_stub.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 - -package ipv6 - -type sysICMPv6Filter struct { -} - -func (f *sysICMPv6Filter) accept(typ ICMPType) { -} - -func (f *sysICMPv6Filter) block(typ ICMPType) { -} - -func (f *sysICMPv6Filter) setAll(block bool) { -} - -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool { - return false -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_test.go b/vendor/golang.org/x/net/ipv6/icmp_test.go deleted file mode 100644 index e192d6d..0000000 --- a/vendor/golang.org/x/net/ipv6/icmp_test.go +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "reflect" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var icmpStringTests = []struct { - in ipv6.ICMPType - out string -}{ - {ipv6.ICMPTypeDestinationUnreachable, "destination unreachable"}, - - {256, ""}, -} - -func TestICMPString(t *testing.T) { - for _, tt := range icmpStringTests { - s := tt.in.String() - if s != tt.out { - t.Errorf("got %s; want %s", s, tt.out) - } - } -} - -func TestICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - - var f ipv6.ICMPFilter - for _, toggle := range []bool{false, true} { - f.SetAll(toggle) - for _, typ := range []ipv6.ICMPType{ - ipv6.ICMPTypeDestinationUnreachable, - ipv6.ICMPTypeEchoReply, - ipv6.ICMPTypeNeighborSolicitation, - ipv6.ICMPTypeDuplicateAddressConfirmation, - } { - f.Accept(typ) - if f.WillBlock(typ) { - t.Errorf("ipv6.ICMPFilter.Set(%v, false) failed", typ) - } - f.Block(typ) - if !f.WillBlock(typ) { - t.Errorf("ipv6.ICMPFilter.Set(%v, true) failed", typ) - } - } - } -} - -func TestSetICMPFilter(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip6:ipv6-icmp", "::1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeEchoRequest) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - kf, err := p.ICMPFilter() - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(kf, &f) { - t.Fatalf("got %#v; want %#v", kf, f) - } -} diff --git a/vendor/golang.org/x/net/ipv6/icmp_windows.go b/vendor/golang.org/x/net/ipv6/icmp_windows.go deleted file mode 100644 index 9dcfb81..0000000 --- a/vendor/golang.org/x/net/ipv6/icmp_windows.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -type sysICMPv6Filter struct { - // TODO(mikio): implement this -} - -func (f *sysICMPv6Filter) accept(typ ICMPType) { - // TODO(mikio): implement this -} - -func (f *sysICMPv6Filter) block(typ ICMPType) { - // TODO(mikio): implement this -} - -func (f *sysICMPv6Filter) setAll(block bool) { - // TODO(mikio): implement this -} - -func (f *sysICMPv6Filter) willBlock(typ ICMPType) bool { - // TODO(mikio): implement this - return false -} diff --git a/vendor/golang.org/x/net/ipv6/mocktransponder_test.go b/vendor/golang.org/x/net/ipv6/mocktransponder_test.go deleted file mode 100644 index d587922..0000000 --- a/vendor/golang.org/x/net/ipv6/mocktransponder_test.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "testing" -) - -func connector(t *testing.T, network, addr string, done chan<- bool) { - defer func() { done <- true }() - - c, err := net.Dial(network, addr) - if err != nil { - t.Error(err) - return - } - c.Close() -} - -func acceptor(t *testing.T, ln net.Listener, done chan<- bool) { - defer func() { done <- true }() - - c, err := ln.Accept() - if err != nil { - t.Error(err) - return - } - c.Close() -} diff --git a/vendor/golang.org/x/net/ipv6/multicast_test.go b/vendor/golang.org/x/net/ipv6/multicast_test.go deleted file mode 100644 index a3a8979..0000000 --- a/vendor/golang.org/x/net/ipv6/multicast_test.go +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var packetConnReadWriteMulticastUDPTests = []struct { - addr string - grp, src *net.UDPAddr -}{ - {"[ff02::]:0", &net.UDPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727 - - {"[ff30::8000:0]:0", &net.UDPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.UDPAddr{IP: net.IPv6loopback}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastUDP(t *testing.T) { - switch runtime.GOOS { - case "freebsd": // due to a bug on loopback marking - // See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065. - t.Skipf("not supported on %s", runtime.GOOS) - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastUDPTests { - c, err := net.ListenPacket("udp6", tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - grp := *tt.grp - grp.Port = c.LocalAddr().(*net.UDPAddr).Port - p := ipv6.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, &grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, &grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, &grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support MLDv2 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, &grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - IfIndex: ifi.Index, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - cm.HopLimit = i + 1 - if n, err := p.WriteTo(wb, &cm, &grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatal(err) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } - } -} - -var packetConnReadWriteMulticastICMPTests = []struct { - grp, src *net.IPAddr -}{ - {&net.IPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727 - - {&net.IPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.IPAddr{IP: net.IPv6loopback}}, // see RFC 5771 -} - -func TestPacketConnReadWriteMulticastICMP(t *testing.T) { - switch runtime.GOOS { - case "freebsd": // due to a bug on loopback marking - // See http://www.freebsd.org/cgi/query-pr.cgi?pr=180065. - t.Skipf("not supported on %s", runtime.GOOS) - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - for _, tt := range packetConnReadWriteMulticastICMPTests { - c, err := net.ListenPacket("ip6:ipv6-icmp", "::") - if err != nil { - t.Fatal(err) - } - defer c.Close() - - pshicmp := icmp.IPv6PseudoHeader(c.LocalAddr().(*net.IPAddr).IP, tt.grp.IP) - p := ipv6.NewPacketConn(c) - defer p.Close() - if tt.src == nil { - if err := p.JoinGroup(ifi, tt.grp); err != nil { - t.Fatal(err) - } - defer p.LeaveGroup(ifi, tt.grp) - } else { - if err := p.JoinSourceSpecificGroup(ifi, tt.grp, tt.src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support MLDv2 fail here - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - defer p.LeaveSourceSpecificGroup(ifi, tt.grp, tt.src) - } - if err := p.SetMulticastInterface(ifi); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastInterface(); err != nil { - t.Fatal(err) - } - if err := p.SetMulticastLoopback(true); err != nil { - t.Fatal(err) - } - if _, err := p.MulticastLoopback(); err != nil { - t.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - IfIndex: ifi.Index, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - - var psh []byte - for i, toggle := range []bool{true, false, true} { - if toggle { - psh = nil - if err := p.SetChecksum(true, 2); err != nil { - t.Fatal(err) - } - } else { - psh = pshicmp - // Some platforms never allow to - // disable the kernel checksum - // processing. - p.SetChecksum(false, -1) - } - wb, err := (&icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(psh) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } - if err := p.SetDeadline(time.Now().Add(200 * time.Millisecond)); err != nil { - t.Fatal(err) - } - cm.HopLimit = i + 1 - if n, err := p.WriteTo(wb, &cm, tt.grp); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if n, _, _, err := p.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - if m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, rb[:n]); err != nil { - t.Fatal(err) - } else if m.Type != ipv6.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv6.ICMPTypeEchoReply, 0) - } - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/multicastlistener_test.go b/vendor/golang.org/x/net/ipv6/multicastlistener_test.go deleted file mode 100644 index 9711f75..0000000 --- a/vendor/golang.org/x/net/ipv6/multicastlistener_test.go +++ /dev/null @@ -1,246 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "fmt" - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var udpMultipleGroupListenerTests = []net.Addr{ - &net.UDPAddr{IP: net.ParseIP("ff02::114")}, // see RFC 4727 - &net.UDPAddr{IP: net.ParseIP("ff02::1:114")}, - &net.UDPAddr{IP: net.ParseIP("ff02::2:114")}, -} - -func TestUDPSinglePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c, err := net.ListenPacket("udp6", "[::]:0") // wildcard address with non-reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok { - continue - } - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } -} - -func TestUDPMultiplePacketConnWithMultipleGroupListeners(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - for _, gaddr := range udpMultipleGroupListenerTests { - c1, err := net.ListenPacket("udp6", "[ff02::]:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c1.Close() - - c2, err := net.ListenPacket("udp6", "[ff02::]:1024") // wildcard address with reusable port - if err != nil { - t.Fatal(err) - } - defer c2.Close() - - var ps [2]*ipv6.PacketConn - ps[0] = ipv6.NewPacketConn(c1) - ps[1] = ipv6.NewPacketConn(c2) - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok { - continue - } - for _, p := range ps { - if err := p.JoinGroup(&ifi, gaddr); err != nil { - t.Fatal(err) - } - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - for _, p := range ps { - if err := p.LeaveGroup(ifi, gaddr); err != nil { - t.Fatal(err) - } - } - } - } -} - -func TestUDPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727 - type ml struct { - c *ipv6.PacketConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip6", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("udp6", fmt.Sprintf("[%s%%%s]:1024", ip.String(), ifi.Name)) // unicast address with non-reusable port - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{p, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip6:ipv6-icmp", "::") // wildcard address - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727 - var mift []*net.Interface - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - if _, ok := nettest.IsMulticastCapable("ip6", &ifi); !ok { - continue - } - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mift = append(mift, &ift[i]) - } - for _, ifi := range mift { - if err := p.LeaveGroup(ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} - -func TestIPPerInterfaceSinglePacketConnWithSingleGroupListener(t *testing.T) { - switch runtime.GOOS { - case "darwin", "dragonfly", "openbsd": // platforms that return fe80::1%lo0: bind: can't assign requested address - t.Skipf("not supported on %s", runtime.GOOS) - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - gaddr := net.IPAddr{IP: net.ParseIP("ff02::114")} // see RFC 4727 - type ml struct { - c *ipv6.PacketConn - ifi *net.Interface - } - var mlt []*ml - - ift, err := net.Interfaces() - if err != nil { - t.Fatal(err) - } - for i, ifi := range ift { - ip, ok := nettest.IsMulticastCapable("ip6", &ifi) - if !ok { - continue - } - c, err := net.ListenPacket("ip6:ipv6-icmp", fmt.Sprintf("%s%%%s", ip.String(), ifi.Name)) // unicast address - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - if err := p.JoinGroup(&ifi, &gaddr); err != nil { - t.Fatal(err) - } - mlt = append(mlt, &ml{p, &ift[i]}) - } - for _, m := range mlt { - if err := m.c.LeaveGroup(m.ifi, &gaddr); err != nil { - t.Fatal(err) - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go b/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go deleted file mode 100644 index fe0e6e1..0000000 --- a/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var packetConnMulticastSocketOptionTests = []struct { - net, proto, addr string - grp, src net.Addr -}{ - {"udp6", "", "[ff02::]:0", &net.UDPAddr{IP: net.ParseIP("ff02::114")}, nil}, // see RFC 4727 - {"ip6", ":ipv6-icmp", "::", &net.IPAddr{IP: net.ParseIP("ff02::115")}, nil}, // see RFC 4727 - - {"udp6", "", "[ff30::8000:0]:0", &net.UDPAddr{IP: net.ParseIP("ff30::8000:1")}, &net.UDPAddr{IP: net.IPv6loopback}}, // see RFC 5771 - {"ip6", ":ipv6-icmp", "::", &net.IPAddr{IP: net.ParseIP("ff30::8000:2")}, &net.IPAddr{IP: net.IPv6loopback}}, // see RFC 5771 -} - -func TestPacketConnMulticastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagMulticast|net.FlagLoopback) - if ifi == nil { - t.Skipf("not available on %s", runtime.GOOS) - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnMulticastSocketOptionTests { - if tt.net == "ip6" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - if tt.src == nil { - testMulticastSocketOptions(t, p, ifi, tt.grp) - } else { - testSourceSpecificMulticastSocketOptions(t, p, ifi, tt.grp, tt.src) - } - } -} - -type testIPv6MulticastConn interface { - MulticastHopLimit() (int, error) - SetMulticastHopLimit(ttl int) error - MulticastLoopback() (bool, error) - SetMulticastLoopback(bool) error - JoinGroup(*net.Interface, net.Addr) error - LeaveGroup(*net.Interface, net.Addr) error - JoinSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - LeaveSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - ExcludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error - IncludeSourceSpecificGroup(*net.Interface, net.Addr, net.Addr) error -} - -func testMulticastSocketOptions(t *testing.T, c testIPv6MulticastConn, ifi *net.Interface, grp net.Addr) { - const hoplim = 255 - if err := c.SetMulticastHopLimit(hoplim); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastHopLimit(); err != nil { - t.Error(err) - return - } else if v != hoplim { - t.Errorf("got %v; want %v", v, hoplim) - return - } - - for _, toggle := range []bool{true, false} { - if err := c.SetMulticastLoopback(toggle); err != nil { - t.Error(err) - return - } - if v, err := c.MulticastLoopback(); err != nil { - t.Error(err) - return - } else if v != toggle { - t.Errorf("got %v; want %v", v, toggle) - return - } - } - - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} - -func testSourceSpecificMulticastSocketOptions(t *testing.T, c testIPv6MulticastConn, ifi *net.Interface, grp, src net.Addr) { - // MCAST_JOIN_GROUP -> MCAST_BLOCK_SOURCE -> MCAST_UNBLOCK_SOURCE -> MCAST_LEAVE_GROUP - if err := c.JoinGroup(ifi, grp); err != nil { - t.Error(err) - return - } - if err := c.ExcludeSourceSpecificGroup(ifi, grp, src); err != nil { - switch runtime.GOOS { - case "freebsd", "linux": - default: // platforms that don't support MLDv2 fail here - t.Logf("not supported on %s", runtime.GOOS) - return - } - t.Error(err) - return - } - if err := c.IncludeSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_SOURCE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - - // MCAST_JOIN_SOURCE_GROUP -> MCAST_LEAVE_GROUP - if err := c.JoinSourceSpecificGroup(ifi, grp, src); err != nil { - t.Error(err) - return - } - if err := c.LeaveGroup(ifi, grp); err != nil { - t.Error(err) - return - } -} diff --git a/vendor/golang.org/x/net/ipv6/payload.go b/vendor/golang.org/x/net/ipv6/payload.go deleted file mode 100644 index 529b20b..0000000 --- a/vendor/golang.org/x/net/ipv6/payload.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import "net" - -// A payloadHandler represents the IPv6 datagram payload handler. -type payloadHandler struct { - net.PacketConn - rawOpt -} - -func (c *payloadHandler) ok() bool { return c != nil && c.PacketConn != nil } diff --git a/vendor/golang.org/x/net/ipv6/payload_cmsg.go b/vendor/golang.org/x/net/ipv6/payload_cmsg.go deleted file mode 100644 index 8e90d32..0000000 --- a/vendor/golang.org/x/net/ipv6/payload_cmsg.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !nacl,!plan9,!windows - -package ipv6 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv6 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - oob := newControlMessage(&c.rawOpt) - var oobn int - switch c := c.PacketConn.(type) { - case *net.UDPConn: - if n, oobn, _, src, err = c.ReadMsgUDP(b, oob); err != nil { - return 0, nil, nil, err - } - case *net.IPConn: - if n, oobn, _, src, err = c.ReadMsgIP(b, oob); err != nil { - return 0, nil, nil, err - } - default: - return 0, nil, nil, errInvalidConnType - } - if cm, err = parseControlMessage(oob[:oobn]); err != nil { - return 0, nil, nil, err - } - if cm != nil { - cm.Src = netAddrToIP16(src) - } - return -} - -// WriteTo writes a payload of the IPv6 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the IPv6 header fields and the datagram path to be specified. The -// cm may be nil if control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - oob := marshalControlMessage(cm) - if dst == nil { - return 0, errMissingAddress - } - switch c := c.PacketConn.(type) { - case *net.UDPConn: - n, _, err = c.WriteMsgUDP(b, oob, dst.(*net.UDPAddr)) - case *net.IPConn: - n, _, err = c.WriteMsgIP(b, oob, dst.(*net.IPAddr)) - default: - return 0, errInvalidConnType - } - if err != nil { - return 0, err - } - return -} diff --git a/vendor/golang.org/x/net/ipv6/payload_nocmsg.go b/vendor/golang.org/x/net/ipv6/payload_nocmsg.go deleted file mode 100644 index 499204d..0000000 --- a/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 windows - -package ipv6 - -import ( - "net" - "syscall" -) - -// ReadFrom reads a payload of the received IPv6 datagram, from the -// endpoint c, copying the payload into b. It returns the number of -// bytes copied into b, the control message cm and the source address -// src of the received datagram. -func (c *payloadHandler) ReadFrom(b []byte) (n int, cm *ControlMessage, src net.Addr, err error) { - if !c.ok() { - return 0, nil, nil, syscall.EINVAL - } - if n, src, err = c.PacketConn.ReadFrom(b); err != nil { - return 0, nil, nil, err - } - return -} - -// WriteTo writes a payload of the IPv6 datagram, to the destination -// address dst through the endpoint c, copying the payload from b. It -// returns the number of bytes written. The control message cm allows -// the IPv6 header fields and the datagram path to be specified. The -// cm may be nil if control of the outgoing datagram is not required. -func (c *payloadHandler) WriteTo(b []byte, cm *ControlMessage, dst net.Addr) (n int, err error) { - if !c.ok() { - return 0, syscall.EINVAL - } - if dst == nil { - return 0, errMissingAddress - } - return c.PacketConn.WriteTo(b, dst) -} diff --git a/vendor/golang.org/x/net/ipv6/readwrite_test.go b/vendor/golang.org/x/net/ipv6/readwrite_test.go deleted file mode 100644 index 8c8c6fd..0000000 --- a/vendor/golang.org/x/net/ipv6/readwrite_test.go +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "bytes" - "net" - "runtime" - "strings" - "sync" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -func benchmarkUDPListener() (net.PacketConn, net.Addr, error) { - c, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - return nil, nil, err - } - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String()) - if err != nil { - c.Close() - return nil, nil, err - } - return c, dst, nil -} - -func BenchmarkReadWriteNetUDP(b *testing.B) { - if !supportsIPv6 { - b.Skip("ipv6 is not supported") - } - - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteNetUDP(b, c, wb, rb, dst) - } -} - -func benchmarkReadWriteNetUDP(b *testing.B, c net.PacketConn, wb, rb []byte, dst net.Addr) { - if _, err := c.WriteTo(wb, dst); err != nil { - b.Fatal(err) - } - if _, _, err := c.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func BenchmarkReadWriteIPv6UDP(b *testing.B) { - if !supportsIPv6 { - b.Skip("ipv6 is not supported") - } - - c, dst, err := benchmarkUDPListener() - if err != nil { - b.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - if err := p.SetControlMessage(cf, true); err != nil { - b.Fatal(err) - } - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - - wb, rb := []byte("HELLO-R-U-THERE"), make([]byte, 128) - b.ResetTimer() - for i := 0; i < b.N; i++ { - benchmarkReadWriteIPv6UDP(b, p, wb, rb, dst, ifi) - } -} - -func benchmarkReadWriteIPv6UDP(b *testing.B, p *ipv6.PacketConn, wb, rb []byte, dst net.Addr, ifi *net.Interface) { - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - HopLimit: 1, - } - if ifi != nil { - cm.IfIndex = ifi.Index - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - b.Fatal(err) - } else if n != len(wb) { - b.Fatalf("got %v; want %v", n, len(wb)) - } - if _, _, _, err := p.ReadFrom(rb); err != nil { - b.Fatal(err) - } -} - -func TestPacketConnConcurrentReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - c, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - wb := []byte("HELLO-R-U-THERE") - - if err := p.SetControlMessage(cf, true); err != nil { // probe before test - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - - var wg sync.WaitGroup - reader := func() { - defer wg.Done() - rb := make([]byte, 128) - if n, cm, _, err := p.ReadFrom(rb); err != nil { - t.Error(err) - return - } else if !bytes.Equal(rb[:n], wb) { - t.Errorf("got %v; want %v", rb[:n], wb) - return - } else { - s := cm.String() - if strings.Contains(s, ",") { - t.Errorf("should be space-separated values: %s", s) - } - } - } - writer := func(toggle bool) { - defer wg.Done() - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - } - if ifi != nil { - cm.IfIndex = ifi.Index - } - if err := p.SetControlMessage(cf, toggle); err != nil { - t.Error(err) - return - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Error(err) - return - } else if n != len(wb) { - t.Errorf("got %v; want %v", n, len(wb)) - return - } - } - - const N = 10 - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Add(2 * N) - for i := 0; i < 2*N; i++ { - go writer(i%2 != 0) - } - wg.Add(N) - for i := 0; i < N; i++ { - go reader() - } - wg.Wait() -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt.go b/vendor/golang.org/x/net/ipv6/sockopt.go deleted file mode 100644 index f0cfc2f..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -// Sticky socket options -const ( - ssoTrafficClass = iota // header field for unicast packet, RFC 3542 - ssoHopLimit // header field for unicast packet, RFC 3493 - ssoMulticastInterface // outbound interface for multicast packet, RFC 3493 - ssoMulticastHopLimit // header field for multicast packet, RFC 3493 - ssoMulticastLoopback // loopback for multicast packet, RFC 3493 - ssoReceiveTrafficClass // header field on received packet, RFC 3542 - ssoReceiveHopLimit // header field on received packet, RFC 2292 or 3542 - ssoReceivePacketInfo // incbound or outbound packet path, RFC 2292 or 3542 - ssoReceivePathMTU // path mtu, RFC 3542 - ssoPathMTU // path mtu, RFC 3542 - ssoChecksum // packet checksum, RFC 2292 or 3542 - ssoICMPFilter // icmp filter, RFC 2292 or 3542 - ssoJoinGroup // any-source multicast, RFC 3493 - ssoLeaveGroup // any-source multicast, RFC 3493 - ssoJoinSourceGroup // source-specific multicast - ssoLeaveSourceGroup // source-specific multicast - ssoBlockSourceGroup // any-source or source-specific multicast - ssoUnblockSourceGroup // any-source or source-specific multicast - ssoMax -) - -// Sticky socket option value types -const ( - ssoTypeInt = iota + 1 - ssoTypeInterface - ssoTypeICMPFilter - ssoTypeMTUInfo - ssoTypeIPMreq - ssoTypeGroupReq - ssoTypeGroupSourceReq -) - -// A sockOpt represents a binding for sticky socket option. -type sockOpt struct { - level int // option level - name int // option name, must be equal or greater than 1 - typ int // option value type, must be equal or greater than 1 -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_asmreq_unix.go b/vendor/golang.org/x/net/ipv6/sockopt_asmreq_unix.go deleted file mode 100644 index b7fd4fe..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_asmreq_unix.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv6 - -import ( - "net" - "os" - "unsafe" -) - -func setsockoptIPMreq(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - var mreq sysIPv6Mreq - copy(mreq.Multiaddr[:], grp) - if ifi != nil { - mreq.setIfindex(ifi.Index) - } - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&mreq), sysSizeofIPv6Mreq)) -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_asmreq_windows.go b/vendor/golang.org/x/net/ipv6/sockopt_asmreq_windows.go deleted file mode 100644 index c03c731..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_asmreq_windows.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "os" - "syscall" - "unsafe" -) - -func setsockoptIPMreq(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - var mreq sysIPv6Mreq - copy(mreq.Multiaddr[:], grp) - if ifi != nil { - mreq.setIfindex(ifi.Index) - } - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&mreq)), sysSizeofIPv6Mreq)) -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go b/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go deleted file mode 100644 index 7732e49..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_stub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !darwin,!freebsd,!linux - -package ipv6 - -import "net" - -func setsockoptGroupReq(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - return errOpNoSupport -} - -func setsockoptGroupSourceReq(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go b/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go deleted file mode 100644 index a36a7e0..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_ssmreq_unix.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin freebsd linux - -package ipv6 - -import ( - "net" - "os" - "unsafe" -) - -var freebsd32o64 bool - -func setsockoptGroupReq(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - var gr sysGroupReq - if ifi != nil { - gr.Interface = uint32(ifi.Index) - } - gr.setGroup(grp) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sysSizeofGroupReq + 4]byte - s := (*[sysSizeofGroupReq]byte)(unsafe.Pointer(&gr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sysSizeofGroupReq + 4 - } else { - p = unsafe.Pointer(&gr) - l = sysSizeofGroupReq - } - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, p, l)) -} - -func setsockoptGroupSourceReq(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - var gsr sysGroupSourceReq - if ifi != nil { - gsr.Interface = uint32(ifi.Index) - } - gsr.setSourceGroup(grp, src) - var p unsafe.Pointer - var l uint32 - if freebsd32o64 { - var d [sysSizeofGroupSourceReq + 4]byte - s := (*[sysSizeofGroupSourceReq]byte)(unsafe.Pointer(&gsr)) - copy(d[:4], s[:4]) - copy(d[8:], s[4:]) - p = unsafe.Pointer(&d[0]) - l = sysSizeofGroupSourceReq + 4 - } else { - p = unsafe.Pointer(&gsr) - l = sysSizeofGroupSourceReq - } - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, p, l)) -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_stub.go b/vendor/golang.org/x/net/ipv6/sockopt_stub.go deleted file mode 100644 index b8dacfd..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv6 - -import "net" - -func getMTUInfo(fd int, opt *sockOpt) (*net.Interface, int, error) { - return nil, 0, errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_test.go b/vendor/golang.org/x/net/ipv6/sockopt_test.go deleted file mode 100644 index 9c21903..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_test.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "fmt" - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -var supportsIPv6 bool = nettest.SupportsIPv6() - -func TestConnInitiatorPathMTU(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - ln, err := net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - done := make(chan bool) - go acceptor(t, ln, done) - - c, err := net.Dial("tcp6", ln.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels don't support IPV6_PATHMTU option - t.Logf("not supported on %s", runtime.GOOS) - default: - t.Fatal(err) - } - } else { - t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu) - } - - <-done -} - -func TestConnResponderPathMTU(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - ln, err := net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - done := make(chan bool) - go connector(t, "tcp6", ln.Addr().String(), done) - - c, err := ln.Accept() - if err != nil { - t.Fatal(err) - } - defer c.Close() - - if pmtu, err := ipv6.NewConn(c).PathMTU(); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels don't support IPV6_PATHMTU option - t.Logf("not supported on %s", runtime.GOOS) - default: - t.Fatal(err) - } - } else { - t.Logf("path mtu for %v: %v", c.RemoteAddr(), pmtu) - } - - <-done -} - -func TestPacketConnChecksum(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket(fmt.Sprintf("ip6:%d", iana.ProtocolOSPFIGP), "::") // OSPF for IPv6 - if err != nil { - t.Fatal(err) - } - defer c.Close() - - p := ipv6.NewPacketConn(c) - offset := 12 // see RFC 5340 - - for _, toggle := range []bool{false, true} { - if err := p.SetChecksum(toggle, offset); err != nil { - if toggle { - t.Fatalf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err) - } else { - // Some platforms never allow to disable the kernel - // checksum processing. - t.Logf("ipv6.PacketConn.SetChecksum(%v, %v) failed: %v", toggle, offset, err) - } - } - if on, offset, err := p.Checksum(); err != nil { - t.Fatal(err) - } else { - t.Logf("kernel checksum processing enabled=%v, offset=%v", on, offset) - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_unix.go b/vendor/golang.org/x/net/ipv6/sockopt_unix.go deleted file mode 100644 index 7115b18..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_unix.go +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux netbsd openbsd - -package ipv6 - -import ( - "net" - "os" - "unsafe" -) - -func getInt(fd int, opt *sockOpt) (int, error) { - if opt.name < 1 || opt.typ != ssoTypeInt { - return 0, errOpNoSupport - } - var i int32 - l := uint32(4) - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), &l); err != nil { - return 0, os.NewSyscallError("getsockopt", err) - } - return int(i), nil -} - -func setInt(fd int, opt *sockOpt, v int) error { - if opt.name < 1 || opt.typ != ssoTypeInt { - return errOpNoSupport - } - i := int32(v) - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), 4)) -} - -func getInterface(fd int, opt *sockOpt) (*net.Interface, error) { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return nil, errOpNoSupport - } - var i int32 - l := uint32(4) - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - if i == 0 { - return nil, nil - } - ifi, err := net.InterfaceByIndex(int(i)) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setInterface(fd int, opt *sockOpt, ifi *net.Interface) error { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return errOpNoSupport - } - var i int32 - if ifi != nil { - i = int32(ifi.Index) - } - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&i), 4)) -} - -func getICMPFilter(fd int, opt *sockOpt) (*ICMPFilter, error) { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return nil, errOpNoSupport - } - var f ICMPFilter - l := uint32(sysSizeofICMPv6Filter) - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&f.sysICMPv6Filter), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - return &f, nil -} - -func setICMPFilter(fd int, opt *sockOpt, f *ICMPFilter) error { - if opt.name < 1 || opt.typ != ssoTypeICMPFilter { - return errOpNoSupport - } - return os.NewSyscallError("setsockopt", setsockopt(fd, opt.level, opt.name, unsafe.Pointer(&f.sysICMPv6Filter), sysSizeofICMPv6Filter)) -} - -func getMTUInfo(fd int, opt *sockOpt) (*net.Interface, int, error) { - if opt.name < 1 || opt.typ != ssoTypeMTUInfo { - return nil, 0, errOpNoSupport - } - var mi sysIPv6Mtuinfo - l := uint32(sysSizeofIPv6Mtuinfo) - if err := getsockopt(fd, opt.level, opt.name, unsafe.Pointer(&mi), &l); err != nil { - return nil, 0, os.NewSyscallError("getsockopt", err) - } - if mi.Addr.Scope_id == 0 { - return nil, int(mi.Mtu), nil - } - ifi, err := net.InterfaceByIndex(int(mi.Addr.Scope_id)) - if err != nil { - return nil, 0, err - } - return ifi, int(mi.Mtu), nil -} - -func setGroup(fd int, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - if opt.name < 1 { - return errOpNoSupport - } - switch opt.typ { - case ssoTypeIPMreq: - return setsockoptIPMreq(fd, opt, ifi, grp) - case ssoTypeGroupReq: - return setsockoptGroupReq(fd, opt, ifi, grp) - default: - return errOpNoSupport - } -} - -func setSourceGroup(fd int, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - if opt.name < 1 || opt.typ != ssoTypeGroupSourceReq { - return errOpNoSupport - } - return setsockoptGroupSourceReq(fd, opt, ifi, grp, src) -} diff --git a/vendor/golang.org/x/net/ipv6/sockopt_windows.go b/vendor/golang.org/x/net/ipv6/sockopt_windows.go deleted file mode 100644 index 32c73b7..0000000 --- a/vendor/golang.org/x/net/ipv6/sockopt_windows.go +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "os" - "syscall" - "unsafe" -) - -func getInt(fd syscall.Handle, opt *sockOpt) (int, error) { - if opt.name < 1 || opt.typ != ssoTypeInt { - return 0, errOpNoSupport - } - var i int32 - l := int32(4) - if err := syscall.Getsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil { - return 0, os.NewSyscallError("getsockopt", err) - } - return int(i), nil -} - -func setInt(fd syscall.Handle, opt *sockOpt, v int) error { - if opt.name < 1 || opt.typ != ssoTypeInt { - return errOpNoSupport - } - i := int32(v) - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4)) -} - -func getInterface(fd syscall.Handle, opt *sockOpt) (*net.Interface, error) { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return nil, errOpNoSupport - } - var i int32 - l := int32(4) - if err := syscall.Getsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), &l); err != nil { - return nil, os.NewSyscallError("getsockopt", err) - } - if i == 0 { - return nil, nil - } - ifi, err := net.InterfaceByIndex(int(i)) - if err != nil { - return nil, err - } - return ifi, nil -} - -func setInterface(fd syscall.Handle, opt *sockOpt, ifi *net.Interface) error { - if opt.name < 1 || opt.typ != ssoTypeInterface { - return errOpNoSupport - } - var i int32 - if ifi != nil { - i = int32(ifi.Index) - } - return os.NewSyscallError("setsockopt", syscall.Setsockopt(fd, int32(opt.level), int32(opt.name), (*byte)(unsafe.Pointer(&i)), 4)) -} - -func getICMPFilter(fd syscall.Handle, opt *sockOpt) (*ICMPFilter, error) { - return nil, errOpNoSupport -} - -func setICMPFilter(fd syscall.Handle, opt *sockOpt, f *ICMPFilter) error { - return errOpNoSupport -} - -func getMTUInfo(fd syscall.Handle, opt *sockOpt) (*net.Interface, int, error) { - return nil, 0, errOpNoSupport -} - -func setGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp net.IP) error { - if opt.name < 1 || opt.typ != ssoTypeIPMreq { - return errOpNoSupport - } - return setsockoptIPMreq(fd, opt, ifi, grp) -} - -func setSourceGroup(fd syscall.Handle, opt *sockOpt, ifi *net.Interface, grp, src net.IP) error { - // TODO(mikio): implement this - return errOpNoSupport -} diff --git a/vendor/golang.org/x/net/ipv6/sys_bsd.go b/vendor/golang.org/x/net/ipv6/sys_bsd.go deleted file mode 100644 index 0ee43e6..0000000 --- a/vendor/golang.org/x/net/ipv6/sys_bsd.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build dragonfly netbsd openbsd - -package ipv6 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sysSizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sysSizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sysSizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt}, - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt}, - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt}, - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo}, - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq}, - } -) - -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *sysInet6Pktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (mreq *sysIPv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_darwin.go b/vendor/golang.org/x/net/ipv6/sys_darwin.go deleted file mode 100644 index c263f08..0000000 --- a/vendor/golang.org/x/net/ipv6/sys_darwin.go +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlHopLimit: {sysIPV6_2292HOPLIMIT, 4, marshal2292HopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_2292PKTINFO, sysSizeofInet6Pktinfo, marshal2292PacketInfo, parsePacketInfo}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_2292HOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_2292PKTINFO, ssoTypeInt}, - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq}, - } -) - -func init() { - // Seems like kern.osreldate is veiled on latest OS X. We use - // kern.osrelease instead. - osver, err := syscall.Sysctl("kern.osrelease") - if err != nil { - return - } - var i int - for i = range osver { - if osver[i] == '.' { - break - } - } - // The IP_PKTINFO and protocol-independent multicast API were - // introduced in OS X 10.7 (Darwin 11.0.0). But it looks like - // those features require OS X 10.8 (Darwin 12.0.0) and above. - // See http://support.apple.com/kb/HT1633. - if i > 2 || i == 2 && osver[0] >= '1' && osver[1] >= '2' { - ctlOpts[ctlTrafficClass].name = sysIPV6_TCLASS - ctlOpts[ctlTrafficClass].length = 4 - ctlOpts[ctlTrafficClass].marshal = marshalTrafficClass - ctlOpts[ctlTrafficClass].parse = parseTrafficClass - ctlOpts[ctlHopLimit].name = sysIPV6_HOPLIMIT - ctlOpts[ctlHopLimit].marshal = marshalHopLimit - ctlOpts[ctlPacketInfo].name = sysIPV6_PKTINFO - ctlOpts[ctlPacketInfo].marshal = marshalPacketInfo - ctlOpts[ctlNextHop].name = sysIPV6_NEXTHOP - ctlOpts[ctlNextHop].length = sysSizeofSockaddrInet6 - ctlOpts[ctlNextHop].marshal = marshalNextHop - ctlOpts[ctlNextHop].parse = parseNextHop - ctlOpts[ctlPathMTU].name = sysIPV6_PATHMTU - ctlOpts[ctlPathMTU].length = sysSizeofIPv6Mtuinfo - ctlOpts[ctlPathMTU].marshal = marshalPathMTU - ctlOpts[ctlPathMTU].parse = parsePathMTU - sockOpts[ssoTrafficClass].level = iana.ProtocolIPv6 - sockOpts[ssoTrafficClass].name = sysIPV6_TCLASS - sockOpts[ssoTrafficClass].typ = ssoTypeInt - sockOpts[ssoReceiveTrafficClass].level = iana.ProtocolIPv6 - sockOpts[ssoReceiveTrafficClass].name = sysIPV6_RECVTCLASS - sockOpts[ssoReceiveTrafficClass].typ = ssoTypeInt - sockOpts[ssoReceiveHopLimit].name = sysIPV6_RECVHOPLIMIT - sockOpts[ssoReceivePacketInfo].name = sysIPV6_RECVPKTINFO - sockOpts[ssoReceivePathMTU].level = iana.ProtocolIPv6 - sockOpts[ssoReceivePathMTU].name = sysIPV6_RECVPATHMTU - sockOpts[ssoReceivePathMTU].typ = ssoTypeInt - sockOpts[ssoPathMTU].level = iana.ProtocolIPv6 - sockOpts[ssoPathMTU].name = sysIPV6_PATHMTU - sockOpts[ssoPathMTU].typ = ssoTypeMTUInfo - sockOpts[ssoJoinGroup].name = sysMCAST_JOIN_GROUP - sockOpts[ssoJoinGroup].typ = ssoTypeGroupReq - sockOpts[ssoLeaveGroup].name = sysMCAST_LEAVE_GROUP - sockOpts[ssoLeaveGroup].typ = ssoTypeGroupReq - sockOpts[ssoJoinSourceGroup].level = iana.ProtocolIPv6 - sockOpts[ssoJoinSourceGroup].name = sysMCAST_JOIN_SOURCE_GROUP - sockOpts[ssoJoinSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoLeaveSourceGroup].level = iana.ProtocolIPv6 - sockOpts[ssoLeaveSourceGroup].name = sysMCAST_LEAVE_SOURCE_GROUP - sockOpts[ssoLeaveSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoBlockSourceGroup].level = iana.ProtocolIPv6 - sockOpts[ssoBlockSourceGroup].name = sysMCAST_BLOCK_SOURCE - sockOpts[ssoBlockSourceGroup].typ = ssoTypeGroupSourceReq - sockOpts[ssoUnblockSourceGroup].level = iana.ProtocolIPv6 - sockOpts[ssoUnblockSourceGroup].name = sysMCAST_UNBLOCK_SOURCE - sockOpts[ssoUnblockSourceGroup].typ = ssoTypeGroupSourceReq - } -} - -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *sysInet6Pktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (mreq *sysIPv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} - -func (gr *sysGroupReq) setGroup(grp net.IP) { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gr.Pad_cgo_0[0])) - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) -} - -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Pad_cgo_0[0])) - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) - sa = (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Pad_cgo_1[0])) - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_freebsd.go b/vendor/golang.org/x/net/ipv6/sys_freebsd.go deleted file mode 100644 index 5527001..0000000 --- a/vendor/golang.org/x/net/ipv6/sys_freebsd.go +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "runtime" - "strings" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sysSizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlNextHop: {sysIPV6_NEXTHOP, sysSizeofSockaddrInet6, marshalNextHop, parseNextHop}, - ctlPathMTU: {sysIPV6_PATHMTU, sysSizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt}, - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt}, - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt}, - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo}, - ssoChecksum: {iana.ProtocolIPv6, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMP6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func init() { - if runtime.GOOS == "freebsd" && runtime.GOARCH == "386" { - archs, _ := syscall.Sysctl("kern.supported_archs") - for _, s := range strings.Fields(archs) { - if s == "amd64" { - freebsd32o64 = true - break - } - } - } -} - -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *sysInet6Pktinfo) setIfindex(i int) { - pi.Ifindex = uint32(i) -} - -func (mreq *sysIPv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} - -func (gr *sysGroupReq) setGroup(grp net.IP) { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gr.Group)) - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) -} - -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Group)) - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) - sa = (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Source)) - sa.Len = sysSizeofSockaddrInet6 - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_linux.go b/vendor/golang.org/x/net/ipv6/sys_linux.go deleted file mode 100644 index fd7d5b1..0000000 --- a/vendor/golang.org/x/net/ipv6/sys_linux.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - "unsafe" - - "golang.org/x/net/internal/iana" -) - -var ( - ctlOpts = [ctlMax]ctlOpt{ - ctlTrafficClass: {sysIPV6_TCLASS, 4, marshalTrafficClass, parseTrafficClass}, - ctlHopLimit: {sysIPV6_HOPLIMIT, 4, marshalHopLimit, parseHopLimit}, - ctlPacketInfo: {sysIPV6_PKTINFO, sysSizeofInet6Pktinfo, marshalPacketInfo, parsePacketInfo}, - ctlPathMTU: {sysIPV6_PATHMTU, sysSizeofIPv6Mtuinfo, marshalPathMTU, parsePathMTU}, - } - - sockOpts = [ssoMax]sockOpt{ - ssoTrafficClass: {iana.ProtocolIPv6, sysIPV6_TCLASS, ssoTypeInt}, - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoReceiveTrafficClass: {iana.ProtocolIPv6, sysIPV6_RECVTCLASS, ssoTypeInt}, - ssoReceiveHopLimit: {iana.ProtocolIPv6, sysIPV6_RECVHOPLIMIT, ssoTypeInt}, - ssoReceivePacketInfo: {iana.ProtocolIPv6, sysIPV6_RECVPKTINFO, ssoTypeInt}, - ssoReceivePathMTU: {iana.ProtocolIPv6, sysIPV6_RECVPATHMTU, ssoTypeInt}, - ssoPathMTU: {iana.ProtocolIPv6, sysIPV6_PATHMTU, ssoTypeMTUInfo}, - ssoChecksum: {iana.ProtocolReserved, sysIPV6_CHECKSUM, ssoTypeInt}, - ssoICMPFilter: {iana.ProtocolIPv6ICMP, sysICMPV6_FILTER, ssoTypeICMPFilter}, - ssoJoinGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_GROUP, ssoTypeGroupReq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_GROUP, ssoTypeGroupReq}, - ssoJoinSourceGroup: {iana.ProtocolIPv6, sysMCAST_JOIN_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoLeaveSourceGroup: {iana.ProtocolIPv6, sysMCAST_LEAVE_SOURCE_GROUP, ssoTypeGroupSourceReq}, - ssoBlockSourceGroup: {iana.ProtocolIPv6, sysMCAST_BLOCK_SOURCE, ssoTypeGroupSourceReq}, - ssoUnblockSourceGroup: {iana.ProtocolIPv6, sysMCAST_UNBLOCK_SOURCE, ssoTypeGroupSourceReq}, - } -) - -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (pi *sysInet6Pktinfo) setIfindex(i int) { - pi.Ifindex = int32(i) -} - -func (mreq *sysIPv6Mreq) setIfindex(i int) { - mreq.Ifindex = int32(i) -} - -func (gr *sysGroupReq) setGroup(grp net.IP) { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gr.Group)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) -} - -func (gsr *sysGroupSourceReq) setSourceGroup(grp, src net.IP) { - sa := (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Group)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], grp) - sa = (*sysSockaddrInet6)(unsafe.Pointer(&gsr.Source)) - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], src) -} diff --git a/vendor/golang.org/x/net/ipv6/sys_stub.go b/vendor/golang.org/x/net/ipv6/sys_stub.go deleted file mode 100644 index ead0f4d..0000000 --- a/vendor/golang.org/x/net/ipv6/sys_stub.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build nacl plan9 solaris - -package ipv6 - -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{} -) diff --git a/vendor/golang.org/x/net/ipv6/sys_windows.go b/vendor/golang.org/x/net/ipv6/sys_windows.go deleted file mode 100644 index fda8757..0000000 --- a/vendor/golang.org/x/net/ipv6/sys_windows.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "net" - "syscall" - - "golang.org/x/net/internal/iana" -) - -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 - - sysSizeofSockaddrInet6 = 0x1c - - sysSizeofIPv6Mreq = 0x14 -) - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -var ( - ctlOpts = [ctlMax]ctlOpt{} - - sockOpts = [ssoMax]sockOpt{ - ssoHopLimit: {iana.ProtocolIPv6, sysIPV6_UNICAST_HOPS, ssoTypeInt}, - ssoMulticastInterface: {iana.ProtocolIPv6, sysIPV6_MULTICAST_IF, ssoTypeInterface}, - ssoMulticastHopLimit: {iana.ProtocolIPv6, sysIPV6_MULTICAST_HOPS, ssoTypeInt}, - ssoMulticastLoopback: {iana.ProtocolIPv6, sysIPV6_MULTICAST_LOOP, ssoTypeInt}, - ssoJoinGroup: {iana.ProtocolIPv6, sysIPV6_JOIN_GROUP, ssoTypeIPMreq}, - ssoLeaveGroup: {iana.ProtocolIPv6, sysIPV6_LEAVE_GROUP, ssoTypeIPMreq}, - } -) - -func (sa *sysSockaddrInet6) setSockaddr(ip net.IP, i int) { - sa.Family = syscall.AF_INET6 - copy(sa.Addr[:], ip) - sa.Scope_id = uint32(i) -} - -func (mreq *sysIPv6Mreq) setIfindex(i int) { - mreq.Interface = uint32(i) -} diff --git a/vendor/golang.org/x/net/ipv6/syscall_linux_386.go b/vendor/golang.org/x/net/ipv6/syscall_linux_386.go deleted file mode 100644 index 64a3c66..0000000 --- a/vendor/golang.org/x/net/ipv6/syscall_linux_386.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6 - -import ( - "syscall" - "unsafe" -) - -const ( - sysGETSOCKOPT = 0xf - sysSETSOCKOPT = 0xe -) - -func socketcall(call int, a0, a1, a2, a3, a4, a5 uintptr) (int, syscall.Errno) - -func getsockopt(fd, level, name int, v unsafe.Pointer, l *uint32) error { - if _, errno := socketcall(sysGETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(fd, level, name int, v unsafe.Pointer, l uint32) error { - if _, errno := socketcall(sysSETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/syscall_unix.go b/vendor/golang.org/x/net/ipv6/syscall_unix.go deleted file mode 100644 index 925fd2f..0000000 --- a/vendor/golang.org/x/net/ipv6/syscall_unix.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd linux,!386 netbsd openbsd - -package ipv6 - -import ( - "syscall" - "unsafe" -) - -func getsockopt(fd, level, name int, v unsafe.Pointer, l *uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_GETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(unsafe.Pointer(l)), 0); errno != 0 { - return error(errno) - } - return nil -} - -func setsockopt(fd, level, name int, v unsafe.Pointer, l uint32) error { - if _, _, errno := syscall.Syscall6(syscall.SYS_SETSOCKOPT, uintptr(fd), uintptr(level), uintptr(name), uintptr(v), uintptr(l), 0); errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/ipv6/thunk_linux_386.s b/vendor/golang.org/x/net/ipv6/thunk_linux_386.s deleted file mode 100644 index daa78bc..0000000 --- a/vendor/golang.org/x/net/ipv6/thunk_linux_386.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.2 - -TEXT ·socketcall(SB),4,$0-36 - JMP syscall·socketcall(SB) diff --git a/vendor/golang.org/x/net/ipv6/unicast_test.go b/vendor/golang.org/x/net/ipv6/unicast_test.go deleted file mode 100644 index db5b08a..0000000 --- a/vendor/golang.org/x/net/ipv6/unicast_test.go +++ /dev/null @@ -1,182 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "bytes" - "net" - "os" - "runtime" - "testing" - "time" - - "golang.org/x/net/icmp" - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -func TestPacketConnReadWriteUnicastUDP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - c, err := net.ListenPacket("udp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveUDPAddr("udp6", c.LocalAddr().String()) - if err != nil { - t.Fatal(err) - } - - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - if ifi != nil { - cm.IfIndex = ifi.Index - } - wb := []byte("HELLO-R-U-THERE") - - for i, toggle := range []bool{true, false, true} { - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - cm.HopLimit = i + 1 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - t.Fatal(err) - } else if !bytes.Equal(rb[:n], wb) { - t.Fatalf("got %v; want %v", rb[:n], wb) - } - } -} - -func TestPacketConnReadWriteUnicastICMP(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - if m, ok := nettest.SupportsRawIPSocket(); !ok { - t.Skip(m) - } - - c, err := net.ListenPacket("ip6:ipv6-icmp", "::1") - if err != nil { - t.Fatal(err) - } - defer c.Close() - p := ipv6.NewPacketConn(c) - defer p.Close() - - dst, err := net.ResolveIPAddr("ip6", "::1") - if err != nil { - t.Fatal(err) - } - - pshicmp := icmp.IPv6PseudoHeader(c.LocalAddr().(*net.IPAddr).IP, dst.IP) - cm := ipv6.ControlMessage{ - TrafficClass: iana.DiffServAF11 | iana.CongestionExperienced, - Src: net.IPv6loopback, - } - cf := ipv6.FlagTrafficClass | ipv6.FlagHopLimit | ipv6.FlagSrc | ipv6.FlagDst | ipv6.FlagInterface | ipv6.FlagPathMTU - ifi := nettest.RoutedInterface("ip6", net.FlagUp|net.FlagLoopback) - if ifi != nil { - cm.IfIndex = ifi.Index - } - - var f ipv6.ICMPFilter - f.SetAll(true) - f.Accept(ipv6.ICMPTypeEchoReply) - if err := p.SetICMPFilter(&f); err != nil { - t.Fatal(err) - } - - var psh []byte - for i, toggle := range []bool{true, false, true} { - if toggle { - psh = nil - if err := p.SetChecksum(true, 2); err != nil { - t.Fatal(err) - } - } else { - psh = pshicmp - // Some platforms never allow to disable the - // kernel checksum processing. - p.SetChecksum(false, -1) - } - wb, err := (&icmp.Message{ - Type: ipv6.ICMPTypeEchoRequest, Code: 0, - Body: &icmp.Echo{ - ID: os.Getpid() & 0xffff, Seq: i + 1, - Data: []byte("HELLO-R-U-THERE"), - }, - }).Marshal(psh) - if err != nil { - t.Fatal(err) - } - if err := p.SetControlMessage(cf, toggle); err != nil { - if nettest.ProtocolNotSupported(err) { - t.Skipf("not supported on %s", runtime.GOOS) - } - t.Fatal(err) - } - cm.HopLimit = i + 1 - if err := p.SetWriteDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, err := p.WriteTo(wb, &cm, dst); err != nil { - t.Fatal(err) - } else if n != len(wb) { - t.Fatalf("got %v; want %v", n, len(wb)) - } - rb := make([]byte, 128) - if err := p.SetReadDeadline(time.Now().Add(100 * time.Millisecond)); err != nil { - t.Fatal(err) - } - if n, _, _, err := p.ReadFrom(rb); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels have some limitation on receiving icmp packet through raw socket - t.Logf("not supported on %s", runtime.GOOS) - continue - } - t.Fatal(err) - } else { - if m, err := icmp.ParseMessage(iana.ProtocolIPv6ICMP, rb[:n]); err != nil { - t.Fatal(err) - } else if m.Type != ipv6.ICMPTypeEchoReply || m.Code != 0 { - t.Fatalf("got type=%v, code=%v; want type=%v, code=%v", m.Type, m.Code, ipv6.ICMPTypeEchoReply, 0) - } - } - } -} diff --git a/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go b/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go deleted file mode 100644 index 7bb2e44..0000000 --- a/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package ipv6_test - -import ( - "net" - "runtime" - "testing" - - "golang.org/x/net/internal/iana" - "golang.org/x/net/internal/nettest" - "golang.org/x/net/ipv6" -) - -func TestConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - ln, err := net.Listen("tcp6", "[::1]:0") - if err != nil { - t.Fatal(err) - } - defer ln.Close() - - done := make(chan bool) - go acceptor(t, ln, done) - - c, err := net.Dial("tcp6", ln.Addr().String()) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv6.NewConn(c)) - - <-done -} - -var packetConnUnicastSocketOptionTests = []struct { - net, proto, addr string -}{ - {"udp6", "", "[::1]:0"}, - {"ip6", ":ipv6-icmp", "::1"}, -} - -func TestPacketConnUnicastSocketOptions(t *testing.T) { - switch runtime.GOOS { - case "nacl", "plan9", "solaris", "windows": - t.Skipf("not supported on %s", runtime.GOOS) - } - if !supportsIPv6 { - t.Skip("ipv6 is not supported") - } - - m, ok := nettest.SupportsRawIPSocket() - for _, tt := range packetConnUnicastSocketOptionTests { - if tt.net == "ip6" && !ok { - t.Log(m) - continue - } - c, err := net.ListenPacket(tt.net+tt.proto, tt.addr) - if err != nil { - t.Fatal(err) - } - defer c.Close() - - testUnicastSocketOptions(t, ipv6.NewPacketConn(c)) - } -} - -type testIPv6UnicastConn interface { - TrafficClass() (int, error) - SetTrafficClass(int) error - HopLimit() (int, error) - SetHopLimit(int) error -} - -func testUnicastSocketOptions(t *testing.T, c testIPv6UnicastConn) { - tclass := iana.DiffServCS0 | iana.NotECNTransport - if err := c.SetTrafficClass(tclass); err != nil { - switch runtime.GOOS { - case "darwin": // older darwin kernels don't support IPV6_TCLASS option - t.Logf("not supported on %s", runtime.GOOS) - goto next - } - t.Fatal(err) - } - if v, err := c.TrafficClass(); err != nil { - t.Fatal(err) - } else if v != tclass { - t.Fatalf("got %v; want %v", v, tclass) - } - -next: - hoplim := 255 - if err := c.SetHopLimit(hoplim); err != nil { - t.Fatal(err) - } - if v, err := c.HopLimit(); err != nil { - t.Fatal(err) - } else if v != hoplim { - t.Fatalf("got %v; want %v", v, hoplim) - } -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_darwin.go b/vendor/golang.org/x/net/ipv6/zsys_darwin.go deleted file mode 100644 index cb044b0..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_darwin.go +++ /dev/null @@ -1,131 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -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_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 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysICMPv6Filter struct { - Filt [8]uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [128]byte -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [128]byte - Pad_cgo_1 [128]byte -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go b/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go deleted file mode 100644 index 5a03ab7..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +++ /dev/null @@ -1,90 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -// +build dragonfly - -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_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 - - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - - sysSizeofIPv6Mreq = 0x14 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysICMPv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go b/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go deleted file mode 100644 index 4ace96f..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +++ /dev/null @@ -1,122 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -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_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 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysGroupReq struct { - Interface uint32 - Group sysSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Group sysSockaddrStorage - Source sysSockaddrStorage -} - -type sysICMPv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go deleted file mode 100644 index 4a62c2d..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +++ /dev/null @@ -1,124 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -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_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 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage - Source sysSockaddrStorage -} - -type sysICMPv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go b/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go deleted file mode 100644 index 4a62c2d..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +++ /dev/null @@ -1,124 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -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_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 - - sysSizeofSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrStorage struct { - Len uint8 - Family uint8 - X__ss_pad1 [6]int8 - X__ss_align int64 - X__ss_pad2 [112]int8 -} - -type sysSockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysSockaddrStorage - Source sysSockaddrStorage -} - -type sysICMPv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_386.go b/vendor/golang.org/x/net/ipv6/zsys_linux_386.go deleted file mode 100644 index 36fccbb..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +++ /dev/null @@ -1,168 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go deleted file mode 100644 index 7461e7e..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +++ /dev/null @@ -1,170 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go b/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go deleted file mode 100644 index 36fccbb..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +++ /dev/null @@ -1,168 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x84 - sysSizeofGroupSourceReq = 0x104 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [2]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go deleted file mode 100644 index ed35f60..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +++ /dev/null @@ -1,172 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,arm64 - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go deleted file mode 100644 index 141c869..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +++ /dev/null @@ -1,172 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,mips64 - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go b/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go deleted file mode 100644 index d50eb63..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +++ /dev/null @@ -1,172 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,mips64le - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go b/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go deleted file mode 100644 index c1d775f..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +++ /dev/null @@ -1,172 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,ppc64 - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go b/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go deleted file mode 100644 index e385fb7..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +++ /dev/null @@ -1,172 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,ppc64le - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go b/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go deleted file mode 100644 index 28d69b1..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +++ /dev/null @@ -1,172 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_linux.go - -// +build linux,s390x - -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 - - sysSOL_SOCKET = 0x1 - sysSO_ATTACH_FILTER = 0x1a - - sysSizeofKernelSockaddrStorage = 0x80 - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - sysSizeofIPv6FlowlabelReq = 0x20 - - sysSizeofIPv6Mreq = 0x14 - sysSizeofGroupReq = 0x88 - sysSizeofGroupSourceReq = 0x108 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysKernelSockaddrStorage struct { - Family uint16 - X__data [126]int8 -} - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6FlowlabelReq struct { - Dst [16]byte /* in6_addr */ - Label uint32 - Action uint8 - Share uint8 - Flags uint16 - Expires uint16 - Linger uint16 - X__flr_pad uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Ifindex int32 -} - -type sysGroupReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage -} - -type sysGroupSourceReq struct { - Interface uint32 - Pad_cgo_0 [4]byte - Group sysKernelSockaddrStorage - Source sysKernelSockaddrStorage -} - -type sysICMPv6Filter struct { - Data [8]uint32 -} - -type sysSockFProg struct { - Len uint16 - Pad_cgo_0 [6]byte - Filter *sysSockFilter -} - -type sysSockFilter struct { - Code uint16 - Jt uint8 - Jf uint8 - K uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_netbsd.go b/vendor/golang.org/x/net/ipv6/zsys_netbsd.go deleted file mode 100644 index d6ec88e..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +++ /dev/null @@ -1,84 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -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_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 - - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - - sysSizeofIPv6Mreq = 0x14 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysICMPv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_openbsd.go b/vendor/golang.org/x/net/ipv6/zsys_openbsd.go deleted file mode 100644 index 3e080b7..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +++ /dev/null @@ -1,93 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -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_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 - - sysSizeofSockaddrInet6 = 0x1c - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x20 - - sysSizeofIPv6Mreq = 0x14 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrInet6 struct { - Len uint8 - Family uint8 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysICMPv6Filter struct { - Filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/ipv6/zsys_solaris.go b/vendor/golang.org/x/net/ipv6/zsys_solaris.go deleted file mode 100644 index cdf00c2..0000000 --- a/vendor/golang.org/x/net/ipv6/zsys_solaris.go +++ /dev/null @@ -1,105 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_solaris.go - -// +build solaris - -package ipv6 - -const ( - sysIPV6_UNICAST_HOPS = 0x5 - sysIPV6_MULTICAST_IF = 0x6 - sysIPV6_MULTICAST_HOPS = 0x7 - sysIPV6_MULTICAST_LOOP = 0x8 - sysIPV6_JOIN_GROUP = 0x9 - sysIPV6_LEAVE_GROUP = 0xa - - sysIPV6_PKTINFO = 0xb - - sysIPV6_HOPLIMIT = 0xc - sysIPV6_NEXTHOP = 0xd - sysIPV6_HOPOPTS = 0xe - sysIPV6_DSTOPTS = 0xf - - sysIPV6_RTHDR = 0x10 - sysIPV6_RTHDRDSTOPTS = 0x11 - - sysIPV6_RECVPKTINFO = 0x12 - sysIPV6_RECVHOPLIMIT = 0x13 - sysIPV6_RECVHOPOPTS = 0x14 - - sysIPV6_RECVRTHDR = 0x16 - - sysIPV6_RECVRTHDRDSTOPTS = 0x17 - - sysIPV6_CHECKSUM = 0x18 - sysIPV6_RECVTCLASS = 0x19 - sysIPV6_USE_MIN_MTU = 0x20 - sysIPV6_DONTFRAG = 0x21 - sysIPV6_SEC_OPT = 0x22 - sysIPV6_SRC_PREFERENCES = 0x23 - sysIPV6_RECVPATHMTU = 0x24 - sysIPV6_PATHMTU = 0x25 - sysIPV6_TCLASS = 0x26 - sysIPV6_V6ONLY = 0x27 - - sysIPV6_RECVDSTOPTS = 0x28 - - sysIPV6_PREFER_SRC_HOME = 0x1 - sysIPV6_PREFER_SRC_COA = 0x2 - sysIPV6_PREFER_SRC_PUBLIC = 0x4 - sysIPV6_PREFER_SRC_TMP = 0x8 - sysIPV6_PREFER_SRC_NONCGA = 0x10 - sysIPV6_PREFER_SRC_CGA = 0x20 - - sysIPV6_PREFER_SRC_MIPMASK = 0x3 - sysIPV6_PREFER_SRC_MIPDEFAULT = 0x1 - sysIPV6_PREFER_SRC_TMPMASK = 0xc - sysIPV6_PREFER_SRC_TMPDEFAULT = 0x4 - sysIPV6_PREFER_SRC_CGAMASK = 0x30 - sysIPV6_PREFER_SRC_CGADEFAULT = 0x10 - - sysIPV6_PREFER_SRC_MASK = 0x3f - - sysIPV6_PREFER_SRC_DEFAULT = 0x15 - - sysIPV6_BOUND_IF = 0x41 - sysIPV6_UNSPEC_SRC = 0x42 - - sysICMP6_FILTER = 0x1 - - sysSizeofSockaddrInet6 = 0x20 - sysSizeofInet6Pktinfo = 0x14 - sysSizeofIPv6Mtuinfo = 0x24 - - sysSizeofIPv6Mreq = 0x14 - - sysSizeofICMPv6Filter = 0x20 -) - -type sysSockaddrInet6 struct { - Family uint16 - Port uint16 - Flowinfo uint32 - Addr [16]byte /* in6_addr */ - Scope_id uint32 - X__sin6_src_id uint32 -} - -type sysInet6Pktinfo struct { - Addr [16]byte /* in6_addr */ - Ifindex uint32 -} - -type sysIPv6Mtuinfo struct { - Addr sysSockaddrInet6 - Mtu uint32 -} - -type sysIPv6Mreq struct { - Multiaddr [16]byte /* in6_addr */ - Interface uint32 -} - -type sysICMPv6Filter struct { - X__icmp6_filt [8]uint32 -} diff --git a/vendor/golang.org/x/net/lex/httplex/httplex.go b/vendor/golang.org/x/net/lex/httplex/httplex.go deleted file mode 100644 index bd0ec24..0000000 --- a/vendor/golang.org/x/net/lex/httplex/httplex.go +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package httplex contains rules around lexical matters of various -// HTTP-related specifications. -// -// This package is shared by the standard library (which vendors it) -// and x/net/http2. It comes with no API stability promise. -package httplex - -import ( - "strings" - "unicode/utf8" -) - -var isTokenTable = [127]bool{ - '!': true, - '#': true, - '$': true, - '%': true, - '&': true, - '\'': true, - '*': true, - '+': true, - '-': true, - '.': true, - '0': true, - '1': true, - '2': true, - '3': true, - '4': true, - '5': true, - '6': true, - '7': true, - '8': true, - '9': true, - 'A': true, - 'B': true, - 'C': true, - 'D': true, - 'E': true, - 'F': true, - 'G': true, - 'H': true, - 'I': true, - 'J': true, - 'K': true, - 'L': true, - 'M': true, - 'N': true, - 'O': true, - 'P': true, - 'Q': true, - 'R': true, - 'S': true, - 'T': true, - 'U': true, - 'W': true, - 'V': true, - 'X': true, - 'Y': true, - 'Z': true, - '^': true, - '_': true, - '`': true, - 'a': true, - 'b': true, - 'c': true, - 'd': true, - 'e': true, - 'f': true, - 'g': true, - 'h': true, - 'i': true, - 'j': true, - 'k': true, - 'l': true, - 'm': true, - 'n': true, - 'o': true, - 'p': true, - 'q': true, - 'r': true, - 's': true, - 't': true, - 'u': true, - 'v': true, - 'w': true, - 'x': true, - 'y': true, - 'z': true, - '|': true, - '~': true, -} - -func IsTokenRune(r rune) bool { - i := int(r) - return i < len(isTokenTable) && isTokenTable[i] -} - -func isNotToken(r rune) bool { - return !IsTokenRune(r) -} - -// HeaderValuesContainsToken reports whether any string in values -// contains the provided token, ASCII case-insensitively. -func HeaderValuesContainsToken(values []string, token string) bool { - for _, v := range values { - if headerValueContainsToken(v, token) { - return true - } - } - return false -} - -// isOWS reports whether b is an optional whitespace byte, as defined -// by RFC 7230 section 3.2.3. -func isOWS(b byte) bool { return b == ' ' || b == '\t' } - -// trimOWS returns x with all optional whitespace removes from the -// beginning and end. -func trimOWS(x string) string { - // TODO: consider using strings.Trim(x, " \t") instead, - // if and when it's fast enough. See issue 10292. - // But this ASCII-only code will probably always beat UTF-8 - // aware code. - for len(x) > 0 && isOWS(x[0]) { - x = x[1:] - } - for len(x) > 0 && isOWS(x[len(x)-1]) { - x = x[:len(x)-1] - } - return x -} - -// headerValueContainsToken reports whether v (assumed to be a -// 0#element, in the ABNF extension described in RFC 7230 section 7) -// contains token amongst its comma-separated tokens, ASCII -// case-insensitively. -func headerValueContainsToken(v string, token string) bool { - v = trimOWS(v) - if comma := strings.IndexByte(v, ','); comma != -1 { - return tokenEqual(trimOWS(v[:comma]), token) || headerValueContainsToken(v[comma+1:], token) - } - return tokenEqual(v, token) -} - -// lowerASCII returns the ASCII lowercase version of b. -func lowerASCII(b byte) byte { - if 'A' <= b && b <= 'Z' { - return b + ('a' - 'A') - } - return b -} - -// tokenEqual reports whether t1 and t2 are equal, ASCII case-insensitively. -func tokenEqual(t1, t2 string) bool { - if len(t1) != len(t2) { - return false - } - for i, b := range t1 { - if b >= utf8.RuneSelf { - // No UTF-8 or non-ASCII allowed in tokens. - return false - } - if lowerASCII(byte(b)) != lowerASCII(t2[i]) { - return false - } - } - return true -} - -// isLWS reports whether b is linear white space, according -// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// LWS = [CRLF] 1*( SP | HT ) -func isLWS(b byte) bool { return b == ' ' || b == '\t' } - -// isCTL reports whether b is a control byte, according -// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 -// CTL = -func isCTL(b byte) bool { - const del = 0x7f // a CTL - return b < ' ' || b == del -} - -// ValidHeaderFieldName reports whether v is a valid HTTP/1.x header name. -// HTTP/2 imposes the additional restriction that uppercase ASCII -// letters are not allowed. -// -// RFC 7230 says: -// header-field = field-name ":" OWS field-value OWS -// field-name = token -// token = 1*tchar -// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." / -// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA -func ValidHeaderFieldName(v string) bool { - if len(v) == 0 { - return false - } - for _, r := range v { - if !IsTokenRune(r) { - return false - } - } - return true -} - -// ValidHostHeader reports whether h is a valid host header. -func ValidHostHeader(h string) bool { - // The latest spec is actually this: - // - // http://tools.ietf.org/html/rfc7230#section-5.4 - // Host = uri-host [ ":" port ] - // - // Where uri-host is: - // http://tools.ietf.org/html/rfc3986#section-3.2.2 - // - // But we're going to be much more lenient for now and just - // search for any byte that's not a valid byte in any of those - // expressions. - for i := 0; i < len(h); i++ { - if !validHostByte[h[i]] { - return false - } - } - return true -} - -// See the validHostHeader comment. -var validHostByte = [256]bool{ - '0': true, '1': true, '2': true, '3': true, '4': true, '5': true, '6': true, '7': true, - '8': true, '9': true, - - 'a': true, 'b': true, 'c': true, 'd': true, 'e': true, 'f': true, 'g': true, 'h': true, - 'i': true, 'j': true, 'k': true, 'l': true, 'm': true, 'n': true, 'o': true, 'p': true, - 'q': true, 'r': true, 's': true, 't': true, 'u': true, 'v': true, 'w': true, 'x': true, - 'y': true, 'z': true, - - 'A': true, 'B': true, 'C': true, 'D': true, 'E': true, 'F': true, 'G': true, 'H': true, - 'I': true, 'J': true, 'K': true, 'L': true, 'M': true, 'N': true, 'O': true, 'P': true, - 'Q': true, 'R': true, 'S': true, 'T': true, 'U': true, 'V': true, 'W': true, 'X': true, - 'Y': true, 'Z': true, - - '!': true, // sub-delims - '$': true, // sub-delims - '%': true, // pct-encoded (and used in IPv6 zones) - '&': true, // sub-delims - '(': true, // sub-delims - ')': true, // sub-delims - '*': true, // sub-delims - '+': true, // sub-delims - ',': true, // sub-delims - '-': true, // unreserved - '.': true, // unreserved - ':': true, // IPv6address + Host expression's optional port - ';': true, // sub-delims - '=': true, // sub-delims - '[': true, - '\'': true, // sub-delims - ']': true, - '_': true, // unreserved - '~': true, // unreserved -} - -// ValidHeaderFieldValue reports whether v is a valid "field-value" according to -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 : -// -// message-header = field-name ":" [ field-value ] -// field-value = *( field-content | LWS ) -// field-content = -// -// http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 : -// -// TEXT = -// LWS = [CRLF] 1*( SP | HT ) -// CTL = -// -// RFC 7230 says: -// field-value = *( field-content / obs-fold ) -// obj-fold = N/A to http2, and deprecated -// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ] -// field-vchar = VCHAR / obs-text -// obs-text = %x80-FF -// VCHAR = "any visible [USASCII] character" -// -// http2 further says: "Similarly, HTTP/2 allows header field values -// that are not valid. While most of the values that can be encoded -// will not alter header field parsing, carriage return (CR, ASCII -// 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII -// 0x0) might be exploited by an attacker if they are translated -// verbatim. Any request or response that contains a character not -// permitted in a header field value MUST be treated as malformed -// (Section 8.1.2.6). Valid characters are defined by the -// field-content ABNF rule in Section 3.2 of [RFC7230]." -// -// This function does not (yet?) properly handle the rejection of -// strings that begin or end with SP or HTAB. -func ValidHeaderFieldValue(v string) bool { - for i := 0; i < len(v); i++ { - b := v[i] - if isCTL(b) && !isLWS(b) { - return false - } - } - return true -} diff --git a/vendor/golang.org/x/net/lex/httplex/httplex_test.go b/vendor/golang.org/x/net/lex/httplex/httplex_test.go deleted file mode 100644 index c4ace19..0000000 --- a/vendor/golang.org/x/net/lex/httplex/httplex_test.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package httplex - -import ( - "testing" -) - -func isChar(c rune) bool { return c <= 127 } - -func isCtl(c rune) bool { return c <= 31 || c == 127 } - -func isSeparator(c rune) bool { - switch c { - case '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}', ' ', '\t': - return true - } - return false -} - -func TestIsToken(t *testing.T) { - for i := 0; i <= 130; i++ { - r := rune(i) - expected := isChar(r) && !isCtl(r) && !isSeparator(r) - if IsTokenRune(r) != expected { - t.Errorf("isToken(0x%x) = %v", r, !expected) - } - } -} - -func TestHeaderValuesContainsToken(t *testing.T) { - tests := []struct { - vals []string - token string - want bool - }{ - { - vals: []string{"foo"}, - token: "foo", - want: true, - }, - { - vals: []string{"bar", "foo"}, - token: "foo", - want: true, - }, - { - vals: []string{"foo"}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo"}, - token: "bar", - want: false, - }, - { - vals: []string{" foo "}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar,foo,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar , foo"}, - token: "FOO", - want: true, - }, - { - vals: []string{"foo ,bar "}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar, foo ,bar"}, - token: "FOO", - want: true, - }, - { - vals: []string{"bar , foo"}, - token: "FOO", - want: true, - }, - } - for _, tt := range tests { - got := HeaderValuesContainsToken(tt.vals, tt.token) - if got != tt.want { - t.Errorf("headerValuesContainsToken(%q, %q) = %v; want %v", tt.vals, tt.token, got, tt.want) - } - } -} diff --git a/vendor/golang.org/x/net/netutil/listen.go b/vendor/golang.org/x/net/netutil/listen.go deleted file mode 100644 index b317ba2..0000000 --- a/vendor/golang.org/x/net/netutil/listen.go +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package netutil provides network utility functions, complementing the more -// common ones in the net package. -package netutil // import "golang.org/x/net/netutil" - -import ( - "net" - "sync" -) - -// LimitListener returns a Listener that accepts at most n simultaneous -// connections from the provided Listener. -func LimitListener(l net.Listener, n int) net.Listener { - return &limitListener{l, make(chan struct{}, n)} -} - -type limitListener struct { - net.Listener - sem chan struct{} -} - -func (l *limitListener) acquire() { l.sem <- struct{}{} } -func (l *limitListener) release() { <-l.sem } - -func (l *limitListener) Accept() (net.Conn, error) { - l.acquire() - c, err := l.Listener.Accept() - if err != nil { - l.release() - return nil, err - } - return &limitListenerConn{Conn: c, release: l.release}, nil -} - -type limitListenerConn struct { - net.Conn - releaseOnce sync.Once - release func() -} - -func (l *limitListenerConn) Close() error { - err := l.Conn.Close() - l.releaseOnce.Do(l.release) - return err -} diff --git a/vendor/golang.org/x/net/netutil/listen_test.go b/vendor/golang.org/x/net/netutil/listen_test.go deleted file mode 100644 index c1a3d55..0000000 --- a/vendor/golang.org/x/net/netutil/listen_test.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright 2013 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package netutil - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "net" - "net/http" - "sync" - "sync/atomic" - "testing" - "time" - - "golang.org/x/net/internal/nettest" -) - -func TestLimitListener(t *testing.T) { - const max = 5 - attempts := (nettest.MaxOpenFiles() - max) / 2 - if attempts > 256 { // maximum length of accept queue is 128 by default - attempts = 256 - } - - l, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatal(err) - } - defer l.Close() - l = LimitListener(l, max) - - var open int32 - go http.Serve(l, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if n := atomic.AddInt32(&open, 1); n > max { - t.Errorf("%d open connections, want <= %d", n, max) - } - defer atomic.AddInt32(&open, -1) - time.Sleep(10 * time.Millisecond) - fmt.Fprint(w, "some body") - })) - - var wg sync.WaitGroup - var failed int32 - for i := 0; i < attempts; i++ { - wg.Add(1) - go func() { - defer wg.Done() - c := http.Client{Timeout: 3 * time.Second} - r, err := c.Get("http://" + l.Addr().String()) - if err != nil { - t.Log(err) - atomic.AddInt32(&failed, 1) - return - } - defer r.Body.Close() - io.Copy(ioutil.Discard, r.Body) - }() - } - wg.Wait() - - // We expect some Gets to fail as the kernel's accept queue is filled, - // but most should succeed. - if int(failed) >= attempts/2 { - t.Errorf("%d requests failed within %d attempts", failed, attempts) - } -} - -type errorListener struct { - net.Listener -} - -func (errorListener) Accept() (net.Conn, error) { - return nil, errFake -} - -var errFake = errors.New("fake error from errorListener") - -// This used to hang. -func TestLimitListenerError(t *testing.T) { - donec := make(chan bool, 1) - go func() { - const n = 2 - ll := LimitListener(errorListener{}, n) - for i := 0; i < n+1; i++ { - _, err := ll.Accept() - if err != errFake { - t.Fatalf("Accept error = %v; want errFake", err) - } - } - donec <- true - }() - select { - case <-donec: - case <-time.After(5 * time.Second): - t.Fatal("timeout. deadlock?") - } -} diff --git a/vendor/golang.org/x/net/proxy/direct.go b/vendor/golang.org/x/net/proxy/direct.go deleted file mode 100644 index 4c5ad88..0000000 --- a/vendor/golang.org/x/net/proxy/direct.go +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2011 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 proxy - -import ( - "net" -) - -type direct struct{} - -// Direct is a direct proxy: one that makes network connections directly. -var Direct = direct{} - -func (direct) Dial(network, addr string) (net.Conn, error) { - return net.Dial(network, addr) -} diff --git a/vendor/golang.org/x/net/proxy/per_host.go b/vendor/golang.org/x/net/proxy/per_host.go deleted file mode 100644 index f540b19..0000000 --- a/vendor/golang.org/x/net/proxy/per_host.go +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2011 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 proxy - -import ( - "net" - "strings" -) - -// A PerHost directs connections to a default Dialer unless the hostname -// requested matches one of a number of exceptions. -type PerHost struct { - def, bypass Dialer - - bypassNetworks []*net.IPNet - bypassIPs []net.IP - bypassZones []string - bypassHosts []string -} - -// NewPerHost returns a PerHost Dialer that directs connections to either -// defaultDialer or bypass, depending on whether the connection matches one of -// the configured rules. -func NewPerHost(defaultDialer, bypass Dialer) *PerHost { - return &PerHost{ - def: defaultDialer, - bypass: bypass, - } -} - -// Dial connects to the address addr on the given network through either -// defaultDialer or bypass. -func (p *PerHost) Dial(network, addr string) (c net.Conn, err error) { - host, _, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - - return p.dialerForRequest(host).Dial(network, addr) -} - -func (p *PerHost) dialerForRequest(host string) Dialer { - if ip := net.ParseIP(host); ip != nil { - for _, net := range p.bypassNetworks { - if net.Contains(ip) { - return p.bypass - } - } - for _, bypassIP := range p.bypassIPs { - if bypassIP.Equal(ip) { - return p.bypass - } - } - return p.def - } - - for _, zone := range p.bypassZones { - if strings.HasSuffix(host, zone) { - return p.bypass - } - if host == zone[1:] { - // For a zone "example.com", we match "example.com" - // too. - return p.bypass - } - } - for _, bypassHost := range p.bypassHosts { - if bypassHost == host { - return p.bypass - } - } - return p.def -} - -// AddFromString parses a string that contains comma-separated values -// specifying hosts that should use the bypass proxy. Each value is either an -// IP address, a CIDR range, a zone (*.example.com) or a hostname -// (localhost). A best effort is made to parse the string and errors are -// ignored. -func (p *PerHost) AddFromString(s string) { - hosts := strings.Split(s, ",") - for _, host := range hosts { - host = strings.TrimSpace(host) - if len(host) == 0 { - continue - } - if strings.Contains(host, "/") { - // We assume that it's a CIDR address like 127.0.0.0/8 - if _, net, err := net.ParseCIDR(host); err == nil { - p.AddNetwork(net) - } - continue - } - if ip := net.ParseIP(host); ip != nil { - p.AddIP(ip) - continue - } - if strings.HasPrefix(host, "*.") { - p.AddZone(host[1:]) - continue - } - p.AddHost(host) - } -} - -// AddIP specifies an IP address that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match an IP. -func (p *PerHost) AddIP(ip net.IP) { - p.bypassIPs = append(p.bypassIPs, ip) -} - -// AddNetwork specifies an IP range that will use the bypass proxy. Note that -// this will only take effect if a literal IP address is dialed. A connection -// to a named host will never match. -func (p *PerHost) AddNetwork(net *net.IPNet) { - p.bypassNetworks = append(p.bypassNetworks, net) -} - -// AddZone specifies a DNS suffix that will use the bypass proxy. A zone of -// "example.com" matches "example.com" and all of its subdomains. -func (p *PerHost) AddZone(zone string) { - if strings.HasSuffix(zone, ".") { - zone = zone[:len(zone)-1] - } - if !strings.HasPrefix(zone, ".") { - zone = "." + zone - } - p.bypassZones = append(p.bypassZones, zone) -} - -// AddHost specifies a hostname that will use the bypass proxy. -func (p *PerHost) AddHost(host string) { - if strings.HasSuffix(host, ".") { - host = host[:len(host)-1] - } - p.bypassHosts = append(p.bypassHosts, host) -} diff --git a/vendor/golang.org/x/net/proxy/per_host_test.go b/vendor/golang.org/x/net/proxy/per_host_test.go deleted file mode 100644 index a7d8095..0000000 --- a/vendor/golang.org/x/net/proxy/per_host_test.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2011 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 proxy - -import ( - "errors" - "net" - "reflect" - "testing" -) - -type recordingProxy struct { - addrs []string -} - -func (r *recordingProxy) Dial(network, addr string) (net.Conn, error) { - r.addrs = append(r.addrs, addr) - return nil, errors.New("recordingProxy") -} - -func TestPerHost(t *testing.T) { - var def, bypass recordingProxy - perHost := NewPerHost(&def, &bypass) - perHost.AddFromString("localhost,*.zone,127.0.0.1,10.0.0.1/8,1000::/16") - - expectedDef := []string{ - "example.com:123", - "1.2.3.4:123", - "[1001::]:123", - } - expectedBypass := []string{ - "localhost:123", - "zone:123", - "foo.zone:123", - "127.0.0.1:123", - "10.1.2.3:123", - "[1000::]:123", - } - - for _, addr := range expectedDef { - perHost.Dial("tcp", addr) - } - for _, addr := range expectedBypass { - perHost.Dial("tcp", addr) - } - - if !reflect.DeepEqual(expectedDef, def.addrs) { - t.Errorf("Hosts which went to the default proxy didn't match. Got %v, want %v", def.addrs, expectedDef) - } - if !reflect.DeepEqual(expectedBypass, bypass.addrs) { - t.Errorf("Hosts which went to the bypass proxy didn't match. Got %v, want %v", bypass.addrs, expectedBypass) - } -} diff --git a/vendor/golang.org/x/net/proxy/proxy.go b/vendor/golang.org/x/net/proxy/proxy.go deleted file mode 100644 index 78a8b7b..0000000 --- a/vendor/golang.org/x/net/proxy/proxy.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2011 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 proxy provides support for a variety of protocols to proxy network -// data. -package proxy // import "golang.org/x/net/proxy" - -import ( - "errors" - "net" - "net/url" - "os" -) - -// A Dialer is a means to establish a connection. -type Dialer interface { - // Dial connects to the given address via the proxy. - Dial(network, addr string) (c net.Conn, err error) -} - -// Auth contains authentication parameters that specific Dialers may require. -type Auth struct { - User, Password string -} - -// FromEnvironment returns the dialer specified by the proxy related variables in -// the environment. -func FromEnvironment() Dialer { - allProxy := os.Getenv("all_proxy") - if len(allProxy) == 0 { - return Direct - } - - proxyURL, err := url.Parse(allProxy) - if err != nil { - return Direct - } - proxy, err := FromURL(proxyURL, Direct) - if err != nil { - return Direct - } - - noProxy := os.Getenv("no_proxy") - if len(noProxy) == 0 { - return proxy - } - - perHost := NewPerHost(proxy, Direct) - perHost.AddFromString(noProxy) - return perHost -} - -// proxySchemes is a map from URL schemes to a function that creates a Dialer -// from a URL with such a scheme. -var proxySchemes map[string]func(*url.URL, Dialer) (Dialer, error) - -// RegisterDialerType takes a URL scheme and a function to generate Dialers from -// a URL with that scheme and a forwarding Dialer. Registered schemes are used -// by FromURL. -func RegisterDialerType(scheme string, f func(*url.URL, Dialer) (Dialer, error)) { - if proxySchemes == nil { - proxySchemes = make(map[string]func(*url.URL, Dialer) (Dialer, error)) - } - proxySchemes[scheme] = f -} - -// FromURL returns a Dialer given a URL specification and an underlying -// Dialer for it to make network requests. -func FromURL(u *url.URL, forward Dialer) (Dialer, error) { - var auth *Auth - if u.User != nil { - auth = new(Auth) - auth.User = u.User.Username() - if p, ok := u.User.Password(); ok { - auth.Password = p - } - } - - switch u.Scheme { - case "socks5": - return SOCKS5("tcp", u.Host, auth, forward) - } - - // If the scheme doesn't match any of the built-in schemes, see if it - // was registered by another package. - if proxySchemes != nil { - if f, ok := proxySchemes[u.Scheme]; ok { - return f(u, forward) - } - } - - return nil, errors.New("proxy: unknown scheme: " + u.Scheme) -} diff --git a/vendor/golang.org/x/net/proxy/proxy_test.go b/vendor/golang.org/x/net/proxy/proxy_test.go deleted file mode 100644 index c19a5c0..0000000 --- a/vendor/golang.org/x/net/proxy/proxy_test.go +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright 2011 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 proxy - -import ( - "io" - "net" - "net/url" - "strconv" - "sync" - "testing" -) - -func TestFromURL(t *testing.T) { - endSystem, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer endSystem.Close() - gateway, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer gateway.Close() - - var wg sync.WaitGroup - wg.Add(1) - go socks5Gateway(t, gateway, endSystem, socks5Domain, &wg) - - url, err := url.Parse("socks5://user:password@" + gateway.Addr().String()) - if err != nil { - t.Fatalf("url.Parse failed: %v", err) - } - proxy, err := FromURL(url, Direct) - if err != nil { - t.Fatalf("FromURL failed: %v", err) - } - _, port, err := net.SplitHostPort(endSystem.Addr().String()) - if err != nil { - t.Fatalf("net.SplitHostPort failed: %v", err) - } - if c, err := proxy.Dial("tcp", "localhost:"+port); err != nil { - t.Fatalf("FromURL.Dial failed: %v", err) - } else { - c.Close() - } - - wg.Wait() -} - -func TestSOCKS5(t *testing.T) { - endSystem, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer endSystem.Close() - gateway, err := net.Listen("tcp", "127.0.0.1:0") - if err != nil { - t.Fatalf("net.Listen failed: %v", err) - } - defer gateway.Close() - - var wg sync.WaitGroup - wg.Add(1) - go socks5Gateway(t, gateway, endSystem, socks5IP4, &wg) - - proxy, err := SOCKS5("tcp", gateway.Addr().String(), nil, Direct) - if err != nil { - t.Fatalf("SOCKS5 failed: %v", err) - } - if c, err := proxy.Dial("tcp", endSystem.Addr().String()); err != nil { - t.Fatalf("SOCKS5.Dial failed: %v", err) - } else { - c.Close() - } - - wg.Wait() -} - -func socks5Gateway(t *testing.T, gateway, endSystem net.Listener, typ byte, wg *sync.WaitGroup) { - defer wg.Done() - - c, err := gateway.Accept() - if err != nil { - t.Errorf("net.Listener.Accept failed: %v", err) - return - } - defer c.Close() - - b := make([]byte, 32) - var n int - if typ == socks5Domain { - n = 4 - } else { - n = 3 - } - if _, err := io.ReadFull(c, b[:n]); err != nil { - t.Errorf("io.ReadFull failed: %v", err) - return - } - if _, err := c.Write([]byte{socks5Version, socks5AuthNone}); err != nil { - t.Errorf("net.Conn.Write failed: %v", err) - return - } - if typ == socks5Domain { - n = 16 - } else { - n = 10 - } - if _, err := io.ReadFull(c, b[:n]); err != nil { - t.Errorf("io.ReadFull failed: %v", err) - return - } - if b[0] != socks5Version || b[1] != socks5Connect || b[2] != 0x00 || b[3] != typ { - t.Errorf("got an unexpected packet: %#02x %#02x %#02x %#02x", b[0], b[1], b[2], b[3]) - return - } - if typ == socks5Domain { - copy(b[:5], []byte{socks5Version, 0x00, 0x00, socks5Domain, 9}) - b = append(b, []byte("localhost")...) - } else { - copy(b[:4], []byte{socks5Version, 0x00, 0x00, socks5IP4}) - } - host, port, err := net.SplitHostPort(endSystem.Addr().String()) - if err != nil { - t.Errorf("net.SplitHostPort failed: %v", err) - return - } - b = append(b, []byte(net.ParseIP(host).To4())...) - p, err := strconv.Atoi(port) - if err != nil { - t.Errorf("strconv.Atoi failed: %v", err) - return - } - b = append(b, []byte{byte(p >> 8), byte(p)}...) - if _, err := c.Write(b); err != nil { - t.Errorf("net.Conn.Write failed: %v", err) - return - } -} diff --git a/vendor/golang.org/x/net/proxy/socks5.go b/vendor/golang.org/x/net/proxy/socks5.go deleted file mode 100644 index 9b96282..0000000 --- a/vendor/golang.org/x/net/proxy/socks5.go +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2011 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 proxy - -import ( - "errors" - "io" - "net" - "strconv" -) - -// SOCKS5 returns a Dialer that makes SOCKSv5 connections to the given address -// with an optional username and password. See RFC 1928. -func SOCKS5(network, addr string, auth *Auth, forward Dialer) (Dialer, error) { - s := &socks5{ - network: network, - addr: addr, - forward: forward, - } - if auth != nil { - s.user = auth.User - s.password = auth.Password - } - - return s, nil -} - -type socks5 struct { - user, password string - network, addr string - forward Dialer -} - -const socks5Version = 5 - -const ( - socks5AuthNone = 0 - socks5AuthPassword = 2 -) - -const socks5Connect = 1 - -const ( - socks5IP4 = 1 - socks5Domain = 3 - socks5IP6 = 4 -) - -var socks5Errors = []string{ - "", - "general failure", - "connection forbidden", - "network unreachable", - "host unreachable", - "connection refused", - "TTL expired", - "command not supported", - "address type not supported", -} - -// Dial connects to the address addr on the network net via the SOCKS5 proxy. -func (s *socks5) Dial(network, addr string) (net.Conn, error) { - switch network { - case "tcp", "tcp6", "tcp4": - default: - return nil, errors.New("proxy: no support for SOCKS5 proxy connections of type " + network) - } - - conn, err := s.forward.Dial(s.network, s.addr) - if err != nil { - return nil, err - } - closeConn := &conn - defer func() { - if closeConn != nil { - (*closeConn).Close() - } - }() - - host, portStr, err := net.SplitHostPort(addr) - if err != nil { - return nil, err - } - - port, err := strconv.Atoi(portStr) - if err != nil { - return nil, errors.New("proxy: failed to parse port number: " + portStr) - } - if port < 1 || port > 0xffff { - return nil, errors.New("proxy: port number out of range: " + portStr) - } - - // the size here is just an estimate - buf := make([]byte, 0, 6+len(host)) - - buf = append(buf, socks5Version) - if len(s.user) > 0 && len(s.user) < 256 && len(s.password) < 256 { - buf = append(buf, 2 /* num auth methods */, socks5AuthNone, socks5AuthPassword) - } else { - buf = append(buf, 1 /* num auth methods */, socks5AuthNone) - } - - if _, err := conn.Write(buf); err != nil { - return nil, errors.New("proxy: failed to write greeting to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return nil, errors.New("proxy: failed to read greeting from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - if buf[0] != 5 { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " has unexpected version " + strconv.Itoa(int(buf[0]))) - } - if buf[1] == 0xff { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " requires authentication") - } - - if buf[1] == socks5AuthPassword { - buf = buf[:0] - buf = append(buf, 1 /* password protocol version */) - buf = append(buf, uint8(len(s.user))) - buf = append(buf, s.user...) - buf = append(buf, uint8(len(s.password))) - buf = append(buf, s.password...) - - if _, err := conn.Write(buf); err != nil { - return nil, errors.New("proxy: failed to write authentication request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return nil, errors.New("proxy: failed to read authentication reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if buf[1] != 0 { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " rejected username/password") - } - } - - buf = buf[:0] - buf = append(buf, socks5Version, socks5Connect, 0 /* reserved */) - - if ip := net.ParseIP(host); ip != nil { - if ip4 := ip.To4(); ip4 != nil { - buf = append(buf, socks5IP4) - ip = ip4 - } else { - buf = append(buf, socks5IP6) - } - buf = append(buf, ip...) - } else { - if len(host) > 255 { - return nil, errors.New("proxy: destination hostname too long: " + host) - } - buf = append(buf, socks5Domain) - buf = append(buf, byte(len(host))) - buf = append(buf, host...) - } - buf = append(buf, byte(port>>8), byte(port)) - - if _, err := conn.Write(buf); err != nil { - return nil, errors.New("proxy: failed to write connect request to SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - if _, err := io.ReadFull(conn, buf[:4]); err != nil { - return nil, errors.New("proxy: failed to read connect reply from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - failure := "unknown error" - if int(buf[1]) < len(socks5Errors) { - failure = socks5Errors[buf[1]] - } - - if len(failure) > 0 { - return nil, errors.New("proxy: SOCKS5 proxy at " + s.addr + " failed to connect: " + failure) - } - - bytesToDiscard := 0 - switch buf[3] { - case socks5IP4: - bytesToDiscard = net.IPv4len - case socks5IP6: - bytesToDiscard = net.IPv6len - case socks5Domain: - _, err := io.ReadFull(conn, buf[:1]) - if err != nil { - return nil, errors.New("proxy: failed to read domain length from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - bytesToDiscard = int(buf[0]) - default: - return nil, errors.New("proxy: got unknown address type " + strconv.Itoa(int(buf[3])) + " from SOCKS5 proxy at " + s.addr) - } - - if cap(buf) < bytesToDiscard { - buf = make([]byte, bytesToDiscard) - } else { - buf = buf[:bytesToDiscard] - } - if _, err := io.ReadFull(conn, buf); err != nil { - return nil, errors.New("proxy: failed to read address from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - // Also need to discard the port number - if _, err := io.ReadFull(conn, buf[:2]); err != nil { - return nil, errors.New("proxy: failed to read port from SOCKS5 proxy at " + s.addr + ": " + err.Error()) - } - - closeConn = nil - return conn, nil -} diff --git a/vendor/golang.org/x/net/publicsuffix/gen.go b/vendor/golang.org/x/net/publicsuffix/gen.go deleted file mode 100644 index add1c2e..0000000 --- a/vendor/golang.org/x/net/publicsuffix/gen.go +++ /dev/null @@ -1,713 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package main - -// This program generates table.go and table_test.go based on the authoritative -// public suffix list at https://publicsuffix.org/list/effective_tld_names.dat -// -// The version is derived from -// https://api.github.com/repos/publicsuffix/list/commits?path=public_suffix_list.dat -// and a human-readable form is at -// https://github.com/publicsuffix/list/commits/master/public_suffix_list.dat -// -// To fetch a particular git revision, such as 5c70ccd250, pass -// -url "https://raw.githubusercontent.com/publicsuffix/list/5c70ccd250/public_suffix_list.dat" -// and -version "an explicit version string". - -import ( - "bufio" - "bytes" - "flag" - "fmt" - "go/format" - "io" - "io/ioutil" - "net/http" - "os" - "regexp" - "sort" - "strings" - - "golang.org/x/net/idna" -) - -const ( - // These sum of these four values must be no greater than 32. - nodesBitsChildren = 9 - nodesBitsICANN = 1 - nodesBitsTextOffset = 15 - nodesBitsTextLength = 6 - - // These sum of these four values must be no greater than 32. - childrenBitsWildcard = 1 - childrenBitsNodeType = 2 - childrenBitsHi = 14 - childrenBitsLo = 14 -) - -var ( - maxChildren int - maxTextOffset int - maxTextLength int - maxHi uint32 - maxLo uint32 -) - -func max(a, b int) int { - if a < b { - return b - } - return a -} - -func u32max(a, b uint32) uint32 { - if a < b { - return b - } - return a -} - -const ( - nodeTypeNormal = 0 - nodeTypeException = 1 - nodeTypeParentOnly = 2 - numNodeType = 3 -) - -func nodeTypeStr(n int) string { - switch n { - case nodeTypeNormal: - return "+" - case nodeTypeException: - return "!" - case nodeTypeParentOnly: - return "o" - } - panic("unreachable") -} - -const ( - defaultURL = "https://publicsuffix.org/list/effective_tld_names.dat" - gitCommitURL = "https://api.github.com/repos/publicsuffix/list/commits?path=public_suffix_list.dat" -) - -var ( - labelEncoding = map[string]uint32{} - labelsList = []string{} - labelsMap = map[string]bool{} - rules = []string{} - - // validSuffixRE is used to check that the entries in the public suffix - // list are in canonical form (after Punycode encoding). Specifically, - // capital letters are not allowed. - validSuffixRE = regexp.MustCompile(`^[a-z0-9_\!\*\-\.]+$`) - - shaRE = regexp.MustCompile(`"sha":"([^"]+)"`) - dateRE = regexp.MustCompile(`"committer":{[^{]+"date":"([^"]+)"`) - - comments = flag.Bool("comments", false, "generate table.go comments, for debugging") - subset = flag.Bool("subset", false, "generate only a subset of the full table, for debugging") - url = flag.String("url", defaultURL, "URL of the publicsuffix.org list. If empty, stdin is read instead") - v = flag.Bool("v", false, "verbose output (to stderr)") - version = flag.String("version", "", "the effective_tld_names.dat version") -) - -func main() { - if err := main1(); err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} - -func main1() error { - flag.Parse() - if nodesBitsTextLength+nodesBitsTextOffset+nodesBitsICANN+nodesBitsChildren > 32 { - return fmt.Errorf("not enough bits to encode the nodes table") - } - if childrenBitsLo+childrenBitsHi+childrenBitsNodeType+childrenBitsWildcard > 32 { - return fmt.Errorf("not enough bits to encode the children table") - } - if *version == "" { - if *url != defaultURL { - return fmt.Errorf("-version was not specified, and the -url is not the default one") - } - sha, date, err := gitCommit() - if err != nil { - return err - } - *version = fmt.Sprintf("publicsuffix.org's public_suffix_list.dat, git revision %s (%s)", sha, date) - } - var r io.Reader = os.Stdin - if *url != "" { - res, err := http.Get(*url) - if err != nil { - return err - } - if res.StatusCode != http.StatusOK { - return fmt.Errorf("bad GET status for %s: %d", *url, res.Status) - } - r = res.Body - defer res.Body.Close() - } - - var root node - icann := false - br := bufio.NewReader(r) - for { - s, err := br.ReadString('\n') - if err != nil { - if err == io.EOF { - break - } - return err - } - s = strings.TrimSpace(s) - if strings.Contains(s, "BEGIN ICANN DOMAINS") { - icann = true - continue - } - if strings.Contains(s, "END ICANN DOMAINS") { - icann = false - continue - } - if s == "" || strings.HasPrefix(s, "//") { - continue - } - s, err = idna.ToASCII(s) - if err != nil { - return err - } - if !validSuffixRE.MatchString(s) { - return fmt.Errorf("bad publicsuffix.org list data: %q", s) - } - - if *subset { - switch { - case s == "ac.jp" || strings.HasSuffix(s, ".ac.jp"): - case s == "ak.us" || strings.HasSuffix(s, ".ak.us"): - case s == "ao" || strings.HasSuffix(s, ".ao"): - case s == "ar" || strings.HasSuffix(s, ".ar"): - case s == "arpa" || strings.HasSuffix(s, ".arpa"): - case s == "cy" || strings.HasSuffix(s, ".cy"): - case s == "dyndns.org" || strings.HasSuffix(s, ".dyndns.org"): - case s == "jp": - case s == "kobe.jp" || strings.HasSuffix(s, ".kobe.jp"): - case s == "kyoto.jp" || strings.HasSuffix(s, ".kyoto.jp"): - case s == "om" || strings.HasSuffix(s, ".om"): - case s == "uk" || strings.HasSuffix(s, ".uk"): - case s == "uk.com" || strings.HasSuffix(s, ".uk.com"): - case s == "tw" || strings.HasSuffix(s, ".tw"): - case s == "zw" || strings.HasSuffix(s, ".zw"): - case s == "xn--p1ai" || strings.HasSuffix(s, ".xn--p1ai"): - // xn--p1ai is Russian-Cyrillic "рф". - default: - continue - } - } - - rules = append(rules, s) - - nt, wildcard := nodeTypeNormal, false - switch { - case strings.HasPrefix(s, "*."): - s, nt = s[2:], nodeTypeParentOnly - wildcard = true - case strings.HasPrefix(s, "!"): - s, nt = s[1:], nodeTypeException - } - labels := strings.Split(s, ".") - for n, i := &root, len(labels)-1; i >= 0; i-- { - label := labels[i] - n = n.child(label) - if i == 0 { - if nt != nodeTypeParentOnly && n.nodeType == nodeTypeParentOnly { - n.nodeType = nt - } - n.icann = n.icann && icann - n.wildcard = n.wildcard || wildcard - } - labelsMap[label] = true - } - } - labelsList = make([]string, 0, len(labelsMap)) - for label := range labelsMap { - labelsList = append(labelsList, label) - } - sort.Strings(labelsList) - - if err := generate(printReal, &root, "table.go"); err != nil { - return err - } - if err := generate(printTest, &root, "table_test.go"); err != nil { - return err - } - return nil -} - -func generate(p func(io.Writer, *node) error, root *node, filename string) error { - buf := new(bytes.Buffer) - if err := p(buf, root); err != nil { - return err - } - b, err := format.Source(buf.Bytes()) - if err != nil { - return err - } - return ioutil.WriteFile(filename, b, 0644) -} - -func gitCommit() (sha, date string, retErr error) { - res, err := http.Get(gitCommitURL) - if err != nil { - return "", "", err - } - if res.StatusCode != http.StatusOK { - return "", "", fmt.Errorf("bad GET status for %s: %d", gitCommitURL, res.Status) - } - defer res.Body.Close() - b, err := ioutil.ReadAll(res.Body) - if err != nil { - return "", "", err - } - if m := shaRE.FindSubmatch(b); m != nil { - sha = string(m[1]) - } - if m := dateRE.FindSubmatch(b); m != nil { - date = string(m[1]) - } - if sha == "" || date == "" { - retErr = fmt.Errorf("could not find commit SHA and date in %s", gitCommitURL) - } - return sha, date, retErr -} - -func printTest(w io.Writer, n *node) error { - fmt.Fprintf(w, "// generated by go run gen.go; DO NOT EDIT\n\n") - fmt.Fprintf(w, "package publicsuffix\n\nvar rules = [...]string{\n") - for _, rule := range rules { - fmt.Fprintf(w, "%q,\n", rule) - } - fmt.Fprintf(w, "}\n\nvar nodeLabels = [...]string{\n") - if err := n.walk(w, printNodeLabel); err != nil { - return err - } - fmt.Fprintf(w, "}\n") - return nil -} - -func printReal(w io.Writer, n *node) error { - const header = `// generated by go run gen.go; DO NOT EDIT - -package publicsuffix - -const version = %q - -const ( - nodesBitsChildren = %d - nodesBitsICANN = %d - nodesBitsTextOffset = %d - nodesBitsTextLength = %d - - childrenBitsWildcard = %d - childrenBitsNodeType = %d - childrenBitsHi = %d - childrenBitsLo = %d -) - -const ( - nodeTypeNormal = %d - nodeTypeException = %d - nodeTypeParentOnly = %d -) - -// numTLD is the number of top level domains. -const numTLD = %d - -` - fmt.Fprintf(w, header, *version, - nodesBitsChildren, nodesBitsICANN, nodesBitsTextOffset, nodesBitsTextLength, - childrenBitsWildcard, childrenBitsNodeType, childrenBitsHi, childrenBitsLo, - nodeTypeNormal, nodeTypeException, nodeTypeParentOnly, len(n.children)) - - text := combineText(labelsList) - if text == "" { - return fmt.Errorf("internal error: makeText returned no text") - } - for _, label := range labelsList { - offset, length := strings.Index(text, label), len(label) - if offset < 0 { - return fmt.Errorf("internal error: could not find %q in text %q", label, text) - } - maxTextOffset, maxTextLength = max(maxTextOffset, offset), max(maxTextLength, length) - if offset >= 1<= 1< 64 { - n, plus = 64, " +" - } - fmt.Fprintf(w, "%q%s\n", text[:n], plus) - text = text[n:] - } - - if err := n.walk(w, assignIndexes); err != nil { - return err - } - - fmt.Fprintf(w, ` - -// nodes is the list of nodes. Each node is represented as a uint32, which -// encodes the node's children, wildcard bit and node type (as an index into -// the children array), ICANN bit and text. -// -// If the table was generated with the -comments flag, there is a //-comment -// after each node's data. In it is the nodes-array indexes of the children, -// formatted as (n0x1234-n0x1256), with * denoting the wildcard bit. The -// nodeType is printed as + for normal, ! for exception, and o for parent-only -// nodes that have children but don't match a domain label in their own right. -// An I denotes an ICANN domain. -// -// The layout within the uint32, from MSB to LSB, is: -// [%2d bits] unused -// [%2d bits] children index -// [%2d bits] ICANN bit -// [%2d bits] text index -// [%2d bits] text length -var nodes = [...]uint32{ -`, - 32-nodesBitsChildren-nodesBitsICANN-nodesBitsTextOffset-nodesBitsTextLength, - nodesBitsChildren, nodesBitsICANN, nodesBitsTextOffset, nodesBitsTextLength) - if err := n.walk(w, printNode); err != nil { - return err - } - fmt.Fprintf(w, `} - -// children is the list of nodes' children, the parent's wildcard bit and the -// parent's node type. If a node has no children then their children index -// will be in the range [0, 6), depending on the wildcard bit and node type. -// -// The layout within the uint32, from MSB to LSB, is: -// [%2d bits] unused -// [%2d bits] wildcard bit -// [%2d bits] node type -// [%2d bits] high nodes index (exclusive) of children -// [%2d bits] low nodes index (inclusive) of children -var children=[...]uint32{ -`, - 32-childrenBitsWildcard-childrenBitsNodeType-childrenBitsHi-childrenBitsLo, - childrenBitsWildcard, childrenBitsNodeType, childrenBitsHi, childrenBitsLo) - for i, c := range childrenEncoding { - s := "---------------" - lo := c & (1<> childrenBitsLo) & (1<>(childrenBitsLo+childrenBitsHi)) & (1<>(childrenBitsLo+childrenBitsHi+childrenBitsNodeType) != 0 - if *comments { - fmt.Fprintf(w, "0x%08x, // c0x%04x (%s)%s %s\n", - c, i, s, wildcardStr(wildcard), nodeTypeStr(nodeType)) - } else { - fmt.Fprintf(w, "0x%08x,\n", c) - } - } - fmt.Fprintf(w, "}\n\n") - fmt.Fprintf(w, "// max children %d (capacity %d)\n", maxChildren, 1<= 1<= 1<= 1< 0 && ss[0] == "" { - ss = ss[1:] - } - return ss -} - -// crush combines a list of strings, taking advantage of overlaps. It returns a -// single string that contains each input string as a substring. -func crush(ss []string) string { - maxLabelLen := 0 - for _, s := range ss { - if maxLabelLen < len(s) { - maxLabelLen = len(s) - } - } - - for prefixLen := maxLabelLen; prefixLen > 0; prefixLen-- { - prefixes := makePrefixMap(ss, prefixLen) - for i, s := range ss { - if len(s) <= prefixLen { - continue - } - mergeLabel(ss, i, prefixLen, prefixes) - } - } - - return strings.Join(ss, "") -} - -// mergeLabel merges the label at ss[i] with the first available matching label -// in prefixMap, where the last "prefixLen" characters in ss[i] match the first -// "prefixLen" characters in the matching label. -// It will merge ss[i] repeatedly until no more matches are available. -// All matching labels merged into ss[i] are replaced by "". -func mergeLabel(ss []string, i, prefixLen int, prefixes prefixMap) { - s := ss[i] - suffix := s[len(s)-prefixLen:] - for _, j := range prefixes[suffix] { - // Empty strings mean "already used." Also avoid merging with self. - if ss[j] == "" || i == j { - continue - } - if *v { - fmt.Fprintf(os.Stderr, "%d-length overlap at (%4d,%4d): %q and %q share %q\n", - prefixLen, i, j, ss[i], ss[j], suffix) - } - ss[i] += ss[j][prefixLen:] - ss[j] = "" - // ss[i] has a new suffix, so merge again if possible. - // Note: we only have to merge again at the same prefix length. Shorter - // prefix lengths will be handled in the next iteration of crush's for loop. - // Can there be matches for longer prefix lengths, introduced by the merge? - // I believe that any such matches would by necessity have been eliminated - // during substring removal or merged at a higher prefix length. For - // instance, in crush("abc", "cde", "bcdef"), combining "abc" and "cde" - // would yield "abcde", which could be merged with "bcdef." However, in - // practice "cde" would already have been elimintated by removeSubstrings. - mergeLabel(ss, i, prefixLen, prefixes) - return - } -} - -// prefixMap maps from a prefix to a list of strings containing that prefix. The -// list of strings is represented as indexes into a slice of strings stored -// elsewhere. -type prefixMap map[string][]int - -// makePrefixMap constructs a prefixMap from a slice of strings. -func makePrefixMap(ss []string, prefixLen int) prefixMap { - prefixes := make(prefixMap) - for i, s := range ss { - // We use < rather than <= because if a label matches on a prefix equal to - // its full length, that's actually a substring match handled by - // removeSubstrings. - if prefixLen < len(s) { - prefix := s[:prefixLen] - prefixes[prefix] = append(prefixes[prefix], i) - } - } - - return prefixes -} diff --git a/vendor/golang.org/x/net/publicsuffix/list.go b/vendor/golang.org/x/net/publicsuffix/list.go deleted file mode 100644 index 8bbf3bc..0000000 --- a/vendor/golang.org/x/net/publicsuffix/list.go +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:generate go run gen.go - -// Package publicsuffix provides a public suffix list based on data from -// http://publicsuffix.org/. A public suffix is one under which Internet users -// can directly register names. -package publicsuffix // import "golang.org/x/net/publicsuffix" - -// TODO: specify case sensitivity and leading/trailing dot behavior for -// func PublicSuffix and func EffectiveTLDPlusOne. - -import ( - "fmt" - "net/http/cookiejar" - "strings" -) - -// List implements the cookiejar.PublicSuffixList interface by calling the -// PublicSuffix function. -var List cookiejar.PublicSuffixList = list{} - -type list struct{} - -func (list) PublicSuffix(domain string) string { - ps, _ := PublicSuffix(domain) - return ps -} - -func (list) String() string { - return version -} - -// PublicSuffix returns the public suffix of the domain using a copy of the -// publicsuffix.org database compiled into the library. -// -// icann is whether the public suffix is managed by the Internet Corporation -// for Assigned Names and Numbers. If not, the public suffix is privately -// managed. For example, foo.org and foo.co.uk are ICANN domains, -// foo.dyndns.org and foo.blogspot.co.uk are private domains. -// -// Use cases for distinguishing ICANN domains like foo.com from private -// domains like foo.appspot.com can be found at -// https://wiki.mozilla.org/Public_Suffix_List/Use_Cases -func PublicSuffix(domain string) (publicSuffix string, icann bool) { - lo, hi := uint32(0), uint32(numTLD) - s, suffix, wildcard := domain, len(domain), false -loop: - for { - dot := strings.LastIndex(s, ".") - if wildcard { - suffix = 1 + dot - } - if lo == hi { - break - } - f := find(s[1+dot:], lo, hi) - if f == notFound { - break - } - - u := nodes[f] >> (nodesBitsTextOffset + nodesBitsTextLength) - icann = u&(1<>= nodesBitsICANN - u = children[u&(1<>= childrenBitsLo - hi = u & (1<>= childrenBitsHi - switch u & (1<>= childrenBitsNodeType - wildcard = u&(1<>= nodesBitsTextLength - offset := x & (1< len(b[j]) -} - -// eTLDPlusOneTestCases come from -// https://github.com/publicsuffix/list/blob/master/tests/test_psl.txt -var eTLDPlusOneTestCases = []struct { - domain, want string -}{ - // Empty input. - {"", ""}, - // Unlisted TLD. - {"example", ""}, - {"example.example", "example.example"}, - {"b.example.example", "example.example"}, - {"a.b.example.example", "example.example"}, - // TLD with only 1 rule. - {"biz", ""}, - {"domain.biz", "domain.biz"}, - {"b.domain.biz", "domain.biz"}, - {"a.b.domain.biz", "domain.biz"}, - // TLD with some 2-level rules. - {"com", ""}, - {"example.com", "example.com"}, - {"b.example.com", "example.com"}, - {"a.b.example.com", "example.com"}, - {"uk.com", ""}, - {"example.uk.com", "example.uk.com"}, - {"b.example.uk.com", "example.uk.com"}, - {"a.b.example.uk.com", "example.uk.com"}, - {"test.ac", "test.ac"}, - // TLD with only 1 (wildcard) rule. - {"mm", ""}, - {"c.mm", ""}, - {"b.c.mm", "b.c.mm"}, - {"a.b.c.mm", "b.c.mm"}, - // More complex TLD. - {"jp", ""}, - {"test.jp", "test.jp"}, - {"www.test.jp", "test.jp"}, - {"ac.jp", ""}, - {"test.ac.jp", "test.ac.jp"}, - {"www.test.ac.jp", "test.ac.jp"}, - {"kyoto.jp", ""}, - {"test.kyoto.jp", "test.kyoto.jp"}, - {"ide.kyoto.jp", ""}, - {"b.ide.kyoto.jp", "b.ide.kyoto.jp"}, - {"a.b.ide.kyoto.jp", "b.ide.kyoto.jp"}, - {"c.kobe.jp", ""}, - {"b.c.kobe.jp", "b.c.kobe.jp"}, - {"a.b.c.kobe.jp", "b.c.kobe.jp"}, - {"city.kobe.jp", "city.kobe.jp"}, - {"www.city.kobe.jp", "city.kobe.jp"}, - // TLD with a wildcard rule and exceptions. - {"ck", ""}, - {"test.ck", ""}, - {"b.test.ck", "b.test.ck"}, - {"a.b.test.ck", "b.test.ck"}, - {"www.ck", "www.ck"}, - {"www.www.ck", "www.ck"}, - // US K12. - {"us", ""}, - {"test.us", "test.us"}, - {"www.test.us", "test.us"}, - {"ak.us", ""}, - {"test.ak.us", "test.ak.us"}, - {"www.test.ak.us", "test.ak.us"}, - {"k12.ak.us", ""}, - {"test.k12.ak.us", "test.k12.ak.us"}, - {"www.test.k12.ak.us", "test.k12.ak.us"}, - // Punycoded IDN labels - {"xn--85x722f.com.cn", "xn--85x722f.com.cn"}, - {"xn--85x722f.xn--55qx5d.cn", "xn--85x722f.xn--55qx5d.cn"}, - {"www.xn--85x722f.xn--55qx5d.cn", "xn--85x722f.xn--55qx5d.cn"}, - {"shishi.xn--55qx5d.cn", "shishi.xn--55qx5d.cn"}, - {"xn--55qx5d.cn", ""}, - {"xn--85x722f.xn--fiqs8s", "xn--85x722f.xn--fiqs8s"}, - {"www.xn--85x722f.xn--fiqs8s", "xn--85x722f.xn--fiqs8s"}, - {"shishi.xn--fiqs8s", "shishi.xn--fiqs8s"}, - {"xn--fiqs8s", ""}, -} - -func TestEffectiveTLDPlusOne(t *testing.T) { - for _, tc := range eTLDPlusOneTestCases { - got, _ := EffectiveTLDPlusOne(tc.domain) - if got != tc.want { - t.Errorf("%q: got %q, want %q", tc.domain, got, tc.want) - } - } -} diff --git a/vendor/golang.org/x/net/publicsuffix/table.go b/vendor/golang.org/x/net/publicsuffix/table.go deleted file mode 100644 index 7649b28..0000000 --- a/vendor/golang.org/x/net/publicsuffix/table.go +++ /dev/null @@ -1,8947 +0,0 @@ -// generated by go run gen.go; DO NOT EDIT - -package publicsuffix - -const version = "publicsuffix.org's public_suffix_list.dat, git revision ea9f4f9c51f5bfc5c85a41a5637ab671c07c542a (2016-05-31T18:30:56Z)" - -const ( - nodesBitsChildren = 9 - nodesBitsICANN = 1 - nodesBitsTextOffset = 15 - nodesBitsTextLength = 6 - - childrenBitsWildcard = 1 - childrenBitsNodeType = 2 - childrenBitsHi = 14 - childrenBitsLo = 14 -) - -const ( - nodeTypeNormal = 0 - nodeTypeException = 1 - nodeTypeParentOnly = 2 -) - -// numTLD is the number of top level domains. -const numTLD = 1552 - -// Text is the combined text of all labels. -const text = "bievatmallorcadaquesamsunglassassinationalheritagematsubarakawag" + - "oebifukagawalmartatsunomutashinainuyamanouchikuhokuryugasakitash" + - "iobarabihorologyusuisservecounterstrikebikedagestangeorgeorgiabi" + - "lbaogakievenesandvikcoromantovalle-d-aostatoilomzansimagicasadel" + - "amonedavvenjargapartmentsanfranciscofreakunemurorangeiseiyoichir" + - "opracticaseihichisobetsuitaipeiheijinvestmentsangobillustrationi" + - "nohekinannestadrangedalorenskogliwicebiobirdartcenterprisesakiko" + - "naircraftraeumtgeradealstahaugesundrivelandrobaknoluoktagajoboji" + - "s-a-candidatebirkenesoddtangenovaravennagatorogersvpalanakhodkan" + - "anporovnobirthplacebjarkoyuuconnectattoolsztynsettlersanjotaxihu" + - "aninomiyakonojoshkar-olayangroupaleobjerkreimdbalatinorddalimano" + - "warudastronomydissentargets-itargi234bjugnieznordlandunloppacifi" + - "casertairablockbusternidunsagaeroclubmedecincinnationwidealerblo" + - "ombergbauernrtgoryuzawabloxcmsannanirasakis-a-catererbluedaplier" + - "neuesannohelplfinancialotenkawabmoattachmentsanokasumigaurawa-ma" + - "zowszexboxenapponazure-mobilebmsantabarbarabmwegroweibolzanordre" + - "-landupontariobnpparibaselburglobalashovhachinohedmarkhangelskas" + - "uyakutiabomloansantacruzsantafedextraspace-to-rentalstomakomaiba" + - "rabondurbanamexhibitionishiazais-a-celticsfanishigotsukisofukush" + - "imarnardalottebonnishiharabookinglobodoes-itverranzanquannefrank" + - "furtjeldsundurhamburglogoweirbootsanukis-a-chefarmsteadvrcambrid" + - "gestonewyorkshiredumbrellajollamericanexpressexyzgorzeleccologne" + - "wportlligatewayuzhno-sakhalinskaszubyboschaefflerdalottokorozawa" + - "bostikatowicebostonakijinsekikogentingloppenzaogashimadachicagob" + - "oatsaotomeloyalistockholmestrandvrdnsfor-better-thandabotanicalg" + - "ardenishiizunazukis-a-conservativefsncfdwgmbhartiffanynysafetysf" + - "jordyndns-ipalermomasvuotnakatombetsupplybotanicgardenishikataka" + - "zakis-a-cpadoval-daostavalleybotanybouncemerckatsushikabeeldenge" + - "luidyndns-mailouvrepairbusantiquest-a-la-maisondre-landebusiness" + - "ebyklefrakkestadyndns-office-on-the-webcampobassociatesapodhalew" + - "ismillerbounty-fullensakerrypropertiesapporoboutiquebecngminakam" + - "ichigangwonishikatsuragithubusercontentjmaxxxfinitybozentsujiieb" + - "radescorporationishikawazukaneyamaxunjargabrandywinevalleybrasil" + - "iabresciabrindisibenikebristolgamvikatsuyamasfjordenishimerabrit" + - "ishcolumbialowiezaganishinomiyashironobroadcastleclercasinordrei" + - "sa-geekaufenishinoomotegotvalleaostavernishinoshimatteledatabase" + - "ballooningmodenakanotoddenishiokoppegardyndns-picsaratovalled-ao" + - "stavropolitiendabroadwaybroke-itjomebrokerbronnoysundyndns-remot" + - "egildeskalmykiabrothermesaverdedyn-o-saurechtrainingmxjaworznowt" + - "valledaostakkofuelowiczest-le-patrondheimperiabrumunddalucaniabr" + - "unelblagdenesnaaseralingenkainanaejrietisalatinabenoboribetsucks" + - "ardegnamsosnowiecateringebudejjuedischesapeakebayernurembergreta" + - "kamatsukawabrusselsardiniabruxellesarluccapitalonewjerseybryansk" + - "jervoyagebryneustarhubalestrandabergamoarekehimejibestadiscovery" + - "okamikawanehonbetsurutaharaugustowadaegubs3-ap-southeast-2busker" + - "udinewhampshirecipesaro-urbino-pesarourbinopesaromamurogawalterb" + - "uzenishitosashimizunaminamiashigarabuzzgradyndns-servercellikes-" + - "piedmontblancomeeresarpsborgrimstadyndns-weberlincolnishiwakis-a" + - "-cubicle-slavellinotteroybwfarsundyndns-wikinderoybzhitomirkutsk" + - "leppalmspringsakercompute-1computerhistoryofscience-fictioncomse" + - "curitytacticsbschokoladencondoshichinohealthcareerscholarshipsch" + - "ooluzernconferenceconstructionconsuladoharuhrconsultanthropology" + - "consultingvollvivano-frankivskharkivgucciprianiigataitogojomedio" + - "-campidano-mediocampidanomediocontactoyosatoyokawacontemporaryar" + - "teducationalchikugokaseljeffersoncontractorskenconventureshinode" + - "sashibetsuikimobetsuliguriacookingchannelveruminamidaitomangotem" + - "baixadacoolkuszippodlasiellakasamatsudovre-eikercooperaunitelevi" + - "sioncopenhagencyclopedichelyabinskodjeepilepsydneycorsicagliarid" + - "agawarszawashingtondclkharkovallee-aosteroycorvettemasekhersonco" + - "senzakopanerairforcecostumedizinhistorischeschulezajskhmelnitski" + - "yamashikecouchpotatofrieschwarzgwangjuifminamiechizencouncilcoup" + - "onschweizjcbnlcoursesciencecentersciencehistorycq-acranbrookuwan" + - "alyticscientistor-elvdalcreditcardcreditunioncremonashorokanaiec" + - "rewiiheyaizuwakamatsubushikusakadogawacricketrzyncrimeacrotonews" + - "papercrownprovidercrscjohnsoncruisescotlandcuisinellahppiacenzam" + - "amibuilderscrapper-siteculturalcentertainmentoyotaris-a-doctoray" + - "cuneocupcakecxn--1ctwolominamatamayukis-a-financialadvisor-aurda" + - "lcymruovatoyotomiyazakis-a-geekgalaxycyonabarussiacyouthdfcbankz" + - "lgujolsterfiguerestaurantoyourafilateliafilminamifuranofinalfina" + - "ncefineartservegame-serverisignfinlandfinnoyfirebaseapparaglidin" + - "guovdageaidnudmurtiafirenzefirestonexuscultureggio-calabriafirmd" + - "aleirfjordfishingolffanservehalflifestylefitjarqhachiojiyahikobe" + - "atservehttparisor-fronfitnessettlementoystre-slidrettozawafjaler" + - "flesbergushikamifuranosegawaflickragerotikamakurazakinkobayashik" + - "shacknetnedalflightservehumourflirumannorthwesternmutualfloginto" + - "hmansionserveirchernihivanovosibirskydivingripefloraflorenceflor" + - "idafloristanohatakahamanxn--1lqs71dfloromskoguchikuzenflowerserv" + - "eminecraftozsdeflsmidthruhereggio-emilia-romagnakanojohanamakino" + - "haraflynnhubalsfjordishakotankarmoyomitanobiraurskog-holandrover" + - "halla-speziaeroportalabamagasakishimabarackmaze12fndfoodnetworks" + - "hoppingxn--1qqw23afor-ourfor-someetranbyfor-theaterforexrothachi" + - "rogatakamoriokamikitayamatotakadaforgotdnservemp3utilitiesquarez" + - "zoologicalvinklein-addrammenuernbergdyniabcn-north-1kappleaseati" + - "ng-organicbcg12000emmafanconagawakayamadridvagsoyericsson-aptibl" + - "eangaviikadenaamesjevuemielno-ip6forli-cesena-forlicesenaforlike" + - "scandyndns-at-workinggrouparliamentrani-andria-barletta-trani-an" + - "driaforsaleirvikhvanylveniceforsandasuoloftraniandriabarlettatra" + - "niandriafortmissoulan-udegreefortworthadanoshiroomuraforuminamii" + - "selectranoyfosneservep2parmafotransportrapaniimimatakatsukis-a-g" + - "reenfoxn--2m4a15efreeboxostrowiechernivtsiciliafreemasonryfreibu" + - "rgzparocherkasyzrankoshigayaltaikis-a-gurufcfanfreightcmwildlife" + - "djejuegoshikiminokamoenairlinedre-eikerfreseniusdecorativeartser" + - "vepicservequakefribourgfriuli-v-giuliafriuli-ve-giuliafriuli-veg" + - "iuliafriuli-venezia-giuliafriuli-veneziagiuliafriuli-vgiuliafriu" + - "liv-giuliafriulive-giuliafriulivegiuliafriulivenezia-giuliafriul" + - "iveneziagiuliafriulivgiuliafrlfroganservesarcasmatartanddesignfr" + - "ognfrolandfrom-akrehamnfrom-alfrom-arfrom-azwilliamhillfrom-cape" + - "townnews-stagingfrom-collectionfrom-ctravelchannelfrom-dchernovt" + - "sykkylvenetogitsuldalukowhalingriwataraidyndns-workisboringronda" + - "rfrom-dell-ogliastrakhanawawinbaltimore-og-romsdalimoliserniaust" + - "evollavangenativeamericanantiques3-eu-central-1from-flanderservi" + - "cesettsurfastlyfrom-gausdalfrom-higashiagatsumagoiparsevastopole" + - "from-iafrom-idfrom-ilfrom-incheonfrom-ksevenassisicilyfrom-kyoto" + - "betsumidatlantichiryukyuragifudaigodoesntexistanbullensvanguardy" + - "nnsarufutsunomiyawakasaikaitakoelnissedaluroyfrom-lanbibaidarfro" + - "m-maorivnefrom-mdfrom-megurorostrowwlkpmgfrom-microsoftbanklabud" + - "habikinokawabarthadselfipartis-a-hard-workerfrom-mnfrom-mochizuk" + - "irafrom-msewindmillfrom-mtnfrom-nchitachinakagawatchandclockazim" + - "ierz-dolnyfrom-ndfrom-nefrom-nhktravelersinsurancefrom-njcpartne" + - "rsfranziskanerdpolicefrom-nminamiizukamitsuefrom-nvaolbia-tempio" + - "-olbiatempioolbialystokkemerovodkagoshimakeupowiathletajimabaria" + - "kepnoipirangalsacefrom-nyfrom-ohkurafrom-oketohnoshoooshikamaish" + - "imofusartshangrilangevagrarboretumbriamallamaintenancechirealtor" + - "landfrom-orfrom-paderbornfrom-pratohobby-sitexasdaburyatiaarpart" + - "sharis-a-hunterfrom-ris-a-knightrdfrom-schoenbrunnfrom-sdniprope" + - "trovskypescaravantaafrom-tnfrom-txn--30rr7yfrom-utazuerichardlil" + - "lehammerfest-mon-blogueurovisionfrom-vaksdalfrom-vtrentino-a-adi" + - "gefrom-wafrom-wielunnerfrom-wvareservebeerfrom-wyfrosinonefrosta" + - "lowa-wolawafroyahabaghdadultrentino-aadigefstcgroupartyfujiidera" + - "fujikawaguchikonefujiminohtawaramotoineppugliafujinomiyadafujiok" + - "ayamarburgfujisatoshonairportland-4-salernogatachikawakuyabukick" + - "s-assedichitosetogliattiresasayamafujisawafujishiroishidakabirat" + - "oridellogliastraderfujitsurugashimamateramodalenfujixeroxn--32vp" + - "30haebaruminamimakis-a-landscaperugiafujiyoshidafukayabeardubaid" + - "uckdnsdojoburgfukuchiyamadafukudominichloefukuis-a-lawyerfukumit" + - "subishigakirkenesharpasadenaklodzkodairafukuokazakirovogradoyfuk" + - "uroishikarikaturindalfukusakiryuohagakhanamigawafukuyamagatakaha" + - "rulsandoyfunabashiriuchinadafunagatakahashimamakisarazurewebsite" + - "shikagamiishibukawafunahashikamiamakusatsumasendaisennangonoheji" + - "s-a-liberalfundaciofuoiskujukuriyamarcheapassagenshawaiijimarumo" + - "rimachidafuosskoczowindowshellaspeziafurnitureggiocalabriafurubi" + - "raquarellebesbyglandfurudonostiafurukawairtelecityeatshimokawafu" + - "sodegaurafussaikishiwadafutabayamaguchinomigawafutboldlygoingnow" + - "here-for-moregontrailroadfuttsurugiminamiminowafvgfyis-a-liberta" + - "rianfylkesbiblackfridayfyresdalhannovarggatrentino-alto-adigehan" + - "yuzenhapmirhappoumuenchenhareidsbergenharstadharvestcelebrationh" + - "asamarahasaminami-alpssells-for-ulvikmshimonosekikawahashbanghas" + - "udahasvikokonoehatogayahoohatoyamazakitahatakanabeautydalhatsuka" + - "ichiharahattfjelldalhayashimamotobuildinghazuminobusells-itrenti" + - "no-altoadigehboehringerikehelsinkitahiroshimarshallstatebankolob" + - "rzegersundhembygdsforbundhemneshimosuwalkis-a-musicianhemsedalhe" + - "rokussldheroyhgtvaroyhigashichichibungotakadatinghigashihiroshim" + - "anehigashiizumozakitakamiizumisanofidelityumenhigashikagawahigas" + - "hikagurasoedahigashikawakitaaikitakatakanezawahigashikurumeiwama" + - "rugame-hostinghigashimatsushimarinehigashimatsuyamakitaakitadait" + - "oigawahigashimurayamalatvuopmidoris-a-nascarfanhigashinarusellsy" + - "ourhomeipaviancarbonia-iglesias-carboniaiglesiascarboniahigashin" + - "ehigashiomihachimanchesterhigashiosakasayamamotorcycleshimotsuke" + - "higashishirakawamatakaokamikoaniikappulawyhigashisumiyoshikawami" + - "namiaikitakyushuaiahigashitsunotogawahigashiurausukitamidsundhig" + - "ashiyamatokoriyamanakakogawahigashiyodogawahigashiyoshinogaris-a" + - "-nurseoulminamisanrikubetsupplieshimotsumahiraizumisatokamachipp" + - "ubetsubetsugarunusualpersonhirakatashinagawahiranais-a-painterac" + - "tivegarsheis-a-patsfanhirarahiratsukagawahirayaitakarazukamimine" + - "rshinichinanhistorichouseshinjournalismailillesandefjordhitachio" + - "miyaginankokubunjis-a-personaltrainerhitachiotagooglecodespotren" + - "tino-s-tirollagrigentomologyhitoyoshimifunehitradinghjartdalhjel" + - "melandholeckobierzyceholidayhomelinuxn--3bst00minamitanehomesecu" + - "ritymaceratakasagopocznortonsberghomesecuritypccwinnershinjukuma" + - "nohomesensembokukitamotosumitakaginowaniihamatamakawajimaritimod" + - "ellinghomeunixn--3ds443ghondahonefosshinkamigotoyohashimotottori" + - "s-a-photographerokuappfizerhoneywellhongorgehonjyoitakasakitanak" + - "agusukumoduminamiuonumatsumaebashimodatehornindalhorseminehorten" + - "dofinternetrentino-stirolhoteleshinshinotsurgeonshalloffamemerge" + - "ncyberlevagangaviikanonjis-a-playerhotmailhoyangerhoylandetroits" + - "komaganehumanitieshinshirohurdalhurumajis-a-republicancerresearc" + - "haeologicaliforniahyllestadhyogoris-a-rockstarachowicehyugawarah" + - "yundaiwafunehzchonanbugattipschmidtre-gauldaluxembourgrongaiwcho" + - "seirouterjgorajlchoshibuyachiyodavvesiidazaifuefukihaborokunohea" + - "lth-carereformitakeharajlljmpgfoggiajnjelenia-gorajoyokaichibahc" + - "avuotnagaraholtalenjpmorganjpnchoyodobashichikashukujitawarajprs" + - "hioyamemorialjuniperjurkristiansundkrodsheradkrokstadelvaldaosta" + - "rostwodzislawioshirakoenigkryminamiyamashirokawanabellevuelosang" + - "elesjaguarchitecturebungoonomichinomiyakekumatorinokumejimasudak" + - "umenanyokkaichirurgiens-dentistes-en-francekunisakis-an-accounta" + - "ntshintokushimakunitachiarailwaykunitomigusukumamotoyamassa-carr" + - "ara-massacarraramassabunkyonanaoshimageandsoundandvisionkunneppu" + - "pharmacyshiranukanmakiwakunigamihamadakunstsammlungkunstunddesig" + - "nkuokgrouphiladelphiaareadmyblogsitekureitrentinoa-adigekurganku" + - "robelgorodeokurogimilitarykuroisoftwarendalenugkuromatsunais-an-" + - "actorkurotakikawasakis-an-actresshintomikasaharakurskommunekushi" + - "rogawakustanais-an-anarchistoricalsocietykusupersportrentinoaadi" + - "gekutchanelkutnokuzbassnillfjordkuzumakis-an-artistjohnkvafjordk" + - "valsundkvamfamberkeleykvanangenkvinesdalkvinnheradkviteseidskogk" + - "vitsoykwpspiegelkyowariasahikawamisugitokuyamatsusakahoginozawao" + - "nsenmitourismolanciamitoyoakemiuramiyazumiyotamanomjondalenmlbfa" + - "nmonmouthaibarakisosakitagawamonstermonticellombardiamondshiraoi" + - "zumizakis-bymontrealestatefarmequipmentrentinoalto-adigemonza-br" + - "ianzaporizhzheguris-certifiedekakegawamonza-e-della-brianzaporiz" + - "hzhiamonzabrianzapposhiraokannamiharumonzaebrianzaptokyotangotpa" + - "ntheonsitextileitungsenmonzaedellabrianzaramoparachutingmordovia" + - "jessheiminanomoriyamatsushigemoriyoshiokamogawamormoneymoroyamat" + - "suuramortgagemoscowitdkomorotsukamisunagawamoseushistorymosjoenm" + - "oskeneshiratakahagivingmosshishikuis-foundationmosvikomvuxn--3e0" + - "b707emoviemovistargardmtpchristmasakikuchikuseikarugaulardaluxur" + - "ymtranakatsugawamuenstermugithubcloudusercontentrentinoaltoadige" + - "muikanagawamukochikushinonsenergymulhouservebbshisognemultichoic" + - "emunakatanemuncieszynmuosattemuphilatelymurmanskongsbergmurotorc" + - "raftrentinos-tirolmusashimurayamatsuzakis-gonemusashinoharamusee" + - "trentinostirolmuseumverenigingmutsuzawamutuellevangermydshisuifu" + - "ettertdasnetzmyeffectrentinosud-tirolmyfritzmyftphilipsymykolaiv" + - "barclaycardstvedestrandiskstationatuurwetenschappenaumburgjovika" + - "rpaczeladz-2mymediapchromedicaltanissettaishinomakikugawatchesas" + - "katchewanggouvicenzamyokohamamatsudamypepostfoldnavyatkakudamats" + - "uemypetshitaramamyphotoshibahccavuotnagareyamalopolskanlandmypsx" + - "n--3oq18vl8pn36amysecuritycamerakermytis-a-bookkeepermincommbank" + - "omonomyvnchryslerpiagetmyiphoenixn--3pxu8kongsvingerpictetrentin" + - "osudtirolpictureshizukuishimogosenpiemontepilotshizuokanoyakagep" + - "inkoninjamisonpioneerpippupiszpittsburghofauskedsmokorsetagayase" + - "lls-for-lesscrappingulenpiwatepizzapkonskowolancashirehabmerplan" + - "etariuminnesotaketakayamatsumotofukeplantationplantshoujis-into-" + - "animelbourneplatformintelligenceplaystationplazaplchungbukchrist" + - "iansburgrossetouchijiwadeloittenrightathomegoodsassaris-a-democr" + - "atkmaxxn--11b4c3dynv6plombardyndns-blogdnsiskinkyknethnologyplum" + - "bingovtrentinosued-tirolplusterpmnpodzonepohlpointtoshimapokerpo" + - "krovskonsulatrobelaudibleborkdalpharmaciensnasaarlandpolkowicepo" + - "ltavalle-aostathellexuslivinghistorypomorzeszowithgoogleapisa-ho" + - "ckeynutrentinosuedtirolpordenonepornporsangerporsanguideltaiwana" + - "irguardporsgrunnanpoznanpraxis-a-bruinsfanprdpreservationpresidi" + - "oprgmrprimelhustkamitondabayashiogamagoriziaprincipeprivatizehea" + - "lthinsuranceprochowiceproductionshowaprofbsbxn--1lqs03nprogressi" + - "vegaskimitsubatamicable-modembetsukuis-into-carshinyoshitomiokan" + - "iepceprojectrentoyonakagyokutoyakokamishihoronobeokaminoyamatsur" + - "is-into-cartoonshiojirishirifujiedapromombetsupportrevisohughesh" + - "owtimetlifeinsurancepropertyprotectionprudentialpruszkowithyoutu" + - "bentleyprzeworskogptzpvtroandinosaurlandeshriramlidlugolekagamin" + - "ogiessengerdalcesienaplesigdalpwchungnamdalseidfjordyroyrvikingr" + - "oundhandlingroznypzqldqponqslgbtrogstadquicksytesilkonyvelolqvch" + - "urchasejnysowaspjelkavikosakaerodromegallupinbananarepublicartie" + - "reviewskrakoweddingjesdalindasiaustinnaturalhistorymuseumcentere" + - "pbodyndns-freebox-oskolegnicanonoichikawamisatogakushimotoganewh" + - "ollanddnskingjerdrumckinseyekaterinburgjerstadotsuruokamchatkame" + - "okameyamashinatsukigatakahatakaishimoichinosekigaharaetnagaivuot" + - "nagaokakyotambabydgoszczecinemailavagiske164spreadbettingspydebe" + - "rgsrlsrtromsojavald-aostarnbergsrvdonskoseis-a-teacherkassymante" + - "chnologystoragestordalstorenburgstorfjordstpetersburgstreamsterd" + - "amnserverbaniastudiostudyndns-homeftpaccessimple-urlstuff-4-sale" + - "stufftoread-booksnesirdalstuttgartrusteesurnadalsurreysusakis-lo" + - "stre-toteneis-a-soxfansusonosuzakanumazurysuzukanzakiwiensuzukis" + - "-not-certifiedogawarabikomaezakirunorilskomakiyosatokigawasvalba" + - "rdudinkakamigaharasveiosvelvikosherbrookegawasvizzeraswedenswidn" + - "icargodaddyndns-at-homednshomebuiltrvenneslaskerrylogisticslings" + - "wiebodzindianmarketingswiftcoveronaritakurashikis-saveducatorahi" + - "meshimakanegasakindleikangerswinoujscienceandhistoryswisshikis-s" + - "lickomatsushimashikiyosemitevestnesnzvestre-slidreamhostersokanr" + - "avestre-totennishiawakuravestvagoyvevelstadvibo-valentiavibovale" + - "ntiavideovillaskoyabearalvahkihokumakogenglandvinnicarriervinnyt" + - "siavipsinaapphotographysiovirginiavirtualvirtuelvisakatakinouevi" + - "staprinternationalfirearmsokndalviterboltrysiljan-mayenvivoldavl" + - "adikavkazanvladimirvladivostokaizukarasuyamazoevlogvolkenkunders" + - "eaportulanslupskopervikomitamamuravolkswagentsolarssonvologdansk" + - "ostromahachijorpelandvolvolgogradvolyngdalvoronezhytomyrvossevan" + - "genvotevotingvotoyonezawavrnworse-thangglidingwowiwatsukiyonowru" + - "zhgorodoywritesthisblogsytewroclawloclawekosugewtchuvashiawtfbx-" + - "oslodingenwuozuwwworldwzmiuwajimaxn--4it168dxn--4it797kotohirado" + - "mainsureisenxn--4pvxsolognexn--54b7fta0ccitadeliveryggeelvinckdd" + - "ielddanuorrikuzentakatajimicrolightingrpamperedchefashionisshing" + - "ugexn--55qw42gxn--55qx5dxn--5js045dxn--5rtp49citicatholicdn77-ss" + - "lattuminamibosogndalucernexn--5rtq34kotouraxn--5su34j936bgsgxn--" + - "5tzm5gxn--6btw5axn--6frz82gxn--6orx2rxn--6qq986b3xlxn--7t0a264ci" + - "vilaviationiyodogawaxn--80adxhksolundbeckosaigawaxn--80ao21axn--" + - "80aqecdr1axn--80asehdbarclays3-us-west-2xn--80aswgxn--80audnedal" + - "nxn--8ltr62kouhokutamakizunokunimilanoxn--8pvr4uxn--8y0a063axn--" + - "90a3academyactivedirectoryazannakadomari-elasticbeanstalkounosun" + - "ndalxn--90aishobaraomoriguchiharagusabaerobaticketsaritsynologye" + - "ongnamegawakeisenbahnxn--90azhair-surveillancexn--9dbhblg6dietci" + - "mmobilienxn--9dbq2axn--9et52uxn--9krt00axn--andy-iraxn--aroport-" + - "byanagawaxn--asky-iraxn--aurskog-hland-jnbarefootballangenoamish" + - "irasatochigiftsakuraibigawaustraliaisondriodejaneirochestereport" + - "arnobrzegyptianaturalsciencesnaturelles3-eu-west-1xn--avery-yuas" + - "akegawaxn--b-5gaxn--b4w605ferdxn--bck1b9a5dre4civilisationrwhosw" + - "hokksundxn--bdddj-mrabdxn--bearalvhki-y4axn--berlevg-jxaxn--bhca" + - "vuotna-s4axn--bhccavuotna-k7axn--bidr-5nachikatsuuraxn--bievt-0q" + - "a2xn--bjarky-fyanaizuxn--bjddar-ptamboversaillesnoasaitamatsukur" + - "is-into-gamessinashikitaurayasudaxn--blt-elaborxn--bmlo-grainger" + - "xn--bod-2naroyxn--brnny-wuaccident-investigationjukudoyamagadanc" + - "ebetsukubabia-goracleaningatlantabusebastopologyeonggiehtavuoatn" + - "adexeterimo-i-ranagahamaroygardendoftheinternetflixilovecollegef" + - "antasyleaguernseyxn--brnnysund-m8accident-preventionlineat-urlxn" + - "--brum-voagatunesmolenskoryolasitexn--btsfjord-9zaxn--c1avgxn--c" + - "2br7gxn--c3s14misasaguris-an-entertainerxn--cck2b3bargainstitute" + - "lefonicafederationaustdalinkaruizawaustrheimatunduhrennesoyokosu" + - "kareliancebinorfolkebiblegoldpoint2thisayamanashiibadajozorahkke" + - "ravjudygarlandds3-external-1xn--cg4bkis-uberleetrentino-sudtirol" + - "xn--ciqpnxn--clchc0ea0b2g2a9gcdn77-securecreationxn--comunicaes-" + - "v6a2oxn--correios-e-telecomunicaes-ghc29axn--czr694barreauctiona" + - "val-d-aosta-valleyonagoyauthordalandroidgcahcesuolocalhistorybni" + - "kahokutoeigersundigitalaziobihirosakikamijimagroks-thisamitsukem" + - "buchikumagayagawakkanaibetsubamericanfamilydscloudappspotenzachp" + - "omorskienebakkeshibechambagriculturennebudapest-a-la-masionthewi" + - "fiat-band-campaniabogadocscbggfareastcoastaldefence-burgjemnes3-" + - "ap-northeast-1xn--czrs0tunkoshimizumakiyosumydrobofagexn--czru2d" + - "xn--czrw28barrel-of-knowledgeologyonaguniversityoriikarumaifarme" + - "rseinextdirectarumizusawautomotivecodynaliascoli-picenord-aurdal" + - "ipayufuchukotkafjordiscountysvardolls3-external-2xn--d1acj3barre" + - "ll-of-knowledgeometre-experts-comptablesakyotanabeneventodayukuh" + - "ashimojibmditchyouripagefrontappagespeedmobilizerobninskasaokami" + - "satokashikitchenavigationavuotnakayamatta-varjjatatamotorsalange" + - "nayoroceanographicsalondonetskashibatakashimaseratiinetatarstanf" + - "lfanfshostrodawarautoscanadaejeonbukariyakumoldevents3-fips-us-g" + - "ov-west-1xn--d1alfaromeoxn--d1aturystykarasjokoshunantokonamegat" + - "akatoris-a-techietis-a-socialistmeindianapolis-a-bloggerxn--d5qv" + - "7z876civilizationxn--davvenjrga-y4axn--djrs72d6uyxn--djty4kouyam" + - "ashikokuchuoxn--dnna-grajewolterskluwerxn--drbak-wuaxn--dyry-ira" + - "xn--e1a4civilwarmanagementmpanamaxn--eckvdtc9dxn--efvn9solutions" + - "imbirskooris-a-studentalxn--efvy88hakatanotaireshimokitayamaxn--" + - "ehqz56nxn--elqq16hakodatexn--estv75gxn--eveni-0qa01gaxn--f6qx53a" + - "xn--fct429kouzushimasoyxn--fhbeiarnxn--finny-yuaxn--fiq228c5hsom" + - "axn--fiq64bashkiriaveroykeniwaizumiotsukumiyamazonawsadodgemolog" + - "icallyngenvironmentalconservationaturbruksgymnaturhistorisches3-" + - "sa-east-1xn--fiqs8somnarashinoxn--fiqz9sooxn--fjord-lraxn--fjq72" + - "0axn--fl-ziaxn--flor-jraxn--flw351exn--fpcrj9c3dxn--frde-grandra" + - "pidsopotromsakakinokiaxn--frna-woaraisaijosoyrovigorlicexn--frya" + - "-hraxn--fzc2c9e2claimsaudaxn--fzys8d69uvgmailxn--g2xx48clickfhsk" + - "habarovskhakassiaxn--gckr3f0fbxostrolekaluganskhmelnytskyivallee" + - "aosteigenxn--gecrj9clinicheltenham-radio-openair-traffic-control" + - "leyxn--ggaviika-8ya47hakonexn--gildeskl-g0axn--givuotna-8yandexn" + - "--42c2d9axn--gjvik-wuaxn--gk3at1exn--gls-elacaixaxn--gmq050is-ve" + - "ry-badaddjamalborkangerxn--gmqw5axn--h-2failxn--h1aeghakubankmps" + - "pacekitagatakasugais-a-linux-useranishiaritabashikaoirminamiogun" + - "icomcastresistancexn--h2brj9cliniquenoharaxn--hbmer-xqaxn--hcesu" + - "olo-7ya35basilicataniavocatanzarowebhoppdalillyokotebizenakamura" + - "tajirissagamiharamusementarantours3-ap-northeast-2xn--hery-iraxn" + - "--hgebostad-g3axn--hmmrfeasta-s4acctuscanyxn--hnefoss-q1axn--hob" + - "l-iraxn--holtlen-hxaxn--hpmir-xqaxn--hxt814exn--hyanger-q1axn--h" + - "ylandet-54axn--i1b6b1a6a2exn--imr513nxn--indery-fyaotsurgutsirac" + - "usaitotalxn--io0a7is-very-evillagexn--j1aefermobilyxn--j1amhakui" + - "s-a-llamarylhursteinkjerusalembroideryxn--j6w193gxn--jlq61u9w7ba" + - "sketballfinanzgoravoues3-us-gov-west-1xn--jlster-byaroslavlaande" + - "renxn--jrpeland-54axn--jvr189misawaxn--k7yn95exn--karmy-yuaxn--k" + - "brq7oxn--kcrx77d1x4axn--kfjord-iuaxn--klbu-woaxn--klt787dxn--klt" + - "p7dxn--kltx9axn--klty5xn--45brj9circlegallocus-east-1xn--koluokt" + - "a-7ya57hakusandiegoodyearthagebostadxn--kprw13dxn--kpry57dxn--kp" + - "u716ferraraxn--kput3is-very-goodhandsonxn--krager-gyasakaiminato" + - "yonoxn--kranghke-b0axn--krdsherad-m8axn--krehamn-dxaxn--krjohka-" + - "hwab49jetztrentino-suedtirolxn--ksnes-uuaxn--kvfjord-nxaxn--kvit" + - "sy-fyasugis-very-nicexn--kvnangen-k0axn--l-1fairwindsor-odalxn--" + - "l1accentureklamborghiniizaxn--laheadju-7yasuokaratexn--langevg-j" + - "xaxn--lcvr32dxn--ldingen-q1axn--leagaviika-52batochiokinoshimalv" + - "ikashiharaxasnesoddenmarkets3-ap-southeast-1xn--lesund-huaxn--lg" + - "bbat1ad8jevnakershusgardenxn--lgrd-poacoachampionshiphoptobamaga" + - "zinebraskaunbieidsvollxn--lhppi-xqaxn--linds-pramericanartushuis" + - "sier-justicexn--lns-qlanxessor-varangerxn--loabt-0qaxn--lrdal-sr" + - "axn--lrenskog-54axn--lt-liaclintonoshoesauheradxn--lten-granexn-" + - "-lury-iraxn--mely-iraxn--merker-kuaxn--mgb2ddesorfoldxn--mgb9awb" + - "ferrarittoguraxn--mgba3a3ejtuvalle-daostavangerxn--mgba3a4f16axn" + - "--mgba3a4franamizuholdingsmileksvikozagawaxn--mgba7c0bbn0axn--mg" + - "baakc7dvferreroticapebretonamiasakuchinotsuchiurakawassamukawata" + - "ricohdatsunanjoetsuwanouchikujogaszkoladbrokeserveexchangexn--mg" + - "baam7a8haldenxn--mgbab2bdxn--mgbai9a5eva00batsfjordivtasvuodnaha" + - "rimaniwakuratevadsoccertificationhlfanhsaltdalinzaiitatebayashij" + - "onawatemrhcloudcontrolledivttasvuotnakaiwamizawaxn--mgbai9azgqp6" + - "jewelryxn--mgbayh7gpaduaxn--mgbb9fbpobanazawaxn--mgbbh1a71exn--m" + - "gbc0a9azcgxn--mgbca7dzdoxn--mgberp4a5d4a87gxn--mgberp4a5d4arxn--" + - "mgbi4ecexposedxn--mgbpl2fhvalerxn--mgbqly7c0a67fbclothingruexn--" + - "mgbqly7cvafredrikstadtvsorreisahayakawakamiichikaiseis-leetrenti" + - "no-sud-tirolxn--mgbt3dhdxn--mgbtf8flatangerxn--mgbtx2bauhauspost" + - "s-and-telecommunicationsupdatelekommunikationikiiyamanobeauxarts" + - "andcraftsalvadordalibabaikaliszczytnord-odalvdalaskanittedallasa" + - "lleasinglesalzburgladelmenhorstalbansamegawaxn--mgbx4cd0abbottxn" + - "--mix082fetsundxn--mix891fgunmarriottoyotsukaidownloadxn--mjndal" + - "en-64axn--mk0axindustriesteambulancexn--mk1bu44cloudfrontdoorxn-" + - "-mkru45is-very-sweetrentino-sued-tirolxn--mlatvuopmi-s4axn--mli-" + - "tlapyatigorskozakis-a-therapistoiaxn--mlselv-iuaxn--moreke-juaxn" + - "--mori-qsakuhokkaidontexisteingeekpnxn--mosjen-eyatominamiawajik" + - "is-with-thebandoomdnsaliascolipicenord-frontierxn--mot-tlaquilan" + - "casterxn--mre-og-romsdal-qqbbcartoonartdecoffeedbackashiwaraxn--" + - "msy-ula0halsaintlouis-a-anarchistoireggioemiliaromagnakasatsunai" + - "rtraffichocolatelemarkazoxn--mtta-vrjjat-k7afamilycompanycloudfu" + - "nctionsavannahgaxn--muost-0qaxn--mxtq1misconfusedxn--ngbc5azdxn-" + - "-ngbe9e0axn--ngbrxn--45q11circuscountryestateofdelawaredstonewme" + - "xicoldwarmiamiastaplesatxn--1ck2e1balsanagochihayaakasakawaharau" + - "malselvendrellimitedunetbankarlsoyokozemersongdalenviknakaniikaw" + - "atanaguraukraanghkebinagisochildrensgardenasushiobarabruzzoology" + - "eongbuk-uralsk12xn--nit225kppspbarcelonagasakijobserverdalindesn" + - "es3-us-west-1xn--nmesjevuemie-tcbajddarchaeologyxn--nnx388axn--n" + - "odessakuragawaxn--nqv7fs00emaxn--nry-yla5gxn--ntso0iqx3axn--ntsq" + - "17gxn--nttery-byaeserveblogspotxn--nvuotna-hwaxn--nyqy26axn--o1a" + - "chattanooganore-og-uvdalxn--o3cw4hammarfeastafricamagichofunator" + - "ientexpressaseboknowsitallutskazunoxn--od0algxn--od0aq3bbtateshi" + - "nanomachintaijinfinitinfolldalipetskashiwazakiyokawaraxn--ogbpf8" + - "flekkefjordxn--oppegrd-ixaxn--ostery-fyatsukaratsuginamikatagami" + - "hoboleslawiecntoyookarasjohkamiokaminokawanishiaizubangexn--osyr" + - "o-wuaxn--p1acfidonnakamagayachtserveftpanasonichernigovernmentjx" + - "n--0trq7p7nnissandnessjoenissayokoshibahikariwanumataketomisatom" + - "skautokeinoxn--p1aisleofmandalxn--pbt977colonialwilliamsburguita" + - "rsaves-the-whalessandria-trani-barletta-andriatranibarlettaandri" + - "axn--pgbs0dhlxn--porsgu-sta26fieldxn--pssu33lxn--pssy2uxn--q9jyb" + - "4coloradoplateaudioxn--qcka1pmcdonaldsortlandxn--qqqt11mishimats" + - "unoxn--qxamurskiptveterinairealtychyattorneyagawalbrzycharternop" + - "ilawalesundxn--rady-iraxn--rdal-poaxn--rde-ularvikrasnodarxn--rd" + - "y-0nabarissmarterthanyounzenxn--rennesy-v1axn--rhkkervju-01aflak" + - "stadaokagakibichuoxn--rholt-mragowoodsidexn--rhqv96gxn--rht27zxn" + - "--rht3dxn--rht61exn--risa-5narusawaxn--risr-iraxn--rland-uuaxn--" + - "rlingen-mxaxn--rmskog-byatsushiroxn--rny31hamurakamigoriginshimo" + - "nitayanagivestbytomaritimekeepingxn--rovu88bbvacationswatch-and-" + - "clockerxn--rros-granvindafjordxn--rskog-uuaxn--rst-0narutomobell" + - "unordkappgafanpachigasakidsmynasperschlesischesorumisakis-an-eng" + - "ineeringxn--rsta-francaiseharaxn--ryken-vuaxn--ryrvik-byawaraxn-" + - "-s-1faitheguardianxn--s9brj9columbusheyxn--sandnessjen-ogbizhevs" + - "krasnoyarskommunalforbundxn--sandy-yuaxn--seral-lraxn--ses554gxn" + - "--sgne-gratangenxn--skierv-utazaskvolloabathsbcommunitysnesavona" + - "msskoganeis-a-designerimarylandxn--skjervy-v1axn--skjk-soaxn--sk" + - "nit-yqaxn--sknland-fxaxn--slat-5narviikanazawaxn--slt-elabourxn-" + - "-smla-hraxn--smna-gratis-a-bulls-fanxn--snase-nraxn--sndre-land-" + - "0cbremangerxn--snes-poaxn--snsa-roaxn--sr-aurdal-l8axn--sr-fron-" + - "q1axn--sr-odal-q1axn--sr-varanger-ggbeppubolognagasukepsonyoursi" + - "defenseljordiyurihonjournalistjordalshalsenikkoebenhavnikolaever" + - "bankasukabedzin-the-bandaikawachinaganoharamcoalaheadjudaicaaarb" + - "orteaches-yogasawaracingroks-theatreevje-og-hornnesamnangerxn--s" + - "rfold-byawatahamaxn--srreisa-q1axn--srum-grazxn--stfold-9xaxn--s" + - "tjrdal-s1axn--stjrdalshalsen-sqberndnpalacexn--stre-toten-zcbsou" + - "thcarolinazawaxn--t60b56axn--tckweatherchannelxn--tiq49xqyjewish" + - "artgalleryxn--tjme-hraxn--tn0agrinet-freaksouthwestfalenxn--tnsb" + - "erg-q1axn--tor131oxn--trany-yuaxn--trgstad-r1axn--trna-woaxn--tr" + - "oms-zuaxn--tysvr-vraxn--uc0atversicherungxn--uc0ay4axn--uist22ha" + - "ngoutsystemscloudcontrolappassenger-associationxn--uisz3gxn--unj" + - "rga-rtaobaokinawashirosatobishimaizurubtsovskjakdnepropetrovskie" + - "rvaapsteiermarkredirectmeldalxn--unup4yxn--uuwu58axn--vads-jraxn" + - "--vard-jraxn--vegrshei-c0axn--vermgensberater-ctbeskidynathomede" + - "potaruintuitateyamaxn--vermgensberatung-pwbestbuyshousesamsclubi" + - "ndalivornoceanographiquexn--vestvgy-ixa6oxn--vg-yiabbvieeexn--vg" + - "an-qoaxn--vgsy-qoa0jfkomforbamblebtimnetz-1xn--vgu402comobaraxn-" + - "-vhquvestfoldxn--vler-qoaxn--vre-eiker-k8axn--vrggt-xqadxn--vry-" + - "yla5gxn--vuq861betainaboxfordeatnuorockartuzyusuharaxn--w4r85el8" + - "fhu5dnraxn--w4rs40lxn--wcvs22dxn--wgbh1comparemarkerryhotelsaxox" + - "n--wgbl6axn--xhq521bielawallonieruchomoscienceandindustrynikonan" + - "tanangerxn--xkc2al3hye2axn--xkc2dl3a5ee0hannanmokuizumodernxn--y" + - "9a3aquariumissilelxn--yer-znarvikristiansandcatshirahamatonbetsu" + - "rgeryxn--yfro4i67oxn--ygarden-p1axn--ygbi2ammxn--4gbriminingxn--" + - "ystre-slidre-ujbiellaakesvuemieleccexn--zbx025dxn--zf0ao64axn--z" + - "f0avxn--4gq48lf9jeonnamerikawauexn--zfr164bieszczadygeyachimatai" + - "naioiraseeklogesuranceoddaxperiaxz" - -// nodes is the list of nodes. Each node is represented as a uint32, which -// encodes the node's children, wildcard bit and node type (as an index into -// the children array), ICANN bit and text. -// -// If the table was generated with the -comments flag, there is a //-comment -// after each node's data. In it is the nodes-array indexes of the children, -// formatted as (n0x1234-n0x1256), with * denoting the wildcard bit. The -// nodeType is printed as + for normal, ! for exception, and o for parent-only -// nodes that have children but don't match a domain label in their own right. -// An I denotes an ICANN domain. -// -// The layout within the uint32, from MSB to LSB, is: -// [ 1 bits] unused -// [ 9 bits] children index -// [ 1 bits] ICANN bit -// [15 bits] text index -// [ 6 bits] text length -var nodes = [...]uint32{ - 0x00398ec3, - 0x00271e44, - 0x0026a2c6, - 0x00367e03, - 0x00367e06, - 0x003a5c86, - 0x00252a03, - 0x002dd4c4, - 0x00322447, - 0x00269f08, - 0x01a050c2, - 0x00307107, - 0x00351089, - 0x002aee0a, - 0x002aee0b, - 0x00235c43, - 0x00298f86, - 0x00236985, - 0x01e00342, - 0x00217d44, - 0x0026a443, - 0x002765c5, - 0x02207282, - 0x0022c903, - 0x0260c744, - 0x002e8d05, - 0x02a07182, - 0x00370ace, - 0x002496c3, - 0x0037ab06, - 0x0037ab0b, - 0x02e00bc2, - 0x0027e887, - 0x00239286, - 0x032017c2, - 0x002677c3, - 0x002677c4, - 0x0021c506, - 0x0023b308, - 0x002839c6, - 0x003a1b84, - 0x036001c2, - 0x0032c3c9, - 0x00366447, - 0x00325f86, - 0x00348149, - 0x0028bc08, - 0x00335084, - 0x0026f306, - 0x00211c86, - 0x03a00502, - 0x0021578f, - 0x0032074e, - 0x002122c4, - 0x002b7245, - 0x002dd3c5, - 0x002ebe49, - 0x0023df89, - 0x0031e847, - 0x00213cc6, - 0x00213c03, - 0x03e03082, - 0x0026dcc3, - 0x002043ca, - 0x0020f303, - 0x00252d45, - 0x002003c2, - 0x00283049, - 0x04200e02, - 0x002020c4, - 0x00398a06, - 0x002ad205, - 0x00349cc4, - 0x04a71e84, - 0x00201383, - 0x00235f84, - 0x04e006c2, - 0x00271b84, - 0x002e5704, - 0x0021db4a, - 0x05200102, - 0x0026ec07, - 0x00385908, - 0x05a076c2, - 0x0031de07, - 0x002d7484, - 0x002d7487, - 0x00384385, - 0x00364e47, - 0x0031e606, - 0x00325604, - 0x0032b445, - 0x00292247, - 0x06a00f02, - 0x00334c83, - 0x00209ec2, - 0x00353243, - 0x06e0efc2, - 0x0020f445, - 0x07200dc2, - 0x002e9344, - 0x0027bf05, - 0x00212207, - 0x002e4b4e, - 0x00322144, - 0x00243ec4, - 0x00200dc3, - 0x003767c9, - 0x002c900b, - 0x00305548, - 0x0030ba48, - 0x00318c88, - 0x00223f08, - 0x00347f8a, - 0x00364d47, - 0x00229b86, - 0x07671942, - 0x0036e6c3, - 0x0037bdc3, - 0x0038bac4, - 0x00253283, - 0x00252a43, - 0x0170f302, - 0x07a054c2, - 0x00247f85, - 0x00289c06, - 0x00275984, - 0x002e1007, - 0x0022fac6, - 0x0022bc84, - 0x003a4a87, - 0x002054c3, - 0x07eb9f42, - 0x08302e02, - 0x08619ac2, - 0x00219ac6, - 0x08a00002, - 0x0031a505, - 0x00310843, - 0x002029c4, - 0x002d6004, - 0x002d6005, - 0x00206943, - 0x08f41d03, - 0x092094c2, - 0x00286305, - 0x0028630b, - 0x0022f206, - 0x0020c28b, - 0x00274444, - 0x0020cf49, - 0x0020dd44, - 0x0960c902, - 0x0020f743, - 0x0020fac3, - 0x01610382, - 0x0023d2c3, - 0x0021038a, - 0x09a07f02, - 0x00217fc5, - 0x0028b34a, - 0x00323c04, - 0x00211203, - 0x00212084, - 0x00213683, - 0x00213684, - 0x00213687, - 0x00214745, - 0x00216945, - 0x00217006, - 0x00217346, - 0x00218d83, - 0x0021eb08, - 0x0020f1c3, - 0x09e14f02, - 0x0021ffc8, - 0x00214f0b, - 0x00225408, - 0x00225906, - 0x002263c7, - 0x0022a2c8, - 0x0a62ca02, - 0x0aae3782, - 0x003219c8, - 0x002a7507, - 0x002410c5, - 0x002410c8, - 0x0021ce08, - 0x002a8583, - 0x0022e8c4, - 0x0038bb02, - 0x0ae30642, - 0x0b2168c2, - 0x0ba30c82, - 0x00230c83, - 0x0be00302, - 0x002dd483, - 0x00319184, - 0x00218f03, - 0x00335044, - 0x002521cb, - 0x00214e43, - 0x002cd686, - 0x0021d9c4, - 0x002a5cce, - 0x002e66c5, - 0x00260f08, - 0x0022aa07, - 0x0022aa0a, - 0x00232b03, - 0x00273287, - 0x002c91c5, - 0x00232b04, - 0x00232b06, - 0x00232b07, - 0x002ddb04, - 0x002e4e87, - 0x00203e44, - 0x002051c4, - 0x002051c6, - 0x002d1bc4, - 0x00222d46, - 0x0020db83, - 0x00229408, - 0x00301c48, - 0x00243e83, - 0x0023d283, - 0x00395044, - 0x0039bec3, - 0x0c215e02, - 0x0c701e02, - 0x002068c3, - 0x00206bc6, - 0x003b0503, - 0x00302544, - 0x0ca19942, - 0x0025aac3, - 0x00219943, - 0x0021abc2, - 0x0ce01a82, - 0x002b6146, - 0x00237887, - 0x002e4085, - 0x002e7e04, - 0x00281945, - 0x0037c187, - 0x0027c945, - 0x002c2649, - 0x002ca506, - 0x002ce248, - 0x002e3f86, - 0x0d2047c2, - 0x002349c8, - 0x0034b806, - 0x002047c5, - 0x002ffa07, - 0x00301b44, - 0x00301b45, - 0x00283b84, - 0x00283b88, - 0x0d60c342, - 0x0da0c842, - 0x00339406, - 0x00314488, - 0x00339dc5, - 0x0033b4c6, - 0x00340708, - 0x00362c48, - 0x002c3805, - 0x0020c844, - 0x0020c847, - 0x0de0d6c2, - 0x0e21ed82, - 0x0fa02682, - 0x00354985, - 0x0029bd45, - 0x0036ea46, - 0x00315e07, - 0x00215e47, - 0x1022f303, - 0x00340047, - 0x002cde08, - 0x00391b89, - 0x00370c87, - 0x003a99c7, - 0x002316c8, - 0x00231ec6, - 0x00232646, - 0x0023348c, - 0x0023400a, - 0x00235787, - 0x0023684b, - 0x002376c7, - 0x002376ce, - 0x002381c4, - 0x00238c04, - 0x00239c87, - 0x00372807, - 0x0023cf06, - 0x0023cf07, - 0x0023d387, - 0x12a07102, - 0x0023e606, - 0x0023e60a, - 0x0023e88b, - 0x0023f987, - 0x00240145, - 0x00240483, - 0x00240746, - 0x00240747, - 0x0023e143, - 0x12e30042, - 0x00240aca, - 0x133521c2, - 0x1369ebc2, - 0x13a42302, - 0x13e39382, - 0x00243045, - 0x00243c84, - 0x14627542, - 0x00271c05, - 0x00276583, - 0x00313f05, - 0x00208244, - 0x0028dac6, - 0x0035c146, - 0x00286503, - 0x0023a4c4, - 0x0031b343, - 0x14a03f42, - 0x002074c4, - 0x0020cdc6, - 0x002074c5, - 0x002575c6, - 0x002ffb08, - 0x00263184, - 0x002d45c8, - 0x002d9d85, - 0x002d4e88, - 0x00331486, - 0x002ae607, - 0x0025fe04, - 0x0025fe06, - 0x0032bb83, - 0x00383283, - 0x002bac88, - 0x00309e84, - 0x0031f407, - 0x00307446, - 0x00307449, - 0x003264c8, - 0x0022bdc8, - 0x0024e4c4, - 0x003972c3, - 0x002398c2, - 0x14e08f02, - 0x15210c42, - 0x0039b8c3, - 0x15613942, - 0x00322584, - 0x00334d85, - 0x0023f803, - 0x00233944, - 0x002fef87, - 0x002e7b43, - 0x00368b88, - 0x00207885, - 0x002c9284, - 0x00363503, - 0x0027be85, - 0x0027bfc4, - 0x0020bd06, - 0x0020c5c4, - 0x00210106, - 0x00212146, - 0x00253a84, - 0x002199c3, - 0x15a7d7c2, - 0x0034c585, - 0x00247fc3, - 0x15e02642, - 0x002bc6c5, - 0x00215403, - 0x00236049, - 0x1621be02, - 0x16a0fb82, - 0x002e9705, - 0x0021ba06, - 0x00374987, - 0x002c46c6, - 0x0038df48, - 0x0038df4b, - 0x00206c0b, - 0x002cb9c5, - 0x00396d45, - 0x002bb789, - 0x01600ac2, - 0x00253c48, - 0x0020c4c4, - 0x17200482, - 0x00251e03, - 0x17abb506, - 0x003b0388, - 0x17e05502, - 0x00228948, - 0x002072c2, - 0x0027458a, - 0x0022b343, - 0x0032bbc6, - 0x00397f08, - 0x0035cc88, - 0x00327586, - 0x003621c7, - 0x00215987, - 0x0021180a, - 0x00323c84, - 0x0033ea04, - 0x00350b09, - 0x0038f105, - 0x00320946, - 0x00212a83, - 0x00247504, - 0x00214b84, - 0x00324ec7, - 0x00300c87, - 0x00265244, - 0x00211745, - 0x0036eb08, - 0x00359007, - 0x0035b207, - 0x1820bf82, - 0x00322004, - 0x0028e888, - 0x0037f344, - 0x00244a04, - 0x00244dc5, - 0x00244f07, - 0x0020e389, - 0x00245b04, - 0x002466c9, - 0x00246ec8, - 0x00247284, - 0x00247287, - 0x00247a43, - 0x00248587, - 0x01619fc2, - 0x017a6502, - 0x00249706, - 0x0024a347, - 0x0024a784, - 0x0024c0c7, - 0x0024cd87, - 0x0024d3c8, - 0x0024e103, - 0x0023c9c2, - 0x00218942, - 0x0024fd03, - 0x0024fd04, - 0x0024fd0b, - 0x0030bb48, - 0x003a8644, - 0x00250cc5, - 0x00256107, - 0x00257d45, - 0x002c194a, - 0x00259103, - 0x186046c2, - 0x00259444, - 0x0025b9c9, - 0x0025f6c3, - 0x0025f787, - 0x00369d09, - 0x0036d9c8, - 0x002071c3, - 0x0027a4c7, - 0x0027ac09, - 0x0027f243, - 0x002812c4, - 0x00282949, - 0x00284bc6, - 0x00285c83, - 0x00201202, - 0x002437c3, - 0x0039d0c7, - 0x0034b985, - 0x002e4946, - 0x002453c4, - 0x00312205, - 0x00204383, - 0x00218fc6, - 0x0020d142, - 0x0038fe04, - 0x002281c2, - 0x002d5983, - 0x18a00c02, - 0x00246183, - 0x002177c4, - 0x002177c7, - 0x00202cc6, - 0x0025c582, - 0x18e46b82, - 0x002ffd04, - 0x1924a402, - 0x19602ec2, - 0x0030c284, - 0x0030c285, - 0x0038b205, - 0x002c1446, - 0x19a00642, - 0x00367445, - 0x00200645, - 0x00292603, - 0x00210746, - 0x00213805, - 0x00219a42, - 0x00339a05, - 0x00219a44, - 0x00224243, - 0x00226cc3, - 0x19e0ba02, - 0x002f1107, - 0x0031a644, - 0x0031a649, - 0x00247404, - 0x0029bbc3, - 0x0034d709, - 0x0034c448, - 0x0029bbc4, - 0x0029bbc6, - 0x0029e403, - 0x00212c43, - 0x002235c4, - 0x002d60c3, - 0x1a2e1442, - 0x0035ff02, - 0x1a60a6c2, - 0x00312e08, - 0x0032a2c8, - 0x00394486, - 0x00258fc5, - 0x0024ba85, - 0x0020a6c5, - 0x00231302, - 0x1aa3a3c2, - 0x0162c702, - 0x0038f288, - 0x00234905, - 0x00300fc4, - 0x002d9cc5, - 0x00381ec7, - 0x0025a984, - 0x0021f1c2, - 0x1ae02382, - 0x00309744, - 0x00214387, - 0x0039ff87, - 0x00364e04, - 0x0028b303, - 0x00243dc4, - 0x00243dc8, - 0x00232986, - 0x0023298a, - 0x0020e244, - 0x0028b688, - 0x0024d644, - 0x002264c6, - 0x0028d344, - 0x00354c86, - 0x0031fd09, - 0x0026b887, - 0x0024b543, - 0x1b20a402, - 0x0026c783, - 0x0020e9c2, - 0x1b616442, - 0x002d8f86, - 0x0035a488, - 0x0029d547, - 0x003a3e89, - 0x002d49c9, - 0x0029de05, - 0x0029f089, - 0x002a0605, - 0x002a16c9, - 0x002a2c45, - 0x002901c4, - 0x002901c7, - 0x002a1143, - 0x002a3647, - 0x003a9d86, - 0x002a48c7, - 0x0029a505, - 0x002a6c03, - 0x1ba33ac2, - 0x00391ac4, - 0x1be26ac2, - 0x0025ad03, - 0x1c209f82, - 0x002dfe46, - 0x00385885, - 0x002a6fc7, - 0x003281c3, - 0x00253204, - 0x00206883, - 0x00321703, - 0x1c608202, - 0x1ce00042, - 0x003a5d84, - 0x0023c983, - 0x0032ac85, - 0x002a4445, - 0x1d202fc2, - 0x1da03d02, - 0x0027a806, - 0x0020aac4, - 0x00309fc4, - 0x00309fca, - 0x1e200842, - 0x003693ca, - 0x0037c388, - 0x1e77c544, - 0x00213783, - 0x00249d03, - 0x00318dc9, - 0x0026ca49, - 0x002ff086, - 0x1ea4af03, - 0x002d3505, - 0x002f814d, - 0x003a4186, - 0x002058cb, - 0x1ee00942, - 0x0026f148, - 0x1f21c742, - 0x1f604f82, - 0x002df505, - 0x1fa024c2, - 0x00257fc7, - 0x0029a907, - 0x002183c3, - 0x00267ac8, - 0x1fe00b42, - 0x00312544, - 0x00213a83, - 0x003257c5, - 0x002a7ec3, - 0x002ad106, - 0x002ea344, - 0x0023d243, - 0x0026ce03, - 0x2020a942, - 0x00239904, - 0x0034f185, - 0x00360007, - 0x00277f03, - 0x002a8383, - 0x002a95c3, - 0x0161f9c2, - 0x002a9683, - 0x002a9903, - 0x20607e82, - 0x00376b84, - 0x0027c206, - 0x00209e03, - 0x002a9c83, - 0x20aaa4c2, - 0x002aa4c8, - 0x002aaf04, - 0x0025b0c6, - 0x002ab347, - 0x00223186, - 0x002fff44, - 0x2e602942, - 0x003a9c4b, - 0x002f1b4e, - 0x0021e5cf, - 0x00339ec3, - 0x2ee43782, - 0x01608e42, - 0x2f201e82, - 0x00226303, - 0x002372c3, - 0x00230a86, - 0x002f33c6, - 0x00329247, - 0x002eecc4, - 0x2f64fa82, - 0x2fa07bc2, - 0x00268745, - 0x002f40c7, - 0x002f0746, - 0x2fe69942, - 0x00269944, - 0x0036c843, - 0x3020aa02, - 0x0034e603, - 0x003a2384, - 0x002b2049, - 0x016b8182, - 0x3064b8c2, - 0x002d5bc6, - 0x00266ec5, - 0x30a43f82, - 0x30e00682, - 0x0033da87, - 0x0035c949, - 0x0035130b, - 0x00215745, - 0x0036df49, - 0x002b9386, - 0x0022f247, - 0x002079c4, - 0x0024edc9, - 0x00356547, - 0x00366f07, - 0x0020ac03, - 0x0020ac06, - 0x002d7287, - 0x002761c3, - 0x0027ccc6, - 0x31203002, - 0x316362c2, - 0x00214183, - 0x00252e05, - 0x00222bc7, - 0x0021d106, - 0x0034b905, - 0x0031a5c4, - 0x002d8485, - 0x002e3704, - 0x31a067c2, - 0x0030c807, - 0x002e1c04, - 0x00247804, - 0x002e01cd, - 0x00247809, - 0x00300788, - 0x0022ee84, - 0x00341a85, - 0x00374347, - 0x00263c44, - 0x0022fb87, - 0x00376e45, - 0x31f19604, - 0x002c8cc5, - 0x0025e384, - 0x002d85c6, - 0x00315c05, - 0x32238282, - 0x002112c4, - 0x002112c5, - 0x0038c046, - 0x0034ba45, - 0x002569c4, - 0x002e3e43, - 0x0032a506, - 0x00213245, - 0x00216cc5, - 0x00315d04, - 0x0020e2c3, - 0x0020e2cc, - 0x32685502, - 0x32a07582, - 0x32e12942, - 0x0035ea43, - 0x0035ea44, - 0x33205d42, - 0x00304848, - 0x002e4a05, - 0x002a7b04, - 0x002c2ec6, - 0x33634342, - 0x33a1a9c2, - 0x33e00182, - 0x002b1105, - 0x00253946, - 0x00324e04, - 0x0021ca46, - 0x0026e9c6, - 0x00201943, - 0x3433040a, - 0x00237e05, - 0x002f2346, - 0x002f2349, - 0x00353547, - 0x00368748, - 0x0028bac9, - 0x0032aac8, - 0x00223c46, - 0x00237fc3, - 0x346e5e02, - 0x00384743, - 0x00384749, - 0x002e74c8, - 0x34a0ab02, - 0x34e04502, - 0x0020c943, - 0x002ca385, - 0x002507c4, - 0x002d30c9, - 0x002a3e44, - 0x002ab148, - 0x00204503, - 0x00252644, - 0x002e7f83, - 0x002e0107, - 0x352699c2, - 0x00260c82, - 0x00373245, - 0x00269b89, - 0x0021e083, - 0x0027c844, - 0x002d34c4, - 0x0024e903, - 0x0027cf4a, - 0x35769282, - 0x35a11282, - 0x002b9ec3, - 0x0036b983, - 0x01652602, - 0x002534c3, - 0x35e60542, - 0x003a6904, - 0x36204042, - 0x3660f5c4, - 0x00346b46, - 0x0027aa44, - 0x0025b4c3, - 0x002e88c3, - 0x0021a403, - 0x0023ec06, - 0x002bfc85, - 0x002ba747, - 0x0022f109, - 0x002beac5, - 0x002bfbc6, - 0x002c0148, - 0x002c0346, - 0x00277804, - 0x00293b0b, - 0x002c2143, - 0x002c2145, - 0x002c2288, - 0x0021da42, - 0x0033dd82, - 0x36a430c2, - 0x36e00542, - 0x00263b43, - 0x37207342, - 0x0026b603, - 0x002c2584, - 0x002c3043, - 0x37a015c2, - 0x002c4d8b, - 0x37ec7386, - 0x0024ac86, - 0x002c79c8, - 0x38221802, - 0x3860fb02, - 0x38a26d02, - 0x38e0b302, - 0x39203bc2, - 0x00203bcb, - 0x39600882, - 0x00228b83, - 0x00314fc5, - 0x0031e4c6, - 0x39a12284, - 0x0038d747, - 0x0020cbca, - 0x002e5946, - 0x002cbc04, - 0x00263743, - 0x3a604782, - 0x002032c2, - 0x002097c3, - 0x3aa4a143, - 0x00374547, - 0x00315b07, - 0x3be4fe07, - 0x0022b307, - 0x00215143, - 0x002e6f0a, - 0x0023ff04, - 0x00325104, - 0x0032510a, - 0x00246885, - 0x3c204682, - 0x0024cd43, - 0x3c600602, - 0x00205bc3, - 0x0026c743, - 0x3ce05f82, - 0x0033ffc4, - 0x002214c4, - 0x003aae45, - 0x002d0105, - 0x003802c6, - 0x00380646, - 0x3d20bd82, - 0x3d601542, - 0x00338445, - 0x0024a992, - 0x0029e586, - 0x0020af83, - 0x002fcec6, - 0x00226f05, - 0x01609042, - 0x45a0d2c2, - 0x002f4f83, - 0x0030ee43, - 0x002d6c03, - 0x45e01842, - 0x00370dc3, - 0x46213c42, - 0x00205c43, - 0x00376bc8, - 0x0021d583, - 0x0021d586, - 0x003a1287, - 0x0020a546, - 0x0020a54b, - 0x002cbb47, - 0x003918c4, - 0x46a01582, - 0x002e4885, - 0x00204083, - 0x002a1943, - 0x00316c83, - 0x00316c86, - 0x00396e0a, - 0x0026fcc3, - 0x00239144, - 0x003143c6, - 0x00204bc6, - 0x46e02d43, - 0x002530c7, - 0x0037af8d, - 0x0038ad47, - 0x00293845, - 0x002c06c6, - 0x00213283, - 0x48610983, - 0x48a04402, - 0x00328504, - 0x003009cc, - 0x0037f989, - 0x0023b1c7, - 0x00248285, - 0x00265c84, - 0x0026ce88, - 0x00271f05, - 0x00276c85, - 0x00281a49, - 0x00326043, - 0x00326044, - 0x0029eb44, - 0x48e05702, - 0x00260f83, - 0x492a1542, - 0x002a1546, - 0x016a9702, - 0x496a1102, - 0x002b1008, - 0x002c8c07, - 0x002a1105, - 0x002f730b, - 0x002cc486, - 0x002f7506, - 0x002ce446, - 0x00224b84, - 0x002ced06, - 0x002cf248, - 0x00235103, - 0x002500c3, - 0x002500c4, - 0x002cffc4, - 0x002d0387, - 0x002d1785, - 0x49ad18c2, - 0x49e09382, - 0x00209385, - 0x002a4744, - 0x002d380b, - 0x002d5f08, - 0x002d6604, - 0x00269982, - 0x4a66f082, - 0x002aa703, - 0x002d6a44, - 0x002d6e45, - 0x00225187, - 0x002d9804, - 0x002cba04, - 0x4aa05042, - 0x00355b49, - 0x002da605, - 0x00215a05, - 0x002db185, - 0x4ae1e703, - 0x002dc584, - 0x002dc58b, - 0x002dc944, - 0x002dcdcb, - 0x002df8c5, - 0x0021e70a, - 0x002e0508, - 0x002e070a, - 0x002e0983, - 0x002e098a, - 0x4b22d242, - 0x4b653ec2, - 0x00297fc3, - 0x4bae2782, - 0x002e2783, - 0x4bee9e82, - 0x4c310fc2, - 0x002e3584, - 0x0021ec46, - 0x0021c785, - 0x002e3f03, - 0x00399486, - 0x00262944, - 0x4c604942, - 0x002b2584, - 0x002bb40a, - 0x00270e47, - 0x003856c6, - 0x0022d347, - 0x002153c3, - 0x00372d48, - 0x002153cb, - 0x002d1d05, - 0x002ff185, - 0x002ff186, - 0x002b2984, - 0x0031a088, - 0x00206603, - 0x00211b84, - 0x00211b87, - 0x0021c446, - 0x0030ce86, - 0x002a5b0a, - 0x002443c4, - 0x002443ca, - 0x002e5006, - 0x002e5007, - 0x00250d47, - 0x00273d84, - 0x00273d89, - 0x0035c005, - 0x002d480b, - 0x00270383, - 0x002102c3, - 0x0024bac3, - 0x002a9304, - 0x4ca02282, - 0x0025a146, - 0x002a6985, - 0x002b31c5, - 0x00208b06, - 0x00257b84, - 0x4ce02802, - 0x00208c04, - 0x4d20b082, - 0x00233a44, - 0x00227fc3, - 0x4d6c9942, - 0x002c9943, - 0x00267486, - 0x4da004c2, - 0x002d7b48, - 0x00219e04, - 0x00219e06, - 0x0030c386, - 0x002561c4, - 0x0032a485, - 0x003a4dc8, - 0x002004c7, - 0x00203347, - 0x0020334f, - 0x0028e786, - 0x0021dd83, - 0x0021dd84, - 0x0022a884, - 0x00200743, - 0x00226604, - 0x003a9ec4, - 0x4de2f5c2, - 0x00286243, - 0x00232303, - 0x4e204842, - 0x00255003, - 0x00322643, - 0x002169ca, - 0x002a7707, - 0x00232c8c, - 0x00232f46, - 0x0023bac6, - 0x0023c607, - 0x00231b07, - 0x00240509, - 0x00220104, - 0x002408c4, - 0x4e64d302, - 0x4ea02542, - 0x00252ec4, - 0x0031c8c6, - 0x00231f88, - 0x003b01c4, - 0x00258006, - 0x002c4685, - 0x00264ec8, - 0x00206e03, - 0x002669c5, - 0x0026b243, - 0x00215b03, - 0x00215b04, - 0x0026d043, - 0x4eeda282, - 0x4f2016c2, - 0x00270249, - 0x0027d405, - 0x00281c44, - 0x00282645, - 0x00212604, - 0x00249f07, - 0x003578c5, - 0x0024ffc4, - 0x0024ffc8, - 0x002d2cc6, - 0x002dc804, - 0x002dff88, - 0x002e1a47, - 0x4f600802, - 0x002e3c04, - 0x00200804, - 0x00367107, - 0x4fa414c4, - 0x00254442, - 0x4fe066c2, - 0x0023bf43, - 0x002d5ac4, - 0x0024b883, - 0x00273105, - 0x50230242, - 0x002f1e85, - 0x0021e042, - 0x00387285, - 0x0035a645, - 0x506198c2, - 0x002198c4, - 0x50a05442, - 0x0035e446, - 0x0032d5c6, - 0x00269cc8, - 0x002b37c8, - 0x002dfdc4, - 0x002fab45, - 0x00330dc9, - 0x00374a84, - 0x00396dc4, - 0x00253b83, - 0x00211945, - 0x002b8247, - 0x0029be44, - 0x002e9b0d, - 0x002ea082, - 0x002ea083, - 0x002ea143, - 0x50e02842, - 0x00388005, - 0x003733c7, - 0x0022b3c4, - 0x0022b3c7, - 0x0028bcc9, - 0x002bb549, - 0x002039c7, - 0x00276ac3, - 0x00276ac8, - 0x00218409, - 0x002eb207, - 0x002eb585, - 0x002ebd46, - 0x002ec386, - 0x002ec505, - 0x00247905, - 0x51200582, - 0x00228ec5, - 0x002b5aca, - 0x00297648, - 0x0021a8c6, - 0x002dfb07, - 0x00265184, - 0x003acf87, - 0x002eee46, - 0x51608c42, - 0x0038bd46, - 0x002f258a, - 0x002f3d05, - 0x51accf82, - 0x51e39b02, - 0x00239b06, - 0x002eae48, - 0x003a0147, - 0x52209a42, - 0x0020f883, - 0x00205646, - 0x00307d44, - 0x003a1146, - 0x0020b506, - 0x00329c0a, - 0x0032ad85, - 0x00209886, - 0x00209e83, - 0x00209e84, - 0x00206b82, - 0x00309f43, - 0x52651982, - 0x002c0503, - 0x00369644, - 0x002eaf84, - 0x002eaf8a, - 0x00223d03, - 0x00283a88, - 0x00318f8a, - 0x0023ac47, - 0x002f5286, - 0x0035e304, - 0x0028a2c2, - 0x00207382, - 0x52a09302, - 0x00243d83, - 0x00250b07, - 0x00399747, - 0x0038f1cb, - 0x00271dc4, - 0x00308b07, - 0x00225286, - 0x00219bc7, - 0x002a7644, - 0x00279585, - 0x0029c1c5, - 0x52e140c2, - 0x0021f986, - 0x0037ff43, - 0x002cbd42, - 0x002d5046, - 0x53209c42, - 0x53600142, - 0x00200145, - 0x53a1a602, - 0x53e036c2, - 0x00327dc5, - 0x002bdcc5, - 0x00209945, - 0x00265e83, - 0x00241ec5, - 0x002cc547, - 0x00346105, - 0x00342745, - 0x00261004, - 0x00241b06, - 0x00248944, - 0x54202882, - 0x0027a345, - 0x0029cb47, - 0x00226b08, - 0x00261946, - 0x0026194d, - 0x0026c809, - 0x0026c812, - 0x002ed845, - 0x002f1883, - 0x54e09902, - 0x002e0f84, - 0x003a4203, - 0x00317305, - 0x00355e45, - 0x55213ac2, - 0x00363543, - 0x556424c2, - 0x55ac82c2, - 0x55e09fc2, - 0x0033ee05, - 0x0022c9c3, - 0x002096c8, - 0x56201d42, - 0x56601142, - 0x0033ff86, - 0x0032498a, - 0x00201503, - 0x00256943, - 0x002fa303, - 0x57202402, - 0x65601882, - 0x65e0d482, - 0x002000c2, - 0x0038bb49, - 0x002b75c4, - 0x00267dc8, - 0x662e3f42, - 0x66602602, - 0x002dd005, - 0x00236c88, - 0x002455c8, - 0x0039f74c, - 0x0023ab83, - 0x002348c2, - 0x66a03442, - 0x002bef46, - 0x002f6105, - 0x00329443, - 0x002e2e46, - 0x002f6246, - 0x0024b9c3, - 0x002f70c3, - 0x002f7686, - 0x002f7c04, - 0x00238f86, - 0x002c2305, - 0x002f7f8a, - 0x00234384, - 0x002f8dc4, - 0x00348e4a, - 0x66e09182, - 0x0026e745, - 0x002fa88a, - 0x002fb545, - 0x002fc0c4, - 0x002fc1c6, - 0x002fc344, - 0x0022b0c6, - 0x6721a542, - 0x002acdc6, - 0x003860c5, - 0x00201287, - 0x0022de46, - 0x0023c804, - 0x002cb187, - 0x00330346, - 0x0026bbc5, - 0x002cadc7, - 0x0039c807, - 0x0039c80e, - 0x0021d906, - 0x0022fa45, - 0x0027fe47, - 0x002e5303, - 0x002e5307, - 0x0020fc85, - 0x00214644, - 0x00230682, - 0x0030eec7, - 0x002eed44, - 0x00230a04, - 0x00260b0b, - 0x00220c03, - 0x002824c7, - 0x00220c04, - 0x0029ec07, - 0x00372f43, - 0x0032f68d, - 0x00388848, - 0x0024fec4, - 0x0024fec5, - 0x002fe445, - 0x002fcb83, - 0x6760f082, - 0x002fdbc3, - 0x002fde83, - 0x0020f184, - 0x0027ad05, - 0x0021fb07, - 0x00209f06, - 0x00369383, - 0x002d518b, - 0x0037360b, - 0x002501cb, - 0x0027384a, - 0x0029d90b, - 0x002a034b, - 0x002c1e4c, - 0x002ccfd1, - 0x002ce80a, - 0x0033cf8b, - 0x0034b58b, - 0x0037244a, - 0x003adb4a, - 0x003af10d, - 0x002ff6ce, - 0x003010cb, - 0x0030138a, - 0x00302ad1, - 0x00302f0a, - 0x0030340b, - 0x0030394e, - 0x0030450c, - 0x00304c4b, - 0x00304f0e, - 0x0030528c, - 0x00305a0a, - 0x00306c0c, - 0x67b06f0a, - 0x00308109, - 0x0030a24a, - 0x0030a4ca, - 0x0030a74b, - 0x0030e40e, - 0x0030e791, - 0x00317c89, - 0x00317eca, - 0x00318a0b, - 0x0031b70a, - 0x0031c256, - 0x0031da4b, - 0x0032338a, - 0x00323d8a, - 0x00326c4b, - 0x0032c249, - 0x00330009, - 0x0033084d, - 0x0033160b, - 0x0033264b, - 0x0033300b, - 0x003335c9, - 0x00333c0e, - 0x0033404a, - 0x0033624a, - 0x0033678a, - 0x00336dcb, - 0x0033760b, - 0x003378cd, - 0x0033910d, - 0x00339690, - 0x00339b4b, - 0x0033a44c, - 0x0033b24b, - 0x0033d58b, - 0x0034048b, - 0x0034484b, - 0x003452cf, - 0x0034568b, - 0x0034624a, - 0x00346889, - 0x00346cc9, - 0x0034798b, - 0x00347c4e, - 0x003494cb, - 0x0034a14f, - 0x0034c90b, - 0x0034cbcb, - 0x0034ce8b, - 0x0034d2ca, - 0x00350f09, - 0x00353e8f, - 0x003588cc, - 0x00358d4c, - 0x0035938e, - 0x00359bcf, - 0x00359f8e, - 0x0035aa90, - 0x0035ae8f, - 0x0035ce8e, - 0x0035d34c, - 0x0035d652, - 0x0035fc11, - 0x003601ce, - 0x0036060e, - 0x00360b4e, - 0x00360ecf, - 0x0036128e, - 0x00361613, - 0x00361ad1, - 0x00361f0e, - 0x0036238c, - 0x003627d3, - 0x00362f10, - 0x0036430c, - 0x0036460c, - 0x00364acb, - 0x00367b0e, - 0x00367f8b, - 0x003683cb, - 0x0036990c, - 0x0037174a, - 0x00371c4c, - 0x00371f4c, - 0x00372249, - 0x00377c0b, - 0x00377ec8, - 0x00378389, - 0x0037838f, - 0x00379b8b, - 0x0037a60a, - 0x0037cd8c, - 0x0037f149, - 0x003812c8, - 0x0038178b, - 0x0038304b, - 0x00383b4a, - 0x00383dcb, - 0x003844cc, - 0x003850c8, - 0x00388a4b, - 0x0038b84b, - 0x0038f48b, - 0x00390ccb, - 0x0039c38b, - 0x0039c649, - 0x0039cb8d, - 0x003a274a, - 0x003a3697, - 0x003a44d8, - 0x003a6f49, - 0x003a814b, - 0x003a8d14, - 0x003a920b, - 0x003a978a, - 0x003a9fca, - 0x003aa24b, - 0x003ab210, - 0x003ab611, - 0x003abeca, - 0x003ad14d, - 0x003ad84d, - 0x003af80b, - 0x003b0686, - 0x0021fa83, - 0x00215b83, - 0x0037f686, - 0x00289545, - 0x00220787, - 0x0033ce46, - 0x01629c02, - 0x002aa849, - 0x00399284, - 0x002cb548, - 0x00243cc3, - 0x002e0ec7, - 0x00232142, - 0x002a7003, - 0x67e03c02, - 0x002bd3c6, - 0x002be9c4, - 0x00328b84, - 0x00238383, - 0x00238385, - 0x686c8302, - 0x002d6944, - 0x00273cc7, - 0x01660ac2, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00201543, - 0x002050c2, - 0x001795c8, - 0x00202682, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x002169c3, - 0x00313696, - 0x00316853, - 0x00308989, - 0x0020c748, - 0x002e4709, - 0x002faa06, - 0x00309790, - 0x0033bb53, - 0x00207048, - 0x0025b5c7, - 0x00278587, - 0x0036ff8a, - 0x003696c9, - 0x00342409, - 0x003a090b, - 0x0031e606, - 0x0022400a, - 0x00225906, - 0x00398e83, - 0x002f1045, - 0x00229408, - 0x0035e50d, - 0x00354a4c, - 0x00385d87, - 0x00303f8d, - 0x0020c844, - 0x0023320a, - 0x00233b4a, - 0x0023400a, - 0x0033be47, - 0x0023cd47, - 0x0023efc4, - 0x0025fe06, - 0x0031e9c4, - 0x002f2d48, - 0x002a3e89, - 0x0038df46, - 0x0038df48, - 0x0024180d, - 0x002bb789, - 0x0035cc88, - 0x00215987, - 0x0031920a, - 0x0024a346, - 0x0025abc7, - 0x00227384, - 0x00245e87, - 0x0037fd0a, - 0x002e2f8e, - 0x0020a6c5, - 0x002fc8cb, - 0x002f1689, - 0x0026ca49, - 0x0029a747, - 0x0039750a, - 0x00367047, - 0x002f1c89, - 0x00354f08, - 0x00270acb, - 0x002ca385, - 0x0030064a, - 0x0029ff49, - 0x003293ca, - 0x002beb4b, - 0x00245d8b, - 0x003a0695, - 0x002cfa85, - 0x00215a05, - 0x002dc58a, - 0x0031c9ca, - 0x002e5f87, - 0x00215a43, - 0x002a5e48, - 0x002c5e8a, - 0x00219e06, - 0x0023e189, - 0x00264ec8, - 0x002dc804, - 0x0024b889, - 0x002b37c8, - 0x003313c7, - 0x0027a346, - 0x0029cb47, - 0x0029b787, - 0x0023ea05, - 0x0025538c, - 0x0024fec5, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00202682, - 0x0022f303, - 0x0024a143, - 0x00201543, - 0x00202d43, - 0x0022f303, - 0x0024a143, - 0x0021d583, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x00202682, - 0x00202a82, - 0x00234242, - 0x00200b42, - 0x00202342, - 0x002e6002, - 0x0462f303, - 0x00215403, - 0x00205c03, - 0x002d60c3, - 0x0024af03, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00236d43, - 0x001795c8, - 0x002e9a04, - 0x00252407, - 0x00254783, - 0x002df504, - 0x00232043, - 0x00282983, - 0x002d60c3, - 0x002050c2, - 0x00141d03, - 0x05602682, - 0x00234242, - 0x0017c544, - 0x00200282, - 0x000dbd04, - 0x001795c8, - 0x002050c3, - 0x002c81c3, - 0x05e2f303, - 0x00233204, - 0x06215403, - 0x066d60c3, - 0x00208202, - 0x0037c544, - 0x0024a143, - 0x002f0e83, - 0x00202742, - 0x00202d43, - 0x00216ec2, - 0x002e34c3, - 0x002004c2, - 0x00201643, - 0x00264f83, - 0x00200f42, - 0x001795c8, - 0x002050c3, - 0x002f0e83, - 0x00202742, - 0x002e34c3, - 0x002004c2, - 0x00201643, - 0x00264f83, - 0x00200f42, - 0x002e34c3, - 0x002004c2, - 0x00201643, - 0x00264f83, - 0x00200f42, - 0x0022f303, - 0x00341d03, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0024af03, - 0x0021e083, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0020be42, - 0x0021e703, - 0x001795c8, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00202802, - 0x00355284, - 0x0020c604, - 0x00341d03, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0024a143, - 0x00202d43, - 0x002eb585, - 0x00213ac2, - 0x002050c2, - 0x001795c8, - 0x002d60c3, - 0x002533c1, - 0x00231681, - 0x0020b881, - 0x0020b8c1, - 0x0020b901, - 0x002593c1, - 0x00254801, - 0x0024c801, - 0x002cd1c1, - 0x002fed01, - 0x00200101, - 0x00200001, - 0x001795c8, - 0x00200301, - 0x00200381, - 0x00200081, - 0x00201101, - 0x00200641, - 0x00200a81, - 0x00200041, - 0x002042c1, - 0x00200ec1, - 0x00200201, - 0x00200181, - 0x00200601, - 0x00200281, - 0x00204401, - 0x00200401, - 0x002002c1, - 0x002004c1, - 0x00200141, - 0x00200441, - 0x002000c1, - 0x00200f41, - 0x00209f01, - 0x002018c1, - 0x00203c01, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x00200282, - 0x00202d43, - 0x00120ac7, - 0x0001a0c6, - 0x0001894a, - 0x00085148, - 0x00050648, - 0x00050a07, - 0x000534c6, - 0x000c8b05, - 0x000546c5, - 0x0006a4c6, - 0x00141846, - 0x0021db44, - 0x0031dcc7, - 0x001795c8, - 0x002cb284, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x002d60c3, - 0x0024af03, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00213ac2, - 0x002b2603, - 0x00214d43, - 0x00270583, - 0x00200502, - 0x00247b43, - 0x00201383, - 0x00203a43, - 0x00200001, - 0x00206943, - 0x00274444, - 0x00328203, - 0x00309f83, - 0x0021ed83, - 0x0037e303, - 0x0a22f303, - 0x00238c04, - 0x0021ed43, - 0x00202643, - 0x00215403, - 0x00235d83, - 0x0021bf03, - 0x0029be03, - 0x00309f03, - 0x00228943, - 0x00214b83, - 0x0024ae04, - 0x0023c9c2, - 0x0024fc43, - 0x00258703, - 0x00276a83, - 0x00253303, - 0x00322703, - 0x002d60c3, - 0x00331003, - 0x002212c3, - 0x0037c383, - 0x0021a003, - 0x00356143, - 0x002e6583, - 0x003ac3c3, - 0x00200c83, - 0x0020c943, - 0x0021e083, - 0x0021da42, - 0x0028cb83, - 0x0024a143, - 0x01601543, - 0x00224483, - 0x002368c3, - 0x00213903, - 0x00202d43, - 0x0038d1c3, - 0x0021e703, - 0x00232f03, - 0x002f7143, - 0x002e3683, - 0x0033b8c5, - 0x00226a03, - 0x002e36c3, - 0x002ea7c3, - 0x00209e84, - 0x00372ac3, - 0x00330643, - 0x002727c3, - 0x00236d43, - 0x00213ac2, - 0x0023ab83, - 0x002f9bc4, - 0x00230a04, - 0x00243fc3, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00202682, - 0x00202d43, - 0x0b62f303, - 0x002d60c3, - 0x0021e083, - 0x002048c2, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00003c02, - 0x00202142, - 0x0021d982, - 0x001795c8, - 0x00002682, - 0x00237842, - 0x0020d042, - 0x0022c342, - 0x00204682, - 0x0020bd82, - 0x000546c5, - 0x00203c82, - 0x00202742, - 0x00201842, - 0x00200982, - 0x00205702, - 0x003845c2, - 0x002066c2, - 0x0021d082, - 0x00115fcd, - 0x000ec889, - 0x000453cb, - 0x000cc408, - 0x000d12c9, - 0x002d60c3, - 0x001795c8, - 0x001795c8, - 0x00051906, - 0x002050c2, - 0x0021db44, - 0x00202682, - 0x0022f303, - 0x00202a82, - 0x00215403, - 0x00200fc2, - 0x002cb284, - 0x0024af03, - 0x0020ab02, - 0x0024a143, - 0x00200282, - 0x00202d43, - 0x00215a06, - 0x0030ad0f, - 0x006fe3c3, - 0x001795c8, - 0x00202682, - 0x00205c03, - 0x002d60c3, - 0x0021e083, - 0x00202682, - 0x0022f303, - 0x002d60c3, - 0x0024a143, - 0x002050c2, - 0x00207642, - 0x0e734b09, - 0x002094c2, - 0x0ee2f303, - 0x0023dbc2, - 0x00215403, - 0x00219fc2, - 0x002281c2, - 0x002d60c3, - 0x00231302, - 0x00250182, - 0x0025a042, - 0x00207682, - 0x00288e02, - 0x00200a82, - 0x00201702, - 0x0020a402, - 0x0026ec82, - 0x00216442, - 0x002a8382, - 0x0023bcc2, - 0x0030fd42, - 0x0022fcc2, - 0x0021e083, - 0x00204042, - 0x0024a143, - 0x00241a02, - 0x0024c5c2, - 0x00202d43, - 0x00247bc2, - 0x00204842, - 0x0024d302, - 0x002016c2, - 0x002198c2, - 0x002ccf82, - 0x002140c2, - 0x002424c2, - 0x00226d42, - 0x0030138a, - 0x0034624a, - 0x0037b8ca, - 0x003b0802, - 0x00209b02, - 0x0023d202, - 0x0e831487, - 0x00052a8a, - 0x0f334b09, - 0x0f652a8a, - 0x0002ca42, - 0x002451c4, - 0x0fe2f303, - 0x00215403, - 0x00246ec4, - 0x002d60c3, - 0x0037c544, - 0x0024af03, - 0x0021e083, - 0x0024a143, - 0x00201543, - 0x00202d43, - 0x00226a03, - 0x0021d903, - 0x001795c8, - 0x01453444, - 0x00052cc5, - 0x00051c0a, - 0x00106b82, - 0x0017ab06, - 0x10734b09, - 0x00120c87, - 0x00000e02, - 0x001a83ca, - 0x000d58c7, - 0x001795c8, - 0x000fd4c8, - 0x0000d5c7, - 0x1181e20b, - 0x00014f02, - 0x00070d07, - 0x000047ca, - 0x001a030f, - 0x0015f28f, - 0x0001ed82, - 0x00002682, - 0x0009bd48, - 0x000ebfca, - 0x000e7148, - 0x00003f42, - 0x0012828b, - 0x0016d488, - 0x0007c0c7, - 0x000d59ca, - 0x000678cb, - 0x0016c489, - 0x0016d387, - 0x000f4bcc, - 0x0018d647, - 0x000267ca, - 0x00125908, - 0x000f124e, - 0x0005510e, - 0x000d570b, - 0x000e60cb, - 0x000ec5cb, - 0x0001a0c9, - 0x0001c0cb, - 0x0001d3cd, - 0x000249cb, - 0x00025d0d, - 0x0002ea8d, - 0x0002f88a, - 0x0003084b, - 0x00062a0b, - 0x00067f85, - 0x00107a50, - 0x0001c80f, - 0x00121b0f, - 0x000275cd, - 0x00074250, - 0x000072c2, - 0x00120948, - 0x11edca05, - 0x00045b0b, - 0x0004e108, - 0x000e628a, - 0x00059449, - 0x00060287, - 0x000605c7, - 0x00060787, - 0x00060dc7, - 0x000617c7, - 0x00061c87, - 0x00063047, - 0x00064bc7, - 0x000653c7, - 0x000656c7, - 0x00066007, - 0x000661c7, - 0x00066387, - 0x00066547, - 0x00066847, - 0x00066d87, - 0x00068f47, - 0x00069287, - 0x00069a47, - 0x0006ab07, - 0x0006acc7, - 0x0006b0c7, - 0x0006b4c7, - 0x0006b6c7, - 0x0006c287, - 0x0006c447, - 0x0006c607, - 0x0006cc87, - 0x0006d547, - 0x0006db07, - 0x0006f647, - 0x0006f907, - 0x00071107, - 0x000712c7, - 0x00071647, - 0x000723c7, - 0x00072887, - 0x00072c87, - 0x00073507, - 0x000736c7, - 0x00073ac7, - 0x00074807, - 0x00074b07, - 0x00075087, - 0x00075247, - 0x000755c7, - 0x00075a87, - 0x0000d142, - 0x000436ca, - 0x000ce507, - 0x120c368b, - 0x014c3696, - 0x0001f591, - 0x000d8c8a, - 0x0009bbca, - 0x00051906, - 0x000bdecb, - 0x0000a6c2, - 0x000a8f51, - 0x000a1349, - 0x0008cf89, - 0x0000a402, - 0x000718ca, - 0x0009d709, - 0x0009de0f, - 0x0009e84e, - 0x000a0188, - 0x00009f82, - 0x00070909, - 0x0016f4ce, - 0x0012db0c, - 0x000cd98f, - 0x0019458e, - 0x0000da4c, - 0x00014989, - 0x00019451, - 0x0001b0c8, - 0x0002ff12, - 0x000d4d4d, - 0x0019224d, - 0x00041ccb, - 0x00042955, - 0x00043589, - 0x00058e8a, - 0x0005a849, - 0x0006a710, - 0x0007210b, - 0x0007b48f, - 0x0007cb8b, - 0x00080fcc, - 0x00085d10, - 0x00146fca, - 0x0008ca4d, - 0x0009184e, - 0x00096f0a, - 0x00098c8c, - 0x0009b454, - 0x000a0fd1, - 0x000a460b, - 0x000a59cf, - 0x000a684d, - 0x0012d48e, - 0x0013128c, - 0x000eaa8c, - 0x0012d18b, - 0x0016b44e, - 0x000aec90, - 0x000b3e8b, - 0x000b450d, - 0x000b534f, - 0x000b69cc, - 0x0018ddce, - 0x001185d1, - 0x000bc44c, - 0x000c69c7, - 0x000d2e0d, - 0x000dd90c, - 0x000df010, - 0x0011200d, - 0x00163d07, - 0x000eef90, - 0x000f3f08, - 0x0011b94b, - 0x0016d00f, - 0x00022fc8, - 0x000d8e8d, - 0x00187210, - 0x000aa6c3, - 0x0000aa02, - 0x0002ee89, - 0x00054f0a, - 0x00012303, - 0x00107251, - 0x00123ac7, - 0x000cd410, - 0x000ce145, - 0x00116d88, - 0x0019d84a, - 0x0012b0c7, - 0x00001542, - 0x00053dca, - 0x00121e49, - 0x00038c8a, - 0x001a008f, - 0x000401cb, - 0x0012850c, - 0x001287d2, - 0x000a9705, - 0x0011a74a, - 0x126db045, - 0x00110fc3, - 0x001845c2, - 0x000e39ca, - 0x0004f9c8, - 0x0015f207, - 0x00002282, - 0x0000b082, - 0x000004c2, - 0x00182050, - 0x00002542, - 0x00031f8f, - 0x0006a4c6, - 0x000d0f8e, - 0x0008858b, - 0x000c49c8, - 0x00075849, - 0x00002552, - 0x0015cb4d, - 0x0017f7c8, - 0x00045289, - 0x000475cd, - 0x00048089, - 0x0004a4cb, - 0x0004b208, - 0x00051a48, - 0x00058408, - 0x0005bf49, - 0x0005c14a, - 0x0005f90c, - 0x000eca8a, - 0x000f7187, - 0x0001194d, - 0x000ed00b, - 0x0019908c, - 0x00061010, - 0x00001142, - 0x0009838d, - 0x00002402, - 0x00001882, - 0x000f70ca, - 0x000d8b8a, - 0x000e0dcb, - 0x00062bcc, - 0x000fd24e, - 0x0000f24d, - 0x00117688, - 0x00003c02, - 0x10b4290e, - 0x10c31487, - 0x11031489, - 0x00010603, - 0x116648cc, - 0x0002ca42, - 0x00122f51, - 0x00142851, - 0x001536d1, - 0x0002ca51, - 0x0006480f, - 0x0010d98c, - 0x0011b3cd, - 0x0012690d, - 0x0012bd15, - 0x00135f4c, - 0x00148590, - 0x0017704c, - 0x0010570c, - 0x0014bb09, - 0x0002ca42, - 0x0012300e, - 0x0014290e, - 0x0015378e, - 0x0002cb0e, - 0x000648cc, - 0x0010da49, - 0x00136009, - 0x0012bf0d, - 0x00177109, - 0x001057c9, - 0x001a6a03, - 0x000ca243, - 0x0002ca42, - 0x000d7785, - 0x001a83c4, - 0x00120c84, - 0x0142aa43, - 0x01411803, - 0x000f1d04, - 0x0000f243, - 0x002050c2, - 0x00202682, - 0x00202a82, - 0x0020bf82, - 0x00200fc2, - 0x00200282, - 0x002004c2, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c383, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x0024a143, - 0x00202d43, - 0x0006ec03, - 0x002d60c3, - 0x002050c2, - 0x00341d03, - 0x1422f303, - 0x003b0247, - 0x002d60c3, - 0x0035ea43, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0025564a, - 0x00215a05, - 0x0021e703, - 0x00200142, - 0x001795c8, - 0x001795c8, - 0x00002682, - 0x0010eb02, - 0x001795c8, - 0x0002f303, - 0x000f15c7, - 0x000c7f8f, - 0x00065bc4, - 0x0016c60a, - 0x0012d747, - 0x001a67ca, - 0x000be34a, - 0x0000720d, - 0x00141d03, - 0x001795c8, - 0x00002682, - 0x00046ec4, - 0x00046b03, - 0x000eb585, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00201383, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x0028d143, - 0x0021d903, - 0x00201383, - 0x0021db44, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00225183, - 0x0022f303, - 0x00215403, - 0x0020e383, - 0x00205c03, - 0x002d60c3, - 0x0037c544, - 0x00376343, - 0x0020c943, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x0021e703, - 0x00205683, - 0x1662f303, - 0x00215403, - 0x002bc643, - 0x002d60c3, - 0x00281103, - 0x0020c943, - 0x00202d43, - 0x00206d43, - 0x00324c44, - 0x001795c8, - 0x16e2f303, - 0x00215403, - 0x002a0243, - 0x002d60c3, - 0x0021e083, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x00221143, - 0x001795c8, - 0x1762f303, - 0x00215403, - 0x00205c03, - 0x00201543, - 0x00202d43, - 0x001795c8, - 0x01431487, - 0x00341d03, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0031e7c5, - 0x001795c8, - 0x0001a0c2, - 0x00030a43, - 0x0024f2c8, - 0x00279087, - 0x0021db44, - 0x00341546, - 0x00348446, - 0x001795c8, - 0x00234983, - 0x00321509, - 0x002ae315, - 0x000ae31f, - 0x0022f303, - 0x00327592, - 0x000fdf06, - 0x0013a705, - 0x000e628a, - 0x00059449, - 0x0032734f, - 0x002cb284, - 0x00229ec5, - 0x00355f10, - 0x0020c947, - 0x00201543, - 0x00331a08, - 0x002d780a, - 0x00216044, - 0x002daa83, - 0x00215a06, - 0x00200142, - 0x0038548b, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x002e1543, - 0x00202682, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0035ea43, - 0x00224283, - 0x00202d43, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x0024a143, - 0x00202d43, - 0x002050c2, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0021db44, - 0x0022f303, - 0x00215403, - 0x0020f5c4, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x002212c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x00253a43, - 0x0000ca83, - 0x0015ea43, - 0x0024a143, - 0x00202d43, - 0x0030138a, - 0x0031c009, - 0x0033dc4b, - 0x0033e5ca, - 0x0034624a, - 0x0035208b, - 0x0036918a, - 0x0037174a, - 0x0037b8ca, - 0x0037bb4b, - 0x0039d589, - 0x0039f50a, - 0x0039fa4b, - 0x003a94cb, - 0x003aeeca, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00260284, - 0x00219242, - 0x00212284, - 0x002765c5, - 0x00201383, - 0x0021db44, - 0x0022f303, - 0x00238c04, - 0x00215403, - 0x00246ec4, - 0x002cb284, - 0x0037c544, - 0x0020c943, - 0x0024a143, - 0x00202d43, - 0x00298545, - 0x00225183, - 0x0021e703, - 0x00215543, - 0x0024ffc4, - 0x00253384, - 0x00270585, - 0x001795c8, - 0x002f8944, - 0x00222d46, - 0x00283b84, - 0x00202682, - 0x0035b307, - 0x00249907, - 0x00244a04, - 0x00257d45, - 0x00312205, - 0x002a3645, - 0x0037c544, - 0x003145c8, - 0x0035c746, - 0x002e3cc8, - 0x00238685, - 0x002ca385, - 0x0023ff04, - 0x00202d43, - 0x002dbd04, - 0x00351246, - 0x00215b03, - 0x0024ffc4, - 0x00258885, - 0x00237484, - 0x0020f0c4, - 0x00200142, - 0x0024d246, - 0x003916c6, - 0x002f6105, - 0x002050c2, - 0x00341d03, - 0x1ca02682, - 0x00236f84, - 0x00200fc2, - 0x0021e083, - 0x0020b302, - 0x0024a143, - 0x00200282, - 0x002169c3, - 0x0021d903, - 0x001795c8, - 0x001795c8, - 0x002d60c3, - 0x002050c2, - 0x1d602682, - 0x002d60c3, - 0x00266303, - 0x00376343, - 0x0031cdc4, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x002050c2, - 0x1de02682, - 0x0022f303, - 0x0024a143, - 0x00202d43, - 0x00209902, - 0x00213ac2, - 0x0035ea43, - 0x002d3c03, - 0x002050c2, - 0x001795c8, - 0x00202682, - 0x00215403, - 0x00246ec4, - 0x002086c3, - 0x002d60c3, - 0x002212c3, - 0x0021e083, - 0x0024a143, - 0x00218e83, - 0x00202d43, - 0x00215a43, - 0x00124293, - 0x00126ed4, - 0x00014d86, - 0x0001a0c6, - 0x00050487, - 0x001995c9, - 0x0011fb4a, - 0x0008500d, - 0x00115ccc, - 0x0017b40a, - 0x000546c5, - 0x00165588, - 0x0006a4c6, - 0x00141846, - 0x002072c2, - 0x0022f303, - 0x00026745, - 0x0001f586, - 0x000a7303, - 0x00199585, - 0x0000c543, - 0x000bdf8c, - 0x001aca08, - 0x0013efc8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x002050c2, - 0x00202682, - 0x002d60c3, - 0x00208202, - 0x0024a143, - 0x00202d43, - 0x002169c3, - 0x00359bcf, - 0x00359f8e, - 0x001795c8, - 0x0022f303, - 0x00042147, - 0x00215403, - 0x002d60c3, - 0x0024af03, - 0x0024a143, - 0x00202d43, - 0x00220a43, - 0x00375d07, - 0x00200bc2, - 0x0029c349, - 0x002001c2, - 0x0038234b, - 0x00286cca, - 0x0028b0c9, - 0x00201982, - 0x002535c6, - 0x00255a15, - 0x00382495, - 0x00256bd3, - 0x00382a13, - 0x00203082, - 0x00203945, - 0x0031e18c, - 0x0021b48b, - 0x0023a8c5, - 0x002043c2, - 0x002003c2, - 0x0036de46, - 0x00200e02, - 0x00251f06, - 0x00325a8d, - 0x0036d60c, - 0x00307ac4, - 0x00200102, - 0x00204182, - 0x002302c8, - 0x00200dc2, - 0x00373886, - 0x0026eec4, - 0x00255bd5, - 0x00256d53, - 0x00210543, - 0x0034124a, - 0x0038cf07, - 0x00327c09, - 0x0022b807, - 0x00302e02, - 0x00200002, - 0x003ae3c6, - 0x0020c282, - 0x001795c8, - 0x00210382, - 0x00207f02, - 0x00396a47, - 0x0020fd47, - 0x0021fcc5, - 0x00214f02, - 0x00221087, - 0x00221248, - 0x0022ca02, - 0x002e3782, - 0x00230c82, - 0x00200302, - 0x00239dc8, - 0x00218f03, - 0x00246cc8, - 0x002ca70d, - 0x00214e43, - 0x00322288, - 0x0023504f, - 0x0023540e, - 0x0021d9ca, - 0x00292391, - 0x00292810, - 0x002aff0d, - 0x002b024c, - 0x0020c007, - 0x003413c7, - 0x00341609, - 0x0023d282, - 0x002068c2, - 0x002549cc, - 0x00254ccb, - 0x00201a82, - 0x0032d346, - 0x002047c2, - 0x0020c842, - 0x0021ed82, - 0x00202682, - 0x003a6d44, - 0x0023af87, - 0x00207102, - 0x0023eb47, - 0x0023fdc7, - 0x00212a02, - 0x00205102, - 0x00242005, - 0x00227542, - 0x0026318e, - 0x0027a0cd, - 0x00215403, - 0x0024d88e, - 0x0036fa4d, - 0x0035f183, - 0x00203282, - 0x00208904, - 0x00243e42, - 0x00211742, - 0x00346a85, - 0x0034d107, - 0x00368642, - 0x0020bf82, - 0x00246507, - 0x0024bd08, - 0x0023c9c2, - 0x002a9786, - 0x0025484c, - 0x00254b8b, - 0x002046c2, - 0x0025c5cf, - 0x0025c990, - 0x0025cd8f, - 0x0025d155, - 0x0025d694, - 0x0025db8e, - 0x0025df0e, - 0x0025e28f, - 0x0025e64e, - 0x0025e9d4, - 0x0025eed3, - 0x0025f38d, - 0x00275c49, - 0x00285bc3, - 0x00200c02, - 0x0030bdc5, - 0x002086c6, - 0x00200fc2, - 0x002db947, - 0x002d60c3, - 0x0020a6c2, - 0x002d41c8, - 0x002925d1, - 0x00292a10, - 0x00203d02, - 0x002279c7, - 0x002024c2, - 0x00263d87, - 0x0020aa02, - 0x0024f0c9, - 0x0036de07, - 0x00282748, - 0x00228a86, - 0x002d3b03, - 0x0031f585, - 0x002362c2, - 0x00203802, - 0x003ae7c5, - 0x00215d85, - 0x002067c2, - 0x00216183, - 0x00237507, - 0x003a50c7, - 0x00200242, - 0x002fe084, - 0x00203b43, - 0x002bab09, - 0x002d5588, - 0x00212942, - 0x00205d42, - 0x00227dc7, - 0x0022a945, - 0x0029e108, - 0x00203607, - 0x00201343, - 0x00281886, - 0x002afd8d, - 0x002b010c, - 0x0027a8c6, - 0x0020d042, - 0x002e5e02, - 0x00204502, - 0x00234ecf, - 0x002352ce, - 0x00312287, - 0x0020a142, - 0x00306805, - 0x00306806, - 0x00260542, - 0x00204042, - 0x00224286, - 0x00263cc3, - 0x00263cc6, - 0x002bbe05, - 0x002bbe0d, - 0x002bc995, - 0x002bd14c, - 0x002bd94d, - 0x002be5d2, - 0x00200542, - 0x00207342, - 0x00200882, - 0x002e24c6, - 0x0032d9c6, - 0x00201542, - 0x00208746, - 0x00201842, - 0x003a8805, - 0x00202342, - 0x002632c9, - 0x0026dd0c, - 0x0026e04b, - 0x00200282, - 0x0024c148, - 0x00209e42, - 0x00204402, - 0x0021b246, - 0x003604c5, - 0x0021a2c7, - 0x002585c5, - 0x00292205, - 0x002421c2, - 0x003419c2, - 0x00205702, - 0x0027b787, - 0x0022d44d, - 0x0022d7cc, - 0x002731c7, - 0x002a9702, - 0x00224b82, - 0x00240dc8, - 0x0022f008, - 0x002cf888, - 0x002d8e44, - 0x0036b6c7, - 0x002d67c3, - 0x0026f082, - 0x00209082, - 0x002d95c9, - 0x00320d87, - 0x00205042, - 0x00271785, - 0x00253ec2, - 0x00231542, - 0x00277a03, - 0x00277a06, - 0x002e1542, - 0x002e3442, - 0x00200e42, - 0x003087c6, - 0x00208847, - 0x002002c2, - 0x00204942, - 0x00246b0f, - 0x0024d6cd, - 0x00282b0e, - 0x0036f8cc, - 0x00202d82, - 0x00200b02, - 0x002288c5, - 0x003add06, - 0x00214c02, - 0x0020c502, - 0x00202282, - 0x00203584, - 0x002ca584, - 0x00338b46, - 0x002004c2, - 0x00278907, - 0x00224c43, - 0x00228fc8, - 0x0022a488, - 0x002d4bc7, - 0x00391e86, - 0x00200802, - 0x00239d43, - 0x00259a07, - 0x00266c06, - 0x002e2405, - 0x00345ec8, - 0x00205442, - 0x0030c907, - 0x00211942, - 0x002ea082, - 0x00200702, - 0x002d9389, - 0x00208c42, - 0x00200b82, - 0x00273443, - 0x00342607, - 0x00202782, - 0x0026de8c, - 0x0026e18b, - 0x0027a946, - 0x0020c485, - 0x0021a602, - 0x002036c2, - 0x002adb46, - 0x0022e203, - 0x0032b4c7, - 0x00248242, - 0x00202882, - 0x00255895, - 0x00382655, - 0x00256a93, - 0x00382b93, - 0x00258987, - 0x00274c88, - 0x00274c90, - 0x002766cf, - 0x00286a93, - 0x0028ae92, - 0x0029bf10, - 0x002a328f, - 0x00363e92, - 0x0031bbd1, - 0x0036a4d3, - 0x0034f292, - 0x002b2a4f, - 0x002b5d0e, - 0x002bb992, - 0x002c3bd1, - 0x002c60cf, - 0x002c700e, - 0x002c8511, - 0x002cee50, - 0x002d6192, - 0x002d9191, - 0x002de2c6, - 0x002dfc87, - 0x00369507, - 0x00200d02, - 0x0027e345, - 0x003438c7, - 0x00213ac2, - 0x0020b0c2, - 0x0022d005, - 0x00215483, - 0x00270806, - 0x0022d60d, - 0x0022d94c, - 0x002000c2, - 0x0031e00b, - 0x0021b34a, - 0x002ea3ca, - 0x002abdc9, - 0x002d80cb, - 0x0020374d, - 0x0035974c, - 0x0022368a, - 0x00224dcc, - 0x0022700b, - 0x0023a70c, - 0x0033ae8b, - 0x0026dc83, - 0x00275746, - 0x002c8fc2, - 0x002e3f42, - 0x0023e503, - 0x00202602, - 0x00203243, - 0x00262186, - 0x0025d307, - 0x00256586, - 0x002ec188, - 0x0022ed08, - 0x002f2746, - 0x00203442, - 0x002f5acd, - 0x002f5e0c, - 0x002cb347, - 0x002f8807, - 0x00214dc2, - 0x002346c2, - 0x00259982, - 0x002041c2, - 0x00202682, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x002169c3, - 0x002050c2, - 0x00200342, - 0x20e89fc5, - 0x21201e45, - 0x21708486, - 0x001795c8, - 0x21aa9e45, - 0x00202682, - 0x00202a82, - 0x21e2bac5, - 0x2227ca85, - 0x2267da07, - 0x22a12e89, - 0x22e67684, - 0x00200fc2, - 0x0020a6c2, - 0x23368685, - 0x2368b909, - 0x23b6c308, - 0x23ea66c5, - 0x242ba287, - 0x24620408, - 0x24ad1645, - 0x24e01186, - 0x2526e809, - 0x256c40c8, - 0x25ab4348, - 0x25e9518a, - 0x26247f04, - 0x266c4345, - 0x26aafb08, - 0x26e66ec5, - 0x00218f82, - 0x2723cb03, - 0x2769b006, - 0x27a433c8, - 0x27f98846, - 0x28376988, - 0x2871e4c6, - 0x28b36544, - 0x002032c2, - 0x28e34b47, - 0x292a1c44, - 0x29677f87, - 0x29ba1287, - 0x00200282, - 0x29e93845, - 0x2a20c684, - 0x2a711cc7, - 0x2aa1e947, - 0x2ae80b06, - 0x2b22e705, - 0x2b68df07, - 0x2bacfbc8, - 0x2bf0c147, - 0x2c2af189, - 0x2c6bdcc5, - 0x2caa0e47, - 0x2ce89706, - 0x2d2537c8, - 0x0037ffcd, - 0x00242349, - 0x002dcb0b, - 0x0024c60b, - 0x0025918b, - 0x0027ae0b, - 0x002fe84b, - 0x002feb0b, - 0x002ff309, - 0x0030160b, - 0x003018cb, - 0x0030268b, - 0x0030318a, - 0x003036ca, - 0x00303ccc, - 0x0030604b, - 0x0030698a, - 0x0031814a, - 0x0032de0e, - 0x0032e8ce, - 0x0032ec4a, - 0x00330b8a, - 0x00331f0b, - 0x003321cb, - 0x00332d4b, - 0x003498cb, - 0x00349eca, - 0x0034ab8b, - 0x0034ae4a, - 0x0034b0ca, - 0x0034b34a, - 0x00369f4b, - 0x0037640b, - 0x00378a8e, - 0x00378e0b, - 0x0038388b, - 0x00384b4b, - 0x00388d0a, - 0x00388f89, - 0x003891ca, - 0x0038a84a, - 0x0039e1cb, - 0x0039fd0b, - 0x003a0bca, - 0x003a29cb, - 0x003a6acb, - 0x003ae90b, - 0x2d67ed08, - 0x2da84789, - 0x2df1aa09, - 0x2e2cb548, - 0x003388c5, - 0x00201903, - 0x00209d84, - 0x00396c45, - 0x002673c6, - 0x0026b845, - 0x00283f84, - 0x002db848, - 0x00218c45, - 0x0028aa44, - 0x00206087, - 0x0029594a, - 0x002ad74a, - 0x0039c1c7, - 0x00201807, - 0x002f3d87, - 0x0035e147, - 0x002ddf45, - 0x0032b8c6, - 0x0033f307, - 0x0026afc4, - 0x00323946, - 0x002efa06, - 0x003aaec5, - 0x0024e604, - 0x002b1786, - 0x00294cc7, - 0x00224646, - 0x00300e07, - 0x0027c243, - 0x0024cac6, - 0x00233985, - 0x0027db07, - 0x002b848a, - 0x00279344, - 0x0021f308, - 0x002a5449, - 0x002cc1c7, - 0x0022c546, - 0x0024c3c8, - 0x003a1609, - 0x0031f184, - 0x00234d44, - 0x002f96c5, - 0x0032cd48, - 0x002b9587, - 0x002a0b89, - 0x00235a88, - 0x002fc3c6, - 0x00241b06, - 0x002905c8, - 0x0036cc06, - 0x00201e45, - 0x00280bc6, - 0x00278288, - 0x00234dc6, - 0x00250ecb, - 0x002872c6, - 0x00291bcd, - 0x00397445, - 0x002a1b06, - 0x002204c5, - 0x002945c9, - 0x0037e6c7, - 0x0037de08, - 0x0037b746, - 0x00290cc9, - 0x002e45c6, - 0x002b8405, - 0x00297c46, - 0x0029dc86, - 0x002bf749, - 0x0031ef86, - 0x00257a47, - 0x002a28c5, - 0x002030c3, - 0x00251045, - 0x0029f247, - 0x00341b86, - 0x00397349, - 0x00308486, - 0x00280e06, - 0x00210a09, - 0x002805c9, - 0x00298b07, - 0x0031f748, - 0x0038b049, - 0x0027dfc8, - 0x00349746, - 0x002c7785, - 0x0030778a, - 0x00280e86, - 0x003b00c6, - 0x0029f8c5, - 0x002a8dc8, - 0x0020e107, - 0x0023278a, - 0x00247306, - 0x00227245, - 0x0022c7c6, - 0x00298207, - 0x0022c407, - 0x002ef505, - 0x002b85c5, - 0x002a7386, - 0x002a7f46, - 0x002a8406, - 0x0032f204, - 0x0027f249, - 0x00285646, - 0x0027e98a, - 0x0028a008, - 0x002e6848, - 0x002ad74a, - 0x0035eb85, - 0x00294c05, - 0x0037f508, - 0x002bf9c8, - 0x0036ecc7, - 0x0032d046, - 0x00310b08, - 0x002dd147, - 0x0027fbc8, - 0x0036b306, - 0x00281608, - 0x002b0606, - 0x00238807, - 0x00291706, - 0x002b1786, - 0x0030214a, - 0x003a6dc6, - 0x002c7789, - 0x002aa146, - 0x002cc90a, - 0x00336549, - 0x002f2846, - 0x00386d44, - 0x0030be8d, - 0x00284a07, - 0x00313b86, - 0x002b4205, - 0x002e4645, - 0x0030c386, - 0x0026ff89, - 0x002ac3c7, - 0x00279b86, - 0x002c7e06, - 0x00284009, - 0x002ba444, - 0x002686c4, - 0x003a42c8, - 0x002e6e06, - 0x0026fb08, - 0x00380dc8, - 0x00312607, - 0x003afd89, - 0x002a8607, - 0x002a9d0a, - 0x0038078f, - 0x0036898a, - 0x002286c5, - 0x002784c5, - 0x0021ae45, - 0x0026ee07, - 0x00204e03, - 0x0031f948, - 0x002f6706, - 0x002f6809, - 0x002c27c6, - 0x00384f07, - 0x00290a89, - 0x0037dd08, - 0x0029f987, - 0x002fe303, - 0x00338945, - 0x00204d85, - 0x0032f04b, - 0x00266f84, - 0x002df2c4, - 0x00277246, - 0x002fe687, - 0x0039a1ca, - 0x0023cb87, - 0x00205747, - 0x0027ca85, - 0x00202a05, - 0x002218c9, - 0x002b1786, - 0x0023ca0d, - 0x00354e45, - 0x002fee43, - 0x0020a283, - 0x003088c5, - 0x0034dd45, - 0x0024c3c8, - 0x0027a5c7, - 0x00268446, - 0x00296006, - 0x0022dfc5, - 0x00236307, - 0x00201a87, - 0x0035c607, - 0x002c43ca, - 0x0024cb88, - 0x0032f204, - 0x002a89c7, - 0x0027c387, - 0x00331886, - 0x00265807, - 0x002aca08, - 0x0031a908, - 0x0026d806, - 0x002e82c8, - 0x002b8cc4, - 0x0033f306, - 0x00210f46, - 0x0037cc06, - 0x003092c6, - 0x00296584, - 0x0035e206, - 0x002b3306, - 0x0028fd46, - 0x0022e546, - 0x0020a146, - 0x002ac846, - 0x00268348, - 0x003237c8, - 0x002c5048, - 0x0026ba48, - 0x0037f486, - 0x00212585, - 0x00278a46, - 0x002a6745, - 0x00388147, - 0x00235b45, - 0x00213703, - 0x00201585, - 0x002a7dc4, - 0x0020a285, - 0x00218143, - 0x00304a87, - 0x00318408, - 0x00300ec6, - 0x002ddbcd, - 0x00278486, - 0x0028f205, - 0x0026da43, - 0x002af4c9, - 0x002ba5c6, - 0x0028f806, - 0x00271844, - 0x00368907, - 0x002371c6, - 0x002a8c05, - 0x0020ecc3, - 0x00202404, - 0x0027c546, - 0x002ab0c4, - 0x0030b048, - 0x00327ec9, - 0x0037ebc9, - 0x00297b4a, - 0x0023f20d, - 0x00373d07, - 0x00398506, - 0x00208244, - 0x00212e89, - 0x00283508, - 0x00284606, - 0x00263546, - 0x00265807, - 0x002c11c6, - 0x00222806, - 0x0035ec86, - 0x003a130a, - 0x00220408, - 0x0022fe05, - 0x002bafc9, - 0x002800ca, - 0x00220688, - 0x00294308, - 0x0028f788, - 0x00201e8c, - 0x00331185, - 0x00296288, - 0x00306706, - 0x002bd7c6, - 0x00384dc7, - 0x0023ca85, - 0x00280d45, - 0x0037ea89, - 0x00212b07, - 0x002f67c5, - 0x00223487, - 0x0020a283, - 0x002b9ac5, - 0x00367908, - 0x002cf607, - 0x002941c9, - 0x002dc805, - 0x00333f44, - 0x00299848, - 0x002ca9c7, - 0x0029fb48, - 0x00375048, - 0x002ee1c5, - 0x00278e06, - 0x00251546, - 0x002dee09, - 0x00311387, - 0x002a6dc6, - 0x0038d307, - 0x0020f283, - 0x00267684, - 0x0029b105, - 0x00267844, - 0x00244044, - 0x0027f987, - 0x00205307, - 0x00279d44, - 0x00294010, - 0x0030c507, - 0x00202a05, - 0x002f018c, - 0x002ddf44, - 0x002b4a08, - 0x00238709, - 0x003af686, - 0x0033f108, - 0x0025b344, - 0x0025b348, - 0x002a9346, - 0x0022e3c8, - 0x0029f506, - 0x002c314b, - 0x002030c5, - 0x002b8c48, - 0x00217644, - 0x002e8aca, - 0x002941c9, - 0x00300546, - 0x002d2448, - 0x003a4085, - 0x002efc84, - 0x002b4906, - 0x0035c4c8, - 0x0027ed08, - 0x00345c46, - 0x0032a084, - 0x00307706, - 0x002a8687, - 0x00277e87, - 0x0026580f, - 0x00206dc7, - 0x002f2907, - 0x002bd685, - 0x002f4f05, - 0x002987c9, - 0x0026a206, - 0x0027e6c5, - 0x002808c7, - 0x002a2688, - 0x0028fe45, - 0x00291706, - 0x0021ee48, - 0x0039884a, - 0x0024db88, - 0x003abac7, - 0x00380bc6, - 0x002baf86, - 0x00204bc3, - 0x00209e43, - 0x00280289, - 0x0038aec9, - 0x002af086, - 0x002dc805, - 0x002a1cc8, - 0x002d2448, - 0x002fa688, - 0x0035ed0b, - 0x002dde07, - 0x002fcd09, - 0x00265a88, - 0x00340884, - 0x002bf848, - 0x00288209, - 0x002a70c5, - 0x0026ed07, - 0x00326145, - 0x0027ec08, - 0x00289e4b, - 0x0028dc50, - 0x002a1905, - 0x0021758c, - 0x00268605, - 0x0027cb03, - 0x0029ef06, - 0x002b2904, - 0x003422c6, - 0x00294cc7, - 0x0021a644, - 0x002ad648, - 0x0031f80d, - 0x002d2305, - 0x0023f704, - 0x00228404, - 0x0033f789, - 0x0029a048, - 0x00308307, - 0x002a93c8, - 0x0027f308, - 0x00279e85, - 0x00320547, - 0x00279e07, - 0x003212c7, - 0x002b85c9, - 0x00237049, - 0x0023ecc6, - 0x002b0446, - 0x00265a46, - 0x00268d45, - 0x00355304, - 0x00201086, - 0x00202186, - 0x00279ec8, - 0x00297ecb, - 0x00279207, - 0x00208244, - 0x00314006, - 0x002dd6c7, - 0x00334645, - 0x00315185, - 0x00203304, - 0x00236fc6, - 0x00201108, - 0x00212e89, - 0x00244c46, - 0x00282e88, - 0x002a8cc6, - 0x00332448, - 0x003acd0c, - 0x00279d46, - 0x0028eecd, - 0x0028f34b, - 0x00257b05, - 0x00201bc7, - 0x0031f086, - 0x0022c2c8, - 0x0023ed49, - 0x002dea48, - 0x00202a05, - 0x002f3107, - 0x0027e0c8, - 0x0035f9c9, - 0x002d9ec6, - 0x0024930a, - 0x0022c048, - 0x002de88b, - 0x002c07cc, - 0x0025b448, - 0x0027bc86, - 0x0031ff48, - 0x00206f07, - 0x002372c9, - 0x0028b80d, - 0x00295c86, - 0x002efb08, - 0x00323689, - 0x002b0e08, - 0x00281708, - 0x002b3bcc, - 0x002b4ec7, - 0x002b6087, - 0x002b8405, - 0x0023c087, - 0x002a2548, - 0x002b4986, - 0x00244acc, - 0x002df988, - 0x002c0ac8, - 0x0035be06, - 0x00204b07, - 0x0023eec4, - 0x0026ba48, - 0x0036fd0c, - 0x0021a64c, - 0x00228745, - 0x00208fc7, - 0x0032a006, - 0x00204a86, - 0x00294788, - 0x00365b04, - 0x0022464b, - 0x00228c8b, - 0x00380bc6, - 0x0031f687, - 0x0024ea45, - 0x0026fa45, - 0x00224786, - 0x003a4045, - 0x00266f45, - 0x002d2747, - 0x00277849, - 0x002873c4, - 0x0031adc5, - 0x002d0545, - 0x0025a408, - 0x002ad485, - 0x00297489, - 0x002df547, - 0x002df54b, - 0x0022db46, - 0x00268089, - 0x0024e548, - 0x00272005, - 0x003213c8, - 0x00237088, - 0x0021bc87, - 0x0033fb87, - 0x0027fa09, - 0x0022e307, - 0x00283d49, - 0x002a37cc, - 0x002af088, - 0x002b1209, - 0x002bae47, - 0x0027f3c9, - 0x00205447, - 0x002c08c8, - 0x0025a745, - 0x0033f286, - 0x002b4248, - 0x002f7d88, - 0x0027ff89, - 0x00266f87, - 0x0024af85, - 0x00211d49, - 0x0038b406, - 0x00289704, - 0x002de706, - 0x00243248, - 0x00244607, - 0x002980c8, - 0x002e8389, - 0x0035bb87, - 0x00295b06, - 0x00201c84, - 0x00201609, - 0x003203c8, - 0x0035bcc7, - 0x0032b9c6, - 0x00204e46, - 0x003b0044, - 0x0032a946, - 0x0020a203, - 0x0024f5c9, - 0x00203086, - 0x0029e345, - 0x00296006, - 0x0029fc85, - 0x0027e548, - 0x0025b187, - 0x0035df86, - 0x0022bb06, - 0x002e6848, - 0x00298947, - 0x00295cc5, - 0x00296508, - 0x0038ac08, - 0x0022c048, - 0x002684c5, - 0x0033f306, - 0x0037e989, - 0x002513c4, - 0x0036cd0b, - 0x0022250b, - 0x0022fd09, - 0x0020a283, - 0x002567c5, - 0x0020d746, - 0x00279688, - 0x00380704, - 0x00300ec6, - 0x002c4509, - 0x002c4b85, - 0x002d2686, - 0x002ca9c6, - 0x0021af04, - 0x00299c0a, - 0x0029e288, - 0x002f7d86, - 0x002e9285, - 0x00201407, - 0x0037e387, - 0x00278e04, - 0x00222747, - 0x0022bfc4, - 0x00235b06, - 0x0021ef83, - 0x002b85c5, - 0x0036d2c5, - 0x002c29c8, - 0x00267785, - 0x00279a89, - 0x0026b887, - 0x0026b88b, - 0x0029ae0c, - 0x0029b94a, - 0x002ba287, - 0x00200843, - 0x00312388, - 0x00268685, - 0x0028fec5, - 0x00338a04, - 0x002c07c6, - 0x00238706, - 0x0032a987, - 0x0020ec0b, - 0x00296584, - 0x0037df84, - 0x002b9104, - 0x002bf346, - 0x0021a644, - 0x0032ce48, - 0x00338805, - 0x0022dd85, - 0x002fa5c7, - 0x00201cc9, - 0x0034dd45, - 0x0037810a, - 0x002a27c9, - 0x0029780a, - 0x003a1449, - 0x002e4284, - 0x002c7ec5, - 0x002c12c8, - 0x00311d8b, - 0x002f96c5, - 0x0038ce06, - 0x002150c4, - 0x00279fc6, - 0x0035ba09, - 0x003140c7, - 0x00308648, - 0x0023f586, - 0x002a8607, - 0x0027ed08, - 0x0038edc6, - 0x00242884, - 0x0035a2c7, - 0x00346ec5, - 0x0034c1c7, - 0x00201184, - 0x0031f006, - 0x00393988, - 0x0028f508, - 0x002f40c7, - 0x00224388, - 0x002b06c5, - 0x0020a0c4, - 0x002e6748, - 0x00224484, - 0x0021adc5, - 0x002eea84, - 0x002dd247, - 0x00285707, - 0x0027f508, - 0x0029fcc6, - 0x00267705, - 0x00279888, - 0x0024dd88, - 0x00297a89, - 0x00222806, - 0x00232808, - 0x002e894a, - 0x003346c8, - 0x002d1645, - 0x00207e86, - 0x0026fe48, - 0x002f31ca, - 0x00324d07, - 0x00283905, - 0x0028e448, - 0x002aac84, - 0x002a8e46, - 0x002b6808, - 0x0020a146, - 0x00325448, - 0x00251207, - 0x00205f86, - 0x00386d44, - 0x0037ae07, - 0x0032cb84, - 0x0035b9c7, - 0x0030028d, - 0x0022fd85, - 0x002cf40b, - 0x0029f606, - 0x0024c248, - 0x003577c4, - 0x00276386, - 0x0027c546, - 0x00320287, - 0x0028eb8d, - 0x002a4487, - 0x002fed88, - 0x0024a8c5, - 0x0028ff88, - 0x002b9506, - 0x002b0748, - 0x00214846, - 0x002e7ac7, - 0x00229f89, - 0x003577c7, - 0x002848c8, - 0x00273c05, - 0x0021fd48, - 0x002049c5, - 0x00240f85, - 0x00352c85, - 0x00222fc3, - 0x00280c44, - 0x0028e645, - 0x0026e809, - 0x002cfd46, - 0x002acb08, - 0x00249cc5, - 0x0032ee87, - 0x00249aca, - 0x002d25c9, - 0x0029db8a, - 0x002c50c8, - 0x002232cc, - 0x0028094d, - 0x003369c3, - 0x00325348, - 0x002023c5, - 0x00398606, - 0x0037db86, - 0x002d0ec5, - 0x0038d409, - 0x00375485, - 0x00279888, - 0x00257946, - 0x0033c546, - 0x00299709, - 0x0038e5c7, - 0x00363bc6, - 0x00249a48, - 0x0037cb08, - 0x002cb747, - 0x0022e54e, - 0x002b9745, - 0x0035f8c5, - 0x0020a048, - 0x0032b2c7, - 0x00203ac2, - 0x002b3744, - 0x003421ca, - 0x0035bd88, - 0x002dd7c6, - 0x00290bc8, - 0x00251546, - 0x00319e88, - 0x002a6dc8, - 0x00240f44, - 0x00333345, - 0x00683b84, - 0x00683b84, - 0x00683b84, - 0x00201e43, - 0x00204cc6, - 0x00279d46, - 0x002954cc, - 0x00205fc3, - 0x002800c6, - 0x0021ef44, - 0x002ba548, - 0x002c4345, - 0x003422c6, - 0x002afc08, - 0x002c5e06, - 0x0035df06, - 0x00341e08, - 0x0029b187, - 0x0022e0c9, - 0x0030428a, - 0x0026ae44, - 0x00235b45, - 0x002a0b45, - 0x00212c86, - 0x00373d46, - 0x002a20c6, - 0x002edd86, - 0x0022e204, - 0x0022e20b, - 0x00235904, - 0x00201485, - 0x002a58c5, - 0x003126c6, - 0x003a8b08, - 0x00280807, - 0x00308404, - 0x00259d03, - 0x002aa785, - 0x002de5c7, - 0x0029c709, - 0x0028070b, - 0x0032a987, - 0x002c28c7, - 0x002e45c4, - 0x002afb08, - 0x002f4347, - 0x0029c946, - 0x00242608, - 0x0033fd8b, - 0x00396b86, - 0x00213449, - 0x0033ff05, - 0x002fe303, - 0x002d2686, - 0x00251108, - 0x00212d43, - 0x002de6c3, - 0x0027ed06, - 0x00251546, - 0x0038a5ca, - 0x0027bcc5, - 0x0027c38b, - 0x00295f4b, - 0x0020cd83, - 0x0021cec3, - 0x002a9c84, - 0x002e7f07, - 0x00251184, - 0x00201e84, - 0x00306584, - 0x003349c8, - 0x002e91c8, - 0x00327a49, - 0x002bdd48, - 0x003a17c7, - 0x0022e546, - 0x002ac74f, - 0x002b9886, - 0x002c42c4, - 0x002e900a, - 0x002de4c7, - 0x003aaf46, - 0x00289749, - 0x003279c5, - 0x002c2b05, - 0x00327b06, - 0x0021fe83, - 0x002aacc9, - 0x00220586, - 0x002e8149, - 0x0039a1c6, - 0x002b85c5, - 0x00228b45, - 0x00204d43, - 0x002e8048, - 0x00200ec7, - 0x002f6704, - 0x002ba3c8, - 0x002b1504, - 0x002cdfc6, - 0x0029ef06, - 0x0023dec6, - 0x002b8b09, - 0x0028fe45, - 0x002b1786, - 0x00257e49, - 0x002b8806, - 0x002ac846, - 0x003870c6, - 0x00212f85, - 0x002eea86, - 0x002e7ac4, - 0x0025a745, - 0x002b4244, - 0x00306486, - 0x00354e04, - 0x00200d03, - 0x002835c5, - 0x00236d88, - 0x00262847, - 0x002ae189, - 0x00283808, - 0x00290391, - 0x002caa4a, - 0x00380b07, - 0x002cbd86, - 0x0021ef44, - 0x002b4348, - 0x00281e88, - 0x0029054a, - 0x0029724d, - 0x00297c46, - 0x00341f06, - 0x0037aec6, - 0x002ef387, - 0x002fee45, - 0x00253687, - 0x002ba485, - 0x002df684, - 0x002a2d06, - 0x0032a7c7, - 0x002aa9cd, - 0x0026fd87, - 0x002db748, - 0x00279b89, - 0x00207d86, - 0x002d9e45, - 0x00218184, - 0x00243346, - 0x00278d06, - 0x0035bf06, - 0x00293a08, - 0x00217b03, - 0x0020a5c3, - 0x0031a245, - 0x00236446, - 0x002a6d85, - 0x0023f788, - 0x00294e8a, - 0x00376b04, - 0x002ba548, - 0x0028f788, - 0x00312507, - 0x00249d89, - 0x002af808, - 0x00212f07, - 0x00258b86, - 0x0020a14a, - 0x002433c8, - 0x002c0609, - 0x0029a108, - 0x00221cc9, - 0x002deb47, - 0x00346045, - 0x0031ab86, - 0x002b4808, - 0x0027ee88, - 0x00289a88, - 0x0021af08, - 0x00201485, - 0x00210a44, - 0x00200bc8, - 0x00208f84, - 0x003a1244, - 0x002b85c5, - 0x0028aa87, - 0x00201a89, - 0x00320087, - 0x00210a85, - 0x00277446, - 0x0033ed46, - 0x00213584, - 0x00299a46, - 0x002a8944, - 0x00281d86, - 0x00365bc6, - 0x00219206, - 0x00202a05, - 0x0023f647, - 0x00200843, - 0x003196c9, - 0x003638c8, - 0x00212d84, - 0x00212d8d, - 0x0028f608, - 0x002a5008, - 0x002c0586, - 0x0022a089, - 0x002d25c9, - 0x0035b705, - 0x00294f8a, - 0x0027b24a, - 0x002858cc, - 0x00285a46, - 0x00277d06, - 0x002b9a06, - 0x0026ae09, - 0x00398846, - 0x002536c6, - 0x00375546, - 0x0026ba48, - 0x00224386, - 0x002b8e4b, - 0x0028ac05, - 0x0022dd85, - 0x00277f85, - 0x0037c0c6, - 0x0020a103, - 0x0023de46, - 0x0026fd07, - 0x002b4205, - 0x00241bc5, - 0x002e4645, - 0x003382c6, - 0x0030c384, - 0x0036c206, - 0x0028c789, - 0x0037bf4c, - 0x002df3c8, - 0x0028c8c4, - 0x002ee706, - 0x0029f706, - 0x00251108, - 0x002d2448, - 0x0037be49, - 0x00201407, - 0x002e6b49, - 0x00359206, - 0x00230d84, - 0x0020ddc4, - 0x0022c844, - 0x0027ed08, - 0x002018ca, - 0x0034dcc6, - 0x00351a07, - 0x002d4407, - 0x00268185, - 0x002a0b04, - 0x002881c6, - 0x002fee86, - 0x00230a43, - 0x00363707, - 0x00374f48, - 0x0035b84a, - 0x002bff48, - 0x00376988, - 0x00354e45, - 0x00257c05, - 0x00279305, - 0x00268546, - 0x0037b286, - 0x00205245, - 0x0024f809, - 0x002a090c, - 0x00262287, - 0x002905c8, - 0x003875c5, - 0x00683b84, - 0x0027f104, - 0x002cf744, - 0x002bc306, - 0x00296ace, - 0x002c2b87, - 0x002ef585, - 0x0025134c, - 0x002b13c7, - 0x0032a747, - 0x00353049, - 0x0021f3c9, - 0x00283905, - 0x003638c8, - 0x0037e989, - 0x003175c5, - 0x002b4148, - 0x0026d986, - 0x002ad8c6, - 0x00336544, - 0x00249508, - 0x00207f43, - 0x00320bc4, - 0x002aa805, - 0x0030c387, - 0x00205b45, - 0x002e8809, - 0x00331bcd, - 0x0029a646, - 0x0037fa84, - 0x0032cfc8, - 0x0027768a, - 0x0020e607, - 0x002d4745, - 0x0020b0c3, - 0x0029610e, - 0x0025154c, - 0x002f9a07, - 0x00296c87, - 0x002011c3, - 0x00398885, - 0x002cf745, - 0x00290f88, - 0x0028e289, - 0x0035c346, - 0x00251184, - 0x00380a46, - 0x0037c8cb, - 0x002a22cc, - 0x0031fe07, - 0x002c4005, - 0x0038ab08, - 0x002cb505, - 0x002e9007, - 0x00234b47, - 0x00247d45, - 0x0020a103, - 0x00334d04, - 0x00209d45, - 0x002a8005, - 0x002a8006, - 0x00288b48, - 0x0032a7c7, - 0x0037de86, - 0x003aff46, - 0x00352bc6, - 0x00297d49, - 0x00320647, - 0x0035c1c6, - 0x002a2446, - 0x00247e06, - 0x002a1c05, - 0x0020d446, - 0x00396905, - 0x002ad508, - 0x0028d88b, - 0x00287fc6, - 0x002d4444, - 0x002f2f89, - 0x0026b884, - 0x0026d908, - 0x00289207, - 0x00281604, - 0x002aeac8, - 0x002b5a44, - 0x002a1c44, - 0x00284305, - 0x002d2346, - 0x00334907, - 0x0021c603, - 0x00295bc5, - 0x003260c4, - 0x0035f906, - 0x0035b788, - 0x00341d05, - 0x0028a509, - 0x00211f45, - 0x002e1e48, - 0x00328dc7, - 0x00388288, - 0x002adfc7, - 0x002f29c9, - 0x0035e086, - 0x0038dc86, - 0x00375544, - 0x00258ac5, - 0x002f534c, - 0x00277f87, - 0x00278387, - 0x002d42c8, - 0x0029a646, - 0x0026fc44, - 0x002ea2c4, - 0x0027f889, - 0x002b9b06, - 0x00221947, - 0x00309244, - 0x002cfe46, - 0x00324905, - 0x0029f807, - 0x002b8dc6, - 0x002491c9, - 0x0027b087, - 0x00265807, - 0x00299586, - 0x0023f105, - 0x0027d0c8, - 0x00220408, - 0x00237d46, - 0x00341d45, - 0x00254206, - 0x00206103, - 0x00290e09, - 0x002a1e4e, - 0x002adcc8, - 0x002b1608, - 0x00237b4b, - 0x0028a746, - 0x0031e4c4, - 0x00280544, - 0x002a1f4a, - 0x00217487, - 0x0035c285, - 0x00213449, - 0x002b33c5, - 0x003a1287, - 0x0037f404, - 0x00328047, - 0x00380cc8, - 0x002cc286, - 0x00329089, - 0x002af90a, - 0x00217406, - 0x0028f146, - 0x002a5845, - 0x003793c5, - 0x0024e887, - 0x00243988, - 0x00324848, - 0x00240f46, - 0x00228bc5, - 0x00373ace, - 0x0032f204, - 0x00237cc5, - 0x00276dc9, - 0x0026a008, - 0x003aba06, - 0x0029368c, - 0x00294a90, - 0x0029670f, - 0x002986c8, - 0x002ba287, - 0x00202a05, - 0x0028e645, - 0x00334789, - 0x0028e649, - 0x00307806, - 0x002f9747, - 0x00208f45, - 0x0036ecc9, - 0x00331906, - 0x0039868d, - 0x002843c9, - 0x00201e84, - 0x002ada48, - 0x00200c89, - 0x0034de86, - 0x00277545, - 0x0038dc86, - 0x00308509, - 0x00385a48, - 0x00212585, - 0x00249504, - 0x0029384b, - 0x0034dd45, - 0x00279706, - 0x00280c86, - 0x00265086, - 0x0035ef0b, - 0x0028a609, - 0x00205585, - 0x00388047, - 0x002ca9c6, - 0x00342006, - 0x002e86c8, - 0x00258c89, - 0x002db50c, - 0x002de3c8, - 0x0034df86, - 0x00345c43, - 0x0026ef06, - 0x002f2885, - 0x0027c6c8, - 0x002285c6, - 0x0029fa48, - 0x0023cc05, - 0x00290705, - 0x00299e08, - 0x002eeb87, - 0x0037dac7, - 0x0032a987, - 0x0033f108, - 0x00289908, - 0x0023bf86, - 0x003062c7, - 0x00267547, - 0x0033f88a, - 0x0024ae83, - 0x0037c0c6, - 0x00201a05, - 0x0020c684, - 0x00279b89, - 0x002f2944, - 0x002628c4, - 0x0029f584, - 0x00296c8b, - 0x00200e07, - 0x0034dd05, - 0x0028d708, - 0x00277446, - 0x00277448, - 0x0027bc06, - 0x002867c5, - 0x00286f45, - 0x00288f46, - 0x002893c8, - 0x00289688, - 0x00279d46, - 0x0028d54f, - 0x002908d0, - 0x00397445, - 0x00200843, - 0x0024a805, - 0x002fcc48, - 0x0028e549, - 0x0022c048, - 0x00328f08, - 0x003980c8, - 0x00200ec7, - 0x00277109, - 0x0029fc48, - 0x00370544, - 0x0029f408, - 0x0025a4c9, - 0x00307e07, - 0x0029f384, - 0x00320148, - 0x0023f40a, - 0x002bf1c6, - 0x00297c46, - 0x002226c9, - 0x00294cc7, - 0x002bfdc8, - 0x00208988, - 0x003090c8, - 0x00351545, - 0x0037a205, - 0x0022dd85, - 0x002cf705, - 0x002f0987, - 0x0020a105, - 0x002b4205, - 0x00213bc6, - 0x0022bf87, - 0x00311cc7, - 0x0023f706, - 0x002c5605, - 0x00279706, - 0x0025b205, - 0x002bd508, - 0x002f4e84, - 0x002b8886, - 0x00327dc4, - 0x002efc88, - 0x00216d8a, - 0x0027a5cc, - 0x0020ee05, - 0x002ef446, - 0x002db6c6, - 0x00374846, - 0x002fce44, - 0x00324bc5, - 0x0027ba47, - 0x00294d49, - 0x0029c807, - 0x00683b84, - 0x00683b84, - 0x00308285, - 0x0022b8c4, - 0x0029304a, - 0x002772c6, - 0x002de804, - 0x003aaec5, - 0x002ea985, - 0x002fed84, - 0x002808c7, - 0x00211ec7, - 0x002bf348, - 0x00315408, - 0x00212589, - 0x00295748, - 0x0029320b, - 0x00212c84, - 0x00359145, - 0x0027e745, - 0x0032a909, - 0x00258c89, - 0x002f2e88, - 0x00235908, - 0x003126c4, - 0x0029f745, - 0x00201903, - 0x00212c45, - 0x002b1806, - 0x0028e0cc, - 0x00220486, - 0x0025b246, - 0x0028e285, - 0x00338348, - 0x002ade46, - 0x002cbf06, - 0x00297c46, - 0x002239cc, - 0x0035c0c4, - 0x00352d0a, - 0x003abbc8, - 0x0028df07, - 0x00242786, - 0x0035c407, - 0x002da345, - 0x0032b9c6, - 0x00350106, - 0x0037d987, - 0x00262904, - 0x002dd345, - 0x00276dc4, - 0x002df707, - 0x00277008, - 0x00277b8a, - 0x0027df47, - 0x00237ec7, - 0x002ba207, - 0x002cb649, - 0x0028e0ca, - 0x0022e1c3, - 0x00262805, - 0x00219243, - 0x003065c9, - 0x002bc788, - 0x002bd687, - 0x0022c149, - 0x00220506, - 0x002cac48, - 0x00304a05, - 0x0024de8a, - 0x002c67c9, - 0x0026d6c9, - 0x00384dc7, - 0x00281f89, - 0x00219108, - 0x002ee886, - 0x002ef608, - 0x00217c47, - 0x0022e307, - 0x002a27c7, - 0x002cfbc8, - 0x002ee586, - 0x0023f1c5, - 0x0027ba47, - 0x0028ec48, - 0x00352b44, - 0x0027e844, - 0x00363ac7, - 0x002a7147, - 0x0037e80a, - 0x002ee806, - 0x002f988a, - 0x002b3687, - 0x0032efc7, - 0x00241044, - 0x00283e04, - 0x00225f46, - 0x00375a44, - 0x00375a4c, - 0x00397a85, - 0x0021ad49, - 0x002e1fc4, - 0x002fee45, - 0x00277608, - 0x00289745, - 0x0030c386, - 0x0020eb04, - 0x00293d8a, - 0x002aafc6, - 0x0028f90a, - 0x0030c147, - 0x00298205, - 0x0021fe85, - 0x002681ca, - 0x00299b45, - 0x00297b46, - 0x00208f84, - 0x002a9e06, - 0x0024e945, - 0x00228686, - 0x002f40cc, - 0x002bf4ca, - 0x00258b84, - 0x0022e546, - 0x00294cc7, - 0x002c3604, - 0x0026ba48, - 0x0038cd06, - 0x00373949, - 0x002c1689, - 0x002af189, - 0x0036cec6, - 0x00217d46, - 0x002ef747, - 0x0024f748, - 0x00217b49, - 0x00200e07, - 0x002b0546, - 0x002a8687, - 0x0037ad85, - 0x0032f204, - 0x002ef307, - 0x00326145, - 0x00284245, - 0x002fb1c7, - 0x00247c08, - 0x0038aa86, - 0x0028fb8d, - 0x0029118f, - 0x00295f4d, - 0x00210ac4, - 0x00236e86, - 0x002c6cc8, - 0x00375505, - 0x0033fa48, - 0x0021bb4a, - 0x00201e84, - 0x002f4486, - 0x0027d847, - 0x003920c7, - 0x0029b249, - 0x002ef5c5, - 0x002fed84, - 0x0033328a, - 0x002af3c9, - 0x00282087, - 0x00269586, - 0x0034de86, - 0x0029f686, - 0x0035a386, - 0x002c648f, - 0x002c6b89, - 0x00224386, - 0x003924c6, - 0x003992c9, - 0x003063c7, - 0x002181c3, - 0x00223b46, - 0x00209e43, - 0x002d0d88, - 0x002a84c7, - 0x002988c9, - 0x0029ed88, - 0x0037dc08, - 0x002670c6, - 0x00278b49, - 0x00234c85, - 0x00242784, - 0x002d6c87, - 0x0026ae85, - 0x00210ac4, - 0x00373dc8, - 0x00217744, - 0x00302907, - 0x00318386, - 0x002a7445, - 0x0029a108, - 0x0034dd4b, - 0x002a0e47, - 0x00268446, - 0x002b9904, - 0x0031e446, - 0x002b85c5, - 0x00326145, - 0x0027ce49, - 0x002804c9, - 0x0022e344, - 0x0022e385, - 0x0022e585, - 0x0024dd06, - 0x003639c8, - 0x002b2f86, - 0x00374d8b, - 0x003af50a, - 0x0032cc85, - 0x00286fc6, - 0x002f6405, - 0x0020c145, - 0x00294487, - 0x003a42c8, - 0x00289444, - 0x0035b606, - 0x00289706, - 0x002192c7, - 0x002fe2c4, - 0x0027c546, - 0x00239f05, - 0x00239f09, - 0x00217f44, - 0x002a0c89, - 0x00279d46, - 0x002b4f88, - 0x0022e585, - 0x002d4505, - 0x00228686, - 0x002db409, - 0x0021f3c9, - 0x0025b2c6, - 0x0026a108, - 0x00251448, - 0x002f63c4, - 0x0035a884, - 0x0035a888, - 0x00313c88, - 0x002e6c49, - 0x002b1786, - 0x00297c46, - 0x003109cd, - 0x00300ec6, - 0x003acbc9, - 0x0037c285, - 0x00327b06, - 0x002537c8, - 0x0030df05, - 0x00267584, - 0x002b85c5, - 0x0027f708, - 0x00292e09, - 0x00276e84, - 0x0031f006, - 0x002dec8a, - 0x00220688, - 0x0037e989, - 0x0022dc4a, - 0x0022c0c6, - 0x00291348, - 0x002e8dc5, - 0x00329788, - 0x002ae0c5, - 0x002203c9, - 0x00360909, - 0x00201002, - 0x0033ff05, - 0x0026f786, - 0x00279c87, - 0x0020c685, - 0x002f7c86, - 0x0030dfc8, - 0x0029a646, - 0x002c1189, - 0x00278486, - 0x002e8548, - 0x002a2f45, - 0x00248d06, - 0x002e7bc8, - 0x0027ed08, - 0x00365c48, - 0x002fc448, - 0x0020d444, - 0x0022e883, - 0x002c13c4, - 0x0027e146, - 0x0037adc4, - 0x002b1547, - 0x002cbe09, - 0x002b9105, - 0x00208986, - 0x00223b46, - 0x0028898b, - 0x0032cbc6, - 0x003147c6, - 0x002b8988, - 0x00241b06, - 0x00297543, - 0x00209643, - 0x0032f204, - 0x00232705, - 0x002a8b07, - 0x00277008, - 0x0027700f, - 0x0027b94b, - 0x003637c8, - 0x0031f086, - 0x002e684e, - 0x00228683, - 0x00227304, - 0x0032cb45, - 0x002fda46, - 0x002882cb, - 0x0028ab46, - 0x0021eec9, - 0x002a7445, - 0x003896c8, - 0x0020d888, - 0x0021f28c, - 0x00296cc6, - 0x00212c86, - 0x002dc805, - 0x00284688, - 0x0022c405, - 0x00340888, - 0x0029638a, - 0x0031aa09, - 0x00683b84, - 0x2ea02682, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00341d03, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0024a143, - 0x00202d43, - 0x002006c3, - 0x0021db44, - 0x0022f303, - 0x00238c04, - 0x00215403, - 0x002cb284, - 0x002d60c3, - 0x0020c947, - 0x0021e083, - 0x00201543, - 0x00331a08, - 0x00202d43, - 0x002d780b, - 0x002daa83, - 0x00215a06, - 0x00200142, - 0x0038548b, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x00202d43, - 0x0021c443, - 0x00205e03, - 0x002050c2, - 0x001795c8, - 0x0021c5c5, - 0x002d3c88, - 0x002e2808, - 0x00202682, - 0x0022c8c5, - 0x0032b687, - 0x00200482, - 0x0021f107, - 0x00200fc2, - 0x0023c7c7, - 0x00375f89, - 0x00314b88, - 0x00308f49, - 0x00333f02, - 0x00266687, - 0x0025b044, - 0x0032b747, - 0x003af407, - 0x00243782, - 0x0021e083, - 0x00200542, - 0x002032c2, - 0x00200282, - 0x00205702, - 0x00204942, - 0x00204842, - 0x00297105, - 0x0027f045, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00000301, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0024af03, - 0x0024a143, - 0x00202d43, - 0x0021e7c3, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00009602, - 0x001795c8, - 0x00043944, - 0x000cb905, - 0x002050c2, - 0x002b6504, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x00300943, - 0x002a3645, - 0x0024af03, - 0x0035ea43, - 0x0024a143, - 0x00205bc3, - 0x00202d43, - 0x002169c3, - 0x0021dbc3, - 0x0021d903, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00202682, - 0x00202d43, - 0x001795c8, - 0x002d60c3, - 0x001795c8, - 0x002c81c3, - 0x0022f303, - 0x00233204, - 0x00215403, - 0x002d60c3, - 0x00208202, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x00208202, - 0x0020c943, - 0x0024a143, - 0x00202d43, - 0x002d3c03, - 0x002169c3, - 0x002050c2, - 0x00202682, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00215a05, - 0x000a80c6, - 0x0021db44, - 0x00200142, - 0x001795c8, - 0x002050c2, - 0x00020e88, - 0x00202682, - 0x0000de46, - 0x000e7144, - 0x000c958b, - 0x00018886, - 0x00120ac7, - 0x00215403, - 0x002d60c3, - 0x00154d45, - 0x0000b844, - 0x0023bec3, - 0x0004ae47, - 0x000c7d44, - 0x0024a143, - 0x0006f0c4, - 0x00202d43, - 0x002dbd04, - 0x00108dc8, - 0x00141846, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x00201543, - 0x00202d43, - 0x002daa83, - 0x00200142, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c383, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002cb284, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00215a06, - 0x00215403, - 0x002d60c3, - 0x00170dc3, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00120ac7, - 0x001795c8, - 0x002d60c3, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x3762f303, - 0x00215403, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x002050c2, - 0x00202682, - 0x0022f303, - 0x002d60c3, - 0x0024a143, - 0x00200282, - 0x00202d43, - 0x00307107, - 0x0032164b, - 0x00207043, - 0x002d9fc8, - 0x0024f4c7, - 0x00366b86, - 0x002b7305, - 0x003696c9, - 0x00215788, - 0x00264449, - 0x00264450, - 0x00355bcb, - 0x002ebe49, - 0x00203383, - 0x00213dc9, - 0x00233d06, - 0x00233d0c, - 0x0021c688, - 0x003ac0c8, - 0x00270649, - 0x002a5f4e, - 0x0037794b, - 0x002ad20c, - 0x00201383, - 0x0025fc8c, - 0x00206b09, - 0x0036e907, - 0x00235f8c, - 0x0039d00a, - 0x002451c4, - 0x00365f0d, - 0x0025fb48, - 0x002006cd, - 0x00266b06, - 0x003a090b, - 0x0020b149, - 0x00314687, - 0x002e57c6, - 0x0030c689, - 0x0032560a, - 0x003040c8, - 0x002da684, - 0x0031ac87, - 0x00276487, - 0x00309444, - 0x0022b544, - 0x00263789, - 0x003767c9, - 0x00223f08, - 0x00210545, - 0x00391a05, - 0x0020d186, - 0x00365dc9, - 0x0021bdcd, - 0x002acc88, - 0x0020d087, - 0x002b7388, - 0x0022fac6, - 0x0039b7c4, - 0x0031a505, - 0x00202f86, - 0x00205c84, - 0x00206a07, - 0x0020924a, - 0x00213384, - 0x00217346, - 0x00218d89, - 0x00218d8f, - 0x0021aa4d, - 0x0021b746, - 0x00220a90, - 0x00220e86, - 0x002215c7, - 0x00221f07, - 0x00221f0f, - 0x00222989, - 0x00227f86, - 0x0022a2c7, - 0x0022a2c8, - 0x0022a689, - 0x0028a848, - 0x002d08c7, - 0x0020c3c3, - 0x0038f846, - 0x00200308, - 0x002a620a, - 0x00214e49, - 0x00208103, - 0x0032b586, - 0x0035b44a, - 0x002f6cc7, - 0x0036e74a, - 0x00203e4e, - 0x00222ac6, - 0x00340107, - 0x002128c6, - 0x00206bc6, - 0x0037a00b, - 0x0033b60a, - 0x0022990d, - 0x00217e07, - 0x003756c8, - 0x003756c9, - 0x003756cf, - 0x00204f0c, - 0x003701c9, - 0x002d3e8e, - 0x0020ca4a, - 0x002e9646, - 0x00372686, - 0x0030eb8c, - 0x0032e14c, - 0x00330208, - 0x003576c7, - 0x0026bdc5, - 0x00398b04, - 0x0032294e, - 0x00325884, - 0x00373087, - 0x0026154a, - 0x00381a14, - 0x0038404f, - 0x002220c8, - 0x0038f708, - 0x0036528d, - 0x0036528e, - 0x00391b89, - 0x002316c8, - 0x002316cf, - 0x00235c8c, - 0x00235c8f, - 0x00236bc7, - 0x0023910a, - 0x0022014b, - 0x0023aac8, - 0x0023b507, - 0x0037280d, - 0x00326586, - 0x003660c6, - 0x0023dcc9, - 0x0031ca48, - 0x002415c8, - 0x002415ce, - 0x002469c7, - 0x002a4045, - 0x00243045, - 0x0020ae04, - 0x00366e46, - 0x00223e08, - 0x00252503, - 0x0025bc0e, - 0x00372bc8, - 0x0036750b, - 0x00353487, - 0x003a3f85, - 0x0025fe06, - 0x002a4e07, - 0x002e1708, - 0x0022bdc9, - 0x00326805, - 0x00283608, - 0x002142c6, - 0x0037aa0a, - 0x00322849, - 0x00236049, - 0x0023604b, - 0x0030d1c8, - 0x00309309, - 0x00210606, - 0x0037410a, - 0x0034770a, - 0x0023930c, - 0x002f69c7, - 0x0029c48a, - 0x0033520b, - 0x00335219, - 0x00239988, - 0x00215a85, - 0x002bb506, - 0x002d5cc9, - 0x00315086, - 0x0021234a, - 0x00320946, - 0x00214b84, - 0x002bb68d, - 0x00324ec7, - 0x00214b89, - 0x00383745, - 0x00244288, - 0x002447c9, - 0x00244a04, - 0x002450c7, - 0x002450c8, - 0x002457c7, - 0x00264d08, - 0x0024bf07, - 0x0023b3c5, - 0x0025720c, - 0x00257749, - 0x002c194a, - 0x0038e449, - 0x00213ec9, - 0x0026d08c, - 0x00259bcb, - 0x00259e88, - 0x0025c3c8, - 0x0025f784, - 0x002812c8, - 0x00282949, - 0x0039d0c7, - 0x00218fc6, - 0x00216207, - 0x002ffd49, - 0x00334e4b, - 0x003246c7, - 0x00202dc7, - 0x002e2047, - 0x00200644, - 0x00200645, - 0x002a19c5, - 0x00337e4b, - 0x0039aa44, - 0x00316248, - 0x002a3c4a, - 0x00214387, - 0x0034d807, - 0x00287b52, - 0x00281c86, - 0x00232986, - 0x00319a0e, - 0x00282686, - 0x0028b688, - 0x0028c28f, - 0x00200a88, - 0x0036f748, - 0x002b560a, - 0x002b5611, - 0x0029a30e, - 0x0023b80a, - 0x0023b80c, - 0x002318c7, - 0x002318d0, - 0x00202208, - 0x0029a505, - 0x002a520a, - 0x00205ccc, - 0x002b088d, - 0x002f21c6, - 0x0032d887, - 0x0032d88c, - 0x002f21cc, - 0x002d350c, - 0x00298e4b, - 0x00282fc4, - 0x00222844, - 0x00381489, - 0x002d01c7, - 0x00236609, - 0x00347549, - 0x00360007, - 0x0039ce86, - 0x0039ce89, - 0x003a64c3, - 0x0029a74a, - 0x00398d47, - 0x0031b0cb, - 0x0022978a, - 0x0023c904, - 0x00351b46, - 0x0027e1c9, - 0x0038d5c4, - 0x00397b4a, - 0x00268745, - 0x002b1985, - 0x002b198d, - 0x002b1cce, - 0x00312a85, - 0x00393dc6, - 0x00215607, - 0x002d1b0a, - 0x002e1906, - 0x002fa1c4, - 0x002fabc7, - 0x0021df4b, - 0x0022fb87, - 0x0035eb44, - 0x002d85c6, - 0x002d85cd, - 0x0031ec4c, - 0x0032a506, - 0x002ace8a, - 0x0021c346, - 0x00218288, - 0x003024c7, - 0x002a7b0a, - 0x00233086, - 0x00217d03, - 0x00253946, - 0x00200188, - 0x0029340a, - 0x0024b047, - 0x0024b048, - 0x0024c544, - 0x002780c7, - 0x0038b488, - 0x0029fdc8, - 0x003925c8, - 0x003471ca, - 0x002ca385, - 0x002ca607, - 0x0023b653, - 0x0022f386, - 0x002ab148, - 0x00226589, - 0x0021efc8, - 0x0026714b, - 0x002b3488, - 0x0021e084, - 0x00299f06, - 0x003add86, - 0x002d2189, - 0x003ac287, - 0x00257308, - 0x003abd46, - 0x0021a404, - 0x002bfc85, - 0x002ba048, - 0x002ba90a, - 0x002bb308, - 0x002c0346, - 0x00293b0a, - 0x00287448, - 0x002c3408, - 0x002c4848, - 0x002c52c6, - 0x002c6ec6, - 0x002e5ccc, - 0x002c7390, - 0x0028cb85, - 0x00200888, - 0x002f8290, - 0x00200890, - 0x002642ce, - 0x002e594e, - 0x002e5954, - 0x0030d38f, - 0x0030d746, - 0x00335b51, - 0x002c9813, - 0x002c9c88, - 0x0031df85, - 0x00355088, - 0x0020e005, - 0x0022d0cc, - 0x0022ac09, - 0x00372ec9, - 0x00215f87, - 0x0023ff09, - 0x00215147, - 0x002ddfc6, - 0x0031a307, - 0x0024a985, - 0x0030ee43, - 0x002526c9, - 0x00229cc9, - 0x00370dc3, - 0x00219d04, - 0x0032a14d, - 0x003a524f, - 0x002fb105, - 0x00316c86, - 0x002101c7, - 0x0033ba47, - 0x00285286, - 0x0028528b, - 0x0029bb05, - 0x003a85c6, - 0x0020be87, - 0x00271409, - 0x0039b946, - 0x0020a7c5, - 0x002310cb, - 0x003306c6, - 0x00248285, - 0x0027d508, - 0x002b1008, - 0x002b224c, - 0x002b2250, - 0x002c57c9, - 0x002ce687, - 0x002f730b, - 0x002cfa86, - 0x002d078a, - 0x002d1f0b, - 0x002d290a, - 0x002d2b86, - 0x002d3ac5, - 0x0024f3c6, - 0x00278648, - 0x0021604a, - 0x00364f1c, - 0x002dab4c, - 0x002dae48, - 0x00215a05, - 0x002de147, - 0x002a5b86, - 0x003969c5, - 0x0021ec46, - 0x00285448, - 0x002af647, - 0x002a5e48, - 0x0034020a, - 0x0030ca0c, - 0x0030cc89, - 0x003a88c7, - 0x00203584, - 0x00243b06, - 0x0036f2ca, - 0x00347645, - 0x0036620c, - 0x00367288, - 0x0034c2c8, - 0x0020460c, - 0x0020f7cc, - 0x002113c9, - 0x00211607, - 0x002caf4c, - 0x00373544, - 0x0037118a, - 0x0038d8cc, - 0x002729cb, - 0x0023238b, - 0x00232f46, - 0x0023d087, - 0x00231b07, - 0x00231b0f, - 0x002f38d1, - 0x003aa9d2, - 0x0023d50d, - 0x0023d50e, - 0x0023d84e, - 0x0030d548, - 0x0030d552, - 0x002408c8, - 0x002f9fc7, - 0x0024870a, - 0x00209b88, - 0x00282645, - 0x002f07ca, - 0x002213c7, - 0x002e3c04, - 0x0023bf43, - 0x002e64c5, - 0x002b5887, - 0x002ff507, - 0x002b0a8e, - 0x0039bf4d, - 0x0039da89, - 0x00211945, - 0x002e9e43, - 0x00251e46, - 0x00363445, - 0x00367748, - 0x002ea589, - 0x0028bcc5, - 0x00372a0f, - 0x002c9687, - 0x00369605, - 0x003a214a, - 0x002b6c46, - 0x00218409, - 0x002eba4c, - 0x002ed649, - 0x00202446, - 0x002a3a4c, - 0x002edc06, - 0x002f0b48, - 0x002f0d46, - 0x00239b06, - 0x0024e684, - 0x0025ad43, - 0x002eaf8a, - 0x00365711, - 0x00238e8a, - 0x00271ac5, - 0x002be207, - 0x00250b07, - 0x002e0084, - 0x0038b58b, - 0x00314a08, - 0x002adb46, - 0x002d4345, - 0x00261004, - 0x00258789, - 0x00399844, - 0x0033bf07, - 0x002ed845, - 0x002ed847, - 0x00319c45, - 0x002971c3, - 0x002f9e88, - 0x0032498a, - 0x0021c603, - 0x0021c60a, - 0x00270106, - 0x0037278f, - 0x00246949, - 0x0025bb90, - 0x00354488, - 0x002c0bc9, - 0x00295307, - 0x002d854f, - 0x0022c504, - 0x002cb304, - 0x0021b5c6, - 0x00273386, - 0x0031198a, - 0x002e2e46, - 0x003466c7, - 0x002f7688, - 0x002f7887, - 0x002f7a47, - 0x00348e4a, - 0x002f9ccb, - 0x003860c5, - 0x003aa608, - 0x0020b003, - 0x0023a24c, - 0x0038bd8f, - 0x0026bbcd, - 0x0024aac7, - 0x0039dbc9, - 0x00262607, - 0x0025ae08, - 0x00381c0c, - 0x0026b2c8, - 0x0024fec8, - 0x00309b8e, - 0x0031cc54, - 0x0031d164, - 0x0033eb0a, - 0x0035630b, - 0x00215204, - 0x00215209, - 0x002f4508, - 0x00243cc5, - 0x0025200a, - 0x00375e47, - 0x0020c744, - 0x00341d03, - 0x0022f303, - 0x00238c04, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0024af03, - 0x0021e083, - 0x002c7386, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0021e703, - 0x002050c2, - 0x00341d03, - 0x00202682, - 0x0022f303, - 0x00238c04, - 0x00215403, - 0x002d60c3, - 0x0024af03, - 0x002c7386, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x00623d08, - 0x00200302, - 0x00215e02, - 0x00202682, - 0x0022f303, - 0x00206382, - 0x00200842, - 0x0037c544, - 0x0020f5c4, - 0x00226d02, - 0x00212284, - 0x00200282, - 0x00202d43, - 0x0021e703, - 0x00232f46, - 0x00213ac2, - 0x00202402, - 0x0020f082, - 0x39e00a83, - 0x3a2053c3, - 0x00051846, - 0x00051846, - 0x0021db44, - 0x0012208c, - 0x0000f44c, - 0x0007fd0d, - 0x000d58c7, - 0x0001b8c8, - 0x00025608, - 0x001a4b8a, - 0x3af01e05, - 0x00101e09, - 0x00120b48, - 0x00169bca, - 0x00170e4e, - 0x000e7144, - 0x0016d488, - 0x0007c0c7, - 0x00013947, - 0x0016c489, - 0x0018d647, - 0x00125908, - 0x001a3d49, - 0x000d5405, - 0x00052f0e, - 0x000a2f8d, - 0x00120948, - 0x3b265246, - 0x00060947, - 0x00061407, - 0x00068b47, - 0x0006f487, - 0x0000d142, - 0x0000b5c7, - 0x0013b7cc, - 0x000ec787, - 0x000920c6, - 0x0009d709, - 0x000a0188, - 0x00009f82, - 0x00000842, - 0x0019834b, - 0x00014989, - 0x00043589, - 0x00022fc8, - 0x000aa4c2, - 0x00078f09, - 0x0000b309, - 0x000c8348, - 0x000c8947, - 0x000ca309, - 0x000ccec5, - 0x000cd410, - 0x0015e806, - 0x000546c5, - 0x0001d58d, - 0x0018d206, - 0x000d6887, - 0x000dbd18, - 0x0004f9c8, - 0x001a23ca, - 0x0004128d, - 0x00002542, - 0x0006a4c6, - 0x0008acc8, - 0x000c49c8, - 0x00179489, - 0x0017f7c8, - 0x0004cf0e, - 0x000e3b05, - 0x0004d548, - 0x00001142, - 0x00141846, - 0x00003c02, - 0x000002c1, - 0x3b6dc584, - 0x3ba8d103, - 0x00000101, - 0x00010746, - 0x00000101, - 0x00000001, - 0x00010746, - 0x014e2305, - 0x002451c4, - 0x0022f303, - 0x00246ec4, - 0x0037c544, - 0x0024a143, - 0x00226445, - 0x0021e7c3, - 0x00226a03, - 0x002eb585, - 0x0021d903, - 0x3ca2f303, - 0x00215403, - 0x002d60c3, - 0x00200041, - 0x0021e083, - 0x0020f5c4, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x002169c3, - 0x001795c8, - 0x002050c2, - 0x00341d03, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x00200842, - 0x0037c544, - 0x0024af03, - 0x0021e083, - 0x0024a143, - 0x00201543, - 0x00202d43, - 0x0021d903, - 0x001795c8, - 0x0038bb02, - 0x00002682, - 0x3da28382, - 0x00398f08, - 0x00228806, - 0x002b6e46, - 0x00228187, - 0x3de07642, - 0x3e354308, - 0x00207b8a, - 0x002603c8, - 0x002001c2, - 0x00398b89, - 0x00386107, - 0x00218f46, - 0x00207549, - 0x0025a6c4, - 0x00366a86, - 0x002e1b84, - 0x002777c4, - 0x00256809, - 0x0021cd06, - 0x0027f105, - 0x00213145, - 0x003a9ac7, - 0x002b3907, - 0x00213084, - 0x002283c6, - 0x002f1ac5, - 0x002dd0c5, - 0x002f6345, - 0x003917c7, - 0x003532c5, - 0x00305e09, - 0x00375205, - 0x00226984, - 0x002e1847, - 0x0024eb4e, - 0x00263f09, - 0x003198c9, - 0x00334486, - 0x0033e0c8, - 0x002a9f0b, - 0x002cc68c, - 0x00268dc6, - 0x00377807, - 0x0020ab85, - 0x0022b54a, - 0x0030bc49, - 0x0024e2c9, - 0x003a66c6, - 0x002eff85, - 0x0027b145, - 0x0035da89, - 0x002f64cb, - 0x0027bd86, - 0x00333746, - 0x0020d084, - 0x00287806, - 0x002a40c8, - 0x00200006, - 0x003a4f86, - 0x00208348, - 0x002094c7, - 0x0020a909, - 0x0020b945, - 0x001795c8, - 0x002138c4, - 0x0037b384, - 0x00211205, - 0x00395089, - 0x00225a87, - 0x00225a8b, - 0x00227b8a, - 0x0022b245, - 0x3e60c3c2, - 0x00229647, - 0x3ea2ce88, - 0x00283347, - 0x0021d045, - 0x0031ea4a, - 0x00002682, - 0x0020414b, - 0x002a87ca, - 0x003a8706, - 0x003a3f83, - 0x002fffcd, - 0x0035dc8c, - 0x0035f60d, - 0x0037f3c5, - 0x00238945, - 0x00252547, - 0x00206389, - 0x00207a86, - 0x002e2cc5, - 0x0028c088, - 0x00287703, - 0x002e2b08, - 0x00287708, - 0x002b7e07, - 0x00355388, - 0x0031f209, - 0x002379c7, - 0x003211c7, - 0x002e2188, - 0x0024a184, - 0x0024a187, - 0x00266a08, - 0x00203206, - 0x0039990f, - 0x002306c7, - 0x002d0a46, - 0x0025af85, - 0x00219e83, - 0x00368207, - 0x00339f03, - 0x00245986, - 0x00247a46, - 0x00248e86, - 0x0028a305, - 0x00264d03, - 0x00387f08, - 0x00364889, - 0x0037d00b, - 0x00249008, - 0x0024bbc5, - 0x0024c8c5, - 0x3ee3c9c2, - 0x0031a3c9, - 0x0037c5c7, - 0x003a8645, - 0x00256707, - 0x002582c6, - 0x0035a245, - 0x0036328b, - 0x00259e84, - 0x0025ff85, - 0x002600c7, - 0x00275e86, - 0x002762c5, - 0x002814c7, - 0x00282247, - 0x002700c4, - 0x0028610a, - 0x002865c8, - 0x002e8e49, - 0x0026f2c5, - 0x00221786, - 0x002a428a, - 0x002c2cc6, - 0x00265507, - 0x00314d0d, - 0x00226049, - 0x002e9905, - 0x00322dc7, - 0x002e7308, - 0x002e7988, - 0x002e5487, - 0x002c9e46, - 0x00217947, - 0x00247403, - 0x00337e44, - 0x00357e05, - 0x0038c407, - 0x003911c9, - 0x0022f6c8, - 0x002a7d45, - 0x00362e04, - 0x002d14c5, - 0x0024600d, - 0x00207682, - 0x002d1d86, - 0x0026a406, - 0x0034c68a, - 0x0035d1c6, - 0x0036f205, - 0x00315505, - 0x00315507, - 0x0037a84c, - 0x0027408a, - 0x00287146, - 0x002c6dc5, - 0x00287646, - 0x00287987, - 0x002890c6, - 0x0028a20c, - 0x00207689, - 0x3f210bc7, - 0x0028c645, - 0x0028c646, - 0x0028cd88, - 0x002aba05, - 0x0029cac5, - 0x0029cd08, - 0x0029cf0a, - 0x3f66ec82, - 0x3fa0e9c2, - 0x0037e005, - 0x002d09c3, - 0x0030f008, - 0x00218543, - 0x0029d184, - 0x0021854b, - 0x002aa2c8, - 0x002a0748, - 0x3ff1e6c9, - 0x002a2a09, - 0x002a2e86, - 0x002a4a88, - 0x002a4c89, - 0x002a5686, - 0x002a5805, - 0x00362646, - 0x002a6489, - 0x0022bc47, - 0x00248bc6, - 0x00230ac7, - 0x00207907, - 0x00234884, - 0x402f8b89, - 0x002bf008, - 0x00354208, - 0x002440c7, - 0x002b9cc6, - 0x002fb309, - 0x00326347, - 0x0037e4ca, - 0x0032c988, - 0x003746c7, - 0x0024e746, - 0x0038104a, - 0x0027d248, - 0x00269e85, - 0x00230fc5, - 0x002b4d07, - 0x002c5bc9, - 0x002cea4b, - 0x002fa3c8, - 0x00375289, - 0x00249807, - 0x003ac80c, - 0x002ab5cc, - 0x002ab8ca, - 0x002abb4c, - 0x002b6dc8, - 0x002b6fc8, - 0x002b71c4, - 0x002b7589, - 0x002b77c9, - 0x002b7a0a, - 0x002b7c89, - 0x002b7fc7, - 0x003ae4cc, - 0x00240cc6, - 0x00270408, - 0x002c2d86, - 0x00386b06, - 0x002e9807, - 0x00264108, - 0x00253fcb, - 0x00283207, - 0x002f34c9, - 0x00247049, - 0x00256247, - 0x002e1dc4, - 0x0035a707, - 0x00374c06, - 0x00216b86, - 0x002ad045, - 0x002c7b48, - 0x0020df04, - 0x0020df06, - 0x00273f4b, - 0x0029aa49, - 0x002e5606, - 0x00376e49, - 0x00391946, - 0x002fe088, - 0x00203b43, - 0x0020bdc5, - 0x00206589, - 0x0020e585, - 0x00304844, - 0x00275446, - 0x00268a05, - 0x002d6646, - 0x002fb8c7, - 0x00335106, - 0x002914cb, - 0x00374007, - 0x00352f06, - 0x00381606, - 0x003a9b86, - 0x00213049, - 0x00221a8a, - 0x00333485, - 0x0032990d, - 0x0029d006, - 0x003a25c6, - 0x002db246, - 0x00218205, - 0x002cd707, - 0x00295d87, - 0x002a77ce, - 0x0021e083, - 0x002b9c89, - 0x00315249, - 0x0022b947, - 0x0027aa47, - 0x002a21c5, - 0x0032bac5, - 0x406638cf, - 0x002c0e07, - 0x002c0fc8, - 0x002c15c4, - 0x002c1bc6, - 0x40a430c2, - 0x002c5546, - 0x002c7386, - 0x0025430e, - 0x002e294a, - 0x00229146, - 0x00391f8a, - 0x00206189, - 0x00313245, - 0x00393808, - 0x003ac6c6, - 0x00319448, - 0x00329608, - 0x0025b70b, - 0x00228285, - 0x00353348, - 0x0020848c, - 0x0021cf07, - 0x00248646, - 0x00268848, - 0x00366d08, - 0x40e0bd82, - 0x00325d4b, - 0x0036d889, - 0x003668c9, - 0x0020ad07, - 0x0038d048, - 0x4120bb48, - 0x0020fe8b, - 0x00222e49, - 0x0037a2cd, - 0x00224488, - 0x00230448, - 0x41602742, - 0x003b0584, - 0x41a048c2, - 0x002ed386, - 0x41e022c2, - 0x0021a44a, - 0x00341946, - 0x00224808, - 0x0033e3c8, - 0x002d7686, - 0x00270f86, - 0x002e1306, - 0x003676c5, - 0x0023afc4, - 0x422fe004, - 0x00338a46, - 0x0023a907, - 0x426cba47, - 0x002edfcb, - 0x0024ef09, - 0x0023898a, - 0x00253bc4, - 0x00315648, - 0x0024898d, - 0x002d9909, - 0x002d9b48, - 0x002da1c9, - 0x002dbd04, - 0x00207444, - 0x0027de05, - 0x0031ae8b, - 0x002aa246, - 0x00338885, - 0x0021d1c9, - 0x00228488, - 0x00298b84, - 0x0022b6c9, - 0x00373f45, - 0x002b3948, - 0x00321887, - 0x00319cc8, - 0x0027e3c6, - 0x00229507, - 0x0028b449, - 0x00231249, - 0x00248305, - 0x00342105, - 0x42a2a902, - 0x002e1604, - 0x002fd105, - 0x0029c246, - 0x00338205, - 0x0024c987, - 0x00269685, - 0x00269704, - 0x00334546, - 0x002e2d47, - 0x00243106, - 0x002ffc85, - 0x00329e48, - 0x00228a05, - 0x0035e9c7, - 0x00399c89, - 0x0029ab8a, - 0x00380387, - 0x0038038c, - 0x0027f0c6, - 0x0022f4c9, - 0x00339545, - 0x003579c8, - 0x002105c3, - 0x002105c5, - 0x00236545, - 0x00397147, - 0x42e12a42, - 0x00238587, - 0x002e2606, - 0x002f8ac6, - 0x002ed4c6, - 0x00366c46, - 0x002cccc8, - 0x003551c5, - 0x002d0b07, - 0x002d0b0d, - 0x0023bf43, - 0x00321105, - 0x003a1f07, - 0x00385348, - 0x003a1ac5, - 0x0022af88, - 0x00239806, - 0x00301fc7, - 0x002b92c5, - 0x00228306, - 0x002d7a85, - 0x002b658a, - 0x00311bc6, - 0x00302347, - 0x002c4c45, - 0x002f8647, - 0x002fab44, - 0x003047c6, - 0x00336485, - 0x0021cb0b, - 0x00374a89, - 0x00242dca, - 0x00248388, - 0x00350d08, - 0x003566cc, - 0x00358b87, - 0x003635c8, - 0x00384948, - 0x0038db85, - 0x002e438a, - 0x002e9e49, - 0x43202842, - 0x00202bc6, - 0x002039c4, - 0x002d82c9, - 0x00359989, - 0x00223847, - 0x0033b087, - 0x003473c9, - 0x00397708, - 0x0039770f, - 0x0026e4c6, - 0x0023e34b, - 0x002eb3c5, - 0x002eb3c7, - 0x002eb809, - 0x00218686, - 0x0022b647, - 0x003aad45, - 0x00233844, - 0x002623c6, - 0x002077c4, - 0x00307f47, - 0x002eda08, - 0x436efe88, - 0x002f0485, - 0x002f05c7, - 0x00262009, - 0x002a1ec4, - 0x003ab008, - 0x43b70388, - 0x002e0084, - 0x00234188, - 0x002e5884, - 0x002140c9, - 0x002257c5, - 0x43e00142, - 0x0026e505, - 0x002216c5, - 0x0029e648, - 0x00236a07, - 0x44202882, - 0x002c3085, - 0x00250886, - 0x00258146, - 0x002e15c8, - 0x002e37c8, - 0x003381c6, - 0x002ea1c6, - 0x00227809, - 0x002f8a06, - 0x002c930b, - 0x00289d05, - 0x00209ac6, - 0x00219f08, - 0x00391d46, - 0x00326686, - 0x0021e40a, - 0x00267c4a, - 0x00288805, - 0x002208c7, - 0x00345e46, - 0x446000c2, - 0x003a2047, - 0x0035e385, - 0x002a4204, - 0x002a4205, - 0x00253ac6, - 0x00274947, - 0x00203745, - 0x00264184, - 0x00256448, - 0x00326745, - 0x00286907, - 0x0028d405, - 0x00219805, - 0x00245344, - 0x00299089, - 0x002f1908, - 0x00376d06, - 0x00213b06, - 0x0038b286, - 0x44ba7148, - 0x002f4707, - 0x002f494d, - 0x002f504c, - 0x002f5649, - 0x002f5889, - 0x44f4fb82, - 0x003a6283, - 0x00203443, - 0x00374cc5, - 0x0038c50a, - 0x003171c6, - 0x002f8e45, - 0x002fbe04, - 0x002fbe0b, - 0x0030aa0c, - 0x0030b24c, - 0x0030b555, - 0x0030dc8d, - 0x0030f20f, - 0x0030f5d2, - 0x0030fa4f, - 0x0030fe12, - 0x00310293, - 0x0031074d, - 0x00310d0d, - 0x0031108e, - 0x0031154e, - 0x0031284c, - 0x00312bcc, - 0x0031300b, - 0x0031338e, - 0x00316452, - 0x00316f8c, - 0x00317890, - 0x0032e452, - 0x0032f30c, - 0x0032f9cd, - 0x0032fd0c, - 0x00332911, - 0x003338cd, - 0x00336a8d, - 0x0033708a, - 0x0033730c, - 0x00337c0c, - 0x0033858c, - 0x00338e0c, - 0x0033c0d3, - 0x0033c6d0, - 0x0033cad0, - 0x0033d24d, - 0x0033d84c, - 0x0033e849, - 0x00340a8d, - 0x00340dd3, - 0x00342f91, - 0x003433d3, - 0x00343a8f, - 0x00343e4c, - 0x0034414f, - 0x0034450d, - 0x00344b0f, - 0x00344ed0, - 0x0034594e, - 0x0034898e, - 0x003490d0, - 0x00349b8d, - 0x0034a50e, - 0x0034a88c, - 0x0034bd53, - 0x0034d9ce, - 0x0034e110, - 0x0034e511, - 0x0034e94f, - 0x0034ed13, - 0x0034f70d, - 0x0034fa4f, - 0x0034fe0e, - 0x00350550, - 0x00350949, - 0x00351690, - 0x00351ccf, - 0x0035234f, - 0x00352712, - 0x00353b0e, - 0x0035468d, - 0x0035558d, - 0x003558cd, - 0x003569cd, - 0x00356d0d, - 0x00357050, - 0x0035744b, - 0x00357bcc, - 0x00357f4c, - 0x0035824c, - 0x0035854e, - 0x00368d90, - 0x0036a992, - 0x0036ae0b, - 0x0036b88e, - 0x0036bc0e, - 0x0036c90e, - 0x0036dbcb, - 0x4536e196, - 0x0036ef0d, - 0x00370654, - 0x0037140d, - 0x00377355, - 0x0037874d, - 0x003790cf, - 0x003797cf, - 0x0037d2cf, - 0x0037d68e, - 0x0037ee0d, - 0x00383351, - 0x003862cc, - 0x003865cc, - 0x003868cb, - 0x00386e8c, - 0x0038770f, - 0x00387ad2, - 0x0038848d, - 0x0038944c, - 0x003898cc, - 0x00389bcd, - 0x00389f0f, - 0x0038a2ce, - 0x0038c1cc, - 0x0038c78d, - 0x0038cacb, - 0x0038e20c, - 0x0038e78d, - 0x0038eace, - 0x0038ef49, - 0x0038f9d3, - 0x0039064d, - 0x0039098d, - 0x00390f8c, - 0x0039140e, - 0x003927cf, - 0x00392b8c, - 0x00392e8d, - 0x003931cf, - 0x0039358c, - 0x00393b8c, - 0x00393f4c, - 0x0039424c, - 0x0039490d, - 0x00394c52, - 0x003952cc, - 0x003955cc, - 0x003958d1, - 0x00395d0f, - 0x003960cf, - 0x00396493, - 0x00399ece, - 0x0039a44f, - 0x0039a80c, - 0x4579ab4e, - 0x0039aecf, - 0x0039b296, - 0x0039bad2, - 0x0039d28c, - 0x0039de0f, - 0x0039e48d, - 0x0039e7cf, - 0x0039eb8c, - 0x0039ee8d, - 0x0039f1cd, - 0x003a0e4e, - 0x003a2c8c, - 0x003a2f8c, - 0x003a3290, - 0x003a5611, - 0x003a5a4b, - 0x003a5e8c, - 0x003a618e, - 0x003a7651, - 0x003a7a8e, - 0x003a7e0d, - 0x003ac48b, - 0x003ad48f, - 0x003adf14, - 0x00231302, - 0x00231302, - 0x002032c3, - 0x00231302, - 0x002032c3, - 0x00231302, - 0x00203982, - 0x00362685, - 0x003a734c, - 0x00231302, - 0x00231302, - 0x00203982, - 0x00231302, - 0x0028d205, - 0x0029ab85, - 0x00231302, - 0x00231302, - 0x00207f02, - 0x0028d205, - 0x0030e1c9, - 0x00342c8c, - 0x00231302, - 0x00231302, - 0x00231302, - 0x00231302, - 0x00362685, - 0x00231302, - 0x00231302, - 0x00231302, - 0x00231302, - 0x00207f02, - 0x0030e1c9, - 0x00231302, - 0x00231302, - 0x00231302, - 0x0029ab85, - 0x00231302, - 0x0029ab85, - 0x00342c8c, - 0x003a734c, - 0x00341d03, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0024a143, - 0x00202d43, - 0x00124f88, - 0x0004d044, - 0x0004a008, - 0x002050c2, - 0x46602682, - 0x0023f983, - 0x002230c4, - 0x002086c3, - 0x002d60c4, - 0x00232986, - 0x00206803, - 0x002eecc4, - 0x00269085, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x0025564a, - 0x00232f46, - 0x0036bf8c, - 0x001795c8, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0020c943, - 0x002c7386, - 0x0024a143, - 0x00202d43, - 0x0021e703, - 0x00007282, - 0x000d58c7, - 0x000b2708, - 0x0000e7ce, - 0x00084c92, - 0x000dd48b, - 0x47301e05, - 0x4771c74c, - 0x00115e0a, - 0x0003c250, - 0x0016d488, - 0x0007c0c7, - 0x000678cb, - 0x0016c489, - 0x0016d387, - 0x0018d647, - 0x0007bfc7, - 0x000187c6, - 0x00125908, - 0x47c1a0c6, - 0x000a2f8d, - 0x001157d0, - 0x480072c2, - 0x00120948, - 0x00069447, - 0x00090089, - 0x00051906, - 0x0000a402, - 0x000718ca, - 0x000f14c7, - 0x000ec787, - 0x0009d709, - 0x000a0188, - 0x00154d45, - 0x000da70e, - 0x00007fce, - 0x0001278f, - 0x00014989, - 0x00043589, - 0x0007254b, - 0x0013f48f, - 0x0009928c, - 0x000ee2cb, - 0x000c1888, - 0x000edec7, - 0x000f2bc8, - 0x0013decb, - 0x0014648c, - 0x0014d50c, - 0x0015024c, - 0x0016a1cd, - 0x00022fc8, - 0x00078f09, - 0x0017198b, - 0x000b9ec6, - 0x000c8b05, - 0x000cd410, - 0x0012af86, - 0x000546c5, - 0x000d6887, - 0x000ed1ca, - 0x000b258a, - 0x0006a4c6, - 0x00091e8d, - 0x000c49c8, - 0x0017f7c8, - 0x00045289, - 0x000ecd0c, - 0x001235c4, - 0x0005aa46, - 0x00002402, - 0x00141846, - 0x00003c02, - 0x000bdc05, - 0x00000301, - 0x00032c43, - 0x47b8ad46, - 0x0008d103, - 0x00000fc2, - 0x000920c4, - 0x000001c2, - 0x0001db44, - 0x00000102, - 0x000076c2, - 0x000054c2, - 0x00102e02, - 0x00000302, - 0x00101e02, - 0x00001a82, - 0x0001ed82, - 0x00039382, - 0x00027542, - 0x00003f42, - 0x00008f02, - 0x00015403, - 0x0001be02, - 0x00000482, - 0x0000bf82, - 0x000046c2, - 0x0000a6c2, - 0x00033ac2, - 0x00009f82, - 0x00000042, - 0x00002fc2, - 0x00000842, - 0x0004af03, - 0x000024c2, - 0x00000b42, - 0x000aa4c2, - 0x0000aa02, - 0x00012942, - 0x00005d42, - 0x00034342, - 0x000e5e02, - 0x00004502, - 0x00169282, - 0x00007342, - 0x0000b302, - 0x0004a143, - 0x00000602, - 0x0000bd82, - 0x00001542, - 0x00013c42, - 0x00048285, - 0x00009382, - 0x00053ec2, - 0x0003dc03, - 0x00002282, - 0x0000b082, - 0x00002542, - 0x00000802, - 0x000066c2, - 0x00002882, - 0x00001142, - 0x00002402, - 0x0006d2c7, - 0x002111c3, - 0x002050c2, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x00213783, - 0x0020c943, - 0x0024a143, - 0x00201543, - 0x00202d43, - 0x0028d143, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x0021e083, - 0x0024a143, - 0x00201543, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x00200041, - 0x0021e083, - 0x0024a143, - 0x00205bc3, - 0x00202d43, - 0x00341d03, - 0x0022f303, - 0x00215403, - 0x002a3dc3, - 0x00205c03, - 0x00236443, - 0x00280e03, - 0x0029e403, - 0x0025b183, - 0x002d60c3, - 0x0037c544, - 0x0024a143, - 0x00202d43, - 0x0021d903, - 0x0031fb04, - 0x00246203, - 0x00001383, - 0x00200103, - 0x0022c688, - 0x00325604, - 0x0031420a, - 0x00398246, - 0x003a3c07, - 0x0022220a, - 0x0026e389, - 0x003aa4c7, - 0x003afa8a, - 0x00341d03, - 0x0037e08b, - 0x002e93c9, - 0x0038b385, - 0x002c5387, - 0x00002682, - 0x0022f303, - 0x002ca0c7, - 0x00227545, - 0x002e1c89, - 0x00215403, - 0x00228086, - 0x002b6243, - 0x000e2683, - 0x000fae86, - 0x000528c6, - 0x00006787, - 0x00214506, - 0x0021ee05, - 0x0020ba07, - 0x00338c47, - 0x4a2d60c3, - 0x0032f547, - 0x0035a603, - 0x00386005, - 0x0037c544, - 0x00226d88, - 0x002a998c, - 0x002a8245, - 0x00366646, - 0x002c9f87, - 0x003a8987, - 0x00216787, - 0x00217148, - 0x0026becf, - 0x0026f005, - 0x0023fa87, - 0x0027d707, - 0x0029d2ca, - 0x0028bec9, - 0x002d0085, - 0x002d190a, - 0x000e51c6, - 0x002b62c5, - 0x0036b044, - 0x002d75c6, - 0x002e6587, - 0x0023bbc7, - 0x0020ae88, - 0x00203b45, - 0x00227446, - 0x003a4f05, - 0x00262505, - 0x0021c284, - 0x0033e2c7, - 0x002ccb0a, - 0x0020ef88, - 0x002ee906, - 0x0000c943, - 0x002ca385, - 0x00373306, - 0x003ae706, - 0x002545c6, - 0x0021e083, - 0x00388707, - 0x0027d685, - 0x0024a143, - 0x003aa74d, - 0x00201543, - 0x0020af88, - 0x00219d84, - 0x00276185, - 0x0029d1c6, - 0x00238246, - 0x002099c7, - 0x0029e447, - 0x00265ec5, - 0x00202d43, - 0x0032b1c7, - 0x0033a7c9, - 0x00259609, - 0x0026974a, - 0x002421c2, - 0x00385fc4, - 0x002d0684, - 0x0021de07, - 0x00238448, - 0x002d7d49, - 0x00320fc9, - 0x002d8907, - 0x0026eb06, - 0x000da486, - 0x002dbd04, - 0x002dc30a, - 0x002e0c08, - 0x002e11c9, - 0x00294906, - 0x002fef05, - 0x0020ee48, - 0x002bb40a, - 0x00215543, - 0x0031eec6, - 0x002d8a07, - 0x0020eb05, - 0x002e4145, - 0x00215b03, - 0x0024ffc4, - 0x00230f85, - 0x00282347, - 0x002f1a45, - 0x002fa286, - 0x001380c5, - 0x00229203, - 0x00229209, - 0x00275f4c, - 0x002a6a8c, - 0x002c2388, - 0x0028c8c7, - 0x002f0ec8, - 0x002f1fca, - 0x002f370b, - 0x002e9508, - 0x00366748, - 0x0035c846, - 0x0020b745, - 0x0030cfca, - 0x0020d345, - 0x00200142, - 0x002b9187, - 0x00261946, - 0x003511c5, - 0x0032c7c9, - 0x003857c5, - 0x002db345, - 0x00385bc9, - 0x00373186, - 0x0023a0c8, - 0x00263643, - 0x0020fb46, - 0x00275386, - 0x002fd845, - 0x002fd849, - 0x002ac109, - 0x00242507, - 0x000fd6c4, - 0x002fd6c7, - 0x00320ec9, - 0x00222405, - 0x0003b0c8, - 0x00341745, - 0x00348345, - 0x00215c09, - 0x002043c2, - 0x00262784, - 0x00203e02, - 0x002024c2, - 0x0033ef05, - 0x002d7148, - 0x00376685, - 0x002b8183, - 0x002b8185, - 0x002c5743, - 0x0020fb02, - 0x0033fcc4, - 0x002873c3, - 0x00204402, - 0x002e4a84, - 0x002d1603, - 0x00209082, - 0x002b8203, - 0x00288504, - 0x002b0f83, - 0x0023c744, - 0x002004c2, - 0x00272dc3, - 0x002066c3, - 0x00205442, - 0x002ea082, - 0x002abf49, - 0x00201d42, - 0x00285804, - 0x00207302, - 0x0020ecc4, - 0x0026eac4, - 0x002dfb44, - 0x00202402, - 0x0023df02, - 0x00211583, - 0x002f25c3, - 0x0023f084, - 0x002636c4, - 0x002ac304, - 0x002c0484, - 0x002fcc03, - 0x00334cc3, - 0x002e5144, - 0x002fe284, - 0x002fe586, - 0x0025a082, - 0x00202682, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x002050c2, - 0x00341d03, - 0x0022f303, - 0x00215403, - 0x00202b83, - 0x002d60c3, - 0x0037c544, - 0x002ac204, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0021e703, - 0x002dc944, - 0x00398ec3, - 0x002b0203, - 0x00343804, - 0x00341546, - 0x00200dc3, - 0x0021b203, - 0x0021bf03, - 0x002ab503, - 0x002761c3, - 0x0020c943, - 0x00226a05, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x002d5543, - 0x00231f83, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024af03, - 0x0024a143, - 0x002355c4, - 0x00202d43, - 0x002a5b84, - 0x002d73c5, - 0x00202682, - 0x00202a82, - 0x00200fc2, - 0x002032c2, - 0x00200282, - 0x0022f303, - 0x00238c04, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x002169c3, - 0x0021db44, - 0x001795c8, - 0x0022f303, - 0x00201543, - 0x002451c4, - 0x001795c8, - 0x0022f303, - 0x00246ec4, - 0x0037c544, - 0x00201543, - 0x00202742, - 0x00202d43, - 0x00226a03, - 0x002eb585, - 0x00200142, - 0x002fe3c3, - 0x002050c2, - 0x001795c8, - 0x00202682, - 0x00215403, - 0x002d60c3, - 0x00200842, - 0x00202d43, - 0x002050c2, - 0x003afc47, - 0x0025a6c5, - 0x0022dc84, - 0x00385246, - 0x00210ccb, - 0x002633c9, - 0x00366586, - 0x00334289, - 0x002b3088, - 0x00206a03, - 0x001795c8, - 0x0022ae47, - 0x00271c88, - 0x00322683, - 0x002395c4, - 0x002395cb, - 0x0026b845, - 0x003261c8, - 0x002fdc49, - 0x0025ad83, - 0x0022f303, - 0x00202ac8, - 0x002f0047, - 0x00322c86, - 0x00215403, - 0x00322787, - 0x002d60c3, - 0x002e32c6, - 0x0024af03, - 0x00230e47, - 0x0024b587, - 0x0038fe87, - 0x0033e245, - 0x002042c3, - 0x0020a34b, - 0x00376188, - 0x002261c8, - 0x0033a986, - 0x002e7d49, - 0x0031a007, - 0x002f9185, - 0x002d3e44, - 0x0026e5c8, - 0x00339fca, - 0x0033a209, - 0x002563c3, - 0x0027dc45, - 0x00288903, - 0x002ac506, - 0x002fa584, - 0x002fafc8, - 0x0039000b, - 0x0033edc5, - 0x002b2e06, - 0x002b4c05, - 0x002b5188, - 0x002b6407, - 0x0037c747, - 0x00313e07, - 0x00290744, - 0x00307907, - 0x00290746, - 0x0021e083, - 0x002bee08, - 0x0024ca03, - 0x002c5a08, - 0x002cd8c5, - 0x00208dc8, - 0x00236247, - 0x0024a143, - 0x00243f43, - 0x00286844, - 0x002ef887, - 0x00208743, - 0x0024b64b, - 0x00206683, - 0x0024c9c4, - 0x002eb608, - 0x00202d43, - 0x00317605, - 0x002e6485, - 0x00208cc6, - 0x00217a45, - 0x002cdc84, - 0x0020be42, - 0x002e1483, - 0x0036b0ca, - 0x0039b843, - 0x003a1909, - 0x00307606, - 0x00216548, - 0x00288046, - 0x00224c47, - 0x00330fc8, - 0x00317408, - 0x002f4883, - 0x00376743, - 0x00225009, - 0x002c92c3, - 0x00345d46, - 0x0025a346, - 0x00311846, - 0x0032ad89, - 0x002fd304, - 0x00211d43, - 0x00380f45, - 0x00308c49, - 0x00230f43, - 0x002fa144, - 0x003596c4, - 0x00213ac4, - 0x0028ea06, - 0x00246303, - 0x00246308, - 0x00257448, - 0x002ea846, - 0x002f8f8b, - 0x002f92c8, - 0x002f94cb, - 0x002fb609, - 0x002fad87, - 0x002fba88, - 0x002fc643, - 0x002cbc86, - 0x00211047, - 0x00291445, - 0x00348c89, - 0x002e768d, - 0x00216391, - 0x0022e985, - 0x002050c2, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002cb284, - 0x002d60c3, - 0x0024af03, - 0x0021e083, - 0x0024a143, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0020c943, - 0x0024a143, - 0x00202d43, - 0x00297fc3, - 0x002169c3, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0020c943, - 0x0024a143, - 0x00202d43, - 0x00213ac2, - 0x00200101, - 0x002050c2, - 0x00200001, - 0x0030f302, - 0x001795c8, - 0x00220a85, - 0x00200301, - 0x0002f303, - 0x00200381, - 0x00200081, - 0x00201101, - 0x003336c2, - 0x00339f04, - 0x00362603, - 0x00200641, - 0x00200a81, - 0x00200041, - 0x00200ec1, - 0x003a6547, - 0x0039028f, - 0x002c1d06, - 0x00200201, - 0x00268c86, - 0x00200181, - 0x00200601, - 0x0033580e, - 0x00200281, - 0x00202d43, - 0x00204401, - 0x0026a605, - 0x0020be42, - 0x00215a05, - 0x002002c1, - 0x002004c1, - 0x00200141, - 0x00200142, - 0x00200441, - 0x00200f41, - 0x00209f01, - 0x002018c1, - 0x00203c01, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x0021e7c3, - 0x0022f303, - 0x002d60c3, - 0x00088d48, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x014d3308, - 0x001795c8, - 0x00043944, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0024a143, - 0x00202d43, - 0x00201383, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002cb284, - 0x00202d43, - 0x00298545, - 0x00324984, - 0x0022f303, - 0x0024a143, - 0x00202d43, - 0x00202682, - 0x0022f303, - 0x00233789, - 0x00215403, - 0x00237f89, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x002dbb08, - 0x002180c7, - 0x002eb585, - 0x003afc47, - 0x00210ccb, - 0x00210808, - 0x00334289, - 0x0022ae47, - 0x00202ac8, - 0x002e32c6, - 0x0024b587, - 0x002261c8, - 0x0033a986, - 0x0031a007, - 0x0033a209, - 0x00386c49, - 0x002b2e06, - 0x002b3a85, - 0x002bee08, - 0x0024ca03, - 0x002c5a08, - 0x00236247, - 0x00208743, - 0x00328c47, - 0x00217a45, - 0x002d6f88, - 0x00375645, - 0x00376743, - 0x002793c9, - 0x002a4e87, - 0x002fa144, - 0x003596c4, - 0x002f8f8b, - 0x002f92c8, - 0x002fad87, - 0x0022f303, - 0x00215403, - 0x00205c03, - 0x00202d43, - 0x002153c3, - 0x002d60c3, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x002050c2, - 0x00202682, - 0x00202d43, - 0x001795c8, - 0x002050c2, - 0x00202682, - 0x00200fc2, - 0x00200842, - 0x0020a142, - 0x0024a143, - 0x00200282, - 0x002050c2, - 0x00341d03, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x00200fc2, - 0x002d60c3, - 0x0024af03, - 0x0021e083, - 0x00212284, - 0x0024a143, - 0x00218e83, - 0x00202d43, - 0x002fd304, - 0x0021d903, - 0x002d60c3, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00201543, - 0x00202d43, - 0x0039d747, - 0x0022f303, - 0x00397007, - 0x00374486, - 0x00206643, - 0x0020e383, - 0x002d60c3, - 0x002212c3, - 0x0037c544, - 0x0036f344, - 0x002cdd46, - 0x00200883, - 0x0024a143, - 0x00202d43, - 0x00298545, - 0x0020d284, - 0x00316303, - 0x00229c83, - 0x002b9187, - 0x00321805, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00204182, - 0x002c4b03, - 0x002acc83, - 0x00341d03, - 0x5462f303, - 0x00206382, - 0x00215403, - 0x002086c3, - 0x002d60c3, - 0x0037c544, - 0x00376343, - 0x0026f003, - 0x0021e083, - 0x00212284, - 0x54a04782, - 0x0024a143, - 0x00202d43, - 0x00225183, - 0x00223d03, - 0x00213ac2, - 0x0021d903, - 0x001795c8, - 0x002d60c3, - 0x0020c744, - 0x00341d03, - 0x00202682, - 0x0022f303, - 0x00238c04, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0024af03, - 0x00376b84, - 0x0020f5c4, - 0x002c7386, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0021e703, - 0x00261946, - 0x00018a4b, - 0x0001a0c6, - 0x0001d74a, - 0x000fc70a, - 0x001795c8, - 0x0020c844, - 0x0022f303, - 0x00341cc4, - 0x00215403, - 0x002453c4, - 0x002d60c3, - 0x00253a43, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x0032400b, - 0x0039f50a, - 0x003aebcc, - 0x002050c2, - 0x00202682, - 0x00200fc2, - 0x002a3645, - 0x0037c544, - 0x00204502, - 0x0021e083, - 0x0020f5c4, - 0x002032c2, - 0x00200282, - 0x00204842, - 0x00213ac2, - 0x00141d03, - 0x002eac89, - 0x0025a1c8, - 0x0037fb89, - 0x0024b3c9, - 0x0025980a, - 0x00261e0a, - 0x0020c342, - 0x0021ed82, - 0x00002682, - 0x0022f303, - 0x00207102, - 0x0023fc46, - 0x003521c2, - 0x00218882, - 0x003a1c0e, - 0x00272e0e, - 0x0027c7c7, - 0x0032a5c7, - 0x0026d382, - 0x00215403, - 0x002d60c3, - 0x002010c2, - 0x00200842, - 0x002343cf, - 0x00208e42, - 0x00234747, - 0x0023a587, - 0x0023adc7, - 0x0023bd4c, - 0x0033ab8c, - 0x00203184, - 0x0027dc4a, - 0x0024fa82, - 0x0020aa02, - 0x002ac684, - 0x002152c2, - 0x002b6dc2, - 0x0033adc4, - 0x00218f82, - 0x00212942, - 0x0033aa07, - 0x0037b645, - 0x00234342, - 0x00234344, - 0x00369282, - 0x002c8e08, - 0x0024a143, - 0x00397d88, - 0x00208542, - 0x00236f45, - 0x00378006, - 0x00202d43, - 0x00209382, - 0x002d7f87, - 0x0000be42, - 0x00269145, - 0x00209105, - 0x002025c2, - 0x0022f5c2, - 0x003148ca, - 0x00265d4a, - 0x0021e042, - 0x00323a44, - 0x00202782, - 0x00385e88, - 0x0020d482, - 0x002fcfc8, - 0x002f6b87, - 0x002f6e89, - 0x00209182, - 0x002fb845, - 0x0025a685, - 0x002bc0cb, - 0x002bce4c, - 0x00230cc8, - 0x002fbc08, - 0x0025a082, - 0x00209a82, - 0x002050c2, - 0x001795c8, - 0x00202682, - 0x0022f303, - 0x00200fc2, - 0x002032c2, - 0x00200282, - 0x00202d43, - 0x00204842, - 0x002050c2, - 0x56a02682, - 0x56ed60c3, - 0x0035ea43, - 0x00204502, - 0x0024a143, - 0x0035e943, - 0x00202d43, - 0x002d3c03, - 0x0026d3c6, - 0x016169c3, - 0x001795c8, - 0x000546c5, - 0x00064ec7, - 0x57600e82, - 0x57a001c2, - 0x57e00e02, - 0x582006c2, - 0x5860efc2, - 0x58a00302, - 0x58e02682, - 0x59205102, - 0x59622a82, - 0x59a03f42, - 0x00272e03, - 0x00211743, - 0x59e16b42, - 0x5a201202, - 0x00047407, - 0x5a62c702, - 0x5aa01702, - 0x5ae02f02, - 0x5b208202, - 0x5b602fc2, - 0x5ba00842, - 0x000bb1c5, - 0x00222fc3, - 0x0038d5c4, - 0x5be152c2, - 0x5c24b8c2, - 0x5c600682, - 0x0007874b, - 0x5ca00182, - 0x5d20ab02, - 0x5d604502, - 0x5da0a142, - 0x5de60542, - 0x5e204042, - 0x5e600542, - 0x5ea07342, - 0x5ee04782, - 0x5f2033c2, - 0x5f6032c2, - 0x5fa39202, - 0x5fe04282, - 0x60241a02, - 0x0006f0c4, - 0x002d7a43, - 0x60605902, - 0x60a19d02, - 0x60e06042, - 0x61201c02, - 0x61600282, - 0x61a04402, - 0x000d6b47, - 0x61e05042, - 0x62200b02, - 0x62604842, - 0x62a4d302, - 0x000ecd0c, - 0x62e1a602, - 0x63273802, - 0x63601602, - 0x63a000c2, - 0x63e03442, - 0x64259982, - 0x64600f42, - 0x64a06842, - 0x64e75702, - 0x652151c2, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x5cf76343, - 0x00281103, - 0x00226a84, - 0x0025a0c6, - 0x002e1543, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x00215e02, - 0x00215e02, - 0x00376343, - 0x00281103, - 0x65a2f303, - 0x00215403, - 0x0022c983, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x001795c8, - 0x00202682, - 0x0022f303, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x002451c4, - 0x00202682, - 0x0022f303, - 0x0024fb83, - 0x00215403, - 0x00246ec4, - 0x00205c03, - 0x002d60c3, - 0x0037c544, - 0x0024af03, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x00226a03, - 0x002eb585, - 0x00241543, - 0x0021d903, - 0x00202682, - 0x0022f303, - 0x00376343, - 0x0024a143, - 0x00202d43, - 0x002050c2, - 0x00341d03, - 0x001795c8, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x00232986, - 0x0037c544, - 0x0024af03, - 0x00212284, - 0x0024a143, - 0x00202d43, - 0x0021e703, - 0x0022f303, - 0x00215403, - 0x0024a143, - 0x00202d43, - 0x0022f303, - 0x0001a0c6, - 0x00215403, - 0x002d60c3, - 0x000cc086, - 0x0024a143, - 0x00202d43, - 0x00305c88, - 0x00309549, - 0x00317c89, - 0x0032c608, - 0x00379e48, - 0x00379e49, - 0x002050c2, - 0x00321645, - 0x0022de83, - 0x68202682, - 0x00215403, - 0x002d60c3, - 0x00262e87, - 0x002761c3, - 0x0021e083, - 0x0024a143, - 0x00205bc3, - 0x00212583, - 0x00201543, - 0x00202d43, - 0x00232f46, - 0x00200142, - 0x0021d903, - 0x001795c8, - 0x002050c2, - 0x00341d03, - 0x00202682, - 0x0022f303, - 0x00215403, - 0x002d60c3, - 0x0037c544, - 0x0021e083, - 0x0024a143, - 0x00202d43, - 0x002169c3, -} - -// children is the list of nodes' children, the parent's wildcard bit and the -// parent's node type. If a node has no children then their children index -// will be in the range [0, 6), depending on the wildcard bit and node type. -// -// The layout within the uint32, from MSB to LSB, is: -// [ 1 bits] unused -// [ 1 bits] wildcard bit -// [ 2 bits] node type -// [14 bits] high nodes index (exclusive) of children -// [14 bits] low nodes index (inclusive) of children -var children = [...]uint32{ - 0x00000000, - 0x10000000, - 0x20000000, - 0x40000000, - 0x50000000, - 0x60000000, - 0x01858610, - 0x0185c616, - 0x0187c617, - 0x019d861f, - 0x019ec676, - 0x01a0067b, - 0x01a10680, - 0x01a2c684, - 0x01a3068b, - 0x01a4868c, - 0x01a6c692, - 0x01a7069b, - 0x01a8869c, - 0x01a8c6a2, - 0x01aa86a3, - 0x01aac6aa, - 0x01af46ab, - 0x01af86bd, - 0x01b186be, - 0x01b2c6c6, - 0x01b306cb, - 0x01b606cc, - 0x01b8c6d8, - 0x01bb46e3, - 0x01bbc6ed, - 0x01bc06ef, - 0x01c546f0, - 0x01c68715, - 0x01c7c71a, - 0x01ca871f, - 0x01cb872a, - 0x01ccc72e, - 0x01cf0733, - 0x01e0873c, - 0x01e0c782, - 0x01e20783, - 0x01e34788, - 0x01e3c78d, - 0x01e4c78f, - 0x01e50793, - 0x01e68794, - 0x01eb079a, - 0x01ec47ac, - 0x01ec87b1, - 0x01ecc7b2, - 0x01ed47b3, - 0x01f107b5, - 0x61f147c4, - 0x01f287c5, - 0x01f387ca, - 0x01fec7ce, - 0x21ff07fb, - 0x01ff47fc, - 0x01ff87fd, - 0x21ffc7fe, - 0x220007ff, - 0x02034800, - 0x0203880d, - 0x0244880e, - 0x22498912, - 0x2249c926, - 0x024c4927, - 0x024cc931, - 0x224d0933, - 0x024d8934, - 0x224dc936, - 0x024e8937, - 0x224ec93a, - 0x0250893b, - 0x02520942, - 0x02524948, - 0x02534949, - 0x0253c94d, - 0x2257094f, - 0x0257495c, - 0x0258095d, - 0x025a8960, - 0x025c096a, - 0x025d4970, - 0x025fc975, - 0x0261c97f, - 0x0264c987, - 0x02674993, - 0x0267899d, - 0x0269c99e, - 0x026a09a7, - 0x026b49a8, - 0x026b89ad, - 0x026bc9ae, - 0x026dc9af, - 0x026ec9b7, - 0x027609bb, - 0x0277c9d8, - 0x027889df, - 0x0279c9e2, - 0x027b49e7, - 0x027c89ed, - 0x027e09f2, - 0x027f89f8, - 0x028109fe, - 0x0282ca04, - 0x02844a0b, - 0x028a4a11, - 0x028bca29, - 0x028d0a2f, - 0x02914a34, - 0x02994a45, - 0x029c0a65, - 0x029c4a70, - 0x029cca71, - 0x029eca73, - 0x029f0a7b, - 0x02a0ca7c, - 0x02a14a83, - 0x02a48a85, - 0x02a80a92, - 0x02a84aa0, - 0x02aa8aa1, - 0x02ac0aaa, - 0x02ae4ab0, - 0x02b04ab9, - 0x030c8ac1, - 0x030d4c32, - 0x030f4c35, - 0x032b0c3d, - 0x03380cac, - 0x033f0ce0, - 0x03448cfc, - 0x03530d12, - 0x03588d4c, - 0x035c4d62, - 0x036c0d71, - 0x0378cdb0, - 0x03824de3, - 0x038b4e09, - 0x03918e2d, - 0x03b50e46, - 0x03c08ed4, - 0x03cd4f02, - 0x03d20f35, - 0x03da8f48, - 0x03de4f6a, - 0x03e34f79, - 0x03eacf8d, - 0x63eb0fab, - 0x63eb4fac, - 0x63eb8fad, - 0x03f34fae, - 0x03f9cfcd, - 0x04018fe7, - 0x04091006, - 0x04111024, - 0x0417d044, - 0x042a905f, - 0x043010aa, - 0x643050c0, - 0x0439d0c1, - 0x044250e7, - 0x04471109, - 0x044d911c, - 0x04581136, - 0x04649160, - 0x046b1192, - 0x047c51ac, - 0x647c91f1, - 0x647cd1f2, - 0x048291f3, - 0x0488520a, - 0x04915221, - 0x04991245, - 0x049d5264, - 0x04ab9275, - 0x04aed2ae, - 0x04b4d2bb, - 0x04bc12d3, - 0x04c492f0, - 0x04c89312, - 0x04cf9322, - 0x64cfd33e, - 0x64d0133f, - 0x24d05340, - 0x04d1d341, - 0x04d39347, - 0x04d7d34e, - 0x04d8d35f, - 0x04da5363, - 0x04e1d369, - 0x04e31387, - 0x04e4938c, - 0x04e6d392, - 0x04e8139b, - 0x04e9d3a0, - 0x04ea13a7, - 0x04ea93a8, - 0x04ee53aa, - 0x04ef93b9, - 0x04f013be, - 0x04f093c0, - 0x04f0d3c2, - 0x04f313c3, - 0x04f553cc, - 0x04f6d3d5, - 0x04f713db, - 0x04f793dc, - 0x04f7d3de, - 0x04fd13df, - 0x04ff53f4, - 0x050153fd, - 0x05031405, - 0x0504140c, - 0x05055410, - 0x05059415, - 0x05061416, - 0x05075418, - 0x0508541d, - 0x05089421, - 0x050a5422, - 0x05935429, - 0x0596d64d, - 0x0599965b, - 0x059b1666, - 0x059d166c, - 0x659d5674, - 0x05a19675, - 0x05a21686, - 0x25a25688, - 0x25a29689, - 0x05a2d68a, - 0x05b4968b, - 0x25b4d6d2, - 0x25b556d3, - 0x25b5d6d5, - 0x25b696d7, - 0x05b6d6da, - 0x05b956db, - 0x05bbd6e5, - 0x05bc16ef, - 0x25bf96f0, - 0x05c056fe, - 0x0675d701, - 0x067619d7, - 0x067659d8, - 0x267699d9, - 0x0676d9da, - 0x267719db, - 0x067759dc, - 0x267819dd, - 0x067859e0, - 0x067899e1, - 0x2678d9e2, - 0x067919e3, - 0x267999e4, - 0x0679d9e6, - 0x067a19e7, - 0x267b19e8, - 0x067b59ec, - 0x067b99ed, - 0x067bd9ee, - 0x067c19ef, - 0x267c59f0, - 0x067c99f1, - 0x067cd9f2, - 0x067d19f3, - 0x067d59f4, - 0x267dd9f5, - 0x067e19f7, - 0x067e59f8, - 0x067e99f9, - 0x267ed9fa, - 0x067f19fb, - 0x267f99fc, - 0x267fd9fe, - 0x068199ff, - 0x06825a06, - 0x06865a09, - 0x06869a19, - 0x0688da1a, - 0x069b5a23, - 0x269bda6d, - 0x269c1a6f, - 0x269c5a70, - 0x069cda71, - 0x06aa9a73, - 0x06aadaaa, - 0x06ad9aab, - 0x06af9ab6, - 0x06b05abe, - 0x06b25ac1, - 0x06b5dac9, - 0x06df1ad7, - 0x06eadb7c, - 0x06ec1bab, - 0x06ef5bb0, - 0x06f21bbd, - 0x06f3dbc8, - 0x06f61bcf, - 0x06f79bd8, - 0x06f95bde, - 0x06fb9be5, - 0x06fc9bee, - 0x06ff9bf2, - 0x07015bfe, - 0x07221c05, - 0x07245c88, - 0x07265c91, - 0x07279c99, - 0x0728dc9e, - 0x072adca3, - 0x07351cab, - 0x0736dcd4, - 0x07389cdb, - 0x0738dce2, - 0x07391ce3, - 0x07395ce4, - 0x073a9ce5, - 0x073c9cea, - 0x073d5cf2, - 0x07405cf5, - 0x07485d01, - 0x07499d21, - 0x0749dd26, - 0x074b5d27, - 0x074c1d2d, - 0x074c5d30, - 0x074e1d31, - 0x0751dd38, - 0x07521d47, - 0x07541d48, - 0x07591d50, - 0x075a9d64, - 0x075fdd6a, - 0x07601d7f, - 0x07605d80, - 0x07649d81, - 0x07659d92, - 0x07691d96, - 0x076c1da4, - 0x077fddb0, - 0x07821dff, - 0x0784de08, - 0x07855e13, - 0x07859e15, - 0x07961e16, - 0x0796de58, - 0x07979e5b, - 0x07985e5e, - 0x07991e61, - 0x0799de64, - 0x079a9e67, - 0x079b5e6a, - 0x079c1e6d, - 0x079cde70, - 0x079d9e73, - 0x079e5e76, - 0x079f1e79, - 0x079fde7c, - 0x07a05e7f, - 0x07a11e81, - 0x07a1de84, - 0x07a29e87, - 0x07a35e8a, - 0x07a41e8d, - 0x07a4de90, - 0x07a59e93, - 0x07a65e96, - 0x07a71e99, - 0x07a7de9c, - 0x07a89e9f, - 0x07a95ea2, - 0x07aa1ea5, - 0x07aadea8, - 0x07ab9eab, - 0x07ac5eae, - 0x07ad1eb1, - 0x07ad9eb4, - 0x07ae5eb6, - 0x07af1eb9, - 0x07afdebc, - 0x07b09ebf, - 0x07b15ec2, - 0x07b21ec5, - 0x07b2dec8, - 0x07b39ecb, - 0x07b45ece, - 0x07b51ed1, - 0x07b5ded4, - 0x07b69ed7, - 0x07b75eda, - 0x07b7dedd, - 0x07b89edf, - 0x07b95ee2, - 0x07ba1ee5, - 0x07badee8, - 0x07bb9eeb, - 0x07bc5eee, - 0x07bd1ef1, - 0x07bddef4, - 0x07be1ef7, - 0x07bedef8, - 0x07c05efb, - 0x07c09f01, - 0x07c19f02, - 0x07c31f06, - 0x07c75f0c, - 0x07c89f1d, - 0x07cbdf22, - 0x07ccdf2f, - 0x07ce9f33, - 0x07d01f3a, - 0x27d45f40, - 0x07d49f51, - 0x07d75f52, -} - -// max children 417 (capacity 511) -// max text offset 27680 (capacity 32767) -// max text length 36 (capacity 63) -// max hi 8029 (capacity 16383) -// max lo 8018 (capacity 16383) diff --git a/vendor/golang.org/x/net/publicsuffix/table_test.go b/vendor/golang.org/x/net/publicsuffix/table_test.go deleted file mode 100644 index 8830b09..0000000 --- a/vendor/golang.org/x/net/publicsuffix/table_test.go +++ /dev/null @@ -1,16035 +0,0 @@ -// generated by go run gen.go; DO NOT EDIT - -package publicsuffix - -var rules = [...]string{ - "ac", - "com.ac", - "edu.ac", - "gov.ac", - "net.ac", - "mil.ac", - "org.ac", - "ad", - "nom.ad", - "ae", - "co.ae", - "net.ae", - "org.ae", - "sch.ae", - "ac.ae", - "gov.ae", - "mil.ae", - "aero", - "accident-investigation.aero", - "accident-prevention.aero", - "aerobatic.aero", - "aeroclub.aero", - "aerodrome.aero", - "agents.aero", - "aircraft.aero", - "airline.aero", - "airport.aero", - "air-surveillance.aero", - "airtraffic.aero", - "air-traffic-control.aero", - "ambulance.aero", - "amusement.aero", - "association.aero", - "author.aero", - "ballooning.aero", - "broker.aero", - "caa.aero", - "cargo.aero", - "catering.aero", - "certification.aero", - "championship.aero", - "charter.aero", - "civilaviation.aero", - "club.aero", - "conference.aero", - "consultant.aero", - "consulting.aero", - "control.aero", - "council.aero", - "crew.aero", - "design.aero", - "dgca.aero", - "educator.aero", - "emergency.aero", - "engine.aero", - "engineer.aero", - "entertainment.aero", - "equipment.aero", - "exchange.aero", - "express.aero", - "federation.aero", - "flight.aero", - "freight.aero", - "fuel.aero", - "gliding.aero", - "government.aero", - "groundhandling.aero", - "group.aero", - "hanggliding.aero", - "homebuilt.aero", - "insurance.aero", - "journal.aero", - "journalist.aero", - "leasing.aero", - "logistics.aero", - "magazine.aero", - "maintenance.aero", - "media.aero", - "microlight.aero", - "modelling.aero", - "navigation.aero", - "parachuting.aero", - "paragliding.aero", - "passenger-association.aero", - "pilot.aero", - "press.aero", - "production.aero", - "recreation.aero", - "repbody.aero", - "res.aero", - "research.aero", - "rotorcraft.aero", - "safety.aero", - "scientist.aero", - "services.aero", - "show.aero", - "skydiving.aero", - "software.aero", - "student.aero", - "trader.aero", - "trading.aero", - "trainer.aero", - "union.aero", - "workinggroup.aero", - "works.aero", - "af", - "gov.af", - "com.af", - "org.af", - "net.af", - "edu.af", - "ag", - "com.ag", - "org.ag", - "net.ag", - "co.ag", - "nom.ag", - "ai", - "off.ai", - "com.ai", - "net.ai", - "org.ai", - "al", - "com.al", - "edu.al", - "gov.al", - "mil.al", - "net.al", - "org.al", - "am", - "ao", - "ed.ao", - "gv.ao", - "og.ao", - "co.ao", - "pb.ao", - "it.ao", - "aq", - "ar", - "com.ar", - "edu.ar", - "gob.ar", - "gov.ar", - "int.ar", - "mil.ar", - "net.ar", - "org.ar", - "tur.ar", - "arpa", - "e164.arpa", - "in-addr.arpa", - "ip6.arpa", - "iris.arpa", - "uri.arpa", - "urn.arpa", - "as", - "gov.as", - "asia", - "at", - "ac.at", - "co.at", - "gv.at", - "or.at", - "au", - "com.au", - "net.au", - "org.au", - "edu.au", - "gov.au", - "asn.au", - "id.au", - "info.au", - "conf.au", - "oz.au", - "act.au", - "nsw.au", - "nt.au", - "qld.au", - "sa.au", - "tas.au", - "vic.au", - "wa.au", - "act.edu.au", - "nsw.edu.au", - "nt.edu.au", - "qld.edu.au", - "sa.edu.au", - "tas.edu.au", - "vic.edu.au", - "wa.edu.au", - "qld.gov.au", - "sa.gov.au", - "tas.gov.au", - "vic.gov.au", - "wa.gov.au", - "aw", - "com.aw", - "ax", - "az", - "com.az", - "net.az", - "int.az", - "gov.az", - "org.az", - "edu.az", - "info.az", - "pp.az", - "mil.az", - "name.az", - "pro.az", - "biz.az", - "ba", - "org.ba", - "net.ba", - "edu.ba", - "gov.ba", - "mil.ba", - "unsa.ba", - "unbi.ba", - "co.ba", - "com.ba", - "rs.ba", - "bb", - "biz.bb", - "co.bb", - "com.bb", - "edu.bb", - "gov.bb", - "info.bb", - "net.bb", - "org.bb", - "store.bb", - "tv.bb", - "*.bd", - "be", - "ac.be", - "bf", - "gov.bf", - "bg", - "a.bg", - "b.bg", - "c.bg", - "d.bg", - "e.bg", - "f.bg", - "g.bg", - "h.bg", - "i.bg", - "j.bg", - "k.bg", - "l.bg", - "m.bg", - "n.bg", - "o.bg", - "p.bg", - "q.bg", - "r.bg", - "s.bg", - "t.bg", - "u.bg", - "v.bg", - "w.bg", - "x.bg", - "y.bg", - "z.bg", - "0.bg", - "1.bg", - "2.bg", - "3.bg", - "4.bg", - "5.bg", - "6.bg", - "7.bg", - "8.bg", - "9.bg", - "bh", - "com.bh", - "edu.bh", - "net.bh", - "org.bh", - "gov.bh", - "bi", - "co.bi", - "com.bi", - "edu.bi", - "or.bi", - "org.bi", - "biz", - "bj", - "asso.bj", - "barreau.bj", - "gouv.bj", - "bm", - "com.bm", - "edu.bm", - "gov.bm", - "net.bm", - "org.bm", - "*.bn", - "bo", - "com.bo", - "edu.bo", - "gov.bo", - "gob.bo", - "int.bo", - "org.bo", - "net.bo", - "mil.bo", - "tv.bo", - "br", - "adm.br", - "adv.br", - "agr.br", - "am.br", - "arq.br", - "art.br", - "ato.br", - "b.br", - "bio.br", - "blog.br", - "bmd.br", - "cim.br", - "cng.br", - "cnt.br", - "com.br", - "coop.br", - "ecn.br", - "eco.br", - "edu.br", - "emp.br", - "eng.br", - "esp.br", - "etc.br", - "eti.br", - "far.br", - "flog.br", - "fm.br", - "fnd.br", - "fot.br", - "fst.br", - "g12.br", - "ggf.br", - "gov.br", - "imb.br", - "ind.br", - "inf.br", - "jor.br", - "jus.br", - "leg.br", - "lel.br", - "mat.br", - "med.br", - "mil.br", - "mp.br", - "mus.br", - "net.br", - "*.nom.br", - "not.br", - "ntr.br", - "odo.br", - "org.br", - "ppg.br", - "pro.br", - "psc.br", - "psi.br", - "qsl.br", - "radio.br", - "rec.br", - "slg.br", - "srv.br", - "taxi.br", - "teo.br", - "tmp.br", - "trd.br", - "tur.br", - "tv.br", - "vet.br", - "vlog.br", - "wiki.br", - "zlg.br", - "bs", - "com.bs", - "net.bs", - "org.bs", - "edu.bs", - "gov.bs", - "bt", - "com.bt", - "edu.bt", - "gov.bt", - "net.bt", - "org.bt", - "bv", - "bw", - "co.bw", - "org.bw", - "by", - "gov.by", - "mil.by", - "com.by", - "of.by", - "bz", - "com.bz", - "net.bz", - "org.bz", - "edu.bz", - "gov.bz", - "ca", - "ab.ca", - "bc.ca", - "mb.ca", - "nb.ca", - "nf.ca", - "nl.ca", - "ns.ca", - "nt.ca", - "nu.ca", - "on.ca", - "pe.ca", - "qc.ca", - "sk.ca", - "yk.ca", - "gc.ca", - "cat", - "cc", - "cd", - "gov.cd", - "cf", - "cg", - "ch", - "ci", - "org.ci", - "or.ci", - "com.ci", - "co.ci", - "edu.ci", - "ed.ci", - "ac.ci", - "net.ci", - "go.ci", - "asso.ci", - "xn--aroport-bya.ci", - "int.ci", - "presse.ci", - "md.ci", - "gouv.ci", - "*.ck", - "!www.ck", - "cl", - "gov.cl", - "gob.cl", - "co.cl", - "mil.cl", - "cm", - "co.cm", - "com.cm", - "gov.cm", - "net.cm", - "cn", - "ac.cn", - "com.cn", - "edu.cn", - "gov.cn", - "net.cn", - "org.cn", - "mil.cn", - "xn--55qx5d.cn", - "xn--io0a7i.cn", - "xn--od0alg.cn", - "ah.cn", - "bj.cn", - "cq.cn", - "fj.cn", - "gd.cn", - "gs.cn", - "gz.cn", - "gx.cn", - "ha.cn", - "hb.cn", - "he.cn", - "hi.cn", - "hl.cn", - "hn.cn", - "jl.cn", - "js.cn", - "jx.cn", - "ln.cn", - "nm.cn", - "nx.cn", - "qh.cn", - "sc.cn", - "sd.cn", - "sh.cn", - "sn.cn", - "sx.cn", - "tj.cn", - "xj.cn", - "xz.cn", - "yn.cn", - "zj.cn", - "hk.cn", - "mo.cn", - "tw.cn", - "co", - "arts.co", - "com.co", - "edu.co", - "firm.co", - "gov.co", - "info.co", - "int.co", - "mil.co", - "net.co", - "nom.co", - "org.co", - "rec.co", - "web.co", - "com", - "coop", - "cr", - "ac.cr", - "co.cr", - "ed.cr", - "fi.cr", - "go.cr", - "or.cr", - "sa.cr", - "cu", - "com.cu", - "edu.cu", - "org.cu", - "net.cu", - "gov.cu", - "inf.cu", - "cv", - "cw", - "com.cw", - "edu.cw", - "net.cw", - "org.cw", - "cx", - "gov.cx", - "ac.cy", - "biz.cy", - "com.cy", - "ekloges.cy", - "gov.cy", - "ltd.cy", - "name.cy", - "net.cy", - "org.cy", - "parliament.cy", - "press.cy", - "pro.cy", - "tm.cy", - "cz", - "de", - "dj", - "dk", - "dm", - "com.dm", - "net.dm", - "org.dm", - "edu.dm", - "gov.dm", - "do", - "art.do", - "com.do", - "edu.do", - "gob.do", - "gov.do", - "mil.do", - "net.do", - "org.do", - "sld.do", - "web.do", - "dz", - "com.dz", - "org.dz", - "net.dz", - "gov.dz", - "edu.dz", - "asso.dz", - "pol.dz", - "art.dz", - "ec", - "com.ec", - "info.ec", - "net.ec", - "fin.ec", - "k12.ec", - "med.ec", - "pro.ec", - "org.ec", - "edu.ec", - "gov.ec", - "gob.ec", - "mil.ec", - "edu", - "ee", - "edu.ee", - "gov.ee", - "riik.ee", - "lib.ee", - "med.ee", - "com.ee", - "pri.ee", - "aip.ee", - "org.ee", - "fie.ee", - "eg", - "com.eg", - "edu.eg", - "eun.eg", - "gov.eg", - "mil.eg", - "name.eg", - "net.eg", - "org.eg", - "sci.eg", - "*.er", - "es", - "com.es", - "nom.es", - "org.es", - "gob.es", - "edu.es", - "et", - "com.et", - "gov.et", - "org.et", - "edu.et", - "biz.et", - "name.et", - "info.et", - "net.et", - "eu", - "fi", - "aland.fi", - "*.fj", - "*.fk", - "fm", - "fo", - "fr", - "com.fr", - "asso.fr", - "nom.fr", - "prd.fr", - "presse.fr", - "tm.fr", - "aeroport.fr", - "assedic.fr", - "avocat.fr", - "avoues.fr", - "cci.fr", - "chambagri.fr", - "chirurgiens-dentistes.fr", - "experts-comptables.fr", - "geometre-expert.fr", - "gouv.fr", - "greta.fr", - "huissier-justice.fr", - "medecin.fr", - "notaires.fr", - "pharmacien.fr", - "port.fr", - "veterinaire.fr", - "ga", - "gb", - "gd", - "ge", - "com.ge", - "edu.ge", - "gov.ge", - "org.ge", - "mil.ge", - "net.ge", - "pvt.ge", - "gf", - "gg", - "co.gg", - "net.gg", - "org.gg", - "gh", - "com.gh", - "edu.gh", - "gov.gh", - "org.gh", - "mil.gh", - "gi", - "com.gi", - "ltd.gi", - "gov.gi", - "mod.gi", - "edu.gi", - "org.gi", - "gl", - "co.gl", - "com.gl", - "edu.gl", - "net.gl", - "org.gl", - "gm", - "gn", - "ac.gn", - "com.gn", - "edu.gn", - "gov.gn", - "org.gn", - "net.gn", - "gov", - "gp", - "com.gp", - "net.gp", - "mobi.gp", - "edu.gp", - "org.gp", - "asso.gp", - "gq", - "gr", - "com.gr", - "edu.gr", - "net.gr", - "org.gr", - "gov.gr", - "gs", - "gt", - "com.gt", - "edu.gt", - "gob.gt", - "ind.gt", - "mil.gt", - "net.gt", - "org.gt", - "*.gu", - "gw", - "gy", - "co.gy", - "com.gy", - "edu.gy", - "gov.gy", - "net.gy", - "org.gy", - "hk", - "com.hk", - "edu.hk", - "gov.hk", - "idv.hk", - "net.hk", - "org.hk", - "xn--55qx5d.hk", - "xn--wcvs22d.hk", - "xn--lcvr32d.hk", - "xn--mxtq1m.hk", - "xn--gmqw5a.hk", - "xn--ciqpn.hk", - "xn--gmq050i.hk", - "xn--zf0avx.hk", - "xn--io0a7i.hk", - "xn--mk0axi.hk", - "xn--od0alg.hk", - "xn--od0aq3b.hk", - "xn--tn0ag.hk", - "xn--uc0atv.hk", - "xn--uc0ay4a.hk", - "hm", - "hn", - "com.hn", - "edu.hn", - "org.hn", - "net.hn", - "mil.hn", - "gob.hn", - "hr", - "iz.hr", - "from.hr", - "name.hr", - "com.hr", - "ht", - "com.ht", - "shop.ht", - "firm.ht", - "info.ht", - "adult.ht", - "net.ht", - "pro.ht", - "org.ht", - "med.ht", - "art.ht", - "coop.ht", - "pol.ht", - "asso.ht", - "edu.ht", - "rel.ht", - "gouv.ht", - "perso.ht", - "hu", - "co.hu", - "info.hu", - "org.hu", - "priv.hu", - "sport.hu", - "tm.hu", - "2000.hu", - "agrar.hu", - "bolt.hu", - "casino.hu", - "city.hu", - "erotica.hu", - "erotika.hu", - "film.hu", - "forum.hu", - "games.hu", - "hotel.hu", - "ingatlan.hu", - "jogasz.hu", - "konyvelo.hu", - "lakas.hu", - "media.hu", - "news.hu", - "reklam.hu", - "sex.hu", - "shop.hu", - "suli.hu", - "szex.hu", - "tozsde.hu", - "utazas.hu", - "video.hu", - "id", - "ac.id", - "biz.id", - "co.id", - "desa.id", - "go.id", - "mil.id", - "my.id", - "net.id", - "or.id", - "sch.id", - "web.id", - "ie", - "gov.ie", - "il", - "ac.il", - "co.il", - "gov.il", - "idf.il", - "k12.il", - "muni.il", - "net.il", - "org.il", - "im", - "ac.im", - "co.im", - "com.im", - "ltd.co.im", - "net.im", - "org.im", - "plc.co.im", - "tt.im", - "tv.im", - "in", - "co.in", - "firm.in", - "net.in", - "org.in", - "gen.in", - "ind.in", - "nic.in", - "ac.in", - "edu.in", - "res.in", - "gov.in", - "mil.in", - "info", - "int", - "eu.int", - "io", - "com.io", - "iq", - "gov.iq", - "edu.iq", - "mil.iq", - "com.iq", - "org.iq", - "net.iq", - "ir", - "ac.ir", - "co.ir", - "gov.ir", - "id.ir", - "net.ir", - "org.ir", - "sch.ir", - "xn--mgba3a4f16a.ir", - "xn--mgba3a4fra.ir", - "is", - "net.is", - "com.is", - "edu.is", - "gov.is", - "org.is", - "int.is", - "it", - "gov.it", - "edu.it", - "abr.it", - "abruzzo.it", - "aosta-valley.it", - "aostavalley.it", - "bas.it", - "basilicata.it", - "cal.it", - "calabria.it", - "cam.it", - "campania.it", - "emilia-romagna.it", - "emiliaromagna.it", - "emr.it", - "friuli-v-giulia.it", - "friuli-ve-giulia.it", - "friuli-vegiulia.it", - "friuli-venezia-giulia.it", - "friuli-veneziagiulia.it", - "friuli-vgiulia.it", - "friuliv-giulia.it", - "friulive-giulia.it", - "friulivegiulia.it", - "friulivenezia-giulia.it", - "friuliveneziagiulia.it", - "friulivgiulia.it", - "fvg.it", - "laz.it", - "lazio.it", - "lig.it", - "liguria.it", - "lom.it", - "lombardia.it", - "lombardy.it", - "lucania.it", - "mar.it", - "marche.it", - "mol.it", - "molise.it", - "piedmont.it", - "piemonte.it", - "pmn.it", - "pug.it", - "puglia.it", - "sar.it", - "sardegna.it", - "sardinia.it", - "sic.it", - "sicilia.it", - "sicily.it", - "taa.it", - "tos.it", - "toscana.it", - "trentino-a-adige.it", - "trentino-aadige.it", - "trentino-alto-adige.it", - "trentino-altoadige.it", - "trentino-s-tirol.it", - "trentino-stirol.it", - "trentino-sud-tirol.it", - "trentino-sudtirol.it", - "trentino-sued-tirol.it", - "trentino-suedtirol.it", - "trentinoa-adige.it", - "trentinoaadige.it", - "trentinoalto-adige.it", - "trentinoaltoadige.it", - "trentinos-tirol.it", - "trentinostirol.it", - "trentinosud-tirol.it", - "trentinosudtirol.it", - "trentinosued-tirol.it", - "trentinosuedtirol.it", - "tuscany.it", - "umb.it", - "umbria.it", - "val-d-aosta.it", - "val-daosta.it", - "vald-aosta.it", - "valdaosta.it", - "valle-aosta.it", - "valle-d-aosta.it", - "valle-daosta.it", - "valleaosta.it", - "valled-aosta.it", - "valledaosta.it", - "vallee-aoste.it", - "valleeaoste.it", - "vao.it", - "vda.it", - "ven.it", - "veneto.it", - "ag.it", - "agrigento.it", - "al.it", - "alessandria.it", - "alto-adige.it", - "altoadige.it", - "an.it", - "ancona.it", - "andria-barletta-trani.it", - "andria-trani-barletta.it", - "andriabarlettatrani.it", - "andriatranibarletta.it", - "ao.it", - "aosta.it", - "aoste.it", - "ap.it", - "aq.it", - "aquila.it", - "ar.it", - "arezzo.it", - "ascoli-piceno.it", - "ascolipiceno.it", - "asti.it", - "at.it", - "av.it", - "avellino.it", - "ba.it", - "balsan.it", - "bari.it", - "barletta-trani-andria.it", - "barlettatraniandria.it", - "belluno.it", - "benevento.it", - "bergamo.it", - "bg.it", - "bi.it", - "biella.it", - "bl.it", - "bn.it", - "bo.it", - "bologna.it", - "bolzano.it", - "bozen.it", - "br.it", - "brescia.it", - "brindisi.it", - "bs.it", - "bt.it", - "bz.it", - "ca.it", - "cagliari.it", - "caltanissetta.it", - "campidano-medio.it", - "campidanomedio.it", - "campobasso.it", - "carbonia-iglesias.it", - "carboniaiglesias.it", - "carrara-massa.it", - "carraramassa.it", - "caserta.it", - "catania.it", - "catanzaro.it", - "cb.it", - "ce.it", - "cesena-forli.it", - "cesenaforli.it", - "ch.it", - "chieti.it", - "ci.it", - "cl.it", - "cn.it", - "co.it", - "como.it", - "cosenza.it", - "cr.it", - "cremona.it", - "crotone.it", - "cs.it", - "ct.it", - "cuneo.it", - "cz.it", - "dell-ogliastra.it", - "dellogliastra.it", - "en.it", - "enna.it", - "fc.it", - "fe.it", - "fermo.it", - "ferrara.it", - "fg.it", - "fi.it", - "firenze.it", - "florence.it", - "fm.it", - "foggia.it", - "forli-cesena.it", - "forlicesena.it", - "fr.it", - "frosinone.it", - "ge.it", - "genoa.it", - "genova.it", - "go.it", - "gorizia.it", - "gr.it", - "grosseto.it", - "iglesias-carbonia.it", - "iglesiascarbonia.it", - "im.it", - "imperia.it", - "is.it", - "isernia.it", - "kr.it", - "la-spezia.it", - "laquila.it", - "laspezia.it", - "latina.it", - "lc.it", - "le.it", - "lecce.it", - "lecco.it", - "li.it", - "livorno.it", - "lo.it", - "lodi.it", - "lt.it", - "lu.it", - "lucca.it", - "macerata.it", - "mantova.it", - "massa-carrara.it", - "massacarrara.it", - "matera.it", - "mb.it", - "mc.it", - "me.it", - "medio-campidano.it", - "mediocampidano.it", - "messina.it", - "mi.it", - "milan.it", - "milano.it", - "mn.it", - "mo.it", - "modena.it", - "monza-brianza.it", - "monza-e-della-brianza.it", - "monza.it", - "monzabrianza.it", - "monzaebrianza.it", - "monzaedellabrianza.it", - "ms.it", - "mt.it", - "na.it", - "naples.it", - "napoli.it", - "no.it", - "novara.it", - "nu.it", - "nuoro.it", - "og.it", - "ogliastra.it", - "olbia-tempio.it", - "olbiatempio.it", - "or.it", - "oristano.it", - "ot.it", - "pa.it", - "padova.it", - "padua.it", - "palermo.it", - "parma.it", - "pavia.it", - "pc.it", - "pd.it", - "pe.it", - "perugia.it", - "pesaro-urbino.it", - "pesarourbino.it", - "pescara.it", - "pg.it", - "pi.it", - "piacenza.it", - "pisa.it", - "pistoia.it", - "pn.it", - "po.it", - "pordenone.it", - "potenza.it", - "pr.it", - "prato.it", - "pt.it", - "pu.it", - "pv.it", - "pz.it", - "ra.it", - "ragusa.it", - "ravenna.it", - "rc.it", - "re.it", - "reggio-calabria.it", - "reggio-emilia.it", - "reggiocalabria.it", - "reggioemilia.it", - "rg.it", - "ri.it", - "rieti.it", - "rimini.it", - "rm.it", - "rn.it", - "ro.it", - "roma.it", - "rome.it", - "rovigo.it", - "sa.it", - "salerno.it", - "sassari.it", - "savona.it", - "si.it", - "siena.it", - "siracusa.it", - "so.it", - "sondrio.it", - "sp.it", - "sr.it", - "ss.it", - "suedtirol.it", - "sv.it", - "ta.it", - "taranto.it", - "te.it", - "tempio-olbia.it", - "tempioolbia.it", - "teramo.it", - "terni.it", - "tn.it", - "to.it", - "torino.it", - "tp.it", - "tr.it", - "trani-andria-barletta.it", - "trani-barletta-andria.it", - "traniandriabarletta.it", - "tranibarlettaandria.it", - "trapani.it", - "trentino.it", - "trento.it", - "treviso.it", - "trieste.it", - "ts.it", - "turin.it", - "tv.it", - "ud.it", - "udine.it", - "urbino-pesaro.it", - "urbinopesaro.it", - "va.it", - "varese.it", - "vb.it", - "vc.it", - "ve.it", - "venezia.it", - "venice.it", - "verbania.it", - "vercelli.it", - "verona.it", - "vi.it", - "vibo-valentia.it", - "vibovalentia.it", - "vicenza.it", - "viterbo.it", - "vr.it", - "vs.it", - "vt.it", - "vv.it", - "je", - "co.je", - "net.je", - "org.je", - "*.jm", - "jo", - "com.jo", - "org.jo", - "net.jo", - "edu.jo", - "sch.jo", - "gov.jo", - "mil.jo", - "name.jo", - "jobs", - "jp", - "ac.jp", - "ad.jp", - "co.jp", - "ed.jp", - "go.jp", - "gr.jp", - "lg.jp", - "ne.jp", - "or.jp", - "aichi.jp", - "akita.jp", - "aomori.jp", - "chiba.jp", - "ehime.jp", - "fukui.jp", - "fukuoka.jp", - "fukushima.jp", - "gifu.jp", - "gunma.jp", - "hiroshima.jp", - "hokkaido.jp", - "hyogo.jp", - "ibaraki.jp", - "ishikawa.jp", - "iwate.jp", - "kagawa.jp", - "kagoshima.jp", - "kanagawa.jp", - "kochi.jp", - "kumamoto.jp", - "kyoto.jp", - "mie.jp", - "miyagi.jp", - "miyazaki.jp", - "nagano.jp", - "nagasaki.jp", - "nara.jp", - "niigata.jp", - "oita.jp", - "okayama.jp", - "okinawa.jp", - "osaka.jp", - "saga.jp", - "saitama.jp", - "shiga.jp", - "shimane.jp", - "shizuoka.jp", - "tochigi.jp", - "tokushima.jp", - "tokyo.jp", - "tottori.jp", - "toyama.jp", - "wakayama.jp", - "yamagata.jp", - "yamaguchi.jp", - "yamanashi.jp", - "xn--4pvxs.jp", - "xn--vgu402c.jp", - "xn--c3s14m.jp", - "xn--f6qx53a.jp", - "xn--8pvr4u.jp", - "xn--uist22h.jp", - "xn--djrs72d6uy.jp", - "xn--mkru45i.jp", - "xn--0trq7p7nn.jp", - "xn--8ltr62k.jp", - "xn--2m4a15e.jp", - "xn--efvn9s.jp", - "xn--32vp30h.jp", - "xn--4it797k.jp", - "xn--1lqs71d.jp", - "xn--5rtp49c.jp", - "xn--5js045d.jp", - "xn--ehqz56n.jp", - "xn--1lqs03n.jp", - "xn--qqqt11m.jp", - "xn--kbrq7o.jp", - "xn--pssu33l.jp", - "xn--ntsq17g.jp", - "xn--uisz3g.jp", - "xn--6btw5a.jp", - "xn--1ctwo.jp", - "xn--6orx2r.jp", - "xn--rht61e.jp", - "xn--rht27z.jp", - "xn--djty4k.jp", - "xn--nit225k.jp", - "xn--rht3d.jp", - "xn--klty5x.jp", - "xn--kltx9a.jp", - "xn--kltp7d.jp", - "xn--uuwu58a.jp", - "xn--zbx025d.jp", - "xn--ntso0iqx3a.jp", - "xn--elqq16h.jp", - "xn--4it168d.jp", - "xn--klt787d.jp", - "xn--rny31h.jp", - "xn--7t0a264c.jp", - "xn--5rtq34k.jp", - "xn--k7yn95e.jp", - "xn--tor131o.jp", - "xn--d5qv7z876c.jp", - "*.kawasaki.jp", - "*.kitakyushu.jp", - "*.kobe.jp", - "*.nagoya.jp", - "*.sapporo.jp", - "*.sendai.jp", - "*.yokohama.jp", - "!city.kawasaki.jp", - "!city.kitakyushu.jp", - "!city.kobe.jp", - "!city.nagoya.jp", - "!city.sapporo.jp", - "!city.sendai.jp", - "!city.yokohama.jp", - "aisai.aichi.jp", - "ama.aichi.jp", - "anjo.aichi.jp", - "asuke.aichi.jp", - "chiryu.aichi.jp", - "chita.aichi.jp", - "fuso.aichi.jp", - "gamagori.aichi.jp", - "handa.aichi.jp", - "hazu.aichi.jp", - "hekinan.aichi.jp", - "higashiura.aichi.jp", - "ichinomiya.aichi.jp", - "inazawa.aichi.jp", - "inuyama.aichi.jp", - "isshiki.aichi.jp", - "iwakura.aichi.jp", - "kanie.aichi.jp", - "kariya.aichi.jp", - "kasugai.aichi.jp", - "kira.aichi.jp", - "kiyosu.aichi.jp", - "komaki.aichi.jp", - "konan.aichi.jp", - "kota.aichi.jp", - "mihama.aichi.jp", - "miyoshi.aichi.jp", - "nishio.aichi.jp", - "nisshin.aichi.jp", - "obu.aichi.jp", - "oguchi.aichi.jp", - "oharu.aichi.jp", - "okazaki.aichi.jp", - "owariasahi.aichi.jp", - "seto.aichi.jp", - "shikatsu.aichi.jp", - "shinshiro.aichi.jp", - "shitara.aichi.jp", - "tahara.aichi.jp", - "takahama.aichi.jp", - "tobishima.aichi.jp", - "toei.aichi.jp", - "togo.aichi.jp", - "tokai.aichi.jp", - "tokoname.aichi.jp", - "toyoake.aichi.jp", - "toyohashi.aichi.jp", - "toyokawa.aichi.jp", - "toyone.aichi.jp", - "toyota.aichi.jp", - "tsushima.aichi.jp", - "yatomi.aichi.jp", - "akita.akita.jp", - "daisen.akita.jp", - "fujisato.akita.jp", - "gojome.akita.jp", - "hachirogata.akita.jp", - "happou.akita.jp", - "higashinaruse.akita.jp", - "honjo.akita.jp", - "honjyo.akita.jp", - "ikawa.akita.jp", - "kamikoani.akita.jp", - "kamioka.akita.jp", - "katagami.akita.jp", - "kazuno.akita.jp", - "kitaakita.akita.jp", - "kosaka.akita.jp", - "kyowa.akita.jp", - "misato.akita.jp", - "mitane.akita.jp", - "moriyoshi.akita.jp", - "nikaho.akita.jp", - "noshiro.akita.jp", - "odate.akita.jp", - "oga.akita.jp", - "ogata.akita.jp", - "semboku.akita.jp", - "yokote.akita.jp", - "yurihonjo.akita.jp", - "aomori.aomori.jp", - "gonohe.aomori.jp", - "hachinohe.aomori.jp", - "hashikami.aomori.jp", - "hiranai.aomori.jp", - "hirosaki.aomori.jp", - "itayanagi.aomori.jp", - "kuroishi.aomori.jp", - "misawa.aomori.jp", - "mutsu.aomori.jp", - "nakadomari.aomori.jp", - "noheji.aomori.jp", - "oirase.aomori.jp", - "owani.aomori.jp", - "rokunohe.aomori.jp", - "sannohe.aomori.jp", - "shichinohe.aomori.jp", - "shingo.aomori.jp", - "takko.aomori.jp", - "towada.aomori.jp", - "tsugaru.aomori.jp", - "tsuruta.aomori.jp", - "abiko.chiba.jp", - "asahi.chiba.jp", - "chonan.chiba.jp", - "chosei.chiba.jp", - "choshi.chiba.jp", - "chuo.chiba.jp", - "funabashi.chiba.jp", - "futtsu.chiba.jp", - "hanamigawa.chiba.jp", - "ichihara.chiba.jp", - "ichikawa.chiba.jp", - "ichinomiya.chiba.jp", - "inzai.chiba.jp", - "isumi.chiba.jp", - "kamagaya.chiba.jp", - "kamogawa.chiba.jp", - "kashiwa.chiba.jp", - "katori.chiba.jp", - "katsuura.chiba.jp", - "kimitsu.chiba.jp", - "kisarazu.chiba.jp", - "kozaki.chiba.jp", - "kujukuri.chiba.jp", - "kyonan.chiba.jp", - "matsudo.chiba.jp", - "midori.chiba.jp", - "mihama.chiba.jp", - "minamiboso.chiba.jp", - "mobara.chiba.jp", - "mutsuzawa.chiba.jp", - "nagara.chiba.jp", - "nagareyama.chiba.jp", - "narashino.chiba.jp", - "narita.chiba.jp", - "noda.chiba.jp", - "oamishirasato.chiba.jp", - "omigawa.chiba.jp", - "onjuku.chiba.jp", - "otaki.chiba.jp", - "sakae.chiba.jp", - "sakura.chiba.jp", - "shimofusa.chiba.jp", - "shirako.chiba.jp", - "shiroi.chiba.jp", - "shisui.chiba.jp", - "sodegaura.chiba.jp", - "sosa.chiba.jp", - "tako.chiba.jp", - "tateyama.chiba.jp", - "togane.chiba.jp", - "tohnosho.chiba.jp", - "tomisato.chiba.jp", - "urayasu.chiba.jp", - "yachimata.chiba.jp", - "yachiyo.chiba.jp", - "yokaichiba.chiba.jp", - "yokoshibahikari.chiba.jp", - "yotsukaido.chiba.jp", - "ainan.ehime.jp", - "honai.ehime.jp", - "ikata.ehime.jp", - "imabari.ehime.jp", - "iyo.ehime.jp", - "kamijima.ehime.jp", - "kihoku.ehime.jp", - "kumakogen.ehime.jp", - "masaki.ehime.jp", - "matsuno.ehime.jp", - "matsuyama.ehime.jp", - "namikata.ehime.jp", - "niihama.ehime.jp", - "ozu.ehime.jp", - "saijo.ehime.jp", - "seiyo.ehime.jp", - "shikokuchuo.ehime.jp", - "tobe.ehime.jp", - "toon.ehime.jp", - "uchiko.ehime.jp", - "uwajima.ehime.jp", - "yawatahama.ehime.jp", - "echizen.fukui.jp", - "eiheiji.fukui.jp", - "fukui.fukui.jp", - "ikeda.fukui.jp", - "katsuyama.fukui.jp", - "mihama.fukui.jp", - "minamiechizen.fukui.jp", - "obama.fukui.jp", - "ohi.fukui.jp", - "ono.fukui.jp", - "sabae.fukui.jp", - "sakai.fukui.jp", - "takahama.fukui.jp", - "tsuruga.fukui.jp", - "wakasa.fukui.jp", - "ashiya.fukuoka.jp", - "buzen.fukuoka.jp", - "chikugo.fukuoka.jp", - "chikuho.fukuoka.jp", - "chikujo.fukuoka.jp", - "chikushino.fukuoka.jp", - "chikuzen.fukuoka.jp", - "chuo.fukuoka.jp", - "dazaifu.fukuoka.jp", - "fukuchi.fukuoka.jp", - "hakata.fukuoka.jp", - "higashi.fukuoka.jp", - "hirokawa.fukuoka.jp", - "hisayama.fukuoka.jp", - "iizuka.fukuoka.jp", - "inatsuki.fukuoka.jp", - "kaho.fukuoka.jp", - "kasuga.fukuoka.jp", - "kasuya.fukuoka.jp", - "kawara.fukuoka.jp", - "keisen.fukuoka.jp", - "koga.fukuoka.jp", - "kurate.fukuoka.jp", - "kurogi.fukuoka.jp", - "kurume.fukuoka.jp", - "minami.fukuoka.jp", - "miyako.fukuoka.jp", - "miyama.fukuoka.jp", - "miyawaka.fukuoka.jp", - "mizumaki.fukuoka.jp", - "munakata.fukuoka.jp", - "nakagawa.fukuoka.jp", - "nakama.fukuoka.jp", - "nishi.fukuoka.jp", - "nogata.fukuoka.jp", - "ogori.fukuoka.jp", - "okagaki.fukuoka.jp", - "okawa.fukuoka.jp", - "oki.fukuoka.jp", - "omuta.fukuoka.jp", - "onga.fukuoka.jp", - "onojo.fukuoka.jp", - "oto.fukuoka.jp", - "saigawa.fukuoka.jp", - "sasaguri.fukuoka.jp", - "shingu.fukuoka.jp", - "shinyoshitomi.fukuoka.jp", - "shonai.fukuoka.jp", - "soeda.fukuoka.jp", - "sue.fukuoka.jp", - "tachiarai.fukuoka.jp", - "tagawa.fukuoka.jp", - "takata.fukuoka.jp", - "toho.fukuoka.jp", - "toyotsu.fukuoka.jp", - "tsuiki.fukuoka.jp", - "ukiha.fukuoka.jp", - "umi.fukuoka.jp", - "usui.fukuoka.jp", - "yamada.fukuoka.jp", - "yame.fukuoka.jp", - "yanagawa.fukuoka.jp", - "yukuhashi.fukuoka.jp", - "aizubange.fukushima.jp", - "aizumisato.fukushima.jp", - "aizuwakamatsu.fukushima.jp", - "asakawa.fukushima.jp", - "bandai.fukushima.jp", - "date.fukushima.jp", - "fukushima.fukushima.jp", - "furudono.fukushima.jp", - "futaba.fukushima.jp", - "hanawa.fukushima.jp", - "higashi.fukushima.jp", - "hirata.fukushima.jp", - "hirono.fukushima.jp", - "iitate.fukushima.jp", - "inawashiro.fukushima.jp", - "ishikawa.fukushima.jp", - "iwaki.fukushima.jp", - "izumizaki.fukushima.jp", - "kagamiishi.fukushima.jp", - "kaneyama.fukushima.jp", - "kawamata.fukushima.jp", - "kitakata.fukushima.jp", - "kitashiobara.fukushima.jp", - "koori.fukushima.jp", - "koriyama.fukushima.jp", - "kunimi.fukushima.jp", - "miharu.fukushima.jp", - "mishima.fukushima.jp", - "namie.fukushima.jp", - "nango.fukushima.jp", - "nishiaizu.fukushima.jp", - "nishigo.fukushima.jp", - "okuma.fukushima.jp", - "omotego.fukushima.jp", - "ono.fukushima.jp", - "otama.fukushima.jp", - "samegawa.fukushima.jp", - "shimogo.fukushima.jp", - "shirakawa.fukushima.jp", - "showa.fukushima.jp", - "soma.fukushima.jp", - "sukagawa.fukushima.jp", - "taishin.fukushima.jp", - "tamakawa.fukushima.jp", - "tanagura.fukushima.jp", - "tenei.fukushima.jp", - "yabuki.fukushima.jp", - "yamato.fukushima.jp", - "yamatsuri.fukushima.jp", - "yanaizu.fukushima.jp", - "yugawa.fukushima.jp", - "anpachi.gifu.jp", - "ena.gifu.jp", - "gifu.gifu.jp", - "ginan.gifu.jp", - "godo.gifu.jp", - "gujo.gifu.jp", - "hashima.gifu.jp", - "hichiso.gifu.jp", - "hida.gifu.jp", - "higashishirakawa.gifu.jp", - "ibigawa.gifu.jp", - "ikeda.gifu.jp", - "kakamigahara.gifu.jp", - "kani.gifu.jp", - "kasahara.gifu.jp", - "kasamatsu.gifu.jp", - "kawaue.gifu.jp", - "kitagata.gifu.jp", - "mino.gifu.jp", - "minokamo.gifu.jp", - "mitake.gifu.jp", - "mizunami.gifu.jp", - "motosu.gifu.jp", - "nakatsugawa.gifu.jp", - "ogaki.gifu.jp", - "sakahogi.gifu.jp", - "seki.gifu.jp", - "sekigahara.gifu.jp", - "shirakawa.gifu.jp", - "tajimi.gifu.jp", - "takayama.gifu.jp", - "tarui.gifu.jp", - "toki.gifu.jp", - "tomika.gifu.jp", - "wanouchi.gifu.jp", - "yamagata.gifu.jp", - "yaotsu.gifu.jp", - "yoro.gifu.jp", - "annaka.gunma.jp", - "chiyoda.gunma.jp", - "fujioka.gunma.jp", - "higashiagatsuma.gunma.jp", - "isesaki.gunma.jp", - "itakura.gunma.jp", - "kanna.gunma.jp", - "kanra.gunma.jp", - "katashina.gunma.jp", - "kawaba.gunma.jp", - "kiryu.gunma.jp", - "kusatsu.gunma.jp", - "maebashi.gunma.jp", - "meiwa.gunma.jp", - "midori.gunma.jp", - "minakami.gunma.jp", - "naganohara.gunma.jp", - "nakanojo.gunma.jp", - "nanmoku.gunma.jp", - "numata.gunma.jp", - "oizumi.gunma.jp", - "ora.gunma.jp", - "ota.gunma.jp", - "shibukawa.gunma.jp", - "shimonita.gunma.jp", - "shinto.gunma.jp", - "showa.gunma.jp", - "takasaki.gunma.jp", - "takayama.gunma.jp", - "tamamura.gunma.jp", - "tatebayashi.gunma.jp", - "tomioka.gunma.jp", - "tsukiyono.gunma.jp", - "tsumagoi.gunma.jp", - "ueno.gunma.jp", - "yoshioka.gunma.jp", - "asaminami.hiroshima.jp", - "daiwa.hiroshima.jp", - "etajima.hiroshima.jp", - "fuchu.hiroshima.jp", - "fukuyama.hiroshima.jp", - "hatsukaichi.hiroshima.jp", - "higashihiroshima.hiroshima.jp", - "hongo.hiroshima.jp", - "jinsekikogen.hiroshima.jp", - "kaita.hiroshima.jp", - "kui.hiroshima.jp", - "kumano.hiroshima.jp", - "kure.hiroshima.jp", - "mihara.hiroshima.jp", - "miyoshi.hiroshima.jp", - "naka.hiroshima.jp", - "onomichi.hiroshima.jp", - "osakikamijima.hiroshima.jp", - "otake.hiroshima.jp", - "saka.hiroshima.jp", - "sera.hiroshima.jp", - "seranishi.hiroshima.jp", - "shinichi.hiroshima.jp", - "shobara.hiroshima.jp", - "takehara.hiroshima.jp", - "abashiri.hokkaido.jp", - "abira.hokkaido.jp", - "aibetsu.hokkaido.jp", - "akabira.hokkaido.jp", - "akkeshi.hokkaido.jp", - "asahikawa.hokkaido.jp", - "ashibetsu.hokkaido.jp", - "ashoro.hokkaido.jp", - "assabu.hokkaido.jp", - "atsuma.hokkaido.jp", - "bibai.hokkaido.jp", - "biei.hokkaido.jp", - "bifuka.hokkaido.jp", - "bihoro.hokkaido.jp", - "biratori.hokkaido.jp", - "chippubetsu.hokkaido.jp", - "chitose.hokkaido.jp", - "date.hokkaido.jp", - "ebetsu.hokkaido.jp", - "embetsu.hokkaido.jp", - "eniwa.hokkaido.jp", - "erimo.hokkaido.jp", - "esan.hokkaido.jp", - "esashi.hokkaido.jp", - "fukagawa.hokkaido.jp", - "fukushima.hokkaido.jp", - "furano.hokkaido.jp", - "furubira.hokkaido.jp", - "haboro.hokkaido.jp", - "hakodate.hokkaido.jp", - "hamatonbetsu.hokkaido.jp", - "hidaka.hokkaido.jp", - "higashikagura.hokkaido.jp", - "higashikawa.hokkaido.jp", - "hiroo.hokkaido.jp", - "hokuryu.hokkaido.jp", - "hokuto.hokkaido.jp", - "honbetsu.hokkaido.jp", - "horokanai.hokkaido.jp", - "horonobe.hokkaido.jp", - "ikeda.hokkaido.jp", - "imakane.hokkaido.jp", - "ishikari.hokkaido.jp", - "iwamizawa.hokkaido.jp", - "iwanai.hokkaido.jp", - "kamifurano.hokkaido.jp", - "kamikawa.hokkaido.jp", - "kamishihoro.hokkaido.jp", - "kamisunagawa.hokkaido.jp", - "kamoenai.hokkaido.jp", - "kayabe.hokkaido.jp", - "kembuchi.hokkaido.jp", - "kikonai.hokkaido.jp", - "kimobetsu.hokkaido.jp", - "kitahiroshima.hokkaido.jp", - "kitami.hokkaido.jp", - "kiyosato.hokkaido.jp", - "koshimizu.hokkaido.jp", - "kunneppu.hokkaido.jp", - "kuriyama.hokkaido.jp", - "kuromatsunai.hokkaido.jp", - "kushiro.hokkaido.jp", - "kutchan.hokkaido.jp", - "kyowa.hokkaido.jp", - "mashike.hokkaido.jp", - "matsumae.hokkaido.jp", - "mikasa.hokkaido.jp", - "minamifurano.hokkaido.jp", - "mombetsu.hokkaido.jp", - "moseushi.hokkaido.jp", - "mukawa.hokkaido.jp", - "muroran.hokkaido.jp", - "naie.hokkaido.jp", - "nakagawa.hokkaido.jp", - "nakasatsunai.hokkaido.jp", - "nakatombetsu.hokkaido.jp", - "nanae.hokkaido.jp", - "nanporo.hokkaido.jp", - "nayoro.hokkaido.jp", - "nemuro.hokkaido.jp", - "niikappu.hokkaido.jp", - "niki.hokkaido.jp", - "nishiokoppe.hokkaido.jp", - "noboribetsu.hokkaido.jp", - "numata.hokkaido.jp", - "obihiro.hokkaido.jp", - "obira.hokkaido.jp", - "oketo.hokkaido.jp", - "okoppe.hokkaido.jp", - "otaru.hokkaido.jp", - "otobe.hokkaido.jp", - "otofuke.hokkaido.jp", - "otoineppu.hokkaido.jp", - "oumu.hokkaido.jp", - "ozora.hokkaido.jp", - "pippu.hokkaido.jp", - "rankoshi.hokkaido.jp", - "rebun.hokkaido.jp", - "rikubetsu.hokkaido.jp", - "rishiri.hokkaido.jp", - "rishirifuji.hokkaido.jp", - "saroma.hokkaido.jp", - "sarufutsu.hokkaido.jp", - "shakotan.hokkaido.jp", - "shari.hokkaido.jp", - "shibecha.hokkaido.jp", - "shibetsu.hokkaido.jp", - "shikabe.hokkaido.jp", - "shikaoi.hokkaido.jp", - "shimamaki.hokkaido.jp", - "shimizu.hokkaido.jp", - "shimokawa.hokkaido.jp", - "shinshinotsu.hokkaido.jp", - "shintoku.hokkaido.jp", - "shiranuka.hokkaido.jp", - "shiraoi.hokkaido.jp", - "shiriuchi.hokkaido.jp", - "sobetsu.hokkaido.jp", - "sunagawa.hokkaido.jp", - "taiki.hokkaido.jp", - "takasu.hokkaido.jp", - "takikawa.hokkaido.jp", - "takinoue.hokkaido.jp", - "teshikaga.hokkaido.jp", - "tobetsu.hokkaido.jp", - "tohma.hokkaido.jp", - "tomakomai.hokkaido.jp", - "tomari.hokkaido.jp", - "toya.hokkaido.jp", - "toyako.hokkaido.jp", - "toyotomi.hokkaido.jp", - "toyoura.hokkaido.jp", - "tsubetsu.hokkaido.jp", - "tsukigata.hokkaido.jp", - "urakawa.hokkaido.jp", - "urausu.hokkaido.jp", - "uryu.hokkaido.jp", - "utashinai.hokkaido.jp", - "wakkanai.hokkaido.jp", - "wassamu.hokkaido.jp", - "yakumo.hokkaido.jp", - "yoichi.hokkaido.jp", - "aioi.hyogo.jp", - "akashi.hyogo.jp", - "ako.hyogo.jp", - "amagasaki.hyogo.jp", - "aogaki.hyogo.jp", - "asago.hyogo.jp", - "ashiya.hyogo.jp", - "awaji.hyogo.jp", - "fukusaki.hyogo.jp", - "goshiki.hyogo.jp", - "harima.hyogo.jp", - "himeji.hyogo.jp", - "ichikawa.hyogo.jp", - "inagawa.hyogo.jp", - "itami.hyogo.jp", - "kakogawa.hyogo.jp", - "kamigori.hyogo.jp", - "kamikawa.hyogo.jp", - "kasai.hyogo.jp", - "kasuga.hyogo.jp", - "kawanishi.hyogo.jp", - "miki.hyogo.jp", - "minamiawaji.hyogo.jp", - "nishinomiya.hyogo.jp", - "nishiwaki.hyogo.jp", - "ono.hyogo.jp", - "sanda.hyogo.jp", - "sannan.hyogo.jp", - "sasayama.hyogo.jp", - "sayo.hyogo.jp", - "shingu.hyogo.jp", - "shinonsen.hyogo.jp", - "shiso.hyogo.jp", - "sumoto.hyogo.jp", - "taishi.hyogo.jp", - "taka.hyogo.jp", - "takarazuka.hyogo.jp", - "takasago.hyogo.jp", - "takino.hyogo.jp", - "tamba.hyogo.jp", - "tatsuno.hyogo.jp", - "toyooka.hyogo.jp", - "yabu.hyogo.jp", - "yashiro.hyogo.jp", - "yoka.hyogo.jp", - "yokawa.hyogo.jp", - "ami.ibaraki.jp", - "asahi.ibaraki.jp", - "bando.ibaraki.jp", - "chikusei.ibaraki.jp", - "daigo.ibaraki.jp", - "fujishiro.ibaraki.jp", - "hitachi.ibaraki.jp", - "hitachinaka.ibaraki.jp", - "hitachiomiya.ibaraki.jp", - "hitachiota.ibaraki.jp", - "ibaraki.ibaraki.jp", - "ina.ibaraki.jp", - "inashiki.ibaraki.jp", - "itako.ibaraki.jp", - "iwama.ibaraki.jp", - "joso.ibaraki.jp", - "kamisu.ibaraki.jp", - "kasama.ibaraki.jp", - "kashima.ibaraki.jp", - "kasumigaura.ibaraki.jp", - "koga.ibaraki.jp", - "miho.ibaraki.jp", - "mito.ibaraki.jp", - "moriya.ibaraki.jp", - "naka.ibaraki.jp", - "namegata.ibaraki.jp", - "oarai.ibaraki.jp", - "ogawa.ibaraki.jp", - "omitama.ibaraki.jp", - "ryugasaki.ibaraki.jp", - "sakai.ibaraki.jp", - "sakuragawa.ibaraki.jp", - "shimodate.ibaraki.jp", - "shimotsuma.ibaraki.jp", - "shirosato.ibaraki.jp", - "sowa.ibaraki.jp", - "suifu.ibaraki.jp", - "takahagi.ibaraki.jp", - "tamatsukuri.ibaraki.jp", - "tokai.ibaraki.jp", - "tomobe.ibaraki.jp", - "tone.ibaraki.jp", - "toride.ibaraki.jp", - "tsuchiura.ibaraki.jp", - "tsukuba.ibaraki.jp", - "uchihara.ibaraki.jp", - "ushiku.ibaraki.jp", - "yachiyo.ibaraki.jp", - "yamagata.ibaraki.jp", - "yawara.ibaraki.jp", - "yuki.ibaraki.jp", - "anamizu.ishikawa.jp", - "hakui.ishikawa.jp", - "hakusan.ishikawa.jp", - "kaga.ishikawa.jp", - "kahoku.ishikawa.jp", - "kanazawa.ishikawa.jp", - "kawakita.ishikawa.jp", - "komatsu.ishikawa.jp", - "nakanoto.ishikawa.jp", - "nanao.ishikawa.jp", - "nomi.ishikawa.jp", - "nonoichi.ishikawa.jp", - "noto.ishikawa.jp", - "shika.ishikawa.jp", - "suzu.ishikawa.jp", - "tsubata.ishikawa.jp", - "tsurugi.ishikawa.jp", - "uchinada.ishikawa.jp", - "wajima.ishikawa.jp", - "fudai.iwate.jp", - "fujisawa.iwate.jp", - "hanamaki.iwate.jp", - "hiraizumi.iwate.jp", - "hirono.iwate.jp", - "ichinohe.iwate.jp", - "ichinoseki.iwate.jp", - "iwaizumi.iwate.jp", - "iwate.iwate.jp", - "joboji.iwate.jp", - "kamaishi.iwate.jp", - "kanegasaki.iwate.jp", - "karumai.iwate.jp", - "kawai.iwate.jp", - "kitakami.iwate.jp", - "kuji.iwate.jp", - "kunohe.iwate.jp", - "kuzumaki.iwate.jp", - "miyako.iwate.jp", - "mizusawa.iwate.jp", - "morioka.iwate.jp", - "ninohe.iwate.jp", - "noda.iwate.jp", - "ofunato.iwate.jp", - "oshu.iwate.jp", - "otsuchi.iwate.jp", - "rikuzentakata.iwate.jp", - "shiwa.iwate.jp", - "shizukuishi.iwate.jp", - "sumita.iwate.jp", - "tanohata.iwate.jp", - "tono.iwate.jp", - "yahaba.iwate.jp", - "yamada.iwate.jp", - "ayagawa.kagawa.jp", - "higashikagawa.kagawa.jp", - "kanonji.kagawa.jp", - "kotohira.kagawa.jp", - "manno.kagawa.jp", - "marugame.kagawa.jp", - "mitoyo.kagawa.jp", - "naoshima.kagawa.jp", - "sanuki.kagawa.jp", - "tadotsu.kagawa.jp", - "takamatsu.kagawa.jp", - "tonosho.kagawa.jp", - "uchinomi.kagawa.jp", - "utazu.kagawa.jp", - "zentsuji.kagawa.jp", - "akune.kagoshima.jp", - "amami.kagoshima.jp", - "hioki.kagoshima.jp", - "isa.kagoshima.jp", - "isen.kagoshima.jp", - "izumi.kagoshima.jp", - "kagoshima.kagoshima.jp", - "kanoya.kagoshima.jp", - "kawanabe.kagoshima.jp", - "kinko.kagoshima.jp", - "kouyama.kagoshima.jp", - "makurazaki.kagoshima.jp", - "matsumoto.kagoshima.jp", - "minamitane.kagoshima.jp", - "nakatane.kagoshima.jp", - "nishinoomote.kagoshima.jp", - "satsumasendai.kagoshima.jp", - "soo.kagoshima.jp", - "tarumizu.kagoshima.jp", - "yusui.kagoshima.jp", - "aikawa.kanagawa.jp", - "atsugi.kanagawa.jp", - "ayase.kanagawa.jp", - "chigasaki.kanagawa.jp", - "ebina.kanagawa.jp", - "fujisawa.kanagawa.jp", - "hadano.kanagawa.jp", - "hakone.kanagawa.jp", - "hiratsuka.kanagawa.jp", - "isehara.kanagawa.jp", - "kaisei.kanagawa.jp", - "kamakura.kanagawa.jp", - "kiyokawa.kanagawa.jp", - "matsuda.kanagawa.jp", - "minamiashigara.kanagawa.jp", - "miura.kanagawa.jp", - "nakai.kanagawa.jp", - "ninomiya.kanagawa.jp", - "odawara.kanagawa.jp", - "oi.kanagawa.jp", - "oiso.kanagawa.jp", - "sagamihara.kanagawa.jp", - "samukawa.kanagawa.jp", - "tsukui.kanagawa.jp", - "yamakita.kanagawa.jp", - "yamato.kanagawa.jp", - "yokosuka.kanagawa.jp", - "yugawara.kanagawa.jp", - "zama.kanagawa.jp", - "zushi.kanagawa.jp", - "aki.kochi.jp", - "geisei.kochi.jp", - "hidaka.kochi.jp", - "higashitsuno.kochi.jp", - "ino.kochi.jp", - "kagami.kochi.jp", - "kami.kochi.jp", - "kitagawa.kochi.jp", - "kochi.kochi.jp", - "mihara.kochi.jp", - "motoyama.kochi.jp", - "muroto.kochi.jp", - "nahari.kochi.jp", - "nakamura.kochi.jp", - "nankoku.kochi.jp", - "nishitosa.kochi.jp", - "niyodogawa.kochi.jp", - "ochi.kochi.jp", - "okawa.kochi.jp", - "otoyo.kochi.jp", - "otsuki.kochi.jp", - "sakawa.kochi.jp", - "sukumo.kochi.jp", - "susaki.kochi.jp", - "tosa.kochi.jp", - "tosashimizu.kochi.jp", - "toyo.kochi.jp", - "tsuno.kochi.jp", - "umaji.kochi.jp", - "yasuda.kochi.jp", - "yusuhara.kochi.jp", - "amakusa.kumamoto.jp", - "arao.kumamoto.jp", - "aso.kumamoto.jp", - "choyo.kumamoto.jp", - "gyokuto.kumamoto.jp", - "hitoyoshi.kumamoto.jp", - "kamiamakusa.kumamoto.jp", - "kashima.kumamoto.jp", - "kikuchi.kumamoto.jp", - "kosa.kumamoto.jp", - "kumamoto.kumamoto.jp", - "mashiki.kumamoto.jp", - "mifune.kumamoto.jp", - "minamata.kumamoto.jp", - "minamioguni.kumamoto.jp", - "nagasu.kumamoto.jp", - "nishihara.kumamoto.jp", - "oguni.kumamoto.jp", - "ozu.kumamoto.jp", - "sumoto.kumamoto.jp", - "takamori.kumamoto.jp", - "uki.kumamoto.jp", - "uto.kumamoto.jp", - "yamaga.kumamoto.jp", - "yamato.kumamoto.jp", - "yatsushiro.kumamoto.jp", - "ayabe.kyoto.jp", - "fukuchiyama.kyoto.jp", - "higashiyama.kyoto.jp", - "ide.kyoto.jp", - "ine.kyoto.jp", - "joyo.kyoto.jp", - "kameoka.kyoto.jp", - "kamo.kyoto.jp", - "kita.kyoto.jp", - "kizu.kyoto.jp", - "kumiyama.kyoto.jp", - "kyotamba.kyoto.jp", - "kyotanabe.kyoto.jp", - "kyotango.kyoto.jp", - "maizuru.kyoto.jp", - "minami.kyoto.jp", - "minamiyamashiro.kyoto.jp", - "miyazu.kyoto.jp", - "muko.kyoto.jp", - "nagaokakyo.kyoto.jp", - "nakagyo.kyoto.jp", - "nantan.kyoto.jp", - "oyamazaki.kyoto.jp", - "sakyo.kyoto.jp", - "seika.kyoto.jp", - "tanabe.kyoto.jp", - "uji.kyoto.jp", - "ujitawara.kyoto.jp", - "wazuka.kyoto.jp", - "yamashina.kyoto.jp", - "yawata.kyoto.jp", - "asahi.mie.jp", - "inabe.mie.jp", - "ise.mie.jp", - "kameyama.mie.jp", - "kawagoe.mie.jp", - "kiho.mie.jp", - "kisosaki.mie.jp", - "kiwa.mie.jp", - "komono.mie.jp", - "kumano.mie.jp", - "kuwana.mie.jp", - "matsusaka.mie.jp", - "meiwa.mie.jp", - "mihama.mie.jp", - "minamiise.mie.jp", - "misugi.mie.jp", - "miyama.mie.jp", - "nabari.mie.jp", - "shima.mie.jp", - "suzuka.mie.jp", - "tado.mie.jp", - "taiki.mie.jp", - "taki.mie.jp", - "tamaki.mie.jp", - "toba.mie.jp", - "tsu.mie.jp", - "udono.mie.jp", - "ureshino.mie.jp", - "watarai.mie.jp", - "yokkaichi.mie.jp", - "furukawa.miyagi.jp", - "higashimatsushima.miyagi.jp", - "ishinomaki.miyagi.jp", - "iwanuma.miyagi.jp", - "kakuda.miyagi.jp", - "kami.miyagi.jp", - "kawasaki.miyagi.jp", - "marumori.miyagi.jp", - "matsushima.miyagi.jp", - "minamisanriku.miyagi.jp", - "misato.miyagi.jp", - "murata.miyagi.jp", - "natori.miyagi.jp", - "ogawara.miyagi.jp", - "ohira.miyagi.jp", - "onagawa.miyagi.jp", - "osaki.miyagi.jp", - "rifu.miyagi.jp", - "semine.miyagi.jp", - "shibata.miyagi.jp", - "shichikashuku.miyagi.jp", - "shikama.miyagi.jp", - "shiogama.miyagi.jp", - "shiroishi.miyagi.jp", - "tagajo.miyagi.jp", - "taiwa.miyagi.jp", - "tome.miyagi.jp", - "tomiya.miyagi.jp", - "wakuya.miyagi.jp", - "watari.miyagi.jp", - "yamamoto.miyagi.jp", - "zao.miyagi.jp", - "aya.miyazaki.jp", - "ebino.miyazaki.jp", - "gokase.miyazaki.jp", - "hyuga.miyazaki.jp", - "kadogawa.miyazaki.jp", - "kawaminami.miyazaki.jp", - "kijo.miyazaki.jp", - "kitagawa.miyazaki.jp", - "kitakata.miyazaki.jp", - "kitaura.miyazaki.jp", - "kobayashi.miyazaki.jp", - "kunitomi.miyazaki.jp", - "kushima.miyazaki.jp", - "mimata.miyazaki.jp", - "miyakonojo.miyazaki.jp", - "miyazaki.miyazaki.jp", - "morotsuka.miyazaki.jp", - "nichinan.miyazaki.jp", - "nishimera.miyazaki.jp", - "nobeoka.miyazaki.jp", - "saito.miyazaki.jp", - "shiiba.miyazaki.jp", - "shintomi.miyazaki.jp", - "takaharu.miyazaki.jp", - "takanabe.miyazaki.jp", - "takazaki.miyazaki.jp", - "tsuno.miyazaki.jp", - "achi.nagano.jp", - "agematsu.nagano.jp", - "anan.nagano.jp", - "aoki.nagano.jp", - "asahi.nagano.jp", - "azumino.nagano.jp", - "chikuhoku.nagano.jp", - "chikuma.nagano.jp", - "chino.nagano.jp", - "fujimi.nagano.jp", - "hakuba.nagano.jp", - "hara.nagano.jp", - "hiraya.nagano.jp", - "iida.nagano.jp", - "iijima.nagano.jp", - "iiyama.nagano.jp", - "iizuna.nagano.jp", - "ikeda.nagano.jp", - "ikusaka.nagano.jp", - "ina.nagano.jp", - "karuizawa.nagano.jp", - "kawakami.nagano.jp", - "kiso.nagano.jp", - "kisofukushima.nagano.jp", - "kitaaiki.nagano.jp", - "komagane.nagano.jp", - "komoro.nagano.jp", - "matsukawa.nagano.jp", - "matsumoto.nagano.jp", - "miasa.nagano.jp", - "minamiaiki.nagano.jp", - "minamimaki.nagano.jp", - "minamiminowa.nagano.jp", - "minowa.nagano.jp", - "miyada.nagano.jp", - "miyota.nagano.jp", - "mochizuki.nagano.jp", - "nagano.nagano.jp", - "nagawa.nagano.jp", - "nagiso.nagano.jp", - "nakagawa.nagano.jp", - "nakano.nagano.jp", - "nozawaonsen.nagano.jp", - "obuse.nagano.jp", - "ogawa.nagano.jp", - "okaya.nagano.jp", - "omachi.nagano.jp", - "omi.nagano.jp", - "ookuwa.nagano.jp", - "ooshika.nagano.jp", - "otaki.nagano.jp", - "otari.nagano.jp", - "sakae.nagano.jp", - "sakaki.nagano.jp", - "saku.nagano.jp", - "sakuho.nagano.jp", - "shimosuwa.nagano.jp", - "shinanomachi.nagano.jp", - "shiojiri.nagano.jp", - "suwa.nagano.jp", - "suzaka.nagano.jp", - "takagi.nagano.jp", - "takamori.nagano.jp", - "takayama.nagano.jp", - "tateshina.nagano.jp", - "tatsuno.nagano.jp", - "togakushi.nagano.jp", - "togura.nagano.jp", - "tomi.nagano.jp", - "ueda.nagano.jp", - "wada.nagano.jp", - "yamagata.nagano.jp", - "yamanouchi.nagano.jp", - "yasaka.nagano.jp", - "yasuoka.nagano.jp", - "chijiwa.nagasaki.jp", - "futsu.nagasaki.jp", - "goto.nagasaki.jp", - "hasami.nagasaki.jp", - "hirado.nagasaki.jp", - "iki.nagasaki.jp", - "isahaya.nagasaki.jp", - "kawatana.nagasaki.jp", - "kuchinotsu.nagasaki.jp", - "matsuura.nagasaki.jp", - "nagasaki.nagasaki.jp", - "obama.nagasaki.jp", - "omura.nagasaki.jp", - "oseto.nagasaki.jp", - "saikai.nagasaki.jp", - "sasebo.nagasaki.jp", - "seihi.nagasaki.jp", - "shimabara.nagasaki.jp", - "shinkamigoto.nagasaki.jp", - "togitsu.nagasaki.jp", - "tsushima.nagasaki.jp", - "unzen.nagasaki.jp", - "ando.nara.jp", - "gose.nara.jp", - "heguri.nara.jp", - "higashiyoshino.nara.jp", - "ikaruga.nara.jp", - "ikoma.nara.jp", - "kamikitayama.nara.jp", - "kanmaki.nara.jp", - "kashiba.nara.jp", - "kashihara.nara.jp", - "katsuragi.nara.jp", - "kawai.nara.jp", - "kawakami.nara.jp", - "kawanishi.nara.jp", - "koryo.nara.jp", - "kurotaki.nara.jp", - "mitsue.nara.jp", - "miyake.nara.jp", - "nara.nara.jp", - "nosegawa.nara.jp", - "oji.nara.jp", - "ouda.nara.jp", - "oyodo.nara.jp", - "sakurai.nara.jp", - "sango.nara.jp", - "shimoichi.nara.jp", - "shimokitayama.nara.jp", - "shinjo.nara.jp", - "soni.nara.jp", - "takatori.nara.jp", - "tawaramoto.nara.jp", - "tenkawa.nara.jp", - "tenri.nara.jp", - "uda.nara.jp", - "yamatokoriyama.nara.jp", - "yamatotakada.nara.jp", - "yamazoe.nara.jp", - "yoshino.nara.jp", - "aga.niigata.jp", - "agano.niigata.jp", - "gosen.niigata.jp", - "itoigawa.niigata.jp", - "izumozaki.niigata.jp", - "joetsu.niigata.jp", - "kamo.niigata.jp", - "kariwa.niigata.jp", - "kashiwazaki.niigata.jp", - "minamiuonuma.niigata.jp", - "mitsuke.niigata.jp", - "muika.niigata.jp", - "murakami.niigata.jp", - "myoko.niigata.jp", - "nagaoka.niigata.jp", - "niigata.niigata.jp", - "ojiya.niigata.jp", - "omi.niigata.jp", - "sado.niigata.jp", - "sanjo.niigata.jp", - "seiro.niigata.jp", - "seirou.niigata.jp", - "sekikawa.niigata.jp", - "shibata.niigata.jp", - "tagami.niigata.jp", - "tainai.niigata.jp", - "tochio.niigata.jp", - "tokamachi.niigata.jp", - "tsubame.niigata.jp", - "tsunan.niigata.jp", - "uonuma.niigata.jp", - "yahiko.niigata.jp", - "yoita.niigata.jp", - "yuzawa.niigata.jp", - "beppu.oita.jp", - "bungoono.oita.jp", - "bungotakada.oita.jp", - "hasama.oita.jp", - "hiji.oita.jp", - "himeshima.oita.jp", - "hita.oita.jp", - "kamitsue.oita.jp", - "kokonoe.oita.jp", - "kuju.oita.jp", - "kunisaki.oita.jp", - "kusu.oita.jp", - "oita.oita.jp", - "saiki.oita.jp", - "taketa.oita.jp", - "tsukumi.oita.jp", - "usa.oita.jp", - "usuki.oita.jp", - "yufu.oita.jp", - "akaiwa.okayama.jp", - "asakuchi.okayama.jp", - "bizen.okayama.jp", - "hayashima.okayama.jp", - "ibara.okayama.jp", - "kagamino.okayama.jp", - "kasaoka.okayama.jp", - "kibichuo.okayama.jp", - "kumenan.okayama.jp", - "kurashiki.okayama.jp", - "maniwa.okayama.jp", - "misaki.okayama.jp", - "nagi.okayama.jp", - "niimi.okayama.jp", - "nishiawakura.okayama.jp", - "okayama.okayama.jp", - "satosho.okayama.jp", - "setouchi.okayama.jp", - "shinjo.okayama.jp", - "shoo.okayama.jp", - "soja.okayama.jp", - "takahashi.okayama.jp", - "tamano.okayama.jp", - "tsuyama.okayama.jp", - "wake.okayama.jp", - "yakage.okayama.jp", - "aguni.okinawa.jp", - "ginowan.okinawa.jp", - "ginoza.okinawa.jp", - "gushikami.okinawa.jp", - "haebaru.okinawa.jp", - "higashi.okinawa.jp", - "hirara.okinawa.jp", - "iheya.okinawa.jp", - "ishigaki.okinawa.jp", - "ishikawa.okinawa.jp", - "itoman.okinawa.jp", - "izena.okinawa.jp", - "kadena.okinawa.jp", - "kin.okinawa.jp", - "kitadaito.okinawa.jp", - "kitanakagusuku.okinawa.jp", - "kumejima.okinawa.jp", - "kunigami.okinawa.jp", - "minamidaito.okinawa.jp", - "motobu.okinawa.jp", - "nago.okinawa.jp", - "naha.okinawa.jp", - "nakagusuku.okinawa.jp", - "nakijin.okinawa.jp", - "nanjo.okinawa.jp", - "nishihara.okinawa.jp", - "ogimi.okinawa.jp", - "okinawa.okinawa.jp", - "onna.okinawa.jp", - "shimoji.okinawa.jp", - "taketomi.okinawa.jp", - "tarama.okinawa.jp", - "tokashiki.okinawa.jp", - "tomigusuku.okinawa.jp", - "tonaki.okinawa.jp", - "urasoe.okinawa.jp", - "uruma.okinawa.jp", - "yaese.okinawa.jp", - "yomitan.okinawa.jp", - "yonabaru.okinawa.jp", - "yonaguni.okinawa.jp", - "zamami.okinawa.jp", - "abeno.osaka.jp", - "chihayaakasaka.osaka.jp", - "chuo.osaka.jp", - "daito.osaka.jp", - "fujiidera.osaka.jp", - "habikino.osaka.jp", - "hannan.osaka.jp", - "higashiosaka.osaka.jp", - "higashisumiyoshi.osaka.jp", - "higashiyodogawa.osaka.jp", - "hirakata.osaka.jp", - "ibaraki.osaka.jp", - "ikeda.osaka.jp", - "izumi.osaka.jp", - "izumiotsu.osaka.jp", - "izumisano.osaka.jp", - "kadoma.osaka.jp", - "kaizuka.osaka.jp", - "kanan.osaka.jp", - "kashiwara.osaka.jp", - "katano.osaka.jp", - "kawachinagano.osaka.jp", - "kishiwada.osaka.jp", - "kita.osaka.jp", - "kumatori.osaka.jp", - "matsubara.osaka.jp", - "minato.osaka.jp", - "minoh.osaka.jp", - "misaki.osaka.jp", - "moriguchi.osaka.jp", - "neyagawa.osaka.jp", - "nishi.osaka.jp", - "nose.osaka.jp", - "osakasayama.osaka.jp", - "sakai.osaka.jp", - "sayama.osaka.jp", - "sennan.osaka.jp", - "settsu.osaka.jp", - "shijonawate.osaka.jp", - "shimamoto.osaka.jp", - "suita.osaka.jp", - "tadaoka.osaka.jp", - "taishi.osaka.jp", - "tajiri.osaka.jp", - "takaishi.osaka.jp", - "takatsuki.osaka.jp", - "tondabayashi.osaka.jp", - "toyonaka.osaka.jp", - "toyono.osaka.jp", - "yao.osaka.jp", - "ariake.saga.jp", - "arita.saga.jp", - "fukudomi.saga.jp", - "genkai.saga.jp", - "hamatama.saga.jp", - "hizen.saga.jp", - "imari.saga.jp", - "kamimine.saga.jp", - "kanzaki.saga.jp", - "karatsu.saga.jp", - "kashima.saga.jp", - "kitagata.saga.jp", - "kitahata.saga.jp", - "kiyama.saga.jp", - "kouhoku.saga.jp", - "kyuragi.saga.jp", - "nishiarita.saga.jp", - "ogi.saga.jp", - "omachi.saga.jp", - "ouchi.saga.jp", - "saga.saga.jp", - "shiroishi.saga.jp", - "taku.saga.jp", - "tara.saga.jp", - "tosu.saga.jp", - "yoshinogari.saga.jp", - "arakawa.saitama.jp", - "asaka.saitama.jp", - "chichibu.saitama.jp", - "fujimi.saitama.jp", - "fujimino.saitama.jp", - "fukaya.saitama.jp", - "hanno.saitama.jp", - "hanyu.saitama.jp", - "hasuda.saitama.jp", - "hatogaya.saitama.jp", - "hatoyama.saitama.jp", - "hidaka.saitama.jp", - "higashichichibu.saitama.jp", - "higashimatsuyama.saitama.jp", - "honjo.saitama.jp", - "ina.saitama.jp", - "iruma.saitama.jp", - "iwatsuki.saitama.jp", - "kamiizumi.saitama.jp", - "kamikawa.saitama.jp", - "kamisato.saitama.jp", - "kasukabe.saitama.jp", - "kawagoe.saitama.jp", - "kawaguchi.saitama.jp", - "kawajima.saitama.jp", - "kazo.saitama.jp", - "kitamoto.saitama.jp", - "koshigaya.saitama.jp", - "kounosu.saitama.jp", - "kuki.saitama.jp", - "kumagaya.saitama.jp", - "matsubushi.saitama.jp", - "minano.saitama.jp", - "misato.saitama.jp", - "miyashiro.saitama.jp", - "miyoshi.saitama.jp", - "moroyama.saitama.jp", - "nagatoro.saitama.jp", - "namegawa.saitama.jp", - "niiza.saitama.jp", - "ogano.saitama.jp", - "ogawa.saitama.jp", - "ogose.saitama.jp", - "okegawa.saitama.jp", - "omiya.saitama.jp", - "otaki.saitama.jp", - "ranzan.saitama.jp", - "ryokami.saitama.jp", - "saitama.saitama.jp", - "sakado.saitama.jp", - "satte.saitama.jp", - "sayama.saitama.jp", - "shiki.saitama.jp", - "shiraoka.saitama.jp", - "soka.saitama.jp", - "sugito.saitama.jp", - "toda.saitama.jp", - "tokigawa.saitama.jp", - "tokorozawa.saitama.jp", - "tsurugashima.saitama.jp", - "urawa.saitama.jp", - "warabi.saitama.jp", - "yashio.saitama.jp", - "yokoze.saitama.jp", - "yono.saitama.jp", - "yorii.saitama.jp", - "yoshida.saitama.jp", - "yoshikawa.saitama.jp", - "yoshimi.saitama.jp", - "aisho.shiga.jp", - "gamo.shiga.jp", - "higashiomi.shiga.jp", - "hikone.shiga.jp", - "koka.shiga.jp", - "konan.shiga.jp", - "kosei.shiga.jp", - "koto.shiga.jp", - "kusatsu.shiga.jp", - "maibara.shiga.jp", - "moriyama.shiga.jp", - "nagahama.shiga.jp", - "nishiazai.shiga.jp", - "notogawa.shiga.jp", - "omihachiman.shiga.jp", - "otsu.shiga.jp", - "ritto.shiga.jp", - "ryuoh.shiga.jp", - "takashima.shiga.jp", - "takatsuki.shiga.jp", - "torahime.shiga.jp", - "toyosato.shiga.jp", - "yasu.shiga.jp", - "akagi.shimane.jp", - "ama.shimane.jp", - "gotsu.shimane.jp", - "hamada.shimane.jp", - "higashiizumo.shimane.jp", - "hikawa.shimane.jp", - "hikimi.shimane.jp", - "izumo.shimane.jp", - "kakinoki.shimane.jp", - "masuda.shimane.jp", - "matsue.shimane.jp", - "misato.shimane.jp", - "nishinoshima.shimane.jp", - "ohda.shimane.jp", - "okinoshima.shimane.jp", - "okuizumo.shimane.jp", - "shimane.shimane.jp", - "tamayu.shimane.jp", - "tsuwano.shimane.jp", - "unnan.shimane.jp", - "yakumo.shimane.jp", - "yasugi.shimane.jp", - "yatsuka.shimane.jp", - "arai.shizuoka.jp", - "atami.shizuoka.jp", - "fuji.shizuoka.jp", - "fujieda.shizuoka.jp", - "fujikawa.shizuoka.jp", - "fujinomiya.shizuoka.jp", - "fukuroi.shizuoka.jp", - "gotemba.shizuoka.jp", - "haibara.shizuoka.jp", - "hamamatsu.shizuoka.jp", - "higashiizu.shizuoka.jp", - "ito.shizuoka.jp", - "iwata.shizuoka.jp", - "izu.shizuoka.jp", - "izunokuni.shizuoka.jp", - "kakegawa.shizuoka.jp", - "kannami.shizuoka.jp", - "kawanehon.shizuoka.jp", - "kawazu.shizuoka.jp", - "kikugawa.shizuoka.jp", - "kosai.shizuoka.jp", - "makinohara.shizuoka.jp", - "matsuzaki.shizuoka.jp", - "minamiizu.shizuoka.jp", - "mishima.shizuoka.jp", - "morimachi.shizuoka.jp", - "nishiizu.shizuoka.jp", - "numazu.shizuoka.jp", - "omaezaki.shizuoka.jp", - "shimada.shizuoka.jp", - "shimizu.shizuoka.jp", - "shimoda.shizuoka.jp", - "shizuoka.shizuoka.jp", - "susono.shizuoka.jp", - "yaizu.shizuoka.jp", - "yoshida.shizuoka.jp", - "ashikaga.tochigi.jp", - "bato.tochigi.jp", - "haga.tochigi.jp", - "ichikai.tochigi.jp", - "iwafune.tochigi.jp", - "kaminokawa.tochigi.jp", - "kanuma.tochigi.jp", - "karasuyama.tochigi.jp", - "kuroiso.tochigi.jp", - "mashiko.tochigi.jp", - "mibu.tochigi.jp", - "moka.tochigi.jp", - "motegi.tochigi.jp", - "nasu.tochigi.jp", - "nasushiobara.tochigi.jp", - "nikko.tochigi.jp", - "nishikata.tochigi.jp", - "nogi.tochigi.jp", - "ohira.tochigi.jp", - "ohtawara.tochigi.jp", - "oyama.tochigi.jp", - "sakura.tochigi.jp", - "sano.tochigi.jp", - "shimotsuke.tochigi.jp", - "shioya.tochigi.jp", - "takanezawa.tochigi.jp", - "tochigi.tochigi.jp", - "tsuga.tochigi.jp", - "ujiie.tochigi.jp", - "utsunomiya.tochigi.jp", - "yaita.tochigi.jp", - "aizumi.tokushima.jp", - "anan.tokushima.jp", - "ichiba.tokushima.jp", - "itano.tokushima.jp", - "kainan.tokushima.jp", - "komatsushima.tokushima.jp", - "matsushige.tokushima.jp", - "mima.tokushima.jp", - "minami.tokushima.jp", - "miyoshi.tokushima.jp", - "mugi.tokushima.jp", - "nakagawa.tokushima.jp", - "naruto.tokushima.jp", - "sanagochi.tokushima.jp", - "shishikui.tokushima.jp", - "tokushima.tokushima.jp", - "wajiki.tokushima.jp", - "adachi.tokyo.jp", - "akiruno.tokyo.jp", - "akishima.tokyo.jp", - "aogashima.tokyo.jp", - "arakawa.tokyo.jp", - "bunkyo.tokyo.jp", - "chiyoda.tokyo.jp", - "chofu.tokyo.jp", - "chuo.tokyo.jp", - "edogawa.tokyo.jp", - "fuchu.tokyo.jp", - "fussa.tokyo.jp", - "hachijo.tokyo.jp", - "hachioji.tokyo.jp", - "hamura.tokyo.jp", - "higashikurume.tokyo.jp", - "higashimurayama.tokyo.jp", - "higashiyamato.tokyo.jp", - "hino.tokyo.jp", - "hinode.tokyo.jp", - "hinohara.tokyo.jp", - "inagi.tokyo.jp", - "itabashi.tokyo.jp", - "katsushika.tokyo.jp", - "kita.tokyo.jp", - "kiyose.tokyo.jp", - "kodaira.tokyo.jp", - "koganei.tokyo.jp", - "kokubunji.tokyo.jp", - "komae.tokyo.jp", - "koto.tokyo.jp", - "kouzushima.tokyo.jp", - "kunitachi.tokyo.jp", - "machida.tokyo.jp", - "meguro.tokyo.jp", - "minato.tokyo.jp", - "mitaka.tokyo.jp", - "mizuho.tokyo.jp", - "musashimurayama.tokyo.jp", - "musashino.tokyo.jp", - "nakano.tokyo.jp", - "nerima.tokyo.jp", - "ogasawara.tokyo.jp", - "okutama.tokyo.jp", - "ome.tokyo.jp", - "oshima.tokyo.jp", - "ota.tokyo.jp", - "setagaya.tokyo.jp", - "shibuya.tokyo.jp", - "shinagawa.tokyo.jp", - "shinjuku.tokyo.jp", - "suginami.tokyo.jp", - "sumida.tokyo.jp", - "tachikawa.tokyo.jp", - "taito.tokyo.jp", - "tama.tokyo.jp", - "toshima.tokyo.jp", - "chizu.tottori.jp", - "hino.tottori.jp", - "kawahara.tottori.jp", - "koge.tottori.jp", - "kotoura.tottori.jp", - "misasa.tottori.jp", - "nanbu.tottori.jp", - "nichinan.tottori.jp", - "sakaiminato.tottori.jp", - "tottori.tottori.jp", - "wakasa.tottori.jp", - "yazu.tottori.jp", - "yonago.tottori.jp", - "asahi.toyama.jp", - "fuchu.toyama.jp", - "fukumitsu.toyama.jp", - "funahashi.toyama.jp", - "himi.toyama.jp", - "imizu.toyama.jp", - "inami.toyama.jp", - "johana.toyama.jp", - "kamiichi.toyama.jp", - "kurobe.toyama.jp", - "nakaniikawa.toyama.jp", - "namerikawa.toyama.jp", - "nanto.toyama.jp", - "nyuzen.toyama.jp", - "oyabe.toyama.jp", - "taira.toyama.jp", - "takaoka.toyama.jp", - "tateyama.toyama.jp", - "toga.toyama.jp", - "tonami.toyama.jp", - "toyama.toyama.jp", - "unazuki.toyama.jp", - "uozu.toyama.jp", - "yamada.toyama.jp", - "arida.wakayama.jp", - "aridagawa.wakayama.jp", - "gobo.wakayama.jp", - "hashimoto.wakayama.jp", - "hidaka.wakayama.jp", - "hirogawa.wakayama.jp", - "inami.wakayama.jp", - "iwade.wakayama.jp", - "kainan.wakayama.jp", - "kamitonda.wakayama.jp", - "katsuragi.wakayama.jp", - "kimino.wakayama.jp", - "kinokawa.wakayama.jp", - "kitayama.wakayama.jp", - "koya.wakayama.jp", - "koza.wakayama.jp", - "kozagawa.wakayama.jp", - "kudoyama.wakayama.jp", - "kushimoto.wakayama.jp", - "mihama.wakayama.jp", - "misato.wakayama.jp", - "nachikatsuura.wakayama.jp", - "shingu.wakayama.jp", - "shirahama.wakayama.jp", - "taiji.wakayama.jp", - "tanabe.wakayama.jp", - "wakayama.wakayama.jp", - "yuasa.wakayama.jp", - "yura.wakayama.jp", - "asahi.yamagata.jp", - "funagata.yamagata.jp", - "higashine.yamagata.jp", - "iide.yamagata.jp", - "kahoku.yamagata.jp", - "kaminoyama.yamagata.jp", - "kaneyama.yamagata.jp", - "kawanishi.yamagata.jp", - "mamurogawa.yamagata.jp", - "mikawa.yamagata.jp", - "murayama.yamagata.jp", - "nagai.yamagata.jp", - "nakayama.yamagata.jp", - "nanyo.yamagata.jp", - "nishikawa.yamagata.jp", - "obanazawa.yamagata.jp", - "oe.yamagata.jp", - "oguni.yamagata.jp", - "ohkura.yamagata.jp", - "oishida.yamagata.jp", - "sagae.yamagata.jp", - "sakata.yamagata.jp", - "sakegawa.yamagata.jp", - "shinjo.yamagata.jp", - "shirataka.yamagata.jp", - "shonai.yamagata.jp", - "takahata.yamagata.jp", - "tendo.yamagata.jp", - "tozawa.yamagata.jp", - "tsuruoka.yamagata.jp", - "yamagata.yamagata.jp", - "yamanobe.yamagata.jp", - "yonezawa.yamagata.jp", - "yuza.yamagata.jp", - "abu.yamaguchi.jp", - "hagi.yamaguchi.jp", - "hikari.yamaguchi.jp", - "hofu.yamaguchi.jp", - "iwakuni.yamaguchi.jp", - "kudamatsu.yamaguchi.jp", - "mitou.yamaguchi.jp", - "nagato.yamaguchi.jp", - "oshima.yamaguchi.jp", - "shimonoseki.yamaguchi.jp", - "shunan.yamaguchi.jp", - "tabuse.yamaguchi.jp", - "tokuyama.yamaguchi.jp", - "toyota.yamaguchi.jp", - "ube.yamaguchi.jp", - "yuu.yamaguchi.jp", - "chuo.yamanashi.jp", - "doshi.yamanashi.jp", - "fuefuki.yamanashi.jp", - "fujikawa.yamanashi.jp", - "fujikawaguchiko.yamanashi.jp", - "fujiyoshida.yamanashi.jp", - "hayakawa.yamanashi.jp", - "hokuto.yamanashi.jp", - "ichikawamisato.yamanashi.jp", - "kai.yamanashi.jp", - "kofu.yamanashi.jp", - "koshu.yamanashi.jp", - "kosuge.yamanashi.jp", - "minami-alps.yamanashi.jp", - "minobu.yamanashi.jp", - "nakamichi.yamanashi.jp", - "nanbu.yamanashi.jp", - "narusawa.yamanashi.jp", - "nirasaki.yamanashi.jp", - "nishikatsura.yamanashi.jp", - "oshino.yamanashi.jp", - "otsuki.yamanashi.jp", - "showa.yamanashi.jp", - "tabayama.yamanashi.jp", - "tsuru.yamanashi.jp", - "uenohara.yamanashi.jp", - "yamanakako.yamanashi.jp", - "yamanashi.yamanashi.jp", - "*.ke", - "kg", - "org.kg", - "net.kg", - "com.kg", - "edu.kg", - "gov.kg", - "mil.kg", - "*.kh", - "ki", - "edu.ki", - "biz.ki", - "net.ki", - "org.ki", - "gov.ki", - "info.ki", - "com.ki", - "km", - "org.km", - "nom.km", - "gov.km", - "prd.km", - "tm.km", - "edu.km", - "mil.km", - "ass.km", - "com.km", - "coop.km", - "asso.km", - "presse.km", - "medecin.km", - "notaires.km", - "pharmaciens.km", - "veterinaire.km", - "gouv.km", - "kn", - "net.kn", - "org.kn", - "edu.kn", - "gov.kn", - "kp", - "com.kp", - "edu.kp", - "gov.kp", - "org.kp", - "rep.kp", - "tra.kp", - "kr", - "ac.kr", - "co.kr", - "es.kr", - "go.kr", - "hs.kr", - "kg.kr", - "mil.kr", - "ms.kr", - "ne.kr", - "or.kr", - "pe.kr", - "re.kr", - "sc.kr", - "busan.kr", - "chungbuk.kr", - "chungnam.kr", - "daegu.kr", - "daejeon.kr", - "gangwon.kr", - "gwangju.kr", - "gyeongbuk.kr", - "gyeonggi.kr", - "gyeongnam.kr", - "incheon.kr", - "jeju.kr", - "jeonbuk.kr", - "jeonnam.kr", - "seoul.kr", - "ulsan.kr", - "*.kw", - "ky", - "edu.ky", - "gov.ky", - "com.ky", - "org.ky", - "net.ky", - "kz", - "org.kz", - "edu.kz", - "net.kz", - "gov.kz", - "mil.kz", - "com.kz", - "la", - "int.la", - "net.la", - "info.la", - "edu.la", - "gov.la", - "per.la", - "com.la", - "org.la", - "lb", - "com.lb", - "edu.lb", - "gov.lb", - "net.lb", - "org.lb", - "lc", - "com.lc", - "net.lc", - "co.lc", - "org.lc", - "edu.lc", - "gov.lc", - "li", - "lk", - "gov.lk", - "sch.lk", - "net.lk", - "int.lk", - "com.lk", - "org.lk", - "edu.lk", - "ngo.lk", - "soc.lk", - "web.lk", - "ltd.lk", - "assn.lk", - "grp.lk", - "hotel.lk", - "ac.lk", - "lr", - "com.lr", - "edu.lr", - "gov.lr", - "org.lr", - "net.lr", - "ls", - "co.ls", - "org.ls", - "lt", - "gov.lt", - "lu", - "lv", - "com.lv", - "edu.lv", - "gov.lv", - "org.lv", - "mil.lv", - "id.lv", - "net.lv", - "asn.lv", - "conf.lv", - "ly", - "com.ly", - "net.ly", - "gov.ly", - "plc.ly", - "edu.ly", - "sch.ly", - "med.ly", - "org.ly", - "id.ly", - "ma", - "co.ma", - "net.ma", - "gov.ma", - "org.ma", - "ac.ma", - "press.ma", - "mc", - "tm.mc", - "asso.mc", - "md", - "me", - "co.me", - "net.me", - "org.me", - "edu.me", - "ac.me", - "gov.me", - "its.me", - "priv.me", - "mg", - "org.mg", - "nom.mg", - "gov.mg", - "prd.mg", - "tm.mg", - "edu.mg", - "mil.mg", - "com.mg", - "co.mg", - "mh", - "mil", - "mk", - "com.mk", - "org.mk", - "net.mk", - "edu.mk", - "gov.mk", - "inf.mk", - "name.mk", - "ml", - "com.ml", - "edu.ml", - "gouv.ml", - "gov.ml", - "net.ml", - "org.ml", - "presse.ml", - "*.mm", - "mn", - "gov.mn", - "edu.mn", - "org.mn", - "mo", - "com.mo", - "net.mo", - "org.mo", - "edu.mo", - "gov.mo", - "mobi", - "mp", - "mq", - "mr", - "gov.mr", - "ms", - "com.ms", - "edu.ms", - "gov.ms", - "net.ms", - "org.ms", - "mt", - "com.mt", - "edu.mt", - "net.mt", - "org.mt", - "mu", - "com.mu", - "net.mu", - "org.mu", - "gov.mu", - "ac.mu", - "co.mu", - "or.mu", - "museum", - "academy.museum", - "agriculture.museum", - "air.museum", - "airguard.museum", - "alabama.museum", - "alaska.museum", - "amber.museum", - "ambulance.museum", - "american.museum", - "americana.museum", - "americanantiques.museum", - "americanart.museum", - "amsterdam.museum", - "and.museum", - "annefrank.museum", - "anthro.museum", - "anthropology.museum", - "antiques.museum", - "aquarium.museum", - "arboretum.museum", - "archaeological.museum", - "archaeology.museum", - "architecture.museum", - "art.museum", - "artanddesign.museum", - "artcenter.museum", - "artdeco.museum", - "arteducation.museum", - "artgallery.museum", - "arts.museum", - "artsandcrafts.museum", - "asmatart.museum", - "assassination.museum", - "assisi.museum", - "association.museum", - "astronomy.museum", - "atlanta.museum", - "austin.museum", - "australia.museum", - "automotive.museum", - "aviation.museum", - "axis.museum", - "badajoz.museum", - "baghdad.museum", - "bahn.museum", - "bale.museum", - "baltimore.museum", - "barcelona.museum", - "baseball.museum", - "basel.museum", - "baths.museum", - "bauern.museum", - "beauxarts.museum", - "beeldengeluid.museum", - "bellevue.museum", - "bergbau.museum", - "berkeley.museum", - "berlin.museum", - "bern.museum", - "bible.museum", - "bilbao.museum", - "bill.museum", - "birdart.museum", - "birthplace.museum", - "bonn.museum", - "boston.museum", - "botanical.museum", - "botanicalgarden.museum", - "botanicgarden.museum", - "botany.museum", - "brandywinevalley.museum", - "brasil.museum", - "bristol.museum", - "british.museum", - "britishcolumbia.museum", - "broadcast.museum", - "brunel.museum", - "brussel.museum", - "brussels.museum", - "bruxelles.museum", - "building.museum", - "burghof.museum", - "bus.museum", - "bushey.museum", - "cadaques.museum", - "california.museum", - "cambridge.museum", - "can.museum", - "canada.museum", - "capebreton.museum", - "carrier.museum", - "cartoonart.museum", - "casadelamoneda.museum", - "castle.museum", - "castres.museum", - "celtic.museum", - "center.museum", - "chattanooga.museum", - "cheltenham.museum", - "chesapeakebay.museum", - "chicago.museum", - "children.museum", - "childrens.museum", - "childrensgarden.museum", - "chiropractic.museum", - "chocolate.museum", - "christiansburg.museum", - "cincinnati.museum", - "cinema.museum", - "circus.museum", - "civilisation.museum", - "civilization.museum", - "civilwar.museum", - "clinton.museum", - "clock.museum", - "coal.museum", - "coastaldefence.museum", - "cody.museum", - "coldwar.museum", - "collection.museum", - "colonialwilliamsburg.museum", - "coloradoplateau.museum", - "columbia.museum", - "columbus.museum", - "communication.museum", - "communications.museum", - "community.museum", - "computer.museum", - "computerhistory.museum", - "xn--comunicaes-v6a2o.museum", - "contemporary.museum", - "contemporaryart.museum", - "convent.museum", - "copenhagen.museum", - "corporation.museum", - "xn--correios-e-telecomunicaes-ghc29a.museum", - "corvette.museum", - "costume.museum", - "countryestate.museum", - "county.museum", - "crafts.museum", - "cranbrook.museum", - "creation.museum", - "cultural.museum", - "culturalcenter.museum", - "culture.museum", - "cyber.museum", - "cymru.museum", - "dali.museum", - "dallas.museum", - "database.museum", - "ddr.museum", - "decorativearts.museum", - "delaware.museum", - "delmenhorst.museum", - "denmark.museum", - "depot.museum", - "design.museum", - "detroit.museum", - "dinosaur.museum", - "discovery.museum", - "dolls.museum", - "donostia.museum", - "durham.museum", - "eastafrica.museum", - "eastcoast.museum", - "education.museum", - "educational.museum", - "egyptian.museum", - "eisenbahn.museum", - "elburg.museum", - "elvendrell.museum", - "embroidery.museum", - "encyclopedic.museum", - "england.museum", - "entomology.museum", - "environment.museum", - "environmentalconservation.museum", - "epilepsy.museum", - "essex.museum", - "estate.museum", - "ethnology.museum", - "exeter.museum", - "exhibition.museum", - "family.museum", - "farm.museum", - "farmequipment.museum", - "farmers.museum", - "farmstead.museum", - "field.museum", - "figueres.museum", - "filatelia.museum", - "film.museum", - "fineart.museum", - "finearts.museum", - "finland.museum", - "flanders.museum", - "florida.museum", - "force.museum", - "fortmissoula.museum", - "fortworth.museum", - "foundation.museum", - "francaise.museum", - "frankfurt.museum", - "franziskaner.museum", - "freemasonry.museum", - "freiburg.museum", - "fribourg.museum", - "frog.museum", - "fundacio.museum", - "furniture.museum", - "gallery.museum", - "garden.museum", - "gateway.museum", - "geelvinck.museum", - "gemological.museum", - "geology.museum", - "georgia.museum", - "giessen.museum", - "glas.museum", - "glass.museum", - "gorge.museum", - "grandrapids.museum", - "graz.museum", - "guernsey.museum", - "halloffame.museum", - "hamburg.museum", - "handson.museum", - "harvestcelebration.museum", - "hawaii.museum", - "health.museum", - "heimatunduhren.museum", - "hellas.museum", - "helsinki.museum", - "hembygdsforbund.museum", - "heritage.museum", - "histoire.museum", - "historical.museum", - "historicalsociety.museum", - "historichouses.museum", - "historisch.museum", - "historisches.museum", - "history.museum", - "historyofscience.museum", - "horology.museum", - "house.museum", - "humanities.museum", - "illustration.museum", - "imageandsound.museum", - "indian.museum", - "indiana.museum", - "indianapolis.museum", - "indianmarket.museum", - "intelligence.museum", - "interactive.museum", - "iraq.museum", - "iron.museum", - "isleofman.museum", - "jamison.museum", - "jefferson.museum", - "jerusalem.museum", - "jewelry.museum", - "jewish.museum", - "jewishart.museum", - "jfk.museum", - "journalism.museum", - "judaica.museum", - "judygarland.museum", - "juedisches.museum", - "juif.museum", - "karate.museum", - "karikatur.museum", - "kids.museum", - "koebenhavn.museum", - "koeln.museum", - "kunst.museum", - "kunstsammlung.museum", - "kunstunddesign.museum", - "labor.museum", - "labour.museum", - "lajolla.museum", - "lancashire.museum", - "landes.museum", - "lans.museum", - "xn--lns-qla.museum", - "larsson.museum", - "lewismiller.museum", - "lincoln.museum", - "linz.museum", - "living.museum", - "livinghistory.museum", - "localhistory.museum", - "london.museum", - "losangeles.museum", - "louvre.museum", - "loyalist.museum", - "lucerne.museum", - "luxembourg.museum", - "luzern.museum", - "mad.museum", - "madrid.museum", - "mallorca.museum", - "manchester.museum", - "mansion.museum", - "mansions.museum", - "manx.museum", - "marburg.museum", - "maritime.museum", - "maritimo.museum", - "maryland.museum", - "marylhurst.museum", - "media.museum", - "medical.museum", - "medizinhistorisches.museum", - "meeres.museum", - "memorial.museum", - "mesaverde.museum", - "michigan.museum", - "midatlantic.museum", - "military.museum", - "mill.museum", - "miners.museum", - "mining.museum", - "minnesota.museum", - "missile.museum", - "missoula.museum", - "modern.museum", - "moma.museum", - "money.museum", - "monmouth.museum", - "monticello.museum", - "montreal.museum", - "moscow.museum", - "motorcycle.museum", - "muenchen.museum", - "muenster.museum", - "mulhouse.museum", - "muncie.museum", - "museet.museum", - "museumcenter.museum", - "museumvereniging.museum", - "music.museum", - "national.museum", - "nationalfirearms.museum", - "nationalheritage.museum", - "nativeamerican.museum", - "naturalhistory.museum", - "naturalhistorymuseum.museum", - "naturalsciences.museum", - "nature.museum", - "naturhistorisches.museum", - "natuurwetenschappen.museum", - "naumburg.museum", - "naval.museum", - "nebraska.museum", - "neues.museum", - "newhampshire.museum", - "newjersey.museum", - "newmexico.museum", - "newport.museum", - "newspaper.museum", - "newyork.museum", - "niepce.museum", - "norfolk.museum", - "north.museum", - "nrw.museum", - "nuernberg.museum", - "nuremberg.museum", - "nyc.museum", - "nyny.museum", - "oceanographic.museum", - "oceanographique.museum", - "omaha.museum", - "online.museum", - "ontario.museum", - "openair.museum", - "oregon.museum", - "oregontrail.museum", - "otago.museum", - "oxford.museum", - "pacific.museum", - "paderborn.museum", - "palace.museum", - "paleo.museum", - "palmsprings.museum", - "panama.museum", - "paris.museum", - "pasadena.museum", - "pharmacy.museum", - "philadelphia.museum", - "philadelphiaarea.museum", - "philately.museum", - "phoenix.museum", - "photography.museum", - "pilots.museum", - "pittsburgh.museum", - "planetarium.museum", - "plantation.museum", - "plants.museum", - "plaza.museum", - "portal.museum", - "portland.museum", - "portlligat.museum", - "posts-and-telecommunications.museum", - "preservation.museum", - "presidio.museum", - "press.museum", - "project.museum", - "public.museum", - "pubol.museum", - "quebec.museum", - "railroad.museum", - "railway.museum", - "research.museum", - "resistance.museum", - "riodejaneiro.museum", - "rochester.museum", - "rockart.museum", - "roma.museum", - "russia.museum", - "saintlouis.museum", - "salem.museum", - "salvadordali.museum", - "salzburg.museum", - "sandiego.museum", - "sanfrancisco.museum", - "santabarbara.museum", - "santacruz.museum", - "santafe.museum", - "saskatchewan.museum", - "satx.museum", - "savannahga.museum", - "schlesisches.museum", - "schoenbrunn.museum", - "schokoladen.museum", - "school.museum", - "schweiz.museum", - "science.museum", - "scienceandhistory.museum", - "scienceandindustry.museum", - "sciencecenter.museum", - "sciencecenters.museum", - "science-fiction.museum", - "sciencehistory.museum", - "sciences.museum", - "sciencesnaturelles.museum", - "scotland.museum", - "seaport.museum", - "settlement.museum", - "settlers.museum", - "shell.museum", - "sherbrooke.museum", - "sibenik.museum", - "silk.museum", - "ski.museum", - "skole.museum", - "society.museum", - "sologne.museum", - "soundandvision.museum", - "southcarolina.museum", - "southwest.museum", - "space.museum", - "spy.museum", - "square.museum", - "stadt.museum", - "stalbans.museum", - "starnberg.museum", - "state.museum", - "stateofdelaware.museum", - "station.museum", - "steam.museum", - "steiermark.museum", - "stjohn.museum", - "stockholm.museum", - "stpetersburg.museum", - "stuttgart.museum", - "suisse.museum", - "surgeonshall.museum", - "surrey.museum", - "svizzera.museum", - "sweden.museum", - "sydney.museum", - "tank.museum", - "tcm.museum", - "technology.museum", - "telekommunikation.museum", - "television.museum", - "texas.museum", - "textile.museum", - "theater.museum", - "time.museum", - "timekeeping.museum", - "topology.museum", - "torino.museum", - "touch.museum", - "town.museum", - "transport.museum", - "tree.museum", - "trolley.museum", - "trust.museum", - "trustee.museum", - "uhren.museum", - "ulm.museum", - "undersea.museum", - "university.museum", - "usa.museum", - "usantiques.museum", - "usarts.museum", - "uscountryestate.museum", - "usculture.museum", - "usdecorativearts.museum", - "usgarden.museum", - "ushistory.museum", - "ushuaia.museum", - "uslivinghistory.museum", - "utah.museum", - "uvic.museum", - "valley.museum", - "vantaa.museum", - "versailles.museum", - "viking.museum", - "village.museum", - "virginia.museum", - "virtual.museum", - "virtuel.museum", - "vlaanderen.museum", - "volkenkunde.museum", - "wales.museum", - "wallonie.museum", - "war.museum", - "washingtondc.museum", - "watchandclock.museum", - "watch-and-clock.museum", - "western.museum", - "westfalen.museum", - "whaling.museum", - "wildlife.museum", - "williamsburg.museum", - "windmill.museum", - "workshop.museum", - "york.museum", - "yorkshire.museum", - "yosemite.museum", - "youth.museum", - "zoological.museum", - "zoology.museum", - "xn--9dbhblg6di.museum", - "xn--h1aegh.museum", - "mv", - "aero.mv", - "biz.mv", - "com.mv", - "coop.mv", - "edu.mv", - "gov.mv", - "info.mv", - "int.mv", - "mil.mv", - "museum.mv", - "name.mv", - "net.mv", - "org.mv", - "pro.mv", - "mw", - "ac.mw", - "biz.mw", - "co.mw", - "com.mw", - "coop.mw", - "edu.mw", - "gov.mw", - "int.mw", - "museum.mw", - "net.mw", - "org.mw", - "mx", - "com.mx", - "org.mx", - "gob.mx", - "edu.mx", - "net.mx", - "my", - "com.my", - "net.my", - "org.my", - "gov.my", - "edu.my", - "mil.my", - "name.my", - "*.mz", - "!teledata.mz", - "na", - "info.na", - "pro.na", - "name.na", - "school.na", - "or.na", - "dr.na", - "us.na", - "mx.na", - "ca.na", - "in.na", - "cc.na", - "tv.na", - "ws.na", - "mobi.na", - "co.na", - "com.na", - "org.na", - "name", - "nc", - "asso.nc", - "ne", - "net", - "nf", - "com.nf", - "net.nf", - "per.nf", - "rec.nf", - "web.nf", - "arts.nf", - "firm.nf", - "info.nf", - "other.nf", - "store.nf", - "ng", - "com.ng", - "edu.ng", - "gov.ng", - "i.ng", - "mil.ng", - "mobi.ng", - "name.ng", - "net.ng", - "org.ng", - "sch.ng", - "com.ni", - "gob.ni", - "edu.ni", - "org.ni", - "nom.ni", - "net.ni", - "mil.ni", - "co.ni", - "biz.ni", - "web.ni", - "int.ni", - "ac.ni", - "in.ni", - "info.ni", - "nl", - "bv.nl", - "no", - "fhs.no", - "vgs.no", - "fylkesbibl.no", - "folkebibl.no", - "museum.no", - "idrett.no", - "priv.no", - "mil.no", - "stat.no", - "dep.no", - "kommune.no", - "herad.no", - "aa.no", - "ah.no", - "bu.no", - "fm.no", - "hl.no", - "hm.no", - "jan-mayen.no", - "mr.no", - "nl.no", - "nt.no", - "of.no", - "ol.no", - "oslo.no", - "rl.no", - "sf.no", - "st.no", - "svalbard.no", - "tm.no", - "tr.no", - "va.no", - "vf.no", - "gs.aa.no", - "gs.ah.no", - "gs.bu.no", - "gs.fm.no", - "gs.hl.no", - "gs.hm.no", - "gs.jan-mayen.no", - "gs.mr.no", - "gs.nl.no", - "gs.nt.no", - "gs.of.no", - "gs.ol.no", - "gs.oslo.no", - "gs.rl.no", - "gs.sf.no", - "gs.st.no", - "gs.svalbard.no", - "gs.tm.no", - "gs.tr.no", - "gs.va.no", - "gs.vf.no", - "akrehamn.no", - "xn--krehamn-dxa.no", - "algard.no", - "xn--lgrd-poac.no", - "arna.no", - "brumunddal.no", - "bryne.no", - "bronnoysund.no", - "xn--brnnysund-m8ac.no", - "drobak.no", - "xn--drbak-wua.no", - "egersund.no", - "fetsund.no", - "floro.no", - "xn--flor-jra.no", - "fredrikstad.no", - "hokksund.no", - "honefoss.no", - "xn--hnefoss-q1a.no", - "jessheim.no", - "jorpeland.no", - "xn--jrpeland-54a.no", - "kirkenes.no", - "kopervik.no", - "krokstadelva.no", - "langevag.no", - "xn--langevg-jxa.no", - "leirvik.no", - "mjondalen.no", - "xn--mjndalen-64a.no", - "mo-i-rana.no", - "mosjoen.no", - "xn--mosjen-eya.no", - "nesoddtangen.no", - "orkanger.no", - "osoyro.no", - "xn--osyro-wua.no", - "raholt.no", - "xn--rholt-mra.no", - "sandnessjoen.no", - "xn--sandnessjen-ogb.no", - "skedsmokorset.no", - "slattum.no", - "spjelkavik.no", - "stathelle.no", - "stavern.no", - "stjordalshalsen.no", - "xn--stjrdalshalsen-sqb.no", - "tananger.no", - "tranby.no", - "vossevangen.no", - "afjord.no", - "xn--fjord-lra.no", - "agdenes.no", - "al.no", - "xn--l-1fa.no", - "alesund.no", - "xn--lesund-hua.no", - "alstahaug.no", - "alta.no", - "xn--lt-liac.no", - "alaheadju.no", - "xn--laheadju-7ya.no", - "alvdal.no", - "amli.no", - "xn--mli-tla.no", - "amot.no", - "xn--mot-tla.no", - "andebu.no", - "andoy.no", - "xn--andy-ira.no", - "andasuolo.no", - "ardal.no", - "xn--rdal-poa.no", - "aremark.no", - "arendal.no", - "xn--s-1fa.no", - "aseral.no", - "xn--seral-lra.no", - "asker.no", - "askim.no", - "askvoll.no", - "askoy.no", - "xn--asky-ira.no", - "asnes.no", - "xn--snes-poa.no", - "audnedaln.no", - "aukra.no", - "aure.no", - "aurland.no", - "aurskog-holand.no", - "xn--aurskog-hland-jnb.no", - "austevoll.no", - "austrheim.no", - "averoy.no", - "xn--avery-yua.no", - "balestrand.no", - "ballangen.no", - "balat.no", - "xn--blt-elab.no", - "balsfjord.no", - "bahccavuotna.no", - "xn--bhccavuotna-k7a.no", - "bamble.no", - "bardu.no", - "beardu.no", - "beiarn.no", - "bajddar.no", - "xn--bjddar-pta.no", - "baidar.no", - "xn--bidr-5nac.no", - "berg.no", - "bergen.no", - "berlevag.no", - "xn--berlevg-jxa.no", - "bearalvahki.no", - "xn--bearalvhki-y4a.no", - "bindal.no", - "birkenes.no", - "bjarkoy.no", - "xn--bjarky-fya.no", - "bjerkreim.no", - "bjugn.no", - "bodo.no", - "xn--bod-2na.no", - "badaddja.no", - "xn--bdddj-mrabd.no", - "budejju.no", - "bokn.no", - "bremanger.no", - "bronnoy.no", - "xn--brnny-wuac.no", - "bygland.no", - "bykle.no", - "barum.no", - "xn--brum-voa.no", - "bo.telemark.no", - "xn--b-5ga.telemark.no", - "bo.nordland.no", - "xn--b-5ga.nordland.no", - "bievat.no", - "xn--bievt-0qa.no", - "bomlo.no", - "xn--bmlo-gra.no", - "batsfjord.no", - "xn--btsfjord-9za.no", - "bahcavuotna.no", - "xn--bhcavuotna-s4a.no", - "dovre.no", - "drammen.no", - "drangedal.no", - "dyroy.no", - "xn--dyry-ira.no", - "donna.no", - "xn--dnna-gra.no", - "eid.no", - "eidfjord.no", - "eidsberg.no", - "eidskog.no", - "eidsvoll.no", - "eigersund.no", - "elverum.no", - "enebakk.no", - "engerdal.no", - "etne.no", - "etnedal.no", - "evenes.no", - "evenassi.no", - "xn--eveni-0qa01ga.no", - "evje-og-hornnes.no", - "farsund.no", - "fauske.no", - "fuossko.no", - "fuoisku.no", - "fedje.no", - "fet.no", - "finnoy.no", - "xn--finny-yua.no", - "fitjar.no", - "fjaler.no", - "fjell.no", - "flakstad.no", - "flatanger.no", - "flekkefjord.no", - "flesberg.no", - "flora.no", - "fla.no", - "xn--fl-zia.no", - "folldal.no", - "forsand.no", - "fosnes.no", - "frei.no", - "frogn.no", - "froland.no", - "frosta.no", - "frana.no", - "xn--frna-woa.no", - "froya.no", - "xn--frya-hra.no", - "fusa.no", - "fyresdal.no", - "forde.no", - "xn--frde-gra.no", - "gamvik.no", - "gangaviika.no", - "xn--ggaviika-8ya47h.no", - "gaular.no", - "gausdal.no", - "gildeskal.no", - "xn--gildeskl-g0a.no", - "giske.no", - "gjemnes.no", - "gjerdrum.no", - "gjerstad.no", - "gjesdal.no", - "gjovik.no", - "xn--gjvik-wua.no", - "gloppen.no", - "gol.no", - "gran.no", - "grane.no", - "granvin.no", - "gratangen.no", - "grimstad.no", - "grong.no", - "kraanghke.no", - "xn--kranghke-b0a.no", - "grue.no", - "gulen.no", - "hadsel.no", - "halden.no", - "halsa.no", - "hamar.no", - "hamaroy.no", - "habmer.no", - "xn--hbmer-xqa.no", - "hapmir.no", - "xn--hpmir-xqa.no", - "hammerfest.no", - "hammarfeasta.no", - "xn--hmmrfeasta-s4ac.no", - "haram.no", - "hareid.no", - "harstad.no", - "hasvik.no", - "aknoluokta.no", - "xn--koluokta-7ya57h.no", - "hattfjelldal.no", - "aarborte.no", - "haugesund.no", - "hemne.no", - "hemnes.no", - "hemsedal.no", - "heroy.more-og-romsdal.no", - "xn--hery-ira.xn--mre-og-romsdal-qqb.no", - "heroy.nordland.no", - "xn--hery-ira.nordland.no", - "hitra.no", - "hjartdal.no", - "hjelmeland.no", - "hobol.no", - "xn--hobl-ira.no", - "hof.no", - "hol.no", - "hole.no", - "holmestrand.no", - "holtalen.no", - "xn--holtlen-hxa.no", - "hornindal.no", - "horten.no", - "hurdal.no", - "hurum.no", - "hvaler.no", - "hyllestad.no", - "hagebostad.no", - "xn--hgebostad-g3a.no", - "hoyanger.no", - "xn--hyanger-q1a.no", - "hoylandet.no", - "xn--hylandet-54a.no", - "ha.no", - "xn--h-2fa.no", - "ibestad.no", - "inderoy.no", - "xn--indery-fya.no", - "iveland.no", - "jevnaker.no", - "jondal.no", - "jolster.no", - "xn--jlster-bya.no", - "karasjok.no", - "karasjohka.no", - "xn--krjohka-hwab49j.no", - "karlsoy.no", - "galsa.no", - "xn--gls-elac.no", - "karmoy.no", - "xn--karmy-yua.no", - "kautokeino.no", - "guovdageaidnu.no", - "klepp.no", - "klabu.no", - "xn--klbu-woa.no", - "kongsberg.no", - "kongsvinger.no", - "kragero.no", - "xn--krager-gya.no", - "kristiansand.no", - "kristiansund.no", - "krodsherad.no", - "xn--krdsherad-m8a.no", - "kvalsund.no", - "rahkkeravju.no", - "xn--rhkkervju-01af.no", - "kvam.no", - "kvinesdal.no", - "kvinnherad.no", - "kviteseid.no", - "kvitsoy.no", - "xn--kvitsy-fya.no", - "kvafjord.no", - "xn--kvfjord-nxa.no", - "giehtavuoatna.no", - "kvanangen.no", - "xn--kvnangen-k0a.no", - "navuotna.no", - "xn--nvuotna-hwa.no", - "kafjord.no", - "xn--kfjord-iua.no", - "gaivuotna.no", - "xn--givuotna-8ya.no", - "larvik.no", - "lavangen.no", - "lavagis.no", - "loabat.no", - "xn--loabt-0qa.no", - "lebesby.no", - "davvesiida.no", - "leikanger.no", - "leirfjord.no", - "leka.no", - "leksvik.no", - "lenvik.no", - "leangaviika.no", - "xn--leagaviika-52b.no", - "lesja.no", - "levanger.no", - "lier.no", - "lierne.no", - "lillehammer.no", - "lillesand.no", - "lindesnes.no", - "lindas.no", - "xn--linds-pra.no", - "lom.no", - "loppa.no", - "lahppi.no", - "xn--lhppi-xqa.no", - "lund.no", - "lunner.no", - "luroy.no", - "xn--lury-ira.no", - "luster.no", - "lyngdal.no", - "lyngen.no", - "ivgu.no", - "lardal.no", - "lerdal.no", - "xn--lrdal-sra.no", - "lodingen.no", - "xn--ldingen-q1a.no", - "lorenskog.no", - "xn--lrenskog-54a.no", - "loten.no", - "xn--lten-gra.no", - "malvik.no", - "masoy.no", - "xn--msy-ula0h.no", - "muosat.no", - "xn--muost-0qa.no", - "mandal.no", - "marker.no", - "marnardal.no", - "masfjorden.no", - "meland.no", - "meldal.no", - "melhus.no", - "meloy.no", - "xn--mely-ira.no", - "meraker.no", - "xn--merker-kua.no", - "moareke.no", - "xn--moreke-jua.no", - "midsund.no", - "midtre-gauldal.no", - "modalen.no", - "modum.no", - "molde.no", - "moskenes.no", - "moss.no", - "mosvik.no", - "malselv.no", - "xn--mlselv-iua.no", - "malatvuopmi.no", - "xn--mlatvuopmi-s4a.no", - "namdalseid.no", - "aejrie.no", - "namsos.no", - "namsskogan.no", - "naamesjevuemie.no", - "xn--nmesjevuemie-tcba.no", - "laakesvuemie.no", - "nannestad.no", - "narvik.no", - "narviika.no", - "naustdal.no", - "nedre-eiker.no", - "nes.akershus.no", - "nes.buskerud.no", - "nesna.no", - "nesodden.no", - "nesseby.no", - "unjarga.no", - "xn--unjrga-rta.no", - "nesset.no", - "nissedal.no", - "nittedal.no", - "nord-aurdal.no", - "nord-fron.no", - "nord-odal.no", - "norddal.no", - "nordkapp.no", - "davvenjarga.no", - "xn--davvenjrga-y4a.no", - "nordre-land.no", - "nordreisa.no", - "raisa.no", - "xn--risa-5na.no", - "nore-og-uvdal.no", - "notodden.no", - "naroy.no", - "xn--nry-yla5g.no", - "notteroy.no", - "xn--nttery-byae.no", - "odda.no", - "oksnes.no", - "xn--ksnes-uua.no", - "oppdal.no", - "oppegard.no", - "xn--oppegrd-ixa.no", - "orkdal.no", - "orland.no", - "xn--rland-uua.no", - "orskog.no", - "xn--rskog-uua.no", - "orsta.no", - "xn--rsta-fra.no", - "os.hedmark.no", - "os.hordaland.no", - "osen.no", - "osteroy.no", - "xn--ostery-fya.no", - "ostre-toten.no", - "xn--stre-toten-zcb.no", - "overhalla.no", - "ovre-eiker.no", - "xn--vre-eiker-k8a.no", - "oyer.no", - "xn--yer-zna.no", - "oygarden.no", - "xn--ygarden-p1a.no", - "oystre-slidre.no", - "xn--ystre-slidre-ujb.no", - "porsanger.no", - "porsangu.no", - "xn--porsgu-sta26f.no", - "porsgrunn.no", - "radoy.no", - "xn--rady-ira.no", - "rakkestad.no", - "rana.no", - "ruovat.no", - "randaberg.no", - "rauma.no", - "rendalen.no", - "rennebu.no", - "rennesoy.no", - "xn--rennesy-v1a.no", - "rindal.no", - "ringebu.no", - "ringerike.no", - "ringsaker.no", - "rissa.no", - "risor.no", - "xn--risr-ira.no", - "roan.no", - "rollag.no", - "rygge.no", - "ralingen.no", - "xn--rlingen-mxa.no", - "rodoy.no", - "xn--rdy-0nab.no", - "romskog.no", - "xn--rmskog-bya.no", - "roros.no", - "xn--rros-gra.no", - "rost.no", - "xn--rst-0na.no", - "royken.no", - "xn--ryken-vua.no", - "royrvik.no", - "xn--ryrvik-bya.no", - "rade.no", - "xn--rde-ula.no", - "salangen.no", - "siellak.no", - "saltdal.no", - "salat.no", - "xn--slt-elab.no", - "xn--slat-5na.no", - "samnanger.no", - "sande.more-og-romsdal.no", - "sande.xn--mre-og-romsdal-qqb.no", - "sande.vestfold.no", - "sandefjord.no", - "sandnes.no", - "sandoy.no", - "xn--sandy-yua.no", - "sarpsborg.no", - "sauda.no", - "sauherad.no", - "sel.no", - "selbu.no", - "selje.no", - "seljord.no", - "sigdal.no", - "siljan.no", - "sirdal.no", - "skaun.no", - "skedsmo.no", - "ski.no", - "skien.no", - "skiptvet.no", - "skjervoy.no", - "xn--skjervy-v1a.no", - "skierva.no", - "xn--skierv-uta.no", - "skjak.no", - "xn--skjk-soa.no", - "skodje.no", - "skanland.no", - "xn--sknland-fxa.no", - "skanit.no", - "xn--sknit-yqa.no", - "smola.no", - "xn--smla-hra.no", - "snillfjord.no", - "snasa.no", - "xn--snsa-roa.no", - "snoasa.no", - "snaase.no", - "xn--snase-nra.no", - "sogndal.no", - "sokndal.no", - "sola.no", - "solund.no", - "songdalen.no", - "sortland.no", - "spydeberg.no", - "stange.no", - "stavanger.no", - "steigen.no", - "steinkjer.no", - "stjordal.no", - "xn--stjrdal-s1a.no", - "stokke.no", - "stor-elvdal.no", - "stord.no", - "stordal.no", - "storfjord.no", - "omasvuotna.no", - "strand.no", - "stranda.no", - "stryn.no", - "sula.no", - "suldal.no", - "sund.no", - "sunndal.no", - "surnadal.no", - "sveio.no", - "svelvik.no", - "sykkylven.no", - "sogne.no", - "xn--sgne-gra.no", - "somna.no", - "xn--smna-gra.no", - "sondre-land.no", - "xn--sndre-land-0cb.no", - "sor-aurdal.no", - "xn--sr-aurdal-l8a.no", - "sor-fron.no", - "xn--sr-fron-q1a.no", - "sor-odal.no", - "xn--sr-odal-q1a.no", - "sor-varanger.no", - "xn--sr-varanger-ggb.no", - "matta-varjjat.no", - "xn--mtta-vrjjat-k7af.no", - "sorfold.no", - "xn--srfold-bya.no", - "sorreisa.no", - "xn--srreisa-q1a.no", - "sorum.no", - "xn--srum-gra.no", - "tana.no", - "deatnu.no", - "time.no", - "tingvoll.no", - "tinn.no", - "tjeldsund.no", - "dielddanuorri.no", - "tjome.no", - "xn--tjme-hra.no", - "tokke.no", - "tolga.no", - "torsken.no", - "tranoy.no", - "xn--trany-yua.no", - "tromso.no", - "xn--troms-zua.no", - "tromsa.no", - "romsa.no", - "trondheim.no", - "troandin.no", - "trysil.no", - "trana.no", - "xn--trna-woa.no", - "trogstad.no", - "xn--trgstad-r1a.no", - "tvedestrand.no", - "tydal.no", - "tynset.no", - "tysfjord.no", - "divtasvuodna.no", - "divttasvuotna.no", - "tysnes.no", - "tysvar.no", - "xn--tysvr-vra.no", - "tonsberg.no", - "xn--tnsberg-q1a.no", - "ullensaker.no", - "ullensvang.no", - "ulvik.no", - "utsira.no", - "vadso.no", - "xn--vads-jra.no", - "cahcesuolo.no", - "xn--hcesuolo-7ya35b.no", - "vaksdal.no", - "valle.no", - "vang.no", - "vanylven.no", - "vardo.no", - "xn--vard-jra.no", - "varggat.no", - "xn--vrggt-xqad.no", - "vefsn.no", - "vaapste.no", - "vega.no", - "vegarshei.no", - "xn--vegrshei-c0a.no", - "vennesla.no", - "verdal.no", - "verran.no", - "vestby.no", - "vestnes.no", - "vestre-slidre.no", - "vestre-toten.no", - "vestvagoy.no", - "xn--vestvgy-ixa6o.no", - "vevelstad.no", - "vik.no", - "vikna.no", - "vindafjord.no", - "volda.no", - "voss.no", - "varoy.no", - "xn--vry-yla5g.no", - "vagan.no", - "xn--vgan-qoa.no", - "voagat.no", - "vagsoy.no", - "xn--vgsy-qoa0j.no", - "vaga.no", - "xn--vg-yiab.no", - "valer.ostfold.no", - "xn--vler-qoa.xn--stfold-9xa.no", - "valer.hedmark.no", - "xn--vler-qoa.hedmark.no", - "*.np", - "nr", - "biz.nr", - "info.nr", - "gov.nr", - "edu.nr", - "org.nr", - "net.nr", - "com.nr", - "nu", - "nz", - "ac.nz", - "co.nz", - "cri.nz", - "geek.nz", - "gen.nz", - "govt.nz", - "health.nz", - "iwi.nz", - "kiwi.nz", - "maori.nz", - "mil.nz", - "xn--mori-qsa.nz", - "net.nz", - "org.nz", - "parliament.nz", - "school.nz", - "om", - "co.om", - "com.om", - "edu.om", - "gov.om", - "med.om", - "museum.om", - "net.om", - "org.om", - "pro.om", - "org", - "pa", - "ac.pa", - "gob.pa", - "com.pa", - "org.pa", - "sld.pa", - "edu.pa", - "net.pa", - "ing.pa", - "abo.pa", - "med.pa", - "nom.pa", - "pe", - "edu.pe", - "gob.pe", - "nom.pe", - "mil.pe", - "org.pe", - "com.pe", - "net.pe", - "pf", - "com.pf", - "org.pf", - "edu.pf", - "*.pg", - "ph", - "com.ph", - "net.ph", - "org.ph", - "gov.ph", - "edu.ph", - "ngo.ph", - "mil.ph", - "i.ph", - "pk", - "com.pk", - "net.pk", - "edu.pk", - "org.pk", - "fam.pk", - "biz.pk", - "web.pk", - "gov.pk", - "gob.pk", - "gok.pk", - "gon.pk", - "gop.pk", - "gos.pk", - "info.pk", - "pl", - "com.pl", - "net.pl", - "org.pl", - "aid.pl", - "agro.pl", - "atm.pl", - "auto.pl", - "biz.pl", - "edu.pl", - "gmina.pl", - "gsm.pl", - "info.pl", - "mail.pl", - "miasta.pl", - "media.pl", - "mil.pl", - "nieruchomosci.pl", - "nom.pl", - "pc.pl", - "powiat.pl", - "priv.pl", - "realestate.pl", - "rel.pl", - "sex.pl", - "shop.pl", - "sklep.pl", - "sos.pl", - "szkola.pl", - "targi.pl", - "tm.pl", - "tourism.pl", - "travel.pl", - "turystyka.pl", - "gov.pl", - "ap.gov.pl", - "ic.gov.pl", - "is.gov.pl", - "us.gov.pl", - "kmpsp.gov.pl", - "kppsp.gov.pl", - "kwpsp.gov.pl", - "psp.gov.pl", - "wskr.gov.pl", - "kwp.gov.pl", - "mw.gov.pl", - "ug.gov.pl", - "um.gov.pl", - "umig.gov.pl", - "ugim.gov.pl", - "upow.gov.pl", - "uw.gov.pl", - "starostwo.gov.pl", - "pa.gov.pl", - "po.gov.pl", - "psse.gov.pl", - "pup.gov.pl", - "rzgw.gov.pl", - "sa.gov.pl", - "so.gov.pl", - "sr.gov.pl", - "wsa.gov.pl", - "sko.gov.pl", - "uzs.gov.pl", - "wiih.gov.pl", - "winb.gov.pl", - "pinb.gov.pl", - "wios.gov.pl", - "witd.gov.pl", - "wzmiuw.gov.pl", - "piw.gov.pl", - "wiw.gov.pl", - "griw.gov.pl", - "wif.gov.pl", - "oum.gov.pl", - "sdn.gov.pl", - "zp.gov.pl", - "uppo.gov.pl", - "mup.gov.pl", - "wuoz.gov.pl", - "konsulat.gov.pl", - "oirm.gov.pl", - "augustow.pl", - "babia-gora.pl", - "bedzin.pl", - "beskidy.pl", - "bialowieza.pl", - "bialystok.pl", - "bielawa.pl", - "bieszczady.pl", - "boleslawiec.pl", - "bydgoszcz.pl", - "bytom.pl", - "cieszyn.pl", - "czeladz.pl", - "czest.pl", - "dlugoleka.pl", - "elblag.pl", - "elk.pl", - "glogow.pl", - "gniezno.pl", - "gorlice.pl", - "grajewo.pl", - "ilawa.pl", - "jaworzno.pl", - "jelenia-gora.pl", - "jgora.pl", - "kalisz.pl", - "kazimierz-dolny.pl", - "karpacz.pl", - "kartuzy.pl", - "kaszuby.pl", - "katowice.pl", - "kepno.pl", - "ketrzyn.pl", - "klodzko.pl", - "kobierzyce.pl", - "kolobrzeg.pl", - "konin.pl", - "konskowola.pl", - "kutno.pl", - "lapy.pl", - "lebork.pl", - "legnica.pl", - "lezajsk.pl", - "limanowa.pl", - "lomza.pl", - "lowicz.pl", - "lubin.pl", - "lukow.pl", - "malbork.pl", - "malopolska.pl", - "mazowsze.pl", - "mazury.pl", - "mielec.pl", - "mielno.pl", - "mragowo.pl", - "naklo.pl", - "nowaruda.pl", - "nysa.pl", - "olawa.pl", - "olecko.pl", - "olkusz.pl", - "olsztyn.pl", - "opoczno.pl", - "opole.pl", - "ostroda.pl", - "ostroleka.pl", - "ostrowiec.pl", - "ostrowwlkp.pl", - "pila.pl", - "pisz.pl", - "podhale.pl", - "podlasie.pl", - "polkowice.pl", - "pomorze.pl", - "pomorskie.pl", - "prochowice.pl", - "pruszkow.pl", - "przeworsk.pl", - "pulawy.pl", - "radom.pl", - "rawa-maz.pl", - "rybnik.pl", - "rzeszow.pl", - "sanok.pl", - "sejny.pl", - "slask.pl", - "slupsk.pl", - "sosnowiec.pl", - "stalowa-wola.pl", - "skoczow.pl", - "starachowice.pl", - "stargard.pl", - "suwalki.pl", - "swidnica.pl", - "swiebodzin.pl", - "swinoujscie.pl", - "szczecin.pl", - "szczytno.pl", - "tarnobrzeg.pl", - "tgory.pl", - "turek.pl", - "tychy.pl", - "ustka.pl", - "walbrzych.pl", - "warmia.pl", - "warszawa.pl", - "waw.pl", - "wegrow.pl", - "wielun.pl", - "wlocl.pl", - "wloclawek.pl", - "wodzislaw.pl", - "wolomin.pl", - "wroclaw.pl", - "zachpomor.pl", - "zagan.pl", - "zarow.pl", - "zgora.pl", - "zgorzelec.pl", - "pm", - "pn", - "gov.pn", - "co.pn", - "org.pn", - "edu.pn", - "net.pn", - "post", - "pr", - "com.pr", - "net.pr", - "org.pr", - "gov.pr", - "edu.pr", - "isla.pr", - "pro.pr", - "biz.pr", - "info.pr", - "name.pr", - "est.pr", - "prof.pr", - "ac.pr", - "pro", - "aaa.pro", - "aca.pro", - "acct.pro", - "avocat.pro", - "bar.pro", - "cpa.pro", - "eng.pro", - "jur.pro", - "law.pro", - "med.pro", - "recht.pro", - "ps", - "edu.ps", - "gov.ps", - "sec.ps", - "plo.ps", - "com.ps", - "org.ps", - "net.ps", - "pt", - "net.pt", - "gov.pt", - "org.pt", - "edu.pt", - "int.pt", - "publ.pt", - "com.pt", - "nome.pt", - "pw", - "co.pw", - "ne.pw", - "or.pw", - "ed.pw", - "go.pw", - "belau.pw", - "py", - "com.py", - "coop.py", - "edu.py", - "gov.py", - "mil.py", - "net.py", - "org.py", - "qa", - "com.qa", - "edu.qa", - "gov.qa", - "mil.qa", - "name.qa", - "net.qa", - "org.qa", - "sch.qa", - "re", - "asso.re", - "com.re", - "nom.re", - "ro", - "arts.ro", - "com.ro", - "firm.ro", - "info.ro", - "nom.ro", - "nt.ro", - "org.ro", - "rec.ro", - "store.ro", - "tm.ro", - "www.ro", - "rs", - "ac.rs", - "co.rs", - "edu.rs", - "gov.rs", - "in.rs", - "org.rs", - "ru", - "ac.ru", - "com.ru", - "edu.ru", - "int.ru", - "net.ru", - "org.ru", - "pp.ru", - "adygeya.ru", - "altai.ru", - "amur.ru", - "arkhangelsk.ru", - "astrakhan.ru", - "bashkiria.ru", - "belgorod.ru", - "bir.ru", - "bryansk.ru", - "buryatia.ru", - "cbg.ru", - "chel.ru", - "chelyabinsk.ru", - "chita.ru", - "chukotka.ru", - "chuvashia.ru", - "dagestan.ru", - "dudinka.ru", - "e-burg.ru", - "grozny.ru", - "irkutsk.ru", - "ivanovo.ru", - "izhevsk.ru", - "jar.ru", - "joshkar-ola.ru", - "kalmykia.ru", - "kaluga.ru", - "kamchatka.ru", - "karelia.ru", - "kazan.ru", - "kchr.ru", - "kemerovo.ru", - "khabarovsk.ru", - "khakassia.ru", - "khv.ru", - "kirov.ru", - "koenig.ru", - "komi.ru", - "kostroma.ru", - "krasnoyarsk.ru", - "kuban.ru", - "kurgan.ru", - "kursk.ru", - "lipetsk.ru", - "magadan.ru", - "mari.ru", - "mari-el.ru", - "marine.ru", - "mordovia.ru", - "msk.ru", - "murmansk.ru", - "nalchik.ru", - "nnov.ru", - "nov.ru", - "novosibirsk.ru", - "nsk.ru", - "omsk.ru", - "orenburg.ru", - "oryol.ru", - "palana.ru", - "penza.ru", - "perm.ru", - "ptz.ru", - "rnd.ru", - "ryazan.ru", - "sakhalin.ru", - "samara.ru", - "saratov.ru", - "simbirsk.ru", - "smolensk.ru", - "spb.ru", - "stavropol.ru", - "stv.ru", - "surgut.ru", - "tambov.ru", - "tatarstan.ru", - "tom.ru", - "tomsk.ru", - "tsaritsyn.ru", - "tsk.ru", - "tula.ru", - "tuva.ru", - "tver.ru", - "tyumen.ru", - "udm.ru", - "udmurtia.ru", - "ulan-ude.ru", - "vladikavkaz.ru", - "vladimir.ru", - "vladivostok.ru", - "volgograd.ru", - "vologda.ru", - "voronezh.ru", - "vrn.ru", - "vyatka.ru", - "yakutia.ru", - "yamal.ru", - "yaroslavl.ru", - "yekaterinburg.ru", - "yuzhno-sakhalinsk.ru", - "amursk.ru", - "baikal.ru", - "cmw.ru", - "fareast.ru", - "jamal.ru", - "kms.ru", - "k-uralsk.ru", - "kustanai.ru", - "kuzbass.ru", - "mytis.ru", - "nakhodka.ru", - "nkz.ru", - "norilsk.ru", - "oskol.ru", - "pyatigorsk.ru", - "rubtsovsk.ru", - "snz.ru", - "syzran.ru", - "vdonsk.ru", - "zgrad.ru", - "gov.ru", - "mil.ru", - "test.ru", - "rw", - "gov.rw", - "net.rw", - "edu.rw", - "ac.rw", - "com.rw", - "co.rw", - "int.rw", - "mil.rw", - "gouv.rw", - "sa", - "com.sa", - "net.sa", - "org.sa", - "gov.sa", - "med.sa", - "pub.sa", - "edu.sa", - "sch.sa", - "sb", - "com.sb", - "edu.sb", - "gov.sb", - "net.sb", - "org.sb", - "sc", - "com.sc", - "gov.sc", - "net.sc", - "org.sc", - "edu.sc", - "sd", - "com.sd", - "net.sd", - "org.sd", - "edu.sd", - "med.sd", - "tv.sd", - "gov.sd", - "info.sd", - "se", - "a.se", - "ac.se", - "b.se", - "bd.se", - "brand.se", - "c.se", - "d.se", - "e.se", - "f.se", - "fh.se", - "fhsk.se", - "fhv.se", - "g.se", - "h.se", - "i.se", - "k.se", - "komforb.se", - "kommunalforbund.se", - "komvux.se", - "l.se", - "lanbib.se", - "m.se", - "n.se", - "naturbruksgymn.se", - "o.se", - "org.se", - "p.se", - "parti.se", - "pp.se", - "press.se", - "r.se", - "s.se", - "t.se", - "tm.se", - "u.se", - "w.se", - "x.se", - "y.se", - "z.se", - "sg", - "com.sg", - "net.sg", - "org.sg", - "gov.sg", - "edu.sg", - "per.sg", - "sh", - "com.sh", - "net.sh", - "gov.sh", - "org.sh", - "mil.sh", - "si", - "sj", - "sk", - "sl", - "com.sl", - "net.sl", - "edu.sl", - "gov.sl", - "org.sl", - "sm", - "sn", - "art.sn", - "com.sn", - "edu.sn", - "gouv.sn", - "org.sn", - "perso.sn", - "univ.sn", - "so", - "com.so", - "net.so", - "org.so", - "sr", - "st", - "co.st", - "com.st", - "consulado.st", - "edu.st", - "embaixada.st", - "gov.st", - "mil.st", - "net.st", - "org.st", - "principe.st", - "saotome.st", - "store.st", - "su", - "adygeya.su", - "arkhangelsk.su", - "balashov.su", - "bashkiria.su", - "bryansk.su", - "dagestan.su", - "grozny.su", - "ivanovo.su", - "kalmykia.su", - "kaluga.su", - "karelia.su", - "khakassia.su", - "krasnodar.su", - "kurgan.su", - "lenug.su", - "mordovia.su", - "msk.su", - "murmansk.su", - "nalchik.su", - "nov.su", - "obninsk.su", - "penza.su", - "pokrovsk.su", - "sochi.su", - "spb.su", - "togliatti.su", - "troitsk.su", - "tula.su", - "tuva.su", - "vladikavkaz.su", - "vladimir.su", - "vologda.su", - "sv", - "com.sv", - "edu.sv", - "gob.sv", - "org.sv", - "red.sv", - "sx", - "gov.sx", - "sy", - "edu.sy", - "gov.sy", - "net.sy", - "mil.sy", - "com.sy", - "org.sy", - "sz", - "co.sz", - "ac.sz", - "org.sz", - "tc", - "td", - "tel", - "tf", - "tg", - "th", - "ac.th", - "co.th", - "go.th", - "in.th", - "mi.th", - "net.th", - "or.th", - "tj", - "ac.tj", - "biz.tj", - "co.tj", - "com.tj", - "edu.tj", - "go.tj", - "gov.tj", - "int.tj", - "mil.tj", - "name.tj", - "net.tj", - "nic.tj", - "org.tj", - "test.tj", - "web.tj", - "tk", - "tl", - "gov.tl", - "tm", - "com.tm", - "co.tm", - "org.tm", - "net.tm", - "nom.tm", - "gov.tm", - "mil.tm", - "edu.tm", - "tn", - "com.tn", - "ens.tn", - "fin.tn", - "gov.tn", - "ind.tn", - "intl.tn", - "nat.tn", - "net.tn", - "org.tn", - "info.tn", - "perso.tn", - "tourism.tn", - "edunet.tn", - "rnrt.tn", - "rns.tn", - "rnu.tn", - "mincom.tn", - "agrinet.tn", - "defense.tn", - "turen.tn", - "to", - "com.to", - "gov.to", - "net.to", - "org.to", - "edu.to", - "mil.to", - "tr", - "com.tr", - "info.tr", - "biz.tr", - "net.tr", - "org.tr", - "web.tr", - "gen.tr", - "tv.tr", - "av.tr", - "dr.tr", - "bbs.tr", - "name.tr", - "tel.tr", - "gov.tr", - "bel.tr", - "pol.tr", - "mil.tr", - "k12.tr", - "edu.tr", - "kep.tr", - "nc.tr", - "gov.nc.tr", - "travel", - "tt", - "co.tt", - "com.tt", - "org.tt", - "net.tt", - "biz.tt", - "info.tt", - "pro.tt", - "int.tt", - "coop.tt", - "jobs.tt", - "mobi.tt", - "travel.tt", - "museum.tt", - "aero.tt", - "name.tt", - "gov.tt", - "edu.tt", - "tv", - "tw", - "edu.tw", - "gov.tw", - "mil.tw", - "com.tw", - "net.tw", - "org.tw", - "idv.tw", - "game.tw", - "ebiz.tw", - "club.tw", - "xn--zf0ao64a.tw", - "xn--uc0atv.tw", - "xn--czrw28b.tw", - "tz", - "ac.tz", - "co.tz", - "go.tz", - "hotel.tz", - "info.tz", - "me.tz", - "mil.tz", - "mobi.tz", - "ne.tz", - "or.tz", - "sc.tz", - "tv.tz", - "ua", - "com.ua", - "edu.ua", - "gov.ua", - "in.ua", - "net.ua", - "org.ua", - "cherkassy.ua", - "cherkasy.ua", - "chernigov.ua", - "chernihiv.ua", - "chernivtsi.ua", - "chernovtsy.ua", - "ck.ua", - "cn.ua", - "cr.ua", - "crimea.ua", - "cv.ua", - "dn.ua", - "dnepropetrovsk.ua", - "dnipropetrovsk.ua", - "dominic.ua", - "donetsk.ua", - "dp.ua", - "if.ua", - "ivano-frankivsk.ua", - "kh.ua", - "kharkiv.ua", - "kharkov.ua", - "kherson.ua", - "khmelnitskiy.ua", - "khmelnytskyi.ua", - "kiev.ua", - "kirovograd.ua", - "km.ua", - "kr.ua", - "krym.ua", - "ks.ua", - "kv.ua", - "kyiv.ua", - "lg.ua", - "lt.ua", - "lugansk.ua", - "lutsk.ua", - "lv.ua", - "lviv.ua", - "mk.ua", - "mykolaiv.ua", - "nikolaev.ua", - "od.ua", - "odesa.ua", - "odessa.ua", - "pl.ua", - "poltava.ua", - "rivne.ua", - "rovno.ua", - "rv.ua", - "sb.ua", - "sebastopol.ua", - "sevastopol.ua", - "sm.ua", - "sumy.ua", - "te.ua", - "ternopil.ua", - "uz.ua", - "uzhgorod.ua", - "vinnica.ua", - "vinnytsia.ua", - "vn.ua", - "volyn.ua", - "yalta.ua", - "zaporizhzhe.ua", - "zaporizhzhia.ua", - "zhitomir.ua", - "zhytomyr.ua", - "zp.ua", - "zt.ua", - "ug", - "co.ug", - "or.ug", - "ac.ug", - "sc.ug", - "go.ug", - "ne.ug", - "com.ug", - "org.ug", - "uk", - "ac.uk", - "co.uk", - "gov.uk", - "ltd.uk", - "me.uk", - "net.uk", - "nhs.uk", - "org.uk", - "plc.uk", - "police.uk", - "*.sch.uk", - "us", - "dni.us", - "fed.us", - "isa.us", - "kids.us", - "nsn.us", - "ak.us", - "al.us", - "ar.us", - "as.us", - "az.us", - "ca.us", - "co.us", - "ct.us", - "dc.us", - "de.us", - "fl.us", - "ga.us", - "gu.us", - "hi.us", - "ia.us", - "id.us", - "il.us", - "in.us", - "ks.us", - "ky.us", - "la.us", - "ma.us", - "md.us", - "me.us", - "mi.us", - "mn.us", - "mo.us", - "ms.us", - "mt.us", - "nc.us", - "nd.us", - "ne.us", - "nh.us", - "nj.us", - "nm.us", - "nv.us", - "ny.us", - "oh.us", - "ok.us", - "or.us", - "pa.us", - "pr.us", - "ri.us", - "sc.us", - "sd.us", - "tn.us", - "tx.us", - "ut.us", - "vi.us", - "vt.us", - "va.us", - "wa.us", - "wi.us", - "wv.us", - "wy.us", - "k12.ak.us", - "k12.al.us", - "k12.ar.us", - "k12.as.us", - "k12.az.us", - "k12.ca.us", - "k12.co.us", - "k12.ct.us", - "k12.dc.us", - "k12.de.us", - "k12.fl.us", - "k12.ga.us", - "k12.gu.us", - "k12.ia.us", - "k12.id.us", - "k12.il.us", - "k12.in.us", - "k12.ks.us", - "k12.ky.us", - "k12.la.us", - "k12.ma.us", - "k12.md.us", - "k12.me.us", - "k12.mi.us", - "k12.mn.us", - "k12.mo.us", - "k12.ms.us", - "k12.mt.us", - "k12.nc.us", - "k12.ne.us", - "k12.nh.us", - "k12.nj.us", - "k12.nm.us", - "k12.nv.us", - "k12.ny.us", - "k12.oh.us", - "k12.ok.us", - "k12.or.us", - "k12.pa.us", - "k12.pr.us", - "k12.ri.us", - "k12.sc.us", - "k12.tn.us", - "k12.tx.us", - "k12.ut.us", - "k12.vi.us", - "k12.vt.us", - "k12.va.us", - "k12.wa.us", - "k12.wi.us", - "k12.wy.us", - "cc.ak.us", - "cc.al.us", - "cc.ar.us", - "cc.as.us", - "cc.az.us", - "cc.ca.us", - "cc.co.us", - "cc.ct.us", - "cc.dc.us", - "cc.de.us", - "cc.fl.us", - "cc.ga.us", - "cc.gu.us", - "cc.hi.us", - "cc.ia.us", - "cc.id.us", - "cc.il.us", - "cc.in.us", - "cc.ks.us", - "cc.ky.us", - "cc.la.us", - "cc.ma.us", - "cc.md.us", - "cc.me.us", - "cc.mi.us", - "cc.mn.us", - "cc.mo.us", - "cc.ms.us", - "cc.mt.us", - "cc.nc.us", - "cc.nd.us", - "cc.ne.us", - "cc.nh.us", - "cc.nj.us", - "cc.nm.us", - "cc.nv.us", - "cc.ny.us", - "cc.oh.us", - "cc.ok.us", - "cc.or.us", - "cc.pa.us", - "cc.pr.us", - "cc.ri.us", - "cc.sc.us", - "cc.sd.us", - "cc.tn.us", - "cc.tx.us", - "cc.ut.us", - "cc.vi.us", - "cc.vt.us", - "cc.va.us", - "cc.wa.us", - "cc.wi.us", - "cc.wv.us", - "cc.wy.us", - "lib.ak.us", - "lib.al.us", - "lib.ar.us", - "lib.as.us", - "lib.az.us", - "lib.ca.us", - "lib.co.us", - "lib.ct.us", - "lib.dc.us", - "lib.de.us", - "lib.fl.us", - "lib.ga.us", - "lib.gu.us", - "lib.hi.us", - "lib.ia.us", - "lib.id.us", - "lib.il.us", - "lib.in.us", - "lib.ks.us", - "lib.ky.us", - "lib.la.us", - "lib.ma.us", - "lib.md.us", - "lib.me.us", - "lib.mi.us", - "lib.mn.us", - "lib.mo.us", - "lib.ms.us", - "lib.mt.us", - "lib.nc.us", - "lib.nd.us", - "lib.ne.us", - "lib.nh.us", - "lib.nj.us", - "lib.nm.us", - "lib.nv.us", - "lib.ny.us", - "lib.oh.us", - "lib.ok.us", - "lib.or.us", - "lib.pa.us", - "lib.pr.us", - "lib.ri.us", - "lib.sc.us", - "lib.sd.us", - "lib.tn.us", - "lib.tx.us", - "lib.ut.us", - "lib.vi.us", - "lib.vt.us", - "lib.va.us", - "lib.wa.us", - "lib.wi.us", - "lib.wy.us", - "pvt.k12.ma.us", - "chtr.k12.ma.us", - "paroch.k12.ma.us", - "uy", - "com.uy", - "edu.uy", - "gub.uy", - "mil.uy", - "net.uy", - "org.uy", - "uz", - "co.uz", - "com.uz", - "net.uz", - "org.uz", - "va", - "vc", - "com.vc", - "net.vc", - "org.vc", - "gov.vc", - "mil.vc", - "edu.vc", - "ve", - "arts.ve", - "co.ve", - "com.ve", - "e12.ve", - "edu.ve", - "firm.ve", - "gob.ve", - "gov.ve", - "info.ve", - "int.ve", - "mil.ve", - "net.ve", - "org.ve", - "rec.ve", - "store.ve", - "tec.ve", - "web.ve", - "vg", - "vi", - "co.vi", - "com.vi", - "k12.vi", - "net.vi", - "org.vi", - "vn", - "com.vn", - "net.vn", - "org.vn", - "edu.vn", - "gov.vn", - "int.vn", - "ac.vn", - "biz.vn", - "info.vn", - "name.vn", - "pro.vn", - "health.vn", - "vu", - "com.vu", - "edu.vu", - "net.vu", - "org.vu", - "wf", - "ws", - "com.ws", - "net.ws", - "org.ws", - "gov.ws", - "edu.ws", - "yt", - "xn--mgbaam7a8h", - "xn--y9a3aq", - "xn--54b7fta0cc", - "xn--90ais", - "xn--fiqs8s", - "xn--fiqz9s", - "xn--lgbbat1ad8j", - "xn--wgbh1c", - "xn--e1a4c", - "xn--node", - "xn--qxam", - "xn--j6w193g", - "xn--h2brj9c", - "xn--mgbbh1a71e", - "xn--fpcrj9c3d", - "xn--gecrj9c", - "xn--s9brj9c", - "xn--45brj9c", - "xn--xkc2dl3a5ee0h", - "xn--mgba3a4f16a", - "xn--mgba3a4fra", - "xn--mgbtx2b", - "xn--mgbayh7gpa", - "xn--3e0b707e", - "xn--80ao21a", - "xn--fzc2c9e2c", - "xn--xkc2al3hye2a", - "xn--mgbc0a9azcg", - "xn--d1alf", - "xn--l1acc", - "xn--mix891f", - "xn--mix082f", - "xn--mgbx4cd0ab", - "xn--mgb9awbf", - "xn--mgbai9azgqp6j", - "xn--mgbai9a5eva00b", - "xn--ygbi2ammx", - "xn--90a3ac", - "xn--o1ac.xn--90a3ac", - "xn--c1avg.xn--90a3ac", - "xn--90azh.xn--90a3ac", - "xn--d1at.xn--90a3ac", - "xn--o1ach.xn--90a3ac", - "xn--80au.xn--90a3ac", - "xn--p1ai", - "xn--wgbl6a", - "xn--mgberp4a5d4ar", - "xn--mgberp4a5d4a87g", - "xn--mgbqly7c0a67fbc", - "xn--mgbqly7cvafr", - "xn--mgbpl2fh", - "xn--yfro4i67o", - "xn--clchc0ea0b2g2a9gcd", - "xn--ogbpf8fl", - "xn--mgbtf8fl", - "xn--o3cw4h", - "xn--pgbs0dh", - "xn--kpry57d", - "xn--kprw13d", - "xn--nnx388a", - "xn--j1amh", - "xn--mgb2ddes", - "xxx", - "*.ye", - "ac.za", - "agric.za", - "alt.za", - "co.za", - "edu.za", - "gov.za", - "grondar.za", - "law.za", - "mil.za", - "net.za", - "ngo.za", - "nis.za", - "nom.za", - "org.za", - "school.za", - "tm.za", - "web.za", - "zm", - "ac.zm", - "biz.zm", - "co.zm", - "com.zm", - "edu.zm", - "gov.zm", - "info.zm", - "mil.zm", - "net.zm", - "org.zm", - "sch.zm", - "*.zw", - "aaa", - "aarp", - "abarth", - "abb", - "abbott", - "abbvie", - "abc", - "able", - "abogado", - "abudhabi", - "academy", - "accenture", - "accountant", - "accountants", - "aco", - "active", - "actor", - "adac", - "ads", - "adult", - "aeg", - "aetna", - "afamilycompany", - "afl", - "africa", - "africamagic", - "agakhan", - "agency", - "aig", - "aigo", - "airbus", - "airforce", - "airtel", - "akdn", - "alfaromeo", - "alibaba", - "alipay", - "allfinanz", - "allstate", - "ally", - "alsace", - "alstom", - "americanexpress", - "americanfamily", - "amex", - "amfam", - "amica", - "amsterdam", - "analytics", - "android", - "anquan", - "anz", - "aol", - "apartments", - "app", - "apple", - "aquarelle", - "arab", - "aramco", - "archi", - "army", - "art", - "arte", - "asda", - "associates", - "athleta", - "attorney", - "auction", - "audi", - "audible", - "audio", - "auspost", - "author", - "auto", - "autos", - "avianca", - "aws", - "axa", - "azure", - "baby", - "baidu", - "banamex", - "bananarepublic", - "band", - "bank", - "bar", - "barcelona", - "barclaycard", - "barclays", - "barefoot", - "bargains", - "baseball", - "basketball", - "bauhaus", - "bayern", - "bbc", - "bbt", - "bbva", - "bcg", - "bcn", - "beats", - "beauty", - "beer", - "bentley", - "berlin", - "best", - "bestbuy", - "bet", - "bharti", - "bible", - "bid", - "bike", - "bing", - "bingo", - "bio", - "black", - "blackfriday", - "blanco", - "blockbuster", - "blog", - "bloomberg", - "blue", - "bms", - "bmw", - "bnl", - "bnpparibas", - "boats", - "boehringer", - "bofa", - "bom", - "bond", - "boo", - "book", - "booking", - "boots", - "bosch", - "bostik", - "boston", - "bot", - "boutique", - "box", - "bradesco", - "bridgestone", - "broadway", - "broker", - "brother", - "brussels", - "budapest", - "bugatti", - "build", - "builders", - "business", - "buy", - "buzz", - "bzh", - "cab", - "cafe", - "cal", - "call", - "calvinklein", - "cam", - "camera", - "camp", - "cancerresearch", - "canon", - "capetown", - "capital", - "capitalone", - "car", - "caravan", - "cards", - "care", - "career", - "careers", - "cars", - "cartier", - "casa", - "case", - "caseih", - "cash", - "casino", - "catering", - "catholic", - "cba", - "cbn", - "cbre", - "cbs", - "ceb", - "center", - "ceo", - "cern", - "cfa", - "cfd", - "chanel", - "channel", - "chase", - "chat", - "cheap", - "chintai", - "chloe", - "christmas", - "chrome", - "chrysler", - "church", - "cipriani", - "circle", - "cisco", - "citadel", - "citi", - "citic", - "city", - "cityeats", - "claims", - "cleaning", - "click", - "clinic", - "clinique", - "clothing", - "cloud", - "club", - "clubmed", - "coach", - "codes", - "coffee", - "college", - "cologne", - "comcast", - "commbank", - "community", - "company", - "compare", - "computer", - "comsec", - "condos", - "construction", - "consulting", - "contact", - "contractors", - "cooking", - "cookingchannel", - "cool", - "corsica", - "country", - "coupon", - "coupons", - "courses", - "credit", - "creditcard", - "creditunion", - "cricket", - "crown", - "crs", - "cruise", - "cruises", - "csc", - "cuisinella", - "cymru", - "cyou", - "dabur", - "dad", - "dance", - "date", - "dating", - "datsun", - "day", - "dclk", - "dds", - "deal", - "dealer", - "deals", - "degree", - "delivery", - "dell", - "deloitte", - "delta", - "democrat", - "dental", - "dentist", - "desi", - "design", - "dev", - "dhl", - "diamonds", - "diet", - "digital", - "direct", - "directory", - "discount", - "discover", - "dish", - "diy", - "dnp", - "docs", - "dodge", - "dog", - "doha", - "domains", - "dot", - "download", - "drive", - "dstv", - "dtv", - "dubai", - "duck", - "dunlop", - "duns", - "dupont", - "durban", - "dvag", - "dwg", - "earth", - "eat", - "edeka", - "education", - "email", - "emerck", - "emerson", - "energy", - "engineer", - "engineering", - "enterprises", - "epost", - "epson", - "equipment", - "ericsson", - "erni", - "esq", - "estate", - "esurance", - "etisalat", - "eurovision", - "eus", - "events", - "everbank", - "exchange", - "expert", - "exposed", - "express", - "extraspace", - "fage", - "fail", - "fairwinds", - "faith", - "family", - "fan", - "fans", - "farm", - "farmers", - "fashion", - "fast", - "fedex", - "feedback", - "ferrari", - "ferrero", - "fiat", - "fidelity", - "fido", - "film", - "final", - "finance", - "financial", - "fire", - "firestone", - "firmdale", - "fish", - "fishing", - "fit", - "fitness", - "flickr", - "flights", - "flir", - "florist", - "flowers", - "flsmidth", - "fly", - "foo", - "food", - "foodnetwork", - "football", - "ford", - "forex", - "forsale", - "forum", - "foundation", - "fox", - "free", - "fresenius", - "frl", - "frogans", - "frontdoor", - "frontier", - "ftr", - "fujitsu", - "fujixerox", - "fun", - "fund", - "furniture", - "futbol", - "fyi", - "gal", - "gallery", - "gallo", - "gallup", - "game", - "games", - "gap", - "garden", - "gbiz", - "gdn", - "gea", - "gent", - "genting", - "george", - "ggee", - "gift", - "gifts", - "gives", - "giving", - "glade", - "glass", - "gle", - "global", - "globo", - "gmail", - "gmbh", - "gmo", - "gmx", - "godaddy", - "gold", - "goldpoint", - "golf", - "goo", - "goodhands", - "goodyear", - "goog", - "google", - "gop", - "got", - "gotv", - "grainger", - "graphics", - "gratis", - "green", - "gripe", - "group", - "guardian", - "gucci", - "guge", - "guide", - "guitars", - "guru", - "hair", - "hamburg", - "hangout", - "haus", - "hbo", - "hdfc", - "hdfcbank", - "health", - "healthcare", - "help", - "helsinki", - "here", - "hermes", - "hgtv", - "hiphop", - "hisamitsu", - "hitachi", - "hiv", - "hkt", - "hockey", - "holdings", - "holiday", - "homedepot", - "homegoods", - "homes", - "homesense", - "honda", - "honeywell", - "horse", - "host", - "hosting", - "hot", - "hoteles", - "hotels", - "hotmail", - "house", - "how", - "hsbc", - "htc", - "hughes", - "hyatt", - "hyundai", - "ibm", - "icbc", - "ice", - "icu", - "ieee", - "ifm", - "iinet", - "ikano", - "imamat", - "imdb", - "immo", - "immobilien", - "industries", - "infiniti", - "ing", - "ink", - "institute", - "insurance", - "insure", - "intel", - "international", - "intuit", - "investments", - "ipiranga", - "irish", - "iselect", - "ismaili", - "ist", - "istanbul", - "itau", - "itv", - "iveco", - "iwc", - "jaguar", - "java", - "jcb", - "jcp", - "jeep", - "jetzt", - "jewelry", - "jio", - "jlc", - "jll", - "jmp", - "jnj", - "joburg", - "jot", - "joy", - "jpmorgan", - "jprs", - "juegos", - "juniper", - "kaufen", - "kddi", - "kerryhotels", - "kerrylogistics", - "kerryproperties", - "kfh", - "kia", - "kim", - "kinder", - "kindle", - "kitchen", - "kiwi", - "koeln", - "komatsu", - "kosher", - "kpmg", - "kpn", - "krd", - "kred", - "kuokgroup", - "kyknet", - "kyoto", - "lacaixa", - "ladbrokes", - "lamborghini", - "lamer", - "lancaster", - "lancia", - "lancome", - "land", - "landrover", - "lanxess", - "lasalle", - "lat", - "latino", - "latrobe", - "law", - "lawyer", - "lds", - "lease", - "leclerc", - "lefrak", - "legal", - "lego", - "lexus", - "lgbt", - "liaison", - "lidl", - "life", - "lifeinsurance", - "lifestyle", - "lighting", - "like", - "lilly", - "limited", - "limo", - "lincoln", - "linde", - "link", - "lipsy", - "live", - "living", - "lixil", - "loan", - "loans", - "locker", - "locus", - "loft", - "lol", - "london", - "lotte", - "lotto", - "love", - "lpl", - "lplfinancial", - "ltd", - "ltda", - "lundbeck", - "lupin", - "luxe", - "luxury", - "macys", - "madrid", - "maif", - "maison", - "makeup", - "man", - "management", - "mango", - "market", - "marketing", - "markets", - "marriott", - "marshalls", - "maserati", - "mattel", - "mba", - "mcd", - "mcdonalds", - "mckinsey", - "med", - "media", - "meet", - "melbourne", - "meme", - "memorial", - "men", - "menu", - "meo", - "metlife", - "miami", - "microsoft", - "mini", - "mint", - "mit", - "mitsubishi", - "mlb", - "mls", - "mma", - "mnet", - "mobily", - "moda", - "moe", - "moi", - "mom", - "monash", - "money", - "monster", - "montblanc", - "mopar", - "mormon", - "mortgage", - "moscow", - "moto", - "motorcycles", - "mov", - "movie", - "movistar", - "msd", - "mtn", - "mtpc", - "mtr", - "multichoice", - "mutual", - "mutuelle", - "mzansimagic", - "nab", - "nadex", - "nagoya", - "naspers", - "nationwide", - "natura", - "navy", - "nba", - "nec", - "netbank", - "netflix", - "network", - "neustar", - "new", - "newholland", - "news", - "next", - "nextdirect", - "nexus", - "nfl", - "ngo", - "nhk", - "nico", - "nike", - "nikon", - "ninja", - "nissan", - "nissay", - "nokia", - "northwesternmutual", - "norton", - "now", - "nowruz", - "nowtv", - "nra", - "nrw", - "ntt", - "nyc", - "obi", - "observer", - "off", - "office", - "okinawa", - "olayan", - "olayangroup", - "oldnavy", - "ollo", - "omega", - "one", - "ong", - "onl", - "online", - "onyourside", - "ooo", - "open", - "oracle", - "orange", - "organic", - "orientexpress", - "origins", - "osaka", - "otsuka", - "ott", - "ovh", - "page", - "pamperedchef", - "panasonic", - "panerai", - "paris", - "pars", - "partners", - "parts", - "party", - "passagens", - "pay", - "payu", - "pccw", - "pet", - "pfizer", - "pharmacy", - "philips", - "photo", - "photography", - "photos", - "physio", - "piaget", - "pics", - "pictet", - "pictures", - "pid", - "pin", - "ping", - "pink", - "pioneer", - "pizza", - "place", - "play", - "playstation", - "plumbing", - "plus", - "pnc", - "pohl", - "poker", - "politie", - "porn", - "pramerica", - "praxi", - "press", - "prime", - "prod", - "productions", - "prof", - "progressive", - "promo", - "properties", - "property", - "protection", - "pru", - "prudential", - "pub", - "pwc", - "qpon", - "quebec", - "quest", - "qvc", - "racing", - "raid", - "read", - "realestate", - "realtor", - "realty", - "recipes", - "red", - "redstone", - "redumbrella", - "rehab", - "reise", - "reisen", - "reit", - "reliance", - "ren", - "rent", - "rentals", - "repair", - "report", - "republican", - "rest", - "restaurant", - "review", - "reviews", - "rexroth", - "rich", - "richardli", - "ricoh", - "rightathome", - "ril", - "rio", - "rip", - "rmit", - "rocher", - "rocks", - "rodeo", - "rogers", - "room", - "rsvp", - "ruhr", - "run", - "rwe", - "ryukyu", - "saarland", - "safe", - "safety", - "sakura", - "sale", - "salon", - "samsclub", - "samsung", - "sandvik", - "sandvikcoromant", - "sanofi", - "sap", - "sapo", - "sarl", - "sas", - "save", - "saxo", - "sbi", - "sbs", - "sca", - "scb", - "schaeffler", - "schmidt", - "scholarships", - "school", - "schule", - "schwarz", - "science", - "scjohnson", - "scor", - "scot", - "seat", - "secure", - "security", - "seek", - "select", - "sener", - "services", - "ses", - "seven", - "sew", - "sex", - "sexy", - "sfr", - "shangrila", - "sharp", - "shaw", - "shell", - "shia", - "shiksha", - "shoes", - "shop", - "shopping", - "shouji", - "show", - "showtime", - "shriram", - "silk", - "sina", - "singles", - "site", - "ski", - "skin", - "sky", - "skype", - "sling", - "smart", - "smile", - "sncf", - "soccer", - "social", - "softbank", - "software", - "sohu", - "solar", - "solutions", - "song", - "sony", - "soy", - "space", - "spiegel", - "spot", - "spreadbetting", - "srl", - "srt", - "stada", - "staples", - "star", - "starhub", - "statebank", - "statefarm", - "statoil", - "stc", - "stcgroup", - "stockholm", - "storage", - "store", - "stream", - "studio", - "study", - "style", - "sucks", - "supersport", - "supplies", - "supply", - "support", - "surf", - "surgery", - "suzuki", - "swatch", - "swiftcover", - "swiss", - "sydney", - "symantec", - "systems", - "tab", - "taipei", - "talk", - "taobao", - "target", - "tatamotors", - "tatar", - "tattoo", - "tax", - "taxi", - "tci", - "tdk", - "team", - "tech", - "technology", - "telecity", - "telefonica", - "temasek", - "tennis", - "teva", - "thd", - "theater", - "theatre", - "theguardian", - "tiaa", - "tickets", - "tienda", - "tiffany", - "tips", - "tires", - "tirol", - "tjmaxx", - "tjx", - "tkmaxx", - "tmall", - "today", - "tokyo", - "tools", - "top", - "toray", - "toshiba", - "total", - "tours", - "town", - "toyota", - "toys", - "trade", - "trading", - "training", - "travelchannel", - "travelers", - "travelersinsurance", - "trust", - "trv", - "tube", - "tui", - "tunes", - "tushu", - "tvs", - "ubank", - "ubs", - "uconnect", - "unicom", - "university", - "uno", - "uol", - "ups", - "vacations", - "vana", - "vanguard", - "vegas", - "ventures", - "verisign", - "versicherung", - "vet", - "viajes", - "video", - "vig", - "viking", - "villas", - "vin", - "vip", - "virgin", - "visa", - "vision", - "vista", - "vistaprint", - "viva", - "vivo", - "vlaanderen", - "vodka", - "volkswagen", - "volvo", - "vote", - "voting", - "voto", - "voyage", - "vuelos", - "wales", - "walmart", - "walter", - "wang", - "wanggou", - "warman", - "watch", - "watches", - "weather", - "weatherchannel", - "webcam", - "weber", - "website", - "wed", - "wedding", - "weibo", - "weir", - "whoswho", - "wien", - "wiki", - "williamhill", - "win", - "windows", - "wine", - "winners", - "wme", - "wolterskluwer", - "woodside", - "work", - "works", - "world", - "wow", - "wtc", - "wtf", - "xbox", - "xerox", - "xfinity", - "xihuan", - "xin", - "xn--11b4c3d", - "xn--1ck2e1b", - "xn--1qqw23a", - "xn--30rr7y", - "xn--3bst00m", - "xn--3ds443g", - "xn--3oq18vl8pn36a", - "xn--3pxu8k", - "xn--42c2d9a", - "xn--45q11c", - "xn--4gbrim", - "xn--4gq48lf9j", - "xn--55qw42g", - "xn--55qx5d", - "xn--5su34j936bgsg", - "xn--5tzm5g", - "xn--6frz82g", - "xn--6qq986b3xl", - "xn--80adxhks", - "xn--80aqecdr1a", - "xn--80asehdb", - "xn--80aswg", - "xn--8y0a063a", - "xn--9dbq2a", - "xn--9et52u", - "xn--9krt00a", - "xn--b4w605ferd", - "xn--bck1b9a5dre4c", - "xn--c1avg", - "xn--c2br7g", - "xn--cck2b3b", - "xn--cg4bki", - "xn--czr694b", - "xn--czrs0t", - "xn--czru2d", - "xn--d1acj3b", - "xn--eckvdtc9d", - "xn--efvy88h", - "xn--estv75g", - "xn--fct429k", - "xn--fhbei", - "xn--fiq228c5hs", - "xn--fiq64b", - "xn--fjq720a", - "xn--flw351e", - "xn--fzys8d69uvgm", - "xn--g2xx48c", - "xn--gckr3f0f", - "xn--gk3at1e", - "xn--hxt814e", - "xn--i1b6b1a6a2e", - "xn--imr513n", - "xn--io0a7i", - "xn--j1aef", - "xn--jlq61u9w7b", - "xn--jvr189m", - "xn--kcrx77d1x4a", - "xn--kpu716f", - "xn--kput3i", - "xn--mgba3a3ejt", - "xn--mgba7c0bbn0a", - "xn--mgbaakc7dvf", - "xn--mgbab2bd", - "xn--mgbb9fbpob", - "xn--mgbca7dzdo", - "xn--mgbi4ecexp", - "xn--mgbt3dhd", - "xn--mk1bu44c", - "xn--mxtq1m", - "xn--ngbc5azd", - "xn--ngbe9e0a", - "xn--ngbrx", - "xn--nqv7f", - "xn--nqv7fs00ema", - "xn--nyqy26a", - "xn--p1acf", - "xn--pbt977c", - "xn--pssy2u", - "xn--q9jyb4c", - "xn--qcka1pmc", - "xn--rhqv96g", - "xn--rovu88b", - "xn--ses554g", - "xn--t60b56a", - "xn--tckwe", - "xn--tiq49xqyj", - "xn--unup4y", - "xn--vermgensberater-ctb", - "xn--vermgensberatung-pwb", - "xn--vhquv", - "xn--vuq861b", - "xn--w4r85el8fhu5dnra", - "xn--w4rs40l", - "xn--xhq521b", - "xn--zfr164b", - "xperia", - "xyz", - "yachts", - "yahoo", - "yamaxun", - "yandex", - "yodobashi", - "yoga", - "yokohama", - "you", - "youtube", - "yun", - "zappos", - "zara", - "zero", - "zip", - "zippo", - "zone", - "zuerich", - "*.compute.estate", - "*.alces.network", - "cloudfront.net", - "ap-northeast-1.compute.amazonaws.com", - "ap-northeast-2.compute.amazonaws.com", - "ap-southeast-1.compute.amazonaws.com", - "ap-southeast-2.compute.amazonaws.com", - "cn-north-1.compute.amazonaws.cn", - "compute-1.amazonaws.com", - "compute.amazonaws.cn", - "compute.amazonaws.com", - "eu-central-1.compute.amazonaws.com", - "eu-west-1.compute.amazonaws.com", - "sa-east-1.compute.amazonaws.com", - "us-east-1.amazonaws.com", - "us-gov-west-1.compute.amazonaws.com", - "us-west-1.compute.amazonaws.com", - "us-west-2.compute.amazonaws.com", - "z-1.compute-1.amazonaws.com", - "z-2.compute-1.amazonaws.com", - "elasticbeanstalk.com", - "elb.amazonaws.com", - "s3.amazonaws.com", - "s3-ap-northeast-1.amazonaws.com", - "s3-ap-northeast-2.amazonaws.com", - "s3-ap-southeast-1.amazonaws.com", - "s3-ap-southeast-2.amazonaws.com", - "s3-eu-central-1.amazonaws.com", - "s3-eu-west-1.amazonaws.com", - "s3-external-1.amazonaws.com", - "s3-external-2.amazonaws.com", - "s3-fips-us-gov-west-1.amazonaws.com", - "s3-sa-east-1.amazonaws.com", - "s3-us-gov-west-1.amazonaws.com", - "s3-us-west-1.amazonaws.com", - "s3-us-west-2.amazonaws.com", - "s3.ap-northeast-2.amazonaws.com", - "s3.cn-north-1.amazonaws.com.cn", - "s3.eu-central-1.amazonaws.com", - "on-aptible.com", - "myfritz.net", - "betainabox.com", - "ae.org", - "ar.com", - "br.com", - "cn.com", - "com.de", - "com.se", - "de.com", - "eu.com", - "gb.com", - "gb.net", - "hu.com", - "hu.net", - "jp.net", - "jpn.com", - "kr.com", - "mex.com", - "no.com", - "qc.com", - "ru.com", - "sa.com", - "se.com", - "se.net", - "uk.com", - "uk.net", - "us.com", - "uy.com", - "za.bz", - "za.com", - "africa.com", - "gr.com", - "in.net", - "us.org", - "co.com", - "c.la", - "xenapponazure.com", - "cloudcontrolled.com", - "cloudcontrolapp.com", - "co.ca", - "co.cz", - "c.cdn77.org", - "cdn77-ssl.net", - "r.cdn77.net", - "rsc.cdn77.org", - "ssl.origin.cdn77-secure.org", - "co.nl", - "co.no", - "*.platform.sh", - "cupcake.is", - "cyon.link", - "cyon.site", - "daplie.me", - "biz.dk", - "co.dk", - "firm.dk", - "reg.dk", - "store.dk", - "dedyn.io", - "dnshome.de", - "dreamhosters.com", - "mydrobo.com", - "duckdns.org", - "dy.fi", - "tunk.org", - "dyndns-at-home.com", - "dyndns-at-work.com", - "dyndns-blog.com", - "dyndns-free.com", - "dyndns-home.com", - "dyndns-ip.com", - "dyndns-mail.com", - "dyndns-office.com", - "dyndns-pics.com", - "dyndns-remote.com", - "dyndns-server.com", - "dyndns-web.com", - "dyndns-wiki.com", - "dyndns-work.com", - "dyndns.biz", - "dyndns.info", - "dyndns.org", - "dyndns.tv", - "at-band-camp.net", - "ath.cx", - "barrel-of-knowledge.info", - "barrell-of-knowledge.info", - "better-than.tv", - "blogdns.com", - "blogdns.net", - "blogdns.org", - "blogsite.org", - "boldlygoingnowhere.org", - "broke-it.net", - "buyshouses.net", - "cechire.com", - "dnsalias.com", - "dnsalias.net", - "dnsalias.org", - "dnsdojo.com", - "dnsdojo.net", - "dnsdojo.org", - "does-it.net", - "doesntexist.com", - "doesntexist.org", - "dontexist.com", - "dontexist.net", - "dontexist.org", - "doomdns.com", - "doomdns.org", - "dvrdns.org", - "dyn-o-saur.com", - "dynalias.com", - "dynalias.net", - "dynalias.org", - "dynathome.net", - "dyndns.ws", - "endofinternet.net", - "endofinternet.org", - "endoftheinternet.org", - "est-a-la-maison.com", - "est-a-la-masion.com", - "est-le-patron.com", - "est-mon-blogueur.com", - "for-better.biz", - "for-more.biz", - "for-our.info", - "for-some.biz", - "for-the.biz", - "forgot.her.name", - "forgot.his.name", - "from-ak.com", - "from-al.com", - "from-ar.com", - "from-az.net", - "from-ca.com", - "from-co.net", - "from-ct.com", - "from-dc.com", - "from-de.com", - "from-fl.com", - "from-ga.com", - "from-hi.com", - "from-ia.com", - "from-id.com", - "from-il.com", - "from-in.com", - "from-ks.com", - "from-ky.com", - "from-la.net", - "from-ma.com", - "from-md.com", - "from-me.org", - "from-mi.com", - "from-mn.com", - "from-mo.com", - "from-ms.com", - "from-mt.com", - "from-nc.com", - "from-nd.com", - "from-ne.com", - "from-nh.com", - "from-nj.com", - "from-nm.com", - "from-nv.com", - "from-ny.net", - "from-oh.com", - "from-ok.com", - "from-or.com", - "from-pa.com", - "from-pr.com", - "from-ri.com", - "from-sc.com", - "from-sd.com", - "from-tn.com", - "from-tx.com", - "from-ut.com", - "from-va.com", - "from-vt.com", - "from-wa.com", - "from-wi.com", - "from-wv.com", - "from-wy.com", - "ftpaccess.cc", - "fuettertdasnetz.de", - "game-host.org", - "game-server.cc", - "getmyip.com", - "gets-it.net", - "go.dyndns.org", - "gotdns.com", - "gotdns.org", - "groks-the.info", - "groks-this.info", - "ham-radio-op.net", - "here-for-more.info", - "hobby-site.com", - "hobby-site.org", - "home.dyndns.org", - "homedns.org", - "homeftp.net", - "homeftp.org", - "homeip.net", - "homelinux.com", - "homelinux.net", - "homelinux.org", - "homeunix.com", - "homeunix.net", - "homeunix.org", - "iamallama.com", - "in-the-band.net", - "is-a-anarchist.com", - "is-a-blogger.com", - "is-a-bookkeeper.com", - "is-a-bruinsfan.org", - "is-a-bulls-fan.com", - "is-a-candidate.org", - "is-a-caterer.com", - "is-a-celticsfan.org", - "is-a-chef.com", - "is-a-chef.net", - "is-a-chef.org", - "is-a-conservative.com", - "is-a-cpa.com", - "is-a-cubicle-slave.com", - "is-a-democrat.com", - "is-a-designer.com", - "is-a-doctor.com", - "is-a-financialadvisor.com", - "is-a-geek.com", - "is-a-geek.net", - "is-a-geek.org", - "is-a-green.com", - "is-a-guru.com", - "is-a-hard-worker.com", - "is-a-hunter.com", - "is-a-knight.org", - "is-a-landscaper.com", - "is-a-lawyer.com", - "is-a-liberal.com", - "is-a-libertarian.com", - "is-a-linux-user.org", - "is-a-llama.com", - "is-a-musician.com", - "is-a-nascarfan.com", - "is-a-nurse.com", - "is-a-painter.com", - "is-a-patsfan.org", - "is-a-personaltrainer.com", - "is-a-photographer.com", - "is-a-player.com", - "is-a-republican.com", - "is-a-rockstar.com", - "is-a-socialist.com", - "is-a-soxfan.org", - "is-a-student.com", - "is-a-teacher.com", - "is-a-techie.com", - "is-a-therapist.com", - "is-an-accountant.com", - "is-an-actor.com", - "is-an-actress.com", - "is-an-anarchist.com", - "is-an-artist.com", - "is-an-engineer.com", - "is-an-entertainer.com", - "is-by.us", - "is-certified.com", - "is-found.org", - "is-gone.com", - "is-into-anime.com", - "is-into-cars.com", - "is-into-cartoons.com", - "is-into-games.com", - "is-leet.com", - "is-lost.org", - "is-not-certified.com", - "is-saved.org", - "is-slick.com", - "is-uberleet.com", - "is-very-bad.org", - "is-very-evil.org", - "is-very-good.org", - "is-very-nice.org", - "is-very-sweet.org", - "is-with-theband.com", - "isa-geek.com", - "isa-geek.net", - "isa-geek.org", - "isa-hockeynut.com", - "issmarterthanyou.com", - "isteingeek.de", - "istmein.de", - "kicks-ass.net", - "kicks-ass.org", - "knowsitall.info", - "land-4-sale.us", - "lebtimnetz.de", - "leitungsen.de", - "likes-pie.com", - "likescandy.com", - "merseine.nu", - "mine.nu", - "misconfused.org", - "mypets.ws", - "myphotos.cc", - "neat-url.com", - "office-on-the.net", - "on-the-web.tv", - "podzone.net", - "podzone.org", - "readmyblog.org", - "saves-the-whales.com", - "scrapper-site.net", - "scrapping.cc", - "selfip.biz", - "selfip.com", - "selfip.info", - "selfip.net", - "selfip.org", - "sells-for-less.com", - "sells-for-u.com", - "sells-it.net", - "sellsyourhome.org", - "servebbs.com", - "servebbs.net", - "servebbs.org", - "serveftp.net", - "serveftp.org", - "servegame.org", - "shacknet.nu", - "simple-url.com", - "space-to-rent.com", - "stuff-4-sale.org", - "stuff-4-sale.us", - "teaches-yoga.com", - "thruhere.net", - "traeumtgerade.de", - "webhop.biz", - "webhop.info", - "webhop.net", - "webhop.org", - "worse-than.tv", - "writesthisblog.com", - "dynv6.net", - "e4.cz", - "eu.org", - "al.eu.org", - "asso.eu.org", - "at.eu.org", - "au.eu.org", - "be.eu.org", - "bg.eu.org", - "ca.eu.org", - "cd.eu.org", - "ch.eu.org", - "cn.eu.org", - "cy.eu.org", - "cz.eu.org", - "de.eu.org", - "dk.eu.org", - "edu.eu.org", - "ee.eu.org", - "es.eu.org", - "fi.eu.org", - "fr.eu.org", - "gr.eu.org", - "hr.eu.org", - "hu.eu.org", - "ie.eu.org", - "il.eu.org", - "in.eu.org", - "int.eu.org", - "is.eu.org", - "it.eu.org", - "jp.eu.org", - "kr.eu.org", - "lt.eu.org", - "lu.eu.org", - "lv.eu.org", - "mc.eu.org", - "me.eu.org", - "mk.eu.org", - "mt.eu.org", - "my.eu.org", - "net.eu.org", - "ng.eu.org", - "nl.eu.org", - "no.eu.org", - "nz.eu.org", - "paris.eu.org", - "pl.eu.org", - "pt.eu.org", - "q-a.eu.org", - "ro.eu.org", - "ru.eu.org", - "se.eu.org", - "si.eu.org", - "sk.eu.org", - "tr.eu.org", - "uk.eu.org", - "us.eu.org", - "apps.fbsbx.com", - "a.ssl.fastly.net", - "b.ssl.fastly.net", - "global.ssl.fastly.net", - "a.prod.fastly.net", - "global.prod.fastly.net", - "firebaseapp.com", - "flynnhub.com", - "freebox-os.com", - "freeboxos.com", - "fbx-os.fr", - "fbxos.fr", - "freebox-os.fr", - "freeboxos.fr", - "service.gov.uk", - "github.io", - "githubusercontent.com", - "githubcloud.com", - "*.api.githubcloud.com", - "*.ext.githubcloud.com", - "gist.githubcloud.com", - "*.githubcloudusercontent.com", - "ro.com", - "goip.de", - "*.0emm.com", - "appspot.com", - "blogspot.ae", - "blogspot.al", - "blogspot.am", - "blogspot.ba", - "blogspot.be", - "blogspot.bg", - "blogspot.bj", - "blogspot.ca", - "blogspot.cf", - "blogspot.ch", - "blogspot.cl", - "blogspot.co.at", - "blogspot.co.id", - "blogspot.co.il", - "blogspot.co.ke", - "blogspot.co.nz", - "blogspot.co.uk", - "blogspot.co.za", - "blogspot.com", - "blogspot.com.ar", - "blogspot.com.au", - "blogspot.com.br", - "blogspot.com.by", - "blogspot.com.co", - "blogspot.com.cy", - "blogspot.com.ee", - "blogspot.com.eg", - "blogspot.com.es", - "blogspot.com.mt", - "blogspot.com.ng", - "blogspot.com.tr", - "blogspot.com.uy", - "blogspot.cv", - "blogspot.cz", - "blogspot.de", - "blogspot.dk", - "blogspot.fi", - "blogspot.fr", - "blogspot.gr", - "blogspot.hk", - "blogspot.hr", - "blogspot.hu", - "blogspot.ie", - "blogspot.in", - "blogspot.is", - "blogspot.it", - "blogspot.jp", - "blogspot.kr", - "blogspot.li", - "blogspot.lt", - "blogspot.lu", - "blogspot.md", - "blogspot.mk", - "blogspot.mr", - "blogspot.mx", - "blogspot.my", - "blogspot.nl", - "blogspot.no", - "blogspot.pe", - "blogspot.pt", - "blogspot.qa", - "blogspot.re", - "blogspot.ro", - "blogspot.rs", - "blogspot.ru", - "blogspot.se", - "blogspot.sg", - "blogspot.si", - "blogspot.sk", - "blogspot.sn", - "blogspot.td", - "blogspot.tw", - "blogspot.ug", - "blogspot.vn", - "cloudfunctions.net", - "codespot.com", - "googleapis.com", - "googlecode.com", - "pagespeedmobilizer.com", - "withgoogle.com", - "withyoutube.com", - "hashbang.sh", - "herokuapp.com", - "herokussl.com", - "iki.fi", - "biz.at", - "info.at", - "co.pl", - "azurewebsites.net", - "azure-mobile.net", - "cloudapp.net", - "bmoattachments.org", - "4u.com", - "ngrok.io", - "nfshost.com", - "nsupdate.info", - "nerdpol.ovh", - "blogsyte.com", - "brasilia.me", - "cable-modem.org", - "ciscofreak.com", - "collegefan.org", - "couchpotatofries.org", - "damnserver.com", - "ddns.me", - "ditchyourip.com", - "dnsfor.me", - "dnsiskinky.com", - "dvrcam.info", - "dynns.com", - "eating-organic.net", - "fantasyleague.cc", - "geekgalaxy.com", - "golffan.us", - "health-carereform.com", - "homesecuritymac.com", - "homesecuritypc.com", - "hopto.me", - "ilovecollege.info", - "loginto.me", - "mlbfan.org", - "mmafan.biz", - "myactivedirectory.com", - "mydissent.net", - "myeffect.net", - "mymediapc.net", - "mypsx.net", - "mysecuritycamera.com", - "mysecuritycamera.net", - "mysecuritycamera.org", - "net-freaks.com", - "nflfan.org", - "nhlfan.net", - "no-ip.ca", - "no-ip.co.uk", - "no-ip.net", - "noip.us", - "onthewifi.com", - "pgafan.net", - "point2this.com", - "pointto.us", - "privatizehealthinsurance.net", - "quicksytes.com", - "read-books.org", - "securitytactics.com", - "serveexchange.com", - "servehumour.com", - "servep2p.com", - "servesarcasm.com", - "stufftoread.com", - "ufcfan.org", - "unusualperson.com", - "workisboring.com", - "3utilities.com", - "bounceme.net", - "ddns.net", - "ddnsking.com", - "gotdns.ch", - "hopto.org", - "myftp.biz", - "myftp.org", - "myvnc.com", - "no-ip.biz", - "no-ip.info", - "no-ip.org", - "noip.me", - "redirectme.net", - "servebeer.com", - "serveblog.net", - "servecounterstrike.com", - "serveftp.com", - "servegame.com", - "servehalflife.com", - "servehttp.com", - "serveirc.com", - "serveminecraft.net", - "servemp3.com", - "servepics.com", - "servequake.com", - "sytes.net", - "webhop.me", - "zapto.org", - "nyc.mn", - "nid.io", - "operaunite.com", - "outsystemscloud.com", - "ownprovider.com", - "oy.lc", - "pgfog.com", - "pagefrontapp.com", - "art.pl", - "gliwice.pl", - "krakow.pl", - "poznan.pl", - "wroc.pl", - "zakopane.pl", - "pantheonsite.io", - "gotpantheon.com", - "mypep.link", - "xen.prgmr.com", - "priv.at", - "chirurgiens-dentistes-en-france.fr", - "qa2.com", - "rackmaze.com", - "rackmaze.net", - "rhcloud.com", - "hzc.io", - "sandcats.io", - "biz.ua", - "co.ua", - "pp.ua", - "sinaapp.com", - "vipsinaapp.com", - "1kapp.com", - "bounty-full.com", - "alpha.bounty-full.com", - "beta.bounty-full.com", - "spacekit.io", - "diskstation.me", - "dscloud.biz", - "dscloud.me", - "dscloud.mobi", - "dsmynas.com", - "dsmynas.net", - "dsmynas.org", - "familyds.com", - "familyds.net", - "familyds.org", - "i234.me", - "myds.me", - "synology.me", - "gda.pl", - "gdansk.pl", - "gdynia.pl", - "med.pl", - "sopot.pl", - "bloxcms.com", - "townnews-staging.com", - "hk.com", - "hk.org", - "ltd.hk", - "inc.hk", - "router.management", - "yolasite.com", - "za.net", - "za.org", -} - -var nodeLabels = [...]string{ - "aaa", - "aarp", - "abarth", - "abb", - "abbott", - "abbvie", - "abc", - "able", - "abogado", - "abudhabi", - "ac", - "academy", - "accenture", - "accountant", - "accountants", - "aco", - "active", - "actor", - "ad", - "adac", - "ads", - "adult", - "ae", - "aeg", - "aero", - "aetna", - "af", - "afamilycompany", - "afl", - "africa", - "africamagic", - "ag", - "agakhan", - "agency", - "ai", - "aig", - "aigo", - "airbus", - "airforce", - "airtel", - "akdn", - "al", - "alfaromeo", - "alibaba", - "alipay", - "allfinanz", - "allstate", - "ally", - "alsace", - "alstom", - "am", - "americanexpress", - "americanfamily", - "amex", - "amfam", - "amica", - "amsterdam", - "analytics", - "android", - "anquan", - "anz", - "ao", - "aol", - "apartments", - "app", - "apple", - "aq", - "aquarelle", - "ar", - "arab", - "aramco", - "archi", - "army", - "arpa", - "art", - "arte", - "as", - "asda", - "asia", - "associates", - "at", - "athleta", - "attorney", - "au", - "auction", - "audi", - "audible", - "audio", - "auspost", - "author", - "auto", - "autos", - "avianca", - "aw", - "aws", - "ax", - "axa", - "az", - "azure", - "ba", - "baby", - "baidu", - "banamex", - "bananarepublic", - "band", - "bank", - "bar", - "barcelona", - "barclaycard", - "barclays", - "barefoot", - "bargains", - "baseball", - "basketball", - "bauhaus", - "bayern", - "bb", - "bbc", - "bbt", - "bbva", - "bcg", - "bcn", - "bd", - "be", - "beats", - "beauty", - "beer", - "bentley", - "berlin", - "best", - "bestbuy", - "bet", - "bf", - "bg", - "bh", - "bharti", - "bi", - "bible", - "bid", - "bike", - "bing", - "bingo", - "bio", - "biz", - "bj", - "black", - "blackfriday", - "blanco", - "blockbuster", - "blog", - "bloomberg", - "blue", - "bm", - "bms", - "bmw", - "bn", - "bnl", - "bnpparibas", - "bo", - "boats", - "boehringer", - "bofa", - "bom", - "bond", - "boo", - "book", - "booking", - "boots", - "bosch", - "bostik", - "boston", - "bot", - "boutique", - "box", - "br", - "bradesco", - "bridgestone", - "broadway", - "broker", - "brother", - "brussels", - "bs", - "bt", - "budapest", - "bugatti", - "build", - "builders", - "business", - "buy", - "buzz", - "bv", - "bw", - "by", - "bz", - "bzh", - "ca", - "cab", - "cafe", - "cal", - "call", - "calvinklein", - "cam", - "camera", - "camp", - "cancerresearch", - "canon", - "capetown", - "capital", - "capitalone", - "car", - "caravan", - "cards", - "care", - "career", - "careers", - "cars", - "cartier", - "casa", - "case", - "caseih", - "cash", - "casino", - "cat", - "catering", - "catholic", - "cba", - "cbn", - "cbre", - "cbs", - "cc", - "cd", - "ceb", - "center", - "ceo", - "cern", - "cf", - "cfa", - "cfd", - "cg", - "ch", - "chanel", - "channel", - "chase", - "chat", - "cheap", - "chintai", - "chloe", - "christmas", - "chrome", - "chrysler", - "church", - "ci", - "cipriani", - "circle", - "cisco", - "citadel", - "citi", - "citic", - "city", - "cityeats", - "ck", - "cl", - "claims", - "cleaning", - "click", - "clinic", - "clinique", - "clothing", - "cloud", - "club", - "clubmed", - "cm", - "cn", - "co", - "coach", - "codes", - "coffee", - "college", - "cologne", - "com", - "comcast", - "commbank", - "community", - "company", - "compare", - "computer", - "comsec", - "condos", - "construction", - "consulting", - "contact", - "contractors", - "cooking", - "cookingchannel", - "cool", - "coop", - "corsica", - "country", - "coupon", - "coupons", - "courses", - "cr", - "credit", - "creditcard", - "creditunion", - "cricket", - "crown", - "crs", - "cruise", - "cruises", - "csc", - "cu", - "cuisinella", - "cv", - "cw", - "cx", - "cy", - "cymru", - "cyou", - "cz", - "dabur", - "dad", - "dance", - "date", - "dating", - "datsun", - "day", - "dclk", - "dds", - "de", - "deal", - "dealer", - "deals", - "degree", - "delivery", - "dell", - "deloitte", - "delta", - "democrat", - "dental", - "dentist", - "desi", - "design", - "dev", - "dhl", - "diamonds", - "diet", - "digital", - "direct", - "directory", - "discount", - "discover", - "dish", - "diy", - "dj", - "dk", - "dm", - "dnp", - "do", - "docs", - "dodge", - "dog", - "doha", - "domains", - "dot", - "download", - "drive", - "dstv", - "dtv", - "dubai", - "duck", - "dunlop", - "duns", - "dupont", - "durban", - "dvag", - "dwg", - "dz", - "earth", - "eat", - "ec", - "edeka", - "edu", - "education", - "ee", - "eg", - "email", - "emerck", - "emerson", - "energy", - "engineer", - "engineering", - "enterprises", - "epost", - "epson", - "equipment", - "er", - "ericsson", - "erni", - "es", - "esq", - "estate", - "esurance", - "et", - "etisalat", - "eu", - "eurovision", - "eus", - "events", - "everbank", - "exchange", - "expert", - "exposed", - "express", - "extraspace", - "fage", - "fail", - "fairwinds", - "faith", - "family", - "fan", - "fans", - "farm", - "farmers", - "fashion", - "fast", - "fedex", - "feedback", - "ferrari", - "ferrero", - "fi", - "fiat", - "fidelity", - "fido", - "film", - "final", - "finance", - "financial", - "fire", - "firestone", - "firmdale", - "fish", - "fishing", - "fit", - "fitness", - "fj", - "fk", - "flickr", - "flights", - "flir", - "florist", - "flowers", - "flsmidth", - "fly", - "fm", - "fo", - "foo", - "food", - "foodnetwork", - "football", - "ford", - "forex", - "forsale", - "forum", - "foundation", - "fox", - "fr", - "free", - "fresenius", - "frl", - "frogans", - "frontdoor", - "frontier", - "ftr", - "fujitsu", - "fujixerox", - "fun", - "fund", - "furniture", - "futbol", - "fyi", - "ga", - "gal", - "gallery", - "gallo", - "gallup", - "game", - "games", - "gap", - "garden", - "gb", - "gbiz", - "gd", - "gdn", - "ge", - "gea", - "gent", - "genting", - "george", - "gf", - "gg", - "ggee", - "gh", - "gi", - "gift", - "gifts", - "gives", - "giving", - "gl", - "glade", - "glass", - "gle", - "global", - "globo", - "gm", - "gmail", - "gmbh", - "gmo", - "gmx", - "gn", - "godaddy", - "gold", - "goldpoint", - "golf", - "goo", - "goodhands", - "goodyear", - "goog", - "google", - "gop", - "got", - "gotv", - "gov", - "gp", - "gq", - "gr", - "grainger", - "graphics", - "gratis", - "green", - "gripe", - "group", - "gs", - "gt", - "gu", - "guardian", - "gucci", - "guge", - "guide", - "guitars", - "guru", - "gw", - "gy", - "hair", - "hamburg", - "hangout", - "haus", - "hbo", - "hdfc", - "hdfcbank", - "health", - "healthcare", - "help", - "helsinki", - "here", - "hermes", - "hgtv", - "hiphop", - "hisamitsu", - "hitachi", - "hiv", - "hk", - "hkt", - "hm", - "hn", - "hockey", - "holdings", - "holiday", - "homedepot", - "homegoods", - "homes", - "homesense", - "honda", - "honeywell", - "horse", - "host", - "hosting", - "hot", - "hoteles", - "hotels", - "hotmail", - "house", - "how", - "hr", - "hsbc", - "ht", - "htc", - "hu", - "hughes", - "hyatt", - "hyundai", - "ibm", - "icbc", - "ice", - "icu", - "id", - "ie", - "ieee", - "ifm", - "iinet", - "ikano", - "il", - "im", - "imamat", - "imdb", - "immo", - "immobilien", - "in", - "industries", - "infiniti", - "info", - "ing", - "ink", - "institute", - "insurance", - "insure", - "int", - "intel", - "international", - "intuit", - "investments", - "io", - "ipiranga", - "iq", - "ir", - "irish", - "is", - "iselect", - "ismaili", - "ist", - "istanbul", - "it", - "itau", - "itv", - "iveco", - "iwc", - "jaguar", - "java", - "jcb", - "jcp", - "je", - "jeep", - "jetzt", - "jewelry", - "jio", - "jlc", - "jll", - "jm", - "jmp", - "jnj", - "jo", - "jobs", - "joburg", - "jot", - "joy", - "jp", - "jpmorgan", - "jprs", - "juegos", - "juniper", - "kaufen", - "kddi", - "ke", - "kerryhotels", - "kerrylogistics", - "kerryproperties", - "kfh", - "kg", - "kh", - "ki", - "kia", - "kim", - "kinder", - "kindle", - "kitchen", - "kiwi", - "km", - "kn", - "koeln", - "komatsu", - "kosher", - "kp", - "kpmg", - "kpn", - "kr", - "krd", - "kred", - "kuokgroup", - "kw", - "ky", - "kyknet", - "kyoto", - "kz", - "la", - "lacaixa", - "ladbrokes", - "lamborghini", - "lamer", - "lancaster", - "lancia", - "lancome", - "land", - "landrover", - "lanxess", - "lasalle", - "lat", - "latino", - "latrobe", - "law", - "lawyer", - "lb", - "lc", - "lds", - "lease", - "leclerc", - "lefrak", - "legal", - "lego", - "lexus", - "lgbt", - "li", - "liaison", - "lidl", - "life", - "lifeinsurance", - "lifestyle", - "lighting", - "like", - "lilly", - "limited", - "limo", - "lincoln", - "linde", - "link", - "lipsy", - "live", - "living", - "lixil", - "lk", - "loan", - "loans", - "locker", - "locus", - "loft", - "lol", - "london", - "lotte", - "lotto", - "love", - "lpl", - "lplfinancial", - "lr", - "ls", - "lt", - "ltd", - "ltda", - "lu", - "lundbeck", - "lupin", - "luxe", - "luxury", - "lv", - "ly", - "ma", - "macys", - "madrid", - "maif", - "maison", - "makeup", - "man", - "management", - "mango", - "market", - "marketing", - "markets", - "marriott", - "marshalls", - "maserati", - "mattel", - "mba", - "mc", - "mcd", - "mcdonalds", - "mckinsey", - "md", - "me", - "med", - "media", - "meet", - "melbourne", - "meme", - "memorial", - "men", - "menu", - "meo", - "metlife", - "mg", - "mh", - "miami", - "microsoft", - "mil", - "mini", - "mint", - "mit", - "mitsubishi", - "mk", - "ml", - "mlb", - "mls", - "mm", - "mma", - "mn", - "mnet", - "mo", - "mobi", - "mobily", - "moda", - "moe", - "moi", - "mom", - "monash", - "money", - "monster", - "montblanc", - "mopar", - "mormon", - "mortgage", - "moscow", - "moto", - "motorcycles", - "mov", - "movie", - "movistar", - "mp", - "mq", - "mr", - "ms", - "msd", - "mt", - "mtn", - "mtpc", - "mtr", - "mu", - "multichoice", - "museum", - "mutual", - "mutuelle", - "mv", - "mw", - "mx", - "my", - "mz", - "mzansimagic", - "na", - "nab", - "nadex", - "nagoya", - "name", - "naspers", - "nationwide", - "natura", - "navy", - "nba", - "nc", - "ne", - "nec", - "net", - "netbank", - "netflix", - "network", - "neustar", - "new", - "newholland", - "news", - "next", - "nextdirect", - "nexus", - "nf", - "nfl", - "ng", - "ngo", - "nhk", - "ni", - "nico", - "nike", - "nikon", - "ninja", - "nissan", - "nissay", - "nl", - "no", - "nokia", - "northwesternmutual", - "norton", - "now", - "nowruz", - "nowtv", - "np", - "nr", - "nra", - "nrw", - "ntt", - "nu", - "nyc", - "nz", - "obi", - "observer", - "off", - "office", - "okinawa", - "olayan", - "olayangroup", - "oldnavy", - "ollo", - "om", - "omega", - "one", - "ong", - "onl", - "online", - "onyourside", - "ooo", - "open", - "oracle", - "orange", - "org", - "organic", - "orientexpress", - "origins", - "osaka", - "otsuka", - "ott", - "ovh", - "pa", - "page", - "pamperedchef", - "panasonic", - "panerai", - "paris", - "pars", - "partners", - "parts", - "party", - "passagens", - "pay", - "payu", - "pccw", - "pe", - "pet", - "pf", - "pfizer", - "pg", - "ph", - "pharmacy", - "philips", - "photo", - "photography", - "photos", - "physio", - "piaget", - "pics", - "pictet", - "pictures", - "pid", - "pin", - "ping", - "pink", - "pioneer", - "pizza", - "pk", - "pl", - "place", - "play", - "playstation", - "plumbing", - "plus", - "pm", - "pn", - "pnc", - "pohl", - "poker", - "politie", - "porn", - "post", - "pr", - "pramerica", - "praxi", - "press", - "prime", - "pro", - "prod", - "productions", - "prof", - "progressive", - "promo", - "properties", - "property", - "protection", - "pru", - "prudential", - "ps", - "pt", - "pub", - "pw", - "pwc", - "py", - "qa", - "qpon", - "quebec", - "quest", - "qvc", - "racing", - "raid", - "re", - "read", - "realestate", - "realtor", - "realty", - "recipes", - "red", - "redstone", - "redumbrella", - "rehab", - "reise", - "reisen", - "reit", - "reliance", - "ren", - "rent", - "rentals", - "repair", - "report", - "republican", - "rest", - "restaurant", - "review", - "reviews", - "rexroth", - "rich", - "richardli", - "ricoh", - "rightathome", - "ril", - "rio", - "rip", - "rmit", - "ro", - "rocher", - "rocks", - "rodeo", - "rogers", - "room", - "rs", - "rsvp", - "ru", - "ruhr", - "run", - "rw", - "rwe", - "ryukyu", - "sa", - "saarland", - "safe", - "safety", - "sakura", - "sale", - "salon", - "samsclub", - "samsung", - "sandvik", - "sandvikcoromant", - "sanofi", - "sap", - "sapo", - "sarl", - "sas", - "save", - "saxo", - "sb", - "sbi", - "sbs", - "sc", - "sca", - "scb", - "schaeffler", - "schmidt", - "scholarships", - "school", - "schule", - "schwarz", - "science", - "scjohnson", - "scor", - "scot", - "sd", - "se", - "seat", - "secure", - "security", - "seek", - "select", - "sener", - "services", - "ses", - "seven", - "sew", - "sex", - "sexy", - "sfr", - "sg", - "sh", - "shangrila", - "sharp", - "shaw", - "shell", - "shia", - "shiksha", - "shoes", - "shop", - "shopping", - "shouji", - "show", - "showtime", - "shriram", - "si", - "silk", - "sina", - "singles", - "site", - "sj", - "sk", - "ski", - "skin", - "sky", - "skype", - "sl", - "sling", - "sm", - "smart", - "smile", - "sn", - "sncf", - "so", - "soccer", - "social", - "softbank", - "software", - "sohu", - "solar", - "solutions", - "song", - "sony", - "soy", - "space", - "spiegel", - "spot", - "spreadbetting", - "sr", - "srl", - "srt", - "st", - "stada", - "staples", - "star", - "starhub", - "statebank", - "statefarm", - "statoil", - "stc", - "stcgroup", - "stockholm", - "storage", - "store", - "stream", - "studio", - "study", - "style", - "su", - "sucks", - "supersport", - "supplies", - "supply", - "support", - "surf", - "surgery", - "suzuki", - "sv", - "swatch", - "swiftcover", - "swiss", - "sx", - "sy", - "sydney", - "symantec", - "systems", - "sz", - "tab", - "taipei", - "talk", - "taobao", - "target", - "tatamotors", - "tatar", - "tattoo", - "tax", - "taxi", - "tc", - "tci", - "td", - "tdk", - "team", - "tech", - "technology", - "tel", - "telecity", - "telefonica", - "temasek", - "tennis", - "teva", - "tf", - "tg", - "th", - "thd", - "theater", - "theatre", - "theguardian", - "tiaa", - "tickets", - "tienda", - "tiffany", - "tips", - "tires", - "tirol", - "tj", - "tjmaxx", - "tjx", - "tk", - "tkmaxx", - "tl", - "tm", - "tmall", - "tn", - "to", - "today", - "tokyo", - "tools", - "top", - "toray", - "toshiba", - "total", - "tours", - "town", - "toyota", - "toys", - "tr", - "trade", - "trading", - "training", - "travel", - "travelchannel", - "travelers", - "travelersinsurance", - "trust", - "trv", - "tt", - "tube", - "tui", - "tunes", - "tushu", - "tv", - "tvs", - "tw", - "tz", - "ua", - "ubank", - "ubs", - "uconnect", - "ug", - "uk", - "unicom", - "university", - "uno", - "uol", - "ups", - "us", - "uy", - "uz", - "va", - "vacations", - "vana", - "vanguard", - "vc", - "ve", - "vegas", - "ventures", - "verisign", - "versicherung", - "vet", - "vg", - "vi", - "viajes", - "video", - "vig", - "viking", - "villas", - "vin", - "vip", - "virgin", - "visa", - "vision", - "vista", - "vistaprint", - "viva", - "vivo", - "vlaanderen", - "vn", - "vodka", - "volkswagen", - "volvo", - "vote", - "voting", - "voto", - "voyage", - "vu", - "vuelos", - "wales", - "walmart", - "walter", - "wang", - "wanggou", - "warman", - "watch", - "watches", - "weather", - "weatherchannel", - "webcam", - "weber", - "website", - "wed", - "wedding", - "weibo", - "weir", - "wf", - "whoswho", - "wien", - "wiki", - "williamhill", - "win", - "windows", - "wine", - "winners", - "wme", - "wolterskluwer", - "woodside", - "work", - "works", - "world", - "wow", - "ws", - "wtc", - "wtf", - "xbox", - "xerox", - "xfinity", - "xihuan", - "xin", - "xn--11b4c3d", - "xn--1ck2e1b", - "xn--1qqw23a", - "xn--30rr7y", - "xn--3bst00m", - "xn--3ds443g", - "xn--3e0b707e", - "xn--3oq18vl8pn36a", - "xn--3pxu8k", - "xn--42c2d9a", - "xn--45brj9c", - "xn--45q11c", - "xn--4gbrim", - "xn--4gq48lf9j", - "xn--54b7fta0cc", - "xn--55qw42g", - "xn--55qx5d", - "xn--5su34j936bgsg", - "xn--5tzm5g", - "xn--6frz82g", - "xn--6qq986b3xl", - "xn--80adxhks", - "xn--80ao21a", - "xn--80aqecdr1a", - "xn--80asehdb", - "xn--80aswg", - "xn--8y0a063a", - "xn--90a3ac", - "xn--90ais", - "xn--9dbq2a", - "xn--9et52u", - "xn--9krt00a", - "xn--b4w605ferd", - "xn--bck1b9a5dre4c", - "xn--c1avg", - "xn--c2br7g", - "xn--cck2b3b", - "xn--cg4bki", - "xn--clchc0ea0b2g2a9gcd", - "xn--czr694b", - "xn--czrs0t", - "xn--czru2d", - "xn--d1acj3b", - "xn--d1alf", - "xn--e1a4c", - "xn--eckvdtc9d", - "xn--efvy88h", - "xn--estv75g", - "xn--fct429k", - "xn--fhbei", - "xn--fiq228c5hs", - "xn--fiq64b", - "xn--fiqs8s", - "xn--fiqz9s", - "xn--fjq720a", - "xn--flw351e", - "xn--fpcrj9c3d", - "xn--fzc2c9e2c", - "xn--fzys8d69uvgm", - "xn--g2xx48c", - "xn--gckr3f0f", - "xn--gecrj9c", - "xn--gk3at1e", - "xn--h2brj9c", - "xn--hxt814e", - "xn--i1b6b1a6a2e", - "xn--imr513n", - "xn--io0a7i", - "xn--j1aef", - "xn--j1amh", - "xn--j6w193g", - "xn--jlq61u9w7b", - "xn--jvr189m", - "xn--kcrx77d1x4a", - "xn--kprw13d", - "xn--kpry57d", - "xn--kpu716f", - "xn--kput3i", - "xn--l1acc", - "xn--lgbbat1ad8j", - "xn--mgb2ddes", - "xn--mgb9awbf", - "xn--mgba3a3ejt", - "xn--mgba3a4f16a", - "xn--mgba3a4fra", - "xn--mgba7c0bbn0a", - "xn--mgbaakc7dvf", - "xn--mgbaam7a8h", - "xn--mgbab2bd", - "xn--mgbai9a5eva00b", - "xn--mgbai9azgqp6j", - "xn--mgbayh7gpa", - "xn--mgbb9fbpob", - "xn--mgbbh1a71e", - "xn--mgbc0a9azcg", - "xn--mgbca7dzdo", - "xn--mgberp4a5d4a87g", - "xn--mgberp4a5d4ar", - "xn--mgbi4ecexp", - "xn--mgbpl2fh", - "xn--mgbqly7c0a67fbc", - "xn--mgbqly7cvafr", - "xn--mgbt3dhd", - "xn--mgbtf8fl", - "xn--mgbtx2b", - "xn--mgbx4cd0ab", - "xn--mix082f", - "xn--mix891f", - "xn--mk1bu44c", - "xn--mxtq1m", - "xn--ngbc5azd", - "xn--ngbe9e0a", - "xn--ngbrx", - "xn--nnx388a", - "xn--node", - "xn--nqv7f", - "xn--nqv7fs00ema", - "xn--nyqy26a", - "xn--o3cw4h", - "xn--ogbpf8fl", - "xn--p1acf", - "xn--p1ai", - "xn--pbt977c", - "xn--pgbs0dh", - "xn--pssy2u", - "xn--q9jyb4c", - "xn--qcka1pmc", - "xn--qxam", - "xn--rhqv96g", - "xn--rovu88b", - "xn--s9brj9c", - "xn--ses554g", - "xn--t60b56a", - "xn--tckwe", - "xn--tiq49xqyj", - "xn--unup4y", - "xn--vermgensberater-ctb", - "xn--vermgensberatung-pwb", - "xn--vhquv", - "xn--vuq861b", - "xn--w4r85el8fhu5dnra", - "xn--w4rs40l", - "xn--wgbh1c", - "xn--wgbl6a", - "xn--xhq521b", - "xn--xkc2al3hye2a", - "xn--xkc2dl3a5ee0h", - "xn--y9a3aq", - "xn--yfro4i67o", - "xn--ygbi2ammx", - "xn--zfr164b", - "xperia", - "xxx", - "xyz", - "yachts", - "yahoo", - "yamaxun", - "yandex", - "ye", - "yodobashi", - "yoga", - "yokohama", - "you", - "youtube", - "yt", - "yun", - "za", - "zappos", - "zara", - "zero", - "zip", - "zippo", - "zm", - "zone", - "zuerich", - "zw", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "nom", - "ac", - "blogspot", - "co", - "gov", - "mil", - "net", - "org", - "sch", - "accident-investigation", - "accident-prevention", - "aerobatic", - "aeroclub", - "aerodrome", - "agents", - "air-surveillance", - "air-traffic-control", - "aircraft", - "airline", - "airport", - "airtraffic", - "ambulance", - "amusement", - "association", - "author", - "ballooning", - "broker", - "caa", - "cargo", - "catering", - "certification", - "championship", - "charter", - "civilaviation", - "club", - "conference", - "consultant", - "consulting", - "control", - "council", - "crew", - "design", - "dgca", - "educator", - "emergency", - "engine", - "engineer", - "entertainment", - "equipment", - "exchange", - "express", - "federation", - "flight", - "freight", - "fuel", - "gliding", - "government", - "groundhandling", - "group", - "hanggliding", - "homebuilt", - "insurance", - "journal", - "journalist", - "leasing", - "logistics", - "magazine", - "maintenance", - "media", - "microlight", - "modelling", - "navigation", - "parachuting", - "paragliding", - "passenger-association", - "pilot", - "press", - "production", - "recreation", - "repbody", - "res", - "research", - "rotorcraft", - "safety", - "scientist", - "services", - "show", - "skydiving", - "software", - "student", - "trader", - "trading", - "trainer", - "union", - "workinggroup", - "works", - "com", - "edu", - "gov", - "net", - "org", - "co", - "com", - "net", - "nom", - "org", - "com", - "net", - "off", - "org", - "blogspot", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "blogspot", - "co", - "ed", - "gv", - "it", - "og", - "pb", - "com", - "edu", - "gob", - "gov", - "int", - "mil", - "net", - "org", - "tur", - "blogspot", - "e164", - "in-addr", - "ip6", - "iris", - "uri", - "urn", - "gov", - "ac", - "biz", - "co", - "gv", - "info", - "or", - "priv", - "blogspot", - "act", - "asn", - "com", - "conf", - "edu", - "gov", - "id", - "info", - "net", - "nsw", - "nt", - "org", - "oz", - "qld", - "sa", - "tas", - "vic", - "wa", - "blogspot", - "act", - "nsw", - "nt", - "qld", - "sa", - "tas", - "vic", - "wa", - "qld", - "sa", - "tas", - "vic", - "wa", - "com", - "biz", - "com", - "edu", - "gov", - "info", - "int", - "mil", - "name", - "net", - "org", - "pp", - "pro", - "blogspot", - "co", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "rs", - "unbi", - "unsa", - "biz", - "co", - "com", - "edu", - "gov", - "info", - "net", - "org", - "store", - "tv", - "ac", - "blogspot", - "gov", - "0", - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", - "9", - "a", - "b", - "blogspot", - "c", - "d", - "e", - "f", - "g", - "h", - "i", - "j", - "k", - "l", - "m", - "n", - "o", - "p", - "q", - "r", - "s", - "t", - "u", - "v", - "w", - "x", - "y", - "z", - "com", - "edu", - "gov", - "net", - "org", - "co", - "com", - "edu", - "or", - "org", - "dscloud", - "dyndns", - "for-better", - "for-more", - "for-some", - "for-the", - "mmafan", - "myftp", - "no-ip", - "selfip", - "webhop", - "asso", - "barreau", - "blogspot", - "gouv", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gob", - "gov", - "int", - "mil", - "net", - "org", - "tv", - "adm", - "adv", - "agr", - "am", - "arq", - "art", - "ato", - "b", - "bio", - "blog", - "bmd", - "cim", - "cng", - "cnt", - "com", - "coop", - "ecn", - "eco", - "edu", - "emp", - "eng", - "esp", - "etc", - "eti", - "far", - "flog", - "fm", - "fnd", - "fot", - "fst", - "g12", - "ggf", - "gov", - "imb", - "ind", - "inf", - "jor", - "jus", - "leg", - "lel", - "mat", - "med", - "mil", - "mp", - "mus", - "net", - "nom", - "not", - "ntr", - "odo", - "org", - "ppg", - "pro", - "psc", - "psi", - "qsl", - "radio", - "rec", - "slg", - "srv", - "taxi", - "teo", - "tmp", - "trd", - "tur", - "tv", - "vet", - "vlog", - "wiki", - "zlg", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "net", - "org", - "co", - "org", - "com", - "gov", - "mil", - "of", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "za", - "ab", - "bc", - "blogspot", - "co", - "gc", - "mb", - "nb", - "nf", - "nl", - "no-ip", - "ns", - "nt", - "nu", - "on", - "pe", - "qc", - "sk", - "yk", - "fantasyleague", - "ftpaccess", - "game-server", - "myphotos", - "scrapping", - "gov", - "blogspot", - "blogspot", - "gotdns", - "ac", - "asso", - "co", - "com", - "ed", - "edu", - "go", - "gouv", - "int", - "md", - "net", - "or", - "org", - "presse", - "xn--aroport-bya", - "www", - "blogspot", - "co", - "gob", - "gov", - "mil", - "co", - "com", - "gov", - "net", - "ac", - "ah", - "amazonaws", - "bj", - "com", - "cq", - "edu", - "fj", - "gd", - "gov", - "gs", - "gx", - "gz", - "ha", - "hb", - "he", - "hi", - "hk", - "hl", - "hn", - "jl", - "js", - "jx", - "ln", - "mil", - "mo", - "net", - "nm", - "nx", - "org", - "qh", - "sc", - "sd", - "sh", - "sn", - "sx", - "tj", - "tw", - "xj", - "xn--55qx5d", - "xn--io0a7i", - "xn--od0alg", - "xz", - "yn", - "zj", - "compute", - "cn-north-1", - "amazonaws", - "cn-north-1", - "s3", - "arts", - "com", - "edu", - "firm", - "gov", - "info", - "int", - "mil", - "net", - "nom", - "org", - "rec", - "web", - "blogspot", - "0emm", - "1kapp", - "3utilities", - "4u", - "africa", - "amazonaws", - "appspot", - "ar", - "betainabox", - "blogdns", - "blogspot", - "blogsyte", - "bloxcms", - "bounty-full", - "br", - "cechire", - "ciscofreak", - "cloudcontrolapp", - "cloudcontrolled", - "cn", - "co", - "codespot", - "damnserver", - "ddnsking", - "de", - "ditchyourip", - "dnsalias", - "dnsdojo", - "dnsiskinky", - "doesntexist", - "dontexist", - "doomdns", - "dreamhosters", - "dsmynas", - "dyn-o-saur", - "dynalias", - "dyndns-at-home", - "dyndns-at-work", - "dyndns-blog", - "dyndns-free", - "dyndns-home", - "dyndns-ip", - "dyndns-mail", - "dyndns-office", - "dyndns-pics", - "dyndns-remote", - "dyndns-server", - "dyndns-web", - "dyndns-wiki", - "dyndns-work", - "dynns", - "elasticbeanstalk", - "est-a-la-maison", - "est-a-la-masion", - "est-le-patron", - "est-mon-blogueur", - "eu", - "familyds", - "fbsbx", - "firebaseapp", - "flynnhub", - "freebox-os", - "freeboxos", - "from-ak", - "from-al", - "from-ar", - "from-ca", - "from-ct", - "from-dc", - "from-de", - "from-fl", - "from-ga", - "from-hi", - "from-ia", - "from-id", - "from-il", - "from-in", - "from-ks", - "from-ky", - "from-ma", - "from-md", - "from-mi", - "from-mn", - "from-mo", - "from-ms", - "from-mt", - "from-nc", - "from-nd", - "from-ne", - "from-nh", - "from-nj", - "from-nm", - "from-nv", - "from-oh", - "from-ok", - "from-or", - "from-pa", - "from-pr", - "from-ri", - "from-sc", - "from-sd", - "from-tn", - "from-tx", - "from-ut", - "from-va", - "from-vt", - "from-wa", - "from-wi", - "from-wv", - "from-wy", - "gb", - "geekgalaxy", - "getmyip", - "githubcloud", - "githubcloudusercontent", - "githubusercontent", - "googleapis", - "googlecode", - "gotdns", - "gotpantheon", - "gr", - "health-carereform", - "herokuapp", - "herokussl", - "hk", - "hobby-site", - "homelinux", - "homesecuritymac", - "homesecuritypc", - "homeunix", - "hu", - "iamallama", - "is-a-anarchist", - "is-a-blogger", - "is-a-bookkeeper", - "is-a-bulls-fan", - "is-a-caterer", - "is-a-chef", - "is-a-conservative", - "is-a-cpa", - "is-a-cubicle-slave", - "is-a-democrat", - "is-a-designer", - "is-a-doctor", - "is-a-financialadvisor", - "is-a-geek", - "is-a-green", - "is-a-guru", - "is-a-hard-worker", - "is-a-hunter", - "is-a-landscaper", - "is-a-lawyer", - "is-a-liberal", - "is-a-libertarian", - "is-a-llama", - "is-a-musician", - "is-a-nascarfan", - "is-a-nurse", - "is-a-painter", - "is-a-personaltrainer", - "is-a-photographer", - "is-a-player", - "is-a-republican", - "is-a-rockstar", - "is-a-socialist", - "is-a-student", - "is-a-teacher", - "is-a-techie", - "is-a-therapist", - "is-an-accountant", - "is-an-actor", - "is-an-actress", - "is-an-anarchist", - "is-an-artist", - "is-an-engineer", - "is-an-entertainer", - "is-certified", - "is-gone", - "is-into-anime", - "is-into-cars", - "is-into-cartoons", - "is-into-games", - "is-leet", - "is-not-certified", - "is-slick", - "is-uberleet", - "is-with-theband", - "isa-geek", - "isa-hockeynut", - "issmarterthanyou", - "jpn", - "kr", - "likes-pie", - "likescandy", - "mex", - "myactivedirectory", - "mydrobo", - "mysecuritycamera", - "myvnc", - "neat-url", - "net-freaks", - "nfshost", - "no", - "on-aptible", - "onthewifi", - "operaunite", - "outsystemscloud", - "ownprovider", - "pagefrontapp", - "pagespeedmobilizer", - "pgfog", - "point2this", - "prgmr", - "qa2", - "qc", - "quicksytes", - "rackmaze", - "rhcloud", - "ro", - "ru", - "sa", - "saves-the-whales", - "se", - "securitytactics", - "selfip", - "sells-for-less", - "sells-for-u", - "servebbs", - "servebeer", - "servecounterstrike", - "serveexchange", - "serveftp", - "servegame", - "servehalflife", - "servehttp", - "servehumour", - "serveirc", - "servemp3", - "servep2p", - "servepics", - "servequake", - "servesarcasm", - "simple-url", - "sinaapp", - "space-to-rent", - "stufftoread", - "teaches-yoga", - "townnews-staging", - "uk", - "unusualperson", - "us", - "uy", - "vipsinaapp", - "withgoogle", - "withyoutube", - "workisboring", - "writesthisblog", - "xenapponazure", - "yolasite", - "za", - "ap-northeast-2", - "compute", - "compute-1", - "elb", - "eu-central-1", - "s3", - "s3-ap-northeast-1", - "s3-ap-northeast-2", - "s3-ap-southeast-1", - "s3-ap-southeast-2", - "s3-eu-central-1", - "s3-eu-west-1", - "s3-external-1", - "s3-external-2", - "s3-fips-us-gov-west-1", - "s3-sa-east-1", - "s3-us-gov-west-1", - "s3-us-west-1", - "s3-us-west-2", - "us-east-1", - "s3", - "ap-northeast-1", - "ap-northeast-2", - "ap-southeast-1", - "ap-southeast-2", - "eu-central-1", - "eu-west-1", - "sa-east-1", - "us-gov-west-1", - "us-west-1", - "us-west-2", - "z-1", - "z-2", - "s3", - "alpha", - "beta", - "apps", - "api", - "ext", - "gist", - "xen", - "ac", - "co", - "ed", - "fi", - "go", - "or", - "sa", - "com", - "edu", - "gov", - "inf", - "net", - "org", - "blogspot", - "com", - "edu", - "net", - "org", - "ath", - "gov", - "ac", - "biz", - "com", - "ekloges", - "gov", - "ltd", - "name", - "net", - "org", - "parliament", - "press", - "pro", - "tm", - "blogspot", - "blogspot", - "co", - "e4", - "blogspot", - "com", - "dnshome", - "fuettertdasnetz", - "goip", - "isteingeek", - "istmein", - "lebtimnetz", - "leitungsen", - "traeumtgerade", - "biz", - "blogspot", - "co", - "firm", - "reg", - "store", - "com", - "edu", - "gov", - "net", - "org", - "art", - "com", - "edu", - "gob", - "gov", - "mil", - "net", - "org", - "sld", - "web", - "art", - "asso", - "com", - "edu", - "gov", - "net", - "org", - "pol", - "com", - "edu", - "fin", - "gob", - "gov", - "info", - "k12", - "med", - "mil", - "net", - "org", - "pro", - "aip", - "com", - "edu", - "fie", - "gov", - "lib", - "med", - "org", - "pri", - "riik", - "blogspot", - "com", - "edu", - "eun", - "gov", - "mil", - "name", - "net", - "org", - "sci", - "blogspot", - "com", - "edu", - "gob", - "nom", - "org", - "blogspot", - "compute", - "biz", - "com", - "edu", - "gov", - "info", - "name", - "net", - "org", - "aland", - "blogspot", - "dy", - "iki", - "aeroport", - "assedic", - "asso", - "avocat", - "avoues", - "blogspot", - "cci", - "chambagri", - "chirurgiens-dentistes", - "chirurgiens-dentistes-en-france", - "com", - "experts-comptables", - "fbx-os", - "fbxos", - "freebox-os", - "freeboxos", - "geometre-expert", - "gouv", - "greta", - "huissier-justice", - "medecin", - "nom", - "notaires", - "pharmacien", - "port", - "prd", - "presse", - "tm", - "veterinaire", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "pvt", - "co", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "org", - "com", - "edu", - "gov", - "ltd", - "mod", - "org", - "co", - "com", - "edu", - "net", - "org", - "ac", - "com", - "edu", - "gov", - "net", - "org", - "asso", - "com", - "edu", - "mobi", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gob", - "ind", - "mil", - "net", - "org", - "co", - "com", - "edu", - "gov", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "idv", - "inc", - "ltd", - "net", - "org", - "xn--55qx5d", - "xn--ciqpn", - "xn--gmq050i", - "xn--gmqw5a", - "xn--io0a7i", - "xn--lcvr32d", - "xn--mk0axi", - "xn--mxtq1m", - "xn--od0alg", - "xn--od0aq3b", - "xn--tn0ag", - "xn--uc0atv", - "xn--uc0ay4a", - "xn--wcvs22d", - "xn--zf0avx", - "com", - "edu", - "gob", - "mil", - "net", - "org", - "blogspot", - "com", - "from", - "iz", - "name", - "adult", - "art", - "asso", - "com", - "coop", - "edu", - "firm", - "gouv", - "info", - "med", - "net", - "org", - "perso", - "pol", - "pro", - "rel", - "shop", - "2000", - "agrar", - "blogspot", - "bolt", - "casino", - "city", - "co", - "erotica", - "erotika", - "film", - "forum", - "games", - "hotel", - "info", - "ingatlan", - "jogasz", - "konyvelo", - "lakas", - "media", - "news", - "org", - "priv", - "reklam", - "sex", - "shop", - "sport", - "suli", - "szex", - "tm", - "tozsde", - "utazas", - "video", - "ac", - "biz", - "co", - "desa", - "go", - "mil", - "my", - "net", - "or", - "sch", - "web", - "blogspot", - "blogspot", - "gov", - "ac", - "co", - "gov", - "idf", - "k12", - "muni", - "net", - "org", - "blogspot", - "ac", - "co", - "com", - "net", - "org", - "tt", - "tv", - "ltd", - "plc", - "ac", - "blogspot", - "co", - "edu", - "firm", - "gen", - "gov", - "ind", - "mil", - "net", - "nic", - "org", - "res", - "barrel-of-knowledge", - "barrell-of-knowledge", - "dvrcam", - "dyndns", - "for-our", - "groks-the", - "groks-this", - "here-for-more", - "ilovecollege", - "knowsitall", - "no-ip", - "nsupdate", - "selfip", - "webhop", - "eu", - "com", - "dedyn", - "github", - "hzc", - "ngrok", - "nid", - "pantheonsite", - "sandcats", - "spacekit", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "ac", - "co", - "gov", - "id", - "net", - "org", - "sch", - "xn--mgba3a4f16a", - "xn--mgba3a4fra", - "blogspot", - "com", - "cupcake", - "edu", - "gov", - "int", - "net", - "org", - "abr", - "abruzzo", - "ag", - "agrigento", - "al", - "alessandria", - "alto-adige", - "altoadige", - "an", - "ancona", - "andria-barletta-trani", - "andria-trani-barletta", - "andriabarlettatrani", - "andriatranibarletta", - "ao", - "aosta", - "aosta-valley", - "aostavalley", - "aoste", - "ap", - "aq", - "aquila", - "ar", - "arezzo", - "ascoli-piceno", - "ascolipiceno", - "asti", - "at", - "av", - "avellino", - "ba", - "balsan", - "bari", - "barletta-trani-andria", - "barlettatraniandria", - "bas", - "basilicata", - "belluno", - "benevento", - "bergamo", - "bg", - "bi", - "biella", - "bl", - "blogspot", - "bn", - "bo", - "bologna", - "bolzano", - "bozen", - "br", - "brescia", - "brindisi", - "bs", - "bt", - "bz", - "ca", - "cagliari", - "cal", - "calabria", - "caltanissetta", - "cam", - "campania", - "campidano-medio", - "campidanomedio", - "campobasso", - "carbonia-iglesias", - "carboniaiglesias", - "carrara-massa", - "carraramassa", - "caserta", - "catania", - "catanzaro", - "cb", - "ce", - "cesena-forli", - "cesenaforli", - "ch", - "chieti", - "ci", - "cl", - "cn", - "co", - "como", - "cosenza", - "cr", - "cremona", - "crotone", - "cs", - "ct", - "cuneo", - "cz", - "dell-ogliastra", - "dellogliastra", - "edu", - "emilia-romagna", - "emiliaromagna", - "emr", - "en", - "enna", - "fc", - "fe", - "fermo", - "ferrara", - "fg", - "fi", - "firenze", - "florence", - "fm", - "foggia", - "forli-cesena", - "forlicesena", - "fr", - "friuli-v-giulia", - "friuli-ve-giulia", - "friuli-vegiulia", - "friuli-venezia-giulia", - "friuli-veneziagiulia", - "friuli-vgiulia", - "friuliv-giulia", - "friulive-giulia", - "friulivegiulia", - "friulivenezia-giulia", - "friuliveneziagiulia", - "friulivgiulia", - "frosinone", - "fvg", - "ge", - "genoa", - "genova", - "go", - "gorizia", - "gov", - "gr", - "grosseto", - "iglesias-carbonia", - "iglesiascarbonia", - "im", - "imperia", - "is", - "isernia", - "kr", - "la-spezia", - "laquila", - "laspezia", - "latina", - "laz", - "lazio", - "lc", - "le", - "lecce", - "lecco", - "li", - "lig", - "liguria", - "livorno", - "lo", - "lodi", - "lom", - "lombardia", - "lombardy", - "lt", - "lu", - "lucania", - "lucca", - "macerata", - "mantova", - "mar", - "marche", - "massa-carrara", - "massacarrara", - "matera", - "mb", - "mc", - "me", - "medio-campidano", - "mediocampidano", - "messina", - "mi", - "milan", - "milano", - "mn", - "mo", - "modena", - "mol", - "molise", - "monza", - "monza-brianza", - "monza-e-della-brianza", - "monzabrianza", - "monzaebrianza", - "monzaedellabrianza", - "ms", - "mt", - "na", - "naples", - "napoli", - "no", - "novara", - "nu", - "nuoro", - "og", - "ogliastra", - "olbia-tempio", - "olbiatempio", - "or", - "oristano", - "ot", - "pa", - "padova", - "padua", - "palermo", - "parma", - "pavia", - "pc", - "pd", - "pe", - "perugia", - "pesaro-urbino", - "pesarourbino", - "pescara", - "pg", - "pi", - "piacenza", - "piedmont", - "piemonte", - "pisa", - "pistoia", - "pmn", - "pn", - "po", - "pordenone", - "potenza", - "pr", - "prato", - "pt", - "pu", - "pug", - "puglia", - "pv", - "pz", - "ra", - "ragusa", - "ravenna", - "rc", - "re", - "reggio-calabria", - "reggio-emilia", - "reggiocalabria", - "reggioemilia", - "rg", - "ri", - "rieti", - "rimini", - "rm", - "rn", - "ro", - "roma", - "rome", - "rovigo", - "sa", - "salerno", - "sar", - "sardegna", - "sardinia", - "sassari", - "savona", - "si", - "sic", - "sicilia", - "sicily", - "siena", - "siracusa", - "so", - "sondrio", - "sp", - "sr", - "ss", - "suedtirol", - "sv", - "ta", - "taa", - "taranto", - "te", - "tempio-olbia", - "tempioolbia", - "teramo", - "terni", - "tn", - "to", - "torino", - "tos", - "toscana", - "tp", - "tr", - "trani-andria-barletta", - "trani-barletta-andria", - "traniandriabarletta", - "tranibarlettaandria", - "trapani", - "trentino", - "trentino-a-adige", - "trentino-aadige", - "trentino-alto-adige", - "trentino-altoadige", - "trentino-s-tirol", - "trentino-stirol", - "trentino-sud-tirol", - "trentino-sudtirol", - "trentino-sued-tirol", - "trentino-suedtirol", - "trentinoa-adige", - "trentinoaadige", - "trentinoalto-adige", - "trentinoaltoadige", - "trentinos-tirol", - "trentinostirol", - "trentinosud-tirol", - "trentinosudtirol", - "trentinosued-tirol", - "trentinosuedtirol", - "trento", - "treviso", - "trieste", - "ts", - "turin", - "tuscany", - "tv", - "ud", - "udine", - "umb", - "umbria", - "urbino-pesaro", - "urbinopesaro", - "va", - "val-d-aosta", - "val-daosta", - "vald-aosta", - "valdaosta", - "valle-aosta", - "valle-d-aosta", - "valle-daosta", - "valleaosta", - "valled-aosta", - "valledaosta", - "vallee-aoste", - "valleeaoste", - "vao", - "varese", - "vb", - "vc", - "vda", - "ve", - "ven", - "veneto", - "venezia", - "venice", - "verbania", - "vercelli", - "verona", - "vi", - "vibo-valentia", - "vibovalentia", - "vicenza", - "viterbo", - "vr", - "vs", - "vt", - "vv", - "co", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "name", - "net", - "org", - "sch", - "ac", - "ad", - "aichi", - "akita", - "aomori", - "blogspot", - "chiba", - "co", - "ed", - "ehime", - "fukui", - "fukuoka", - "fukushima", - "gifu", - "go", - "gr", - "gunma", - "hiroshima", - "hokkaido", - "hyogo", - "ibaraki", - "ishikawa", - "iwate", - "kagawa", - "kagoshima", - "kanagawa", - "kawasaki", - "kitakyushu", - "kobe", - "kochi", - "kumamoto", - "kyoto", - "lg", - "mie", - "miyagi", - "miyazaki", - "nagano", - "nagasaki", - "nagoya", - "nara", - "ne", - "niigata", - "oita", - "okayama", - "okinawa", - "or", - "osaka", - "saga", - "saitama", - "sapporo", - "sendai", - "shiga", - "shimane", - "shizuoka", - "tochigi", - "tokushima", - "tokyo", - "tottori", - "toyama", - "wakayama", - "xn--0trq7p7nn", - "xn--1ctwo", - "xn--1lqs03n", - "xn--1lqs71d", - "xn--2m4a15e", - "xn--32vp30h", - "xn--4it168d", - "xn--4it797k", - "xn--4pvxs", - "xn--5js045d", - "xn--5rtp49c", - "xn--5rtq34k", - "xn--6btw5a", - "xn--6orx2r", - "xn--7t0a264c", - "xn--8ltr62k", - "xn--8pvr4u", - "xn--c3s14m", - "xn--d5qv7z876c", - "xn--djrs72d6uy", - "xn--djty4k", - "xn--efvn9s", - "xn--ehqz56n", - "xn--elqq16h", - "xn--f6qx53a", - "xn--k7yn95e", - "xn--kbrq7o", - "xn--klt787d", - "xn--kltp7d", - "xn--kltx9a", - "xn--klty5x", - "xn--mkru45i", - "xn--nit225k", - "xn--ntso0iqx3a", - "xn--ntsq17g", - "xn--pssu33l", - "xn--qqqt11m", - "xn--rht27z", - "xn--rht3d", - "xn--rht61e", - "xn--rny31h", - "xn--tor131o", - "xn--uist22h", - "xn--uisz3g", - "xn--uuwu58a", - "xn--vgu402c", - "xn--zbx025d", - "yamagata", - "yamaguchi", - "yamanashi", - "yokohama", - "aisai", - "ama", - "anjo", - "asuke", - "chiryu", - "chita", - "fuso", - "gamagori", - "handa", - "hazu", - "hekinan", - "higashiura", - "ichinomiya", - "inazawa", - "inuyama", - "isshiki", - "iwakura", - "kanie", - "kariya", - "kasugai", - "kira", - "kiyosu", - "komaki", - "konan", - "kota", - "mihama", - "miyoshi", - "nishio", - "nisshin", - "obu", - "oguchi", - "oharu", - "okazaki", - "owariasahi", - "seto", - "shikatsu", - "shinshiro", - "shitara", - "tahara", - "takahama", - "tobishima", - "toei", - "togo", - "tokai", - "tokoname", - "toyoake", - "toyohashi", - "toyokawa", - "toyone", - "toyota", - "tsushima", - "yatomi", - "akita", - "daisen", - "fujisato", - "gojome", - "hachirogata", - "happou", - "higashinaruse", - "honjo", - "honjyo", - "ikawa", - "kamikoani", - "kamioka", - "katagami", - "kazuno", - "kitaakita", - "kosaka", - "kyowa", - "misato", - "mitane", - "moriyoshi", - "nikaho", - "noshiro", - "odate", - "oga", - "ogata", - "semboku", - "yokote", - "yurihonjo", - "aomori", - "gonohe", - "hachinohe", - "hashikami", - "hiranai", - "hirosaki", - "itayanagi", - "kuroishi", - "misawa", - "mutsu", - "nakadomari", - "noheji", - "oirase", - "owani", - "rokunohe", - "sannohe", - "shichinohe", - "shingo", - "takko", - "towada", - "tsugaru", - "tsuruta", - "abiko", - "asahi", - "chonan", - "chosei", - "choshi", - "chuo", - "funabashi", - "futtsu", - "hanamigawa", - "ichihara", - "ichikawa", - "ichinomiya", - "inzai", - "isumi", - "kamagaya", - "kamogawa", - "kashiwa", - "katori", - "katsuura", - "kimitsu", - "kisarazu", - "kozaki", - "kujukuri", - "kyonan", - "matsudo", - "midori", - "mihama", - "minamiboso", - "mobara", - "mutsuzawa", - "nagara", - "nagareyama", - "narashino", - "narita", - "noda", - "oamishirasato", - "omigawa", - "onjuku", - "otaki", - "sakae", - "sakura", - "shimofusa", - "shirako", - "shiroi", - "shisui", - "sodegaura", - "sosa", - "tako", - "tateyama", - "togane", - "tohnosho", - "tomisato", - "urayasu", - "yachimata", - "yachiyo", - "yokaichiba", - "yokoshibahikari", - "yotsukaido", - "ainan", - "honai", - "ikata", - "imabari", - "iyo", - "kamijima", - "kihoku", - "kumakogen", - "masaki", - "matsuno", - "matsuyama", - "namikata", - "niihama", - "ozu", - "saijo", - "seiyo", - "shikokuchuo", - "tobe", - "toon", - "uchiko", - "uwajima", - "yawatahama", - "echizen", - "eiheiji", - "fukui", - "ikeda", - "katsuyama", - "mihama", - "minamiechizen", - "obama", - "ohi", - "ono", - "sabae", - "sakai", - "takahama", - "tsuruga", - "wakasa", - "ashiya", - "buzen", - "chikugo", - "chikuho", - "chikujo", - "chikushino", - "chikuzen", - "chuo", - "dazaifu", - "fukuchi", - "hakata", - "higashi", - "hirokawa", - "hisayama", - "iizuka", - "inatsuki", - "kaho", - "kasuga", - "kasuya", - "kawara", - "keisen", - "koga", - "kurate", - "kurogi", - "kurume", - "minami", - "miyako", - "miyama", - "miyawaka", - "mizumaki", - "munakata", - "nakagawa", - "nakama", - "nishi", - "nogata", - "ogori", - "okagaki", - "okawa", - "oki", - "omuta", - "onga", - "onojo", - "oto", - "saigawa", - "sasaguri", - "shingu", - "shinyoshitomi", - "shonai", - "soeda", - "sue", - "tachiarai", - "tagawa", - "takata", - "toho", - "toyotsu", - "tsuiki", - "ukiha", - "umi", - "usui", - "yamada", - "yame", - "yanagawa", - "yukuhashi", - "aizubange", - "aizumisato", - "aizuwakamatsu", - "asakawa", - "bandai", - "date", - "fukushima", - "furudono", - "futaba", - "hanawa", - "higashi", - "hirata", - "hirono", - "iitate", - "inawashiro", - "ishikawa", - "iwaki", - "izumizaki", - "kagamiishi", - "kaneyama", - "kawamata", - "kitakata", - "kitashiobara", - "koori", - "koriyama", - "kunimi", - "miharu", - "mishima", - "namie", - "nango", - "nishiaizu", - "nishigo", - "okuma", - "omotego", - "ono", - "otama", - "samegawa", - "shimogo", - "shirakawa", - "showa", - "soma", - "sukagawa", - "taishin", - "tamakawa", - "tanagura", - "tenei", - "yabuki", - "yamato", - "yamatsuri", - "yanaizu", - "yugawa", - "anpachi", - "ena", - "gifu", - "ginan", - "godo", - "gujo", - "hashima", - "hichiso", - "hida", - "higashishirakawa", - "ibigawa", - "ikeda", - "kakamigahara", - "kani", - "kasahara", - "kasamatsu", - "kawaue", - "kitagata", - "mino", - "minokamo", - "mitake", - "mizunami", - "motosu", - "nakatsugawa", - "ogaki", - "sakahogi", - "seki", - "sekigahara", - "shirakawa", - "tajimi", - "takayama", - "tarui", - "toki", - "tomika", - "wanouchi", - "yamagata", - "yaotsu", - "yoro", - "annaka", - "chiyoda", - "fujioka", - "higashiagatsuma", - "isesaki", - "itakura", - "kanna", - "kanra", - "katashina", - "kawaba", - "kiryu", - "kusatsu", - "maebashi", - "meiwa", - "midori", - "minakami", - "naganohara", - "nakanojo", - "nanmoku", - "numata", - "oizumi", - "ora", - "ota", - "shibukawa", - "shimonita", - "shinto", - "showa", - "takasaki", - "takayama", - "tamamura", - "tatebayashi", - "tomioka", - "tsukiyono", - "tsumagoi", - "ueno", - "yoshioka", - "asaminami", - "daiwa", - "etajima", - "fuchu", - "fukuyama", - "hatsukaichi", - "higashihiroshima", - "hongo", - "jinsekikogen", - "kaita", - "kui", - "kumano", - "kure", - "mihara", - "miyoshi", - "naka", - "onomichi", - "osakikamijima", - "otake", - "saka", - "sera", - "seranishi", - "shinichi", - "shobara", - "takehara", - "abashiri", - "abira", - "aibetsu", - "akabira", - "akkeshi", - "asahikawa", - "ashibetsu", - "ashoro", - "assabu", - "atsuma", - "bibai", - "biei", - "bifuka", - "bihoro", - "biratori", - "chippubetsu", - "chitose", - "date", - "ebetsu", - "embetsu", - "eniwa", - "erimo", - "esan", - "esashi", - "fukagawa", - "fukushima", - "furano", - "furubira", - "haboro", - "hakodate", - "hamatonbetsu", - "hidaka", - "higashikagura", - "higashikawa", - "hiroo", - "hokuryu", - "hokuto", - "honbetsu", - "horokanai", - "horonobe", - "ikeda", - "imakane", - "ishikari", - "iwamizawa", - "iwanai", - "kamifurano", - "kamikawa", - "kamishihoro", - "kamisunagawa", - "kamoenai", - "kayabe", - "kembuchi", - "kikonai", - "kimobetsu", - "kitahiroshima", - "kitami", - "kiyosato", - "koshimizu", - "kunneppu", - "kuriyama", - "kuromatsunai", - "kushiro", - "kutchan", - "kyowa", - "mashike", - "matsumae", - "mikasa", - "minamifurano", - "mombetsu", - "moseushi", - "mukawa", - "muroran", - "naie", - "nakagawa", - "nakasatsunai", - "nakatombetsu", - "nanae", - "nanporo", - "nayoro", - "nemuro", - "niikappu", - "niki", - "nishiokoppe", - "noboribetsu", - "numata", - "obihiro", - "obira", - "oketo", - "okoppe", - "otaru", - "otobe", - "otofuke", - "otoineppu", - "oumu", - "ozora", - "pippu", - "rankoshi", - "rebun", - "rikubetsu", - "rishiri", - "rishirifuji", - "saroma", - "sarufutsu", - "shakotan", - "shari", - "shibecha", - "shibetsu", - "shikabe", - "shikaoi", - "shimamaki", - "shimizu", - "shimokawa", - "shinshinotsu", - "shintoku", - "shiranuka", - "shiraoi", - "shiriuchi", - "sobetsu", - "sunagawa", - "taiki", - "takasu", - "takikawa", - "takinoue", - "teshikaga", - "tobetsu", - "tohma", - "tomakomai", - "tomari", - "toya", - "toyako", - "toyotomi", - "toyoura", - "tsubetsu", - "tsukigata", - "urakawa", - "urausu", - "uryu", - "utashinai", - "wakkanai", - "wassamu", - "yakumo", - "yoichi", - "aioi", - "akashi", - "ako", - "amagasaki", - "aogaki", - "asago", - "ashiya", - "awaji", - "fukusaki", - "goshiki", - "harima", - "himeji", - "ichikawa", - "inagawa", - "itami", - "kakogawa", - "kamigori", - "kamikawa", - "kasai", - "kasuga", - "kawanishi", - "miki", - "minamiawaji", - "nishinomiya", - "nishiwaki", - "ono", - "sanda", - "sannan", - "sasayama", - "sayo", - "shingu", - "shinonsen", - "shiso", - "sumoto", - "taishi", - "taka", - "takarazuka", - "takasago", - "takino", - "tamba", - "tatsuno", - "toyooka", - "yabu", - "yashiro", - "yoka", - "yokawa", - "ami", - "asahi", - "bando", - "chikusei", - "daigo", - "fujishiro", - "hitachi", - "hitachinaka", - "hitachiomiya", - "hitachiota", - "ibaraki", - "ina", - "inashiki", - "itako", - "iwama", - "joso", - "kamisu", - "kasama", - "kashima", - "kasumigaura", - "koga", - "miho", - "mito", - "moriya", - "naka", - "namegata", - "oarai", - "ogawa", - "omitama", - "ryugasaki", - "sakai", - "sakuragawa", - "shimodate", - "shimotsuma", - "shirosato", - "sowa", - "suifu", - "takahagi", - "tamatsukuri", - "tokai", - "tomobe", - "tone", - "toride", - "tsuchiura", - "tsukuba", - "uchihara", - "ushiku", - "yachiyo", - "yamagata", - "yawara", - "yuki", - "anamizu", - "hakui", - "hakusan", - "kaga", - "kahoku", - "kanazawa", - "kawakita", - "komatsu", - "nakanoto", - "nanao", - "nomi", - "nonoichi", - "noto", - "shika", - "suzu", - "tsubata", - "tsurugi", - "uchinada", - "wajima", - "fudai", - "fujisawa", - "hanamaki", - "hiraizumi", - "hirono", - "ichinohe", - "ichinoseki", - "iwaizumi", - "iwate", - "joboji", - "kamaishi", - "kanegasaki", - "karumai", - "kawai", - "kitakami", - "kuji", - "kunohe", - "kuzumaki", - "miyako", - "mizusawa", - "morioka", - "ninohe", - "noda", - "ofunato", - "oshu", - "otsuchi", - "rikuzentakata", - "shiwa", - "shizukuishi", - "sumita", - "tanohata", - "tono", - "yahaba", - "yamada", - "ayagawa", - "higashikagawa", - "kanonji", - "kotohira", - "manno", - "marugame", - "mitoyo", - "naoshima", - "sanuki", - "tadotsu", - "takamatsu", - "tonosho", - "uchinomi", - "utazu", - "zentsuji", - "akune", - "amami", - "hioki", - "isa", - "isen", - "izumi", - "kagoshima", - "kanoya", - "kawanabe", - "kinko", - "kouyama", - "makurazaki", - "matsumoto", - "minamitane", - "nakatane", - "nishinoomote", - "satsumasendai", - "soo", - "tarumizu", - "yusui", - "aikawa", - "atsugi", - "ayase", - "chigasaki", - "ebina", - "fujisawa", - "hadano", - "hakone", - "hiratsuka", - "isehara", - "kaisei", - "kamakura", - "kiyokawa", - "matsuda", - "minamiashigara", - "miura", - "nakai", - "ninomiya", - "odawara", - "oi", - "oiso", - "sagamihara", - "samukawa", - "tsukui", - "yamakita", - "yamato", - "yokosuka", - "yugawara", - "zama", - "zushi", - "city", - "city", - "city", - "aki", - "geisei", - "hidaka", - "higashitsuno", - "ino", - "kagami", - "kami", - "kitagawa", - "kochi", - "mihara", - "motoyama", - "muroto", - "nahari", - "nakamura", - "nankoku", - "nishitosa", - "niyodogawa", - "ochi", - "okawa", - "otoyo", - "otsuki", - "sakawa", - "sukumo", - "susaki", - "tosa", - "tosashimizu", - "toyo", - "tsuno", - "umaji", - "yasuda", - "yusuhara", - "amakusa", - "arao", - "aso", - "choyo", - "gyokuto", - "hitoyoshi", - "kamiamakusa", - "kashima", - "kikuchi", - "kosa", - "kumamoto", - "mashiki", - "mifune", - "minamata", - "minamioguni", - "nagasu", - "nishihara", - "oguni", - "ozu", - "sumoto", - "takamori", - "uki", - "uto", - "yamaga", - "yamato", - "yatsushiro", - "ayabe", - "fukuchiyama", - "higashiyama", - "ide", - "ine", - "joyo", - "kameoka", - "kamo", - "kita", - "kizu", - "kumiyama", - "kyotamba", - "kyotanabe", - "kyotango", - "maizuru", - "minami", - "minamiyamashiro", - "miyazu", - "muko", - "nagaokakyo", - "nakagyo", - "nantan", - "oyamazaki", - "sakyo", - "seika", - "tanabe", - "uji", - "ujitawara", - "wazuka", - "yamashina", - "yawata", - "asahi", - "inabe", - "ise", - "kameyama", - "kawagoe", - "kiho", - "kisosaki", - "kiwa", - "komono", - "kumano", - "kuwana", - "matsusaka", - "meiwa", - "mihama", - "minamiise", - "misugi", - "miyama", - "nabari", - "shima", - "suzuka", - "tado", - "taiki", - "taki", - "tamaki", - "toba", - "tsu", - "udono", - "ureshino", - "watarai", - "yokkaichi", - "furukawa", - "higashimatsushima", - "ishinomaki", - "iwanuma", - "kakuda", - "kami", - "kawasaki", - "marumori", - "matsushima", - "minamisanriku", - "misato", - "murata", - "natori", - "ogawara", - "ohira", - "onagawa", - "osaki", - "rifu", - "semine", - "shibata", - "shichikashuku", - "shikama", - "shiogama", - "shiroishi", - "tagajo", - "taiwa", - "tome", - "tomiya", - "wakuya", - "watari", - "yamamoto", - "zao", - "aya", - "ebino", - "gokase", - "hyuga", - "kadogawa", - "kawaminami", - "kijo", - "kitagawa", - "kitakata", - "kitaura", - "kobayashi", - "kunitomi", - "kushima", - "mimata", - "miyakonojo", - "miyazaki", - "morotsuka", - "nichinan", - "nishimera", - "nobeoka", - "saito", - "shiiba", - "shintomi", - "takaharu", - "takanabe", - "takazaki", - "tsuno", - "achi", - "agematsu", - "anan", - "aoki", - "asahi", - "azumino", - "chikuhoku", - "chikuma", - "chino", - "fujimi", - "hakuba", - "hara", - "hiraya", - "iida", - "iijima", - "iiyama", - "iizuna", - "ikeda", - "ikusaka", - "ina", - "karuizawa", - "kawakami", - "kiso", - "kisofukushima", - "kitaaiki", - "komagane", - "komoro", - "matsukawa", - "matsumoto", - "miasa", - "minamiaiki", - "minamimaki", - "minamiminowa", - "minowa", - "miyada", - "miyota", - "mochizuki", - "nagano", - "nagawa", - "nagiso", - "nakagawa", - "nakano", - "nozawaonsen", - "obuse", - "ogawa", - "okaya", - "omachi", - "omi", - "ookuwa", - "ooshika", - "otaki", - "otari", - "sakae", - "sakaki", - "saku", - "sakuho", - "shimosuwa", - "shinanomachi", - "shiojiri", - "suwa", - "suzaka", - "takagi", - "takamori", - "takayama", - "tateshina", - "tatsuno", - "togakushi", - "togura", - "tomi", - "ueda", - "wada", - "yamagata", - "yamanouchi", - "yasaka", - "yasuoka", - "chijiwa", - "futsu", - "goto", - "hasami", - "hirado", - "iki", - "isahaya", - "kawatana", - "kuchinotsu", - "matsuura", - "nagasaki", - "obama", - "omura", - "oseto", - "saikai", - "sasebo", - "seihi", - "shimabara", - "shinkamigoto", - "togitsu", - "tsushima", - "unzen", - "city", - "ando", - "gose", - "heguri", - "higashiyoshino", - "ikaruga", - "ikoma", - "kamikitayama", - "kanmaki", - "kashiba", - "kashihara", - "katsuragi", - "kawai", - "kawakami", - "kawanishi", - "koryo", - "kurotaki", - "mitsue", - "miyake", - "nara", - "nosegawa", - "oji", - "ouda", - "oyodo", - "sakurai", - "sango", - "shimoichi", - "shimokitayama", - "shinjo", - "soni", - "takatori", - "tawaramoto", - "tenkawa", - "tenri", - "uda", - "yamatokoriyama", - "yamatotakada", - "yamazoe", - "yoshino", - "aga", - "agano", - "gosen", - "itoigawa", - "izumozaki", - "joetsu", - "kamo", - "kariwa", - "kashiwazaki", - "minamiuonuma", - "mitsuke", - "muika", - "murakami", - "myoko", - "nagaoka", - "niigata", - "ojiya", - "omi", - "sado", - "sanjo", - "seiro", - "seirou", - "sekikawa", - "shibata", - "tagami", - "tainai", - "tochio", - "tokamachi", - "tsubame", - "tsunan", - "uonuma", - "yahiko", - "yoita", - "yuzawa", - "beppu", - "bungoono", - "bungotakada", - "hasama", - "hiji", - "himeshima", - "hita", - "kamitsue", - "kokonoe", - "kuju", - "kunisaki", - "kusu", - "oita", - "saiki", - "taketa", - "tsukumi", - "usa", - "usuki", - "yufu", - "akaiwa", - "asakuchi", - "bizen", - "hayashima", - "ibara", - "kagamino", - "kasaoka", - "kibichuo", - "kumenan", - "kurashiki", - "maniwa", - "misaki", - "nagi", - "niimi", - "nishiawakura", - "okayama", - "satosho", - "setouchi", - "shinjo", - "shoo", - "soja", - "takahashi", - "tamano", - "tsuyama", - "wake", - "yakage", - "aguni", - "ginowan", - "ginoza", - "gushikami", - "haebaru", - "higashi", - "hirara", - "iheya", - "ishigaki", - "ishikawa", - "itoman", - "izena", - "kadena", - "kin", - "kitadaito", - "kitanakagusuku", - "kumejima", - "kunigami", - "minamidaito", - "motobu", - "nago", - "naha", - "nakagusuku", - "nakijin", - "nanjo", - "nishihara", - "ogimi", - "okinawa", - "onna", - "shimoji", - "taketomi", - "tarama", - "tokashiki", - "tomigusuku", - "tonaki", - "urasoe", - "uruma", - "yaese", - "yomitan", - "yonabaru", - "yonaguni", - "zamami", - "abeno", - "chihayaakasaka", - "chuo", - "daito", - "fujiidera", - "habikino", - "hannan", - "higashiosaka", - "higashisumiyoshi", - "higashiyodogawa", - "hirakata", - "ibaraki", - "ikeda", - "izumi", - "izumiotsu", - "izumisano", - "kadoma", - "kaizuka", - "kanan", - "kashiwara", - "katano", - "kawachinagano", - "kishiwada", - "kita", - "kumatori", - "matsubara", - "minato", - "minoh", - "misaki", - "moriguchi", - "neyagawa", - "nishi", - "nose", - "osakasayama", - "sakai", - "sayama", - "sennan", - "settsu", - "shijonawate", - "shimamoto", - "suita", - "tadaoka", - "taishi", - "tajiri", - "takaishi", - "takatsuki", - "tondabayashi", - "toyonaka", - "toyono", - "yao", - "ariake", - "arita", - "fukudomi", - "genkai", - "hamatama", - "hizen", - "imari", - "kamimine", - "kanzaki", - "karatsu", - "kashima", - "kitagata", - "kitahata", - "kiyama", - "kouhoku", - "kyuragi", - "nishiarita", - "ogi", - "omachi", - "ouchi", - "saga", - "shiroishi", - "taku", - "tara", - "tosu", - "yoshinogari", - "arakawa", - "asaka", - "chichibu", - "fujimi", - "fujimino", - "fukaya", - "hanno", - "hanyu", - "hasuda", - "hatogaya", - "hatoyama", - "hidaka", - "higashichichibu", - "higashimatsuyama", - "honjo", - "ina", - "iruma", - "iwatsuki", - "kamiizumi", - "kamikawa", - "kamisato", - "kasukabe", - "kawagoe", - "kawaguchi", - "kawajima", - "kazo", - "kitamoto", - "koshigaya", - "kounosu", - "kuki", - "kumagaya", - "matsubushi", - "minano", - "misato", - "miyashiro", - "miyoshi", - "moroyama", - "nagatoro", - "namegawa", - "niiza", - "ogano", - "ogawa", - "ogose", - "okegawa", - "omiya", - "otaki", - "ranzan", - "ryokami", - "saitama", - "sakado", - "satte", - "sayama", - "shiki", - "shiraoka", - "soka", - "sugito", - "toda", - "tokigawa", - "tokorozawa", - "tsurugashima", - "urawa", - "warabi", - "yashio", - "yokoze", - "yono", - "yorii", - "yoshida", - "yoshikawa", - "yoshimi", - "city", - "city", - "aisho", - "gamo", - "higashiomi", - "hikone", - "koka", - "konan", - "kosei", - "koto", - "kusatsu", - "maibara", - "moriyama", - "nagahama", - "nishiazai", - "notogawa", - "omihachiman", - "otsu", - "ritto", - "ryuoh", - "takashima", - "takatsuki", - "torahime", - "toyosato", - "yasu", - "akagi", - "ama", - "gotsu", - "hamada", - "higashiizumo", - "hikawa", - "hikimi", - "izumo", - "kakinoki", - "masuda", - "matsue", - "misato", - "nishinoshima", - "ohda", - "okinoshima", - "okuizumo", - "shimane", - "tamayu", - "tsuwano", - "unnan", - "yakumo", - "yasugi", - "yatsuka", - "arai", - "atami", - "fuji", - "fujieda", - "fujikawa", - "fujinomiya", - "fukuroi", - "gotemba", - "haibara", - "hamamatsu", - "higashiizu", - "ito", - "iwata", - "izu", - "izunokuni", - "kakegawa", - "kannami", - "kawanehon", - "kawazu", - "kikugawa", - "kosai", - "makinohara", - "matsuzaki", - "minamiizu", - "mishima", - "morimachi", - "nishiizu", - "numazu", - "omaezaki", - "shimada", - "shimizu", - "shimoda", - "shizuoka", - "susono", - "yaizu", - "yoshida", - "ashikaga", - "bato", - "haga", - "ichikai", - "iwafune", - "kaminokawa", - "kanuma", - "karasuyama", - "kuroiso", - "mashiko", - "mibu", - "moka", - "motegi", - "nasu", - "nasushiobara", - "nikko", - "nishikata", - "nogi", - "ohira", - "ohtawara", - "oyama", - "sakura", - "sano", - "shimotsuke", - "shioya", - "takanezawa", - "tochigi", - "tsuga", - "ujiie", - "utsunomiya", - "yaita", - "aizumi", - "anan", - "ichiba", - "itano", - "kainan", - "komatsushima", - "matsushige", - "mima", - "minami", - "miyoshi", - "mugi", - "nakagawa", - "naruto", - "sanagochi", - "shishikui", - "tokushima", - "wajiki", - "adachi", - "akiruno", - "akishima", - "aogashima", - "arakawa", - "bunkyo", - "chiyoda", - "chofu", - "chuo", - "edogawa", - "fuchu", - "fussa", - "hachijo", - "hachioji", - "hamura", - "higashikurume", - "higashimurayama", - "higashiyamato", - "hino", - "hinode", - "hinohara", - "inagi", - "itabashi", - "katsushika", - "kita", - "kiyose", - "kodaira", - "koganei", - "kokubunji", - "komae", - "koto", - "kouzushima", - "kunitachi", - "machida", - "meguro", - "minato", - "mitaka", - "mizuho", - "musashimurayama", - "musashino", - "nakano", - "nerima", - "ogasawara", - "okutama", - "ome", - "oshima", - "ota", - "setagaya", - "shibuya", - "shinagawa", - "shinjuku", - "suginami", - "sumida", - "tachikawa", - "taito", - "tama", - "toshima", - "chizu", - "hino", - "kawahara", - "koge", - "kotoura", - "misasa", - "nanbu", - "nichinan", - "sakaiminato", - "tottori", - "wakasa", - "yazu", - "yonago", - "asahi", - "fuchu", - "fukumitsu", - "funahashi", - "himi", - "imizu", - "inami", - "johana", - "kamiichi", - "kurobe", - "nakaniikawa", - "namerikawa", - "nanto", - "nyuzen", - "oyabe", - "taira", - "takaoka", - "tateyama", - "toga", - "tonami", - "toyama", - "unazuki", - "uozu", - "yamada", - "arida", - "aridagawa", - "gobo", - "hashimoto", - "hidaka", - "hirogawa", - "inami", - "iwade", - "kainan", - "kamitonda", - "katsuragi", - "kimino", - "kinokawa", - "kitayama", - "koya", - "koza", - "kozagawa", - "kudoyama", - "kushimoto", - "mihama", - "misato", - "nachikatsuura", - "shingu", - "shirahama", - "taiji", - "tanabe", - "wakayama", - "yuasa", - "yura", - "asahi", - "funagata", - "higashine", - "iide", - "kahoku", - "kaminoyama", - "kaneyama", - "kawanishi", - "mamurogawa", - "mikawa", - "murayama", - "nagai", - "nakayama", - "nanyo", - "nishikawa", - "obanazawa", - "oe", - "oguni", - "ohkura", - "oishida", - "sagae", - "sakata", - "sakegawa", - "shinjo", - "shirataka", - "shonai", - "takahata", - "tendo", - "tozawa", - "tsuruoka", - "yamagata", - "yamanobe", - "yonezawa", - "yuza", - "abu", - "hagi", - "hikari", - "hofu", - "iwakuni", - "kudamatsu", - "mitou", - "nagato", - "oshima", - "shimonoseki", - "shunan", - "tabuse", - "tokuyama", - "toyota", - "ube", - "yuu", - "chuo", - "doshi", - "fuefuki", - "fujikawa", - "fujikawaguchiko", - "fujiyoshida", - "hayakawa", - "hokuto", - "ichikawamisato", - "kai", - "kofu", - "koshu", - "kosuge", - "minami-alps", - "minobu", - "nakamichi", - "nanbu", - "narusawa", - "nirasaki", - "nishikatsura", - "oshino", - "otsuki", - "showa", - "tabayama", - "tsuru", - "uenohara", - "yamanakako", - "yamanashi", - "city", - "co", - "blogspot", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "biz", - "com", - "edu", - "gov", - "info", - "net", - "org", - "ass", - "asso", - "com", - "coop", - "edu", - "gouv", - "gov", - "medecin", - "mil", - "nom", - "notaires", - "org", - "pharmaciens", - "prd", - "presse", - "tm", - "veterinaire", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "org", - "rep", - "tra", - "ac", - "blogspot", - "busan", - "chungbuk", - "chungnam", - "co", - "daegu", - "daejeon", - "es", - "gangwon", - "go", - "gwangju", - "gyeongbuk", - "gyeonggi", - "gyeongnam", - "hs", - "incheon", - "jeju", - "jeonbuk", - "jeonnam", - "kg", - "mil", - "ms", - "ne", - "or", - "pe", - "re", - "sc", - "seoul", - "ulsan", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "c", - "com", - "edu", - "gov", - "info", - "int", - "net", - "org", - "per", - "com", - "edu", - "gov", - "net", - "org", - "co", - "com", - "edu", - "gov", - "net", - "org", - "oy", - "blogspot", - "cyon", - "mypep", - "ac", - "assn", - "com", - "edu", - "gov", - "grp", - "hotel", - "int", - "ltd", - "net", - "ngo", - "org", - "sch", - "soc", - "web", - "com", - "edu", - "gov", - "net", - "org", - "co", - "org", - "blogspot", - "gov", - "blogspot", - "asn", - "com", - "conf", - "edu", - "gov", - "id", - "mil", - "net", - "org", - "com", - "edu", - "gov", - "id", - "med", - "net", - "org", - "plc", - "sch", - "ac", - "co", - "gov", - "net", - "org", - "press", - "router", - "asso", - "tm", - "blogspot", - "ac", - "brasilia", - "co", - "daplie", - "ddns", - "diskstation", - "dnsfor", - "dscloud", - "edu", - "gov", - "hopto", - "i234", - "its", - "loginto", - "myds", - "net", - "noip", - "org", - "priv", - "synology", - "webhop", - "co", - "com", - "edu", - "gov", - "mil", - "nom", - "org", - "prd", - "tm", - "blogspot", - "com", - "edu", - "gov", - "inf", - "name", - "net", - "org", - "com", - "edu", - "gouv", - "gov", - "net", - "org", - "presse", - "edu", - "gov", - "nyc", - "org", - "com", - "edu", - "gov", - "net", - "org", - "dscloud", - "blogspot", - "gov", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "net", - "org", - "blogspot", - "ac", - "co", - "com", - "gov", - "net", - "or", - "org", - "academy", - "agriculture", - "air", - "airguard", - "alabama", - "alaska", - "amber", - "ambulance", - "american", - "americana", - "americanantiques", - "americanart", - "amsterdam", - "and", - "annefrank", - "anthro", - "anthropology", - "antiques", - "aquarium", - "arboretum", - "archaeological", - "archaeology", - "architecture", - "art", - "artanddesign", - "artcenter", - "artdeco", - "arteducation", - "artgallery", - "arts", - "artsandcrafts", - "asmatart", - "assassination", - "assisi", - "association", - "astronomy", - "atlanta", - "austin", - "australia", - "automotive", - "aviation", - "axis", - "badajoz", - "baghdad", - "bahn", - "bale", - "baltimore", - "barcelona", - "baseball", - "basel", - "baths", - "bauern", - "beauxarts", - "beeldengeluid", - "bellevue", - "bergbau", - "berkeley", - "berlin", - "bern", - "bible", - "bilbao", - "bill", - "birdart", - "birthplace", - "bonn", - "boston", - "botanical", - "botanicalgarden", - "botanicgarden", - "botany", - "brandywinevalley", - "brasil", - "bristol", - "british", - "britishcolumbia", - "broadcast", - "brunel", - "brussel", - "brussels", - "bruxelles", - "building", - "burghof", - "bus", - "bushey", - "cadaques", - "california", - "cambridge", - "can", - "canada", - "capebreton", - "carrier", - "cartoonart", - "casadelamoneda", - "castle", - "castres", - "celtic", - "center", - "chattanooga", - "cheltenham", - "chesapeakebay", - "chicago", - "children", - "childrens", - "childrensgarden", - "chiropractic", - "chocolate", - "christiansburg", - "cincinnati", - "cinema", - "circus", - "civilisation", - "civilization", - "civilwar", - "clinton", - "clock", - "coal", - "coastaldefence", - "cody", - "coldwar", - "collection", - "colonialwilliamsburg", - "coloradoplateau", - "columbia", - "columbus", - "communication", - "communications", - "community", - "computer", - "computerhistory", - "contemporary", - "contemporaryart", - "convent", - "copenhagen", - "corporation", - "corvette", - "costume", - "countryestate", - "county", - "crafts", - "cranbrook", - "creation", - "cultural", - "culturalcenter", - "culture", - "cyber", - "cymru", - "dali", - "dallas", - "database", - "ddr", - "decorativearts", - "delaware", - "delmenhorst", - "denmark", - "depot", - "design", - "detroit", - "dinosaur", - "discovery", - "dolls", - "donostia", - "durham", - "eastafrica", - "eastcoast", - "education", - "educational", - "egyptian", - "eisenbahn", - "elburg", - "elvendrell", - "embroidery", - "encyclopedic", - "england", - "entomology", - "environment", - "environmentalconservation", - "epilepsy", - "essex", - "estate", - "ethnology", - "exeter", - "exhibition", - "family", - "farm", - "farmequipment", - "farmers", - "farmstead", - "field", - "figueres", - "filatelia", - "film", - "fineart", - "finearts", - "finland", - "flanders", - "florida", - "force", - "fortmissoula", - "fortworth", - "foundation", - "francaise", - "frankfurt", - "franziskaner", - "freemasonry", - "freiburg", - "fribourg", - "frog", - "fundacio", - "furniture", - "gallery", - "garden", - "gateway", - "geelvinck", - "gemological", - "geology", - "georgia", - "giessen", - "glas", - "glass", - "gorge", - "grandrapids", - "graz", - "guernsey", - "halloffame", - "hamburg", - "handson", - "harvestcelebration", - "hawaii", - "health", - "heimatunduhren", - "hellas", - "helsinki", - "hembygdsforbund", - "heritage", - "histoire", - "historical", - "historicalsociety", - "historichouses", - "historisch", - "historisches", - "history", - "historyofscience", - "horology", - "house", - "humanities", - "illustration", - "imageandsound", - "indian", - "indiana", - "indianapolis", - "indianmarket", - "intelligence", - "interactive", - "iraq", - "iron", - "isleofman", - "jamison", - "jefferson", - "jerusalem", - "jewelry", - "jewish", - "jewishart", - "jfk", - "journalism", - "judaica", - "judygarland", - "juedisches", - "juif", - "karate", - "karikatur", - "kids", - "koebenhavn", - "koeln", - "kunst", - "kunstsammlung", - "kunstunddesign", - "labor", - "labour", - "lajolla", - "lancashire", - "landes", - "lans", - "larsson", - "lewismiller", - "lincoln", - "linz", - "living", - "livinghistory", - "localhistory", - "london", - "losangeles", - "louvre", - "loyalist", - "lucerne", - "luxembourg", - "luzern", - "mad", - "madrid", - "mallorca", - "manchester", - "mansion", - "mansions", - "manx", - "marburg", - "maritime", - "maritimo", - "maryland", - "marylhurst", - "media", - "medical", - "medizinhistorisches", - "meeres", - "memorial", - "mesaverde", - "michigan", - "midatlantic", - "military", - "mill", - "miners", - "mining", - "minnesota", - "missile", - "missoula", - "modern", - "moma", - "money", - "monmouth", - "monticello", - "montreal", - "moscow", - "motorcycle", - "muenchen", - "muenster", - "mulhouse", - "muncie", - "museet", - "museumcenter", - "museumvereniging", - "music", - "national", - "nationalfirearms", - "nationalheritage", - "nativeamerican", - "naturalhistory", - "naturalhistorymuseum", - "naturalsciences", - "nature", - "naturhistorisches", - "natuurwetenschappen", - "naumburg", - "naval", - "nebraska", - "neues", - "newhampshire", - "newjersey", - "newmexico", - "newport", - "newspaper", - "newyork", - "niepce", - "norfolk", - "north", - "nrw", - "nuernberg", - "nuremberg", - "nyc", - "nyny", - "oceanographic", - "oceanographique", - "omaha", - "online", - "ontario", - "openair", - "oregon", - "oregontrail", - "otago", - "oxford", - "pacific", - "paderborn", - "palace", - "paleo", - "palmsprings", - "panama", - "paris", - "pasadena", - "pharmacy", - "philadelphia", - "philadelphiaarea", - "philately", - "phoenix", - "photography", - "pilots", - "pittsburgh", - "planetarium", - "plantation", - "plants", - "plaza", - "portal", - "portland", - "portlligat", - "posts-and-telecommunications", - "preservation", - "presidio", - "press", - "project", - "public", - "pubol", - "quebec", - "railroad", - "railway", - "research", - "resistance", - "riodejaneiro", - "rochester", - "rockart", - "roma", - "russia", - "saintlouis", - "salem", - "salvadordali", - "salzburg", - "sandiego", - "sanfrancisco", - "santabarbara", - "santacruz", - "santafe", - "saskatchewan", - "satx", - "savannahga", - "schlesisches", - "schoenbrunn", - "schokoladen", - "school", - "schweiz", - "science", - "science-fiction", - "scienceandhistory", - "scienceandindustry", - "sciencecenter", - "sciencecenters", - "sciencehistory", - "sciences", - "sciencesnaturelles", - "scotland", - "seaport", - "settlement", - "settlers", - "shell", - "sherbrooke", - "sibenik", - "silk", - "ski", - "skole", - "society", - "sologne", - "soundandvision", - "southcarolina", - "southwest", - "space", - "spy", - "square", - "stadt", - "stalbans", - "starnberg", - "state", - "stateofdelaware", - "station", - "steam", - "steiermark", - "stjohn", - "stockholm", - "stpetersburg", - "stuttgart", - "suisse", - "surgeonshall", - "surrey", - "svizzera", - "sweden", - "sydney", - "tank", - "tcm", - "technology", - "telekommunikation", - "television", - "texas", - "textile", - "theater", - "time", - "timekeeping", - "topology", - "torino", - "touch", - "town", - "transport", - "tree", - "trolley", - "trust", - "trustee", - "uhren", - "ulm", - "undersea", - "university", - "usa", - "usantiques", - "usarts", - "uscountryestate", - "usculture", - "usdecorativearts", - "usgarden", - "ushistory", - "ushuaia", - "uslivinghistory", - "utah", - "uvic", - "valley", - "vantaa", - "versailles", - "viking", - "village", - "virginia", - "virtual", - "virtuel", - "vlaanderen", - "volkenkunde", - "wales", - "wallonie", - "war", - "washingtondc", - "watch-and-clock", - "watchandclock", - "western", - "westfalen", - "whaling", - "wildlife", - "williamsburg", - "windmill", - "workshop", - "xn--9dbhblg6di", - "xn--comunicaes-v6a2o", - "xn--correios-e-telecomunicaes-ghc29a", - "xn--h1aegh", - "xn--lns-qla", - "york", - "yorkshire", - "yosemite", - "youth", - "zoological", - "zoology", - "aero", - "biz", - "com", - "coop", - "edu", - "gov", - "info", - "int", - "mil", - "museum", - "name", - "net", - "org", - "pro", - "ac", - "biz", - "co", - "com", - "coop", - "edu", - "gov", - "int", - "museum", - "net", - "org", - "blogspot", - "com", - "edu", - "gob", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "mil", - "name", - "net", - "org", - "teledata", - "ca", - "cc", - "co", - "com", - "dr", - "in", - "info", - "mobi", - "mx", - "name", - "or", - "org", - "pro", - "school", - "tv", - "us", - "ws", - "her", - "his", - "forgot", - "forgot", - "asso", - "at-band-camp", - "azure-mobile", - "azurewebsites", - "blogdns", - "bounceme", - "broke-it", - "buyshouses", - "cdn77", - "cdn77-ssl", - "cloudapp", - "cloudfront", - "cloudfunctions", - "ddns", - "dnsalias", - "dnsdojo", - "does-it", - "dontexist", - "dsmynas", - "dynalias", - "dynathome", - "dynv6", - "eating-organic", - "endofinternet", - "familyds", - "fastly", - "from-az", - "from-co", - "from-la", - "from-ny", - "gb", - "gets-it", - "ham-radio-op", - "homeftp", - "homeip", - "homelinux", - "homeunix", - "hu", - "in", - "in-the-band", - "is-a-chef", - "is-a-geek", - "isa-geek", - "jp", - "kicks-ass", - "mydissent", - "myeffect", - "myfritz", - "mymediapc", - "mypsx", - "mysecuritycamera", - "nhlfan", - "no-ip", - "office-on-the", - "pgafan", - "podzone", - "privatizehealthinsurance", - "rackmaze", - "redirectme", - "scrapper-site", - "se", - "selfip", - "sells-it", - "servebbs", - "serveblog", - "serveftp", - "serveminecraft", - "sytes", - "thruhere", - "uk", - "webhop", - "za", - "r", - "prod", - "ssl", - "a", - "global", - "a", - "b", - "global", - "alces", - "arts", - "com", - "firm", - "info", - "net", - "other", - "per", - "rec", - "store", - "web", - "com", - "edu", - "gov", - "i", - "mil", - "mobi", - "name", - "net", - "org", - "sch", - "blogspot", - "ac", - "biz", - "co", - "com", - "edu", - "gob", - "in", - "info", - "int", - "mil", - "net", - "nom", - "org", - "web", - "blogspot", - "bv", - "co", - "aa", - "aarborte", - "aejrie", - "afjord", - "agdenes", - "ah", - "akershus", - "aknoluokta", - "akrehamn", - "al", - "alaheadju", - "alesund", - "algard", - "alstahaug", - "alta", - "alvdal", - "amli", - "amot", - "andasuolo", - "andebu", - "andoy", - "ardal", - "aremark", - "arendal", - "arna", - "aseral", - "asker", - "askim", - "askoy", - "askvoll", - "asnes", - "audnedaln", - "aukra", - "aure", - "aurland", - "aurskog-holand", - "austevoll", - "austrheim", - "averoy", - "badaddja", - "bahcavuotna", - "bahccavuotna", - "baidar", - "bajddar", - "balat", - "balestrand", - "ballangen", - "balsfjord", - "bamble", - "bardu", - "barum", - "batsfjord", - "bearalvahki", - "beardu", - "beiarn", - "berg", - "bergen", - "berlevag", - "bievat", - "bindal", - "birkenes", - "bjarkoy", - "bjerkreim", - "bjugn", - "blogspot", - "bodo", - "bokn", - "bomlo", - "bremanger", - "bronnoy", - "bronnoysund", - "brumunddal", - "bryne", - "bu", - "budejju", - "buskerud", - "bygland", - "bykle", - "cahcesuolo", - "co", - "davvenjarga", - "davvesiida", - "deatnu", - "dep", - "dielddanuorri", - "divtasvuodna", - "divttasvuotna", - "donna", - "dovre", - "drammen", - "drangedal", - "drobak", - "dyroy", - "egersund", - "eid", - "eidfjord", - "eidsberg", - "eidskog", - "eidsvoll", - "eigersund", - "elverum", - "enebakk", - "engerdal", - "etne", - "etnedal", - "evenassi", - "evenes", - "evje-og-hornnes", - "farsund", - "fauske", - "fedje", - "fet", - "fetsund", - "fhs", - "finnoy", - "fitjar", - "fjaler", - "fjell", - "fla", - "flakstad", - "flatanger", - "flekkefjord", - "flesberg", - "flora", - "floro", - "fm", - "folkebibl", - "folldal", - "forde", - "forsand", - "fosnes", - "frana", - "fredrikstad", - "frei", - "frogn", - "froland", - "frosta", - "froya", - "fuoisku", - "fuossko", - "fusa", - "fylkesbibl", - "fyresdal", - "gaivuotna", - "galsa", - "gamvik", - "gangaviika", - "gaular", - "gausdal", - "giehtavuoatna", - "gildeskal", - "giske", - "gjemnes", - "gjerdrum", - "gjerstad", - "gjesdal", - "gjovik", - "gloppen", - "gol", - "gran", - "grane", - "granvin", - "gratangen", - "grimstad", - "grong", - "grue", - "gulen", - "guovdageaidnu", - "ha", - "habmer", - "hadsel", - "hagebostad", - "halden", - "halsa", - "hamar", - "hamaroy", - "hammarfeasta", - "hammerfest", - "hapmir", - "haram", - "hareid", - "harstad", - "hasvik", - "hattfjelldal", - "haugesund", - "hedmark", - "hemne", - "hemnes", - "hemsedal", - "herad", - "hitra", - "hjartdal", - "hjelmeland", - "hl", - "hm", - "hobol", - "hof", - "hokksund", - "hol", - "hole", - "holmestrand", - "holtalen", - "honefoss", - "hordaland", - "hornindal", - "horten", - "hoyanger", - "hoylandet", - "hurdal", - "hurum", - "hvaler", - "hyllestad", - "ibestad", - "idrett", - "inderoy", - "iveland", - "ivgu", - "jan-mayen", - "jessheim", - "jevnaker", - "jolster", - "jondal", - "jorpeland", - "kafjord", - "karasjohka", - "karasjok", - "karlsoy", - "karmoy", - "kautokeino", - "kirkenes", - "klabu", - "klepp", - "kommune", - "kongsberg", - "kongsvinger", - "kopervik", - "kraanghke", - "kragero", - "kristiansand", - "kristiansund", - "krodsherad", - "krokstadelva", - "kvafjord", - "kvalsund", - "kvam", - "kvanangen", - "kvinesdal", - "kvinnherad", - "kviteseid", - "kvitsoy", - "laakesvuemie", - "lahppi", - "langevag", - "lardal", - "larvik", - "lavagis", - "lavangen", - "leangaviika", - "lebesby", - "leikanger", - "leirfjord", - "leirvik", - "leka", - "leksvik", - "lenvik", - "lerdal", - "lesja", - "levanger", - "lier", - "lierne", - "lillehammer", - "lillesand", - "lindas", - "lindesnes", - "loabat", - "lodingen", - "lom", - "loppa", - "lorenskog", - "loten", - "lund", - "lunner", - "luroy", - "luster", - "lyngdal", - "lyngen", - "malatvuopmi", - "malselv", - "malvik", - "mandal", - "marker", - "marnardal", - "masfjorden", - "masoy", - "matta-varjjat", - "meland", - "meldal", - "melhus", - "meloy", - "meraker", - "midsund", - "midtre-gauldal", - "mil", - "mjondalen", - "mo-i-rana", - "moareke", - "modalen", - "modum", - "molde", - "more-og-romsdal", - "mosjoen", - "moskenes", - "moss", - "mosvik", - "mr", - "muosat", - "museum", - "naamesjevuemie", - "namdalseid", - "namsos", - "namsskogan", - "nannestad", - "naroy", - "narviika", - "narvik", - "naustdal", - "navuotna", - "nedre-eiker", - "nesna", - "nesodden", - "nesoddtangen", - "nesseby", - "nesset", - "nissedal", - "nittedal", - "nl", - "nord-aurdal", - "nord-fron", - "nord-odal", - "norddal", - "nordkapp", - "nordland", - "nordre-land", - "nordreisa", - "nore-og-uvdal", - "notodden", - "notteroy", - "nt", - "odda", - "of", - "oksnes", - "ol", - "omasvuotna", - "oppdal", - "oppegard", - "orkanger", - "orkdal", - "orland", - "orskog", - "orsta", - "osen", - "oslo", - "osoyro", - "osteroy", - "ostfold", - "ostre-toten", - "overhalla", - "ovre-eiker", - "oyer", - "oygarden", - "oystre-slidre", - "porsanger", - "porsangu", - "porsgrunn", - "priv", - "rade", - "radoy", - "rahkkeravju", - "raholt", - "raisa", - "rakkestad", - "ralingen", - "rana", - "randaberg", - "rauma", - "rendalen", - "rennebu", - "rennesoy", - "rindal", - "ringebu", - "ringerike", - "ringsaker", - "risor", - "rissa", - "rl", - "roan", - "rodoy", - "rollag", - "romsa", - "romskog", - "roros", - "rost", - "royken", - "royrvik", - "ruovat", - "rygge", - "salangen", - "salat", - "saltdal", - "samnanger", - "sandefjord", - "sandnes", - "sandnessjoen", - "sandoy", - "sarpsborg", - "sauda", - "sauherad", - "sel", - "selbu", - "selje", - "seljord", - "sf", - "siellak", - "sigdal", - "siljan", - "sirdal", - "skanit", - "skanland", - "skaun", - "skedsmo", - "skedsmokorset", - "ski", - "skien", - "skierva", - "skiptvet", - "skjak", - "skjervoy", - "skodje", - "slattum", - "smola", - "snaase", - "snasa", - "snillfjord", - "snoasa", - "sogndal", - "sogne", - "sokndal", - "sola", - "solund", - "somna", - "sondre-land", - "songdalen", - "sor-aurdal", - "sor-fron", - "sor-odal", - "sor-varanger", - "sorfold", - "sorreisa", - "sortland", - "sorum", - "spjelkavik", - "spydeberg", - "st", - "stange", - "stat", - "stathelle", - "stavanger", - "stavern", - "steigen", - "steinkjer", - "stjordal", - "stjordalshalsen", - "stokke", - "stor-elvdal", - "stord", - "stordal", - "storfjord", - "strand", - "stranda", - "stryn", - "sula", - "suldal", - "sund", - "sunndal", - "surnadal", - "svalbard", - "sveio", - "svelvik", - "sykkylven", - "tana", - "tananger", - "telemark", - "time", - "tingvoll", - "tinn", - "tjeldsund", - "tjome", - "tm", - "tokke", - "tolga", - "tonsberg", - "torsken", - "tr", - "trana", - "tranby", - "tranoy", - "troandin", - "trogstad", - "tromsa", - "tromso", - "trondheim", - "trysil", - "tvedestrand", - "tydal", - "tynset", - "tysfjord", - "tysnes", - "tysvar", - "ullensaker", - "ullensvang", - "ulvik", - "unjarga", - "utsira", - "va", - "vaapste", - "vadso", - "vaga", - "vagan", - "vagsoy", - "vaksdal", - "valle", - "vang", - "vanylven", - "vardo", - "varggat", - "varoy", - "vefsn", - "vega", - "vegarshei", - "vennesla", - "verdal", - "verran", - "vestby", - "vestfold", - "vestnes", - "vestre-slidre", - "vestre-toten", - "vestvagoy", - "vevelstad", - "vf", - "vgs", - "vik", - "vikna", - "vindafjord", - "voagat", - "volda", - "voss", - "vossevangen", - "xn--andy-ira", - "xn--asky-ira", - "xn--aurskog-hland-jnb", - "xn--avery-yua", - "xn--bdddj-mrabd", - "xn--bearalvhki-y4a", - "xn--berlevg-jxa", - "xn--bhcavuotna-s4a", - "xn--bhccavuotna-k7a", - "xn--bidr-5nac", - "xn--bievt-0qa", - "xn--bjarky-fya", - "xn--bjddar-pta", - "xn--blt-elab", - "xn--bmlo-gra", - "xn--bod-2na", - "xn--brnny-wuac", - "xn--brnnysund-m8ac", - "xn--brum-voa", - "xn--btsfjord-9za", - "xn--davvenjrga-y4a", - "xn--dnna-gra", - "xn--drbak-wua", - "xn--dyry-ira", - "xn--eveni-0qa01ga", - "xn--finny-yua", - "xn--fjord-lra", - "xn--fl-zia", - "xn--flor-jra", - "xn--frde-gra", - "xn--frna-woa", - "xn--frya-hra", - "xn--ggaviika-8ya47h", - "xn--gildeskl-g0a", - "xn--givuotna-8ya", - "xn--gjvik-wua", - "xn--gls-elac", - "xn--h-2fa", - "xn--hbmer-xqa", - "xn--hcesuolo-7ya35b", - "xn--hgebostad-g3a", - "xn--hmmrfeasta-s4ac", - "xn--hnefoss-q1a", - "xn--hobl-ira", - "xn--holtlen-hxa", - "xn--hpmir-xqa", - "xn--hyanger-q1a", - "xn--hylandet-54a", - "xn--indery-fya", - "xn--jlster-bya", - "xn--jrpeland-54a", - "xn--karmy-yua", - "xn--kfjord-iua", - "xn--klbu-woa", - "xn--koluokta-7ya57h", - "xn--krager-gya", - "xn--kranghke-b0a", - "xn--krdsherad-m8a", - "xn--krehamn-dxa", - "xn--krjohka-hwab49j", - "xn--ksnes-uua", - "xn--kvfjord-nxa", - "xn--kvitsy-fya", - "xn--kvnangen-k0a", - "xn--l-1fa", - "xn--laheadju-7ya", - "xn--langevg-jxa", - "xn--ldingen-q1a", - "xn--leagaviika-52b", - "xn--lesund-hua", - "xn--lgrd-poac", - "xn--lhppi-xqa", - "xn--linds-pra", - "xn--loabt-0qa", - "xn--lrdal-sra", - "xn--lrenskog-54a", - "xn--lt-liac", - "xn--lten-gra", - "xn--lury-ira", - "xn--mely-ira", - "xn--merker-kua", - "xn--mjndalen-64a", - "xn--mlatvuopmi-s4a", - "xn--mli-tla", - "xn--mlselv-iua", - "xn--moreke-jua", - "xn--mosjen-eya", - "xn--mot-tla", - "xn--mre-og-romsdal-qqb", - "xn--msy-ula0h", - "xn--mtta-vrjjat-k7af", - "xn--muost-0qa", - "xn--nmesjevuemie-tcba", - "xn--nry-yla5g", - "xn--nttery-byae", - "xn--nvuotna-hwa", - "xn--oppegrd-ixa", - "xn--ostery-fya", - "xn--osyro-wua", - "xn--porsgu-sta26f", - "xn--rady-ira", - "xn--rdal-poa", - "xn--rde-ula", - "xn--rdy-0nab", - "xn--rennesy-v1a", - "xn--rhkkervju-01af", - "xn--rholt-mra", - "xn--risa-5na", - "xn--risr-ira", - "xn--rland-uua", - "xn--rlingen-mxa", - "xn--rmskog-bya", - "xn--rros-gra", - "xn--rskog-uua", - "xn--rst-0na", - "xn--rsta-fra", - "xn--ryken-vua", - "xn--ryrvik-bya", - "xn--s-1fa", - "xn--sandnessjen-ogb", - "xn--sandy-yua", - "xn--seral-lra", - "xn--sgne-gra", - "xn--skierv-uta", - "xn--skjervy-v1a", - "xn--skjk-soa", - "xn--sknit-yqa", - "xn--sknland-fxa", - "xn--slat-5na", - "xn--slt-elab", - "xn--smla-hra", - "xn--smna-gra", - "xn--snase-nra", - "xn--sndre-land-0cb", - "xn--snes-poa", - "xn--snsa-roa", - "xn--sr-aurdal-l8a", - "xn--sr-fron-q1a", - "xn--sr-odal-q1a", - "xn--sr-varanger-ggb", - "xn--srfold-bya", - "xn--srreisa-q1a", - "xn--srum-gra", - "xn--stfold-9xa", - "xn--stjrdal-s1a", - "xn--stjrdalshalsen-sqb", - "xn--stre-toten-zcb", - "xn--tjme-hra", - "xn--tnsberg-q1a", - "xn--trany-yua", - "xn--trgstad-r1a", - "xn--trna-woa", - "xn--troms-zua", - "xn--tysvr-vra", - "xn--unjrga-rta", - "xn--vads-jra", - "xn--vard-jra", - "xn--vegrshei-c0a", - "xn--vestvgy-ixa6o", - "xn--vg-yiab", - "xn--vgan-qoa", - "xn--vgsy-qoa0j", - "xn--vre-eiker-k8a", - "xn--vrggt-xqad", - "xn--vry-yla5g", - "xn--yer-zna", - "xn--ygarden-p1a", - "xn--ystre-slidre-ujb", - "gs", - "gs", - "nes", - "gs", - "nes", - "gs", - "os", - "valer", - "xn--vler-qoa", - "gs", - "gs", - "os", - "gs", - "heroy", - "sande", - "gs", - "gs", - "bo", - "heroy", - "xn--b-5ga", - "xn--hery-ira", - "gs", - "gs", - "gs", - "gs", - "valer", - "gs", - "gs", - "gs", - "gs", - "bo", - "xn--b-5ga", - "gs", - "gs", - "gs", - "sande", - "gs", - "sande", - "xn--hery-ira", - "xn--vler-qoa", - "biz", - "com", - "edu", - "gov", - "info", - "net", - "org", - "merseine", - "mine", - "shacknet", - "ac", - "co", - "cri", - "geek", - "gen", - "govt", - "health", - "iwi", - "kiwi", - "maori", - "mil", - "net", - "org", - "parliament", - "school", - "xn--mori-qsa", - "blogspot", - "co", - "com", - "edu", - "gov", - "med", - "museum", - "net", - "org", - "pro", - "ae", - "blogdns", - "blogsite", - "bmoattachments", - "boldlygoingnowhere", - "cable-modem", - "cdn77", - "cdn77-secure", - "collegefan", - "couchpotatofries", - "dnsalias", - "dnsdojo", - "doesntexist", - "dontexist", - "doomdns", - "dsmynas", - "duckdns", - "dvrdns", - "dynalias", - "dyndns", - "endofinternet", - "endoftheinternet", - "eu", - "familyds", - "from-me", - "game-host", - "gotdns", - "hk", - "hobby-site", - "homedns", - "homeftp", - "homelinux", - "homeunix", - "hopto", - "is-a-bruinsfan", - "is-a-candidate", - "is-a-celticsfan", - "is-a-chef", - "is-a-geek", - "is-a-knight", - "is-a-linux-user", - "is-a-patsfan", - "is-a-soxfan", - "is-found", - "is-lost", - "is-saved", - "is-very-bad", - "is-very-evil", - "is-very-good", - "is-very-nice", - "is-very-sweet", - "isa-geek", - "kicks-ass", - "misconfused", - "mlbfan", - "myftp", - "mysecuritycamera", - "nflfan", - "no-ip", - "podzone", - "read-books", - "readmyblog", - "selfip", - "sellsyourhome", - "servebbs", - "serveftp", - "servegame", - "stuff-4-sale", - "tunk", - "ufcfan", - "us", - "webhop", - "za", - "zapto", - "c", - "rsc", - "origin", - "ssl", - "go", - "home", - "al", - "asso", - "at", - "au", - "be", - "bg", - "ca", - "cd", - "ch", - "cn", - "cy", - "cz", - "de", - "dk", - "edu", - "ee", - "es", - "fi", - "fr", - "gr", - "hr", - "hu", - "ie", - "il", - "in", - "int", - "is", - "it", - "jp", - "kr", - "lt", - "lu", - "lv", - "mc", - "me", - "mk", - "mt", - "my", - "net", - "ng", - "nl", - "no", - "nz", - "paris", - "pl", - "pt", - "q-a", - "ro", - "ru", - "se", - "si", - "sk", - "tr", - "uk", - "us", - "nerdpol", - "abo", - "ac", - "com", - "edu", - "gob", - "ing", - "med", - "net", - "nom", - "org", - "sld", - "blogspot", - "com", - "edu", - "gob", - "mil", - "net", - "nom", - "org", - "com", - "edu", - "org", - "com", - "edu", - "gov", - "i", - "mil", - "net", - "ngo", - "org", - "biz", - "com", - "edu", - "fam", - "gob", - "gok", - "gon", - "gop", - "gos", - "gov", - "info", - "net", - "org", - "web", - "agro", - "aid", - "art", - "atm", - "augustow", - "auto", - "babia-gora", - "bedzin", - "beskidy", - "bialowieza", - "bialystok", - "bielawa", - "bieszczady", - "biz", - "boleslawiec", - "bydgoszcz", - "bytom", - "cieszyn", - "co", - "com", - "czeladz", - "czest", - "dlugoleka", - "edu", - "elblag", - "elk", - "gda", - "gdansk", - "gdynia", - "gliwice", - "glogow", - "gmina", - "gniezno", - "gorlice", - "gov", - "grajewo", - "gsm", - "ilawa", - "info", - "jaworzno", - "jelenia-gora", - "jgora", - "kalisz", - "karpacz", - "kartuzy", - "kaszuby", - "katowice", - "kazimierz-dolny", - "kepno", - "ketrzyn", - "klodzko", - "kobierzyce", - "kolobrzeg", - "konin", - "konskowola", - "krakow", - "kutno", - "lapy", - "lebork", - "legnica", - "lezajsk", - "limanowa", - "lomza", - "lowicz", - "lubin", - "lukow", - "mail", - "malbork", - "malopolska", - "mazowsze", - "mazury", - "med", - "media", - "miasta", - "mielec", - "mielno", - "mil", - "mragowo", - "naklo", - "net", - "nieruchomosci", - "nom", - "nowaruda", - "nysa", - "olawa", - "olecko", - "olkusz", - "olsztyn", - "opoczno", - "opole", - "org", - "ostroda", - "ostroleka", - "ostrowiec", - "ostrowwlkp", - "pc", - "pila", - "pisz", - "podhale", - "podlasie", - "polkowice", - "pomorskie", - "pomorze", - "powiat", - "poznan", - "priv", - "prochowice", - "pruszkow", - "przeworsk", - "pulawy", - "radom", - "rawa-maz", - "realestate", - "rel", - "rybnik", - "rzeszow", - "sanok", - "sejny", - "sex", - "shop", - "sklep", - "skoczow", - "slask", - "slupsk", - "sopot", - "sos", - "sosnowiec", - "stalowa-wola", - "starachowice", - "stargard", - "suwalki", - "swidnica", - "swiebodzin", - "swinoujscie", - "szczecin", - "szczytno", - "szkola", - "targi", - "tarnobrzeg", - "tgory", - "tm", - "tourism", - "travel", - "turek", - "turystyka", - "tychy", - "ustka", - "walbrzych", - "warmia", - "warszawa", - "waw", - "wegrow", - "wielun", - "wlocl", - "wloclawek", - "wodzislaw", - "wolomin", - "wroc", - "wroclaw", - "zachpomor", - "zagan", - "zakopane", - "zarow", - "zgora", - "zgorzelec", - "ap", - "griw", - "ic", - "is", - "kmpsp", - "konsulat", - "kppsp", - "kwp", - "kwpsp", - "mup", - "mw", - "oirm", - "oum", - "pa", - "pinb", - "piw", - "po", - "psp", - "psse", - "pup", - "rzgw", - "sa", - "sdn", - "sko", - "so", - "sr", - "starostwo", - "ug", - "ugim", - "um", - "umig", - "upow", - "uppo", - "us", - "uw", - "uzs", - "wif", - "wiih", - "winb", - "wios", - "witd", - "wiw", - "wsa", - "wskr", - "wuoz", - "wzmiuw", - "zp", - "co", - "edu", - "gov", - "net", - "org", - "ac", - "biz", - "com", - "edu", - "est", - "gov", - "info", - "isla", - "name", - "net", - "org", - "pro", - "prof", - "aaa", - "aca", - "acct", - "avocat", - "bar", - "cpa", - "eng", - "jur", - "law", - "med", - "recht", - "com", - "edu", - "gov", - "net", - "org", - "plo", - "sec", - "blogspot", - "com", - "edu", - "gov", - "int", - "net", - "nome", - "org", - "publ", - "belau", - "co", - "ed", - "go", - "ne", - "or", - "com", - "coop", - "edu", - "gov", - "mil", - "net", - "org", - "blogspot", - "com", - "edu", - "gov", - "mil", - "name", - "net", - "org", - "sch", - "asso", - "blogspot", - "com", - "nom", - "arts", - "blogspot", - "com", - "firm", - "info", - "nom", - "nt", - "org", - "rec", - "store", - "tm", - "www", - "ac", - "blogspot", - "co", - "edu", - "gov", - "in", - "org", - "ac", - "adygeya", - "altai", - "amur", - "amursk", - "arkhangelsk", - "astrakhan", - "baikal", - "bashkiria", - "belgorod", - "bir", - "blogspot", - "bryansk", - "buryatia", - "cbg", - "chel", - "chelyabinsk", - "chita", - "chukotka", - "chuvashia", - "cmw", - "com", - "dagestan", - "dudinka", - "e-burg", - "edu", - "fareast", - "gov", - "grozny", - "int", - "irkutsk", - "ivanovo", - "izhevsk", - "jamal", - "jar", - "joshkar-ola", - "k-uralsk", - "kalmykia", - "kaluga", - "kamchatka", - "karelia", - "kazan", - "kchr", - "kemerovo", - "khabarovsk", - "khakassia", - "khv", - "kirov", - "kms", - "koenig", - "komi", - "kostroma", - "krasnoyarsk", - "kuban", - "kurgan", - "kursk", - "kustanai", - "kuzbass", - "lipetsk", - "magadan", - "mari", - "mari-el", - "marine", - "mil", - "mordovia", - "msk", - "murmansk", - "mytis", - "nakhodka", - "nalchik", - "net", - "nkz", - "nnov", - "norilsk", - "nov", - "novosibirsk", - "nsk", - "omsk", - "orenburg", - "org", - "oryol", - "oskol", - "palana", - "penza", - "perm", - "pp", - "ptz", - "pyatigorsk", - "rnd", - "rubtsovsk", - "ryazan", - "sakhalin", - "samara", - "saratov", - "simbirsk", - "smolensk", - "snz", - "spb", - "stavropol", - "stv", - "surgut", - "syzran", - "tambov", - "tatarstan", - "test", - "tom", - "tomsk", - "tsaritsyn", - "tsk", - "tula", - "tuva", - "tver", - "tyumen", - "udm", - "udmurtia", - "ulan-ude", - "vdonsk", - "vladikavkaz", - "vladimir", - "vladivostok", - "volgograd", - "vologda", - "voronezh", - "vrn", - "vyatka", - "yakutia", - "yamal", - "yaroslavl", - "yekaterinburg", - "yuzhno-sakhalinsk", - "zgrad", - "ac", - "co", - "com", - "edu", - "gouv", - "gov", - "int", - "mil", - "net", - "com", - "edu", - "gov", - "med", - "net", - "org", - "pub", - "sch", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "net", - "org", - "com", - "edu", - "gov", - "info", - "med", - "net", - "org", - "tv", - "a", - "ac", - "b", - "bd", - "blogspot", - "brand", - "c", - "com", - "d", - "e", - "f", - "fh", - "fhsk", - "fhv", - "g", - "h", - "i", - "k", - "komforb", - "kommunalforbund", - "komvux", - "l", - "lanbib", - "m", - "n", - "naturbruksgymn", - "o", - "org", - "p", - "parti", - "pp", - "press", - "r", - "s", - "t", - "tm", - "u", - "w", - "x", - "y", - "z", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "per", - "com", - "gov", - "hashbang", - "mil", - "net", - "org", - "platform", - "blogspot", - "cyon", - "blogspot", - "com", - "edu", - "gov", - "net", - "org", - "art", - "blogspot", - "com", - "edu", - "gouv", - "org", - "perso", - "univ", - "com", - "net", - "org", - "co", - "com", - "consulado", - "edu", - "embaixada", - "gov", - "mil", - "net", - "org", - "principe", - "saotome", - "store", - "adygeya", - "arkhangelsk", - "balashov", - "bashkiria", - "bryansk", - "dagestan", - "grozny", - "ivanovo", - "kalmykia", - "kaluga", - "karelia", - "khakassia", - "krasnodar", - "kurgan", - "lenug", - "mordovia", - "msk", - "murmansk", - "nalchik", - "nov", - "obninsk", - "penza", - "pokrovsk", - "sochi", - "spb", - "togliatti", - "troitsk", - "tula", - "tuva", - "vladikavkaz", - "vladimir", - "vologda", - "com", - "edu", - "gob", - "org", - "red", - "gov", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "ac", - "co", - "org", - "blogspot", - "ac", - "co", - "go", - "in", - "mi", - "net", - "or", - "ac", - "biz", - "co", - "com", - "edu", - "go", - "gov", - "int", - "mil", - "name", - "net", - "nic", - "org", - "test", - "web", - "gov", - "co", - "com", - "edu", - "gov", - "mil", - "net", - "nom", - "org", - "agrinet", - "com", - "defense", - "edunet", - "ens", - "fin", - "gov", - "ind", - "info", - "intl", - "mincom", - "nat", - "net", - "org", - "perso", - "rnrt", - "rns", - "rnu", - "tourism", - "turen", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "av", - "bbs", - "bel", - "biz", - "com", - "dr", - "edu", - "gen", - "gov", - "info", - "k12", - "kep", - "mil", - "name", - "nc", - "net", - "org", - "pol", - "tel", - "tv", - "web", - "blogspot", - "gov", - "aero", - "biz", - "co", - "com", - "coop", - "edu", - "gov", - "info", - "int", - "jobs", - "mobi", - "museum", - "name", - "net", - "org", - "pro", - "travel", - "better-than", - "dyndns", - "on-the-web", - "worse-than", - "blogspot", - "club", - "com", - "ebiz", - "edu", - "game", - "gov", - "idv", - "mil", - "net", - "org", - "xn--czrw28b", - "xn--uc0atv", - "xn--zf0ao64a", - "ac", - "co", - "go", - "hotel", - "info", - "me", - "mil", - "mobi", - "ne", - "or", - "sc", - "tv", - "biz", - "cherkassy", - "cherkasy", - "chernigov", - "chernihiv", - "chernivtsi", - "chernovtsy", - "ck", - "cn", - "co", - "com", - "cr", - "crimea", - "cv", - "dn", - "dnepropetrovsk", - "dnipropetrovsk", - "dominic", - "donetsk", - "dp", - "edu", - "gov", - "if", - "in", - "ivano-frankivsk", - "kh", - "kharkiv", - "kharkov", - "kherson", - "khmelnitskiy", - "khmelnytskyi", - "kiev", - "kirovograd", - "km", - "kr", - "krym", - "ks", - "kv", - "kyiv", - "lg", - "lt", - "lugansk", - "lutsk", - "lv", - "lviv", - "mk", - "mykolaiv", - "net", - "nikolaev", - "od", - "odesa", - "odessa", - "org", - "pl", - "poltava", - "pp", - "rivne", - "rovno", - "rv", - "sb", - "sebastopol", - "sevastopol", - "sm", - "sumy", - "te", - "ternopil", - "uz", - "uzhgorod", - "vinnica", - "vinnytsia", - "vn", - "volyn", - "yalta", - "zaporizhzhe", - "zaporizhzhia", - "zhitomir", - "zhytomyr", - "zp", - "zt", - "ac", - "blogspot", - "co", - "com", - "go", - "ne", - "or", - "org", - "sc", - "ac", - "co", - "gov", - "ltd", - "me", - "net", - "nhs", - "org", - "plc", - "police", - "sch", - "blogspot", - "no-ip", - "service", - "ak", - "al", - "ar", - "as", - "az", - "ca", - "co", - "ct", - "dc", - "de", - "dni", - "fed", - "fl", - "ga", - "golffan", - "gu", - "hi", - "ia", - "id", - "il", - "in", - "is-by", - "isa", - "kids", - "ks", - "ky", - "la", - "land-4-sale", - "ma", - "md", - "me", - "mi", - "mn", - "mo", - "ms", - "mt", - "nc", - "nd", - "ne", - "nh", - "nj", - "nm", - "noip", - "nsn", - "nv", - "ny", - "oh", - "ok", - "or", - "pa", - "pointto", - "pr", - "ri", - "sc", - "sd", - "stuff-4-sale", - "tn", - "tx", - "ut", - "va", - "vi", - "vt", - "wa", - "wi", - "wv", - "wy", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "chtr", - "paroch", - "pvt", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "k12", - "lib", - "cc", - "cc", - "k12", - "lib", - "com", - "edu", - "gub", - "mil", - "net", - "org", - "blogspot", - "co", - "com", - "net", - "org", - "com", - "edu", - "gov", - "mil", - "net", - "org", - "arts", - "co", - "com", - "e12", - "edu", - "firm", - "gob", - "gov", - "info", - "int", - "mil", - "net", - "org", - "rec", - "store", - "tec", - "web", - "co", - "com", - "k12", - "net", - "org", - "ac", - "biz", - "blogspot", - "com", - "edu", - "gov", - "health", - "info", - "int", - "name", - "net", - "org", - "pro", - "com", - "edu", - "net", - "org", - "com", - "dyndns", - "edu", - "gov", - "mypets", - "net", - "org", - "xn--80au", - "xn--90azh", - "xn--c1avg", - "xn--d1at", - "xn--o1ac", - "xn--o1ach", - "ac", - "agric", - "alt", - "co", - "edu", - "gov", - "grondar", - "law", - "mil", - "net", - "ngo", - "nis", - "nom", - "org", - "school", - "tm", - "web", - "blogspot", - "ac", - "biz", - "co", - "com", - "edu", - "gov", - "info", - "mil", - "net", - "org", - "sch", -} diff --git a/vendor/golang.org/x/net/route/address.go b/vendor/golang.org/x/net/route/address.go deleted file mode 100644 index 206a837..0000000 --- a/vendor/golang.org/x/net/route/address.go +++ /dev/null @@ -1,269 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import "runtime" - -// An Addr represents an address associated with packet routing. -type Addr interface { - // Family returns an address family. - Family() int -} - -// A LinkAddr represents a link-layer address. -type LinkAddr struct { - Index int // interface index when attached - Name string // interface name when attached - Addr []byte // link-layer address when attached -} - -// Family implements the Family method of Addr interface. -func (a *LinkAddr) Family() int { return sysAF_LINK } - -func parseLinkAddr(b []byte) (Addr, error) { - if len(b) < 8 { - return nil, errInvalidAddr - } - _, a, err := parseKernelLinkAddr(sysAF_LINK, b[4:]) - if err != nil { - return nil, err - } - a.(*LinkAddr).Index = int(nativeEndian.Uint16(b[2:4])) - return a, nil -} - -// parseKernelLinkAddr parses b as a link-layer address in -// conventional BSD kernel form. -func parseKernelLinkAddr(_ int, b []byte) (int, Addr, error) { - // The encoding looks like the following: - // +----------------------------+ - // | Type (1 octet) | - // +----------------------------+ - // | Name length (1 octet) | - // +----------------------------+ - // | Address length (1 octet) | - // +----------------------------+ - // | Selector length (1 octet) | - // +----------------------------+ - // | Data (variable) | - // +----------------------------+ - // - // On some platforms, all-bit-one of length field means "don't - // care". - nlen, alen, slen := int(b[1]), int(b[2]), int(b[3]) - if nlen == 0xff { - nlen = 0 - } - if alen == 0xff { - alen = 0 - } - if slen == 0xff { - slen = 0 - } - l := 4 + nlen + alen + slen - if len(b) < l { - return 0, nil, errInvalidAddr - } - data := b[4:] - var name string - var addr []byte - if nlen > 0 { - name = string(data[:nlen]) - data = data[nlen:] - } - if alen > 0 { - addr = data[:alen] - data = data[alen:] - } - return l, &LinkAddr{Name: name, Addr: addr}, nil -} - -// An Inet4Addr represents an internet address for IPv4. -type Inet4Addr struct { - IP [4]byte // IP address -} - -// Family implements the Family method of Addr interface. -func (a *Inet4Addr) Family() int { return sysAF_INET } - -// An Inet6Addr represents an internet address for IPv6. -type Inet6Addr struct { - IP [16]byte // IP address - ZoneID int // zone identifier -} - -// Family implements the Family method of Addr interface. -func (a *Inet6Addr) Family() int { return sysAF_INET6 } - -// parseInetAddr parses b as an internet address for IPv4 or IPv6. -func parseInetAddr(af int, b []byte) (Addr, error) { - switch af { - case sysAF_INET: - if len(b) < 16 { - return nil, errInvalidAddr - } - a := &Inet4Addr{} - copy(a.IP[:], b[4:8]) - return a, nil - case sysAF_INET6: - if len(b) < 28 { - return nil, errInvalidAddr - } - a := &Inet6Addr{ZoneID: int(nativeEndian.Uint32(b[24:28]))} - copy(a.IP[:], b[8:24]) - if a.IP[0] == 0xfe && a.IP[1]&0xc0 == 0x80 || a.IP[0] == 0xff && (a.IP[1]&0x0f == 0x01 || a.IP[1]&0x0f == 0x02) { - // KAME based IPv6 protocol stack usually - // embeds the interface index in the - // interface-local or link-local address as - // the kernel-internal form. - id := int(bigEndian.Uint16(a.IP[2:4])) - if id != 0 { - a.ZoneID = id - a.IP[2], a.IP[3] = 0, 0 - } - } - return a, nil - default: - return nil, errInvalidAddr - } -} - -// parseKernelInetAddr parses b as an internet address in conventional -// BSD kernel form. -func parseKernelInetAddr(af int, b []byte) (int, Addr, error) { - // The encoding looks similar to the NLRI encoding. - // +----------------------------+ - // | Length (1 octet) | - // +----------------------------+ - // | Address prefix (variable) | - // +----------------------------+ - // - // The differences between the kernel form and the NLRI - // encoding are: - // - // - The length field of the kernel form indicates the prefix - // length in bytes, not in bits - // - // - In the kernel form, zero value of the length field - // doesn't mean 0.0.0.0/0 or ::/0 - // - // - The kernel form appends leading bytes to the prefix field - // to make the tuple to be conformed with - // the routing message boundary - l := int(b[0]) - if runtime.GOOS == "darwin" { - // On Darwn, an address in the kernel form is also - // used as a message filler. - if l == 0 || len(b) > roundup(l) { - l = roundup(l) - } - } else { - l = roundup(l) - } - if len(b) < l { - return 0, nil, errInvalidAddr - } - // Don't reorder case expressions. - // The case expressions for IPv6 must come first. - const ( - off4 = 4 // offset of in_addr - off6 = 8 // offset of in6_addr - ) - switch { - case b[0] == 28: // size of sockaddr_in6 - a := &Inet6Addr{} - copy(a.IP[:], b[off6:off6+16]) - return int(b[0]), a, nil - case af == sysAF_INET6: - a := &Inet6Addr{} - if l-1 < off6 { - copy(a.IP[:], b[1:l]) - } else { - copy(a.IP[:], b[l-off6:l]) - } - return int(b[0]), a, nil - case b[0] == 16: // size of sockaddr_in - a := &Inet4Addr{} - copy(a.IP[:], b[off4:off4+4]) - return int(b[0]), a, nil - default: // an old fashion, AF_UNSPEC or unknown means AF_INET - a := &Inet4Addr{} - if l-1 < off4 { - copy(a.IP[:], b[1:l]) - } else { - copy(a.IP[:], b[l-off4:l]) - } - return int(b[0]), a, nil - } -} - -// A DefaultAddr represents an address of various operating -// system-specific features. -type DefaultAddr struct { - af int - Raw []byte // raw format of address -} - -// Family implements the Family method of Addr interface. -func (a *DefaultAddr) Family() int { return a.af } - -func parseDefaultAddr(b []byte) (Addr, error) { - if len(b) < 2 || len(b) < int(b[0]) { - return nil, errInvalidAddr - } - a := &DefaultAddr{af: int(b[1]), Raw: b[:b[0]]} - return a, nil -} - -func parseAddrs(attrs uint, fn func(int, []byte) (int, Addr, error), b []byte) ([]Addr, error) { - var as [sysRTAX_MAX]Addr - af := int(sysAF_UNSPEC) - for i := uint(0); i < sysRTAX_MAX && len(b) >= roundup(0); i++ { - if attrs&(1<> 8) -} - -func (binaryLittleEndian) Uint32(b []byte) uint32 { - _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 - return uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 -} - -func (binaryLittleEndian) PutUint32(b []byte, v uint32) { - _ = b[3] // early bounds check to guarantee safety of writes below - b[0] = byte(v) - b[1] = byte(v >> 8) - b[2] = byte(v >> 16) - b[3] = byte(v >> 24) -} - -func (binaryLittleEndian) Uint64(b []byte) uint64 { - _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 - return uint64(b[0]) | uint64(b[1])<<8 | uint64(b[2])<<16 | uint64(b[3])<<24 | - uint64(b[4])<<32 | uint64(b[5])<<40 | uint64(b[6])<<48 | uint64(b[7])<<56 -} - -type binaryBigEndian struct{} - -func (binaryBigEndian) Uint16(b []byte) uint16 { - _ = b[1] // bounds check hint to compiler; see golang.org/issue/14808 - return uint16(b[1]) | uint16(b[0])<<8 -} - -func (binaryBigEndian) PutUint16(b []byte, v uint16) { - _ = b[1] // early bounds check to guarantee safety of writes below - b[0] = byte(v >> 8) - b[1] = byte(v) -} - -func (binaryBigEndian) Uint32(b []byte) uint32 { - _ = b[3] // bounds check hint to compiler; see golang.org/issue/14808 - return uint32(b[3]) | uint32(b[2])<<8 | uint32(b[1])<<16 | uint32(b[0])<<24 -} - -func (binaryBigEndian) PutUint32(b []byte, v uint32) { - _ = b[3] // early bounds check to guarantee safety of writes below - b[0] = byte(v >> 24) - b[1] = byte(v >> 16) - b[2] = byte(v >> 8) - b[3] = byte(v) -} - -func (binaryBigEndian) Uint64(b []byte) uint64 { - _ = b[7] // bounds check hint to compiler; see golang.org/issue/14808 - return uint64(b[7]) | uint64(b[6])<<8 | uint64(b[5])<<16 | uint64(b[4])<<24 | - uint64(b[3])<<32 | uint64(b[2])<<40 | uint64(b[1])<<48 | uint64(b[0])<<56 -} diff --git a/vendor/golang.org/x/net/route/defs_darwin.go b/vendor/golang.org/x/net/route/defs_darwin.go deleted file mode 100644 index f452ad1..0000000 --- a/vendor/golang.org/x/net/route/defs_darwin.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_STAT = C.NET_RT_STAT - sysNET_RT_TRASH = C.NET_RT_TRASH - sysNET_RT_IFLIST2 = C.NET_RT_IFLIST2 - sysNET_RT_DUMP2 = C.NET_RT_DUMP2 - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_OLDADD = C.RTM_OLDADD - sysRTM_OLDDEL = C.RTM_OLDDEL - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_NEWMADDR = C.RTM_NEWMADDR - sysRTM_DELMADDR = C.RTM_DELMADDR - sysRTM_IFINFO2 = C.RTM_IFINFO2 - sysRTM_NEWMADDR2 = C.RTM_NEWMADDR2 - sysRTM_GET2 = C.RTM_GET2 - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrDarwin15 = C.sizeof_struct_if_msghdr - sizeofIfaMsghdrDarwin15 = C.sizeof_struct_ifa_msghdr - sizeofIfmaMsghdrDarwin15 = C.sizeof_struct_ifma_msghdr - sizeofIfMsghdr2Darwin15 = C.sizeof_struct_if_msghdr2 - sizeofIfmaMsghdr2Darwin15 = C.sizeof_struct_ifma_msghdr2 - sizeofIfDataDarwin15 = C.sizeof_struct_if_data - sizeofIfData64Darwin15 = C.sizeof_struct_if_data64 - - sizeofRtMsghdrDarwin15 = C.sizeof_struct_rt_msghdr - sizeofRtMsghdr2Darwin15 = C.sizeof_struct_rt_msghdr2 - sizeofRtMetricsDarwin15 = C.sizeof_struct_rt_metrics -) diff --git a/vendor/golang.org/x/net/route/defs_dragonfly.go b/vendor/golang.org/x/net/route/defs_dragonfly.go deleted file mode 100644 index c737751..0000000 --- a/vendor/golang.org/x/net/route/defs_dragonfly.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_P1003_1B = C.CTL_P1003_1B - sysCTL_LWKT = C.CTL_LWKT - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_OLDADD = C.RTM_OLDADD - sysRTM_OLDDEL = C.RTM_OLDDEL - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_NEWMADDR = C.RTM_NEWMADDR - sysRTM_DELMADDR = C.RTM_DELMADDR - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_IEEE80211 = C.RTM_IEEE80211 - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - sysRTA_MPLS1 = C.RTA_MPLS1 - sysRTA_MPLS2 = C.RTA_MPLS2 - sysRTA_MPLS3 = C.RTA_MPLS3 - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_MPLS1 = C.RTAX_MPLS1 - sysRTAX_MPLS2 = C.RTAX_MPLS2 - sysRTAX_MPLS3 = C.RTAX_MPLS3 - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrDragonFlyBSD4 = C.sizeof_struct_if_msghdr - sizeofIfaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifa_msghdr - sizeofIfmaMsghdrDragonFlyBSD4 = C.sizeof_struct_ifma_msghdr - sizeofIfAnnouncemsghdrDragonFlyBSD4 = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrDragonFlyBSD4 = C.sizeof_struct_rt_msghdr - sizeofRtMetricsDragonFlyBSD4 = C.sizeof_struct_rt_metrics -) diff --git a/vendor/golang.org/x/net/route/defs_freebsd.go b/vendor/golang.org/x/net/route/defs_freebsd.go deleted file mode 100644 index 8f834e8..0000000 --- a/vendor/golang.org/x/net/route/defs_freebsd.go +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include - -struct if_data_freebsd7 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_spare_char1; - u_char ifi_spare_char2; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - u_long ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd8 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_spare_char1; - u_char ifi_spare_char2; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - u_long ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd9 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_spare_char1; - u_char ifi_spare_char2; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - u_long ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd10 { - u_char ifi_type; - u_char ifi_physical; - u_char ifi_addrlen; - u_char ifi_hdrlen; - u_char ifi_link_state; - u_char ifi_vhid; - u_char ifi_baudrate_pf; - u_char ifi_datalen; - u_long ifi_mtu; - u_long ifi_metric; - u_long ifi_baudrate; - u_long ifi_ipackets; - u_long ifi_ierrors; - u_long ifi_opackets; - u_long ifi_oerrors; - u_long ifi_collisions; - u_long ifi_ibytes; - u_long ifi_obytes; - u_long ifi_imcasts; - u_long ifi_omcasts; - u_long ifi_iqdrops; - u_long ifi_noproto; - uint64_t ifi_hwassist; - time_t __ifi_epoch; - struct timeval __ifi_lastchange; -}; - -struct if_data_freebsd11 { - uint8_t ifi_type; - uint8_t ifi_physical; - uint8_t ifi_addrlen; - uint8_t ifi_hdrlen; - uint8_t ifi_link_state; - uint8_t ifi_vhid; - uint16_t ifi_datalen; - uint32_t ifi_mtu; - uint32_t ifi_metric; - uint64_t ifi_baudrate; - uint64_t ifi_ipackets; - uint64_t ifi_ierrors; - uint64_t ifi_opackets; - uint64_t ifi_oerrors; - uint64_t ifi_collisions; - uint64_t ifi_ibytes; - uint64_t ifi_obytes; - uint64_t ifi_imcasts; - uint64_t ifi_omcasts; - uint64_t ifi_iqdrops; - uint64_t ifi_oqdrops; - uint64_t ifi_noproto; - uint64_t ifi_hwassist; - union { - time_t tt; - uint64_t ph; - } __ifi_epoch; - union { - struct timeval tv; - struct { - uint64_t ph1; - uint64_t ph2; - } ph; - } __ifi_lastchange; -}; - -struct if_msghdr_freebsd7 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd7 ifm_data; -}; - -struct if_msghdr_freebsd8 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd8 ifm_data; -}; - -struct if_msghdr_freebsd9 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd9 ifm_data; -}; - -struct if_msghdr_freebsd10 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd10 ifm_data; -}; - -struct if_msghdr_freebsd11 { - u_short ifm_msglen; - u_char ifm_version; - u_char ifm_type; - int ifm_addrs; - int ifm_flags; - u_short ifm_index; - struct if_data_freebsd11 ifm_data; -}; -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_IFMALIST = C.NET_RT_IFMALIST - sysNET_RT_IFLISTL = C.NET_RT_IFLISTL -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_P1003_1B = C.CTL_P1003_1B -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_NEWMADDR = C.RTM_NEWMADDR - sysRTM_DELMADDR = C.RTM_DELMADDR - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_IEEE80211 = C.RTM_IEEE80211 - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrlFreeBSD10 = C.sizeof_struct_if_msghdrl - sizeofIfaMsghdrFreeBSD10 = C.sizeof_struct_ifa_msghdr - sizeofIfaMsghdrlFreeBSD10 = C.sizeof_struct_ifa_msghdrl - sizeofIfmaMsghdrFreeBSD10 = C.sizeof_struct_ifma_msghdr - sizeofIfAnnouncemsghdrFreeBSD10 = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrFreeBSD10 = C.sizeof_struct_rt_msghdr - sizeofRtMetricsFreeBSD10 = C.sizeof_struct_rt_metrics - - sizeofIfMsghdrFreeBSD7 = C.sizeof_struct_if_msghdr_freebsd7 - sizeofIfMsghdrFreeBSD8 = C.sizeof_struct_if_msghdr_freebsd8 - sizeofIfMsghdrFreeBSD9 = C.sizeof_struct_if_msghdr_freebsd9 - sizeofIfMsghdrFreeBSD10 = C.sizeof_struct_if_msghdr_freebsd10 - sizeofIfMsghdrFreeBSD11 = C.sizeof_struct_if_msghdr_freebsd11 - - sizeofIfDataFreeBSD7 = C.sizeof_struct_if_data_freebsd7 - sizeofIfDataFreeBSD8 = C.sizeof_struct_if_data_freebsd8 - sizeofIfDataFreeBSD9 = C.sizeof_struct_if_data_freebsd9 - sizeofIfDataFreeBSD10 = C.sizeof_struct_if_data_freebsd10 - sizeofIfDataFreeBSD11 = C.sizeof_struct_if_data_freebsd11 - - sizeofIfMsghdrlFreeBSD10Emu = C.sizeof_struct_if_msghdrl - sizeofIfaMsghdrFreeBSD10Emu = C.sizeof_struct_ifa_msghdr - sizeofIfaMsghdrlFreeBSD10Emu = C.sizeof_struct_ifa_msghdrl - sizeofIfmaMsghdrFreeBSD10Emu = C.sizeof_struct_ifma_msghdr - sizeofIfAnnouncemsghdrFreeBSD10Emu = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrFreeBSD10Emu = C.sizeof_struct_rt_msghdr - sizeofRtMetricsFreeBSD10Emu = C.sizeof_struct_rt_metrics - - sizeofIfMsghdrFreeBSD7Emu = C.sizeof_struct_if_msghdr_freebsd7 - sizeofIfMsghdrFreeBSD8Emu = C.sizeof_struct_if_msghdr_freebsd8 - sizeofIfMsghdrFreeBSD9Emu = C.sizeof_struct_if_msghdr_freebsd9 - sizeofIfMsghdrFreeBSD10Emu = C.sizeof_struct_if_msghdr_freebsd10 - sizeofIfMsghdrFreeBSD11Emu = C.sizeof_struct_if_msghdr_freebsd11 - - sizeofIfDataFreeBSD7Emu = C.sizeof_struct_if_data_freebsd7 - sizeofIfDataFreeBSD8Emu = C.sizeof_struct_if_data_freebsd8 - sizeofIfDataFreeBSD9Emu = C.sizeof_struct_if_data_freebsd9 - sizeofIfDataFreeBSD10Emu = C.sizeof_struct_if_data_freebsd10 - sizeofIfDataFreeBSD11Emu = C.sizeof_struct_if_data_freebsd11 -) diff --git a/vendor/golang.org/x/net/route/defs_netbsd.go b/vendor/golang.org/x/net/route/defs_netbsd.go deleted file mode 100644 index b18d85e..0000000 --- a/vendor/golang.org/x/net/route/defs_netbsd.go +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_VFS = C.CTL_VFS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_USER = C.CTL_USER - sysCTL_DDB = C.CTL_DDB - sysCTL_PROC = C.CTL_PROC - sysCTL_VENDOR = C.CTL_VENDOR - sysCTL_EMUL = C.CTL_EMUL - sysCTL_SECURITY = C.CTL_SECURITY - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_OLDADD = C.RTM_OLDADD - sysRTM_OLDDEL = C.RTM_OLDDEL - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_IEEE80211 = C.RTM_IEEE80211 - sysRTM_SETGATE = C.RTM_SETGATE - sysRTM_LLINFO_UPD = C.RTM_LLINFO_UPD - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_CHGADDR = C.RTM_CHGADDR - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - sysRTA_TAG = C.RTA_TAG - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_TAG = C.RTAX_TAG - sysRTAX_MAX = C.RTAX_MAX -) - -const ( - sizeofIfMsghdrNetBSD7 = C.sizeof_struct_if_msghdr - sizeofIfaMsghdrNetBSD7 = C.sizeof_struct_ifa_msghdr - sizeofIfAnnouncemsghdrNetBSD7 = C.sizeof_struct_if_announcemsghdr - - sizeofRtMsghdrNetBSD7 = C.sizeof_struct_rt_msghdr - sizeofRtMetricsNetBSD7 = C.sizeof_struct_rt_metrics -) diff --git a/vendor/golang.org/x/net/route/defs_openbsd.go b/vendor/golang.org/x/net/route/defs_openbsd.go deleted file mode 100644 index 5df7a43..0000000 --- a/vendor/golang.org/x/net/route/defs_openbsd.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -package route - -/* -#include -#include - -#include -#include -#include -*/ -import "C" - -const ( - sysAF_UNSPEC = C.AF_UNSPEC - sysAF_INET = C.AF_INET - sysAF_ROUTE = C.AF_ROUTE - sysAF_LINK = C.AF_LINK - sysAF_INET6 = C.AF_INET6 - - sysNET_RT_DUMP = C.NET_RT_DUMP - sysNET_RT_FLAGS = C.NET_RT_FLAGS - sysNET_RT_IFLIST = C.NET_RT_IFLIST - sysNET_RT_STATS = C.NET_RT_STATS - sysNET_RT_TABLE = C.NET_RT_TABLE - sysNET_RT_IFNAMES = C.NET_RT_IFNAMES - sysNET_RT_MAXID = C.NET_RT_MAXID -) - -const ( - sysCTL_MAXNAME = C.CTL_MAXNAME - - sysCTL_UNSPEC = C.CTL_UNSPEC - sysCTL_KERN = C.CTL_KERN - sysCTL_VM = C.CTL_VM - sysCTL_FS = C.CTL_FS - sysCTL_NET = C.CTL_NET - sysCTL_DEBUG = C.CTL_DEBUG - sysCTL_HW = C.CTL_HW - sysCTL_MACHDEP = C.CTL_MACHDEP - sysCTL_DDB = C.CTL_DDB - sysCTL_VFS = C.CTL_VFS - sysCTL_MAXID = C.CTL_MAXID -) - -const ( - sysRTM_VERSION = C.RTM_VERSION - - sysRTM_ADD = C.RTM_ADD - sysRTM_DELETE = C.RTM_DELETE - sysRTM_CHANGE = C.RTM_CHANGE - sysRTM_GET = C.RTM_GET - sysRTM_LOSING = C.RTM_LOSING - sysRTM_REDIRECT = C.RTM_REDIRECT - sysRTM_MISS = C.RTM_MISS - sysRTM_LOCK = C.RTM_LOCK - sysRTM_RESOLVE = C.RTM_RESOLVE - sysRTM_NEWADDR = C.RTM_NEWADDR - sysRTM_DELADDR = C.RTM_DELADDR - sysRTM_IFINFO = C.RTM_IFINFO - sysRTM_IFANNOUNCE = C.RTM_IFANNOUNCE - sysRTM_DESYNC = C.RTM_DESYNC - - sysRTA_DST = C.RTA_DST - sysRTA_GATEWAY = C.RTA_GATEWAY - sysRTA_NETMASK = C.RTA_NETMASK - sysRTA_GENMASK = C.RTA_GENMASK - sysRTA_IFP = C.RTA_IFP - sysRTA_IFA = C.RTA_IFA - sysRTA_AUTHOR = C.RTA_AUTHOR - sysRTA_BRD = C.RTA_BRD - sysRTA_SRC = C.RTA_SRC - sysRTA_SRCMASK = C.RTA_SRCMASK - sysRTA_LABEL = C.RTA_LABEL - - sysRTAX_DST = C.RTAX_DST - sysRTAX_GATEWAY = C.RTAX_GATEWAY - sysRTAX_NETMASK = C.RTAX_NETMASK - sysRTAX_GENMASK = C.RTAX_GENMASK - sysRTAX_IFP = C.RTAX_IFP - sysRTAX_IFA = C.RTAX_IFA - sysRTAX_AUTHOR = C.RTAX_AUTHOR - sysRTAX_BRD = C.RTAX_BRD - sysRTAX_SRC = C.RTAX_SRC - sysRTAX_SRCMASK = C.RTAX_SRCMASK - sysRTAX_LABEL = C.RTAX_LABEL - sysRTAX_MAX = C.RTAX_MAX -) diff --git a/vendor/golang.org/x/net/route/interface.go b/vendor/golang.org/x/net/route/interface.go deleted file mode 100644 index 854906d..0000000 --- a/vendor/golang.org/x/net/route/interface.go +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -// An InterfaceMessage represents an interface message. -type InterfaceMessage struct { - Version int // message version - Type int // message type - Flags int // interface flags - Index int // interface index - Name string // interface name - Addrs []Addr // addresses - - extOff int // offset of header extension - raw []byte // raw message -} - -// An InterfaceAddrMessage represents an interface address message. -type InterfaceAddrMessage struct { - Version int // message version - Type int // message type - Flags int // interface flags - Index int // interface index - Addrs []Addr // addresses - - raw []byte // raw message -} - -// Sys implements the Sys method of Message interface. -func (m *InterfaceAddrMessage) Sys() []Sys { return nil } - -// An InterfaceMulticastAddrMessage represents an interface multicast -// address message. -type InterfaceMulticastAddrMessage struct { - Version int // message version - Type int // messsage type - Flags int // interface flags - Index int // interface index - Addrs []Addr // addresses - - raw []byte // raw message -} - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMulticastAddrMessage) Sys() []Sys { return nil } - -// An InterfaceAnnounceMessage represents an interface announcement -// message. -type InterfaceAnnounceMessage struct { - Version int // message version - Type int // message type - Index int // interface index - Name string // interface name - What int // what type of announcement - - raw []byte // raw message -} - -// Sys implements the Sys method of Message interface. -func (m *InterfaceAnnounceMessage) Sys() []Sys { return nil } diff --git a/vendor/golang.org/x/net/route/interface_announce.go b/vendor/golang.org/x/net/route/interface_announce.go deleted file mode 100644 index 520d657..0000000 --- a/vendor/golang.org/x/net/route/interface_announce.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build dragonfly freebsd netbsd - -package route - -func (w *wireFormat) parseInterfaceAnnounceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAnnounceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Index: int(nativeEndian.Uint16(b[4:6])), - What: int(nativeEndian.Uint16(b[22:24])), - raw: b[:l], - } - for i := 0; i < 16; i++ { - if b[6+i] != 0 { - continue - } - m.Name = string(b[6 : 6+i]) - break - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_classic.go b/vendor/golang.org/x/net/route/interface_classic.go deleted file mode 100644 index ac4e7a6..0000000 --- a/vendor/golang.org/x/net/route/interface_classic.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly netbsd - -package route - -import "runtime" - -func (w *wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - attrs := uint(nativeEndian.Uint32(b[4:8])) - if attrs&sysRTA_IFP == 0 { - return nil, nil - } - m := &InterfaceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Addrs: make([]Addr, sysRTAX_MAX), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - extOff: w.extOff, - raw: b[:l], - } - a, err := parseLinkAddr(b[w.bodyOff:]) - if err != nil { - return nil, err - } - m.Addrs[sysRTAX_IFP] = a - m.Name = a.(*LinkAddr).Name - return m, nil -} - -func (w *wireFormat) parseInterfaceAddrMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - raw: b[:l], - } - if runtime.GOOS == "netbsd" { - m.Index = int(nativeEndian.Uint16(b[16:18])) - } else { - m.Index = int(nativeEndian.Uint16(b[12:14])) - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_freebsd.go b/vendor/golang.org/x/net/route/interface_freebsd.go deleted file mode 100644 index c830539..0000000 --- a/vendor/golang.org/x/net/route/interface_freebsd.go +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (w *wireFormat) parseInterfaceMessage(typ RIBType, b []byte) (Message, error) { - var extOff, bodyOff int - if typ == sysNET_RT_IFLISTL { - if len(b) < 20 { - return nil, errMessageTooShort - } - extOff = int(nativeEndian.Uint16(b[18:20])) - bodyOff = int(nativeEndian.Uint16(b[16:18])) - } else { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - extOff = w.extOff - bodyOff = w.bodyOff - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - attrs := uint(nativeEndian.Uint32(b[4:8])) - if attrs&sysRTA_IFP == 0 { - return nil, nil - } - m := &InterfaceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - Addrs: make([]Addr, sysRTAX_MAX), - extOff: extOff, - raw: b[:l], - } - a, err := parseLinkAddr(b[bodyOff:]) - if err != nil { - return nil, err - } - m.Addrs[sysRTAX_IFP] = a - m.Name = a.(*LinkAddr).Name - return m, nil -} - -func (w *wireFormat) parseInterfaceAddrMessage(typ RIBType, b []byte) (Message, error) { - var bodyOff int - if typ == sysNET_RT_IFLISTL { - if len(b) < 24 { - return nil, errMessageTooShort - } - bodyOff = int(nativeEndian.Uint16(b[16:18])) - } else { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - bodyOff = w.bodyOff - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - raw: b[:l], - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_multicast.go b/vendor/golang.org/x/net/route/interface_multicast.go deleted file mode 100644 index 1e99a9c..0000000 --- a/vendor/golang.org/x/net/route/interface_multicast.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd - -package route - -func (w *wireFormat) parseInterfaceMulticastAddrMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceMulticastAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[12:14])), - raw: b[:l], - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[4:8])), parseKernelInetAddr, b[w.bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/interface_openbsd.go b/vendor/golang.org/x/net/route/interface_openbsd.go deleted file mode 100644 index 24451d8..0000000 --- a/vendor/golang.org/x/net/route/interface_openbsd.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (*wireFormat) parseInterfaceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < 32 { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - attrs := uint(nativeEndian.Uint32(b[12:16])) - if attrs&sysRTA_IFP == 0 { - return nil, nil - } - m := &InterfaceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[16:20])), - Index: int(nativeEndian.Uint16(b[6:8])), - Addrs: make([]Addr, sysRTAX_MAX), - raw: b[:l], - } - a, err := parseLinkAddr(b[int(nativeEndian.Uint16(b[4:6])):]) - if err != nil { - return nil, err - } - m.Addrs[sysRTAX_IFP] = a - m.Name = a.(*LinkAddr).Name - return m, nil -} - -func (*wireFormat) parseInterfaceAddrMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < 24 { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - bodyOff := int(nativeEndian.Uint16(b[4:6])) - m := &InterfaceAddrMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[12:16])), - Index: int(nativeEndian.Uint16(b[6:8])), - raw: b[:l], - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} - -func (*wireFormat) parseInterfaceAnnounceMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < 26 { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &InterfaceAnnounceMessage{ - Version: int(b[2]), - Type: int(b[3]), - Index: int(nativeEndian.Uint16(b[6:8])), - What: int(nativeEndian.Uint16(b[8:10])), - raw: b[:l], - } - for i := 0; i < 16; i++ { - if b[10+i] != 0 { - continue - } - m.Name = string(b[10 : 10+i]) - break - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/message.go b/vendor/golang.org/x/net/route/message.go deleted file mode 100644 index 27cbf6b..0000000 --- a/vendor/golang.org/x/net/route/message.go +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -// A Message represents a routing message. -// -// Note: This interface will be changed to support Marshal method in -// future version. -type Message interface { - // Sys returns operating system-specific information. - Sys() []Sys -} - -// A Sys reprensents operating system-specific information. -type Sys interface { - // SysType returns a type of operating system-specific - // information. - SysType() SysType -} - -// A SysType represents a type of operating system-specific -// information. -type SysType int - -const ( - SysMetrics SysType = iota - SysStats -) - -// ParseRIB parses b as a routing information base and returns a list -// of routing messages. -func ParseRIB(typ RIBType, b []byte) ([]Message, error) { - if !typ.parseable() { - return nil, errUnsupportedMessage - } - var msgs []Message - nmsgs, nskips := 0, 0 - for len(b) > 4 { - nmsgs++ - l := int(nativeEndian.Uint16(b[:2])) - if b[2] != sysRTM_VERSION { - b = b[l:] - continue - } - mtyp := int(b[3]) - if fn, ok := parseFns[mtyp]; !ok { - nskips++ - } else { - m, err := fn(typ, b) - if err != nil { - return nil, err - } - if m == nil { - nskips++ - } else { - msgs = append(msgs, m) - } - } - b = b[l:] - } - // We failed to parse any of the messages - version mismatch? - if nmsgs != len(msgs)+nskips { - return nil, errMessageMismatch - } - return msgs, nil -} diff --git a/vendor/golang.org/x/net/route/message_darwin_test.go b/vendor/golang.org/x/net/route/message_darwin_test.go deleted file mode 100644 index 3fdd12d..0000000 --- a/vendor/golang.org/x/net/route/message_darwin_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import "testing" - -func TestFetchAndParseRIBOnDarwin(t *testing.T) { - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - for _, typ := range []RIBType{sysNET_RT_FLAGS, sysNET_RT_DUMP2, sysNET_RT_IFLIST2} { - ms, err := fetchAndParseRIB(af, typ) - if err != nil { - t.Error(err) - continue - } - ss, err := msgs(ms).validate() - if err != nil { - t.Errorf("%v %d %v", addrFamily(af), typ, err) - continue - } - for _, s := range ss { - t.Log(s) - } - } - } -} diff --git a/vendor/golang.org/x/net/route/message_freebsd_test.go b/vendor/golang.org/x/net/route/message_freebsd_test.go deleted file mode 100644 index 785c273..0000000 --- a/vendor/golang.org/x/net/route/message_freebsd_test.go +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import ( - "testing" - "time" - "unsafe" -) - -func TestFetchAndParseRIBOnFreeBSD(t *testing.T) { - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - for _, typ := range []RIBType{sysNET_RT_IFMALIST} { - ms, err := fetchAndParseRIB(af, typ) - if err != nil { - t.Error(err) - continue - } - ss, err := msgs(ms).validate() - if err != nil { - t.Errorf("%v %d %v", addrFamily(af), typ, err) - continue - } - for _, s := range ss { - t.Log(s) - } - } - } -} - -func TestFetchAndParseRIBOnFreeBSD10AndAbove(t *testing.T) { - if _, err := FetchRIB(sysAF_UNSPEC, sysNET_RT_IFLISTL, 0); err != nil { - t.Skip("NET_RT_IFLISTL not supported") - } - var p uintptr - if kernelAlign != int(unsafe.Sizeof(p)) { - t.Skip("NET_RT_IFLIST vs. NET_RT_IFLISTL doesn't work for 386 emulation on amd64") - } - - var tests = [2]struct { - typ RIBType - b []byte - msgs []Message - ss []string - }{ - {typ: sysNET_RT_IFLIST}, - {typ: sysNET_RT_IFLISTL}, - } - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - var lastErr error - for i := 0; i < 3; i++ { - for j := range tests { - var err error - if tests[j].b, err = FetchRIB(af, tests[j].typ, 0); err != nil { - lastErr = err - time.Sleep(10 * time.Millisecond) - } - } - if lastErr == nil { - break - } - } - if lastErr != nil { - t.Error(af, lastErr) - continue - } - for i := range tests { - var err error - if tests[i].msgs, err = ParseRIB(tests[i].typ, tests[i].b); err != nil { - lastErr = err - t.Error(af, err) - } - } - if lastErr != nil { - continue - } - for i := range tests { - var err error - tests[i].ss, err = msgs(tests[i].msgs).validate() - if err != nil { - lastErr = err - t.Error(af, err) - } - for _, s := range tests[i].ss { - t.Log(s) - } - } - if lastErr != nil { - continue - } - for i := len(tests) - 1; i > 0; i-- { - if len(tests[i].ss) != len(tests[i-1].ss) { - t.Errorf("got %v; want %v", tests[i].ss, tests[i-1].ss) - continue - } - for j, s1 := range tests[i].ss { - s0 := tests[i-1].ss[j] - if s1 != s0 { - t.Errorf("got %s; want %s", s1, s0) - } - } - } - } -} diff --git a/vendor/golang.org/x/net/route/message_test.go b/vendor/golang.org/x/net/route/message_test.go deleted file mode 100644 index a1263d8..0000000 --- a/vendor/golang.org/x/net/route/message_test.go +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import ( - "os" - "syscall" - "testing" - "time" -) - -func TestFetchAndParseRIB(t *testing.T) { - for _, af := range []int{sysAF_UNSPEC, sysAF_INET, sysAF_INET6} { - for _, typ := range []RIBType{sysNET_RT_DUMP, sysNET_RT_IFLIST} { - ms, err := fetchAndParseRIB(af, typ) - if err != nil { - t.Error(err) - continue - } - ss, err := msgs(ms).validate() - if err != nil { - t.Errorf("%v %d %v", addrFamily(af), typ, err) - continue - } - for _, s := range ss { - t.Log(s) - } - } - } -} - -func TestMonitorAndParseRIB(t *testing.T) { - if testing.Short() || os.Getuid() != 0 { - t.Skip("must be root") - } - - // We suppose that using an IPv4 link-local address and the - // dot1Q ID for Token Ring and FDDI doesn't harm anyone. - pv := &propVirtual{addr: "169.254.0.1", mask: "255.255.255.0"} - if err := pv.configure(1002); err != nil { - t.Skip(err) - } - if err := pv.setup(); err != nil { - t.Skip(err) - } - pv.teardown() - - s, err := syscall.Socket(syscall.AF_ROUTE, syscall.SOCK_RAW, syscall.AF_UNSPEC) - if err != nil { - t.Fatal(err) - } - defer syscall.Close(s) - - go func() { - b := make([]byte, os.Getpagesize()) - for { - n, err := syscall.Read(s, b) - if err != nil { - return - } - ms, err := ParseRIB(0, b[:n]) - if err != nil { - t.Error(err) - return - } - ss, err := msgs(ms).validate() - if err != nil { - t.Error(err) - return - } - for _, s := range ss { - t.Log(s) - } - } - }() - - for _, vid := range []int{1002, 1003, 1004, 1005} { - pv := &propVirtual{addr: "169.254.0.1", mask: "255.255.255.0"} - if err := pv.configure(vid); err != nil { - t.Fatal(err) - } - if err := pv.setup(); err != nil { - t.Fatal(err) - } - time.Sleep(200 * time.Millisecond) - if err := pv.teardown(); err != nil { - t.Fatal(err) - } - time.Sleep(200 * time.Millisecond) - } -} diff --git a/vendor/golang.org/x/net/route/route.go b/vendor/golang.org/x/net/route/route.go deleted file mode 100644 index c986e29..0000000 --- a/vendor/golang.org/x/net/route/route.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -// Package route provides basic functions for the manipulation of -// packet routing facilities on BSD variants. -// -// The package supports any version of Darwin, any version of -// DragonFly BSD, FreeBSD 7 through 11, NetBSD 6 and above, and -// OpenBSD 5.6 and above. -package route - -import ( - "errors" - "os" - "syscall" -) - -var ( - errUnsupportedMessage = errors.New("unsupported message") - errMessageMismatch = errors.New("message mismatch") - errMessageTooShort = errors.New("message too short") - errInvalidMessage = errors.New("invalid message") - errInvalidAddr = errors.New("invalid address") -) - -// A RouteMessage represents a message conveying an address prefix, a -// nexthop address and an output interface. -type RouteMessage struct { - Version int // message version - Type int // message type - Flags int // route flags - Index int // interface index when atatched - Addrs []Addr // addresses - - extOff int // offset of header extension - raw []byte // raw message -} - -// A RIBType reprensents a type of routing information base. -type RIBType int - -const ( - RIBTypeRoute RIBType = syscall.NET_RT_DUMP - RIBTypeInterface RIBType = syscall.NET_RT_IFLIST -) - -// FetchRIB fetches a routing information base from the operating -// system. -// -// The provided af must be an address family. -// -// The provided arg must be a RIBType-specific argument. -// When RIBType is related to routes, arg might be a set of route -// flags. When RIBType is related to network interfaces, arg might be -// an interface index or a set of interface flags. In most cases, zero -// means a wildcard. -func FetchRIB(af int, typ RIBType, arg int) ([]byte, error) { - mib := [6]int32{sysCTL_NET, sysAF_ROUTE, 0, int32(af), int32(typ), int32(arg)} - n := uintptr(0) - if err := sysctl(mib[:], nil, &n, nil, 0); err != nil { - return nil, os.NewSyscallError("sysctl", err) - } - if n == 0 { - return nil, nil - } - b := make([]byte, n) - if err := sysctl(mib[:], &b[0], &n, nil, 0); err != nil { - return nil, os.NewSyscallError("sysctl", err) - } - return b[:n], nil -} diff --git a/vendor/golang.org/x/net/route/route_classic.go b/vendor/golang.org/x/net/route/route_classic.go deleted file mode 100644 index d333c6a..0000000 --- a/vendor/golang.org/x/net/route/route_classic.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd - -package route - -func (w *wireFormat) parseRouteMessage(typ RIBType, b []byte) (Message, error) { - if len(b) < w.bodyOff { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &RouteMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[8:12])), - Index: int(nativeEndian.Uint16(b[4:6])), - extOff: w.extOff, - raw: b[:l], - } - var err error - m.Addrs, err = parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[w.bodyOff:]) - if err != nil { - return nil, err - } - return m, nil -} diff --git a/vendor/golang.org/x/net/route/route_openbsd.go b/vendor/golang.org/x/net/route/route_openbsd.go deleted file mode 100644 index b07862f..0000000 --- a/vendor/golang.org/x/net/route/route_openbsd.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (*wireFormat) parseRouteMessage(_ RIBType, b []byte) (Message, error) { - if len(b) < 40 { - return nil, errMessageTooShort - } - l := int(nativeEndian.Uint16(b[:2])) - if len(b) < l { - return nil, errInvalidMessage - } - m := &RouteMessage{ - Version: int(b[2]), - Type: int(b[3]), - Flags: int(nativeEndian.Uint32(b[16:20])), - Index: int(nativeEndian.Uint16(b[6:8])), - raw: b[:l], - } - as, err := parseAddrs(uint(nativeEndian.Uint32(b[12:16])), parseKernelInetAddr, b[int(nativeEndian.Uint16(b[4:6])):]) - if err != nil { - return nil, err - } - m.Addrs = as - return m, nil -} diff --git a/vendor/golang.org/x/net/route/route_test.go b/vendor/golang.org/x/net/route/route_test.go deleted file mode 100644 index 99f57b7..0000000 --- a/vendor/golang.org/x/net/route/route_test.go +++ /dev/null @@ -1,385 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import ( - "fmt" - "os/exec" - "runtime" - "time" -) - -func (m *RouteMessage) String() string { - return fmt.Sprintf("%s", addrAttrs(nativeEndian.Uint32(m.raw[12:16]))) -} - -func (m *InterfaceMessage) String() string { - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - return fmt.Sprintf("%s", attrs) -} - -func (m *InterfaceAddrMessage) String() string { - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - return fmt.Sprintf("%s", attrs) -} - -func (m *InterfaceMulticastAddrMessage) String() string { - return fmt.Sprintf("%s", addrAttrs(nativeEndian.Uint32(m.raw[4:8]))) -} - -func (m *InterfaceAnnounceMessage) String() string { - what := "" - switch m.What { - case 0: - what = "arrival" - case 1: - what = "departure" - } - return fmt.Sprintf("(%d %s %s)", m.Index, m.Name, what) -} - -func (m *InterfaceMetrics) String() string { - return fmt.Sprintf("(type=%d mtu=%d)", m.Type, m.MTU) -} - -func (m *RouteMetrics) String() string { - return fmt.Sprintf("(pmtu=%d)", m.PathMTU) -} - -type addrAttrs uint - -var addrAttrNames = [...]string{ - "dst", - "gateway", - "netmask", - "genmask", - "ifp", - "ifa", - "author", - "brd", - "df:mpls1-n:tag-o:src", // mpls1 for dragonfly, tag for netbsd, src for openbsd - "df:mpls2-o:srcmask", // mpls2 for dragonfly, srcmask for openbsd - "df:mpls3-o:label", // mpls3 for dragonfly, label for openbsd -} - -func (attrs addrAttrs) String() string { - var s string - for i, name := range addrAttrNames { - if attrs&(1<" - } - return s -} - -type msgs []Message - -func (ms msgs) validate() ([]string, error) { - var ss []string - for _, m := range ms { - switch m := m.(type) { - case *RouteMessage: - if err := addrs(m.Addrs).match(addrAttrs(nativeEndian.Uint32(m.raw[12:16]))); err != nil { - return nil, err - } - sys := m.Sys() - if sys == nil { - return nil, fmt.Errorf("no sys for %s", m.String()) - } - ss = append(ss, m.String()+" "+syss(sys).String()+" "+addrs(m.Addrs).String()) - case *InterfaceMessage: - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - if err := addrs(m.Addrs).match(attrs); err != nil { - return nil, err - } - sys := m.Sys() - if sys == nil { - return nil, fmt.Errorf("no sys for %s", m.String()) - } - ss = append(ss, m.String()+" "+syss(sys).String()+" "+addrs(m.Addrs).String()) - case *InterfaceAddrMessage: - var attrs addrAttrs - if runtime.GOOS == "openbsd" { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[12:16])) - } else { - attrs = addrAttrs(nativeEndian.Uint32(m.raw[4:8])) - } - if err := addrs(m.Addrs).match(attrs); err != nil { - return nil, err - } - ss = append(ss, m.String()+" "+addrs(m.Addrs).String()) - case *InterfaceMulticastAddrMessage: - if err := addrs(m.Addrs).match(addrAttrs(nativeEndian.Uint32(m.raw[4:8]))); err != nil { - return nil, err - } - ss = append(ss, m.String()+" "+addrs(m.Addrs).String()) - case *InterfaceAnnounceMessage: - ss = append(ss, m.String()) - default: - ss = append(ss, fmt.Sprintf("%+v", m)) - } - } - return ss, nil -} - -type syss []Sys - -func (sys syss) String() string { - var s string - for _, sy := range sys { - switch sy := sy.(type) { - case *InterfaceMetrics: - if len(s) > 0 { - s += " " - } - s += sy.String() - case *RouteMetrics: - if len(s) > 0 { - s += " " - } - s += sy.String() - } - } - return s -} - -type addrFamily int - -func (af addrFamily) String() string { - switch af { - case sysAF_UNSPEC: - return "unspec" - case sysAF_LINK: - return "link" - case sysAF_INET: - return "inet4" - case sysAF_INET6: - return "inet6" - default: - return fmt.Sprintf("%d", af) - } -} - -const hexDigit = "0123456789abcdef" - -type llAddr []byte - -func (a llAddr) String() string { - if len(a) == 0 { - return "" - } - buf := make([]byte, 0, len(a)*3-1) - for i, b := range a { - if i > 0 { - buf = append(buf, ':') - } - buf = append(buf, hexDigit[b>>4]) - buf = append(buf, hexDigit[b&0xF]) - } - return string(buf) -} - -type ipAddr []byte - -func (a ipAddr) String() string { - if len(a) == 0 { - return "" - } - if len(a) == 4 { - return fmt.Sprintf("%d.%d.%d.%d", a[0], a[1], a[2], a[3]) - } - if len(a) == 16 { - return fmt.Sprintf("%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8], a[9], a[10], a[11], a[12], a[13], a[14], a[15]) - } - s := make([]byte, len(a)*2) - for i, tn := range a { - s[i*2], s[i*2+1] = hexDigit[tn>>4], hexDigit[tn&0xf] - } - return string(s) -} - -func (a *LinkAddr) String() string { - name := a.Name - if name == "" { - name = "" - } - lla := llAddr(a.Addr).String() - if lla == "" { - lla = "" - } - return fmt.Sprintf("(%v %d %s %s)", addrFamily(a.Family()), a.Index, name, lla) -} - -func (a Inet4Addr) String() string { - return fmt.Sprintf("(%v %v)", addrFamily(a.Family()), ipAddr(a.IP[:])) -} - -func (a *Inet6Addr) String() string { - return fmt.Sprintf("(%v %v %d)", addrFamily(a.Family()), ipAddr(a.IP[:]), a.ZoneID) -} - -func (a *DefaultAddr) String() string { - return fmt.Sprintf("(%v %s)", addrFamily(a.Family()), ipAddr(a.Raw[2:]).String()) -} - -type addrs []Addr - -func (as addrs) String() string { - var s string - for _, a := range as { - if a == nil { - continue - } - if len(s) > 0 { - s += " " - } - switch a := a.(type) { - case *LinkAddr: - s += a.String() - case *Inet4Addr: - s += a.String() - case *Inet6Addr: - s += a.String() - case *DefaultAddr: - s += a.String() - } - } - if s == "" { - return "" - } - return s -} - -func (as addrs) match(attrs addrAttrs) error { - var ts addrAttrs - af := sysAF_UNSPEC - for i := range as { - if as[i] != nil { - ts |= 1 << uint(i) - } - switch as[i].(type) { - case *Inet4Addr: - if af == sysAF_UNSPEC { - af = sysAF_INET - } - if af != sysAF_INET { - return fmt.Errorf("got %v; want %v", addrs(as), addrFamily(af)) - } - case *Inet6Addr: - if af == sysAF_UNSPEC { - af = sysAF_INET6 - } - if af != sysAF_INET6 { - return fmt.Errorf("got %v; want %v", addrs(as), addrFamily(af)) - } - } - } - if ts != attrs && ts > attrs { - return fmt.Errorf("%v not included in %v", ts, attrs) - } - return nil -} - -func fetchAndParseRIB(af int, typ RIBType) ([]Message, error) { - var err error - var b []byte - for i := 0; i < 3; i++ { - if b, err = FetchRIB(af, typ, 0); err != nil { - time.Sleep(10 * time.Millisecond) - continue - } - break - } - if err != nil { - return nil, fmt.Errorf("%v %d %v", addrFamily(af), typ, err) - } - ms, err := ParseRIB(typ, b) - if err != nil { - return nil, fmt.Errorf("%v %d %v", addrFamily(af), typ, err) - } - return ms, nil -} - -type propVirtual struct { - name string - addr, mask string - setupCmds []*exec.Cmd - teardownCmds []*exec.Cmd -} - -func (ti *propVirtual) setup() error { - for _, cmd := range ti.setupCmds { - if err := cmd.Run(); err != nil { - ti.teardown() - return err - } - } - return nil -} - -func (ti *propVirtual) teardown() error { - for _, cmd := range ti.teardownCmds { - if err := cmd.Run(); err != nil { - return err - } - } - return nil -} - -func (ti *propVirtual) configure(suffix int) error { - if runtime.GOOS == "openbsd" { - ti.name = fmt.Sprintf("vether%d", suffix) - } else { - ti.name = fmt.Sprintf("vlan%d", suffix) - } - xname, err := exec.LookPath("ifconfig") - if err != nil { - return err - } - ti.setupCmds = append(ti.setupCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", ti.name, "create"}, - }) - if runtime.GOOS == "netbsd" { - // NetBSD requires an underlying dot1Q-capable network - // interface. - ti.setupCmds = append(ti.setupCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", ti.name, "vlan", fmt.Sprintf("%d", suffix&0xfff), "vlanif", "wm0"}, - }) - } - ti.setupCmds = append(ti.setupCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", ti.name, "inet", ti.addr, "netmask", ti.mask}, - }) - ti.teardownCmds = append(ti.teardownCmds, &exec.Cmd{ - Path: xname, - Args: []string{"ifconfig", ti.name, "destroy"}, - }) - return nil -} diff --git a/vendor/golang.org/x/net/route/sys.go b/vendor/golang.org/x/net/route/sys.go deleted file mode 100644 index 80ca83a..0000000 --- a/vendor/golang.org/x/net/route/sys.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import "unsafe" - -var ( - nativeEndian binaryByteOrder - kernelAlign int - parseFns map[int]parseFn -) - -func init() { - i := uint32(1) - b := (*[4]byte)(unsafe.Pointer(&i)) - if b[0] == 1 { - nativeEndian = littleEndian - } else { - nativeEndian = bigEndian - } - kernelAlign, parseFns = probeRoutingStack() -} - -func roundup(l int) int { - if l == 0 { - return kernelAlign - } - return (l + kernelAlign - 1) & ^(kernelAlign - 1) -} - -type parseFn func(RIBType, []byte) (Message, error) - -type wireFormat struct { - extOff int // offset of header extension - bodyOff int // offset of message body -} diff --git a/vendor/golang.org/x/net/route/sys_darwin.go b/vendor/golang.org/x/net/route/sys_darwin.go deleted file mode 100644 index fff3a0f..0000000 --- a/vendor/golang.org/x/net/route/sys_darwin.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (typ RIBType) parseable() bool { - switch typ { - case sysNET_RT_STAT, sysNET_RT_TRASH: - return false - default: - return true - } -} - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint32(m.raw[m.extOff+4 : m.extOff+8])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]parseFn) { - rtm := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdrDarwin15} - rtm2 := &wireFormat{extOff: 36, bodyOff: sizeofRtMsghdr2Darwin15} - ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDarwin15} - ifm2 := &wireFormat{extOff: 32, bodyOff: sizeofIfMsghdr2Darwin15} - ifam := &wireFormat{extOff: sizeofIfaMsghdrDarwin15, bodyOff: sizeofIfaMsghdrDarwin15} - ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDarwin15, bodyOff: sizeofIfmaMsghdrDarwin15} - ifmam2 := &wireFormat{extOff: sizeofIfmaMsghdr2Darwin15, bodyOff: sizeofIfmaMsghdr2Darwin15} - // Darwin kernels require 32-bit aligned access to routing facilities. - return 4, map[int]parseFn{ - sysRTM_ADD: rtm.parseRouteMessage, - sysRTM_DELETE: rtm.parseRouteMessage, - sysRTM_CHANGE: rtm.parseRouteMessage, - sysRTM_GET: rtm.parseRouteMessage, - sysRTM_LOSING: rtm.parseRouteMessage, - sysRTM_REDIRECT: rtm.parseRouteMessage, - sysRTM_MISS: rtm.parseRouteMessage, - sysRTM_LOCK: rtm.parseRouteMessage, - sysRTM_RESOLVE: rtm.parseRouteMessage, - sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage, - sysRTM_DELADDR: ifam.parseInterfaceAddrMessage, - sysRTM_IFINFO: ifm.parseInterfaceMessage, - sysRTM_NEWMADDR: ifmam.parseInterfaceMulticastAddrMessage, - sysRTM_DELMADDR: ifmam.parseInterfaceMulticastAddrMessage, - sysRTM_IFINFO2: ifm2.parseInterfaceMessage, - sysRTM_NEWMADDR2: ifmam2.parseInterfaceMulticastAddrMessage, - sysRTM_GET2: rtm2.parseRouteMessage, - } -} diff --git a/vendor/golang.org/x/net/route/sys_dragonfly.go b/vendor/golang.org/x/net/route/sys_dragonfly.go deleted file mode 100644 index da848b3..0000000 --- a/vendor/golang.org/x/net/route/sys_dragonfly.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import "unsafe" - -func (typ RIBType) parseable() bool { return true } - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]parseFn) { - var p uintptr - rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrDragonFlyBSD4} - ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrDragonFlyBSD4} - ifam := &wireFormat{extOff: sizeofIfaMsghdrDragonFlyBSD4, bodyOff: sizeofIfaMsghdrDragonFlyBSD4} - ifmam := &wireFormat{extOff: sizeofIfmaMsghdrDragonFlyBSD4, bodyOff: sizeofIfmaMsghdrDragonFlyBSD4} - ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrDragonFlyBSD4, bodyOff: sizeofIfAnnouncemsghdrDragonFlyBSD4} - return int(unsafe.Sizeof(p)), map[int]parseFn{ - sysRTM_ADD: rtm.parseRouteMessage, - sysRTM_DELETE: rtm.parseRouteMessage, - sysRTM_CHANGE: rtm.parseRouteMessage, - sysRTM_GET: rtm.parseRouteMessage, - sysRTM_LOSING: rtm.parseRouteMessage, - sysRTM_REDIRECT: rtm.parseRouteMessage, - sysRTM_MISS: rtm.parseRouteMessage, - sysRTM_LOCK: rtm.parseRouteMessage, - sysRTM_RESOLVE: rtm.parseRouteMessage, - sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage, - sysRTM_DELADDR: ifam.parseInterfaceAddrMessage, - sysRTM_IFINFO: ifm.parseInterfaceMessage, - sysRTM_NEWMADDR: ifmam.parseInterfaceMulticastAddrMessage, - sysRTM_DELMADDR: ifmam.parseInterfaceMulticastAddrMessage, - sysRTM_IFANNOUNCE: ifanm.parseInterfaceAnnounceMessage, - } -} diff --git a/vendor/golang.org/x/net/route/sys_freebsd.go b/vendor/golang.org/x/net/route/sys_freebsd.go deleted file mode 100644 index 7b05c1a..0000000 --- a/vendor/golang.org/x/net/route/sys_freebsd.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import ( - "syscall" - "unsafe" -) - -func (typ RIBType) parseable() bool { return true } - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - if kernelAlign == 8 { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])), - }, - } - } - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint32(m.raw[m.extOff+4 : m.extOff+8])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]parseFn) { - var p uintptr - wordSize := int(unsafe.Sizeof(p)) - align := int(unsafe.Sizeof(p)) - // In the case of kern.supported_archs="amd64 i386", we need - // to know the underlying kernel's architecture because the - // alignment for routing facilities are set at the build time - // of the kernel. - conf, _ := syscall.Sysctl("kern.conftxt") - for i, j := 0, 0; j < len(conf); j++ { - if conf[j] != '\n' { - continue - } - s := conf[i:j] - i = j + 1 - if len(s) > len("machine") && s[:len("machine")] == "machine" { - s = s[len("machine"):] - for k := 0; k < len(s); k++ { - if s[k] == ' ' || s[k] == '\t' { - s = s[1:] - } - break - } - if s == "amd64" { - align = 8 - } - break - } - } - var rtm, ifm, ifam, ifmam, ifanm *wireFormat - if align != wordSize { // 386 emulation on amd64 - rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10Emu - sizeofRtMetricsFreeBSD10Emu, bodyOff: sizeofRtMsghdrFreeBSD10Emu} - ifm = &wireFormat{extOff: 16} - ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10Emu, bodyOff: sizeofIfaMsghdrFreeBSD10Emu} - ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10Emu, bodyOff: sizeofIfmaMsghdrFreeBSD10Emu} - ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10Emu, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10Emu} - } else { - rtm = &wireFormat{extOff: sizeofRtMsghdrFreeBSD10 - sizeofRtMetricsFreeBSD10, bodyOff: sizeofRtMsghdrFreeBSD10} - ifm = &wireFormat{extOff: 16} - ifam = &wireFormat{extOff: sizeofIfaMsghdrFreeBSD10, bodyOff: sizeofIfaMsghdrFreeBSD10} - ifmam = &wireFormat{extOff: sizeofIfmaMsghdrFreeBSD10, bodyOff: sizeofIfmaMsghdrFreeBSD10} - ifanm = &wireFormat{extOff: sizeofIfAnnouncemsghdrFreeBSD10, bodyOff: sizeofIfAnnouncemsghdrFreeBSD10} - } - rel, _ := syscall.SysctlUint32("kern.osreldate") - switch { - case rel < 800000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD7Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD7 - } - case 800000 <= rel && rel < 900000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD8Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD8 - } - case 900000 <= rel && rel < 1000000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD9Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD9 - } - case 1000000 <= rel && rel < 1100000: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD10Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD10 - } - default: - if align != wordSize { // 386 emulation on amd64 - ifm.bodyOff = sizeofIfMsghdrFreeBSD11Emu - } else { - ifm.bodyOff = sizeofIfMsghdrFreeBSD11 - } - } - return align, map[int]parseFn{ - sysRTM_ADD: rtm.parseRouteMessage, - sysRTM_DELETE: rtm.parseRouteMessage, - sysRTM_CHANGE: rtm.parseRouteMessage, - sysRTM_GET: rtm.parseRouteMessage, - sysRTM_LOSING: rtm.parseRouteMessage, - sysRTM_REDIRECT: rtm.parseRouteMessage, - sysRTM_MISS: rtm.parseRouteMessage, - sysRTM_LOCK: rtm.parseRouteMessage, - sysRTM_RESOLVE: rtm.parseRouteMessage, - sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage, - sysRTM_DELADDR: ifam.parseInterfaceAddrMessage, - sysRTM_IFINFO: ifm.parseInterfaceMessage, - sysRTM_NEWMADDR: ifmam.parseInterfaceMulticastAddrMessage, - sysRTM_DELMADDR: ifmam.parseInterfaceMulticastAddrMessage, - sysRTM_IFANNOUNCE: ifanm.parseInterfaceAnnounceMessage, - } -} diff --git a/vendor/golang.org/x/net/route/sys_netbsd.go b/vendor/golang.org/x/net/route/sys_netbsd.go deleted file mode 100644 index 4d8076b..0000000 --- a/vendor/golang.org/x/net/route/sys_netbsd.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -func (typ RIBType) parseable() bool { return true } - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint64(m.raw[m.extOff+8 : m.extOff+16])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[m.extOff]), - MTU: int(nativeEndian.Uint32(m.raw[m.extOff+8 : m.extOff+12])), - }, - } -} - -func probeRoutingStack() (int, map[int]parseFn) { - rtm := &wireFormat{extOff: 40, bodyOff: sizeofRtMsghdrNetBSD7} - ifm := &wireFormat{extOff: 16, bodyOff: sizeofIfMsghdrNetBSD7} - ifam := &wireFormat{extOff: sizeofIfaMsghdrNetBSD7, bodyOff: sizeofIfaMsghdrNetBSD7} - ifanm := &wireFormat{extOff: sizeofIfAnnouncemsghdrNetBSD7, bodyOff: sizeofIfAnnouncemsghdrNetBSD7} - // NetBSD 6 and above kernels require 64-bit aligned access to - // routing facilities. - return 8, map[int]parseFn{ - sysRTM_ADD: rtm.parseRouteMessage, - sysRTM_DELETE: rtm.parseRouteMessage, - sysRTM_CHANGE: rtm.parseRouteMessage, - sysRTM_GET: rtm.parseRouteMessage, - sysRTM_LOSING: rtm.parseRouteMessage, - sysRTM_REDIRECT: rtm.parseRouteMessage, - sysRTM_MISS: rtm.parseRouteMessage, - sysRTM_LOCK: rtm.parseRouteMessage, - sysRTM_RESOLVE: rtm.parseRouteMessage, - sysRTM_NEWADDR: ifam.parseInterfaceAddrMessage, - sysRTM_DELADDR: ifam.parseInterfaceAddrMessage, - sysRTM_IFANNOUNCE: ifanm.parseInterfaceAnnounceMessage, - sysRTM_IFINFO: ifm.parseInterfaceMessage, - } -} diff --git a/vendor/golang.org/x/net/route/sys_openbsd.go b/vendor/golang.org/x/net/route/sys_openbsd.go deleted file mode 100644 index 26d0438..0000000 --- a/vendor/golang.org/x/net/route/sys_openbsd.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package route - -import "unsafe" - -func (typ RIBType) parseable() bool { - switch typ { - case sysNET_RT_STATS, sysNET_RT_TABLE: - return false - default: - return true - } -} - -// A RouteMetrics represents route metrics. -type RouteMetrics struct { - PathMTU int // path maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (rmx *RouteMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *RouteMessage) Sys() []Sys { - return []Sys{ - &RouteMetrics{ - PathMTU: int(nativeEndian.Uint32(m.raw[60:64])), - }, - } -} - -// A InterfaceMetrics represents interface metrics. -type InterfaceMetrics struct { - Type int // interface type - MTU int // maximum transmission unit -} - -// SysType implements the SysType method of Sys interface. -func (imx *InterfaceMetrics) SysType() SysType { return SysMetrics } - -// Sys implements the Sys method of Message interface. -func (m *InterfaceMessage) Sys() []Sys { - return []Sys{ - &InterfaceMetrics{ - Type: int(m.raw[24]), - MTU: int(nativeEndian.Uint32(m.raw[28:32])), - }, - } -} - -func probeRoutingStack() (int, map[int]parseFn) { - var p uintptr - nooff := &wireFormat{extOff: -1, bodyOff: -1} - return int(unsafe.Sizeof(p)), map[int]parseFn{ - sysRTM_ADD: nooff.parseRouteMessage, - sysRTM_DELETE: nooff.parseRouteMessage, - sysRTM_CHANGE: nooff.parseRouteMessage, - sysRTM_GET: nooff.parseRouteMessage, - sysRTM_LOSING: nooff.parseRouteMessage, - sysRTM_REDIRECT: nooff.parseRouteMessage, - sysRTM_MISS: nooff.parseRouteMessage, - sysRTM_LOCK: nooff.parseRouteMessage, - sysRTM_RESOLVE: nooff.parseRouteMessage, - sysRTM_NEWADDR: nooff.parseInterfaceAddrMessage, - sysRTM_DELADDR: nooff.parseInterfaceAddrMessage, - sysRTM_IFINFO: nooff.parseInterfaceMessage, - sysRTM_IFANNOUNCE: nooff.parseInterfaceAnnounceMessage, - } -} diff --git a/vendor/golang.org/x/net/route/syscall.go b/vendor/golang.org/x/net/route/syscall.go deleted file mode 100644 index d136325..0000000 --- a/vendor/golang.org/x/net/route/syscall.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build darwin dragonfly freebsd netbsd openbsd - -package route - -import ( - "syscall" - "unsafe" -) - -// TODO: replace with runtime.KeepAlive when available -//go:noescape -func keepAlive(p unsafe.Pointer) - -var zero uintptr - -func sysctl(mib []int32, old *byte, oldlen *uintptr, new *byte, newlen uintptr) error { - var p unsafe.Pointer - if len(mib) > 0 { - p = unsafe.Pointer(&mib[0]) - } else { - p = unsafe.Pointer(&zero) - } - _, _, errno := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(p), uintptr(len(mib)), uintptr(unsafe.Pointer(old)), uintptr(unsafe.Pointer(oldlen)), uintptr(unsafe.Pointer(new)), uintptr(newlen)) - keepAlive(p) - if errno != 0 { - return error(errno) - } - return nil -} diff --git a/vendor/golang.org/x/net/route/syscall.s b/vendor/golang.org/x/net/route/syscall.s deleted file mode 100644 index fa6297f..0000000 --- a/vendor/golang.org/x/net/route/syscall.s +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -#include "textflag.h" - -TEXT ·keepAlive(SB),NOSPLIT,$0 - RET diff --git a/vendor/golang.org/x/net/route/zsys_darwin.go b/vendor/golang.org/x/net/route/zsys_darwin.go deleted file mode 100644 index 265b81c..0000000 --- a/vendor/golang.org/x/net/route/zsys_darwin.go +++ /dev/null @@ -1,93 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_darwin.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1e - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_STAT = 0x4 - sysNET_RT_TRASH = 0x5 - sysNET_RT_IFLIST2 = 0x6 - sysNET_RT_DUMP2 = 0x7 - sysNET_RT_MAXID = 0xa -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_MAXID = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_OLDADD = 0x9 - sysRTM_OLDDEL = 0xa - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFINFO2 = 0x12 - sysRTM_NEWMADDR2 = 0x13 - sysRTM_GET2 = 0x14 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrDarwin15 = 0x70 - sizeofIfaMsghdrDarwin15 = 0x14 - sizeofIfmaMsghdrDarwin15 = 0x10 - sizeofIfMsghdr2Darwin15 = 0xa0 - sizeofIfmaMsghdr2Darwin15 = 0x14 - sizeofIfDataDarwin15 = 0x60 - sizeofIfData64Darwin15 = 0x80 - - sizeofRtMsghdrDarwin15 = 0x5c - sizeofRtMsghdr2Darwin15 = 0x5c - sizeofRtMetricsDarwin15 = 0x38 -) diff --git a/vendor/golang.org/x/net/route/zsys_dragonfly.go b/vendor/golang.org/x/net/route/zsys_dragonfly.go deleted file mode 100644 index dd36dec..0000000 --- a/vendor/golang.org/x/net/route/zsys_dragonfly.go +++ /dev/null @@ -1,92 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_dragonfly.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_MAXID = 0x4 -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 - sysCTL_LWKT = 0xa - sysCTL_MAXID = 0xb -) - -const ( - sysRTM_VERSION = 0x6 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_OLDADD = 0x9 - sysRTM_OLDDEL = 0xa - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - sysRTA_MPLS1 = 0x100 - sysRTA_MPLS2 = 0x200 - sysRTA_MPLS3 = 0x400 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MPLS1 = 0x8 - sysRTAX_MPLS2 = 0x9 - sysRTAX_MPLS3 = 0xa - sysRTAX_MAX = 0xb -) - -const ( - sizeofIfMsghdrDragonFlyBSD4 = 0xb0 - sizeofIfaMsghdrDragonFlyBSD4 = 0x14 - sizeofIfmaMsghdrDragonFlyBSD4 = 0x10 - sizeofIfAnnouncemsghdrDragonFlyBSD4 = 0x18 - - sizeofRtMsghdrDragonFlyBSD4 = 0x98 - sizeofRtMetricsDragonFlyBSD4 = 0x70 -) diff --git a/vendor/golang.org/x/net/route/zsys_freebsd_386.go b/vendor/golang.org/x/net/route/zsys_freebsd_386.go deleted file mode 100644 index 9bac2e3..0000000 --- a/vendor/golang.org/x/net/route/zsys_freebsd_386.go +++ /dev/null @@ -1,120 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_IFMALIST = 0x4 - sysNET_RT_IFLISTL = 0x5 -) - -const ( - sysCTL_MAXNAME = 0x18 - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrlFreeBSD10 = 0x68 - sizeofIfaMsghdrFreeBSD10 = 0x14 - sizeofIfaMsghdrlFreeBSD10 = 0x6c - sizeofIfmaMsghdrFreeBSD10 = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10 = 0x18 - - sizeofRtMsghdrFreeBSD10 = 0x5c - sizeofRtMetricsFreeBSD10 = 0x38 - - sizeofIfMsghdrFreeBSD7 = 0x60 - sizeofIfMsghdrFreeBSD8 = 0x60 - sizeofIfMsghdrFreeBSD9 = 0x60 - sizeofIfMsghdrFreeBSD10 = 0x64 - sizeofIfMsghdrFreeBSD11 = 0xa8 - - sizeofIfDataFreeBSD7 = 0x50 - sizeofIfDataFreeBSD8 = 0x50 - sizeofIfDataFreeBSD9 = 0x50 - sizeofIfDataFreeBSD10 = 0x54 - sizeofIfDataFreeBSD11 = 0x98 - - // MODIFIED BY HAND FOR 386 EMULATION ON AMD64 - // 386 EMULATION USES THE UNDERLYING RAW DATA LAYOUT - - sizeofIfMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfaMsghdrFreeBSD10Emu = 0x14 - sizeofIfaMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfmaMsghdrFreeBSD10Emu = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18 - - sizeofRtMsghdrFreeBSD10Emu = 0x98 - sizeofRtMetricsFreeBSD10Emu = 0x70 - - sizeofIfMsghdrFreeBSD7Emu = 0xa8 - sizeofIfMsghdrFreeBSD8Emu = 0xa8 - sizeofIfMsghdrFreeBSD9Emu = 0xa8 - sizeofIfMsghdrFreeBSD10Emu = 0xa8 - sizeofIfMsghdrFreeBSD11Emu = 0xa8 - - sizeofIfDataFreeBSD7Emu = 0x98 - sizeofIfDataFreeBSD8Emu = 0x98 - sizeofIfDataFreeBSD9Emu = 0x98 - sizeofIfDataFreeBSD10Emu = 0x98 - sizeofIfDataFreeBSD11Emu = 0x98 -) diff --git a/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go b/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go deleted file mode 100644 index b1920d7..0000000 --- a/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go +++ /dev/null @@ -1,117 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_IFMALIST = 0x4 - sysNET_RT_IFLISTL = 0x5 -) - -const ( - sysCTL_MAXNAME = 0x18 - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrlFreeBSD10 = 0xb0 - sizeofIfaMsghdrFreeBSD10 = 0x14 - sizeofIfaMsghdrlFreeBSD10 = 0xb0 - sizeofIfmaMsghdrFreeBSD10 = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10 = 0x18 - - sizeofRtMsghdrFreeBSD10 = 0x98 - sizeofRtMetricsFreeBSD10 = 0x70 - - sizeofIfMsghdrFreeBSD7 = 0xa8 - sizeofIfMsghdrFreeBSD8 = 0xa8 - sizeofIfMsghdrFreeBSD9 = 0xa8 - sizeofIfMsghdrFreeBSD10 = 0xa8 - sizeofIfMsghdrFreeBSD11 = 0xa8 - - sizeofIfDataFreeBSD7 = 0x98 - sizeofIfDataFreeBSD8 = 0x98 - sizeofIfDataFreeBSD9 = 0x98 - sizeofIfDataFreeBSD10 = 0x98 - sizeofIfDataFreeBSD11 = 0x98 - - sizeofIfMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfaMsghdrFreeBSD10Emu = 0x14 - sizeofIfaMsghdrlFreeBSD10Emu = 0xb0 - sizeofIfmaMsghdrFreeBSD10Emu = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18 - - sizeofRtMsghdrFreeBSD10Emu = 0x98 - sizeofRtMetricsFreeBSD10Emu = 0x70 - - sizeofIfMsghdrFreeBSD7Emu = 0xa8 - sizeofIfMsghdrFreeBSD8Emu = 0xa8 - sizeofIfMsghdrFreeBSD9Emu = 0xa8 - sizeofIfMsghdrFreeBSD10Emu = 0xa8 - sizeofIfMsghdrFreeBSD11Emu = 0xa8 - - sizeofIfDataFreeBSD7Emu = 0x98 - sizeofIfDataFreeBSD8Emu = 0x98 - sizeofIfDataFreeBSD9Emu = 0x98 - sizeofIfDataFreeBSD10Emu = 0x98 - sizeofIfDataFreeBSD11Emu = 0x98 -) diff --git a/vendor/golang.org/x/net/route/zsys_freebsd_arm.go b/vendor/golang.org/x/net/route/zsys_freebsd_arm.go deleted file mode 100644 index a034d6f..0000000 --- a/vendor/golang.org/x/net/route/zsys_freebsd_arm.go +++ /dev/null @@ -1,117 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_freebsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x1c - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_IFMALIST = 0x4 - sysNET_RT_IFLISTL = 0x5 -) - -const ( - sysCTL_MAXNAME = 0x18 - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_P1003_1B = 0x9 -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_NEWMADDR = 0xf - sysRTM_DELMADDR = 0x10 - sysRTM_IFANNOUNCE = 0x11 - sysRTM_IEEE80211 = 0x12 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_MAX = 0x8 -) - -const ( - sizeofIfMsghdrlFreeBSD10 = 0x68 - sizeofIfaMsghdrFreeBSD10 = 0x14 - sizeofIfaMsghdrlFreeBSD10 = 0x6c - sizeofIfmaMsghdrFreeBSD10 = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10 = 0x18 - - sizeofRtMsghdrFreeBSD10 = 0x5c - sizeofRtMetricsFreeBSD10 = 0x38 - - sizeofIfMsghdrFreeBSD7 = 0x70 - sizeofIfMsghdrFreeBSD8 = 0x70 - sizeofIfMsghdrFreeBSD9 = 0x70 - sizeofIfMsghdrFreeBSD10 = 0x70 - sizeofIfMsghdrFreeBSD11 = 0xa8 - - sizeofIfDataFreeBSD7 = 0x60 - sizeofIfDataFreeBSD8 = 0x60 - sizeofIfDataFreeBSD9 = 0x60 - sizeofIfDataFreeBSD10 = 0x60 - sizeofIfDataFreeBSD11 = 0x98 - - sizeofIfMsghdrlFreeBSD10Emu = 0x68 - sizeofIfaMsghdrFreeBSD10Emu = 0x14 - sizeofIfaMsghdrlFreeBSD10Emu = 0x6c - sizeofIfmaMsghdrFreeBSD10Emu = 0x10 - sizeofIfAnnouncemsghdrFreeBSD10Emu = 0x18 - - sizeofRtMsghdrFreeBSD10Emu = 0x5c - sizeofRtMetricsFreeBSD10Emu = 0x38 - - sizeofIfMsghdrFreeBSD7Emu = 0x70 - sizeofIfMsghdrFreeBSD8Emu = 0x70 - sizeofIfMsghdrFreeBSD9Emu = 0x70 - sizeofIfMsghdrFreeBSD10Emu = 0x70 - sizeofIfMsghdrFreeBSD11Emu = 0xa8 - - sizeofIfDataFreeBSD7Emu = 0x60 - sizeofIfDataFreeBSD8Emu = 0x60 - sizeofIfDataFreeBSD9Emu = 0x60 - sizeofIfDataFreeBSD10Emu = 0x60 - sizeofIfDataFreeBSD11Emu = 0x98 -) diff --git a/vendor/golang.org/x/net/route/zsys_netbsd.go b/vendor/golang.org/x/net/route/zsys_netbsd.go deleted file mode 100644 index aa4aad1..0000000 --- a/vendor/golang.org/x/net/route/zsys_netbsd.go +++ /dev/null @@ -1,91 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_netbsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x22 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x18 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x5 - sysNET_RT_MAXID = 0x6 -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_VFS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_USER = 0x8 - sysCTL_DDB = 0x9 - sysCTL_PROC = 0xa - sysCTL_VENDOR = 0xb - sysCTL_EMUL = 0xc - sysCTL_SECURITY = 0xd - sysCTL_MAXID = 0xe -) - -const ( - sysRTM_VERSION = 0x4 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_OLDADD = 0x9 - sysRTM_OLDDEL = 0xa - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFANNOUNCE = 0x10 - sysRTM_IEEE80211 = 0x11 - sysRTM_SETGATE = 0x12 - sysRTM_LLINFO_UPD = 0x13 - sysRTM_IFINFO = 0x14 - sysRTM_CHGADDR = 0x15 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - sysRTA_TAG = 0x100 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_TAG = 0x8 - sysRTAX_MAX = 0x9 -) - -const ( - sizeofIfMsghdrNetBSD7 = 0x98 - sizeofIfaMsghdrNetBSD7 = 0x18 - sizeofIfAnnouncemsghdrNetBSD7 = 0x18 - - sizeofRtMsghdrNetBSD7 = 0x78 - sizeofRtMetricsNetBSD7 = 0x50 -) diff --git a/vendor/golang.org/x/net/route/zsys_openbsd.go b/vendor/golang.org/x/net/route/zsys_openbsd.go deleted file mode 100644 index 4fadc4e..0000000 --- a/vendor/golang.org/x/net/route/zsys_openbsd.go +++ /dev/null @@ -1,80 +0,0 @@ -// Created by cgo -godefs - DO NOT EDIT -// cgo -godefs defs_openbsd.go - -package route - -const ( - sysAF_UNSPEC = 0x0 - sysAF_INET = 0x2 - sysAF_ROUTE = 0x11 - sysAF_LINK = 0x12 - sysAF_INET6 = 0x18 - - sysNET_RT_DUMP = 0x1 - sysNET_RT_FLAGS = 0x2 - sysNET_RT_IFLIST = 0x3 - sysNET_RT_STATS = 0x4 - sysNET_RT_TABLE = 0x5 - sysNET_RT_IFNAMES = 0x6 - sysNET_RT_MAXID = 0x7 -) - -const ( - sysCTL_MAXNAME = 0xc - - sysCTL_UNSPEC = 0x0 - sysCTL_KERN = 0x1 - sysCTL_VM = 0x2 - sysCTL_FS = 0x3 - sysCTL_NET = 0x4 - sysCTL_DEBUG = 0x5 - sysCTL_HW = 0x6 - sysCTL_MACHDEP = 0x7 - sysCTL_DDB = 0x9 - sysCTL_VFS = 0xa - sysCTL_MAXID = 0xb -) - -const ( - sysRTM_VERSION = 0x5 - - sysRTM_ADD = 0x1 - sysRTM_DELETE = 0x2 - sysRTM_CHANGE = 0x3 - sysRTM_GET = 0x4 - sysRTM_LOSING = 0x5 - sysRTM_REDIRECT = 0x6 - sysRTM_MISS = 0x7 - sysRTM_LOCK = 0x8 - sysRTM_RESOLVE = 0xb - sysRTM_NEWADDR = 0xc - sysRTM_DELADDR = 0xd - sysRTM_IFINFO = 0xe - sysRTM_IFANNOUNCE = 0xf - sysRTM_DESYNC = 0x10 - - sysRTA_DST = 0x1 - sysRTA_GATEWAY = 0x2 - sysRTA_NETMASK = 0x4 - sysRTA_GENMASK = 0x8 - sysRTA_IFP = 0x10 - sysRTA_IFA = 0x20 - sysRTA_AUTHOR = 0x40 - sysRTA_BRD = 0x80 - sysRTA_SRC = 0x100 - sysRTA_SRCMASK = 0x200 - sysRTA_LABEL = 0x400 - - sysRTAX_DST = 0x0 - sysRTAX_GATEWAY = 0x1 - sysRTAX_NETMASK = 0x2 - sysRTAX_GENMASK = 0x3 - sysRTAX_IFP = 0x4 - sysRTAX_IFA = 0x5 - sysRTAX_AUTHOR = 0x6 - sysRTAX_BRD = 0x7 - sysRTAX_SRC = 0x8 - sysRTAX_SRCMASK = 0x9 - sysRTAX_LABEL = 0xa - sysRTAX_MAX = 0xb -) diff --git a/vendor/golang.org/x/net/trace/events.go b/vendor/golang.org/x/net/trace/events.go deleted file mode 100644 index e66c7e3..0000000 --- a/vendor/golang.org/x/net/trace/events.go +++ /dev/null @@ -1,524 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package trace - -import ( - "bytes" - "fmt" - "html/template" - "io" - "log" - "net/http" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "sync/atomic" - "text/tabwriter" - "time" -) - -var eventsTmpl = template.Must(template.New("events").Funcs(template.FuncMap{ - "elapsed": elapsed, - "trimSpace": strings.TrimSpace, -}).Parse(eventsHTML)) - -const maxEventsPerLog = 100 - -type bucket struct { - MaxErrAge time.Duration - String string -} - -var buckets = []bucket{ - {0, "total"}, - {10 * time.Second, "errs<10s"}, - {1 * time.Minute, "errs<1m"}, - {10 * time.Minute, "errs<10m"}, - {1 * time.Hour, "errs<1h"}, - {10 * time.Hour, "errs<10h"}, - {24000 * time.Hour, "errors"}, -} - -// RenderEvents renders the HTML page typically served at /debug/events. -// It does not do any auth checking; see AuthRequest for the default auth check -// used by the handler registered on http.DefaultServeMux. -// req may be nil. -func RenderEvents(w http.ResponseWriter, req *http.Request, sensitive bool) { - now := time.Now() - data := &struct { - Families []string // family names - Buckets []bucket - Counts [][]int // eventLog count per family/bucket - - // Set when a bucket has been selected. - Family string - Bucket int - EventLogs eventLogs - Expanded bool - }{ - Buckets: buckets, - } - - data.Families = make([]string, 0, len(families)) - famMu.RLock() - for name := range families { - data.Families = append(data.Families, name) - } - famMu.RUnlock() - sort.Strings(data.Families) - - // Count the number of eventLogs in each family for each error age. - data.Counts = make([][]int, len(data.Families)) - for i, name := range data.Families { - // TODO(sameer): move this loop under the family lock. - f := getEventFamily(name) - data.Counts[i] = make([]int, len(data.Buckets)) - for j, b := range data.Buckets { - data.Counts[i][j] = f.Count(now, b.MaxErrAge) - } - } - - if req != nil { - var ok bool - data.Family, data.Bucket, ok = parseEventsArgs(req) - if !ok { - // No-op - } else { - data.EventLogs = getEventFamily(data.Family).Copy(now, buckets[data.Bucket].MaxErrAge) - } - if data.EventLogs != nil { - defer data.EventLogs.Free() - sort.Sort(data.EventLogs) - } - if exp, err := strconv.ParseBool(req.FormValue("exp")); err == nil { - data.Expanded = exp - } - } - - famMu.RLock() - defer famMu.RUnlock() - if err := eventsTmpl.Execute(w, data); err != nil { - log.Printf("net/trace: Failed executing template: %v", err) - } -} - -func parseEventsArgs(req *http.Request) (fam string, b int, ok bool) { - fam, bStr := req.FormValue("fam"), req.FormValue("b") - if fam == "" || bStr == "" { - return "", 0, false - } - b, err := strconv.Atoi(bStr) - if err != nil || b < 0 || b >= len(buckets) { - return "", 0, false - } - return fam, b, true -} - -// An EventLog provides a log of events associated with a specific object. -type EventLog interface { - // Printf formats its arguments with fmt.Sprintf and adds the - // result to the event log. - Printf(format string, a ...interface{}) - - // Errorf is like Printf, but it marks this event as an error. - Errorf(format string, a ...interface{}) - - // Finish declares that this event log is complete. - // The event log should not be used after calling this method. - Finish() -} - -// NewEventLog returns a new EventLog with the specified family name -// and title. -func NewEventLog(family, title string) EventLog { - el := newEventLog() - el.ref() - el.Family, el.Title = family, title - el.Start = time.Now() - el.events = make([]logEntry, 0, maxEventsPerLog) - el.stack = make([]uintptr, 32) - n := runtime.Callers(2, el.stack) - el.stack = el.stack[:n] - - getEventFamily(family).add(el) - return el -} - -func (el *eventLog) Finish() { - getEventFamily(el.Family).remove(el) - el.unref() // matches ref in New -} - -var ( - famMu sync.RWMutex - families = make(map[string]*eventFamily) // family name => family -) - -func getEventFamily(fam string) *eventFamily { - famMu.Lock() - defer famMu.Unlock() - f := families[fam] - if f == nil { - f = &eventFamily{} - families[fam] = f - } - return f -} - -type eventFamily struct { - mu sync.RWMutex - eventLogs eventLogs -} - -func (f *eventFamily) add(el *eventLog) { - f.mu.Lock() - f.eventLogs = append(f.eventLogs, el) - f.mu.Unlock() -} - -func (f *eventFamily) remove(el *eventLog) { - f.mu.Lock() - defer f.mu.Unlock() - for i, el0 := range f.eventLogs { - if el == el0 { - copy(f.eventLogs[i:], f.eventLogs[i+1:]) - f.eventLogs = f.eventLogs[:len(f.eventLogs)-1] - return - } - } -} - -func (f *eventFamily) Count(now time.Time, maxErrAge time.Duration) (n int) { - f.mu.RLock() - defer f.mu.RUnlock() - for _, el := range f.eventLogs { - if el.hasRecentError(now, maxErrAge) { - n++ - } - } - return -} - -func (f *eventFamily) Copy(now time.Time, maxErrAge time.Duration) (els eventLogs) { - f.mu.RLock() - defer f.mu.RUnlock() - els = make(eventLogs, 0, len(f.eventLogs)) - for _, el := range f.eventLogs { - if el.hasRecentError(now, maxErrAge) { - el.ref() - els = append(els, el) - } - } - return -} - -type eventLogs []*eventLog - -// Free calls unref on each element of the list. -func (els eventLogs) Free() { - for _, el := range els { - el.unref() - } -} - -// eventLogs may be sorted in reverse chronological order. -func (els eventLogs) Len() int { return len(els) } -func (els eventLogs) Less(i, j int) bool { return els[i].Start.After(els[j].Start) } -func (els eventLogs) Swap(i, j int) { els[i], els[j] = els[j], els[i] } - -// A logEntry is a timestamped log entry in an event log. -type logEntry struct { - When time.Time - Elapsed time.Duration // since previous event in log - NewDay bool // whether this event is on a different day to the previous event - What string - IsErr bool -} - -// WhenString returns a string representation of the elapsed time of the event. -// It will include the date if midnight was crossed. -func (e logEntry) WhenString() string { - if e.NewDay { - return e.When.Format("2006/01/02 15:04:05.000000") - } - return e.When.Format("15:04:05.000000") -} - -// An eventLog represents an active event log. -type eventLog struct { - // Family is the top-level grouping of event logs to which this belongs. - Family string - - // Title is the title of this event log. - Title string - - // Timing information. - Start time.Time - - // Call stack where this event log was created. - stack []uintptr - - // Append-only sequence of events. - // - // TODO(sameer): change this to a ring buffer to avoid the array copy - // when we hit maxEventsPerLog. - mu sync.RWMutex - events []logEntry - LastErrorTime time.Time - discarded int - - refs int32 // how many buckets this is in -} - -func (el *eventLog) reset() { - // Clear all but the mutex. Mutexes may not be copied, even when unlocked. - el.Family = "" - el.Title = "" - el.Start = time.Time{} - el.stack = nil - el.events = nil - el.LastErrorTime = time.Time{} - el.discarded = 0 - el.refs = 0 -} - -func (el *eventLog) hasRecentError(now time.Time, maxErrAge time.Duration) bool { - if maxErrAge == 0 { - return true - } - el.mu.RLock() - defer el.mu.RUnlock() - return now.Sub(el.LastErrorTime) < maxErrAge -} - -// delta returns the elapsed time since the last event or the log start, -// and whether it spans midnight. -// L >= el.mu -func (el *eventLog) delta(t time.Time) (time.Duration, bool) { - if len(el.events) == 0 { - return t.Sub(el.Start), false - } - prev := el.events[len(el.events)-1].When - return t.Sub(prev), prev.Day() != t.Day() - -} - -func (el *eventLog) Printf(format string, a ...interface{}) { - el.printf(false, format, a...) -} - -func (el *eventLog) Errorf(format string, a ...interface{}) { - el.printf(true, format, a...) -} - -func (el *eventLog) printf(isErr bool, format string, a ...interface{}) { - e := logEntry{When: time.Now(), IsErr: isErr, What: fmt.Sprintf(format, a...)} - el.mu.Lock() - e.Elapsed, e.NewDay = el.delta(e.When) - if len(el.events) < maxEventsPerLog { - el.events = append(el.events, e) - } else { - // Discard the oldest event. - if el.discarded == 0 { - // el.discarded starts at two to count for the event it - // is replacing, plus the next one that we are about to - // drop. - el.discarded = 2 - } else { - el.discarded++ - } - // TODO(sameer): if this causes allocations on a critical path, - // change eventLog.What to be a fmt.Stringer, as in trace.go. - el.events[0].What = fmt.Sprintf("(%d events discarded)", el.discarded) - // The timestamp of the discarded meta-event should be - // the time of the last event it is representing. - el.events[0].When = el.events[1].When - copy(el.events[1:], el.events[2:]) - el.events[maxEventsPerLog-1] = e - } - if e.IsErr { - el.LastErrorTime = e.When - } - el.mu.Unlock() -} - -func (el *eventLog) ref() { - atomic.AddInt32(&el.refs, 1) -} - -func (el *eventLog) unref() { - if atomic.AddInt32(&el.refs, -1) == 0 { - freeEventLog(el) - } -} - -func (el *eventLog) When() string { - return el.Start.Format("2006/01/02 15:04:05.000000") -} - -func (el *eventLog) ElapsedTime() string { - elapsed := time.Since(el.Start) - return fmt.Sprintf("%.6f", elapsed.Seconds()) -} - -func (el *eventLog) Stack() string { - buf := new(bytes.Buffer) - tw := tabwriter.NewWriter(buf, 1, 8, 1, '\t', 0) - printStackRecord(tw, el.stack) - tw.Flush() - return buf.String() -} - -// printStackRecord prints the function + source line information -// for a single stack trace. -// Adapted from runtime/pprof/pprof.go. -func printStackRecord(w io.Writer, stk []uintptr) { - for _, pc := range stk { - f := runtime.FuncForPC(pc) - if f == nil { - continue - } - file, line := f.FileLine(pc) - name := f.Name() - // Hide runtime.goexit and any runtime functions at the beginning. - if strings.HasPrefix(name, "runtime.") { - continue - } - fmt.Fprintf(w, "# %s\t%s:%d\n", name, file, line) - } -} - -func (el *eventLog) Events() []logEntry { - el.mu.RLock() - defer el.mu.RUnlock() - return el.events -} - -// freeEventLogs is a freelist of *eventLog -var freeEventLogs = make(chan *eventLog, 1000) - -// newEventLog returns a event log ready to use. -func newEventLog() *eventLog { - select { - case el := <-freeEventLogs: - return el - default: - return new(eventLog) - } -} - -// freeEventLog adds el to freeEventLogs if there's room. -// This is non-blocking. -func freeEventLog(el *eventLog) { - el.reset() - select { - case freeEventLogs <- el: - default: - } -} - -const eventsHTML = ` - - - events - - - - -

    /debug/events

    - -
  • - {{range $i, $fam := .Families}} - - - - {{range $j, $bucket := $.Buckets}} - {{$n := index $.Counts $i $j}} - - {{end}} - - {{end}} -
    {{$fam}} - {{if $n}}{{end}} - [{{$n}} {{$bucket.String}}] - {{if $n}}{{end}} -
    - -{{if $.EventLogs}} -


    -

    Family: {{$.Family}}

    - -{{if $.Expanded}}{{end}} -[Summary]{{if $.Expanded}}{{end}} - -{{if not $.Expanded}}{{end}} -[Expanded]{{if not $.Expanded}}{{end}} - - - - {{range $el := $.EventLogs}} - - - - - {{if $.Expanded}} - - - - - - {{range $el.Events}} - - - - - - {{end}} - {{end}} - {{end}} -
    WhenElapsed
    {{$el.When}}{{$el.ElapsedTime}}{{$el.Title}} -
    {{$el.Stack|trimSpace}}
    {{.WhenString}}{{elapsed .Elapsed}}.{{if .IsErr}}E{{else}}.{{end}}. {{.What}}
    -{{end}} - - -` diff --git a/vendor/golang.org/x/net/trace/histogram.go b/vendor/golang.org/x/net/trace/histogram.go deleted file mode 100644 index bb42aa5..0000000 --- a/vendor/golang.org/x/net/trace/histogram.go +++ /dev/null @@ -1,356 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package trace - -// This file implements histogramming for RPC statistics collection. - -import ( - "bytes" - "fmt" - "html/template" - "log" - "math" - - "golang.org/x/net/internal/timeseries" -) - -const ( - bucketCount = 38 -) - -// histogram keeps counts of values in buckets that are spaced -// out in powers of 2: 0-1, 2-3, 4-7... -// histogram implements timeseries.Observable -type histogram struct { - sum int64 // running total of measurements - sumOfSquares float64 // square of running total - buckets []int64 // bucketed values for histogram - value int // holds a single value as an optimization - valueCount int64 // number of values recorded for single value -} - -// AddMeasurement records a value measurement observation to the histogram. -func (h *histogram) addMeasurement(value int64) { - // TODO: assert invariant - h.sum += value - h.sumOfSquares += float64(value) * float64(value) - - bucketIndex := getBucket(value) - - if h.valueCount == 0 || (h.valueCount > 0 && h.value == bucketIndex) { - h.value = bucketIndex - h.valueCount++ - } else { - h.allocateBuckets() - h.buckets[bucketIndex]++ - } -} - -func (h *histogram) allocateBuckets() { - if h.buckets == nil { - h.buckets = make([]int64, bucketCount) - h.buckets[h.value] = h.valueCount - h.value = 0 - h.valueCount = -1 - } -} - -func log2(i int64) int { - n := 0 - for ; i >= 0x100; i >>= 8 { - n += 8 - } - for ; i > 0; i >>= 1 { - n += 1 - } - return n -} - -func getBucket(i int64) (index int) { - index = log2(i) - 1 - if index < 0 { - index = 0 - } - if index >= bucketCount { - index = bucketCount - 1 - } - return -} - -// Total returns the number of recorded observations. -func (h *histogram) total() (total int64) { - if h.valueCount >= 0 { - total = h.valueCount - } - for _, val := range h.buckets { - total += int64(val) - } - return -} - -// Average returns the average value of recorded observations. -func (h *histogram) average() float64 { - t := h.total() - if t == 0 { - return 0 - } - return float64(h.sum) / float64(t) -} - -// Variance returns the variance of recorded observations. -func (h *histogram) variance() float64 { - t := float64(h.total()) - if t == 0 { - return 0 - } - s := float64(h.sum) / t - return h.sumOfSquares/t - s*s -} - -// StandardDeviation returns the standard deviation of recorded observations. -func (h *histogram) standardDeviation() float64 { - return math.Sqrt(h.variance()) -} - -// PercentileBoundary estimates the value that the given fraction of recorded -// observations are less than. -func (h *histogram) percentileBoundary(percentile float64) int64 { - total := h.total() - - // Corner cases (make sure result is strictly less than Total()) - if total == 0 { - return 0 - } else if total == 1 { - return int64(h.average()) - } - - percentOfTotal := round(float64(total) * percentile) - var runningTotal int64 - - for i := range h.buckets { - value := h.buckets[i] - runningTotal += value - if runningTotal == percentOfTotal { - // We hit an exact bucket boundary. If the next bucket has data, it is a - // good estimate of the value. If the bucket is empty, we interpolate the - // midpoint between the next bucket's boundary and the next non-zero - // bucket. If the remaining buckets are all empty, then we use the - // boundary for the next bucket as the estimate. - j := uint8(i + 1) - min := bucketBoundary(j) - if runningTotal < total { - for h.buckets[j] == 0 { - j++ - } - } - max := bucketBoundary(j) - return min + round(float64(max-min)/2) - } else if runningTotal > percentOfTotal { - // The value is in this bucket. Interpolate the value. - delta := runningTotal - percentOfTotal - percentBucket := float64(value-delta) / float64(value) - bucketMin := bucketBoundary(uint8(i)) - nextBucketMin := bucketBoundary(uint8(i + 1)) - bucketSize := nextBucketMin - bucketMin - return bucketMin + round(percentBucket*float64(bucketSize)) - } - } - return bucketBoundary(bucketCount - 1) -} - -// Median returns the estimated median of the observed values. -func (h *histogram) median() int64 { - return h.percentileBoundary(0.5) -} - -// Add adds other to h. -func (h *histogram) Add(other timeseries.Observable) { - o := other.(*histogram) - if o.valueCount == 0 { - // Other histogram is empty - } else if h.valueCount >= 0 && o.valueCount > 0 && h.value == o.value { - // Both have a single bucketed value, aggregate them - h.valueCount += o.valueCount - } else { - // Two different values necessitate buckets in this histogram - h.allocateBuckets() - if o.valueCount >= 0 { - h.buckets[o.value] += o.valueCount - } else { - for i := range h.buckets { - h.buckets[i] += o.buckets[i] - } - } - } - h.sumOfSquares += o.sumOfSquares - h.sum += o.sum -} - -// Clear resets the histogram to an empty state, removing all observed values. -func (h *histogram) Clear() { - h.buckets = nil - h.value = 0 - h.valueCount = 0 - h.sum = 0 - h.sumOfSquares = 0 -} - -// CopyFrom copies from other, which must be a *histogram, into h. -func (h *histogram) CopyFrom(other timeseries.Observable) { - o := other.(*histogram) - if o.valueCount == -1 { - h.allocateBuckets() - copy(h.buckets, o.buckets) - } - h.sum = o.sum - h.sumOfSquares = o.sumOfSquares - h.value = o.value - h.valueCount = o.valueCount -} - -// Multiply scales the histogram by the specified ratio. -func (h *histogram) Multiply(ratio float64) { - if h.valueCount == -1 { - for i := range h.buckets { - h.buckets[i] = int64(float64(h.buckets[i]) * ratio) - } - } else { - h.valueCount = int64(float64(h.valueCount) * ratio) - } - h.sum = int64(float64(h.sum) * ratio) - h.sumOfSquares = h.sumOfSquares * ratio -} - -// New creates a new histogram. -func (h *histogram) New() timeseries.Observable { - r := new(histogram) - r.Clear() - return r -} - -func (h *histogram) String() string { - return fmt.Sprintf("%d, %f, %d, %d, %v", - h.sum, h.sumOfSquares, h.value, h.valueCount, h.buckets) -} - -// round returns the closest int64 to the argument -func round(in float64) int64 { - return int64(math.Floor(in + 0.5)) -} - -// bucketBoundary returns the first value in the bucket. -func bucketBoundary(bucket uint8) int64 { - if bucket == 0 { - return 0 - } - return 1 << bucket -} - -// bucketData holds data about a specific bucket for use in distTmpl. -type bucketData struct { - Lower, Upper int64 - N int64 - Pct, CumulativePct float64 - GraphWidth int -} - -// data holds data about a Distribution for use in distTmpl. -type data struct { - Buckets []*bucketData - Count, Median int64 - Mean, StandardDeviation float64 -} - -// maxHTMLBarWidth is the maximum width of the HTML bar for visualizing buckets. -const maxHTMLBarWidth = 350.0 - -// newData returns data representing h for use in distTmpl. -func (h *histogram) newData() *data { - // Force the allocation of buckets to simplify the rendering implementation - h.allocateBuckets() - // We scale the bars on the right so that the largest bar is - // maxHTMLBarWidth pixels in width. - maxBucket := int64(0) - for _, n := range h.buckets { - if n > maxBucket { - maxBucket = n - } - } - total := h.total() - barsizeMult := maxHTMLBarWidth / float64(maxBucket) - var pctMult float64 - if total == 0 { - pctMult = 1.0 - } else { - pctMult = 100.0 / float64(total) - } - - buckets := make([]*bucketData, len(h.buckets)) - runningTotal := int64(0) - for i, n := range h.buckets { - if n == 0 { - continue - } - runningTotal += n - var upperBound int64 - if i < bucketCount-1 { - upperBound = bucketBoundary(uint8(i + 1)) - } else { - upperBound = math.MaxInt64 - } - buckets[i] = &bucketData{ - Lower: bucketBoundary(uint8(i)), - Upper: upperBound, - N: n, - Pct: float64(n) * pctMult, - CumulativePct: float64(runningTotal) * pctMult, - GraphWidth: int(float64(n) * barsizeMult), - } - } - return &data{ - Buckets: buckets, - Count: total, - Median: h.median(), - Mean: h.average(), - StandardDeviation: h.standardDeviation(), - } -} - -func (h *histogram) html() template.HTML { - buf := new(bytes.Buffer) - if err := distTmpl.Execute(buf, h.newData()); err != nil { - buf.Reset() - log.Printf("net/trace: couldn't execute template: %v", err) - } - return template.HTML(buf.String()) -} - -// Input: data -var distTmpl = template.Must(template.New("distTmpl").Parse(` - - - - - - - -
    Count: {{.Count}}Mean: {{printf "%.0f" .Mean}}StdDev: {{printf "%.0f" .StandardDeviation}}Median: {{.Median}}
    -
    - -{{range $b := .Buckets}} -{{if $b}} - - - - - - - - - -{{end}} -{{end}} -
    [{{.Lower}},{{.Upper}}){{.N}}{{printf "%#.3f" .Pct}}%{{printf "%#.3f" .CumulativePct}}%
    -`)) diff --git a/vendor/golang.org/x/net/trace/histogram_test.go b/vendor/golang.org/x/net/trace/histogram_test.go deleted file mode 100644 index d384b93..0000000 --- a/vendor/golang.org/x/net/trace/histogram_test.go +++ /dev/null @@ -1,325 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package trace - -import ( - "math" - "testing" -) - -type sumTest struct { - value int64 - sum int64 - sumOfSquares float64 - total int64 -} - -var sumTests = []sumTest{ - {100, 100, 10000, 1}, - {50, 150, 12500, 2}, - {50, 200, 15000, 3}, - {50, 250, 17500, 4}, -} - -type bucketingTest struct { - in int64 - log int - bucket int -} - -var bucketingTests = []bucketingTest{ - {0, 0, 0}, - {1, 1, 0}, - {2, 2, 1}, - {3, 2, 1}, - {4, 3, 2}, - {1000, 10, 9}, - {1023, 10, 9}, - {1024, 11, 10}, - {1000000, 20, 19}, -} - -type multiplyTest struct { - in int64 - ratio float64 - expectedSum int64 - expectedTotal int64 - expectedSumOfSquares float64 -} - -var multiplyTests = []multiplyTest{ - {15, 2.5, 37, 2, 562.5}, - {128, 4.6, 758, 13, 77953.9}, -} - -type percentileTest struct { - fraction float64 - expected int64 -} - -var percentileTests = []percentileTest{ - {0.25, 48}, - {0.5, 96}, - {0.6, 109}, - {0.75, 128}, - {0.90, 205}, - {0.95, 230}, - {0.99, 256}, -} - -func TestSum(t *testing.T) { - var h histogram - - for _, test := range sumTests { - h.addMeasurement(test.value) - sum := h.sum - if sum != test.sum { - t.Errorf("h.Sum = %v WANT: %v", sum, test.sum) - } - - sumOfSquares := h.sumOfSquares - if sumOfSquares != test.sumOfSquares { - t.Errorf("h.SumOfSquares = %v WANT: %v", sumOfSquares, test.sumOfSquares) - } - - total := h.total() - if total != test.total { - t.Errorf("h.Total = %v WANT: %v", total, test.total) - } - } -} - -func TestMultiply(t *testing.T) { - var h histogram - for i, test := range multiplyTests { - h.addMeasurement(test.in) - h.Multiply(test.ratio) - if h.sum != test.expectedSum { - t.Errorf("#%v: h.sum = %v WANT: %v", i, h.sum, test.expectedSum) - } - if h.total() != test.expectedTotal { - t.Errorf("#%v: h.total = %v WANT: %v", i, h.total(), test.expectedTotal) - } - if h.sumOfSquares != test.expectedSumOfSquares { - t.Errorf("#%v: h.SumOfSquares = %v WANT: %v", i, test.expectedSumOfSquares, h.sumOfSquares) - } - } -} - -func TestBucketingFunctions(t *testing.T) { - for _, test := range bucketingTests { - log := log2(test.in) - if log != test.log { - t.Errorf("log2 = %v WANT: %v", log, test.log) - } - - bucket := getBucket(test.in) - if bucket != test.bucket { - t.Errorf("getBucket = %v WANT: %v", bucket, test.bucket) - } - } -} - -func TestAverage(t *testing.T) { - a := new(histogram) - average := a.average() - if average != 0 { - t.Errorf("Average of empty histogram was %v WANT: 0", average) - } - - a.addMeasurement(1) - a.addMeasurement(1) - a.addMeasurement(3) - const expected = float64(5) / float64(3) - average = a.average() - - if !isApproximate(average, expected) { - t.Errorf("Average = %g WANT: %v", average, expected) - } -} - -func TestStandardDeviation(t *testing.T) { - a := new(histogram) - add(a, 10, 1<<4) - add(a, 10, 1<<5) - add(a, 10, 1<<6) - stdDev := a.standardDeviation() - const expected = 19.95 - - if !isApproximate(stdDev, expected) { - t.Errorf("StandardDeviation = %v WANT: %v", stdDev, expected) - } - - // No values - a = new(histogram) - stdDev = a.standardDeviation() - - if !isApproximate(stdDev, 0) { - t.Errorf("StandardDeviation = %v WANT: 0", stdDev) - } - - add(a, 1, 1<<4) - if !isApproximate(stdDev, 0) { - t.Errorf("StandardDeviation = %v WANT: 0", stdDev) - } - - add(a, 10, 1<<4) - if !isApproximate(stdDev, 0) { - t.Errorf("StandardDeviation = %v WANT: 0", stdDev) - } -} - -func TestPercentileBoundary(t *testing.T) { - a := new(histogram) - add(a, 5, 1<<4) - add(a, 10, 1<<6) - add(a, 5, 1<<7) - - for _, test := range percentileTests { - percentile := a.percentileBoundary(test.fraction) - if percentile != test.expected { - t.Errorf("h.PercentileBoundary (fraction=%v) = %v WANT: %v", test.fraction, percentile, test.expected) - } - } -} - -func TestCopyFrom(t *testing.T) { - a := histogram{5, 25, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38}, 4, -1} - b := histogram{6, 36, []int64{2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39}, 5, -1} - - a.CopyFrom(&b) - - if a.String() != b.String() { - t.Errorf("a.String = %s WANT: %s", a.String(), b.String()) - } -} - -func TestClear(t *testing.T) { - a := histogram{5, 25, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38}, 4, -1} - - a.Clear() - - expected := "0, 0.000000, 0, 0, []" - if a.String() != expected { - t.Errorf("a.String = %s WANT %s", a.String(), expected) - } -} - -func TestNew(t *testing.T) { - a := histogram{5, 25, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38}, 4, -1} - b := a.New() - - expected := "0, 0.000000, 0, 0, []" - if b.(*histogram).String() != expected { - t.Errorf("b.(*histogram).String = %s WANT: %s", b.(*histogram).String(), expected) - } -} - -func TestAdd(t *testing.T) { - // The tests here depend on the associativity of addMeasurement and Add. - // Add empty observation - a := histogram{5, 25, []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38}, 4, -1} - b := a.New() - - expected := a.String() - a.Add(b) - if a.String() != expected { - t.Errorf("a.String = %s WANT: %s", a.String(), expected) - } - - // Add same bucketed value, no new buckets - c := new(histogram) - d := new(histogram) - e := new(histogram) - c.addMeasurement(12) - d.addMeasurement(11) - e.addMeasurement(12) - e.addMeasurement(11) - c.Add(d) - if c.String() != e.String() { - t.Errorf("c.String = %s WANT: %s", c.String(), e.String()) - } - - // Add bucketed values - f := new(histogram) - g := new(histogram) - h := new(histogram) - f.addMeasurement(4) - f.addMeasurement(12) - f.addMeasurement(100) - g.addMeasurement(18) - g.addMeasurement(36) - g.addMeasurement(255) - h.addMeasurement(4) - h.addMeasurement(12) - h.addMeasurement(100) - h.addMeasurement(18) - h.addMeasurement(36) - h.addMeasurement(255) - f.Add(g) - if f.String() != h.String() { - t.Errorf("f.String = %q WANT: %q", f.String(), h.String()) - } - - // add buckets to no buckets - i := new(histogram) - j := new(histogram) - k := new(histogram) - j.addMeasurement(18) - j.addMeasurement(36) - j.addMeasurement(255) - k.addMeasurement(18) - k.addMeasurement(36) - k.addMeasurement(255) - i.Add(j) - if i.String() != k.String() { - t.Errorf("i.String = %q WANT: %q", i.String(), k.String()) - } - - // add buckets to single value (no overlap) - l := new(histogram) - m := new(histogram) - n := new(histogram) - l.addMeasurement(0) - m.addMeasurement(18) - m.addMeasurement(36) - m.addMeasurement(255) - n.addMeasurement(0) - n.addMeasurement(18) - n.addMeasurement(36) - n.addMeasurement(255) - l.Add(m) - if l.String() != n.String() { - t.Errorf("l.String = %q WANT: %q", l.String(), n.String()) - } - - // mixed order - o := new(histogram) - p := new(histogram) - o.addMeasurement(0) - o.addMeasurement(2) - o.addMeasurement(0) - p.addMeasurement(0) - p.addMeasurement(0) - p.addMeasurement(2) - if o.String() != p.String() { - t.Errorf("o.String = %q WANT: %q", o.String(), p.String()) - } -} - -func add(h *histogram, times int, val int64) { - for i := 0; i < times; i++ { - h.addMeasurement(val) - } -} - -func isApproximate(x, y float64) bool { - return math.Abs(x-y) < 1e-2 -} diff --git a/vendor/golang.org/x/net/trace/trace.go b/vendor/golang.org/x/net/trace/trace.go deleted file mode 100644 index d860fcc..0000000 --- a/vendor/golang.org/x/net/trace/trace.go +++ /dev/null @@ -1,1063 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -/* -Package trace implements tracing of requests and long-lived objects. -It exports HTTP interfaces on /debug/requests and /debug/events. - -A trace.Trace provides tracing for short-lived objects, usually requests. -A request handler might be implemented like this: - - func fooHandler(w http.ResponseWriter, req *http.Request) { - tr := trace.New("mypkg.Foo", req.URL.Path) - defer tr.Finish() - ... - tr.LazyPrintf("some event %q happened", str) - ... - if err := somethingImportant(); err != nil { - tr.LazyPrintf("somethingImportant failed: %v", err) - tr.SetError() - } - } - -The /debug/requests HTTP endpoint organizes the traces by family, -errors, and duration. It also provides histogram of request duration -for each family. - -A trace.EventLog provides tracing for long-lived objects, such as RPC -connections. - - // A Fetcher fetches URL paths for a single domain. - type Fetcher struct { - domain string - events trace.EventLog - } - - func NewFetcher(domain string) *Fetcher { - return &Fetcher{ - domain, - trace.NewEventLog("mypkg.Fetcher", domain), - } - } - - func (f *Fetcher) Fetch(path string) (string, error) { - resp, err := http.Get("http://" + f.domain + "/" + path) - if err != nil { - f.events.Errorf("Get(%q) = %v", path, err) - return "", err - } - f.events.Printf("Get(%q) = %s", path, resp.Status) - ... - } - - func (f *Fetcher) Close() error { - f.events.Finish() - return nil - } - -The /debug/events HTTP endpoint organizes the event logs by family and -by time since the last error. The expanded view displays recent log -entries and the log's call stack. -*/ -package trace // import "golang.org/x/net/trace" - -import ( - "bytes" - "fmt" - "html/template" - "io" - "log" - "net" - "net/http" - "runtime" - "sort" - "strconv" - "sync" - "sync/atomic" - "time" - - "golang.org/x/net/context" - "golang.org/x/net/internal/timeseries" -) - -// DebugUseAfterFinish controls whether to debug uses of Trace values after finishing. -// FOR DEBUGGING ONLY. This will slow down the program. -var DebugUseAfterFinish = false - -// AuthRequest determines whether a specific request is permitted to load the -// /debug/requests or /debug/events pages. -// -// It returns two bools; the first indicates whether the page may be viewed at all, -// and the second indicates whether sensitive events will be shown. -// -// AuthRequest may be replaced by a program to customise its authorisation requirements. -// -// The default AuthRequest function returns (true, true) if and only if the request -// comes from localhost/127.0.0.1/[::1]. -var AuthRequest = func(req *http.Request) (any, sensitive bool) { - // RemoteAddr is commonly in the form "IP" or "IP:port". - // If it is in the form "IP:port", split off the port. - host, _, err := net.SplitHostPort(req.RemoteAddr) - if err != nil { - host = req.RemoteAddr - } - switch host { - case "localhost", "127.0.0.1", "::1": - return true, true - default: - return false, false - } -} - -func init() { - http.HandleFunc("/debug/requests", func(w http.ResponseWriter, req *http.Request) { - any, sensitive := AuthRequest(req) - if !any { - http.Error(w, "not allowed", http.StatusUnauthorized) - return - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - Render(w, req, sensitive) - }) - http.HandleFunc("/debug/events", func(w http.ResponseWriter, req *http.Request) { - any, sensitive := AuthRequest(req) - if !any { - http.Error(w, "not allowed", http.StatusUnauthorized) - return - } - w.Header().Set("Content-Type", "text/html; charset=utf-8") - RenderEvents(w, req, sensitive) - }) -} - -// Render renders the HTML page typically served at /debug/requests. -// It does not do any auth checking; see AuthRequest for the default auth check -// used by the handler registered on http.DefaultServeMux. -// req may be nil. -func Render(w io.Writer, req *http.Request, sensitive bool) { - data := &struct { - Families []string - ActiveTraceCount map[string]int - CompletedTraces map[string]*family - - // Set when a bucket has been selected. - Traces traceList - Family string - Bucket int - Expanded bool - Traced bool - Active bool - ShowSensitive bool // whether to show sensitive events - - Histogram template.HTML - HistogramWindow string // e.g. "last minute", "last hour", "all time" - - // If non-zero, the set of traces is a partial set, - // and this is the total number. - Total int - }{ - CompletedTraces: completedTraces, - } - - data.ShowSensitive = sensitive - if req != nil { - // Allow show_sensitive=0 to force hiding of sensitive data for testing. - // This only goes one way; you can't use show_sensitive=1 to see things. - if req.FormValue("show_sensitive") == "0" { - data.ShowSensitive = false - } - - if exp, err := strconv.ParseBool(req.FormValue("exp")); err == nil { - data.Expanded = exp - } - if exp, err := strconv.ParseBool(req.FormValue("rtraced")); err == nil { - data.Traced = exp - } - } - - completedMu.RLock() - data.Families = make([]string, 0, len(completedTraces)) - for fam := range completedTraces { - data.Families = append(data.Families, fam) - } - completedMu.RUnlock() - sort.Strings(data.Families) - - // We are careful here to minimize the time spent locking activeMu, - // since that lock is required every time an RPC starts and finishes. - data.ActiveTraceCount = make(map[string]int, len(data.Families)) - activeMu.RLock() - for fam, s := range activeTraces { - data.ActiveTraceCount[fam] = s.Len() - } - activeMu.RUnlock() - - var ok bool - data.Family, data.Bucket, ok = parseArgs(req) - switch { - case !ok: - // No-op - case data.Bucket == -1: - data.Active = true - n := data.ActiveTraceCount[data.Family] - data.Traces = getActiveTraces(data.Family) - if len(data.Traces) < n { - data.Total = n - } - case data.Bucket < bucketsPerFamily: - if b := lookupBucket(data.Family, data.Bucket); b != nil { - data.Traces = b.Copy(data.Traced) - } - default: - if f := getFamily(data.Family, false); f != nil { - var obs timeseries.Observable - f.LatencyMu.RLock() - switch o := data.Bucket - bucketsPerFamily; o { - case 0: - obs = f.Latency.Minute() - data.HistogramWindow = "last minute" - case 1: - obs = f.Latency.Hour() - data.HistogramWindow = "last hour" - case 2: - obs = f.Latency.Total() - data.HistogramWindow = "all time" - } - f.LatencyMu.RUnlock() - if obs != nil { - data.Histogram = obs.(*histogram).html() - } - } - } - - if data.Traces != nil { - defer data.Traces.Free() - sort.Sort(data.Traces) - } - - completedMu.RLock() - defer completedMu.RUnlock() - if err := pageTmpl.ExecuteTemplate(w, "Page", data); err != nil { - log.Printf("net/trace: Failed executing template: %v", err) - } -} - -func parseArgs(req *http.Request) (fam string, b int, ok bool) { - if req == nil { - return "", 0, false - } - fam, bStr := req.FormValue("fam"), req.FormValue("b") - if fam == "" || bStr == "" { - return "", 0, false - } - b, err := strconv.Atoi(bStr) - if err != nil || b < -1 { - return "", 0, false - } - - return fam, b, true -} - -func lookupBucket(fam string, b int) *traceBucket { - f := getFamily(fam, false) - if f == nil || b < 0 || b >= len(f.Buckets) { - return nil - } - return f.Buckets[b] -} - -type contextKeyT string - -var contextKey = contextKeyT("golang.org/x/net/trace.Trace") - -// NewContext returns a copy of the parent context -// and associates it with a Trace. -func NewContext(ctx context.Context, tr Trace) context.Context { - return context.WithValue(ctx, contextKey, tr) -} - -// FromContext returns the Trace bound to the context, if any. -func FromContext(ctx context.Context) (tr Trace, ok bool) { - tr, ok = ctx.Value(contextKey).(Trace) - return -} - -// Trace represents an active request. -type Trace interface { - // LazyLog adds x to the event log. It will be evaluated each time the - // /debug/requests page is rendered. Any memory referenced by x will be - // pinned until the trace is finished and later discarded. - LazyLog(x fmt.Stringer, sensitive bool) - - // LazyPrintf evaluates its arguments with fmt.Sprintf each time the - // /debug/requests page is rendered. Any memory referenced by a will be - // pinned until the trace is finished and later discarded. - LazyPrintf(format string, a ...interface{}) - - // SetError declares that this trace resulted in an error. - SetError() - - // SetRecycler sets a recycler for the trace. - // f will be called for each event passed to LazyLog at a time when - // it is no longer required, whether while the trace is still active - // and the event is discarded, or when a completed trace is discarded. - SetRecycler(f func(interface{})) - - // SetTraceInfo sets the trace info for the trace. - // This is currently unused. - SetTraceInfo(traceID, spanID uint64) - - // SetMaxEvents sets the maximum number of events that will be stored - // in the trace. This has no effect if any events have already been - // added to the trace. - SetMaxEvents(m int) - - // Finish declares that this trace is complete. - // The trace should not be used after calling this method. - Finish() -} - -type lazySprintf struct { - format string - a []interface{} -} - -func (l *lazySprintf) String() string { - return fmt.Sprintf(l.format, l.a...) -} - -// New returns a new Trace with the specified family and title. -func New(family, title string) Trace { - tr := newTrace() - tr.ref() - tr.Family, tr.Title = family, title - tr.Start = time.Now() - tr.events = make([]event, 0, maxEventsPerTrace) - - activeMu.RLock() - s := activeTraces[tr.Family] - activeMu.RUnlock() - if s == nil { - activeMu.Lock() - s = activeTraces[tr.Family] // check again - if s == nil { - s = new(traceSet) - activeTraces[tr.Family] = s - } - activeMu.Unlock() - } - s.Add(tr) - - // Trigger allocation of the completed trace structure for this family. - // This will cause the family to be present in the request page during - // the first trace of this family. We don't care about the return value, - // nor is there any need for this to run inline, so we execute it in its - // own goroutine, but only if the family isn't allocated yet. - completedMu.RLock() - if _, ok := completedTraces[tr.Family]; !ok { - go allocFamily(tr.Family) - } - completedMu.RUnlock() - - return tr -} - -func (tr *trace) Finish() { - tr.Elapsed = time.Now().Sub(tr.Start) - if DebugUseAfterFinish { - buf := make([]byte, 4<<10) // 4 KB should be enough - n := runtime.Stack(buf, false) - tr.finishStack = buf[:n] - } - - activeMu.RLock() - m := activeTraces[tr.Family] - activeMu.RUnlock() - m.Remove(tr) - - f := getFamily(tr.Family, true) - for _, b := range f.Buckets { - if b.Cond.match(tr) { - b.Add(tr) - } - } - // Add a sample of elapsed time as microseconds to the family's timeseries - h := new(histogram) - h.addMeasurement(tr.Elapsed.Nanoseconds() / 1e3) - f.LatencyMu.Lock() - f.Latency.Add(h) - f.LatencyMu.Unlock() - - tr.unref() // matches ref in New -} - -const ( - bucketsPerFamily = 9 - tracesPerBucket = 10 - maxActiveTraces = 20 // Maximum number of active traces to show. - maxEventsPerTrace = 10 - numHistogramBuckets = 38 -) - -var ( - // The active traces. - activeMu sync.RWMutex - activeTraces = make(map[string]*traceSet) // family -> traces - - // Families of completed traces. - completedMu sync.RWMutex - completedTraces = make(map[string]*family) // family -> traces -) - -type traceSet struct { - mu sync.RWMutex - m map[*trace]bool - - // We could avoid the entire map scan in FirstN by having a slice of all the traces - // ordered by start time, and an index into that from the trace struct, with a periodic - // repack of the slice after enough traces finish; we could also use a skip list or similar. - // However, that would shift some of the expense from /debug/requests time to RPC time, - // which is probably the wrong trade-off. -} - -func (ts *traceSet) Len() int { - ts.mu.RLock() - defer ts.mu.RUnlock() - return len(ts.m) -} - -func (ts *traceSet) Add(tr *trace) { - ts.mu.Lock() - if ts.m == nil { - ts.m = make(map[*trace]bool) - } - ts.m[tr] = true - ts.mu.Unlock() -} - -func (ts *traceSet) Remove(tr *trace) { - ts.mu.Lock() - delete(ts.m, tr) - ts.mu.Unlock() -} - -// FirstN returns the first n traces ordered by time. -func (ts *traceSet) FirstN(n int) traceList { - ts.mu.RLock() - defer ts.mu.RUnlock() - - if n > len(ts.m) { - n = len(ts.m) - } - trl := make(traceList, 0, n) - - // Fast path for when no selectivity is needed. - if n == len(ts.m) { - for tr := range ts.m { - tr.ref() - trl = append(trl, tr) - } - sort.Sort(trl) - return trl - } - - // Pick the oldest n traces. - // This is inefficient. See the comment in the traceSet struct. - for tr := range ts.m { - // Put the first n traces into trl in the order they occur. - // When we have n, sort trl, and thereafter maintain its order. - if len(trl) < n { - tr.ref() - trl = append(trl, tr) - if len(trl) == n { - // This is guaranteed to happen exactly once during this loop. - sort.Sort(trl) - } - continue - } - if tr.Start.After(trl[n-1].Start) { - continue - } - - // Find where to insert this one. - tr.ref() - i := sort.Search(n, func(i int) bool { return trl[i].Start.After(tr.Start) }) - trl[n-1].unref() - copy(trl[i+1:], trl[i:]) - trl[i] = tr - } - - return trl -} - -func getActiveTraces(fam string) traceList { - activeMu.RLock() - s := activeTraces[fam] - activeMu.RUnlock() - if s == nil { - return nil - } - return s.FirstN(maxActiveTraces) -} - -func getFamily(fam string, allocNew bool) *family { - completedMu.RLock() - f := completedTraces[fam] - completedMu.RUnlock() - if f == nil && allocNew { - f = allocFamily(fam) - } - return f -} - -func allocFamily(fam string) *family { - completedMu.Lock() - defer completedMu.Unlock() - f := completedTraces[fam] - if f == nil { - f = newFamily() - completedTraces[fam] = f - } - return f -} - -// family represents a set of trace buckets and associated latency information. -type family struct { - // traces may occur in multiple buckets. - Buckets [bucketsPerFamily]*traceBucket - - // latency time series - LatencyMu sync.RWMutex - Latency *timeseries.MinuteHourSeries -} - -func newFamily() *family { - return &family{ - Buckets: [bucketsPerFamily]*traceBucket{ - {Cond: minCond(0)}, - {Cond: minCond(50 * time.Millisecond)}, - {Cond: minCond(100 * time.Millisecond)}, - {Cond: minCond(200 * time.Millisecond)}, - {Cond: minCond(500 * time.Millisecond)}, - {Cond: minCond(1 * time.Second)}, - {Cond: minCond(10 * time.Second)}, - {Cond: minCond(100 * time.Second)}, - {Cond: errorCond{}}, - }, - Latency: timeseries.NewMinuteHourSeries(func() timeseries.Observable { return new(histogram) }), - } -} - -// traceBucket represents a size-capped bucket of historic traces, -// along with a condition for a trace to belong to the bucket. -type traceBucket struct { - Cond cond - - // Ring buffer implementation of a fixed-size FIFO queue. - mu sync.RWMutex - buf [tracesPerBucket]*trace - start int // < tracesPerBucket - length int // <= tracesPerBucket -} - -func (b *traceBucket) Add(tr *trace) { - b.mu.Lock() - defer b.mu.Unlock() - - i := b.start + b.length - if i >= tracesPerBucket { - i -= tracesPerBucket - } - if b.length == tracesPerBucket { - // "Remove" an element from the bucket. - b.buf[i].unref() - b.start++ - if b.start == tracesPerBucket { - b.start = 0 - } - } - b.buf[i] = tr - if b.length < tracesPerBucket { - b.length++ - } - tr.ref() -} - -// Copy returns a copy of the traces in the bucket. -// If tracedOnly is true, only the traces with trace information will be returned. -// The logs will be ref'd before returning; the caller should call -// the Free method when it is done with them. -// TODO(dsymonds): keep track of traced requests in separate buckets. -func (b *traceBucket) Copy(tracedOnly bool) traceList { - b.mu.RLock() - defer b.mu.RUnlock() - - trl := make(traceList, 0, b.length) - for i, x := 0, b.start; i < b.length; i++ { - tr := b.buf[x] - if !tracedOnly || tr.spanID != 0 { - tr.ref() - trl = append(trl, tr) - } - x++ - if x == b.length { - x = 0 - } - } - return trl -} - -func (b *traceBucket) Empty() bool { - b.mu.RLock() - defer b.mu.RUnlock() - return b.length == 0 -} - -// cond represents a condition on a trace. -type cond interface { - match(t *trace) bool - String() string -} - -type minCond time.Duration - -func (m minCond) match(t *trace) bool { return t.Elapsed >= time.Duration(m) } -func (m minCond) String() string { return fmt.Sprintf("≥%gs", time.Duration(m).Seconds()) } - -type errorCond struct{} - -func (e errorCond) match(t *trace) bool { return t.IsError } -func (e errorCond) String() string { return "errors" } - -type traceList []*trace - -// Free calls unref on each element of the list. -func (trl traceList) Free() { - for _, t := range trl { - t.unref() - } -} - -// traceList may be sorted in reverse chronological order. -func (trl traceList) Len() int { return len(trl) } -func (trl traceList) Less(i, j int) bool { return trl[i].Start.After(trl[j].Start) } -func (trl traceList) Swap(i, j int) { trl[i], trl[j] = trl[j], trl[i] } - -// An event is a timestamped log entry in a trace. -type event struct { - When time.Time - Elapsed time.Duration // since previous event in trace - NewDay bool // whether this event is on a different day to the previous event - Recyclable bool // whether this event was passed via LazyLog - What interface{} // string or fmt.Stringer - Sensitive bool // whether this event contains sensitive information -} - -// WhenString returns a string representation of the elapsed time of the event. -// It will include the date if midnight was crossed. -func (e event) WhenString() string { - if e.NewDay { - return e.When.Format("2006/01/02 15:04:05.000000") - } - return e.When.Format("15:04:05.000000") -} - -// discarded represents a number of discarded events. -// It is stored as *discarded to make it easier to update in-place. -type discarded int - -func (d *discarded) String() string { - return fmt.Sprintf("(%d events discarded)", int(*d)) -} - -// trace represents an active or complete request, -// either sent or received by this program. -type trace struct { - // Family is the top-level grouping of traces to which this belongs. - Family string - - // Title is the title of this trace. - Title string - - // Timing information. - Start time.Time - Elapsed time.Duration // zero while active - - // Trace information if non-zero. - traceID uint64 - spanID uint64 - - // Whether this trace resulted in an error. - IsError bool - - // Append-only sequence of events (modulo discards). - mu sync.RWMutex - events []event - - refs int32 // how many buckets this is in - recycler func(interface{}) - disc discarded // scratch space to avoid allocation - - finishStack []byte // where finish was called, if DebugUseAfterFinish is set -} - -func (tr *trace) reset() { - // Clear all but the mutex. Mutexes may not be copied, even when unlocked. - tr.Family = "" - tr.Title = "" - tr.Start = time.Time{} - tr.Elapsed = 0 - tr.traceID = 0 - tr.spanID = 0 - tr.IsError = false - tr.events = nil - tr.refs = 0 - tr.recycler = nil - tr.disc = 0 - tr.finishStack = nil -} - -// delta returns the elapsed time since the last event or the trace start, -// and whether it spans midnight. -// L >= tr.mu -func (tr *trace) delta(t time.Time) (time.Duration, bool) { - if len(tr.events) == 0 { - return t.Sub(tr.Start), false - } - prev := tr.events[len(tr.events)-1].When - return t.Sub(prev), prev.Day() != t.Day() -} - -func (tr *trace) addEvent(x interface{}, recyclable, sensitive bool) { - if DebugUseAfterFinish && tr.finishStack != nil { - buf := make([]byte, 4<<10) // 4 KB should be enough - n := runtime.Stack(buf, false) - log.Printf("net/trace: trace used after finish:\nFinished at:\n%s\nUsed at:\n%s", tr.finishStack, buf[:n]) - } - - /* - NOTE TO DEBUGGERS - - If you are here because your program panicked in this code, - it is almost definitely the fault of code using this package, - and very unlikely to be the fault of this code. - - The most likely scenario is that some code elsewhere is using - a requestz.Trace after its Finish method is called. - You can temporarily set the DebugUseAfterFinish var - to help discover where that is; do not leave that var set, - since it makes this package much less efficient. - */ - - e := event{When: time.Now(), What: x, Recyclable: recyclable, Sensitive: sensitive} - tr.mu.Lock() - e.Elapsed, e.NewDay = tr.delta(e.When) - if len(tr.events) < cap(tr.events) { - tr.events = append(tr.events, e) - } else { - // Discard the middle events. - di := int((cap(tr.events) - 1) / 2) - if d, ok := tr.events[di].What.(*discarded); ok { - (*d)++ - } else { - // disc starts at two to count for the event it is replacing, - // plus the next one that we are about to drop. - tr.disc = 2 - if tr.recycler != nil && tr.events[di].Recyclable { - go tr.recycler(tr.events[di].What) - } - tr.events[di].What = &tr.disc - } - // The timestamp of the discarded meta-event should be - // the time of the last event it is representing. - tr.events[di].When = tr.events[di+1].When - - if tr.recycler != nil && tr.events[di+1].Recyclable { - go tr.recycler(tr.events[di+1].What) - } - copy(tr.events[di+1:], tr.events[di+2:]) - tr.events[cap(tr.events)-1] = e - } - tr.mu.Unlock() -} - -func (tr *trace) LazyLog(x fmt.Stringer, sensitive bool) { - tr.addEvent(x, true, sensitive) -} - -func (tr *trace) LazyPrintf(format string, a ...interface{}) { - tr.addEvent(&lazySprintf{format, a}, false, false) -} - -func (tr *trace) SetError() { tr.IsError = true } - -func (tr *trace) SetRecycler(f func(interface{})) { - tr.recycler = f -} - -func (tr *trace) SetTraceInfo(traceID, spanID uint64) { - tr.traceID, tr.spanID = traceID, spanID -} - -func (tr *trace) SetMaxEvents(m int) { - // Always keep at least three events: first, discarded count, last. - if len(tr.events) == 0 && m > 3 { - tr.events = make([]event, 0, m) - } -} - -func (tr *trace) ref() { - atomic.AddInt32(&tr.refs, 1) -} - -func (tr *trace) unref() { - if atomic.AddInt32(&tr.refs, -1) == 0 { - if tr.recycler != nil { - // freeTrace clears tr, so we hold tr.recycler and tr.events here. - go func(f func(interface{}), es []event) { - for _, e := range es { - if e.Recyclable { - f(e.What) - } - } - }(tr.recycler, tr.events) - } - - freeTrace(tr) - } -} - -func (tr *trace) When() string { - return tr.Start.Format("2006/01/02 15:04:05.000000") -} - -func (tr *trace) ElapsedTime() string { - t := tr.Elapsed - if t == 0 { - // Active trace. - t = time.Since(tr.Start) - } - return fmt.Sprintf("%.6f", t.Seconds()) -} - -func (tr *trace) Events() []event { - tr.mu.RLock() - defer tr.mu.RUnlock() - return tr.events -} - -var traceFreeList = make(chan *trace, 1000) // TODO(dsymonds): Use sync.Pool? - -// newTrace returns a trace ready to use. -func newTrace() *trace { - select { - case tr := <-traceFreeList: - return tr - default: - return new(trace) - } -} - -// freeTrace adds tr to traceFreeList if there's room. -// This is non-blocking. -func freeTrace(tr *trace) { - if DebugUseAfterFinish { - return // never reuse - } - tr.reset() - select { - case traceFreeList <- tr: - default: - } -} - -func elapsed(d time.Duration) string { - b := []byte(fmt.Sprintf("%.6f", d.Seconds())) - - // For subsecond durations, blank all zeros before decimal point, - // and all zeros between the decimal point and the first non-zero digit. - if d < time.Second { - dot := bytes.IndexByte(b, '.') - for i := 0; i < dot; i++ { - b[i] = ' ' - } - for i := dot + 1; i < len(b); i++ { - if b[i] == '0' { - b[i] = ' ' - } else { - break - } - } - } - - return string(b) -} - -var pageTmpl = template.Must(template.New("Page").Funcs(template.FuncMap{ - "elapsed": elapsed, - "add": func(a, b int) int { return a + b }, -}).Parse(pageHTML)) - -const pageHTML = ` -{{template "Prolog" .}} -{{template "StatusTable" .}} -{{template "Epilog" .}} - -{{define "Prolog"}} - - - /debug/requests - - - - -

    /debug/requests

    -{{end}} {{/* end of Prolog */}} - -{{define "StatusTable"}} - - {{range $fam := .Families}} - - - - {{$n := index $.ActiveTraceCount $fam}} - - - {{$f := index $.CompletedTraces $fam}} - {{range $i, $b := $f.Buckets}} - {{$empty := $b.Empty}} - - {{end}} - - {{$nb := len $f.Buckets}} - - - - - - {{end}} -
    {{$fam}} - {{if $n}}{{end}} - [{{$n}} active] - {{if $n}}{{end}} - - {{if not $empty}}{{end}} - [{{.Cond}}] - {{if not $empty}}{{end}} - - [minute] - - [hour] - - [total] -
    -{{end}} {{/* end of StatusTable */}} - -{{define "Epilog"}} -{{if $.Traces}} -
    -

    Family: {{$.Family}}

    - -{{if or $.Expanded $.Traced}} - [Normal/Summary] -{{else}} - [Normal/Summary] -{{end}} - -{{if or (not $.Expanded) $.Traced}} - [Normal/Expanded] -{{else}} - [Normal/Expanded] -{{end}} - -{{if not $.Active}} - {{if or $.Expanded (not $.Traced)}} - [Traced/Summary] - {{else}} - [Traced/Summary] - {{end}} - {{if or (not $.Expanded) (not $.Traced)}} - [Traced/Expanded] - {{else}} - [Traced/Expanded] - {{end}} -{{end}} - -{{if $.Total}} -

    Showing {{len $.Traces}} of {{$.Total}} traces.

    -{{end}} - - - - - {{range $tr := $.Traces}} - - - - - {{/* TODO: include traceID/spanID */}} - - {{if $.Expanded}} - {{range $tr.Events}} - - - - - - {{end}} - {{end}} - {{end}} -
    - {{if $.Active}}Active{{else}}Completed{{end}} Requests -
    WhenElapsed (s)
    {{$tr.When}}{{$tr.ElapsedTime}}{{$tr.Title}}
    {{.WhenString}}{{elapsed .Elapsed}}{{if or $.ShowSensitive (not .Sensitive)}}... {{.What}}{{else}}[redacted]{{end}}
    -{{end}} {{/* if $.Traces */}} - -{{if $.Histogram}} -

    Latency (µs) of {{$.Family}} over {{$.HistogramWindow}}

    -{{$.Histogram}} -{{end}} {{/* if $.Histogram */}} - - - -{{end}} {{/* end of Epilog */}} -` diff --git a/vendor/golang.org/x/net/trace/trace_test.go b/vendor/golang.org/x/net/trace/trace_test.go deleted file mode 100644 index 14d7c23..0000000 --- a/vendor/golang.org/x/net/trace/trace_test.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package trace - -import ( - "net/http" - "reflect" - "testing" -) - -type s struct{} - -func (s) String() string { return "lazy string" } - -// TestReset checks whether all the fields are zeroed after reset. -func TestReset(t *testing.T) { - tr := New("foo", "bar") - tr.LazyLog(s{}, false) - tr.LazyPrintf("%d", 1) - tr.SetRecycler(func(_ interface{}) {}) - tr.SetTraceInfo(3, 4) - tr.SetMaxEvents(100) - tr.SetError() - tr.Finish() - - tr.(*trace).reset() - - if !reflect.DeepEqual(tr, new(trace)) { - t.Errorf("reset didn't clear all fields: %+v", tr) - } -} - -// TestResetLog checks whether all the fields are zeroed after reset. -func TestResetLog(t *testing.T) { - el := NewEventLog("foo", "bar") - el.Printf("message") - el.Errorf("error") - el.Finish() - - el.(*eventLog).reset() - - if !reflect.DeepEqual(el, new(eventLog)) { - t.Errorf("reset didn't clear all fields: %+v", el) - } -} - -func TestAuthRequest(t *testing.T) { - testCases := []struct { - host string - want bool - }{ - {host: "192.168.23.1", want: false}, - {host: "192.168.23.1:8080", want: false}, - {host: "malformed remote addr", want: false}, - {host: "localhost", want: true}, - {host: "localhost:8080", want: true}, - {host: "127.0.0.1", want: true}, - {host: "127.0.0.1:8080", want: true}, - {host: "::1", want: true}, - {host: "[::1]:8080", want: true}, - } - for _, tt := range testCases { - req := &http.Request{RemoteAddr: tt.host} - any, sensitive := AuthRequest(req) - if any != tt.want || sensitive != tt.want { - t.Errorf("AuthRequest(%q) = %t, %t; want %t, %t", tt.host, any, sensitive, tt.want, tt.want) - } - } -} diff --git a/vendor/golang.org/x/net/webdav/file.go b/vendor/golang.org/x/net/webdav/file.go deleted file mode 100644 index 3d95c6c..0000000 --- a/vendor/golang.org/x/net/webdav/file.go +++ /dev/null @@ -1,794 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "encoding/xml" - "io" - "net/http" - "os" - "path" - "path/filepath" - "strings" - "sync" - "time" -) - -// slashClean is equivalent to but slightly more efficient than -// path.Clean("/" + name). -func slashClean(name string) string { - if name == "" || name[0] != '/' { - name = "/" + name - } - return path.Clean(name) -} - -// A FileSystem implements access to a collection of named files. The elements -// in a file path are separated by slash ('/', U+002F) characters, regardless -// of host operating system convention. -// -// Each method has the same semantics as the os package's function of the same -// name. -// -// Note that the os.Rename documentation says that "OS-specific restrictions -// might apply". In particular, whether or not renaming a file or directory -// overwriting another existing file or directory is an error is OS-dependent. -type FileSystem interface { - Mkdir(name string, perm os.FileMode) error - OpenFile(name string, flag int, perm os.FileMode) (File, error) - RemoveAll(name string) error - Rename(oldName, newName string) error - Stat(name string) (os.FileInfo, error) -} - -// A File is returned by a FileSystem's OpenFile method and can be served by a -// Handler. -// -// A File may optionally implement the DeadPropsHolder interface, if it can -// load and save dead properties. -type File interface { - http.File - io.Writer -} - -// A Dir implements FileSystem using the native file system restricted to a -// specific directory tree. -// -// While the FileSystem.OpenFile method takes '/'-separated paths, a Dir's -// string value is a filename on the native file system, not a URL, so it is -// separated by filepath.Separator, which isn't necessarily '/'. -// -// An empty Dir is treated as ".". -type Dir string - -func (d Dir) resolve(name string) string { - // This implementation is based on Dir.Open's code in the standard net/http package. - if filepath.Separator != '/' && strings.IndexRune(name, filepath.Separator) >= 0 || - strings.Contains(name, "\x00") { - return "" - } - dir := string(d) - if dir == "" { - dir = "." - } - return filepath.Join(dir, filepath.FromSlash(slashClean(name))) -} - -func (d Dir) Mkdir(name string, perm os.FileMode) error { - if name = d.resolve(name); name == "" { - return os.ErrNotExist - } - return os.Mkdir(name, perm) -} - -func (d Dir) OpenFile(name string, flag int, perm os.FileMode) (File, error) { - if name = d.resolve(name); name == "" { - return nil, os.ErrNotExist - } - f, err := os.OpenFile(name, flag, perm) - if err != nil { - return nil, err - } - return f, nil -} - -func (d Dir) RemoveAll(name string) error { - if name = d.resolve(name); name == "" { - return os.ErrNotExist - } - if name == filepath.Clean(string(d)) { - // Prohibit removing the virtual root directory. - return os.ErrInvalid - } - return os.RemoveAll(name) -} - -func (d Dir) Rename(oldName, newName string) error { - if oldName = d.resolve(oldName); oldName == "" { - return os.ErrNotExist - } - if newName = d.resolve(newName); newName == "" { - return os.ErrNotExist - } - if root := filepath.Clean(string(d)); root == oldName || root == newName { - // Prohibit renaming from or to the virtual root directory. - return os.ErrInvalid - } - return os.Rename(oldName, newName) -} - -func (d Dir) Stat(name string) (os.FileInfo, error) { - if name = d.resolve(name); name == "" { - return nil, os.ErrNotExist - } - return os.Stat(name) -} - -// NewMemFS returns a new in-memory FileSystem implementation. -func NewMemFS() FileSystem { - return &memFS{ - root: memFSNode{ - children: make(map[string]*memFSNode), - mode: 0660 | os.ModeDir, - modTime: time.Now(), - }, - } -} - -// A memFS implements FileSystem, storing all metadata and actual file data -// in-memory. No limits on filesystem size are used, so it is not recommended -// this be used where the clients are untrusted. -// -// Concurrent access is permitted. The tree structure is protected by a mutex, -// and each node's contents and metadata are protected by a per-node mutex. -// -// TODO: Enforce file permissions. -type memFS struct { - mu sync.Mutex - root memFSNode -} - -// TODO: clean up and rationalize the walk/find code. - -// walk walks the directory tree for the fullname, calling f at each step. If f -// returns an error, the walk will be aborted and return that same error. -// -// dir is the directory at that step, frag is the name fragment, and final is -// whether it is the final step. For example, walking "/foo/bar/x" will result -// in 3 calls to f: -// - "/", "foo", false -// - "/foo/", "bar", false -// - "/foo/bar/", "x", true -// The frag argument will be empty only if dir is the root node and the walk -// ends at that root node. -func (fs *memFS) walk(op, fullname string, f func(dir *memFSNode, frag string, final bool) error) error { - original := fullname - fullname = slashClean(fullname) - - // Strip any leading "/"s to make fullname a relative path, as the walk - // starts at fs.root. - if fullname[0] == '/' { - fullname = fullname[1:] - } - dir := &fs.root - - for { - frag, remaining := fullname, "" - i := strings.IndexRune(fullname, '/') - final := i < 0 - if !final { - frag, remaining = fullname[:i], fullname[i+1:] - } - if frag == "" && dir != &fs.root { - panic("webdav: empty path fragment for a clean path") - } - if err := f(dir, frag, final); err != nil { - return &os.PathError{ - Op: op, - Path: original, - Err: err, - } - } - if final { - break - } - child := dir.children[frag] - if child == nil { - return &os.PathError{ - Op: op, - Path: original, - Err: os.ErrNotExist, - } - } - if !child.mode.IsDir() { - return &os.PathError{ - Op: op, - Path: original, - Err: os.ErrInvalid, - } - } - dir, fullname = child, remaining - } - return nil -} - -// find returns the parent of the named node and the relative name fragment -// from the parent to the child. For example, if finding "/foo/bar/baz" then -// parent will be the node for "/foo/bar" and frag will be "baz". -// -// If the fullname names the root node, then parent, frag and err will be zero. -// -// find returns an error if the parent does not already exist or the parent -// isn't a directory, but it will not return an error per se if the child does -// not already exist. The error returned is either nil or an *os.PathError -// whose Op is op. -func (fs *memFS) find(op, fullname string) (parent *memFSNode, frag string, err error) { - err = fs.walk(op, fullname, func(parent0 *memFSNode, frag0 string, final bool) error { - if !final { - return nil - } - if frag0 != "" { - parent, frag = parent0, frag0 - } - return nil - }) - return parent, frag, err -} - -func (fs *memFS) Mkdir(name string, perm os.FileMode) error { - fs.mu.Lock() - defer fs.mu.Unlock() - - dir, frag, err := fs.find("mkdir", name) - if err != nil { - return err - } - if dir == nil { - // We can't create the root. - return os.ErrInvalid - } - if _, ok := dir.children[frag]; ok { - return os.ErrExist - } - dir.children[frag] = &memFSNode{ - children: make(map[string]*memFSNode), - mode: perm.Perm() | os.ModeDir, - modTime: time.Now(), - } - return nil -} - -func (fs *memFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) { - fs.mu.Lock() - defer fs.mu.Unlock() - - dir, frag, err := fs.find("open", name) - if err != nil { - return nil, err - } - var n *memFSNode - if dir == nil { - // We're opening the root. - if flag&(os.O_WRONLY|os.O_RDWR) != 0 { - return nil, os.ErrPermission - } - n, frag = &fs.root, "/" - - } else { - n = dir.children[frag] - if flag&(os.O_SYNC|os.O_APPEND) != 0 { - // memFile doesn't support these flags yet. - return nil, os.ErrInvalid - } - if flag&os.O_CREATE != 0 { - if flag&os.O_EXCL != 0 && n != nil { - return nil, os.ErrExist - } - if n == nil { - n = &memFSNode{ - mode: perm.Perm(), - } - dir.children[frag] = n - } - } - if n == nil { - return nil, os.ErrNotExist - } - if flag&(os.O_WRONLY|os.O_RDWR) != 0 && flag&os.O_TRUNC != 0 { - n.mu.Lock() - n.data = nil - n.mu.Unlock() - } - } - - children := make([]os.FileInfo, 0, len(n.children)) - for cName, c := range n.children { - children = append(children, c.stat(cName)) - } - return &memFile{ - n: n, - nameSnapshot: frag, - childrenSnapshot: children, - }, nil -} - -func (fs *memFS) RemoveAll(name string) error { - fs.mu.Lock() - defer fs.mu.Unlock() - - dir, frag, err := fs.find("remove", name) - if err != nil { - return err - } - if dir == nil { - // We can't remove the root. - return os.ErrInvalid - } - delete(dir.children, frag) - return nil -} - -func (fs *memFS) Rename(oldName, newName string) error { - fs.mu.Lock() - defer fs.mu.Unlock() - - oldName = slashClean(oldName) - newName = slashClean(newName) - if oldName == newName { - return nil - } - if strings.HasPrefix(newName, oldName+"/") { - // We can't rename oldName to be a sub-directory of itself. - return os.ErrInvalid - } - - oDir, oFrag, err := fs.find("rename", oldName) - if err != nil { - return err - } - if oDir == nil { - // We can't rename from the root. - return os.ErrInvalid - } - - nDir, nFrag, err := fs.find("rename", newName) - if err != nil { - return err - } - if nDir == nil { - // We can't rename to the root. - return os.ErrInvalid - } - - oNode, ok := oDir.children[oFrag] - if !ok { - return os.ErrNotExist - } - if oNode.children != nil { - if nNode, ok := nDir.children[nFrag]; ok { - if nNode.children == nil { - return errNotADirectory - } - if len(nNode.children) != 0 { - return errDirectoryNotEmpty - } - } - } - delete(oDir.children, oFrag) - nDir.children[nFrag] = oNode - return nil -} - -func (fs *memFS) Stat(name string) (os.FileInfo, error) { - fs.mu.Lock() - defer fs.mu.Unlock() - - dir, frag, err := fs.find("stat", name) - if err != nil { - return nil, err - } - if dir == nil { - // We're stat'ting the root. - return fs.root.stat("/"), nil - } - if n, ok := dir.children[frag]; ok { - return n.stat(path.Base(name)), nil - } - return nil, os.ErrNotExist -} - -// A memFSNode represents a single entry in the in-memory filesystem and also -// implements os.FileInfo. -type memFSNode struct { - // children is protected by memFS.mu. - children map[string]*memFSNode - - mu sync.Mutex - data []byte - mode os.FileMode - modTime time.Time - deadProps map[xml.Name]Property -} - -func (n *memFSNode) stat(name string) *memFileInfo { - n.mu.Lock() - defer n.mu.Unlock() - return &memFileInfo{ - name: name, - size: int64(len(n.data)), - mode: n.mode, - modTime: n.modTime, - } -} - -func (n *memFSNode) DeadProps() (map[xml.Name]Property, error) { - n.mu.Lock() - defer n.mu.Unlock() - if len(n.deadProps) == 0 { - return nil, nil - } - ret := make(map[xml.Name]Property, len(n.deadProps)) - for k, v := range n.deadProps { - ret[k] = v - } - return ret, nil -} - -func (n *memFSNode) Patch(patches []Proppatch) ([]Propstat, error) { - n.mu.Lock() - defer n.mu.Unlock() - pstat := Propstat{Status: http.StatusOK} - for _, patch := range patches { - for _, p := range patch.Props { - pstat.Props = append(pstat.Props, Property{XMLName: p.XMLName}) - if patch.Remove { - delete(n.deadProps, p.XMLName) - continue - } - if n.deadProps == nil { - n.deadProps = map[xml.Name]Property{} - } - n.deadProps[p.XMLName] = p - } - } - return []Propstat{pstat}, nil -} - -type memFileInfo struct { - name string - size int64 - mode os.FileMode - modTime time.Time -} - -func (f *memFileInfo) Name() string { return f.name } -func (f *memFileInfo) Size() int64 { return f.size } -func (f *memFileInfo) Mode() os.FileMode { return f.mode } -func (f *memFileInfo) ModTime() time.Time { return f.modTime } -func (f *memFileInfo) IsDir() bool { return f.mode.IsDir() } -func (f *memFileInfo) Sys() interface{} { return nil } - -// A memFile is a File implementation for a memFSNode. It is a per-file (not -// per-node) read/write position, and a snapshot of the memFS' tree structure -// (a node's name and children) for that node. -type memFile struct { - n *memFSNode - nameSnapshot string - childrenSnapshot []os.FileInfo - // pos is protected by n.mu. - pos int -} - -// A *memFile implements the optional DeadPropsHolder interface. -var _ DeadPropsHolder = (*memFile)(nil) - -func (f *memFile) DeadProps() (map[xml.Name]Property, error) { return f.n.DeadProps() } -func (f *memFile) Patch(patches []Proppatch) ([]Propstat, error) { return f.n.Patch(patches) } - -func (f *memFile) Close() error { - return nil -} - -func (f *memFile) Read(p []byte) (int, error) { - f.n.mu.Lock() - defer f.n.mu.Unlock() - if f.n.mode.IsDir() { - return 0, os.ErrInvalid - } - if f.pos >= len(f.n.data) { - return 0, io.EOF - } - n := copy(p, f.n.data[f.pos:]) - f.pos += n - return n, nil -} - -func (f *memFile) Readdir(count int) ([]os.FileInfo, error) { - f.n.mu.Lock() - defer f.n.mu.Unlock() - if !f.n.mode.IsDir() { - return nil, os.ErrInvalid - } - old := f.pos - if old >= len(f.childrenSnapshot) { - // The os.File Readdir docs say that at the end of a directory, - // the error is io.EOF if count > 0 and nil if count <= 0. - if count > 0 { - return nil, io.EOF - } - return nil, nil - } - if count > 0 { - f.pos += count - if f.pos > len(f.childrenSnapshot) { - f.pos = len(f.childrenSnapshot) - } - } else { - f.pos = len(f.childrenSnapshot) - old = 0 - } - return f.childrenSnapshot[old:f.pos], nil -} - -func (f *memFile) Seek(offset int64, whence int) (int64, error) { - f.n.mu.Lock() - defer f.n.mu.Unlock() - npos := f.pos - // TODO: How to handle offsets greater than the size of system int? - switch whence { - case os.SEEK_SET: - npos = int(offset) - case os.SEEK_CUR: - npos += int(offset) - case os.SEEK_END: - npos = len(f.n.data) + int(offset) - default: - npos = -1 - } - if npos < 0 { - return 0, os.ErrInvalid - } - f.pos = npos - return int64(f.pos), nil -} - -func (f *memFile) Stat() (os.FileInfo, error) { - return f.n.stat(f.nameSnapshot), nil -} - -func (f *memFile) Write(p []byte) (int, error) { - lenp := len(p) - f.n.mu.Lock() - defer f.n.mu.Unlock() - - if f.n.mode.IsDir() { - return 0, os.ErrInvalid - } - if f.pos < len(f.n.data) { - n := copy(f.n.data[f.pos:], p) - f.pos += n - p = p[n:] - } else if f.pos > len(f.n.data) { - // Write permits the creation of holes, if we've seek'ed past the - // existing end of file. - if f.pos <= cap(f.n.data) { - oldLen := len(f.n.data) - f.n.data = f.n.data[:f.pos] - hole := f.n.data[oldLen:] - for i := range hole { - hole[i] = 0 - } - } else { - d := make([]byte, f.pos, f.pos+len(p)) - copy(d, f.n.data) - f.n.data = d - } - } - - if len(p) > 0 { - // We should only get here if f.pos == len(f.n.data). - f.n.data = append(f.n.data, p...) - f.pos = len(f.n.data) - } - f.n.modTime = time.Now() - return lenp, nil -} - -// moveFiles moves files and/or directories from src to dst. -// -// See section 9.9.4 for when various HTTP status codes apply. -func moveFiles(fs FileSystem, src, dst string, overwrite bool) (status int, err error) { - created := false - if _, err := fs.Stat(dst); err != nil { - if !os.IsNotExist(err) { - return http.StatusForbidden, err - } - created = true - } else if overwrite { - // Section 9.9.3 says that "If a resource exists at the destination - // and the Overwrite header is "T", then prior to performing the move, - // the server must perform a DELETE with "Depth: infinity" on the - // destination resource. - if err := fs.RemoveAll(dst); err != nil { - return http.StatusForbidden, err - } - } else { - return http.StatusPreconditionFailed, os.ErrExist - } - if err := fs.Rename(src, dst); err != nil { - return http.StatusForbidden, err - } - if created { - return http.StatusCreated, nil - } - return http.StatusNoContent, nil -} - -func copyProps(dst, src File) error { - d, ok := dst.(DeadPropsHolder) - if !ok { - return nil - } - s, ok := src.(DeadPropsHolder) - if !ok { - return nil - } - m, err := s.DeadProps() - if err != nil { - return err - } - props := make([]Property, 0, len(m)) - for _, prop := range m { - props = append(props, prop) - } - _, err = d.Patch([]Proppatch{{Props: props}}) - return err -} - -// copyFiles copies files and/or directories from src to dst. -// -// See section 9.8.5 for when various HTTP status codes apply. -func copyFiles(fs FileSystem, src, dst string, overwrite bool, depth int, recursion int) (status int, err error) { - if recursion == 1000 { - return http.StatusInternalServerError, errRecursionTooDeep - } - recursion++ - - // TODO: section 9.8.3 says that "Note that an infinite-depth COPY of /A/ - // into /A/B/ could lead to infinite recursion if not handled correctly." - - srcFile, err := fs.OpenFile(src, os.O_RDONLY, 0) - if err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusInternalServerError, err - } - defer srcFile.Close() - srcStat, err := srcFile.Stat() - if err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusInternalServerError, err - } - srcPerm := srcStat.Mode() & os.ModePerm - - created := false - if _, err := fs.Stat(dst); err != nil { - if os.IsNotExist(err) { - created = true - } else { - return http.StatusForbidden, err - } - } else { - if !overwrite { - return http.StatusPreconditionFailed, os.ErrExist - } - if err := fs.RemoveAll(dst); err != nil && !os.IsNotExist(err) { - return http.StatusForbidden, err - } - } - - if srcStat.IsDir() { - if err := fs.Mkdir(dst, srcPerm); err != nil { - return http.StatusForbidden, err - } - if depth == infiniteDepth { - children, err := srcFile.Readdir(-1) - if err != nil { - return http.StatusForbidden, err - } - for _, c := range children { - name := c.Name() - s := path.Join(src, name) - d := path.Join(dst, name) - cStatus, cErr := copyFiles(fs, s, d, overwrite, depth, recursion) - if cErr != nil { - // TODO: MultiStatus. - return cStatus, cErr - } - } - } - - } else { - dstFile, err := fs.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, srcPerm) - if err != nil { - if os.IsNotExist(err) { - return http.StatusConflict, err - } - return http.StatusForbidden, err - - } - _, copyErr := io.Copy(dstFile, srcFile) - propsErr := copyProps(dstFile, srcFile) - closeErr := dstFile.Close() - if copyErr != nil { - return http.StatusInternalServerError, copyErr - } - if propsErr != nil { - return http.StatusInternalServerError, propsErr - } - if closeErr != nil { - return http.StatusInternalServerError, closeErr - } - } - - if created { - return http.StatusCreated, nil - } - return http.StatusNoContent, nil -} - -// walkFS traverses filesystem fs starting at name up to depth levels. -// -// Allowed values for depth are 0, 1 or infiniteDepth. For each visited node, -// walkFS calls walkFn. If a visited file system node is a directory and -// walkFn returns filepath.SkipDir, walkFS will skip traversal of this node. -func walkFS(fs FileSystem, depth int, name string, info os.FileInfo, walkFn filepath.WalkFunc) error { - // This implementation is based on Walk's code in the standard path/filepath package. - err := walkFn(name, info, nil) - if err != nil { - if info.IsDir() && err == filepath.SkipDir { - return nil - } - return err - } - if !info.IsDir() || depth == 0 { - return nil - } - if depth == 1 { - depth = 0 - } - - // Read directory names. - f, err := fs.OpenFile(name, os.O_RDONLY, 0) - if err != nil { - return walkFn(name, info, err) - } - fileInfos, err := f.Readdir(0) - f.Close() - if err != nil { - return walkFn(name, info, err) - } - - for _, fileInfo := range fileInfos { - filename := path.Join(name, fileInfo.Name()) - fileInfo, err := fs.Stat(filename) - if err != nil { - if err := walkFn(filename, fileInfo, err); err != nil && err != filepath.SkipDir { - return err - } - } else { - err = walkFS(fs, depth, filename, fileInfo, walkFn) - if err != nil { - if !fileInfo.IsDir() || err != filepath.SkipDir { - return err - } - } - } - } - return nil -} diff --git a/vendor/golang.org/x/net/webdav/file_test.go b/vendor/golang.org/x/net/webdav/file_test.go deleted file mode 100644 index 7ce6c12..0000000 --- a/vendor/golang.org/x/net/webdav/file_test.go +++ /dev/null @@ -1,1166 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "encoding/xml" - "fmt" - "io" - "io/ioutil" - "os" - "path" - "path/filepath" - "reflect" - "runtime" - "sort" - "strconv" - "strings" - "testing" -) - -func TestSlashClean(t *testing.T) { - testCases := []string{ - "", - ".", - "/", - "/./", - "//", - "//.", - "//a", - "/a", - "/a/b/c", - "/a//b/./../c/d/", - "a", - "a/b/c", - } - for _, tc := range testCases { - got := slashClean(tc) - want := path.Clean("/" + tc) - if got != want { - t.Errorf("tc=%q: got %q, want %q", tc, got, want) - } - } -} - -func TestDirResolve(t *testing.T) { - testCases := []struct { - dir, name, want string - }{ - {"/", "", "/"}, - {"/", "/", "/"}, - {"/", ".", "/"}, - {"/", "./a", "/a"}, - {"/", "..", "/"}, - {"/", "..", "/"}, - {"/", "../", "/"}, - {"/", "../.", "/"}, - {"/", "../a", "/a"}, - {"/", "../..", "/"}, - {"/", "../bar/a", "/bar/a"}, - {"/", "../baz/a", "/baz/a"}, - {"/", "...", "/..."}, - {"/", ".../a", "/.../a"}, - {"/", ".../..", "/"}, - {"/", "a", "/a"}, - {"/", "a/./b", "/a/b"}, - {"/", "a/../../b", "/b"}, - {"/", "a/../b", "/b"}, - {"/", "a/b", "/a/b"}, - {"/", "a/b/c/../../d", "/a/d"}, - {"/", "a/b/c/../../../d", "/d"}, - {"/", "a/b/c/../../../../d", "/d"}, - {"/", "a/b/c/d", "/a/b/c/d"}, - - {"/foo/bar", "", "/foo/bar"}, - {"/foo/bar", "/", "/foo/bar"}, - {"/foo/bar", ".", "/foo/bar"}, - {"/foo/bar", "./a", "/foo/bar/a"}, - {"/foo/bar", "..", "/foo/bar"}, - {"/foo/bar", "../", "/foo/bar"}, - {"/foo/bar", "../.", "/foo/bar"}, - {"/foo/bar", "../a", "/foo/bar/a"}, - {"/foo/bar", "../..", "/foo/bar"}, - {"/foo/bar", "../bar/a", "/foo/bar/bar/a"}, - {"/foo/bar", "../baz/a", "/foo/bar/baz/a"}, - {"/foo/bar", "...", "/foo/bar/..."}, - {"/foo/bar", ".../a", "/foo/bar/.../a"}, - {"/foo/bar", ".../..", "/foo/bar"}, - {"/foo/bar", "a", "/foo/bar/a"}, - {"/foo/bar", "a/./b", "/foo/bar/a/b"}, - {"/foo/bar", "a/../../b", "/foo/bar/b"}, - {"/foo/bar", "a/../b", "/foo/bar/b"}, - {"/foo/bar", "a/b", "/foo/bar/a/b"}, - {"/foo/bar", "a/b/c/../../d", "/foo/bar/a/d"}, - {"/foo/bar", "a/b/c/../../../d", "/foo/bar/d"}, - {"/foo/bar", "a/b/c/../../../../d", "/foo/bar/d"}, - {"/foo/bar", "a/b/c/d", "/foo/bar/a/b/c/d"}, - - {"/foo/bar/", "", "/foo/bar"}, - {"/foo/bar/", "/", "/foo/bar"}, - {"/foo/bar/", ".", "/foo/bar"}, - {"/foo/bar/", "./a", "/foo/bar/a"}, - {"/foo/bar/", "..", "/foo/bar"}, - - {"/foo//bar///", "", "/foo/bar"}, - {"/foo//bar///", "/", "/foo/bar"}, - {"/foo//bar///", ".", "/foo/bar"}, - {"/foo//bar///", "./a", "/foo/bar/a"}, - {"/foo//bar///", "..", "/foo/bar"}, - - {"/x/y/z", "ab/c\x00d/ef", ""}, - - {".", "", "."}, - {".", "/", "."}, - {".", ".", "."}, - {".", "./a", "a"}, - {".", "..", "."}, - {".", "..", "."}, - {".", "../", "."}, - {".", "../.", "."}, - {".", "../a", "a"}, - {".", "../..", "."}, - {".", "../bar/a", "bar/a"}, - {".", "../baz/a", "baz/a"}, - {".", "...", "..."}, - {".", ".../a", ".../a"}, - {".", ".../..", "."}, - {".", "a", "a"}, - {".", "a/./b", "a/b"}, - {".", "a/../../b", "b"}, - {".", "a/../b", "b"}, - {".", "a/b", "a/b"}, - {".", "a/b/c/../../d", "a/d"}, - {".", "a/b/c/../../../d", "d"}, - {".", "a/b/c/../../../../d", "d"}, - {".", "a/b/c/d", "a/b/c/d"}, - - {"", "", "."}, - {"", "/", "."}, - {"", ".", "."}, - {"", "./a", "a"}, - {"", "..", "."}, - } - - for _, tc := range testCases { - d := Dir(filepath.FromSlash(tc.dir)) - if got := filepath.ToSlash(d.resolve(tc.name)); got != tc.want { - t.Errorf("dir=%q, name=%q: got %q, want %q", tc.dir, tc.name, got, tc.want) - } - } -} - -func TestWalk(t *testing.T) { - type walkStep struct { - name, frag string - final bool - } - - testCases := []struct { - dir string - want []walkStep - }{ - {"", []walkStep{ - {"", "", true}, - }}, - {"/", []walkStep{ - {"", "", true}, - }}, - {"/a", []walkStep{ - {"", "a", true}, - }}, - {"/a/", []walkStep{ - {"", "a", true}, - }}, - {"/a/b", []walkStep{ - {"", "a", false}, - {"a", "b", true}, - }}, - {"/a/b/", []walkStep{ - {"", "a", false}, - {"a", "b", true}, - }}, - {"/a/b/c", []walkStep{ - {"", "a", false}, - {"a", "b", false}, - {"b", "c", true}, - }}, - // The following test case is the one mentioned explicitly - // in the method description. - {"/foo/bar/x", []walkStep{ - {"", "foo", false}, - {"foo", "bar", false}, - {"bar", "x", true}, - }}, - } - - for _, tc := range testCases { - fs := NewMemFS().(*memFS) - - parts := strings.Split(tc.dir, "/") - for p := 2; p < len(parts); p++ { - d := strings.Join(parts[:p], "/") - if err := fs.Mkdir(d, 0666); err != nil { - t.Errorf("tc.dir=%q: mkdir: %q: %v", tc.dir, d, err) - } - } - - i, prevFrag := 0, "" - err := fs.walk("test", tc.dir, func(dir *memFSNode, frag string, final bool) error { - got := walkStep{ - name: prevFrag, - frag: frag, - final: final, - } - want := tc.want[i] - - if got != want { - return fmt.Errorf("got %+v, want %+v", got, want) - } - i, prevFrag = i+1, frag - return nil - }) - if err != nil { - t.Errorf("tc.dir=%q: %v", tc.dir, err) - } - } -} - -// find appends to ss the names of the named file and its children. It is -// analogous to the Unix find command. -// -// The returned strings are not guaranteed to be in any particular order. -func find(ss []string, fs FileSystem, name string) ([]string, error) { - stat, err := fs.Stat(name) - if err != nil { - return nil, err - } - ss = append(ss, name) - if stat.IsDir() { - f, err := fs.OpenFile(name, os.O_RDONLY, 0) - if err != nil { - return nil, err - } - defer f.Close() - children, err := f.Readdir(-1) - if err != nil { - return nil, err - } - for _, c := range children { - ss, err = find(ss, fs, path.Join(name, c.Name())) - if err != nil { - return nil, err - } - } - } - return ss, nil -} - -func testFS(t *testing.T, fs FileSystem) { - errStr := func(err error) string { - switch { - case os.IsExist(err): - return "errExist" - case os.IsNotExist(err): - return "errNotExist" - case err != nil: - return "err" - } - return "ok" - } - - // The non-"find" non-"stat" test cases should change the file system state. The - // indentation of the "find"s and "stat"s helps distinguish such test cases. - testCases := []string{ - " stat / want dir", - " stat /a want errNotExist", - " stat /d want errNotExist", - " stat /d/e want errNotExist", - "create /a A want ok", - " stat /a want 1", - "create /d/e EEE want errNotExist", - "mk-dir /a want errExist", - "mk-dir /d/m want errNotExist", - "mk-dir /d want ok", - " stat /d want dir", - "create /d/e EEE want ok", - " stat /d/e want 3", - " find / /a /d /d/e", - "create /d/f FFFF want ok", - "create /d/g GGGGGGG want ok", - "mk-dir /d/m want ok", - "mk-dir /d/m want errExist", - "create /d/m/p PPPPP want ok", - " stat /d/e want 3", - " stat /d/f want 4", - " stat /d/g want 7", - " stat /d/h want errNotExist", - " stat /d/m want dir", - " stat /d/m/p want 5", - " find / /a /d /d/e /d/f /d/g /d/m /d/m/p", - "rm-all /d want ok", - " stat /a want 1", - " stat /d want errNotExist", - " stat /d/e want errNotExist", - " stat /d/f want errNotExist", - " stat /d/g want errNotExist", - " stat /d/m want errNotExist", - " stat /d/m/p want errNotExist", - " find / /a", - "mk-dir /d/m want errNotExist", - "mk-dir /d want ok", - "create /d/f FFFF want ok", - "rm-all /d/f want ok", - "mk-dir /d/m want ok", - "rm-all /z want ok", - "rm-all / want err", - "create /b BB want ok", - " stat / want dir", - " stat /a want 1", - " stat /b want 2", - " stat /c want errNotExist", - " stat /d want dir", - " stat /d/m want dir", - " find / /a /b /d /d/m", - "move__ o=F /b /c want ok", - " stat /b want errNotExist", - " stat /c want 2", - " stat /d/m want dir", - " stat /d/n want errNotExist", - " find / /a /c /d /d/m", - "move__ o=F /d/m /d/n want ok", - "create /d/n/q QQQQ want ok", - " stat /d/m want errNotExist", - " stat /d/n want dir", - " stat /d/n/q want 4", - "move__ o=F /d /d/n/z want err", - "move__ o=T /c /d/n/q want ok", - " stat /c want errNotExist", - " stat /d/n/q want 2", - " find / /a /d /d/n /d/n/q", - "create /d/n/r RRRRR want ok", - "mk-dir /u want ok", - "mk-dir /u/v want ok", - "move__ o=F /d/n /u want errExist", - "create /t TTTTTT want ok", - "move__ o=F /d/n /t want errExist", - "rm-all /t want ok", - "move__ o=F /d/n /t want ok", - " stat /d want dir", - " stat /d/n want errNotExist", - " stat /d/n/r want errNotExist", - " stat /t want dir", - " stat /t/q want 2", - " stat /t/r want 5", - " find / /a /d /t /t/q /t/r /u /u/v", - "move__ o=F /t / want errExist", - "move__ o=T /t /u/v want ok", - " stat /u/v/r want 5", - "move__ o=F / /z want err", - " find / /a /d /u /u/v /u/v/q /u/v/r", - " stat /a want 1", - " stat /b want errNotExist", - " stat /c want errNotExist", - " stat /u/v/r want 5", - "copy__ o=F d=0 /a /b want ok", - "copy__ o=T d=0 /a /c want ok", - " stat /a want 1", - " stat /b want 1", - " stat /c want 1", - " stat /u/v/r want 5", - "copy__ o=F d=0 /u/v/r /b want errExist", - " stat /b want 1", - "copy__ o=T d=0 /u/v/r /b want ok", - " stat /a want 1", - " stat /b want 5", - " stat /u/v/r want 5", - "rm-all /a want ok", - "rm-all /b want ok", - "mk-dir /u/v/w want ok", - "create /u/v/w/s SSSSSSSS want ok", - " stat /d want dir", - " stat /d/x want errNotExist", - " stat /d/y want errNotExist", - " stat /u/v/r want 5", - " stat /u/v/w/s want 8", - " find / /c /d /u /u/v /u/v/q /u/v/r /u/v/w /u/v/w/s", - "copy__ o=T d=0 /u/v /d/x want ok", - "copy__ o=T d=∞ /u/v /d/y want ok", - "rm-all /u want ok", - " stat /d/x want dir", - " stat /d/x/q want errNotExist", - " stat /d/x/r want errNotExist", - " stat /d/x/w want errNotExist", - " stat /d/x/w/s want errNotExist", - " stat /d/y want dir", - " stat /d/y/q want 2", - " stat /d/y/r want 5", - " stat /d/y/w want dir", - " stat /d/y/w/s want 8", - " stat /u want errNotExist", - " find / /c /d /d/x /d/y /d/y/q /d/y/r /d/y/w /d/y/w/s", - "copy__ o=F d=∞ /d/y /d/x want errExist", - } - - for i, tc := range testCases { - tc = strings.TrimSpace(tc) - j := strings.IndexByte(tc, ' ') - if j < 0 { - t.Fatalf("test case #%d %q: invalid command", i, tc) - } - op, arg := tc[:j], tc[j+1:] - - switch op { - default: - t.Fatalf("test case #%d %q: invalid operation %q", i, tc, op) - - case "create": - parts := strings.Split(arg, " ") - if len(parts) != 4 || parts[2] != "want" { - t.Fatalf("test case #%d %q: invalid write", i, tc) - } - f, opErr := fs.OpenFile(parts[0], os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if got := errStr(opErr); got != parts[3] { - t.Fatalf("test case #%d %q: OpenFile: got %q (%v), want %q", i, tc, got, opErr, parts[3]) - } - if f != nil { - if _, err := f.Write([]byte(parts[1])); err != nil { - t.Fatalf("test case #%d %q: Write: %v", i, tc, err) - } - if err := f.Close(); err != nil { - t.Fatalf("test case #%d %q: Close: %v", i, tc, err) - } - } - - case "find": - got, err := find(nil, fs, "/") - if err != nil { - t.Fatalf("test case #%d %q: find: %v", i, tc, err) - } - sort.Strings(got) - want := strings.Split(arg, " ") - if !reflect.DeepEqual(got, want) { - t.Fatalf("test case #%d %q:\ngot %s\nwant %s", i, tc, got, want) - } - - case "copy__", "mk-dir", "move__", "rm-all", "stat": - nParts := 3 - switch op { - case "copy__": - nParts = 6 - case "move__": - nParts = 5 - } - parts := strings.Split(arg, " ") - if len(parts) != nParts { - t.Fatalf("test case #%d %q: invalid %s", i, tc, op) - } - - got, opErr := "", error(nil) - switch op { - case "copy__": - depth := 0 - if parts[1] == "d=∞" { - depth = infiniteDepth - } - _, opErr = copyFiles(fs, parts[2], parts[3], parts[0] == "o=T", depth, 0) - case "mk-dir": - opErr = fs.Mkdir(parts[0], 0777) - case "move__": - _, opErr = moveFiles(fs, parts[1], parts[2], parts[0] == "o=T") - case "rm-all": - opErr = fs.RemoveAll(parts[0]) - case "stat": - var stat os.FileInfo - fileName := parts[0] - if stat, opErr = fs.Stat(fileName); opErr == nil { - if stat.IsDir() { - got = "dir" - } else { - got = strconv.Itoa(int(stat.Size())) - } - - if fileName == "/" { - // For a Dir FileSystem, the virtual file system root maps to a - // real file system name like "/tmp/webdav-test012345", which does - // not end with "/". We skip such cases. - } else if statName := stat.Name(); path.Base(fileName) != statName { - t.Fatalf("test case #%d %q: file name %q inconsistent with stat name %q", - i, tc, fileName, statName) - } - } - } - if got == "" { - got = errStr(opErr) - } - - if parts[len(parts)-2] != "want" { - t.Fatalf("test case #%d %q: invalid %s", i, tc, op) - } - if want := parts[len(parts)-1]; got != want { - t.Fatalf("test case #%d %q: got %q (%v), want %q", i, tc, got, opErr, want) - } - } - } -} - -func TestDir(t *testing.T) { - switch runtime.GOOS { - case "nacl": - t.Skip("see golang.org/issue/12004") - case "plan9": - t.Skip("see golang.org/issue/11453") - } - - td, err := ioutil.TempDir("", "webdav-test") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(td) - testFS(t, Dir(td)) -} - -func TestMemFS(t *testing.T) { - testFS(t, NewMemFS()) -} - -func TestMemFSRoot(t *testing.T) { - fs := NewMemFS() - for i := 0; i < 5; i++ { - stat, err := fs.Stat("/") - if err != nil { - t.Fatalf("i=%d: Stat: %v", i, err) - } - if !stat.IsDir() { - t.Fatalf("i=%d: Stat.IsDir is false, want true", i) - } - - f, err := fs.OpenFile("/", os.O_RDONLY, 0) - if err != nil { - t.Fatalf("i=%d: OpenFile: %v", i, err) - } - defer f.Close() - children, err := f.Readdir(-1) - if err != nil { - t.Fatalf("i=%d: Readdir: %v", i, err) - } - if len(children) != i { - t.Fatalf("i=%d: got %d children, want %d", i, len(children), i) - } - - if _, err := f.Write(make([]byte, 1)); err == nil { - t.Fatalf("i=%d: Write: got nil error, want non-nil", i) - } - - if err := fs.Mkdir(fmt.Sprintf("/dir%d", i), 0777); err != nil { - t.Fatalf("i=%d: Mkdir: %v", i, err) - } - } -} - -func TestMemFileReaddir(t *testing.T) { - fs := NewMemFS() - if err := fs.Mkdir("/foo", 0777); err != nil { - t.Fatalf("Mkdir: %v", err) - } - readdir := func(count int) ([]os.FileInfo, error) { - f, err := fs.OpenFile("/foo", os.O_RDONLY, 0) - if err != nil { - t.Fatalf("OpenFile: %v", err) - } - defer f.Close() - return f.Readdir(count) - } - if got, err := readdir(-1); len(got) != 0 || err != nil { - t.Fatalf("readdir(-1): got %d fileInfos with err=%v, want 0, ", len(got), err) - } - if got, err := readdir(+1); len(got) != 0 || err != io.EOF { - t.Fatalf("readdir(+1): got %d fileInfos with err=%v, want 0, EOF", len(got), err) - } -} - -func TestMemFile(t *testing.T) { - testCases := []string{ - "wantData ", - "wantSize 0", - "write abc", - "wantData abc", - "write de", - "wantData abcde", - "wantSize 5", - "write 5*x", - "write 4*y+2*z", - "write 3*st", - "wantData abcdexxxxxyyyyzzststst", - "wantSize 22", - "seek set 4 want 4", - "write EFG", - "wantData abcdEFGxxxyyyyzzststst", - "wantSize 22", - "seek set 2 want 2", - "read cdEF", - "read Gx", - "seek cur 0 want 8", - "seek cur 2 want 10", - "seek cur -1 want 9", - "write J", - "wantData abcdEFGxxJyyyyzzststst", - "wantSize 22", - "seek cur -4 want 6", - "write ghijk", - "wantData abcdEFghijkyyyzzststst", - "wantSize 22", - "read yyyz", - "seek cur 0 want 15", - "write ", - "seek cur 0 want 15", - "read ", - "seek cur 0 want 15", - "seek end -3 want 19", - "write ZZ", - "wantData abcdEFghijkyyyzzstsZZt", - "wantSize 22", - "write 4*A", - "wantData abcdEFghijkyyyzzstsZZAAAA", - "wantSize 25", - "seek end 0 want 25", - "seek end -5 want 20", - "read Z+4*A", - "write 5*B", - "wantData abcdEFghijkyyyzzstsZZAAAABBBBB", - "wantSize 30", - "seek end 10 want 40", - "write C", - "wantData abcdEFghijkyyyzzstsZZAAAABBBBB..........C", - "wantSize 41", - "write D", - "wantData abcdEFghijkyyyzzstsZZAAAABBBBB..........CD", - "wantSize 42", - "seek set 43 want 43", - "write E", - "wantData abcdEFghijkyyyzzstsZZAAAABBBBB..........CD.E", - "wantSize 44", - "seek set 0 want 0", - "write 5*123456789_", - "wantData 123456789_123456789_123456789_123456789_123456789_", - "wantSize 50", - "seek cur 0 want 50", - "seek cur -99 want err", - } - - const filename = "/foo" - fs := NewMemFS() - f, err := fs.OpenFile(filename, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - t.Fatalf("OpenFile: %v", err) - } - defer f.Close() - - for i, tc := range testCases { - j := strings.IndexByte(tc, ' ') - if j < 0 { - t.Fatalf("test case #%d %q: invalid command", i, tc) - } - op, arg := tc[:j], tc[j+1:] - - // Expand an arg like "3*a+2*b" to "aaabb". - parts := strings.Split(arg, "+") - for j, part := range parts { - if k := strings.IndexByte(part, '*'); k >= 0 { - repeatCount, repeatStr := part[:k], part[k+1:] - n, err := strconv.Atoi(repeatCount) - if err != nil { - t.Fatalf("test case #%d %q: invalid repeat count %q", i, tc, repeatCount) - } - parts[j] = strings.Repeat(repeatStr, n) - } - } - arg = strings.Join(parts, "") - - switch op { - default: - t.Fatalf("test case #%d %q: invalid operation %q", i, tc, op) - - case "read": - buf := make([]byte, len(arg)) - if _, err := io.ReadFull(f, buf); err != nil { - t.Fatalf("test case #%d %q: ReadFull: %v", i, tc, err) - } - if got := string(buf); got != arg { - t.Fatalf("test case #%d %q:\ngot %q\nwant %q", i, tc, got, arg) - } - - case "seek": - parts := strings.Split(arg, " ") - if len(parts) != 4 { - t.Fatalf("test case #%d %q: invalid seek", i, tc) - } - - whence := 0 - switch parts[0] { - default: - t.Fatalf("test case #%d %q: invalid seek whence", i, tc) - case "set": - whence = os.SEEK_SET - case "cur": - whence = os.SEEK_CUR - case "end": - whence = os.SEEK_END - } - offset, err := strconv.Atoi(parts[1]) - if err != nil { - t.Fatalf("test case #%d %q: invalid offset %q", i, tc, parts[1]) - } - - if parts[2] != "want" { - t.Fatalf("test case #%d %q: invalid seek", i, tc) - } - if parts[3] == "err" { - _, err := f.Seek(int64(offset), whence) - if err == nil { - t.Fatalf("test case #%d %q: Seek returned nil error, want non-nil", i, tc) - } - } else { - got, err := f.Seek(int64(offset), whence) - if err != nil { - t.Fatalf("test case #%d %q: Seek: %v", i, tc, err) - } - want, err := strconv.Atoi(parts[3]) - if err != nil { - t.Fatalf("test case #%d %q: invalid want %q", i, tc, parts[3]) - } - if got != int64(want) { - t.Fatalf("test case #%d %q: got %d, want %d", i, tc, got, want) - } - } - - case "write": - n, err := f.Write([]byte(arg)) - if err != nil { - t.Fatalf("test case #%d %q: write: %v", i, tc, err) - } - if n != len(arg) { - t.Fatalf("test case #%d %q: write returned %d bytes, want %d", i, tc, n, len(arg)) - } - - case "wantData": - g, err := fs.OpenFile(filename, os.O_RDONLY, 0666) - if err != nil { - t.Fatalf("test case #%d %q: OpenFile: %v", i, tc, err) - } - gotBytes, err := ioutil.ReadAll(g) - if err != nil { - t.Fatalf("test case #%d %q: ReadAll: %v", i, tc, err) - } - for i, c := range gotBytes { - if c == '\x00' { - gotBytes[i] = '.' - } - } - got := string(gotBytes) - if got != arg { - t.Fatalf("test case #%d %q:\ngot %q\nwant %q", i, tc, got, arg) - } - if err := g.Close(); err != nil { - t.Fatalf("test case #%d %q: Close: %v", i, tc, err) - } - - case "wantSize": - n, err := strconv.Atoi(arg) - if err != nil { - t.Fatalf("test case #%d %q: invalid size %q", i, tc, arg) - } - fi, err := fs.Stat(filename) - if err != nil { - t.Fatalf("test case #%d %q: Stat: %v", i, tc, err) - } - if got, want := fi.Size(), int64(n); got != want { - t.Fatalf("test case #%d %q: got %d, want %d", i, tc, got, want) - } - } - } -} - -// TestMemFileWriteAllocs tests that writing N consecutive 1KiB chunks to a -// memFile doesn't allocate a new buffer for each of those N times. Otherwise, -// calling io.Copy(aMemFile, src) is likely to have quadratic complexity. -func TestMemFileWriteAllocs(t *testing.T) { - fs := NewMemFS() - f, err := fs.OpenFile("/xxx", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - t.Fatalf("OpenFile: %v", err) - } - defer f.Close() - - xxx := make([]byte, 1024) - for i := range xxx { - xxx[i] = 'x' - } - - a := testing.AllocsPerRun(100, func() { - f.Write(xxx) - }) - // AllocsPerRun returns an integral value, so we compare the rounded-down - // number to zero. - if a > 0 { - t.Fatalf("%v allocs per run, want 0", a) - } -} - -func BenchmarkMemFileWrite(b *testing.B) { - fs := NewMemFS() - xxx := make([]byte, 1024) - for i := range xxx { - xxx[i] = 'x' - } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - f, err := fs.OpenFile("/xxx", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - b.Fatalf("OpenFile: %v", err) - } - for j := 0; j < 100; j++ { - f.Write(xxx) - } - if err := f.Close(); err != nil { - b.Fatalf("Close: %v", err) - } - if err := fs.RemoveAll("/xxx"); err != nil { - b.Fatalf("RemoveAll: %v", err) - } - } -} - -func TestCopyMoveProps(t *testing.T) { - fs := NewMemFS() - create := func(name string) error { - f, err := fs.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - return err - } - _, wErr := f.Write([]byte("contents")) - cErr := f.Close() - if wErr != nil { - return wErr - } - return cErr - } - patch := func(name string, patches ...Proppatch) error { - f, err := fs.OpenFile(name, os.O_RDWR, 0666) - if err != nil { - return err - } - _, pErr := f.(DeadPropsHolder).Patch(patches) - cErr := f.Close() - if pErr != nil { - return pErr - } - return cErr - } - props := func(name string) (map[xml.Name]Property, error) { - f, err := fs.OpenFile(name, os.O_RDWR, 0666) - if err != nil { - return nil, err - } - m, pErr := f.(DeadPropsHolder).DeadProps() - cErr := f.Close() - if pErr != nil { - return nil, pErr - } - if cErr != nil { - return nil, cErr - } - return m, nil - } - - p0 := Property{ - XMLName: xml.Name{Space: "x:", Local: "boat"}, - InnerXML: []byte("pea-green"), - } - p1 := Property{ - XMLName: xml.Name{Space: "x:", Local: "ring"}, - InnerXML: []byte("1 shilling"), - } - p2 := Property{ - XMLName: xml.Name{Space: "x:", Local: "spoon"}, - InnerXML: []byte("runcible"), - } - p3 := Property{ - XMLName: xml.Name{Space: "x:", Local: "moon"}, - InnerXML: []byte("light"), - } - - if err := create("/src"); err != nil { - t.Fatalf("create /src: %v", err) - } - if err := patch("/src", Proppatch{Props: []Property{p0, p1}}); err != nil { - t.Fatalf("patch /src +p0 +p1: %v", err) - } - if _, err := copyFiles(fs, "/src", "/tmp", true, infiniteDepth, 0); err != nil { - t.Fatalf("copyFiles /src /tmp: %v", err) - } - if _, err := moveFiles(fs, "/tmp", "/dst", true); err != nil { - t.Fatalf("moveFiles /tmp /dst: %v", err) - } - if err := patch("/src", Proppatch{Props: []Property{p0}, Remove: true}); err != nil { - t.Fatalf("patch /src -p0: %v", err) - } - if err := patch("/src", Proppatch{Props: []Property{p2}}); err != nil { - t.Fatalf("patch /src +p2: %v", err) - } - if err := patch("/dst", Proppatch{Props: []Property{p1}, Remove: true}); err != nil { - t.Fatalf("patch /dst -p1: %v", err) - } - if err := patch("/dst", Proppatch{Props: []Property{p3}}); err != nil { - t.Fatalf("patch /dst +p3: %v", err) - } - - gotSrc, err := props("/src") - if err != nil { - t.Fatalf("props /src: %v", err) - } - wantSrc := map[xml.Name]Property{ - p1.XMLName: p1, - p2.XMLName: p2, - } - if !reflect.DeepEqual(gotSrc, wantSrc) { - t.Fatalf("props /src:\ngot %v\nwant %v", gotSrc, wantSrc) - } - - gotDst, err := props("/dst") - if err != nil { - t.Fatalf("props /dst: %v", err) - } - wantDst := map[xml.Name]Property{ - p0.XMLName: p0, - p3.XMLName: p3, - } - if !reflect.DeepEqual(gotDst, wantDst) { - t.Fatalf("props /dst:\ngot %v\nwant %v", gotDst, wantDst) - } -} - -func TestWalkFS(t *testing.T) { - testCases := []struct { - desc string - buildfs []string - startAt string - depth int - walkFn filepath.WalkFunc - want []string - }{{ - "just root", - []string{}, - "/", - infiniteDepth, - nil, - []string{ - "/", - }, - }, { - "infinite walk from root", - []string{ - "mkdir /a", - "mkdir /a/b", - "touch /a/b/c", - "mkdir /a/d", - "mkdir /e", - "touch /f", - }, - "/", - infiniteDepth, - nil, - []string{ - "/", - "/a", - "/a/b", - "/a/b/c", - "/a/d", - "/e", - "/f", - }, - }, { - "infinite walk from subdir", - []string{ - "mkdir /a", - "mkdir /a/b", - "touch /a/b/c", - "mkdir /a/d", - "mkdir /e", - "touch /f", - }, - "/a", - infiniteDepth, - nil, - []string{ - "/a", - "/a/b", - "/a/b/c", - "/a/d", - }, - }, { - "depth 1 walk from root", - []string{ - "mkdir /a", - "mkdir /a/b", - "touch /a/b/c", - "mkdir /a/d", - "mkdir /e", - "touch /f", - }, - "/", - 1, - nil, - []string{ - "/", - "/a", - "/e", - "/f", - }, - }, { - "depth 1 walk from subdir", - []string{ - "mkdir /a", - "mkdir /a/b", - "touch /a/b/c", - "mkdir /a/b/g", - "mkdir /a/b/g/h", - "touch /a/b/g/i", - "touch /a/b/g/h/j", - }, - "/a/b", - 1, - nil, - []string{ - "/a/b", - "/a/b/c", - "/a/b/g", - }, - }, { - "depth 0 walk from subdir", - []string{ - "mkdir /a", - "mkdir /a/b", - "touch /a/b/c", - "mkdir /a/b/g", - "mkdir /a/b/g/h", - "touch /a/b/g/i", - "touch /a/b/g/h/j", - }, - "/a/b", - 0, - nil, - []string{ - "/a/b", - }, - }, { - "infinite walk from file", - []string{ - "mkdir /a", - "touch /a/b", - "touch /a/c", - }, - "/a/b", - 0, - nil, - []string{ - "/a/b", - }, - }, { - "infinite walk with skipped subdir", - []string{ - "mkdir /a", - "mkdir /a/b", - "touch /a/b/c", - "mkdir /a/b/g", - "mkdir /a/b/g/h", - "touch /a/b/g/i", - "touch /a/b/g/h/j", - "touch /a/b/z", - }, - "/", - infiniteDepth, - func(path string, info os.FileInfo, err error) error { - if path == "/a/b/g" { - return filepath.SkipDir - } - return nil - }, - []string{ - "/", - "/a", - "/a/b", - "/a/b/c", - "/a/b/z", - }, - }} - for _, tc := range testCases { - fs, err := buildTestFS(tc.buildfs) - if err != nil { - t.Fatalf("%s: cannot create test filesystem: %v", tc.desc, err) - } - var got []string - traceFn := func(path string, info os.FileInfo, err error) error { - if tc.walkFn != nil { - err = tc.walkFn(path, info, err) - if err != nil { - return err - } - } - got = append(got, path) - return nil - } - fi, err := fs.Stat(tc.startAt) - if err != nil { - t.Fatalf("%s: cannot stat: %v", tc.desc, err) - } - err = walkFS(fs, tc.depth, tc.startAt, fi, traceFn) - if err != nil { - t.Errorf("%s:\ngot error %v, want nil", tc.desc, err) - continue - } - sort.Strings(got) - sort.Strings(tc.want) - if !reflect.DeepEqual(got, tc.want) { - t.Errorf("%s:\ngot %q\nwant %q", tc.desc, got, tc.want) - continue - } - } -} - -func buildTestFS(buildfs []string) (FileSystem, error) { - // TODO: Could this be merged with the build logic in TestFS? - - fs := NewMemFS() - for _, b := range buildfs { - op := strings.Split(b, " ") - switch op[0] { - case "mkdir": - err := fs.Mkdir(op[1], os.ModeDir|0777) - if err != nil { - return nil, err - } - case "touch": - f, err := fs.OpenFile(op[1], os.O_RDWR|os.O_CREATE, 0666) - if err != nil { - return nil, err - } - f.Close() - case "write": - f, err := fs.OpenFile(op[1], os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - return nil, err - } - _, err = f.Write([]byte(op[2])) - f.Close() - if err != nil { - return nil, err - } - default: - return nil, fmt.Errorf("unknown file operation %q", op[0]) - } - } - return fs, nil -} diff --git a/vendor/golang.org/x/net/webdav/if.go b/vendor/golang.org/x/net/webdav/if.go deleted file mode 100644 index 416e81c..0000000 --- a/vendor/golang.org/x/net/webdav/if.go +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -// The If header is covered by Section 10.4. -// http://www.webdav.org/specs/rfc4918.html#HEADER_If - -import ( - "strings" -) - -// ifHeader is a disjunction (OR) of ifLists. -type ifHeader struct { - lists []ifList -} - -// ifList is a conjunction (AND) of Conditions, and an optional resource tag. -type ifList struct { - resourceTag string - conditions []Condition -} - -// parseIfHeader parses the "If: foo bar" HTTP header. The httpHeader string -// should omit the "If:" prefix and have any "\r\n"s collapsed to a " ", as is -// returned by req.Header.Get("If") for a http.Request req. -func parseIfHeader(httpHeader string) (h ifHeader, ok bool) { - s := strings.TrimSpace(httpHeader) - switch tokenType, _, _ := lex(s); tokenType { - case '(': - return parseNoTagLists(s) - case angleTokenType: - return parseTaggedLists(s) - default: - return ifHeader{}, false - } -} - -func parseNoTagLists(s string) (h ifHeader, ok bool) { - for { - l, remaining, ok := parseList(s) - if !ok { - return ifHeader{}, false - } - h.lists = append(h.lists, l) - if remaining == "" { - return h, true - } - s = remaining - } -} - -func parseTaggedLists(s string) (h ifHeader, ok bool) { - resourceTag, n := "", 0 - for first := true; ; first = false { - tokenType, tokenStr, remaining := lex(s) - switch tokenType { - case angleTokenType: - if !first && n == 0 { - return ifHeader{}, false - } - resourceTag, n = tokenStr, 0 - s = remaining - case '(': - n++ - l, remaining, ok := parseList(s) - if !ok { - return ifHeader{}, false - } - l.resourceTag = resourceTag - h.lists = append(h.lists, l) - if remaining == "" { - return h, true - } - s = remaining - default: - return ifHeader{}, false - } - } -} - -func parseList(s string) (l ifList, remaining string, ok bool) { - tokenType, _, s := lex(s) - if tokenType != '(' { - return ifList{}, "", false - } - for { - tokenType, _, remaining = lex(s) - if tokenType == ')' { - if len(l.conditions) == 0 { - return ifList{}, "", false - } - return l, remaining, true - } - c, remaining, ok := parseCondition(s) - if !ok { - return ifList{}, "", false - } - l.conditions = append(l.conditions, c) - s = remaining - } -} - -func parseCondition(s string) (c Condition, remaining string, ok bool) { - tokenType, tokenStr, s := lex(s) - if tokenType == notTokenType { - c.Not = true - tokenType, tokenStr, s = lex(s) - } - switch tokenType { - case strTokenType, angleTokenType: - c.Token = tokenStr - case squareTokenType: - c.ETag = tokenStr - default: - return Condition{}, "", false - } - return c, s, true -} - -// Single-rune tokens like '(' or ')' have a token type equal to their rune. -// All other tokens have a negative token type. -const ( - errTokenType = rune(-1) - eofTokenType = rune(-2) - strTokenType = rune(-3) - notTokenType = rune(-4) - angleTokenType = rune(-5) - squareTokenType = rune(-6) -) - -func lex(s string) (tokenType rune, tokenStr string, remaining string) { - // The net/textproto Reader that parses the HTTP header will collapse - // Linear White Space that spans multiple "\r\n" lines to a single " ", - // so we don't need to look for '\r' or '\n'. - for len(s) > 0 && (s[0] == '\t' || s[0] == ' ') { - s = s[1:] - } - if len(s) == 0 { - return eofTokenType, "", "" - } - i := 0 -loop: - for ; i < len(s); i++ { - switch s[i] { - case '\t', ' ', '(', ')', '<', '>', '[', ']': - break loop - } - } - - if i != 0 { - tokenStr, remaining = s[:i], s[i:] - if tokenStr == "Not" { - return notTokenType, "", remaining - } - return strTokenType, tokenStr, remaining - } - - j := 0 - switch s[0] { - case '<': - j, tokenType = strings.IndexByte(s, '>'), angleTokenType - case '[': - j, tokenType = strings.IndexByte(s, ']'), squareTokenType - default: - return rune(s[0]), "", s[1:] - } - if j < 0 { - return errTokenType, "", "" - } - return tokenType, s[1:j], s[j+1:] -} diff --git a/vendor/golang.org/x/net/webdav/if_test.go b/vendor/golang.org/x/net/webdav/if_test.go deleted file mode 100644 index aad61a4..0000000 --- a/vendor/golang.org/x/net/webdav/if_test.go +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "reflect" - "strings" - "testing" -) - -func TestParseIfHeader(t *testing.T) { - // The "section x.y.z" test cases come from section x.y.z of the spec at - // http://www.webdav.org/specs/rfc4918.html - testCases := []struct { - desc string - input string - want ifHeader - }{{ - "bad: empty", - ``, - ifHeader{}, - }, { - "bad: no parens", - `foobar`, - ifHeader{}, - }, { - "bad: empty list #1", - `()`, - ifHeader{}, - }, { - "bad: empty list #2", - `(a) (b c) () (d)`, - ifHeader{}, - }, { - "bad: no list after resource #1", - ``, - ifHeader{}, - }, { - "bad: no list after resource #2", - ` (a)`, - ifHeader{}, - }, { - "bad: no list after resource #3", - ` (a) (b) `, - ifHeader{}, - }, { - "bad: no-tag-list followed by tagged-list", - `(a) (b) (c)`, - ifHeader{}, - }, { - "bad: unfinished list", - `(a`, - ifHeader{}, - }, { - "bad: unfinished ETag", - `([b`, - ifHeader{}, - }, { - "bad: unfinished Notted list", - `(Not a`, - ifHeader{}, - }, { - "bad: double Not", - `(Not Not a)`, - ifHeader{}, - }, { - "good: one list with a Token", - `(a)`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Token: `a`, - }}, - }}, - }, - }, { - "good: one list with an ETag", - `([a])`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - ETag: `a`, - }}, - }}, - }, - }, { - "good: one list with three Nots", - `(Not a Not b Not [d])`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Not: true, - Token: `a`, - }, { - Not: true, - Token: `b`, - }, { - Not: true, - ETag: `d`, - }}, - }}, - }, - }, { - "good: two lists", - `(a) (b)`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Token: `a`, - }}, - }, { - conditions: []Condition{{ - Token: `b`, - }}, - }}, - }, - }, { - "good: two Notted lists", - `(Not a) (Not b)`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Not: true, - Token: `a`, - }}, - }, { - conditions: []Condition{{ - Not: true, - Token: `b`, - }}, - }}, - }, - }, { - "section 7.5.1", - ` - ()`, - ifHeader{ - lists: []ifList{{ - resourceTag: `http://www.example.com/users/f/fielding/index.html`, - conditions: []Condition{{ - Token: `urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6`, - }}, - }}, - }, - }, { - "section 7.5.2 #1", - `()`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Token: `urn:uuid:150852e2-3847-42d5-8cbe-0f4f296f26cf`, - }}, - }}, - }, - }, { - "section 7.5.2 #2", - ` - ()`, - ifHeader{ - lists: []ifList{{ - resourceTag: `http://example.com/locked/`, - conditions: []Condition{{ - Token: `urn:uuid:150852e2-3847-42d5-8cbe-0f4f296f26cf`, - }}, - }}, - }, - }, { - "section 7.5.2 #3", - ` - ()`, - ifHeader{ - lists: []ifList{{ - resourceTag: `http://example.com/locked/member`, - conditions: []Condition{{ - Token: `urn:uuid:150852e2-3847-42d5-8cbe-0f4f296f26cf`, - }}, - }}, - }, - }, { - "section 9.9.6", - `() - ()`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Token: `urn:uuid:fe184f2e-6eec-41d0-c765-01adc56e6bb4`, - }}, - }, { - conditions: []Condition{{ - Token: `urn:uuid:e454f3f3-acdc-452a-56c7-00a5c91e4b77`, - }}, - }}, - }, - }, { - "section 9.10.8", - `()`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Token: `urn:uuid:e71d4fae-5dec-22d6-fea5-00a0c91e6be4`, - }}, - }}, - }, - }, { - "section 10.4.6", - `( - ["I am an ETag"]) - (["I am another ETag"])`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Token: `urn:uuid:181d4fae-7d8c-11d0-a765-00a0c91e6bf2`, - }, { - ETag: `"I am an ETag"`, - }}, - }, { - conditions: []Condition{{ - ETag: `"I am another ETag"`, - }}, - }}, - }, - }, { - "section 10.4.7", - `(Not - )`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Not: true, - Token: `urn:uuid:181d4fae-7d8c-11d0-a765-00a0c91e6bf2`, - }, { - Token: `urn:uuid:58f202ac-22cf-11d1-b12d-002035b29092`, - }}, - }}, - }, - }, { - "section 10.4.8", - `() - (Not )`, - ifHeader{ - lists: []ifList{{ - conditions: []Condition{{ - Token: `urn:uuid:181d4fae-7d8c-11d0-a765-00a0c91e6bf2`, - }}, - }, { - conditions: []Condition{{ - Not: true, - Token: `DAV:no-lock`, - }}, - }}, - }, - }, { - "section 10.4.9", - ` - ( - [W/"A weak ETag"]) (["strong ETag"])`, - ifHeader{ - lists: []ifList{{ - resourceTag: `/resource1`, - conditions: []Condition{{ - Token: `urn:uuid:181d4fae-7d8c-11d0-a765-00a0c91e6bf2`, - }, { - ETag: `W/"A weak ETag"`, - }}, - }, { - resourceTag: `/resource1`, - conditions: []Condition{{ - ETag: `"strong ETag"`, - }}, - }}, - }, - }, { - "section 10.4.10", - ` - ()`, - ifHeader{ - lists: []ifList{{ - resourceTag: `http://www.example.com/specs/`, - conditions: []Condition{{ - Token: `urn:uuid:181d4fae-7d8c-11d0-a765-00a0c91e6bf2`, - }}, - }}, - }, - }, { - "section 10.4.11 #1", - ` (["4217"])`, - ifHeader{ - lists: []ifList{{ - resourceTag: `/specs/rfc2518.doc`, - conditions: []Condition{{ - ETag: `"4217"`, - }}, - }}, - }, - }, { - "section 10.4.11 #2", - ` (Not ["4217"])`, - ifHeader{ - lists: []ifList{{ - resourceTag: `/specs/rfc2518.doc`, - conditions: []Condition{{ - Not: true, - ETag: `"4217"`, - }}, - }}, - }, - }} - - for _, tc := range testCases { - got, ok := parseIfHeader(strings.Replace(tc.input, "\n", "", -1)) - if gotEmpty := reflect.DeepEqual(got, ifHeader{}); gotEmpty == ok { - t.Errorf("%s: should be different: empty header == %t, ok == %t", tc.desc, gotEmpty, ok) - continue - } - if !reflect.DeepEqual(got, tc.want) { - t.Errorf("%s:\ngot %v\nwant %v", tc.desc, got, tc.want) - continue - } - } -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/README b/vendor/golang.org/x/net/webdav/internal/xml/README deleted file mode 100644 index 89656f4..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/README +++ /dev/null @@ -1,11 +0,0 @@ -This is a fork of the encoding/xml package at ca1d6c4, the last commit before -https://go.googlesource.com/go/+/c0d6d33 "encoding/xml: restore Go 1.4 name -space behavior" made late in the lead-up to the Go 1.5 release. - -The list of encoding/xml changes is at -https://go.googlesource.com/go/+log/master/src/encoding/xml - -This fork is temporary, and I (nigeltao) expect to revert it after Go 1.6 is -released. - -See http://golang.org/issue/11841 diff --git a/vendor/golang.org/x/net/webdav/internal/xml/atom_test.go b/vendor/golang.org/x/net/webdav/internal/xml/atom_test.go deleted file mode 100644 index a712843..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/atom_test.go +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2011 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 xml - -import "time" - -var atomValue = &Feed{ - XMLName: Name{"http://www.w3.org/2005/Atom", "feed"}, - Title: "Example Feed", - Link: []Link{{Href: "http://example.org/"}}, - Updated: ParseTime("2003-12-13T18:30:02Z"), - Author: Person{Name: "John Doe"}, - Id: "urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6", - - Entry: []Entry{ - { - Title: "Atom-Powered Robots Run Amok", - Link: []Link{{Href: "http://example.org/2003/12/13/atom03"}}, - Id: "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a", - Updated: ParseTime("2003-12-13T18:30:02Z"), - Summary: NewText("Some text."), - }, - }, -} - -var atomXml = `` + - `` + - `Example Feed` + - `urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6` + - `` + - `John Doe` + - `` + - `Atom-Powered Robots Run Amok` + - `urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a` + - `` + - `2003-12-13T18:30:02Z` + - `` + - `Some text.` + - `` + - `` - -func ParseTime(str string) time.Time { - t, err := time.Parse(time.RFC3339, str) - if err != nil { - panic(err) - } - return t -} - -func NewText(text string) Text { - return Text{ - Body: text, - } -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/example_test.go b/vendor/golang.org/x/net/webdav/internal/xml/example_test.go deleted file mode 100644 index becedd5..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/example_test.go +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xml_test - -import ( - "encoding/xml" - "fmt" - "os" -) - -func ExampleMarshalIndent() { - type Address struct { - City, State string - } - type Person struct { - XMLName xml.Name `xml:"person"` - Id int `xml:"id,attr"` - FirstName string `xml:"name>first"` - LastName string `xml:"name>last"` - Age int `xml:"age"` - Height float32 `xml:"height,omitempty"` - Married bool - Address - Comment string `xml:",comment"` - } - - v := &Person{Id: 13, FirstName: "John", LastName: "Doe", Age: 42} - v.Comment = " Need more details. " - v.Address = Address{"Hanga Roa", "Easter Island"} - - output, err := xml.MarshalIndent(v, " ", " ") - if err != nil { - fmt.Printf("error: %v\n", err) - } - - os.Stdout.Write(output) - // Output: - // - // - // John - // Doe - // - // 42 - // false - // Hanga Roa - // Easter Island - // - // -} - -func ExampleEncoder() { - type Address struct { - City, State string - } - type Person struct { - XMLName xml.Name `xml:"person"` - Id int `xml:"id,attr"` - FirstName string `xml:"name>first"` - LastName string `xml:"name>last"` - Age int `xml:"age"` - Height float32 `xml:"height,omitempty"` - Married bool - Address - Comment string `xml:",comment"` - } - - v := &Person{Id: 13, FirstName: "John", LastName: "Doe", Age: 42} - v.Comment = " Need more details. " - v.Address = Address{"Hanga Roa", "Easter Island"} - - enc := xml.NewEncoder(os.Stdout) - enc.Indent(" ", " ") - if err := enc.Encode(v); err != nil { - fmt.Printf("error: %v\n", err) - } - - // Output: - // - // - // John - // Doe - // - // 42 - // false - // Hanga Roa - // Easter Island - // - // -} - -// This example demonstrates unmarshaling an XML excerpt into a value with -// some preset fields. Note that the Phone field isn't modified and that -// the XML element is ignored. Also, the Groups field is assigned -// considering the element path provided in its tag. -func ExampleUnmarshal() { - type Email struct { - Where string `xml:"where,attr"` - Addr string - } - type Address struct { - City, State string - } - type Result struct { - XMLName xml.Name `xml:"Person"` - Name string `xml:"FullName"` - Phone string - Email []Email - Groups []string `xml:"Group>Value"` - Address - } - v := Result{Name: "none", Phone: "none"} - - data := ` - - Grace R. Emlin - Example Inc. - - gre@example.com - - - gre@work.com - - - Friends - Squash - - Hanga Roa - Easter Island - - ` - err := xml.Unmarshal([]byte(data), &v) - if err != nil { - fmt.Printf("error: %v", err) - return - } - fmt.Printf("XMLName: %#v\n", v.XMLName) - fmt.Printf("Name: %q\n", v.Name) - fmt.Printf("Phone: %q\n", v.Phone) - fmt.Printf("Email: %v\n", v.Email) - fmt.Printf("Groups: %v\n", v.Groups) - fmt.Printf("Address: %v\n", v.Address) - // Output: - // XMLName: xml.Name{Space:"", Local:"Person"} - // Name: "Grace R. Emlin" - // Phone: "none" - // Email: [{home gre@example.com} {work gre@work.com}] - // Groups: [Friends Squash] - // Address: {Hanga Roa Easter Island} -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/marshal.go b/vendor/golang.org/x/net/webdav/internal/xml/marshal.go deleted file mode 100644 index 3c3b6ac..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/marshal.go +++ /dev/null @@ -1,1223 +0,0 @@ -// Copyright 2011 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 xml - -import ( - "bufio" - "bytes" - "encoding" - "fmt" - "io" - "reflect" - "strconv" - "strings" -) - -const ( - // A generic XML header suitable for use with the output of Marshal. - // This is not automatically added to any output of this package, - // it is provided as a convenience. - Header = `` + "\n" -) - -// Marshal returns the XML encoding of v. -// -// Marshal handles an array or slice by marshalling each of the elements. -// Marshal handles a pointer by marshalling the value it points at or, if the -// pointer is nil, by writing nothing. Marshal handles an interface value by -// marshalling the value it contains or, if the interface value is nil, by -// writing nothing. Marshal handles all other data by writing one or more XML -// elements containing the data. -// -// The name for the XML elements is taken from, in order of preference: -// - the tag on the XMLName field, if the data is a struct -// - the value of the XMLName field of type xml.Name -// - the tag of the struct field used to obtain the data -// - the name of the struct field used to obtain the data -// - the name of the marshalled type -// -// The XML element for a struct contains marshalled elements for each of the -// exported fields of the struct, with these exceptions: -// - the XMLName field, described above, is omitted. -// - a field with tag "-" is omitted. -// - a field with tag "name,attr" becomes an attribute with -// the given name in the XML element. -// - a field with tag ",attr" becomes an attribute with the -// field name in the XML element. -// - a field with tag ",chardata" is written as character data, -// not as an XML element. -// - a field with tag ",innerxml" is written verbatim, not subject -// to the usual marshalling procedure. -// - a field with tag ",comment" is written as an XML comment, not -// subject to the usual marshalling procedure. It must not contain -// the "--" string within it. -// - a field with a tag including the "omitempty" option is omitted -// if the field value is empty. The empty values are false, 0, any -// nil pointer or interface value, and any array, slice, map, or -// string of length zero. -// - an anonymous struct field is handled as if the fields of its -// value were part of the outer struct. -// -// If a field uses a tag "a>b>c", then the element c will be nested inside -// parent elements a and b. Fields that appear next to each other that name -// the same parent will be enclosed in one XML element. -// -// See MarshalIndent for an example. -// -// Marshal will return an error if asked to marshal a channel, function, or map. -func Marshal(v interface{}) ([]byte, error) { - var b bytes.Buffer - if err := NewEncoder(&b).Encode(v); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -// Marshaler is the interface implemented by objects that can marshal -// themselves into valid XML elements. -// -// MarshalXML encodes the receiver as zero or more XML elements. -// By convention, arrays or slices are typically encoded as a sequence -// of elements, one per entry. -// Using start as the element tag is not required, but doing so -// will enable Unmarshal to match the XML elements to the correct -// struct field. -// One common implementation strategy is to construct a separate -// value with a layout corresponding to the desired XML and then -// to encode it using e.EncodeElement. -// Another common strategy is to use repeated calls to e.EncodeToken -// to generate the XML output one token at a time. -// The sequence of encoded tokens must make up zero or more valid -// XML elements. -type Marshaler interface { - MarshalXML(e *Encoder, start StartElement) error -} - -// MarshalerAttr is the interface implemented by objects that can marshal -// themselves into valid XML attributes. -// -// MarshalXMLAttr returns an XML attribute with the encoded value of the receiver. -// Using name as the attribute name is not required, but doing so -// will enable Unmarshal to match the attribute to the correct -// struct field. -// If MarshalXMLAttr returns the zero attribute Attr{}, no attribute -// will be generated in the output. -// MarshalXMLAttr is used only for struct fields with the -// "attr" option in the field tag. -type MarshalerAttr interface { - MarshalXMLAttr(name Name) (Attr, error) -} - -// MarshalIndent works like Marshal, but each XML element begins on a new -// indented line that starts with prefix and is followed by one or more -// copies of indent according to the nesting depth. -func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { - var b bytes.Buffer - enc := NewEncoder(&b) - enc.Indent(prefix, indent) - if err := enc.Encode(v); err != nil { - return nil, err - } - return b.Bytes(), nil -} - -// An Encoder writes XML data to an output stream. -type Encoder struct { - p printer -} - -// NewEncoder returns a new encoder that writes to w. -func NewEncoder(w io.Writer) *Encoder { - e := &Encoder{printer{Writer: bufio.NewWriter(w)}} - e.p.encoder = e - return e -} - -// Indent sets the encoder to generate XML in which each element -// begins on a new indented line that starts with prefix and is followed by -// one or more copies of indent according to the nesting depth. -func (enc *Encoder) Indent(prefix, indent string) { - enc.p.prefix = prefix - enc.p.indent = indent -} - -// Encode writes the XML encoding of v to the stream. -// -// See the documentation for Marshal for details about the conversion -// of Go values to XML. -// -// Encode calls Flush before returning. -func (enc *Encoder) Encode(v interface{}) error { - err := enc.p.marshalValue(reflect.ValueOf(v), nil, nil) - if err != nil { - return err - } - return enc.p.Flush() -} - -// EncodeElement writes the XML encoding of v to the stream, -// using start as the outermost tag in the encoding. -// -// See the documentation for Marshal for details about the conversion -// of Go values to XML. -// -// EncodeElement calls Flush before returning. -func (enc *Encoder) EncodeElement(v interface{}, start StartElement) error { - err := enc.p.marshalValue(reflect.ValueOf(v), nil, &start) - if err != nil { - return err - } - return enc.p.Flush() -} - -var ( - begComment = []byte("") - endProcInst = []byte("?>") - endDirective = []byte(">") -) - -// EncodeToken writes the given XML token to the stream. -// It returns an error if StartElement and EndElement tokens are not -// properly matched. -// -// EncodeToken does not call Flush, because usually it is part of a -// larger operation such as Encode or EncodeElement (or a custom -// Marshaler's MarshalXML invoked during those), and those will call -// Flush when finished. Callers that create an Encoder and then invoke -// EncodeToken directly, without using Encode or EncodeElement, need to -// call Flush when finished to ensure that the XML is written to the -// underlying writer. -// -// EncodeToken allows writing a ProcInst with Target set to "xml" only -// as the first token in the stream. -// -// When encoding a StartElement holding an XML namespace prefix -// declaration for a prefix that is not already declared, contained -// elements (including the StartElement itself) will use the declared -// prefix when encoding names with matching namespace URIs. -func (enc *Encoder) EncodeToken(t Token) error { - - p := &enc.p - switch t := t.(type) { - case StartElement: - if err := p.writeStart(&t); err != nil { - return err - } - case EndElement: - if err := p.writeEnd(t.Name); err != nil { - return err - } - case CharData: - escapeText(p, t, false) - case Comment: - if bytes.Contains(t, endComment) { - return fmt.Errorf("xml: EncodeToken of Comment containing --> marker") - } - p.WriteString("") - return p.cachedWriteError() - case ProcInst: - // First token to be encoded which is also a ProcInst with target of xml - // is the xml declaration. The only ProcInst where target of xml is allowed. - if t.Target == "xml" && p.Buffered() != 0 { - return fmt.Errorf("xml: EncodeToken of ProcInst xml target only valid for xml declaration, first token encoded") - } - if !isNameString(t.Target) { - return fmt.Errorf("xml: EncodeToken of ProcInst with invalid Target") - } - if bytes.Contains(t.Inst, endProcInst) { - return fmt.Errorf("xml: EncodeToken of ProcInst containing ?> marker") - } - p.WriteString(" 0 { - p.WriteByte(' ') - p.Write(t.Inst) - } - p.WriteString("?>") - case Directive: - if !isValidDirective(t) { - return fmt.Errorf("xml: EncodeToken of Directive containing wrong < or > markers") - } - p.WriteString("") - default: - return fmt.Errorf("xml: EncodeToken of invalid token type") - - } - return p.cachedWriteError() -} - -// isValidDirective reports whether dir is a valid directive text, -// meaning angle brackets are matched, ignoring comments and strings. -func isValidDirective(dir Directive) bool { - var ( - depth int - inquote uint8 - incomment bool - ) - for i, c := range dir { - switch { - case incomment: - if c == '>' { - if n := 1 + i - len(endComment); n >= 0 && bytes.Equal(dir[n:i+1], endComment) { - incomment = false - } - } - // Just ignore anything in comment - case inquote != 0: - if c == inquote { - inquote = 0 - } - // Just ignore anything within quotes - case c == '\'' || c == '"': - inquote = c - case c == '<': - if i+len(begComment) < len(dir) && bytes.Equal(dir[i:i+len(begComment)], begComment) { - incomment = true - } else { - depth++ - } - case c == '>': - if depth == 0 { - return false - } - depth-- - } - } - return depth == 0 && inquote == 0 && !incomment -} - -// Flush flushes any buffered XML to the underlying writer. -// See the EncodeToken documentation for details about when it is necessary. -func (enc *Encoder) Flush() error { - return enc.p.Flush() -} - -type printer struct { - *bufio.Writer - encoder *Encoder - seq int - indent string - prefix string - depth int - indentedIn bool - putNewline bool - defaultNS string - attrNS map[string]string // map prefix -> name space - attrPrefix map[string]string // map name space -> prefix - prefixes []printerPrefix - tags []Name -} - -// printerPrefix holds a namespace undo record. -// When an element is popped, the prefix record -// is set back to the recorded URL. The empty -// prefix records the URL for the default name space. -// -// The start of an element is recorded with an element -// that has mark=true. -type printerPrefix struct { - prefix string - url string - mark bool -} - -func (p *printer) prefixForNS(url string, isAttr bool) string { - // The "http://www.w3.org/XML/1998/namespace" name space is predefined as "xml" - // and must be referred to that way. - // (The "http://www.w3.org/2000/xmlns/" name space is also predefined as "xmlns", - // but users should not be trying to use that one directly - that's our job.) - if url == xmlURL { - return "xml" - } - if !isAttr && url == p.defaultNS { - // We can use the default name space. - return "" - } - return p.attrPrefix[url] -} - -// defineNS pushes any namespace definition found in the given attribute. -// If ignoreNonEmptyDefault is true, an xmlns="nonempty" -// attribute will be ignored. -func (p *printer) defineNS(attr Attr, ignoreNonEmptyDefault bool) error { - var prefix string - if attr.Name.Local == "xmlns" { - if attr.Name.Space != "" && attr.Name.Space != "xml" && attr.Name.Space != xmlURL { - return fmt.Errorf("xml: cannot redefine xmlns attribute prefix") - } - } else if attr.Name.Space == "xmlns" && attr.Name.Local != "" { - prefix = attr.Name.Local - if attr.Value == "" { - // Technically, an empty XML namespace is allowed for an attribute. - // From http://www.w3.org/TR/xml-names11/#scoping-defaulting: - // - // The attribute value in a namespace declaration for a prefix may be - // empty. This has the effect, within the scope of the declaration, of removing - // any association of the prefix with a namespace name. - // - // However our namespace prefixes here are used only as hints. There's - // no need to respect the removal of a namespace prefix, so we ignore it. - return nil - } - } else { - // Ignore: it's not a namespace definition - return nil - } - if prefix == "" { - if attr.Value == p.defaultNS { - // No need for redefinition. - return nil - } - if attr.Value != "" && ignoreNonEmptyDefault { - // We have an xmlns="..." value but - // it can't define a name space in this context, - // probably because the element has an empty - // name space. In this case, we just ignore - // the name space declaration. - return nil - } - } else if _, ok := p.attrPrefix[attr.Value]; ok { - // There's already a prefix for the given name space, - // so use that. This prevents us from - // having two prefixes for the same name space - // so attrNS and attrPrefix can remain bijective. - return nil - } - p.pushPrefix(prefix, attr.Value) - return nil -} - -// createNSPrefix creates a name space prefix attribute -// to use for the given name space, defining a new prefix -// if necessary. -// If isAttr is true, the prefix is to be created for an attribute -// prefix, which means that the default name space cannot -// be used. -func (p *printer) createNSPrefix(url string, isAttr bool) { - if _, ok := p.attrPrefix[url]; ok { - // We already have a prefix for the given URL. - return - } - switch { - case !isAttr && url == p.defaultNS: - // We can use the default name space. - return - case url == "": - // The only way we can encode names in the empty - // name space is by using the default name space, - // so we must use that. - if p.defaultNS != "" { - // The default namespace is non-empty, so we - // need to set it to empty. - p.pushPrefix("", "") - } - return - case url == xmlURL: - return - } - // TODO If the URL is an existing prefix, we could - // use it as is. That would enable the - // marshaling of elements that had been unmarshaled - // and with a name space prefix that was not found. - // although technically it would be incorrect. - - // Pick a name. We try to use the final element of the path - // but fall back to _. - prefix := strings.TrimRight(url, "/") - if i := strings.LastIndex(prefix, "/"); i >= 0 { - prefix = prefix[i+1:] - } - if prefix == "" || !isName([]byte(prefix)) || strings.Contains(prefix, ":") { - prefix = "_" - } - if strings.HasPrefix(prefix, "xml") { - // xmlanything is reserved. - prefix = "_" + prefix - } - if p.attrNS[prefix] != "" { - // Name is taken. Find a better one. - for p.seq++; ; p.seq++ { - if id := prefix + "_" + strconv.Itoa(p.seq); p.attrNS[id] == "" { - prefix = id - break - } - } - } - - p.pushPrefix(prefix, url) -} - -// writeNamespaces writes xmlns attributes for all the -// namespace prefixes that have been defined in -// the current element. -func (p *printer) writeNamespaces() { - for i := len(p.prefixes) - 1; i >= 0; i-- { - prefix := p.prefixes[i] - if prefix.mark { - return - } - p.WriteString(" ") - if prefix.prefix == "" { - // Default name space. - p.WriteString(`xmlns="`) - } else { - p.WriteString("xmlns:") - p.WriteString(prefix.prefix) - p.WriteString(`="`) - } - EscapeText(p, []byte(p.nsForPrefix(prefix.prefix))) - p.WriteString(`"`) - } -} - -// pushPrefix pushes a new prefix on the prefix stack -// without checking to see if it is already defined. -func (p *printer) pushPrefix(prefix, url string) { - p.prefixes = append(p.prefixes, printerPrefix{ - prefix: prefix, - url: p.nsForPrefix(prefix), - }) - p.setAttrPrefix(prefix, url) -} - -// nsForPrefix returns the name space for the given -// prefix. Note that this is not valid for the -// empty attribute prefix, which always has an empty -// name space. -func (p *printer) nsForPrefix(prefix string) string { - if prefix == "" { - return p.defaultNS - } - return p.attrNS[prefix] -} - -// markPrefix marks the start of an element on the prefix -// stack. -func (p *printer) markPrefix() { - p.prefixes = append(p.prefixes, printerPrefix{ - mark: true, - }) -} - -// popPrefix pops all defined prefixes for the current -// element. -func (p *printer) popPrefix() { - for len(p.prefixes) > 0 { - prefix := p.prefixes[len(p.prefixes)-1] - p.prefixes = p.prefixes[:len(p.prefixes)-1] - if prefix.mark { - break - } - p.setAttrPrefix(prefix.prefix, prefix.url) - } -} - -// setAttrPrefix sets an attribute name space prefix. -// If url is empty, the attribute is removed. -// If prefix is empty, the default name space is set. -func (p *printer) setAttrPrefix(prefix, url string) { - if prefix == "" { - p.defaultNS = url - return - } - if url == "" { - delete(p.attrPrefix, p.attrNS[prefix]) - delete(p.attrNS, prefix) - return - } - if p.attrPrefix == nil { - // Need to define a new name space. - p.attrPrefix = make(map[string]string) - p.attrNS = make(map[string]string) - } - // Remove any old prefix value. This is OK because we maintain a - // strict one-to-one mapping between prefix and URL (see - // defineNS) - delete(p.attrPrefix, p.attrNS[prefix]) - p.attrPrefix[url] = prefix - p.attrNS[prefix] = url -} - -var ( - marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() - marshalerAttrType = reflect.TypeOf((*MarshalerAttr)(nil)).Elem() - textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() -) - -// marshalValue writes one or more XML elements representing val. -// If val was obtained from a struct field, finfo must have its details. -func (p *printer) marshalValue(val reflect.Value, finfo *fieldInfo, startTemplate *StartElement) error { - if startTemplate != nil && startTemplate.Name.Local == "" { - return fmt.Errorf("xml: EncodeElement of StartElement with missing name") - } - - if !val.IsValid() { - return nil - } - if finfo != nil && finfo.flags&fOmitEmpty != 0 && isEmptyValue(val) { - return nil - } - - // Drill into interfaces and pointers. - // This can turn into an infinite loop given a cyclic chain, - // but it matches the Go 1 behavior. - for val.Kind() == reflect.Interface || val.Kind() == reflect.Ptr { - if val.IsNil() { - return nil - } - val = val.Elem() - } - - kind := val.Kind() - typ := val.Type() - - // Check for marshaler. - if val.CanInterface() && typ.Implements(marshalerType) { - return p.marshalInterface(val.Interface().(Marshaler), p.defaultStart(typ, finfo, startTemplate)) - } - if val.CanAddr() { - pv := val.Addr() - if pv.CanInterface() && pv.Type().Implements(marshalerType) { - return p.marshalInterface(pv.Interface().(Marshaler), p.defaultStart(pv.Type(), finfo, startTemplate)) - } - } - - // Check for text marshaler. - if val.CanInterface() && typ.Implements(textMarshalerType) { - return p.marshalTextInterface(val.Interface().(encoding.TextMarshaler), p.defaultStart(typ, finfo, startTemplate)) - } - if val.CanAddr() { - pv := val.Addr() - if pv.CanInterface() && pv.Type().Implements(textMarshalerType) { - return p.marshalTextInterface(pv.Interface().(encoding.TextMarshaler), p.defaultStart(pv.Type(), finfo, startTemplate)) - } - } - - // Slices and arrays iterate over the elements. They do not have an enclosing tag. - if (kind == reflect.Slice || kind == reflect.Array) && typ.Elem().Kind() != reflect.Uint8 { - for i, n := 0, val.Len(); i < n; i++ { - if err := p.marshalValue(val.Index(i), finfo, startTemplate); err != nil { - return err - } - } - return nil - } - - tinfo, err := getTypeInfo(typ) - if err != nil { - return err - } - - // Create start element. - // Precedence for the XML element name is: - // 0. startTemplate - // 1. XMLName field in underlying struct; - // 2. field name/tag in the struct field; and - // 3. type name - var start StartElement - - // explicitNS records whether the element's name space has been - // explicitly set (for example an XMLName field). - explicitNS := false - - if startTemplate != nil { - start.Name = startTemplate.Name - explicitNS = true - start.Attr = append(start.Attr, startTemplate.Attr...) - } else if tinfo.xmlname != nil { - xmlname := tinfo.xmlname - if xmlname.name != "" { - start.Name.Space, start.Name.Local = xmlname.xmlns, xmlname.name - } else if v, ok := xmlname.value(val).Interface().(Name); ok && v.Local != "" { - start.Name = v - } - explicitNS = true - } - if start.Name.Local == "" && finfo != nil { - start.Name.Local = finfo.name - if finfo.xmlns != "" { - start.Name.Space = finfo.xmlns - explicitNS = true - } - } - if start.Name.Local == "" { - name := typ.Name() - if name == "" { - return &UnsupportedTypeError{typ} - } - start.Name.Local = name - } - - // defaultNS records the default name space as set by a xmlns="..." - // attribute. We don't set p.defaultNS because we want to let - // the attribute writing code (in p.defineNS) be solely responsible - // for maintaining that. - defaultNS := p.defaultNS - - // Attributes - for i := range tinfo.fields { - finfo := &tinfo.fields[i] - if finfo.flags&fAttr == 0 { - continue - } - attr, err := p.fieldAttr(finfo, val) - if err != nil { - return err - } - if attr.Name.Local == "" { - continue - } - start.Attr = append(start.Attr, attr) - if attr.Name.Space == "" && attr.Name.Local == "xmlns" { - defaultNS = attr.Value - } - } - if !explicitNS { - // Historic behavior: elements use the default name space - // they are contained in by default. - start.Name.Space = defaultNS - } - // Historic behaviour: an element that's in a namespace sets - // the default namespace for all elements contained within it. - start.setDefaultNamespace() - - if err := p.writeStart(&start); err != nil { - return err - } - - if val.Kind() == reflect.Struct { - err = p.marshalStruct(tinfo, val) - } else { - s, b, err1 := p.marshalSimple(typ, val) - if err1 != nil { - err = err1 - } else if b != nil { - EscapeText(p, b) - } else { - p.EscapeString(s) - } - } - if err != nil { - return err - } - - if err := p.writeEnd(start.Name); err != nil { - return err - } - - return p.cachedWriteError() -} - -// fieldAttr returns the attribute of the given field. -// If the returned attribute has an empty Name.Local, -// it should not be used. -// The given value holds the value containing the field. -func (p *printer) fieldAttr(finfo *fieldInfo, val reflect.Value) (Attr, error) { - fv := finfo.value(val) - name := Name{Space: finfo.xmlns, Local: finfo.name} - if finfo.flags&fOmitEmpty != 0 && isEmptyValue(fv) { - return Attr{}, nil - } - if fv.Kind() == reflect.Interface && fv.IsNil() { - return Attr{}, nil - } - if fv.CanInterface() && fv.Type().Implements(marshalerAttrType) { - attr, err := fv.Interface().(MarshalerAttr).MarshalXMLAttr(name) - return attr, err - } - if fv.CanAddr() { - pv := fv.Addr() - if pv.CanInterface() && pv.Type().Implements(marshalerAttrType) { - attr, err := pv.Interface().(MarshalerAttr).MarshalXMLAttr(name) - return attr, err - } - } - if fv.CanInterface() && fv.Type().Implements(textMarshalerType) { - text, err := fv.Interface().(encoding.TextMarshaler).MarshalText() - if err != nil { - return Attr{}, err - } - return Attr{name, string(text)}, nil - } - if fv.CanAddr() { - pv := fv.Addr() - if pv.CanInterface() && pv.Type().Implements(textMarshalerType) { - text, err := pv.Interface().(encoding.TextMarshaler).MarshalText() - if err != nil { - return Attr{}, err - } - return Attr{name, string(text)}, nil - } - } - // Dereference or skip nil pointer, interface values. - switch fv.Kind() { - case reflect.Ptr, reflect.Interface: - if fv.IsNil() { - return Attr{}, nil - } - fv = fv.Elem() - } - s, b, err := p.marshalSimple(fv.Type(), fv) - if err != nil { - return Attr{}, err - } - if b != nil { - s = string(b) - } - return Attr{name, s}, nil -} - -// defaultStart returns the default start element to use, -// given the reflect type, field info, and start template. -func (p *printer) defaultStart(typ reflect.Type, finfo *fieldInfo, startTemplate *StartElement) StartElement { - var start StartElement - // Precedence for the XML element name is as above, - // except that we do not look inside structs for the first field. - if startTemplate != nil { - start.Name = startTemplate.Name - start.Attr = append(start.Attr, startTemplate.Attr...) - } else if finfo != nil && finfo.name != "" { - start.Name.Local = finfo.name - start.Name.Space = finfo.xmlns - } else if typ.Name() != "" { - start.Name.Local = typ.Name() - } else { - // Must be a pointer to a named type, - // since it has the Marshaler methods. - start.Name.Local = typ.Elem().Name() - } - // Historic behaviour: elements use the name space of - // the element they are contained in by default. - if start.Name.Space == "" { - start.Name.Space = p.defaultNS - } - start.setDefaultNamespace() - return start -} - -// marshalInterface marshals a Marshaler interface value. -func (p *printer) marshalInterface(val Marshaler, start StartElement) error { - // Push a marker onto the tag stack so that MarshalXML - // cannot close the XML tags that it did not open. - p.tags = append(p.tags, Name{}) - n := len(p.tags) - - err := val.MarshalXML(p.encoder, start) - if err != nil { - return err - } - - // Make sure MarshalXML closed all its tags. p.tags[n-1] is the mark. - if len(p.tags) > n { - return fmt.Errorf("xml: %s.MarshalXML wrote invalid XML: <%s> not closed", receiverType(val), p.tags[len(p.tags)-1].Local) - } - p.tags = p.tags[:n-1] - return nil -} - -// marshalTextInterface marshals a TextMarshaler interface value. -func (p *printer) marshalTextInterface(val encoding.TextMarshaler, start StartElement) error { - if err := p.writeStart(&start); err != nil { - return err - } - text, err := val.MarshalText() - if err != nil { - return err - } - EscapeText(p, text) - return p.writeEnd(start.Name) -} - -// writeStart writes the given start element. -func (p *printer) writeStart(start *StartElement) error { - if start.Name.Local == "" { - return fmt.Errorf("xml: start tag with no name") - } - - p.tags = append(p.tags, start.Name) - p.markPrefix() - // Define any name spaces explicitly declared in the attributes. - // We do this as a separate pass so that explicitly declared prefixes - // will take precedence over implicitly declared prefixes - // regardless of the order of the attributes. - ignoreNonEmptyDefault := start.Name.Space == "" - for _, attr := range start.Attr { - if err := p.defineNS(attr, ignoreNonEmptyDefault); err != nil { - return err - } - } - // Define any new name spaces implied by the attributes. - for _, attr := range start.Attr { - name := attr.Name - // From http://www.w3.org/TR/xml-names11/#defaulting - // "Default namespace declarations do not apply directly - // to attribute names; the interpretation of unprefixed - // attributes is determined by the element on which they - // appear." - // This means we don't need to create a new namespace - // when an attribute name space is empty. - if name.Space != "" && !name.isNamespace() { - p.createNSPrefix(name.Space, true) - } - } - p.createNSPrefix(start.Name.Space, false) - - p.writeIndent(1) - p.WriteByte('<') - p.writeName(start.Name, false) - p.writeNamespaces() - for _, attr := range start.Attr { - name := attr.Name - if name.Local == "" || name.isNamespace() { - // Namespaces have already been written by writeNamespaces above. - continue - } - p.WriteByte(' ') - p.writeName(name, true) - p.WriteString(`="`) - p.EscapeString(attr.Value) - p.WriteByte('"') - } - p.WriteByte('>') - return nil -} - -// writeName writes the given name. It assumes -// that p.createNSPrefix(name) has already been called. -func (p *printer) writeName(name Name, isAttr bool) { - if prefix := p.prefixForNS(name.Space, isAttr); prefix != "" { - p.WriteString(prefix) - p.WriteByte(':') - } - p.WriteString(name.Local) -} - -func (p *printer) writeEnd(name Name) error { - if name.Local == "" { - return fmt.Errorf("xml: end tag with no name") - } - if len(p.tags) == 0 || p.tags[len(p.tags)-1].Local == "" { - return fmt.Errorf("xml: end tag without start tag", name.Local) - } - if top := p.tags[len(p.tags)-1]; top != name { - if top.Local != name.Local { - return fmt.Errorf("xml: end tag does not match start tag <%s>", name.Local, top.Local) - } - return fmt.Errorf("xml: end tag in namespace %s does not match start tag <%s> in namespace %s", name.Local, name.Space, top.Local, top.Space) - } - p.tags = p.tags[:len(p.tags)-1] - - p.writeIndent(-1) - p.WriteByte('<') - p.WriteByte('/') - p.writeName(name, false) - p.WriteByte('>') - p.popPrefix() - return nil -} - -func (p *printer) marshalSimple(typ reflect.Type, val reflect.Value) (string, []byte, error) { - switch val.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return strconv.FormatInt(val.Int(), 10), nil, nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return strconv.FormatUint(val.Uint(), 10), nil, nil - case reflect.Float32, reflect.Float64: - return strconv.FormatFloat(val.Float(), 'g', -1, val.Type().Bits()), nil, nil - case reflect.String: - return val.String(), nil, nil - case reflect.Bool: - return strconv.FormatBool(val.Bool()), nil, nil - case reflect.Array: - if typ.Elem().Kind() != reflect.Uint8 { - break - } - // [...]byte - var bytes []byte - if val.CanAddr() { - bytes = val.Slice(0, val.Len()).Bytes() - } else { - bytes = make([]byte, val.Len()) - reflect.Copy(reflect.ValueOf(bytes), val) - } - return "", bytes, nil - case reflect.Slice: - if typ.Elem().Kind() != reflect.Uint8 { - break - } - // []byte - return "", val.Bytes(), nil - } - return "", nil, &UnsupportedTypeError{typ} -} - -var ddBytes = []byte("--") - -func (p *printer) marshalStruct(tinfo *typeInfo, val reflect.Value) error { - s := parentStack{p: p} - for i := range tinfo.fields { - finfo := &tinfo.fields[i] - if finfo.flags&fAttr != 0 { - continue - } - vf := finfo.value(val) - - // Dereference or skip nil pointer, interface values. - switch vf.Kind() { - case reflect.Ptr, reflect.Interface: - if !vf.IsNil() { - vf = vf.Elem() - } - } - - switch finfo.flags & fMode { - case fCharData: - if err := s.setParents(&noField, reflect.Value{}); err != nil { - return err - } - if vf.CanInterface() && vf.Type().Implements(textMarshalerType) { - data, err := vf.Interface().(encoding.TextMarshaler).MarshalText() - if err != nil { - return err - } - Escape(p, data) - continue - } - if vf.CanAddr() { - pv := vf.Addr() - if pv.CanInterface() && pv.Type().Implements(textMarshalerType) { - data, err := pv.Interface().(encoding.TextMarshaler).MarshalText() - if err != nil { - return err - } - Escape(p, data) - continue - } - } - var scratch [64]byte - switch vf.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - Escape(p, strconv.AppendInt(scratch[:0], vf.Int(), 10)) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - Escape(p, strconv.AppendUint(scratch[:0], vf.Uint(), 10)) - case reflect.Float32, reflect.Float64: - Escape(p, strconv.AppendFloat(scratch[:0], vf.Float(), 'g', -1, vf.Type().Bits())) - case reflect.Bool: - Escape(p, strconv.AppendBool(scratch[:0], vf.Bool())) - case reflect.String: - if err := EscapeText(p, []byte(vf.String())); err != nil { - return err - } - case reflect.Slice: - if elem, ok := vf.Interface().([]byte); ok { - if err := EscapeText(p, elem); err != nil { - return err - } - } - } - continue - - case fComment: - if err := s.setParents(&noField, reflect.Value{}); err != nil { - return err - } - k := vf.Kind() - if !(k == reflect.String || k == reflect.Slice && vf.Type().Elem().Kind() == reflect.Uint8) { - return fmt.Errorf("xml: bad type for comment field of %s", val.Type()) - } - if vf.Len() == 0 { - continue - } - p.writeIndent(0) - p.WriteString("" is invalid grammar. Make it "- -->" - p.WriteByte(' ') - } - p.WriteString("-->") - continue - - case fInnerXml: - iface := vf.Interface() - switch raw := iface.(type) { - case []byte: - p.Write(raw) - continue - case string: - p.WriteString(raw) - continue - } - - case fElement, fElement | fAny: - if err := s.setParents(finfo, vf); err != nil { - return err - } - } - if err := p.marshalValue(vf, finfo, nil); err != nil { - return err - } - } - if err := s.setParents(&noField, reflect.Value{}); err != nil { - return err - } - return p.cachedWriteError() -} - -var noField fieldInfo - -// return the bufio Writer's cached write error -func (p *printer) cachedWriteError() error { - _, err := p.Write(nil) - return err -} - -func (p *printer) writeIndent(depthDelta int) { - if len(p.prefix) == 0 && len(p.indent) == 0 { - return - } - if depthDelta < 0 { - p.depth-- - if p.indentedIn { - p.indentedIn = false - return - } - p.indentedIn = false - } - if p.putNewline { - p.WriteByte('\n') - } else { - p.putNewline = true - } - if len(p.prefix) > 0 { - p.WriteString(p.prefix) - } - if len(p.indent) > 0 { - for i := 0; i < p.depth; i++ { - p.WriteString(p.indent) - } - } - if depthDelta > 0 { - p.depth++ - p.indentedIn = true - } -} - -type parentStack struct { - p *printer - xmlns string - parents []string -} - -// setParents sets the stack of current parents to those found in finfo. -// It only writes the start elements if vf holds a non-nil value. -// If finfo is &noField, it pops all elements. -func (s *parentStack) setParents(finfo *fieldInfo, vf reflect.Value) error { - xmlns := s.p.defaultNS - if finfo.xmlns != "" { - xmlns = finfo.xmlns - } - commonParents := 0 - if xmlns == s.xmlns { - for ; commonParents < len(finfo.parents) && commonParents < len(s.parents); commonParents++ { - if finfo.parents[commonParents] != s.parents[commonParents] { - break - } - } - } - // Pop off any parents that aren't in common with the previous field. - for i := len(s.parents) - 1; i >= commonParents; i-- { - if err := s.p.writeEnd(Name{ - Space: s.xmlns, - Local: s.parents[i], - }); err != nil { - return err - } - } - s.parents = finfo.parents - s.xmlns = xmlns - if commonParents >= len(s.parents) { - // No new elements to push. - return nil - } - if (vf.Kind() == reflect.Ptr || vf.Kind() == reflect.Interface) && vf.IsNil() { - // The element is nil, so no need for the start elements. - s.parents = s.parents[:commonParents] - return nil - } - // Push any new parents required. - for _, name := range s.parents[commonParents:] { - start := &StartElement{ - Name: Name{ - Space: s.xmlns, - Local: name, - }, - } - // Set the default name space for parent elements - // to match what we do with other elements. - if s.xmlns != s.p.defaultNS { - start.setDefaultNamespace() - } - if err := s.p.writeStart(start); err != nil { - return err - } - } - return nil -} - -// A MarshalXMLError is returned when Marshal encounters a type -// that cannot be converted into XML. -type UnsupportedTypeError struct { - Type reflect.Type -} - -func (e *UnsupportedTypeError) Error() string { - return "xml: unsupported type: " + e.Type.String() -} - -func isEmptyValue(v reflect.Value) bool { - switch v.Kind() { - case reflect.Array, reflect.Map, reflect.Slice, reflect.String: - return v.Len() == 0 - case reflect.Bool: - return !v.Bool() - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return v.Int() == 0 - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - return v.Uint() == 0 - case reflect.Float32, reflect.Float64: - return v.Float() == 0 - case reflect.Interface, reflect.Ptr: - return v.IsNil() - } - return false -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go b/vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go deleted file mode 100644 index 5dc78e7..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go +++ /dev/null @@ -1,1939 +0,0 @@ -// Copyright 2011 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 xml - -import ( - "bytes" - "errors" - "fmt" - "io" - "reflect" - "strconv" - "strings" - "sync" - "testing" - "time" -) - -type DriveType int - -const ( - HyperDrive DriveType = iota - ImprobabilityDrive -) - -type Passenger struct { - Name []string `xml:"name"` - Weight float32 `xml:"weight"` -} - -type Ship struct { - XMLName struct{} `xml:"spaceship"` - - Name string `xml:"name,attr"` - Pilot string `xml:"pilot,attr"` - Drive DriveType `xml:"drive"` - Age uint `xml:"age"` - Passenger []*Passenger `xml:"passenger"` - secret string -} - -type NamedType string - -type Port struct { - XMLName struct{} `xml:"port"` - Type string `xml:"type,attr,omitempty"` - Comment string `xml:",comment"` - Number string `xml:",chardata"` -} - -type Domain struct { - XMLName struct{} `xml:"domain"` - Country string `xml:",attr,omitempty"` - Name []byte `xml:",chardata"` - Comment []byte `xml:",comment"` -} - -type Book struct { - XMLName struct{} `xml:"book"` - Title string `xml:",chardata"` -} - -type Event struct { - XMLName struct{} `xml:"event"` - Year int `xml:",chardata"` -} - -type Movie struct { - XMLName struct{} `xml:"movie"` - Length uint `xml:",chardata"` -} - -type Pi struct { - XMLName struct{} `xml:"pi"` - Approximation float32 `xml:",chardata"` -} - -type Universe struct { - XMLName struct{} `xml:"universe"` - Visible float64 `xml:",chardata"` -} - -type Particle struct { - XMLName struct{} `xml:"particle"` - HasMass bool `xml:",chardata"` -} - -type Departure struct { - XMLName struct{} `xml:"departure"` - When time.Time `xml:",chardata"` -} - -type SecretAgent struct { - XMLName struct{} `xml:"agent"` - Handle string `xml:"handle,attr"` - Identity string - Obfuscate string `xml:",innerxml"` -} - -type NestedItems struct { - XMLName struct{} `xml:"result"` - Items []string `xml:">item"` - Item1 []string `xml:"Items>item1"` -} - -type NestedOrder struct { - XMLName struct{} `xml:"result"` - Field1 string `xml:"parent>c"` - Field2 string `xml:"parent>b"` - Field3 string `xml:"parent>a"` -} - -type MixedNested struct { - XMLName struct{} `xml:"result"` - A string `xml:"parent1>a"` - B string `xml:"b"` - C string `xml:"parent1>parent2>c"` - D string `xml:"parent1>d"` -} - -type NilTest struct { - A interface{} `xml:"parent1>parent2>a"` - B interface{} `xml:"parent1>b"` - C interface{} `xml:"parent1>parent2>c"` -} - -type Service struct { - XMLName struct{} `xml:"service"` - Domain *Domain `xml:"host>domain"` - Port *Port `xml:"host>port"` - Extra1 interface{} - Extra2 interface{} `xml:"host>extra2"` -} - -var nilStruct *Ship - -type EmbedA struct { - EmbedC - EmbedB EmbedB - FieldA string -} - -type EmbedB struct { - FieldB string - *EmbedC -} - -type EmbedC struct { - FieldA1 string `xml:"FieldA>A1"` - FieldA2 string `xml:"FieldA>A2"` - FieldB string - FieldC string -} - -type NameCasing struct { - XMLName struct{} `xml:"casing"` - Xy string - XY string - XyA string `xml:"Xy,attr"` - XYA string `xml:"XY,attr"` -} - -type NamePrecedence struct { - XMLName Name `xml:"Parent"` - FromTag XMLNameWithoutTag `xml:"InTag"` - FromNameVal XMLNameWithoutTag - FromNameTag XMLNameWithTag - InFieldName string -} - -type XMLNameWithTag struct { - XMLName Name `xml:"InXMLNameTag"` - Value string `xml:",chardata"` -} - -type XMLNameWithNSTag struct { - XMLName Name `xml:"ns InXMLNameWithNSTag"` - Value string `xml:",chardata"` -} - -type XMLNameWithoutTag struct { - XMLName Name - Value string `xml:",chardata"` -} - -type NameInField struct { - Foo Name `xml:"ns foo"` -} - -type AttrTest struct { - Int int `xml:",attr"` - Named int `xml:"int,attr"` - Float float64 `xml:",attr"` - Uint8 uint8 `xml:",attr"` - Bool bool `xml:",attr"` - Str string `xml:",attr"` - Bytes []byte `xml:",attr"` -} - -type OmitAttrTest struct { - Int int `xml:",attr,omitempty"` - Named int `xml:"int,attr,omitempty"` - Float float64 `xml:",attr,omitempty"` - Uint8 uint8 `xml:",attr,omitempty"` - Bool bool `xml:",attr,omitempty"` - Str string `xml:",attr,omitempty"` - Bytes []byte `xml:",attr,omitempty"` -} - -type OmitFieldTest struct { - Int int `xml:",omitempty"` - Named int `xml:"int,omitempty"` - Float float64 `xml:",omitempty"` - Uint8 uint8 `xml:",omitempty"` - Bool bool `xml:",omitempty"` - Str string `xml:",omitempty"` - Bytes []byte `xml:",omitempty"` - Ptr *PresenceTest `xml:",omitempty"` -} - -type AnyTest struct { - XMLName struct{} `xml:"a"` - Nested string `xml:"nested>value"` - AnyField AnyHolder `xml:",any"` -} - -type AnyOmitTest struct { - XMLName struct{} `xml:"a"` - Nested string `xml:"nested>value"` - AnyField *AnyHolder `xml:",any,omitempty"` -} - -type AnySliceTest struct { - XMLName struct{} `xml:"a"` - Nested string `xml:"nested>value"` - AnyField []AnyHolder `xml:",any"` -} - -type AnyHolder struct { - XMLName Name - XML string `xml:",innerxml"` -} - -type RecurseA struct { - A string - B *RecurseB -} - -type RecurseB struct { - A *RecurseA - B string -} - -type PresenceTest struct { - Exists *struct{} -} - -type IgnoreTest struct { - PublicSecret string `xml:"-"` -} - -type MyBytes []byte - -type Data struct { - Bytes []byte - Attr []byte `xml:",attr"` - Custom MyBytes -} - -type Plain struct { - V interface{} -} - -type MyInt int - -type EmbedInt struct { - MyInt -} - -type Strings struct { - X []string `xml:"A>B,omitempty"` -} - -type PointerFieldsTest struct { - XMLName Name `xml:"dummy"` - Name *string `xml:"name,attr"` - Age *uint `xml:"age,attr"` - Empty *string `xml:"empty,attr"` - Contents *string `xml:",chardata"` -} - -type ChardataEmptyTest struct { - XMLName Name `xml:"test"` - Contents *string `xml:",chardata"` -} - -type MyMarshalerTest struct { -} - -var _ Marshaler = (*MyMarshalerTest)(nil) - -func (m *MyMarshalerTest) MarshalXML(e *Encoder, start StartElement) error { - e.EncodeToken(start) - e.EncodeToken(CharData([]byte("hello world"))) - e.EncodeToken(EndElement{start.Name}) - return nil -} - -type MyMarshalerAttrTest struct{} - -var _ MarshalerAttr = (*MyMarshalerAttrTest)(nil) - -func (m *MyMarshalerAttrTest) MarshalXMLAttr(name Name) (Attr, error) { - return Attr{name, "hello world"}, nil -} - -type MyMarshalerValueAttrTest struct{} - -var _ MarshalerAttr = MyMarshalerValueAttrTest{} - -func (m MyMarshalerValueAttrTest) MarshalXMLAttr(name Name) (Attr, error) { - return Attr{name, "hello world"}, nil -} - -type MarshalerStruct struct { - Foo MyMarshalerAttrTest `xml:",attr"` -} - -type MarshalerValueStruct struct { - Foo MyMarshalerValueAttrTest `xml:",attr"` -} - -type InnerStruct struct { - XMLName Name `xml:"testns outer"` -} - -type OuterStruct struct { - InnerStruct - IntAttr int `xml:"int,attr"` -} - -type OuterNamedStruct struct { - InnerStruct - XMLName Name `xml:"outerns test"` - IntAttr int `xml:"int,attr"` -} - -type OuterNamedOrderedStruct struct { - XMLName Name `xml:"outerns test"` - InnerStruct - IntAttr int `xml:"int,attr"` -} - -type OuterOuterStruct struct { - OuterStruct -} - -type NestedAndChardata struct { - AB []string `xml:"A>B"` - Chardata string `xml:",chardata"` -} - -type NestedAndComment struct { - AB []string `xml:"A>B"` - Comment string `xml:",comment"` -} - -type XMLNSFieldStruct struct { - Ns string `xml:"xmlns,attr"` - Body string -} - -type NamedXMLNSFieldStruct struct { - XMLName struct{} `xml:"testns test"` - Ns string `xml:"xmlns,attr"` - Body string -} - -type XMLNSFieldStructWithOmitEmpty struct { - Ns string `xml:"xmlns,attr,omitempty"` - Body string -} - -type NamedXMLNSFieldStructWithEmptyNamespace struct { - XMLName struct{} `xml:"test"` - Ns string `xml:"xmlns,attr"` - Body string -} - -type RecursiveXMLNSFieldStruct struct { - Ns string `xml:"xmlns,attr"` - Body *RecursiveXMLNSFieldStruct `xml:",omitempty"` - Text string `xml:",omitempty"` -} - -func ifaceptr(x interface{}) interface{} { - return &x -} - -var ( - nameAttr = "Sarah" - ageAttr = uint(12) - contentsAttr = "lorem ipsum" -) - -// Unless explicitly stated as such (or *Plain), all of the -// tests below are two-way tests. When introducing new tests, -// please try to make them two-way as well to ensure that -// marshalling and unmarshalling are as symmetrical as feasible. -var marshalTests = []struct { - Value interface{} - ExpectXML string - MarshalOnly bool - UnmarshalOnly bool -}{ - // Test nil marshals to nothing - {Value: nil, ExpectXML: ``, MarshalOnly: true}, - {Value: nilStruct, ExpectXML: ``, MarshalOnly: true}, - - // Test value types - {Value: &Plain{true}, ExpectXML: `true`}, - {Value: &Plain{false}, ExpectXML: `false`}, - {Value: &Plain{int(42)}, ExpectXML: `42`}, - {Value: &Plain{int8(42)}, ExpectXML: `42`}, - {Value: &Plain{int16(42)}, ExpectXML: `42`}, - {Value: &Plain{int32(42)}, ExpectXML: `42`}, - {Value: &Plain{uint(42)}, ExpectXML: `42`}, - {Value: &Plain{uint8(42)}, ExpectXML: `42`}, - {Value: &Plain{uint16(42)}, ExpectXML: `42`}, - {Value: &Plain{uint32(42)}, ExpectXML: `42`}, - {Value: &Plain{float32(1.25)}, ExpectXML: `1.25`}, - {Value: &Plain{float64(1.25)}, ExpectXML: `1.25`}, - {Value: &Plain{uintptr(0xFFDD)}, ExpectXML: `65501`}, - {Value: &Plain{"gopher"}, ExpectXML: `gopher`}, - {Value: &Plain{[]byte("gopher")}, ExpectXML: `gopher`}, - {Value: &Plain{""}, ExpectXML: `</>`}, - {Value: &Plain{[]byte("")}, ExpectXML: `</>`}, - {Value: &Plain{[3]byte{'<', '/', '>'}}, ExpectXML: `</>`}, - {Value: &Plain{NamedType("potato")}, ExpectXML: `potato`}, - {Value: &Plain{[]int{1, 2, 3}}, ExpectXML: `123`}, - {Value: &Plain{[3]int{1, 2, 3}}, ExpectXML: `123`}, - {Value: ifaceptr(true), MarshalOnly: true, ExpectXML: `true`}, - - // Test time. - { - Value: &Plain{time.Unix(1e9, 123456789).UTC()}, - ExpectXML: `2001-09-09T01:46:40.123456789Z`, - }, - - // A pointer to struct{} may be used to test for an element's presence. - { - Value: &PresenceTest{new(struct{})}, - ExpectXML: ``, - }, - { - Value: &PresenceTest{}, - ExpectXML: ``, - }, - - // A pointer to struct{} may be used to test for an element's presence. - { - Value: &PresenceTest{new(struct{})}, - ExpectXML: ``, - }, - { - Value: &PresenceTest{}, - ExpectXML: ``, - }, - - // A []byte field is only nil if the element was not found. - { - Value: &Data{}, - ExpectXML: ``, - UnmarshalOnly: true, - }, - { - Value: &Data{Bytes: []byte{}, Custom: MyBytes{}, Attr: []byte{}}, - ExpectXML: ``, - UnmarshalOnly: true, - }, - - // Check that []byte works, including named []byte types. - { - Value: &Data{Bytes: []byte("ab"), Custom: MyBytes("cd"), Attr: []byte{'v'}}, - ExpectXML: `abcd`, - }, - - // Test innerxml - { - Value: &SecretAgent{ - Handle: "007", - Identity: "James Bond", - Obfuscate: "", - }, - ExpectXML: `James Bond`, - MarshalOnly: true, - }, - { - Value: &SecretAgent{ - Handle: "007", - Identity: "James Bond", - Obfuscate: "James Bond", - }, - ExpectXML: `James Bond`, - UnmarshalOnly: true, - }, - - // Test structs - {Value: &Port{Type: "ssl", Number: "443"}, ExpectXML: `443`}, - {Value: &Port{Number: "443"}, ExpectXML: `443`}, - {Value: &Port{Type: ""}, ExpectXML: ``}, - {Value: &Port{Number: "443", Comment: "https"}, ExpectXML: `443`}, - {Value: &Port{Number: "443", Comment: "add space-"}, ExpectXML: `443`, MarshalOnly: true}, - {Value: &Domain{Name: []byte("google.com&friends")}, ExpectXML: `google.com&friends`}, - {Value: &Domain{Name: []byte("google.com"), Comment: []byte(" &friends ")}, ExpectXML: `google.com`}, - {Value: &Book{Title: "Pride & Prejudice"}, ExpectXML: `Pride & Prejudice`}, - {Value: &Event{Year: -3114}, ExpectXML: `-3114`}, - {Value: &Movie{Length: 13440}, ExpectXML: `13440`}, - {Value: &Pi{Approximation: 3.14159265}, ExpectXML: `3.1415927`}, - {Value: &Universe{Visible: 9.3e13}, ExpectXML: `9.3e+13`}, - {Value: &Particle{HasMass: true}, ExpectXML: `true`}, - {Value: &Departure{When: ParseTime("2013-01-09T00:15:00-09:00")}, ExpectXML: `2013-01-09T00:15:00-09:00`}, - {Value: atomValue, ExpectXML: atomXml}, - { - Value: &Ship{ - Name: "Heart of Gold", - Pilot: "Computer", - Age: 1, - Drive: ImprobabilityDrive, - Passenger: []*Passenger{ - { - Name: []string{"Zaphod", "Beeblebrox"}, - Weight: 7.25, - }, - { - Name: []string{"Trisha", "McMillen"}, - Weight: 5.5, - }, - { - Name: []string{"Ford", "Prefect"}, - Weight: 7, - }, - { - Name: []string{"Arthur", "Dent"}, - Weight: 6.75, - }, - }, - }, - ExpectXML: `` + - `` + strconv.Itoa(int(ImprobabilityDrive)) + `` + - `1` + - `` + - `Zaphod` + - `Beeblebrox` + - `7.25` + - `` + - `` + - `Trisha` + - `McMillen` + - `5.5` + - `` + - `` + - `Ford` + - `Prefect` + - `7` + - `` + - `` + - `Arthur` + - `Dent` + - `6.75` + - `` + - ``, - }, - - // Test a>b - { - Value: &NestedItems{Items: nil, Item1: nil}, - ExpectXML: `` + - `` + - `` + - ``, - }, - { - Value: &NestedItems{Items: []string{}, Item1: []string{}}, - ExpectXML: `` + - `` + - `` + - ``, - MarshalOnly: true, - }, - { - Value: &NestedItems{Items: nil, Item1: []string{"A"}}, - ExpectXML: `` + - `` + - `A` + - `` + - ``, - }, - { - Value: &NestedItems{Items: []string{"A", "B"}, Item1: nil}, - ExpectXML: `` + - `` + - `A` + - `B` + - `` + - ``, - }, - { - Value: &NestedItems{Items: []string{"A", "B"}, Item1: []string{"C"}}, - ExpectXML: `` + - `` + - `A` + - `B` + - `C` + - `` + - ``, - }, - { - Value: &NestedOrder{Field1: "C", Field2: "B", Field3: "A"}, - ExpectXML: `` + - `` + - `C` + - `B` + - `A` + - `` + - ``, - }, - { - Value: &NilTest{A: "A", B: nil, C: "C"}, - ExpectXML: `` + - `` + - `A` + - `C` + - `` + - ``, - MarshalOnly: true, // Uses interface{} - }, - { - Value: &MixedNested{A: "A", B: "B", C: "C", D: "D"}, - ExpectXML: `` + - `A` + - `B` + - `` + - `C` + - `D` + - `` + - ``, - }, - { - Value: &Service{Port: &Port{Number: "80"}}, - ExpectXML: `80`, - }, - { - Value: &Service{}, - ExpectXML: ``, - }, - { - Value: &Service{Port: &Port{Number: "80"}, Extra1: "A", Extra2: "B"}, - ExpectXML: `` + - `80` + - `A` + - `B` + - ``, - MarshalOnly: true, - }, - { - Value: &Service{Port: &Port{Number: "80"}, Extra2: "example"}, - ExpectXML: `` + - `80` + - `example` + - ``, - MarshalOnly: true, - }, - { - Value: &struct { - XMLName struct{} `xml:"space top"` - A string `xml:"x>a"` - B string `xml:"x>b"` - C string `xml:"space x>c"` - C1 string `xml:"space1 x>c"` - D1 string `xml:"space1 x>d"` - E1 string `xml:"x>e"` - }{ - A: "a", - B: "b", - C: "c", - C1: "c1", - D1: "d1", - E1: "e1", - }, - ExpectXML: `` + - `abc` + - `` + - `c1` + - `d1` + - `` + - `` + - `e1` + - `` + - ``, - }, - { - Value: &struct { - XMLName Name - A string `xml:"x>a"` - B string `xml:"x>b"` - C string `xml:"space x>c"` - C1 string `xml:"space1 x>c"` - D1 string `xml:"space1 x>d"` - }{ - XMLName: Name{ - Space: "space0", - Local: "top", - }, - A: "a", - B: "b", - C: "c", - C1: "c1", - D1: "d1", - }, - ExpectXML: `` + - `ab` + - `c` + - `` + - `c1` + - `d1` + - `` + - ``, - }, - { - Value: &struct { - XMLName struct{} `xml:"top"` - B string `xml:"space x>b"` - B1 string `xml:"space1 x>b"` - }{ - B: "b", - B1: "b1", - }, - ExpectXML: `` + - `b` + - `b1` + - ``, - }, - - // Test struct embedding - { - Value: &EmbedA{ - EmbedC: EmbedC{ - FieldA1: "", // Shadowed by A.A - FieldA2: "", // Shadowed by A.A - FieldB: "A.C.B", - FieldC: "A.C.C", - }, - EmbedB: EmbedB{ - FieldB: "A.B.B", - EmbedC: &EmbedC{ - FieldA1: "A.B.C.A1", - FieldA2: "A.B.C.A2", - FieldB: "", // Shadowed by A.B.B - FieldC: "A.B.C.C", - }, - }, - FieldA: "A.A", - }, - ExpectXML: `` + - `A.C.B` + - `A.C.C` + - `` + - `A.B.B` + - `` + - `A.B.C.A1` + - `A.B.C.A2` + - `` + - `A.B.C.C` + - `` + - `A.A` + - ``, - }, - - // Test that name casing matters - { - Value: &NameCasing{Xy: "mixed", XY: "upper", XyA: "mixedA", XYA: "upperA"}, - ExpectXML: `mixedupper`, - }, - - // Test the order in which the XML element name is chosen - { - Value: &NamePrecedence{ - FromTag: XMLNameWithoutTag{Value: "A"}, - FromNameVal: XMLNameWithoutTag{XMLName: Name{Local: "InXMLName"}, Value: "B"}, - FromNameTag: XMLNameWithTag{Value: "C"}, - InFieldName: "D", - }, - ExpectXML: `` + - `A` + - `B` + - `C` + - `D` + - ``, - MarshalOnly: true, - }, - { - Value: &NamePrecedence{ - XMLName: Name{Local: "Parent"}, - FromTag: XMLNameWithoutTag{XMLName: Name{Local: "InTag"}, Value: "A"}, - FromNameVal: XMLNameWithoutTag{XMLName: Name{Local: "FromNameVal"}, Value: "B"}, - FromNameTag: XMLNameWithTag{XMLName: Name{Local: "InXMLNameTag"}, Value: "C"}, - InFieldName: "D", - }, - ExpectXML: `` + - `A` + - `B` + - `C` + - `D` + - ``, - UnmarshalOnly: true, - }, - - // xml.Name works in a plain field as well. - { - Value: &NameInField{Name{Space: "ns", Local: "foo"}}, - ExpectXML: ``, - }, - { - Value: &NameInField{Name{Space: "ns", Local: "foo"}}, - ExpectXML: ``, - UnmarshalOnly: true, - }, - - // Marshaling zero xml.Name uses the tag or field name. - { - Value: &NameInField{}, - ExpectXML: ``, - MarshalOnly: true, - }, - - // Test attributes - { - Value: &AttrTest{ - Int: 8, - Named: 9, - Float: 23.5, - Uint8: 255, - Bool: true, - Str: "str", - Bytes: []byte("byt"), - }, - ExpectXML: ``, - }, - { - Value: &AttrTest{Bytes: []byte{}}, - ExpectXML: ``, - }, - { - Value: &OmitAttrTest{ - Int: 8, - Named: 9, - Float: 23.5, - Uint8: 255, - Bool: true, - Str: "str", - Bytes: []byte("byt"), - }, - ExpectXML: ``, - }, - { - Value: &OmitAttrTest{}, - ExpectXML: ``, - }, - - // pointer fields - { - Value: &PointerFieldsTest{Name: &nameAttr, Age: &ageAttr, Contents: &contentsAttr}, - ExpectXML: `lorem ipsum`, - MarshalOnly: true, - }, - - // empty chardata pointer field - { - Value: &ChardataEmptyTest{}, - ExpectXML: ``, - MarshalOnly: true, - }, - - // omitempty on fields - { - Value: &OmitFieldTest{ - Int: 8, - Named: 9, - Float: 23.5, - Uint8: 255, - Bool: true, - Str: "str", - Bytes: []byte("byt"), - Ptr: &PresenceTest{}, - }, - ExpectXML: `` + - `8` + - `9` + - `23.5` + - `255` + - `true` + - `str` + - `byt` + - `` + - ``, - }, - { - Value: &OmitFieldTest{}, - ExpectXML: ``, - }, - - // Test ",any" - { - ExpectXML: `knownunknown`, - Value: &AnyTest{ - Nested: "known", - AnyField: AnyHolder{ - XMLName: Name{Local: "other"}, - XML: "unknown", - }, - }, - }, - { - Value: &AnyTest{Nested: "known", - AnyField: AnyHolder{ - XML: "", - XMLName: Name{Local: "AnyField"}, - }, - }, - ExpectXML: `known`, - }, - { - ExpectXML: `b`, - Value: &AnyOmitTest{ - Nested: "b", - }, - }, - { - ExpectXML: `bei`, - Value: &AnySliceTest{ - Nested: "b", - AnyField: []AnyHolder{ - { - XMLName: Name{Local: "c"}, - XML: "e", - }, - { - XMLName: Name{Space: "f", Local: "g"}, - XML: "i", - }, - }, - }, - }, - { - ExpectXML: `b`, - Value: &AnySliceTest{ - Nested: "b", - }, - }, - - // Test recursive types. - { - Value: &RecurseA{ - A: "a1", - B: &RecurseB{ - A: &RecurseA{"a2", nil}, - B: "b1", - }, - }, - ExpectXML: `a1a2b1`, - }, - - // Test ignoring fields via "-" tag - { - ExpectXML: ``, - Value: &IgnoreTest{}, - }, - { - ExpectXML: ``, - Value: &IgnoreTest{PublicSecret: "can't tell"}, - MarshalOnly: true, - }, - { - ExpectXML: `ignore me`, - Value: &IgnoreTest{}, - UnmarshalOnly: true, - }, - - // Test escaping. - { - ExpectXML: `dquote: "; squote: '; ampersand: &; less: <; greater: >;`, - Value: &AnyTest{ - Nested: `dquote: "; squote: '; ampersand: &; less: <; greater: >;`, - AnyField: AnyHolder{XMLName: Name{Local: "empty"}}, - }, - }, - { - ExpectXML: `newline: ; cr: ; tab: ;`, - Value: &AnyTest{ - Nested: "newline: \n; cr: \r; tab: \t;", - AnyField: AnyHolder{XMLName: Name{Local: "AnyField"}}, - }, - }, - { - ExpectXML: "1\r2\r\n3\n\r4\n5", - Value: &AnyTest{ - Nested: "1\n2\n3\n\n4\n5", - }, - UnmarshalOnly: true, - }, - { - ExpectXML: `42`, - Value: &EmbedInt{ - MyInt: 42, - }, - }, - // Test omitempty with parent chain; see golang.org/issue/4168. - { - ExpectXML: ``, - Value: &Strings{}, - }, - // Custom marshalers. - { - ExpectXML: `hello world`, - Value: &MyMarshalerTest{}, - }, - { - ExpectXML: ``, - Value: &MarshalerStruct{}, - }, - { - ExpectXML: ``, - Value: &MarshalerValueStruct{}, - }, - { - ExpectXML: ``, - Value: &OuterStruct{IntAttr: 10}, - }, - { - ExpectXML: ``, - Value: &OuterNamedStruct{XMLName: Name{Space: "outerns", Local: "test"}, IntAttr: 10}, - }, - { - ExpectXML: ``, - Value: &OuterNamedOrderedStruct{XMLName: Name{Space: "outerns", Local: "test"}, IntAttr: 10}, - }, - { - ExpectXML: ``, - Value: &OuterOuterStruct{OuterStruct{IntAttr: 10}}, - }, - { - ExpectXML: `test`, - Value: &NestedAndChardata{AB: make([]string, 2), Chardata: "test"}, - }, - { - ExpectXML: ``, - Value: &NestedAndComment{AB: make([]string, 2), Comment: "test"}, - }, - { - ExpectXML: `hello world`, - Value: &XMLNSFieldStruct{Ns: "http://example.com/ns", Body: "hello world"}, - }, - { - ExpectXML: `hello world`, - Value: &NamedXMLNSFieldStruct{Ns: "http://example.com/ns", Body: "hello world"}, - }, - { - ExpectXML: `hello world`, - Value: &NamedXMLNSFieldStruct{Ns: "", Body: "hello world"}, - }, - { - ExpectXML: `hello world`, - Value: &XMLNSFieldStructWithOmitEmpty{Body: "hello world"}, - }, - { - // The xmlns attribute must be ignored because the - // element is in the empty namespace, so it's not possible - // to set the default namespace to something non-empty. - ExpectXML: `hello world`, - Value: &NamedXMLNSFieldStructWithEmptyNamespace{Ns: "foo", Body: "hello world"}, - MarshalOnly: true, - }, - { - ExpectXML: `hello world`, - Value: &RecursiveXMLNSFieldStruct{ - Ns: "foo", - Body: &RecursiveXMLNSFieldStruct{ - Text: "hello world", - }, - }, - }, -} - -func TestMarshal(t *testing.T) { - for idx, test := range marshalTests { - if test.UnmarshalOnly { - continue - } - data, err := Marshal(test.Value) - if err != nil { - t.Errorf("#%d: marshal(%#v): %s", idx, test.Value, err) - continue - } - if got, want := string(data), test.ExpectXML; got != want { - if strings.Contains(want, "\n") { - t.Errorf("#%d: marshal(%#v):\nHAVE:\n%s\nWANT:\n%s", idx, test.Value, got, want) - } else { - t.Errorf("#%d: marshal(%#v):\nhave %#q\nwant %#q", idx, test.Value, got, want) - } - } - } -} - -type AttrParent struct { - X string `xml:"X>Y,attr"` -} - -type BadAttr struct { - Name []string `xml:"name,attr"` -} - -var marshalErrorTests = []struct { - Value interface{} - Err string - Kind reflect.Kind -}{ - { - Value: make(chan bool), - Err: "xml: unsupported type: chan bool", - Kind: reflect.Chan, - }, - { - Value: map[string]string{ - "question": "What do you get when you multiply six by nine?", - "answer": "42", - }, - Err: "xml: unsupported type: map[string]string", - Kind: reflect.Map, - }, - { - Value: map[*Ship]bool{nil: false}, - Err: "xml: unsupported type: map[*xml.Ship]bool", - Kind: reflect.Map, - }, - { - Value: &Domain{Comment: []byte("f--bar")}, - Err: `xml: comments must not contain "--"`, - }, - // Reject parent chain with attr, never worked; see golang.org/issue/5033. - { - Value: &AttrParent{}, - Err: `xml: X>Y chain not valid with attr flag`, - }, - { - Value: BadAttr{[]string{"X", "Y"}}, - Err: `xml: unsupported type: []string`, - }, -} - -var marshalIndentTests = []struct { - Value interface{} - Prefix string - Indent string - ExpectXML string -}{ - { - Value: &SecretAgent{ - Handle: "007", - Identity: "James Bond", - Obfuscate: "", - }, - Prefix: "", - Indent: "\t", - ExpectXML: fmt.Sprintf("\n\tJames Bond\n"), - }, -} - -func TestMarshalErrors(t *testing.T) { - for idx, test := range marshalErrorTests { - data, err := Marshal(test.Value) - if err == nil { - t.Errorf("#%d: marshal(%#v) = [success] %q, want error %v", idx, test.Value, data, test.Err) - continue - } - if err.Error() != test.Err { - t.Errorf("#%d: marshal(%#v) = [error] %v, want %v", idx, test.Value, err, test.Err) - } - if test.Kind != reflect.Invalid { - if kind := err.(*UnsupportedTypeError).Type.Kind(); kind != test.Kind { - t.Errorf("#%d: marshal(%#v) = [error kind] %s, want %s", idx, test.Value, kind, test.Kind) - } - } - } -} - -// Do invertibility testing on the various structures that we test -func TestUnmarshal(t *testing.T) { - for i, test := range marshalTests { - if test.MarshalOnly { - continue - } - if _, ok := test.Value.(*Plain); ok { - continue - } - vt := reflect.TypeOf(test.Value) - dest := reflect.New(vt.Elem()).Interface() - err := Unmarshal([]byte(test.ExpectXML), dest) - - switch fix := dest.(type) { - case *Feed: - fix.Author.InnerXML = "" - for i := range fix.Entry { - fix.Entry[i].Author.InnerXML = "" - } - } - - if err != nil { - t.Errorf("#%d: unexpected error: %#v", i, err) - } else if got, want := dest, test.Value; !reflect.DeepEqual(got, want) { - t.Errorf("#%d: unmarshal(%q):\nhave %#v\nwant %#v", i, test.ExpectXML, got, want) - } - } -} - -func TestMarshalIndent(t *testing.T) { - for i, test := range marshalIndentTests { - data, err := MarshalIndent(test.Value, test.Prefix, test.Indent) - if err != nil { - t.Errorf("#%d: Error: %s", i, err) - continue - } - if got, want := string(data), test.ExpectXML; got != want { - t.Errorf("#%d: MarshalIndent:\nGot:%s\nWant:\n%s", i, got, want) - } - } -} - -type limitedBytesWriter struct { - w io.Writer - remain int // until writes fail -} - -func (lw *limitedBytesWriter) Write(p []byte) (n int, err error) { - if lw.remain <= 0 { - println("error") - return 0, errors.New("write limit hit") - } - if len(p) > lw.remain { - p = p[:lw.remain] - n, _ = lw.w.Write(p) - lw.remain = 0 - return n, errors.New("write limit hit") - } - n, err = lw.w.Write(p) - lw.remain -= n - return n, err -} - -func TestMarshalWriteErrors(t *testing.T) { - var buf bytes.Buffer - const writeCap = 1024 - w := &limitedBytesWriter{&buf, writeCap} - enc := NewEncoder(w) - var err error - var i int - const n = 4000 - for i = 1; i <= n; i++ { - err = enc.Encode(&Passenger{ - Name: []string{"Alice", "Bob"}, - Weight: 5, - }) - if err != nil { - break - } - } - if err == nil { - t.Error("expected an error") - } - if i == n { - t.Errorf("expected to fail before the end") - } - if buf.Len() != writeCap { - t.Errorf("buf.Len() = %d; want %d", buf.Len(), writeCap) - } -} - -func TestMarshalWriteIOErrors(t *testing.T) { - enc := NewEncoder(errWriter{}) - - expectErr := "unwritable" - err := enc.Encode(&Passenger{}) - if err == nil || err.Error() != expectErr { - t.Errorf("EscapeTest = [error] %v, want %v", err, expectErr) - } -} - -func TestMarshalFlush(t *testing.T) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - if err := enc.EncodeToken(CharData("hello world")); err != nil { - t.Fatalf("enc.EncodeToken: %v", err) - } - if buf.Len() > 0 { - t.Fatalf("enc.EncodeToken caused actual write: %q", buf.Bytes()) - } - if err := enc.Flush(); err != nil { - t.Fatalf("enc.Flush: %v", err) - } - if buf.String() != "hello world" { - t.Fatalf("after enc.Flush, buf.String() = %q, want %q", buf.String(), "hello world") - } -} - -var encodeElementTests = []struct { - desc string - value interface{} - start StartElement - expectXML string -}{{ - desc: "simple string", - value: "hello", - start: StartElement{ - Name: Name{Local: "a"}, - }, - expectXML: `hello`, -}, { - desc: "string with added attributes", - value: "hello", - start: StartElement{ - Name: Name{Local: "a"}, - Attr: []Attr{{ - Name: Name{Local: "x"}, - Value: "y", - }, { - Name: Name{Local: "foo"}, - Value: "bar", - }}, - }, - expectXML: `hello`, -}, { - desc: "start element with default name space", - value: struct { - Foo XMLNameWithNSTag - }{ - Foo: XMLNameWithNSTag{ - Value: "hello", - }, - }, - start: StartElement{ - Name: Name{Space: "ns", Local: "a"}, - Attr: []Attr{{ - Name: Name{Local: "xmlns"}, - // "ns" is the name space defined in XMLNameWithNSTag - Value: "ns", - }}, - }, - expectXML: `hello`, -}, { - desc: "start element in name space with different default name space", - value: struct { - Foo XMLNameWithNSTag - }{ - Foo: XMLNameWithNSTag{ - Value: "hello", - }, - }, - start: StartElement{ - Name: Name{Space: "ns2", Local: "a"}, - Attr: []Attr{{ - Name: Name{Local: "xmlns"}, - // "ns" is the name space defined in XMLNameWithNSTag - Value: "ns", - }}, - }, - expectXML: `hello`, -}, { - desc: "XMLMarshaler with start element with default name space", - value: &MyMarshalerTest{}, - start: StartElement{ - Name: Name{Space: "ns2", Local: "a"}, - Attr: []Attr{{ - Name: Name{Local: "xmlns"}, - // "ns" is the name space defined in XMLNameWithNSTag - Value: "ns", - }}, - }, - expectXML: `hello world`, -}} - -func TestEncodeElement(t *testing.T) { - for idx, test := range encodeElementTests { - var buf bytes.Buffer - enc := NewEncoder(&buf) - err := enc.EncodeElement(test.value, test.start) - if err != nil { - t.Fatalf("enc.EncodeElement: %v", err) - } - err = enc.Flush() - if err != nil { - t.Fatalf("enc.Flush: %v", err) - } - if got, want := buf.String(), test.expectXML; got != want { - t.Errorf("#%d(%s): EncodeElement(%#v, %#v):\nhave %#q\nwant %#q", idx, test.desc, test.value, test.start, got, want) - } - } -} - -func BenchmarkMarshal(b *testing.B) { - b.ReportAllocs() - for i := 0; i < b.N; i++ { - Marshal(atomValue) - } -} - -func BenchmarkUnmarshal(b *testing.B) { - b.ReportAllocs() - xml := []byte(atomXml) - for i := 0; i < b.N; i++ { - Unmarshal(xml, &Feed{}) - } -} - -// golang.org/issue/6556 -func TestStructPointerMarshal(t *testing.T) { - type A struct { - XMLName string `xml:"a"` - B []interface{} - } - type C struct { - XMLName Name - Value string `xml:"value"` - } - - a := new(A) - a.B = append(a.B, &C{ - XMLName: Name{Local: "c"}, - Value: "x", - }) - - b, err := Marshal(a) - if err != nil { - t.Fatal(err) - } - if x := string(b); x != "x" { - t.Fatal(x) - } - var v A - err = Unmarshal(b, &v) - if err != nil { - t.Fatal(err) - } -} - -var encodeTokenTests = []struct { - desc string - toks []Token - want string - err string -}{{ - desc: "start element with name space", - toks: []Token{ - StartElement{Name{"space", "local"}, nil}, - }, - want: ``, -}, { - desc: "start element with no name", - toks: []Token{ - StartElement{Name{"space", ""}, nil}, - }, - err: "xml: start tag with no name", -}, { - desc: "end element with no name", - toks: []Token{ - EndElement{Name{"space", ""}}, - }, - err: "xml: end tag with no name", -}, { - desc: "char data", - toks: []Token{ - CharData("foo"), - }, - want: `foo`, -}, { - desc: "char data with escaped chars", - toks: []Token{ - CharData(" \t\n"), - }, - want: " \n", -}, { - desc: "comment", - toks: []Token{ - Comment("foo"), - }, - want: ``, -}, { - desc: "comment with invalid content", - toks: []Token{ - Comment("foo-->"), - }, - err: "xml: EncodeToken of Comment containing --> marker", -}, { - desc: "proc instruction", - toks: []Token{ - ProcInst{"Target", []byte("Instruction")}, - }, - want: ``, -}, { - desc: "proc instruction with empty target", - toks: []Token{ - ProcInst{"", []byte("Instruction")}, - }, - err: "xml: EncodeToken of ProcInst with invalid Target", -}, { - desc: "proc instruction with bad content", - toks: []Token{ - ProcInst{"", []byte("Instruction?>")}, - }, - err: "xml: EncodeToken of ProcInst with invalid Target", -}, { - desc: "directive", - toks: []Token{ - Directive("foo"), - }, - want: ``, -}, { - desc: "more complex directive", - toks: []Token{ - Directive("DOCTYPE doc [ '> ]"), - }, - want: `'> ]>`, -}, { - desc: "directive instruction with bad name", - toks: []Token{ - Directive("foo>"), - }, - err: "xml: EncodeToken of Directive containing wrong < or > markers", -}, { - desc: "end tag without start tag", - toks: []Token{ - EndElement{Name{"foo", "bar"}}, - }, - err: "xml: end tag without start tag", -}, { - desc: "mismatching end tag local name", - toks: []Token{ - StartElement{Name{"", "foo"}, nil}, - EndElement{Name{"", "bar"}}, - }, - err: "xml: end tag does not match start tag ", - want: ``, -}, { - desc: "mismatching end tag namespace", - toks: []Token{ - StartElement{Name{"space", "foo"}, nil}, - EndElement{Name{"another", "foo"}}, - }, - err: "xml: end tag in namespace another does not match start tag in namespace space", - want: ``, -}, { - desc: "start element with explicit namespace", - toks: []Token{ - StartElement{Name{"space", "local"}, []Attr{ - {Name{"xmlns", "x"}, "space"}, - {Name{"space", "foo"}, "value"}, - }}, - }, - want: ``, -}, { - desc: "start element with explicit namespace and colliding prefix", - toks: []Token{ - StartElement{Name{"space", "local"}, []Attr{ - {Name{"xmlns", "x"}, "space"}, - {Name{"space", "foo"}, "value"}, - {Name{"x", "bar"}, "other"}, - }}, - }, - want: ``, -}, { - desc: "start element using previously defined namespace", - toks: []Token{ - StartElement{Name{"", "local"}, []Attr{ - {Name{"xmlns", "x"}, "space"}, - }}, - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"space", "x"}, "y"}, - }}, - }, - want: ``, -}, { - desc: "nested name space with same prefix", - toks: []Token{ - StartElement{Name{"", "foo"}, []Attr{ - {Name{"xmlns", "x"}, "space1"}, - }}, - StartElement{Name{"", "foo"}, []Attr{ - {Name{"xmlns", "x"}, "space2"}, - }}, - StartElement{Name{"", "foo"}, []Attr{ - {Name{"space1", "a"}, "space1 value"}, - {Name{"space2", "b"}, "space2 value"}, - }}, - EndElement{Name{"", "foo"}}, - EndElement{Name{"", "foo"}}, - StartElement{Name{"", "foo"}, []Attr{ - {Name{"space1", "a"}, "space1 value"}, - {Name{"space2", "b"}, "space2 value"}, - }}, - }, - want: ``, -}, { - desc: "start element defining several prefixes for the same name space", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"xmlns", "a"}, "space"}, - {Name{"xmlns", "b"}, "space"}, - {Name{"space", "x"}, "value"}, - }}, - }, - want: ``, -}, { - desc: "nested element redefines name space", - toks: []Token{ - StartElement{Name{"", "foo"}, []Attr{ - {Name{"xmlns", "x"}, "space"}, - }}, - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"xmlns", "y"}, "space"}, - {Name{"space", "a"}, "value"}, - }}, - }, - want: ``, -}, { - desc: "nested element creates alias for default name space", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - }}, - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"xmlns", "y"}, "space"}, - {Name{"space", "a"}, "value"}, - }}, - }, - want: ``, -}, { - desc: "nested element defines default name space with existing prefix", - toks: []Token{ - StartElement{Name{"", "foo"}, []Attr{ - {Name{"xmlns", "x"}, "space"}, - }}, - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - {Name{"space", "a"}, "value"}, - }}, - }, - want: ``, -}, { - desc: "nested element uses empty attribute name space when default ns defined", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - }}, - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "attr"}, "value"}, - }}, - }, - want: ``, -}, { - desc: "redefine xmlns", - toks: []Token{ - StartElement{Name{"", "foo"}, []Attr{ - {Name{"foo", "xmlns"}, "space"}, - }}, - }, - err: `xml: cannot redefine xmlns attribute prefix`, -}, { - desc: "xmlns with explicit name space #1", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"xml", "xmlns"}, "space"}, - }}, - }, - want: ``, -}, { - desc: "xmlns with explicit name space #2", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{xmlURL, "xmlns"}, "space"}, - }}, - }, - want: ``, -}, { - desc: "empty name space declaration is ignored", - toks: []Token{ - StartElement{Name{"", "foo"}, []Attr{ - {Name{"xmlns", "foo"}, ""}, - }}, - }, - want: ``, -}, { - desc: "attribute with no name is ignored", - toks: []Token{ - StartElement{Name{"", "foo"}, []Attr{ - {Name{"", ""}, "value"}, - }}, - }, - want: ``, -}, { - desc: "namespace URL with non-valid name", - toks: []Token{ - StartElement{Name{"/34", "foo"}, []Attr{ - {Name{"/34", "x"}, "value"}, - }}, - }, - want: `<_:foo xmlns:_="/34" _:x="value">`, -}, { - desc: "nested element resets default namespace to empty", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - }}, - StartElement{Name{"", "foo"}, []Attr{ - {Name{"", "xmlns"}, ""}, - {Name{"", "x"}, "value"}, - {Name{"space", "x"}, "value"}, - }}, - }, - want: ``, -}, { - desc: "nested element requires empty default name space", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - }}, - StartElement{Name{"", "foo"}, nil}, - }, - want: ``, -}, { - desc: "attribute uses name space from xmlns", - toks: []Token{ - StartElement{Name{"some/space", "foo"}, []Attr{ - {Name{"", "attr"}, "value"}, - {Name{"some/space", "other"}, "other value"}, - }}, - }, - want: ``, -}, { - desc: "default name space should not be used by attributes", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - {Name{"xmlns", "bar"}, "space"}, - {Name{"space", "baz"}, "foo"}, - }}, - StartElement{Name{"space", "baz"}, nil}, - EndElement{Name{"space", "baz"}}, - EndElement{Name{"space", "foo"}}, - }, - want: ``, -}, { - desc: "default name space not used by attributes, not explicitly defined", - toks: []Token{ - StartElement{Name{"space", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - {Name{"space", "baz"}, "foo"}, - }}, - StartElement{Name{"space", "baz"}, nil}, - EndElement{Name{"space", "baz"}}, - EndElement{Name{"space", "foo"}}, - }, - want: ``, -}, { - desc: "impossible xmlns declaration", - toks: []Token{ - StartElement{Name{"", "foo"}, []Attr{ - {Name{"", "xmlns"}, "space"}, - }}, - StartElement{Name{"space", "bar"}, []Attr{ - {Name{"space", "attr"}, "value"}, - }}, - }, - want: ``, -}} - -func TestEncodeToken(t *testing.T) { -loop: - for i, tt := range encodeTokenTests { - var buf bytes.Buffer - enc := NewEncoder(&buf) - var err error - for j, tok := range tt.toks { - err = enc.EncodeToken(tok) - if err != nil && j < len(tt.toks)-1 { - t.Errorf("#%d %s token #%d: %v", i, tt.desc, j, err) - continue loop - } - } - errorf := func(f string, a ...interface{}) { - t.Errorf("#%d %s token #%d:%s", i, tt.desc, len(tt.toks)-1, fmt.Sprintf(f, a...)) - } - switch { - case tt.err != "" && err == nil: - errorf(" expected error; got none") - continue - case tt.err == "" && err != nil: - errorf(" got error: %v", err) - continue - case tt.err != "" && err != nil && tt.err != err.Error(): - errorf(" error mismatch; got %v, want %v", err, tt.err) - continue - } - if err := enc.Flush(); err != nil { - errorf(" %v", err) - continue - } - if got := buf.String(); got != tt.want { - errorf("\ngot %v\nwant %v", got, tt.want) - continue - } - } -} - -func TestProcInstEncodeToken(t *testing.T) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - - if err := enc.EncodeToken(ProcInst{"xml", []byte("Instruction")}); err != nil { - t.Fatalf("enc.EncodeToken: expected to be able to encode xml target ProcInst as first token, %s", err) - } - - if err := enc.EncodeToken(ProcInst{"Target", []byte("Instruction")}); err != nil { - t.Fatalf("enc.EncodeToken: expected to be able to add non-xml target ProcInst") - } - - if err := enc.EncodeToken(ProcInst{"xml", []byte("Instruction")}); err == nil { - t.Fatalf("enc.EncodeToken: expected to not be allowed to encode xml target ProcInst when not first token") - } -} - -func TestDecodeEncode(t *testing.T) { - var in, out bytes.Buffer - in.WriteString(` - - - -`) - dec := NewDecoder(&in) - enc := NewEncoder(&out) - for tok, err := dec.Token(); err == nil; tok, err = dec.Token() { - err = enc.EncodeToken(tok) - if err != nil { - t.Fatalf("enc.EncodeToken: Unable to encode token (%#v), %v", tok, err) - } - } -} - -// Issue 9796. Used to fail with GORACE="halt_on_error=1" -race. -func TestRace9796(t *testing.T) { - type A struct{} - type B struct { - C []A `xml:"X>Y"` - } - var wg sync.WaitGroup - for i := 0; i < 2; i++ { - wg.Add(1) - go func() { - Marshal(B{[]A{A{}}}) - wg.Done() - }() - } - wg.Wait() -} - -func TestIsValidDirective(t *testing.T) { - testOK := []string{ - "<>", - "< < > >", - "' '>' >", - " ]>", - " '<' ' doc ANY> ]>", - ">>> a < comment --> [ ] >", - } - testKO := []string{ - "<", - ">", - "", - "< > > < < >", - " -->", - "", - "'", - "", - } - for _, s := range testOK { - if !isValidDirective(Directive(s)) { - t.Errorf("Directive %q is expected to be valid", s) - } - } - for _, s := range testKO { - if isValidDirective(Directive(s)) { - t.Errorf("Directive %q is expected to be invalid", s) - } - } -} - -// Issue 11719. EncodeToken used to silently eat tokens with an invalid type. -func TestSimpleUseOfEncodeToken(t *testing.T) { - var buf bytes.Buffer - enc := NewEncoder(&buf) - if err := enc.EncodeToken(&StartElement{Name: Name{"", "object1"}}); err == nil { - t.Errorf("enc.EncodeToken: pointer type should be rejected") - } - if err := enc.EncodeToken(&EndElement{Name: Name{"", "object1"}}); err == nil { - t.Errorf("enc.EncodeToken: pointer type should be rejected") - } - if err := enc.EncodeToken(StartElement{Name: Name{"", "object2"}}); err != nil { - t.Errorf("enc.EncodeToken: StartElement %s", err) - } - if err := enc.EncodeToken(EndElement{Name: Name{"", "object2"}}); err != nil { - t.Errorf("enc.EncodeToken: EndElement %s", err) - } - if err := enc.EncodeToken(Universe{}); err == nil { - t.Errorf("enc.EncodeToken: invalid type not caught") - } - if err := enc.Flush(); err != nil { - t.Errorf("enc.Flush: %s", err) - } - if buf.Len() == 0 { - t.Errorf("enc.EncodeToken: empty buffer") - } - want := "" - if buf.String() != want { - t.Errorf("enc.EncodeToken: expected %q; got %q", want, buf.String()) - } -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/read.go b/vendor/golang.org/x/net/webdav/internal/xml/read.go deleted file mode 100644 index 75b9f2b..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/read.go +++ /dev/null @@ -1,692 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xml - -import ( - "bytes" - "encoding" - "errors" - "fmt" - "reflect" - "strconv" - "strings" -) - -// BUG(rsc): Mapping between XML elements and data structures is inherently flawed: -// an XML element is an order-dependent collection of anonymous -// values, while a data structure is an order-independent collection -// of named values. -// See package json for a textual representation more suitable -// to data structures. - -// Unmarshal parses the XML-encoded data and stores the result in -// the value pointed to by v, which must be an arbitrary struct, -// slice, or string. Well-formed data that does not fit into v is -// discarded. -// -// Because Unmarshal uses the reflect package, it can only assign -// to exported (upper case) fields. Unmarshal uses a case-sensitive -// comparison to match XML element names to tag values and struct -// field names. -// -// Unmarshal maps an XML element to a struct using the following rules. -// In the rules, the tag of a field refers to the value associated with the -// key 'xml' in the struct field's tag (see the example above). -// -// * If the struct has a field of type []byte or string with tag -// ",innerxml", Unmarshal accumulates the raw XML nested inside the -// element in that field. The rest of the rules still apply. -// -// * If the struct has a field named XMLName of type xml.Name, -// Unmarshal records the element name in that field. -// -// * If the XMLName field has an associated tag of the form -// "name" or "namespace-URL name", the XML element must have -// the given name (and, optionally, name space) or else Unmarshal -// returns an error. -// -// * If the XML element has an attribute whose name matches a -// struct field name with an associated tag containing ",attr" or -// the explicit name in a struct field tag of the form "name,attr", -// Unmarshal records the attribute value in that field. -// -// * If the XML element contains character data, that data is -// accumulated in the first struct field that has tag ",chardata". -// The struct field may have type []byte or string. -// If there is no such field, the character data is discarded. -// -// * If the XML element contains comments, they are accumulated in -// the first struct field that has tag ",comment". The struct -// field may have type []byte or string. If there is no such -// field, the comments are discarded. -// -// * If the XML element contains a sub-element whose name matches -// the prefix of a tag formatted as "a" or "a>b>c", unmarshal -// will descend into the XML structure looking for elements with the -// given names, and will map the innermost elements to that struct -// field. A tag starting with ">" is equivalent to one starting -// with the field name followed by ">". -// -// * If the XML element contains a sub-element whose name matches -// a struct field's XMLName tag and the struct field has no -// explicit name tag as per the previous rule, unmarshal maps -// the sub-element to that struct field. -// -// * If the XML element contains a sub-element whose name matches a -// field without any mode flags (",attr", ",chardata", etc), Unmarshal -// maps the sub-element to that struct field. -// -// * If the XML element contains a sub-element that hasn't matched any -// of the above rules and the struct has a field with tag ",any", -// unmarshal maps the sub-element to that struct field. -// -// * An anonymous struct field is handled as if the fields of its -// value were part of the outer struct. -// -// * A struct field with tag "-" is never unmarshalled into. -// -// Unmarshal maps an XML element to a string or []byte by saving the -// concatenation of that element's character data in the string or -// []byte. The saved []byte is never nil. -// -// Unmarshal maps an attribute value to a string or []byte by saving -// the value in the string or slice. -// -// Unmarshal maps an XML element to a slice by extending the length of -// the slice and mapping the element to the newly created value. -// -// Unmarshal maps an XML element or attribute value to a bool by -// setting it to the boolean value represented by the string. -// -// Unmarshal maps an XML element or attribute value to an integer or -// floating-point field by setting the field to the result of -// interpreting the string value in decimal. There is no check for -// overflow. -// -// Unmarshal maps an XML element to an xml.Name by recording the -// element name. -// -// Unmarshal maps an XML element to a pointer by setting the pointer -// to a freshly allocated value and then mapping the element to that value. -// -func Unmarshal(data []byte, v interface{}) error { - return NewDecoder(bytes.NewReader(data)).Decode(v) -} - -// Decode works like xml.Unmarshal, except it reads the decoder -// stream to find the start element. -func (d *Decoder) Decode(v interface{}) error { - return d.DecodeElement(v, nil) -} - -// DecodeElement works like xml.Unmarshal except that it takes -// a pointer to the start XML element to decode into v. -// It is useful when a client reads some raw XML tokens itself -// but also wants to defer to Unmarshal for some elements. -func (d *Decoder) DecodeElement(v interface{}, start *StartElement) error { - val := reflect.ValueOf(v) - if val.Kind() != reflect.Ptr { - return errors.New("non-pointer passed to Unmarshal") - } - return d.unmarshal(val.Elem(), start) -} - -// An UnmarshalError represents an error in the unmarshalling process. -type UnmarshalError string - -func (e UnmarshalError) Error() string { return string(e) } - -// Unmarshaler is the interface implemented by objects that can unmarshal -// an XML element description of themselves. -// -// UnmarshalXML decodes a single XML element -// beginning with the given start element. -// If it returns an error, the outer call to Unmarshal stops and -// returns that error. -// UnmarshalXML must consume exactly one XML element. -// One common implementation strategy is to unmarshal into -// a separate value with a layout matching the expected XML -// using d.DecodeElement, and then to copy the data from -// that value into the receiver. -// Another common strategy is to use d.Token to process the -// XML object one token at a time. -// UnmarshalXML may not use d.RawToken. -type Unmarshaler interface { - UnmarshalXML(d *Decoder, start StartElement) error -} - -// UnmarshalerAttr is the interface implemented by objects that can unmarshal -// an XML attribute description of themselves. -// -// UnmarshalXMLAttr decodes a single XML attribute. -// If it returns an error, the outer call to Unmarshal stops and -// returns that error. -// UnmarshalXMLAttr is used only for struct fields with the -// "attr" option in the field tag. -type UnmarshalerAttr interface { - UnmarshalXMLAttr(attr Attr) error -} - -// receiverType returns the receiver type to use in an expression like "%s.MethodName". -func receiverType(val interface{}) string { - t := reflect.TypeOf(val) - if t.Name() != "" { - return t.String() - } - return "(" + t.String() + ")" -} - -// unmarshalInterface unmarshals a single XML element into val. -// start is the opening tag of the element. -func (p *Decoder) unmarshalInterface(val Unmarshaler, start *StartElement) error { - // Record that decoder must stop at end tag corresponding to start. - p.pushEOF() - - p.unmarshalDepth++ - err := val.UnmarshalXML(p, *start) - p.unmarshalDepth-- - if err != nil { - p.popEOF() - return err - } - - if !p.popEOF() { - return fmt.Errorf("xml: %s.UnmarshalXML did not consume entire <%s> element", receiverType(val), start.Name.Local) - } - - return nil -} - -// unmarshalTextInterface unmarshals a single XML element into val. -// The chardata contained in the element (but not its children) -// is passed to the text unmarshaler. -func (p *Decoder) unmarshalTextInterface(val encoding.TextUnmarshaler, start *StartElement) error { - var buf []byte - depth := 1 - for depth > 0 { - t, err := p.Token() - if err != nil { - return err - } - switch t := t.(type) { - case CharData: - if depth == 1 { - buf = append(buf, t...) - } - case StartElement: - depth++ - case EndElement: - depth-- - } - } - return val.UnmarshalText(buf) -} - -// unmarshalAttr unmarshals a single XML attribute into val. -func (p *Decoder) unmarshalAttr(val reflect.Value, attr Attr) error { - if val.Kind() == reflect.Ptr { - if val.IsNil() { - val.Set(reflect.New(val.Type().Elem())) - } - val = val.Elem() - } - - if val.CanInterface() && val.Type().Implements(unmarshalerAttrType) { - // This is an unmarshaler with a non-pointer receiver, - // so it's likely to be incorrect, but we do what we're told. - return val.Interface().(UnmarshalerAttr).UnmarshalXMLAttr(attr) - } - if val.CanAddr() { - pv := val.Addr() - if pv.CanInterface() && pv.Type().Implements(unmarshalerAttrType) { - return pv.Interface().(UnmarshalerAttr).UnmarshalXMLAttr(attr) - } - } - - // Not an UnmarshalerAttr; try encoding.TextUnmarshaler. - if val.CanInterface() && val.Type().Implements(textUnmarshalerType) { - // This is an unmarshaler with a non-pointer receiver, - // so it's likely to be incorrect, but we do what we're told. - return val.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(attr.Value)) - } - if val.CanAddr() { - pv := val.Addr() - if pv.CanInterface() && pv.Type().Implements(textUnmarshalerType) { - return pv.Interface().(encoding.TextUnmarshaler).UnmarshalText([]byte(attr.Value)) - } - } - - copyValue(val, []byte(attr.Value)) - return nil -} - -var ( - unmarshalerType = reflect.TypeOf((*Unmarshaler)(nil)).Elem() - unmarshalerAttrType = reflect.TypeOf((*UnmarshalerAttr)(nil)).Elem() - textUnmarshalerType = reflect.TypeOf((*encoding.TextUnmarshaler)(nil)).Elem() -) - -// Unmarshal a single XML element into val. -func (p *Decoder) unmarshal(val reflect.Value, start *StartElement) error { - // Find start element if we need it. - if start == nil { - for { - tok, err := p.Token() - if err != nil { - return err - } - if t, ok := tok.(StartElement); ok { - start = &t - break - } - } - } - - // Load value from interface, but only if the result will be - // usefully addressable. - if val.Kind() == reflect.Interface && !val.IsNil() { - e := val.Elem() - if e.Kind() == reflect.Ptr && !e.IsNil() { - val = e - } - } - - if val.Kind() == reflect.Ptr { - if val.IsNil() { - val.Set(reflect.New(val.Type().Elem())) - } - val = val.Elem() - } - - if val.CanInterface() && val.Type().Implements(unmarshalerType) { - // This is an unmarshaler with a non-pointer receiver, - // so it's likely to be incorrect, but we do what we're told. - return p.unmarshalInterface(val.Interface().(Unmarshaler), start) - } - - if val.CanAddr() { - pv := val.Addr() - if pv.CanInterface() && pv.Type().Implements(unmarshalerType) { - return p.unmarshalInterface(pv.Interface().(Unmarshaler), start) - } - } - - if val.CanInterface() && val.Type().Implements(textUnmarshalerType) { - return p.unmarshalTextInterface(val.Interface().(encoding.TextUnmarshaler), start) - } - - if val.CanAddr() { - pv := val.Addr() - if pv.CanInterface() && pv.Type().Implements(textUnmarshalerType) { - return p.unmarshalTextInterface(pv.Interface().(encoding.TextUnmarshaler), start) - } - } - - var ( - data []byte - saveData reflect.Value - comment []byte - saveComment reflect.Value - saveXML reflect.Value - saveXMLIndex int - saveXMLData []byte - saveAny reflect.Value - sv reflect.Value - tinfo *typeInfo - err error - ) - - switch v := val; v.Kind() { - default: - return errors.New("unknown type " + v.Type().String()) - - case reflect.Interface: - // TODO: For now, simply ignore the field. In the near - // future we may choose to unmarshal the start - // element on it, if not nil. - return p.Skip() - - case reflect.Slice: - typ := v.Type() - if typ.Elem().Kind() == reflect.Uint8 { - // []byte - saveData = v - break - } - - // Slice of element values. - // Grow slice. - n := v.Len() - if n >= v.Cap() { - ncap := 2 * n - if ncap < 4 { - ncap = 4 - } - new := reflect.MakeSlice(typ, n, ncap) - reflect.Copy(new, v) - v.Set(new) - } - v.SetLen(n + 1) - - // Recur to read element into slice. - if err := p.unmarshal(v.Index(n), start); err != nil { - v.SetLen(n) - return err - } - return nil - - case reflect.Bool, reflect.Float32, reflect.Float64, reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, reflect.String: - saveData = v - - case reflect.Struct: - typ := v.Type() - if typ == nameType { - v.Set(reflect.ValueOf(start.Name)) - break - } - - sv = v - tinfo, err = getTypeInfo(typ) - if err != nil { - return err - } - - // Validate and assign element name. - if tinfo.xmlname != nil { - finfo := tinfo.xmlname - if finfo.name != "" && finfo.name != start.Name.Local { - return UnmarshalError("expected element type <" + finfo.name + "> but have <" + start.Name.Local + ">") - } - if finfo.xmlns != "" && finfo.xmlns != start.Name.Space { - e := "expected element <" + finfo.name + "> in name space " + finfo.xmlns + " but have " - if start.Name.Space == "" { - e += "no name space" - } else { - e += start.Name.Space - } - return UnmarshalError(e) - } - fv := finfo.value(sv) - if _, ok := fv.Interface().(Name); ok { - fv.Set(reflect.ValueOf(start.Name)) - } - } - - // Assign attributes. - // Also, determine whether we need to save character data or comments. - for i := range tinfo.fields { - finfo := &tinfo.fields[i] - switch finfo.flags & fMode { - case fAttr: - strv := finfo.value(sv) - // Look for attribute. - for _, a := range start.Attr { - if a.Name.Local == finfo.name && (finfo.xmlns == "" || finfo.xmlns == a.Name.Space) { - if err := p.unmarshalAttr(strv, a); err != nil { - return err - } - break - } - } - - case fCharData: - if !saveData.IsValid() { - saveData = finfo.value(sv) - } - - case fComment: - if !saveComment.IsValid() { - saveComment = finfo.value(sv) - } - - case fAny, fAny | fElement: - if !saveAny.IsValid() { - saveAny = finfo.value(sv) - } - - case fInnerXml: - if !saveXML.IsValid() { - saveXML = finfo.value(sv) - if p.saved == nil { - saveXMLIndex = 0 - p.saved = new(bytes.Buffer) - } else { - saveXMLIndex = p.savedOffset() - } - } - } - } - } - - // Find end element. - // Process sub-elements along the way. -Loop: - for { - var savedOffset int - if saveXML.IsValid() { - savedOffset = p.savedOffset() - } - tok, err := p.Token() - if err != nil { - return err - } - switch t := tok.(type) { - case StartElement: - consumed := false - if sv.IsValid() { - consumed, err = p.unmarshalPath(tinfo, sv, nil, &t) - if err != nil { - return err - } - if !consumed && saveAny.IsValid() { - consumed = true - if err := p.unmarshal(saveAny, &t); err != nil { - return err - } - } - } - if !consumed { - if err := p.Skip(); err != nil { - return err - } - } - - case EndElement: - if saveXML.IsValid() { - saveXMLData = p.saved.Bytes()[saveXMLIndex:savedOffset] - if saveXMLIndex == 0 { - p.saved = nil - } - } - break Loop - - case CharData: - if saveData.IsValid() { - data = append(data, t...) - } - - case Comment: - if saveComment.IsValid() { - comment = append(comment, t...) - } - } - } - - if saveData.IsValid() && saveData.CanInterface() && saveData.Type().Implements(textUnmarshalerType) { - if err := saveData.Interface().(encoding.TextUnmarshaler).UnmarshalText(data); err != nil { - return err - } - saveData = reflect.Value{} - } - - if saveData.IsValid() && saveData.CanAddr() { - pv := saveData.Addr() - if pv.CanInterface() && pv.Type().Implements(textUnmarshalerType) { - if err := pv.Interface().(encoding.TextUnmarshaler).UnmarshalText(data); err != nil { - return err - } - saveData = reflect.Value{} - } - } - - if err := copyValue(saveData, data); err != nil { - return err - } - - switch t := saveComment; t.Kind() { - case reflect.String: - t.SetString(string(comment)) - case reflect.Slice: - t.Set(reflect.ValueOf(comment)) - } - - switch t := saveXML; t.Kind() { - case reflect.String: - t.SetString(string(saveXMLData)) - case reflect.Slice: - t.Set(reflect.ValueOf(saveXMLData)) - } - - return nil -} - -func copyValue(dst reflect.Value, src []byte) (err error) { - dst0 := dst - - if dst.Kind() == reflect.Ptr { - if dst.IsNil() { - dst.Set(reflect.New(dst.Type().Elem())) - } - dst = dst.Elem() - } - - // Save accumulated data. - switch dst.Kind() { - case reflect.Invalid: - // Probably a comment. - default: - return errors.New("cannot unmarshal into " + dst0.Type().String()) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - itmp, err := strconv.ParseInt(string(src), 10, dst.Type().Bits()) - if err != nil { - return err - } - dst.SetInt(itmp) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - utmp, err := strconv.ParseUint(string(src), 10, dst.Type().Bits()) - if err != nil { - return err - } - dst.SetUint(utmp) - case reflect.Float32, reflect.Float64: - ftmp, err := strconv.ParseFloat(string(src), dst.Type().Bits()) - if err != nil { - return err - } - dst.SetFloat(ftmp) - case reflect.Bool: - value, err := strconv.ParseBool(strings.TrimSpace(string(src))) - if err != nil { - return err - } - dst.SetBool(value) - case reflect.String: - dst.SetString(string(src)) - case reflect.Slice: - if len(src) == 0 { - // non-nil to flag presence - src = []byte{} - } - dst.SetBytes(src) - } - return nil -} - -// unmarshalPath walks down an XML structure looking for wanted -// paths, and calls unmarshal on them. -// The consumed result tells whether XML elements have been consumed -// from the Decoder until start's matching end element, or if it's -// still untouched because start is uninteresting for sv's fields. -func (p *Decoder) unmarshalPath(tinfo *typeInfo, sv reflect.Value, parents []string, start *StartElement) (consumed bool, err error) { - recurse := false -Loop: - for i := range tinfo.fields { - finfo := &tinfo.fields[i] - if finfo.flags&fElement == 0 || len(finfo.parents) < len(parents) || finfo.xmlns != "" && finfo.xmlns != start.Name.Space { - continue - } - for j := range parents { - if parents[j] != finfo.parents[j] { - continue Loop - } - } - if len(finfo.parents) == len(parents) && finfo.name == start.Name.Local { - // It's a perfect match, unmarshal the field. - return true, p.unmarshal(finfo.value(sv), start) - } - if len(finfo.parents) > len(parents) && finfo.parents[len(parents)] == start.Name.Local { - // It's a prefix for the field. Break and recurse - // since it's not ok for one field path to be itself - // the prefix for another field path. - recurse = true - - // We can reuse the same slice as long as we - // don't try to append to it. - parents = finfo.parents[:len(parents)+1] - break - } - } - if !recurse { - // We have no business with this element. - return false, nil - } - // The element is not a perfect match for any field, but one - // or more fields have the path to this element as a parent - // prefix. Recurse and attempt to match these. - for { - var tok Token - tok, err = p.Token() - if err != nil { - return true, err - } - switch t := tok.(type) { - case StartElement: - consumed2, err := p.unmarshalPath(tinfo, sv, parents, &t) - if err != nil { - return true, err - } - if !consumed2 { - if err := p.Skip(); err != nil { - return true, err - } - } - case EndElement: - return true, nil - } - } -} - -// Skip reads tokens until it has consumed the end element -// matching the most recent start element already consumed. -// It recurs if it encounters a start element, so it can be used to -// skip nested structures. -// It returns nil if it finds an end element matching the start -// element; otherwise it returns an error describing the problem. -func (d *Decoder) Skip() error { - for { - tok, err := d.Token() - if err != nil { - return err - } - switch tok.(type) { - case StartElement: - if err := d.Skip(); err != nil { - return err - } - case EndElement: - return nil - } - } -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/read_test.go b/vendor/golang.org/x/net/webdav/internal/xml/read_test.go deleted file mode 100644 index 02f1e10..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/read_test.go +++ /dev/null @@ -1,744 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xml - -import ( - "bytes" - "fmt" - "io" - "reflect" - "strings" - "testing" - "time" -) - -// Stripped down Atom feed data structures. - -func TestUnmarshalFeed(t *testing.T) { - var f Feed - if err := Unmarshal([]byte(atomFeedString), &f); err != nil { - t.Fatalf("Unmarshal: %s", err) - } - if !reflect.DeepEqual(f, atomFeed) { - t.Fatalf("have %#v\nwant %#v", f, atomFeed) - } -} - -// hget http://codereview.appspot.com/rss/mine/rsc -const atomFeedString = ` - -Code Review - My issueshttp://codereview.appspot.com/rietveld<>rietveld: an attempt at pubsubhubbub -2009-10-04T01:35:58+00:00email-address-removedurn:md5:134d9179c41f806be79b3a5f7877d19a - An attempt at adding pubsubhubbub support to Rietveld. -http://code.google.com/p/pubsubhubbub -http://code.google.com/p/rietveld/issues/detail?id=155 - -The server side of the protocol is trivial: - 1. add a &lt;link rel=&quot;hub&quot; href=&quot;hub-server&quot;&gt; tag to all - feeds that will be pubsubhubbubbed. - 2. every time one of those feeds changes, tell the hub - with a simple POST request. - -I have tested this by adding debug prints to a local hub -server and checking that the server got the right publish -requests. - -I can&#39;t quite get the server to work, but I think the bug -is not in my code. I think that the server expects to be -able to grab the feed and see the feed&#39;s actual URL in -the link rel=&quot;self&quot;, but the default value for that drops -the :port from the URL, and I cannot for the life of me -figure out how to get the Atom generator deep inside -django not to do that, or even where it is doing that, -or even what code is running to generate the Atom feed. -(I thought I knew but I added some assert False statements -and it kept running!) - -Ignoring that particular problem, I would appreciate -feedback on the right way to get the two values at -the top of feeds.py marked NOTE(rsc). - - -rietveld: correct tab handling -2009-10-03T23:02:17+00:00email-address-removedurn:md5:0a2a4f19bb815101f0ba2904aed7c35a - This fixes the buggy tab rendering that can be seen at -http://codereview.appspot.com/116075/diff/1/2 - -The fundamental problem was that the tab code was -not being told what column the text began in, so it -didn&#39;t know where to put the tab stops. Another problem -was that some of the code assumed that string byte -offsets were the same as column offsets, which is only -true if there are no tabs. - -In the process of fixing this, I cleaned up the arguments -to Fold and ExpandTabs and renamed them Break and -_ExpandTabs so that I could be sure that I found all the -call sites. I also wanted to verify that ExpandTabs was -not being used from outside intra_region_diff.py. - - - ` - -type Feed struct { - XMLName Name `xml:"http://www.w3.org/2005/Atom feed"` - Title string `xml:"title"` - Id string `xml:"id"` - Link []Link `xml:"link"` - Updated time.Time `xml:"updated,attr"` - Author Person `xml:"author"` - Entry []Entry `xml:"entry"` -} - -type Entry struct { - Title string `xml:"title"` - Id string `xml:"id"` - Link []Link `xml:"link"` - Updated time.Time `xml:"updated"` - Author Person `xml:"author"` - Summary Text `xml:"summary"` -} - -type Link struct { - Rel string `xml:"rel,attr,omitempty"` - Href string `xml:"href,attr"` -} - -type Person struct { - Name string `xml:"name"` - URI string `xml:"uri"` - Email string `xml:"email"` - InnerXML string `xml:",innerxml"` -} - -type Text struct { - Type string `xml:"type,attr,omitempty"` - Body string `xml:",chardata"` -} - -var atomFeed = Feed{ - XMLName: Name{"http://www.w3.org/2005/Atom", "feed"}, - Title: "Code Review - My issues", - Link: []Link{ - {Rel: "alternate", Href: "http://codereview.appspot.com/"}, - {Rel: "self", Href: "http://codereview.appspot.com/rss/mine/rsc"}, - }, - Id: "http://codereview.appspot.com/", - Updated: ParseTime("2009-10-04T01:35:58+00:00"), - Author: Person{ - Name: "rietveld<>", - InnerXML: "rietveld<>", - }, - Entry: []Entry{ - { - Title: "rietveld: an attempt at pubsubhubbub\n", - Link: []Link{ - {Rel: "alternate", Href: "http://codereview.appspot.com/126085"}, - }, - Updated: ParseTime("2009-10-04T01:35:58+00:00"), - Author: Person{ - Name: "email-address-removed", - InnerXML: "email-address-removed", - }, - Id: "urn:md5:134d9179c41f806be79b3a5f7877d19a", - Summary: Text{ - Type: "html", - Body: ` - An attempt at adding pubsubhubbub support to Rietveld. -http://code.google.com/p/pubsubhubbub -http://code.google.com/p/rietveld/issues/detail?id=155 - -The server side of the protocol is trivial: - 1. add a <link rel="hub" href="hub-server"> tag to all - feeds that will be pubsubhubbubbed. - 2. every time one of those feeds changes, tell the hub - with a simple POST request. - -I have tested this by adding debug prints to a local hub -server and checking that the server got the right publish -requests. - -I can't quite get the server to work, but I think the bug -is not in my code. I think that the server expects to be -able to grab the feed and see the feed's actual URL in -the link rel="self", but the default value for that drops -the :port from the URL, and I cannot for the life of me -figure out how to get the Atom generator deep inside -django not to do that, or even where it is doing that, -or even what code is running to generate the Atom feed. -(I thought I knew but I added some assert False statements -and it kept running!) - -Ignoring that particular problem, I would appreciate -feedback on the right way to get the two values at -the top of feeds.py marked NOTE(rsc). - - -`, - }, - }, - { - Title: "rietveld: correct tab handling\n", - Link: []Link{ - {Rel: "alternate", Href: "http://codereview.appspot.com/124106"}, - }, - Updated: ParseTime("2009-10-03T23:02:17+00:00"), - Author: Person{ - Name: "email-address-removed", - InnerXML: "email-address-removed", - }, - Id: "urn:md5:0a2a4f19bb815101f0ba2904aed7c35a", - Summary: Text{ - Type: "html", - Body: ` - This fixes the buggy tab rendering that can be seen at -http://codereview.appspot.com/116075/diff/1/2 - -The fundamental problem was that the tab code was -not being told what column the text began in, so it -didn't know where to put the tab stops. Another problem -was that some of the code assumed that string byte -offsets were the same as column offsets, which is only -true if there are no tabs. - -In the process of fixing this, I cleaned up the arguments -to Fold and ExpandTabs and renamed them Break and -_ExpandTabs so that I could be sure that I found all the -call sites. I also wanted to verify that ExpandTabs was -not being used from outside intra_region_diff.py. - - -`, - }, - }, - }, -} - -const pathTestString = ` - - 1 - - - A - - - B - - - C - D - - <_> - E - - - 2 - -` - -type PathTestItem struct { - Value string -} - -type PathTestA struct { - Items []PathTestItem `xml:">Item1"` - Before, After string -} - -type PathTestB struct { - Other []PathTestItem `xml:"Items>Item1"` - Before, After string -} - -type PathTestC struct { - Values1 []string `xml:"Items>Item1>Value"` - Values2 []string `xml:"Items>Item2>Value"` - Before, After string -} - -type PathTestSet struct { - Item1 []PathTestItem -} - -type PathTestD struct { - Other PathTestSet `xml:"Items"` - Before, After string -} - -type PathTestE struct { - Underline string `xml:"Items>_>Value"` - Before, After string -} - -var pathTests = []interface{}{ - &PathTestA{Items: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"}, - &PathTestB{Other: []PathTestItem{{"A"}, {"D"}}, Before: "1", After: "2"}, - &PathTestC{Values1: []string{"A", "C", "D"}, Values2: []string{"B"}, Before: "1", After: "2"}, - &PathTestD{Other: PathTestSet{Item1: []PathTestItem{{"A"}, {"D"}}}, Before: "1", After: "2"}, - &PathTestE{Underline: "E", Before: "1", After: "2"}, -} - -func TestUnmarshalPaths(t *testing.T) { - for _, pt := range pathTests { - v := reflect.New(reflect.TypeOf(pt).Elem()).Interface() - if err := Unmarshal([]byte(pathTestString), v); err != nil { - t.Fatalf("Unmarshal: %s", err) - } - if !reflect.DeepEqual(v, pt) { - t.Fatalf("have %#v\nwant %#v", v, pt) - } - } -} - -type BadPathTestA struct { - First string `xml:"items>item1"` - Other string `xml:"items>item2"` - Second string `xml:"items"` -} - -type BadPathTestB struct { - Other string `xml:"items>item2>value"` - First string `xml:"items>item1"` - Second string `xml:"items>item1>value"` -} - -type BadPathTestC struct { - First string - Second string `xml:"First"` -} - -type BadPathTestD struct { - BadPathEmbeddedA - BadPathEmbeddedB -} - -type BadPathEmbeddedA struct { - First string -} - -type BadPathEmbeddedB struct { - Second string `xml:"First"` -} - -var badPathTests = []struct { - v, e interface{} -}{ - {&BadPathTestA{}, &TagPathError{reflect.TypeOf(BadPathTestA{}), "First", "items>item1", "Second", "items"}}, - {&BadPathTestB{}, &TagPathError{reflect.TypeOf(BadPathTestB{}), "First", "items>item1", "Second", "items>item1>value"}}, - {&BadPathTestC{}, &TagPathError{reflect.TypeOf(BadPathTestC{}), "First", "", "Second", "First"}}, - {&BadPathTestD{}, &TagPathError{reflect.TypeOf(BadPathTestD{}), "First", "", "Second", "First"}}, -} - -func TestUnmarshalBadPaths(t *testing.T) { - for _, tt := range badPathTests { - err := Unmarshal([]byte(pathTestString), tt.v) - if !reflect.DeepEqual(err, tt.e) { - t.Fatalf("Unmarshal with %#v didn't fail properly:\nhave %#v,\nwant %#v", tt.v, err, tt.e) - } - } -} - -const OK = "OK" -const withoutNameTypeData = ` - -` - -type TestThree struct { - XMLName Name `xml:"Test3"` - Attr string `xml:",attr"` -} - -func TestUnmarshalWithoutNameType(t *testing.T) { - var x TestThree - if err := Unmarshal([]byte(withoutNameTypeData), &x); err != nil { - t.Fatalf("Unmarshal: %s", err) - } - if x.Attr != OK { - t.Fatalf("have %v\nwant %v", x.Attr, OK) - } -} - -func TestUnmarshalAttr(t *testing.T) { - type ParamVal struct { - Int int `xml:"int,attr"` - } - - type ParamPtr struct { - Int *int `xml:"int,attr"` - } - - type ParamStringPtr struct { - Int *string `xml:"int,attr"` - } - - x := []byte(``) - - p1 := &ParamPtr{} - if err := Unmarshal(x, p1); err != nil { - t.Fatalf("Unmarshal: %s", err) - } - if p1.Int == nil { - t.Fatalf("Unmarshal failed in to *int field") - } else if *p1.Int != 1 { - t.Fatalf("Unmarshal with %s failed:\nhave %#v,\n want %#v", x, p1.Int, 1) - } - - p2 := &ParamVal{} - if err := Unmarshal(x, p2); err != nil { - t.Fatalf("Unmarshal: %s", err) - } - if p2.Int != 1 { - t.Fatalf("Unmarshal with %s failed:\nhave %#v,\n want %#v", x, p2.Int, 1) - } - - p3 := &ParamStringPtr{} - if err := Unmarshal(x, p3); err != nil { - t.Fatalf("Unmarshal: %s", err) - } - if p3.Int == nil { - t.Fatalf("Unmarshal failed in to *string field") - } else if *p3.Int != "1" { - t.Fatalf("Unmarshal with %s failed:\nhave %#v,\n want %#v", x, p3.Int, 1) - } -} - -type Tables struct { - HTable string `xml:"http://www.w3.org/TR/html4/ table"` - FTable string `xml:"http://www.w3schools.com/furniture table"` -} - -var tables = []struct { - xml string - tab Tables - ns string -}{ - { - xml: `` + - `hello
    ` + - `world
    ` + - `
    `, - tab: Tables{"hello", "world"}, - }, - { - xml: `` + - `world
    ` + - `hello
    ` + - `
    `, - tab: Tables{"hello", "world"}, - }, - { - xml: `` + - `world` + - `hello` + - ``, - tab: Tables{"hello", "world"}, - }, - { - xml: `` + - `bogus
    ` + - `
    `, - tab: Tables{}, - }, - { - xml: `` + - `only
    ` + - `
    `, - tab: Tables{HTable: "only"}, - ns: "http://www.w3.org/TR/html4/", - }, - { - xml: `` + - `only
    ` + - `
    `, - tab: Tables{FTable: "only"}, - ns: "http://www.w3schools.com/furniture", - }, - { - xml: `` + - `only
    ` + - `
    `, - tab: Tables{}, - ns: "something else entirely", - }, -} - -func TestUnmarshalNS(t *testing.T) { - for i, tt := range tables { - var dst Tables - var err error - if tt.ns != "" { - d := NewDecoder(strings.NewReader(tt.xml)) - d.DefaultSpace = tt.ns - err = d.Decode(&dst) - } else { - err = Unmarshal([]byte(tt.xml), &dst) - } - if err != nil { - t.Errorf("#%d: Unmarshal: %v", i, err) - continue - } - want := tt.tab - if dst != want { - t.Errorf("#%d: dst=%+v, want %+v", i, dst, want) - } - } -} - -func TestRoundTrip(t *testing.T) { - // From issue 7535 - const s = `` - in := bytes.NewBufferString(s) - for i := 0; i < 10; i++ { - out := &bytes.Buffer{} - d := NewDecoder(in) - e := NewEncoder(out) - - for { - t, err := d.Token() - if err == io.EOF { - break - } - if err != nil { - fmt.Println("failed:", err) - return - } - e.EncodeToken(t) - } - e.Flush() - in = out - } - if got := in.String(); got != s { - t.Errorf("have: %q\nwant: %q\n", got, s) - } -} - -func TestMarshalNS(t *testing.T) { - dst := Tables{"hello", "world"} - data, err := Marshal(&dst) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - want := `hello
    world
    ` - str := string(data) - if str != want { - t.Errorf("have: %q\nwant: %q\n", str, want) - } -} - -type TableAttrs struct { - TAttr TAttr -} - -type TAttr struct { - HTable string `xml:"http://www.w3.org/TR/html4/ table,attr"` - FTable string `xml:"http://www.w3schools.com/furniture table,attr"` - Lang string `xml:"http://www.w3.org/XML/1998/namespace lang,attr,omitempty"` - Other1 string `xml:"http://golang.org/xml/ other,attr,omitempty"` - Other2 string `xml:"http://golang.org/xmlfoo/ other,attr,omitempty"` - Other3 string `xml:"http://golang.org/json/ other,attr,omitempty"` - Other4 string `xml:"http://golang.org/2/json/ other,attr,omitempty"` -} - -var tableAttrs = []struct { - xml string - tab TableAttrs - ns string -}{ - { - xml: ``, - tab: TableAttrs{TAttr{HTable: "hello", FTable: "world"}}, - }, - { - xml: ``, - tab: TableAttrs{TAttr{HTable: "hello", FTable: "world"}}, - }, - { - xml: ``, - tab: TableAttrs{TAttr{HTable: "hello", FTable: "world"}}, - }, - { - // Default space does not apply to attribute names. - xml: ``, - tab: TableAttrs{TAttr{HTable: "hello", FTable: ""}}, - }, - { - // Default space does not apply to attribute names. - xml: ``, - tab: TableAttrs{TAttr{HTable: "", FTable: "world"}}, - }, - { - xml: ``, - tab: TableAttrs{}, - }, - { - // Default space does not apply to attribute names. - xml: ``, - tab: TableAttrs{TAttr{HTable: "hello", FTable: ""}}, - ns: "http://www.w3schools.com/furniture", - }, - { - // Default space does not apply to attribute names. - xml: ``, - tab: TableAttrs{TAttr{HTable: "", FTable: "world"}}, - ns: "http://www.w3.org/TR/html4/", - }, - { - xml: ``, - tab: TableAttrs{}, - ns: "something else entirely", - }, -} - -func TestUnmarshalNSAttr(t *testing.T) { - for i, tt := range tableAttrs { - var dst TableAttrs - var err error - if tt.ns != "" { - d := NewDecoder(strings.NewReader(tt.xml)) - d.DefaultSpace = tt.ns - err = d.Decode(&dst) - } else { - err = Unmarshal([]byte(tt.xml), &dst) - } - if err != nil { - t.Errorf("#%d: Unmarshal: %v", i, err) - continue - } - want := tt.tab - if dst != want { - t.Errorf("#%d: dst=%+v, want %+v", i, dst, want) - } - } -} - -func TestMarshalNSAttr(t *testing.T) { - src := TableAttrs{TAttr{"hello", "world", "en_US", "other1", "other2", "other3", "other4"}} - data, err := Marshal(&src) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - want := `` - str := string(data) - if str != want { - t.Errorf("Marshal:\nhave: %#q\nwant: %#q\n", str, want) - } - - var dst TableAttrs - if err := Unmarshal(data, &dst); err != nil { - t.Errorf("Unmarshal: %v", err) - } - - if dst != src { - t.Errorf("Unmarshal = %q, want %q", dst, src) - } -} - -type MyCharData struct { - body string -} - -func (m *MyCharData) UnmarshalXML(d *Decoder, start StartElement) error { - for { - t, err := d.Token() - if err == io.EOF { // found end of element - break - } - if err != nil { - return err - } - if char, ok := t.(CharData); ok { - m.body += string(char) - } - } - return nil -} - -var _ Unmarshaler = (*MyCharData)(nil) - -func (m *MyCharData) UnmarshalXMLAttr(attr Attr) error { - panic("must not call") -} - -type MyAttr struct { - attr string -} - -func (m *MyAttr) UnmarshalXMLAttr(attr Attr) error { - m.attr = attr.Value - return nil -} - -var _ UnmarshalerAttr = (*MyAttr)(nil) - -type MyStruct struct { - Data *MyCharData - Attr *MyAttr `xml:",attr"` - - Data2 MyCharData - Attr2 MyAttr `xml:",attr"` -} - -func TestUnmarshaler(t *testing.T) { - xml := ` - - hello world - howdy world - - ` - - var m MyStruct - if err := Unmarshal([]byte(xml), &m); err != nil { - t.Fatal(err) - } - - if m.Data == nil || m.Attr == nil || m.Data.body != "hello world" || m.Attr.attr != "attr1" || m.Data2.body != "howdy world" || m.Attr2.attr != "attr2" { - t.Errorf("m=%#+v\n", m) - } -} - -type Pea struct { - Cotelydon string -} - -type Pod struct { - Pea interface{} `xml:"Pea"` -} - -// https://golang.org/issue/6836 -func TestUnmarshalIntoInterface(t *testing.T) { - pod := new(Pod) - pod.Pea = new(Pea) - xml := `Green stuff` - err := Unmarshal([]byte(xml), pod) - if err != nil { - t.Fatalf("failed to unmarshal %q: %v", xml, err) - } - pea, ok := pod.Pea.(*Pea) - if !ok { - t.Fatalf("unmarshalled into wrong type: have %T want *Pea", pod.Pea) - } - have, want := pea.Cotelydon, "Green stuff" - if have != want { - t.Errorf("failed to unmarshal into interface, have %q want %q", have, want) - } -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go b/vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go deleted file mode 100644 index c9a6421..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go +++ /dev/null @@ -1,371 +0,0 @@ -// Copyright 2011 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 xml - -import ( - "fmt" - "reflect" - "strings" - "sync" -) - -// typeInfo holds details for the xml representation of a type. -type typeInfo struct { - xmlname *fieldInfo - fields []fieldInfo -} - -// fieldInfo holds details for the xml representation of a single field. -type fieldInfo struct { - idx []int - name string - xmlns string - flags fieldFlags - parents []string -} - -type fieldFlags int - -const ( - fElement fieldFlags = 1 << iota - fAttr - fCharData - fInnerXml - fComment - fAny - - fOmitEmpty - - fMode = fElement | fAttr | fCharData | fInnerXml | fComment | fAny -) - -var tinfoMap = make(map[reflect.Type]*typeInfo) -var tinfoLock sync.RWMutex - -var nameType = reflect.TypeOf(Name{}) - -// getTypeInfo returns the typeInfo structure with details necessary -// for marshalling and unmarshalling typ. -func getTypeInfo(typ reflect.Type) (*typeInfo, error) { - tinfoLock.RLock() - tinfo, ok := tinfoMap[typ] - tinfoLock.RUnlock() - if ok { - return tinfo, nil - } - tinfo = &typeInfo{} - if typ.Kind() == reflect.Struct && typ != nameType { - n := typ.NumField() - for i := 0; i < n; i++ { - f := typ.Field(i) - if f.PkgPath != "" || f.Tag.Get("xml") == "-" { - continue // Private field - } - - // For embedded structs, embed its fields. - if f.Anonymous { - t := f.Type - if t.Kind() == reflect.Ptr { - t = t.Elem() - } - if t.Kind() == reflect.Struct { - inner, err := getTypeInfo(t) - if err != nil { - return nil, err - } - if tinfo.xmlname == nil { - tinfo.xmlname = inner.xmlname - } - for _, finfo := range inner.fields { - finfo.idx = append([]int{i}, finfo.idx...) - if err := addFieldInfo(typ, tinfo, &finfo); err != nil { - return nil, err - } - } - continue - } - } - - finfo, err := structFieldInfo(typ, &f) - if err != nil { - return nil, err - } - - if f.Name == "XMLName" { - tinfo.xmlname = finfo - continue - } - - // Add the field if it doesn't conflict with other fields. - if err := addFieldInfo(typ, tinfo, finfo); err != nil { - return nil, err - } - } - } - tinfoLock.Lock() - tinfoMap[typ] = tinfo - tinfoLock.Unlock() - return tinfo, nil -} - -// structFieldInfo builds and returns a fieldInfo for f. -func structFieldInfo(typ reflect.Type, f *reflect.StructField) (*fieldInfo, error) { - finfo := &fieldInfo{idx: f.Index} - - // Split the tag from the xml namespace if necessary. - tag := f.Tag.Get("xml") - if i := strings.Index(tag, " "); i >= 0 { - finfo.xmlns, tag = tag[:i], tag[i+1:] - } - - // Parse flags. - tokens := strings.Split(tag, ",") - if len(tokens) == 1 { - finfo.flags = fElement - } else { - tag = tokens[0] - for _, flag := range tokens[1:] { - switch flag { - case "attr": - finfo.flags |= fAttr - case "chardata": - finfo.flags |= fCharData - case "innerxml": - finfo.flags |= fInnerXml - case "comment": - finfo.flags |= fComment - case "any": - finfo.flags |= fAny - case "omitempty": - finfo.flags |= fOmitEmpty - } - } - - // Validate the flags used. - valid := true - switch mode := finfo.flags & fMode; mode { - case 0: - finfo.flags |= fElement - case fAttr, fCharData, fInnerXml, fComment, fAny: - if f.Name == "XMLName" || tag != "" && mode != fAttr { - valid = false - } - default: - // This will also catch multiple modes in a single field. - valid = false - } - if finfo.flags&fMode == fAny { - finfo.flags |= fElement - } - if finfo.flags&fOmitEmpty != 0 && finfo.flags&(fElement|fAttr) == 0 { - valid = false - } - if !valid { - return nil, fmt.Errorf("xml: invalid tag in field %s of type %s: %q", - f.Name, typ, f.Tag.Get("xml")) - } - } - - // Use of xmlns without a name is not allowed. - if finfo.xmlns != "" && tag == "" { - return nil, fmt.Errorf("xml: namespace without name in field %s of type %s: %q", - f.Name, typ, f.Tag.Get("xml")) - } - - if f.Name == "XMLName" { - // The XMLName field records the XML element name. Don't - // process it as usual because its name should default to - // empty rather than to the field name. - finfo.name = tag - return finfo, nil - } - - if tag == "" { - // If the name part of the tag is completely empty, get - // default from XMLName of underlying struct if feasible, - // or field name otherwise. - if xmlname := lookupXMLName(f.Type); xmlname != nil { - finfo.xmlns, finfo.name = xmlname.xmlns, xmlname.name - } else { - finfo.name = f.Name - } - return finfo, nil - } - - if finfo.xmlns == "" && finfo.flags&fAttr == 0 { - // If it's an element no namespace specified, get the default - // from the XMLName of enclosing struct if possible. - if xmlname := lookupXMLName(typ); xmlname != nil { - finfo.xmlns = xmlname.xmlns - } - } - - // Prepare field name and parents. - parents := strings.Split(tag, ">") - if parents[0] == "" { - parents[0] = f.Name - } - if parents[len(parents)-1] == "" { - return nil, fmt.Errorf("xml: trailing '>' in field %s of type %s", f.Name, typ) - } - finfo.name = parents[len(parents)-1] - if len(parents) > 1 { - if (finfo.flags & fElement) == 0 { - return nil, fmt.Errorf("xml: %s chain not valid with %s flag", tag, strings.Join(tokens[1:], ",")) - } - finfo.parents = parents[:len(parents)-1] - } - - // If the field type has an XMLName field, the names must match - // so that the behavior of both marshalling and unmarshalling - // is straightforward and unambiguous. - if finfo.flags&fElement != 0 { - ftyp := f.Type - xmlname := lookupXMLName(ftyp) - if xmlname != nil && xmlname.name != finfo.name { - return nil, fmt.Errorf("xml: name %q in tag of %s.%s conflicts with name %q in %s.XMLName", - finfo.name, typ, f.Name, xmlname.name, ftyp) - } - } - return finfo, nil -} - -// lookupXMLName returns the fieldInfo for typ's XMLName field -// in case it exists and has a valid xml field tag, otherwise -// it returns nil. -func lookupXMLName(typ reflect.Type) (xmlname *fieldInfo) { - for typ.Kind() == reflect.Ptr { - typ = typ.Elem() - } - if typ.Kind() != reflect.Struct { - return nil - } - for i, n := 0, typ.NumField(); i < n; i++ { - f := typ.Field(i) - if f.Name != "XMLName" { - continue - } - finfo, err := structFieldInfo(typ, &f) - if finfo.name != "" && err == nil { - return finfo - } - // Also consider errors as a non-existent field tag - // and let getTypeInfo itself report the error. - break - } - return nil -} - -func min(a, b int) int { - if a <= b { - return a - } - return b -} - -// addFieldInfo adds finfo to tinfo.fields if there are no -// conflicts, or if conflicts arise from previous fields that were -// obtained from deeper embedded structures than finfo. In the latter -// case, the conflicting entries are dropped. -// A conflict occurs when the path (parent + name) to a field is -// itself a prefix of another path, or when two paths match exactly. -// It is okay for field paths to share a common, shorter prefix. -func addFieldInfo(typ reflect.Type, tinfo *typeInfo, newf *fieldInfo) error { - var conflicts []int -Loop: - // First, figure all conflicts. Most working code will have none. - for i := range tinfo.fields { - oldf := &tinfo.fields[i] - if oldf.flags&fMode != newf.flags&fMode { - continue - } - if oldf.xmlns != "" && newf.xmlns != "" && oldf.xmlns != newf.xmlns { - continue - } - minl := min(len(newf.parents), len(oldf.parents)) - for p := 0; p < minl; p++ { - if oldf.parents[p] != newf.parents[p] { - continue Loop - } - } - if len(oldf.parents) > len(newf.parents) { - if oldf.parents[len(newf.parents)] == newf.name { - conflicts = append(conflicts, i) - } - } else if len(oldf.parents) < len(newf.parents) { - if newf.parents[len(oldf.parents)] == oldf.name { - conflicts = append(conflicts, i) - } - } else { - if newf.name == oldf.name { - conflicts = append(conflicts, i) - } - } - } - // Without conflicts, add the new field and return. - if conflicts == nil { - tinfo.fields = append(tinfo.fields, *newf) - return nil - } - - // If any conflict is shallower, ignore the new field. - // This matches the Go field resolution on embedding. - for _, i := range conflicts { - if len(tinfo.fields[i].idx) < len(newf.idx) { - return nil - } - } - - // Otherwise, if any of them is at the same depth level, it's an error. - for _, i := range conflicts { - oldf := &tinfo.fields[i] - if len(oldf.idx) == len(newf.idx) { - f1 := typ.FieldByIndex(oldf.idx) - f2 := typ.FieldByIndex(newf.idx) - return &TagPathError{typ, f1.Name, f1.Tag.Get("xml"), f2.Name, f2.Tag.Get("xml")} - } - } - - // Otherwise, the new field is shallower, and thus takes precedence, - // so drop the conflicting fields from tinfo and append the new one. - for c := len(conflicts) - 1; c >= 0; c-- { - i := conflicts[c] - copy(tinfo.fields[i:], tinfo.fields[i+1:]) - tinfo.fields = tinfo.fields[:len(tinfo.fields)-1] - } - tinfo.fields = append(tinfo.fields, *newf) - return nil -} - -// A TagPathError represents an error in the unmarshalling process -// caused by the use of field tags with conflicting paths. -type TagPathError struct { - Struct reflect.Type - Field1, Tag1 string - Field2, Tag2 string -} - -func (e *TagPathError) Error() string { - return fmt.Sprintf("%s field %q with tag %q conflicts with field %q with tag %q", e.Struct, e.Field1, e.Tag1, e.Field2, e.Tag2) -} - -// value returns v's field value corresponding to finfo. -// It's equivalent to v.FieldByIndex(finfo.idx), but initializes -// and dereferences pointers as necessary. -func (finfo *fieldInfo) value(v reflect.Value) reflect.Value { - for i, x := range finfo.idx { - if i > 0 { - t := v.Type() - if t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct { - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - v = v.Elem() - } - } - v = v.Field(x) - } - return v -} diff --git a/vendor/golang.org/x/net/webdav/internal/xml/xml.go b/vendor/golang.org/x/net/webdav/internal/xml/xml.go deleted file mode 100644 index ffab4a7..0000000 --- a/vendor/golang.org/x/net/webdav/internal/xml/xml.go +++ /dev/null @@ -1,1998 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package xml implements a simple XML 1.0 parser that -// understands XML name spaces. -package xml - -// References: -// Annotated XML spec: http://www.xml.com/axml/testaxml.htm -// XML name spaces: http://www.w3.org/TR/REC-xml-names/ - -// TODO(rsc): -// Test error handling. - -import ( - "bufio" - "bytes" - "errors" - "fmt" - "io" - "strconv" - "strings" - "unicode" - "unicode/utf8" -) - -// A SyntaxError represents a syntax error in the XML input stream. -type SyntaxError struct { - Msg string - Line int -} - -func (e *SyntaxError) Error() string { - return "XML syntax error on line " + strconv.Itoa(e.Line) + ": " + e.Msg -} - -// A Name represents an XML name (Local) annotated with a name space -// identifier (Space). In tokens returned by Decoder.Token, the Space -// identifier is given as a canonical URL, not the short prefix used in -// the document being parsed. -// -// As a special case, XML namespace declarations will use the literal -// string "xmlns" for the Space field instead of the fully resolved URL. -// See Encoder.EncodeToken for more information on namespace encoding -// behaviour. -type Name struct { - Space, Local string -} - -// isNamespace reports whether the name is a namespace-defining name. -func (name Name) isNamespace() bool { - return name.Local == "xmlns" || name.Space == "xmlns" -} - -// An Attr represents an attribute in an XML element (Name=Value). -type Attr struct { - Name Name - Value string -} - -// A Token is an interface holding one of the token types: -// StartElement, EndElement, CharData, Comment, ProcInst, or Directive. -type Token interface{} - -// A StartElement represents an XML start element. -type StartElement struct { - Name Name - Attr []Attr -} - -func (e StartElement) Copy() StartElement { - attrs := make([]Attr, len(e.Attr)) - copy(attrs, e.Attr) - e.Attr = attrs - return e -} - -// End returns the corresponding XML end element. -func (e StartElement) End() EndElement { - return EndElement{e.Name} -} - -// setDefaultNamespace sets the namespace of the element -// as the default for all elements contained within it. -func (e *StartElement) setDefaultNamespace() { - if e.Name.Space == "" { - // If there's no namespace on the element, don't - // set the default. Strictly speaking this might be wrong, as - // we can't tell if the element had no namespace set - // or was just using the default namespace. - return - } - // Don't add a default name space if there's already one set. - for _, attr := range e.Attr { - if attr.Name.Space == "" && attr.Name.Local == "xmlns" { - return - } - } - e.Attr = append(e.Attr, Attr{ - Name: Name{ - Local: "xmlns", - }, - Value: e.Name.Space, - }) -} - -// An EndElement represents an XML end element. -type EndElement struct { - Name Name -} - -// A CharData represents XML character data (raw text), -// in which XML escape sequences have been replaced by -// the characters they represent. -type CharData []byte - -func makeCopy(b []byte) []byte { - b1 := make([]byte, len(b)) - copy(b1, b) - return b1 -} - -func (c CharData) Copy() CharData { return CharData(makeCopy(c)) } - -// A Comment represents an XML comment of the form . -// The bytes do not include the comment markers. -type Comment []byte - -func (c Comment) Copy() Comment { return Comment(makeCopy(c)) } - -// A ProcInst represents an XML processing instruction of the form -type ProcInst struct { - Target string - Inst []byte -} - -func (p ProcInst) Copy() ProcInst { - p.Inst = makeCopy(p.Inst) - return p -} - -// A Directive represents an XML directive of the form . -// The bytes do not include the markers. -type Directive []byte - -func (d Directive) Copy() Directive { return Directive(makeCopy(d)) } - -// CopyToken returns a copy of a Token. -func CopyToken(t Token) Token { - switch v := t.(type) { - case CharData: - return v.Copy() - case Comment: - return v.Copy() - case Directive: - return v.Copy() - case ProcInst: - return v.Copy() - case StartElement: - return v.Copy() - } - return t -} - -// A Decoder represents an XML parser reading a particular input stream. -// The parser assumes that its input is encoded in UTF-8. -type Decoder struct { - // Strict defaults to true, enforcing the requirements - // of the XML specification. - // If set to false, the parser allows input containing common - // mistakes: - // * If an element is missing an end tag, the parser invents - // end tags as necessary to keep the return values from Token - // properly balanced. - // * In attribute values and character data, unknown or malformed - // character entities (sequences beginning with &) are left alone. - // - // Setting: - // - // d.Strict = false; - // d.AutoClose = HTMLAutoClose; - // d.Entity = HTMLEntity - // - // creates a parser that can handle typical HTML. - // - // Strict mode does not enforce the requirements of the XML name spaces TR. - // In particular it does not reject name space tags using undefined prefixes. - // Such tags are recorded with the unknown prefix as the name space URL. - Strict bool - - // When Strict == false, AutoClose indicates a set of elements to - // consider closed immediately after they are opened, regardless - // of whether an end element is present. - AutoClose []string - - // Entity can be used to map non-standard entity names to string replacements. - // The parser behaves as if these standard mappings are present in the map, - // regardless of the actual map content: - // - // "lt": "<", - // "gt": ">", - // "amp": "&", - // "apos": "'", - // "quot": `"`, - Entity map[string]string - - // CharsetReader, if non-nil, defines a function to generate - // charset-conversion readers, converting from the provided - // non-UTF-8 charset into UTF-8. If CharsetReader is nil or - // returns an error, parsing stops with an error. One of the - // the CharsetReader's result values must be non-nil. - CharsetReader func(charset string, input io.Reader) (io.Reader, error) - - // DefaultSpace sets the default name space used for unadorned tags, - // as if the entire XML stream were wrapped in an element containing - // the attribute xmlns="DefaultSpace". - DefaultSpace string - - r io.ByteReader - buf bytes.Buffer - saved *bytes.Buffer - stk *stack - free *stack - needClose bool - toClose Name - nextToken Token - nextByte int - ns map[string]string - err error - line int - offset int64 - unmarshalDepth int -} - -// NewDecoder creates a new XML parser reading from r. -// If r does not implement io.ByteReader, NewDecoder will -// do its own buffering. -func NewDecoder(r io.Reader) *Decoder { - d := &Decoder{ - ns: make(map[string]string), - nextByte: -1, - line: 1, - Strict: true, - } - d.switchToReader(r) - return d -} - -// Token returns the next XML token in the input stream. -// At the end of the input stream, Token returns nil, io.EOF. -// -// Slices of bytes in the returned token data refer to the -// parser's internal buffer and remain valid only until the next -// call to Token. To acquire a copy of the bytes, call CopyToken -// or the token's Copy method. -// -// Token expands self-closing elements such as
    -// into separate start and end elements returned by successive calls. -// -// Token guarantees that the StartElement and EndElement -// tokens it returns are properly nested and matched: -// if Token encounters an unexpected end element, -// it will return an error. -// -// Token implements XML name spaces as described by -// http://www.w3.org/TR/REC-xml-names/. Each of the -// Name structures contained in the Token has the Space -// set to the URL identifying its name space when known. -// If Token encounters an unrecognized name space prefix, -// it uses the prefix as the Space rather than report an error. -func (d *Decoder) Token() (t Token, err error) { - if d.stk != nil && d.stk.kind == stkEOF { - err = io.EOF - return - } - if d.nextToken != nil { - t = d.nextToken - d.nextToken = nil - } else if t, err = d.rawToken(); err != nil { - return - } - - if !d.Strict { - if t1, ok := d.autoClose(t); ok { - d.nextToken = t - t = t1 - } - } - switch t1 := t.(type) { - case StartElement: - // In XML name spaces, the translations listed in the - // attributes apply to the element name and - // to the other attribute names, so process - // the translations first. - for _, a := range t1.Attr { - if a.Name.Space == "xmlns" { - v, ok := d.ns[a.Name.Local] - d.pushNs(a.Name.Local, v, ok) - d.ns[a.Name.Local] = a.Value - } - if a.Name.Space == "" && a.Name.Local == "xmlns" { - // Default space for untagged names - v, ok := d.ns[""] - d.pushNs("", v, ok) - d.ns[""] = a.Value - } - } - - d.translate(&t1.Name, true) - for i := range t1.Attr { - d.translate(&t1.Attr[i].Name, false) - } - d.pushElement(t1.Name) - t = t1 - - case EndElement: - d.translate(&t1.Name, true) - if !d.popElement(&t1) { - return nil, d.err - } - t = t1 - } - return -} - -const xmlURL = "http://www.w3.org/XML/1998/namespace" - -// Apply name space translation to name n. -// The default name space (for Space=="") -// applies only to element names, not to attribute names. -func (d *Decoder) translate(n *Name, isElementName bool) { - switch { - case n.Space == "xmlns": - return - case n.Space == "" && !isElementName: - return - case n.Space == "xml": - n.Space = xmlURL - case n.Space == "" && n.Local == "xmlns": - return - } - if v, ok := d.ns[n.Space]; ok { - n.Space = v - } else if n.Space == "" { - n.Space = d.DefaultSpace - } -} - -func (d *Decoder) switchToReader(r io.Reader) { - // Get efficient byte at a time reader. - // Assume that if reader has its own - // ReadByte, it's efficient enough. - // Otherwise, use bufio. - if rb, ok := r.(io.ByteReader); ok { - d.r = rb - } else { - d.r = bufio.NewReader(r) - } -} - -// Parsing state - stack holds old name space translations -// and the current set of open elements. The translations to pop when -// ending a given tag are *below* it on the stack, which is -// more work but forced on us by XML. -type stack struct { - next *stack - kind int - name Name - ok bool -} - -const ( - stkStart = iota - stkNs - stkEOF -) - -func (d *Decoder) push(kind int) *stack { - s := d.free - if s != nil { - d.free = s.next - } else { - s = new(stack) - } - s.next = d.stk - s.kind = kind - d.stk = s - return s -} - -func (d *Decoder) pop() *stack { - s := d.stk - if s != nil { - d.stk = s.next - s.next = d.free - d.free = s - } - return s -} - -// Record that after the current element is finished -// (that element is already pushed on the stack) -// Token should return EOF until popEOF is called. -func (d *Decoder) pushEOF() { - // Walk down stack to find Start. - // It might not be the top, because there might be stkNs - // entries above it. - start := d.stk - for start.kind != stkStart { - start = start.next - } - // The stkNs entries below a start are associated with that - // element too; skip over them. - for start.next != nil && start.next.kind == stkNs { - start = start.next - } - s := d.free - if s != nil { - d.free = s.next - } else { - s = new(stack) - } - s.kind = stkEOF - s.next = start.next - start.next = s -} - -// Undo a pushEOF. -// The element must have been finished, so the EOF should be at the top of the stack. -func (d *Decoder) popEOF() bool { - if d.stk == nil || d.stk.kind != stkEOF { - return false - } - d.pop() - return true -} - -// Record that we are starting an element with the given name. -func (d *Decoder) pushElement(name Name) { - s := d.push(stkStart) - s.name = name -} - -// Record that we are changing the value of ns[local]. -// The old value is url, ok. -func (d *Decoder) pushNs(local string, url string, ok bool) { - s := d.push(stkNs) - s.name.Local = local - s.name.Space = url - s.ok = ok -} - -// Creates a SyntaxError with the current line number. -func (d *Decoder) syntaxError(msg string) error { - return &SyntaxError{Msg: msg, Line: d.line} -} - -// Record that we are ending an element with the given name. -// The name must match the record at the top of the stack, -// which must be a pushElement record. -// After popping the element, apply any undo records from -// the stack to restore the name translations that existed -// before we saw this element. -func (d *Decoder) popElement(t *EndElement) bool { - s := d.pop() - name := t.Name - switch { - case s == nil || s.kind != stkStart: - d.err = d.syntaxError("unexpected end element ") - return false - case s.name.Local != name.Local: - if !d.Strict { - d.needClose = true - d.toClose = t.Name - t.Name = s.name - return true - } - d.err = d.syntaxError("element <" + s.name.Local + "> closed by ") - return false - case s.name.Space != name.Space: - d.err = d.syntaxError("element <" + s.name.Local + "> in space " + s.name.Space + - "closed by in space " + name.Space) - return false - } - - // Pop stack until a Start or EOF is on the top, undoing the - // translations that were associated with the element we just closed. - for d.stk != nil && d.stk.kind != stkStart && d.stk.kind != stkEOF { - s := d.pop() - if s.ok { - d.ns[s.name.Local] = s.name.Space - } else { - delete(d.ns, s.name.Local) - } - } - - return true -} - -// If the top element on the stack is autoclosing and -// t is not the end tag, invent the end tag. -func (d *Decoder) autoClose(t Token) (Token, bool) { - if d.stk == nil || d.stk.kind != stkStart { - return nil, false - } - name := strings.ToLower(d.stk.name.Local) - for _, s := range d.AutoClose { - if strings.ToLower(s) == name { - // This one should be auto closed if t doesn't close it. - et, ok := t.(EndElement) - if !ok || et.Name.Local != name { - return EndElement{d.stk.name}, true - } - break - } - } - return nil, false -} - -var errRawToken = errors.New("xml: cannot use RawToken from UnmarshalXML method") - -// RawToken is like Token but does not verify that -// start and end elements match and does not translate -// name space prefixes to their corresponding URLs. -func (d *Decoder) RawToken() (Token, error) { - if d.unmarshalDepth > 0 { - return nil, errRawToken - } - return d.rawToken() -} - -func (d *Decoder) rawToken() (Token, error) { - if d.err != nil { - return nil, d.err - } - if d.needClose { - // The last element we read was self-closing and - // we returned just the StartElement half. - // Return the EndElement half now. - d.needClose = false - return EndElement{d.toClose}, nil - } - - b, ok := d.getc() - if !ok { - return nil, d.err - } - - if b != '<' { - // Text section. - d.ungetc(b) - data := d.text(-1, false) - if data == nil { - return nil, d.err - } - return CharData(data), nil - } - - if b, ok = d.mustgetc(); !ok { - return nil, d.err - } - switch b { - case '/': - // ' { - d.err = d.syntaxError("invalid characters between ") - return nil, d.err - } - return EndElement{name}, nil - - case '?': - // ' { - break - } - b0 = b - } - data := d.buf.Bytes() - data = data[0 : len(data)-2] // chop ?> - - if target == "xml" { - content := string(data) - ver := procInst("version", content) - if ver != "" && ver != "1.0" { - d.err = fmt.Errorf("xml: unsupported version %q; only version 1.0 is supported", ver) - return nil, d.err - } - enc := procInst("encoding", content) - if enc != "" && enc != "utf-8" && enc != "UTF-8" { - if d.CharsetReader == nil { - d.err = fmt.Errorf("xml: encoding %q declared but Decoder.CharsetReader is nil", enc) - return nil, d.err - } - newr, err := d.CharsetReader(enc, d.r.(io.Reader)) - if err != nil { - d.err = fmt.Errorf("xml: opening charset %q: %v", enc, err) - return nil, d.err - } - if newr == nil { - panic("CharsetReader returned a nil Reader for charset " + enc) - } - d.switchToReader(newr) - } - } - return ProcInst{target, data}, nil - - case '!': - // ' { - break - } - b0, b1 = b1, b - } - data := d.buf.Bytes() - data = data[0 : len(data)-3] // chop --> - return Comment(data), nil - - case '[': // . - data := d.text(-1, true) - if data == nil { - return nil, d.err - } - return CharData(data), nil - } - - // Probably a directive: , , etc. - // We don't care, but accumulate for caller. Quoted angle - // brackets do not count for nesting. - d.buf.Reset() - d.buf.WriteByte(b) - inquote := uint8(0) - depth := 0 - for { - if b, ok = d.mustgetc(); !ok { - return nil, d.err - } - if inquote == 0 && b == '>' && depth == 0 { - break - } - HandleB: - d.buf.WriteByte(b) - switch { - case b == inquote: - inquote = 0 - - case inquote != 0: - // in quotes, no special action - - case b == '\'' || b == '"': - inquote = b - - case b == '>' && inquote == 0: - depth-- - - case b == '<' && inquote == 0: - // Look for ` - -var testEntity = map[string]string{"何": "What", "is-it": "is it?"} - -var rawTokens = []Token{ - CharData("\n"), - ProcInst{"xml", []byte(`version="1.0" encoding="UTF-8"`)}, - CharData("\n"), - Directive(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`), - CharData("\n"), - StartElement{Name{"", "body"}, []Attr{{Name{"xmlns", "foo"}, "ns1"}, {Name{"", "xmlns"}, "ns2"}, {Name{"xmlns", "tag"}, "ns3"}}}, - CharData("\n "), - StartElement{Name{"", "hello"}, []Attr{{Name{"", "lang"}, "en"}}}, - CharData("World <>'\" 白鵬翔"), - EndElement{Name{"", "hello"}}, - CharData("\n "), - StartElement{Name{"", "query"}, []Attr{}}, - CharData("What is it?"), - EndElement{Name{"", "query"}}, - CharData("\n "), - StartElement{Name{"", "goodbye"}, []Attr{}}, - EndElement{Name{"", "goodbye"}}, - CharData("\n "), - StartElement{Name{"", "outer"}, []Attr{{Name{"foo", "attr"}, "value"}, {Name{"xmlns", "tag"}, "ns4"}}}, - CharData("\n "), - StartElement{Name{"", "inner"}, []Attr{}}, - EndElement{Name{"", "inner"}}, - CharData("\n "), - EndElement{Name{"", "outer"}}, - CharData("\n "), - StartElement{Name{"tag", "name"}, []Attr{}}, - CharData("\n "), - CharData("Some text here."), - CharData("\n "), - EndElement{Name{"tag", "name"}}, - CharData("\n"), - EndElement{Name{"", "body"}}, - Comment(" missing final newline "), -} - -var cookedTokens = []Token{ - CharData("\n"), - ProcInst{"xml", []byte(`version="1.0" encoding="UTF-8"`)}, - CharData("\n"), - Directive(`DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" - "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"`), - CharData("\n"), - StartElement{Name{"ns2", "body"}, []Attr{{Name{"xmlns", "foo"}, "ns1"}, {Name{"", "xmlns"}, "ns2"}, {Name{"xmlns", "tag"}, "ns3"}}}, - CharData("\n "), - StartElement{Name{"ns2", "hello"}, []Attr{{Name{"", "lang"}, "en"}}}, - CharData("World <>'\" 白鵬翔"), - EndElement{Name{"ns2", "hello"}}, - CharData("\n "), - StartElement{Name{"ns2", "query"}, []Attr{}}, - CharData("What is it?"), - EndElement{Name{"ns2", "query"}}, - CharData("\n "), - StartElement{Name{"ns2", "goodbye"}, []Attr{}}, - EndElement{Name{"ns2", "goodbye"}}, - CharData("\n "), - StartElement{Name{"ns2", "outer"}, []Attr{{Name{"ns1", "attr"}, "value"}, {Name{"xmlns", "tag"}, "ns4"}}}, - CharData("\n "), - StartElement{Name{"ns2", "inner"}, []Attr{}}, - EndElement{Name{"ns2", "inner"}}, - CharData("\n "), - EndElement{Name{"ns2", "outer"}}, - CharData("\n "), - StartElement{Name{"ns3", "name"}, []Attr{}}, - CharData("\n "), - CharData("Some text here."), - CharData("\n "), - EndElement{Name{"ns3", "name"}}, - CharData("\n"), - EndElement{Name{"ns2", "body"}}, - Comment(" missing final newline "), -} - -const testInputAltEncoding = ` - -VALUE` - -var rawTokensAltEncoding = []Token{ - CharData("\n"), - ProcInst{"xml", []byte(`version="1.0" encoding="x-testing-uppercase"`)}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("value"), - EndElement{Name{"", "tag"}}, -} - -var xmlInput = []string{ - // unexpected EOF cases - "<", - "", - "", - "", - // "", // let the Token() caller handle - "", - "", - "", - "", - " c;", - "", - "", - "", - // "", // let the Token() caller handle - "", - "", - "cdata]]>", -} - -func TestRawToken(t *testing.T) { - d := NewDecoder(strings.NewReader(testInput)) - d.Entity = testEntity - testRawToken(t, d, testInput, rawTokens) -} - -const nonStrictInput = ` -non&entity -&unknown;entity -{ -&#zzz; -&ãªã¾ãˆ3; -<-gt; -&; -&0a; -` - -var nonStringEntity = map[string]string{"": "oops!", "0a": "oops!"} - -var nonStrictTokens = []Token{ - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("non&entity"), - EndElement{Name{"", "tag"}}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("&unknown;entity"), - EndElement{Name{"", "tag"}}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("{"), - EndElement{Name{"", "tag"}}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("&#zzz;"), - EndElement{Name{"", "tag"}}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("&ãªã¾ãˆ3;"), - EndElement{Name{"", "tag"}}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("<-gt;"), - EndElement{Name{"", "tag"}}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("&;"), - EndElement{Name{"", "tag"}}, - CharData("\n"), - StartElement{Name{"", "tag"}, []Attr{}}, - CharData("&0a;"), - EndElement{Name{"", "tag"}}, - CharData("\n"), -} - -func TestNonStrictRawToken(t *testing.T) { - d := NewDecoder(strings.NewReader(nonStrictInput)) - d.Strict = false - testRawToken(t, d, nonStrictInput, nonStrictTokens) -} - -type downCaser struct { - t *testing.T - r io.ByteReader -} - -func (d *downCaser) ReadByte() (c byte, err error) { - c, err = d.r.ReadByte() - if c >= 'A' && c <= 'Z' { - c += 'a' - 'A' - } - return -} - -func (d *downCaser) Read(p []byte) (int, error) { - d.t.Fatalf("unexpected Read call on downCaser reader") - panic("unreachable") -} - -func TestRawTokenAltEncoding(t *testing.T) { - d := NewDecoder(strings.NewReader(testInputAltEncoding)) - d.CharsetReader = func(charset string, input io.Reader) (io.Reader, error) { - if charset != "x-testing-uppercase" { - t.Fatalf("unexpected charset %q", charset) - } - return &downCaser{t, input.(io.ByteReader)}, nil - } - testRawToken(t, d, testInputAltEncoding, rawTokensAltEncoding) -} - -func TestRawTokenAltEncodingNoConverter(t *testing.T) { - d := NewDecoder(strings.NewReader(testInputAltEncoding)) - token, err := d.RawToken() - if token == nil { - t.Fatalf("expected a token on first RawToken call") - } - if err != nil { - t.Fatal(err) - } - token, err = d.RawToken() - if token != nil { - t.Errorf("expected a nil token; got %#v", token) - } - if err == nil { - t.Fatalf("expected an error on second RawToken call") - } - const encoding = "x-testing-uppercase" - if !strings.Contains(err.Error(), encoding) { - t.Errorf("expected error to contain %q; got error: %v", - encoding, err) - } -} - -func testRawToken(t *testing.T, d *Decoder, raw string, rawTokens []Token) { - lastEnd := int64(0) - for i, want := range rawTokens { - start := d.InputOffset() - have, err := d.RawToken() - end := d.InputOffset() - if err != nil { - t.Fatalf("token %d: unexpected error: %s", i, err) - } - if !reflect.DeepEqual(have, want) { - var shave, swant string - if _, ok := have.(CharData); ok { - shave = fmt.Sprintf("CharData(%q)", have) - } else { - shave = fmt.Sprintf("%#v", have) - } - if _, ok := want.(CharData); ok { - swant = fmt.Sprintf("CharData(%q)", want) - } else { - swant = fmt.Sprintf("%#v", want) - } - t.Errorf("token %d = %s, want %s", i, shave, swant) - } - - // Check that InputOffset returned actual token. - switch { - case start < lastEnd: - t.Errorf("token %d: position [%d,%d) for %T is before previous token", i, start, end, have) - case start >= end: - // Special case: EndElement can be synthesized. - if start == end && end == lastEnd { - break - } - t.Errorf("token %d: position [%d,%d) for %T is empty", i, start, end, have) - case end > int64(len(raw)): - t.Errorf("token %d: position [%d,%d) for %T extends beyond input", i, start, end, have) - default: - text := raw[start:end] - if strings.ContainsAny(text, "<>") && (!strings.HasPrefix(text, "<") || !strings.HasSuffix(text, ">")) { - t.Errorf("token %d: misaligned raw token %#q for %T", i, text, have) - } - } - lastEnd = end - } -} - -// Ensure that directives (specifically !DOCTYPE) include the complete -// text of any nested directives, noting that < and > do not change -// nesting depth if they are in single or double quotes. - -var nestedDirectivesInput = ` -]> -">]> -]> -'>]> -]> -'>]> -]> -` - -var nestedDirectivesTokens = []Token{ - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), - Directive(`DOCTYPE [">]`), - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), - Directive(`DOCTYPE ['>]`), - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), - Directive(`DOCTYPE ['>]`), - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), -} - -func TestNestedDirectives(t *testing.T) { - d := NewDecoder(strings.NewReader(nestedDirectivesInput)) - - for i, want := range nestedDirectivesTokens { - have, err := d.Token() - if err != nil { - t.Fatalf("token %d: unexpected error: %s", i, err) - } - if !reflect.DeepEqual(have, want) { - t.Errorf("token %d = %#v want %#v", i, have, want) - } - } -} - -func TestToken(t *testing.T) { - d := NewDecoder(strings.NewReader(testInput)) - d.Entity = testEntity - - for i, want := range cookedTokens { - have, err := d.Token() - if err != nil { - t.Fatalf("token %d: unexpected error: %s", i, err) - } - if !reflect.DeepEqual(have, want) { - t.Errorf("token %d = %#v want %#v", i, have, want) - } - } -} - -func TestSyntax(t *testing.T) { - for i := range xmlInput { - d := NewDecoder(strings.NewReader(xmlInput[i])) - var err error - for _, err = d.Token(); err == nil; _, err = d.Token() { - } - if _, ok := err.(*SyntaxError); !ok { - t.Fatalf(`xmlInput "%s": expected SyntaxError not received`, xmlInput[i]) - } - } -} - -type allScalars struct { - True1 bool - True2 bool - False1 bool - False2 bool - Int int - Int8 int8 - Int16 int16 - Int32 int32 - Int64 int64 - Uint int - Uint8 uint8 - Uint16 uint16 - Uint32 uint32 - Uint64 uint64 - Uintptr uintptr - Float32 float32 - Float64 float64 - String string - PtrString *string -} - -var all = allScalars{ - True1: true, - True2: true, - False1: false, - False2: false, - Int: 1, - Int8: -2, - Int16: 3, - Int32: -4, - Int64: 5, - Uint: 6, - Uint8: 7, - Uint16: 8, - Uint32: 9, - Uint64: 10, - Uintptr: 11, - Float32: 13.0, - Float64: 14.0, - String: "15", - PtrString: &sixteen, -} - -var sixteen = "16" - -const testScalarsInput = ` - true - 1 - false - 0 - 1 - -2 - 3 - -4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12.0 - 13.0 - 14.0 - 15 - 16 -` - -func TestAllScalars(t *testing.T) { - var a allScalars - err := Unmarshal([]byte(testScalarsInput), &a) - - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(a, all) { - t.Errorf("have %+v want %+v", a, all) - } -} - -type item struct { - Field_a string -} - -func TestIssue569(t *testing.T) { - data := `abcd` - var i item - err := Unmarshal([]byte(data), &i) - - if err != nil || i.Field_a != "abcd" { - t.Fatal("Expecting abcd") - } -} - -func TestUnquotedAttrs(t *testing.T) { - data := "" - d := NewDecoder(strings.NewReader(data)) - d.Strict = false - token, err := d.Token() - if _, ok := err.(*SyntaxError); ok { - t.Errorf("Unexpected error: %v", err) - } - if token.(StartElement).Name.Local != "tag" { - t.Errorf("Unexpected tag name: %v", token.(StartElement).Name.Local) - } - attr := token.(StartElement).Attr[0] - if attr.Value != "azAZ09:-_" { - t.Errorf("Unexpected attribute value: %v", attr.Value) - } - if attr.Name.Local != "attr" { - t.Errorf("Unexpected attribute name: %v", attr.Name.Local) - } -} - -func TestValuelessAttrs(t *testing.T) { - tests := [][3]string{ - {"

    ", "p", "nowrap"}, - {"

    ", "p", "nowrap"}, - {"", "input", "checked"}, - {"", "input", "checked"}, - } - for _, test := range tests { - d := NewDecoder(strings.NewReader(test[0])) - d.Strict = false - token, err := d.Token() - if _, ok := err.(*SyntaxError); ok { - t.Errorf("Unexpected error: %v", err) - } - if token.(StartElement).Name.Local != test[1] { - t.Errorf("Unexpected tag name: %v", token.(StartElement).Name.Local) - } - attr := token.(StartElement).Attr[0] - if attr.Value != test[2] { - t.Errorf("Unexpected attribute value: %v", attr.Value) - } - if attr.Name.Local != test[2] { - t.Errorf("Unexpected attribute name: %v", attr.Name.Local) - } - } -} - -func TestCopyTokenCharData(t *testing.T) { - data := []byte("same data") - var tok1 Token = CharData(data) - tok2 := CopyToken(tok1) - if !reflect.DeepEqual(tok1, tok2) { - t.Error("CopyToken(CharData) != CharData") - } - data[1] = 'o' - if reflect.DeepEqual(tok1, tok2) { - t.Error("CopyToken(CharData) uses same buffer.") - } -} - -func TestCopyTokenStartElement(t *testing.T) { - elt := StartElement{Name{"", "hello"}, []Attr{{Name{"", "lang"}, "en"}}} - var tok1 Token = elt - tok2 := CopyToken(tok1) - if tok1.(StartElement).Attr[0].Value != "en" { - t.Error("CopyToken overwrote Attr[0]") - } - if !reflect.DeepEqual(tok1, tok2) { - t.Error("CopyToken(StartElement) != StartElement") - } - tok1.(StartElement).Attr[0] = Attr{Name{"", "lang"}, "de"} - if reflect.DeepEqual(tok1, tok2) { - t.Error("CopyToken(CharData) uses same buffer.") - } -} - -func TestSyntaxErrorLineNum(t *testing.T) { - testInput := "

    Foo

    \n\n

    Bar\n" - d := NewDecoder(strings.NewReader(testInput)) - var err error - for _, err = d.Token(); err == nil; _, err = d.Token() { - } - synerr, ok := err.(*SyntaxError) - if !ok { - t.Error("Expected SyntaxError.") - } - if synerr.Line != 3 { - t.Error("SyntaxError didn't have correct line number.") - } -} - -func TestTrailingRawToken(t *testing.T) { - input := ` ` - d := NewDecoder(strings.NewReader(input)) - var err error - for _, err = d.RawToken(); err == nil; _, err = d.RawToken() { - } - if err != io.EOF { - t.Fatalf("d.RawToken() = _, %v, want _, io.EOF", err) - } -} - -func TestTrailingToken(t *testing.T) { - input := ` ` - d := NewDecoder(strings.NewReader(input)) - var err error - for _, err = d.Token(); err == nil; _, err = d.Token() { - } - if err != io.EOF { - t.Fatalf("d.Token() = _, %v, want _, io.EOF", err) - } -} - -func TestEntityInsideCDATA(t *testing.T) { - input := `` - d := NewDecoder(strings.NewReader(input)) - var err error - for _, err = d.Token(); err == nil; _, err = d.Token() { - } - if err != io.EOF { - t.Fatalf("d.Token() = _, %v, want _, io.EOF", err) - } -} - -var characterTests = []struct { - in string - err string -}{ - {"\x12", "illegal character code U+0012"}, - {"\x0b", "illegal character code U+000B"}, - {"\xef\xbf\xbe", "illegal character code U+FFFE"}, - {"\r\n\x07", "illegal character code U+0007"}, - {"what's up", "expected attribute name in element"}, - {"&abc\x01;", "invalid character entity &abc (no semicolon)"}, - {"&\x01;", "invalid character entity & (no semicolon)"}, - {"&\xef\xbf\xbe;", "invalid character entity &\uFFFE;"}, - {"&hello;", "invalid character entity &hello;"}, -} - -func TestDisallowedCharacters(t *testing.T) { - - for i, tt := range characterTests { - d := NewDecoder(strings.NewReader(tt.in)) - var err error - - for err == nil { - _, err = d.Token() - } - synerr, ok := err.(*SyntaxError) - if !ok { - t.Fatalf("input %d d.Token() = _, %v, want _, *SyntaxError", i, err) - } - if synerr.Msg != tt.err { - t.Fatalf("input %d synerr.Msg wrong: want %q, got %q", i, tt.err, synerr.Msg) - } - } -} - -type procInstEncodingTest struct { - expect, got string -} - -var procInstTests = []struct { - input string - expect [2]string -}{ - {`version="1.0" encoding="utf-8"`, [2]string{"1.0", "utf-8"}}, - {`version="1.0" encoding='utf-8'`, [2]string{"1.0", "utf-8"}}, - {`version="1.0" encoding='utf-8' `, [2]string{"1.0", "utf-8"}}, - {`version="1.0" encoding=utf-8`, [2]string{"1.0", ""}}, - {`encoding="FOO" `, [2]string{"", "FOO"}}, -} - -func TestProcInstEncoding(t *testing.T) { - for _, test := range procInstTests { - if got := procInst("version", test.input); got != test.expect[0] { - t.Errorf("procInst(version, %q) = %q; want %q", test.input, got, test.expect[0]) - } - if got := procInst("encoding", test.input); got != test.expect[1] { - t.Errorf("procInst(encoding, %q) = %q; want %q", test.input, got, test.expect[1]) - } - } -} - -// Ensure that directives with comments include the complete -// text of any nested directives. - -var directivesWithCommentsInput = ` -]> -]> - --> --> []> -` - -var directivesWithCommentsTokens = []Token{ - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), - Directive(`DOCTYPE []`), - CharData("\n"), -} - -func TestDirectivesWithComments(t *testing.T) { - d := NewDecoder(strings.NewReader(directivesWithCommentsInput)) - - for i, want := range directivesWithCommentsTokens { - have, err := d.Token() - if err != nil { - t.Fatalf("token %d: unexpected error: %s", i, err) - } - if !reflect.DeepEqual(have, want) { - t.Errorf("token %d = %#v want %#v", i, have, want) - } - } -} - -// Writer whose Write method always returns an error. -type errWriter struct{} - -func (errWriter) Write(p []byte) (n int, err error) { return 0, fmt.Errorf("unwritable") } - -func TestEscapeTextIOErrors(t *testing.T) { - expectErr := "unwritable" - err := EscapeText(errWriter{}, []byte{'A'}) - - if err == nil || err.Error() != expectErr { - t.Errorf("have %v, want %v", err, expectErr) - } -} - -func TestEscapeTextInvalidChar(t *testing.T) { - input := []byte("A \x00 terminated string.") - expected := "A \uFFFD terminated string." - - buff := new(bytes.Buffer) - if err := EscapeText(buff, input); err != nil { - t.Fatalf("have %v, want nil", err) - } - text := buff.String() - - if text != expected { - t.Errorf("have %v, want %v", text, expected) - } -} - -func TestIssue5880(t *testing.T) { - type T []byte - data, err := Marshal(T{192, 168, 0, 1}) - if err != nil { - t.Errorf("Marshal error: %v", err) - } - if !utf8.Valid(data) { - t.Errorf("Marshal generated invalid UTF-8: %x", data) - } -} diff --git a/vendor/golang.org/x/net/webdav/litmus_test_server.go b/vendor/golang.org/x/net/webdav/litmus_test_server.go deleted file mode 100644 index 514db5d..0000000 --- a/vendor/golang.org/x/net/webdav/litmus_test_server.go +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build ignore - -/* -This program is a server for the WebDAV 'litmus' compliance test at -http://www.webdav.org/neon/litmus/ -To run the test: - -go run litmus_test_server.go - -and separately, from the downloaded litmus-xxx directory: - -make URL=http://localhost:9999/ check -*/ -package main - -import ( - "flag" - "fmt" - "log" - "net/http" - "net/url" - - "golang.org/x/net/webdav" -) - -var port = flag.Int("port", 9999, "server port") - -func main() { - flag.Parse() - log.SetFlags(0) - h := &webdav.Handler{ - FileSystem: webdav.NewMemFS(), - LockSystem: webdav.NewMemLS(), - Logger: func(r *http.Request, err error) { - litmus := r.Header.Get("X-Litmus") - if len(litmus) > 19 { - litmus = litmus[:16] + "..." - } - - switch r.Method { - case "COPY", "MOVE": - dst := "" - if u, err := url.Parse(r.Header.Get("Destination")); err == nil { - dst = u.Path - } - o := r.Header.Get("Overwrite") - log.Printf("%-20s%-10s%-30s%-30so=%-2s%v", litmus, r.Method, r.URL.Path, dst, o, err) - default: - log.Printf("%-20s%-10s%-30s%v", litmus, r.Method, r.URL.Path, err) - } - }, - } - - // The next line would normally be: - // http.Handle("/", h) - // but we wrap that HTTP handler h to cater for a special case. - // - // The propfind_invalid2 litmus test case expects an empty namespace prefix - // declaration to be an error. The FAQ in the webdav litmus test says: - // - // "What does the "propfind_invalid2" test check for?... - // - // If a request was sent with an XML body which included an empty namespace - // prefix declaration (xmlns:ns1=""), then the server must reject that with - // a "400 Bad Request" response, as it is invalid according to the XML - // Namespace specification." - // - // On the other hand, the Go standard library's encoding/xml package - // accepts an empty xmlns namespace, as per the discussion at - // https://github.com/golang/go/issues/8068 - // - // Empty namespaces seem disallowed in the second (2006) edition of the XML - // standard, but allowed in a later edition. The grammar differs between - // http://www.w3.org/TR/2006/REC-xml-names-20060816/#ns-decl and - // http://www.w3.org/TR/REC-xml-names/#dt-prefix - // - // Thus, we assume that the propfind_invalid2 test is obsolete, and - // hard-code the 400 Bad Request response that the test expects. - http.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - if r.Header.Get("X-Litmus") == "props: 3 (propfind_invalid2)" { - http.Error(w, "400 Bad Request", http.StatusBadRequest) - return - } - h.ServeHTTP(w, r) - })) - - addr := fmt.Sprintf(":%d", *port) - log.Printf("Serving %v", addr) - log.Fatal(http.ListenAndServe(addr, nil)) -} diff --git a/vendor/golang.org/x/net/webdav/lock.go b/vendor/golang.org/x/net/webdav/lock.go deleted file mode 100644 index 344ac5c..0000000 --- a/vendor/golang.org/x/net/webdav/lock.go +++ /dev/null @@ -1,445 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "container/heap" - "errors" - "strconv" - "strings" - "sync" - "time" -) - -var ( - // ErrConfirmationFailed is returned by a LockSystem's Confirm method. - ErrConfirmationFailed = errors.New("webdav: confirmation failed") - // ErrForbidden is returned by a LockSystem's Unlock method. - ErrForbidden = errors.New("webdav: forbidden") - // ErrLocked is returned by a LockSystem's Create, Refresh and Unlock methods. - ErrLocked = errors.New("webdav: locked") - // ErrNoSuchLock is returned by a LockSystem's Refresh and Unlock methods. - ErrNoSuchLock = errors.New("webdav: no such lock") -) - -// Condition can match a WebDAV resource, based on a token or ETag. -// Exactly one of Token and ETag should be non-empty. -type Condition struct { - Not bool - Token string - ETag string -} - -// LockSystem manages access to a collection of named resources. The elements -// in a lock name are separated by slash ('/', U+002F) characters, regardless -// of host operating system convention. -type LockSystem interface { - // Confirm confirms that the caller can claim all of the locks specified by - // the given conditions, and that holding the union of all of those locks - // gives exclusive access to all of the named resources. Up to two resources - // can be named. Empty names are ignored. - // - // Exactly one of release and err will be non-nil. If release is non-nil, - // all of the requested locks are held until release is called. Calling - // release does not unlock the lock, in the WebDAV UNLOCK sense, but once - // Confirm has confirmed that a lock claim is valid, that lock cannot be - // Confirmed again until it has been released. - // - // If Confirm returns ErrConfirmationFailed then the Handler will continue - // to try any other set of locks presented (a WebDAV HTTP request can - // present more than one set of locks). If it returns any other non-nil - // error, the Handler will write a "500 Internal Server Error" HTTP status. - Confirm(now time.Time, name0, name1 string, conditions ...Condition) (release func(), err error) - - // Create creates a lock with the given depth, duration, owner and root - // (name). The depth will either be negative (meaning infinite) or zero. - // - // If Create returns ErrLocked then the Handler will write a "423 Locked" - // HTTP status. If it returns any other non-nil error, the Handler will - // write a "500 Internal Server Error" HTTP status. - // - // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for - // when to use each error. - // - // The token returned identifies the created lock. It should be an absolute - // URI as defined by RFC 3986, Section 4.3. In particular, it should not - // contain whitespace. - Create(now time.Time, details LockDetails) (token string, err error) - - // Refresh refreshes the lock with the given token. - // - // If Refresh returns ErrLocked then the Handler will write a "423 Locked" - // HTTP Status. If Refresh returns ErrNoSuchLock then the Handler will write - // a "412 Precondition Failed" HTTP Status. If it returns any other non-nil - // error, the Handler will write a "500 Internal Server Error" HTTP status. - // - // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.6 for - // when to use each error. - Refresh(now time.Time, token string, duration time.Duration) (LockDetails, error) - - // Unlock unlocks the lock with the given token. - // - // If Unlock returns ErrForbidden then the Handler will write a "403 - // Forbidden" HTTP Status. If Unlock returns ErrLocked then the Handler - // will write a "423 Locked" HTTP status. If Unlock returns ErrNoSuchLock - // then the Handler will write a "409 Conflict" HTTP Status. If it returns - // any other non-nil error, the Handler will write a "500 Internal Server - // Error" HTTP status. - // - // See http://www.webdav.org/specs/rfc4918.html#rfc.section.9.11.1 for - // when to use each error. - Unlock(now time.Time, token string) error -} - -// LockDetails are a lock's metadata. -type LockDetails struct { - // Root is the root resource name being locked. For a zero-depth lock, the - // root is the only resource being locked. - Root string - // Duration is the lock timeout. A negative duration means infinite. - Duration time.Duration - // OwnerXML is the verbatim XML given in a LOCK HTTP request. - // - // TODO: does the "verbatim" nature play well with XML namespaces? - // Does the OwnerXML field need to have more structure? See - // https://codereview.appspot.com/175140043/#msg2 - OwnerXML string - // ZeroDepth is whether the lock has zero depth. If it does not have zero - // depth, it has infinite depth. - ZeroDepth bool -} - -// NewMemLS returns a new in-memory LockSystem. -func NewMemLS() LockSystem { - return &memLS{ - byName: make(map[string]*memLSNode), - byToken: make(map[string]*memLSNode), - gen: uint64(time.Now().Unix()), - } -} - -type memLS struct { - mu sync.Mutex - byName map[string]*memLSNode - byToken map[string]*memLSNode - gen uint64 - // byExpiry only contains those nodes whose LockDetails have a finite - // Duration and are yet to expire. - byExpiry byExpiry -} - -func (m *memLS) nextToken() string { - m.gen++ - return strconv.FormatUint(m.gen, 10) -} - -func (m *memLS) collectExpiredNodes(now time.Time) { - for len(m.byExpiry) > 0 { - if now.Before(m.byExpiry[0].expiry) { - break - } - m.remove(m.byExpiry[0]) - } -} - -func (m *memLS) Confirm(now time.Time, name0, name1 string, conditions ...Condition) (func(), error) { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - - var n0, n1 *memLSNode - if name0 != "" { - if n0 = m.lookup(slashClean(name0), conditions...); n0 == nil { - return nil, ErrConfirmationFailed - } - } - if name1 != "" { - if n1 = m.lookup(slashClean(name1), conditions...); n1 == nil { - return nil, ErrConfirmationFailed - } - } - - // Don't hold the same node twice. - if n1 == n0 { - n1 = nil - } - - if n0 != nil { - m.hold(n0) - } - if n1 != nil { - m.hold(n1) - } - return func() { - m.mu.Lock() - defer m.mu.Unlock() - if n1 != nil { - m.unhold(n1) - } - if n0 != nil { - m.unhold(n0) - } - }, nil -} - -// lookup returns the node n that locks the named resource, provided that n -// matches at least one of the given conditions and that lock isn't held by -// another party. Otherwise, it returns nil. -// -// n may be a parent of the named resource, if n is an infinite depth lock. -func (m *memLS) lookup(name string, conditions ...Condition) (n *memLSNode) { - // TODO: support Condition.Not and Condition.ETag. - for _, c := range conditions { - n = m.byToken[c.Token] - if n == nil || n.held { - continue - } - if name == n.details.Root { - return n - } - if n.details.ZeroDepth { - continue - } - if n.details.Root == "/" || strings.HasPrefix(name, n.details.Root+"/") { - return n - } - } - return nil -} - -func (m *memLS) hold(n *memLSNode) { - if n.held { - panic("webdav: memLS inconsistent held state") - } - n.held = true - if n.details.Duration >= 0 && n.byExpiryIndex >= 0 { - heap.Remove(&m.byExpiry, n.byExpiryIndex) - } -} - -func (m *memLS) unhold(n *memLSNode) { - if !n.held { - panic("webdav: memLS inconsistent held state") - } - n.held = false - if n.details.Duration >= 0 { - heap.Push(&m.byExpiry, n) - } -} - -func (m *memLS) Create(now time.Time, details LockDetails) (string, error) { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - details.Root = slashClean(details.Root) - - if !m.canCreate(details.Root, details.ZeroDepth) { - return "", ErrLocked - } - n := m.create(details.Root) - n.token = m.nextToken() - m.byToken[n.token] = n - n.details = details - if n.details.Duration >= 0 { - n.expiry = now.Add(n.details.Duration) - heap.Push(&m.byExpiry, n) - } - return n.token, nil -} - -func (m *memLS) Refresh(now time.Time, token string, duration time.Duration) (LockDetails, error) { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - - n := m.byToken[token] - if n == nil { - return LockDetails{}, ErrNoSuchLock - } - if n.held { - return LockDetails{}, ErrLocked - } - if n.byExpiryIndex >= 0 { - heap.Remove(&m.byExpiry, n.byExpiryIndex) - } - n.details.Duration = duration - if n.details.Duration >= 0 { - n.expiry = now.Add(n.details.Duration) - heap.Push(&m.byExpiry, n) - } - return n.details, nil -} - -func (m *memLS) Unlock(now time.Time, token string) error { - m.mu.Lock() - defer m.mu.Unlock() - m.collectExpiredNodes(now) - - n := m.byToken[token] - if n == nil { - return ErrNoSuchLock - } - if n.held { - return ErrLocked - } - m.remove(n) - return nil -} - -func (m *memLS) canCreate(name string, zeroDepth bool) bool { - return walkToRoot(name, func(name0 string, first bool) bool { - n := m.byName[name0] - if n == nil { - return true - } - if first { - if n.token != "" { - // The target node is already locked. - return false - } - if !zeroDepth { - // The requested lock depth is infinite, and the fact that n exists - // (n != nil) means that a descendent of the target node is locked. - return false - } - } else if n.token != "" && !n.details.ZeroDepth { - // An ancestor of the target node is locked with infinite depth. - return false - } - return true - }) -} - -func (m *memLS) create(name string) (ret *memLSNode) { - walkToRoot(name, func(name0 string, first bool) bool { - n := m.byName[name0] - if n == nil { - n = &memLSNode{ - details: LockDetails{ - Root: name0, - }, - byExpiryIndex: -1, - } - m.byName[name0] = n - } - n.refCount++ - if first { - ret = n - } - return true - }) - return ret -} - -func (m *memLS) remove(n *memLSNode) { - delete(m.byToken, n.token) - n.token = "" - walkToRoot(n.details.Root, func(name0 string, first bool) bool { - x := m.byName[name0] - x.refCount-- - if x.refCount == 0 { - delete(m.byName, name0) - } - return true - }) - if n.byExpiryIndex >= 0 { - heap.Remove(&m.byExpiry, n.byExpiryIndex) - } -} - -func walkToRoot(name string, f func(name0 string, first bool) bool) bool { - for first := true; ; first = false { - if !f(name, first) { - return false - } - if name == "/" { - break - } - name = name[:strings.LastIndex(name, "/")] - if name == "" { - name = "/" - } - } - return true -} - -type memLSNode struct { - // details are the lock metadata. Even if this node's name is not explicitly locked, - // details.Root will still equal the node's name. - details LockDetails - // token is the unique identifier for this node's lock. An empty token means that - // this node is not explicitly locked. - token string - // refCount is the number of self-or-descendent nodes that are explicitly locked. - refCount int - // expiry is when this node's lock expires. - expiry time.Time - // byExpiryIndex is the index of this node in memLS.byExpiry. It is -1 - // if this node does not expire, or has expired. - byExpiryIndex int - // held is whether this node's lock is actively held by a Confirm call. - held bool -} - -type byExpiry []*memLSNode - -func (b *byExpiry) Len() int { - return len(*b) -} - -func (b *byExpiry) Less(i, j int) bool { - return (*b)[i].expiry.Before((*b)[j].expiry) -} - -func (b *byExpiry) Swap(i, j int) { - (*b)[i], (*b)[j] = (*b)[j], (*b)[i] - (*b)[i].byExpiryIndex = i - (*b)[j].byExpiryIndex = j -} - -func (b *byExpiry) Push(x interface{}) { - n := x.(*memLSNode) - n.byExpiryIndex = len(*b) - *b = append(*b, n) -} - -func (b *byExpiry) Pop() interface{} { - i := len(*b) - 1 - n := (*b)[i] - (*b)[i] = nil - n.byExpiryIndex = -1 - *b = (*b)[:i] - return n -} - -const infiniteTimeout = -1 - -// parseTimeout parses the Timeout HTTP header, as per section 10.7. If s is -// empty, an infiniteTimeout is returned. -func parseTimeout(s string) (time.Duration, error) { - if s == "" { - return infiniteTimeout, nil - } - if i := strings.IndexByte(s, ','); i >= 0 { - s = s[:i] - } - s = strings.TrimSpace(s) - if s == "Infinite" { - return infiniteTimeout, nil - } - const pre = "Second-" - if !strings.HasPrefix(s, pre) { - return 0, errInvalidTimeout - } - s = s[len(pre):] - if s == "" || s[0] < '0' || '9' < s[0] { - return 0, errInvalidTimeout - } - n, err := strconv.ParseInt(s, 10, 64) - if err != nil || 1<<32-1 < n { - return 0, errInvalidTimeout - } - return time.Duration(n) * time.Second, nil -} diff --git a/vendor/golang.org/x/net/webdav/lock_test.go b/vendor/golang.org/x/net/webdav/lock_test.go deleted file mode 100644 index 116d6c0..0000000 --- a/vendor/golang.org/x/net/webdav/lock_test.go +++ /dev/null @@ -1,731 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "fmt" - "math/rand" - "path" - "reflect" - "sort" - "strconv" - "strings" - "testing" - "time" -) - -func TestWalkToRoot(t *testing.T) { - testCases := []struct { - name string - want []string - }{{ - "/a/b/c/d", - []string{ - "/a/b/c/d", - "/a/b/c", - "/a/b", - "/a", - "/", - }, - }, { - "/a", - []string{ - "/a", - "/", - }, - }, { - "/", - []string{ - "/", - }, - }} - - for _, tc := range testCases { - var got []string - if !walkToRoot(tc.name, func(name0 string, first bool) bool { - if first != (len(got) == 0) { - t.Errorf("name=%q: first=%t but len(got)==%d", tc.name, first, len(got)) - return false - } - got = append(got, name0) - return true - }) { - continue - } - if !reflect.DeepEqual(got, tc.want) { - t.Errorf("name=%q:\ngot %q\nwant %q", tc.name, got, tc.want) - } - } -} - -var lockTestDurations = []time.Duration{ - infiniteTimeout, // infiniteTimeout means to never expire. - 0, // A zero duration means to expire immediately. - 100 * time.Hour, // A very large duration will not expire in these tests. -} - -// lockTestNames are the names of a set of mutually compatible locks. For each -// name fragment: -// - _ means no explicit lock. -// - i means a infinite-depth lock, -// - z means a zero-depth lock, -var lockTestNames = []string{ - "/_/_/_/_/z", - "/_/_/i", - "/_/z", - "/_/z/i", - "/_/z/z", - "/_/z/_/i", - "/_/z/_/z", - "/i", - "/z", - "/z/_/i", - "/z/_/z", -} - -func lockTestZeroDepth(name string) bool { - switch name[len(name)-1] { - case 'i': - return false - case 'z': - return true - } - panic(fmt.Sprintf("lock name %q did not end with 'i' or 'z'", name)) -} - -func TestMemLSCanCreate(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - - for _, name := range lockTestNames { - _, err := m.Create(now, LockDetails{ - Root: name, - Duration: infiniteTimeout, - ZeroDepth: lockTestZeroDepth(name), - }) - if err != nil { - t.Fatalf("creating lock for %q: %v", name, err) - } - } - - wantCanCreate := func(name string, zeroDepth bool) bool { - for _, n := range lockTestNames { - switch { - case n == name: - // An existing lock has the same name as the proposed lock. - return false - case strings.HasPrefix(n, name): - // An existing lock would be a child of the proposed lock, - // which conflicts if the proposed lock has infinite depth. - if !zeroDepth { - return false - } - case strings.HasPrefix(name, n): - // An existing lock would be an ancestor of the proposed lock, - // which conflicts if the ancestor has infinite depth. - if n[len(n)-1] == 'i' { - return false - } - } - } - return true - } - - var check func(int, string) - check = func(recursion int, name string) { - for _, zeroDepth := range []bool{false, true} { - got := m.canCreate(name, zeroDepth) - want := wantCanCreate(name, zeroDepth) - if got != want { - t.Errorf("canCreate name=%q zeroDepth=%t: got %t, want %t", name, zeroDepth, got, want) - } - } - if recursion == 6 { - return - } - if name != "/" { - name += "/" - } - for _, c := range "_iz" { - check(recursion+1, name+string(c)) - } - } - check(0, "/") -} - -func TestMemLSLookup(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - - badToken := m.nextToken() - t.Logf("badToken=%q", badToken) - - for _, name := range lockTestNames { - token, err := m.Create(now, LockDetails{ - Root: name, - Duration: infiniteTimeout, - ZeroDepth: lockTestZeroDepth(name), - }) - if err != nil { - t.Fatalf("creating lock for %q: %v", name, err) - } - t.Logf("%-15q -> node=%p token=%q", name, m.byName[name], token) - } - - baseNames := append([]string{"/a", "/b/c"}, lockTestNames...) - for _, baseName := range baseNames { - for _, suffix := range []string{"", "/0", "/1/2/3"} { - name := baseName + suffix - - goodToken := "" - base := m.byName[baseName] - if base != nil && (suffix == "" || !lockTestZeroDepth(baseName)) { - goodToken = base.token - } - - for _, token := range []string{badToken, goodToken} { - if token == "" { - continue - } - - got := m.lookup(name, Condition{Token: token}) - want := base - if token == badToken { - want = nil - } - if got != want { - t.Errorf("name=%-20qtoken=%q (bad=%t): got %p, want %p", - name, token, token == badToken, got, want) - } - } - } - } -} - -func TestMemLSConfirm(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - alice, err := m.Create(now, LockDetails{ - Root: "/alice", - Duration: infiniteTimeout, - ZeroDepth: false, - }) - tweedle, err := m.Create(now, LockDetails{ - Root: "/tweedle", - Duration: infiniteTimeout, - ZeroDepth: false, - }) - if err != nil { - t.Fatalf("Create: %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Create: inconsistent state: %v", err) - } - - // Test a mismatch between name and condition. - _, err = m.Confirm(now, "/tweedle/dee", "", Condition{Token: alice}) - if err != ErrConfirmationFailed { - t.Fatalf("Confirm (mismatch): got %v, want ErrConfirmationFailed", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (mismatch): inconsistent state: %v", err) - } - - // Test two names (that fall under the same lock) in the one Confirm call. - release, err := m.Confirm(now, "/tweedle/dee", "/tweedle/dum", Condition{Token: tweedle}) - if err != nil { - t.Fatalf("Confirm (twins): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (twins): inconsistent state: %v", err) - } - release() - if err := m.consistent(); err != nil { - t.Fatalf("release (twins): inconsistent state: %v", err) - } - - // Test the same two names in overlapping Confirm / release calls. - releaseDee, err := m.Confirm(now, "/tweedle/dee", "", Condition{Token: tweedle}) - if err != nil { - t.Fatalf("Confirm (sequence #0): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (sequence #0): inconsistent state: %v", err) - } - - _, err = m.Confirm(now, "/tweedle/dum", "", Condition{Token: tweedle}) - if err != ErrConfirmationFailed { - t.Fatalf("Confirm (sequence #1): got %v, want ErrConfirmationFailed", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (sequence #1): inconsistent state: %v", err) - } - - releaseDee() - if err := m.consistent(); err != nil { - t.Fatalf("release (sequence #2): inconsistent state: %v", err) - } - - releaseDum, err := m.Confirm(now, "/tweedle/dum", "", Condition{Token: tweedle}) - if err != nil { - t.Fatalf("Confirm (sequence #3): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Confirm (sequence #3): inconsistent state: %v", err) - } - - // Test that you can't unlock a held lock. - err = m.Unlock(now, tweedle) - if err != ErrLocked { - t.Fatalf("Unlock (sequence #4): got %v, want ErrLocked", err) - } - - releaseDum() - if err := m.consistent(); err != nil { - t.Fatalf("release (sequence #5): inconsistent state: %v", err) - } - - err = m.Unlock(now, tweedle) - if err != nil { - t.Fatalf("Unlock (sequence #6): %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Unlock (sequence #6): inconsistent state: %v", err) - } -} - -func TestMemLSNonCanonicalRoot(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - token, err := m.Create(now, LockDetails{ - Root: "/foo/./bar//", - Duration: 1 * time.Second, - }) - if err != nil { - t.Fatalf("Create: %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Create: inconsistent state: %v", err) - } - if err := m.Unlock(now, token); err != nil { - t.Fatalf("Unlock: %v", err) - } - if err := m.consistent(); err != nil { - t.Fatalf("Unlock: inconsistent state: %v", err) - } -} - -func TestMemLSExpiry(t *testing.T) { - m := NewMemLS().(*memLS) - testCases := []string{ - "setNow 0", - "create /a.5", - "want /a.5", - "create /c.6", - "want /a.5 /c.6", - "create /a/b.7", - "want /a.5 /a/b.7 /c.6", - "setNow 4", - "want /a.5 /a/b.7 /c.6", - "setNow 5", - "want /a/b.7 /c.6", - "setNow 6", - "want /a/b.7", - "setNow 7", - "want ", - "setNow 8", - "want ", - "create /a.12", - "create /b.13", - "create /c.15", - "create /a/d.16", - "want /a.12 /a/d.16 /b.13 /c.15", - "refresh /a.14", - "want /a.14 /a/d.16 /b.13 /c.15", - "setNow 12", - "want /a.14 /a/d.16 /b.13 /c.15", - "setNow 13", - "want /a.14 /a/d.16 /c.15", - "setNow 14", - "want /a/d.16 /c.15", - "refresh /a/d.20", - "refresh /c.20", - "want /a/d.20 /c.20", - "setNow 20", - "want ", - } - - tokens := map[string]string{} - zTime := time.Unix(0, 0) - now := zTime - for i, tc := range testCases { - j := strings.IndexByte(tc, ' ') - if j < 0 { - t.Fatalf("test case #%d %q: invalid command", i, tc) - } - op, arg := tc[:j], tc[j+1:] - switch op { - default: - t.Fatalf("test case #%d %q: invalid operation %q", i, tc, op) - - case "create", "refresh": - parts := strings.Split(arg, ".") - if len(parts) != 2 { - t.Fatalf("test case #%d %q: invalid create", i, tc) - } - root := parts[0] - d, err := strconv.Atoi(parts[1]) - if err != nil { - t.Fatalf("test case #%d %q: invalid duration", i, tc) - } - dur := time.Unix(0, 0).Add(time.Duration(d) * time.Second).Sub(now) - - switch op { - case "create": - token, err := m.Create(now, LockDetails{ - Root: root, - Duration: dur, - ZeroDepth: true, - }) - if err != nil { - t.Fatalf("test case #%d %q: Create: %v", i, tc, err) - } - tokens[root] = token - - case "refresh": - token := tokens[root] - if token == "" { - t.Fatalf("test case #%d %q: no token for %q", i, tc, root) - } - got, err := m.Refresh(now, token, dur) - if err != nil { - t.Fatalf("test case #%d %q: Refresh: %v", i, tc, err) - } - want := LockDetails{ - Root: root, - Duration: dur, - ZeroDepth: true, - } - if got != want { - t.Fatalf("test case #%d %q:\ngot %v\nwant %v", i, tc, got, want) - } - } - - case "setNow": - d, err := strconv.Atoi(arg) - if err != nil { - t.Fatalf("test case #%d %q: invalid duration", i, tc) - } - now = time.Unix(0, 0).Add(time.Duration(d) * time.Second) - - case "want": - m.mu.Lock() - m.collectExpiredNodes(now) - got := make([]string, 0, len(m.byToken)) - for _, n := range m.byToken { - got = append(got, fmt.Sprintf("%s.%d", - n.details.Root, n.expiry.Sub(zTime)/time.Second)) - } - m.mu.Unlock() - sort.Strings(got) - want := []string{} - if arg != "" { - want = strings.Split(arg, " ") - } - if !reflect.DeepEqual(got, want) { - t.Fatalf("test case #%d %q:\ngot %q\nwant %q", i, tc, got, want) - } - } - - if err := m.consistent(); err != nil { - t.Fatalf("test case #%d %q: inconsistent state: %v", i, tc, err) - } - } -} - -func TestMemLS(t *testing.T) { - now := time.Unix(0, 0) - m := NewMemLS().(*memLS) - rng := rand.New(rand.NewSource(0)) - tokens := map[string]string{} - nConfirm, nCreate, nRefresh, nUnlock := 0, 0, 0, 0 - const N = 2000 - - for i := 0; i < N; i++ { - name := lockTestNames[rng.Intn(len(lockTestNames))] - duration := lockTestDurations[rng.Intn(len(lockTestDurations))] - confirmed, unlocked := false, false - - // If the name was already locked, we randomly confirm/release, refresh - // or unlock it. Otherwise, we create a lock. - token := tokens[name] - if token != "" { - switch rng.Intn(3) { - case 0: - confirmed = true - nConfirm++ - release, err := m.Confirm(now, name, "", Condition{Token: token}) - if err != nil { - t.Fatalf("iteration #%d: Confirm %q: %v", i, name, err) - } - if err := m.consistent(); err != nil { - t.Fatalf("iteration #%d: inconsistent state: %v", i, err) - } - release() - - case 1: - nRefresh++ - if _, err := m.Refresh(now, token, duration); err != nil { - t.Fatalf("iteration #%d: Refresh %q: %v", i, name, err) - } - - case 2: - unlocked = true - nUnlock++ - if err := m.Unlock(now, token); err != nil { - t.Fatalf("iteration #%d: Unlock %q: %v", i, name, err) - } - } - - } else { - nCreate++ - var err error - token, err = m.Create(now, LockDetails{ - Root: name, - Duration: duration, - ZeroDepth: lockTestZeroDepth(name), - }) - if err != nil { - t.Fatalf("iteration #%d: Create %q: %v", i, name, err) - } - } - - if !confirmed { - if duration == 0 || unlocked { - // A zero-duration lock should expire immediately and is - // effectively equivalent to being unlocked. - tokens[name] = "" - } else { - tokens[name] = token - } - } - - if err := m.consistent(); err != nil { - t.Fatalf("iteration #%d: inconsistent state: %v", i, err) - } - } - - if nConfirm < N/10 { - t.Fatalf("too few Confirm calls: got %d, want >= %d", nConfirm, N/10) - } - if nCreate < N/10 { - t.Fatalf("too few Create calls: got %d, want >= %d", nCreate, N/10) - } - if nRefresh < N/10 { - t.Fatalf("too few Refresh calls: got %d, want >= %d", nRefresh, N/10) - } - if nUnlock < N/10 { - t.Fatalf("too few Unlock calls: got %d, want >= %d", nUnlock, N/10) - } -} - -func (m *memLS) consistent() error { - m.mu.Lock() - defer m.mu.Unlock() - - // If m.byName is non-empty, then it must contain an entry for the root "/", - // and its refCount should equal the number of locked nodes. - if len(m.byName) > 0 { - n := m.byName["/"] - if n == nil { - return fmt.Errorf(`non-empty m.byName does not contain the root "/"`) - } - if n.refCount != len(m.byToken) { - return fmt.Errorf("root node refCount=%d, differs from len(m.byToken)=%d", n.refCount, len(m.byToken)) - } - } - - for name, n := range m.byName { - // The map keys should be consistent with the node's copy of the key. - if n.details.Root != name { - return fmt.Errorf("node name %q != byName map key %q", n.details.Root, name) - } - - // A name must be clean, and start with a "/". - if len(name) == 0 || name[0] != '/' { - return fmt.Errorf(`node name %q does not start with "/"`, name) - } - if name != path.Clean(name) { - return fmt.Errorf(`node name %q is not clean`, name) - } - - // A node's refCount should be positive. - if n.refCount <= 0 { - return fmt.Errorf("non-positive refCount for node at name %q", name) - } - - // A node's refCount should be the number of self-or-descendents that - // are locked (i.e. have a non-empty token). - var list []string - for name0, n0 := range m.byName { - // All of lockTestNames' name fragments are one byte long: '_', 'i' or 'z', - // so strings.HasPrefix is equivalent to self-or-descendent name match. - // We don't have to worry about "/foo/bar" being a false positive match - // for "/foo/b". - if strings.HasPrefix(name0, name) && n0.token != "" { - list = append(list, name0) - } - } - if n.refCount != len(list) { - sort.Strings(list) - return fmt.Errorf("node at name %q has refCount %d but locked self-or-descendents are %q (len=%d)", - name, n.refCount, list, len(list)) - } - - // A node n is in m.byToken if it has a non-empty token. - if n.token != "" { - if _, ok := m.byToken[n.token]; !ok { - return fmt.Errorf("node at name %q has token %q but not in m.byToken", name, n.token) - } - } - - // A node n is in m.byExpiry if it has a non-negative byExpiryIndex. - if n.byExpiryIndex >= 0 { - if n.byExpiryIndex >= len(m.byExpiry) { - return fmt.Errorf("node at name %q has byExpiryIndex %d but m.byExpiry has length %d", name, n.byExpiryIndex, len(m.byExpiry)) - } - if n != m.byExpiry[n.byExpiryIndex] { - return fmt.Errorf("node at name %q has byExpiryIndex %d but that indexes a different node", name, n.byExpiryIndex) - } - } - } - - for token, n := range m.byToken { - // The map keys should be consistent with the node's copy of the key. - if n.token != token { - return fmt.Errorf("node token %q != byToken map key %q", n.token, token) - } - - // Every node in m.byToken is in m.byName. - if _, ok := m.byName[n.details.Root]; !ok { - return fmt.Errorf("node at name %q in m.byToken but not in m.byName", n.details.Root) - } - } - - for i, n := range m.byExpiry { - // The slice indices should be consistent with the node's copy of the index. - if n.byExpiryIndex != i { - return fmt.Errorf("node byExpiryIndex %d != byExpiry slice index %d", n.byExpiryIndex, i) - } - - // Every node in m.byExpiry is in m.byName. - if _, ok := m.byName[n.details.Root]; !ok { - return fmt.Errorf("node at name %q in m.byExpiry but not in m.byName", n.details.Root) - } - - // No node in m.byExpiry should be held. - if n.held { - return fmt.Errorf("node at name %q in m.byExpiry is held", n.details.Root) - } - } - return nil -} - -func TestParseTimeout(t *testing.T) { - testCases := []struct { - s string - want time.Duration - wantErr error - }{{ - "", - infiniteTimeout, - nil, - }, { - "Infinite", - infiniteTimeout, - nil, - }, { - "Infinitesimal", - 0, - errInvalidTimeout, - }, { - "infinite", - 0, - errInvalidTimeout, - }, { - "Second-0", - 0 * time.Second, - nil, - }, { - "Second-123", - 123 * time.Second, - nil, - }, { - " Second-456 ", - 456 * time.Second, - nil, - }, { - "Second-4100000000", - 4100000000 * time.Second, - nil, - }, { - "junk", - 0, - errInvalidTimeout, - }, { - "Second-", - 0, - errInvalidTimeout, - }, { - "Second--1", - 0, - errInvalidTimeout, - }, { - "Second--123", - 0, - errInvalidTimeout, - }, { - "Second-+123", - 0, - errInvalidTimeout, - }, { - "Second-0x123", - 0, - errInvalidTimeout, - }, { - "second-123", - 0, - errInvalidTimeout, - }, { - "Second-4294967295", - 4294967295 * time.Second, - nil, - }, { - // Section 10.7 says that "The timeout value for TimeType "Second" - // must not be greater than 2^32-1." - "Second-4294967296", - 0, - errInvalidTimeout, - }, { - // This test case comes from section 9.10.9 of the spec. It says, - // - // "In this request, the client has specified that it desires an - // infinite-length lock, if available, otherwise a timeout of 4.1 - // billion seconds, if available." - // - // The Go WebDAV package always supports infinite length locks, - // and ignores the fallback after the comma. - "Infinite, Second-4100000000", - infiniteTimeout, - nil, - }} - - for _, tc := range testCases { - got, gotErr := parseTimeout(tc.s) - if got != tc.want || gotErr != tc.wantErr { - t.Errorf("parsing %q:\ngot %v, %v\nwant %v, %v", tc.s, got, gotErr, tc.want, tc.wantErr) - } - } -} diff --git a/vendor/golang.org/x/net/webdav/prop.go b/vendor/golang.org/x/net/webdav/prop.go deleted file mode 100644 index 1459466..0000000 --- a/vendor/golang.org/x/net/webdav/prop.go +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "encoding/xml" - "fmt" - "io" - "mime" - "net/http" - "os" - "path/filepath" - "strconv" -) - -// Proppatch describes a property update instruction as defined in RFC 4918. -// See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPPATCH -type Proppatch struct { - // Remove specifies whether this patch removes properties. If it does not - // remove them, it sets them. - Remove bool - // Props contains the properties to be set or removed. - Props []Property -} - -// Propstat describes a XML propstat element as defined in RFC 4918. -// See http://www.webdav.org/specs/rfc4918.html#ELEMENT_propstat -type Propstat struct { - // Props contains the properties for which Status applies. - Props []Property - - // Status defines the HTTP status code of the properties in Prop. - // Allowed values include, but are not limited to the WebDAV status - // code extensions for HTTP/1.1. - // http://www.webdav.org/specs/rfc4918.html#status.code.extensions.to.http11 - Status int - - // XMLError contains the XML representation of the optional error element. - // XML content within this field must not rely on any predefined - // namespace declarations or prefixes. If empty, the XML error element - // is omitted. - XMLError string - - // ResponseDescription contains the contents of the optional - // responsedescription field. If empty, the XML element is omitted. - ResponseDescription string -} - -// makePropstats returns a slice containing those of x and y whose Props slice -// is non-empty. If both are empty, it returns a slice containing an otherwise -// zero Propstat whose HTTP status code is 200 OK. -func makePropstats(x, y Propstat) []Propstat { - pstats := make([]Propstat, 0, 2) - if len(x.Props) != 0 { - pstats = append(pstats, x) - } - if len(y.Props) != 0 { - pstats = append(pstats, y) - } - if len(pstats) == 0 { - pstats = append(pstats, Propstat{ - Status: http.StatusOK, - }) - } - return pstats -} - -// DeadPropsHolder holds the dead properties of a resource. -// -// Dead properties are those properties that are explicitly defined. In -// comparison, live properties, such as DAV:getcontentlength, are implicitly -// defined by the underlying resource, and cannot be explicitly overridden or -// removed. See the Terminology section of -// http://www.webdav.org/specs/rfc4918.html#rfc.section.3 -// -// There is a whitelist of the names of live properties. This package handles -// all live properties, and will only pass non-whitelisted names to the Patch -// method of DeadPropsHolder implementations. -type DeadPropsHolder interface { - // DeadProps returns a copy of the dead properties held. - DeadProps() (map[xml.Name]Property, error) - - // Patch patches the dead properties held. - // - // Patching is atomic; either all or no patches succeed. It returns (nil, - // non-nil) if an internal server error occurred, otherwise the Propstats - // collectively contain one Property for each proposed patch Property. If - // all patches succeed, Patch returns a slice of length one and a Propstat - // element with a 200 OK HTTP status code. If none succeed, for reasons - // other than an internal server error, no Propstat has status 200 OK. - // - // For more details on when various HTTP status codes apply, see - // http://www.webdav.org/specs/rfc4918.html#PROPPATCH-status - Patch([]Proppatch) ([]Propstat, error) -} - -// liveProps contains all supported, protected DAV: properties. -var liveProps = map[xml.Name]struct { - // findFn implements the propfind function of this property. If nil, - // it indicates a hidden property. - findFn func(FileSystem, LockSystem, string, os.FileInfo) (string, error) - // dir is true if the property applies to directories. - dir bool -}{ - xml.Name{Space: "DAV:", Local: "resourcetype"}: { - findFn: findResourceType, - dir: true, - }, - xml.Name{Space: "DAV:", Local: "displayname"}: { - findFn: findDisplayName, - dir: true, - }, - xml.Name{Space: "DAV:", Local: "getcontentlength"}: { - findFn: findContentLength, - dir: false, - }, - xml.Name{Space: "DAV:", Local: "getlastmodified"}: { - findFn: findLastModified, - // http://webdav.org/specs/rfc4918.html#PROPERTY_getlastmodified - // suggests that getlastmodified should only apply to GETable - // resources, and this package does not support GET on directories. - // - // Nonetheless, some WebDAV clients expect child directories to be - // sortable by getlastmodified date, so this value is true, not false. - // See golang.org/issue/15334. - dir: true, - }, - xml.Name{Space: "DAV:", Local: "creationdate"}: { - findFn: nil, - dir: false, - }, - xml.Name{Space: "DAV:", Local: "getcontentlanguage"}: { - findFn: nil, - dir: false, - }, - xml.Name{Space: "DAV:", Local: "getcontenttype"}: { - findFn: findContentType, - dir: false, - }, - xml.Name{Space: "DAV:", Local: "getetag"}: { - findFn: findETag, - // findETag implements ETag as the concatenated hex values of a file's - // modification time and size. This is not a reliable synchronization - // mechanism for directories, so we do not advertise getetag for DAV - // collections. - dir: false, - }, - - // TODO: The lockdiscovery property requires LockSystem to list the - // active locks on a resource. - xml.Name{Space: "DAV:", Local: "lockdiscovery"}: {}, - xml.Name{Space: "DAV:", Local: "supportedlock"}: { - findFn: findSupportedLock, - dir: true, - }, -} - -// TODO(nigeltao) merge props and allprop? - -// Props returns the status of the properties named pnames for resource name. -// -// Each Propstat has a unique status and each property name will only be part -// of one Propstat element. -func props(fs FileSystem, ls LockSystem, name string, pnames []xml.Name) ([]Propstat, error) { - f, err := fs.OpenFile(name, os.O_RDONLY, 0) - if err != nil { - return nil, err - } - defer f.Close() - fi, err := f.Stat() - if err != nil { - return nil, err - } - isDir := fi.IsDir() - - var deadProps map[xml.Name]Property - if dph, ok := f.(DeadPropsHolder); ok { - deadProps, err = dph.DeadProps() - if err != nil { - return nil, err - } - } - - pstatOK := Propstat{Status: http.StatusOK} - pstatNotFound := Propstat{Status: http.StatusNotFound} - for _, pn := range pnames { - // If this file has dead properties, check if they contain pn. - if dp, ok := deadProps[pn]; ok { - pstatOK.Props = append(pstatOK.Props, dp) - continue - } - // Otherwise, it must either be a live property or we don't know it. - if prop := liveProps[pn]; prop.findFn != nil && (prop.dir || !isDir) { - innerXML, err := prop.findFn(fs, ls, name, fi) - if err != nil { - return nil, err - } - pstatOK.Props = append(pstatOK.Props, Property{ - XMLName: pn, - InnerXML: []byte(innerXML), - }) - } else { - pstatNotFound.Props = append(pstatNotFound.Props, Property{ - XMLName: pn, - }) - } - } - return makePropstats(pstatOK, pstatNotFound), nil -} - -// Propnames returns the property names defined for resource name. -func propnames(fs FileSystem, ls LockSystem, name string) ([]xml.Name, error) { - f, err := fs.OpenFile(name, os.O_RDONLY, 0) - if err != nil { - return nil, err - } - defer f.Close() - fi, err := f.Stat() - if err != nil { - return nil, err - } - isDir := fi.IsDir() - - var deadProps map[xml.Name]Property - if dph, ok := f.(DeadPropsHolder); ok { - deadProps, err = dph.DeadProps() - if err != nil { - return nil, err - } - } - - pnames := make([]xml.Name, 0, len(liveProps)+len(deadProps)) - for pn, prop := range liveProps { - if prop.findFn != nil && (prop.dir || !isDir) { - pnames = append(pnames, pn) - } - } - for pn := range deadProps { - pnames = append(pnames, pn) - } - return pnames, nil -} - -// Allprop returns the properties defined for resource name and the properties -// named in include. -// -// Note that RFC 4918 defines 'allprop' to return the DAV: properties defined -// within the RFC plus dead properties. Other live properties should only be -// returned if they are named in 'include'. -// -// See http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND -func allprop(fs FileSystem, ls LockSystem, name string, include []xml.Name) ([]Propstat, error) { - pnames, err := propnames(fs, ls, name) - if err != nil { - return nil, err - } - // Add names from include if they are not already covered in pnames. - nameset := make(map[xml.Name]bool) - for _, pn := range pnames { - nameset[pn] = true - } - for _, pn := range include { - if !nameset[pn] { - pnames = append(pnames, pn) - } - } - return props(fs, ls, name, pnames) -} - -// Patch patches the properties of resource name. The return values are -// constrained in the same manner as DeadPropsHolder.Patch. -func patch(fs FileSystem, ls LockSystem, name string, patches []Proppatch) ([]Propstat, error) { - conflict := false -loop: - for _, patch := range patches { - for _, p := range patch.Props { - if _, ok := liveProps[p.XMLName]; ok { - conflict = true - break loop - } - } - } - if conflict { - pstatForbidden := Propstat{ - Status: http.StatusForbidden, - XMLError: ``, - } - pstatFailedDep := Propstat{ - Status: StatusFailedDependency, - } - for _, patch := range patches { - for _, p := range patch.Props { - if _, ok := liveProps[p.XMLName]; ok { - pstatForbidden.Props = append(pstatForbidden.Props, Property{XMLName: p.XMLName}) - } else { - pstatFailedDep.Props = append(pstatFailedDep.Props, Property{XMLName: p.XMLName}) - } - } - } - return makePropstats(pstatForbidden, pstatFailedDep), nil - } - - f, err := fs.OpenFile(name, os.O_RDWR, 0) - if err != nil { - return nil, err - } - defer f.Close() - if dph, ok := f.(DeadPropsHolder); ok { - ret, err := dph.Patch(patches) - if err != nil { - return nil, err - } - // http://www.webdav.org/specs/rfc4918.html#ELEMENT_propstat says that - // "The contents of the prop XML element must only list the names of - // properties to which the result in the status element applies." - for _, pstat := range ret { - for i, p := range pstat.Props { - pstat.Props[i] = Property{XMLName: p.XMLName} - } - } - return ret, nil - } - // The file doesn't implement the optional DeadPropsHolder interface, so - // all patches are forbidden. - pstat := Propstat{Status: http.StatusForbidden} - for _, patch := range patches { - for _, p := range patch.Props { - pstat.Props = append(pstat.Props, Property{XMLName: p.XMLName}) - } - } - return []Propstat{pstat}, nil -} - -func findResourceType(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - if fi.IsDir() { - return ``, nil - } - return "", nil -} - -func findDisplayName(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - if slashClean(name) == "/" { - // Hide the real name of a possibly prefixed root directory. - return "", nil - } - return fi.Name(), nil -} - -func findContentLength(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - return strconv.FormatInt(fi.Size(), 10), nil -} - -func findLastModified(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - return fi.ModTime().Format(http.TimeFormat), nil -} - -func findContentType(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - f, err := fs.OpenFile(name, os.O_RDONLY, 0) - if err != nil { - return "", err - } - defer f.Close() - // This implementation is based on serveContent's code in the standard net/http package. - ctype := mime.TypeByExtension(filepath.Ext(name)) - if ctype != "" { - return ctype, nil - } - // Read a chunk to decide between utf-8 text and binary. - var buf [512]byte - n, err := io.ReadFull(f, buf[:]) - if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { - return "", err - } - ctype = http.DetectContentType(buf[:n]) - // Rewind file. - _, err = f.Seek(0, os.SEEK_SET) - return ctype, err -} - -func findETag(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - // The Apache http 2.4 web server by default concatenates the - // modification time and size of a file. We replicate the heuristic - // with nanosecond granularity. - return fmt.Sprintf(`"%x%x"`, fi.ModTime().UnixNano(), fi.Size()), nil -} - -func findSupportedLock(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) { - return `` + - `` + - `` + - `` + - ``, nil -} diff --git a/vendor/golang.org/x/net/webdav/prop_test.go b/vendor/golang.org/x/net/webdav/prop_test.go deleted file mode 100644 index 0834dc9..0000000 --- a/vendor/golang.org/x/net/webdav/prop_test.go +++ /dev/null @@ -1,610 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "encoding/xml" - "fmt" - "net/http" - "os" - "reflect" - "sort" - "testing" -) - -func TestMemPS(t *testing.T) { - // calcProps calculates the getlastmodified and getetag DAV: property - // values in pstats for resource name in file-system fs. - calcProps := func(name string, fs FileSystem, ls LockSystem, pstats []Propstat) error { - fi, err := fs.Stat(name) - if err != nil { - return err - } - for _, pst := range pstats { - for i, p := range pst.Props { - switch p.XMLName { - case xml.Name{Space: "DAV:", Local: "getlastmodified"}: - p.InnerXML = []byte(fi.ModTime().Format(http.TimeFormat)) - pst.Props[i] = p - case xml.Name{Space: "DAV:", Local: "getetag"}: - if fi.IsDir() { - continue - } - etag, err := findETag(fs, ls, name, fi) - if err != nil { - return err - } - p.InnerXML = []byte(etag) - pst.Props[i] = p - } - } - } - return nil - } - - const ( - lockEntry = `` + - `` + - `` + - `` + - `` - statForbiddenError = `` - ) - - type propOp struct { - op string - name string - pnames []xml.Name - patches []Proppatch - wantPnames []xml.Name - wantPropstats []Propstat - } - - testCases := []struct { - desc string - noDeadProps bool - buildfs []string - propOp []propOp - }{{ - desc: "propname", - buildfs: []string{"mkdir /dir", "touch /file"}, - propOp: []propOp{{ - op: "propname", - name: "/dir", - wantPnames: []xml.Name{ - {Space: "DAV:", Local: "resourcetype"}, - {Space: "DAV:", Local: "displayname"}, - {Space: "DAV:", Local: "supportedlock"}, - {Space: "DAV:", Local: "getlastmodified"}, - }, - }, { - op: "propname", - name: "/file", - wantPnames: []xml.Name{ - {Space: "DAV:", Local: "resourcetype"}, - {Space: "DAV:", Local: "displayname"}, - {Space: "DAV:", Local: "getcontentlength"}, - {Space: "DAV:", Local: "getlastmodified"}, - {Space: "DAV:", Local: "getcontenttype"}, - {Space: "DAV:", Local: "getetag"}, - {Space: "DAV:", Local: "supportedlock"}, - }, - }}, - }, { - desc: "allprop dir and file", - buildfs: []string{"mkdir /dir", "write /file foobarbaz"}, - propOp: []propOp{{ - op: "allprop", - name: "/dir", - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(``), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("dir"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getlastmodified"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, - InnerXML: []byte(lockEntry), - }}, - }}, - }, { - op: "allprop", - name: "/file", - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(""), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("file"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontentlength"}, - InnerXML: []byte("9"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getlastmodified"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontenttype"}, - InnerXML: []byte("text/plain; charset=utf-8"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, - InnerXML: []byte(lockEntry), - }}, - }}, - }, { - op: "allprop", - name: "/file", - pnames: []xml.Name{ - {"DAV:", "resourcetype"}, - {"foo", "bar"}, - }, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(""), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("file"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontentlength"}, - InnerXML: []byte("9"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getlastmodified"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getcontenttype"}, - InnerXML: []byte("text/plain; charset=utf-8"), - }, { - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - InnerXML: nil, // Calculated during test. - }, { - XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"}, - InnerXML: []byte(lockEntry), - }}}, { - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}}, - }, - }}, - }, { - desc: "propfind DAV:resourcetype", - buildfs: []string{"mkdir /dir", "touch /file"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "resourcetype"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(``), - }}, - }}, - }, { - op: "propfind", - name: "/file", - pnames: []xml.Name{{"DAV:", "resourcetype"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "resourcetype"}, - InnerXML: []byte(""), - }}, - }}, - }}, - }, { - desc: "propfind unsupported DAV properties", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "getcontentlanguage"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getcontentlanguage"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "creationdate"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "creationdate"}, - }}, - }}, - }}, - }, { - desc: "propfind getetag for files but not for directories", - buildfs: []string{"mkdir /dir", "touch /file"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"DAV:", "getetag"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - }}, - }}, - }, { - op: "propfind", - name: "/file", - pnames: []xml.Name{{"DAV:", "getetag"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - InnerXML: nil, // Calculated during test. - }}, - }}, - }}, - }, { - desc: "proppatch property on no-dead-properties file system", - buildfs: []string{"mkdir /dir"}, - noDeadProps: true, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusForbidden, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusForbidden, - XMLError: statForbiddenError, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "getetag"}, - }}, - }}, - }}, - }, { - desc: "proppatch dead property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{{Space: "foo", Local: "bar"}}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }}, - }}, - }, { - desc: "proppatch dead property with failed dependency", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }, { - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - InnerXML: []byte("xxx"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusForbidden, - XMLError: statForbiddenError, - Props: []Property{{ - XMLName: xml.Name{Space: "DAV:", Local: "displayname"}, - }}, - }, { - Status: StatusFailedDependency, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{{Space: "foo", Local: "bar"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }}, - }, { - desc: "proppatch remove dead property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }, { - XMLName: xml.Name{Space: "spam", Local: "ham"}, - InnerXML: []byte("eggs"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }, { - XMLName: xml.Name{Space: "spam", Local: "ham"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{ - {Space: "foo", Local: "bar"}, - {Space: "spam", Local: "ham"}, - }, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }, { - XMLName: xml.Name{Space: "spam", Local: "ham"}, - InnerXML: []byte("eggs"), - }}, - }}, - }, { - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Remove: true, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propfind", - name: "/dir", - pnames: []xml.Name{ - {Space: "foo", Local: "bar"}, - {Space: "spam", Local: "ham"}, - }, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }, { - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "spam", Local: "ham"}, - InnerXML: []byte("eggs"), - }}, - }}, - }}, - }, { - desc: "propname with dead property", - buildfs: []string{"touch /file"}, - propOp: []propOp{{ - op: "proppatch", - name: "/file", - patches: []Proppatch{{ - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - InnerXML: []byte("baz"), - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }, { - op: "propname", - name: "/file", - wantPnames: []xml.Name{ - {Space: "DAV:", Local: "resourcetype"}, - {Space: "DAV:", Local: "displayname"}, - {Space: "DAV:", Local: "getcontentlength"}, - {Space: "DAV:", Local: "getlastmodified"}, - {Space: "DAV:", Local: "getcontenttype"}, - {Space: "DAV:", Local: "getetag"}, - {Space: "DAV:", Local: "supportedlock"}, - {Space: "foo", Local: "bar"}, - }, - }}, - }, { - desc: "proppatch remove unknown dead property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "proppatch", - name: "/dir", - patches: []Proppatch{{ - Remove: true, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - wantPropstats: []Propstat{{ - Status: http.StatusOK, - Props: []Property{{ - XMLName: xml.Name{Space: "foo", Local: "bar"}, - }}, - }}, - }}, - }, { - desc: "bad: propfind unknown property", - buildfs: []string{"mkdir /dir"}, - propOp: []propOp{{ - op: "propfind", - name: "/dir", - pnames: []xml.Name{{"foo:", "bar"}}, - wantPropstats: []Propstat{{ - Status: http.StatusNotFound, - Props: []Property{{ - XMLName: xml.Name{Space: "foo:", Local: "bar"}, - }}, - }}, - }}, - }} - - for _, tc := range testCases { - fs, err := buildTestFS(tc.buildfs) - if err != nil { - t.Fatalf("%s: cannot create test filesystem: %v", tc.desc, err) - } - if tc.noDeadProps { - fs = noDeadPropsFS{fs} - } - ls := NewMemLS() - for _, op := range tc.propOp { - desc := fmt.Sprintf("%s: %s %s", tc.desc, op.op, op.name) - if err = calcProps(op.name, fs, ls, op.wantPropstats); err != nil { - t.Fatalf("%s: calcProps: %v", desc, err) - } - - // Call property system. - var propstats []Propstat - switch op.op { - case "propname": - pnames, err := propnames(fs, ls, op.name) - if err != nil { - t.Errorf("%s: got error %v, want nil", desc, err) - continue - } - sort.Sort(byXMLName(pnames)) - sort.Sort(byXMLName(op.wantPnames)) - if !reflect.DeepEqual(pnames, op.wantPnames) { - t.Errorf("%s: pnames\ngot %q\nwant %q", desc, pnames, op.wantPnames) - } - continue - case "allprop": - propstats, err = allprop(fs, ls, op.name, op.pnames) - case "propfind": - propstats, err = props(fs, ls, op.name, op.pnames) - case "proppatch": - propstats, err = patch(fs, ls, op.name, op.patches) - default: - t.Fatalf("%s: %s not implemented", desc, op.op) - } - if err != nil { - t.Errorf("%s: got error %v, want nil", desc, err) - continue - } - // Compare return values from allprop, propfind or proppatch. - for _, pst := range propstats { - sort.Sort(byPropname(pst.Props)) - } - for _, pst := range op.wantPropstats { - sort.Sort(byPropname(pst.Props)) - } - sort.Sort(byStatus(propstats)) - sort.Sort(byStatus(op.wantPropstats)) - if !reflect.DeepEqual(propstats, op.wantPropstats) { - t.Errorf("%s: propstat\ngot %q\nwant %q", desc, propstats, op.wantPropstats) - } - } - } -} - -func cmpXMLName(a, b xml.Name) bool { - if a.Space != b.Space { - return a.Space < b.Space - } - return a.Local < b.Local -} - -type byXMLName []xml.Name - -func (b byXMLName) Len() int { return len(b) } -func (b byXMLName) Swap(i, j int) { b[i], b[j] = b[j], b[i] } -func (b byXMLName) Less(i, j int) bool { return cmpXMLName(b[i], b[j]) } - -type byPropname []Property - -func (b byPropname) Len() int { return len(b) } -func (b byPropname) Swap(i, j int) { b[i], b[j] = b[j], b[i] } -func (b byPropname) Less(i, j int) bool { return cmpXMLName(b[i].XMLName, b[j].XMLName) } - -type byStatus []Propstat - -func (b byStatus) Len() int { return len(b) } -func (b byStatus) Swap(i, j int) { b[i], b[j] = b[j], b[i] } -func (b byStatus) Less(i, j int) bool { return b[i].Status < b[j].Status } - -type noDeadPropsFS struct { - FileSystem -} - -func (fs noDeadPropsFS) OpenFile(name string, flag int, perm os.FileMode) (File, error) { - f, err := fs.FileSystem.OpenFile(name, flag, perm) - if err != nil { - return nil, err - } - return noDeadPropsFile{f}, nil -} - -// noDeadPropsFile wraps a File but strips any optional DeadPropsHolder methods -// provided by the underlying File implementation. -type noDeadPropsFile struct { - f File -} - -func (f noDeadPropsFile) Close() error { return f.f.Close() } -func (f noDeadPropsFile) Read(p []byte) (int, error) { return f.f.Read(p) } -func (f noDeadPropsFile) Readdir(count int) ([]os.FileInfo, error) { return f.f.Readdir(count) } -func (f noDeadPropsFile) Seek(off int64, whence int) (int64, error) { return f.f.Seek(off, whence) } -func (f noDeadPropsFile) Stat() (os.FileInfo, error) { return f.f.Stat() } -func (f noDeadPropsFile) Write(p []byte) (int, error) { return f.f.Write(p) } diff --git a/vendor/golang.org/x/net/webdav/webdav.go b/vendor/golang.org/x/net/webdav/webdav.go deleted file mode 100644 index 4ce0972..0000000 --- a/vendor/golang.org/x/net/webdav/webdav.go +++ /dev/null @@ -1,689 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package webdav provides a WebDAV server implementation. -package webdav // import "golang.org/x/net/webdav" - -import ( - "errors" - "fmt" - "io" - "net/http" - "net/url" - "os" - "path" - "strings" - "time" -) - -type Handler struct { - // Prefix is the URL path prefix to strip from WebDAV resource paths. - Prefix string - // FileSystem is the virtual file system. - FileSystem FileSystem - // LockSystem is the lock management system. - LockSystem LockSystem - // Logger is an optional error logger. If non-nil, it will be called - // for all HTTP requests. - Logger func(*http.Request, error) -} - -func (h *Handler) stripPrefix(p string) (string, int, error) { - if h.Prefix == "" { - return p, http.StatusOK, nil - } - if r := strings.TrimPrefix(p, h.Prefix); len(r) < len(p) { - return r, http.StatusOK, nil - } - return p, http.StatusNotFound, errPrefixMismatch -} - -func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { - status, err := http.StatusBadRequest, errUnsupportedMethod - if h.FileSystem == nil { - status, err = http.StatusInternalServerError, errNoFileSystem - } else if h.LockSystem == nil { - status, err = http.StatusInternalServerError, errNoLockSystem - } else { - switch r.Method { - case "OPTIONS": - status, err = h.handleOptions(w, r) - case "GET", "HEAD", "POST": - status, err = h.handleGetHeadPost(w, r) - case "DELETE": - status, err = h.handleDelete(w, r) - case "PUT": - status, err = h.handlePut(w, r) - case "MKCOL": - status, err = h.handleMkcol(w, r) - case "COPY", "MOVE": - status, err = h.handleCopyMove(w, r) - case "LOCK": - status, err = h.handleLock(w, r) - case "UNLOCK": - status, err = h.handleUnlock(w, r) - case "PROPFIND": - status, err = h.handlePropfind(w, r) - case "PROPPATCH": - status, err = h.handleProppatch(w, r) - } - } - - if status != 0 { - w.WriteHeader(status) - if status != http.StatusNoContent { - w.Write([]byte(StatusText(status))) - } - } - if h.Logger != nil { - h.Logger(r, err) - } -} - -func (h *Handler) lock(now time.Time, root string) (token string, status int, err error) { - token, err = h.LockSystem.Create(now, LockDetails{ - Root: root, - Duration: infiniteTimeout, - ZeroDepth: true, - }) - if err != nil { - if err == ErrLocked { - return "", StatusLocked, err - } - return "", http.StatusInternalServerError, err - } - return token, 0, nil -} - -func (h *Handler) confirmLocks(r *http.Request, src, dst string) (release func(), status int, err error) { - hdr := r.Header.Get("If") - if hdr == "" { - // An empty If header means that the client hasn't previously created locks. - // Even if this client doesn't care about locks, we still need to check that - // the resources aren't locked by another client, so we create temporary - // locks that would conflict with another client's locks. These temporary - // locks are unlocked at the end of the HTTP request. - now, srcToken, dstToken := time.Now(), "", "" - if src != "" { - srcToken, status, err = h.lock(now, src) - if err != nil { - return nil, status, err - } - } - if dst != "" { - dstToken, status, err = h.lock(now, dst) - if err != nil { - if srcToken != "" { - h.LockSystem.Unlock(now, srcToken) - } - return nil, status, err - } - } - - return func() { - if dstToken != "" { - h.LockSystem.Unlock(now, dstToken) - } - if srcToken != "" { - h.LockSystem.Unlock(now, srcToken) - } - }, 0, nil - } - - ih, ok := parseIfHeader(hdr) - if !ok { - return nil, http.StatusBadRequest, errInvalidIfHeader - } - // ih is a disjunction (OR) of ifLists, so any ifList will do. - for _, l := range ih.lists { - lsrc := l.resourceTag - if lsrc == "" { - lsrc = src - } else { - u, err := url.Parse(lsrc) - if err != nil { - continue - } - if u.Host != r.Host { - continue - } - lsrc, status, err = h.stripPrefix(u.Path) - if err != nil { - return nil, status, err - } - } - release, err = h.LockSystem.Confirm(time.Now(), lsrc, dst, l.conditions...) - if err == ErrConfirmationFailed { - continue - } - if err != nil { - return nil, http.StatusInternalServerError, err - } - return release, 0, nil - } - // Section 10.4.1 says that "If this header is evaluated and all state lists - // fail, then the request must fail with a 412 (Precondition Failed) status." - // We follow the spec even though the cond_put_corrupt_token test case from - // the litmus test warns on seeing a 412 instead of a 423 (Locked). - return nil, http.StatusPreconditionFailed, ErrLocked -} - -func (h *Handler) handleOptions(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - allow := "OPTIONS, LOCK, PUT, MKCOL" - if fi, err := h.FileSystem.Stat(reqPath); err == nil { - if fi.IsDir() { - allow = "OPTIONS, LOCK, DELETE, PROPPATCH, COPY, MOVE, UNLOCK, PROPFIND" - } else { - allow = "OPTIONS, LOCK, GET, HEAD, POST, DELETE, PROPPATCH, COPY, MOVE, UNLOCK, PROPFIND, PUT" - } - } - w.Header().Set("Allow", allow) - // http://www.webdav.org/specs/rfc4918.html#dav.compliance.classes - w.Header().Set("DAV", "1, 2") - // http://msdn.microsoft.com/en-au/library/cc250217.aspx - w.Header().Set("MS-Author-Via", "DAV") - return 0, nil -} - -func (h *Handler) handleGetHeadPost(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - // TODO: check locks for read-only access?? - f, err := h.FileSystem.OpenFile(reqPath, os.O_RDONLY, 0) - if err != nil { - return http.StatusNotFound, err - } - defer f.Close() - fi, err := f.Stat() - if err != nil { - return http.StatusNotFound, err - } - if fi.IsDir() { - return http.StatusMethodNotAllowed, nil - } - etag, err := findETag(h.FileSystem, h.LockSystem, reqPath, fi) - if err != nil { - return http.StatusInternalServerError, err - } - w.Header().Set("ETag", etag) - // Let ServeContent determine the Content-Type header. - http.ServeContent(w, r, reqPath, fi.ModTime(), f) - return 0, nil -} - -func (h *Handler) handleDelete(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - - // TODO: return MultiStatus where appropriate. - - // "godoc os RemoveAll" says that "If the path does not exist, RemoveAll - // returns nil (no error)." WebDAV semantics are that it should return a - // "404 Not Found". We therefore have to Stat before we RemoveAll. - if _, err := h.FileSystem.Stat(reqPath); err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusMethodNotAllowed, err - } - if err := h.FileSystem.RemoveAll(reqPath); err != nil { - return http.StatusMethodNotAllowed, err - } - return http.StatusNoContent, nil -} - -func (h *Handler) handlePut(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - // TODO(rost): Support the If-Match, If-None-Match headers? See bradfitz' - // comments in http.checkEtag. - - f, err := h.FileSystem.OpenFile(reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - return http.StatusNotFound, err - } - _, copyErr := io.Copy(f, r.Body) - fi, statErr := f.Stat() - closeErr := f.Close() - // TODO(rost): Returning 405 Method Not Allowed might not be appropriate. - if copyErr != nil { - return http.StatusMethodNotAllowed, copyErr - } - if statErr != nil { - return http.StatusMethodNotAllowed, statErr - } - if closeErr != nil { - return http.StatusMethodNotAllowed, closeErr - } - etag, err := findETag(h.FileSystem, h.LockSystem, reqPath, fi) - if err != nil { - return http.StatusInternalServerError, err - } - w.Header().Set("ETag", etag) - return http.StatusCreated, nil -} - -func (h *Handler) handleMkcol(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - - if r.ContentLength > 0 { - return http.StatusUnsupportedMediaType, nil - } - if err := h.FileSystem.Mkdir(reqPath, 0777); err != nil { - if os.IsNotExist(err) { - return http.StatusConflict, err - } - return http.StatusMethodNotAllowed, err - } - return http.StatusCreated, nil -} - -func (h *Handler) handleCopyMove(w http.ResponseWriter, r *http.Request) (status int, err error) { - hdr := r.Header.Get("Destination") - if hdr == "" { - return http.StatusBadRequest, errInvalidDestination - } - u, err := url.Parse(hdr) - if err != nil { - return http.StatusBadRequest, errInvalidDestination - } - if u.Host != r.Host { - return http.StatusBadGateway, errInvalidDestination - } - - src, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - - dst, status, err := h.stripPrefix(u.Path) - if err != nil { - return status, err - } - - if dst == "" { - return http.StatusBadGateway, errInvalidDestination - } - if dst == src { - return http.StatusForbidden, errDestinationEqualsSource - } - - if r.Method == "COPY" { - // Section 7.5.1 says that a COPY only needs to lock the destination, - // not both destination and source. Strictly speaking, this is racy, - // even though a COPY doesn't modify the source, if a concurrent - // operation modifies the source. However, the litmus test explicitly - // checks that COPYing a locked-by-another source is OK. - release, status, err := h.confirmLocks(r, "", dst) - if err != nil { - return status, err - } - defer release() - - // Section 9.8.3 says that "The COPY method on a collection without a Depth - // header must act as if a Depth header with value "infinity" was included". - depth := infiniteDepth - if hdr := r.Header.Get("Depth"); hdr != "" { - depth = parseDepth(hdr) - if depth != 0 && depth != infiniteDepth { - // Section 9.8.3 says that "A client may submit a Depth header on a - // COPY on a collection with a value of "0" or "infinity"." - return http.StatusBadRequest, errInvalidDepth - } - } - return copyFiles(h.FileSystem, src, dst, r.Header.Get("Overwrite") != "F", depth, 0) - } - - release, status, err := h.confirmLocks(r, src, dst) - if err != nil { - return status, err - } - defer release() - - // Section 9.9.2 says that "The MOVE method on a collection must act as if - // a "Depth: infinity" header was used on it. A client must not submit a - // Depth header on a MOVE on a collection with any value but "infinity"." - if hdr := r.Header.Get("Depth"); hdr != "" { - if parseDepth(hdr) != infiniteDepth { - return http.StatusBadRequest, errInvalidDepth - } - } - return moveFiles(h.FileSystem, src, dst, r.Header.Get("Overwrite") == "T") -} - -func (h *Handler) handleLock(w http.ResponseWriter, r *http.Request) (retStatus int, retErr error) { - duration, err := parseTimeout(r.Header.Get("Timeout")) - if err != nil { - return http.StatusBadRequest, err - } - li, status, err := readLockInfo(r.Body) - if err != nil { - return status, err - } - - token, ld, now, created := "", LockDetails{}, time.Now(), false - if li == (lockInfo{}) { - // An empty lockInfo means to refresh the lock. - ih, ok := parseIfHeader(r.Header.Get("If")) - if !ok { - return http.StatusBadRequest, errInvalidIfHeader - } - if len(ih.lists) == 1 && len(ih.lists[0].conditions) == 1 { - token = ih.lists[0].conditions[0].Token - } - if token == "" { - return http.StatusBadRequest, errInvalidLockToken - } - ld, err = h.LockSystem.Refresh(now, token, duration) - if err != nil { - if err == ErrNoSuchLock { - return http.StatusPreconditionFailed, err - } - return http.StatusInternalServerError, err - } - - } else { - // Section 9.10.3 says that "If no Depth header is submitted on a LOCK request, - // then the request MUST act as if a "Depth:infinity" had been submitted." - depth := infiniteDepth - if hdr := r.Header.Get("Depth"); hdr != "" { - depth = parseDepth(hdr) - if depth != 0 && depth != infiniteDepth { - // Section 9.10.3 says that "Values other than 0 or infinity must not be - // used with the Depth header on a LOCK method". - return http.StatusBadRequest, errInvalidDepth - } - } - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - ld = LockDetails{ - Root: reqPath, - Duration: duration, - OwnerXML: li.Owner.InnerXML, - ZeroDepth: depth == 0, - } - token, err = h.LockSystem.Create(now, ld) - if err != nil { - if err == ErrLocked { - return StatusLocked, err - } - return http.StatusInternalServerError, err - } - defer func() { - if retErr != nil { - h.LockSystem.Unlock(now, token) - } - }() - - // Create the resource if it didn't previously exist. - if _, err := h.FileSystem.Stat(reqPath); err != nil { - f, err := h.FileSystem.OpenFile(reqPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0666) - if err != nil { - // TODO: detect missing intermediate dirs and return http.StatusConflict? - return http.StatusInternalServerError, err - } - f.Close() - created = true - } - - // http://www.webdav.org/specs/rfc4918.html#HEADER_Lock-Token says that the - // Lock-Token value is a Coded-URL. We add angle brackets. - w.Header().Set("Lock-Token", "<"+token+">") - } - - w.Header().Set("Content-Type", "application/xml; charset=utf-8") - if created { - // This is "w.WriteHeader(http.StatusCreated)" and not "return - // http.StatusCreated, nil" because we write our own (XML) response to w - // and Handler.ServeHTTP would otherwise write "Created". - w.WriteHeader(http.StatusCreated) - } - writeLockInfo(w, token, ld) - return 0, nil -} - -func (h *Handler) handleUnlock(w http.ResponseWriter, r *http.Request) (status int, err error) { - // http://www.webdav.org/specs/rfc4918.html#HEADER_Lock-Token says that the - // Lock-Token value is a Coded-URL. We strip its angle brackets. - t := r.Header.Get("Lock-Token") - if len(t) < 2 || t[0] != '<' || t[len(t)-1] != '>' { - return http.StatusBadRequest, errInvalidLockToken - } - t = t[1 : len(t)-1] - - switch err = h.LockSystem.Unlock(time.Now(), t); err { - case nil: - return http.StatusNoContent, err - case ErrForbidden: - return http.StatusForbidden, err - case ErrLocked: - return StatusLocked, err - case ErrNoSuchLock: - return http.StatusConflict, err - default: - return http.StatusInternalServerError, err - } -} - -func (h *Handler) handlePropfind(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - fi, err := h.FileSystem.Stat(reqPath) - if err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusMethodNotAllowed, err - } - depth := infiniteDepth - if hdr := r.Header.Get("Depth"); hdr != "" { - depth = parseDepth(hdr) - if depth == invalidDepth { - return http.StatusBadRequest, errInvalidDepth - } - } - pf, status, err := readPropfind(r.Body) - if err != nil { - return status, err - } - - mw := multistatusWriter{w: w} - - walkFn := func(reqPath string, info os.FileInfo, err error) error { - if err != nil { - return err - } - var pstats []Propstat - if pf.Propname != nil { - pnames, err := propnames(h.FileSystem, h.LockSystem, reqPath) - if err != nil { - return err - } - pstat := Propstat{Status: http.StatusOK} - for _, xmlname := range pnames { - pstat.Props = append(pstat.Props, Property{XMLName: xmlname}) - } - pstats = append(pstats, pstat) - } else if pf.Allprop != nil { - pstats, err = allprop(h.FileSystem, h.LockSystem, reqPath, pf.Prop) - } else { - pstats, err = props(h.FileSystem, h.LockSystem, reqPath, pf.Prop) - } - if err != nil { - return err - } - return mw.write(makePropstatResponse(path.Join(h.Prefix, reqPath), pstats)) - } - - walkErr := walkFS(h.FileSystem, depth, reqPath, fi, walkFn) - closeErr := mw.close() - if walkErr != nil { - return http.StatusInternalServerError, walkErr - } - if closeErr != nil { - return http.StatusInternalServerError, closeErr - } - return 0, nil -} - -func (h *Handler) handleProppatch(w http.ResponseWriter, r *http.Request) (status int, err error) { - reqPath, status, err := h.stripPrefix(r.URL.Path) - if err != nil { - return status, err - } - release, status, err := h.confirmLocks(r, reqPath, "") - if err != nil { - return status, err - } - defer release() - - if _, err := h.FileSystem.Stat(reqPath); err != nil { - if os.IsNotExist(err) { - return http.StatusNotFound, err - } - return http.StatusMethodNotAllowed, err - } - patches, status, err := readProppatch(r.Body) - if err != nil { - return status, err - } - pstats, err := patch(h.FileSystem, h.LockSystem, reqPath, patches) - if err != nil { - return http.StatusInternalServerError, err - } - mw := multistatusWriter{w: w} - writeErr := mw.write(makePropstatResponse(r.URL.Path, pstats)) - closeErr := mw.close() - if writeErr != nil { - return http.StatusInternalServerError, writeErr - } - if closeErr != nil { - return http.StatusInternalServerError, closeErr - } - return 0, nil -} - -func makePropstatResponse(href string, pstats []Propstat) *response { - resp := response{ - Href: []string{(&url.URL{Path: href}).EscapedPath()}, - Propstat: make([]propstat, 0, len(pstats)), - } - for _, p := range pstats { - var xmlErr *xmlError - if p.XMLError != "" { - xmlErr = &xmlError{InnerXML: []byte(p.XMLError)} - } - resp.Propstat = append(resp.Propstat, propstat{ - Status: fmt.Sprintf("HTTP/1.1 %d %s", p.Status, StatusText(p.Status)), - Prop: p.Props, - ResponseDescription: p.ResponseDescription, - Error: xmlErr, - }) - } - return &resp -} - -const ( - infiniteDepth = -1 - invalidDepth = -2 -) - -// parseDepth maps the strings "0", "1" and "infinity" to 0, 1 and -// infiniteDepth. Parsing any other string returns invalidDepth. -// -// Different WebDAV methods have further constraints on valid depths: -// - PROPFIND has no further restrictions, as per section 9.1. -// - COPY accepts only "0" or "infinity", as per section 9.8.3. -// - MOVE accepts only "infinity", as per section 9.9.2. -// - LOCK accepts only "0" or "infinity", as per section 9.10.3. -// These constraints are enforced by the handleXxx methods. -func parseDepth(s string) int { - switch s { - case "0": - return 0 - case "1": - return 1 - case "infinity": - return infiniteDepth - } - return invalidDepth -} - -// http://www.webdav.org/specs/rfc4918.html#status.code.extensions.to.http11 -const ( - StatusMulti = 207 - StatusUnprocessableEntity = 422 - StatusLocked = 423 - StatusFailedDependency = 424 - StatusInsufficientStorage = 507 -) - -func StatusText(code int) string { - switch code { - case StatusMulti: - return "Multi-Status" - case StatusUnprocessableEntity: - return "Unprocessable Entity" - case StatusLocked: - return "Locked" - case StatusFailedDependency: - return "Failed Dependency" - case StatusInsufficientStorage: - return "Insufficient Storage" - } - return http.StatusText(code) -} - -var ( - errDestinationEqualsSource = errors.New("webdav: destination equals source") - errDirectoryNotEmpty = errors.New("webdav: directory not empty") - errInvalidDepth = errors.New("webdav: invalid depth") - errInvalidDestination = errors.New("webdav: invalid destination") - errInvalidIfHeader = errors.New("webdav: invalid If header") - errInvalidLockInfo = errors.New("webdav: invalid lock info") - errInvalidLockToken = errors.New("webdav: invalid lock token") - errInvalidPropfind = errors.New("webdav: invalid propfind") - errInvalidProppatch = errors.New("webdav: invalid proppatch") - errInvalidResponse = errors.New("webdav: invalid response") - errInvalidTimeout = errors.New("webdav: invalid timeout") - errNoFileSystem = errors.New("webdav: no file system") - errNoLockSystem = errors.New("webdav: no lock system") - errNotADirectory = errors.New("webdav: not a directory") - errPrefixMismatch = errors.New("webdav: prefix mismatch") - errRecursionTooDeep = errors.New("webdav: recursion too deep") - errUnsupportedLockInfo = errors.New("webdav: unsupported lock info") - errUnsupportedMethod = errors.New("webdav: unsupported method") -) diff --git a/vendor/golang.org/x/net/webdav/webdav_test.go b/vendor/golang.org/x/net/webdav/webdav_test.go deleted file mode 100644 index b068aab..0000000 --- a/vendor/golang.org/x/net/webdav/webdav_test.go +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "errors" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/http/httptest" - "net/url" - "os" - "reflect" - "regexp" - "sort" - "strings" - "testing" -) - -// TODO: add tests to check XML responses with the expected prefix path -func TestPrefix(t *testing.T) { - const dst, blah = "Destination", "blah blah blah" - - // createLockBody comes from the example in Section 9.10.7. - const createLockBody = ` - - - - - http://example.org/~ejw/contact.html - - - ` - - do := func(method, urlStr string, body string, wantStatusCode int, headers ...string) (http.Header, error) { - var bodyReader io.Reader - if body != "" { - bodyReader = strings.NewReader(body) - } - req, err := http.NewRequest(method, urlStr, bodyReader) - if err != nil { - return nil, err - } - for len(headers) >= 2 { - req.Header.Add(headers[0], headers[1]) - headers = headers[2:] - } - res, err := http.DefaultClient.Do(req) - if err != nil { - return nil, err - } - defer res.Body.Close() - if res.StatusCode != wantStatusCode { - return nil, fmt.Errorf("got status code %d, want %d", res.StatusCode, wantStatusCode) - } - return res.Header, nil - } - - prefixes := []string{ - "/", - "/a/", - "/a/b/", - "/a/b/c/", - } - for _, prefix := range prefixes { - fs := NewMemFS() - h := &Handler{ - FileSystem: fs, - LockSystem: NewMemLS(), - } - mux := http.NewServeMux() - if prefix != "/" { - h.Prefix = prefix - } - mux.Handle(prefix, h) - srv := httptest.NewServer(mux) - defer srv.Close() - - // The script is: - // MKCOL /a - // MKCOL /a/b - // PUT /a/b/c - // COPY /a/b/c /a/b/d - // MKCOL /a/b/e - // MOVE /a/b/d /a/b/e/f - // LOCK /a/b/e/g - // PUT /a/b/e/g - // which should yield the (possibly stripped) filenames /a/b/c, - // /a/b/e/f and /a/b/e/g, plus their parent directories. - - wantA := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusMovedPermanently, - "/a/b/": http.StatusNotFound, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MKCOL", srv.URL+"/a", "", wantA); err != nil { - t.Errorf("prefix=%-9q MKCOL /a: %v", prefix, err) - continue - } - - wantB := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusMovedPermanently, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MKCOL", srv.URL+"/a/b", "", wantB); err != nil { - t.Errorf("prefix=%-9q MKCOL /a/b: %v", prefix, err) - continue - } - - wantC := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusMovedPermanently, - }[prefix] - if _, err := do("PUT", srv.URL+"/a/b/c", blah, wantC); err != nil { - t.Errorf("prefix=%-9q PUT /a/b/c: %v", prefix, err) - continue - } - - wantD := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusMovedPermanently, - }[prefix] - if _, err := do("COPY", srv.URL+"/a/b/c", "", wantD, dst, srv.URL+"/a/b/d"); err != nil { - t.Errorf("prefix=%-9q COPY /a/b/c /a/b/d: %v", prefix, err) - continue - } - - wantE := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MKCOL", srv.URL+"/a/b/e", "", wantE); err != nil { - t.Errorf("prefix=%-9q MKCOL /a/b/e: %v", prefix, err) - continue - } - - wantF := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("MOVE", srv.URL+"/a/b/d", "", wantF, dst, srv.URL+"/a/b/e/f"); err != nil { - t.Errorf("prefix=%-9q MOVE /a/b/d /a/b/e/f: %v", prefix, err) - continue - } - - var lockToken string - wantG := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if h, err := do("LOCK", srv.URL+"/a/b/e/g", createLockBody, wantG); err != nil { - t.Errorf("prefix=%-9q LOCK /a/b/e/g: %v", prefix, err) - continue - } else { - lockToken = h.Get("Lock-Token") - } - - ifHeader := fmt.Sprintf("<%s/a/b/e/g> (%s)", srv.URL, lockToken) - wantH := map[string]int{ - "/": http.StatusCreated, - "/a/": http.StatusCreated, - "/a/b/": http.StatusCreated, - "/a/b/c/": http.StatusNotFound, - }[prefix] - if _, err := do("PUT", srv.URL+"/a/b/e/g", blah, wantH, "If", ifHeader); err != nil { - t.Errorf("prefix=%-9q PUT /a/b/e/g: %v", prefix, err) - continue - } - - got, err := find(nil, fs, "/") - if err != nil { - t.Errorf("prefix=%-9q find: %v", prefix, err) - continue - } - sort.Strings(got) - want := map[string][]string{ - "/": {"/", "/a", "/a/b", "/a/b/c", "/a/b/e", "/a/b/e/f", "/a/b/e/g"}, - "/a/": {"/", "/b", "/b/c", "/b/e", "/b/e/f", "/b/e/g"}, - "/a/b/": {"/", "/c", "/e", "/e/f", "/e/g"}, - "/a/b/c/": {"/"}, - }[prefix] - if !reflect.DeepEqual(got, want) { - t.Errorf("prefix=%-9q find:\ngot %v\nwant %v", prefix, got, want) - continue - } - } -} - -func TestFilenameEscape(t *testing.T) { - re := regexp.MustCompile(`([^<]*)`) - do := func(method, urlStr string) (string, error) { - req, err := http.NewRequest(method, urlStr, nil) - if err != nil { - return "", err - } - res, err := http.DefaultClient.Do(req) - if err != nil { - return "", err - } - defer res.Body.Close() - - b, err := ioutil.ReadAll(res.Body) - if err != nil { - return "", err - } - m := re.FindStringSubmatch(string(b)) - if len(m) != 2 { - return "", errors.New("D:href not found") - } - - return m[1], nil - } - - testCases := []struct { - name, want string - }{{ - name: `/foo%bar`, - want: `/foo%25bar`, - }, { - name: `/ã“ã‚“ã«ã¡ã‚世界`, - want: `/%E3%81%93%E3%82%93%E3%81%AB%E3%81%A1%E3%82%8F%E4%B8%96%E7%95%8C`, - }, { - name: `/Program Files/`, - want: `/Program%20Files`, - }, { - name: `/go+lang`, - want: `/go+lang`, - }, { - name: `/go&lang`, - want: `/go&lang`, - }} - fs := NewMemFS() - for _, tc := range testCases { - if strings.HasSuffix(tc.name, "/") { - if err := fs.Mkdir(tc.name, 0755); err != nil { - t.Fatalf("name=%q: Mkdir: %v", tc.name, err) - } - } else { - f, err := fs.OpenFile(tc.name, os.O_CREATE, 0644) - if err != nil { - t.Fatalf("name=%q: OpenFile: %v", tc.name, err) - } - f.Close() - } - } - - srv := httptest.NewServer(&Handler{ - FileSystem: fs, - LockSystem: NewMemLS(), - }) - defer srv.Close() - - u, err := url.Parse(srv.URL) - if err != nil { - t.Fatal(err) - } - - for _, tc := range testCases { - u.Path = tc.name - got, err := do("PROPFIND", u.String()) - if err != nil { - t.Errorf("name=%q: PROPFIND: %v", tc.name, err) - continue - } - if got != tc.want { - t.Errorf("name=%q: got %q, want %q", tc.name, got, tc.want) - } - } -} diff --git a/vendor/golang.org/x/net/webdav/xml.go b/vendor/golang.org/x/net/webdav/xml.go deleted file mode 100644 index 790dc81..0000000 --- a/vendor/golang.org/x/net/webdav/xml.go +++ /dev/null @@ -1,519 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -// The XML encoding is covered by Section 14. -// http://www.webdav.org/specs/rfc4918.html#xml.element.definitions - -import ( - "bytes" - "encoding/xml" - "fmt" - "io" - "net/http" - "time" - - // As of https://go-review.googlesource.com/#/c/12772/ which was submitted - // in July 2015, this package uses an internal fork of the standard - // library's encoding/xml package, due to changes in the way namespaces - // were encoded. Such changes were introduced in the Go 1.5 cycle, but were - // rolled back in response to https://github.com/golang/go/issues/11841 - // - // However, this package's exported API, specifically the Property and - // DeadPropsHolder types, need to refer to the standard library's version - // of the xml.Name type, as code that imports this package cannot refer to - // the internal version. - // - // This file therefore imports both the internal and external versions, as - // ixml and xml, and converts between them. - // - // In the long term, this package should use the standard library's version - // only, and the internal fork deleted, once - // https://github.com/golang/go/issues/13400 is resolved. - ixml "golang.org/x/net/webdav/internal/xml" -) - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_lockinfo -type lockInfo struct { - XMLName ixml.Name `xml:"lockinfo"` - Exclusive *struct{} `xml:"lockscope>exclusive"` - Shared *struct{} `xml:"lockscope>shared"` - Write *struct{} `xml:"locktype>write"` - Owner owner `xml:"owner"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_owner -type owner struct { - InnerXML string `xml:",innerxml"` -} - -func readLockInfo(r io.Reader) (li lockInfo, status int, err error) { - c := &countingReader{r: r} - if err = ixml.NewDecoder(c).Decode(&li); err != nil { - if err == io.EOF { - if c.n == 0 { - // An empty body means to refresh the lock. - // http://www.webdav.org/specs/rfc4918.html#refreshing-locks - return lockInfo{}, 0, nil - } - err = errInvalidLockInfo - } - return lockInfo{}, http.StatusBadRequest, err - } - // We only support exclusive (non-shared) write locks. In practice, these are - // the only types of locks that seem to matter. - if li.Exclusive == nil || li.Shared != nil || li.Write == nil { - return lockInfo{}, http.StatusNotImplemented, errUnsupportedLockInfo - } - return li, 0, nil -} - -type countingReader struct { - n int - r io.Reader -} - -func (c *countingReader) Read(p []byte) (int, error) { - n, err := c.r.Read(p) - c.n += n - return n, err -} - -func writeLockInfo(w io.Writer, token string, ld LockDetails) (int, error) { - depth := "infinity" - if ld.ZeroDepth { - depth = "0" - } - timeout := ld.Duration / time.Second - return fmt.Fprintf(w, "\n"+ - "\n"+ - " \n"+ - " \n"+ - " %s\n"+ - " %s\n"+ - " Second-%d\n"+ - " %s\n"+ - " %s\n"+ - "", - depth, ld.OwnerXML, timeout, escape(token), escape(ld.Root), - ) -} - -func escape(s string) string { - for i := 0; i < len(s); i++ { - switch s[i] { - case '"', '&', '\'', '<', '>': - b := bytes.NewBuffer(nil) - ixml.EscapeText(b, []byte(s)) - return b.String() - } - } - return s -} - -// Next returns the next token, if any, in the XML stream of d. -// RFC 4918 requires to ignore comments, processing instructions -// and directives. -// http://www.webdav.org/specs/rfc4918.html#property_values -// http://www.webdav.org/specs/rfc4918.html#xml-extensibility -func next(d *ixml.Decoder) (ixml.Token, error) { - for { - t, err := d.Token() - if err != nil { - return t, err - } - switch t.(type) { - case ixml.Comment, ixml.Directive, ixml.ProcInst: - continue - default: - return t, nil - } - } -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_prop (for propfind) -type propfindProps []xml.Name - -// UnmarshalXML appends the property names enclosed within start to pn. -// -// It returns an error if start does not contain any properties or if -// properties contain values. Character data between properties is ignored. -func (pn *propfindProps) UnmarshalXML(d *ixml.Decoder, start ixml.StartElement) error { - for { - t, err := next(d) - if err != nil { - return err - } - switch t.(type) { - case ixml.EndElement: - if len(*pn) == 0 { - return fmt.Errorf("%s must not be empty", start.Name.Local) - } - return nil - case ixml.StartElement: - name := t.(ixml.StartElement).Name - t, err = next(d) - if err != nil { - return err - } - if _, ok := t.(ixml.EndElement); !ok { - return fmt.Errorf("unexpected token %T", t) - } - *pn = append(*pn, xml.Name(name)) - } - } -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_propfind -type propfind struct { - XMLName ixml.Name `xml:"DAV: propfind"` - Allprop *struct{} `xml:"DAV: allprop"` - Propname *struct{} `xml:"DAV: propname"` - Prop propfindProps `xml:"DAV: prop"` - Include propfindProps `xml:"DAV: include"` -} - -func readPropfind(r io.Reader) (pf propfind, status int, err error) { - c := countingReader{r: r} - if err = ixml.NewDecoder(&c).Decode(&pf); err != nil { - if err == io.EOF { - if c.n == 0 { - // An empty body means to propfind allprop. - // http://www.webdav.org/specs/rfc4918.html#METHOD_PROPFIND - return propfind{Allprop: new(struct{})}, 0, nil - } - err = errInvalidPropfind - } - return propfind{}, http.StatusBadRequest, err - } - - if pf.Allprop == nil && pf.Include != nil { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - if pf.Allprop != nil && (pf.Prop != nil || pf.Propname != nil) { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - if pf.Prop != nil && pf.Propname != nil { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - if pf.Propname == nil && pf.Allprop == nil && pf.Prop == nil { - return propfind{}, http.StatusBadRequest, errInvalidPropfind - } - return pf, 0, nil -} - -// Property represents a single DAV resource property as defined in RFC 4918. -// See http://www.webdav.org/specs/rfc4918.html#data.model.for.resource.properties -type Property struct { - // XMLName is the fully qualified name that identifies this property. - XMLName xml.Name - - // Lang is an optional xml:lang attribute. - Lang string `xml:"xml:lang,attr,omitempty"` - - // InnerXML contains the XML representation of the property value. - // See http://www.webdav.org/specs/rfc4918.html#property_values - // - // Property values of complex type or mixed-content must have fully - // expanded XML namespaces or be self-contained with according - // XML namespace declarations. They must not rely on any XML - // namespace declarations within the scope of the XML document, - // even including the DAV: namespace. - InnerXML []byte `xml:",innerxml"` -} - -// ixmlProperty is the same as the Property type except it holds an ixml.Name -// instead of an xml.Name. -type ixmlProperty struct { - XMLName ixml.Name - Lang string `xml:"xml:lang,attr,omitempty"` - InnerXML []byte `xml:",innerxml"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_error -// See multistatusWriter for the "D:" namespace prefix. -type xmlError struct { - XMLName ixml.Name `xml:"D:error"` - InnerXML []byte `xml:",innerxml"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_propstat -// See multistatusWriter for the "D:" namespace prefix. -type propstat struct { - Prop []Property `xml:"D:prop>_ignored_"` - Status string `xml:"D:status"` - Error *xmlError `xml:"D:error"` - ResponseDescription string `xml:"D:responsedescription,omitempty"` -} - -// ixmlPropstat is the same as the propstat type except it holds an ixml.Name -// instead of an xml.Name. -type ixmlPropstat struct { - Prop []ixmlProperty `xml:"D:prop>_ignored_"` - Status string `xml:"D:status"` - Error *xmlError `xml:"D:error"` - ResponseDescription string `xml:"D:responsedescription,omitempty"` -} - -// MarshalXML prepends the "D:" namespace prefix on properties in the DAV: namespace -// before encoding. See multistatusWriter. -func (ps propstat) MarshalXML(e *ixml.Encoder, start ixml.StartElement) error { - // Convert from a propstat to an ixmlPropstat. - ixmlPs := ixmlPropstat{ - Prop: make([]ixmlProperty, len(ps.Prop)), - Status: ps.Status, - Error: ps.Error, - ResponseDescription: ps.ResponseDescription, - } - for k, prop := range ps.Prop { - ixmlPs.Prop[k] = ixmlProperty{ - XMLName: ixml.Name(prop.XMLName), - Lang: prop.Lang, - InnerXML: prop.InnerXML, - } - } - - for k, prop := range ixmlPs.Prop { - if prop.XMLName.Space == "DAV:" { - prop.XMLName = ixml.Name{Space: "", Local: "D:" + prop.XMLName.Local} - ixmlPs.Prop[k] = prop - } - } - // Distinct type to avoid infinite recursion of MarshalXML. - type newpropstat ixmlPropstat - return e.EncodeElement(newpropstat(ixmlPs), start) -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_response -// See multistatusWriter for the "D:" namespace prefix. -type response struct { - XMLName ixml.Name `xml:"D:response"` - Href []string `xml:"D:href"` - Propstat []propstat `xml:"D:propstat"` - Status string `xml:"D:status,omitempty"` - Error *xmlError `xml:"D:error"` - ResponseDescription string `xml:"D:responsedescription,omitempty"` -} - -// MultistatusWriter marshals one or more Responses into a XML -// multistatus response. -// See http://www.webdav.org/specs/rfc4918.html#ELEMENT_multistatus -// TODO(rsto, mpl): As a workaround, the "D:" namespace prefix, defined as -// "DAV:" on this element, is prepended on the nested response, as well as on all -// its nested elements. All property names in the DAV: namespace are prefixed as -// well. This is because some versions of Mini-Redirector (on windows 7) ignore -// elements with a default namespace (no prefixed namespace). A less intrusive fix -// should be possible after golang.org/cl/11074. See https://golang.org/issue/11177 -type multistatusWriter struct { - // ResponseDescription contains the optional responsedescription - // of the multistatus XML element. Only the latest content before - // close will be emitted. Empty response descriptions are not - // written. - responseDescription string - - w http.ResponseWriter - enc *ixml.Encoder -} - -// Write validates and emits a DAV response as part of a multistatus response -// element. -// -// It sets the HTTP status code of its underlying http.ResponseWriter to 207 -// (Multi-Status) and populates the Content-Type header. If r is the -// first, valid response to be written, Write prepends the XML representation -// of r with a multistatus tag. Callers must call close after the last response -// has been written. -func (w *multistatusWriter) write(r *response) error { - switch len(r.Href) { - case 0: - return errInvalidResponse - case 1: - if len(r.Propstat) > 0 != (r.Status == "") { - return errInvalidResponse - } - default: - if len(r.Propstat) > 0 || r.Status == "" { - return errInvalidResponse - } - } - err := w.writeHeader() - if err != nil { - return err - } - return w.enc.Encode(r) -} - -// writeHeader writes a XML multistatus start element on w's underlying -// http.ResponseWriter and returns the result of the write operation. -// After the first write attempt, writeHeader becomes a no-op. -func (w *multistatusWriter) writeHeader() error { - if w.enc != nil { - return nil - } - w.w.Header().Add("Content-Type", "text/xml; charset=utf-8") - w.w.WriteHeader(StatusMulti) - _, err := fmt.Fprintf(w.w, ``) - if err != nil { - return err - } - w.enc = ixml.NewEncoder(w.w) - return w.enc.EncodeToken(ixml.StartElement{ - Name: ixml.Name{ - Space: "DAV:", - Local: "multistatus", - }, - Attr: []ixml.Attr{{ - Name: ixml.Name{Space: "xmlns", Local: "D"}, - Value: "DAV:", - }}, - }) -} - -// Close completes the marshalling of the multistatus response. It returns -// an error if the multistatus response could not be completed. If both the -// return value and field enc of w are nil, then no multistatus response has -// been written. -func (w *multistatusWriter) close() error { - if w.enc == nil { - return nil - } - var end []ixml.Token - if w.responseDescription != "" { - name := ixml.Name{Space: "DAV:", Local: "responsedescription"} - end = append(end, - ixml.StartElement{Name: name}, - ixml.CharData(w.responseDescription), - ixml.EndElement{Name: name}, - ) - } - end = append(end, ixml.EndElement{ - Name: ixml.Name{Space: "DAV:", Local: "multistatus"}, - }) - for _, t := range end { - err := w.enc.EncodeToken(t) - if err != nil { - return err - } - } - return w.enc.Flush() -} - -var xmlLangName = ixml.Name{Space: "http://www.w3.org/XML/1998/namespace", Local: "lang"} - -func xmlLang(s ixml.StartElement, d string) string { - for _, attr := range s.Attr { - if attr.Name == xmlLangName { - return attr.Value - } - } - return d -} - -type xmlValue []byte - -func (v *xmlValue) UnmarshalXML(d *ixml.Decoder, start ixml.StartElement) error { - // The XML value of a property can be arbitrary, mixed-content XML. - // To make sure that the unmarshalled value contains all required - // namespaces, we encode all the property value XML tokens into a - // buffer. This forces the encoder to redeclare any used namespaces. - var b bytes.Buffer - e := ixml.NewEncoder(&b) - for { - t, err := next(d) - if err != nil { - return err - } - if e, ok := t.(ixml.EndElement); ok && e.Name == start.Name { - break - } - if err = e.EncodeToken(t); err != nil { - return err - } - } - err := e.Flush() - if err != nil { - return err - } - *v = b.Bytes() - return nil -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_prop (for proppatch) -type proppatchProps []Property - -// UnmarshalXML appends the property names and values enclosed within start -// to ps. -// -// An xml:lang attribute that is defined either on the DAV:prop or property -// name XML element is propagated to the property's Lang field. -// -// UnmarshalXML returns an error if start does not contain any properties or if -// property values contain syntactically incorrect XML. -func (ps *proppatchProps) UnmarshalXML(d *ixml.Decoder, start ixml.StartElement) error { - lang := xmlLang(start, "") - for { - t, err := next(d) - if err != nil { - return err - } - switch elem := t.(type) { - case ixml.EndElement: - if len(*ps) == 0 { - return fmt.Errorf("%s must not be empty", start.Name.Local) - } - return nil - case ixml.StartElement: - p := Property{ - XMLName: xml.Name(t.(ixml.StartElement).Name), - Lang: xmlLang(t.(ixml.StartElement), lang), - } - err = d.DecodeElement(((*xmlValue)(&p.InnerXML)), &elem) - if err != nil { - return err - } - *ps = append(*ps, p) - } - } -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_set -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_remove -type setRemove struct { - XMLName ixml.Name - Lang string `xml:"xml:lang,attr,omitempty"` - Prop proppatchProps `xml:"DAV: prop"` -} - -// http://www.webdav.org/specs/rfc4918.html#ELEMENT_propertyupdate -type propertyupdate struct { - XMLName ixml.Name `xml:"DAV: propertyupdate"` - Lang string `xml:"xml:lang,attr,omitempty"` - SetRemove []setRemove `xml:",any"` -} - -func readProppatch(r io.Reader) (patches []Proppatch, status int, err error) { - var pu propertyupdate - if err = ixml.NewDecoder(r).Decode(&pu); err != nil { - return nil, http.StatusBadRequest, err - } - for _, op := range pu.SetRemove { - remove := false - switch op.XMLName { - case ixml.Name{Space: "DAV:", Local: "set"}: - // No-op. - case ixml.Name{Space: "DAV:", Local: "remove"}: - for _, p := range op.Prop { - if len(p.InnerXML) > 0 { - return nil, http.StatusBadRequest, errInvalidProppatch - } - } - remove = true - default: - return nil, http.StatusBadRequest, errInvalidProppatch - } - patches = append(patches, Proppatch{Remove: remove, Props: op.Prop}) - } - return patches, 0, nil -} diff --git a/vendor/golang.org/x/net/webdav/xml_test.go b/vendor/golang.org/x/net/webdav/xml_test.go deleted file mode 100644 index a3d9e1e..0000000 --- a/vendor/golang.org/x/net/webdav/xml_test.go +++ /dev/null @@ -1,906 +0,0 @@ -// Copyright 2014 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package webdav - -import ( - "bytes" - "encoding/xml" - "fmt" - "io" - "net/http" - "net/http/httptest" - "reflect" - "sort" - "strings" - "testing" - - ixml "golang.org/x/net/webdav/internal/xml" -) - -func TestReadLockInfo(t *testing.T) { - // The "section x.y.z" test cases come from section x.y.z of the spec at - // http://www.webdav.org/specs/rfc4918.html - testCases := []struct { - desc string - input string - wantLI lockInfo - wantStatus int - }{{ - "bad: junk", - "xxx", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: invalid owner XML", - "" + - "\n" + - " \n" + - " \n" + - " \n" + - " no end tag \n" + - " \n" + - "", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: invalid UTF-8", - "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \xff \n" + - " \n" + - "", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: unfinished XML #1", - "" + - "\n" + - " \n" + - " \n", - lockInfo{}, - http.StatusBadRequest, - }, { - "bad: unfinished XML #2", - "" + - "\n" + - " \n" + - " \n" + - " \n", - lockInfo{}, - http.StatusBadRequest, - }, { - "good: empty", - "", - lockInfo{}, - 0, - }, { - "good: plain-text owner", - "" + - "\n" + - " \n" + - " \n" + - " gopher\n" + - "", - lockInfo{ - XMLName: ixml.Name{Space: "DAV:", Local: "lockinfo"}, - Exclusive: new(struct{}), - Write: new(struct{}), - Owner: owner{ - InnerXML: "gopher", - }, - }, - 0, - }, { - "section 9.10.7", - "" + - "\n" + - " \n" + - " \n" + - " \n" + - " http://example.org/~ejw/contact.html\n" + - " \n" + - "", - lockInfo{ - XMLName: ixml.Name{Space: "DAV:", Local: "lockinfo"}, - Exclusive: new(struct{}), - Write: new(struct{}), - Owner: owner{ - InnerXML: "\n http://example.org/~ejw/contact.html\n ", - }, - }, - 0, - }} - - for _, tc := range testCases { - li, status, err := readLockInfo(strings.NewReader(tc.input)) - if tc.wantStatus != 0 { - if err == nil { - t.Errorf("%s: got nil error, want non-nil", tc.desc) - continue - } - } else if err != nil { - t.Errorf("%s: %v", tc.desc, err) - continue - } - if !reflect.DeepEqual(li, tc.wantLI) || status != tc.wantStatus { - t.Errorf("%s:\ngot lockInfo=%v, status=%v\nwant lockInfo=%v, status=%v", - tc.desc, li, status, tc.wantLI, tc.wantStatus) - continue - } - } -} - -func TestReadPropfind(t *testing.T) { - testCases := []struct { - desc string - input string - wantPF propfind - wantStatus int - }{{ - desc: "propfind: propname", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Propname: new(struct{}), - }, - }, { - desc: "propfind: empty body means allprop", - input: "", - wantPF: propfind{ - Allprop: new(struct{}), - }, - }, { - desc: "propfind: allprop", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Allprop: new(struct{}), - }, - }, { - desc: "propfind: allprop followed by include", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Allprop: new(struct{}), - Include: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: include followed by allprop", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Allprop: new(struct{}), - Include: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propfind", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: prop with ignored comments", - input: "" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propfind with ignored whitespace", - input: "" + - "\n" + - " \n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propfind with ignored mixed-content", - input: "" + - "\n" + - " foobar\n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Prop: propfindProps{xml.Name{Space: "DAV:", Local: "displayname"}}, - }, - }, { - desc: "propfind: propname with ignored element (section A.4)", - input: "" + - "\n" + - " \n" + - " *boss*\n" + - "", - wantPF: propfind{ - XMLName: ixml.Name{Space: "DAV:", Local: "propfind"}, - Propname: new(struct{}), - }, - }, { - desc: "propfind: bad: junk", - input: "xxx", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: propname and allprop (section A.3)", - input: "" + - "\n" + - " " + - " " + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: propname and prop", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: allprop and prop", - input: "" + - "\n" + - " \n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: empty propfind with ignored element (section A.4)", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: empty prop", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: prop with just chardata", - input: "" + - "\n" + - " foo\n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: interrupted prop", - input: "" + - "\n" + - " \n", - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: malformed end element prop", - input: "" + - "\n" + - " \n", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: property with chardata value", - input: "" + - "\n" + - " bar\n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: property with whitespace value", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }, { - desc: "propfind: bad: include without allprop", - input: "" + - "\n" + - " \n" + - "", - wantStatus: http.StatusBadRequest, - }} - - for _, tc := range testCases { - pf, status, err := readPropfind(strings.NewReader(tc.input)) - if tc.wantStatus != 0 { - if err == nil { - t.Errorf("%s: got nil error, want non-nil", tc.desc) - continue - } - } else if err != nil { - t.Errorf("%s: %v", tc.desc, err) - continue - } - if !reflect.DeepEqual(pf, tc.wantPF) || status != tc.wantStatus { - t.Errorf("%s:\ngot propfind=%v, status=%v\nwant propfind=%v, status=%v", - tc.desc, pf, status, tc.wantPF, tc.wantStatus) - continue - } - } -} - -func TestMultistatusWriter(t *testing.T) { - ///The "section x.y.z" test cases come from section x.y.z of the spec at - // http://www.webdav.org/specs/rfc4918.html - testCases := []struct { - desc string - responses []response - respdesc string - writeHeader bool - wantXML string - wantCode int - wantErr error - }{{ - desc: "section 9.2.2 (failed dependency)", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://ns.example.com/", - Local: "Authors", - }, - }}, - Status: "HTTP/1.1 424 Failed Dependency", - }, { - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://ns.example.com/", - Local: "Copyright-Owner", - }, - }}, - Status: "HTTP/1.1 409 Conflict", - }}, - ResponseDescription: "Copyright Owner cannot be deleted or altered.", - }}, - wantXML: `` + - `` + - `` + - ` ` + - ` http://example.com/foo` + - ` ` + - ` ` + - ` ` + - ` ` + - ` HTTP/1.1 424 Failed Dependency` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ` HTTP/1.1 409 Conflict` + - ` ` + - ` Copyright Owner cannot be deleted or altered.` + - `` + - ``, - wantCode: StatusMulti, - }, { - desc: "section 9.6.2 (lock-token-submitted)", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Status: "HTTP/1.1 423 Locked", - Error: &xmlError{ - InnerXML: []byte(``), - }, - }}, - wantXML: `` + - `` + - `` + - ` ` + - ` http://example.com/foo` + - ` HTTP/1.1 423 Locked` + - ` ` + - ` ` + - ``, - wantCode: StatusMulti, - }, { - desc: "section 9.1.3", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "bigbox"}, - InnerXML: []byte(`` + - `` + - `Box type A` + - ``), - }, { - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "author"}, - InnerXML: []byte(`` + - `` + - `J.J. Johnson` + - ``), - }}, - Status: "HTTP/1.1 200 OK", - }, { - Prop: []Property{{ - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "DingALing"}, - }, { - XMLName: xml.Name{Space: "http://ns.example.com/boxschema/", Local: "Random"}, - }}, - Status: "HTTP/1.1 403 Forbidden", - ResponseDescription: "The user does not have access to the DingALing property.", - }}, - }}, - respdesc: "There has been an access violation error.", - wantXML: `` + - `` + - `` + - ` ` + - ` http://example.com/foo` + - ` ` + - ` ` + - ` Box type A` + - ` J.J. Johnson` + - ` ` + - ` HTTP/1.1 200 OK` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ` HTTP/1.1 403 Forbidden` + - ` The user does not have access to the DingALing property.` + - ` ` + - ` ` + - ` There has been an access violation error.` + - ``, - wantCode: StatusMulti, - }, { - desc: "no response written", - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "no response written (with description)", - respdesc: "too bad", - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "empty multistatus with header", - writeHeader: true, - wantXML: ``, - wantCode: StatusMulti, - }, { - desc: "bad: no href", - responses: []response{{ - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://example.com/", - Local: "foo", - }, - }}, - Status: "HTTP/1.1 200 OK", - }}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: multiple hrefs and no status", - responses: []response{{ - Href: []string{"http://example.com/foo", "http://example.com/bar"}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: one href and no propstat", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: status with one href and propstat", - responses: []response{{ - Href: []string{"http://example.com/foo"}, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://example.com/", - Local: "foo", - }, - }}, - Status: "HTTP/1.1 200 OK", - }}, - Status: "HTTP/1.1 200 OK", - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }, { - desc: "bad: multiple hrefs and propstat", - responses: []response{{ - Href: []string{ - "http://example.com/foo", - "http://example.com/bar", - }, - Propstat: []propstat{{ - Prop: []Property{{ - XMLName: xml.Name{ - Space: "http://example.com/", - Local: "foo", - }, - }}, - Status: "HTTP/1.1 200 OK", - }}, - }}, - wantErr: errInvalidResponse, - // default of http.responseWriter - wantCode: http.StatusOK, - }} - - n := xmlNormalizer{omitWhitespace: true} -loop: - for _, tc := range testCases { - rec := httptest.NewRecorder() - w := multistatusWriter{w: rec, responseDescription: tc.respdesc} - if tc.writeHeader { - if err := w.writeHeader(); err != nil { - t.Errorf("%s: got writeHeader error %v, want nil", tc.desc, err) - continue - } - } - for _, r := range tc.responses { - if err := w.write(&r); err != nil { - if err != tc.wantErr { - t.Errorf("%s: got write error %v, want %v", - tc.desc, err, tc.wantErr) - } - continue loop - } - } - if err := w.close(); err != tc.wantErr { - t.Errorf("%s: got close error %v, want %v", - tc.desc, err, tc.wantErr) - continue - } - if rec.Code != tc.wantCode { - t.Errorf("%s: got HTTP status code %d, want %d\n", - tc.desc, rec.Code, tc.wantCode) - continue - } - gotXML := rec.Body.String() - eq, err := n.equalXML(strings.NewReader(gotXML), strings.NewReader(tc.wantXML)) - if err != nil { - t.Errorf("%s: equalXML: %v", tc.desc, err) - continue - } - if !eq { - t.Errorf("%s: XML body\ngot %s\nwant %s", tc.desc, gotXML, tc.wantXML) - } - } -} - -func TestReadProppatch(t *testing.T) { - ppStr := func(pps []Proppatch) string { - var outer []string - for _, pp := range pps { - var inner []string - for _, p := range pp.Props { - inner = append(inner, fmt.Sprintf("{XMLName: %q, Lang: %q, InnerXML: %q}", - p.XMLName, p.Lang, p.InnerXML)) - } - outer = append(outer, fmt.Sprintf("{Remove: %t, Props: [%s]}", - pp.Remove, strings.Join(inner, ", "))) - } - return "[" + strings.Join(outer, ", ") + "]" - } - - testCases := []struct { - desc string - input string - wantPP []Proppatch - wantStatus int - }{{ - desc: "proppatch: section 9.2 (with simple property value)", - input: `` + - `` + - `` + - ` ` + - ` somevalue` + - ` ` + - ` ` + - ` ` + - ` ` + - ``, - wantPP: []Proppatch{{ - Props: []Property{{ - xml.Name{Space: "http://ns.example.com/z/", Local: "Authors"}, - "", - []byte(`somevalue`), - }}, - }, { - Remove: true, - Props: []Property{{ - xml.Name{Space: "http://ns.example.com/z/", Local: "Copyright-Owner"}, - "", - nil, - }}, - }}, - }, { - desc: "proppatch: lang attribute on prop", - input: `` + - `` + - `` + - ` ` + - ` ` + - ` ` + - ` ` + - ` ` + - ``, - wantPP: []Proppatch{{ - Props: []Property{{ - xml.Name{Space: "http://example.com/ns", Local: "foo"}, - "en", - nil, - }}, - }}, - }, { - desc: "bad: remove with value", - input: `` + - `` + - `` + - ` ` + - ` ` + - ` ` + - ` Jim Whitehead` + - ` ` + - ` ` + - ` ` + - ``, - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: empty propertyupdate", - input: `` + - `` + - ``, - wantStatus: http.StatusBadRequest, - }, { - desc: "bad: empty prop", - input: `` + - `` + - `` + - ` ` + - ` ` + - ` ` + - ``, - wantStatus: http.StatusBadRequest, - }} - - for _, tc := range testCases { - pp, status, err := readProppatch(strings.NewReader(tc.input)) - if tc.wantStatus != 0 { - if err == nil { - t.Errorf("%s: got nil error, want non-nil", tc.desc) - continue - } - } else if err != nil { - t.Errorf("%s: %v", tc.desc, err) - continue - } - if status != tc.wantStatus { - t.Errorf("%s: got status %d, want %d", tc.desc, status, tc.wantStatus) - continue - } - if !reflect.DeepEqual(pp, tc.wantPP) || status != tc.wantStatus { - t.Errorf("%s: proppatch\ngot %v\nwant %v", tc.desc, ppStr(pp), ppStr(tc.wantPP)) - } - } -} - -func TestUnmarshalXMLValue(t *testing.T) { - testCases := []struct { - desc string - input string - wantVal string - }{{ - desc: "simple char data", - input: "foo", - wantVal: "foo", - }, { - desc: "empty element", - input: "", - wantVal: "", - }, { - desc: "preserve namespace", - input: ``, - wantVal: ``, - }, { - desc: "preserve root element namespace", - input: ``, - wantVal: ``, - }, { - desc: "preserve whitespace", - input: " \t ", - wantVal: " \t ", - }, { - desc: "preserve mixed content", - input: ` a `, - wantVal: ` a `, - }, { - desc: "section 9.2", - input: `` + - `` + - ` Jim Whitehead` + - ` Roy Fielding` + - ``, - wantVal: `` + - ` Jim Whitehead` + - ` Roy Fielding`, - }, { - desc: "section 4.3.1 (mixed content)", - input: `` + - `` + - ` Jane Doe` + - ` ` + - ` mailto:jane.doe@example.com` + - ` http://www.example.com` + - ` ` + - ` Jane has been working way too long on the` + - ` long-awaited revision of ]]>.` + - ` ` + - ``, - wantVal: `` + - ` Jane Doe` + - ` ` + - ` mailto:jane.doe@example.com` + - ` http://www.example.com` + - ` ` + - ` Jane has been working way too long on the` + - ` long-awaited revision of <RFC2518>.` + - ` `, - }} - - var n xmlNormalizer - for _, tc := range testCases { - d := ixml.NewDecoder(strings.NewReader(tc.input)) - var v xmlValue - if err := d.Decode(&v); err != nil { - t.Errorf("%s: got error %v, want nil", tc.desc, err) - continue - } - eq, err := n.equalXML(bytes.NewReader(v), strings.NewReader(tc.wantVal)) - if err != nil { - t.Errorf("%s: equalXML: %v", tc.desc, err) - continue - } - if !eq { - t.Errorf("%s:\ngot %s\nwant %s", tc.desc, string(v), tc.wantVal) - } - } -} - -// xmlNormalizer normalizes XML. -type xmlNormalizer struct { - // omitWhitespace instructs to ignore whitespace between element tags. - omitWhitespace bool - // omitComments instructs to ignore XML comments. - omitComments bool -} - -// normalize writes the normalized XML content of r to w. It applies the -// following rules -// -// * Rename namespace prefixes according to an internal heuristic. -// * Remove unnecessary namespace declarations. -// * Sort attributes in XML start elements in lexical order of their -// fully qualified name. -// * Remove XML directives and processing instructions. -// * Remove CDATA between XML tags that only contains whitespace, if -// instructed to do so. -// * Remove comments, if instructed to do so. -// -func (n *xmlNormalizer) normalize(w io.Writer, r io.Reader) error { - d := ixml.NewDecoder(r) - e := ixml.NewEncoder(w) - for { - t, err := d.Token() - if err != nil { - if t == nil && err == io.EOF { - break - } - return err - } - switch val := t.(type) { - case ixml.Directive, ixml.ProcInst: - continue - case ixml.Comment: - if n.omitComments { - continue - } - case ixml.CharData: - if n.omitWhitespace && len(bytes.TrimSpace(val)) == 0 { - continue - } - case ixml.StartElement: - start, _ := ixml.CopyToken(val).(ixml.StartElement) - attr := start.Attr[:0] - for _, a := range start.Attr { - if a.Name.Space == "xmlns" || a.Name.Local == "xmlns" { - continue - } - attr = append(attr, a) - } - sort.Sort(byName(attr)) - start.Attr = attr - t = start - } - err = e.EncodeToken(t) - if err != nil { - return err - } - } - return e.Flush() -} - -// equalXML tests for equality of the normalized XML contents of a and b. -func (n *xmlNormalizer) equalXML(a, b io.Reader) (bool, error) { - var buf bytes.Buffer - if err := n.normalize(&buf, a); err != nil { - return false, err - } - normA := buf.String() - buf.Reset() - if err := n.normalize(&buf, b); err != nil { - return false, err - } - normB := buf.String() - return normA == normB, nil -} - -type byName []ixml.Attr - -func (a byName) Len() int { return len(a) } -func (a byName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a byName) Less(i, j int) bool { - if a[i].Name.Space != a[j].Name.Space { - return a[i].Name.Space < a[j].Name.Space - } - return a[i].Name.Local < a[j].Name.Local -} diff --git a/vendor/golang.org/x/net/websocket/client.go b/vendor/golang.org/x/net/websocket/client.go deleted file mode 100644 index 20d1e1e..0000000 --- a/vendor/golang.org/x/net/websocket/client.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "bufio" - "crypto/tls" - "io" - "net" - "net/http" - "net/url" -) - -// DialError is an error that occurs while dialling a websocket server. -type DialError struct { - *Config - Err error -} - -func (e *DialError) Error() string { - return "websocket.Dial " + e.Config.Location.String() + ": " + e.Err.Error() -} - -// NewConfig creates a new WebSocket config for client connection. -func NewConfig(server, origin string) (config *Config, err error) { - config = new(Config) - config.Version = ProtocolVersionHybi13 - config.Location, err = url.ParseRequestURI(server) - if err != nil { - return - } - config.Origin, err = url.ParseRequestURI(origin) - if err != nil { - return - } - config.Header = http.Header(make(map[string][]string)) - return -} - -// NewClient creates a new WebSocket client connection over rwc. -func NewClient(config *Config, rwc io.ReadWriteCloser) (ws *Conn, err error) { - br := bufio.NewReader(rwc) - bw := bufio.NewWriter(rwc) - err = hybiClientHandshake(config, br, bw) - if err != nil { - return - } - buf := bufio.NewReadWriter(br, bw) - ws = newHybiClientConn(config, buf, rwc) - return -} - -// Dial opens a new client connection to a WebSocket. -func Dial(url_, protocol, origin string) (ws *Conn, err error) { - config, err := NewConfig(url_, origin) - if err != nil { - return nil, err - } - if protocol != "" { - config.Protocol = []string{protocol} - } - return DialConfig(config) -} - -var portMap = map[string]string{ - "ws": "80", - "wss": "443", -} - -func parseAuthority(location *url.URL) string { - if _, ok := portMap[location.Scheme]; ok { - if _, _, err := net.SplitHostPort(location.Host); err != nil { - return net.JoinHostPort(location.Host, portMap[location.Scheme]) - } - } - return location.Host -} - -// DialConfig opens a new client connection to a WebSocket with a config. -func DialConfig(config *Config) (ws *Conn, err error) { - var client net.Conn - if config.Location == nil { - return nil, &DialError{config, ErrBadWebSocketLocation} - } - if config.Origin == nil { - return nil, &DialError{config, ErrBadWebSocketOrigin} - } - switch config.Location.Scheme { - case "ws": - client, err = net.Dial("tcp", parseAuthority(config.Location)) - - case "wss": - client, err = tls.Dial("tcp", parseAuthority(config.Location), config.TlsConfig) - - default: - err = ErrBadScheme - } - if err != nil { - goto Error - } - - ws, err = NewClient(config, client) - if err != nil { - client.Close() - goto Error - } - return - -Error: - return nil, &DialError{config, err} -} diff --git a/vendor/golang.org/x/net/websocket/exampledial_test.go b/vendor/golang.org/x/net/websocket/exampledial_test.go deleted file mode 100644 index 72bb9d4..0000000 --- a/vendor/golang.org/x/net/websocket/exampledial_test.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket_test - -import ( - "fmt" - "log" - - "golang.org/x/net/websocket" -) - -// This example demonstrates a trivial client. -func ExampleDial() { - origin := "http://localhost/" - url := "ws://localhost:12345/ws" - ws, err := websocket.Dial(url, "", origin) - if err != nil { - log.Fatal(err) - } - if _, err := ws.Write([]byte("hello, world!\n")); err != nil { - log.Fatal(err) - } - var msg = make([]byte, 512) - var n int - if n, err = ws.Read(msg); err != nil { - log.Fatal(err) - } - fmt.Printf("Received: %s.\n", msg[:n]) -} diff --git a/vendor/golang.org/x/net/websocket/examplehandler_test.go b/vendor/golang.org/x/net/websocket/examplehandler_test.go deleted file mode 100644 index f22a98f..0000000 --- a/vendor/golang.org/x/net/websocket/examplehandler_test.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket_test - -import ( - "io" - "net/http" - - "golang.org/x/net/websocket" -) - -// Echo the data received on the WebSocket. -func EchoServer(ws *websocket.Conn) { - io.Copy(ws, ws) -} - -// This example demonstrates a trivial echo server. -func ExampleHandler() { - http.Handle("/echo", websocket.Handler(EchoServer)) - err := http.ListenAndServe(":12345", nil) - if err != nil { - panic("ListenAndServe: " + err.Error()) - } -} diff --git a/vendor/golang.org/x/net/websocket/hybi.go b/vendor/golang.org/x/net/websocket/hybi.go deleted file mode 100644 index 8cffdd1..0000000 --- a/vendor/golang.org/x/net/websocket/hybi.go +++ /dev/null @@ -1,583 +0,0 @@ -// Copyright 2011 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 websocket - -// This file implements a protocol of hybi draft. -// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 - -import ( - "bufio" - "bytes" - "crypto/rand" - "crypto/sha1" - "encoding/base64" - "encoding/binary" - "fmt" - "io" - "io/ioutil" - "net/http" - "net/url" - "strings" -) - -const ( - websocketGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" - - closeStatusNormal = 1000 - closeStatusGoingAway = 1001 - closeStatusProtocolError = 1002 - closeStatusUnsupportedData = 1003 - closeStatusFrameTooLarge = 1004 - closeStatusNoStatusRcvd = 1005 - closeStatusAbnormalClosure = 1006 - closeStatusBadMessageData = 1007 - closeStatusPolicyViolation = 1008 - closeStatusTooBigData = 1009 - closeStatusExtensionMismatch = 1010 - - maxControlFramePayloadLength = 125 -) - -var ( - ErrBadMaskingKey = &ProtocolError{"bad masking key"} - ErrBadPongMessage = &ProtocolError{"bad pong message"} - ErrBadClosingStatus = &ProtocolError{"bad closing status"} - ErrUnsupportedExtensions = &ProtocolError{"unsupported extensions"} - ErrNotImplemented = &ProtocolError{"not implemented"} - - handshakeHeader = map[string]bool{ - "Host": true, - "Upgrade": true, - "Connection": true, - "Sec-Websocket-Key": true, - "Sec-Websocket-Origin": true, - "Sec-Websocket-Version": true, - "Sec-Websocket-Protocol": true, - "Sec-Websocket-Accept": true, - } -) - -// A hybiFrameHeader is a frame header as defined in hybi draft. -type hybiFrameHeader struct { - Fin bool - Rsv [3]bool - OpCode byte - Length int64 - MaskingKey []byte - - data *bytes.Buffer -} - -// A hybiFrameReader is a reader for hybi frame. -type hybiFrameReader struct { - reader io.Reader - - header hybiFrameHeader - pos int64 - length int -} - -func (frame *hybiFrameReader) Read(msg []byte) (n int, err error) { - n, err = frame.reader.Read(msg) - if frame.header.MaskingKey != nil { - for i := 0; i < n; i++ { - msg[i] = msg[i] ^ frame.header.MaskingKey[frame.pos%4] - frame.pos++ - } - } - return n, err -} - -func (frame *hybiFrameReader) PayloadType() byte { return frame.header.OpCode } - -func (frame *hybiFrameReader) HeaderReader() io.Reader { - if frame.header.data == nil { - return nil - } - if frame.header.data.Len() == 0 { - return nil - } - return frame.header.data -} - -func (frame *hybiFrameReader) TrailerReader() io.Reader { return nil } - -func (frame *hybiFrameReader) Len() (n int) { return frame.length } - -// A hybiFrameReaderFactory creates new frame reader based on its frame type. -type hybiFrameReaderFactory struct { - *bufio.Reader -} - -// NewFrameReader reads a frame header from the connection, and creates new reader for the frame. -// See Section 5.2 Base Framing protocol for detail. -// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17#section-5.2 -func (buf hybiFrameReaderFactory) NewFrameReader() (frame frameReader, err error) { - hybiFrame := new(hybiFrameReader) - frame = hybiFrame - var header []byte - var b byte - // First byte. FIN/RSV1/RSV2/RSV3/OpCode(4bits) - b, err = buf.ReadByte() - if err != nil { - return - } - header = append(header, b) - hybiFrame.header.Fin = ((header[0] >> 7) & 1) != 0 - for i := 0; i < 3; i++ { - j := uint(6 - i) - hybiFrame.header.Rsv[i] = ((header[0] >> j) & 1) != 0 - } - hybiFrame.header.OpCode = header[0] & 0x0f - - // Second byte. Mask/Payload len(7bits) - b, err = buf.ReadByte() - if err != nil { - return - } - header = append(header, b) - mask := (b & 0x80) != 0 - b &= 0x7f - lengthFields := 0 - switch { - case b <= 125: // Payload length 7bits. - hybiFrame.header.Length = int64(b) - case b == 126: // Payload length 7+16bits - lengthFields = 2 - case b == 127: // Payload length 7+64bits - lengthFields = 8 - } - for i := 0; i < lengthFields; i++ { - b, err = buf.ReadByte() - if err != nil { - return - } - if lengthFields == 8 && i == 0 { // MSB must be zero when 7+64 bits - b &= 0x7f - } - header = append(header, b) - hybiFrame.header.Length = hybiFrame.header.Length*256 + int64(b) - } - if mask { - // Masking key. 4 bytes. - for i := 0; i < 4; i++ { - b, err = buf.ReadByte() - if err != nil { - return - } - header = append(header, b) - hybiFrame.header.MaskingKey = append(hybiFrame.header.MaskingKey, b) - } - } - hybiFrame.reader = io.LimitReader(buf.Reader, hybiFrame.header.Length) - hybiFrame.header.data = bytes.NewBuffer(header) - hybiFrame.length = len(header) + int(hybiFrame.header.Length) - return -} - -// A HybiFrameWriter is a writer for hybi frame. -type hybiFrameWriter struct { - writer *bufio.Writer - - header *hybiFrameHeader -} - -func (frame *hybiFrameWriter) Write(msg []byte) (n int, err error) { - var header []byte - var b byte - if frame.header.Fin { - b |= 0x80 - } - for i := 0; i < 3; i++ { - if frame.header.Rsv[i] { - j := uint(6 - i) - b |= 1 << j - } - } - b |= frame.header.OpCode - header = append(header, b) - if frame.header.MaskingKey != nil { - b = 0x80 - } else { - b = 0 - } - lengthFields := 0 - length := len(msg) - switch { - case length <= 125: - b |= byte(length) - case length < 65536: - b |= 126 - lengthFields = 2 - default: - b |= 127 - lengthFields = 8 - } - header = append(header, b) - for i := 0; i < lengthFields; i++ { - j := uint((lengthFields - i - 1) * 8) - b = byte((length >> j) & 0xff) - header = append(header, b) - } - if frame.header.MaskingKey != nil { - if len(frame.header.MaskingKey) != 4 { - return 0, ErrBadMaskingKey - } - header = append(header, frame.header.MaskingKey...) - frame.writer.Write(header) - data := make([]byte, length) - for i := range data { - data[i] = msg[i] ^ frame.header.MaskingKey[i%4] - } - frame.writer.Write(data) - err = frame.writer.Flush() - return length, err - } - frame.writer.Write(header) - frame.writer.Write(msg) - err = frame.writer.Flush() - return length, err -} - -func (frame *hybiFrameWriter) Close() error { return nil } - -type hybiFrameWriterFactory struct { - *bufio.Writer - needMaskingKey bool -} - -func (buf hybiFrameWriterFactory) NewFrameWriter(payloadType byte) (frame frameWriter, err error) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: payloadType} - if buf.needMaskingKey { - frameHeader.MaskingKey, err = generateMaskingKey() - if err != nil { - return nil, err - } - } - return &hybiFrameWriter{writer: buf.Writer, header: frameHeader}, nil -} - -type hybiFrameHandler struct { - conn *Conn - payloadType byte -} - -func (handler *hybiFrameHandler) HandleFrame(frame frameReader) (frameReader, error) { - if handler.conn.IsServerConn() { - // The client MUST mask all frames sent to the server. - if frame.(*hybiFrameReader).header.MaskingKey == nil { - handler.WriteClose(closeStatusProtocolError) - return nil, io.EOF - } - } else { - // The server MUST NOT mask all frames. - if frame.(*hybiFrameReader).header.MaskingKey != nil { - handler.WriteClose(closeStatusProtocolError) - return nil, io.EOF - } - } - if header := frame.HeaderReader(); header != nil { - io.Copy(ioutil.Discard, header) - } - switch frame.PayloadType() { - case ContinuationFrame: - frame.(*hybiFrameReader).header.OpCode = handler.payloadType - case TextFrame, BinaryFrame: - handler.payloadType = frame.PayloadType() - case CloseFrame: - return nil, io.EOF - case PingFrame, PongFrame: - b := make([]byte, maxControlFramePayloadLength) - n, err := io.ReadFull(frame, b) - if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF { - return nil, err - } - io.Copy(ioutil.Discard, frame) - if frame.PayloadType() == PingFrame { - if _, err := handler.WritePong(b[:n]); err != nil { - return nil, err - } - } - return nil, nil - } - return frame, nil -} - -func (handler *hybiFrameHandler) WriteClose(status int) (err error) { - handler.conn.wio.Lock() - defer handler.conn.wio.Unlock() - w, err := handler.conn.frameWriterFactory.NewFrameWriter(CloseFrame) - if err != nil { - return err - } - msg := make([]byte, 2) - binary.BigEndian.PutUint16(msg, uint16(status)) - _, err = w.Write(msg) - w.Close() - return err -} - -func (handler *hybiFrameHandler) WritePong(msg []byte) (n int, err error) { - handler.conn.wio.Lock() - defer handler.conn.wio.Unlock() - w, err := handler.conn.frameWriterFactory.NewFrameWriter(PongFrame) - if err != nil { - return 0, err - } - n, err = w.Write(msg) - w.Close() - return n, err -} - -// newHybiConn creates a new WebSocket connection speaking hybi draft protocol. -func newHybiConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { - if buf == nil { - br := bufio.NewReader(rwc) - bw := bufio.NewWriter(rwc) - buf = bufio.NewReadWriter(br, bw) - } - ws := &Conn{config: config, request: request, buf: buf, rwc: rwc, - frameReaderFactory: hybiFrameReaderFactory{buf.Reader}, - frameWriterFactory: hybiFrameWriterFactory{ - buf.Writer, request == nil}, - PayloadType: TextFrame, - defaultCloseStatus: closeStatusNormal} - ws.frameHandler = &hybiFrameHandler{conn: ws} - return ws -} - -// generateMaskingKey generates a masking key for a frame. -func generateMaskingKey() (maskingKey []byte, err error) { - maskingKey = make([]byte, 4) - if _, err = io.ReadFull(rand.Reader, maskingKey); err != nil { - return - } - return -} - -// generateNonce generates a nonce consisting of a randomly selected 16-byte -// value that has been base64-encoded. -func generateNonce() (nonce []byte) { - key := make([]byte, 16) - if _, err := io.ReadFull(rand.Reader, key); err != nil { - panic(err) - } - nonce = make([]byte, 24) - base64.StdEncoding.Encode(nonce, key) - return -} - -// removeZone removes IPv6 zone identifer from host. -// E.g., "[fe80::1%en0]:8080" to "[fe80::1]:8080" -func removeZone(host string) string { - if !strings.HasPrefix(host, "[") { - return host - } - i := strings.LastIndex(host, "]") - if i < 0 { - return host - } - j := strings.LastIndex(host[:i], "%") - if j < 0 { - return host - } - return host[:j] + host[i:] -} - -// getNonceAccept computes the base64-encoded SHA-1 of the concatenation of -// the nonce ("Sec-WebSocket-Key" value) with the websocket GUID string. -func getNonceAccept(nonce []byte) (expected []byte, err error) { - h := sha1.New() - if _, err = h.Write(nonce); err != nil { - return - } - if _, err = h.Write([]byte(websocketGUID)); err != nil { - return - } - expected = make([]byte, 28) - base64.StdEncoding.Encode(expected, h.Sum(nil)) - return -} - -// Client handshake described in draft-ietf-hybi-thewebsocket-protocol-17 -func hybiClientHandshake(config *Config, br *bufio.Reader, bw *bufio.Writer) (err error) { - bw.WriteString("GET " + config.Location.RequestURI() + " HTTP/1.1\r\n") - - // According to RFC 6874, an HTTP client, proxy, or other - // intermediary must remove any IPv6 zone identifier attached - // to an outgoing URI. - bw.WriteString("Host: " + removeZone(config.Location.Host) + "\r\n") - bw.WriteString("Upgrade: websocket\r\n") - bw.WriteString("Connection: Upgrade\r\n") - nonce := generateNonce() - if config.handshakeData != nil { - nonce = []byte(config.handshakeData["key"]) - } - bw.WriteString("Sec-WebSocket-Key: " + string(nonce) + "\r\n") - bw.WriteString("Origin: " + strings.ToLower(config.Origin.String()) + "\r\n") - - if config.Version != ProtocolVersionHybi13 { - return ErrBadProtocolVersion - } - - bw.WriteString("Sec-WebSocket-Version: " + fmt.Sprintf("%d", config.Version) + "\r\n") - if len(config.Protocol) > 0 { - bw.WriteString("Sec-WebSocket-Protocol: " + strings.Join(config.Protocol, ", ") + "\r\n") - } - // TODO(ukai): send Sec-WebSocket-Extensions. - err = config.Header.WriteSubset(bw, handshakeHeader) - if err != nil { - return err - } - - bw.WriteString("\r\n") - if err = bw.Flush(); err != nil { - return err - } - - resp, err := http.ReadResponse(br, &http.Request{Method: "GET"}) - if err != nil { - return err - } - if resp.StatusCode != 101 { - return ErrBadStatus - } - if strings.ToLower(resp.Header.Get("Upgrade")) != "websocket" || - strings.ToLower(resp.Header.Get("Connection")) != "upgrade" { - return ErrBadUpgrade - } - expectedAccept, err := getNonceAccept(nonce) - if err != nil { - return err - } - if resp.Header.Get("Sec-WebSocket-Accept") != string(expectedAccept) { - return ErrChallengeResponse - } - if resp.Header.Get("Sec-WebSocket-Extensions") != "" { - return ErrUnsupportedExtensions - } - offeredProtocol := resp.Header.Get("Sec-WebSocket-Protocol") - if offeredProtocol != "" { - protocolMatched := false - for i := 0; i < len(config.Protocol); i++ { - if config.Protocol[i] == offeredProtocol { - protocolMatched = true - break - } - } - if !protocolMatched { - return ErrBadWebSocketProtocol - } - config.Protocol = []string{offeredProtocol} - } - - return nil -} - -// newHybiClientConn creates a client WebSocket connection after handshake. -func newHybiClientConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser) *Conn { - return newHybiConn(config, buf, rwc, nil) -} - -// A HybiServerHandshaker performs a server handshake using hybi draft protocol. -type hybiServerHandshaker struct { - *Config - accept []byte -} - -func (c *hybiServerHandshaker) ReadHandshake(buf *bufio.Reader, req *http.Request) (code int, err error) { - c.Version = ProtocolVersionHybi13 - if req.Method != "GET" { - return http.StatusMethodNotAllowed, ErrBadRequestMethod - } - // HTTP version can be safely ignored. - - if strings.ToLower(req.Header.Get("Upgrade")) != "websocket" || - !strings.Contains(strings.ToLower(req.Header.Get("Connection")), "upgrade") { - return http.StatusBadRequest, ErrNotWebSocket - } - - key := req.Header.Get("Sec-Websocket-Key") - if key == "" { - return http.StatusBadRequest, ErrChallengeResponse - } - version := req.Header.Get("Sec-Websocket-Version") - switch version { - case "13": - c.Version = ProtocolVersionHybi13 - default: - return http.StatusBadRequest, ErrBadWebSocketVersion - } - var scheme string - if req.TLS != nil { - scheme = "wss" - } else { - scheme = "ws" - } - c.Location, err = url.ParseRequestURI(scheme + "://" + req.Host + req.URL.RequestURI()) - if err != nil { - return http.StatusBadRequest, err - } - protocol := strings.TrimSpace(req.Header.Get("Sec-Websocket-Protocol")) - if protocol != "" { - protocols := strings.Split(protocol, ",") - for i := 0; i < len(protocols); i++ { - c.Protocol = append(c.Protocol, strings.TrimSpace(protocols[i])) - } - } - c.accept, err = getNonceAccept([]byte(key)) - if err != nil { - return http.StatusInternalServerError, err - } - return http.StatusSwitchingProtocols, nil -} - -// Origin parses the Origin header in req. -// If the Origin header is not set, it returns nil and nil. -func Origin(config *Config, req *http.Request) (*url.URL, error) { - var origin string - switch config.Version { - case ProtocolVersionHybi13: - origin = req.Header.Get("Origin") - } - if origin == "" { - return nil, nil - } - return url.ParseRequestURI(origin) -} - -func (c *hybiServerHandshaker) AcceptHandshake(buf *bufio.Writer) (err error) { - if len(c.Protocol) > 0 { - if len(c.Protocol) != 1 { - // You need choose a Protocol in Handshake func in Server. - return ErrBadWebSocketProtocol - } - } - buf.WriteString("HTTP/1.1 101 Switching Protocols\r\n") - buf.WriteString("Upgrade: websocket\r\n") - buf.WriteString("Connection: Upgrade\r\n") - buf.WriteString("Sec-WebSocket-Accept: " + string(c.accept) + "\r\n") - if len(c.Protocol) > 0 { - buf.WriteString("Sec-WebSocket-Protocol: " + c.Protocol[0] + "\r\n") - } - // TODO(ukai): send Sec-WebSocket-Extensions. - if c.Header != nil { - err := c.Header.WriteSubset(buf, handshakeHeader) - if err != nil { - return err - } - } - buf.WriteString("\r\n") - return buf.Flush() -} - -func (c *hybiServerHandshaker) NewServerConn(buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { - return newHybiServerConn(c.Config, buf, rwc, request) -} - -// newHybiServerConn returns a new WebSocket connection speaking hybi draft protocol. -func newHybiServerConn(config *Config, buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) *Conn { - return newHybiConn(config, buf, rwc, request) -} diff --git a/vendor/golang.org/x/net/websocket/hybi_test.go b/vendor/golang.org/x/net/websocket/hybi_test.go deleted file mode 100644 index 9504aa2..0000000 --- a/vendor/golang.org/x/net/websocket/hybi_test.go +++ /dev/null @@ -1,608 +0,0 @@ -// Copyright 2011 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 websocket - -import ( - "bufio" - "bytes" - "fmt" - "io" - "net/http" - "net/url" - "strings" - "testing" -) - -// Test the getNonceAccept function with values in -// http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-17 -func TestSecWebSocketAccept(t *testing.T) { - nonce := []byte("dGhlIHNhbXBsZSBub25jZQ==") - expected := []byte("s3pPLMBiTxaQ9kYGzzhZRbK+xOo=") - accept, err := getNonceAccept(nonce) - if err != nil { - t.Errorf("getNonceAccept: returned error %v", err) - return - } - if !bytes.Equal(expected, accept) { - t.Errorf("getNonceAccept: expected %q got %q", expected, accept) - } -} - -func TestHybiClientHandshake(t *testing.T) { - type test struct { - url, host string - } - tests := []test{ - {"ws://server.example.com/chat", "server.example.com"}, - {"ws://127.0.0.1/chat", "127.0.0.1"}, - } - if _, err := url.ParseRequestURI("http://[fe80::1%25lo0]"); err == nil { - tests = append(tests, test{"ws://[fe80::1%25lo0]/chat", "[fe80::1]"}) - } - - for _, tt := range tests { - var b bytes.Buffer - bw := bufio.NewWriter(&b) - br := bufio.NewReader(strings.NewReader(`HTTP/1.1 101 Switching Protocols -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= -Sec-WebSocket-Protocol: chat - -`)) - var err error - var config Config - config.Location, err = url.ParseRequestURI(tt.url) - if err != nil { - t.Fatal("location url", err) - } - config.Origin, err = url.ParseRequestURI("http://example.com") - if err != nil { - t.Fatal("origin url", err) - } - config.Protocol = append(config.Protocol, "chat") - config.Protocol = append(config.Protocol, "superchat") - config.Version = ProtocolVersionHybi13 - config.handshakeData = map[string]string{ - "key": "dGhlIHNhbXBsZSBub25jZQ==", - } - if err := hybiClientHandshake(&config, br, bw); err != nil { - t.Fatal("handshake", err) - } - req, err := http.ReadRequest(bufio.NewReader(&b)) - if err != nil { - t.Fatal("read request", err) - } - if req.Method != "GET" { - t.Errorf("request method expected GET, but got %s", req.Method) - } - if req.URL.Path != "/chat" { - t.Errorf("request path expected /chat, but got %s", req.URL.Path) - } - if req.Proto != "HTTP/1.1" { - t.Errorf("request proto expected HTTP/1.1, but got %s", req.Proto) - } - if req.Host != tt.host { - t.Errorf("request host expected %s, but got %s", tt.host, req.Host) - } - var expectedHeader = map[string]string{ - "Connection": "Upgrade", - "Upgrade": "websocket", - "Sec-Websocket-Key": config.handshakeData["key"], - "Origin": config.Origin.String(), - "Sec-Websocket-Protocol": "chat, superchat", - "Sec-Websocket-Version": fmt.Sprintf("%d", ProtocolVersionHybi13), - } - for k, v := range expectedHeader { - if req.Header.Get(k) != v { - t.Errorf("%s expected %s, but got %v", k, v, req.Header.Get(k)) - } - } - } -} - -func TestHybiClientHandshakeWithHeader(t *testing.T) { - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - br := bufio.NewReader(strings.NewReader(`HTTP/1.1 101 Switching Protocols -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo= -Sec-WebSocket-Protocol: chat - -`)) - var err error - config := new(Config) - config.Location, err = url.ParseRequestURI("ws://server.example.com/chat") - if err != nil { - t.Fatal("location url", err) - } - config.Origin, err = url.ParseRequestURI("http://example.com") - if err != nil { - t.Fatal("origin url", err) - } - config.Protocol = append(config.Protocol, "chat") - config.Protocol = append(config.Protocol, "superchat") - config.Version = ProtocolVersionHybi13 - config.Header = http.Header(make(map[string][]string)) - config.Header.Add("User-Agent", "test") - - config.handshakeData = map[string]string{ - "key": "dGhlIHNhbXBsZSBub25jZQ==", - } - err = hybiClientHandshake(config, br, bw) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - req, err := http.ReadRequest(bufio.NewReader(b)) - if err != nil { - t.Fatalf("read request: %v", err) - } - if req.Method != "GET" { - t.Errorf("request method expected GET, but got %q", req.Method) - } - if req.URL.Path != "/chat" { - t.Errorf("request path expected /chat, but got %q", req.URL.Path) - } - if req.Proto != "HTTP/1.1" { - t.Errorf("request proto expected HTTP/1.1, but got %q", req.Proto) - } - if req.Host != "server.example.com" { - t.Errorf("request Host expected server.example.com, but got %v", req.Host) - } - var expectedHeader = map[string]string{ - "Connection": "Upgrade", - "Upgrade": "websocket", - "Sec-Websocket-Key": config.handshakeData["key"], - "Origin": config.Origin.String(), - "Sec-Websocket-Protocol": "chat, superchat", - "Sec-Websocket-Version": fmt.Sprintf("%d", ProtocolVersionHybi13), - "User-Agent": "test", - } - for k, v := range expectedHeader { - if req.Header.Get(k) != v { - t.Errorf(fmt.Sprintf("%s expected %q but got %q", k, v, req.Header.Get(k))) - } - } -} - -func TestHybiServerHandshake(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Origin: http://example.com -Sec-WebSocket-Protocol: chat, superchat -Sec-WebSocket-Version: 13 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - if code != http.StatusSwitchingProtocols { - t.Errorf("status expected %q but got %q", http.StatusSwitchingProtocols, code) - } - expectedProtocols := []string{"chat", "superchat"} - if fmt.Sprintf("%v", config.Protocol) != fmt.Sprintf("%v", expectedProtocols) { - t.Errorf("protocol expected %q but got %q", expectedProtocols, config.Protocol) - } - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - - config.Protocol = config.Protocol[:1] - - err = handshaker.AcceptHandshake(bw) - if err != nil { - t.Errorf("handshake response failed: %v", err) - } - expectedResponse := strings.Join([]string{ - "HTTP/1.1 101 Switching Protocols", - "Upgrade: websocket", - "Connection: Upgrade", - "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", - "Sec-WebSocket-Protocol: chat", - "", ""}, "\r\n") - - if b.String() != expectedResponse { - t.Errorf("handshake expected %q but got %q", expectedResponse, b.String()) - } -} - -func TestHybiServerHandshakeNoSubProtocol(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Origin: http://example.com -Sec-WebSocket-Version: 13 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - if code != http.StatusSwitchingProtocols { - t.Errorf("status expected %q but got %q", http.StatusSwitchingProtocols, code) - } - if len(config.Protocol) != 0 { - t.Errorf("len(config.Protocol) expected 0, but got %q", len(config.Protocol)) - } - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - - err = handshaker.AcceptHandshake(bw) - if err != nil { - t.Errorf("handshake response failed: %v", err) - } - expectedResponse := strings.Join([]string{ - "HTTP/1.1 101 Switching Protocols", - "Upgrade: websocket", - "Connection: Upgrade", - "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", - "", ""}, "\r\n") - - if b.String() != expectedResponse { - t.Errorf("handshake expected %q but got %q", expectedResponse, b.String()) - } -} - -func TestHybiServerHandshakeHybiBadVersion(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: Upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Sec-WebSocket-Origin: http://example.com -Sec-WebSocket-Protocol: chat, superchat -Sec-WebSocket-Version: 9 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != ErrBadWebSocketVersion { - t.Errorf("handshake expected err %q but got %q", ErrBadWebSocketVersion, err) - } - if code != http.StatusBadRequest { - t.Errorf("status expected %q but got %q", http.StatusBadRequest, code) - } -} - -func testHybiFrame(t *testing.T, testHeader, testPayload, testMaskedPayload []byte, frameHeader *hybiFrameHeader) { - b := bytes.NewBuffer([]byte{}) - frameWriterFactory := &hybiFrameWriterFactory{bufio.NewWriter(b), false} - w, _ := frameWriterFactory.NewFrameWriter(TextFrame) - w.(*hybiFrameWriter).header = frameHeader - _, err := w.Write(testPayload) - w.Close() - if err != nil { - t.Errorf("Write error %q", err) - } - var expectedFrame []byte - expectedFrame = append(expectedFrame, testHeader...) - expectedFrame = append(expectedFrame, testMaskedPayload...) - if !bytes.Equal(expectedFrame, b.Bytes()) { - t.Errorf("frame expected %q got %q", expectedFrame, b.Bytes()) - } - frameReaderFactory := &hybiFrameReaderFactory{bufio.NewReader(b)} - r, err := frameReaderFactory.NewFrameReader() - if err != nil { - t.Errorf("Read error %q", err) - } - if header := r.HeaderReader(); header == nil { - t.Errorf("no header") - } else { - actualHeader := make([]byte, r.Len()) - n, err := header.Read(actualHeader) - if err != nil { - t.Errorf("Read header error %q", err) - } else { - if n < len(testHeader) { - t.Errorf("header too short %q got %q", testHeader, actualHeader[:n]) - } - if !bytes.Equal(testHeader, actualHeader[:n]) { - t.Errorf("header expected %q got %q", testHeader, actualHeader[:n]) - } - } - } - if trailer := r.TrailerReader(); trailer != nil { - t.Errorf("unexpected trailer %q", trailer) - } - frame := r.(*hybiFrameReader) - if frameHeader.Fin != frame.header.Fin || - frameHeader.OpCode != frame.header.OpCode || - len(testPayload) != int(frame.header.Length) { - t.Errorf("mismatch %v (%d) vs %v", frameHeader, len(testPayload), frame) - } - payload := make([]byte, len(testPayload)) - _, err = r.Read(payload) - if err != nil && err != io.EOF { - t.Errorf("read %v", err) - } - if !bytes.Equal(testPayload, payload) { - t.Errorf("payload %q vs %q", testPayload, payload) - } -} - -func TestHybiShortTextFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: TextFrame} - payload := []byte("hello") - testHybiFrame(t, []byte{0x81, 0x05}, payload, payload, frameHeader) - - payload = make([]byte, 125) - testHybiFrame(t, []byte{0x81, 125}, payload, payload, frameHeader) -} - -func TestHybiShortMaskedTextFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: TextFrame, - MaskingKey: []byte{0xcc, 0x55, 0x80, 0x20}} - payload := []byte("hello") - maskedPayload := []byte{0xa4, 0x30, 0xec, 0x4c, 0xa3} - header := []byte{0x81, 0x85} - header = append(header, frameHeader.MaskingKey...) - testHybiFrame(t, header, payload, maskedPayload, frameHeader) -} - -func TestHybiShortBinaryFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: BinaryFrame} - payload := []byte("hello") - testHybiFrame(t, []byte{0x82, 0x05}, payload, payload, frameHeader) - - payload = make([]byte, 125) - testHybiFrame(t, []byte{0x82, 125}, payload, payload, frameHeader) -} - -func TestHybiControlFrame(t *testing.T) { - payload := []byte("hello") - - frameHeader := &hybiFrameHeader{Fin: true, OpCode: PingFrame} - testHybiFrame(t, []byte{0x89, 0x05}, payload, payload, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: PingFrame} - testHybiFrame(t, []byte{0x89, 0x00}, nil, nil, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: PongFrame} - testHybiFrame(t, []byte{0x8A, 0x05}, payload, payload, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: PongFrame} - testHybiFrame(t, []byte{0x8A, 0x00}, nil, nil, frameHeader) - - frameHeader = &hybiFrameHeader{Fin: true, OpCode: CloseFrame} - payload = []byte{0x03, 0xe8} // 1000 - testHybiFrame(t, []byte{0x88, 0x02}, payload, payload, frameHeader) -} - -func TestHybiLongFrame(t *testing.T) { - frameHeader := &hybiFrameHeader{Fin: true, OpCode: TextFrame} - payload := make([]byte, 126) - testHybiFrame(t, []byte{0x81, 126, 0x00, 126}, payload, payload, frameHeader) - - payload = make([]byte, 65535) - testHybiFrame(t, []byte{0x81, 126, 0xff, 0xff}, payload, payload, frameHeader) - - payload = make([]byte, 65536) - testHybiFrame(t, []byte{0x81, 127, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00}, payload, payload, frameHeader) -} - -func TestHybiClientRead(t *testing.T) { - wireData := []byte{0x81, 0x05, 'h', 'e', 'l', 'l', 'o', - 0x89, 0x05, 'h', 'e', 'l', 'l', 'o', // ping - 0x81, 0x05, 'w', 'o', 'r', 'l', 'd'} - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil) - - msg := make([]byte, 512) - n, err := conn.Read(msg) - if err != nil { - t.Errorf("read 1st frame, error %q", err) - } - if n != 5 { - t.Errorf("read 1st frame, expect 5, got %d", n) - } - if !bytes.Equal(wireData[2:7], msg[:n]) { - t.Errorf("read 1st frame %v, got %v", wireData[2:7], msg[:n]) - } - n, err = conn.Read(msg) - if err != nil { - t.Errorf("read 2nd frame, error %q", err) - } - if n != 5 { - t.Errorf("read 2nd frame, expect 5, got %d", n) - } - if !bytes.Equal(wireData[16:21], msg[:n]) { - t.Errorf("read 2nd frame %v, got %v", wireData[16:21], msg[:n]) - } - n, err = conn.Read(msg) - if err == nil { - t.Errorf("read not EOF") - } - if n != 0 { - t.Errorf("expect read 0, got %d", n) - } -} - -func TestHybiShortRead(t *testing.T) { - wireData := []byte{0x81, 0x05, 'h', 'e', 'l', 'l', 'o', - 0x89, 0x05, 'h', 'e', 'l', 'l', 'o', // ping - 0x81, 0x05, 'w', 'o', 'r', 'l', 'd'} - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil) - - step := 0 - pos := 0 - expectedPos := []int{2, 5, 16, 19} - expectedLen := []int{3, 2, 3, 2} - for { - msg := make([]byte, 3) - n, err := conn.Read(msg) - if step >= len(expectedPos) { - if err == nil { - t.Errorf("read not EOF") - } - if n != 0 { - t.Errorf("expect read 0, got %d", n) - } - return - } - pos = expectedPos[step] - endPos := pos + expectedLen[step] - if err != nil { - t.Errorf("read from %d, got error %q", pos, err) - return - } - if n != endPos-pos { - t.Errorf("read from %d, expect %d, got %d", pos, endPos-pos, n) - } - if !bytes.Equal(wireData[pos:endPos], msg[:n]) { - t.Errorf("read from %d, frame %v, got %v", pos, wireData[pos:endPos], msg[:n]) - } - step++ - } -} - -func TestHybiServerRead(t *testing.T) { - wireData := []byte{0x81, 0x85, 0xcc, 0x55, 0x80, 0x20, - 0xa4, 0x30, 0xec, 0x4c, 0xa3, // hello - 0x89, 0x85, 0xcc, 0x55, 0x80, 0x20, - 0xa4, 0x30, 0xec, 0x4c, 0xa3, // ping: hello - 0x81, 0x85, 0xed, 0x83, 0xb4, 0x24, - 0x9a, 0xec, 0xc6, 0x48, 0x89, // world - } - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, new(http.Request)) - - expected := [][]byte{[]byte("hello"), []byte("world")} - - msg := make([]byte, 512) - n, err := conn.Read(msg) - if err != nil { - t.Errorf("read 1st frame, error %q", err) - } - if n != 5 { - t.Errorf("read 1st frame, expect 5, got %d", n) - } - if !bytes.Equal(expected[0], msg[:n]) { - t.Errorf("read 1st frame %q, got %q", expected[0], msg[:n]) - } - - n, err = conn.Read(msg) - if err != nil { - t.Errorf("read 2nd frame, error %q", err) - } - if n != 5 { - t.Errorf("read 2nd frame, expect 5, got %d", n) - } - if !bytes.Equal(expected[1], msg[:n]) { - t.Errorf("read 2nd frame %q, got %q", expected[1], msg[:n]) - } - - n, err = conn.Read(msg) - if err == nil { - t.Errorf("read not EOF") - } - if n != 0 { - t.Errorf("expect read 0, got %d", n) - } -} - -func TestHybiServerReadWithoutMasking(t *testing.T) { - wireData := []byte{0x81, 0x05, 'h', 'e', 'l', 'l', 'o'} - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, new(http.Request)) - // server MUST close the connection upon receiving a non-masked frame. - msg := make([]byte, 512) - _, err := conn.Read(msg) - if err != io.EOF { - t.Errorf("read 1st frame, expect %q, but got %q", io.EOF, err) - } -} - -func TestHybiClientReadWithMasking(t *testing.T) { - wireData := []byte{0x81, 0x85, 0xcc, 0x55, 0x80, 0x20, - 0xa4, 0x30, 0xec, 0x4c, 0xa3, // hello - } - br := bufio.NewReader(bytes.NewBuffer(wireData)) - bw := bufio.NewWriter(bytes.NewBuffer([]byte{})) - conn := newHybiConn(newConfig(t, "/"), bufio.NewReadWriter(br, bw), nil, nil) - - // client MUST close the connection upon receiving a masked frame. - msg := make([]byte, 512) - _, err := conn.Read(msg) - if err != io.EOF { - t.Errorf("read 1st frame, expect %q, but got %q", io.EOF, err) - } -} - -// Test the hybiServerHandshaker supports firefox implementation and -// checks Connection request header include (but it's not necessary -// equal to) "upgrade" -func TestHybiServerFirefoxHandshake(t *testing.T) { - config := new(Config) - handshaker := &hybiServerHandshaker{Config: config} - br := bufio.NewReader(strings.NewReader(`GET /chat HTTP/1.1 -Host: server.example.com -Upgrade: websocket -Connection: keep-alive, upgrade -Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ== -Origin: http://example.com -Sec-WebSocket-Protocol: chat, superchat -Sec-WebSocket-Version: 13 - -`)) - req, err := http.ReadRequest(br) - if err != nil { - t.Fatal("request", err) - } - code, err := handshaker.ReadHandshake(br, req) - if err != nil { - t.Errorf("handshake failed: %v", err) - } - if code != http.StatusSwitchingProtocols { - t.Errorf("status expected %q but got %q", http.StatusSwitchingProtocols, code) - } - b := bytes.NewBuffer([]byte{}) - bw := bufio.NewWriter(b) - - config.Protocol = []string{"chat"} - - err = handshaker.AcceptHandshake(bw) - if err != nil { - t.Errorf("handshake response failed: %v", err) - } - expectedResponse := strings.Join([]string{ - "HTTP/1.1 101 Switching Protocols", - "Upgrade: websocket", - "Connection: Upgrade", - "Sec-WebSocket-Accept: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=", - "Sec-WebSocket-Protocol: chat", - "", ""}, "\r\n") - - if b.String() != expectedResponse { - t.Errorf("handshake expected %q but got %q", expectedResponse, b.String()) - } -} diff --git a/vendor/golang.org/x/net/websocket/server.go b/vendor/golang.org/x/net/websocket/server.go deleted file mode 100644 index 0895dea..0000000 --- a/vendor/golang.org/x/net/websocket/server.go +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "bufio" - "fmt" - "io" - "net/http" -) - -func newServerConn(rwc io.ReadWriteCloser, buf *bufio.ReadWriter, req *http.Request, config *Config, handshake func(*Config, *http.Request) error) (conn *Conn, err error) { - var hs serverHandshaker = &hybiServerHandshaker{Config: config} - code, err := hs.ReadHandshake(buf.Reader, req) - if err == ErrBadWebSocketVersion { - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - fmt.Fprintf(buf, "Sec-WebSocket-Version: %s\r\n", SupportedProtocolVersion) - buf.WriteString("\r\n") - buf.WriteString(err.Error()) - buf.Flush() - return - } - if err != nil { - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - buf.WriteString("\r\n") - buf.WriteString(err.Error()) - buf.Flush() - return - } - if handshake != nil { - err = handshake(config, req) - if err != nil { - code = http.StatusForbidden - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - buf.WriteString("\r\n") - buf.Flush() - return - } - } - err = hs.AcceptHandshake(buf.Writer) - if err != nil { - code = http.StatusBadRequest - fmt.Fprintf(buf, "HTTP/1.1 %03d %s\r\n", code, http.StatusText(code)) - buf.WriteString("\r\n") - buf.Flush() - return - } - conn = hs.NewServerConn(buf, rwc, req) - return -} - -// Server represents a server of a WebSocket. -type Server struct { - // Config is a WebSocket configuration for new WebSocket connection. - Config - - // Handshake is an optional function in WebSocket handshake. - // For example, you can check, or don't check Origin header. - // Another example, you can select config.Protocol. - Handshake func(*Config, *http.Request) error - - // Handler handles a WebSocket connection. - Handler -} - -// ServeHTTP implements the http.Handler interface for a WebSocket -func (s Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { - s.serveWebSocket(w, req) -} - -func (s Server) serveWebSocket(w http.ResponseWriter, req *http.Request) { - rwc, buf, err := w.(http.Hijacker).Hijack() - if err != nil { - panic("Hijack failed: " + err.Error()) - } - // The server should abort the WebSocket connection if it finds - // the client did not send a handshake that matches with protocol - // specification. - defer rwc.Close() - conn, err := newServerConn(rwc, buf, req, &s.Config, s.Handshake) - if err != nil { - return - } - if conn == nil { - panic("unexpected nil conn") - } - s.Handler(conn) -} - -// Handler is a simple interface to a WebSocket browser client. -// It checks if Origin header is valid URL by default. -// You might want to verify websocket.Conn.Config().Origin in the func. -// If you use Server instead of Handler, you could call websocket.Origin and -// check the origin in your Handshake func. So, if you want to accept -// non-browser clients, which do not send an Origin header, set a -// Server.Handshake that does not check the origin. -type Handler func(*Conn) - -func checkOrigin(config *Config, req *http.Request) (err error) { - config.Origin, err = Origin(config, req) - if err == nil && config.Origin == nil { - return fmt.Errorf("null origin") - } - return err -} - -// ServeHTTP implements the http.Handler interface for a WebSocket -func (h Handler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - s := Server{Handler: h, Handshake: checkOrigin} - s.serveWebSocket(w, req) -} diff --git a/vendor/golang.org/x/net/websocket/websocket.go b/vendor/golang.org/x/net/websocket/websocket.go deleted file mode 100644 index 9412191..0000000 --- a/vendor/golang.org/x/net/websocket/websocket.go +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package websocket implements a client and server for the WebSocket protocol -// as specified in RFC 6455. -package websocket // import "golang.org/x/net/websocket" - -import ( - "bufio" - "crypto/tls" - "encoding/json" - "errors" - "io" - "io/ioutil" - "net" - "net/http" - "net/url" - "sync" - "time" -) - -const ( - ProtocolVersionHybi13 = 13 - ProtocolVersionHybi = ProtocolVersionHybi13 - SupportedProtocolVersion = "13" - - ContinuationFrame = 0 - TextFrame = 1 - BinaryFrame = 2 - CloseFrame = 8 - PingFrame = 9 - PongFrame = 10 - UnknownFrame = 255 -) - -// ProtocolError represents WebSocket protocol errors. -type ProtocolError struct { - ErrorString string -} - -func (err *ProtocolError) Error() string { return err.ErrorString } - -var ( - ErrBadProtocolVersion = &ProtocolError{"bad protocol version"} - ErrBadScheme = &ProtocolError{"bad scheme"} - ErrBadStatus = &ProtocolError{"bad status"} - ErrBadUpgrade = &ProtocolError{"missing or bad upgrade"} - ErrBadWebSocketOrigin = &ProtocolError{"missing or bad WebSocket-Origin"} - ErrBadWebSocketLocation = &ProtocolError{"missing or bad WebSocket-Location"} - ErrBadWebSocketProtocol = &ProtocolError{"missing or bad WebSocket-Protocol"} - ErrBadWebSocketVersion = &ProtocolError{"missing or bad WebSocket Version"} - ErrChallengeResponse = &ProtocolError{"mismatch challenge/response"} - ErrBadFrame = &ProtocolError{"bad frame"} - ErrBadFrameBoundary = &ProtocolError{"not on frame boundary"} - ErrNotWebSocket = &ProtocolError{"not websocket protocol"} - ErrBadRequestMethod = &ProtocolError{"bad method"} - ErrNotSupported = &ProtocolError{"not supported"} -) - -// Addr is an implementation of net.Addr for WebSocket. -type Addr struct { - *url.URL -} - -// Network returns the network type for a WebSocket, "websocket". -func (addr *Addr) Network() string { return "websocket" } - -// Config is a WebSocket configuration -type Config struct { - // A WebSocket server address. - Location *url.URL - - // A Websocket client origin. - Origin *url.URL - - // WebSocket subprotocols. - Protocol []string - - // WebSocket protocol version. - Version int - - // TLS config for secure WebSocket (wss). - TlsConfig *tls.Config - - // Additional header fields to be sent in WebSocket opening handshake. - Header http.Header - - handshakeData map[string]string -} - -// serverHandshaker is an interface to handle WebSocket server side handshake. -type serverHandshaker interface { - // ReadHandshake reads handshake request message from client. - // Returns http response code and error if any. - ReadHandshake(buf *bufio.Reader, req *http.Request) (code int, err error) - - // AcceptHandshake accepts the client handshake request and sends - // handshake response back to client. - AcceptHandshake(buf *bufio.Writer) (err error) - - // NewServerConn creates a new WebSocket connection. - NewServerConn(buf *bufio.ReadWriter, rwc io.ReadWriteCloser, request *http.Request) (conn *Conn) -} - -// frameReader is an interface to read a WebSocket frame. -type frameReader interface { - // Reader is to read payload of the frame. - io.Reader - - // PayloadType returns payload type. - PayloadType() byte - - // HeaderReader returns a reader to read header of the frame. - HeaderReader() io.Reader - - // TrailerReader returns a reader to read trailer of the frame. - // If it returns nil, there is no trailer in the frame. - TrailerReader() io.Reader - - // Len returns total length of the frame, including header and trailer. - Len() int -} - -// frameReaderFactory is an interface to creates new frame reader. -type frameReaderFactory interface { - NewFrameReader() (r frameReader, err error) -} - -// frameWriter is an interface to write a WebSocket frame. -type frameWriter interface { - // Writer is to write payload of the frame. - io.WriteCloser -} - -// frameWriterFactory is an interface to create new frame writer. -type frameWriterFactory interface { - NewFrameWriter(payloadType byte) (w frameWriter, err error) -} - -type frameHandler interface { - HandleFrame(frame frameReader) (r frameReader, err error) - WriteClose(status int) (err error) -} - -// Conn represents a WebSocket connection. -// -// Multiple goroutines may invoke methods on a Conn simultaneously. -type Conn struct { - config *Config - request *http.Request - - buf *bufio.ReadWriter - rwc io.ReadWriteCloser - - rio sync.Mutex - frameReaderFactory - frameReader - - wio sync.Mutex - frameWriterFactory - - frameHandler - PayloadType byte - defaultCloseStatus int -} - -// Read implements the io.Reader interface: -// it reads data of a frame from the WebSocket connection. -// if msg is not large enough for the frame data, it fills the msg and next Read -// will read the rest of the frame data. -// it reads Text frame or Binary frame. -func (ws *Conn) Read(msg []byte) (n int, err error) { - ws.rio.Lock() - defer ws.rio.Unlock() -again: - if ws.frameReader == nil { - frame, err := ws.frameReaderFactory.NewFrameReader() - if err != nil { - return 0, err - } - ws.frameReader, err = ws.frameHandler.HandleFrame(frame) - if err != nil { - return 0, err - } - if ws.frameReader == nil { - goto again - } - } - n, err = ws.frameReader.Read(msg) - if err == io.EOF { - if trailer := ws.frameReader.TrailerReader(); trailer != nil { - io.Copy(ioutil.Discard, trailer) - } - ws.frameReader = nil - goto again - } - return n, err -} - -// Write implements the io.Writer interface: -// it writes data as a frame to the WebSocket connection. -func (ws *Conn) Write(msg []byte) (n int, err error) { - ws.wio.Lock() - defer ws.wio.Unlock() - w, err := ws.frameWriterFactory.NewFrameWriter(ws.PayloadType) - if err != nil { - return 0, err - } - n, err = w.Write(msg) - w.Close() - return n, err -} - -// Close implements the io.Closer interface. -func (ws *Conn) Close() error { - err := ws.frameHandler.WriteClose(ws.defaultCloseStatus) - err1 := ws.rwc.Close() - if err != nil { - return err - } - return err1 -} - -func (ws *Conn) IsClientConn() bool { return ws.request == nil } -func (ws *Conn) IsServerConn() bool { return ws.request != nil } - -// LocalAddr returns the WebSocket Origin for the connection for client, or -// the WebSocket location for server. -func (ws *Conn) LocalAddr() net.Addr { - if ws.IsClientConn() { - return &Addr{ws.config.Origin} - } - return &Addr{ws.config.Location} -} - -// RemoteAddr returns the WebSocket location for the connection for client, or -// the Websocket Origin for server. -func (ws *Conn) RemoteAddr() net.Addr { - if ws.IsClientConn() { - return &Addr{ws.config.Location} - } - return &Addr{ws.config.Origin} -} - -var errSetDeadline = errors.New("websocket: cannot set deadline: not using a net.Conn") - -// SetDeadline sets the connection's network read & write deadlines. -func (ws *Conn) SetDeadline(t time.Time) error { - if conn, ok := ws.rwc.(net.Conn); ok { - return conn.SetDeadline(t) - } - return errSetDeadline -} - -// SetReadDeadline sets the connection's network read deadline. -func (ws *Conn) SetReadDeadline(t time.Time) error { - if conn, ok := ws.rwc.(net.Conn); ok { - return conn.SetReadDeadline(t) - } - return errSetDeadline -} - -// SetWriteDeadline sets the connection's network write deadline. -func (ws *Conn) SetWriteDeadline(t time.Time) error { - if conn, ok := ws.rwc.(net.Conn); ok { - return conn.SetWriteDeadline(t) - } - return errSetDeadline -} - -// Config returns the WebSocket config. -func (ws *Conn) Config() *Config { return ws.config } - -// Request returns the http request upgraded to the WebSocket. -// It is nil for client side. -func (ws *Conn) Request() *http.Request { return ws.request } - -// Codec represents a symmetric pair of functions that implement a codec. -type Codec struct { - Marshal func(v interface{}) (data []byte, payloadType byte, err error) - Unmarshal func(data []byte, payloadType byte, v interface{}) (err error) -} - -// Send sends v marshaled by cd.Marshal as single frame to ws. -func (cd Codec) Send(ws *Conn, v interface{}) (err error) { - data, payloadType, err := cd.Marshal(v) - if err != nil { - return err - } - ws.wio.Lock() - defer ws.wio.Unlock() - w, err := ws.frameWriterFactory.NewFrameWriter(payloadType) - if err != nil { - return err - } - _, err = w.Write(data) - w.Close() - return err -} - -// Receive receives single frame from ws, unmarshaled by cd.Unmarshal and stores in v. -func (cd Codec) Receive(ws *Conn, v interface{}) (err error) { - ws.rio.Lock() - defer ws.rio.Unlock() - if ws.frameReader != nil { - _, err = io.Copy(ioutil.Discard, ws.frameReader) - if err != nil { - return err - } - ws.frameReader = nil - } -again: - frame, err := ws.frameReaderFactory.NewFrameReader() - if err != nil { - return err - } - frame, err = ws.frameHandler.HandleFrame(frame) - if err != nil { - return err - } - if frame == nil { - goto again - } - payloadType := frame.PayloadType() - data, err := ioutil.ReadAll(frame) - if err != nil { - return err - } - return cd.Unmarshal(data, payloadType, v) -} - -func marshal(v interface{}) (msg []byte, payloadType byte, err error) { - switch data := v.(type) { - case string: - return []byte(data), TextFrame, nil - case []byte: - return data, BinaryFrame, nil - } - return nil, UnknownFrame, ErrNotSupported -} - -func unmarshal(msg []byte, payloadType byte, v interface{}) (err error) { - switch data := v.(type) { - case *string: - *data = string(msg) - return nil - case *[]byte: - *data = msg - return nil - } - return ErrNotSupported -} - -/* -Message is a codec to send/receive text/binary data in a frame on WebSocket connection. -To send/receive text frame, use string type. -To send/receive binary frame, use []byte type. - -Trivial usage: - - import "websocket" - - // receive text frame - var message string - websocket.Message.Receive(ws, &message) - - // send text frame - message = "hello" - websocket.Message.Send(ws, message) - - // receive binary frame - var data []byte - websocket.Message.Receive(ws, &data) - - // send binary frame - data = []byte{0, 1, 2} - websocket.Message.Send(ws, data) - -*/ -var Message = Codec{marshal, unmarshal} - -func jsonMarshal(v interface{}) (msg []byte, payloadType byte, err error) { - msg, err = json.Marshal(v) - return msg, TextFrame, err -} - -func jsonUnmarshal(msg []byte, payloadType byte, v interface{}) (err error) { - return json.Unmarshal(msg, v) -} - -/* -JSON is a codec to send/receive JSON data in a frame from a WebSocket connection. - -Trivial usage: - - import "websocket" - - type T struct { - Msg string - Count int - } - - // receive JSON type T - var data T - websocket.JSON.Receive(ws, &data) - - // send JSON type T - websocket.JSON.Send(ws, data) -*/ -var JSON = Codec{jsonMarshal, jsonUnmarshal} diff --git a/vendor/golang.org/x/net/websocket/websocket_test.go b/vendor/golang.org/x/net/websocket/websocket_test.go deleted file mode 100644 index 05b7e53..0000000 --- a/vendor/golang.org/x/net/websocket/websocket_test.go +++ /dev/null @@ -1,587 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package websocket - -import ( - "bytes" - "fmt" - "io" - "log" - "net" - "net/http" - "net/http/httptest" - "net/url" - "reflect" - "runtime" - "strings" - "sync" - "testing" - "time" -) - -var serverAddr string -var once sync.Once - -func echoServer(ws *Conn) { - defer ws.Close() - io.Copy(ws, ws) -} - -type Count struct { - S string - N int -} - -func countServer(ws *Conn) { - defer ws.Close() - for { - var count Count - err := JSON.Receive(ws, &count) - if err != nil { - return - } - count.N++ - count.S = strings.Repeat(count.S, count.N) - err = JSON.Send(ws, count) - if err != nil { - return - } - } -} - -type testCtrlAndDataHandler struct { - hybiFrameHandler -} - -func (h *testCtrlAndDataHandler) WritePing(b []byte) (int, error) { - h.hybiFrameHandler.conn.wio.Lock() - defer h.hybiFrameHandler.conn.wio.Unlock() - w, err := h.hybiFrameHandler.conn.frameWriterFactory.NewFrameWriter(PingFrame) - if err != nil { - return 0, err - } - n, err := w.Write(b) - w.Close() - return n, err -} - -func ctrlAndDataServer(ws *Conn) { - defer ws.Close() - h := &testCtrlAndDataHandler{hybiFrameHandler: hybiFrameHandler{conn: ws}} - ws.frameHandler = h - - go func() { - for i := 0; ; i++ { - var b []byte - if i%2 != 0 { // with or without payload - b = []byte(fmt.Sprintf("#%d-CONTROL-FRAME-FROM-SERVER", i)) - } - if _, err := h.WritePing(b); err != nil { - break - } - if _, err := h.WritePong(b); err != nil { // unsolicited pong - break - } - time.Sleep(10 * time.Millisecond) - } - }() - - b := make([]byte, 128) - for { - n, err := ws.Read(b) - if err != nil { - break - } - if _, err := ws.Write(b[:n]); err != nil { - break - } - } -} - -func subProtocolHandshake(config *Config, req *http.Request) error { - for _, proto := range config.Protocol { - if proto == "chat" { - config.Protocol = []string{proto} - return nil - } - } - return ErrBadWebSocketProtocol -} - -func subProtoServer(ws *Conn) { - for _, proto := range ws.Config().Protocol { - io.WriteString(ws, proto) - } -} - -func startServer() { - http.Handle("/echo", Handler(echoServer)) - http.Handle("/count", Handler(countServer)) - http.Handle("/ctrldata", Handler(ctrlAndDataServer)) - subproto := Server{ - Handshake: subProtocolHandshake, - Handler: Handler(subProtoServer), - } - http.Handle("/subproto", subproto) - server := httptest.NewServer(nil) - serverAddr = server.Listener.Addr().String() - log.Print("Test WebSocket server listening on ", serverAddr) -} - -func newConfig(t *testing.T, path string) *Config { - config, _ := NewConfig(fmt.Sprintf("ws://%s%s", serverAddr, path), "http://localhost") - return config -} - -func TestEcho(t *testing.T) { - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/echo"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - msg := []byte("hello, world\n") - if _, err := conn.Write(msg); err != nil { - t.Errorf("Write: %v", err) - } - var actual_msg = make([]byte, 512) - n, err := conn.Read(actual_msg) - if err != nil { - t.Errorf("Read: %v", err) - } - actual_msg = actual_msg[0:n] - if !bytes.Equal(msg, actual_msg) { - t.Errorf("Echo: expected %q got %q", msg, actual_msg) - } - conn.Close() -} - -func TestAddr(t *testing.T) { - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/echo"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - ra := conn.RemoteAddr().String() - if !strings.HasPrefix(ra, "ws://") || !strings.HasSuffix(ra, "/echo") { - t.Errorf("Bad remote addr: %v", ra) - } - la := conn.LocalAddr().String() - if !strings.HasPrefix(la, "http://") { - t.Errorf("Bad local addr: %v", la) - } - conn.Close() -} - -func TestCount(t *testing.T) { - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/count"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - var count Count - count.S = "hello" - if err := JSON.Send(conn, count); err != nil { - t.Errorf("Write: %v", err) - } - if err := JSON.Receive(conn, &count); err != nil { - t.Errorf("Read: %v", err) - } - if count.N != 1 { - t.Errorf("count: expected %d got %d", 1, count.N) - } - if count.S != "hello" { - t.Errorf("count: expected %q got %q", "hello", count.S) - } - if err := JSON.Send(conn, count); err != nil { - t.Errorf("Write: %v", err) - } - if err := JSON.Receive(conn, &count); err != nil { - t.Errorf("Read: %v", err) - } - if count.N != 2 { - t.Errorf("count: expected %d got %d", 2, count.N) - } - if count.S != "hellohello" { - t.Errorf("count: expected %q got %q", "hellohello", count.S) - } - conn.Close() -} - -func TestWithQuery(t *testing.T) { - once.Do(startServer) - - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - - config := newConfig(t, "/echo") - config.Location, err = url.ParseRequestURI(fmt.Sprintf("ws://%s/echo?q=v", serverAddr)) - if err != nil { - t.Fatal("location url", err) - } - - ws, err := NewClient(config, client) - if err != nil { - t.Errorf("WebSocket handshake: %v", err) - return - } - ws.Close() -} - -func testWithProtocol(t *testing.T, subproto []string) (string, error) { - once.Do(startServer) - - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - - config := newConfig(t, "/subproto") - config.Protocol = subproto - - ws, err := NewClient(config, client) - if err != nil { - return "", err - } - msg := make([]byte, 16) - n, err := ws.Read(msg) - if err != nil { - return "", err - } - ws.Close() - return string(msg[:n]), nil -} - -func TestWithProtocol(t *testing.T) { - proto, err := testWithProtocol(t, []string{"chat"}) - if err != nil { - t.Errorf("SubProto: unexpected error: %v", err) - } - if proto != "chat" { - t.Errorf("SubProto: expected %q, got %q", "chat", proto) - } -} - -func TestWithTwoProtocol(t *testing.T) { - proto, err := testWithProtocol(t, []string{"test", "chat"}) - if err != nil { - t.Errorf("SubProto: unexpected error: %v", err) - } - if proto != "chat" { - t.Errorf("SubProto: expected %q, got %q", "chat", proto) - } -} - -func TestWithBadProtocol(t *testing.T) { - _, err := testWithProtocol(t, []string{"test"}) - if err != ErrBadStatus { - t.Errorf("SubProto: expected %v, got %v", ErrBadStatus, err) - } -} - -func TestHTTP(t *testing.T) { - once.Do(startServer) - - // If the client did not send a handshake that matches the protocol - // specification, the server MUST return an HTTP response with an - // appropriate error code (such as 400 Bad Request) - resp, err := http.Get(fmt.Sprintf("http://%s/echo", serverAddr)) - if err != nil { - t.Errorf("Get: error %#v", err) - return - } - if resp == nil { - t.Error("Get: resp is null") - return - } - if resp.StatusCode != http.StatusBadRequest { - t.Errorf("Get: expected %q got %q", http.StatusBadRequest, resp.StatusCode) - } -} - -func TestTrailingSpaces(t *testing.T) { - // http://code.google.com/p/go/issues/detail?id=955 - // The last runs of this create keys with trailing spaces that should not be - // generated by the client. - once.Do(startServer) - config := newConfig(t, "/echo") - for i := 0; i < 30; i++ { - // body - ws, err := DialConfig(config) - if err != nil { - t.Errorf("Dial #%d failed: %v", i, err) - break - } - ws.Close() - } -} - -func TestDialConfigBadVersion(t *testing.T) { - once.Do(startServer) - config := newConfig(t, "/echo") - config.Version = 1234 - - _, err := DialConfig(config) - - if dialerr, ok := err.(*DialError); ok { - if dialerr.Err != ErrBadProtocolVersion { - t.Errorf("dial expected err %q but got %q", ErrBadProtocolVersion, dialerr.Err) - } - } -} - -func TestSmallBuffer(t *testing.T) { - // http://code.google.com/p/go/issues/detail?id=1145 - // Read should be able to handle reading a fragment of a frame. - once.Do(startServer) - - // websocket.Dial() - client, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - conn, err := NewClient(newConfig(t, "/echo"), client) - if err != nil { - t.Errorf("WebSocket handshake error: %v", err) - return - } - - msg := []byte("hello, world\n") - if _, err := conn.Write(msg); err != nil { - t.Errorf("Write: %v", err) - } - var small_msg = make([]byte, 8) - n, err := conn.Read(small_msg) - if err != nil { - t.Errorf("Read: %v", err) - } - if !bytes.Equal(msg[:len(small_msg)], small_msg) { - t.Errorf("Echo: expected %q got %q", msg[:len(small_msg)], small_msg) - } - var second_msg = make([]byte, len(msg)) - n, err = conn.Read(second_msg) - if err != nil { - t.Errorf("Read: %v", err) - } - second_msg = second_msg[0:n] - if !bytes.Equal(msg[len(small_msg):], second_msg) { - t.Errorf("Echo: expected %q got %q", msg[len(small_msg):], second_msg) - } - conn.Close() -} - -var parseAuthorityTests = []struct { - in *url.URL - out string -}{ - { - &url.URL{ - Scheme: "ws", - Host: "www.google.com", - }, - "www.google.com:80", - }, - { - &url.URL{ - Scheme: "wss", - Host: "www.google.com", - }, - "www.google.com:443", - }, - { - &url.URL{ - Scheme: "ws", - Host: "www.google.com:80", - }, - "www.google.com:80", - }, - { - &url.URL{ - Scheme: "wss", - Host: "www.google.com:443", - }, - "www.google.com:443", - }, - // some invalid ones for parseAuthority. parseAuthority doesn't - // concern itself with the scheme unless it actually knows about it - { - &url.URL{ - Scheme: "http", - Host: "www.google.com", - }, - "www.google.com", - }, - { - &url.URL{ - Scheme: "http", - Host: "www.google.com:80", - }, - "www.google.com:80", - }, - { - &url.URL{ - Scheme: "asdf", - Host: "127.0.0.1", - }, - "127.0.0.1", - }, - { - &url.URL{ - Scheme: "asdf", - Host: "www.google.com", - }, - "www.google.com", - }, -} - -func TestParseAuthority(t *testing.T) { - for _, tt := range parseAuthorityTests { - out := parseAuthority(tt.in) - if out != tt.out { - t.Errorf("got %v; want %v", out, tt.out) - } - } -} - -type closerConn struct { - net.Conn - closed int // count of the number of times Close was called -} - -func (c *closerConn) Close() error { - c.closed++ - return c.Conn.Close() -} - -func TestClose(t *testing.T) { - if runtime.GOOS == "plan9" { - t.Skip("see golang.org/issue/11454") - } - - once.Do(startServer) - - conn, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal("dialing", err) - } - - cc := closerConn{Conn: conn} - - client, err := NewClient(newConfig(t, "/echo"), &cc) - if err != nil { - t.Fatalf("WebSocket handshake: %v", err) - } - - // set the deadline to ten minutes ago, which will have expired by the time - // client.Close sends the close status frame. - conn.SetDeadline(time.Now().Add(-10 * time.Minute)) - - if err := client.Close(); err == nil { - t.Errorf("ws.Close(): expected error, got %v", err) - } - if cc.closed < 1 { - t.Fatalf("ws.Close(): expected underlying ws.rwc.Close to be called > 0 times, got: %v", cc.closed) - } -} - -var originTests = []struct { - req *http.Request - origin *url.URL -}{ - { - req: &http.Request{ - Header: http.Header{ - "Origin": []string{"http://www.example.com"}, - }, - }, - origin: &url.URL{ - Scheme: "http", - Host: "www.example.com", - }, - }, - { - req: &http.Request{}, - }, -} - -func TestOrigin(t *testing.T) { - conf := newConfig(t, "/echo") - conf.Version = ProtocolVersionHybi13 - for i, tt := range originTests { - origin, err := Origin(conf, tt.req) - if err != nil { - t.Error(err) - continue - } - if !reflect.DeepEqual(origin, tt.origin) { - t.Errorf("#%d: got origin %v; want %v", i, origin, tt.origin) - continue - } - } -} - -func TestCtrlAndData(t *testing.T) { - once.Do(startServer) - - c, err := net.Dial("tcp", serverAddr) - if err != nil { - t.Fatal(err) - } - ws, err := NewClient(newConfig(t, "/ctrldata"), c) - if err != nil { - t.Fatal(err) - } - defer ws.Close() - - h := &testCtrlAndDataHandler{hybiFrameHandler: hybiFrameHandler{conn: ws}} - ws.frameHandler = h - - b := make([]byte, 128) - for i := 0; i < 2; i++ { - data := []byte(fmt.Sprintf("#%d-DATA-FRAME-FROM-CLIENT", i)) - if _, err := ws.Write(data); err != nil { - t.Fatalf("#%d: %v", i, err) - } - var ctrl []byte - if i%2 != 0 { // with or without payload - ctrl = []byte(fmt.Sprintf("#%d-CONTROL-FRAME-FROM-CLIENT", i)) - } - if _, err := h.WritePing(ctrl); err != nil { - t.Fatalf("#%d: %v", i, err) - } - n, err := ws.Read(b) - if err != nil { - t.Fatalf("#%d: %v", i, err) - } - if !bytes.Equal(b[:n], data) { - t.Fatalf("#%d: got %v; want %v", i, b[:n], data) - } - } -} diff --git a/vendor/golang.org/x/net/xsrftoken/xsrf.go b/vendor/golang.org/x/net/xsrftoken/xsrf.go deleted file mode 100644 index 8d21878..0000000 --- a/vendor/golang.org/x/net/xsrftoken/xsrf.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Package xsrftoken provides methods for generating and validating secure XSRF tokens. -package xsrftoken // import "golang.org/x/net/xsrftoken" - -import ( - "crypto/hmac" - "crypto/sha1" - "crypto/subtle" - "encoding/base64" - "fmt" - "strconv" - "strings" - "time" -) - -// Timeout is the duration for which XSRF tokens are valid. -// It is exported so clients may set cookie timeouts that match generated tokens. -const Timeout = 24 * time.Hour - -// clean sanitizes a string for inclusion in a token by replacing all ":"s. -func clean(s string) string { - return strings.Replace(s, ":", "_", -1) -} - -// Generate returns a URL-safe secure XSRF token that expires in 24 hours. -// -// key is a secret key for your application. -// userID is a unique identifier for the user. -// actionID is the action the user is taking (e.g. POSTing to a particular path). -func Generate(key, userID, actionID string) string { - return generateTokenAtTime(key, userID, actionID, time.Now()) -} - -// generateTokenAtTime is like Generate, but returns a token that expires 24 hours from now. -func generateTokenAtTime(key, userID, actionID string, now time.Time) string { - // Round time up and convert to milliseconds. - milliTime := (now.UnixNano() + 1e6 - 1) / 1e6 - - h := hmac.New(sha1.New, []byte(key)) - fmt.Fprintf(h, "%s:%s:%d", clean(userID), clean(actionID), milliTime) - - // Get the padded base64 string then removing the padding. - tok := string(h.Sum(nil)) - tok = base64.URLEncoding.EncodeToString([]byte(tok)) - tok = strings.TrimRight(tok, "=") - - return fmt.Sprintf("%s:%d", tok, milliTime) -} - -// Valid reports whether a token is a valid, unexpired token returned by Generate. -func Valid(token, key, userID, actionID string) bool { - return validTokenAtTime(token, key, userID, actionID, time.Now()) -} - -// validTokenAtTime reports whether a token is valid at the given time. -func validTokenAtTime(token, key, userID, actionID string, now time.Time) bool { - // Extract the issue time of the token. - sep := strings.LastIndex(token, ":") - if sep < 0 { - return false - } - millis, err := strconv.ParseInt(token[sep+1:], 10, 64) - if err != nil { - return false - } - issueTime := time.Unix(0, millis*1e6) - - // Check that the token is not expired. - if now.Sub(issueTime) >= Timeout { - return false - } - - // Check that the token is not from the future. - // Allow 1 minute grace period in case the token is being verified on a - // machine whose clock is behind the machine that issued the token. - if issueTime.After(now.Add(1 * time.Minute)) { - return false - } - - expected := generateTokenAtTime(key, userID, actionID, issueTime) - - // Check that the token matches the expected value. - // Use constant time comparison to avoid timing attacks. - return subtle.ConstantTimeCompare([]byte(token), []byte(expected)) == 1 -} diff --git a/vendor/golang.org/x/net/xsrftoken/xsrf_test.go b/vendor/golang.org/x/net/xsrftoken/xsrf_test.go deleted file mode 100644 index 9933f86..0000000 --- a/vendor/golang.org/x/net/xsrftoken/xsrf_test.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright 2012 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package xsrftoken - -import ( - "encoding/base64" - "testing" - "time" -) - -const ( - key = "quay" - userID = "12345678" - actionID = "POST /form" -) - -var ( - now = time.Now() - oneMinuteFromNow = now.Add(1 * time.Minute) -) - -func TestValidToken(t *testing.T) { - tok := generateTokenAtTime(key, userID, actionID, now) - if !validTokenAtTime(tok, key, userID, actionID, oneMinuteFromNow) { - t.Error("One second later: Expected token to be valid") - } - if !validTokenAtTime(tok, key, userID, actionID, now.Add(Timeout-1*time.Nanosecond)) { - t.Error("Just before timeout: Expected token to be valid") - } - if !validTokenAtTime(tok, key, userID, actionID, now.Add(-1*time.Minute+1*time.Millisecond)) { - t.Error("One minute in the past: Expected token to be valid") - } -} - -// TestSeparatorReplacement tests that separators are being correctly substituted -func TestSeparatorReplacement(t *testing.T) { - tok := generateTokenAtTime("foo:bar", "baz", "wah", now) - tok2 := generateTokenAtTime("foo", "bar:baz", "wah", now) - if tok == tok2 { - t.Errorf("Expected generated tokens to be different") - } -} - -func TestInvalidToken(t *testing.T) { - invalidTokenTests := []struct { - name, key, userID, actionID string - t time.Time - }{ - {"Bad key", "foobar", userID, actionID, oneMinuteFromNow}, - {"Bad userID", key, "foobar", actionID, oneMinuteFromNow}, - {"Bad actionID", key, userID, "foobar", oneMinuteFromNow}, - {"Expired", key, userID, actionID, now.Add(Timeout + 1*time.Millisecond)}, - {"More than 1 minute from the future", key, userID, actionID, now.Add(-1*time.Nanosecond - 1*time.Minute)}, - } - - tok := generateTokenAtTime(key, userID, actionID, now) - for _, itt := range invalidTokenTests { - if validTokenAtTime(tok, itt.key, itt.userID, itt.actionID, itt.t) { - t.Errorf("%v: Expected token to be invalid", itt.name) - } - } -} - -// TestValidateBadData primarily tests that no unexpected panics are triggered -// during parsing -func TestValidateBadData(t *testing.T) { - badDataTests := []struct { - name, tok string - }{ - {"Invalid Base64", "ASDab24(@)$*=="}, - {"No delimiter", base64.URLEncoding.EncodeToString([]byte("foobar12345678"))}, - {"Invalid time", base64.URLEncoding.EncodeToString([]byte("foobar:foobar"))}, - {"Wrong length", "1234" + generateTokenAtTime(key, userID, actionID, now)}, - } - - for _, bdt := range badDataTests { - if validTokenAtTime(bdt.tok, key, userID, actionID, oneMinuteFromNow) { - t.Errorf("%v: Expected token to be invalid", bdt.name) - } - } -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/.gitignore b/vendor/gopkg.in/natefinch/lumberjack.v2/.gitignore deleted file mode 100644 index 8365624..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/LICENSE b/vendor/gopkg.in/natefinch/lumberjack.v2/LICENSE deleted file mode 100644 index c3d4cc3..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 Nate Finch - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/README.md b/vendor/gopkg.in/natefinch/lumberjack.v2/README.md deleted file mode 100644 index 9f8e698..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/README.md +++ /dev/null @@ -1,166 +0,0 @@ -# lumberjack [![GoDoc](https://godoc.org/gopkg.in/natefinch/lumberjack.v2?status.png)](https://godoc.org/gopkg.in/natefinch/lumberjack.v2) [![Build Status](https://drone.io/github.com/natefinch/lumberjack/status.png)](https://drone.io/github.com/natefinch/lumberjack/latest) [![Build status](https://ci.appveyor.com/api/projects/status/00gchpxtg4gkrt5d)](https://ci.appveyor.com/project/natefinch/lumberjack) [![Coverage Status](https://coveralls.io/repos/natefinch/lumberjack/badge.svg?branch=v2.0)](https://coveralls.io/r/natefinch/lumberjack?branch=v2.0) - -### Lumberjack is a Go package for writing logs to rolling files. - -Package lumberjack provides a rolling logger. - -Note that this is v2.0 of lumberjack, and should be imported using gopkg.in -thusly: - - import "gopkg.in/natefinch/lumberjack.v2" - -The package name remains simply lumberjack, and the code resides at -https://github.com/natefinch/lumberjack under the v2.0 branch. - -Lumberjack is intended to be one part of a logging infrastructure. -It is not an all-in-one solution, but instead is a pluggable -component at the bottom of the logging stack that simply controls the files -to which logs are written. - -Lumberjack plays well with any logging package that can write to an -io.Writer, including the standard library's log package. - -Lumberjack assumes that only one process is writing to the output files. -Using the same lumberjack configuration from multiple processes on the same -machine will result in improper behavior. - - -**Example** - -To use lumberjack with the standard library's log package, just pass it into the SetOutput function when your application starts. - -Code: - -```go -log.SetOutput(&lumberjack.Logger{ - Filename: "/var/log/myapp/foo.log", - MaxSize: 500, // megabytes - MaxBackups: 3, - MaxAge: 28, //days -}) -``` - - - -## type Logger -``` go -type Logger struct { - // Filename is the file to write logs to. Backup log files will be retained - // in the same directory. It uses -lumberjack.log in - // os.TempDir() if empty. - Filename string `json:"filename" yaml:"filename"` - - // MaxSize is the maximum size in megabytes of the log file before it gets - // rotated. It defaults to 100 megabytes. - MaxSize int `json:"maxsize" yaml:"maxsize"` - - // MaxAge is the maximum number of days to retain old log files based on the - // timestamp encoded in their filename. Note that a day is defined as 24 - // hours and may not exactly correspond to calendar days due to daylight - // savings, leap seconds, etc. The default is not to remove old log files - // based on age. - MaxAge int `json:"maxage" yaml:"maxage"` - - // MaxBackups is the maximum number of old log files to retain. The default - // is to retain all old log files (though MaxAge may still cause them to get - // deleted.) - MaxBackups int `json:"maxbackups" yaml:"maxbackups"` - - // LocalTime determines if the time used for formatting the timestamps in - // backup files is the computer's local time. The default is to use UTC - // time. - LocalTime bool `json:"localtime" yaml:"localtime"` - // contains filtered or unexported fields -} -``` -Logger is an io.WriteCloser that writes to the specified filename. - -Logger opens or creates the logfile on first Write. If the file exists and -is less than MaxSize megabytes, lumberjack will open and append to that file. -If the file exists and its size is >= MaxSize megabytes, the file is renamed -by putting the current time in a timestamp in the name immediately before the -file's extension (or the end of the filename if there's no extension). A new -log file is then created using original filename. - -Whenever a write would cause the current log file exceed MaxSize megabytes, -the current file is closed, renamed, and a new log file created with the -original name. Thus, the filename you give Logger is always the "current" log -file. - -### Cleaning Up Old Log Files -Whenever a new logfile gets created, old log files may be deleted. The most -recent files according to the encoded timestamp will be retained, up to a -number equal to MaxBackups (or all of them if MaxBackups is 0). Any files -with an encoded timestamp older than MaxAge days are deleted, regardless of -MaxBackups. Note that the time encoded in the timestamp is the rotation -time, which may differ from the last time that file was written to. - -If MaxBackups and MaxAge are both 0, no old log files will be deleted. - - - - - - - - - - - -### func (\*Logger) Close -``` go -func (l *Logger) Close() error -``` -Close implements io.Closer, and closes the current logfile. - - - -### func (\*Logger) Rotate -``` go -func (l *Logger) Rotate() error -``` -Rotate causes Logger to close the existing log file and immediately create a -new one. This is a helper function for applications that want to initiate -rotations outside of the normal rotation rules, such as in response to -SIGHUP. After rotating, this initiates a cleanup of old log files according -to the normal rules. - -**Example** - -Example of how to rotate in response to SIGHUP. - -Code: - -```go -l := &lumberjack.Logger{} -log.SetOutput(l) -c := make(chan os.Signal, 1) -signal.Notify(c, syscall.SIGHUP) - -go func() { - for { - <-c - l.Rotate() - } -}() -``` - -### func (\*Logger) Write -``` go -func (l *Logger) Write(p []byte) (n int, err error) -``` -Write implements io.Writer. If a write would cause the log file to be larger -than MaxSize, the file is closed, renamed to include a timestamp of the -current time, and a new log file is created using the original log file name. -If the length of the write is greater than MaxSize, an error is returned. - - - - - - - - - -- - - -Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md) diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/chown.go b/vendor/gopkg.in/natefinch/lumberjack.v2/chown.go deleted file mode 100644 index 11d0669..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/chown.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !linux - -package lumberjack - -import ( - "os" -) - -func chown(_ string, _ os.FileInfo) error { - return nil -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go b/vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go deleted file mode 100644 index 2758ec9..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/chown_linux.go +++ /dev/null @@ -1,19 +0,0 @@ -package lumberjack - -import ( - "os" - "syscall" -) - -// os_Chown is a var so we can mock it out during tests. -var os_Chown = os.Chown - -func chown(name string, info os.FileInfo) error { - f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, info.Mode()) - if err != nil { - return err - } - f.Close() - stat := info.Sys().(*syscall.Stat_t) - return os_Chown(name, int(stat.Uid), int(stat.Gid)) -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/example_test.go b/vendor/gopkg.in/natefinch/lumberjack.v2/example_test.go deleted file mode 100644 index bf689fd..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/example_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package lumberjack_test - -import ( - "log" - - "gopkg.in/natefinch/lumberjack.v2" -) - -// To use lumberjack with the standard library's log package, just pass it into -// the SetOutput function when your application starts. -func Example() { - log.SetOutput(&lumberjack.Logger{ - Filename: "/var/log/myapp/foo.log", - MaxSize: 500, // megabytes - MaxBackups: 3, - MaxAge: 28, // days - }) -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/linux_test.go b/vendor/gopkg.in/natefinch/lumberjack.v2/linux_test.go deleted file mode 100644 index 40f3446..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/linux_test.go +++ /dev/null @@ -1,104 +0,0 @@ -// +build linux - -package lumberjack - -import ( - "os" - "syscall" - "testing" -) - -func TestMaintainMode(t *testing.T) { - currentTime = fakeTime - dir := makeTempDir("TestMaintainMode", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - - mode := os.FileMode(0770) - f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, mode) - isNil(err, t) - f.Close() - - l := &Logger{ - Filename: filename, - MaxBackups: 1, - MaxSize: 100, // megabytes - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - newFakeTime() - - err = l.Rotate() - isNil(err, t) - - filename2 := backupFile(dir) - info, err := os.Stat(filename) - isNil(err, t) - info2, err := os.Stat(filename2) - isNil(err, t) - equals(mode, info.Mode(), t) - equals(mode, info2.Mode(), t) -} - -func TestMaintainOwner(t *testing.T) { - fakeC := fakeChown{} - os_Chown = fakeC.Set - os_Stat = fakeStat - defer func() { - os_Chown = os.Chown - os_Stat = os.Stat - }() - currentTime = fakeTime - dir := makeTempDir("TestMaintainOwner", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - - l := &Logger{ - Filename: filename, - MaxBackups: 1, - MaxSize: 100, // megabytes - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - newFakeTime() - - err = l.Rotate() - isNil(err, t) - - equals(555, fakeC.uid, t) - equals(666, fakeC.gid, t) -} - -type fakeChown struct { - name string - uid int - gid int -} - -func (f *fakeChown) Set(name string, uid, gid int) error { - f.name = name - f.uid = uid - f.gid = gid - return nil -} - -func fakeStat(name string) (os.FileInfo, error) { - info, err := os.Stat(name) - if err != nil { - return info, err - } - stat := info.Sys().(*syscall.Stat_t) - stat.Uid = 555 - stat.Gid = 666 - return info, nil -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack.go b/vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack.go deleted file mode 100644 index 7014444..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack.go +++ /dev/null @@ -1,417 +0,0 @@ -// Package lumberjack provides a rolling logger. -// -// Note that this is v2.0 of lumberjack, and should be imported using gopkg.in -// thusly: -// -// import "gopkg.in/natefinch/lumberjack.v2" -// -// The package name remains simply lumberjack, and the code resides at -// https://github.com/natefinch/lumberjack under the v2.0 branch. -// -// Lumberjack is intended to be one part of a logging infrastructure. -// It is not an all-in-one solution, but instead is a pluggable -// component at the bottom of the logging stack that simply controls the files -// to which logs are written. -// -// Lumberjack plays well with any logging package that can write to an -// io.Writer, including the standard library's log package. -// -// Lumberjack assumes that only one process is writing to the output files. -// Using the same lumberjack configuration from multiple processes on the same -// machine will result in improper behavior. -package lumberjack - -import ( - "fmt" - "io" - "io/ioutil" - "os" - "path/filepath" - "sort" - "strings" - "sync" - "time" -) - -const ( - backupTimeFormat = "2006-01-02T15-04-05.000" - defaultMaxSize = 100 -) - -// ensure we always implement io.WriteCloser -var _ io.WriteCloser = (*Logger)(nil) - -// Logger is an io.WriteCloser that writes to the specified filename. -// -// Logger opens or creates the logfile on first Write. If the file exists and -// is less than MaxSize megabytes, lumberjack will open and append to that file. -// If the file exists and its size is >= MaxSize megabytes, the file is renamed -// by putting the current time in a timestamp in the name immediately before the -// file's extension (or the end of the filename if there's no extension). A new -// log file is then created using original filename. -// -// Whenever a write would cause the current log file exceed MaxSize megabytes, -// the current file is closed, renamed, and a new log file created with the -// original name. Thus, the filename you give Logger is always the "current" log -// file. -// -// Cleaning Up Old Log Files -// -// Whenever a new logfile gets created, old log files may be deleted. The most -// recent files according to the encoded timestamp will be retained, up to a -// number equal to MaxBackups (or all of them if MaxBackups is 0). Any files -// with an encoded timestamp older than MaxAge days are deleted, regardless of -// MaxBackups. Note that the time encoded in the timestamp is the rotation -// time, which may differ from the last time that file was written to. -// -// If MaxBackups and MaxAge are both 0, no old log files will be deleted. -type Logger struct { - // Filename is the file to write logs to. Backup log files will be retained - // in the same directory. It uses -lumberjack.log in - // os.TempDir() if empty. - Filename string `json:"filename" yaml:"filename"` - - // MaxSize is the maximum size in megabytes of the log file before it gets - // rotated. It defaults to 100 megabytes. - MaxSize int `json:"maxsize" yaml:"maxsize"` - - // MaxAge is the maximum number of days to retain old log files based on the - // timestamp encoded in their filename. Note that a day is defined as 24 - // hours and may not exactly correspond to calendar days due to daylight - // savings, leap seconds, etc. The default is not to remove old log files - // based on age. - MaxAge int `json:"maxage" yaml:"maxage"` - - // MaxBackups is the maximum number of old log files to retain. The default - // is to retain all old log files (though MaxAge may still cause them to get - // deleted.) - MaxBackups int `json:"maxbackups" yaml:"maxbackups"` - - // LocalTime determines if the time used for formatting the timestamps in - // backup files is the computer's local time. The default is to use UTC - // time. - LocalTime bool `json:"localtime" yaml:"localtime"` - - size int64 - file *os.File - mu sync.Mutex -} - -var ( - // currentTime exists so it can be mocked out by tests. - currentTime = time.Now - - // os_Stat exists so it can be mocked out by tests. - os_Stat = os.Stat - - // megabyte is the conversion factor between MaxSize and bytes. It is a - // variable so tests can mock it out and not need to write megabytes of data - // to disk. - megabyte = 1024 * 1024 -) - -// Write implements io.Writer. If a write would cause the log file to be larger -// than MaxSize, the file is closed, renamed to include a timestamp of the -// current time, and a new log file is created using the original log file name. -// If the length of the write is greater than MaxSize, an error is returned. -func (l *Logger) Write(p []byte) (n int, err error) { - l.mu.Lock() - defer l.mu.Unlock() - - writeLen := int64(len(p)) - if writeLen > l.max() { - return 0, fmt.Errorf( - "write length %d exceeds maximum file size %d", writeLen, l.max(), - ) - } - - if l.file == nil { - if err = l.openExistingOrNew(len(p)); err != nil { - return 0, err - } - } - - if l.size+writeLen > l.max() { - if err := l.rotate(); err != nil { - return 0, err - } - } - - n, err = l.file.Write(p) - l.size += int64(n) - - return n, err -} - -// Close implements io.Closer, and closes the current logfile. -func (l *Logger) Close() error { - l.mu.Lock() - defer l.mu.Unlock() - return l.close() -} - -// close closes the file if it is open. -func (l *Logger) close() error { - if l.file == nil { - return nil - } - err := l.file.Close() - l.file = nil - return err -} - -// Rotate causes Logger to close the existing log file and immediately create a -// new one. This is a helper function for applications that want to initiate -// rotations outside of the normal rotation rules, such as in response to -// SIGHUP. After rotating, this initiates a cleanup of old log files according -// to the normal rules. -func (l *Logger) Rotate() error { - l.mu.Lock() - defer l.mu.Unlock() - return l.rotate() -} - -// rotate closes the current file, moves it aside with a timestamp in the name, -// (if it exists), opens a new file with the original filename, and then runs -// cleanup. -func (l *Logger) rotate() error { - if err := l.close(); err != nil { - return err - } - - if err := l.openNew(); err != nil { - return err - } - return l.cleanup() -} - -// openNew opens a new log file for writing, moving any old log file out of the -// way. This methods assumes the file has already been closed. -func (l *Logger) openNew() error { - err := os.MkdirAll(l.dir(), 0744) - if err != nil { - return fmt.Errorf("can't make directories for new logfile: %s", err) - } - - name := l.filename() - mode := os.FileMode(0644) - info, err := os_Stat(name) - if err == nil { - // Copy the mode off the old logfile. - mode = info.Mode() - // move the existing file - newname := backupName(name, l.LocalTime) - if err := os.Rename(name, newname); err != nil { - return fmt.Errorf("can't rename log file: %s", err) - } - - // this is a no-op anywhere but linux - if err := chown(name, info); err != nil { - return err - } - } - - // we use truncate here because this should only get called when we've moved - // the file ourselves. if someone else creates the file in the meantime, - // just wipe out the contents. - f, err := os.OpenFile(name, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, mode) - if err != nil { - return fmt.Errorf("can't open new logfile: %s", err) - } - l.file = f - l.size = 0 - return nil -} - -// backupName creates a new filename from the given name, inserting a timestamp -// between the filename and the extension, using the local time if requested -// (otherwise UTC). -func backupName(name string, local bool) string { - dir := filepath.Dir(name) - filename := filepath.Base(name) - ext := filepath.Ext(filename) - prefix := filename[:len(filename)-len(ext)] - t := currentTime() - if !local { - t = t.UTC() - } - - timestamp := t.Format(backupTimeFormat) - return filepath.Join(dir, fmt.Sprintf("%s-%s%s", prefix, timestamp, ext)) -} - -// openExistingOrNew opens the logfile if it exists and if the current write -// would not put it over MaxSize. If there is no such file or the write would -// put it over the MaxSize, a new file is created. -func (l *Logger) openExistingOrNew(writeLen int) error { - filename := l.filename() - info, err := os_Stat(filename) - if os.IsNotExist(err) { - return l.openNew() - } - if err != nil { - return fmt.Errorf("error getting log file info: %s", err) - } - - if info.Size()+int64(writeLen) >= l.max() { - return l.rotate() - } - - file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0644) - if err != nil { - // if we fail to open the old log file for some reason, just ignore - // it and open a new log file. - return l.openNew() - } - l.file = file - l.size = info.Size() - return nil -} - -// genFilename generates the name of the logfile from the current time. -func (l *Logger) filename() string { - if l.Filename != "" { - return l.Filename - } - name := filepath.Base(os.Args[0]) + "-lumberjack.log" - return filepath.Join(os.TempDir(), name) -} - -// cleanup deletes old log files, keeping at most l.MaxBackups files, as long as -// none of them are older than MaxAge. -func (l *Logger) cleanup() error { - if l.MaxBackups == 0 && l.MaxAge == 0 { - return nil - } - - files, err := l.oldLogFiles() - if err != nil { - return err - } - - var deletes []logInfo - - if l.MaxBackups > 0 && l.MaxBackups < len(files) { - deletes = files[l.MaxBackups:] - files = files[:l.MaxBackups] - } - if l.MaxAge > 0 { - diff := time.Duration(int64(24*time.Hour) * int64(l.MaxAge)) - - cutoff := currentTime().Add(-1 * diff) - - for _, f := range files { - if f.timestamp.Before(cutoff) { - deletes = append(deletes, f) - } - } - } - - if len(deletes) == 0 { - return nil - } - - go deleteAll(l.dir(), deletes) - - return nil -} - -func deleteAll(dir string, files []logInfo) { - // remove files on a separate goroutine - for _, f := range files { - // what am I going to do, log this? - _ = os.Remove(filepath.Join(dir, f.Name())) - } -} - -// oldLogFiles returns the list of backup log files stored in the same -// directory as the current log file, sorted by ModTime -func (l *Logger) oldLogFiles() ([]logInfo, error) { - files, err := ioutil.ReadDir(l.dir()) - if err != nil { - return nil, fmt.Errorf("can't read log file directory: %s", err) - } - logFiles := []logInfo{} - - prefix, ext := l.prefixAndExt() - - for _, f := range files { - if f.IsDir() { - continue - } - name := l.timeFromName(f.Name(), prefix, ext) - if name == "" { - continue - } - t, err := time.Parse(backupTimeFormat, name) - if err == nil { - logFiles = append(logFiles, logInfo{t, f}) - } - // error parsing means that the suffix at the end was not generated - // by lumberjack, and therefore it's not a backup file. - } - - sort.Sort(byFormatTime(logFiles)) - - return logFiles, nil -} - -// timeFromName extracts the formatted time from the filename by stripping off -// the filename's prefix and extension. This prevents someone's filename from -// confusing time.parse. -func (l *Logger) timeFromName(filename, prefix, ext string) string { - if !strings.HasPrefix(filename, prefix) { - return "" - } - filename = filename[len(prefix):] - - if !strings.HasSuffix(filename, ext) { - return "" - } - filename = filename[:len(filename)-len(ext)] - return filename -} - -// max returns the maximum size in bytes of log files before rolling. -func (l *Logger) max() int64 { - if l.MaxSize == 0 { - return int64(defaultMaxSize * megabyte) - } - return int64(l.MaxSize) * int64(megabyte) -} - -// dir returns the directory for the current filename. -func (l *Logger) dir() string { - return filepath.Dir(l.filename()) -} - -// prefixAndExt returns the filename part and extension part from the Logger's -// filename. -func (l *Logger) prefixAndExt() (prefix, ext string) { - filename := filepath.Base(l.filename()) - ext = filepath.Ext(filename) - prefix = filename[:len(filename)-len(ext)] + "-" - return prefix, ext -} - -// logInfo is a convenience struct to return the filename and its embedded -// timestamp. -type logInfo struct { - timestamp time.Time - os.FileInfo -} - -// byFormatTime sorts by newest time formatted in the name. -type byFormatTime []logInfo - -func (b byFormatTime) Less(i, j int) bool { - return b[i].timestamp.After(b[j].timestamp) -} - -func (b byFormatTime) Swap(i, j int) { - b[i], b[j] = b[j], b[i] -} - -func (b byFormatTime) Len() int { - return len(b) -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack_test.go b/vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack_test.go deleted file mode 100644 index 8c0e685..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/lumberjack_test.go +++ /dev/null @@ -1,690 +0,0 @@ -package lumberjack - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "testing" - "time" - - "github.com/BurntSushi/toml" - "gopkg.in/yaml.v2" -) - -// !!!NOTE!!! -// -// Running these tests in parallel will almost certainly cause sporadic (or even -// regular) failures, because they're all messing with the same global variable -// that controls the logic's mocked time.Now. So... don't do that. - -// Since all the tests uses the time to determine filenames etc, we need to -// control the wall clock as much as possible, which means having a wall clock -// that doesn't change unless we want it to. -var fakeCurrentTime = time.Now() - -func fakeTime() time.Time { - return fakeCurrentTime -} - -func TestNewFile(t *testing.T) { - currentTime = fakeTime - - dir := makeTempDir("TestNewFile", t) - defer os.RemoveAll(dir) - l := &Logger{ - Filename: logFile(dir), - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - existsWithLen(logFile(dir), n, t) - fileCount(dir, 1, t) -} - -func TestOpenExisting(t *testing.T) { - currentTime = fakeTime - dir := makeTempDir("TestOpenExisting", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - data := []byte("foo!") - err := ioutil.WriteFile(filename, data, 0644) - isNil(err, t) - existsWithLen(filename, len(data), t) - - l := &Logger{ - Filename: filename, - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - // make sure the file got appended - existsWithLen(filename, len(data)+n, t) - - // make sure no other files were created - fileCount(dir, 1, t) -} - -func TestWriteTooLong(t *testing.T) { - currentTime = fakeTime - megabyte = 1 - dir := makeTempDir("TestWriteTooLong", t) - defer os.RemoveAll(dir) - l := &Logger{ - Filename: logFile(dir), - MaxSize: 5, - } - defer l.Close() - b := []byte("booooooooooooooo!") - n, err := l.Write(b) - notNil(err, t) - equals(0, n, t) - equals(err.Error(), - fmt.Sprintf("write length %d exceeds maximum file size %d", len(b), l.MaxSize), t) - _, err = os.Stat(logFile(dir)) - assert(os.IsNotExist(err), t, "File exists, but should not have been created") -} - -func TestMakeLogDir(t *testing.T) { - currentTime = fakeTime - dir := time.Now().Format("TestMakeLogDir" + backupTimeFormat) - dir = filepath.Join(os.TempDir(), dir) - defer os.RemoveAll(dir) - filename := logFile(dir) - l := &Logger{ - Filename: filename, - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - existsWithLen(logFile(dir), n, t) - fileCount(dir, 1, t) -} - -func TestDefaultFilename(t *testing.T) { - currentTime = fakeTime - dir := os.TempDir() - filename := filepath.Join(dir, filepath.Base(os.Args[0])+"-lumberjack.log") - defer os.Remove(filename) - l := &Logger{} - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - - isNil(err, t) - equals(len(b), n, t) - existsWithLen(filename, n, t) -} - -func TestAutoRotate(t *testing.T) { - currentTime = fakeTime - megabyte = 1 - - dir := makeTempDir("TestAutoRotate", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - l := &Logger{ - Filename: filename, - MaxSize: 10, - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - existsWithLen(filename, n, t) - fileCount(dir, 1, t) - - newFakeTime() - - b2 := []byte("foooooo!") - n, err = l.Write(b2) - isNil(err, t) - equals(len(b2), n, t) - - // the old logfile should be moved aside and the main logfile should have - // only the last write in it. - existsWithLen(filename, n, t) - - // the backup file will use the current fake time and have the old contents. - existsWithLen(backupFile(dir), len(b), t) - - fileCount(dir, 2, t) -} - -func TestFirstWriteRotate(t *testing.T) { - currentTime = fakeTime - megabyte = 1 - dir := makeTempDir("TestFirstWriteRotate", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - l := &Logger{ - Filename: filename, - MaxSize: 10, - } - defer l.Close() - - start := []byte("boooooo!") - err := ioutil.WriteFile(filename, start, 0600) - isNil(err, t) - - newFakeTime() - - // this would make us rotate - b := []byte("fooo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - existsWithLen(filename, n, t) - existsWithLen(backupFile(dir), len(start), t) - - fileCount(dir, 2, t) -} - -func TestMaxBackups(t *testing.T) { - currentTime = fakeTime - megabyte = 1 - dir := makeTempDir("TestMaxBackups", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - l := &Logger{ - Filename: filename, - MaxSize: 10, - MaxBackups: 1, - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - existsWithLen(filename, n, t) - fileCount(dir, 1, t) - - newFakeTime() - - // this will put us over the max - b2 := []byte("foooooo!") - n, err = l.Write(b2) - isNil(err, t) - equals(len(b2), n, t) - - // this will use the new fake time - secondFilename := backupFile(dir) - existsWithLen(secondFilename, len(b), t) - - // make sure the old file still exists with the same size. - existsWithLen(filename, n, t) - - fileCount(dir, 2, t) - - newFakeTime() - - // this will make us rotate again - n, err = l.Write(b2) - isNil(err, t) - equals(len(b2), n, t) - - // this will use the new fake time - thirdFilename := backupFile(dir) - existsWithLen(thirdFilename, len(b2), t) - - existsWithLen(filename, n, t) - - // we need to wait a little bit since the files get deleted on a different - // goroutine. - <-time.After(time.Millisecond * 10) - - // should only have two files in the dir still - fileCount(dir, 2, t) - - // second file name should still exist - existsWithLen(thirdFilename, len(b2), t) - - // should have deleted the first backup - notExist(secondFilename, t) - - // now test that we don't delete directories or non-logfile files - - newFakeTime() - - // create a file that is close to but different from the logfile name. - // It shouldn't get caught by our deletion filters. - notlogfile := logFile(dir) + ".foo" - err = ioutil.WriteFile(notlogfile, []byte("data"), 0644) - isNil(err, t) - - // Make a directory that exactly matches our log file filters... it still - // shouldn't get caught by the deletion filter since it's a directory. - notlogfiledir := backupFile(dir) - err = os.Mkdir(notlogfiledir, 0700) - isNil(err, t) - - newFakeTime() - - // this will make us rotate again - n, err = l.Write(b2) - isNil(err, t) - equals(len(b2), n, t) - - // this will use the new fake time - fourthFilename := backupFile(dir) - existsWithLen(fourthFilename, len(b2), t) - - // we need to wait a little bit since the files get deleted on a different - // goroutine. - <-time.After(time.Millisecond * 10) - - // We should have four things in the directory now - the 2 log files, the - // not log file, and the directory - fileCount(dir, 4, t) - - // third file name should still exist - existsWithLen(filename, n, t) - - existsWithLen(fourthFilename, len(b2), t) - - // should have deleted the first filename - notExist(thirdFilename, t) - - // the not-a-logfile should still exist - exists(notlogfile, t) - - // the directory - exists(notlogfiledir, t) -} - -func TestCleanupExistingBackups(t *testing.T) { - // test that if we start with more backup files than we're supposed to have - // in total, that extra ones get cleaned up when we rotate. - - currentTime = fakeTime - megabyte = 1 - - dir := makeTempDir("TestCleanupExistingBackups", t) - defer os.RemoveAll(dir) - - // make 3 backup files - - data := []byte("data") - backup := backupFile(dir) - err := ioutil.WriteFile(backup, data, 0644) - isNil(err, t) - - newFakeTime() - - backup = backupFile(dir) - err = ioutil.WriteFile(backup, data, 0644) - isNil(err, t) - - newFakeTime() - - backup = backupFile(dir) - err = ioutil.WriteFile(backup, data, 0644) - isNil(err, t) - - // now create a primary log file with some data - filename := logFile(dir) - err = ioutil.WriteFile(filename, data, 0644) - isNil(err, t) - - l := &Logger{ - Filename: filename, - MaxSize: 10, - MaxBackups: 1, - } - defer l.Close() - - newFakeTime() - - b2 := []byte("foooooo!") - n, err := l.Write(b2) - isNil(err, t) - equals(len(b2), n, t) - - // we need to wait a little bit since the files get deleted on a different - // goroutine. - <-time.After(time.Millisecond * 10) - - // now we should only have 2 files left - the primary and one backup - fileCount(dir, 2, t) -} - -func TestMaxAge(t *testing.T) { - currentTime = fakeTime - megabyte = 1 - - dir := makeTempDir("TestMaxAge", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - l := &Logger{ - Filename: filename, - MaxSize: 10, - MaxAge: 1, - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - existsWithLen(filename, n, t) - fileCount(dir, 1, t) - - // two days later - newFakeTime() - - b2 := []byte("foooooo!") - n, err = l.Write(b2) - isNil(err, t) - equals(len(b2), n, t) - existsWithLen(backupFile(dir), len(b), t) - - // we need to wait a little bit since the files get deleted on a different - // goroutine. - <-time.After(10 * time.Millisecond) - - // We should still have 2 log files, since the most recent backup was just - // created. - fileCount(dir, 2, t) - - existsWithLen(filename, len(b2), t) - - // we should have deleted the old file due to being too old - existsWithLen(backupFile(dir), len(b), t) - - // two days later - newFakeTime() - - b3 := []byte("foooooo!") - n, err = l.Write(b2) - isNil(err, t) - equals(len(b3), n, t) - existsWithLen(backupFile(dir), len(b2), t) - - // we need to wait a little bit since the files get deleted on a different - // goroutine. - <-time.After(10 * time.Millisecond) - - // We should have 2 log files - the main log file, and the most recent - // backup. The earlier backup is past the cutoff and should be gone. - fileCount(dir, 2, t) - - existsWithLen(filename, len(b3), t) - - // we should have deleted the old file due to being too old - existsWithLen(backupFile(dir), len(b2), t) - -} - -func TestOldLogFiles(t *testing.T) { - currentTime = fakeTime - megabyte = 1 - - dir := makeTempDir("TestOldLogFiles", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - data := []byte("data") - err := ioutil.WriteFile(filename, data, 07) - isNil(err, t) - - // This gives us a time with the same precision as the time we get from the - // timestamp in the name. - t1, err := time.Parse(backupTimeFormat, fakeTime().UTC().Format(backupTimeFormat)) - isNil(err, t) - - backup := backupFile(dir) - err = ioutil.WriteFile(backup, data, 07) - isNil(err, t) - - newFakeTime() - - t2, err := time.Parse(backupTimeFormat, fakeTime().UTC().Format(backupTimeFormat)) - isNil(err, t) - - backup2 := backupFile(dir) - err = ioutil.WriteFile(backup2, data, 07) - isNil(err, t) - - l := &Logger{Filename: filename} - files, err := l.oldLogFiles() - isNil(err, t) - equals(2, len(files), t) - - // should be sorted by newest file first, which would be t2 - equals(t2, files[0].timestamp, t) - equals(t1, files[1].timestamp, t) -} - -func TestTimeFromName(t *testing.T) { - l := &Logger{Filename: "/var/log/myfoo/foo.log"} - prefix, ext := l.prefixAndExt() - val := l.timeFromName("foo-2014-05-04T14-44-33.555.log", prefix, ext) - equals("2014-05-04T14-44-33.555", val, t) - - val = l.timeFromName("foo-2014-05-04T14-44-33.555", prefix, ext) - equals("", val, t) - - val = l.timeFromName("2014-05-04T14-44-33.555.log", prefix, ext) - equals("", val, t) - - val = l.timeFromName("foo.log", prefix, ext) - equals("", val, t) -} - -func TestLocalTime(t *testing.T) { - currentTime = fakeTime - megabyte = 1 - - dir := makeTempDir("TestLocalTime", t) - defer os.RemoveAll(dir) - - l := &Logger{ - Filename: logFile(dir), - MaxSize: 10, - LocalTime: true, - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - b2 := []byte("fooooooo!") - n2, err := l.Write(b2) - isNil(err, t) - equals(len(b2), n2, t) - - existsWithLen(logFile(dir), n2, t) - existsWithLen(backupFileLocal(dir), n, t) -} - -func TestRotate(t *testing.T) { - currentTime = fakeTime - dir := makeTempDir("TestRotate", t) - defer os.RemoveAll(dir) - - filename := logFile(dir) - - l := &Logger{ - Filename: filename, - MaxBackups: 1, - MaxSize: 100, // megabytes - } - defer l.Close() - b := []byte("boo!") - n, err := l.Write(b) - isNil(err, t) - equals(len(b), n, t) - - existsWithLen(filename, n, t) - fileCount(dir, 1, t) - - newFakeTime() - - err = l.Rotate() - isNil(err, t) - - // we need to wait a little bit since the files get deleted on a different - // goroutine. - <-time.After(10 * time.Millisecond) - - filename2 := backupFile(dir) - existsWithLen(filename2, n, t) - existsWithLen(filename, 0, t) - fileCount(dir, 2, t) - newFakeTime() - - err = l.Rotate() - isNil(err, t) - - // we need to wait a little bit since the files get deleted on a different - // goroutine. - <-time.After(10 * time.Millisecond) - - filename3 := backupFile(dir) - existsWithLen(filename3, 0, t) - existsWithLen(filename, 0, t) - fileCount(dir, 2, t) - - b2 := []byte("foooooo!") - n, err = l.Write(b2) - isNil(err, t) - equals(len(b2), n, t) - - // this will use the new fake time - existsWithLen(filename, n, t) -} - -func TestJson(t *testing.T) { - data := []byte(` -{ - "filename": "foo", - "maxsize": 5, - "maxage": 10, - "maxbackups": 3, - "localtime": true -}`[1:]) - - l := Logger{} - err := json.Unmarshal(data, &l) - isNil(err, t) - equals("foo", l.Filename, t) - equals(5, l.MaxSize, t) - equals(10, l.MaxAge, t) - equals(3, l.MaxBackups, t) - equals(true, l.LocalTime, t) -} - -func TestYaml(t *testing.T) { - data := []byte(` -filename: foo -maxsize: 5 -maxage: 10 -maxbackups: 3 -localtime: true`[1:]) - - l := Logger{} - err := yaml.Unmarshal(data, &l) - isNil(err, t) - equals("foo", l.Filename, t) - equals(5, l.MaxSize, t) - equals(10, l.MaxAge, t) - equals(3, l.MaxBackups, t) - equals(true, l.LocalTime, t) -} - -func TestToml(t *testing.T) { - data := ` -filename = "foo" -maxsize = 5 -maxage = 10 -maxbackups = 3 -localtime = true`[1:] - - l := Logger{} - md, err := toml.Decode(data, &l) - isNil(err, t) - equals("foo", l.Filename, t) - equals(5, l.MaxSize, t) - equals(10, l.MaxAge, t) - equals(3, l.MaxBackups, t) - equals(true, l.LocalTime, t) - equals(0, len(md.Undecoded()), t) -} - -// makeTempDir creates a file with a semi-unique name in the OS temp directory. -// It should be based on the name of the test, to keep parallel tests from -// colliding, and must be cleaned up after the test is finished. -func makeTempDir(name string, t testing.TB) string { - dir := time.Now().Format(name + backupTimeFormat) - dir = filepath.Join(os.TempDir(), dir) - isNilUp(os.Mkdir(dir, 0777), t, 1) - return dir -} - -// existsWithLen checks that the given file exists and has the correct length. -func existsWithLen(path string, length int, t testing.TB) { - info, err := os.Stat(path) - isNilUp(err, t, 1) - equalsUp(int64(length), info.Size(), t, 1) -} - -// logFile returns the log file name in the given directory for the current fake -// time. -func logFile(dir string) string { - return filepath.Join(dir, "foobar.log") -} - -func backupFile(dir string) string { - return filepath.Join(dir, "foobar-"+fakeTime().UTC().Format(backupTimeFormat)+".log") -} - -func backupFileLocal(dir string) string { - return filepath.Join(dir, "foobar-"+fakeTime().Format(backupTimeFormat)+".log") -} - -// logFileLocal returns the log file name in the given directory for the current -// fake time using the local timezone. -func logFileLocal(dir string) string { - return filepath.Join(dir, fakeTime().Format(backupTimeFormat)) -} - -// fileCount checks that the number of files in the directory is exp. -func fileCount(dir string, exp int, t testing.TB) { - files, err := ioutil.ReadDir(dir) - isNilUp(err, t, 1) - // Make sure no other files were created. - equalsUp(exp, len(files), t, 1) -} - -// newFakeTime sets the fake "current time" to two days later. -func newFakeTime() { - fakeCurrentTime = fakeCurrentTime.Add(time.Hour * 24 * 2) -} - -func notExist(path string, t testing.TB) { - _, err := os.Stat(path) - assertUp(os.IsNotExist(err), t, 1, "expected to get os.IsNotExist, but instead got %v", err) -} - -func exists(path string, t testing.TB) { - _, err := os.Stat(path) - assertUp(err == nil, t, 1, "expected file to exist, but got error from os.Stat: %v", err) -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/rotate_test.go b/vendor/gopkg.in/natefinch/lumberjack.v2/rotate_test.go deleted file mode 100644 index 4bd4325..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/rotate_test.go +++ /dev/null @@ -1,27 +0,0 @@ -// +build linux - -package lumberjack_test - -import ( - "log" - "os" - "os/signal" - "syscall" - - "gopkg.in/natefinch/lumberjack.v2" -) - -// Example of how to rotate in response to SIGHUP. -func ExampleLogger_Rotate() { - l := &lumberjack.Logger{} - log.SetOutput(l) - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGHUP) - - go func() { - for { - <-c - l.Rotate() - } - }() -} diff --git a/vendor/gopkg.in/natefinch/lumberjack.v2/testing_test.go b/vendor/gopkg.in/natefinch/lumberjack.v2/testing_test.go deleted file mode 100644 index 8e89c08..0000000 --- a/vendor/gopkg.in/natefinch/lumberjack.v2/testing_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package lumberjack - -import ( - "fmt" - "path/filepath" - "reflect" - "runtime" - "testing" -) - -// assert will log the given message if condition is false. -func assert(condition bool, t testing.TB, msg string, v ...interface{}) { - assertUp(condition, t, 1, msg, v...) -} - -// assertUp is like assert, but used inside helper functions, to ensure that -// the file and line number reported by failures corresponds to one or more -// levels up the stack. -func assertUp(condition bool, t testing.TB, caller int, msg string, v ...interface{}) { - if !condition { - _, file, line, _ := runtime.Caller(caller + 1) - v = append([]interface{}{filepath.Base(file), line}, v...) - fmt.Printf("%s:%d: "+msg+"\n", v...) - t.FailNow() - } -} - -// equals tests that the two values are equal according to reflect.DeepEqual. -func equals(exp, act interface{}, t testing.TB) { - equalsUp(exp, act, t, 1) -} - -// equalsUp is like equals, but used inside helper functions, to ensure that the -// file and line number reported by failures corresponds to one or more levels -// up the stack. -func equalsUp(exp, act interface{}, t testing.TB, caller int) { - if !reflect.DeepEqual(exp, act) { - _, file, line, _ := runtime.Caller(caller + 1) - fmt.Printf("%s:%d: exp: %v (%T), got: %v (%T)\n", - filepath.Base(file), line, exp, exp, act, act) - t.FailNow() - } -} - -// isNil reports a failure if the given value is not nil. Note that values -// which cannot be nil will always fail this check. -func isNil(obtained interface{}, t testing.TB) { - isNilUp(obtained, t, 1) -} - -// isNilUp is like isNil, but used inside helper functions, to ensure that the -// file and line number reported by failures corresponds to one or more levels -// up the stack. -func isNilUp(obtained interface{}, t testing.TB, caller int) { - if !_isNil(obtained) { - _, file, line, _ := runtime.Caller(caller + 1) - fmt.Printf("%s:%d: expected nil, got: %v\n", filepath.Base(file), line, obtained) - t.FailNow() - } -} - -// notNil reports a failure if the given value is nil. -func notNil(obtained interface{}, t testing.TB) { - notNilUp(obtained, t, 1) -} - -// notNilUp is like notNil, but used inside helper functions, to ensure that the -// file and line number reported by failures corresponds to one or more levels -// up the stack. -func notNilUp(obtained interface{}, t testing.TB, caller int) { - if _isNil(obtained) { - _, file, line, _ := runtime.Caller(caller + 1) - fmt.Printf("%s:%d: expected non-nil, got: %v\n", filepath.Base(file), line, obtained) - t.FailNow() - } -} - -// _isNil is a helper function for isNil and notNil, and should not be used -// directly. -func _isNil(obtained interface{}) bool { - if obtained == nil { - return true - } - - switch v := reflect.ValueOf(obtained); v.Kind() { - case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: - return v.IsNil() - } - - return false -} diff --git a/vendor/gopkg.in/square/go-jose.v1/.gitcookies.sh.enc b/vendor/gopkg.in/square/go-jose.v1/.gitcookies.sh.enc deleted file mode 100644 index 730e569..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/.gitcookies.sh.enc +++ /dev/null @@ -1 +0,0 @@ -'|Ê&{tÄU|gGê(ìCy=+¨œòcû:u:/pœ#~žü["±4¤!­nÙAªDK<ŠufÿhÅa¿Â:ºü¸¡´B/£Ø¤¹¤ò_hÎÛSãT*wÌx¼¯¹-ç|àÀÓƒÑÄäóÌ㣗A$$â6£ÁâG)8nÏpûÆË¡3ÌšœoïÏvŽB–3¿­]xÝ“Ó2l§G•|qRÞ¯ ö2 5R–Ó×Ç$´ñ½Yè¡ÞÝ™l‘Ë«yAI"ÛŒ˜®íû¹¼kÄ|Kåþ[9ÆâÒå=°úÿŸñ|@S•3 ó#æx?¾V„,¾‚SÆÝõœwPíogÒ6&V6 ©D.dBŠ 7 \ No newline at end of file diff --git a/vendor/gopkg.in/square/go-jose.v1/.gitignore b/vendor/gopkg.in/square/go-jose.v1/.gitignore deleted file mode 100644 index 5b4d73b..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*~ -.*.swp -*.out -*.test -*.pem -*.cov -jose-util/jose-util diff --git a/vendor/gopkg.in/square/go-jose.v1/.travis.yml b/vendor/gopkg.in/square/go-jose.v1/.travis.yml deleted file mode 100644 index 7582bb7..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/.travis.yml +++ /dev/null @@ -1,45 +0,0 @@ -language: go - -sudo: false - -matrix: - fast_finish: true - allow_failures: - - go: tip - -go: -- 1.3 -- 1.4 -- 1.5 -- 1.6 -- tip - -go_import_path: gopkg.in/square/go-jose.v1 - -before_script: -- export PATH=$HOME/.local/bin:$PATH - -before_install: -# Install encrypted gitcookies to get around bandwidth-limits -# that is causing Travis-CI builds to fail. For more info, see -# https://github.com/golang/go/issues/12933 -- openssl aes-256-cbc -K $encrypted_1528c3c2cafd_key -iv $encrypted_1528c3c2cafd_iv -in .gitcookies.sh.enc -out .gitcookies.sh -d || true -- bash .gitcookies.sh || true -- go get github.com/wadey/gocovmerge -- go get github.com/mattn/goveralls -- go get golang.org/x/tools/cmd/cover || true -- go get code.google.com/p/go.tools/cmd/cover || true -- pip install cram --user `whoami` - -script: -- go test . -v -covermode=count -coverprofile=profile.cov -- go test . -tags std_json -v -covermode=count -coverprofile=profile-std-json.cov -- go test ./cipher -v -covermode=count -coverprofile=cipher/profile.cov -- go test ./json -v # no coverage for forked encoding/json package -- cd jose-util && go build && PATH=$PWD:$PATH cram -v jose-util.t -- cd .. - -after_success: -- gocovmerge *.cov */*.cov > merged.coverprofile -- $HOME/gopath/bin/goveralls -coverprofile merged.coverprofile -service=travis-ci - diff --git a/vendor/gopkg.in/square/go-jose.v1/BUG-BOUNTY.md b/vendor/gopkg.in/square/go-jose.v1/BUG-BOUNTY.md deleted file mode 100644 index 97e61db..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/BUG-BOUNTY.md +++ /dev/null @@ -1,10 +0,0 @@ -Serious about security -====================== - -Square recognizes the important contributions the security research community -can make. We therefore encourage reporting security issues with the code -contained in this repository. - -If you believe you have discovered a security vulnerability, please follow the -guidelines at . - diff --git a/vendor/gopkg.in/square/go-jose.v1/CONTRIBUTING.md b/vendor/gopkg.in/square/go-jose.v1/CONTRIBUTING.md deleted file mode 100644 index 61b1836..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/CONTRIBUTING.md +++ /dev/null @@ -1,14 +0,0 @@ -# Contributing - -If you would like to contribute code to go-jose you can do so through GitHub by -forking the repository and sending a pull request. - -When submitting code, please make every effort to follow existing conventions -and style in order to keep the code as readable as possible. Please also make -sure all tests pass by running `go test`, and format your code with `go fmt`. -We also recommend using `golint` and `errcheck`. - -Before your code can be accepted into the project you must also sign the -[Individual Contributor License Agreement][1]. - - [1]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1 diff --git a/vendor/gopkg.in/square/go-jose.v1/LICENSE b/vendor/gopkg.in/square/go-jose.v1/LICENSE deleted file mode 100644 index d645695..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/gopkg.in/square/go-jose.v1/README.md b/vendor/gopkg.in/square/go-jose.v1/README.md deleted file mode 100644 index fd859da..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/README.md +++ /dev/null @@ -1,209 +0,0 @@ -# Go JOSE - -[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/gopkg.in/square/go-jose.v1) [![license](http://img.shields.io/badge/license-apache_2.0-red.svg?style=flat)](https://raw.githubusercontent.com/square/go-jose/master/LICENSE) [![build](https://travis-ci.org/square/go-jose.svg?branch=master)](https://travis-ci.org/square/go-jose) [![coverage](https://coveralls.io/repos/github/square/go-jose/badge.svg?branch=master)](https://coveralls.io/r/square/go-jose) - -Package jose aims to provide an implementation of the Javascript Object Signing -and Encryption set of standards. For the moment, it mainly focuses on encryption -and signing based on the JSON Web Encryption and JSON Web Signature standards. - -**Disclaimer**: This library contains encryption software that is subject to -the U.S. Export Administration Regulations. You may not export, re-export, -transfer or download this code or any part of it in violation of any United -States law, directive or regulation. In particular this software may not be -exported or re-exported in any form or on any media to Iran, North Sudan, -Syria, Cuba, or North Korea, or to denied persons or entities mentioned on any -US maintained blocked list. - -## Overview - -The implementation follows the -[JSON Web Encryption](http://dx.doi.org/10.17487/RFC7516) -standard (RFC 7516) and -[JSON Web Signature](http://dx.doi.org/10.17487/RFC7515) -standard (RFC 7515). Tables of supported algorithms are shown below. -The library supports both the compact and full serialization formats, and has -optional support for multiple recipients. It also comes with a small -command-line utility -([`jose-util`](https://github.com/square/go-jose/tree/master/jose-util)) -for dealing with JOSE messages in a shell. - -**Note**: We use a forked version of the `encoding/json` package from the Go -standard library which uses case-sensitive matching for member names (instead -of [case-insensitive matching](https://www.ietf.org/mail-archive/web/json/current/msg03763.html)). -This is to avoid differences in interpretation of messages between go-jose and -libraries in other languages. If you do not like this behavior, you can use the -`std_json` build tag to disable it (though we do not recommend doing so). - -### Versions - -We use [gopkg.in](https://gopkg.in) for versioning. - -[Version 1](https://gopkg.in/square/go-jose.v1) is the current stable version: - - import "gopkg.in/square/go-jose.v1" - -The interface for [go-jose.v1](https://gopkg.in/square/go-jose.v1) will remain -backwards compatible. We're currently sketching out ideas for a new version, to -clean up the interface a bit. If you have ideas or feature requests [please let -us know](https://github.com/square/go-jose/issues/64)! - -### Supported algorithms - -See below for a table of supported algorithms. Algorithm identifiers match -the names in the -[JSON Web Algorithms](http://dx.doi.org/10.17487/RFC7518) -standard where possible. The -[Godoc reference](https://godoc.org/github.com/square/go-jose#pkg-constants) -has a list of constants. - - Key encryption | Algorithm identifier(s) - :------------------------- | :------------------------------ - RSA-PKCS#1v1.5 | RSA1_5 - RSA-OAEP | RSA-OAEP, RSA-OAEP-256 - AES key wrap | A128KW, A192KW, A256KW - AES-GCM key wrap | A128GCMKW, A192GCMKW, A256GCMKW - ECDH-ES + AES key wrap | ECDH-ES+A128KW, ECDH-ES+A192KW, ECDH-ES+A256KW - ECDH-ES (direct) | ECDH-ES1 - Direct encryption | dir1 - -1. Not supported in multi-recipient mode - - Signing / MAC | Algorithm identifier(s) - :------------------------- | :------------------------------ - RSASSA-PKCS#1v1.5 | RS256, RS384, RS512 - RSASSA-PSS | PS256, PS384, PS512 - HMAC | HS256, HS384, HS512 - ECDSA | ES256, ES384, ES512 - - Content encryption | Algorithm identifier(s) - :------------------------- | :------------------------------ - AES-CBC+HMAC | A128CBC-HS256, A192CBC-HS384, A256CBC-HS512 - AES-GCM | A128GCM, A192GCM, A256GCM - - Compression | Algorithm identifiers(s) - :------------------------- | ------------------------------- - DEFLATE (RFC 1951) | DEF - -### Supported key types - -See below for a table of supported key types. These are understood by the -library, and can be passed to corresponding functions such as `NewEncrypter` or -`NewSigner`. Note that if you are creating a new encrypter or signer with a -JsonWebKey, the key id of the JsonWebKey (if present) will be added to any -resulting messages. - - Algorithm(s) | Corresponding types - :------------------------- | ------------------------------- - RSA | *[rsa.PublicKey](http://golang.org/pkg/crypto/rsa/#PublicKey), *[rsa.PrivateKey](http://golang.org/pkg/crypto/rsa/#PrivateKey), *[jose.JsonWebKey](https://godoc.org/github.com/square/go-jose#JsonWebKey) - ECDH, ECDSA | *[ecdsa.PublicKey](http://golang.org/pkg/crypto/ecdsa/#PublicKey), *[ecdsa.PrivateKey](http://golang.org/pkg/crypto/ecdsa/#PrivateKey), *[jose.JsonWebKey](https://godoc.org/github.com/square/go-jose#JsonWebKey) - AES, HMAC | []byte, *[jose.JsonWebKey](https://godoc.org/github.com/square/go-jose#JsonWebKey) - -## Examples - -Encryption/decryption example using RSA: - -```Go -// Generate a public/private key pair to use for this example. The library -// also provides two utility functions (LoadPublicKey and LoadPrivateKey) -// that can be used to load keys from PEM/DER-encoded data. -privateKey, err := rsa.GenerateKey(rand.Reader, 2048) -if err != nil { - panic(err) -} - -// Instantiate an encrypter using RSA-OAEP with AES128-GCM. An error would -// indicate that the selected algorithm(s) are not currently supported. -publicKey := &privateKey.PublicKey -encrypter, err := NewEncrypter(RSA_OAEP, A128GCM, publicKey) -if err != nil { - panic(err) -} - -// Encrypt a sample plaintext. Calling the encrypter returns an encrypted -// JWE object, which can then be serialized for output afterwards. An error -// would indicate a problem in an underlying cryptographic primitive. -var plaintext = []byte("Lorem ipsum dolor sit amet") -object, err := encrypter.Encrypt(plaintext) -if err != nil { - panic(err) -} - -// Serialize the encrypted object using the full serialization format. -// Alternatively you can also use the compact format here by calling -// object.CompactSerialize() instead. -serialized := object.FullSerialize() - -// Parse the serialized, encrypted JWE object. An error would indicate that -// the given input did not represent a valid message. -object, err = ParseEncrypted(serialized) -if err != nil { - panic(err) -} - -// Now we can decrypt and get back our original plaintext. An error here -// would indicate the the message failed to decrypt, e.g. because the auth -// tag was broken or the message was tampered with. -decrypted, err := object.Decrypt(privateKey) -if err != nil { - panic(err) -} - -fmt.Printf(string(decrypted)) -// output: Lorem ipsum dolor sit amet -``` - -Signing/verification example using RSA: - -```Go -// Generate a public/private key pair to use for this example. The library -// also provides two utility functions (LoadPublicKey and LoadPrivateKey) -// that can be used to load keys from PEM/DER-encoded data. -privateKey, err := rsa.GenerateKey(rand.Reader, 2048) -if err != nil { - panic(err) -} - -// Instantiate a signer using RSASSA-PSS (SHA512) with the given private key. -signer, err := NewSigner(PS512, privateKey) -if err != nil { - panic(err) -} - -// Sign a sample payload. Calling the signer returns a protected JWS object, -// which can then be serialized for output afterwards. An error would -// indicate a problem in an underlying cryptographic primitive. -var payload = []byte("Lorem ipsum dolor sit amet") -object, err := signer.Sign(payload) -if err != nil { - panic(err) -} - -// Serialize the encrypted object using the full serialization format. -// Alternatively you can also use the compact format here by calling -// object.CompactSerialize() instead. -serialized := object.FullSerialize() - -// Parse the serialized, protected JWS object. An error would indicate that -// the given input did not represent a valid message. -object, err = ParseSigned(serialized) -if err != nil { - panic(err) -} - -// Now we can verify the signature on the payload. An error here would -// indicate the the message failed to verify, e.g. because the signature was -// broken or the message was tampered with. -output, err := object.Verify(&privateKey.PublicKey) -if err != nil { - panic(err) -} - -fmt.Printf(string(output)) -// output: Lorem ipsum dolor sit amet -``` - -More examples can be found in the [Godoc -reference](https://godoc.org/github.com/square/go-jose) for this package. The -[`jose-util`](https://github.com/square/go-jose/tree/master/jose-util) -subdirectory also contains a small command-line utility which might -be useful as an example. diff --git a/vendor/gopkg.in/square/go-jose.v1/asymmetric.go b/vendor/gopkg.in/square/go-jose.v1/asymmetric.go deleted file mode 100644 index 381156c..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/asymmetric.go +++ /dev/null @@ -1,498 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose - -import ( - "crypto" - "crypto/aes" - "crypto/ecdsa" - "crypto/rand" - "crypto/rsa" - "crypto/sha1" - "crypto/sha256" - "errors" - "fmt" - "math/big" - - "gopkg.in/square/go-jose.v1/cipher" -) - -// A generic RSA-based encrypter/verifier -type rsaEncrypterVerifier struct { - publicKey *rsa.PublicKey -} - -// A generic RSA-based decrypter/signer -type rsaDecrypterSigner struct { - privateKey *rsa.PrivateKey -} - -// A generic EC-based encrypter/verifier -type ecEncrypterVerifier struct { - publicKey *ecdsa.PublicKey -} - -// A key generator for ECDH-ES -type ecKeyGenerator struct { - size int - algID string - publicKey *ecdsa.PublicKey -} - -// A generic EC-based decrypter/signer -type ecDecrypterSigner struct { - privateKey *ecdsa.PrivateKey -} - -// newRSARecipient creates recipientKeyInfo based on the given key. -func newRSARecipient(keyAlg KeyAlgorithm, publicKey *rsa.PublicKey) (recipientKeyInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch keyAlg { - case RSA1_5, RSA_OAEP, RSA_OAEP_256: - default: - return recipientKeyInfo{}, ErrUnsupportedAlgorithm - } - - return recipientKeyInfo{ - keyAlg: keyAlg, - keyEncrypter: &rsaEncrypterVerifier{ - publicKey: publicKey, - }, - }, nil -} - -// newRSASigner creates a recipientSigInfo based on the given key. -func newRSASigner(sigAlg SignatureAlgorithm, privateKey *rsa.PrivateKey) (recipientSigInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch sigAlg { - case RS256, RS384, RS512, PS256, PS384, PS512: - default: - return recipientSigInfo{}, ErrUnsupportedAlgorithm - } - - return recipientSigInfo{ - sigAlg: sigAlg, - publicKey: &JsonWebKey{ - Key: &privateKey.PublicKey, - }, - signer: &rsaDecrypterSigner{ - privateKey: privateKey, - }, - }, nil -} - -// newECDHRecipient creates recipientKeyInfo based on the given key. -func newECDHRecipient(keyAlg KeyAlgorithm, publicKey *ecdsa.PublicKey) (recipientKeyInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch keyAlg { - case ECDH_ES, ECDH_ES_A128KW, ECDH_ES_A192KW, ECDH_ES_A256KW: - default: - return recipientKeyInfo{}, ErrUnsupportedAlgorithm - } - - return recipientKeyInfo{ - keyAlg: keyAlg, - keyEncrypter: &ecEncrypterVerifier{ - publicKey: publicKey, - }, - }, nil -} - -// newECDSASigner creates a recipientSigInfo based on the given key. -func newECDSASigner(sigAlg SignatureAlgorithm, privateKey *ecdsa.PrivateKey) (recipientSigInfo, error) { - // Verify that key management algorithm is supported by this encrypter - switch sigAlg { - case ES256, ES384, ES512: - default: - return recipientSigInfo{}, ErrUnsupportedAlgorithm - } - - return recipientSigInfo{ - sigAlg: sigAlg, - publicKey: &JsonWebKey{ - Key: &privateKey.PublicKey, - }, - signer: &ecDecrypterSigner{ - privateKey: privateKey, - }, - }, nil -} - -// Encrypt the given payload and update the object. -func (ctx rsaEncrypterVerifier) encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error) { - encryptedKey, err := ctx.encrypt(cek, alg) - if err != nil { - return recipientInfo{}, err - } - - return recipientInfo{ - encryptedKey: encryptedKey, - header: &rawHeader{}, - }, nil -} - -// Encrypt the given payload. Based on the key encryption algorithm, -// this will either use RSA-PKCS1v1.5 or RSA-OAEP (with SHA-1 or SHA-256). -func (ctx rsaEncrypterVerifier) encrypt(cek []byte, alg KeyAlgorithm) ([]byte, error) { - switch alg { - case RSA1_5: - return rsa.EncryptPKCS1v15(randReader, ctx.publicKey, cek) - case RSA_OAEP: - return rsa.EncryptOAEP(sha1.New(), randReader, ctx.publicKey, cek, []byte{}) - case RSA_OAEP_256: - return rsa.EncryptOAEP(sha256.New(), randReader, ctx.publicKey, cek, []byte{}) - } - - return nil, ErrUnsupportedAlgorithm -} - -// Decrypt the given payload and return the content encryption key. -func (ctx rsaDecrypterSigner) decryptKey(headers rawHeader, recipient *recipientInfo, generator keyGenerator) ([]byte, error) { - return ctx.decrypt(recipient.encryptedKey, KeyAlgorithm(headers.Alg), generator) -} - -// Decrypt the given payload. Based on the key encryption algorithm, -// this will either use RSA-PKCS1v1.5 or RSA-OAEP (with SHA-1 or SHA-256). -func (ctx rsaDecrypterSigner) decrypt(jek []byte, alg KeyAlgorithm, generator keyGenerator) ([]byte, error) { - // Note: The random reader on decrypt operations is only used for blinding, - // so stubbing is meanlingless (hence the direct use of rand.Reader). - switch alg { - case RSA1_5: - defer func() { - // DecryptPKCS1v15SessionKey sometimes panics on an invalid payload - // because of an index out of bounds error, which we want to ignore. - // This has been fixed in Go 1.3.1 (released 2014/08/13), the recover() - // only exists for preventing crashes with unpatched versions. - // See: https://groups.google.com/forum/#!topic/golang-dev/7ihX6Y6kx9k - // See: https://code.google.com/p/go/source/detail?r=58ee390ff31602edb66af41ed10901ec95904d33 - _ = recover() - }() - - // Perform some input validation. - keyBytes := ctx.privateKey.PublicKey.N.BitLen() / 8 - if keyBytes != len(jek) { - // Input size is incorrect, the encrypted payload should always match - // the size of the public modulus (e.g. using a 2048 bit key will - // produce 256 bytes of output). Reject this since it's invalid input. - return nil, ErrCryptoFailure - } - - cek, _, err := generator.genKey() - if err != nil { - return nil, ErrCryptoFailure - } - - // When decrypting an RSA-PKCS1v1.5 payload, we must take precautions to - // prevent chosen-ciphertext attacks as described in RFC 3218, "Preventing - // the Million Message Attack on Cryptographic Message Syntax". We are - // therefore deliberatly ignoring errors here. - _ = rsa.DecryptPKCS1v15SessionKey(rand.Reader, ctx.privateKey, jek, cek) - - return cek, nil - case RSA_OAEP: - // Use rand.Reader for RSA blinding - return rsa.DecryptOAEP(sha1.New(), rand.Reader, ctx.privateKey, jek, []byte{}) - case RSA_OAEP_256: - // Use rand.Reader for RSA blinding - return rsa.DecryptOAEP(sha256.New(), rand.Reader, ctx.privateKey, jek, []byte{}) - } - - return nil, ErrUnsupportedAlgorithm -} - -// Sign the given payload -func (ctx rsaDecrypterSigner) signPayload(payload []byte, alg SignatureAlgorithm) (Signature, error) { - var hash crypto.Hash - - switch alg { - case RS256, PS256: - hash = crypto.SHA256 - case RS384, PS384: - hash = crypto.SHA384 - case RS512, PS512: - hash = crypto.SHA512 - default: - return Signature{}, ErrUnsupportedAlgorithm - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - var out []byte - var err error - - switch alg { - case RS256, RS384, RS512: - out, err = rsa.SignPKCS1v15(randReader, ctx.privateKey, hash, hashed) - case PS256, PS384, PS512: - out, err = rsa.SignPSS(randReader, ctx.privateKey, hash, hashed, &rsa.PSSOptions{ - SaltLength: rsa.PSSSaltLengthAuto, - }) - } - - if err != nil { - return Signature{}, err - } - - return Signature{ - Signature: out, - protected: &rawHeader{}, - }, nil -} - -// Verify the given payload -func (ctx rsaEncrypterVerifier) verifyPayload(payload []byte, signature []byte, alg SignatureAlgorithm) error { - var hash crypto.Hash - - switch alg { - case RS256, PS256: - hash = crypto.SHA256 - case RS384, PS384: - hash = crypto.SHA384 - case RS512, PS512: - hash = crypto.SHA512 - default: - return ErrUnsupportedAlgorithm - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - switch alg { - case RS256, RS384, RS512: - return rsa.VerifyPKCS1v15(ctx.publicKey, hash, hashed, signature) - case PS256, PS384, PS512: - return rsa.VerifyPSS(ctx.publicKey, hash, hashed, signature, nil) - } - - return ErrUnsupportedAlgorithm -} - -// Encrypt the given payload and update the object. -func (ctx ecEncrypterVerifier) encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error) { - switch alg { - case ECDH_ES: - // ECDH-ES mode doesn't wrap a key, the shared secret is used directly as the key. - return recipientInfo{ - header: &rawHeader{}, - }, nil - case ECDH_ES_A128KW, ECDH_ES_A192KW, ECDH_ES_A256KW: - default: - return recipientInfo{}, ErrUnsupportedAlgorithm - } - - generator := ecKeyGenerator{ - algID: string(alg), - publicKey: ctx.publicKey, - } - - switch alg { - case ECDH_ES_A128KW: - generator.size = 16 - case ECDH_ES_A192KW: - generator.size = 24 - case ECDH_ES_A256KW: - generator.size = 32 - } - - kek, header, err := generator.genKey() - if err != nil { - return recipientInfo{}, err - } - - block, err := aes.NewCipher(kek) - if err != nil { - return recipientInfo{}, err - } - - jek, err := josecipher.KeyWrap(block, cek) - if err != nil { - return recipientInfo{}, err - } - - return recipientInfo{ - encryptedKey: jek, - header: &header, - }, nil -} - -// Get key size for EC key generator -func (ctx ecKeyGenerator) keySize() int { - return ctx.size -} - -// Get a content encryption key for ECDH-ES -func (ctx ecKeyGenerator) genKey() ([]byte, rawHeader, error) { - priv, err := ecdsa.GenerateKey(ctx.publicKey.Curve, randReader) - if err != nil { - return nil, rawHeader{}, err - } - - out := josecipher.DeriveECDHES(ctx.algID, []byte{}, []byte{}, priv, ctx.publicKey, ctx.size) - - headers := rawHeader{ - Epk: &JsonWebKey{ - Key: &priv.PublicKey, - }, - } - - return out, headers, nil -} - -// Decrypt the given payload and return the content encryption key. -func (ctx ecDecrypterSigner) decryptKey(headers rawHeader, recipient *recipientInfo, generator keyGenerator) ([]byte, error) { - if headers.Epk == nil { - return nil, errors.New("square/go-jose: missing epk header") - } - - publicKey, ok := headers.Epk.Key.(*ecdsa.PublicKey) - if publicKey == nil || !ok { - return nil, errors.New("square/go-jose: invalid epk header") - } - - apuData := headers.Apu.bytes() - apvData := headers.Apv.bytes() - - deriveKey := func(algID string, size int) []byte { - return josecipher.DeriveECDHES(algID, apuData, apvData, ctx.privateKey, publicKey, size) - } - - var keySize int - - switch KeyAlgorithm(headers.Alg) { - case ECDH_ES: - // ECDH-ES uses direct key agreement, no key unwrapping necessary. - return deriveKey(string(headers.Enc), generator.keySize()), nil - case ECDH_ES_A128KW: - keySize = 16 - case ECDH_ES_A192KW: - keySize = 24 - case ECDH_ES_A256KW: - keySize = 32 - default: - return nil, ErrUnsupportedAlgorithm - } - - key := deriveKey(headers.Alg, keySize) - block, err := aes.NewCipher(key) - if err != nil { - return nil, err - } - - return josecipher.KeyUnwrap(block, recipient.encryptedKey) -} - -// Sign the given payload -func (ctx ecDecrypterSigner) signPayload(payload []byte, alg SignatureAlgorithm) (Signature, error) { - var expectedBitSize int - var hash crypto.Hash - - switch alg { - case ES256: - expectedBitSize = 256 - hash = crypto.SHA256 - case ES384: - expectedBitSize = 384 - hash = crypto.SHA384 - case ES512: - expectedBitSize = 521 - hash = crypto.SHA512 - } - - curveBits := ctx.privateKey.Curve.Params().BitSize - if expectedBitSize != curveBits { - return Signature{}, fmt.Errorf("square/go-jose: expected %d bit key, got %d bits instead", expectedBitSize, curveBits) - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - r, s, err := ecdsa.Sign(randReader, ctx.privateKey, hashed) - if err != nil { - return Signature{}, err - } - - keyBytes := curveBits / 8 - if curveBits%8 > 0 { - keyBytes += 1 - } - - // We serialize the outpus (r and s) into big-endian byte arrays and pad - // them with zeros on the left to make sure the sizes work out. Both arrays - // must be keyBytes long, and the output must be 2*keyBytes long. - rBytes := r.Bytes() - rBytesPadded := make([]byte, keyBytes) - copy(rBytesPadded[keyBytes-len(rBytes):], rBytes) - - sBytes := s.Bytes() - sBytesPadded := make([]byte, keyBytes) - copy(sBytesPadded[keyBytes-len(sBytes):], sBytes) - - out := append(rBytesPadded, sBytesPadded...) - - return Signature{ - Signature: out, - protected: &rawHeader{}, - }, nil -} - -// Verify the given payload -func (ctx ecEncrypterVerifier) verifyPayload(payload []byte, signature []byte, alg SignatureAlgorithm) error { - var keySize int - var hash crypto.Hash - - switch alg { - case ES256: - keySize = 32 - hash = crypto.SHA256 - case ES384: - keySize = 48 - hash = crypto.SHA384 - case ES512: - keySize = 66 - hash = crypto.SHA512 - } - - if len(signature) != 2*keySize { - return fmt.Errorf("square/go-jose: invalid signature size, have %d bytes, wanted %d", len(signature), 2*keySize) - } - - hasher := hash.New() - - // According to documentation, Write() on hash never fails - _, _ = hasher.Write(payload) - hashed := hasher.Sum(nil) - - r := big.NewInt(0).SetBytes(signature[:keySize]) - s := big.NewInt(0).SetBytes(signature[keySize:]) - - match := ecdsa.Verify(ctx.publicKey, hashed, r, s) - if !match { - return errors.New("square/go-jose: ecdsa signature failed to verify") - } - - return nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/asymmetric_test.go b/vendor/gopkg.in/square/go-jose.v1/asymmetric_test.go deleted file mode 100644 index 1c8c8b3..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/asymmetric_test.go +++ /dev/null @@ -1,431 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose - -import ( - "bytes" - "crypto/rand" - "crypto/rsa" - "errors" - "io" - "math/big" - "testing" -) - -func TestVectorsRSA(t *testing.T) { - // Sources: - // http://www.emc.com/emc-plus/rsa-labs/standards-initiatives/pkcs-rsa-cryptography-standard.htm - // ftp://ftp.rsa.com/pub/rsalabs/tmp/pkcs1v15crypt-vectors.txt - priv := &rsa.PrivateKey{ - PublicKey: rsa.PublicKey{ - N: fromHexInt(` - a8b3b284af8eb50b387034a860f146c4919f318763cd6c5598c8 - ae4811a1e0abc4c7e0b082d693a5e7fced675cf4668512772c0c - bc64a742c6c630f533c8cc72f62ae833c40bf25842e984bb78bd - bf97c0107d55bdb662f5c4e0fab9845cb5148ef7392dd3aaff93 - ae1e6b667bb3d4247616d4f5ba10d4cfd226de88d39f16fb`), - E: 65537, - }, - D: fromHexInt(` - 53339cfdb79fc8466a655c7316aca85c55fd8f6dd898fdaf1195 - 17ef4f52e8fd8e258df93fee180fa0e4ab29693cd83b152a553d - 4ac4d1812b8b9fa5af0e7f55fe7304df41570926f3311f15c4d6 - 5a732c483116ee3d3d2d0af3549ad9bf7cbfb78ad884f84d5beb - 04724dc7369b31def37d0cf539e9cfcdd3de653729ead5d1`), - Primes: []*big.Int{ - fromHexInt(` - d32737e7267ffe1341b2d5c0d150a81b586fb3132bed2f8d5262 - 864a9cb9f30af38be448598d413a172efb802c21acf1c11c520c - 2f26a471dcad212eac7ca39d`), - fromHexInt(` - cc8853d1d54da630fac004f471f281c7b8982d8224a490edbeb3 - 3d3e3d5cc93c4765703d1dd791642f1f116a0dd852be2419b2af - 72bfe9a030e860b0288b5d77`), - }, - } - - input := fromHexBytes( - "6628194e12073db03ba94cda9ef9532397d50dba79b987004afefe34") - - expectedPKCS := fromHexBytes(` - 50b4c14136bd198c2f3c3ed243fce036e168d56517984a263cd66492b808 - 04f169d210f2b9bdfb48b12f9ea05009c77da257cc600ccefe3a6283789d - 8ea0e607ac58e2690ec4ebc10146e8cbaa5ed4d5cce6fe7b0ff9efc1eabb - 564dbf498285f449ee61dd7b42ee5b5892cb90601f30cda07bf26489310b - cd23b528ceab3c31`) - - expectedOAEP := fromHexBytes(` - 354fe67b4a126d5d35fe36c777791a3f7ba13def484e2d3908aff722fad4 - 68fb21696de95d0be911c2d3174f8afcc201035f7b6d8e69402de5451618 - c21a535fa9d7bfc5b8dd9fc243f8cf927db31322d6e881eaa91a996170e6 - 57a05a266426d98c88003f8477c1227094a0d9fa1e8c4024309ce1ecccb5 - 210035d47ac72e8a`) - - // Mock random reader - randReader = bytes.NewReader(fromHexBytes(` - 017341ae3875d5f87101f8cc4fa9b9bc156bb04628fccdb2f4f11e905bd3 - a155d376f593bd7304210874eba08a5e22bcccb4c9d3882a93a54db022f5 - 03d16338b6b7ce16dc7f4bbf9a96b59772d6606e9747c7649bf9e083db98 - 1884a954ab3c6f18b776ea21069d69776a33e96bad48e1dda0a5ef`)) - defer resetRandReader() - - // RSA-PKCS1v1.5 encrypt - enc := new(rsaEncrypterVerifier) - enc.publicKey = &priv.PublicKey - encryptedPKCS, err := enc.encrypt(input, RSA1_5) - if err != nil { - t.Error("Encryption failed:", err) - return - } - - if bytes.Compare(encryptedPKCS, expectedPKCS) != 0 { - t.Error("Output does not match expected value (PKCS1v1.5)") - } - - // RSA-OAEP encrypt - encryptedOAEP, err := enc.encrypt(input, RSA_OAEP) - if err != nil { - t.Error("Encryption failed:", err) - return - } - - if bytes.Compare(encryptedOAEP, expectedOAEP) != 0 { - t.Error("Output does not match expected value (OAEP)") - } - - // Need fake cipher for PKCS1v1.5 decrypt - resetRandReader() - aes := newAESGCM(len(input)) - - keygen := randomKeyGenerator{ - size: aes.keySize(), - } - - // RSA-PKCS1v1.5 decrypt - dec := new(rsaDecrypterSigner) - dec.privateKey = priv - decryptedPKCS, err := dec.decrypt(encryptedPKCS, RSA1_5, keygen) - if err != nil { - t.Error("Decryption failed:", err) - return - } - - if bytes.Compare(input, decryptedPKCS) != 0 { - t.Error("Output does not match expected value (PKCS1v1.5)") - } - - // RSA-OAEP decrypt - decryptedOAEP, err := dec.decrypt(encryptedOAEP, RSA_OAEP, keygen) - if err != nil { - t.Error("decryption failed:", err) - return - } - - if bytes.Compare(input, decryptedOAEP) != 0 { - t.Error("output does not match expected value (OAEP)") - } -} - -func TestInvalidAlgorithmsRSA(t *testing.T) { - _, err := newRSARecipient("XYZ", nil) - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } - - _, err = newRSASigner("XYZ", nil) - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } - - enc := new(rsaEncrypterVerifier) - enc.publicKey = &rsaTestKey.PublicKey - _, err = enc.encryptKey([]byte{}, "XYZ") - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } - - err = enc.verifyPayload([]byte{}, []byte{}, "XYZ") - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } - - dec := new(rsaDecrypterSigner) - dec.privateKey = rsaTestKey - _, err = dec.decrypt(make([]byte, 256), "XYZ", randomKeyGenerator{size: 16}) - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } - - _, err = dec.signPayload([]byte{}, "XYZ") - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } -} - -type failingKeyGenerator struct{} - -func (ctx failingKeyGenerator) keySize() int { - return 0 -} - -func (ctx failingKeyGenerator) genKey() ([]byte, rawHeader, error) { - return nil, rawHeader{}, errors.New("failed to generate key") -} - -func TestPKCSKeyGeneratorFailure(t *testing.T) { - dec := new(rsaDecrypterSigner) - dec.privateKey = rsaTestKey - generator := failingKeyGenerator{} - _, err := dec.decrypt(make([]byte, 256), RSA1_5, generator) - if err != ErrCryptoFailure { - t.Error("should return error on invalid algorithm") - } -} - -func TestInvalidAlgorithmsEC(t *testing.T) { - _, err := newECDHRecipient("XYZ", nil) - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } - - _, err = newECDSASigner("XYZ", nil) - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } - - enc := new(ecEncrypterVerifier) - enc.publicKey = &ecTestKey256.PublicKey - _, err = enc.encryptKey([]byte{}, "XYZ") - if err != ErrUnsupportedAlgorithm { - t.Error("should return error on invalid algorithm") - } -} - -func TestInvalidECKeyGen(t *testing.T) { - gen := ecKeyGenerator{ - size: 16, - algID: "A128GCM", - publicKey: &ecTestKey256.PublicKey, - } - - if gen.keySize() != 16 { - t.Error("ec key generator reported incorrect key size") - } - - _, _, err := gen.genKey() - if err != nil { - t.Error("ec key generator failed to generate key", err) - } -} - -func TestInvalidECDecrypt(t *testing.T) { - dec := ecDecrypterSigner{ - privateKey: ecTestKey256, - } - - generator := randomKeyGenerator{size: 16} - - // Missing epk header - headers := rawHeader{ - Alg: string(ECDH_ES), - } - - _, err := dec.decryptKey(headers, nil, generator) - if err == nil { - t.Error("ec decrypter accepted object with missing epk header") - } - - // Invalid epk header - headers.Epk = &JsonWebKey{} - - _, err = dec.decryptKey(headers, nil, generator) - if err == nil { - t.Error("ec decrypter accepted object with invalid epk header") - } -} - -func TestDecryptWithIncorrectSize(t *testing.T) { - priv, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - t.Error(err) - return - } - - dec := new(rsaDecrypterSigner) - dec.privateKey = priv - aes := newAESGCM(16) - - keygen := randomKeyGenerator{ - size: aes.keySize(), - } - - payload := make([]byte, 254) - _, err = dec.decrypt(payload, RSA1_5, keygen) - if err == nil { - t.Error("Invalid payload size should return error") - } - - payload = make([]byte, 257) - _, err = dec.decrypt(payload, RSA1_5, keygen) - if err == nil { - t.Error("Invalid payload size should return error") - } -} - -func TestPKCSDecryptNeverFails(t *testing.T) { - // We don't want RSA-PKCS1 v1.5 decryption to ever fail, in order to prevent - // side-channel timing attacks (Bleichenbacher attack in particular). - priv, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - t.Error(err) - return - } - - dec := new(rsaDecrypterSigner) - dec.privateKey = priv - aes := newAESGCM(16) - - keygen := randomKeyGenerator{ - size: aes.keySize(), - } - - for i := 1; i < 50; i++ { - payload := make([]byte, 256) - _, err := io.ReadFull(rand.Reader, payload) - if err != nil { - t.Error("Unable to get random data:", err) - return - } - _, err = dec.decrypt(payload, RSA1_5, keygen) - if err != nil { - t.Error("PKCS1v1.5 decrypt should never fail:", err) - return - } - } -} - -func BenchmarkPKCSDecryptWithValidPayloads(b *testing.B) { - priv, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - panic(err) - } - - enc := new(rsaEncrypterVerifier) - enc.publicKey = &priv.PublicKey - dec := new(rsaDecrypterSigner) - dec.privateKey = priv - aes := newAESGCM(32) - - b.StopTimer() - b.ResetTimer() - for i := 0; i < b.N; i++ { - plaintext := make([]byte, 32) - _, err = io.ReadFull(rand.Reader, plaintext) - if err != nil { - panic(err) - } - - ciphertext, err := enc.encrypt(plaintext, RSA1_5) - if err != nil { - panic(err) - } - - keygen := randomKeyGenerator{ - size: aes.keySize(), - } - - b.StartTimer() - _, err = dec.decrypt(ciphertext, RSA1_5, keygen) - b.StopTimer() - if err != nil { - panic(err) - } - } -} - -func BenchmarkPKCSDecryptWithInvalidPayloads(b *testing.B) { - priv, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - panic(err) - } - - enc := new(rsaEncrypterVerifier) - enc.publicKey = &priv.PublicKey - dec := new(rsaDecrypterSigner) - dec.privateKey = priv - aes := newAESGCM(16) - - keygen := randomKeyGenerator{ - size: aes.keySize(), - } - - b.StopTimer() - b.ResetTimer() - for i := 0; i < b.N; i++ { - plaintext := make([]byte, 16) - _, err = io.ReadFull(rand.Reader, plaintext) - if err != nil { - panic(err) - } - - ciphertext, err := enc.encrypt(plaintext, RSA1_5) - if err != nil { - panic(err) - } - - // Do some simple scrambling - ciphertext[128] ^= 0xFF - - b.StartTimer() - _, err = dec.decrypt(ciphertext, RSA1_5, keygen) - b.StopTimer() - if err != nil { - panic(err) - } - } -} - -func TestInvalidEllipticCurve(t *testing.T) { - signer256 := ecDecrypterSigner{privateKey: ecTestKey256} - signer384 := ecDecrypterSigner{privateKey: ecTestKey384} - signer521 := ecDecrypterSigner{privateKey: ecTestKey521} - - _, err := signer256.signPayload([]byte{}, ES384) - if err == nil { - t.Error("should not generate ES384 signature with P-256 key") - } - _, err = signer256.signPayload([]byte{}, ES512) - if err == nil { - t.Error("should not generate ES512 signature with P-256 key") - } - _, err = signer384.signPayload([]byte{}, ES256) - if err == nil { - t.Error("should not generate ES256 signature with P-384 key") - } - _, err = signer384.signPayload([]byte{}, ES512) - if err == nil { - t.Error("should not generate ES512 signature with P-384 key") - } - _, err = signer521.signPayload([]byte{}, ES256) - if err == nil { - t.Error("should not generate ES256 signature with P-521 key") - } - _, err = signer521.signPayload([]byte{}, ES384) - if err == nil { - t.Error("should not generate ES384 signature with P-521 key") - } -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go b/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go deleted file mode 100644 index a5c3583..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac.go +++ /dev/null @@ -1,196 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "bytes" - "crypto/cipher" - "crypto/hmac" - "crypto/sha256" - "crypto/sha512" - "crypto/subtle" - "encoding/binary" - "errors" - "hash" -) - -const ( - nonceBytes = 16 -) - -// NewCBCHMAC instantiates a new AEAD based on CBC+HMAC. -func NewCBCHMAC(key []byte, newBlockCipher func([]byte) (cipher.Block, error)) (cipher.AEAD, error) { - keySize := len(key) / 2 - integrityKey := key[:keySize] - encryptionKey := key[keySize:] - - blockCipher, err := newBlockCipher(encryptionKey) - if err != nil { - return nil, err - } - - var hash func() hash.Hash - switch keySize { - case 16: - hash = sha256.New - case 24: - hash = sha512.New384 - case 32: - hash = sha512.New - } - - return &cbcAEAD{ - hash: hash, - blockCipher: blockCipher, - authtagBytes: keySize, - integrityKey: integrityKey, - }, nil -} - -// An AEAD based on CBC+HMAC -type cbcAEAD struct { - hash func() hash.Hash - authtagBytes int - integrityKey []byte - blockCipher cipher.Block -} - -func (ctx *cbcAEAD) NonceSize() int { - return nonceBytes -} - -func (ctx *cbcAEAD) Overhead() int { - // Maximum overhead is block size (for padding) plus auth tag length, where - // the length of the auth tag is equivalent to the key size. - return ctx.blockCipher.BlockSize() + ctx.authtagBytes -} - -// Seal encrypts and authenticates the plaintext. -func (ctx *cbcAEAD) Seal(dst, nonce, plaintext, data []byte) []byte { - // Output buffer -- must take care not to mangle plaintext input. - ciphertext := make([]byte, len(plaintext)+ctx.Overhead())[:len(plaintext)] - copy(ciphertext, plaintext) - ciphertext = padBuffer(ciphertext, ctx.blockCipher.BlockSize()) - - cbc := cipher.NewCBCEncrypter(ctx.blockCipher, nonce) - - cbc.CryptBlocks(ciphertext, ciphertext) - authtag := ctx.computeAuthTag(data, nonce, ciphertext) - - ret, out := resize(dst, len(dst)+len(ciphertext)+len(authtag)) - copy(out, ciphertext) - copy(out[len(ciphertext):], authtag) - - return ret -} - -// Open decrypts and authenticates the ciphertext. -func (ctx *cbcAEAD) Open(dst, nonce, ciphertext, data []byte) ([]byte, error) { - if len(ciphertext) < ctx.authtagBytes { - return nil, errors.New("square/go-jose: invalid ciphertext (too short)") - } - - offset := len(ciphertext) - ctx.authtagBytes - expectedTag := ctx.computeAuthTag(data, nonce, ciphertext[:offset]) - match := subtle.ConstantTimeCompare(expectedTag, ciphertext[offset:]) - if match != 1 { - return nil, errors.New("square/go-jose: invalid ciphertext (auth tag mismatch)") - } - - cbc := cipher.NewCBCDecrypter(ctx.blockCipher, nonce) - - // Make copy of ciphertext buffer, don't want to modify in place - buffer := append([]byte{}, []byte(ciphertext[:offset])...) - - if len(buffer)%ctx.blockCipher.BlockSize() > 0 { - return nil, errors.New("square/go-jose: invalid ciphertext (invalid length)") - } - - cbc.CryptBlocks(buffer, buffer) - - // Remove padding - plaintext, err := unpadBuffer(buffer, ctx.blockCipher.BlockSize()) - if err != nil { - return nil, err - } - - ret, out := resize(dst, len(dst)+len(plaintext)) - copy(out, plaintext) - - return ret, nil -} - -// Compute an authentication tag -func (ctx *cbcAEAD) computeAuthTag(aad, nonce, ciphertext []byte) []byte { - buffer := make([]byte, len(aad)+len(nonce)+len(ciphertext)+8) - n := 0 - n += copy(buffer, aad) - n += copy(buffer[n:], nonce) - n += copy(buffer[n:], ciphertext) - binary.BigEndian.PutUint64(buffer[n:], uint64(len(aad)*8)) - - // According to documentation, Write() on hash.Hash never fails. - hmac := hmac.New(ctx.hash, ctx.integrityKey) - _, _ = hmac.Write(buffer) - - return hmac.Sum(nil)[:ctx.authtagBytes] -} - -// resize ensures the the given slice has a capacity of at least n bytes. -// If the capacity of the slice is less than n, a new slice is allocated -// and the existing data will be copied. -func resize(in []byte, n int) (head, tail []byte) { - if cap(in) >= n { - head = in[:n] - } else { - head = make([]byte, n) - copy(head, in) - } - - tail = head[len(in):] - return -} - -// Apply padding -func padBuffer(buffer []byte, blockSize int) []byte { - missing := blockSize - (len(buffer) % blockSize) - ret, out := resize(buffer, len(buffer)+missing) - padding := bytes.Repeat([]byte{byte(missing)}, missing) - copy(out, padding) - return ret -} - -// Remove padding -func unpadBuffer(buffer []byte, blockSize int) ([]byte, error) { - if len(buffer)%blockSize != 0 { - return nil, errors.New("square/go-jose: invalid padding") - } - - last := buffer[len(buffer)-1] - count := int(last) - - if count == 0 || count > blockSize || count > len(buffer) { - return nil, errors.New("square/go-jose: invalid padding") - } - - padding := bytes.Repeat([]byte{last}, count) - if !bytes.HasSuffix(buffer, padding) { - return nil, errors.New("square/go-jose: invalid padding") - } - - return buffer[:len(buffer)-count], nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac_test.go b/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac_test.go deleted file mode 100644 index c230271..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/cbc_hmac_test.go +++ /dev/null @@ -1,498 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "bytes" - "crypto/aes" - "crypto/cipher" - "crypto/rand" - "io" - "strings" - "testing" -) - -func TestInvalidInputs(t *testing.T) { - key := []byte{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - } - - nonce := []byte{ - 92, 80, 104, 49, 133, 25, 161, 215, 173, 101, 219, 211, 136, 91, 210, 145} - - aead, _ := NewCBCHMAC(key, aes.NewCipher) - ciphertext := aead.Seal(nil, nonce, []byte("plaintext"), []byte("aad")) - - // Changed AAD, must fail - _, err := aead.Open(nil, nonce, ciphertext, []byte("INVALID")) - if err == nil { - t.Error("must detect invalid aad") - } - - // Empty ciphertext, must fail - _, err = aead.Open(nil, nonce, []byte{}, []byte("aad")) - if err == nil { - t.Error("must detect invalid/empty ciphertext") - } - - // Corrupt ciphertext, must fail - corrupt := make([]byte, len(ciphertext)) - copy(corrupt, ciphertext) - corrupt[0] ^= 0xFF - - _, err = aead.Open(nil, nonce, corrupt, []byte("aad")) - if err == nil { - t.Error("must detect corrupt ciphertext") - } - - // Corrupt authtag, must fail - copy(corrupt, ciphertext) - corrupt[len(ciphertext)-1] ^= 0xFF - - _, err = aead.Open(nil, nonce, corrupt, []byte("aad")) - if err == nil { - t.Error("must detect corrupt authtag") - } - - // Truncated data, must fail - _, err = aead.Open(nil, nonce, ciphertext[:10], []byte("aad")) - if err == nil { - t.Error("must detect corrupt authtag") - } -} - -func TestVectorsAESCBC128(t *testing.T) { - // Source: http://tools.ietf.org/html/draft-ietf-jose-json-web-encryption-29#appendix-A.2 - plaintext := []byte{ - 76, 105, 118, 101, 32, 108, 111, 110, 103, 32, 97, 110, 100, 32, - 112, 114, 111, 115, 112, 101, 114, 46} - - aad := []byte{ - 101, 121, 74, 104, 98, 71, 99, 105, 79, 105, 74, 83, 85, 48, 69, - 120, 88, 122, 85, 105, 76, 67, 74, 108, 98, 109, 77, 105, 79, 105, - 74, 66, 77, 84, 73, 52, 81, 48, 74, 68, 76, 85, 104, 84, 77, 106, 85, - 50, 73, 110, 48} - - expectedCiphertext := []byte{ - 40, 57, 83, 181, 119, 33, 133, 148, 198, 185, 243, 24, 152, 230, 6, - 75, 129, 223, 127, 19, 210, 82, 183, 230, 168, 33, 215, 104, 143, - 112, 56, 102} - - expectedAuthtag := []byte{ - 246, 17, 244, 190, 4, 95, 98, 3, 231, 0, 115, 157, 242, 203, 100, - 191} - - key := []byte{ - 4, 211, 31, 197, 84, 157, 252, 254, 11, 100, 157, 250, 63, 170, 106, 206, - 107, 124, 212, 45, 111, 107, 9, 219, 200, 177, 0, 240, 143, 156, 44, 207} - - nonce := []byte{ - 3, 22, 60, 12, 43, 67, 104, 105, 108, 108, 105, 99, 111, 116, 104, 101} - - enc, err := NewCBCHMAC(key, aes.NewCipher) - out := enc.Seal(nil, nonce, plaintext, aad) - if err != nil { - t.Error("Unable to encrypt:", err) - return - } - - if bytes.Compare(out[:len(out)-16], expectedCiphertext) != 0 { - t.Error("Ciphertext did not match") - } - if bytes.Compare(out[len(out)-16:], expectedAuthtag) != 0 { - t.Error("Auth tag did not match") - } -} - -func TestVectorsAESCBC256(t *testing.T) { - // Source: https://tools.ietf.org/html/draft-mcgrew-aead-aes-cbc-hmac-sha2-05#section-5.4 - plaintext := []byte{ - 0x41, 0x20, 0x63, 0x69, 0x70, 0x68, 0x65, 0x72, 0x20, 0x73, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x20, - 0x6d, 0x75, 0x73, 0x74, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x65, 0x71, 0x75, - 0x69, 0x72, 0x65, 0x64, 0x20, 0x74, 0x6f, 0x20, 0x62, 0x65, 0x20, 0x73, 0x65, 0x63, 0x72, 0x65, - 0x74, 0x2c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x69, 0x74, 0x20, 0x6d, 0x75, 0x73, 0x74, 0x20, 0x62, - 0x65, 0x20, 0x61, 0x62, 0x6c, 0x65, 0x20, 0x74, 0x6f, 0x20, 0x66, 0x61, 0x6c, 0x6c, 0x20, 0x69, - 0x6e, 0x74, 0x6f, 0x20, 0x74, 0x68, 0x65, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x73, 0x20, 0x6f, 0x66, - 0x20, 0x74, 0x68, 0x65, 0x20, 0x65, 0x6e, 0x65, 0x6d, 0x79, 0x20, 0x77, 0x69, 0x74, 0x68, 0x6f, - 0x75, 0x74, 0x20, 0x69, 0x6e, 0x63, 0x6f, 0x6e, 0x76, 0x65, 0x6e, 0x69, 0x65, 0x6e, 0x63, 0x65} - - aad := []byte{ - 0x54, 0x68, 0x65, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x63, - 0x69, 0x70, 0x6c, 0x65, 0x20, 0x6f, 0x66, 0x20, 0x41, 0x75, 0x67, 0x75, 0x73, 0x74, 0x65, 0x20, - 0x4b, 0x65, 0x72, 0x63, 0x6b, 0x68, 0x6f, 0x66, 0x66, 0x73} - - expectedCiphertext := []byte{ - 0x4a, 0xff, 0xaa, 0xad, 0xb7, 0x8c, 0x31, 0xc5, 0xda, 0x4b, 0x1b, 0x59, 0x0d, 0x10, 0xff, 0xbd, - 0x3d, 0xd8, 0xd5, 0xd3, 0x02, 0x42, 0x35, 0x26, 0x91, 0x2d, 0xa0, 0x37, 0xec, 0xbc, 0xc7, 0xbd, - 0x82, 0x2c, 0x30, 0x1d, 0xd6, 0x7c, 0x37, 0x3b, 0xcc, 0xb5, 0x84, 0xad, 0x3e, 0x92, 0x79, 0xc2, - 0xe6, 0xd1, 0x2a, 0x13, 0x74, 0xb7, 0x7f, 0x07, 0x75, 0x53, 0xdf, 0x82, 0x94, 0x10, 0x44, 0x6b, - 0x36, 0xeb, 0xd9, 0x70, 0x66, 0x29, 0x6a, 0xe6, 0x42, 0x7e, 0xa7, 0x5c, 0x2e, 0x08, 0x46, 0xa1, - 0x1a, 0x09, 0xcc, 0xf5, 0x37, 0x0d, 0xc8, 0x0b, 0xfe, 0xcb, 0xad, 0x28, 0xc7, 0x3f, 0x09, 0xb3, - 0xa3, 0xb7, 0x5e, 0x66, 0x2a, 0x25, 0x94, 0x41, 0x0a, 0xe4, 0x96, 0xb2, 0xe2, 0xe6, 0x60, 0x9e, - 0x31, 0xe6, 0xe0, 0x2c, 0xc8, 0x37, 0xf0, 0x53, 0xd2, 0x1f, 0x37, 0xff, 0x4f, 0x51, 0x95, 0x0b, - 0xbe, 0x26, 0x38, 0xd0, 0x9d, 0xd7, 0xa4, 0x93, 0x09, 0x30, 0x80, 0x6d, 0x07, 0x03, 0xb1, 0xf6} - - expectedAuthtag := []byte{ - 0x4d, 0xd3, 0xb4, 0xc0, 0x88, 0xa7, 0xf4, 0x5c, 0x21, 0x68, 0x39, 0x64, 0x5b, 0x20, 0x12, 0xbf, - 0x2e, 0x62, 0x69, 0xa8, 0xc5, 0x6a, 0x81, 0x6d, 0xbc, 0x1b, 0x26, 0x77, 0x61, 0x95, 0x5b, 0xc5} - - key := []byte{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f} - - nonce := []byte{ - 0x1a, 0xf3, 0x8c, 0x2d, 0xc2, 0xb9, 0x6f, 0xfd, 0xd8, 0x66, 0x94, 0x09, 0x23, 0x41, 0xbc, 0x04} - - enc, err := NewCBCHMAC(key, aes.NewCipher) - out := enc.Seal(nil, nonce, plaintext, aad) - if err != nil { - t.Error("Unable to encrypt:", err) - return - } - - if bytes.Compare(out[:len(out)-32], expectedCiphertext) != 0 { - t.Error("Ciphertext did not match, got", out[:len(out)-32], "wanted", expectedCiphertext) - } - if bytes.Compare(out[len(out)-32:], expectedAuthtag) != 0 { - t.Error("Auth tag did not match, got", out[len(out)-32:], "wanted", expectedAuthtag) - } -} - -func TestAESCBCRoundtrip(t *testing.T) { - key128 := []byte{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} - - key192 := []byte{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7} - - key256 := []byte{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} - - nonce := []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15} - - RunRoundtrip(t, key128, nonce) - RunRoundtrip(t, key192, nonce) - RunRoundtrip(t, key256, nonce) -} - -func RunRoundtrip(t *testing.T, key, nonce []byte) { - aead, err := NewCBCHMAC(key, aes.NewCipher) - if err != nil { - panic(err) - } - - if aead.NonceSize() != len(nonce) { - panic("invalid nonce") - } - - // Test pre-existing data in dst buffer - dst := []byte{15, 15, 15, 15} - plaintext := []byte{0, 0, 0, 0} - aad := []byte{4, 3, 2, 1} - - result := aead.Seal(dst, nonce, plaintext, aad) - if bytes.Compare(dst, result[:4]) != 0 { - t.Error("Existing data in dst not preserved") - } - - // Test pre-existing (empty) dst buffer with sufficient capacity - dst = make([]byte, 256)[:0] - result, err = aead.Open(dst, nonce, result[4:], aad) - if err != nil { - panic(err) - } - - if bytes.Compare(result, plaintext) != 0 { - t.Error("Plaintext does not match output") - } -} - -func TestAESCBCOverhead(t *testing.T) { - aead, err := NewCBCHMAC(make([]byte, 32), aes.NewCipher) - if err != nil { - panic(err) - } - - if aead.Overhead() != 32 { - t.Error("CBC-HMAC reports incorrect overhead value") - } -} - -func TestPadding(t *testing.T) { - for i := 0; i < 256; i++ { - slice := make([]byte, i) - padded := padBuffer(slice, 16) - if len(padded)%16 != 0 { - t.Error("failed to pad slice properly", i) - return - } - unpadded, err := unpadBuffer(padded, 16) - if err != nil || len(unpadded) != i { - t.Error("failed to unpad slice properly", i) - return - } - } -} - -func TestInvalidKey(t *testing.T) { - key := make([]byte, 30) - _, err := NewCBCHMAC(key, aes.NewCipher) - if err == nil { - t.Error("should not be able to instantiate CBC-HMAC with invalid key") - } -} - -func TestTruncatedCiphertext(t *testing.T) { - key := make([]byte, 32) - nonce := make([]byte, 16) - data := make([]byte, 32) - - io.ReadFull(rand.Reader, key) - io.ReadFull(rand.Reader, nonce) - - aead, err := NewCBCHMAC(key, aes.NewCipher) - if err != nil { - panic(err) - } - - ctx := aead.(*cbcAEAD) - ct := aead.Seal(nil, nonce, data, nil) - - // Truncated ciphertext, but with correct auth tag - truncated, tail := resize(ct[:len(ct)-ctx.authtagBytes-2], len(ct)-2) - copy(tail, ctx.computeAuthTag(nil, nonce, truncated[:len(truncated)-ctx.authtagBytes])) - - // Open should fail - _, err = aead.Open(nil, nonce, truncated, nil) - if err == nil { - t.Error("open on truncated ciphertext should fail") - } -} - -func TestInvalidPaddingOpen(t *testing.T) { - key := make([]byte, 32) - nonce := make([]byte, 16) - - // Plaintext with invalid padding - plaintext := padBuffer(make([]byte, 28), aes.BlockSize) - plaintext[len(plaintext)-1] = 0xFF - - io.ReadFull(rand.Reader, key) - io.ReadFull(rand.Reader, nonce) - - block, _ := aes.NewCipher(key) - cbc := cipher.NewCBCEncrypter(block, nonce) - buffer := append([]byte{}, plaintext...) - cbc.CryptBlocks(buffer, buffer) - - aead, _ := NewCBCHMAC(key, aes.NewCipher) - ctx := aead.(*cbcAEAD) - - // Mutated ciphertext, but with correct auth tag - size := len(buffer) - ciphertext, tail := resize(buffer, size+(len(key)/2)) - copy(tail, ctx.computeAuthTag(nil, nonce, ciphertext[:size])) - - // Open should fail (b/c of invalid padding, even though tag matches) - _, err := aead.Open(nil, nonce, ciphertext, nil) - if err == nil || !strings.Contains(err.Error(), "invalid padding") { - t.Error("no or unexpected error on open with invalid padding:", err) - } -} - -func TestInvalidPadding(t *testing.T) { - for i := 0; i < 256; i++ { - slice := make([]byte, i) - padded := padBuffer(slice, 16) - if len(padded)%16 != 0 { - t.Error("failed to pad slice properly", i) - return - } - - paddingBytes := 16 - (i % 16) - - // Mutate padding for testing - for j := 1; j <= paddingBytes; j++ { - mutated := make([]byte, len(padded)) - copy(mutated, padded) - mutated[len(mutated)-j] ^= 0xFF - - _, err := unpadBuffer(mutated, 16) - if err == nil { - t.Error("unpad on invalid padding should fail", i) - return - } - } - - // Test truncated padding - _, err := unpadBuffer(padded[:len(padded)-1], 16) - if err == nil { - t.Error("unpad on truncated padding should fail", i) - return - } - } -} - -func TestZeroLengthPadding(t *testing.T) { - data := make([]byte, 16) - data, err := unpadBuffer(data, 16) - if err == nil { - t.Error("padding with 0x00 should never be valid") - } -} - -func benchEncryptCBCHMAC(b *testing.B, keySize, chunkSize int) { - key := make([]byte, keySize*2) - nonce := make([]byte, 16) - - io.ReadFull(rand.Reader, key) - io.ReadFull(rand.Reader, nonce) - - chunk := make([]byte, chunkSize) - - aead, err := NewCBCHMAC(key, aes.NewCipher) - if err != nil { - panic(err) - } - - b.SetBytes(int64(chunkSize)) - b.ResetTimer() - for i := 0; i < b.N; i++ { - aead.Seal(nil, nonce, chunk, nil) - } -} - -func benchDecryptCBCHMAC(b *testing.B, keySize, chunkSize int) { - key := make([]byte, keySize*2) - nonce := make([]byte, 16) - - io.ReadFull(rand.Reader, key) - io.ReadFull(rand.Reader, nonce) - - chunk := make([]byte, chunkSize) - - aead, err := NewCBCHMAC(key, aes.NewCipher) - if err != nil { - panic(err) - } - - out := aead.Seal(nil, nonce, chunk, nil) - - b.SetBytes(int64(chunkSize)) - b.ResetTimer() - for i := 0; i < b.N; i++ { - aead.Open(nil, nonce, out, nil) - } -} - -func BenchmarkEncryptAES128_CBCHMAC_1k(b *testing.B) { - benchEncryptCBCHMAC(b, 16, 1024) -} - -func BenchmarkEncryptAES128_CBCHMAC_64k(b *testing.B) { - benchEncryptCBCHMAC(b, 16, 65536) -} - -func BenchmarkEncryptAES128_CBCHMAC_1MB(b *testing.B) { - benchEncryptCBCHMAC(b, 16, 1048576) -} - -func BenchmarkEncryptAES128_CBCHMAC_64MB(b *testing.B) { - benchEncryptCBCHMAC(b, 16, 67108864) -} - -func BenchmarkDecryptAES128_CBCHMAC_1k(b *testing.B) { - benchDecryptCBCHMAC(b, 16, 1024) -} - -func BenchmarkDecryptAES128_CBCHMAC_64k(b *testing.B) { - benchDecryptCBCHMAC(b, 16, 65536) -} - -func BenchmarkDecryptAES128_CBCHMAC_1MB(b *testing.B) { - benchDecryptCBCHMAC(b, 16, 1048576) -} - -func BenchmarkDecryptAES128_CBCHMAC_64MB(b *testing.B) { - benchDecryptCBCHMAC(b, 16, 67108864) -} - -func BenchmarkEncryptAES192_CBCHMAC_64k(b *testing.B) { - benchEncryptCBCHMAC(b, 24, 65536) -} - -func BenchmarkEncryptAES192_CBCHMAC_1MB(b *testing.B) { - benchEncryptCBCHMAC(b, 24, 1048576) -} - -func BenchmarkEncryptAES192_CBCHMAC_64MB(b *testing.B) { - benchEncryptCBCHMAC(b, 24, 67108864) -} - -func BenchmarkDecryptAES192_CBCHMAC_1k(b *testing.B) { - benchDecryptCBCHMAC(b, 24, 1024) -} - -func BenchmarkDecryptAES192_CBCHMAC_64k(b *testing.B) { - benchDecryptCBCHMAC(b, 24, 65536) -} - -func BenchmarkDecryptAES192_CBCHMAC_1MB(b *testing.B) { - benchDecryptCBCHMAC(b, 24, 1048576) -} - -func BenchmarkDecryptAES192_CBCHMAC_64MB(b *testing.B) { - benchDecryptCBCHMAC(b, 24, 67108864) -} - -func BenchmarkEncryptAES256_CBCHMAC_64k(b *testing.B) { - benchEncryptCBCHMAC(b, 32, 65536) -} - -func BenchmarkEncryptAES256_CBCHMAC_1MB(b *testing.B) { - benchEncryptCBCHMAC(b, 32, 1048576) -} - -func BenchmarkEncryptAES256_CBCHMAC_64MB(b *testing.B) { - benchEncryptCBCHMAC(b, 32, 67108864) -} - -func BenchmarkDecryptAES256_CBCHMAC_1k(b *testing.B) { - benchDecryptCBCHMAC(b, 32, 1032) -} - -func BenchmarkDecryptAES256_CBCHMAC_64k(b *testing.B) { - benchDecryptCBCHMAC(b, 32, 65536) -} - -func BenchmarkDecryptAES256_CBCHMAC_1MB(b *testing.B) { - benchDecryptCBCHMAC(b, 32, 1048576) -} - -func BenchmarkDecryptAES256_CBCHMAC_64MB(b *testing.B) { - benchDecryptCBCHMAC(b, 32, 67108864) -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go b/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go deleted file mode 100644 index cbb5f7b..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf.go +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "crypto" - "encoding/binary" - "hash" - "io" -) - -type concatKDF struct { - z, info []byte - i uint32 - cache []byte - hasher hash.Hash -} - -// NewConcatKDF builds a KDF reader based on the given inputs. -func NewConcatKDF(hash crypto.Hash, z, algID, ptyUInfo, ptyVInfo, supPubInfo, supPrivInfo []byte) io.Reader { - buffer := make([]byte, len(algID)+len(ptyUInfo)+len(ptyVInfo)+len(supPubInfo)+len(supPrivInfo)) - n := 0 - n += copy(buffer, algID) - n += copy(buffer[n:], ptyUInfo) - n += copy(buffer[n:], ptyVInfo) - n += copy(buffer[n:], supPubInfo) - copy(buffer[n:], supPrivInfo) - - hasher := hash.New() - - return &concatKDF{ - z: z, - info: buffer, - hasher: hasher, - cache: []byte{}, - i: 1, - } -} - -func (ctx *concatKDF) Read(out []byte) (int, error) { - copied := copy(out, ctx.cache) - ctx.cache = ctx.cache[copied:] - - for copied < len(out) { - ctx.hasher.Reset() - - // Write on a hash.Hash never fails - _ = binary.Write(ctx.hasher, binary.BigEndian, ctx.i) - _, _ = ctx.hasher.Write(ctx.z) - _, _ = ctx.hasher.Write(ctx.info) - - hash := ctx.hasher.Sum(nil) - chunkCopied := copy(out[copied:], hash) - copied += chunkCopied - ctx.cache = hash[chunkCopied:] - - ctx.i++ - } - - return copied, nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf_test.go b/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf_test.go deleted file mode 100644 index 48219b3..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/concat_kdf_test.go +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "bytes" - "crypto" - "testing" -) - -// Taken from: https://tools.ietf.org/id/draft-ietf-jose-json-web-algorithms-38.txt -func TestVectorConcatKDF(t *testing.T) { - z := []byte{ - 158, 86, 217, 29, 129, 113, 53, 211, 114, 131, 66, 131, 191, 132, - 38, 156, 251, 49, 110, 163, 218, 128, 106, 72, 246, 218, 167, 121, - 140, 254, 144, 196} - - algID := []byte{0, 0, 0, 7, 65, 49, 50, 56, 71, 67, 77} - - ptyUInfo := []byte{0, 0, 0, 5, 65, 108, 105, 99, 101} - ptyVInfo := []byte{0, 0, 0, 3, 66, 111, 98} - - supPubInfo := []byte{0, 0, 0, 128} - supPrivInfo := []byte{} - - expected := []byte{ - 86, 170, 141, 234, 248, 35, 109, 32, 92, 34, 40, 205, 113, 167, 16, 26} - - ckdf := NewConcatKDF(crypto.SHA256, z, algID, ptyUInfo, ptyVInfo, supPubInfo, supPrivInfo) - - out0 := make([]byte, 9) - out1 := make([]byte, 7) - - read0, err := ckdf.Read(out0) - if err != nil { - t.Error("error when reading from concat kdf reader", err) - return - } - - read1, err := ckdf.Read(out1) - if err != nil { - t.Error("error when reading from concat kdf reader", err) - return - } - - if read0+read1 != len(out0)+len(out1) { - t.Error("did not receive enough bytes from concat kdf reader") - return - } - - out := []byte{} - out = append(out, out0...) - out = append(out, out1...) - - if bytes.Compare(out, expected) != 0 { - t.Error("did not receive expected output from concat kdf reader") - return - } -} - -func TestCache(t *testing.T) { - z := []byte{ - 158, 86, 217, 29, 129, 113, 53, 211, 114, 131, 66, 131, 191, 132, - 38, 156, 251, 49, 110, 163, 218, 128, 106, 72, 246, 218, 167, 121, - 140, 254, 144, 196} - - algID := []byte{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4} - - ptyUInfo := []byte{1, 2, 3, 4} - ptyVInfo := []byte{4, 3, 2, 1} - - supPubInfo := []byte{} - supPrivInfo := []byte{} - - outputs := [][]byte{} - - // Read the same amount of data in different chunk sizes - chunkSizes := []int{1, 2, 4, 8, 16, 32, 64, 128, 256, 512} - - for _, c := range chunkSizes { - out := make([]byte, 1024) - reader := NewConcatKDF(crypto.SHA256, z, algID, ptyUInfo, ptyVInfo, supPubInfo, supPrivInfo) - - for i := 0; i < 1024; i += c { - _, _ = reader.Read(out[i : i+c]) - } - - outputs = append(outputs, out) - } - - for i := range outputs { - if bytes.Compare(outputs[i], outputs[(i+1)%len(outputs)]) != 0 { - t.Error("not all outputs from KDF matched") - } - } -} - -func benchmarkKDF(b *testing.B, total int) { - z := []byte{ - 158, 86, 217, 29, 129, 113, 53, 211, 114, 131, 66, 131, 191, 132, - 38, 156, 251, 49, 110, 163, 218, 128, 106, 72, 246, 218, 167, 121, - 140, 254, 144, 196} - - algID := []byte{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4} - - ptyUInfo := []byte{1, 2, 3, 4} - ptyVInfo := []byte{4, 3, 2, 1} - - supPubInfo := []byte{} - supPrivInfo := []byte{} - - out := make([]byte, total) - reader := NewConcatKDF(crypto.SHA256, z, algID, ptyUInfo, ptyVInfo, supPubInfo, supPrivInfo) - - b.ResetTimer() - b.SetBytes(int64(total)) - for i := 0; i < b.N; i++ { - _, _ = reader.Read(out) - } -} - -func BenchmarkConcatKDF_1k(b *testing.B) { - benchmarkKDF(b, 1024) -} - -func BenchmarkConcatKDF_64k(b *testing.B) { - benchmarkKDF(b, 65536) -} - -func BenchmarkConcatKDF_1MB(b *testing.B) { - benchmarkKDF(b, 1048576) -} - -func BenchmarkConcatKDF_64MB(b *testing.B) { - benchmarkKDF(b, 67108864) -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go b/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go deleted file mode 100644 index c6a5a82..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es.go +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "crypto" - "crypto/ecdsa" - "encoding/binary" -) - -// DeriveECDHES derives a shared encryption key using ECDH/ConcatKDF as described in JWE/JWA. -func DeriveECDHES(alg string, apuData, apvData []byte, priv *ecdsa.PrivateKey, pub *ecdsa.PublicKey, size int) []byte { - // algId, partyUInfo, partyVInfo inputs must be prefixed with the length - algID := lengthPrefixed([]byte(alg)) - ptyUInfo := lengthPrefixed(apuData) - ptyVInfo := lengthPrefixed(apvData) - - // suppPubInfo is the encoded length of the output size in bits - supPubInfo := make([]byte, 4) - binary.BigEndian.PutUint32(supPubInfo, uint32(size)*8) - - z, _ := priv.PublicKey.Curve.ScalarMult(pub.X, pub.Y, priv.D.Bytes()) - reader := NewConcatKDF(crypto.SHA256, z.Bytes(), algID, ptyUInfo, ptyVInfo, supPubInfo, []byte{}) - - key := make([]byte, size) - - // Read on the KDF will never fail - _, _ = reader.Read(key) - return key -} - -func lengthPrefixed(data []byte) []byte { - out := make([]byte, len(data)+4) - binary.BigEndian.PutUint32(out, uint32(len(data))) - copy(out[4:], data) - return out -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es_test.go b/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es_test.go deleted file mode 100644 index f92abb1..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/ecdh_es_test.go +++ /dev/null @@ -1,98 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "bytes" - "crypto/ecdsa" - "crypto/elliptic" - "encoding/base64" - "math/big" - "testing" -) - -// Example keys from JWA, Appendix C -var aliceKey = &ecdsa.PrivateKey{ - PublicKey: ecdsa.PublicKey{ - Curve: elliptic.P256(), - X: fromBase64Int("gI0GAILBdu7T53akrFmMyGcsF3n5dO7MmwNBHKW5SV0="), - Y: fromBase64Int("SLW_xSffzlPWrHEVI30DHM_4egVwt3NQqeUD7nMFpps="), - }, - D: fromBase64Int("0_NxaRPUMQoAJt50Gz8YiTr8gRTwyEaCumd-MToTmIo="), -} - -var bobKey = &ecdsa.PrivateKey{ - PublicKey: ecdsa.PublicKey{ - Curve: elliptic.P256(), - X: fromBase64Int("weNJy2HscCSM6AEDTDg04biOvhFhyyWvOHQfeF_PxMQ="), - Y: fromBase64Int("e8lnCO-AlStT-NJVX-crhB7QRYhiix03illJOVAOyck="), - }, - D: fromBase64Int("VEmDZpDXXK8p8N0Cndsxs924q6nS1RXFASRl6BfUqdw="), -} - -// Build big int from base64-encoded string. Strips whitespace (for testing). -func fromBase64Int(data string) *big.Int { - val, err := base64.URLEncoding.DecodeString(data) - if err != nil { - panic("Invalid test data") - } - return new(big.Int).SetBytes(val) -} - -func TestVectorECDHES(t *testing.T) { - apuData := []byte("Alice") - apvData := []byte("Bob") - - expected := []byte{ - 86, 170, 141, 234, 248, 35, 109, 32, 92, 34, 40, 205, 113, 167, 16, 26} - - output := DeriveECDHES("A128GCM", apuData, apvData, bobKey, &aliceKey.PublicKey, 16) - - if bytes.Compare(output, expected) != 0 { - t.Error("output did not match what we expect, got", output, "wanted", expected) - } -} - -func BenchmarkECDHES_128(b *testing.B) { - apuData := []byte("APU") - apvData := []byte("APV") - - b.ResetTimer() - for i := 0; i < b.N; i++ { - DeriveECDHES("ID", apuData, apvData, bobKey, &aliceKey.PublicKey, 16) - } -} - -func BenchmarkECDHES_192(b *testing.B) { - apuData := []byte("APU") - apvData := []byte("APV") - - b.ResetTimer() - for i := 0; i < b.N; i++ { - DeriveECDHES("ID", apuData, apvData, bobKey, &aliceKey.PublicKey, 24) - } -} - -func BenchmarkECDHES_256(b *testing.B) { - apuData := []byte("APU") - apvData := []byte("APV") - - b.ResetTimer() - for i := 0; i < b.N; i++ { - DeriveECDHES("ID", apuData, apvData, bobKey, &aliceKey.PublicKey, 32) - } -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go b/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go deleted file mode 100644 index 1d36d50..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap.go +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "crypto/cipher" - "crypto/subtle" - "encoding/binary" - "errors" -) - -var defaultIV = []byte{0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6} - -// KeyWrap implements NIST key wrapping; it wraps a content encryption key (cek) with the given block cipher. -func KeyWrap(block cipher.Block, cek []byte) ([]byte, error) { - if len(cek)%8 != 0 { - return nil, errors.New("square/go-jose: key wrap input must be 8 byte blocks") - } - - n := len(cek) / 8 - r := make([][]byte, n) - - for i := range r { - r[i] = make([]byte, 8) - copy(r[i], cek[i*8:]) - } - - buffer := make([]byte, 16) - tBytes := make([]byte, 8) - copy(buffer, defaultIV) - - for t := 0; t < 6*n; t++ { - copy(buffer[8:], r[t%n]) - - block.Encrypt(buffer, buffer) - - binary.BigEndian.PutUint64(tBytes, uint64(t+1)) - - for i := 0; i < 8; i++ { - buffer[i] = buffer[i] ^ tBytes[i] - } - copy(r[t%n], buffer[8:]) - } - - out := make([]byte, (n+1)*8) - copy(out, buffer[:8]) - for i := range r { - copy(out[(i+1)*8:], r[i]) - } - - return out, nil -} - -// KeyUnwrap implements NIST key unwrapping; it unwraps a content encryption key (cek) with the given block cipher. -func KeyUnwrap(block cipher.Block, ciphertext []byte) ([]byte, error) { - if len(ciphertext)%8 != 0 { - return nil, errors.New("square/go-jose: key wrap input must be 8 byte blocks") - } - - n := (len(ciphertext) / 8) - 1 - r := make([][]byte, n) - - for i := range r { - r[i] = make([]byte, 8) - copy(r[i], ciphertext[(i+1)*8:]) - } - - buffer := make([]byte, 16) - tBytes := make([]byte, 8) - copy(buffer[:8], ciphertext[:8]) - - for t := 6*n - 1; t >= 0; t-- { - binary.BigEndian.PutUint64(tBytes, uint64(t+1)) - - for i := 0; i < 8; i++ { - buffer[i] = buffer[i] ^ tBytes[i] - } - copy(buffer[8:], r[t%n]) - - block.Decrypt(buffer, buffer) - - copy(r[t%n], buffer[8:]) - } - - if subtle.ConstantTimeCompare(buffer[:8], defaultIV) == 0 { - return nil, errors.New("square/go-jose: failed to unwrap key") - } - - out := make([]byte, n*8) - for i := range r { - copy(out[i*8:], r[i]) - } - - return out, nil -} diff --git a/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap_test.go b/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap_test.go deleted file mode 100644 index ceecf81..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/cipher/key_wrap_test.go +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 josecipher - -import ( - "bytes" - "crypto/aes" - "encoding/hex" - "testing" -) - -func TestAesKeyWrap(t *testing.T) { - // Test vectors from: http://csrc.nist.gov/groups/ST/toolkit/documents/kms/key-wrap.pdf - kek0, _ := hex.DecodeString("000102030405060708090A0B0C0D0E0F") - cek0, _ := hex.DecodeString("00112233445566778899AABBCCDDEEFF") - - expected0, _ := hex.DecodeString("1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5") - - kek1, _ := hex.DecodeString("000102030405060708090A0B0C0D0E0F1011121314151617") - cek1, _ := hex.DecodeString("00112233445566778899AABBCCDDEEFF") - - expected1, _ := hex.DecodeString("96778B25AE6CA435F92B5B97C050AED2468AB8A17AD84E5D") - - kek2, _ := hex.DecodeString("000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F") - cek2, _ := hex.DecodeString("00112233445566778899AABBCCDDEEFF0001020304050607") - - expected2, _ := hex.DecodeString("A8F9BC1612C68B3FF6E6F4FBE30E71E4769C8B80A32CB8958CD5D17D6B254DA1") - - block0, _ := aes.NewCipher(kek0) - block1, _ := aes.NewCipher(kek1) - block2, _ := aes.NewCipher(kek2) - - out0, _ := KeyWrap(block0, cek0) - out1, _ := KeyWrap(block1, cek1) - out2, _ := KeyWrap(block2, cek2) - - if bytes.Compare(out0, expected0) != 0 { - t.Error("output 0 not as expected, got", out0, "wanted", expected0) - } - - if bytes.Compare(out1, expected1) != 0 { - t.Error("output 1 not as expected, got", out1, "wanted", expected1) - } - - if bytes.Compare(out2, expected2) != 0 { - t.Error("output 2 not as expected, got", out2, "wanted", expected2) - } - - unwrap0, _ := KeyUnwrap(block0, out0) - unwrap1, _ := KeyUnwrap(block1, out1) - unwrap2, _ := KeyUnwrap(block2, out2) - - if bytes.Compare(unwrap0, cek0) != 0 { - t.Error("key unwrap did not return original input, got", unwrap0, "wanted", cek0) - } - - if bytes.Compare(unwrap1, cek1) != 0 { - t.Error("key unwrap did not return original input, got", unwrap1, "wanted", cek1) - } - - if bytes.Compare(unwrap2, cek2) != 0 { - t.Error("key unwrap did not return original input, got", unwrap2, "wanted", cek2) - } -} - -func TestAesKeyWrapInvalid(t *testing.T) { - kek, _ := hex.DecodeString("000102030405060708090A0B0C0D0E0F") - - // Invalid unwrap input (bit flipped) - input0, _ := hex.DecodeString("1EA68C1A8112B447AEF34BD8FB5A7B828D3E862371D2CFE5") - - block, _ := aes.NewCipher(kek) - - _, err := KeyUnwrap(block, input0) - if err == nil { - t.Error("key unwrap failed to detect invalid input") - } - - // Invalid unwrap input (truncated) - input1, _ := hex.DecodeString("1EA68C1A8112B447AEF34BD8FB5A7B828D3E862371D2CF") - - _, err = KeyUnwrap(block, input1) - if err == nil { - t.Error("key unwrap failed to detect truncated input") - } - - // Invalid wrap input (not multiple of 8) - input2, _ := hex.DecodeString("0123456789ABCD") - - _, err = KeyWrap(block, input2) - if err == nil { - t.Error("key wrap accepted invalid input") - } - -} - -func BenchmarkAesKeyWrap(b *testing.B) { - kek, _ := hex.DecodeString("000102030405060708090A0B0C0D0E0F") - key, _ := hex.DecodeString("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF") - - block, _ := aes.NewCipher(kek) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - KeyWrap(block, key) - } -} - -func BenchmarkAesKeyUnwrap(b *testing.B) { - kek, _ := hex.DecodeString("000102030405060708090A0B0C0D0E0F") - input, _ := hex.DecodeString("1FA68B0A8112B447AEF34BD8FB5A7B829D3E862371D2CFE5") - - block, _ := aes.NewCipher(kek) - - b.ResetTimer() - for i := 0; i < b.N; i++ { - KeyUnwrap(block, input) - } -} diff --git a/vendor/gopkg.in/square/go-jose.v1/crypter.go b/vendor/gopkg.in/square/go-jose.v1/crypter.go deleted file mode 100644 index f61af2c..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/crypter.go +++ /dev/null @@ -1,349 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose - -import ( - "crypto/ecdsa" - "crypto/rsa" - "fmt" - "reflect" -) - -// Encrypter represents an encrypter which produces an encrypted JWE object. -type Encrypter interface { - Encrypt(plaintext []byte) (*JsonWebEncryption, error) - EncryptWithAuthData(plaintext []byte, aad []byte) (*JsonWebEncryption, error) - SetCompression(alg CompressionAlgorithm) -} - -// MultiEncrypter represents an encrypter which supports multiple recipients. -type MultiEncrypter interface { - Encrypt(plaintext []byte) (*JsonWebEncryption, error) - EncryptWithAuthData(plaintext []byte, aad []byte) (*JsonWebEncryption, error) - SetCompression(alg CompressionAlgorithm) - AddRecipient(alg KeyAlgorithm, encryptionKey interface{}) error -} - -// A generic content cipher -type contentCipher interface { - keySize() int - encrypt(cek []byte, aad, plaintext []byte) (*aeadParts, error) - decrypt(cek []byte, aad []byte, parts *aeadParts) ([]byte, error) -} - -// A key generator (for generating/getting a CEK) -type keyGenerator interface { - keySize() int - genKey() ([]byte, rawHeader, error) -} - -// A generic key encrypter -type keyEncrypter interface { - encryptKey(cek []byte, alg KeyAlgorithm) (recipientInfo, error) // Encrypt a key -} - -// A generic key decrypter -type keyDecrypter interface { - decryptKey(headers rawHeader, recipient *recipientInfo, generator keyGenerator) ([]byte, error) // Decrypt a key -} - -// A generic encrypter based on the given key encrypter and content cipher. -type genericEncrypter struct { - contentAlg ContentEncryption - compressionAlg CompressionAlgorithm - cipher contentCipher - recipients []recipientKeyInfo - keyGenerator keyGenerator -} - -type recipientKeyInfo struct { - keyID string - keyAlg KeyAlgorithm - keyEncrypter keyEncrypter -} - -// SetCompression sets a compression algorithm to be applied before encryption. -func (ctx *genericEncrypter) SetCompression(compressionAlg CompressionAlgorithm) { - ctx.compressionAlg = compressionAlg -} - -// NewEncrypter creates an appropriate encrypter based on the key type -func NewEncrypter(alg KeyAlgorithm, enc ContentEncryption, encryptionKey interface{}) (Encrypter, error) { - encrypter := &genericEncrypter{ - contentAlg: enc, - compressionAlg: NONE, - recipients: []recipientKeyInfo{}, - cipher: getContentCipher(enc), - } - - if encrypter.cipher == nil { - return nil, ErrUnsupportedAlgorithm - } - - var keyID string - var rawKey interface{} - switch encryptionKey := encryptionKey.(type) { - case *JsonWebKey: - keyID = encryptionKey.KeyID - rawKey = encryptionKey.Key - default: - rawKey = encryptionKey - } - - switch alg { - case DIRECT: - // Direct encryption mode must be treated differently - if reflect.TypeOf(rawKey) != reflect.TypeOf([]byte{}) { - return nil, ErrUnsupportedKeyType - } - encrypter.keyGenerator = staticKeyGenerator{ - key: rawKey.([]byte), - } - recipient, _ := newSymmetricRecipient(alg, rawKey.([]byte)) - if keyID != "" { - recipient.keyID = keyID - } - encrypter.recipients = []recipientKeyInfo{recipient} - return encrypter, nil - case ECDH_ES: - // ECDH-ES (w/o key wrapping) is similar to DIRECT mode - typeOf := reflect.TypeOf(rawKey) - if typeOf != reflect.TypeOf(&ecdsa.PublicKey{}) { - return nil, ErrUnsupportedKeyType - } - encrypter.keyGenerator = ecKeyGenerator{ - size: encrypter.cipher.keySize(), - algID: string(enc), - publicKey: rawKey.(*ecdsa.PublicKey), - } - recipient, _ := newECDHRecipient(alg, rawKey.(*ecdsa.PublicKey)) - if keyID != "" { - recipient.keyID = keyID - } - encrypter.recipients = []recipientKeyInfo{recipient} - return encrypter, nil - default: - // Can just add a standard recipient - encrypter.keyGenerator = randomKeyGenerator{ - size: encrypter.cipher.keySize(), - } - err := encrypter.AddRecipient(alg, encryptionKey) - return encrypter, err - } -} - -// NewMultiEncrypter creates a multi-encrypter based on the given parameters -func NewMultiEncrypter(enc ContentEncryption) (MultiEncrypter, error) { - cipher := getContentCipher(enc) - - if cipher == nil { - return nil, ErrUnsupportedAlgorithm - } - - encrypter := &genericEncrypter{ - contentAlg: enc, - compressionAlg: NONE, - recipients: []recipientKeyInfo{}, - cipher: cipher, - keyGenerator: randomKeyGenerator{ - size: cipher.keySize(), - }, - } - - return encrypter, nil -} - -func (ctx *genericEncrypter) AddRecipient(alg KeyAlgorithm, encryptionKey interface{}) (err error) { - var recipient recipientKeyInfo - - switch alg { - case DIRECT, ECDH_ES: - return fmt.Errorf("square/go-jose: key algorithm '%s' not supported in multi-recipient mode", alg) - } - - recipient, err = makeJWERecipient(alg, encryptionKey) - - if err == nil { - ctx.recipients = append(ctx.recipients, recipient) - } - return err -} - -func makeJWERecipient(alg KeyAlgorithm, encryptionKey interface{}) (recipientKeyInfo, error) { - switch encryptionKey := encryptionKey.(type) { - case *rsa.PublicKey: - return newRSARecipient(alg, encryptionKey) - case *ecdsa.PublicKey: - return newECDHRecipient(alg, encryptionKey) - case []byte: - return newSymmetricRecipient(alg, encryptionKey) - case *JsonWebKey: - recipient, err := makeJWERecipient(alg, encryptionKey.Key) - if err == nil && encryptionKey.KeyID != "" { - recipient.keyID = encryptionKey.KeyID - } - return recipient, err - default: - return recipientKeyInfo{}, ErrUnsupportedKeyType - } -} - -// newDecrypter creates an appropriate decrypter based on the key type -func newDecrypter(decryptionKey interface{}) (keyDecrypter, error) { - switch decryptionKey := decryptionKey.(type) { - case *rsa.PrivateKey: - return &rsaDecrypterSigner{ - privateKey: decryptionKey, - }, nil - case *ecdsa.PrivateKey: - return &ecDecrypterSigner{ - privateKey: decryptionKey, - }, nil - case []byte: - return &symmetricKeyCipher{ - key: decryptionKey, - }, nil - case *JsonWebKey: - return newDecrypter(decryptionKey.Key) - default: - return nil, ErrUnsupportedKeyType - } -} - -// Implementation of encrypt method producing a JWE object. -func (ctx *genericEncrypter) Encrypt(plaintext []byte) (*JsonWebEncryption, error) { - return ctx.EncryptWithAuthData(plaintext, nil) -} - -// Implementation of encrypt method producing a JWE object. -func (ctx *genericEncrypter) EncryptWithAuthData(plaintext, aad []byte) (*JsonWebEncryption, error) { - obj := &JsonWebEncryption{} - obj.aad = aad - - obj.protected = &rawHeader{ - Enc: ctx.contentAlg, - } - obj.recipients = make([]recipientInfo, len(ctx.recipients)) - - if len(ctx.recipients) == 0 { - return nil, fmt.Errorf("square/go-jose: no recipients to encrypt to") - } - - cek, headers, err := ctx.keyGenerator.genKey() - if err != nil { - return nil, err - } - - obj.protected.merge(&headers) - - for i, info := range ctx.recipients { - recipient, err := info.keyEncrypter.encryptKey(cek, info.keyAlg) - if err != nil { - return nil, err - } - - recipient.header.Alg = string(info.keyAlg) - if info.keyID != "" { - recipient.header.Kid = info.keyID - } - obj.recipients[i] = recipient - } - - if len(ctx.recipients) == 1 { - // Move per-recipient headers into main protected header if there's - // only a single recipient. - obj.protected.merge(obj.recipients[0].header) - obj.recipients[0].header = nil - } - - if ctx.compressionAlg != NONE { - plaintext, err = compress(ctx.compressionAlg, plaintext) - if err != nil { - return nil, err - } - - obj.protected.Zip = ctx.compressionAlg - } - - authData := obj.computeAuthData() - parts, err := ctx.cipher.encrypt(cek, authData, plaintext) - if err != nil { - return nil, err - } - - obj.iv = parts.iv - obj.ciphertext = parts.ciphertext - obj.tag = parts.tag - - return obj, nil -} - -// Decrypt and validate the object and return the plaintext. -func (obj JsonWebEncryption) Decrypt(decryptionKey interface{}) ([]byte, error) { - headers := obj.mergedHeaders(nil) - - if len(headers.Crit) > 0 { - return nil, fmt.Errorf("square/go-jose: unsupported crit header") - } - - decrypter, err := newDecrypter(decryptionKey) - if err != nil { - return nil, err - } - - cipher := getContentCipher(headers.Enc) - if cipher == nil { - return nil, fmt.Errorf("square/go-jose: unsupported enc value '%s'", string(headers.Enc)) - } - - generator := randomKeyGenerator{ - size: cipher.keySize(), - } - - parts := &aeadParts{ - iv: obj.iv, - ciphertext: obj.ciphertext, - tag: obj.tag, - } - - authData := obj.computeAuthData() - - var plaintext []byte - for _, recipient := range obj.recipients { - recipientHeaders := obj.mergedHeaders(&recipient) - - cek, err := decrypter.decryptKey(recipientHeaders, &recipient, generator) - if err == nil { - // Found a valid CEK -- let's try to decrypt. - plaintext, err = cipher.decrypt(cek, authData, parts) - if err == nil { - break - } - } - } - - if plaintext == nil { - return nil, ErrCryptoFailure - } - - // The "zip" header paramter may only be present in the protected header. - if obj.protected.Zip != "" { - plaintext, err = decompress(obj.protected.Zip, plaintext) - } - - return plaintext, err -} diff --git a/vendor/gopkg.in/square/go-jose.v1/crypter_test.go b/vendor/gopkg.in/square/go-jose.v1/crypter_test.go deleted file mode 100644 index 86b8fc0..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/crypter_test.go +++ /dev/null @@ -1,784 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose - -import ( - "bytes" - "crypto/ecdsa" - "crypto/elliptic" - "crypto/rand" - "crypto/rsa" - "fmt" - "io" - "testing" -) - -// We generate only a single RSA and EC key for testing, speeds up tests. -var rsaTestKey, _ = rsa.GenerateKey(rand.Reader, 2048) - -var ecTestKey256, _ = ecdsa.GenerateKey(elliptic.P256(), rand.Reader) -var ecTestKey384, _ = ecdsa.GenerateKey(elliptic.P384(), rand.Reader) -var ecTestKey521, _ = ecdsa.GenerateKey(elliptic.P521(), rand.Reader) - -func RoundtripJWE(keyAlg KeyAlgorithm, encAlg ContentEncryption, compressionAlg CompressionAlgorithm, serializer func(*JsonWebEncryption) (string, error), corrupter func(*JsonWebEncryption) bool, aad []byte, encryptionKey interface{}, decryptionKey interface{}) error { - enc, err := NewEncrypter(keyAlg, encAlg, encryptionKey) - if err != nil { - return fmt.Errorf("error on new encrypter: %s", err) - } - - enc.SetCompression(compressionAlg) - - input := []byte("Lorem ipsum dolor sit amet") - obj, err := enc.EncryptWithAuthData(input, aad) - if err != nil { - return fmt.Errorf("error in encrypt: %s", err) - } - - msg, err := serializer(obj) - if err != nil { - return fmt.Errorf("error in serializer: %s", err) - } - - parsed, err := ParseEncrypted(msg) - if err != nil { - return fmt.Errorf("error in parse: %s, on msg '%s'", err, msg) - } - - // (Maybe) mangle object - skip := corrupter(parsed) - if skip { - return fmt.Errorf("corrupter indicated message should be skipped") - } - - if bytes.Compare(parsed.GetAuthData(), aad) != 0 { - return fmt.Errorf("auth data in parsed object does not match") - } - - output, err := parsed.Decrypt(decryptionKey) - if err != nil { - return fmt.Errorf("error on decrypt: %s", err) - } - - if bytes.Compare(input, output) != 0 { - return fmt.Errorf("Decrypted output does not match input, got '%s' but wanted '%s'", output, input) - } - - return nil -} - -func TestRoundtripsJWE(t *testing.T) { - // Test matrix - keyAlgs := []KeyAlgorithm{ - DIRECT, ECDH_ES, ECDH_ES_A128KW, ECDH_ES_A192KW, ECDH_ES_A256KW, A128KW, A192KW, A256KW, - RSA1_5, RSA_OAEP, RSA_OAEP_256, A128GCMKW, A192GCMKW, A256GCMKW} - encAlgs := []ContentEncryption{A128GCM, A192GCM, A256GCM, A128CBC_HS256, A192CBC_HS384, A256CBC_HS512} - zipAlgs := []CompressionAlgorithm{NONE, DEFLATE} - - serializers := []func(*JsonWebEncryption) (string, error){ - func(obj *JsonWebEncryption) (string, error) { return obj.CompactSerialize() }, - func(obj *JsonWebEncryption) (string, error) { return obj.FullSerialize(), nil }, - } - - corrupter := func(obj *JsonWebEncryption) bool { return false } - - // Note: can't use AAD with compact serialization - aads := [][]byte{ - nil, - []byte("Ut enim ad minim veniam"), - } - - // Test all different configurations - for _, alg := range keyAlgs { - for _, enc := range encAlgs { - for _, key := range generateTestKeys(alg, enc) { - for _, zip := range zipAlgs { - for i, serializer := range serializers { - err := RoundtripJWE(alg, enc, zip, serializer, corrupter, aads[i], key.enc, key.dec) - if err != nil { - t.Error(err, alg, enc, zip, i) - } - } - } - } - } - } -} - -func TestRoundtripsJWECorrupted(t *testing.T) { - // Test matrix - keyAlgs := []KeyAlgorithm{DIRECT, ECDH_ES, ECDH_ES_A128KW, A128KW, RSA1_5, RSA_OAEP, RSA_OAEP_256, A128GCMKW} - encAlgs := []ContentEncryption{A128GCM, A192GCM, A256GCM, A128CBC_HS256, A192CBC_HS384, A256CBC_HS512} - zipAlgs := []CompressionAlgorithm{NONE, DEFLATE} - - serializers := []func(*JsonWebEncryption) (string, error){ - func(obj *JsonWebEncryption) (string, error) { return obj.CompactSerialize() }, - func(obj *JsonWebEncryption) (string, error) { return obj.FullSerialize(), nil }, - } - - bitflip := func(slice []byte) bool { - if len(slice) > 0 { - slice[0] ^= 0xFF - return false - } - return true - } - - corrupters := []func(*JsonWebEncryption) bool{ - func(obj *JsonWebEncryption) bool { - // Set invalid ciphertext - return bitflip(obj.ciphertext) - }, - func(obj *JsonWebEncryption) bool { - // Set invalid auth tag - return bitflip(obj.tag) - }, - func(obj *JsonWebEncryption) bool { - // Set invalid AAD - return bitflip(obj.aad) - }, - func(obj *JsonWebEncryption) bool { - // Mess with encrypted key - return bitflip(obj.recipients[0].encryptedKey) - }, - func(obj *JsonWebEncryption) bool { - // Mess with GCM-KW auth tag - return bitflip(obj.protected.Tag.bytes()) - }, - } - - // Note: can't use AAD with compact serialization - aads := [][]byte{ - nil, - []byte("Ut enim ad minim veniam"), - } - - // Test all different configurations - for _, alg := range keyAlgs { - for _, enc := range encAlgs { - for _, key := range generateTestKeys(alg, enc) { - for _, zip := range zipAlgs { - for i, serializer := range serializers { - for j, corrupter := range corrupters { - err := RoundtripJWE(alg, enc, zip, serializer, corrupter, aads[i], key.enc, key.dec) - if err == nil { - t.Error("failed to detect corrupt data", err, alg, enc, zip, i, j) - } - } - } - } - } - } - } -} - -func TestEncrypterWithJWKAndKeyID(t *testing.T) { - enc, err := NewEncrypter(A128KW, A128GCM, &JsonWebKey{ - KeyID: "test-id", - Key: []byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}, - }) - if err != nil { - t.Error(err) - } - - ciphertext, _ := enc.Encrypt([]byte("Lorem ipsum dolor sit amet")) - - serialized1, _ := ciphertext.CompactSerialize() - serialized2 := ciphertext.FullSerialize() - - parsed1, _ := ParseEncrypted(serialized1) - parsed2, _ := ParseEncrypted(serialized2) - - if parsed1.Header.KeyID != "test-id" { - t.Errorf("expected message to have key id from JWK, but found '%s' instead", parsed1.Header.KeyID) - } - if parsed2.Header.KeyID != "test-id" { - t.Errorf("expected message to have key id from JWK, but found '%s' instead", parsed2.Header.KeyID) - } -} - -func TestEncrypterWithBrokenRand(t *testing.T) { - keyAlgs := []KeyAlgorithm{ECDH_ES_A128KW, A128KW, RSA1_5, RSA_OAEP, RSA_OAEP_256, A128GCMKW} - encAlgs := []ContentEncryption{A128GCM, A192GCM, A256GCM, A128CBC_HS256, A192CBC_HS384, A256CBC_HS512} - - serializer := func(obj *JsonWebEncryption) (string, error) { return obj.CompactSerialize() } - corrupter := func(obj *JsonWebEncryption) bool { return false } - - // Break rand reader - readers := []func() io.Reader{ - // Totally broken - func() io.Reader { return bytes.NewReader([]byte{}) }, - // Not enough bytes - func() io.Reader { return io.LimitReader(rand.Reader, 20) }, - } - - defer resetRandReader() - - for _, alg := range keyAlgs { - for _, enc := range encAlgs { - for _, key := range generateTestKeys(alg, enc) { - for i, getReader := range readers { - randReader = getReader() - err := RoundtripJWE(alg, enc, NONE, serializer, corrupter, nil, key.enc, key.dec) - if err == nil { - t.Error("encrypter should fail if rand is broken", i) - } - } - } - } - } -} - -func TestNewEncrypterErrors(t *testing.T) { - _, err := NewEncrypter("XYZ", "XYZ", nil) - if err == nil { - t.Error("was able to instantiate encrypter with invalid cipher") - } - - _, err = NewMultiEncrypter("XYZ") - if err == nil { - t.Error("was able to instantiate multi-encrypter with invalid cipher") - } - - _, err = NewEncrypter(DIRECT, A128GCM, nil) - if err == nil { - t.Error("was able to instantiate encrypter with invalid direct key") - } - - _, err = NewEncrypter(ECDH_ES, A128GCM, nil) - if err == nil { - t.Error("was able to instantiate encrypter with invalid EC key") - } -} - -func TestMultiRecipientJWE(t *testing.T) { - enc, err := NewMultiEncrypter(A128GCM) - if err != nil { - panic(err) - } - - err = enc.AddRecipient(RSA_OAEP, &rsaTestKey.PublicKey) - if err != nil { - t.Error("error when adding RSA recipient", err) - } - - sharedKey := []byte{ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - } - - err = enc.AddRecipient(A256GCMKW, sharedKey) - if err != nil { - t.Error("error when adding AES recipient: ", err) - return - } - - input := []byte("Lorem ipsum dolor sit amet") - obj, err := enc.Encrypt(input) - if err != nil { - t.Error("error in encrypt: ", err) - return - } - - msg := obj.FullSerialize() - - parsed, err := ParseEncrypted(msg) - if err != nil { - t.Error("error in parse: ", err) - return - } - - output, err := parsed.Decrypt(rsaTestKey) - if err != nil { - t.Error("error on decrypt with RSA: ", err) - return - } - - if bytes.Compare(input, output) != 0 { - t.Error("Decrypted output does not match input: ", output, input) - return - } - - output, err = parsed.Decrypt(sharedKey) - if err != nil { - t.Error("error on decrypt with AES: ", err) - return - } - - if bytes.Compare(input, output) != 0 { - t.Error("Decrypted output does not match input", output, input) - return - } -} - -func TestMultiRecipientErrors(t *testing.T) { - enc, err := NewMultiEncrypter(A128GCM) - if err != nil { - panic(err) - } - - input := []byte("Lorem ipsum dolor sit amet") - _, err = enc.Encrypt(input) - if err == nil { - t.Error("should fail when encrypting to zero recipients") - } - - err = enc.AddRecipient(DIRECT, nil) - if err == nil { - t.Error("should reject DIRECT mode when encrypting to multiple recipients") - } - - err = enc.AddRecipient(ECDH_ES, nil) - if err == nil { - t.Error("should reject ECDH_ES mode when encrypting to multiple recipients") - } - - err = enc.AddRecipient(RSA1_5, nil) - if err == nil { - t.Error("should reject invalid recipient key") - } -} - -type testKey struct { - enc, dec interface{} -} - -func symmetricTestKey(size int) []testKey { - key, _, _ := randomKeyGenerator{size: size}.genKey() - - return []testKey{ - testKey{ - enc: key, - dec: key, - }, - testKey{ - enc: &JsonWebKey{KeyID: "test", Key: key}, - dec: &JsonWebKey{KeyID: "test", Key: key}, - }, - } -} - -func generateTestKeys(keyAlg KeyAlgorithm, encAlg ContentEncryption) []testKey { - switch keyAlg { - case DIRECT: - return symmetricTestKey(getContentCipher(encAlg).keySize()) - case ECDH_ES, ECDH_ES_A128KW, ECDH_ES_A192KW, ECDH_ES_A256KW: - return []testKey{ - testKey{ - dec: ecTestKey256, - enc: &ecTestKey256.PublicKey, - }, - testKey{ - dec: ecTestKey384, - enc: &ecTestKey384.PublicKey, - }, - testKey{ - dec: ecTestKey521, - enc: &ecTestKey521.PublicKey, - }, - testKey{ - dec: &JsonWebKey{KeyID: "test", Key: ecTestKey256}, - enc: &JsonWebKey{KeyID: "test", Key: &ecTestKey256.PublicKey}, - }, - } - case A128GCMKW, A128KW: - return symmetricTestKey(16) - case A192GCMKW, A192KW: - return symmetricTestKey(24) - case A256GCMKW, A256KW: - return symmetricTestKey(32) - case RSA1_5, RSA_OAEP, RSA_OAEP_256: - return []testKey{testKey{ - dec: rsaTestKey, - enc: &rsaTestKey.PublicKey, - }} - } - - panic("Must update test case") -} - -func RunRoundtripsJWE(b *testing.B, alg KeyAlgorithm, enc ContentEncryption, zip CompressionAlgorithm, priv, pub interface{}) { - serializer := func(obj *JsonWebEncryption) (string, error) { - return obj.CompactSerialize() - } - - corrupter := func(obj *JsonWebEncryption) bool { return false } - - b.ResetTimer() - for i := 0; i < b.N; i++ { - err := RoundtripJWE(alg, enc, zip, serializer, corrupter, nil, pub, priv) - if err != nil { - b.Error(err) - } - } -} - -var ( - chunks = map[string][]byte{ - "1B": make([]byte, 1), - "64B": make([]byte, 64), - "1KB": make([]byte, 1024), - "64KB": make([]byte, 65536), - "1MB": make([]byte, 1048576), - "64MB": make([]byte, 67108864), - } - - symKey, _, _ = randomKeyGenerator{size: 32}.genKey() - - encrypters = map[string]Encrypter{ - "OAEPAndGCM": mustEncrypter(RSA_OAEP, A128GCM, &rsaTestKey.PublicKey), - "PKCSAndGCM": mustEncrypter(RSA1_5, A128GCM, &rsaTestKey.PublicKey), - "OAEPAndCBC": mustEncrypter(RSA_OAEP, A128CBC_HS256, &rsaTestKey.PublicKey), - "PKCSAndCBC": mustEncrypter(RSA1_5, A128CBC_HS256, &rsaTestKey.PublicKey), - "DirectGCM128": mustEncrypter(DIRECT, A128GCM, symKey), - "DirectCBC128": mustEncrypter(DIRECT, A128CBC_HS256, symKey), - "DirectGCM256": mustEncrypter(DIRECT, A256GCM, symKey), - "DirectCBC256": mustEncrypter(DIRECT, A256CBC_HS512, symKey), - "AESKWAndGCM128": mustEncrypter(A128KW, A128GCM, symKey), - "AESKWAndCBC256": mustEncrypter(A256KW, A256GCM, symKey), - "ECDHOnP256AndGCM128": mustEncrypter(ECDH_ES, A128GCM, &ecTestKey256.PublicKey), - "ECDHOnP384AndGCM128": mustEncrypter(ECDH_ES, A128GCM, &ecTestKey384.PublicKey), - "ECDHOnP521AndGCM128": mustEncrypter(ECDH_ES, A128GCM, &ecTestKey521.PublicKey), - } -) - -func BenchmarkEncrypt1BWithOAEPAndGCM(b *testing.B) { benchEncrypt("1B", "OAEPAndGCM", b) } -func BenchmarkEncrypt64BWithOAEPAndGCM(b *testing.B) { benchEncrypt("64B", "OAEPAndGCM", b) } -func BenchmarkEncrypt1KBWithOAEPAndGCM(b *testing.B) { benchEncrypt("1KB", "OAEPAndGCM", b) } -func BenchmarkEncrypt64KBWithOAEPAndGCM(b *testing.B) { benchEncrypt("64KB", "OAEPAndGCM", b) } -func BenchmarkEncrypt1MBWithOAEPAndGCM(b *testing.B) { benchEncrypt("1MB", "OAEPAndGCM", b) } -func BenchmarkEncrypt64MBWithOAEPAndGCM(b *testing.B) { benchEncrypt("64MB", "OAEPAndGCM", b) } - -func BenchmarkEncrypt1BWithPKCSAndGCM(b *testing.B) { benchEncrypt("1B", "PKCSAndGCM", b) } -func BenchmarkEncrypt64BWithPKCSAndGCM(b *testing.B) { benchEncrypt("64B", "PKCSAndGCM", b) } -func BenchmarkEncrypt1KBWithPKCSAndGCM(b *testing.B) { benchEncrypt("1KB", "PKCSAndGCM", b) } -func BenchmarkEncrypt64KBWithPKCSAndGCM(b *testing.B) { benchEncrypt("64KB", "PKCSAndGCM", b) } -func BenchmarkEncrypt1MBWithPKCSAndGCM(b *testing.B) { benchEncrypt("1MB", "PKCSAndGCM", b) } -func BenchmarkEncrypt64MBWithPKCSAndGCM(b *testing.B) { benchEncrypt("64MB", "PKCSAndGCM", b) } - -func BenchmarkEncrypt1BWithOAEPAndCBC(b *testing.B) { benchEncrypt("1B", "OAEPAndCBC", b) } -func BenchmarkEncrypt64BWithOAEPAndCBC(b *testing.B) { benchEncrypt("64B", "OAEPAndCBC", b) } -func BenchmarkEncrypt1KBWithOAEPAndCBC(b *testing.B) { benchEncrypt("1KB", "OAEPAndCBC", b) } -func BenchmarkEncrypt64KBWithOAEPAndCBC(b *testing.B) { benchEncrypt("64KB", "OAEPAndCBC", b) } -func BenchmarkEncrypt1MBWithOAEPAndCBC(b *testing.B) { benchEncrypt("1MB", "OAEPAndCBC", b) } -func BenchmarkEncrypt64MBWithOAEPAndCBC(b *testing.B) { benchEncrypt("64MB", "OAEPAndCBC", b) } - -func BenchmarkEncrypt1BWithPKCSAndCBC(b *testing.B) { benchEncrypt("1B", "PKCSAndCBC", b) } -func BenchmarkEncrypt64BWithPKCSAndCBC(b *testing.B) { benchEncrypt("64B", "PKCSAndCBC", b) } -func BenchmarkEncrypt1KBWithPKCSAndCBC(b *testing.B) { benchEncrypt("1KB", "PKCSAndCBC", b) } -func BenchmarkEncrypt64KBWithPKCSAndCBC(b *testing.B) { benchEncrypt("64KB", "PKCSAndCBC", b) } -func BenchmarkEncrypt1MBWithPKCSAndCBC(b *testing.B) { benchEncrypt("1MB", "PKCSAndCBC", b) } -func BenchmarkEncrypt64MBWithPKCSAndCBC(b *testing.B) { benchEncrypt("64MB", "PKCSAndCBC", b) } - -func BenchmarkEncrypt1BWithDirectGCM128(b *testing.B) { benchEncrypt("1B", "DirectGCM128", b) } -func BenchmarkEncrypt64BWithDirectGCM128(b *testing.B) { benchEncrypt("64B", "DirectGCM128", b) } -func BenchmarkEncrypt1KBWithDirectGCM128(b *testing.B) { benchEncrypt("1KB", "DirectGCM128", b) } -func BenchmarkEncrypt64KBWithDirectGCM128(b *testing.B) { benchEncrypt("64KB", "DirectGCM128", b) } -func BenchmarkEncrypt1MBWithDirectGCM128(b *testing.B) { benchEncrypt("1MB", "DirectGCM128", b) } -func BenchmarkEncrypt64MBWithDirectGCM128(b *testing.B) { benchEncrypt("64MB", "DirectGCM128", b) } - -func BenchmarkEncrypt1BWithDirectCBC128(b *testing.B) { benchEncrypt("1B", "DirectCBC128", b) } -func BenchmarkEncrypt64BWithDirectCBC128(b *testing.B) { benchEncrypt("64B", "DirectCBC128", b) } -func BenchmarkEncrypt1KBWithDirectCBC128(b *testing.B) { benchEncrypt("1KB", "DirectCBC128", b) } -func BenchmarkEncrypt64KBWithDirectCBC128(b *testing.B) { benchEncrypt("64KB", "DirectCBC128", b) } -func BenchmarkEncrypt1MBWithDirectCBC128(b *testing.B) { benchEncrypt("1MB", "DirectCBC128", b) } -func BenchmarkEncrypt64MBWithDirectCBC128(b *testing.B) { benchEncrypt("64MB", "DirectCBC128", b) } - -func BenchmarkEncrypt1BWithDirectGCM256(b *testing.B) { benchEncrypt("1B", "DirectGCM256", b) } -func BenchmarkEncrypt64BWithDirectGCM256(b *testing.B) { benchEncrypt("64B", "DirectGCM256", b) } -func BenchmarkEncrypt1KBWithDirectGCM256(b *testing.B) { benchEncrypt("1KB", "DirectGCM256", b) } -func BenchmarkEncrypt64KBWithDirectGCM256(b *testing.B) { benchEncrypt("64KB", "DirectGCM256", b) } -func BenchmarkEncrypt1MBWithDirectGCM256(b *testing.B) { benchEncrypt("1MB", "DirectGCM256", b) } -func BenchmarkEncrypt64MBWithDirectGCM256(b *testing.B) { benchEncrypt("64MB", "DirectGCM256", b) } - -func BenchmarkEncrypt1BWithDirectCBC256(b *testing.B) { benchEncrypt("1B", "DirectCBC256", b) } -func BenchmarkEncrypt64BWithDirectCBC256(b *testing.B) { benchEncrypt("64B", "DirectCBC256", b) } -func BenchmarkEncrypt1KBWithDirectCBC256(b *testing.B) { benchEncrypt("1KB", "DirectCBC256", b) } -func BenchmarkEncrypt64KBWithDirectCBC256(b *testing.B) { benchEncrypt("64KB", "DirectCBC256", b) } -func BenchmarkEncrypt1MBWithDirectCBC256(b *testing.B) { benchEncrypt("1MB", "DirectCBC256", b) } -func BenchmarkEncrypt64MBWithDirectCBC256(b *testing.B) { benchEncrypt("64MB", "DirectCBC256", b) } - -func BenchmarkEncrypt1BWithAESKWAndGCM128(b *testing.B) { benchEncrypt("1B", "AESKWAndGCM128", b) } -func BenchmarkEncrypt64BWithAESKWAndGCM128(b *testing.B) { benchEncrypt("64B", "AESKWAndGCM128", b) } -func BenchmarkEncrypt1KBWithAESKWAndGCM128(b *testing.B) { benchEncrypt("1KB", "AESKWAndGCM128", b) } -func BenchmarkEncrypt64KBWithAESKWAndGCM128(b *testing.B) { benchEncrypt("64KB", "AESKWAndGCM128", b) } -func BenchmarkEncrypt1MBWithAESKWAndGCM128(b *testing.B) { benchEncrypt("1MB", "AESKWAndGCM128", b) } -func BenchmarkEncrypt64MBWithAESKWAndGCM128(b *testing.B) { benchEncrypt("64MB", "AESKWAndGCM128", b) } - -func BenchmarkEncrypt1BWithAESKWAndCBC256(b *testing.B) { benchEncrypt("1B", "AESKWAndCBC256", b) } -func BenchmarkEncrypt64BWithAESKWAndCBC256(b *testing.B) { benchEncrypt("64B", "AESKWAndCBC256", b) } -func BenchmarkEncrypt1KBWithAESKWAndCBC256(b *testing.B) { benchEncrypt("1KB", "AESKWAndCBC256", b) } -func BenchmarkEncrypt64KBWithAESKWAndCBC256(b *testing.B) { benchEncrypt("64KB", "AESKWAndCBC256", b) } -func BenchmarkEncrypt1MBWithAESKWAndCBC256(b *testing.B) { benchEncrypt("1MB", "AESKWAndCBC256", b) } -func BenchmarkEncrypt64MBWithAESKWAndCBC256(b *testing.B) { benchEncrypt("64MB", "AESKWAndCBC256", b) } - -func BenchmarkEncrypt1BWithECDHOnP256AndGCM128(b *testing.B) { - benchEncrypt("1B", "ECDHOnP256AndGCM128", b) -} -func BenchmarkEncrypt64BWithECDHOnP256AndGCM128(b *testing.B) { - benchEncrypt("64B", "ECDHOnP256AndGCM128", b) -} -func BenchmarkEncrypt1KBWithECDHOnP256AndGCM128(b *testing.B) { - benchEncrypt("1KB", "ECDHOnP256AndGCM128", b) -} -func BenchmarkEncrypt64KBWithECDHOnP256AndGCM128(b *testing.B) { - benchEncrypt("64KB", "ECDHOnP256AndGCM128", b) -} -func BenchmarkEncrypt1MBWithECDHOnP256AndGCM128(b *testing.B) { - benchEncrypt("1MB", "ECDHOnP256AndGCM128", b) -} -func BenchmarkEncrypt64MBWithECDHOnP256AndGCM128(b *testing.B) { - benchEncrypt("64MB", "ECDHOnP256AndGCM128", b) -} - -func BenchmarkEncrypt1BWithECDHOnP384AndGCM128(b *testing.B) { - benchEncrypt("1B", "ECDHOnP384AndGCM128", b) -} -func BenchmarkEncrypt64BWithECDHOnP384AndGCM128(b *testing.B) { - benchEncrypt("64B", "ECDHOnP384AndGCM128", b) -} -func BenchmarkEncrypt1KBWithECDHOnP384AndGCM128(b *testing.B) { - benchEncrypt("1KB", "ECDHOnP384AndGCM128", b) -} -func BenchmarkEncrypt64KBWithECDHOnP384AndGCM128(b *testing.B) { - benchEncrypt("64KB", "ECDHOnP384AndGCM128", b) -} -func BenchmarkEncrypt1MBWithECDHOnP384AndGCM128(b *testing.B) { - benchEncrypt("1MB", "ECDHOnP384AndGCM128", b) -} -func BenchmarkEncrypt64MBWithECDHOnP384AndGCM128(b *testing.B) { - benchEncrypt("64MB", "ECDHOnP384AndGCM128", b) -} - -func BenchmarkEncrypt1BWithECDHOnP521AndGCM128(b *testing.B) { - benchEncrypt("1B", "ECDHOnP521AndGCM128", b) -} -func BenchmarkEncrypt64BWithECDHOnP521AndGCM128(b *testing.B) { - benchEncrypt("64B", "ECDHOnP521AndGCM128", b) -} -func BenchmarkEncrypt1KBWithECDHOnP521AndGCM128(b *testing.B) { - benchEncrypt("1KB", "ECDHOnP521AndGCM128", b) -} -func BenchmarkEncrypt64KBWithECDHOnP521AndGCM128(b *testing.B) { - benchEncrypt("64KB", "ECDHOnP521AndGCM128", b) -} -func BenchmarkEncrypt1MBWithECDHOnP521AndGCM128(b *testing.B) { - benchEncrypt("1MB", "ECDHOnP521AndGCM128", b) -} -func BenchmarkEncrypt64MBWithECDHOnP521AndGCM128(b *testing.B) { - benchEncrypt("64MB", "ECDHOnP521AndGCM128", b) -} - -func benchEncrypt(chunkKey, primKey string, b *testing.B) { - data, ok := chunks[chunkKey] - if !ok { - b.Fatalf("unknown chunk size %s", chunkKey) - } - - enc, ok := encrypters[primKey] - if !ok { - b.Fatalf("unknown encrypter %s", primKey) - } - - b.SetBytes(int64(len(data))) - for i := 0; i < b.N; i++ { - enc.Encrypt(data) - } -} - -var ( - decryptionKeys = map[string]interface{}{ - "OAEPAndGCM": rsaTestKey, - "PKCSAndGCM": rsaTestKey, - "OAEPAndCBC": rsaTestKey, - "PKCSAndCBC": rsaTestKey, - - "DirectGCM128": symKey, - "DirectCBC128": symKey, - "DirectGCM256": symKey, - "DirectCBC256": symKey, - - "AESKWAndGCM128": symKey, - "AESKWAndCBC256": symKey, - - "ECDHOnP256AndGCM128": ecTestKey256, - "ECDHOnP384AndGCM128": ecTestKey384, - "ECDHOnP521AndGCM128": ecTestKey521, - } -) - -func BenchmarkDecrypt1BWithOAEPAndGCM(b *testing.B) { benchDecrypt("1B", "OAEPAndGCM", b) } -func BenchmarkDecrypt64BWithOAEPAndGCM(b *testing.B) { benchDecrypt("64B", "OAEPAndGCM", b) } -func BenchmarkDecrypt1KBWithOAEPAndGCM(b *testing.B) { benchDecrypt("1KB", "OAEPAndGCM", b) } -func BenchmarkDecrypt64KBWithOAEPAndGCM(b *testing.B) { benchDecrypt("64KB", "OAEPAndGCM", b) } -func BenchmarkDecrypt1MBWithOAEPAndGCM(b *testing.B) { benchDecrypt("1MB", "OAEPAndGCM", b) } -func BenchmarkDecrypt64MBWithOAEPAndGCM(b *testing.B) { benchDecrypt("64MB", "OAEPAndGCM", b) } - -func BenchmarkDecrypt1BWithPKCSAndGCM(b *testing.B) { benchDecrypt("1B", "PKCSAndGCM", b) } -func BenchmarkDecrypt64BWithPKCSAndGCM(b *testing.B) { benchDecrypt("64B", "PKCSAndGCM", b) } -func BenchmarkDecrypt1KBWithPKCSAndGCM(b *testing.B) { benchDecrypt("1KB", "PKCSAndGCM", b) } -func BenchmarkDecrypt64KBWithPKCSAndGCM(b *testing.B) { benchDecrypt("64KB", "PKCSAndGCM", b) } -func BenchmarkDecrypt1MBWithPKCSAndGCM(b *testing.B) { benchDecrypt("1MB", "PKCSAndGCM", b) } -func BenchmarkDecrypt64MBWithPKCSAndGCM(b *testing.B) { benchDecrypt("64MB", "PKCSAndGCM", b) } - -func BenchmarkDecrypt1BWithOAEPAndCBC(b *testing.B) { benchDecrypt("1B", "OAEPAndCBC", b) } -func BenchmarkDecrypt64BWithOAEPAndCBC(b *testing.B) { benchDecrypt("64B", "OAEPAndCBC", b) } -func BenchmarkDecrypt1KBWithOAEPAndCBC(b *testing.B) { benchDecrypt("1KB", "OAEPAndCBC", b) } -func BenchmarkDecrypt64KBWithOAEPAndCBC(b *testing.B) { benchDecrypt("64KB", "OAEPAndCBC", b) } -func BenchmarkDecrypt1MBWithOAEPAndCBC(b *testing.B) { benchDecrypt("1MB", "OAEPAndCBC", b) } -func BenchmarkDecrypt64MBWithOAEPAndCBC(b *testing.B) { benchDecrypt("64MB", "OAEPAndCBC", b) } - -func BenchmarkDecrypt1BWithPKCSAndCBC(b *testing.B) { benchDecrypt("1B", "PKCSAndCBC", b) } -func BenchmarkDecrypt64BWithPKCSAndCBC(b *testing.B) { benchDecrypt("64B", "PKCSAndCBC", b) } -func BenchmarkDecrypt1KBWithPKCSAndCBC(b *testing.B) { benchDecrypt("1KB", "PKCSAndCBC", b) } -func BenchmarkDecrypt64KBWithPKCSAndCBC(b *testing.B) { benchDecrypt("64KB", "PKCSAndCBC", b) } -func BenchmarkDecrypt1MBWithPKCSAndCBC(b *testing.B) { benchDecrypt("1MB", "PKCSAndCBC", b) } -func BenchmarkDecrypt64MBWithPKCSAndCBC(b *testing.B) { benchDecrypt("64MB", "PKCSAndCBC", b) } - -func BenchmarkDecrypt1BWithDirectGCM128(b *testing.B) { benchDecrypt("1B", "DirectGCM128", b) } -func BenchmarkDecrypt64BWithDirectGCM128(b *testing.B) { benchDecrypt("64B", "DirectGCM128", b) } -func BenchmarkDecrypt1KBWithDirectGCM128(b *testing.B) { benchDecrypt("1KB", "DirectGCM128", b) } -func BenchmarkDecrypt64KBWithDirectGCM128(b *testing.B) { benchDecrypt("64KB", "DirectGCM128", b) } -func BenchmarkDecrypt1MBWithDirectGCM128(b *testing.B) { benchDecrypt("1MB", "DirectGCM128", b) } -func BenchmarkDecrypt64MBWithDirectGCM128(b *testing.B) { benchDecrypt("64MB", "DirectGCM128", b) } - -func BenchmarkDecrypt1BWithDirectCBC128(b *testing.B) { benchDecrypt("1B", "DirectCBC128", b) } -func BenchmarkDecrypt64BWithDirectCBC128(b *testing.B) { benchDecrypt("64B", "DirectCBC128", b) } -func BenchmarkDecrypt1KBWithDirectCBC128(b *testing.B) { benchDecrypt("1KB", "DirectCBC128", b) } -func BenchmarkDecrypt64KBWithDirectCBC128(b *testing.B) { benchDecrypt("64KB", "DirectCBC128", b) } -func BenchmarkDecrypt1MBWithDirectCBC128(b *testing.B) { benchDecrypt("1MB", "DirectCBC128", b) } -func BenchmarkDecrypt64MBWithDirectCBC128(b *testing.B) { benchDecrypt("64MB", "DirectCBC128", b) } - -func BenchmarkDecrypt1BWithDirectGCM256(b *testing.B) { benchDecrypt("1B", "DirectGCM256", b) } -func BenchmarkDecrypt64BWithDirectGCM256(b *testing.B) { benchDecrypt("64B", "DirectGCM256", b) } -func BenchmarkDecrypt1KBWithDirectGCM256(b *testing.B) { benchDecrypt("1KB", "DirectGCM256", b) } -func BenchmarkDecrypt64KBWithDirectGCM256(b *testing.B) { benchDecrypt("64KB", "DirectGCM256", b) } -func BenchmarkDecrypt1MBWithDirectGCM256(b *testing.B) { benchDecrypt("1MB", "DirectGCM256", b) } -func BenchmarkDecrypt64MBWithDirectGCM256(b *testing.B) { benchDecrypt("64MB", "DirectGCM256", b) } - -func BenchmarkDecrypt1BWithDirectCBC256(b *testing.B) { benchDecrypt("1B", "DirectCBC256", b) } -func BenchmarkDecrypt64BWithDirectCBC256(b *testing.B) { benchDecrypt("64B", "DirectCBC256", b) } -func BenchmarkDecrypt1KBWithDirectCBC256(b *testing.B) { benchDecrypt("1KB", "DirectCBC256", b) } -func BenchmarkDecrypt64KBWithDirectCBC256(b *testing.B) { benchDecrypt("64KB", "DirectCBC256", b) } -func BenchmarkDecrypt1MBWithDirectCBC256(b *testing.B) { benchDecrypt("1MB", "DirectCBC256", b) } -func BenchmarkDecrypt64MBWithDirectCBC256(b *testing.B) { benchDecrypt("64MB", "DirectCBC256", b) } - -func BenchmarkDecrypt1BWithAESKWAndGCM128(b *testing.B) { benchDecrypt("1B", "AESKWAndGCM128", b) } -func BenchmarkDecrypt64BWithAESKWAndGCM128(b *testing.B) { benchDecrypt("64B", "AESKWAndGCM128", b) } -func BenchmarkDecrypt1KBWithAESKWAndGCM128(b *testing.B) { benchDecrypt("1KB", "AESKWAndGCM128", b) } -func BenchmarkDecrypt64KBWithAESKWAndGCM128(b *testing.B) { benchDecrypt("64KB", "AESKWAndGCM128", b) } -func BenchmarkDecrypt1MBWithAESKWAndGCM128(b *testing.B) { benchDecrypt("1MB", "AESKWAndGCM128", b) } -func BenchmarkDecrypt64MBWithAESKWAndGCM128(b *testing.B) { benchDecrypt("64MB", "AESKWAndGCM128", b) } - -func BenchmarkDecrypt1BWithAESKWAndCBC256(b *testing.B) { benchDecrypt("1B", "AESKWAndCBC256", b) } -func BenchmarkDecrypt64BWithAESKWAndCBC256(b *testing.B) { benchDecrypt("64B", "AESKWAndCBC256", b) } -func BenchmarkDecrypt1KBWithAESKWAndCBC256(b *testing.B) { benchDecrypt("1KB", "AESKWAndCBC256", b) } -func BenchmarkDecrypt64KBWithAESKWAndCBC256(b *testing.B) { benchDecrypt("64KB", "AESKWAndCBC256", b) } -func BenchmarkDecrypt1MBWithAESKWAndCBC256(b *testing.B) { benchDecrypt("1MB", "AESKWAndCBC256", b) } -func BenchmarkDecrypt64MBWithAESKWAndCBC256(b *testing.B) { benchDecrypt("64MB", "AESKWAndCBC256", b) } - -func BenchmarkDecrypt1BWithECDHOnP256AndGCM128(b *testing.B) { - benchDecrypt("1B", "ECDHOnP256AndGCM128", b) -} -func BenchmarkDecrypt64BWithECDHOnP256AndGCM128(b *testing.B) { - benchDecrypt("64B", "ECDHOnP256AndGCM128", b) -} -func BenchmarkDecrypt1KBWithECDHOnP256AndGCM128(b *testing.B) { - benchDecrypt("1KB", "ECDHOnP256AndGCM128", b) -} -func BenchmarkDecrypt64KBWithECDHOnP256AndGCM128(b *testing.B) { - benchDecrypt("64KB", "ECDHOnP256AndGCM128", b) -} -func BenchmarkDecrypt1MBWithECDHOnP256AndGCM128(b *testing.B) { - benchDecrypt("1MB", "ECDHOnP256AndGCM128", b) -} -func BenchmarkDecrypt64MBWithECDHOnP256AndGCM128(b *testing.B) { - benchDecrypt("64MB", "ECDHOnP256AndGCM128", b) -} - -func BenchmarkDecrypt1BWithECDHOnP384AndGCM128(b *testing.B) { - benchDecrypt("1B", "ECDHOnP384AndGCM128", b) -} -func BenchmarkDecrypt64BWithECDHOnP384AndGCM128(b *testing.B) { - benchDecrypt("64B", "ECDHOnP384AndGCM128", b) -} -func BenchmarkDecrypt1KBWithECDHOnP384AndGCM128(b *testing.B) { - benchDecrypt("1KB", "ECDHOnP384AndGCM128", b) -} -func BenchmarkDecrypt64KBWithECDHOnP384AndGCM128(b *testing.B) { - benchDecrypt("64KB", "ECDHOnP384AndGCM128", b) -} -func BenchmarkDecrypt1MBWithECDHOnP384AndGCM128(b *testing.B) { - benchDecrypt("1MB", "ECDHOnP384AndGCM128", b) -} -func BenchmarkDecrypt64MBWithECDHOnP384AndGCM128(b *testing.B) { - benchDecrypt("64MB", "ECDHOnP384AndGCM128", b) -} - -func BenchmarkDecrypt1BWithECDHOnP521AndGCM128(b *testing.B) { - benchDecrypt("1B", "ECDHOnP521AndGCM128", b) -} -func BenchmarkDecrypt64BWithECDHOnP521AndGCM128(b *testing.B) { - benchDecrypt("64B", "ECDHOnP521AndGCM128", b) -} -func BenchmarkDecrypt1KBWithECDHOnP521AndGCM128(b *testing.B) { - benchDecrypt("1KB", "ECDHOnP521AndGCM128", b) -} -func BenchmarkDecrypt64KBWithECDHOnP521AndGCM128(b *testing.B) { - benchDecrypt("64KB", "ECDHOnP521AndGCM128", b) -} -func BenchmarkDecrypt1MBWithECDHOnP521AndGCM128(b *testing.B) { - benchDecrypt("1MB", "ECDHOnP521AndGCM128", b) -} -func BenchmarkDecrypt64MBWithECDHOnP521AndGCM128(b *testing.B) { - benchDecrypt("64MB", "ECDHOnP521AndGCM128", b) -} - -func benchDecrypt(chunkKey, primKey string, b *testing.B) { - chunk, ok := chunks[chunkKey] - if !ok { - b.Fatalf("unknown chunk size %s", chunkKey) - } - - enc, ok := encrypters[primKey] - if !ok { - b.Fatalf("unknown encrypter %s", primKey) - } - - dec, ok := decryptionKeys[primKey] - if !ok { - b.Fatalf("unknown decryption key %s", primKey) - } - - data, err := enc.Encrypt(chunk) - if err != nil { - b.Fatal(err) - } - - b.SetBytes(int64(len(chunk))) - b.ResetTimer() - for i := 0; i < b.N; i++ { - data.Decrypt(dec) - } -} - -func mustEncrypter(keyAlg KeyAlgorithm, encAlg ContentEncryption, encryptionKey interface{}) Encrypter { - enc, err := NewEncrypter(keyAlg, encAlg, encryptionKey) - if err != nil { - panic(err) - } - return enc -} diff --git a/vendor/gopkg.in/square/go-jose.v1/doc.go b/vendor/gopkg.in/square/go-jose.v1/doc.go deleted file mode 100644 index b4cd1e9..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/doc.go +++ /dev/null @@ -1,26 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose aims to provide an implementation of the Javascript Object Signing -and Encryption set of standards. For the moment, it mainly focuses on -encryption and signing based on the JSON Web Encryption and JSON Web Signature -standards. The library supports both the compact and full serialization -formats, and has optional support for multiple recipients. - -*/ -package jose // import "gopkg.in/square/go-jose.v1" diff --git a/vendor/gopkg.in/square/go-jose.v1/doc_test.go b/vendor/gopkg.in/square/go-jose.v1/doc_test.go deleted file mode 100644 index 5046829..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/doc_test.go +++ /dev/null @@ -1,226 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose - -import ( - "crypto/ecdsa" - "crypto/rand" - "crypto/rsa" - "fmt" -) - -// Dummy encrypter for use in examples -var encrypter, _ = NewEncrypter(DIRECT, A128GCM, []byte{}) - -func Example_jWE() { - // Generate a public/private key pair to use for this example. The library - // also provides two utility functions (LoadPublicKey and LoadPrivateKey) - // that can be used to load keys from PEM/DER-encoded data. - privateKey, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - panic(err) - } - - // Instantiate an encrypter using RSA-OAEP with AES128-GCM. An error would - // indicate that the selected algorithm(s) are not currently supported. - publicKey := &privateKey.PublicKey - encrypter, err := NewEncrypter(RSA_OAEP, A128GCM, publicKey) - if err != nil { - panic(err) - } - - // Encrypt a sample plaintext. Calling the encrypter returns an encrypted - // JWE object, which can then be serialized for output afterwards. An error - // would indicate a problem in an underlying cryptographic primitive. - var plaintext = []byte("Lorem ipsum dolor sit amet") - object, err := encrypter.Encrypt(plaintext) - if err != nil { - panic(err) - } - - // Serialize the encrypted object using the full serialization format. - // Alternatively you can also use the compact format here by calling - // object.CompactSerialize() instead. - serialized := object.FullSerialize() - - // Parse the serialized, encrypted JWE object. An error would indicate that - // the given input did not represent a valid message. - object, err = ParseEncrypted(serialized) - if err != nil { - panic(err) - } - - // Now we can decrypt and get back our original plaintext. An error here - // would indicate the the message failed to decrypt, e.g. because the auth - // tag was broken or the message was tampered with. - decrypted, err := object.Decrypt(privateKey) - if err != nil { - panic(err) - } - - fmt.Printf(string(decrypted)) - // output: Lorem ipsum dolor sit amet -} - -func Example_jWS() { - // Generate a public/private key pair to use for this example. The library - // also provides two utility functions (LoadPublicKey and LoadPrivateKey) - // that can be used to load keys from PEM/DER-encoded data. - privateKey, err := rsa.GenerateKey(rand.Reader, 2048) - if err != nil { - panic(err) - } - - // Instantiate a signer using RSASSA-PSS (SHA512) with the given private key. - signer, err := NewSigner(PS512, privateKey) - if err != nil { - panic(err) - } - - // Sign a sample payload. Calling the signer returns a protected JWS object, - // which can then be serialized for output afterwards. An error would - // indicate a problem in an underlying cryptographic primitive. - var payload = []byte("Lorem ipsum dolor sit amet") - object, err := signer.Sign(payload) - if err != nil { - panic(err) - } - - // Serialize the encrypted object using the full serialization format. - // Alternatively you can also use the compact format here by calling - // object.CompactSerialize() instead. - serialized := object.FullSerialize() - - // Parse the serialized, protected JWS object. An error would indicate that - // the given input did not represent a valid message. - object, err = ParseSigned(serialized) - if err != nil { - panic(err) - } - - // Now we can verify the signature on the payload. An error here would - // indicate the the message failed to verify, e.g. because the signature was - // broken or the message was tampered with. - output, err := object.Verify(&privateKey.PublicKey) - if err != nil { - panic(err) - } - - fmt.Printf(string(output)) - // output: Lorem ipsum dolor sit amet -} - -func ExampleNewEncrypter_publicKey() { - var publicKey *rsa.PublicKey - - // Instantiate an encrypter using RSA-OAEP with AES128-GCM. - NewEncrypter(RSA_OAEP, A128GCM, publicKey) - - // Instantiate an encrypter using RSA-PKCS1v1.5 with AES128-CBC+HMAC. - NewEncrypter(RSA1_5, A128CBC_HS256, publicKey) -} - -func ExampleNewEncrypter_symmetric() { - var sharedKey []byte - - // Instantiate an encrypter using AES128-GCM with AES-GCM key wrap. - NewEncrypter(A128GCMKW, A128GCM, sharedKey) - - // Instantiate an encrypter using AES256-GCM directly, w/o key wrapping. - NewEncrypter(DIRECT, A256GCM, sharedKey) -} - -func ExampleNewSigner_publicKey() { - var rsaPrivateKey *rsa.PrivateKey - var ecdsaPrivateKey *ecdsa.PrivateKey - - // Instantiate a signer using RSA-PKCS#1v1.5 with SHA-256. - NewSigner(RS256, rsaPrivateKey) - - // Instantiate a signer using ECDSA with SHA-384. - NewSigner(ES384, ecdsaPrivateKey) -} - -func ExampleNewSigner_symmetric() { - var sharedKey []byte - - // Instantiate an signer using HMAC-SHA256. - NewSigner(HS256, sharedKey) - - // Instantiate an signer using HMAC-SHA512. - NewSigner(HS512, sharedKey) -} - -func ExampleNewMultiEncrypter() { - var publicKey *rsa.PublicKey - var sharedKey []byte - - // Instantiate an encrypter using AES-GCM. - encrypter, err := NewMultiEncrypter(A128GCM) - if err != nil { - panic(err) - } - - // Add a recipient using a shared key with AES-GCM key wap - err = encrypter.AddRecipient(A128GCMKW, sharedKey) - if err != nil { - panic(err) - } - - // Add a recipient using an RSA public key with RSA-OAEP - err = encrypter.AddRecipient(RSA_OAEP, publicKey) - if err != nil { - panic(err) - } -} - -func ExampleNewMultiSigner() { - var privateKey *rsa.PrivateKey - var sharedKey []byte - - // Instantiate a signer for multiple recipients. - signer := NewMultiSigner() - - // Add a recipient using a shared key with HMAC-SHA256 - err := signer.AddRecipient(HS256, sharedKey) - if err != nil { - panic(err) - } - - // Add a recipient using an RSA private key with RSASSA-PSS with SHA384 - err = signer.AddRecipient(PS384, privateKey) - if err != nil { - panic(err) - } -} - -func ExampleEncrypter_encrypt() { - // Encrypt a plaintext in order to get an encrypted JWE object. - var plaintext = []byte("This is a secret message") - - encrypter.Encrypt(plaintext) -} - -func ExampleEncrypter_encryptWithAuthData() { - // Encrypt a plaintext in order to get an encrypted JWE object. Also attach - // some additional authenticated data (AAD) to the object. Note that objects - // with attached AAD can only be represented using full serialization. - var plaintext = []byte("This is a secret message") - var aad = []byte("This is authenticated, but public data") - - encrypter.EncryptWithAuthData(plaintext, aad) -} diff --git a/vendor/gopkg.in/square/go-jose.v1/encoding.go b/vendor/gopkg.in/square/go-jose.v1/encoding.go deleted file mode 100644 index 3e2ac0a..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/encoding.go +++ /dev/null @@ -1,191 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose - -import ( - "bytes" - "compress/flate" - "encoding/base64" - "encoding/binary" - "io" - "math/big" - "regexp" - "strings" -) - -var stripWhitespaceRegex = regexp.MustCompile("\\s") - -// Url-safe base64 encode that strips padding -func base64URLEncode(data []byte) string { - var result = base64.URLEncoding.EncodeToString(data) - return strings.TrimRight(result, "=") -} - -// Url-safe base64 decoder that adds padding -func base64URLDecode(data string) ([]byte, error) { - var missing = (4 - len(data)%4) % 4 - data += strings.Repeat("=", missing) - return base64.URLEncoding.DecodeString(data) -} - -// Helper function to serialize known-good objects. -// Precondition: value is not a nil pointer. -func mustSerializeJSON(value interface{}) []byte { - out, err := MarshalJSON(value) - if err != nil { - panic(err) - } - // We never want to serialize the top-level value "null," since it's not a - // valid JOSE message. But if a caller passes in a nil pointer to this method, - // MarshalJSON will happily serialize it as the top-level value "null". If - // that value is then embedded in another operation, for instance by being - // base64-encoded and fed as input to a signing algorithm - // (https://github.com/square/go-jose/issues/22), the result will be - // incorrect. Because this method is intended for known-good objects, and a nil - // pointer is not a known-good object, we are free to panic in this case. - // Note: It's not possible to directly check whether the data pointed at by an - // interface is a nil pointer, so we do this hacky workaround. - // https://groups.google.com/forum/#!topic/golang-nuts/wnH302gBa4I - if string(out) == "null" { - panic("Tried to serialize a nil pointer.") - } - return out -} - -// Strip all newlines and whitespace -func stripWhitespace(data string) string { - return stripWhitespaceRegex.ReplaceAllString(data, "") -} - -// Perform compression based on algorithm -func compress(algorithm CompressionAlgorithm, input []byte) ([]byte, error) { - switch algorithm { - case DEFLATE: - return deflate(input) - default: - return nil, ErrUnsupportedAlgorithm - } -} - -// Perform decompression based on algorithm -func decompress(algorithm CompressionAlgorithm, input []byte) ([]byte, error) { - switch algorithm { - case DEFLATE: - return inflate(input) - default: - return nil, ErrUnsupportedAlgorithm - } -} - -// Compress with DEFLATE -func deflate(input []byte) ([]byte, error) { - output := new(bytes.Buffer) - - // Writing to byte buffer, err is always nil - writer, _ := flate.NewWriter(output, 1) - _, _ = io.Copy(writer, bytes.NewBuffer(input)) - - err := writer.Close() - return output.Bytes(), err -} - -// Decompress with DEFLATE -func inflate(input []byte) ([]byte, error) { - output := new(bytes.Buffer) - reader := flate.NewReader(bytes.NewBuffer(input)) - - _, err := io.Copy(output, reader) - if err != nil { - return nil, err - } - - err = reader.Close() - return output.Bytes(), err -} - -// byteBuffer represents a slice of bytes that can be serialized to url-safe base64. -type byteBuffer struct { - data []byte -} - -func newBuffer(data []byte) *byteBuffer { - if data == nil { - return nil - } - return &byteBuffer{ - data: data, - } -} - -func newFixedSizeBuffer(data []byte, length int) *byteBuffer { - if len(data) > length { - panic("square/go-jose: invalid call to newFixedSizeBuffer (len(data) > length)") - } - pad := make([]byte, length-len(data)) - return newBuffer(append(pad, data...)) -} - -func newBufferFromInt(num uint64) *byteBuffer { - data := make([]byte, 8) - binary.BigEndian.PutUint64(data, num) - return newBuffer(bytes.TrimLeft(data, "\x00")) -} - -func (b *byteBuffer) MarshalJSON() ([]byte, error) { - return MarshalJSON(b.base64()) -} - -func (b *byteBuffer) UnmarshalJSON(data []byte) error { - var encoded string - err := UnmarshalJSON(data, &encoded) - if err != nil { - return err - } - - if encoded == "" { - return nil - } - - decoded, err := base64URLDecode(encoded) - if err != nil { - return err - } - - *b = *newBuffer(decoded) - - return nil -} - -func (b *byteBuffer) base64() string { - return base64URLEncode(b.data) -} - -func (b *byteBuffer) bytes() []byte { - // Handling nil here allows us to transparently handle nil slices when serializing. - if b == nil { - return nil - } - return b.data -} - -func (b byteBuffer) bigInt() *big.Int { - return new(big.Int).SetBytes(b.data) -} - -func (b byteBuffer) toInt() int { - return int(b.bigInt().Int64()) -} diff --git a/vendor/gopkg.in/square/go-jose.v1/encoding_test.go b/vendor/gopkg.in/square/go-jose.v1/encoding_test.go deleted file mode 100644 index e2f8d97..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/encoding_test.go +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 jose - -import ( - "bytes" - "strings" - "testing" -) - -func TestBase64URLEncode(t *testing.T) { - // Test arrays with various sizes - if base64URLEncode([]byte{}) != "" { - t.Error("failed to encode empty array") - } - - if base64URLEncode([]byte{0}) != "AA" { - t.Error("failed to encode [0x00]") - } - - if base64URLEncode([]byte{0, 1}) != "AAE" { - t.Error("failed to encode [0x00, 0x01]") - } - - if base64URLEncode([]byte{0, 1, 2}) != "AAEC" { - t.Error("failed to encode [0x00, 0x01, 0x02]") - } - - if base64URLEncode([]byte{0, 1, 2, 3}) != "AAECAw" { - t.Error("failed to encode [0x00, 0x01, 0x02, 0x03]") - } -} - -func TestBase64URLDecode(t *testing.T) { - // Test arrays with various sizes - val, err := base64URLDecode("") - if err != nil || !bytes.Equal(val, []byte{}) { - t.Error("failed to decode empty array") - } - - val, err = base64URLDecode("AA") - if err != nil || !bytes.Equal(val, []byte{0}) { - t.Error("failed to decode [0x00]") - } - - val, err = base64URLDecode("AAE") - if err != nil || !bytes.Equal(val, []byte{0, 1}) { - t.Error("failed to decode [0x00, 0x01]") - } - - val, err = base64URLDecode("AAEC") - if err != nil || !bytes.Equal(val, []byte{0, 1, 2}) { - t.Error("failed to decode [0x00, 0x01, 0x02]") - } - - val, err = base64URLDecode("AAECAw") - if err != nil || !bytes.Equal(val, []byte{0, 1, 2, 3}) { - t.Error("failed to decode [0x00, 0x01, 0x02, 0x03]") - } -} - -func TestDeflateRoundtrip(t *testing.T) { - original := []byte("Lorem ipsum dolor sit amet") - - compressed, err := deflate(original) - if err != nil { - panic(err) - } - - output, err := inflate(compressed) - if err != nil { - panic(err) - } - - if bytes.Compare(output, original) != 0 { - t.Error("Input and output do not match") - } -} - -func TestInvalidCompression(t *testing.T) { - _, err := compress("XYZ", []byte{}) - if err == nil { - t.Error("should not accept invalid algorithm") - } - - _, err = decompress("XYZ", []byte{}) - if err == nil { - t.Error("should not accept invalid algorithm") - } - - _, err = decompress(DEFLATE, []byte{1, 2, 3, 4}) - if err == nil { - t.Error("should not accept invalid data") - } -} - -func TestByteBufferTrim(t *testing.T) { - buf := newBufferFromInt(1) - if !bytes.Equal(buf.data, []byte{1}) { - t.Error("Byte buffer for integer '1' should contain [0x01]") - } - - buf = newBufferFromInt(65537) - if !bytes.Equal(buf.data, []byte{1, 0, 1}) { - t.Error("Byte buffer for integer '65537' should contain [0x01, 0x00, 0x01]") - } -} - -func TestFixedSizeBuffer(t *testing.T) { - data0 := []byte{} - data1 := []byte{1} - data2 := []byte{1, 2} - data3 := []byte{1, 2, 3} - data4 := []byte{1, 2, 3, 4} - - buf0 := newFixedSizeBuffer(data0, 4) - buf1 := newFixedSizeBuffer(data1, 4) - buf2 := newFixedSizeBuffer(data2, 4) - buf3 := newFixedSizeBuffer(data3, 4) - buf4 := newFixedSizeBuffer(data4, 4) - - if !bytes.Equal(buf0.data, []byte{0, 0, 0, 0}) { - t.Error("Invalid padded buffer for buf0") - } - if !bytes.Equal(buf1.data, []byte{0, 0, 0, 1}) { - t.Error("Invalid padded buffer for buf1") - } - if !bytes.Equal(buf2.data, []byte{0, 0, 1, 2}) { - t.Error("Invalid padded buffer for buf2") - } - if !bytes.Equal(buf3.data, []byte{0, 1, 2, 3}) { - t.Error("Invalid padded buffer for buf3") - } - if !bytes.Equal(buf4.data, []byte{1, 2, 3, 4}) { - t.Error("Invalid padded buffer for buf4") - } -} - -func TestSerializeJSONRejectsNil(t *testing.T) { - defer func() { - r := recover() - if r == nil || !strings.Contains(r.(string), "nil pointer") { - t.Error("serialize function should not accept nil pointer") - } - }() - - mustSerializeJSON(nil) -} - -func TestFixedSizeBufferTooLarge(t *testing.T) { - defer func() { - r := recover() - if r == nil { - t.Error("should not be able to create fixed size buffer with oversized data") - } - }() - - newFixedSizeBuffer(make([]byte, 2), 1) -} diff --git a/vendor/gopkg.in/square/go-jose.v1/jose-util/README.md b/vendor/gopkg.in/square/go-jose.v1/jose-util/README.md deleted file mode 100644 index 6cfe6a7..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/jose-util/README.md +++ /dev/null @@ -1,59 +0,0 @@ -# JOSE CLI - -The `jose-util` command line utility allows for encryption, decryption, signing -and verification of JOSE messages. Its main purpose is to facilitate dealing -with JOSE messages when testing or debugging. - -## Usage - -The utility includes the subcommands `encrypt`, `decrypt`, `sign`, `verify` and -`expand`. Examples for each command can be found below. - -Algorithms are selected via the `--alg` and `--enc` flags, which influence the -`alg` and `enc` headers in respectively. For JWE, `--alg` specifies the key -managment algorithm (e.g. `RSA-OAEP`) and `--enc` specifies the content -encryption algorithm (e.g. `A128GCM`). For JWS, `--alg` specifies the -signature algorithm (e.g. `PS256`). - -Input and output files can be specified via the `--in` and `--out` flags. -Either flag can be omitted, in which case `jose-util` uses stdin/stdout for -input/output respectively. By default each command will output a compact -message, but it's possible to get the full serialization by supplying the -`--full` flag. - -Keys are specified via the `--key` flag. Supported key types are naked RSA/EC -keys and X.509 certificates with embedded RSA/EC keys. Keys must be in PEM -or DER formats. - -## Examples - -### Encrypt - -Takes a plaintext as input, encrypts, and prints the encrypted message. - - jose-util encrypt -k public-key.pem --alg RSA-OAEP --enc A128GCM - -### Decrypt - -Takes an encrypted message (JWE) as input, decrypts, and prints the plaintext. - - jose-util decrypt -k private-key.pem - -### Sign - -Takes a payload as input, signs it, and prints the signed message with the embedded payload. - - jose-util sign -k private-key.pem --alg PS256 - -### Verify - -Reads a signed message (JWS), verifies it, and extracts the payload. - - jose-util verify -k public-key.pem - -### Expand - -Expands a compact message to the full serialization format. - - jose-util expand --format JWE # Expands a compact JWE to full format - jose-util expand --format JWS # Expands a compact JWS to full format diff --git a/vendor/gopkg.in/square/go-jose.v1/jose-util/jose-util.t b/vendor/gopkg.in/square/go-jose.v1/jose-util/jose-util.t deleted file mode 100644 index 5e42ba4..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/jose-util/jose-util.t +++ /dev/null @@ -1,88 +0,0 @@ -Set up test keys. - - $ cat > rsa.pub < -----BEGIN PUBLIC KEY----- - > MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAslWybuiNYR7uOgKuvaBw - > qVk8saEutKhOAaW+3hWF65gJei+ZV8QFfYDxs9ZaRZlWAUMtncQPnw7ZQlXO9ogN - > 5cMcN50C6qMOOZzghK7danalhF5lUETC4Hk3Eisbi/PR3IfVyXaRmqL6X66MKj/J - > AKyD9NFIDVy52K8A198Jojnrw2+XXQW72U68fZtvlyl/BTBWQ9Re5JSTpEcVmpCR - > 8FrFc0RPMBm+G5dRs08vvhZNiTT2JACO5V+J5ZrgP3s5hnGFcQFZgDnXLInDUdoi - > 1MuCjaAU0ta8/08pHMijNix5kFofdPEB954MiZ9k4kQ5/utt02I9x2ssHqw71ojj - > vwIDAQAB - > -----END PUBLIC KEY----- - > EOF - - $ cat > rsa.key < -----BEGIN RSA PRIVATE KEY----- - > MIIEogIBAAKCAQEAslWybuiNYR7uOgKuvaBwqVk8saEutKhOAaW+3hWF65gJei+Z - > V8QFfYDxs9ZaRZlWAUMtncQPnw7ZQlXO9ogN5cMcN50C6qMOOZzghK7danalhF5l - > UETC4Hk3Eisbi/PR3IfVyXaRmqL6X66MKj/JAKyD9NFIDVy52K8A198Jojnrw2+X - > XQW72U68fZtvlyl/BTBWQ9Re5JSTpEcVmpCR8FrFc0RPMBm+G5dRs08vvhZNiTT2 - > JACO5V+J5ZrgP3s5hnGFcQFZgDnXLInDUdoi1MuCjaAU0ta8/08pHMijNix5kFof - > dPEB954MiZ9k4kQ5/utt02I9x2ssHqw71ojjvwIDAQABAoIBABrYDYDmXom1BzUS - > PE1s/ihvt1QhqA8nmn5i/aUeZkc9XofW7GUqq4zlwPxKEtKRL0IHY7Fw1s0hhhCX - > LA0uE7F3OiMg7lR1cOm5NI6kZ83jyCxxrRx1DUSO2nxQotfhPsDMbaDiyS4WxEts - > 0cp2SYJhdYd/jTH9uDfmt+DGwQN7Jixio1Dj3vwB7krDY+mdre4SFY7Gbk9VxkDg - > LgCLMoq52m+wYufP8CTgpKFpMb2/yJrbLhuJxYZrJ3qd/oYo/91k6v7xlBKEOkwD - > 2veGk9Dqi8YPNxaRktTEjnZb6ybhezat93+VVxq4Oem3wMwou1SfXrSUKtgM/p2H - > vfw/76ECgYEA2fNL9tC8u9M0wjA+kvvtDG96qO6O66Hksssy6RWInD+Iqk3MtHQt - > LeoCjvX+zERqwOb6SI6empk5pZ9E3/9vJ0dBqkxx3nqn4M/nRWnExGgngJsL959t - > f50cdxva8y1RjNhT4kCwTrupX/TP8lAG8SfG1Alo2VFR8iWd8hDQcTECgYEA0Xfj - > EgqAsVh4U0s3lFxKjOepEyp0G1Imty5J16SvcOEAD1Mrmz94aSSp0bYhXNVdbf7n - > Rk77htWC7SE29fGjOzZRS76wxj/SJHF+rktHB2Zt23k1jBeZ4uLMPMnGLY/BJ099 - > 5DTGo0yU0rrPbyXosx+ukfQLAHFuggX4RNeM5+8CgYB7M1J/hGMLcUpjcs4MXCgV - > XXbiw2c6v1r9zmtK4odEe42PZ0cNwpY/XAZyNZAAe7Q0stxL44K4NWEmxC80x7lX - > ZKozz96WOpNnO16qGC3IMHAT/JD5Or+04WTT14Ue7UEp8qcIQDTpbJ9DxKk/eglS - > jH+SIHeKULOXw7fSu7p4IQKBgBnyVchIUMSnBtCagpn4DKwDjif3nEY+GNmb/D2g - > ArNiy5UaYk5qwEmV5ws5GkzbiSU07AUDh5ieHgetk5dHhUayZcOSLWeBRFCLVnvU - > i0nZYEZNb1qZGdDG8zGcdNXz9qMd76Qy/WAA/nZT+Zn1AiweAovFxQ8a/etRPf2Z - > DbU1AoGAHpCgP7B/4GTBe49H0AQueQHBn4RIkgqMy9xiMeR+U+U0vaY0TlfLhnX+ - > 5PkNfkPXohXlfL7pxwZNYa6FZhCAubzvhKCdUASivkoGaIEk6g1VTVYS/eDVQ4CA - > slfl+elXtLq/l1kQ8C14jlHrQzSXx4PQvjDEnAmaHSJNz4mP9Fg= - > -----END RSA PRIVATE KEY----- - > EOF - - $ cat > ec.pub < -----BEGIN PUBLIC KEY----- - > MHYwEAYHKoZIzj0CAQYFK4EEACIDYgAE9yoUEAgxTd9svwe9oPqjhcP+f2jcdTL2 - > Wq8Aw2v9ht1dBy00tFRPNrCxFCkvMcJFhSPoDUV5NL7zfh3/psiSNYziGPrWEJYf - > gmYihjSeoOf0ru1erpBrTflImPrMftCy - > -----END PUBLIC KEY----- - > EOF - - $ cat > ec.key < -----BEGIN EC PRIVATE KEY----- - > MIGkAgEBBDDvoj/bM1HokUjYWO/IDFs26Jo0GIFtU3tMQQu7ZabKscDMK3dZA0mK - > v97ij7BBFbCgBwYFK4EEACKhZANiAAT3KhQQCDFN32y/B72g+qOFw/5/aNx1MvZa - > rwDDa/2G3V0HLTS0VE82sLEUKS8xwkWFI+gNRXk0vvN+Hf+myJI1jOIY+tYQlh+C - > ZiKGNJ6g5/Su7V6ukGtN+UiY+sx+0LI= - > -----END EC PRIVATE KEY----- - > EOF - -Encrypt and then decrypt a test message (RSA). - - $ echo "Lorem ipsum dolor sit amet" | - > jose-util encrypt --alg RSA-OAEP --enc A128GCM --key rsa.pub | - > jose-util decrypt --key rsa.key - Lorem ipsum dolor sit amet - -Encrypt and then decrypt a test message (EC). - - $ echo "Lorem ipsum dolor sit amet" | - > jose-util encrypt --alg ECDH-ES+A128KW --enc A128GCM --key ec.pub | - > jose-util decrypt --key ec.key - Lorem ipsum dolor sit amet - -Sign and verify a test message (RSA). - - $ echo "Lorem ipsum dolor sit amet" | - > jose-util sign --alg PS256 --key rsa.key | - > jose-util verify --key rsa.pub - Lorem ipsum dolor sit amet - -Sign and verify a test message (EC). - - $ echo "Lorem ipsum dolor sit amet" | - > jose-util sign --alg ES384 --key ec.key | - > jose-util verify --key ec.pub - Lorem ipsum dolor sit amet diff --git a/vendor/gopkg.in/square/go-jose.v1/jose-util/main.go b/vendor/gopkg.in/square/go-jose.v1/jose-util/main.go deleted file mode 100644 index 48f0109..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/jose-util/main.go +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * Copyright 2014 Square Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * 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 main - -import ( - "fmt" - "io/ioutil" - "os" - - "gopkg.in/alecthomas/kingpin.v2" - "gopkg.in/square/go-jose.v1" -) - -var ( - app = kingpin.New("jose-util", "A command-line utility for dealing with JOSE objects.") - - keyFile = app.Flag("key", "Path to key file (PEM or DER-encoded)").Required().ExistingFile() - inFile = app.Flag("in", "Path to input file (stdin if missing)").ExistingFile() - outFile = app.Flag("out", "Path to output file (stdout if missing)").ExistingFile() - - encryptCommand = app.Command("encrypt", "Encrypt a plaintext, output ciphertext.") - algFlag = encryptCommand.Flag("alg", "Key management algorithm (e.g. RSA-OAEP)").Required().String() - encFlag = encryptCommand.Flag("enc", "Content encryption algorithm (e.g. A128GCM)").Required().String() - - decryptCommand = app.Command("decrypt", "Decrypt a ciphertext, output plaintext.") - - signCommand = app.Command("sign", "Sign a payload, output signed message.") - sigAlgFlag = signCommand.Flag("alg", "Key management algorithm (e.g. RSA-OAEP)").Required().String() - - verifyCommand = app.Command("verify", "Verify a signed message, output payload.") - - expandCommand = app.Command("expand", "Expand JOSE object to full serialization format.") - formatFlag = expandCommand.Flag("format", "Type of message to expand (JWS or JWE, defaults to JWE)").String() - - full = app.Flag("full", "Use full serialization format (instead of compact)").Bool() -) - -func main() { - app.Version("v1") - - command := kingpin.MustParse(app.Parse(os.Args[1:])) - - keyBytes, err := ioutil.ReadFile(*keyFile) - exitOnError(err, "unable to read key file") - - switch command { - case "encrypt": - pub, err := jose.LoadPublicKey(keyBytes) - exitOnError(err, "unable to read public key") - - alg := jose.KeyAlgorithm(*algFlag) - enc := jose.ContentEncryption(*encFlag) - - crypter, err := jose.NewEncrypter(alg, enc, pub) - exitOnError(err, "unable to instantiate encrypter") - - obj, err := crypter.Encrypt(readInput(*inFile)) - exitOnError(err, "unable to encrypt") - - var msg string - if *full { - msg = obj.FullSerialize() - } else { - msg, err = obj.CompactSerialize() - exitOnError(err, "unable to serialize message") - } - - writeOutput(*outFile, []byte(msg)) - case "decrypt": - priv, err := jose.LoadPrivateKey(keyBytes) - exitOnError(err, "unable to read private key") - - obj, err := jose.ParseEncrypted(string(readInput(*inFile))) - exitOnError(err, "unable to parse message") - - plaintext, err := obj.Decrypt(priv) - exitOnError(err, "unable to decrypt message") - - writeOutput(*outFile, plaintext) - case "sign": - signingKey, err := jose.LoadPrivateKey(keyBytes) - exitOnError(err, "unable to read private key") - - alg := jose.SignatureAlgorithm(*sigAlgFlag) - signer, err := jose.NewSigner(alg, signingKey) - exitOnError(err, "unable to make signer") - - obj, err := signer.Sign(readInput(*inFile)) - exitOnError(err, "unable to sign") - - var msg string - if *full { - msg = obj.FullSerialize() - } else { - msg, err = obj.CompactSerialize() - exitOnError(err, "unable to serialize message") - } - - writeOutput(*outFile, []byte(msg)) - case "verify": - verificationKey, err := jose.LoadPublicKey(keyBytes) - exitOnError(err, "unable to read private key") - - obj, err := jose.ParseSigned(string(readInput(*inFile))) - exitOnError(err, "unable to parse message") - - plaintext, err := obj.Verify(verificationKey) - exitOnError(err, "invalid signature") - - writeOutput(*outFile, plaintext) - case "expand": - input := string(readInput(*inFile)) - - var serialized string - var err error - switch *formatFlag { - case "", "JWE": - var jwe *jose.JsonWebEncryption - jwe, err = jose.ParseEncrypted(input) - if err == nil { - serialized = jwe.FullSerialize() - } - case "JWS": - var jws *jose.JsonWebSignature - jws, err = jose.ParseSigned(input) - if err == nil { - serialized = jws.FullSerialize() - } - } - - exitOnError(err, "unable to expand message") - writeOutput(*outFile, []byte(serialized)) - } -} - -// Exit and print error message if we encountered a problem -func exitOnError(err error, msg string) { - if err != nil { - fmt.Fprintf(os.Stderr, "%s: %s\n", msg, err) - os.Exit(1) - } -} - -// Read input from file or stdin -func readInput(path string) []byte { - var bytes []byte - var err error - - if path != "" { - bytes, err = ioutil.ReadFile(path) - } else { - bytes, err = ioutil.ReadAll(os.Stdin) - } - - exitOnError(err, "unable to read input") - return bytes -} - -// Write output to file or stdin -func writeOutput(path string, data []byte) { - var err error - - if path != "" { - err = ioutil.WriteFile(path, data, 0644) - } else { - _, err = os.Stdout.Write(data) - } - - exitOnError(err, "unable to write output") -} diff --git a/vendor/gopkg.in/square/go-jose.v1/json/LICENSE b/vendor/gopkg.in/square/go-jose.v1/json/LICENSE deleted file mode 100644 index 7448756..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2012 The Go Authors. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/gopkg.in/square/go-jose.v1/json/README.md b/vendor/gopkg.in/square/go-jose.v1/json/README.md deleted file mode 100644 index 86de5e5..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/README.md +++ /dev/null @@ -1,13 +0,0 @@ -# Safe JSON - -This repository contains a fork of the `encoding/json` package from Go 1.6. - -The following changes were made: - -* Object deserialization uses case-sensitive member name matching instead of - [case-insensitive matching](https://www.ietf.org/mail-archive/web/json/current/msg03763.html). - This is to avoid differences in the interpretation of JOSE messages between - go-jose and libraries written in other languages. -* When deserializing a JSON object, we check for duplicate keys and reject the - input whenever we detect a duplicate. Rather than trying to work with malformed - data, we prefer to reject it right away. diff --git a/vendor/gopkg.in/square/go-jose.v1/json/bench_test.go b/vendor/gopkg.in/square/go-jose.v1/json/bench_test.go deleted file mode 100644 index ed89d11..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/bench_test.go +++ /dev/null @@ -1,223 +0,0 @@ -// Copyright 2011 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. - -// Large data benchmark. -// The JSON data is a summary of agl's changes in the -// go, webkit, and chromium open source projects. -// We benchmark converting between the JSON form -// and in-memory data structures. - -package json - -import ( - "bytes" - "compress/gzip" - "io/ioutil" - "os" - "strings" - "testing" -) - -type codeResponse struct { - Tree *codeNode `json:"tree"` - Username string `json:"username"` -} - -type codeNode struct { - Name string `json:"name"` - Kids []*codeNode `json:"kids"` - CLWeight float64 `json:"cl_weight"` - Touches int `json:"touches"` - MinT int64 `json:"min_t"` - MaxT int64 `json:"max_t"` - MeanT int64 `json:"mean_t"` -} - -var codeJSON []byte -var codeStruct codeResponse - -func codeInit() { - f, err := os.Open("testdata/code.json.gz") - if err != nil { - panic(err) - } - defer f.Close() - gz, err := gzip.NewReader(f) - if err != nil { - panic(err) - } - data, err := ioutil.ReadAll(gz) - if err != nil { - panic(err) - } - - codeJSON = data - - if err := Unmarshal(codeJSON, &codeStruct); err != nil { - panic("unmarshal code.json: " + err.Error()) - } - - if data, err = Marshal(&codeStruct); err != nil { - panic("marshal code.json: " + err.Error()) - } - - if !bytes.Equal(data, codeJSON) { - println("different lengths", len(data), len(codeJSON)) - for i := 0; i < len(data) && i < len(codeJSON); i++ { - if data[i] != codeJSON[i] { - println("re-marshal: changed at byte", i) - println("orig: ", string(codeJSON[i-10:i+10])) - println("new: ", string(data[i-10:i+10])) - break - } - } - panic("re-marshal code.json: different result") - } -} - -func BenchmarkCodeEncoder(b *testing.B) { - if codeJSON == nil { - b.StopTimer() - codeInit() - b.StartTimer() - } - enc := NewEncoder(ioutil.Discard) - for i := 0; i < b.N; i++ { - if err := enc.Encode(&codeStruct); err != nil { - b.Fatal("Encode:", err) - } - } - b.SetBytes(int64(len(codeJSON))) -} - -func BenchmarkCodeMarshal(b *testing.B) { - if codeJSON == nil { - b.StopTimer() - codeInit() - b.StartTimer() - } - for i := 0; i < b.N; i++ { - if _, err := Marshal(&codeStruct); err != nil { - b.Fatal("Marshal:", err) - } - } - b.SetBytes(int64(len(codeJSON))) -} - -func BenchmarkCodeDecoder(b *testing.B) { - if codeJSON == nil { - b.StopTimer() - codeInit() - b.StartTimer() - } - var buf bytes.Buffer - dec := NewDecoder(&buf) - var r codeResponse - for i := 0; i < b.N; i++ { - buf.Write(codeJSON) - // hide EOF - buf.WriteByte('\n') - buf.WriteByte('\n') - buf.WriteByte('\n') - if err := dec.Decode(&r); err != nil { - b.Fatal("Decode:", err) - } - } - b.SetBytes(int64(len(codeJSON))) -} - -func BenchmarkDecoderStream(b *testing.B) { - b.StopTimer() - var buf bytes.Buffer - dec := NewDecoder(&buf) - buf.WriteString(`"` + strings.Repeat("x", 1000000) + `"` + "\n\n\n") - var x interface{} - if err := dec.Decode(&x); err != nil { - b.Fatal("Decode:", err) - } - ones := strings.Repeat(" 1\n", 300000) + "\n\n\n" - b.StartTimer() - for i := 0; i < b.N; i++ { - if i%300000 == 0 { - buf.WriteString(ones) - } - x = nil - if err := dec.Decode(&x); err != nil || x != 1.0 { - b.Fatalf("Decode: %v after %d", err, i) - } - } -} - -func BenchmarkCodeUnmarshal(b *testing.B) { - if codeJSON == nil { - b.StopTimer() - codeInit() - b.StartTimer() - } - for i := 0; i < b.N; i++ { - var r codeResponse - if err := Unmarshal(codeJSON, &r); err != nil { - b.Fatal("Unmmarshal:", err) - } - } - b.SetBytes(int64(len(codeJSON))) -} - -func BenchmarkCodeUnmarshalReuse(b *testing.B) { - if codeJSON == nil { - b.StopTimer() - codeInit() - b.StartTimer() - } - var r codeResponse - for i := 0; i < b.N; i++ { - if err := Unmarshal(codeJSON, &r); err != nil { - b.Fatal("Unmmarshal:", err) - } - } -} - -func BenchmarkUnmarshalString(b *testing.B) { - data := []byte(`"hello, world"`) - var s string - - for i := 0; i < b.N; i++ { - if err := Unmarshal(data, &s); err != nil { - b.Fatal("Unmarshal:", err) - } - } -} - -func BenchmarkUnmarshalFloat64(b *testing.B) { - var f float64 - data := []byte(`3.14`) - - for i := 0; i < b.N; i++ { - if err := Unmarshal(data, &f); err != nil { - b.Fatal("Unmarshal:", err) - } - } -} - -func BenchmarkUnmarshalInt64(b *testing.B) { - var x int64 - data := []byte(`3`) - - for i := 0; i < b.N; i++ { - if err := Unmarshal(data, &x); err != nil { - b.Fatal("Unmarshal:", err) - } - } -} - -func BenchmarkIssue10335(b *testing.B) { - b.ReportAllocs() - var s struct{} - j := []byte(`{"a":{ }}`) - for n := 0; n < b.N; n++ { - if err := Unmarshal(j, &s); err != nil { - b.Fatal(err) - } - } -} diff --git a/vendor/gopkg.in/square/go-jose.v1/json/decode.go b/vendor/gopkg.in/square/go-jose.v1/json/decode.go deleted file mode 100644 index 37457e5..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/decode.go +++ /dev/null @@ -1,1183 +0,0 @@ -// Copyright 2010 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. - -// Represents JSON data structure using native Go types: booleans, floats, -// strings, arrays, and maps. - -package json - -import ( - "bytes" - "encoding" - "encoding/base64" - "errors" - "fmt" - "reflect" - "runtime" - "strconv" - "unicode" - "unicode/utf16" - "unicode/utf8" -) - -// Unmarshal parses the JSON-encoded data and stores the result -// in the value pointed to by v. -// -// Unmarshal uses the inverse of the encodings that -// Marshal uses, allocating maps, slices, and pointers as necessary, -// with the following additional rules: -// -// To unmarshal JSON into a pointer, Unmarshal first handles the case of -// the JSON being the JSON literal null. In that case, Unmarshal sets -// the pointer to nil. Otherwise, Unmarshal unmarshals the JSON into -// the value pointed at by the pointer. If the pointer is nil, Unmarshal -// allocates a new value for it to point to. -// -// To unmarshal JSON into a struct, Unmarshal matches incoming object -// keys to the keys used by Marshal (either the struct field name or its tag), -// preferring an exact match but also accepting a case-insensitive match. -// Unmarshal will only set exported fields of the struct. -// -// To unmarshal JSON into an interface value, -// Unmarshal stores one of these in the interface value: -// -// bool, for JSON booleans -// float64, for JSON numbers -// string, for JSON strings -// []interface{}, for JSON arrays -// map[string]interface{}, for JSON objects -// nil for JSON null -// -// To unmarshal a JSON array into a slice, Unmarshal resets the slice length -// to zero and then appends each element to the slice. -// As a special case, to unmarshal an empty JSON array into a slice, -// Unmarshal replaces the slice with a new empty slice. -// -// To unmarshal a JSON array into a Go array, Unmarshal decodes -// JSON array elements into corresponding Go array elements. -// If the Go array is smaller than the JSON array, -// the additional JSON array elements are discarded. -// If the JSON array is smaller than the Go array, -// the additional Go array elements are set to zero values. -// -// To unmarshal a JSON object into a string-keyed map, Unmarshal first -// establishes a map to use, If the map is nil, Unmarshal allocates a new map. -// Otherwise Unmarshal reuses the existing map, keeping existing entries. -// Unmarshal then stores key-value pairs from the JSON object into the map. -// -// If a JSON value is not appropriate for a given target type, -// or if a JSON number overflows the target type, Unmarshal -// skips that field and completes the unmarshaling as best it can. -// If no more serious errors are encountered, Unmarshal returns -// an UnmarshalTypeError describing the earliest such error. -// -// The JSON null value unmarshals into an interface, map, pointer, or slice -// by setting that Go value to nil. Because null is often used in JSON to mean -// ``not present,'' unmarshaling a JSON null into any other Go type has no effect -// on the value and produces no error. -// -// When unmarshaling quoted strings, invalid UTF-8 or -// invalid UTF-16 surrogate pairs are not treated as an error. -// Instead, they are replaced by the Unicode replacement -// character U+FFFD. -// -func Unmarshal(data []byte, v interface{}) error { - // Check for well-formedness. - // Avoids filling out half a data structure - // before discovering a JSON syntax error. - var d decodeState - err := checkValid(data, &d.scan) - if err != nil { - return err - } - - d.init(data) - return d.unmarshal(v) -} - -// Unmarshaler is the interface implemented by objects -// that can unmarshal a JSON description of themselves. -// The input can be assumed to be a valid encoding of -// a JSON value. UnmarshalJSON must copy the JSON data -// if it wishes to retain the data after returning. -type Unmarshaler interface { - UnmarshalJSON([]byte) error -} - -// An UnmarshalTypeError describes a JSON value that was -// not appropriate for a value of a specific Go type. -type UnmarshalTypeError struct { - Value string // description of JSON value - "bool", "array", "number -5" - Type reflect.Type // type of Go value it could not be assigned to - Offset int64 // error occurred after reading Offset bytes -} - -func (e *UnmarshalTypeError) Error() string { - return "json: cannot unmarshal " + e.Value + " into Go value of type " + e.Type.String() -} - -// An UnmarshalFieldError describes a JSON object key that -// led to an unexported (and therefore unwritable) struct field. -// (No longer used; kept for compatibility.) -type UnmarshalFieldError struct { - Key string - Type reflect.Type - Field reflect.StructField -} - -func (e *UnmarshalFieldError) Error() string { - return "json: cannot unmarshal object key " + strconv.Quote(e.Key) + " into unexported field " + e.Field.Name + " of type " + e.Type.String() -} - -// An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. -// (The argument to Unmarshal must be a non-nil pointer.) -type InvalidUnmarshalError struct { - Type reflect.Type -} - -func (e *InvalidUnmarshalError) Error() string { - if e.Type == nil { - return "json: Unmarshal(nil)" - } - - if e.Type.Kind() != reflect.Ptr { - return "json: Unmarshal(non-pointer " + e.Type.String() + ")" - } - return "json: Unmarshal(nil " + e.Type.String() + ")" -} - -func (d *decodeState) unmarshal(v interface{}) (err error) { - defer func() { - if r := recover(); r != nil { - if _, ok := r.(runtime.Error); ok { - panic(r) - } - err = r.(error) - } - }() - - rv := reflect.ValueOf(v) - if rv.Kind() != reflect.Ptr || rv.IsNil() { - return &InvalidUnmarshalError{reflect.TypeOf(v)} - } - - d.scan.reset() - // We decode rv not rv.Elem because the Unmarshaler interface - // test must be applied at the top level of the value. - d.value(rv) - return d.savedError -} - -// A Number represents a JSON number literal. -type Number string - -// String returns the literal text of the number. -func (n Number) String() string { return string(n) } - -// Float64 returns the number as a float64. -func (n Number) Float64() (float64, error) { - return strconv.ParseFloat(string(n), 64) -} - -// Int64 returns the number as an int64. -func (n Number) Int64() (int64, error) { - return strconv.ParseInt(string(n), 10, 64) -} - -// isValidNumber reports whether s is a valid JSON number literal. -func isValidNumber(s string) bool { - // This function implements the JSON numbers grammar. - // See https://tools.ietf.org/html/rfc7159#section-6 - // and http://json.org/number.gif - - if s == "" { - return false - } - - // Optional - - if s[0] == '-' { - s = s[1:] - if s == "" { - return false - } - } - - // Digits - switch { - default: - return false - - case s[0] == '0': - s = s[1:] - - case '1' <= s[0] && s[0] <= '9': - s = s[1:] - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - } - } - - // . followed by 1 or more digits. - if len(s) >= 2 && s[0] == '.' && '0' <= s[1] && s[1] <= '9' { - s = s[2:] - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - } - } - - // e or E followed by an optional - or + and - // 1 or more digits. - if len(s) >= 2 && (s[0] == 'e' || s[0] == 'E') { - s = s[1:] - if s[0] == '+' || s[0] == '-' { - s = s[1:] - if s == "" { - return false - } - } - for len(s) > 0 && '0' <= s[0] && s[0] <= '9' { - s = s[1:] - } - } - - // Make sure we are at the end. - return s == "" -} - -// decodeState represents the state while decoding a JSON value. -type decodeState struct { - data []byte - off int // read offset in data - scan scanner - nextscan scanner // for calls to nextValue - savedError error - useNumber bool -} - -// errPhase is used for errors that should not happen unless -// there is a bug in the JSON decoder or something is editing -// the data slice while the decoder executes. -var errPhase = errors.New("JSON decoder out of sync - data changing underfoot?") - -func (d *decodeState) init(data []byte) *decodeState { - d.data = data - d.off = 0 - d.savedError = nil - return d -} - -// error aborts the decoding by panicking with err. -func (d *decodeState) error(err error) { - panic(err) -} - -// saveError saves the first err it is called with, -// for reporting at the end of the unmarshal. -func (d *decodeState) saveError(err error) { - if d.savedError == nil { - d.savedError = err - } -} - -// next cuts off and returns the next full JSON value in d.data[d.off:]. -// The next value is known to be an object or array, not a literal. -func (d *decodeState) next() []byte { - c := d.data[d.off] - item, rest, err := nextValue(d.data[d.off:], &d.nextscan) - if err != nil { - d.error(err) - } - d.off = len(d.data) - len(rest) - - // Our scanner has seen the opening brace/bracket - // and thinks we're still in the middle of the object. - // invent a closing brace/bracket to get it out. - if c == '{' { - d.scan.step(&d.scan, '}') - } else { - d.scan.step(&d.scan, ']') - } - - return item -} - -// scanWhile processes bytes in d.data[d.off:] until it -// receives a scan code not equal to op. -// It updates d.off and returns the new scan code. -func (d *decodeState) scanWhile(op int) int { - var newOp int - for { - if d.off >= len(d.data) { - newOp = d.scan.eof() - d.off = len(d.data) + 1 // mark processed EOF with len+1 - } else { - c := d.data[d.off] - d.off++ - newOp = d.scan.step(&d.scan, c) - } - if newOp != op { - break - } - } - return newOp -} - -// value decodes a JSON value from d.data[d.off:] into the value. -// it updates d.off to point past the decoded value. -func (d *decodeState) value(v reflect.Value) { - if !v.IsValid() { - _, rest, err := nextValue(d.data[d.off:], &d.nextscan) - if err != nil { - d.error(err) - } - d.off = len(d.data) - len(rest) - - // d.scan thinks we're still at the beginning of the item. - // Feed in an empty string - the shortest, simplest value - - // so that it knows we got to the end of the value. - if d.scan.redo { - // rewind. - d.scan.redo = false - d.scan.step = stateBeginValue - } - d.scan.step(&d.scan, '"') - d.scan.step(&d.scan, '"') - - n := len(d.scan.parseState) - if n > 0 && d.scan.parseState[n-1] == parseObjectKey { - // d.scan thinks we just read an object key; finish the object - d.scan.step(&d.scan, ':') - d.scan.step(&d.scan, '"') - d.scan.step(&d.scan, '"') - d.scan.step(&d.scan, '}') - } - - return - } - - switch op := d.scanWhile(scanSkipSpace); op { - default: - d.error(errPhase) - - case scanBeginArray: - d.array(v) - - case scanBeginObject: - d.object(v) - - case scanBeginLiteral: - d.literal(v) - } -} - -type unquotedValue struct{} - -// valueQuoted is like value but decodes a -// quoted string literal or literal null into an interface value. -// If it finds anything other than a quoted string literal or null, -// valueQuoted returns unquotedValue{}. -func (d *decodeState) valueQuoted() interface{} { - switch op := d.scanWhile(scanSkipSpace); op { - default: - d.error(errPhase) - - case scanBeginArray: - d.array(reflect.Value{}) - - case scanBeginObject: - d.object(reflect.Value{}) - - case scanBeginLiteral: - switch v := d.literalInterface().(type) { - case nil, string: - return v - } - } - return unquotedValue{} -} - -// indirect walks down v allocating pointers as needed, -// until it gets to a non-pointer. -// if it encounters an Unmarshaler, indirect stops and returns that. -// if decodingNull is true, indirect stops at the last pointer so it can be set to nil. -func (d *decodeState) indirect(v reflect.Value, decodingNull bool) (Unmarshaler, encoding.TextUnmarshaler, reflect.Value) { - // If v is a named type and is addressable, - // start with its address, so that if the type has pointer methods, - // we find them. - if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() { - v = v.Addr() - } - for { - // Load value from interface, but only if the result will be - // usefully addressable. - if v.Kind() == reflect.Interface && !v.IsNil() { - e := v.Elem() - if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) { - v = e - continue - } - } - - if v.Kind() != reflect.Ptr { - break - } - - if v.Elem().Kind() != reflect.Ptr && decodingNull && v.CanSet() { - break - } - if v.IsNil() { - v.Set(reflect.New(v.Type().Elem())) - } - if v.Type().NumMethod() > 0 { - if u, ok := v.Interface().(Unmarshaler); ok { - return u, nil, reflect.Value{} - } - if u, ok := v.Interface().(encoding.TextUnmarshaler); ok { - return nil, u, reflect.Value{} - } - } - v = v.Elem() - } - return nil, nil, v -} - -// array consumes an array from d.data[d.off-1:], decoding into the value v. -// the first byte of the array ('[') has been read already. -func (d *decodeState) array(v reflect.Value) { - // Check for unmarshaler. - u, ut, pv := d.indirect(v, false) - if u != nil { - d.off-- - err := u.UnmarshalJSON(d.next()) - if err != nil { - d.error(err) - } - return - } - if ut != nil { - d.saveError(&UnmarshalTypeError{"array", v.Type(), int64(d.off)}) - d.off-- - d.next() - return - } - - v = pv - - // Check type of target. - switch v.Kind() { - case reflect.Interface: - if v.NumMethod() == 0 { - // Decoding into nil interface? Switch to non-reflect code. - v.Set(reflect.ValueOf(d.arrayInterface())) - return - } - // Otherwise it's invalid. - fallthrough - default: - d.saveError(&UnmarshalTypeError{"array", v.Type(), int64(d.off)}) - d.off-- - d.next() - return - case reflect.Array: - case reflect.Slice: - break - } - - i := 0 - for { - // Look ahead for ] - can only happen on first iteration. - op := d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - - // Back up so d.value can have the byte we just read. - d.off-- - d.scan.undo(op) - - // Get element of array, growing if necessary. - if v.Kind() == reflect.Slice { - // Grow slice if necessary - if i >= v.Cap() { - newcap := v.Cap() + v.Cap()/2 - if newcap < 4 { - newcap = 4 - } - newv := reflect.MakeSlice(v.Type(), v.Len(), newcap) - reflect.Copy(newv, v) - v.Set(newv) - } - if i >= v.Len() { - v.SetLen(i + 1) - } - } - - if i < v.Len() { - // Decode into element. - d.value(v.Index(i)) - } else { - // Ran out of fixed array: skip. - d.value(reflect.Value{}) - } - i++ - - // Next token must be , or ]. - op = d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - if op != scanArrayValue { - d.error(errPhase) - } - } - - if i < v.Len() { - if v.Kind() == reflect.Array { - // Array. Zero the rest. - z := reflect.Zero(v.Type().Elem()) - for ; i < v.Len(); i++ { - v.Index(i).Set(z) - } - } else { - v.SetLen(i) - } - } - if i == 0 && v.Kind() == reflect.Slice { - v.Set(reflect.MakeSlice(v.Type(), 0, 0)) - } -} - -var nullLiteral = []byte("null") - -// object consumes an object from d.data[d.off-1:], decoding into the value v. -// the first byte ('{') of the object has been read already. -func (d *decodeState) object(v reflect.Value) { - // Check for unmarshaler. - u, ut, pv := d.indirect(v, false) - if u != nil { - d.off-- - err := u.UnmarshalJSON(d.next()) - if err != nil { - d.error(err) - } - return - } - if ut != nil { - d.saveError(&UnmarshalTypeError{"object", v.Type(), int64(d.off)}) - d.off-- - d.next() // skip over { } in input - return - } - v = pv - - // Decoding into nil interface? Switch to non-reflect code. - if v.Kind() == reflect.Interface && v.NumMethod() == 0 { - v.Set(reflect.ValueOf(d.objectInterface())) - return - } - - // Check type of target: struct or map[string]T - switch v.Kind() { - case reflect.Map: - // map must have string kind - t := v.Type() - if t.Key().Kind() != reflect.String { - d.saveError(&UnmarshalTypeError{"object", v.Type(), int64(d.off)}) - d.off-- - d.next() // skip over { } in input - return - } - if v.IsNil() { - v.Set(reflect.MakeMap(t)) - } - case reflect.Struct: - - default: - d.saveError(&UnmarshalTypeError{"object", v.Type(), int64(d.off)}) - d.off-- - d.next() // skip over { } in input - return - } - - var mapElem reflect.Value - keys := map[string]bool{} - - for { - // Read opening " of string key or closing }. - op := d.scanWhile(scanSkipSpace) - if op == scanEndObject { - // closing } - can only happen on first iteration. - break - } - if op != scanBeginLiteral { - d.error(errPhase) - } - - // Read key. - start := d.off - 1 - op = d.scanWhile(scanContinue) - item := d.data[start : d.off-1] - key, ok := unquote(item) - if !ok { - d.error(errPhase) - } - - // Check for duplicate keys. - _, ok = keys[key] - if !ok { - keys[key] = true - } else { - d.error(fmt.Errorf("json: duplicate key '%s' in object", key)) - } - - // Figure out field corresponding to key. - var subv reflect.Value - destring := false // whether the value is wrapped in a string to be decoded first - - if v.Kind() == reflect.Map { - elemType := v.Type().Elem() - if !mapElem.IsValid() { - mapElem = reflect.New(elemType).Elem() - } else { - mapElem.Set(reflect.Zero(elemType)) - } - subv = mapElem - } else { - var f *field - fields := cachedTypeFields(v.Type()) - for i := range fields { - ff := &fields[i] - if bytes.Equal(ff.nameBytes, []byte(key)) { - f = ff - break - } - } - if f != nil { - subv = v - destring = f.quoted - for _, i := range f.index { - if subv.Kind() == reflect.Ptr { - if subv.IsNil() { - subv.Set(reflect.New(subv.Type().Elem())) - } - subv = subv.Elem() - } - subv = subv.Field(i) - } - } - } - - // Read : before value. - if op == scanSkipSpace { - op = d.scanWhile(scanSkipSpace) - } - if op != scanObjectKey { - d.error(errPhase) - } - - // Read value. - if destring { - switch qv := d.valueQuoted().(type) { - case nil: - d.literalStore(nullLiteral, subv, false) - case string: - d.literalStore([]byte(qv), subv, true) - default: - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal unquoted value into %v", subv.Type())) - } - } else { - d.value(subv) - } - - // Write value back to map; - // if using struct, subv points into struct already. - if v.Kind() == reflect.Map { - kv := reflect.ValueOf(key).Convert(v.Type().Key()) - v.SetMapIndex(kv, subv) - } - - // Next token must be , or }. - op = d.scanWhile(scanSkipSpace) - if op == scanEndObject { - break - } - if op != scanObjectValue { - d.error(errPhase) - } - } -} - -// literal consumes a literal from d.data[d.off-1:], decoding into the value v. -// The first byte of the literal has been read already -// (that's how the caller knows it's a literal). -func (d *decodeState) literal(v reflect.Value) { - // All bytes inside literal return scanContinue op code. - start := d.off - 1 - op := d.scanWhile(scanContinue) - - // Scan read one byte too far; back up. - d.off-- - d.scan.undo(op) - - d.literalStore(d.data[start:d.off], v, false) -} - -// convertNumber converts the number literal s to a float64 or a Number -// depending on the setting of d.useNumber. -func (d *decodeState) convertNumber(s string) (interface{}, error) { - if d.useNumber { - return Number(s), nil - } - f, err := strconv.ParseFloat(s, 64) - if err != nil { - return nil, &UnmarshalTypeError{"number " + s, reflect.TypeOf(0.0), int64(d.off)} - } - return f, nil -} - -var numberType = reflect.TypeOf(Number("")) - -// literalStore decodes a literal stored in item into v. -// -// fromQuoted indicates whether this literal came from unwrapping a -// string from the ",string" struct tag option. this is used only to -// produce more helpful error messages. -func (d *decodeState) literalStore(item []byte, v reflect.Value, fromQuoted bool) { - // Check for unmarshaler. - if len(item) == 0 { - //Empty string given - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - return - } - wantptr := item[0] == 'n' // null - u, ut, pv := d.indirect(v, wantptr) - if u != nil { - err := u.UnmarshalJSON(item) - if err != nil { - d.error(err) - } - return - } - if ut != nil { - if item[0] != '"' { - if fromQuoted { - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - } - return - } - s, ok := unquoteBytes(item) - if !ok { - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(errPhase) - } - } - err := ut.UnmarshalText(s) - if err != nil { - d.error(err) - } - return - } - - v = pv - - switch c := item[0]; c { - case 'n': // null - switch v.Kind() { - case reflect.Interface, reflect.Ptr, reflect.Map, reflect.Slice: - v.Set(reflect.Zero(v.Type())) - // otherwise, ignore null for primitives/string - } - case 't', 'f': // true, false - value := c == 't' - switch v.Kind() { - default: - if fromQuoted { - d.saveError(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.saveError(&UnmarshalTypeError{"bool", v.Type(), int64(d.off)}) - } - case reflect.Bool: - v.SetBool(value) - case reflect.Interface: - if v.NumMethod() == 0 { - v.Set(reflect.ValueOf(value)) - } else { - d.saveError(&UnmarshalTypeError{"bool", v.Type(), int64(d.off)}) - } - } - - case '"': // string - s, ok := unquoteBytes(item) - if !ok { - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(errPhase) - } - } - switch v.Kind() { - default: - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - case reflect.Slice: - if v.Type().Elem().Kind() != reflect.Uint8 { - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - break - } - b := make([]byte, base64.StdEncoding.DecodedLen(len(s))) - n, err := base64.StdEncoding.Decode(b, s) - if err != nil { - d.saveError(err) - break - } - v.SetBytes(b[:n]) - case reflect.String: - v.SetString(string(s)) - case reflect.Interface: - if v.NumMethod() == 0 { - v.Set(reflect.ValueOf(string(s))) - } else { - d.saveError(&UnmarshalTypeError{"string", v.Type(), int64(d.off)}) - } - } - - default: // number - if c != '-' && (c < '0' || c > '9') { - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(errPhase) - } - } - s := string(item) - switch v.Kind() { - default: - if v.Kind() == reflect.String && v.Type() == numberType { - v.SetString(s) - if !isValidNumber(s) { - d.error(fmt.Errorf("json: invalid number literal, trying to unmarshal %q into Number", item)) - } - break - } - if fromQuoted { - d.error(fmt.Errorf("json: invalid use of ,string struct tag, trying to unmarshal %q into %v", item, v.Type())) - } else { - d.error(&UnmarshalTypeError{"number", v.Type(), int64(d.off)}) - } - case reflect.Interface: - n, err := d.convertNumber(s) - if err != nil { - d.saveError(err) - break - } - if v.NumMethod() != 0 { - d.saveError(&UnmarshalTypeError{"number", v.Type(), int64(d.off)}) - break - } - v.Set(reflect.ValueOf(n)) - - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - n, err := strconv.ParseInt(s, 10, 64) - if err != nil || v.OverflowInt(n) { - d.saveError(&UnmarshalTypeError{"number " + s, v.Type(), int64(d.off)}) - break - } - v.SetInt(n) - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: - n, err := strconv.ParseUint(s, 10, 64) - if err != nil || v.OverflowUint(n) { - d.saveError(&UnmarshalTypeError{"number " + s, v.Type(), int64(d.off)}) - break - } - v.SetUint(n) - - case reflect.Float32, reflect.Float64: - n, err := strconv.ParseFloat(s, v.Type().Bits()) - if err != nil || v.OverflowFloat(n) { - d.saveError(&UnmarshalTypeError{"number " + s, v.Type(), int64(d.off)}) - break - } - v.SetFloat(n) - } - } -} - -// The xxxInterface routines build up a value to be stored -// in an empty interface. They are not strictly necessary, -// but they avoid the weight of reflection in this common case. - -// valueInterface is like value but returns interface{} -func (d *decodeState) valueInterface() interface{} { - switch d.scanWhile(scanSkipSpace) { - default: - d.error(errPhase) - panic("unreachable") - case scanBeginArray: - return d.arrayInterface() - case scanBeginObject: - return d.objectInterface() - case scanBeginLiteral: - return d.literalInterface() - } -} - -// arrayInterface is like array but returns []interface{}. -func (d *decodeState) arrayInterface() []interface{} { - var v = make([]interface{}, 0) - for { - // Look ahead for ] - can only happen on first iteration. - op := d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - - // Back up so d.value can have the byte we just read. - d.off-- - d.scan.undo(op) - - v = append(v, d.valueInterface()) - - // Next token must be , or ]. - op = d.scanWhile(scanSkipSpace) - if op == scanEndArray { - break - } - if op != scanArrayValue { - d.error(errPhase) - } - } - return v -} - -// objectInterface is like object but returns map[string]interface{}. -func (d *decodeState) objectInterface() map[string]interface{} { - m := make(map[string]interface{}) - keys := map[string]bool{} - - for { - // Read opening " of string key or closing }. - op := d.scanWhile(scanSkipSpace) - if op == scanEndObject { - // closing } - can only happen on first iteration. - break - } - if op != scanBeginLiteral { - d.error(errPhase) - } - - // Read string key. - start := d.off - 1 - op = d.scanWhile(scanContinue) - item := d.data[start : d.off-1] - key, ok := unquote(item) - if !ok { - d.error(errPhase) - } - - // Check for duplicate keys. - _, ok = keys[key] - if !ok { - keys[key] = true - } else { - d.error(fmt.Errorf("json: duplicate key '%s' in object", key)) - } - - // Read : before value. - if op == scanSkipSpace { - op = d.scanWhile(scanSkipSpace) - } - if op != scanObjectKey { - d.error(errPhase) - } - - // Read value. - m[key] = d.valueInterface() - - // Next token must be , or }. - op = d.scanWhile(scanSkipSpace) - if op == scanEndObject { - break - } - if op != scanObjectValue { - d.error(errPhase) - } - } - return m -} - -// literalInterface is like literal but returns an interface value. -func (d *decodeState) literalInterface() interface{} { - // All bytes inside literal return scanContinue op code. - start := d.off - 1 - op := d.scanWhile(scanContinue) - - // Scan read one byte too far; back up. - d.off-- - d.scan.undo(op) - item := d.data[start:d.off] - - switch c := item[0]; c { - case 'n': // null - return nil - - case 't', 'f': // true, false - return c == 't' - - case '"': // string - s, ok := unquote(item) - if !ok { - d.error(errPhase) - } - return s - - default: // number - if c != '-' && (c < '0' || c > '9') { - d.error(errPhase) - } - n, err := d.convertNumber(string(item)) - if err != nil { - d.saveError(err) - } - return n - } -} - -// getu4 decodes \uXXXX from the beginning of s, returning the hex value, -// or it returns -1. -func getu4(s []byte) rune { - if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { - return -1 - } - r, err := strconv.ParseUint(string(s[2:6]), 16, 64) - if err != nil { - return -1 - } - return rune(r) -} - -// unquote converts a quoted JSON string literal s into an actual string t. -// The rules are different than for Go, so cannot use strconv.Unquote. -func unquote(s []byte) (t string, ok bool) { - s, ok = unquoteBytes(s) - t = string(s) - return -} - -func unquoteBytes(s []byte) (t []byte, ok bool) { - if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' { - return - } - s = s[1 : len(s)-1] - - // Check for unusual characters. If there are none, - // then no unquoting is needed, so return a slice of the - // original bytes. - r := 0 - for r < len(s) { - c := s[r] - if c == '\\' || c == '"' || c < ' ' { - break - } - if c < utf8.RuneSelf { - r++ - continue - } - rr, size := utf8.DecodeRune(s[r:]) - if rr == utf8.RuneError && size == 1 { - break - } - r += size - } - if r == len(s) { - return s, true - } - - b := make([]byte, len(s)+2*utf8.UTFMax) - w := copy(b, s[0:r]) - for r < len(s) { - // Out of room? Can only happen if s is full of - // malformed UTF-8 and we're replacing each - // byte with RuneError. - if w >= len(b)-2*utf8.UTFMax { - nb := make([]byte, (len(b)+utf8.UTFMax)*2) - copy(nb, b[0:w]) - b = nb - } - switch c := s[r]; { - case c == '\\': - r++ - if r >= len(s) { - return - } - switch s[r] { - default: - return - case '"', '\\', '/', '\'': - b[w] = s[r] - r++ - w++ - case 'b': - b[w] = '\b' - r++ - w++ - case 'f': - b[w] = '\f' - r++ - w++ - case 'n': - b[w] = '\n' - r++ - w++ - case 'r': - b[w] = '\r' - r++ - w++ - case 't': - b[w] = '\t' - r++ - w++ - case 'u': - r-- - rr := getu4(s[r:]) - if rr < 0 { - return - } - r += 6 - if utf16.IsSurrogate(rr) { - rr1 := getu4(s[r:]) - if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { - // A valid pair; consume. - r += 6 - w += utf8.EncodeRune(b[w:], dec) - break - } - // Invalid surrogate; fall back to replacement rune. - rr = unicode.ReplacementChar - } - w += utf8.EncodeRune(b[w:], rr) - } - - // Quote, control characters are invalid. - case c == '"', c < ' ': - return - - // ASCII - case c < utf8.RuneSelf: - b[w] = c - r++ - w++ - - // Coerce to well-formed UTF-8. - default: - rr, size := utf8.DecodeRune(s[r:]) - r += size - w += utf8.EncodeRune(b[w:], rr) - } - } - return b[0:w], true -} diff --git a/vendor/gopkg.in/square/go-jose.v1/json/decode_test.go b/vendor/gopkg.in/square/go-jose.v1/json/decode_test.go deleted file mode 100644 index 7577b21..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/decode_test.go +++ /dev/null @@ -1,1474 +0,0 @@ -// Copyright 2010 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 json - -import ( - "bytes" - "encoding" - "fmt" - "image" - "net" - "reflect" - "strings" - "testing" - "time" -) - -type T struct { - X string - Y int - Z int `json:"-"` -} - -type U struct { - Alphabet string `json:"alpha"` -} - -type V struct { - F1 interface{} - F2 int32 - F3 Number -} - -// ifaceNumAsFloat64/ifaceNumAsNumber are used to test unmarshaling with and -// without UseNumber -var ifaceNumAsFloat64 = map[string]interface{}{ - "k1": float64(1), - "k2": "s", - "k3": []interface{}{float64(1), float64(2.0), float64(3e-3)}, - "k4": map[string]interface{}{"kk1": "s", "kk2": float64(2)}, -} - -var ifaceNumAsNumber = map[string]interface{}{ - "k1": Number("1"), - "k2": "s", - "k3": []interface{}{Number("1"), Number("2.0"), Number("3e-3")}, - "k4": map[string]interface{}{"kk1": "s", "kk2": Number("2")}, -} - -type tx struct { - x int -} - -// A type that can unmarshal itself. - -type unmarshaler struct { - T bool -} - -func (u *unmarshaler) UnmarshalJSON(b []byte) error { - *u = unmarshaler{true} // All we need to see that UnmarshalJSON is called. - return nil -} - -type ustruct struct { - M unmarshaler -} - -type unmarshalerText struct { - T bool -} - -// needed for re-marshaling tests -func (u *unmarshalerText) MarshalText() ([]byte, error) { - return []byte(""), nil -} - -func (u *unmarshalerText) UnmarshalText(b []byte) error { - *u = unmarshalerText{true} // All we need to see that UnmarshalText is called. - return nil -} - -var _ encoding.TextUnmarshaler = (*unmarshalerText)(nil) - -type ustructText struct { - M unmarshalerText -} - -var ( - um0, um1 unmarshaler // target2 of unmarshaling - ump = &um1 - umtrue = unmarshaler{true} - umslice = []unmarshaler{{true}} - umslicep = new([]unmarshaler) - umstruct = ustruct{unmarshaler{true}} - - um0T, um1T unmarshalerText // target2 of unmarshaling - umpT = &um1T - umtrueT = unmarshalerText{true} - umsliceT = []unmarshalerText{{true}} - umslicepT = new([]unmarshalerText) - umstructT = ustructText{unmarshalerText{true}} -) - -// Test data structures for anonymous fields. - -type Point struct { - Z int -} - -type Top struct { - Level0 int - Embed0 - *Embed0a - *Embed0b `json:"e,omitempty"` // treated as named - Embed0c `json:"-"` // ignored - Loop - Embed0p // has Point with X, Y, used - Embed0q // has Point with Z, used - embed // contains exported field -} - -type Embed0 struct { - Level1a int // overridden by Embed0a's Level1a with json tag - Level1b int // used because Embed0a's Level1b is renamed - Level1c int // used because Embed0a's Level1c is ignored - Level1d int // annihilated by Embed0a's Level1d - Level1e int `json:"x"` // annihilated by Embed0a.Level1e -} - -type Embed0a struct { - Level1a int `json:"Level1a,omitempty"` - Level1b int `json:"LEVEL1B,omitempty"` - Level1c int `json:"-"` - Level1d int // annihilated by Embed0's Level1d - Level1f int `json:"x"` // annihilated by Embed0's Level1e -} - -type Embed0b Embed0 - -type Embed0c Embed0 - -type Embed0p struct { - image.Point -} - -type Embed0q struct { - Point -} - -type embed struct { - Q int -} - -type Loop struct { - Loop1 int `json:",omitempty"` - Loop2 int `json:",omitempty"` - *Loop -} - -// From reflect test: -// The X in S6 and S7 annihilate, but they also block the X in S8.S9. -type S5 struct { - S6 - S7 - S8 -} - -type S6 struct { - X int -} - -type S7 S6 - -type S8 struct { - S9 -} - -type S9 struct { - X int - Y int -} - -// From reflect test: -// The X in S11.S6 and S12.S6 annihilate, but they also block the X in S13.S8.S9. -type S10 struct { - S11 - S12 - S13 -} - -type S11 struct { - S6 -} - -type S12 struct { - S6 -} - -type S13 struct { - S8 -} - -type unmarshalTest struct { - in string - ptr interface{} - out interface{} - err error - useNumber bool -} - -type XYZ struct { - X interface{} - Y interface{} - Z interface{} -} - -func sliceAddr(x []int) *[]int { return &x } -func mapAddr(x map[string]int) *map[string]int { return &x } - -var unmarshalTests = []unmarshalTest{ - // basic types - {in: `true`, ptr: new(bool), out: true}, - {in: `1`, ptr: new(int), out: 1}, - {in: `1.2`, ptr: new(float64), out: 1.2}, - {in: `-5`, ptr: new(int16), out: int16(-5)}, - {in: `2`, ptr: new(Number), out: Number("2"), useNumber: true}, - {in: `2`, ptr: new(Number), out: Number("2")}, - {in: `2`, ptr: new(interface{}), out: float64(2.0)}, - {in: `2`, ptr: new(interface{}), out: Number("2"), useNumber: true}, - {in: `"a\u1234"`, ptr: new(string), out: "a\u1234"}, - {in: `"http:\/\/"`, ptr: new(string), out: "http://"}, - {in: `"g-clef: \uD834\uDD1E"`, ptr: new(string), out: "g-clef: \U0001D11E"}, - {in: `"invalid: \uD834x\uDD1E"`, ptr: new(string), out: "invalid: \uFFFDx\uFFFD"}, - {in: "null", ptr: new(interface{}), out: nil}, - {in: `{"X": [1,2,3], "Y": 4}`, ptr: new(T), out: T{Y: 4}, err: &UnmarshalTypeError{"array", reflect.TypeOf(""), 7}}, - {in: `{"x": 1}`, ptr: new(tx), out: tx{}}, - {in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: float64(1), F2: int32(2), F3: Number("3")}}, - {in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: Number("1"), F2: int32(2), F3: Number("3")}, useNumber: true}, - {in: `{"k1":1,"k2":"s","k3":[1,2.0,3e-3],"k4":{"kk1":"s","kk2":2}}`, ptr: new(interface{}), out: ifaceNumAsFloat64}, - {in: `{"k1":1,"k2":"s","k3":[1,2.0,3e-3],"k4":{"kk1":"s","kk2":2}}`, ptr: new(interface{}), out: ifaceNumAsNumber, useNumber: true}, - - // raw values with whitespace - {in: "\n true ", ptr: new(bool), out: true}, - {in: "\t 1 ", ptr: new(int), out: 1}, - {in: "\r 1.2 ", ptr: new(float64), out: 1.2}, - {in: "\t -5 \n", ptr: new(int16), out: int16(-5)}, - {in: "\t \"a\\u1234\" \n", ptr: new(string), out: "a\u1234"}, - - // Z has a "-" tag. - {in: `{"Y": 1, "Z": 2}`, ptr: new(T), out: T{Y: 1}}, - - {in: `{"alpha": "abc", "alphabet": "xyz"}`, ptr: new(U), out: U{Alphabet: "abc"}}, - {in: `{"alpha": "abc"}`, ptr: new(U), out: U{Alphabet: "abc"}}, - {in: `{"alphabet": "xyz"}`, ptr: new(U), out: U{}}, - - // syntax errors - {in: `{"X": "foo", "Y"}`, err: &SyntaxError{"invalid character '}' after object key", 17}}, - {in: `[1, 2, 3+]`, err: &SyntaxError{"invalid character '+' after array element", 9}}, - {in: `{"X":12x}`, err: &SyntaxError{"invalid character 'x' after object key:value pair", 8}, useNumber: true}, - - // raw value errors - {in: "\x01 42", err: &SyntaxError{"invalid character '\\x01' looking for beginning of value", 1}}, - {in: " 42 \x01", err: &SyntaxError{"invalid character '\\x01' after top-level value", 5}}, - {in: "\x01 true", err: &SyntaxError{"invalid character '\\x01' looking for beginning of value", 1}}, - {in: " false \x01", err: &SyntaxError{"invalid character '\\x01' after top-level value", 8}}, - {in: "\x01 1.2", err: &SyntaxError{"invalid character '\\x01' looking for beginning of value", 1}}, - {in: " 3.4 \x01", err: &SyntaxError{"invalid character '\\x01' after top-level value", 6}}, - {in: "\x01 \"string\"", err: &SyntaxError{"invalid character '\\x01' looking for beginning of value", 1}}, - {in: " \"string\" \x01", err: &SyntaxError{"invalid character '\\x01' after top-level value", 11}}, - - // array tests - {in: `[1, 2, 3]`, ptr: new([3]int), out: [3]int{1, 2, 3}}, - {in: `[1, 2, 3]`, ptr: new([1]int), out: [1]int{1}}, - {in: `[1, 2, 3]`, ptr: new([5]int), out: [5]int{1, 2, 3, 0, 0}}, - - // empty array to interface test - {in: `[]`, ptr: new([]interface{}), out: []interface{}{}}, - {in: `null`, ptr: new([]interface{}), out: []interface{}(nil)}, - {in: `{"T":[]}`, ptr: new(map[string]interface{}), out: map[string]interface{}{"T": []interface{}{}}}, - {in: `{"T":null}`, ptr: new(map[string]interface{}), out: map[string]interface{}{"T": interface{}(nil)}}, - - // composite tests - {in: allValueIndent, ptr: new(All), out: allValue}, - {in: allValueCompact, ptr: new(All), out: allValue}, - {in: allValueIndent, ptr: new(*All), out: &allValue}, - {in: allValueCompact, ptr: new(*All), out: &allValue}, - {in: pallValueIndent, ptr: new(All), out: pallValue}, - {in: pallValueCompact, ptr: new(All), out: pallValue}, - {in: pallValueIndent, ptr: new(*All), out: &pallValue}, - {in: pallValueCompact, ptr: new(*All), out: &pallValue}, - - // unmarshal interface test - {in: `{"T":false}`, ptr: &um0, out: umtrue}, // use "false" so test will fail if custom unmarshaler is not called - {in: `{"T":false}`, ptr: &ump, out: &umtrue}, - {in: `[{"T":false}]`, ptr: &umslice, out: umslice}, - {in: `[{"T":false}]`, ptr: &umslicep, out: &umslice}, - {in: `{"M":{"T":false}}`, ptr: &umstruct, out: umstruct}, - - // UnmarshalText interface test - {in: `"X"`, ptr: &um0T, out: umtrueT}, // use "false" so test will fail if custom unmarshaler is not called - {in: `"X"`, ptr: &umpT, out: &umtrueT}, - {in: `["X"]`, ptr: &umsliceT, out: umsliceT}, - {in: `["X"]`, ptr: &umslicepT, out: &umsliceT}, - {in: `{"M":"X"}`, ptr: &umstructT, out: umstructT}, - - // Overwriting of data. - // This is different from package xml, but it's what we've always done. - // Now documented and tested. - {in: `[2]`, ptr: sliceAddr([]int{1}), out: []int{2}}, - {in: `{"key": 2}`, ptr: mapAddr(map[string]int{"old": 0, "key": 1}), out: map[string]int{"key": 2}}, - - { - in: `{ - "Level0": 1, - "Level1b": 2, - "Level1c": 3, - "x": 4, - "Level1a": 5, - "LEVEL1B": 6, - "e": { - "Level1a": 8, - "Level1b": 9, - "Level1c": 10, - "Level1d": 11, - "x": 12 - }, - "Loop1": 13, - "Loop2": 14, - "X": 15, - "Y": 16, - "Z": 17, - "Q": 18 - }`, - ptr: new(Top), - out: Top{ - Level0: 1, - Embed0: Embed0{ - Level1b: 2, - Level1c: 3, - }, - Embed0a: &Embed0a{ - Level1a: 5, - Level1b: 6, - }, - Embed0b: &Embed0b{ - Level1a: 8, - Level1b: 9, - Level1c: 10, - Level1d: 11, - Level1e: 12, - }, - Loop: Loop{ - Loop1: 13, - Loop2: 14, - }, - Embed0p: Embed0p{ - Point: image.Point{X: 15, Y: 16}, - }, - Embed0q: Embed0q{ - Point: Point{Z: 17}, - }, - embed: embed{ - Q: 18, - }, - }, - }, - { - in: `{"X": 1,"Y":2}`, - ptr: new(S5), - out: S5{S8: S8{S9: S9{Y: 2}}}, - }, - { - in: `{"X": 1,"Y":2}`, - ptr: new(S10), - out: S10{S13: S13{S8: S8{S9: S9{Y: 2}}}}, - }, - - // invalid UTF-8 is coerced to valid UTF-8. - { - in: "\"hello\xffworld\"", - ptr: new(string), - out: "hello\ufffdworld", - }, - { - in: "\"hello\xc2\xc2world\"", - ptr: new(string), - out: "hello\ufffd\ufffdworld", - }, - { - in: "\"hello\xc2\xffworld\"", - ptr: new(string), - out: "hello\ufffd\ufffdworld", - }, - { - in: "\"hello\\ud800world\"", - ptr: new(string), - out: "hello\ufffdworld", - }, - { - in: "\"hello\\ud800\\ud800world\"", - ptr: new(string), - out: "hello\ufffd\ufffdworld", - }, - { - in: "\"hello\\ud800\\ud800world\"", - ptr: new(string), - out: "hello\ufffd\ufffdworld", - }, - { - in: "\"hello\xed\xa0\x80\xed\xb0\x80world\"", - ptr: new(string), - out: "hello\ufffd\ufffd\ufffd\ufffd\ufffd\ufffdworld", - }, - - // issue 8305 - { - in: `{"2009-11-10T23:00:00Z": "hello world"}`, - ptr: &map[time.Time]string{}, - err: &UnmarshalTypeError{"object", reflect.TypeOf(map[time.Time]string{}), 1}, - }, -} - -func TestMarshal(t *testing.T) { - b, err := Marshal(allValue) - if err != nil { - t.Fatalf("Marshal allValue: %v", err) - } - if string(b) != allValueCompact { - t.Errorf("Marshal allValueCompact") - diff(t, b, []byte(allValueCompact)) - return - } - - b, err = Marshal(pallValue) - if err != nil { - t.Fatalf("Marshal pallValue: %v", err) - } - if string(b) != pallValueCompact { - t.Errorf("Marshal pallValueCompact") - diff(t, b, []byte(pallValueCompact)) - return - } -} - -var badUTF8 = []struct { - in, out string -}{ - {"hello\xffworld", `"hello\ufffdworld"`}, - {"", `""`}, - {"\xff", `"\ufffd"`}, - {"\xff\xff", `"\ufffd\ufffd"`}, - {"a\xffb", `"a\ufffdb"`}, - {"\xe6\x97\xa5\xe6\x9c\xac\xff\xaa\x9e", `"日本\ufffd\ufffd\ufffd"`}, -} - -func TestMarshalBadUTF8(t *testing.T) { - for _, tt := range badUTF8 { - b, err := Marshal(tt.in) - if string(b) != tt.out || err != nil { - t.Errorf("Marshal(%q) = %#q, %v, want %#q, nil", tt.in, b, err, tt.out) - } - } -} - -func TestMarshalNumberZeroVal(t *testing.T) { - var n Number - out, err := Marshal(n) - if err != nil { - t.Fatal(err) - } - outStr := string(out) - if outStr != "0" { - t.Fatalf("Invalid zero val for Number: %q", outStr) - } -} - -func TestMarshalEmbeds(t *testing.T) { - top := &Top{ - Level0: 1, - Embed0: Embed0{ - Level1b: 2, - Level1c: 3, - }, - Embed0a: &Embed0a{ - Level1a: 5, - Level1b: 6, - }, - Embed0b: &Embed0b{ - Level1a: 8, - Level1b: 9, - Level1c: 10, - Level1d: 11, - Level1e: 12, - }, - Loop: Loop{ - Loop1: 13, - Loop2: 14, - }, - Embed0p: Embed0p{ - Point: image.Point{X: 15, Y: 16}, - }, - Embed0q: Embed0q{ - Point: Point{Z: 17}, - }, - embed: embed{ - Q: 18, - }, - } - b, err := Marshal(top) - if err != nil { - t.Fatal(err) - } - want := "{\"Level0\":1,\"Level1b\":2,\"Level1c\":3,\"Level1a\":5,\"LEVEL1B\":6,\"e\":{\"Level1a\":8,\"Level1b\":9,\"Level1c\":10,\"Level1d\":11,\"x\":12},\"Loop1\":13,\"Loop2\":14,\"X\":15,\"Y\":16,\"Z\":17,\"Q\":18}" - if string(b) != want { - t.Errorf("Wrong marshal result.\n got: %q\nwant: %q", b, want) - } -} - -func TestUnmarshal(t *testing.T) { - for i, tt := range unmarshalTests { - var scan scanner - in := []byte(tt.in) - if err := checkValid(in, &scan); err != nil { - if !reflect.DeepEqual(err, tt.err) { - t.Errorf("#%d: checkValid: %#v", i, err) - continue - } - } - if tt.ptr == nil { - continue - } - - // v = new(right-type) - v := reflect.New(reflect.TypeOf(tt.ptr).Elem()) - dec := NewDecoder(bytes.NewReader(in)) - if tt.useNumber { - dec.UseNumber() - } - if err := dec.Decode(v.Interface()); !reflect.DeepEqual(err, tt.err) { - t.Errorf("#%d: %v, want %v", i, err, tt.err) - continue - } else if err != nil { - continue - } - if !reflect.DeepEqual(v.Elem().Interface(), tt.out) { - t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.Elem().Interface(), tt.out) - data, _ := Marshal(v.Elem().Interface()) - println(string(data)) - data, _ = Marshal(tt.out) - println(string(data)) - continue - } - - // Check round trip. - if tt.err == nil { - enc, err := Marshal(v.Interface()) - if err != nil { - t.Errorf("#%d: error re-marshaling: %v", i, err) - continue - } - vv := reflect.New(reflect.TypeOf(tt.ptr).Elem()) - dec = NewDecoder(bytes.NewReader(enc)) - if tt.useNumber { - dec.UseNumber() - } - if err := dec.Decode(vv.Interface()); err != nil { - t.Errorf("#%d: error re-unmarshaling %#q: %v", i, enc, err) - continue - } - if !reflect.DeepEqual(v.Elem().Interface(), vv.Elem().Interface()) { - t.Errorf("#%d: mismatch\nhave: %#+v\nwant: %#+v", i, v.Elem().Interface(), vv.Elem().Interface()) - t.Errorf(" In: %q", strings.Map(noSpace, string(in))) - t.Errorf("Marshal: %q", strings.Map(noSpace, string(enc))) - continue - } - } - } -} - -func TestUnmarshalMarshal(t *testing.T) { - initBig() - var v interface{} - if err := Unmarshal(jsonBig, &v); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - b, err := Marshal(v) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - if !bytes.Equal(jsonBig, b) { - t.Errorf("Marshal jsonBig") - diff(t, b, jsonBig) - return - } -} - -var numberTests = []struct { - in string - i int64 - intErr string - f float64 - floatErr string -}{ - {in: "-1.23e1", intErr: "strconv.ParseInt: parsing \"-1.23e1\": invalid syntax", f: -1.23e1}, - {in: "-12", i: -12, f: -12.0}, - {in: "1e1000", intErr: "strconv.ParseInt: parsing \"1e1000\": invalid syntax", floatErr: "strconv.ParseFloat: parsing \"1e1000\": value out of range"}, -} - -// Independent of Decode, basic coverage of the accessors in Number -func TestNumberAccessors(t *testing.T) { - for _, tt := range numberTests { - n := Number(tt.in) - if s := n.String(); s != tt.in { - t.Errorf("Number(%q).String() is %q", tt.in, s) - } - if i, err := n.Int64(); err == nil && tt.intErr == "" && i != tt.i { - t.Errorf("Number(%q).Int64() is %d", tt.in, i) - } else if (err == nil && tt.intErr != "") || (err != nil && err.Error() != tt.intErr) { - t.Errorf("Number(%q).Int64() wanted error %q but got: %v", tt.in, tt.intErr, err) - } - if f, err := n.Float64(); err == nil && tt.floatErr == "" && f != tt.f { - t.Errorf("Number(%q).Float64() is %g", tt.in, f) - } else if (err == nil && tt.floatErr != "") || (err != nil && err.Error() != tt.floatErr) { - t.Errorf("Number(%q).Float64() wanted error %q but got: %v", tt.in, tt.floatErr, err) - } - } -} - -func TestLargeByteSlice(t *testing.T) { - s0 := make([]byte, 2000) - for i := range s0 { - s0[i] = byte(i) - } - b, err := Marshal(s0) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - var s1 []byte - if err := Unmarshal(b, &s1); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if !bytes.Equal(s0, s1) { - t.Errorf("Marshal large byte slice") - diff(t, s0, s1) - } -} - -type Xint struct { - X int -} - -func TestUnmarshalInterface(t *testing.T) { - var xint Xint - var i interface{} = &xint - if err := Unmarshal([]byte(`{"X":1}`), &i); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if xint.X != 1 { - t.Fatalf("Did not write to xint") - } -} - -func TestUnmarshalPtrPtr(t *testing.T) { - var xint Xint - pxint := &xint - if err := Unmarshal([]byte(`{"X":1}`), &pxint); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if xint.X != 1 { - t.Fatalf("Did not write to xint") - } -} - -func TestEscape(t *testing.T) { - const input = `"foobar"` + " [\u2028 \u2029]" - const expected = `"\"foobar\"\u003chtml\u003e [\u2028 \u2029]"` - b, err := Marshal(input) - if err != nil { - t.Fatalf("Marshal error: %v", err) - } - if s := string(b); s != expected { - t.Errorf("Encoding of [%s]:\n got [%s]\nwant [%s]", input, s, expected) - } -} - -// WrongString is a struct that's misusing the ,string modifier. -type WrongString struct { - Message string `json:"result,string"` -} - -type wrongStringTest struct { - in, err string -} - -var wrongStringTests = []wrongStringTest{ - {`{"result":"x"}`, `json: invalid use of ,string struct tag, trying to unmarshal "x" into string`}, - {`{"result":"foo"}`, `json: invalid use of ,string struct tag, trying to unmarshal "foo" into string`}, - {`{"result":"123"}`, `json: invalid use of ,string struct tag, trying to unmarshal "123" into string`}, - {`{"result":123}`, `json: invalid use of ,string struct tag, trying to unmarshal unquoted value into string`}, -} - -// If people misuse the ,string modifier, the error message should be -// helpful, telling the user that they're doing it wrong. -func TestErrorMessageFromMisusedString(t *testing.T) { - for n, tt := range wrongStringTests { - r := strings.NewReader(tt.in) - var s WrongString - err := NewDecoder(r).Decode(&s) - got := fmt.Sprintf("%v", err) - if got != tt.err { - t.Errorf("%d. got err = %q, want %q", n, got, tt.err) - } - } -} - -func noSpace(c rune) rune { - if isSpace(byte(c)) { //only used for ascii - return -1 - } - return c -} - -type All struct { - Bool bool - Int int - Int8 int8 - Int16 int16 - Int32 int32 - Int64 int64 - Uint uint - Uint8 uint8 - Uint16 uint16 - Uint32 uint32 - Uint64 uint64 - Uintptr uintptr - Float32 float32 - Float64 float64 - - Foo string `json:"bar"` - Foo2 string `json:"bar2,dummyopt"` - - IntStr int64 `json:",string"` - - PBool *bool - PInt *int - PInt8 *int8 - PInt16 *int16 - PInt32 *int32 - PInt64 *int64 - PUint *uint - PUint8 *uint8 - PUint16 *uint16 - PUint32 *uint32 - PUint64 *uint64 - PUintptr *uintptr - PFloat32 *float32 - PFloat64 *float64 - - String string - PString *string - - Map map[string]Small - MapP map[string]*Small - PMap *map[string]Small - PMapP *map[string]*Small - - EmptyMap map[string]Small - NilMap map[string]Small - - Slice []Small - SliceP []*Small - PSlice *[]Small - PSliceP *[]*Small - - EmptySlice []Small - NilSlice []Small - - StringSlice []string - ByteSlice []byte - - Small Small - PSmall *Small - PPSmall **Small - - Interface interface{} - PInterface *interface{} - - unexported int -} - -type Small struct { - Tag string -} - -var allValue = All{ - Bool: true, - Int: 2, - Int8: 3, - Int16: 4, - Int32: 5, - Int64: 6, - Uint: 7, - Uint8: 8, - Uint16: 9, - Uint32: 10, - Uint64: 11, - Uintptr: 12, - Float32: 14.1, - Float64: 15.1, - Foo: "foo", - Foo2: "foo2", - IntStr: 42, - String: "16", - Map: map[string]Small{ - "17": {Tag: "tag17"}, - "18": {Tag: "tag18"}, - }, - MapP: map[string]*Small{ - "19": {Tag: "tag19"}, - "20": nil, - }, - EmptyMap: map[string]Small{}, - Slice: []Small{{Tag: "tag20"}, {Tag: "tag21"}}, - SliceP: []*Small{{Tag: "tag22"}, nil, {Tag: "tag23"}}, - EmptySlice: []Small{}, - StringSlice: []string{"str24", "str25", "str26"}, - ByteSlice: []byte{27, 28, 29}, - Small: Small{Tag: "tag30"}, - PSmall: &Small{Tag: "tag31"}, - Interface: 5.2, -} - -var pallValue = All{ - PBool: &allValue.Bool, - PInt: &allValue.Int, - PInt8: &allValue.Int8, - PInt16: &allValue.Int16, - PInt32: &allValue.Int32, - PInt64: &allValue.Int64, - PUint: &allValue.Uint, - PUint8: &allValue.Uint8, - PUint16: &allValue.Uint16, - PUint32: &allValue.Uint32, - PUint64: &allValue.Uint64, - PUintptr: &allValue.Uintptr, - PFloat32: &allValue.Float32, - PFloat64: &allValue.Float64, - PString: &allValue.String, - PMap: &allValue.Map, - PMapP: &allValue.MapP, - PSlice: &allValue.Slice, - PSliceP: &allValue.SliceP, - PPSmall: &allValue.PSmall, - PInterface: &allValue.Interface, -} - -var allValueIndent = `{ - "Bool": true, - "Int": 2, - "Int8": 3, - "Int16": 4, - "Int32": 5, - "Int64": 6, - "Uint": 7, - "Uint8": 8, - "Uint16": 9, - "Uint32": 10, - "Uint64": 11, - "Uintptr": 12, - "Float32": 14.1, - "Float64": 15.1, - "bar": "foo", - "bar2": "foo2", - "IntStr": "42", - "PBool": null, - "PInt": null, - "PInt8": null, - "PInt16": null, - "PInt32": null, - "PInt64": null, - "PUint": null, - "PUint8": null, - "PUint16": null, - "PUint32": null, - "PUint64": null, - "PUintptr": null, - "PFloat32": null, - "PFloat64": null, - "String": "16", - "PString": null, - "Map": { - "17": { - "Tag": "tag17" - }, - "18": { - "Tag": "tag18" - } - }, - "MapP": { - "19": { - "Tag": "tag19" - }, - "20": null - }, - "PMap": null, - "PMapP": null, - "EmptyMap": {}, - "NilMap": null, - "Slice": [ - { - "Tag": "tag20" - }, - { - "Tag": "tag21" - } - ], - "SliceP": [ - { - "Tag": "tag22" - }, - null, - { - "Tag": "tag23" - } - ], - "PSlice": null, - "PSliceP": null, - "EmptySlice": [], - "NilSlice": null, - "StringSlice": [ - "str24", - "str25", - "str26" - ], - "ByteSlice": "Gxwd", - "Small": { - "Tag": "tag30" - }, - "PSmall": { - "Tag": "tag31" - }, - "PPSmall": null, - "Interface": 5.2, - "PInterface": null -}` - -var allValueCompact = strings.Map(noSpace, allValueIndent) - -var pallValueIndent = `{ - "Bool": false, - "Int": 0, - "Int8": 0, - "Int16": 0, - "Int32": 0, - "Int64": 0, - "Uint": 0, - "Uint8": 0, - "Uint16": 0, - "Uint32": 0, - "Uint64": 0, - "Uintptr": 0, - "Float32": 0, - "Float64": 0, - "bar": "", - "bar2": "", - "IntStr": "0", - "PBool": true, - "PInt": 2, - "PInt8": 3, - "PInt16": 4, - "PInt32": 5, - "PInt64": 6, - "PUint": 7, - "PUint8": 8, - "PUint16": 9, - "PUint32": 10, - "PUint64": 11, - "PUintptr": 12, - "PFloat32": 14.1, - "PFloat64": 15.1, - "String": "", - "PString": "16", - "Map": null, - "MapP": null, - "PMap": { - "17": { - "Tag": "tag17" - }, - "18": { - "Tag": "tag18" - } - }, - "PMapP": { - "19": { - "Tag": "tag19" - }, - "20": null - }, - "EmptyMap": null, - "NilMap": null, - "Slice": null, - "SliceP": null, - "PSlice": [ - { - "Tag": "tag20" - }, - { - "Tag": "tag21" - } - ], - "PSliceP": [ - { - "Tag": "tag22" - }, - null, - { - "Tag": "tag23" - } - ], - "EmptySlice": null, - "NilSlice": null, - "StringSlice": null, - "ByteSlice": null, - "Small": { - "Tag": "" - }, - "PSmall": null, - "PPSmall": { - "Tag": "tag31" - }, - "Interface": null, - "PInterface": 5.2 -}` - -var pallValueCompact = strings.Map(noSpace, pallValueIndent) - -func TestRefUnmarshal(t *testing.T) { - type S struct { - // Ref is defined in encode_test.go. - R0 Ref - R1 *Ref - R2 RefText - R3 *RefText - } - want := S{ - R0: 12, - R1: new(Ref), - R2: 13, - R3: new(RefText), - } - *want.R1 = 12 - *want.R3 = 13 - - var got S - if err := Unmarshal([]byte(`{"R0":"ref","R1":"ref","R2":"ref","R3":"ref"}`), &got); err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if !reflect.DeepEqual(got, want) { - t.Errorf("got %+v, want %+v", got, want) - } -} - -// Test that the empty string doesn't panic decoding when ,string is specified -// Issue 3450 -func TestEmptyString(t *testing.T) { - type T2 struct { - Number1 int `json:",string"` - Number2 int `json:",string"` - } - data := `{"Number1":"1", "Number2":""}` - dec := NewDecoder(strings.NewReader(data)) - var t2 T2 - err := dec.Decode(&t2) - if err == nil { - t.Fatal("Decode: did not return error") - } - if t2.Number1 != 1 { - t.Fatal("Decode: did not set Number1") - } -} - -// Test that a null for ,string is not replaced with the previous quoted string (issue 7046). -// It should also not be an error (issue 2540, issue 8587). -func TestNullString(t *testing.T) { - type T struct { - A int `json:",string"` - B int `json:",string"` - C *int `json:",string"` - } - data := []byte(`{"A": "1", "B": null, "C": null}`) - var s T - s.B = 1 - s.C = new(int) - *s.C = 2 - err := Unmarshal(data, &s) - if err != nil { - t.Fatalf("Unmarshal: %v", err) - } - if s.B != 1 || s.C != nil { - t.Fatalf("after Unmarshal, s.B=%d, s.C=%p, want 1, nil", s.B, s.C) - } -} - -func intp(x int) *int { - p := new(int) - *p = x - return p -} - -func intpp(x *int) **int { - pp := new(*int) - *pp = x - return pp -} - -var interfaceSetTests = []struct { - pre interface{} - json string - post interface{} -}{ - {"foo", `"bar"`, "bar"}, - {"foo", `2`, 2.0}, - {"foo", `true`, true}, - {"foo", `null`, nil}, - - {nil, `null`, nil}, - {new(int), `null`, nil}, - {(*int)(nil), `null`, nil}, - {new(*int), `null`, new(*int)}, - {(**int)(nil), `null`, nil}, - {intp(1), `null`, nil}, - {intpp(nil), `null`, intpp(nil)}, - {intpp(intp(1)), `null`, intpp(nil)}, -} - -func TestInterfaceSet(t *testing.T) { - for _, tt := range interfaceSetTests { - b := struct{ X interface{} }{tt.pre} - blob := `{"X":` + tt.json + `}` - if err := Unmarshal([]byte(blob), &b); err != nil { - t.Errorf("Unmarshal %#q: %v", blob, err) - continue - } - if !reflect.DeepEqual(b.X, tt.post) { - t.Errorf("Unmarshal %#q into %#v: X=%#v, want %#v", blob, tt.pre, b.X, tt.post) - } - } -} - -// JSON null values should be ignored for primitives and string values instead of resulting in an error. -// Issue 2540 -func TestUnmarshalNulls(t *testing.T) { - jsonData := []byte(`{ - "Bool" : null, - "Int" : null, - "Int8" : null, - "Int16" : null, - "Int32" : null, - "Int64" : null, - "Uint" : null, - "Uint8" : null, - "Uint16" : null, - "Uint32" : null, - "Uint64" : null, - "Float32" : null, - "Float64" : null, - "String" : null}`) - - nulls := All{ - Bool: true, - Int: 2, - Int8: 3, - Int16: 4, - Int32: 5, - Int64: 6, - Uint: 7, - Uint8: 8, - Uint16: 9, - Uint32: 10, - Uint64: 11, - Float32: 12.1, - Float64: 13.1, - String: "14"} - - err := Unmarshal(jsonData, &nulls) - if err != nil { - t.Errorf("Unmarshal of null values failed: %v", err) - } - if !nulls.Bool || nulls.Int != 2 || nulls.Int8 != 3 || nulls.Int16 != 4 || nulls.Int32 != 5 || nulls.Int64 != 6 || - nulls.Uint != 7 || nulls.Uint8 != 8 || nulls.Uint16 != 9 || nulls.Uint32 != 10 || nulls.Uint64 != 11 || - nulls.Float32 != 12.1 || nulls.Float64 != 13.1 || nulls.String != "14" { - - t.Errorf("Unmarshal of null values affected primitives") - } -} - -func TestStringKind(t *testing.T) { - type stringKind string - - var m1, m2 map[stringKind]int - m1 = map[stringKind]int{ - "foo": 42, - } - - data, err := Marshal(m1) - if err != nil { - t.Errorf("Unexpected error marshaling: %v", err) - } - - err = Unmarshal(data, &m2) - if err != nil { - t.Errorf("Unexpected error unmarshaling: %v", err) - } - - if !reflect.DeepEqual(m1, m2) { - t.Error("Items should be equal after encoding and then decoding") - } -} - -// Custom types with []byte as underlying type could not be marshalled -// and then unmarshalled. -// Issue 8962. -func TestByteKind(t *testing.T) { - type byteKind []byte - - a := byteKind("hello") - - data, err := Marshal(a) - if err != nil { - t.Error(err) - } - var b byteKind - err = Unmarshal(data, &b) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(a, b) { - t.Errorf("expected %v == %v", a, b) - } -} - -// The fix for issue 8962 introduced a regression. -// Issue 12921. -func TestSliceOfCustomByte(t *testing.T) { - type Uint8 uint8 - - a := []Uint8("hello") - - data, err := Marshal(a) - if err != nil { - t.Fatal(err) - } - var b []Uint8 - err = Unmarshal(data, &b) - if err != nil { - t.Fatal(err) - } - if !reflect.DeepEqual(a, b) { - t.Fatal("expected %v == %v", a, b) - } -} - -var decodeTypeErrorTests = []struct { - dest interface{} - src string -}{ - {new(string), `{"user": "name"}`}, // issue 4628. - {new(error), `{}`}, // issue 4222 - {new(error), `[]`}, - {new(error), `""`}, - {new(error), `123`}, - {new(error), `true`}, -} - -func TestUnmarshalTypeError(t *testing.T) { - for _, item := range decodeTypeErrorTests { - err := Unmarshal([]byte(item.src), item.dest) - if _, ok := err.(*UnmarshalTypeError); !ok { - t.Errorf("expected type error for Unmarshal(%q, type %T): got %T", - item.src, item.dest, err) - } - } -} - -var unmarshalSyntaxTests = []string{ - "tru", - "fals", - "nul", - "123e", - `"hello`, - `[1,2,3`, - `{"key":1`, - `{"key":1,`, -} - -func TestUnmarshalSyntax(t *testing.T) { - var x interface{} - for _, src := range unmarshalSyntaxTests { - err := Unmarshal([]byte(src), &x) - if _, ok := err.(*SyntaxError); !ok { - t.Errorf("expected syntax error for Unmarshal(%q): got %T", src, err) - } - } -} - -// Test handling of unexported fields that should be ignored. -// Issue 4660 -type unexportedFields struct { - Name string - m map[string]interface{} `json:"-"` - m2 map[string]interface{} `json:"abcd"` -} - -func TestUnmarshalUnexported(t *testing.T) { - input := `{"Name": "Bob", "m": {"x": 123}, "m2": {"y": 456}, "abcd": {"z": 789}}` - want := &unexportedFields{Name: "Bob"} - - out := &unexportedFields{} - err := Unmarshal([]byte(input), out) - if err != nil { - t.Errorf("got error %v, expected nil", err) - } - if !reflect.DeepEqual(out, want) { - t.Errorf("got %q, want %q", out, want) - } -} - -// Time3339 is a time.Time which encodes to and from JSON -// as an RFC 3339 time in UTC. -type Time3339 time.Time - -func (t *Time3339) UnmarshalJSON(b []byte) error { - if len(b) < 2 || b[0] != '"' || b[len(b)-1] != '"' { - return fmt.Errorf("types: failed to unmarshal non-string value %q as an RFC 3339 time", b) - } - tm, err := time.Parse(time.RFC3339, string(b[1:len(b)-1])) - if err != nil { - return err - } - *t = Time3339(tm) - return nil -} - -func TestUnmarshalJSONLiteralError(t *testing.T) { - var t3 Time3339 - err := Unmarshal([]byte(`"0000-00-00T00:00:00Z"`), &t3) - if err == nil { - t.Fatalf("expected error; got time %v", time.Time(t3)) - } - if !strings.Contains(err.Error(), "range") { - t.Errorf("got err = %v; want out of range error", err) - } -} - -// Test that extra object elements in an array do not result in a -// "data changing underfoot" error. -// Issue 3717 -func TestSkipArrayObjects(t *testing.T) { - json := `[{}]` - var dest [0]interface{} - - err := Unmarshal([]byte(json), &dest) - if err != nil { - t.Errorf("got error %q, want nil", err) - } -} - -// Test semantics of pre-filled struct fields and pre-filled map fields. -// Issue 4900. -func TestPrefilled(t *testing.T) { - ptrToMap := func(m map[string]interface{}) *map[string]interface{} { return &m } - - // Values here change, cannot reuse table across runs. - var prefillTests = []struct { - in string - ptr interface{} - out interface{} - }{ - { - in: `{"X": 1, "Y": 2}`, - ptr: &XYZ{X: float32(3), Y: int16(4), Z: 1.5}, - out: &XYZ{X: float64(1), Y: float64(2), Z: 1.5}, - }, - { - in: `{"X": 1, "Y": 2}`, - ptr: ptrToMap(map[string]interface{}{"X": float32(3), "Y": int16(4), "Z": 1.5}), - out: ptrToMap(map[string]interface{}{"X": float64(1), "Y": float64(2), "Z": 1.5}), - }, - } - - for _, tt := range prefillTests { - ptrstr := fmt.Sprintf("%v", tt.ptr) - err := Unmarshal([]byte(tt.in), tt.ptr) // tt.ptr edited here - if err != nil { - t.Errorf("Unmarshal: %v", err) - } - if !reflect.DeepEqual(tt.ptr, tt.out) { - t.Errorf("Unmarshal(%#q, %s): have %v, want %v", tt.in, ptrstr, tt.ptr, tt.out) - } - } -} - -var invalidUnmarshalTests = []struct { - v interface{} - want string -}{ - {nil, "json: Unmarshal(nil)"}, - {struct{}{}, "json: Unmarshal(non-pointer struct {})"}, - {(*int)(nil), "json: Unmarshal(nil *int)"}, -} - -func TestInvalidUnmarshal(t *testing.T) { - buf := []byte(`{"a":"1"}`) - for _, tt := range invalidUnmarshalTests { - err := Unmarshal(buf, tt.v) - if err == nil { - t.Errorf("Unmarshal expecting error, got nil") - continue - } - if got := err.Error(); got != tt.want { - t.Errorf("Unmarshal = %q; want %q", got, tt.want) - } - } -} - -var invalidUnmarshalTextTests = []struct { - v interface{} - want string -}{ - {nil, "json: Unmarshal(nil)"}, - {struct{}{}, "json: Unmarshal(non-pointer struct {})"}, - {(*int)(nil), "json: Unmarshal(nil *int)"}, - {new(net.IP), "json: cannot unmarshal string into Go value of type *net.IP"}, -} - -func TestInvalidUnmarshalText(t *testing.T) { - buf := []byte(`123`) - for _, tt := range invalidUnmarshalTextTests { - err := Unmarshal(buf, tt.v) - if err == nil { - t.Errorf("Unmarshal expecting error, got nil") - continue - } - if got := err.Error(); got != tt.want { - t.Errorf("Unmarshal = %q; want %q", got, tt.want) - } - } -} - -// Test that string option is ignored for invalid types. -// Issue 9812. -func TestInvalidStringOption(t *testing.T) { - num := 0 - item := struct { - T time.Time `json:",string"` - M map[string]string `json:",string"` - S []string `json:",string"` - A [1]string `json:",string"` - I interface{} `json:",string"` - P *int `json:",string"` - }{M: make(map[string]string), S: make([]string, 0), I: num, P: &num} - - data, err := Marshal(item) - if err != nil { - t.Fatalf("Marshal: %v", err) - } - - err = Unmarshal(data, &item) - if err != nil { - t.Fatalf("Unmarshal: %v", err) - } -} diff --git a/vendor/gopkg.in/square/go-jose.v1/json/encode.go b/vendor/gopkg.in/square/go-jose.v1/json/encode.go deleted file mode 100644 index 1dae8bb..0000000 --- a/vendor/gopkg.in/square/go-jose.v1/json/encode.go +++ /dev/null @@ -1,1197 +0,0 @@ -// Copyright 2010 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 json implements encoding and decoding of JSON objects as defined in -// RFC 4627. The mapping between JSON objects and Go values is described -// in the documentation for the Marshal and Unmarshal functions. -// -// See "JSON and Go" for an introduction to this package: -// https://golang.org/doc/articles/json_and_go.html -package json - -import ( - "bytes" - "encoding" - "encoding/base64" - "fmt" - "math" - "reflect" - "runtime" - "sort" - "strconv" - "strings" - "sync" - "unicode" - "unicode/utf8" -) - -// Marshal returns the JSON encoding of v. -// -// Marshal traverses the value v recursively. -// If an encountered value implements the Marshaler interface -// and is not a nil pointer, Marshal calls its MarshalJSON method -// to produce JSON. If no MarshalJSON method is present but the -// value implements encoding.TextMarshaler instead, Marshal calls -// its MarshalText method. -// The nil pointer exception is not strictly necessary -// but mimics a similar, necessary exception in the behavior of -// UnmarshalJSON. -// -// Otherwise, Marshal uses the following type-dependent default encodings: -// -// Boolean values encode as JSON booleans. -// -// Floating point, integer, and Number values encode as JSON numbers. -// -// String values encode as JSON strings coerced to valid UTF-8, -// replacing invalid bytes with the Unicode replacement rune. -// The angle brackets "<" and ">" are escaped to "\u003c" and "\u003e" -// to keep some browsers from misinterpreting JSON output as HTML. -// Ampersand "&" is also escaped to "\u0026" for the same reason. -// -// Array and slice values encode as JSON arrays, except that -// []byte encodes as a base64-encoded string, and a nil slice -// encodes as the null JSON object. -// -// Struct values encode as JSON objects. Each exported struct field -// becomes a member of the object unless -// - the field's tag is "-", or -// - the field is empty and its tag specifies the "omitempty" option. -// The empty values are false, 0, any -// nil pointer or interface value, and any array, slice, map, or string of -// length zero. The object's default key string is the struct field name -// but can be specified in the struct field's tag value. The "json" key in -// the struct field's tag value is the key name, followed by an optional comma -// and options. Examples: -// -// // Field is ignored by this package. -// Field int `json:"-"` -// -// // Field appears in JSON as key "myName". -// Field int `json:"myName"` -// -// // Field appears in JSON as key "myName" and -// // the field is omitted from the object if its value is empty, -// // as defined above. -// Field int `json:"myName,omitempty"` -// -// // Field appears in JSON as key "Field" (the default), but -// // the field is skipped if empty. -// // Note the leading comma. -// Field int `json:",omitempty"` -// -// The "string" option signals that a field is stored as JSON inside a -// JSON-encoded string. It applies only to fields of string, floating point, -// integer, or boolean types. This extra level of encoding is sometimes used -// when communicating with JavaScript programs: -// -// Int64String int64 `json:",string"` -// -// The key name will be used if it's a non-empty string consisting of -// only Unicode letters, digits, dollar signs, percent signs, hyphens, -// underscores and slashes. -// -// Anonymous struct fields are usually marshaled as if their inner exported fields -// were fields in the outer struct, subject to the usual Go visibility rules amended -// as described in the next paragraph. -// An anonymous struct field with a name given in its JSON tag is treated as -// having that name, rather than being anonymous. -// An anonymous struct field of interface type is treated the same as having -// that type as its name, rather than being anonymous. -// -// The Go visibility rules for struct fields are amended for JSON when -// deciding which field to marshal or unmarshal. If there are -// multiple fields at the same level, and that level is the least -// nested (and would therefore be the nesting level selected by the -// usual Go rules), the following extra rules apply: -// -// 1) Of those fields, if any are JSON-tagged, only tagged fields are considered, -// even if there are multiple untagged fields that would otherwise conflict. -// 2) If there is exactly one field (tagged or not according to the first rule), that is selected. -// 3) Otherwise there are multiple fields, and all are ignored; no error occurs. -// -// Handling of anonymous struct fields is new in Go 1.1. -// Prior to Go 1.1, anonymous struct fields were ignored. To force ignoring of -// an anonymous struct field in both current and earlier versions, give the field -// a JSON tag of "-". -// -// Map values encode as JSON objects. -// The map's key type must be string; the map keys are used as JSON object -// keys, subject to the UTF-8 coercion described for string values above. -// -// Pointer values encode as the value pointed to. -// A nil pointer encodes as the null JSON object. -// -// Interface values encode as the value contained in the interface. -// A nil interface value encodes as the null JSON object. -// -// Channel, complex, and function values cannot be encoded in JSON. -// Attempting to encode such a value causes Marshal to return -// an UnsupportedTypeError. -// -// JSON cannot represent cyclic data structures and Marshal does not -// handle them. Passing cyclic structures to Marshal will result in -// an infinite recursion. -// -func Marshal(v interface{}) ([]byte, error) { - e := &encodeState{} - err := e.marshal(v) - if err != nil { - return nil, err - } - return e.Bytes(), nil -} - -// MarshalIndent is like Marshal but applies Indent to format the output. -func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) { - b, err := Marshal(v) - if err != nil { - return nil, err - } - var buf bytes.Buffer - err = Indent(&buf, b, prefix, indent) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// HTMLEscape appends to dst the JSON-encoded src with <, >, &, U+2028 and U+2029 -// characters inside string literals changed to \u003c, \u003e, \u0026, \u2028, \u2029 -// so that the JSON will be safe to embed inside HTML