├── .github └── workflows │ └── main.yml ├── Config └── config.go ├── DataBase └── mongodb.go ├── Examples └── Screenshot.png ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── Procfile ├── README.md ├── config.json ├── gshort.go ├── rice-box.go ├── utils.go ├── vendor ├── github.com │ ├── GeertJohan │ │ └── go.rice │ │ │ ├── .gitignore │ │ │ ├── .travis.yml │ │ │ ├── AUTHORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── appended.go │ │ │ ├── box.go │ │ │ ├── config.go │ │ │ ├── debug.go │ │ │ ├── embedded.go │ │ │ ├── embedded │ │ │ └── embedded.go │ │ │ ├── file.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── http.go │ │ │ ├── sort.go │ │ │ ├── virtual.go │ │ │ └── walk.go │ ├── daaku │ │ └── go.zipexe │ │ │ ├── go.mod │ │ │ ├── license │ │ │ ├── readme.md │ │ │ └── zipexe.go │ ├── go-stack │ │ └── stack │ │ │ ├── .travis.yml │ │ │ ├── LICENSE.md │ │ │ ├── README.md │ │ │ ├── go.mod │ │ │ └── stack.go │ ├── golang │ │ └── snappy │ │ │ ├── .gitignore │ │ │ ├── AUTHORS │ │ │ ├── CONTRIBUTORS │ │ │ ├── LICENSE │ │ │ ├── README │ │ │ ├── decode.go │ │ │ ├── decode_amd64.go │ │ │ ├── decode_amd64.s │ │ │ ├── decode_other.go │ │ │ ├── encode.go │ │ │ ├── encode_amd64.go │ │ │ ├── encode_amd64.s │ │ │ ├── encode_other.go │ │ │ ├── go.mod │ │ │ └── snappy.go │ ├── gorilla │ │ └── mux │ │ │ ├── AUTHORS │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── context.go │ │ │ ├── doc.go │ │ │ ├── go.mod │ │ │ ├── middleware.go │ │ │ ├── mux.go │ │ │ ├── regexp.go │ │ │ ├── route.go │ │ │ └── test_helpers.go │ ├── someone-stole-my-name │ │ └── reCAPTCHAv3 │ │ │ └── reCAPTCHAv3.go │ └── xdg │ │ ├── scram │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── client.go │ │ ├── client_conv.go │ │ ├── common.go │ │ ├── doc.go │ │ ├── parse.go │ │ ├── scram.go │ │ ├── server.go │ │ └── server_conv.go │ │ └── stringprep │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── README.md │ │ ├── bidi.go │ │ ├── doc.go │ │ ├── error.go │ │ ├── map.go │ │ ├── profile.go │ │ ├── saslprep.go │ │ ├── set.go │ │ └── tables.go ├── go.mongodb.org │ └── mongo-driver │ │ ├── LICENSE │ │ ├── THIRD-PARTY-NOTICES │ │ ├── bson │ │ ├── bson.go │ │ ├── bson_1_8.go │ │ ├── bsoncodec │ │ │ ├── bsoncodec.go │ │ │ ├── default_value_decoders.go │ │ │ ├── default_value_encoders.go │ │ │ ├── doc.go │ │ │ ├── mode.go │ │ │ ├── pointer_codec.go │ │ │ ├── proxy.go │ │ │ ├── registry.go │ │ │ ├── struct_codec.go │ │ │ ├── struct_tag_parser.go │ │ │ └── types.go │ │ ├── bsonrw │ │ │ ├── copier.go │ │ │ ├── doc.go │ │ │ ├── extjson_parser.go │ │ │ ├── extjson_reader.go │ │ │ ├── extjson_tables.go │ │ │ ├── extjson_wrappers.go │ │ │ ├── extjson_writer.go │ │ │ ├── json_scanner.go │ │ │ ├── mode.go │ │ │ ├── reader.go │ │ │ ├── value_reader.go │ │ │ ├── value_writer.go │ │ │ └── writer.go │ │ ├── bsontype │ │ │ └── bsontype.go │ │ ├── decoder.go │ │ ├── doc.go │ │ ├── encoder.go │ │ ├── marshal.go │ │ ├── primitive │ │ │ ├── decimal.go │ │ │ ├── objectid.go │ │ │ └── primitive.go │ │ ├── primitive_codecs.go │ │ ├── raw.go │ │ ├── raw_element.go │ │ ├── raw_value.go │ │ ├── registry.go │ │ ├── types.go │ │ └── unmarshal.go │ │ ├── etc │ │ └── generate-notices.pl │ │ ├── event │ │ └── monitoring.go │ │ ├── internal │ │ ├── const.go │ │ ├── error.go │ │ └── semaphore.go │ │ ├── mongo │ │ ├── batch_cursor.go │ │ ├── bulk_write.go │ │ ├── bulk_write_models.go │ │ ├── change_stream.go │ │ ├── client.go │ │ ├── collection.go │ │ ├── cursor.go │ │ ├── database.go │ │ ├── doc.go │ │ ├── errors.go │ │ ├── index_options_builder.go │ │ ├── index_view.go │ │ ├── mongo.go │ │ ├── options │ │ │ ├── aggregateoptions.go │ │ │ ├── bulkwriteoptions.go │ │ │ ├── changestreamoptions.go │ │ │ ├── clientoptions.go │ │ │ ├── clientoptions_1_10.go │ │ │ ├── clientoptions_1_9.go │ │ │ ├── collectionoptions.go │ │ │ ├── countoptions.go │ │ │ ├── dboptions.go │ │ │ ├── deleteoptions.go │ │ │ ├── distinctoptions.go │ │ │ ├── estimatedcountoptions.go │ │ │ ├── findoptions.go │ │ │ ├── gridfsoptions.go │ │ │ ├── indexoptions.go │ │ │ ├── insertoptions.go │ │ │ ├── listcollectionsoptions.go │ │ │ ├── listdatabasesoptions.go │ │ │ ├── mongooptions.go │ │ │ ├── replaceoptions.go │ │ │ ├── runcmdoptions.go │ │ │ ├── sessionoptions.go │ │ │ ├── transactionoptions.go │ │ │ └── updateoptions.go │ │ ├── readconcern │ │ │ └── readconcern.go │ │ ├── readpref │ │ │ ├── mode.go │ │ │ ├── options.go │ │ │ └── readpref.go │ │ ├── results.go │ │ ├── session.go │ │ ├── single_result.go │ │ ├── util.go │ │ └── writeconcern │ │ │ └── writeconcern.go │ │ ├── tag │ │ └── tag.go │ │ ├── version │ │ └── version.go │ │ └── x │ │ ├── bsonx │ │ ├── array.go │ │ ├── bsoncore │ │ │ ├── bsoncore.go │ │ │ ├── document.go │ │ │ ├── document_sequence.go │ │ │ ├── element.go │ │ │ ├── tables.go │ │ │ └── value.go │ │ ├── constructor.go │ │ ├── document.go │ │ ├── element.go │ │ ├── mdocument.go │ │ ├── primitive_codecs.go │ │ ├── registry.go │ │ └── value.go │ │ └── mongo │ │ └── driver │ │ ├── DESIGN.md │ │ ├── address │ │ └── addr.go │ │ ├── auth │ │ ├── auth.go │ │ ├── cred.go │ │ ├── default.go │ │ ├── doc.go │ │ ├── gssapi.go │ │ ├── gssapi_not_enabled.go │ │ ├── gssapi_not_supported.go │ │ ├── internal │ │ │ └── gssapi │ │ │ │ ├── gss.go │ │ │ │ ├── gss_wrapper.c │ │ │ │ ├── gss_wrapper.h │ │ │ │ ├── sspi.go │ │ │ │ ├── sspi_wrapper.c │ │ │ │ └── sspi_wrapper.h │ │ ├── mongodbcr.go │ │ ├── plain.go │ │ ├── sasl.go │ │ ├── scram.go │ │ ├── util.go │ │ └── x509.go │ │ ├── batch_cursor.go │ │ ├── batches.go │ │ ├── connstring │ │ └── connstring.go │ │ ├── description │ │ ├── description.go │ │ ├── feature.go │ │ ├── server.go │ │ ├── server_kind.go │ │ ├── server_selector.go │ │ ├── topology.go │ │ ├── topology_kind.go │ │ ├── version.go │ │ └── version_range.go │ │ ├── dns │ │ └── dns.go │ │ ├── driver.go │ │ ├── errors.go │ │ ├── legacy.go │ │ ├── list_collections_batch_cursor.go │ │ ├── operation.go │ │ ├── operation │ │ ├── abort_transaction.go │ │ ├── abort_transaction.toml │ │ ├── aggregate.go │ │ ├── aggregate.toml │ │ ├── command.go │ │ ├── commit_transaction.go │ │ ├── commit_transaction.toml │ │ ├── count.go │ │ ├── count.toml │ │ ├── createIndexes.go │ │ ├── createIndexes.toml │ │ ├── delete.go │ │ ├── delete.toml │ │ ├── distinct.go │ │ ├── distinct.toml │ │ ├── drop_collection.go │ │ ├── drop_collection.toml │ │ ├── drop_database.go │ │ ├── drop_database.toml │ │ ├── drop_indexes.go │ │ ├── drop_indexes.toml │ │ ├── end_sessions.go │ │ ├── end_sessions.toml │ │ ├── find.go │ │ ├── find.toml │ │ ├── find_and_modify.go │ │ ├── find_and_modify.toml │ │ ├── insert.go │ │ ├── insert.toml │ │ ├── ismaster.go │ │ ├── listDatabases.go │ │ ├── listDatabases.toml │ │ ├── list_collections.go │ │ ├── list_collections.toml │ │ ├── list_indexes.go │ │ ├── list_indexes.toml │ │ ├── operation.go │ │ ├── update.go │ │ └── update.toml │ │ ├── operation_legacy.go │ │ ├── session │ │ ├── client_session.go │ │ ├── cluster_clock.go │ │ ├── options.go │ │ ├── server_session.go │ │ └── session_pool.go │ │ ├── topology │ │ ├── DESIGN.md │ │ ├── connection.go │ │ ├── connection_legacy.go │ │ ├── connection_legacy_command_metadata.go │ │ ├── connection_options.go │ │ ├── errors.go │ │ ├── fsm.go │ │ ├── pool.go │ │ ├── resource_pool.go │ │ ├── server.go │ │ ├── server_options.go │ │ ├── topology.go │ │ ├── topology_options.go │ │ ├── topology_options_1_10.go │ │ └── topology_options_1_9.go │ │ ├── uuid │ │ └── uuid.go │ │ └── wiremessage │ │ └── wiremessage.go └── golang.org │ └── x │ ├── crypto │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── pbkdf2 │ │ └── pbkdf2.go │ ├── sync │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ └── semaphore │ │ └── semaphore.go │ └── text │ ├── AUTHORS │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── PATENTS │ ├── internal │ ├── gen │ │ ├── code.go │ │ └── gen.go │ ├── triegen │ │ ├── compact.go │ │ ├── print.go │ │ └── triegen.go │ └── ucd │ │ └── ucd.go │ ├── transform │ └── transform.go │ └── unicode │ ├── cldr │ ├── base.go │ ├── cldr.go │ ├── collate.go │ ├── decode.go │ ├── makexml.go │ ├── resolve.go │ ├── slice.go │ └── xml.go │ └── norm │ ├── composition.go │ ├── forminfo.go │ ├── input.go │ ├── iter.go │ ├── maketables.go │ ├── normalize.go │ ├── readwriter.go │ ├── tables10.0.0.go │ ├── tables11.0.0.go │ ├── tables9.0.0.go │ ├── transform.go │ ├── trie.go │ └── triegen.go └── website ├── assets ├── css │ ├── fontawesome-all.min.css │ ├── images │ │ └── overlay.png │ ├── main.css │ └── noscript.css └── webfonts │ ├── fa-brands-400.eot │ ├── fa-brands-400.svg │ ├── fa-brands-400.ttf │ ├── fa-brands-400.woff │ ├── fa-brands-400.woff2 │ ├── fa-regular-400.eot │ ├── fa-regular-400.svg │ ├── fa-regular-400.ttf │ ├── fa-regular-400.woff │ ├── fa-regular-400.woff2 │ ├── fa-solid-900.eot │ ├── fa-solid-900.svg │ ├── fa-solid-900.ttf │ ├── fa-solid-900.woff │ └── fa-solid-900.woff2 ├── images └── bg.jpg ├── index.html └── password.html /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [push] 3 | jobs: 4 | 5 | build: 6 | name: Build 7 | runs-on: ubuntu-latest 8 | steps: 9 | 10 | - name: Set up Go 1.13 11 | uses: actions/setup-go@v1 12 | with: 13 | go-version: 1.13 14 | id: go 15 | 16 | - name: Check out code into the Go module directory 17 | uses: actions/checkout@v1 18 | 19 | - name: Get dependencies 20 | run: | 21 | export GOPATH=$HOME/go 22 | export GOBIN=$(go env GOPATH)/bin 23 | export PATH=$PATH:$GOPATH 24 | export PATH=$PATH:$GOBIN 25 | mkdir -p $GOPATH/pkg 26 | mkdir -p $GOBIN 27 | mkdir -p $GOPATH/src/github.com/$GITHUB_REPOSITORY 28 | mv ./* $GOPATH/src/github.com/$GITHUB_REPOSITORY 29 | cd $GOPATH/src/github.com/$GITHUB_REPOSITORY 30 | if [ -f Gopkg.toml ]; then 31 | curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh 32 | dep ensure 33 | fi 34 | - name: Build 35 | run: | 36 | cd $HOME/go/src/github.com/$GITHUB_REPOSITORY && mkdir vendor/gShort 37 | mv {Config,DataBase} vendor/gShort 38 | go build *.go 39 | -------------------------------------------------------------------------------- /Config/config.go: -------------------------------------------------------------------------------- 1 | package Config 2 | 3 | import ( 4 | "encoding/json" 5 | "flag" 6 | "io/ioutil" 7 | "os" 8 | ) 9 | 10 | type Args struct { 11 | ConfigFile string 12 | JustTemplate bool 13 | } 14 | 15 | type Config struct { 16 | MongoDB *MongoDB 17 | RandomStringGenerator *RandomStringGenerator 18 | Domain string `json:"Domain"` 19 | Protocol string `json:"Protocol"` 20 | ReCaptcha *ReCaptcha 21 | SiteName string `json:"SiteName"` 22 | TagLine string `json:"TagLine"` 23 | Port int `json:"Port"` 24 | } 25 | 26 | type ReCaptcha struct { 27 | SiteKey string `json:"SiteKey"` 28 | SecretKey string `json:"SecretKey"` 29 | } 30 | 31 | type MongoDB struct { 32 | URI string `json:"URI"` 33 | DataBase string `json:"DataBase"` 34 | Collection string `json:"Collection"` 35 | } 36 | 37 | type RandomStringGenerator struct { 38 | Length int `json:"Length"` 39 | Charset string `json:"Charset"` 40 | } 41 | 42 | func ParseArgs() *Args { 43 | a := &Args{} 44 | flag.StringVar(&a.ConfigFile, "config", "", "JSON Config File") 45 | flag.BoolVar(&a.JustTemplate, "templateonly", false, "Create a _template directory with the templated HTMLs") 46 | flag.Parse() 47 | return a 48 | } 49 | 50 | func (*Config) LoadConfigFrom(file string) (config *Config, err error) { 51 | ConfigFileByteArr, err := ioutil.ReadFile(file) 52 | if err != nil { 53 | return 54 | } 55 | if err = json.Unmarshal(ConfigFileByteArr, &config); err != nil { 56 | return 57 | } 58 | config.checkENV() 59 | return 60 | } 61 | 62 | // Override some settings using ENV (heroku) 63 | func (config *Config) checkENV () *Config { 64 | // TODO REWORK THIS CRAP 65 | i := os.Getenv("ReCaptcha_SiteKey") // heroku 66 | if i != "" { // if env exists 67 | config.ReCaptcha.SiteKey = i 68 | } 69 | 70 | i = os.Getenv("ReCaptcha_SecretKey") // heroku 71 | if i != "" { // if env exists 72 | config.ReCaptcha.SecretKey = i 73 | } 74 | 75 | i = os.Getenv("MongoDB_URI") // heroku 76 | if i != "" { // if env exists 77 | config.MongoDB.URI = i 78 | } 79 | 80 | i = os.Getenv("MongoDB_DataBase") // heroku 81 | if i != "" { // if env exists 82 | config.MongoDB.DataBase = i 83 | } 84 | 85 | i = os.Getenv("MongoDB_Collection") // heroku 86 | if i != "" { // if env exists 87 | config.MongoDB.Collection = i 88 | } 89 | 90 | return config 91 | } -------------------------------------------------------------------------------- /Examples/Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/Examples/Screenshot.png -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | # Gopkg.toml example 2 | # 3 | # Refer to https://golang.github.io/dep/docs/Gopkg.toml.html 4 | # for detailed Gopkg.toml documentation. 5 | # 6 | # required = ["github.com/user/thing/cmd/thing"] 7 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 8 | # 9 | # [[constraint]] 10 | # name = "github.com/user/project" 11 | # version = "1.0.0" 12 | # 13 | # [[constraint]] 14 | # name = "github.com/user/project2" 15 | # branch = "dev" 16 | # source = "github.com/myfork/project2" 17 | # 18 | # [[override]] 19 | # name = "github.com/x/y" 20 | # version = "2.4.0" 21 | # 22 | # [prune] 23 | # non-go = false 24 | # go-tests = true 25 | # unused-packages = true 26 | 27 | [metadata.heroku] 28 | root-package = "gShort" 29 | 30 | [[constraint]] 31 | name = "github.com/GeertJohan/go.rice" 32 | version = "1.0.0" 33 | 34 | [[constraint]] 35 | name = "github.com/gorilla/mux" 36 | version = "1.7.3" 37 | 38 | [[constraint]] 39 | name = "go.mongodb.org/mongo-driver" 40 | version = "1.1.3" 41 | 42 | [prune] 43 | go-tests = true 44 | unused-packages = true 45 | 46 | [[constraint]] 47 | branch = "master" 48 | name = "github.com/someone-stole-my-name/reCAPTCHAv3" 49 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | web: bin/gShort --config=config.json 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gShort 2 | 3 | ![Build](https://github.com/someone-stole-my-name/gShort/workflows/Build/badge.svg) 4 | ![Dependencies](https://img.shields.io/librariesio/github/someone-stole-my-name/gShort) 5 | ![License](https://img.shields.io/github/license/someone-stole-my-name/gShort?color=green) 6 | 7 | ![Screenshot](https://github.com/someone-stole-my-name/gShort/raw/master/Examples/Screenshot.png) 8 | 9 | ## Overview 10 | 11 | gShort is a URL shortener that you can selfhost or easily deploy to a PaaS. 12 | 13 | ### Features 14 | 15 | * Password protected links 16 | * One Time Links or any custom TTL 17 | * Custom charset and length 18 | * Optional reCAPTCHA v3 19 | 20 | ## Configuration 21 | 22 | gShort requires a json configuration file, you can check the one that demo site uses [here][example_config]. 23 | 24 | #### General 25 | 26 | * **Domain**: The domain or IP where gShort will be accesed from. (**Required**) 27 | * **Port**: The port where gShort will listen for incoming requests. (**Required but can be overridden**) 28 | * **Protocol**: The protocol that users will use to access gShort. **This is not the protocol that gShort will use**, only HTTP is supported. Eg: If running on Heroku or behind a reverse proxy configured with SSL this should be HTTPS. (**Required**) 29 | * **SiteName**: HTML Title of your page. (**Required**) 30 | * **TagLine**: (**Required**) 31 | 32 | #### MongoDB 33 | 34 | * **URI**: Format `mongodb+srv://$USER:$PASSWORD@cluster1-agata.mongodb.net/` (**Required but can be overridden**) 35 | * **DataBase**: MongoDB Database to use. (**Required but can be overridden**) 36 | * **Collection**: MongoDB Collection to use. (**Required but can be overridden**) 37 | 38 | #### RandomStringGenerator 39 | 40 | * **Charset**: Charset used when generating short URLs. (**Required**) 41 | * **Length**: Length of the generated random strings. (**Required**) 42 | 43 | #### ReCaptcha 44 | * **SiteKey**: Google's reCAPTCHAv3 Key, if you don't have one of theese just leave it as `""`. (**Optional and can be overridden**) 45 | * **SecretKey**: Google's reCAPTCHAv3 Secret Key, if you don't have one of theese just leave it as `""` (**Optional and can be overridden**) 46 | 47 | ## Heroku (or other PaaS) 48 | 49 | Deployment to Heroku should be pretty straightforward: 50 | * Fork 51 | * Modify the example `config.json` file 52 | * Set the following environment variables: 53 | ``` 54 | MongoDB_Collection 55 | MongoDB_Database 56 | MongoDB_URI 57 | ReCaptcha_SecretKey 58 | ReCaptcha_SiteKey 59 | ``` 60 | * Deploy master branch 61 | 62 | ## Getting Started (self Host) 63 | TODO 64 | 65 | [gshort_demo_site]:https://gshort.christiansegundo.com 66 | [example_config]:https://github.com/someone-stole-my-name/gShort/blob/master/config.json 67 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Domain": "gshort.christiansegundo.com", 3 | "Port": 443, 4 | "Protocol": "https", 5 | "SiteName": "URL Shortener", 6 | "TagLine": "A f* URL Shortener that just works", 7 | "MongoDB": { 8 | "URI": "mongodb+srv://XXXXX:XXXXX@cluster1-agata.mongodb.net/", 9 | "DataBase": "gshort", 10 | "Collection": "maps" 11 | }, 12 | "RandomStringGenerator": { 13 | "Charset": "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 14 | "Length": 7 15 | }, 16 | "ReCaptcha": { 17 | "SiteKey": "XXXXXXXX", 18 | "SecretKey": "XXXXXX" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/.gitignore: -------------------------------------------------------------------------------- 1 | /example/example 2 | /example/example.exe 3 | /rice/rice 4 | /rice/rice.exe 5 | 6 | *.rice-box.go 7 | *.rice-box.syso 8 | .wercker 9 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - master 5 | - 1.11.x 6 | - 1.10.x 7 | - 1.9.x 8 | - 1.8.x 9 | 10 | install: 11 | - go get -t ./... 12 | - env 13 | script: 14 | - go build -x ./... 15 | - go test -cover ./... 16 | - go vet ./... 17 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/AUTHORS: -------------------------------------------------------------------------------- 1 | Geert-Johan Riemer 2 | Paul Maddox 3 | Vincent Petithory 4 | 5 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Geert-Johan Riemer 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/config.go: -------------------------------------------------------------------------------- 1 | package rice 2 | 3 | // LocateMethod defines how a box is located. 4 | type LocateMethod int 5 | 6 | const ( 7 | LocateFS = LocateMethod(iota) // Locate on the filesystem according to package path. 8 | LocateAppended // Locate boxes appended to the executable. 9 | LocateEmbedded // Locate embedded boxes. 10 | LocateWorkingDirectory // Locate on the binary working directory 11 | ) 12 | 13 | // Config allows customizing the box lookup behavior. 14 | type Config struct { 15 | // LocateOrder defines the priority order that boxes are searched for. By 16 | // default, the package global FindBox searches for embedded boxes first, 17 | // then appended boxes, and then finally boxes on the filesystem. That 18 | // search order may be customized by provided the ordered list here. Leaving 19 | // out a particular method will omit that from the search space. For 20 | // example, []LocateMethod{LocateEmbedded, LocateAppended} will never search 21 | // the filesystem for boxes. 22 | LocateOrder []LocateMethod 23 | } 24 | 25 | // FindBox searches for boxes using the LocateOrder of the config. 26 | func (c *Config) FindBox(boxName string) (*Box, error) { 27 | return findBox(boxName, c.LocateOrder) 28 | } 29 | 30 | // MustFindBox searches for boxes using the LocateOrder of the config, like 31 | // FindBox does. It does not return an error, instead it panics when an error 32 | // occurs. 33 | func (c *Config) MustFindBox(boxName string) *Box { 34 | box, err := findBox(boxName, c.LocateOrder) 35 | if err != nil { 36 | panic(err) 37 | } 38 | return box 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/debug.go: -------------------------------------------------------------------------------- 1 | package rice 2 | 3 | // Debug can be set to true to enable debugging. 4 | var Debug = false 5 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/embedded.go: -------------------------------------------------------------------------------- 1 | package rice 2 | 3 | import ( 4 | "os" 5 | "time" 6 | 7 | "github.com/GeertJohan/go.rice/embedded" 8 | ) 9 | 10 | // re-type to make exported methods invisible to user (godoc) 11 | // they're not required for the user 12 | // embeddedDirInfo implements os.FileInfo 13 | type embeddedDirInfo embedded.EmbeddedDir 14 | 15 | // Name returns the base name of the directory 16 | // (implementing os.FileInfo) 17 | func (ed *embeddedDirInfo) Name() string { 18 | return ed.Filename 19 | } 20 | 21 | // Size always returns 0 22 | // (implementing os.FileInfo) 23 | func (ed *embeddedDirInfo) Size() int64 { 24 | return 0 25 | } 26 | 27 | // Mode returns the file mode bits 28 | // (implementing os.FileInfo) 29 | func (ed *embeddedDirInfo) Mode() os.FileMode { 30 | return os.FileMode(0555 | os.ModeDir) // dr-xr-xr-x 31 | } 32 | 33 | // ModTime returns the modification time 34 | // (implementing os.FileInfo) 35 | func (ed *embeddedDirInfo) ModTime() time.Time { 36 | return ed.DirModTime 37 | } 38 | 39 | // IsDir returns the abbreviation for Mode().IsDir() (always true) 40 | // (implementing os.FileInfo) 41 | func (ed *embeddedDirInfo) IsDir() bool { 42 | return true 43 | } 44 | 45 | // Sys returns the underlying data source (always nil) 46 | // (implementing os.FileInfo) 47 | func (ed *embeddedDirInfo) Sys() interface{} { 48 | return nil 49 | } 50 | 51 | // re-type to make exported methods invisible to user (godoc) 52 | // they're not required for the user 53 | // embeddedFileInfo implements os.FileInfo 54 | type embeddedFileInfo embedded.EmbeddedFile 55 | 56 | // Name returns the base name of the file 57 | // (implementing os.FileInfo) 58 | func (ef *embeddedFileInfo) Name() string { 59 | return ef.Filename 60 | } 61 | 62 | // Size returns the length in bytes for regular files; system-dependent for others 63 | // (implementing os.FileInfo) 64 | func (ef *embeddedFileInfo) Size() int64 { 65 | return int64(len(ef.Content)) 66 | } 67 | 68 | // Mode returns the file mode bits 69 | // (implementing os.FileInfo) 70 | func (ef *embeddedFileInfo) Mode() os.FileMode { 71 | return os.FileMode(0555) // r-xr-xr-x 72 | } 73 | 74 | // ModTime returns the modification time 75 | // (implementing os.FileInfo) 76 | func (ef *embeddedFileInfo) ModTime() time.Time { 77 | return ef.FileModTime 78 | } 79 | 80 | // IsDir returns the abbreviation for Mode().IsDir() (always false) 81 | // (implementing os.FileInfo) 82 | func (ef *embeddedFileInfo) IsDir() bool { 83 | return false 84 | } 85 | 86 | // Sys returns the underlying data source (always nil) 87 | // (implementing os.FileInfo) 88 | func (ef *embeddedFileInfo) Sys() interface{} { 89 | return nil 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/embedded/embedded.go: -------------------------------------------------------------------------------- 1 | // Package embedded defines embedded data types that are shared between the go.rice package and generated code. 2 | package embedded 3 | 4 | import ( 5 | "fmt" 6 | "path/filepath" 7 | "strings" 8 | "time" 9 | ) 10 | 11 | const ( 12 | EmbedTypeGo = 0 13 | EmbedTypeSyso = 1 14 | ) 15 | 16 | // EmbeddedBox defines an embedded box 17 | type EmbeddedBox struct { 18 | Name string // box name 19 | Time time.Time // embed time 20 | EmbedType int // kind of embedding 21 | Files map[string]*EmbeddedFile // ALL embedded files by full path 22 | Dirs map[string]*EmbeddedDir // ALL embedded dirs by full path 23 | } 24 | 25 | // Link creates the ChildDirs and ChildFiles links in all EmbeddedDir's 26 | func (e *EmbeddedBox) Link() { 27 | for _, ed := range e.Dirs { 28 | ed.ChildDirs = make([]*EmbeddedDir, 0) 29 | ed.ChildFiles = make([]*EmbeddedFile, 0) 30 | } 31 | for path, ed := range e.Dirs { 32 | // skip for root, it'll create a recursion 33 | if path == "" { 34 | continue 35 | } 36 | parentDirpath, _ := filepath.Split(path) 37 | if strings.HasSuffix(parentDirpath, "/") { 38 | parentDirpath = parentDirpath[:len(parentDirpath)-1] 39 | } 40 | parentDir := e.Dirs[parentDirpath] 41 | if parentDir == nil { 42 | panic("parentDir `" + parentDirpath + "` is missing in embedded box") 43 | } 44 | parentDir.ChildDirs = append(parentDir.ChildDirs, ed) 45 | } 46 | for path, ef := range e.Files { 47 | dirpath, _ := filepath.Split(path) 48 | if strings.HasSuffix(dirpath, "/") { 49 | dirpath = dirpath[:len(dirpath)-1] 50 | } 51 | dir := e.Dirs[dirpath] 52 | if dir == nil { 53 | panic("dir `" + dirpath + "` is missing in embedded box") 54 | } 55 | dir.ChildFiles = append(dir.ChildFiles, ef) 56 | } 57 | } 58 | 59 | // EmbeddedDir is instanced in the code generated by the rice tool and contains all necicary information about an embedded file 60 | type EmbeddedDir struct { 61 | Filename string 62 | DirModTime time.Time 63 | ChildDirs []*EmbeddedDir // direct childs, as returned by virtualDir.Readdir() 64 | ChildFiles []*EmbeddedFile // direct childs, as returned by virtualDir.Readdir() 65 | } 66 | 67 | // EmbeddedFile is instanced in the code generated by the rice tool and contains all necicary information about an embedded file 68 | type EmbeddedFile struct { 69 | Filename string // filename 70 | FileModTime time.Time 71 | Content string 72 | } 73 | 74 | // EmbeddedBoxes is a public register of embedded boxes 75 | var EmbeddedBoxes = make(map[string]*EmbeddedBox) 76 | 77 | // RegisterEmbeddedBox registers an EmbeddedBox 78 | func RegisterEmbeddedBox(name string, box *EmbeddedBox) { 79 | if _, exists := EmbeddedBoxes[name]; exists { 80 | panic(fmt.Sprintf("EmbeddedBox with name `%s` exists already", name)) 81 | } 82 | EmbeddedBoxes[name] = box 83 | } 84 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/GeertJohan/go.rice 2 | 3 | go 1.12 4 | 5 | require ( 6 | github.com/GeertJohan/go.incremental v1.0.0 7 | github.com/akavel/rsrc v0.8.0 8 | github.com/daaku/go.zipexe v1.0.0 9 | github.com/davecgh/go-spew v1.1.1 10 | github.com/jessevdk/go-flags v1.4.0 11 | github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 12 | github.com/valyala/fasttemplate v1.0.1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/go.sum: -------------------------------------------------------------------------------- 1 | github.com/GeertJohan/go.incremental v1.0.0 h1:7AH+pY1XUgQE4Y1HcXYaMqAI0m9yrFqo/jt0CW30vsg= 2 | github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0= 3 | github.com/akavel/rsrc v0.8.0 h1:zjWn7ukO9Kc5Q62DOJCcxGpXC18RawVtYAGdz2aLlfw= 4 | github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c= 5 | github.com/daaku/go.zipexe v1.0.0 h1:VSOgZtH418pH9L16hC/JrgSNJbbAL26pj7lmD1+CGdY= 6 | github.com/daaku/go.zipexe v1.0.0/go.mod h1:z8IiR6TsVLEYKwXAoE/I+8ys/sDkgTzSL0CLnGVd57E= 7 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 8 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 9 | github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= 10 | github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= 11 | github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229 h1:E2B8qYyeSgv5MXpmzZXRNp8IAQ4vjxIjhpAf5hv/tAg= 12 | github.com/nkovacs/streamquote v0.0.0-20170412213628-49af9bddb229/go.mod h1:0aYXnNPJ8l7uZxf45rWW1a/uME32OF0rhiYGNQ2oF2E= 13 | github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= 14 | github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= 15 | github.com/valyala/fasttemplate v1.0.1 h1:tY9CJiPnMXf1ERmG2EyK7gNUd+c6RKGD0IfU8WdUSz8= 16 | github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= 17 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/http.go: -------------------------------------------------------------------------------- 1 | package rice 2 | 3 | import ( 4 | "net/http" 5 | ) 6 | 7 | // HTTPBox implements http.FileSystem which allows the use of Box with a http.FileServer. 8 | // e.g.: http.Handle("/", http.FileServer(rice.MustFindBox("http-files").HTTPBox())) 9 | type HTTPBox struct { 10 | *Box 11 | } 12 | 13 | // HTTPBox creates a new HTTPBox from an existing Box 14 | func (b *Box) HTTPBox() *HTTPBox { 15 | return &HTTPBox{b} 16 | } 17 | 18 | // Open returns a File using the http.File interface 19 | func (hb *HTTPBox) Open(name string) (http.File, error) { 20 | return hb.Box.Open(name) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/GeertJohan/go.rice/sort.go: -------------------------------------------------------------------------------- 1 | package rice 2 | 3 | import "os" 4 | 5 | // SortByName allows an array of os.FileInfo objects 6 | // to be easily sorted by filename using sort.Sort(SortByName(array)) 7 | type SortByName []os.FileInfo 8 | 9 | func (f SortByName) Len() int { return len(f) } 10 | func (f SortByName) Less(i, j int) bool { return f[i].Name() < f[j].Name() } 11 | func (f SortByName) Swap(i, j int) { f[i], f[j] = f[j], f[i] } 12 | 13 | // SortByModified allows an array of os.FileInfo objects 14 | // to be easily sorted by modified date using sort.Sort(SortByModified(array)) 15 | type SortByModified []os.FileInfo 16 | 17 | func (f SortByModified) Len() int { return len(f) } 18 | func (f SortByModified) Less(i, j int) bool { return f[i].ModTime().Unix() > f[j].ModTime().Unix() } 19 | func (f SortByModified) Swap(i, j int) { f[i], f[j] = f[j], f[i] } 20 | -------------------------------------------------------------------------------- /vendor/github.com/daaku/go.zipexe/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/daaku/go.zipexe 2 | 3 | go 1.11 4 | -------------------------------------------------------------------------------- /vendor/github.com/daaku/go.zipexe/license: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2012-2015 Carlos Castillo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the “Software”), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/daaku/go.zipexe/readme.md: -------------------------------------------------------------------------------- 1 | go.zipexe 2 | ========= 3 | 4 | This module was taken as-is from https://github.com/cookieo9/resources-go. 5 | Documentation: https://godoc.org/github.com/daaku/go.zipexe 6 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - 1.7.x 5 | - 1.8.x 6 | - 1.9.x 7 | - 1.10.x 8 | - 1.11.x 9 | - tip 10 | 11 | before_install: 12 | - go get github.com/mattn/goveralls 13 | 14 | script: 15 | - goveralls -service=travis-ci 16 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Chris Hines 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/go-stack/stack?status.svg)](https://godoc.org/github.com/go-stack/stack) 2 | [![Go Report Card](https://goreportcard.com/badge/go-stack/stack)](https://goreportcard.com/report/go-stack/stack) 3 | [![TravisCI](https://travis-ci.org/go-stack/stack.svg?branch=master)](https://travis-ci.org/go-stack/stack) 4 | [![Coverage Status](https://coveralls.io/repos/github/go-stack/stack/badge.svg?branch=master)](https://coveralls.io/github/go-stack/stack?branch=master) 5 | 6 | # stack 7 | 8 | Package stack implements utilities to capture, manipulate, and format call 9 | stacks. It provides a simpler API than package runtime. 10 | 11 | The implementation takes care of the minutia and special cases of interpreting 12 | the program counter (pc) values returned by runtime.Callers. 13 | 14 | ## Versioning 15 | 16 | Package stack publishes releases via [semver](http://semver.org/) compatible Git 17 | tags prefixed with a single 'v'. The master branch always contains the latest 18 | release. The develop branch contains unreleased commits. 19 | 20 | ## Formatting 21 | 22 | Package stack's types implement fmt.Formatter, which provides a simple and 23 | flexible way to declaratively configure formatting when used with logging or 24 | error tracking packages. 25 | 26 | ```go 27 | func DoTheThing() { 28 | c := stack.Caller(0) 29 | log.Print(c) // "source.go:10" 30 | log.Printf("%+v", c) // "pkg/path/source.go:10" 31 | log.Printf("%n", c) // "DoTheThing" 32 | 33 | s := stack.Trace().TrimRuntime() 34 | log.Print(s) // "[source.go:15 caller.go:42 main.go:14]" 35 | } 36 | ``` 37 | 38 | See the docs for all of the supported formatting options. 39 | -------------------------------------------------------------------------------- /vendor/github.com/go-stack/stack/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/go-stack/stack 2 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/.gitignore: -------------------------------------------------------------------------------- 1 | cmd/snappytool/snappytool 2 | testdata/bench 3 | 4 | # These explicitly listed benchmark data files are for an obsolete version of 5 | # snappy_test.go. 6 | testdata/alice29.txt 7 | testdata/asyoulik.txt 8 | testdata/fireworks.jpeg 9 | testdata/geo.protodata 10 | testdata/html 11 | testdata/html_x_4 12 | testdata/kppkn.gtb 13 | testdata/lcet10.txt 14 | testdata/paper-100k.pdf 15 | testdata/plrabn12.txt 16 | testdata/urls.10K 17 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of Snappy-Go authors for copyright purposes. 2 | # This file is distinct from the CONTRIBUTORS files. 3 | # See the latter for an explanation. 4 | 5 | # Names should be added to this file as 6 | # Name or Organization 7 | # The email address is not required for organizations. 8 | 9 | # Please keep the list sorted. 10 | 11 | Damian Gryski 12 | Google Inc. 13 | Jan Mercl <0xjnml@gmail.com> 14 | Klaus Post 15 | Rodolfo Carvalho 16 | Sebastien Binet 17 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This is the official list of people who can contribute 2 | # (and typically have contributed) code to the Snappy-Go repository. 3 | # The AUTHORS file lists the copyright holders; this file 4 | # lists people. For example, Google employees are listed here 5 | # but not in AUTHORS, because Google holds the copyright. 6 | # 7 | # The submission process automatically checks to make sure 8 | # that people submitting code are listed in this file (by email address). 9 | # 10 | # Names should be added to this file only after verifying that 11 | # the individual or the individual's organization has agreed to 12 | # the appropriate Contributor License Agreement, found here: 13 | # 14 | # http://code.google.com/legal/individual-cla-v1.0.html 15 | # http://code.google.com/legal/corporate-cla-v1.0.html 16 | # 17 | # The agreement for individuals can be filled out on the web. 18 | # 19 | # When adding J Random Contributor's name to this file, 20 | # either J's name or J's organization's name should be 21 | # added to the AUTHORS file, depending on whether the 22 | # individual or corporate CLA was used. 23 | 24 | # Names should be added to this file like so: 25 | # Name 26 | 27 | # Please keep the list sorted. 28 | 29 | Damian Gryski 30 | Jan Mercl <0xjnml@gmail.com> 31 | Kai Backman 32 | Klaus Post 33 | Marc-Antoine Ruel 34 | Nigel Tao 35 | Rob Pike 36 | Rodolfo Carvalho 37 | Russ Cox 38 | Sebastien Binet 39 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2011 The Snappy-Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/decode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // decode has the same semantics as in decode_other.go. 12 | // 13 | //go:noescape 14 | func decode(dst, src []byte) int 15 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/encode_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016 The Snappy-Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !appengine 6 | // +build gc 7 | // +build !noasm 8 | 9 | package snappy 10 | 11 | // emitLiteral has the same semantics as in encode_other.go. 12 | // 13 | //go:noescape 14 | func emitLiteral(dst, lit []byte) int 15 | 16 | // emitCopy has the same semantics as in encode_other.go. 17 | // 18 | //go:noescape 19 | func emitCopy(dst []byte, offset, length int) int 20 | 21 | // extendMatch has the same semantics as in encode_other.go. 22 | // 23 | //go:noescape 24 | func extendMatch(src []byte, i, j int) int 25 | 26 | // encodeBlock has the same semantics as in encode_other.go. 27 | // 28 | //go:noescape 29 | func encodeBlock(dst, src []byte) (d int) 30 | -------------------------------------------------------------------------------- /vendor/github.com/golang/snappy/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/golang/snappy 2 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/AUTHORS: -------------------------------------------------------------------------------- 1 | # This is the official list of gorilla/mux authors for copyright purposes. 2 | # 3 | # Please keep the list sorted. 4 | 5 | Google LLC (https://opensource.google.com/) 6 | Kamil Kisielk 7 | Matt Silverlock 8 | Rodrigo Moraes (https://github.com/moraes) 9 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012-2018 The Gorilla Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/context.go: -------------------------------------------------------------------------------- 1 | package mux 2 | 3 | import ( 4 | "context" 5 | "net/http" 6 | ) 7 | 8 | func contextGet(r *http.Request, key interface{}) interface{} { 9 | return r.Context().Value(key) 10 | } 11 | 12 | func contextSet(r *http.Request, key, val interface{}) *http.Request { 13 | if val == nil { 14 | return r 15 | } 16 | 17 | return r.WithContext(context.WithValue(r.Context(), key, val)) 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/gorilla/mux 2 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/middleware.go: -------------------------------------------------------------------------------- 1 | package mux 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | ) 7 | 8 | // MiddlewareFunc is a function which receives an http.Handler and returns another http.Handler. 9 | // Typically, the returned handler is a closure which does something with the http.ResponseWriter and http.Request passed 10 | // to it, and then calls the handler passed as parameter to the MiddlewareFunc. 11 | type MiddlewareFunc func(http.Handler) http.Handler 12 | 13 | // middleware interface is anything which implements a MiddlewareFunc named Middleware. 14 | type middleware interface { 15 | Middleware(handler http.Handler) http.Handler 16 | } 17 | 18 | // Middleware allows MiddlewareFunc to implement the middleware interface. 19 | func (mw MiddlewareFunc) Middleware(handler http.Handler) http.Handler { 20 | return mw(handler) 21 | } 22 | 23 | // Use appends a MiddlewareFunc to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router. 24 | func (r *Router) Use(mwf ...MiddlewareFunc) { 25 | for _, fn := range mwf { 26 | r.middlewares = append(r.middlewares, fn) 27 | } 28 | } 29 | 30 | // useInterface appends a middleware to the chain. Middleware can be used to intercept or otherwise modify requests and/or responses, and are executed in the order that they are applied to the Router. 31 | func (r *Router) useInterface(mw middleware) { 32 | r.middlewares = append(r.middlewares, mw) 33 | } 34 | 35 | // CORSMethodMiddleware automatically sets the Access-Control-Allow-Methods response header 36 | // on requests for routes that have an OPTIONS method matcher to all the method matchers on 37 | // the route. Routes that do not explicitly handle OPTIONS requests will not be processed 38 | // by the middleware. See examples for usage. 39 | func CORSMethodMiddleware(r *Router) MiddlewareFunc { 40 | return func(next http.Handler) http.Handler { 41 | return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) { 42 | allMethods, err := getAllMethodsForRoute(r, req) 43 | if err == nil { 44 | for _, v := range allMethods { 45 | if v == http.MethodOptions { 46 | w.Header().Set("Access-Control-Allow-Methods", strings.Join(allMethods, ",")) 47 | } 48 | } 49 | } 50 | 51 | next.ServeHTTP(w, req) 52 | }) 53 | } 54 | } 55 | 56 | // getAllMethodsForRoute returns all the methods from method matchers matching a given 57 | // request. 58 | func getAllMethodsForRoute(r *Router, req *http.Request) ([]string, error) { 59 | var allMethods []string 60 | 61 | err := r.Walk(func(route *Route, _ *Router, _ []*Route) error { 62 | for _, m := range route.matchers { 63 | if _, ok := m.(*routeRegexp); ok { 64 | if m.Match(req, &RouteMatch{}) { 65 | methods, err := route.GetMethods() 66 | if err != nil { 67 | return err 68 | } 69 | 70 | allMethods = append(allMethods, methods...) 71 | } 72 | break 73 | } 74 | } 75 | return nil 76 | }) 77 | 78 | return allMethods, err 79 | } 80 | -------------------------------------------------------------------------------- /vendor/github.com/gorilla/mux/test_helpers.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Gorilla Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package mux 6 | 7 | import "net/http" 8 | 9 | // SetURLVars sets the URL variables for the given request, to be accessed via 10 | // mux.Vars for testing route behaviour. Arguments are not modified, a shallow 11 | // copy is returned. 12 | // 13 | // This API should only be used for testing purposes; it provides a way to 14 | // inject variables into the request context. Alternatively, URL variables 15 | // can be set by making a route that captures the required variables, 16 | // starting a server and sending the request to that server. 17 | func SetURLVars(r *http.Request, val map[string]string) *http.Request { 18 | return setVars(r, val) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/someone-stole-my-name/reCAPTCHAv3/reCAPTCHAv3.go: -------------------------------------------------------------------------------- 1 | package reCAPTCHAv3 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "io/ioutil" 7 | "net/http" 8 | "net/url" 9 | "time" 10 | ) 11 | 12 | type reCaptchaResponse struct { 13 | Success bool `json:"success"` 14 | ChallengeTS time.Time `json:"challenge_ts"` 15 | Hostname string `json:"hostname"` 16 | ErrorCodes []int `json:"error-codes"` 17 | Score float32 `json:"score"` 18 | } 19 | 20 | func ValidateReCaptcha(SecretKey string, Token string, Domain string) (err error) { 21 | endpoint := "https://www.google.com/recaptcha/api/siteverify" 22 | captchaPayload := url.Values{ 23 | "secret": {SecretKey}, 24 | "response": {Token}, 25 | } 26 | responsePost, err := http.PostForm(endpoint, captchaPayload) 27 | if err != nil { 28 | return 29 | } 30 | defer responsePost.Body.Close() 31 | body, err := ioutil.ReadAll(responsePost.Body) 32 | if err != nil { 33 | return 34 | } 35 | var re reCaptchaResponse 36 | json.Unmarshal(body, &re) 37 | if !re.Success || re.Hostname != Domain { 38 | err = errors.New("Failed reCaptcha") 39 | return 40 | } 41 | return 42 | } -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/vendor/github.com/xdg/scram/.gitignore -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - "1.7" 5 | - "1.8" 6 | - "1.9" 7 | - "1.10" 8 | - master 9 | matrix: 10 | allow_failures: 11 | - go: master 12 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/xdg/scram?status.svg)](https://godoc.org/github.com/xdg/scram) 2 | [![Build Status](https://travis-ci.org/xdg/scram.svg?branch=master)](https://travis-ci.org/xdg/scram) 3 | 4 | # scram – Go implementation of RFC-5802 5 | 6 | ## Description 7 | 8 | Package scram provides client and server implementations of the Salted 9 | Challenge Response Authentication Mechanism (SCRAM) described in 10 | [RFC-5802](https://tools.ietf.org/html/rfc5802) and 11 | [RFC-7677](https://tools.ietf.org/html/rfc7677). 12 | 13 | It includes both client and server side support. 14 | 15 | Channel binding and extensions are not (yet) supported. 16 | 17 | ## Examples 18 | 19 | ### Client side 20 | 21 | package main 22 | 23 | import "github.com/xdg/scram" 24 | 25 | func main() { 26 | // Get Client with username, password and (optional) authorization ID. 27 | clientSHA1, err := scram.SHA1.NewClient("mulder", "trustno1", "") 28 | if err != nil { 29 | panic(err) 30 | } 31 | 32 | // Prepare the authentication conversation. Use the empty string as the 33 | // initial server message argument to start the conversation. 34 | conv := clientSHA1.NewConversation() 35 | var serverMsg string 36 | 37 | // Get the first message, send it and read the response. 38 | firstMsg, err := conv.Step(serverMsg) 39 | if err != nil { 40 | panic(err) 41 | } 42 | serverMsg = sendClientMsg(firstMsg) 43 | 44 | // Get the second message, send it, and read the response. 45 | secondMsg, err := conv.Step(serverMsg) 46 | if err != nil { 47 | panic(err) 48 | } 49 | serverMsg = sendClientMsg(secondMsg) 50 | 51 | // Validate the server's final message. We have no further message to 52 | // send so ignore that return value. 53 | _, err = conv.Step(serverMsg) 54 | if err != nil { 55 | panic(err) 56 | } 57 | 58 | return 59 | } 60 | 61 | func sendClientMsg(s string) string { 62 | // A real implementation would send this to a server and read a reply. 63 | return "" 64 | } 65 | 66 | ## Copyright and License 67 | 68 | Copyright 2018 by David A. Golden. All rights reserved. 69 | 70 | Licensed under the Apache License, Version 2.0 (the "License"). You may 71 | obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 72 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package scram provides client and server implementations of the Salted 8 | // Challenge Response Authentication Mechanism (SCRAM) described in RFC-5802 9 | // and RFC-7677. 10 | // 11 | // Usage 12 | // 13 | // The scram package provides two variables, `SHA1` and `SHA256`, that are 14 | // used to construct Client or Server objects. 15 | // 16 | // clientSHA1, err := scram.SHA1.NewClient(username, password, authID) 17 | // clientSHA256, err := scram.SHA256.NewClient(username, password, authID) 18 | // 19 | // serverSHA1, err := scram.SHA1.NewServer(credentialLookupFcn) 20 | // serverSHA256, err := scram.SHA256.NewServer(credentialLookupFcn) 21 | // 22 | // These objects are used to construct ClientConversation or 23 | // ServerConversation objects that are used to carry out authentication. 24 | package scram 25 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/scram.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package scram 8 | 9 | import ( 10 | "crypto/sha1" 11 | "crypto/sha256" 12 | "fmt" 13 | "hash" 14 | 15 | "github.com/xdg/stringprep" 16 | ) 17 | 18 | // HashGeneratorFcn abstracts a factory function that returns a hash.Hash 19 | // value to be used for SCRAM operations. Generally, one would use the 20 | // provided package variables, `scram.SHA1` and `scram.SHA256`, for the most 21 | // common forms of SCRAM. 22 | type HashGeneratorFcn func() hash.Hash 23 | 24 | // SHA1 is a function that returns a crypto/sha1 hasher and should be used to 25 | // create Client objects configured for SHA-1 hashing. 26 | var SHA1 HashGeneratorFcn = func() hash.Hash { return sha1.New() } 27 | 28 | // SHA256 is a function that returns a crypto/sha256 hasher and should be used 29 | // to create Client objects configured for SHA-256 hashing. 30 | var SHA256 HashGeneratorFcn = func() hash.Hash { return sha256.New() } 31 | 32 | // NewClient constructs a SCRAM client component based on a given hash.Hash 33 | // factory receiver. This constructor will normalize the username, password 34 | // and authzID via the SASLprep algorithm, as recommended by RFC-5802. If 35 | // SASLprep fails, the method returns an error. 36 | func (f HashGeneratorFcn) NewClient(username, password, authzID string) (*Client, error) { 37 | var userprep, passprep, authprep string 38 | var err error 39 | 40 | if userprep, err = stringprep.SASLprep.Prepare(username); err != nil { 41 | return nil, fmt.Errorf("Error SASLprepping username '%s': %v", username, err) 42 | } 43 | if passprep, err = stringprep.SASLprep.Prepare(password); err != nil { 44 | return nil, fmt.Errorf("Error SASLprepping password '%s': %v", password, err) 45 | } 46 | if authprep, err = stringprep.SASLprep.Prepare(authzID); err != nil { 47 | return nil, fmt.Errorf("Error SASLprepping authzID '%s': %v", authzID, err) 48 | } 49 | 50 | return newClient(userprep, passprep, authprep, f), nil 51 | } 52 | 53 | // NewClientUnprepped acts like NewClient, except none of the arguments will 54 | // be normalized via SASLprep. This is not generally recommended, but is 55 | // provided for users that may have custom normalization needs. 56 | func (f HashGeneratorFcn) NewClientUnprepped(username, password, authzID string) (*Client, error) { 57 | return newClient(username, password, authzID, f), nil 58 | } 59 | 60 | // NewServer constructs a SCRAM server component based on a given hash.Hash 61 | // factory receiver. To be maximally generic, it uses dependency injection to 62 | // handle credential lookup, which is the process of turning a username string 63 | // into a struct with stored credentials for authentication. 64 | func (f HashGeneratorFcn) NewServer(cl CredentialLookup) (*Server, error) { 65 | return newServer(cl, f) 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/scram/server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package scram 8 | 9 | import "sync" 10 | 11 | // Server implements the server side of SCRAM authentication. It holds 12 | // configuration values needed to initialize new server-side conversations. 13 | // Generally, this can be persistent within an application. 14 | type Server struct { 15 | sync.RWMutex 16 | credentialCB CredentialLookup 17 | nonceGen NonceGeneratorFcn 18 | hashGen HashGeneratorFcn 19 | } 20 | 21 | func newServer(cl CredentialLookup, fcn HashGeneratorFcn) (*Server, error) { 22 | return &Server{ 23 | credentialCB: cl, 24 | nonceGen: defaultNonceGenerator, 25 | hashGen: fcn, 26 | }, nil 27 | } 28 | 29 | // WithNonceGenerator replaces the default nonce generator (base64 encoding of 30 | // 24 bytes from crypto/rand) with a custom generator. This is provided for 31 | // testing or for users with custom nonce requirements. 32 | func (s *Server) WithNonceGenerator(ng NonceGeneratorFcn) *Server { 33 | s.Lock() 34 | defer s.Unlock() 35 | s.nonceGen = ng 36 | return s 37 | } 38 | 39 | // NewConversation constructs a server-side authentication conversation. 40 | // Conversations cannot be reused, so this must be called for each new 41 | // authentication attempt. 42 | func (s *Server) NewConversation() *ServerConversation { 43 | s.RLock() 44 | defer s.RUnlock() 45 | return &ServerConversation{ 46 | nonceGen: s.nonceGen, 47 | hashGen: s.hashGen, 48 | credentialCB: s.credentialCB, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/vendor/github.com/xdg/stringprep/.gitignore -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | sudo: false 3 | go: 4 | - "1.7" 5 | - "1.8" 6 | - "1.9" 7 | - "1.10" 8 | - master 9 | matrix: 10 | allow_failures: 11 | - go: master 12 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/xdg/stringprep?status.svg)](https://godoc.org/github.com/xdg/stringprep) 2 | [![Build Status](https://travis-ci.org/xdg/stringprep.svg?branch=master)](https://travis-ci.org/xdg/stringprep) 3 | 4 | # stringprep – Go implementation of RFC-3454 stringprep and RFC-4013 SASLprep 5 | 6 | ## Synopsis 7 | 8 | ``` 9 | import "github.com/xdg/stringprep" 10 | 11 | prepped := stringprep.SASLprep.Prepare("TrustNô1") 12 | 13 | ``` 14 | 15 | ## Description 16 | 17 | This library provides an implementation of the stringprep algorithm 18 | (RFC-3454) in Go, including all data tables. 19 | 20 | A pre-built SASLprep (RFC-4013) profile is provided as well. 21 | 22 | ## Copyright and License 23 | 24 | Copyright 2018 by David A. Golden. All rights reserved. 25 | 26 | Licensed under the Apache License, Version 2.0 (the "License"). You may 27 | obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 28 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/bidi.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package stringprep 8 | 9 | var errHasLCat = "BiDi string can't have runes from category L" 10 | var errFirstRune = "BiDi string first rune must have category R or AL" 11 | var errLastRune = "BiDi string last rune must have category R or AL" 12 | 13 | // Check for prohibited characters from table C.8 14 | func checkBiDiProhibitedRune(s string) error { 15 | for _, r := range s { 16 | if TableC8.Contains(r) { 17 | return Error{Msg: errProhibited, Rune: r} 18 | } 19 | } 20 | return nil 21 | } 22 | 23 | // Check for LCat characters from table D.2 24 | func checkBiDiLCat(s string) error { 25 | for _, r := range s { 26 | if TableD2.Contains(r) { 27 | return Error{Msg: errHasLCat, Rune: r} 28 | } 29 | } 30 | return nil 31 | } 32 | 33 | // Check first and last characters are in table D.1; requires non-empty string 34 | func checkBadFirstAndLastRandALCat(s string) error { 35 | rs := []rune(s) 36 | if !TableD1.Contains(rs[0]) { 37 | return Error{Msg: errFirstRune, Rune: rs[0]} 38 | } 39 | n := len(rs) - 1 40 | if !TableD1.Contains(rs[n]) { 41 | return Error{Msg: errLastRune, Rune: rs[n]} 42 | } 43 | return nil 44 | } 45 | 46 | // Look for RandALCat characters from table D.1 47 | func hasBiDiRandALCat(s string) bool { 48 | for _, r := range s { 49 | if TableD1.Contains(r) { 50 | return true 51 | } 52 | } 53 | return false 54 | } 55 | 56 | // Check that BiDi rules are satisfied ; let empty string pass this rule 57 | func passesBiDiRules(s string) error { 58 | if len(s) == 0 { 59 | return nil 60 | } 61 | if err := checkBiDiProhibitedRune(s); err != nil { 62 | return err 63 | } 64 | if hasBiDiRandALCat(s) { 65 | if err := checkBiDiLCat(s); err != nil { 66 | return err 67 | } 68 | if err := checkBadFirstAndLastRandALCat(s); err != nil { 69 | return err 70 | } 71 | } 72 | return nil 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package stringprep provides data tables and algorithms for RFC-3454, 8 | // including errata (as of 2018-02). It also provides a profile for 9 | // SASLprep as defined in RFC-4013. 10 | package stringprep 11 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/error.go: -------------------------------------------------------------------------------- 1 | package stringprep 2 | 3 | import "fmt" 4 | 5 | // Error describes problems encountered during stringprep, including what rune 6 | // was problematic. 7 | type Error struct { 8 | Msg string 9 | Rune rune 10 | } 11 | 12 | func (e Error) Error() string { 13 | return fmt.Sprintf("%s (rune: '\\u%04x')", e.Msg, e.Rune) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/map.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package stringprep 8 | 9 | // Mapping represents a stringprep mapping, from a single rune to zero or more 10 | // runes. 11 | type Mapping map[rune][]rune 12 | 13 | // Map maps a rune to a (possibly empty) rune slice via a stringprep Mapping. 14 | // The ok return value is false if the rune was not found. 15 | func (m Mapping) Map(r rune) (replacement []rune, ok bool) { 16 | rs, ok := m[r] 17 | if !ok { 18 | return nil, false 19 | } 20 | return rs, true 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/profile.go: -------------------------------------------------------------------------------- 1 | package stringprep 2 | 3 | import ( 4 | "golang.org/x/text/unicode/norm" 5 | ) 6 | 7 | // Profile represents a stringprep profile. 8 | type Profile struct { 9 | Mappings []Mapping 10 | Normalize bool 11 | Prohibits []Set 12 | CheckBiDi bool 13 | } 14 | 15 | var errProhibited = "prohibited character" 16 | 17 | // Prepare transforms an input string to an output string following 18 | // the rules defined in the profile as defined by RFC-3454. 19 | func (p Profile) Prepare(s string) (string, error) { 20 | // Optimistically, assume output will be same length as input 21 | temp := make([]rune, 0, len(s)) 22 | 23 | // Apply maps 24 | for _, r := range s { 25 | rs, ok := p.applyMaps(r) 26 | if ok { 27 | temp = append(temp, rs...) 28 | } else { 29 | temp = append(temp, r) 30 | } 31 | } 32 | 33 | // Normalize 34 | var out string 35 | if p.Normalize { 36 | out = norm.NFKC.String(string(temp)) 37 | } else { 38 | out = string(temp) 39 | } 40 | 41 | // Check prohibited 42 | for _, r := range out { 43 | if p.runeIsProhibited(r) { 44 | return "", Error{Msg: errProhibited, Rune: r} 45 | } 46 | } 47 | 48 | // Check BiDi allowed 49 | if p.CheckBiDi { 50 | if err := passesBiDiRules(out); err != nil { 51 | return "", err 52 | } 53 | } 54 | 55 | return out, nil 56 | } 57 | 58 | func (p Profile) applyMaps(r rune) ([]rune, bool) { 59 | for _, m := range p.Mappings { 60 | rs, ok := m.Map(r) 61 | if ok { 62 | return rs, true 63 | } 64 | } 65 | return nil, false 66 | } 67 | 68 | func (p Profile) runeIsProhibited(r rune) bool { 69 | for _, s := range p.Prohibits { 70 | if s.Contains(r) { 71 | return true 72 | } 73 | } 74 | return false 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/saslprep.go: -------------------------------------------------------------------------------- 1 | package stringprep 2 | 3 | var mapNonASCIISpaceToASCIISpace = Mapping{ 4 | 0x00A0: []rune{0x0020}, 5 | 0x1680: []rune{0x0020}, 6 | 0x2000: []rune{0x0020}, 7 | 0x2001: []rune{0x0020}, 8 | 0x2002: []rune{0x0020}, 9 | 0x2003: []rune{0x0020}, 10 | 0x2004: []rune{0x0020}, 11 | 0x2005: []rune{0x0020}, 12 | 0x2006: []rune{0x0020}, 13 | 0x2007: []rune{0x0020}, 14 | 0x2008: []rune{0x0020}, 15 | 0x2009: []rune{0x0020}, 16 | 0x200A: []rune{0x0020}, 17 | 0x200B: []rune{0x0020}, 18 | 0x202F: []rune{0x0020}, 19 | 0x205F: []rune{0x0020}, 20 | 0x3000: []rune{0x0020}, 21 | } 22 | 23 | // SASLprep is a pre-defined stringprep profile for user names and passwords 24 | // as described in RFC-4013. 25 | // 26 | // Because the stringprep distinction between query and stored strings was 27 | // intended for compatibility across profile versions, but SASLprep was never 28 | // updated and is now deprecated, this profile only operates in stored 29 | // strings mode, prohibiting unassigned code points. 30 | var SASLprep Profile = saslprep 31 | 32 | var saslprep = Profile{ 33 | Mappings: []Mapping{ 34 | TableB1, 35 | mapNonASCIISpaceToASCIISpace, 36 | }, 37 | Normalize: true, 38 | Prohibits: []Set{ 39 | TableA1, 40 | TableC1_2, 41 | TableC2_1, 42 | TableC2_2, 43 | TableC3, 44 | TableC4, 45 | TableC5, 46 | TableC6, 47 | TableC7, 48 | TableC8, 49 | TableC9, 50 | }, 51 | CheckBiDi: true, 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/xdg/stringprep/set.go: -------------------------------------------------------------------------------- 1 | // Copyright 2018 by David A. Golden. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package stringprep 8 | 9 | import "sort" 10 | 11 | // RuneRange represents a close-ended range of runes: [N,M]. For a range 12 | // consisting of a single rune, N and M will be equal. 13 | type RuneRange [2]rune 14 | 15 | // Contains returns true if a rune is within the bounds of the RuneRange. 16 | func (rr RuneRange) Contains(r rune) bool { 17 | return rr[0] <= r && r <= rr[1] 18 | } 19 | 20 | func (rr RuneRange) isAbove(r rune) bool { 21 | return r <= rr[0] 22 | } 23 | 24 | // Set represents a stringprep data table used to identify runes of a 25 | // particular type. 26 | type Set []RuneRange 27 | 28 | // Contains returns true if a rune is within any of the RuneRanges in the 29 | // Set. 30 | func (s Set) Contains(r rune) bool { 31 | i := sort.Search(len(s), func(i int) bool { return s[i].Contains(r) || s[i].isAbove(r) }) 32 | if i < len(s) && s[i].Contains(r) { 33 | return true 34 | } 35 | return false 36 | } 37 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bson.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | // 7 | // Based on gopkg.in/mgo.v2/bson by Gustavo Niemeyer 8 | // See THIRD-PARTY-NOTICES for original license terms. 9 | 10 | // +build go1.9 11 | 12 | package bson // import "go.mongodb.org/mongo-driver/bson" 13 | 14 | import ( 15 | "go.mongodb.org/mongo-driver/bson/primitive" 16 | ) 17 | 18 | // Zeroer allows custom struct types to implement a report of zero 19 | // state. All struct types that don't implement Zeroer or where IsZero 20 | // returns false are considered to be not zero. 21 | type Zeroer interface { 22 | IsZero() bool 23 | } 24 | 25 | // D represents a BSON Document. This type can be used to represent BSON in a concise and readable 26 | // manner. It should generally be used when serializing to BSON. For deserializing, the Raw or 27 | // Document types should be used. 28 | // 29 | // Example usage: 30 | // 31 | // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} 32 | // 33 | // This type should be used in situations where order matters, such as MongoDB commands. If the 34 | // order is not important, a map is more comfortable and concise. 35 | type D = primitive.D 36 | 37 | // E represents a BSON element for a D. It is usually used inside a D. 38 | type E = primitive.E 39 | 40 | // M is an unordered, concise representation of a BSON Document. It should generally be used to 41 | // serialize BSON when the order of the elements of a BSON document do not matter. If the element 42 | // order matters, use a D instead. 43 | // 44 | // Example usage: 45 | // 46 | // bson.M{"foo": "bar", "hello": "world", "pi": 3.14159} 47 | // 48 | // This type is handled in the encoders as a regular map[string]interface{}. The elements will be 49 | // serialized in an undefined, random order, and the order will be different each time. 50 | type M = primitive.M 51 | 52 | // An A represents a BSON array. This type can be used to represent a BSON array in a concise and 53 | // readable manner. It should generally be used when serializing to BSON. For deserializing, the 54 | // RawArray or Array types should be used. 55 | // 56 | // Example usage: 57 | // 58 | // bson.A{"bar", "world", 3.14159, bson.D{{"qux", 12345}}} 59 | // 60 | type A = primitive.A 61 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsoncodec 8 | 9 | import "fmt" 10 | 11 | type mode int 12 | 13 | const ( 14 | _ mode = iota 15 | mTopLevel 16 | mDocument 17 | mArray 18 | mValue 19 | mElement 20 | mCodeWithScope 21 | mSpacer 22 | ) 23 | 24 | func (m mode) String() string { 25 | var str string 26 | 27 | switch m { 28 | case mTopLevel: 29 | str = "TopLevel" 30 | case mDocument: 31 | str = "DocumentMode" 32 | case mArray: 33 | str = "ArrayMode" 34 | case mValue: 35 | str = "ValueMode" 36 | case mElement: 37 | str = "ElementMode" 38 | case mCodeWithScope: 39 | str = "CodeWithScopeMode" 40 | case mSpacer: 41 | str = "CodeWithScopeSpacerFrame" 42 | default: 43 | str = "UnknownMode" 44 | } 45 | 46 | return str 47 | } 48 | 49 | // TransitionError is an error returned when an invalid progressing a 50 | // ValueReader or ValueWriter state machine occurs. 51 | type TransitionError struct { 52 | parent mode 53 | current mode 54 | destination mode 55 | } 56 | 57 | func (te TransitionError) Error() string { 58 | if te.destination == mode(0) { 59 | return fmt.Sprintf("invalid state transition: cannot read/write value while in %s", te.current) 60 | } 61 | if te.parent == mode(0) { 62 | return fmt.Sprintf("invalid state transition: %s -> %s", te.current, te.destination) 63 | } 64 | return fmt.Sprintf("invalid state transition: %s -> %s; parent %s", te.current, te.destination, te.parent) 65 | } 66 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsoncodec/proxy.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsoncodec 8 | 9 | // Proxy is an interface implemented by types that cannot themselves be directly encoded. Types 10 | // that implement this interface with have ProxyBSON called during the encoding process and that 11 | // value will be encoded in place for the implementer. 12 | type Proxy interface { 13 | ProxyBSON() (interface{}, error) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsonrw/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package bsonrw contains abstractions for reading and writing 8 | // BSON and BSON like types from sources. 9 | package bsonrw // import "go.mongodb.org/mongo-driver/bson/bsonrw" 10 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsonrw/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonrw 8 | 9 | import ( 10 | "fmt" 11 | ) 12 | 13 | type mode int 14 | 15 | const ( 16 | _ mode = iota 17 | mTopLevel 18 | mDocument 19 | mArray 20 | mValue 21 | mElement 22 | mCodeWithScope 23 | mSpacer 24 | ) 25 | 26 | func (m mode) String() string { 27 | var str string 28 | 29 | switch m { 30 | case mTopLevel: 31 | str = "TopLevel" 32 | case mDocument: 33 | str = "DocumentMode" 34 | case mArray: 35 | str = "ArrayMode" 36 | case mValue: 37 | str = "ValueMode" 38 | case mElement: 39 | str = "ElementMode" 40 | case mCodeWithScope: 41 | str = "CodeWithScopeMode" 42 | case mSpacer: 43 | str = "CodeWithScopeSpacerFrame" 44 | default: 45 | str = "UnknownMode" 46 | } 47 | 48 | return str 49 | } 50 | 51 | func (m mode) TypeString() string { 52 | var str string 53 | 54 | switch m { 55 | case mTopLevel: 56 | str = "TopLevel" 57 | case mDocument: 58 | str = "Document" 59 | case mArray: 60 | str = "Array" 61 | case mValue: 62 | str = "Value" 63 | case mElement: 64 | str = "Element" 65 | case mCodeWithScope: 66 | str = "CodeWithScope" 67 | case mSpacer: 68 | str = "CodeWithScopeSpacer" 69 | default: 70 | str = "Unknown" 71 | } 72 | 73 | return str 74 | } 75 | 76 | // TransitionError is an error returned when an invalid progressing a 77 | // ValueReader or ValueWriter state machine occurs. 78 | // If read is false, the error is for writing 79 | type TransitionError struct { 80 | name string 81 | parent mode 82 | current mode 83 | destination mode 84 | modes []mode 85 | action string 86 | } 87 | 88 | func (te TransitionError) Error() string { 89 | errString := fmt.Sprintf("%s can only %s", te.name, te.action) 90 | if te.destination != mode(0) { 91 | errString = fmt.Sprintf("%s a %s", errString, te.destination.TypeString()) 92 | } 93 | errString = fmt.Sprintf("%s while positioned on a", errString) 94 | for ind, m := range te.modes { 95 | if ind != 0 && len(te.modes) > 2 { 96 | errString = fmt.Sprintf("%s,", errString) 97 | } 98 | if ind == len(te.modes)-1 && len(te.modes) > 1 { 99 | errString = fmt.Sprintf("%s or", errString) 100 | } 101 | errString = fmt.Sprintf("%s %s", errString, m.TypeString()) 102 | } 103 | errString = fmt.Sprintf("%s but is positioned on a %s", errString, te.current.TypeString()) 104 | if te.parent != mode(0) { 105 | errString = fmt.Sprintf("%s with parent %s", errString, te.parent.TypeString()) 106 | } 107 | return errString 108 | } 109 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsonrw/reader.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonrw 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/bson/bsontype" 11 | "go.mongodb.org/mongo-driver/bson/primitive" 12 | ) 13 | 14 | // ArrayReader is implemented by types that allow reading values from a BSON 15 | // array. 16 | type ArrayReader interface { 17 | ReadValue() (ValueReader, error) 18 | } 19 | 20 | // DocumentReader is implemented by types that allow reading elements from a 21 | // BSON document. 22 | type DocumentReader interface { 23 | ReadElement() (string, ValueReader, error) 24 | } 25 | 26 | // ValueReader is a generic interface used to read values from BSON. This type 27 | // is implemented by several types with different underlying representations of 28 | // BSON, such as a bson.Document, raw BSON bytes, or extended JSON. 29 | type ValueReader interface { 30 | Type() bsontype.Type 31 | Skip() error 32 | 33 | ReadArray() (ArrayReader, error) 34 | ReadBinary() (b []byte, btype byte, err error) 35 | ReadBoolean() (bool, error) 36 | ReadDocument() (DocumentReader, error) 37 | ReadCodeWithScope() (code string, dr DocumentReader, err error) 38 | ReadDBPointer() (ns string, oid primitive.ObjectID, err error) 39 | ReadDateTime() (int64, error) 40 | ReadDecimal128() (primitive.Decimal128, error) 41 | ReadDouble() (float64, error) 42 | ReadInt32() (int32, error) 43 | ReadInt64() (int64, error) 44 | ReadJavascript() (code string, err error) 45 | ReadMaxKey() error 46 | ReadMinKey() error 47 | ReadNull() error 48 | ReadObjectID() (primitive.ObjectID, error) 49 | ReadRegex() (pattern, options string, err error) 50 | ReadString() (string, error) 51 | ReadSymbol() (symbol string, err error) 52 | ReadTimestamp() (t, i uint32, err error) 53 | ReadUndefined() error 54 | } 55 | 56 | // BytesReader is a generic interface used to read BSON bytes from a 57 | // ValueReader. This imterface is meant to be a superset of ValueReader, so that 58 | // types that implement ValueReader may also implement this interface. 59 | // 60 | // The bytes of the value will be appended to dst. 61 | type BytesReader interface { 62 | ReadValueBytes(dst []byte) (bsontype.Type, []byte, error) 63 | } 64 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/bsontype/bsontype.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package bsontype is a utility package that contains types for each BSON type and the 8 | // a stringifier for the Type to enable easier debugging when working with BSON. 9 | package bsontype // import "go.mongodb.org/mongo-driver/bson/bsontype" 10 | 11 | // These constants uniquely refer to each BSON type. 12 | const ( 13 | Double Type = 0x01 14 | String Type = 0x02 15 | EmbeddedDocument Type = 0x03 16 | Array Type = 0x04 17 | Binary Type = 0x05 18 | Undefined Type = 0x06 19 | ObjectID Type = 0x07 20 | Boolean Type = 0x08 21 | DateTime Type = 0x09 22 | Null Type = 0x0A 23 | Regex Type = 0x0B 24 | DBPointer Type = 0x0C 25 | JavaScript Type = 0x0D 26 | Symbol Type = 0x0E 27 | CodeWithScope Type = 0x0F 28 | Int32 Type = 0x10 29 | Timestamp Type = 0x11 30 | Int64 Type = 0x12 31 | Decimal128 Type = 0x13 32 | MinKey Type = 0xFF 33 | MaxKey Type = 0x7F 34 | ) 35 | 36 | // Type represents a BSON type. 37 | type Type byte 38 | 39 | // String returns the string representation of the BSON type's name. 40 | func (bt Type) String() string { 41 | switch bt { 42 | case '\x01': 43 | return "double" 44 | case '\x02': 45 | return "string" 46 | case '\x03': 47 | return "embedded document" 48 | case '\x04': 49 | return "array" 50 | case '\x05': 51 | return "binary" 52 | case '\x06': 53 | return "undefined" 54 | case '\x07': 55 | return "objectID" 56 | case '\x08': 57 | return "boolean" 58 | case '\x09': 59 | return "UTC datetime" 60 | case '\x0A': 61 | return "null" 62 | case '\x0B': 63 | return "regex" 64 | case '\x0C': 65 | return "dbPointer" 66 | case '\x0D': 67 | return "javascript" 68 | case '\x0E': 69 | return "symbol" 70 | case '\x0F': 71 | return "code with scope" 72 | case '\x10': 73 | return "32-bit integer" 74 | case '\x11': 75 | return "timestamp" 76 | case '\x12': 77 | return "64-bit integer" 78 | case '\x13': 79 | return "128-bit decimal" 80 | case '\xFF': 81 | return "min key" 82 | case '\x7F': 83 | return "max key" 84 | default: 85 | return "invalid" 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package bson is a library for reading, writing, and manipulating BSON. The 8 | // library has two families of types for representing BSON. 9 | // 10 | // The Raw family of types is used to validate and retrieve elements from a slice of bytes. This 11 | // type is most useful when you want do lookups on BSON bytes without unmarshaling it into another 12 | // type. 13 | // 14 | // Example: 15 | // var raw bson.Raw = ... // bytes from somewhere 16 | // err := raw.Validate() 17 | // if err != nil { return err } 18 | // val := raw.Lookup("foo") 19 | // i32, ok := val.Int32OK() 20 | // // do something with i32... 21 | // 22 | // The D family of types is used to build concise representations of BSON using native Go types. 23 | // These types do not support automatic lookup. 24 | // 25 | // Example: 26 | // bson.D{{"foo", "bar"}, {"hello", "world"}, {"pi", 3.14159}} 27 | // 28 | // 29 | // Marshaling and Unmarshaling are handled with the Marshal and Unmarshal family of functions. If 30 | // you need to write or read BSON from a non-slice source, an Encoder or Decoder can be used with a 31 | // bsonrw.ValueWriter or bsonrw.ValueReader. 32 | // 33 | // Example: 34 | // b, err := bson.Marshal(bson.D{{"foo", "bar"}}) 35 | // if err != nil { return err } 36 | // var fooer struct { 37 | // Foo string 38 | // } 39 | // err = bson.Unmarshal(b, &fooer) 40 | // if err != nil { return err } 41 | // // do something with fooer... 42 | package bson 43 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/raw_element.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bson 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 11 | ) 12 | 13 | // RawElement represents a BSON element in byte form. This type provides a simple way to 14 | // transform a slice of bytes into a BSON element and extract information from it. 15 | // 16 | // RawElement is a thin wrapper around a bsoncore.Element. 17 | type RawElement []byte 18 | 19 | // Key returns the key for this element. If the element is not valid, this method returns an empty 20 | // string. If knowing if the element is valid is important, use KeyErr. 21 | func (re RawElement) Key() string { return bsoncore.Element(re).Key() } 22 | 23 | // KeyErr returns the key for this element, returning an error if the element is not valid. 24 | func (re RawElement) KeyErr() (string, error) { return bsoncore.Element(re).KeyErr() } 25 | 26 | // Value returns the value of this element. If the element is not valid, this method returns an 27 | // empty Value. If knowing if the element is valid is important, use ValueErr. 28 | func (re RawElement) Value() RawValue { return convertFromCoreValue(bsoncore.Element(re).Value()) } 29 | 30 | // ValueErr returns the value for this element, returning an error if the element is not valid. 31 | func (re RawElement) ValueErr() (RawValue, error) { 32 | val, err := bsoncore.Element(re).ValueErr() 33 | return convertFromCoreValue(val), err 34 | } 35 | 36 | // Validate ensures re is a valid BSON element. 37 | func (re RawElement) Validate() error { return bsoncore.Element(re).Validate() } 38 | 39 | // String implements the fmt.Stringer interface. The output will be in extended JSON format. 40 | func (re RawElement) String() string { 41 | doc := bsoncore.BuildDocument(nil, re) 42 | j, err := MarshalExtJSON(Raw(doc), true, false) 43 | if err != nil { 44 | return "" 45 | } 46 | return string(j) 47 | } 48 | 49 | // DebugString outputs a human readable version of RawElement. It will attempt to stringify the 50 | // valid components of the element even if the entire element is not valid. 51 | func (re RawElement) DebugString() string { return bsoncore.Element(re).DebugString() } 52 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/bson/registry.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bson 8 | 9 | import "go.mongodb.org/mongo-driver/bson/bsoncodec" 10 | 11 | // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the 12 | // primitive codecs. 13 | var DefaultRegistry = NewRegistryBuilder().Build() 14 | 15 | // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and 16 | // deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the 17 | // PrimitiveCodecs type in this package. 18 | func NewRegistryBuilder() *bsoncodec.RegistryBuilder { 19 | rb := bsoncodec.NewRegistryBuilder() 20 | bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb) 21 | bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb) 22 | primitiveCodecs.RegisterPrimitiveCodecs(rb) 23 | return rb 24 | } 25 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/internal/const.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package internal // import "go.mongodb.org/mongo-driver/internal" 8 | 9 | // Version is the current version of the driver. 10 | var Version = "local build" 11 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/internal/semaphore.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package internal 8 | 9 | import ( 10 | "context" 11 | "errors" 12 | ) 13 | 14 | // NewSemaphore creates a new semaphore. 15 | func NewSemaphore(slots uint64) *Semaphore { 16 | ch := make(chan struct{}, slots) 17 | for i := uint64(0); i < slots; i++ { 18 | ch <- struct{}{} 19 | } 20 | 21 | return &Semaphore{ 22 | permits: ch, 23 | } 24 | } 25 | 26 | // Semaphore is a synchronization primitive that controls access 27 | // to a common resource. 28 | type Semaphore struct { 29 | permits chan struct{} 30 | } 31 | 32 | // Len gets the number of permits available. 33 | func (s *Semaphore) Len() uint64 { 34 | return uint64(len(s.permits)) 35 | } 36 | 37 | // Wait waits until a resource is available or until the context 38 | // is done. 39 | func (s *Semaphore) Wait(ctx context.Context) error { 40 | select { 41 | case <-s.permits: 42 | return nil 43 | case <-ctx.Done(): 44 | return ctx.Err() 45 | } 46 | } 47 | 48 | // Release releases a resource back into the pool. 49 | func (s *Semaphore) Release() error { 50 | select { 51 | case s.permits <- struct{}{}: 52 | default: 53 | return errors.New("internal.Semaphore.Release: attempt to release more resources than are available") 54 | } 55 | 56 | return nil 57 | } 58 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/batch_cursor.go: -------------------------------------------------------------------------------- 1 | package mongo 2 | 3 | import ( 4 | "context" 5 | 6 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 7 | "go.mongodb.org/mongo-driver/x/mongo/driver" 8 | ) 9 | 10 | // batchCursor is the interface implemented by types that can provide batches of document results. 11 | // The Cursor type is built on top of this type. 12 | type batchCursor interface { 13 | // ID returns the ID of the cursor. 14 | ID() int64 15 | 16 | // Next returns true if there is a batch available. 17 | Next(context.Context) bool 18 | 19 | // Batch will return a DocumentSequence for the current batch of documents. The returned 20 | // DocumentSequence is only valid until the next call to Next or Close. 21 | Batch() *bsoncore.DocumentSequence 22 | 23 | // Server returns a pointer to the cursor's server. 24 | Server() driver.Server 25 | 26 | // Err returns the last error encountered. 27 | Err() error 28 | 29 | // Close closes the cursor. 30 | Close(context.Context) error 31 | } 32 | 33 | // changeStreamCursor is the interface implemented by batch cursors that also provide the functionality for retrieving 34 | // a postBatchResumeToken from commands and allows for the cursor to be killed rather than closed 35 | type changeStreamCursor interface { 36 | batchCursor 37 | // PostBatchResumeToken returns the latest seen post batch resume token. 38 | PostBatchResumeToken() bsoncore.Document 39 | 40 | // KillCursor kills cursor on server without closing batch cursor 41 | KillCursor(context.Context) error 42 | } 43 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/bulkwriteoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // DefaultOrdered is the default order for a BulkWriteOptions struct created from BulkWrite. 10 | var DefaultOrdered = true 11 | 12 | // BulkWriteOptions represent all possible options for a bulkWrite operation. 13 | type BulkWriteOptions struct { 14 | BypassDocumentValidation *bool // If true, allows the write to opt out of document-level validation. 15 | Ordered *bool // If true, when a write fails, return without performing remaining writes. Defaults to true. 16 | } 17 | 18 | // BulkWrite creates a new *BulkWriteOptions 19 | func BulkWrite() *BulkWriteOptions { 20 | return &BulkWriteOptions{ 21 | Ordered: &DefaultOrdered, 22 | } 23 | } 24 | 25 | // SetOrdered configures the ordered option. If true, when a write fails, the function will return without attempting 26 | // remaining writes. Defaults to true. 27 | func (b *BulkWriteOptions) SetOrdered(ordered bool) *BulkWriteOptions { 28 | b.Ordered = &ordered 29 | return b 30 | } 31 | 32 | // SetBypassDocumentValidation specifies if the write should opt out of document-level validation. 33 | // Valid for server versions >= 3.2. For servers < 3.2, this option is ignored. 34 | func (b *BulkWriteOptions) SetBypassDocumentValidation(bypass bool) *BulkWriteOptions { 35 | b.BypassDocumentValidation = &bypass 36 | return b 37 | } 38 | 39 | // MergeBulkWriteOptions combines the given *BulkWriteOptions into a single *BulkWriteOptions in a last one wins fashion. 40 | func MergeBulkWriteOptions(opts ...*BulkWriteOptions) *BulkWriteOptions { 41 | b := BulkWrite() 42 | for _, opt := range opts { 43 | if opt == nil { 44 | continue 45 | } 46 | if opt.Ordered != nil { 47 | b.Ordered = opt.Ordered 48 | } 49 | if opt.BypassDocumentValidation != nil { 50 | b.BypassDocumentValidation = opt.BypassDocumentValidation 51 | } 52 | } 53 | 54 | return b 55 | } 56 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions_1_10.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package options 4 | 5 | import "crypto/x509" 6 | 7 | func x509CertSubject(cert *x509.Certificate) string { 8 | return cert.Subject.String() 9 | } 10 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/clientoptions_1_9.go: -------------------------------------------------------------------------------- 1 | // +build !go1.10 2 | 3 | package options 4 | 5 | import ( 6 | "crypto/x509" 7 | ) 8 | 9 | // We don't support version less then 1.10, but Evergreen needs to be able to compile the driver 10 | // using version 1.8. 11 | func x509CertSubject(cert *x509.Certificate) string { 12 | return "" 13 | } 14 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/collectionoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/bson/bsoncodec" 11 | "go.mongodb.org/mongo-driver/mongo/readconcern" 12 | "go.mongodb.org/mongo-driver/mongo/readpref" 13 | "go.mongodb.org/mongo-driver/mongo/writeconcern" 14 | ) 15 | 16 | // CollectionOptions represent all possible options to configure a Collection. 17 | type CollectionOptions struct { 18 | ReadConcern *readconcern.ReadConcern // The read concern for operations in the collection. 19 | WriteConcern *writeconcern.WriteConcern // The write concern for operations in the collection. 20 | ReadPreference *readpref.ReadPref // The read preference for operations in the collection. 21 | Registry *bsoncodec.Registry // The registry to be used to construct BSON encoders and decoders for the collection. 22 | } 23 | 24 | // Collection creates a new CollectionOptions instance 25 | func Collection() *CollectionOptions { 26 | return &CollectionOptions{} 27 | } 28 | 29 | // SetReadConcern sets the read concern for the collection. 30 | func (c *CollectionOptions) SetReadConcern(rc *readconcern.ReadConcern) *CollectionOptions { 31 | c.ReadConcern = rc 32 | return c 33 | } 34 | 35 | // SetWriteConcern sets the write concern for the collection. 36 | func (c *CollectionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *CollectionOptions { 37 | c.WriteConcern = wc 38 | return c 39 | } 40 | 41 | // SetReadPreference sets the read preference for the collection. 42 | func (c *CollectionOptions) SetReadPreference(rp *readpref.ReadPref) *CollectionOptions { 43 | c.ReadPreference = rp 44 | return c 45 | } 46 | 47 | // SetRegistry sets the bsoncodec Registry for the collection. 48 | func (c *CollectionOptions) SetRegistry(r *bsoncodec.Registry) *CollectionOptions { 49 | c.Registry = r 50 | return c 51 | } 52 | 53 | // MergeCollectionOptions combines the *CollectionOptions arguments into a single *CollectionOptions in a last one wins 54 | // fashion. 55 | func MergeCollectionOptions(opts ...*CollectionOptions) *CollectionOptions { 56 | c := Collection() 57 | 58 | for _, opt := range opts { 59 | if opt == nil { 60 | continue 61 | } 62 | if opt.ReadConcern != nil { 63 | c.ReadConcern = opt.ReadConcern 64 | } 65 | if opt.WriteConcern != nil { 66 | c.WriteConcern = opt.WriteConcern 67 | } 68 | if opt.ReadPreference != nil { 69 | c.ReadPreference = opt.ReadPreference 70 | } 71 | if opt.Registry != nil { 72 | c.Registry = opt.Registry 73 | } 74 | } 75 | 76 | return c 77 | } 78 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/countoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import "time" 10 | 11 | // CountOptions represents all possible options to the Count() function. 12 | type CountOptions struct { 13 | Collation *Collation // Specifies a collation 14 | Hint interface{} // The index to use 15 | Limit *int64 // The maximum number of documents to count 16 | MaxTime *time.Duration // The maximum amount of time to allow the operation to run 17 | Skip *int64 // The number of documents to skip before counting 18 | } 19 | 20 | // Count returns a pointer to a new CountOptions 21 | func Count() *CountOptions { 22 | return &CountOptions{} 23 | } 24 | 25 | // SetCollation specifies a collation 26 | // Valid for server versions >= 3.4 27 | func (co *CountOptions) SetCollation(c *Collation) *CountOptions { 28 | co.Collation = c 29 | return co 30 | } 31 | 32 | // SetHint specifies the index to use 33 | func (co *CountOptions) SetHint(h interface{}) *CountOptions { 34 | co.Hint = h 35 | return co 36 | } 37 | 38 | // SetLimit specifies the maximum number of documents to count 39 | func (co *CountOptions) SetLimit(i int64) *CountOptions { 40 | co.Limit = &i 41 | return co 42 | } 43 | 44 | // SetMaxTime specifies the maximum amount of time to allow the operation to run 45 | func (co *CountOptions) SetMaxTime(d time.Duration) *CountOptions { 46 | co.MaxTime = &d 47 | return co 48 | } 49 | 50 | // SetSkip specifies the number of documents to skip before counting 51 | func (co *CountOptions) SetSkip(i int64) *CountOptions { 52 | co.Skip = &i 53 | return co 54 | } 55 | 56 | // MergeCountOptions combines the argued CountOptions into a single CountOptions in a last-one-wins fashion 57 | func MergeCountOptions(opts ...*CountOptions) *CountOptions { 58 | countOpts := Count() 59 | for _, co := range opts { 60 | if co == nil { 61 | continue 62 | } 63 | if co.Collation != nil { 64 | countOpts.Collation = co.Collation 65 | } 66 | if co.Hint != nil { 67 | countOpts.Hint = co.Hint 68 | } 69 | if co.Limit != nil { 70 | countOpts.Limit = co.Limit 71 | } 72 | if co.MaxTime != nil { 73 | countOpts.MaxTime = co.MaxTime 74 | } 75 | if co.Skip != nil { 76 | countOpts.Skip = co.Skip 77 | } 78 | } 79 | 80 | return countOpts 81 | } 82 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/dboptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/bson/bsoncodec" 11 | "go.mongodb.org/mongo-driver/mongo/readconcern" 12 | "go.mongodb.org/mongo-driver/mongo/readpref" 13 | "go.mongodb.org/mongo-driver/mongo/writeconcern" 14 | ) 15 | 16 | // DatabaseOptions represent all possible options to configure a Database. 17 | type DatabaseOptions struct { 18 | ReadConcern *readconcern.ReadConcern // The read concern for operations in the database. 19 | WriteConcern *writeconcern.WriteConcern // The write concern for operations in the database. 20 | ReadPreference *readpref.ReadPref // The read preference for operations in the database. 21 | Registry *bsoncodec.Registry // The registry to be used to construct BSON encoders and decoders for the database. 22 | } 23 | 24 | // Database creates a new DatabaseOptions instance 25 | func Database() *DatabaseOptions { 26 | return &DatabaseOptions{} 27 | } 28 | 29 | // SetReadConcern sets the read concern for the database. 30 | func (d *DatabaseOptions) SetReadConcern(rc *readconcern.ReadConcern) *DatabaseOptions { 31 | d.ReadConcern = rc 32 | return d 33 | } 34 | 35 | // SetWriteConcern sets the write concern for the database. 36 | func (d *DatabaseOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *DatabaseOptions { 37 | d.WriteConcern = wc 38 | return d 39 | } 40 | 41 | // SetReadPreference sets the read preference for the database. 42 | func (d *DatabaseOptions) SetReadPreference(rp *readpref.ReadPref) *DatabaseOptions { 43 | d.ReadPreference = rp 44 | return d 45 | } 46 | 47 | // SetRegistry sets the bsoncodec Registry for the database. 48 | func (d *DatabaseOptions) SetRegistry(r *bsoncodec.Registry) *DatabaseOptions { 49 | d.Registry = r 50 | return d 51 | } 52 | 53 | // MergeDatabaseOptions combines the *DatabaseOptions arguments into a single *DatabaseOptions in a last one wins 54 | // fashion. 55 | func MergeDatabaseOptions(opts ...*DatabaseOptions) *DatabaseOptions { 56 | d := Database() 57 | 58 | for _, opt := range opts { 59 | if opt == nil { 60 | continue 61 | } 62 | if opt.ReadConcern != nil { 63 | d.ReadConcern = opt.ReadConcern 64 | } 65 | if opt.WriteConcern != nil { 66 | d.WriteConcern = opt.WriteConcern 67 | } 68 | if opt.ReadPreference != nil { 69 | d.ReadPreference = opt.ReadPreference 70 | } 71 | if opt.Registry != nil { 72 | d.Registry = opt.Registry 73 | } 74 | } 75 | 76 | return d 77 | } 78 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/deleteoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // DeleteOptions represents all possible options to the DeleteOne() and DeleteMany() functions. 10 | type DeleteOptions struct { 11 | Collation *Collation // Specifies a collation 12 | } 13 | 14 | // Delete returns a pointer to a new DeleteOptions 15 | func Delete() *DeleteOptions { 16 | return &DeleteOptions{} 17 | } 18 | 19 | // SetCollation specifies a collation 20 | // Valid for servers >= 3.4. 21 | func (do *DeleteOptions) SetCollation(c *Collation) *DeleteOptions { 22 | do.Collation = c 23 | return do 24 | } 25 | 26 | // MergeDeleteOptions combines the argued DeleteOptions into a single DeleteOptions in a last-one-wins fashion 27 | func MergeDeleteOptions(opts ...*DeleteOptions) *DeleteOptions { 28 | dOpts := Delete() 29 | for _, do := range opts { 30 | if do == nil { 31 | continue 32 | } 33 | if do.Collation != nil { 34 | dOpts.Collation = do.Collation 35 | } 36 | } 37 | 38 | return dOpts 39 | } 40 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/distinctoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import "time" 10 | 11 | // DistinctOptions represents all possible options to the Distinct() function. 12 | type DistinctOptions struct { 13 | Collation *Collation // Specifies a collation 14 | MaxTime *time.Duration // The maximum amount of time to allow the operation to run 15 | } 16 | 17 | // Distinct returns a pointer to a new DistinctOptions 18 | func Distinct() *DistinctOptions { 19 | return &DistinctOptions{} 20 | } 21 | 22 | // SetCollation specifies a collation 23 | // Valid for server versions >= 3.4 24 | func (do *DistinctOptions) SetCollation(c *Collation) *DistinctOptions { 25 | do.Collation = c 26 | return do 27 | } 28 | 29 | // SetMaxTime specifies the maximum amount of time to allow the operation to run 30 | func (do *DistinctOptions) SetMaxTime(d time.Duration) *DistinctOptions { 31 | do.MaxTime = &d 32 | return do 33 | } 34 | 35 | // MergeDistinctOptions combines the argued DistinctOptions into a single DistinctOptions in a last-one-wins fashion 36 | func MergeDistinctOptions(opts ...*DistinctOptions) *DistinctOptions { 37 | distinctOpts := Distinct() 38 | for _, do := range opts { 39 | if do == nil { 40 | continue 41 | } 42 | if do.Collation != nil { 43 | distinctOpts.Collation = do.Collation 44 | } 45 | if do.MaxTime != nil { 46 | distinctOpts.MaxTime = do.MaxTime 47 | } 48 | } 49 | 50 | return distinctOpts 51 | } 52 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/estimatedcountoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import "time" 10 | 11 | // EstimatedDocumentCountOptions represents all possible options to the EstimatedDocumentCount() function. 12 | type EstimatedDocumentCountOptions struct { 13 | MaxTime *time.Duration // The maximum amount of time to allow the operation to run 14 | } 15 | 16 | // EstimatedDocumentCount returns a pointer to a new EstimatedDocumentCountOptions 17 | func EstimatedDocumentCount() *EstimatedDocumentCountOptions { 18 | return &EstimatedDocumentCountOptions{} 19 | } 20 | 21 | // SetMaxTime specifies the maximum amount of time to allow the operation to run 22 | func (eco *EstimatedDocumentCountOptions) SetMaxTime(d time.Duration) *EstimatedDocumentCountOptions { 23 | eco.MaxTime = &d 24 | return eco 25 | } 26 | 27 | // MergeEstimatedDocumentCountOptions combines the given *EstimatedDocumentCountOptions into a single 28 | // *EstimatedDocumentCountOptions in a last one wins fashion. 29 | func MergeEstimatedDocumentCountOptions(opts ...*EstimatedDocumentCountOptions) *EstimatedDocumentCountOptions { 30 | e := EstimatedDocumentCount() 31 | for _, opt := range opts { 32 | if opt == nil { 33 | continue 34 | } 35 | 36 | if opt.MaxTime != nil { 37 | e.MaxTime = opt.MaxTime 38 | } 39 | } 40 | 41 | return e 42 | } 43 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/listcollectionsoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // ListCollectionsOptions represents all possible options for a listCollections command. 10 | type ListCollectionsOptions struct { 11 | NameOnly *bool // If true, only the collection names will be returned. 12 | } 13 | 14 | // ListCollections creates a new *ListCollectionsOptions 15 | func ListCollections() *ListCollectionsOptions { 16 | return &ListCollectionsOptions{} 17 | } 18 | 19 | // SetNameOnly specifies whether to return only the collection names. 20 | func (lc *ListCollectionsOptions) SetNameOnly(b bool) *ListCollectionsOptions { 21 | lc.NameOnly = &b 22 | return lc 23 | } 24 | 25 | // MergeListCollectionsOptions combines the given *ListCollectionsOptions into a single *ListCollectionsOptions in a 26 | // last one wins fashion. 27 | func MergeListCollectionsOptions(opts ...*ListCollectionsOptions) *ListCollectionsOptions { 28 | lc := ListCollections() 29 | for _, opt := range opts { 30 | if opt == nil { 31 | continue 32 | } 33 | if opt.NameOnly != nil { 34 | lc.NameOnly = opt.NameOnly 35 | } 36 | } 37 | 38 | return lc 39 | } 40 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/listdatabasesoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // ListDatabasesOptions represents all possible options for a listDatabases command. 10 | type ListDatabasesOptions struct { 11 | NameOnly *bool // If true, only the database names will be returned. 12 | } 13 | 14 | // ListDatabases creates a new *ListDatabasesOptions 15 | func ListDatabases() *ListDatabasesOptions { 16 | return &ListDatabasesOptions{} 17 | } 18 | 19 | // SetNameOnly specifies whether to return only the database names. 20 | func (ld *ListDatabasesOptions) SetNameOnly(b bool) *ListDatabasesOptions { 21 | ld.NameOnly = &b 22 | return ld 23 | } 24 | 25 | // MergeListDatabasesOptions combines the given *ListDatabasesOptions into a single *ListDatabasesOptions in a last one 26 | // wins fashion. 27 | func MergeListDatabasesOptions(opts ...*ListDatabasesOptions) *ListDatabasesOptions { 28 | ld := ListDatabases() 29 | for _, opt := range opts { 30 | if opts == nil { 31 | continue 32 | } 33 | if opt.NameOnly != nil { 34 | ld.NameOnly = opt.NameOnly 35 | } 36 | } 37 | 38 | return ld 39 | } 40 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/replaceoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // ReplaceOptions represents all possible options to the ReplaceOne() function. 10 | type ReplaceOptions struct { 11 | BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation 12 | Collation *Collation // Specifies a collation 13 | Upsert *bool // When true, creates a new document if no document matches the query 14 | } 15 | 16 | // Replace returns a pointer to a new ReplaceOptions 17 | func Replace() *ReplaceOptions { 18 | return &ReplaceOptions{} 19 | } 20 | 21 | // SetBypassDocumentValidation allows the write to opt-out of document level validation. 22 | // Valid for server versions >= 3.2. For servers < 3.2, this option is ignored. 23 | func (ro *ReplaceOptions) SetBypassDocumentValidation(b bool) *ReplaceOptions { 24 | ro.BypassDocumentValidation = &b 25 | return ro 26 | } 27 | 28 | // SetCollation specifies a collation. 29 | // Valid for servers >= 3.4 30 | func (ro *ReplaceOptions) SetCollation(c *Collation) *ReplaceOptions { 31 | ro.Collation = c 32 | return ro 33 | } 34 | 35 | // SetUpsert allows the creation of a new document if not document matches the query 36 | func (ro *ReplaceOptions) SetUpsert(b bool) *ReplaceOptions { 37 | ro.Upsert = &b 38 | return ro 39 | } 40 | 41 | // MergeReplaceOptions combines the argued ReplaceOptions into a single ReplaceOptions in a last-one-wins fashion 42 | func MergeReplaceOptions(opts ...*ReplaceOptions) *ReplaceOptions { 43 | rOpts := Replace() 44 | for _, ro := range opts { 45 | if ro == nil { 46 | continue 47 | } 48 | if ro.BypassDocumentValidation != nil { 49 | rOpts.BypassDocumentValidation = ro.BypassDocumentValidation 50 | } 51 | if ro.Collation != nil { 52 | rOpts.Collation = ro.Collation 53 | } 54 | if ro.Upsert != nil { 55 | rOpts.Upsert = ro.Upsert 56 | } 57 | } 58 | 59 | return rOpts 60 | } 61 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/runcmdoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import "go.mongodb.org/mongo-driver/mongo/readpref" 10 | 11 | // RunCmdOptions represents all possible options for a runCommand operation. 12 | type RunCmdOptions struct { 13 | ReadPreference *readpref.ReadPref // The read preference for the operation. 14 | } 15 | 16 | // RunCmd creates a new *RunCmdOptions 17 | func RunCmd() *RunCmdOptions { 18 | return &RunCmdOptions{} 19 | } 20 | 21 | // SetReadPreference sets the read preference for the operation. 22 | func (rc *RunCmdOptions) SetReadPreference(rp *readpref.ReadPref) *RunCmdOptions { 23 | rc.ReadPreference = rp 24 | return rc 25 | } 26 | 27 | // MergeRunCmdOptions combines the given *RunCmdOptions into one *RunCmdOptions in a last one wins fashion. 28 | func MergeRunCmdOptions(opts ...*RunCmdOptions) *RunCmdOptions { 29 | rc := RunCmd() 30 | for _, opt := range opts { 31 | if opt == nil { 32 | continue 33 | } 34 | if opt.ReadPreference != nil { 35 | rc.ReadPreference = opt.ReadPreference 36 | } 37 | } 38 | 39 | return rc 40 | } 41 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/transactionoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | import ( 10 | "time" 11 | 12 | "go.mongodb.org/mongo-driver/mongo/readconcern" 13 | "go.mongodb.org/mongo-driver/mongo/readpref" 14 | "go.mongodb.org/mongo-driver/mongo/writeconcern" 15 | ) 16 | 17 | // TransactionOptions represents all possible options for starting a transaction. 18 | type TransactionOptions struct { 19 | ReadConcern *readconcern.ReadConcern // The read concern for the transaction. Defaults to the session's read concern. 20 | ReadPreference *readpref.ReadPref // The read preference for the transaction. Defaults to the session's read preference. 21 | WriteConcern *writeconcern.WriteConcern // The write concern for the transaction. Defaults to the session's write concern. 22 | MaxCommitTime *time.Duration // The maximum amount of time to allow a single commitTransaction command to run. 23 | } 24 | 25 | // Transaction creates a new *TransactionOptions 26 | func Transaction() *TransactionOptions { 27 | return &TransactionOptions{} 28 | } 29 | 30 | // SetReadConcern sets the read concern for the transaction. 31 | func (t *TransactionOptions) SetReadConcern(rc *readconcern.ReadConcern) *TransactionOptions { 32 | t.ReadConcern = rc 33 | return t 34 | } 35 | 36 | // SetReadPreference sets the read preference for the transaction. 37 | func (t *TransactionOptions) SetReadPreference(rp *readpref.ReadPref) *TransactionOptions { 38 | t.ReadPreference = rp 39 | return t 40 | } 41 | 42 | // SetWriteConcern sets the write concern for the transaction. 43 | func (t *TransactionOptions) SetWriteConcern(wc *writeconcern.WriteConcern) *TransactionOptions { 44 | t.WriteConcern = wc 45 | return t 46 | } 47 | 48 | // SetMaxCommitTime sets the max commit time for the transaction. 49 | func (t *TransactionOptions) SetMaxCommitTime(mct *time.Duration) *TransactionOptions { 50 | t.MaxCommitTime = mct 51 | return t 52 | } 53 | 54 | // MergeTransactionOptions combines the given *TransactionOptions into a single *TransactionOptions in a last one wins 55 | // fashion. 56 | func MergeTransactionOptions(opts ...*TransactionOptions) *TransactionOptions { 57 | t := Transaction() 58 | for _, opt := range opts { 59 | if opt == nil { 60 | continue 61 | } 62 | if opt.ReadConcern != nil { 63 | t.ReadConcern = opt.ReadConcern 64 | } 65 | if opt.ReadPreference != nil { 66 | t.ReadPreference = opt.ReadPreference 67 | } 68 | if opt.WriteConcern != nil { 69 | t.WriteConcern = opt.WriteConcern 70 | } 71 | if opt.MaxCommitTime != nil { 72 | t.MaxCommitTime = opt.MaxCommitTime 73 | } 74 | } 75 | 76 | return t 77 | } 78 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/options/updateoptions.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package options 8 | 9 | // UpdateOptions represents all possible options to the UpdateOne() and UpdateMany() functions. 10 | type UpdateOptions struct { 11 | ArrayFilters *ArrayFilters // A set of filters specifying to which array elements an update should apply 12 | BypassDocumentValidation *bool // If true, allows the write to opt-out of document level validation 13 | Collation *Collation // Specifies a collation 14 | Upsert *bool // When true, creates a new document if no document matches the query 15 | } 16 | 17 | // Update returns a pointer to a new UpdateOptions 18 | func Update() *UpdateOptions { 19 | return &UpdateOptions{} 20 | } 21 | 22 | // SetArrayFilters specifies a set of filters specifying to which array elements an update should apply 23 | // Valid for server versions >= 3.6. 24 | func (uo *UpdateOptions) SetArrayFilters(af ArrayFilters) *UpdateOptions { 25 | uo.ArrayFilters = &af 26 | return uo 27 | } 28 | 29 | // SetBypassDocumentValidation allows the write to opt-out of document level validation. 30 | // Valid for server versions >= 3.2. For servers < 3.2, this option is ignored. 31 | func (uo *UpdateOptions) SetBypassDocumentValidation(b bool) *UpdateOptions { 32 | uo.BypassDocumentValidation = &b 33 | return uo 34 | } 35 | 36 | // SetCollation specifies a collation. 37 | // Valid for server versions >= 3.4. 38 | func (uo *UpdateOptions) SetCollation(c *Collation) *UpdateOptions { 39 | uo.Collation = c 40 | return uo 41 | } 42 | 43 | // SetUpsert allows the creation of a new document if not document matches the query 44 | func (uo *UpdateOptions) SetUpsert(b bool) *UpdateOptions { 45 | uo.Upsert = &b 46 | return uo 47 | } 48 | 49 | // MergeUpdateOptions combines the argued UpdateOptions into a single UpdateOptions in a last-one-wins fashion 50 | func MergeUpdateOptions(opts ...*UpdateOptions) *UpdateOptions { 51 | uOpts := Update() 52 | for _, uo := range opts { 53 | if uo == nil { 54 | continue 55 | } 56 | if uo.ArrayFilters != nil { 57 | uOpts.ArrayFilters = uo.ArrayFilters 58 | } 59 | if uo.BypassDocumentValidation != nil { 60 | uOpts.BypassDocumentValidation = uo.BypassDocumentValidation 61 | } 62 | if uo.Collation != nil { 63 | uOpts.Collation = uo.Collation 64 | } 65 | if uo.Upsert != nil { 66 | uOpts.Upsert = uo.Upsert 67 | } 68 | } 69 | 70 | return uOpts 71 | } 72 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/readconcern/readconcern.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package readconcern // import "go.mongodb.org/mongo-driver/mongo/readconcern" 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/bson/bsontype" 11 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 12 | ) 13 | 14 | // ReadConcern for replica sets and replica set shards determines which data to return from a query. 15 | type ReadConcern struct { 16 | level string 17 | } 18 | 19 | // Option is an option to provide when creating a ReadConcern. 20 | type Option func(concern *ReadConcern) 21 | 22 | // Level creates an option that sets the level of a ReadConcern. 23 | func Level(level string) Option { 24 | return func(concern *ReadConcern) { 25 | concern.level = level 26 | } 27 | } 28 | 29 | // Local specifies that the query should return the instance’s most recent data. 30 | func Local() *ReadConcern { 31 | return New(Level("local")) 32 | } 33 | 34 | // Majority specifies that the query should return the instance’s most recent data acknowledged as 35 | // having been written to a majority of members in the replica set. 36 | func Majority() *ReadConcern { 37 | return New(Level("majority")) 38 | } 39 | 40 | // Linearizable specifies that the query should return data that reflects all successful writes 41 | // issued with a write concern of "majority" and acknowledged prior to the start of the read operation. 42 | func Linearizable() *ReadConcern { 43 | return New(Level("linearizable")) 44 | } 45 | 46 | // Available specifies that the query should return data from the instance with no guarantee 47 | // that the data has been written to a majority of the replica set members (i.e. may be rolled back). 48 | func Available() *ReadConcern { 49 | return New(Level("available")) 50 | } 51 | 52 | // Snapshot is only available for operations within multi-document transactions. 53 | func Snapshot() *ReadConcern { 54 | return New(Level("snapshot")) 55 | } 56 | 57 | // New constructs a new read concern from the given string. 58 | func New(options ...Option) *ReadConcern { 59 | concern := &ReadConcern{} 60 | 61 | for _, option := range options { 62 | option(concern) 63 | } 64 | 65 | return concern 66 | } 67 | 68 | // MarshalBSONValue implements the bson.ValueMarshaler interface. 69 | func (rc *ReadConcern) MarshalBSONValue() (bsontype.Type, []byte, error) { 70 | var elems []byte 71 | 72 | if len(rc.level) > 0 { 73 | elems = bsoncore.AppendStringElement(elems, "level", rc.level) 74 | } 75 | 76 | return bsontype.EmbeddedDocument, bsoncore.BuildDocument(nil, elems), nil 77 | } 78 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/readpref/mode.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package readpref 8 | 9 | import ( 10 | "fmt" 11 | "strings" 12 | ) 13 | 14 | // Mode indicates the user's preference on reads. 15 | type Mode uint8 16 | 17 | // Mode constants 18 | const ( 19 | _ Mode = iota 20 | // PrimaryMode indicates that only a primary is 21 | // considered for reading. This is the default 22 | // mode. 23 | PrimaryMode 24 | // PrimaryPreferredMode indicates that if a primary 25 | // is available, use it; otherwise, eligible 26 | // secondaries will be considered. 27 | PrimaryPreferredMode 28 | // SecondaryMode indicates that only secondaries 29 | // should be considered. 30 | SecondaryMode 31 | // SecondaryPreferredMode indicates that only secondaries 32 | // should be considered when one is available. If none 33 | // are available, then a primary will be considered. 34 | SecondaryPreferredMode 35 | // NearestMode indicates that all primaries and secondaries 36 | // will be considered. 37 | NearestMode 38 | ) 39 | 40 | // ModeFromString returns a mode corresponding to 41 | // mode. 42 | func ModeFromString(mode string) (Mode, error) { 43 | switch strings.ToLower(mode) { 44 | case "primary": 45 | return PrimaryMode, nil 46 | case "primarypreferred": 47 | return PrimaryPreferredMode, nil 48 | case "secondary": 49 | return SecondaryMode, nil 50 | case "secondarypreferred": 51 | return SecondaryPreferredMode, nil 52 | case "nearest": 53 | return NearestMode, nil 54 | } 55 | return Mode(0), fmt.Errorf("unknown read preference %v", mode) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/readpref/options.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package readpref 8 | 9 | import ( 10 | "errors" 11 | "time" 12 | 13 | "go.mongodb.org/mongo-driver/tag" 14 | ) 15 | 16 | // ErrInvalidTagSet indicates that an invalid set of tags was specified. 17 | var ErrInvalidTagSet = errors.New("an even number of tags must be specified") 18 | 19 | // Option configures a read preference 20 | type Option func(*ReadPref) error 21 | 22 | // WithMaxStaleness sets the maximum staleness a 23 | // server is allowed. 24 | func WithMaxStaleness(ms time.Duration) Option { 25 | return func(rp *ReadPref) error { 26 | rp.maxStaleness = ms 27 | rp.maxStalenessSet = true 28 | return nil 29 | } 30 | } 31 | 32 | // WithTags sets a single tag set used to match 33 | // a server. The last call to WithTags or WithTagSets 34 | // overrides all previous calls to either method. 35 | func WithTags(tags ...string) Option { 36 | return func(rp *ReadPref) error { 37 | length := len(tags) 38 | if length < 2 || length%2 != 0 { 39 | return ErrInvalidTagSet 40 | } 41 | 42 | tagset := make(tag.Set, 0, length/2) 43 | 44 | for i := 1; i < length; i += 2 { 45 | tagset = append(tagset, tag.Tag{Name: tags[i-1], Value: tags[i]}) 46 | } 47 | 48 | return WithTagSets(tagset)(rp) 49 | } 50 | } 51 | 52 | // WithTagSets sets the tag sets used to match 53 | // a server. The last call to WithTags or WithTagSets 54 | // overrides all previous calls to either method. 55 | func WithTagSets(tagSets ...tag.Set) Option { 56 | return func(rp *ReadPref) error { 57 | rp.tagSets = tagSets 58 | return nil 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/single_result.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package mongo 8 | 9 | import ( 10 | "context" 11 | "errors" 12 | 13 | "go.mongodb.org/mongo-driver/bson" 14 | "go.mongodb.org/mongo-driver/bson/bsoncodec" 15 | ) 16 | 17 | // ErrNoDocuments is returned by Decode when an operation that returns a 18 | // SingleResult doesn't return any documents. 19 | var ErrNoDocuments = errors.New("mongo: no documents in result") 20 | 21 | // SingleResult represents a single document returned from an operation. If 22 | // the operation returned an error, the Err method of SingleResult will 23 | // return that error. 24 | type SingleResult struct { 25 | err error 26 | cur *Cursor 27 | rdr bson.Raw 28 | reg *bsoncodec.Registry 29 | } 30 | 31 | // Decode will attempt to decode the first document into v. If there was an 32 | // error from the operation that created this SingleResult then the error 33 | // will be returned. If there were no returned documents, ErrNoDocuments is 34 | // returned. If v is nil or is a typed nil, an error will be returned. 35 | func (sr *SingleResult) Decode(v interface{}) error { 36 | if sr.err != nil { 37 | return sr.err 38 | } 39 | if sr.reg == nil { 40 | return bson.ErrNilRegistry 41 | } 42 | 43 | if sr.err = sr.setRdrContents(); sr.err != nil { 44 | return sr.err 45 | } 46 | return bson.UnmarshalWithRegistry(sr.reg, sr.rdr, v) 47 | } 48 | 49 | // DecodeBytes will return a copy of the document as a bson.Raw. If there was an 50 | // error from the operation that created this SingleResult then the error 51 | // will be returned along with the result. If there were no returned documents, ErrNoDocuments is 52 | // returned. 53 | func (sr *SingleResult) DecodeBytes() (bson.Raw, error) { 54 | if sr.err != nil { 55 | return sr.rdr, sr.err 56 | } 57 | 58 | if sr.err = sr.setRdrContents(); sr.err != nil { 59 | return nil, sr.err 60 | } 61 | return sr.rdr, nil 62 | } 63 | 64 | // setRdrContents will set the contents of rdr by iterating the underlying cursor if necessary. 65 | func (sr *SingleResult) setRdrContents() error { 66 | switch { 67 | case sr.err != nil: 68 | return sr.err 69 | case sr.rdr != nil: 70 | return nil 71 | case sr.cur != nil: 72 | defer sr.cur.Close(context.TODO()) 73 | if !sr.cur.Next(context.TODO()) { 74 | if err := sr.cur.Err(); err != nil { 75 | return err 76 | } 77 | 78 | return ErrNoDocuments 79 | } 80 | sr.rdr = sr.cur.Current 81 | return nil 82 | } 83 | 84 | return ErrNoDocuments 85 | } 86 | 87 | // Err will return the error from the operation that created this SingleResult. 88 | // If there was no error, nil is returned. 89 | func (sr *SingleResult) Err() error { 90 | sr.err = sr.setRdrContents() 91 | 92 | return sr.err 93 | } 94 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/mongo/util.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package mongo 8 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/tag/tag.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package tag // import "go.mongodb.org/mongo-driver/tag" 8 | 9 | // Tag is a name/vlaue pair. 10 | type Tag struct { 11 | Name string 12 | Value string 13 | } 14 | 15 | // NewTagSetFromMap creates a new tag set from a map. 16 | func NewTagSetFromMap(m map[string]string) Set { 17 | var set Set 18 | for k, v := range m { 19 | set = append(set, Tag{Name: k, Value: v}) 20 | } 21 | 22 | return set 23 | } 24 | 25 | // NewTagSetsFromMaps creates new tag sets from maps. 26 | func NewTagSetsFromMaps(maps []map[string]string) []Set { 27 | sets := make([]Set, 0, len(maps)) 28 | for _, m := range maps { 29 | sets = append(sets, NewTagSetFromMap(m)) 30 | } 31 | return sets 32 | } 33 | 34 | // Set is an ordered list of Tags. 35 | type Set []Tag 36 | 37 | // Contains indicates whether the name/value pair exists in the tagset. 38 | func (ts Set) Contains(name, value string) bool { 39 | for _, t := range ts { 40 | if t.Name == name && t.Value == value { 41 | return true 42 | } 43 | } 44 | 45 | return false 46 | } 47 | 48 | // ContainsAll indicates whether all the name/value pairs exist in the tagset. 49 | func (ts Set) ContainsAll(other []Tag) bool { 50 | for _, ot := range other { 51 | if !ts.Contains(ot.Name, ot.Value) { 52 | return false 53 | } 54 | } 55 | 56 | return true 57 | } 58 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/version/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package version // import "go.mongodb.org/mongo-driver/version" 8 | 9 | // Driver is the current version of the driver. 10 | var Driver = "v1.1.3" 11 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/bsonx/array.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonx // import "go.mongodb.org/mongo-driver/x/bsonx" 8 | 9 | import ( 10 | "bytes" 11 | "errors" 12 | "fmt" 13 | "strconv" 14 | 15 | "go.mongodb.org/mongo-driver/bson/bsontype" 16 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 17 | ) 18 | 19 | // ErrNilArray indicates that an operation was attempted on a nil *Array. 20 | var ErrNilArray = errors.New("array is nil") 21 | 22 | // Arr represents an array in BSON. 23 | type Arr []Val 24 | 25 | // String implements the fmt.Stringer interface. 26 | func (a Arr) String() string { 27 | var buf bytes.Buffer 28 | buf.Write([]byte("bson.Array[")) 29 | for idx, val := range a { 30 | if idx > 0 { 31 | buf.Write([]byte(", ")) 32 | } 33 | fmt.Fprintf(&buf, "%s", val) 34 | } 35 | buf.WriteByte(']') 36 | 37 | return buf.String() 38 | } 39 | 40 | // MarshalBSONValue implements the bsoncodec.ValueMarshaler interface. 41 | func (a Arr) MarshalBSONValue() (bsontype.Type, []byte, error) { 42 | if a == nil { 43 | // TODO: Should we do this? 44 | return bsontype.Null, nil, nil 45 | } 46 | 47 | idx, dst := bsoncore.ReserveLength(nil) 48 | for idx, value := range a { 49 | t, data, _ := value.MarshalBSONValue() // marshalBSONValue never returns an error. 50 | dst = append(dst, byte(t)) 51 | dst = append(dst, strconv.Itoa(idx)...) 52 | dst = append(dst, 0x00) 53 | dst = append(dst, data...) 54 | } 55 | dst = append(dst, 0x00) 56 | dst = bsoncore.UpdateLength(dst, idx, int32(len(dst[idx:]))) 57 | return bsontype.Array, dst, nil 58 | } 59 | 60 | // UnmarshalBSONValue implements the bsoncodec.ValueUnmarshaler interface. 61 | func (a *Arr) UnmarshalBSONValue(t bsontype.Type, data []byte) error { 62 | if a == nil { 63 | return ErrNilArray 64 | } 65 | *a = (*a)[:0] 66 | 67 | elements, err := bsoncore.Document(data).Elements() 68 | if err != nil { 69 | return err 70 | } 71 | 72 | for _, elem := range elements { 73 | var val Val 74 | rawval := elem.Value() 75 | err = val.UnmarshalBSONValue(rawval.Type, rawval.Data) 76 | if err != nil { 77 | return err 78 | } 79 | *a = append(*a, val) 80 | } 81 | return nil 82 | } 83 | 84 | // Equal compares this document to another, returning true if they are equal. 85 | func (a Arr) Equal(a2 Arr) bool { 86 | if len(a) != len(a2) { 87 | return false 88 | } 89 | for idx := range a { 90 | if !a[idx].Equal(a2[idx]) { 91 | return false 92 | } 93 | } 94 | return true 95 | } 96 | 97 | func (Arr) idoc() {} 98 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/bsonx/element.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package bsonx 8 | 9 | import ( 10 | "fmt" 11 | 12 | "go.mongodb.org/mongo-driver/bson/bsontype" 13 | ) 14 | 15 | const validateMaxDepthDefault = 2048 16 | 17 | // ElementTypeError specifies that a method to obtain a BSON value an incorrect type was called on a bson.Value. 18 | // 19 | // TODO: rename this ValueTypeError. 20 | type ElementTypeError struct { 21 | Method string 22 | Type bsontype.Type 23 | } 24 | 25 | // Error implements the error interface. 26 | func (ete ElementTypeError) Error() string { 27 | return "Call of " + ete.Method + " on " + ete.Type.String() + " type" 28 | } 29 | 30 | // Elem represents a BSON element. 31 | // 32 | // NOTE: Element cannot be the value of a map nor a property of a struct without special handling. 33 | // The default encoders and decoders will not process Element correctly. To do so would require 34 | // information loss since an Element contains a key, but the keys used when encoding a struct are 35 | // the struct field names. Instead of using an Element, use a Value as a value in a map or a 36 | // property of a struct. 37 | type Elem struct { 38 | Key string 39 | Value Val 40 | } 41 | 42 | // Equal compares e and e2 and returns true if they are equal. 43 | func (e Elem) Equal(e2 Elem) bool { 44 | if e.Key != e2.Key { 45 | return false 46 | } 47 | return e.Value.Equal(e2.Value) 48 | } 49 | 50 | func (e Elem) String() string { 51 | // TODO(GODRIVER-612): When bsoncore has appenders for extended JSON use that here. 52 | return fmt.Sprintf(`bson.Element{"%s": %v}`, e.Key, e.Value) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/bsonx/registry.go: -------------------------------------------------------------------------------- 1 | package bsonx 2 | 3 | import ( 4 | "go.mongodb.org/mongo-driver/bson" 5 | "go.mongodb.org/mongo-driver/bson/bsoncodec" 6 | ) 7 | 8 | // DefaultRegistry is the default bsoncodec.Registry. It contains the default codecs and the 9 | // primitive codecs. 10 | var DefaultRegistry = NewRegistryBuilder().Build() 11 | 12 | // NewRegistryBuilder creates a new RegistryBuilder configured with the default encoders and 13 | // deocders from the bsoncodec.DefaultValueEncoders and bsoncodec.DefaultValueDecoders types and the 14 | // PrimitiveCodecs type in this package. 15 | func NewRegistryBuilder() *bsoncodec.RegistryBuilder { 16 | rb := bsoncodec.NewRegistryBuilder() 17 | bsoncodec.DefaultValueEncoders{}.RegisterDefaultEncoders(rb) 18 | bsoncodec.DefaultValueDecoders{}.RegisterDefaultDecoders(rb) 19 | bson.PrimitiveCodecs{}.RegisterPrimitiveCodecs(rb) 20 | primitiveCodecs.RegisterPrimitiveCodecs(rb) 21 | return rb 22 | } 23 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/DESIGN.md: -------------------------------------------------------------------------------- 1 | # Driver Library Design 2 | This document outlines the design for this package. 3 | 4 | ## Deployment, Server, and Connection 5 | Acquiring a `Connection` from a `Server` selected from a `Deployment` enables sending and receiving 6 | wire messages. A `Deployment` represents an set of MongoDB servers and a `Server` represents a 7 | member of that set. These three types form the operation execution stack. 8 | 9 | ### Compression 10 | Compression is handled by Connection type while uncompression is handled automatically by the 11 | Operation type. This is done because the compressor to use for compressing a wire message is 12 | chosen by the connection during handshake, while uncompression can be performed without this 13 | information. This does make the design of compression non-symmetric, but it makes the design simpler 14 | to implement and more consistent. 15 | 16 | ## Operation 17 | The `Operation` type handles executing a series of commands using a `Deployment`. For most uses 18 | `Operation` will only execute a single command, but the main use case for a series of commands is 19 | batch split write commands, such as insert. The type itself is heavily documented, so reading the 20 | code and comments together should provide an understanding of how the type works. 21 | 22 | This type is not meant to be used directly by callers. Instead an wrapping type should be defined 23 | using the IDL and an implementation generated using `operationgen`. 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/address/addr.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package address // import "go.mongodb.org/mongo-driver/x/mongo/driver/address" 8 | 9 | import ( 10 | "net" 11 | "strings" 12 | ) 13 | 14 | const defaultPort = "27017" 15 | 16 | // Address is a network address. It can either be an IP address or a DNS name. 17 | type Address string 18 | 19 | // Network is the network protocol for this address. In most cases this will be 20 | // "tcp" or "unix". 21 | func (a Address) Network() string { 22 | if strings.HasSuffix(string(a), "sock") { 23 | return "unix" 24 | } 25 | return "tcp" 26 | } 27 | 28 | // String is the canonical version of this address, e.g. localhost:27017, 29 | // 1.2.3.4:27017, example.com:27017. 30 | func (a Address) String() string { 31 | // TODO: unicode case folding? 32 | s := strings.ToLower(string(a)) 33 | if len(s) == 0 { 34 | return "" 35 | } 36 | if a.Network() != "unix" { 37 | _, _, err := net.SplitHostPort(s) 38 | if err != nil && strings.Contains(err.Error(), "missing port in address") { 39 | s += ":" + defaultPort 40 | } 41 | } 42 | 43 | return s 44 | } 45 | 46 | // Canonicalize creates a canonicalized address. 47 | func (a Address) Canonicalize() Address { 48 | return Address(a.String()) 49 | } 50 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/cred.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | // Cred is a user's credential. 10 | type Cred struct { 11 | Source string 12 | Username string 13 | Password string 14 | PasswordSet bool 15 | Props map[string]string 16 | } 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/default.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | import ( 10 | "context" 11 | 12 | "go.mongodb.org/mongo-driver/x/mongo/driver" 13 | "go.mongodb.org/mongo-driver/x/mongo/driver/description" 14 | ) 15 | 16 | func newDefaultAuthenticator(cred *Cred) (Authenticator, error) { 17 | return &DefaultAuthenticator{ 18 | Cred: cred, 19 | }, nil 20 | } 21 | 22 | // DefaultAuthenticator uses SCRAM-SHA-1 or MONGODB-CR depending 23 | // on the server version. 24 | type DefaultAuthenticator struct { 25 | Cred *Cred 26 | } 27 | 28 | // Auth authenticates the connection. 29 | func (a *DefaultAuthenticator) Auth(ctx context.Context, desc description.Server, conn driver.Connection) error { 30 | var actual Authenticator 31 | var err error 32 | 33 | switch chooseAuthMechanism(desc) { 34 | case SCRAMSHA256: 35 | actual, err = newScramSHA256Authenticator(a.Cred) 36 | case SCRAMSHA1: 37 | actual, err = newScramSHA1Authenticator(a.Cred) 38 | default: 39 | actual, err = newMongoDBCRAuthenticator(a.Cred) 40 | } 41 | 42 | if err != nil { 43 | return newAuthError("error creating authenticator", err) 44 | } 45 | 46 | return actual.Auth(ctx, desc, conn) 47 | } 48 | 49 | // If a server provides a list of supported mechanisms, we choose 50 | // SCRAM-SHA-256 if it exists or else MUST use SCRAM-SHA-1. 51 | // Otherwise, we decide based on what is supported. 52 | func chooseAuthMechanism(desc description.Server) string { 53 | if desc.SaslSupportedMechs != nil { 54 | for _, v := range desc.SaslSupportedMechs { 55 | if v == SCRAMSHA256 { 56 | return v 57 | } 58 | } 59 | return SCRAMSHA1 60 | } 61 | 62 | if err := description.ScramSHA1Supported(desc.WireVersion); err == nil { 63 | return SCRAMSHA1 64 | } 65 | 66 | return MONGODBCR 67 | } 68 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | // Package auth is not for public use. 8 | // 9 | // The API for packages in the 'private' directory have no stability 10 | // guarantee. 11 | // 12 | // The packages within the 'private' directory would normally be put into an 13 | // 'internal' directory to prohibit their use outside the 'mongo' directory. 14 | // However, some MongoDB tools require very low-level access to the building 15 | // blocks of a driver, so we have placed them under 'private' to allow these 16 | // packages to be imported by projects that need them. 17 | // 18 | // These package APIs may be modified in backwards-incompatible ways at any 19 | // time. 20 | // 21 | // You are strongly discouraged from directly using any packages 22 | // under 'private'. 23 | package auth 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | //+build gssapi 8 | //+build windows linux darwin 9 | 10 | package auth 11 | 12 | import ( 13 | "context" 14 | "fmt" 15 | "net" 16 | 17 | "go.mongodb.org/mongo-driver/x/mongo/driver" 18 | "go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi" 19 | "go.mongodb.org/mongo-driver/x/mongo/driver/description" 20 | ) 21 | 22 | // GSSAPI is the mechanism name for GSSAPI. 23 | const GSSAPI = "GSSAPI" 24 | 25 | func newGSSAPIAuthenticator(cred *Cred) (Authenticator, error) { 26 | if cred.Source != "" && cred.Source != "$external" { 27 | return nil, newAuthError("GSSAPI source must be empty or $external", nil) 28 | } 29 | 30 | return &GSSAPIAuthenticator{ 31 | Username: cred.Username, 32 | Password: cred.Password, 33 | PasswordSet: cred.PasswordSet, 34 | Props: cred.Props, 35 | }, nil 36 | } 37 | 38 | // GSSAPIAuthenticator uses the GSSAPI algorithm over SASL to authenticate a connection. 39 | type GSSAPIAuthenticator struct { 40 | Username string 41 | Password string 42 | PasswordSet bool 43 | Props map[string]string 44 | } 45 | 46 | // Auth authenticates the connection. 47 | func (a *GSSAPIAuthenticator) Auth(ctx context.Context, desc description.Server, conn driver.Connection) error { 48 | target := desc.Addr.String() 49 | hostname, _, err := net.SplitHostPort(target) 50 | if err != nil { 51 | return newAuthError(fmt.Sprintf("invalid endpoint (%s) specified: %s", target, err), nil) 52 | } 53 | 54 | client, err := gssapi.New(hostname, a.Username, a.Password, a.PasswordSet, a.Props) 55 | 56 | if err != nil { 57 | return newAuthError("error creating gssapi", err) 58 | } 59 | return ConductSaslConversation(ctx, conn, "$external", client) 60 | } 61 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi_not_enabled.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | //+build !gssapi 8 | 9 | package auth 10 | 11 | // GSSAPI is the mechanism name for GSSAPI. 12 | const GSSAPI = "GSSAPI" 13 | 14 | func newGSSAPIAuthenticator(cred *Cred) (Authenticator, error) { 15 | return nil, newAuthError("GSSAPI support not enabled during build (-tags gssapi)", nil) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/gssapi_not_supported.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | //+build gssapi,!windows,!linux,!darwin 8 | 9 | package auth 10 | 11 | import ( 12 | "fmt" 13 | "runtime" 14 | ) 15 | 16 | // GSSAPI is the mechanism name for GSSAPI. 17 | const GSSAPI = "GSSAPI" 18 | 19 | func newGSSAPIAuthenticator(cred *Cred) (Authenticator, error) { 20 | return nil, newAuthError(fmt.Sprintf("GSSAPI is not supported on %s", runtime.GOOS), nil) 21 | } 22 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/gss_wrapper.h: -------------------------------------------------------------------------------- 1 | //+build gssapi 2 | //+build linux darwin 3 | #ifndef GSS_WRAPPER_H 4 | #define GSS_WRAPPER_H 5 | 6 | #include 7 | #ifdef GOOS_linux 8 | #include 9 | #include 10 | #endif 11 | #ifdef GOOS_darwin 12 | #include 13 | #endif 14 | 15 | #define GSSAPI_OK 0 16 | #define GSSAPI_CONTINUE 1 17 | #define GSSAPI_ERROR 2 18 | 19 | typedef struct { 20 | gss_name_t spn; 21 | gss_cred_id_t cred; 22 | gss_ctx_id_t ctx; 23 | 24 | OM_uint32 maj_stat; 25 | OM_uint32 min_stat; 26 | } gssapi_client_state; 27 | 28 | int gssapi_error_desc( 29 | OM_uint32 maj_stat, 30 | OM_uint32 min_stat, 31 | char **desc 32 | ); 33 | 34 | int gssapi_client_init( 35 | gssapi_client_state *client, 36 | char* spn, 37 | char* username, 38 | char* password 39 | ); 40 | 41 | int gssapi_client_username( 42 | gssapi_client_state *client, 43 | char** username 44 | ); 45 | 46 | int gssapi_client_negotiate( 47 | gssapi_client_state *client, 48 | void* input, 49 | size_t input_length, 50 | void** output, 51 | size_t* output_length 52 | ); 53 | 54 | int gssapi_client_wrap_msg( 55 | gssapi_client_state *client, 56 | void* input, 57 | size_t input_length, 58 | void** output, 59 | size_t* output_length 60 | ); 61 | 62 | int gssapi_client_destroy( 63 | gssapi_client_state *client 64 | ); 65 | 66 | #endif -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/internal/gssapi/sspi_wrapper.h: -------------------------------------------------------------------------------- 1 | //+build gssapi,windows 2 | 3 | #ifndef SSPI_WRAPPER_H 4 | #define SSPI_WRAPPER_H 5 | 6 | #define SECURITY_WIN32 1 /* Required for SSPI */ 7 | 8 | #include 9 | #include 10 | 11 | #define SSPI_OK 0 12 | #define SSPI_CONTINUE 1 13 | #define SSPI_ERROR 2 14 | 15 | typedef struct { 16 | CredHandle cred; 17 | CtxtHandle ctx; 18 | 19 | int has_ctx; 20 | 21 | SECURITY_STATUS status; 22 | } sspi_client_state; 23 | 24 | int sspi_init(); 25 | 26 | int sspi_client_init( 27 | sspi_client_state *client, 28 | char* username, 29 | char* password 30 | ); 31 | 32 | int sspi_client_username( 33 | sspi_client_state *client, 34 | char** username 35 | ); 36 | 37 | int sspi_client_negotiate( 38 | sspi_client_state *client, 39 | char* spn, 40 | PVOID input, 41 | ULONG input_length, 42 | PVOID* output, 43 | ULONG* output_length 44 | ); 45 | 46 | int sspi_client_wrap_msg( 47 | sspi_client_state *client, 48 | PVOID input, 49 | ULONG input_length, 50 | PVOID* output, 51 | ULONG* output_length 52 | ); 53 | 54 | int sspi_client_destroy( 55 | sspi_client_state *client 56 | ); 57 | 58 | #endif -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/plain.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | import ( 10 | "context" 11 | 12 | "go.mongodb.org/mongo-driver/x/mongo/driver" 13 | "go.mongodb.org/mongo-driver/x/mongo/driver/description" 14 | ) 15 | 16 | // PLAIN is the mechanism name for PLAIN. 17 | const PLAIN = "PLAIN" 18 | 19 | func newPlainAuthenticator(cred *Cred) (Authenticator, error) { 20 | return &PlainAuthenticator{ 21 | Username: cred.Username, 22 | Password: cred.Password, 23 | }, nil 24 | } 25 | 26 | // PlainAuthenticator uses the PLAIN algorithm over SASL to authenticate a connection. 27 | type PlainAuthenticator struct { 28 | Username string 29 | Password string 30 | } 31 | 32 | // Auth authenticates the connection. 33 | func (a *PlainAuthenticator) Auth(ctx context.Context, _ description.Server, conn driver.Connection) error { 34 | return ConductSaslConversation(ctx, conn, "$external", &plainSaslClient{ 35 | username: a.Username, 36 | password: a.Password, 37 | }) 38 | } 39 | 40 | type plainSaslClient struct { 41 | username string 42 | password string 43 | } 44 | 45 | func (c *plainSaslClient) Start() (string, []byte, error) { 46 | b := []byte("\x00" + c.username + "\x00" + c.password) 47 | return PLAIN, b, nil 48 | } 49 | 50 | func (c *plainSaslClient) Next(challenge []byte) ([]byte, error) { 51 | return nil, newAuthError("unexpected server challenge", nil) 52 | } 53 | 54 | func (c *plainSaslClient) Completed() bool { 55 | return true 56 | } 57 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/util.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | import ( 10 | "crypto/md5" 11 | "fmt" 12 | "io" 13 | ) 14 | 15 | const defaultAuthDB = "admin" 16 | 17 | func mongoPasswordDigest(username, password string) string { 18 | h := md5.New() 19 | _, _ = io.WriteString(h, username) 20 | _, _ = io.WriteString(h, ":mongo:") 21 | _, _ = io.WriteString(h, password) 22 | return fmt.Sprintf("%x", h.Sum(nil)) 23 | } 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/auth/x509.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package auth 8 | 9 | import ( 10 | "context" 11 | 12 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 13 | "go.mongodb.org/mongo-driver/x/mongo/driver" 14 | "go.mongodb.org/mongo-driver/x/mongo/driver/description" 15 | "go.mongodb.org/mongo-driver/x/mongo/driver/operation" 16 | ) 17 | 18 | // MongoDBX509 is the mechanism name for MongoDBX509. 19 | const MongoDBX509 = "MONGODB-X509" 20 | 21 | func newMongoDBX509Authenticator(cred *Cred) (Authenticator, error) { 22 | return &MongoDBX509Authenticator{User: cred.Username}, nil 23 | } 24 | 25 | // MongoDBX509Authenticator uses X.509 certificates over TLS to authenticate a connection. 26 | type MongoDBX509Authenticator struct { 27 | User string 28 | } 29 | 30 | // Auth implements the Authenticator interface. 31 | func (a *MongoDBX509Authenticator) Auth(ctx context.Context, desc description.Server, conn driver.Connection) error { 32 | requestDoc := bsoncore.AppendInt32Element(nil, "authenticate", 1) 33 | requestDoc = bsoncore.AppendStringElement(requestDoc, "mechanism", MongoDBX509) 34 | 35 | if desc.WireVersion == nil || desc.WireVersion.Max < 5 { 36 | requestDoc = bsoncore.AppendStringElement(requestDoc, "user", a.User) 37 | } 38 | 39 | authCmd := operation. 40 | NewCommand(bsoncore.BuildDocument(nil, requestDoc)). 41 | Database("$external"). 42 | Deployment(driver.SingleConnectionDeployment{conn}) 43 | err := authCmd.Execute(ctx) 44 | if err != nil { 45 | return newAuthError("round trip error", err) 46 | } 47 | 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/batches.go: -------------------------------------------------------------------------------- 1 | package driver 2 | 3 | import ( 4 | "errors" 5 | 6 | "go.mongodb.org/mongo-driver/x/bsonx/bsoncore" 7 | ) 8 | 9 | // this is the amount of reserved buffer space in a message that the 10 | // driver reserves for command overhead. 11 | const reservedCommandBufferBytes = 16 * 10 * 10 * 10 12 | 13 | // ErrDocumentTooLarge occurs when a document that is larger than the maximum size accepted by a 14 | // server is passed to an insert command. 15 | var ErrDocumentTooLarge = errors.New("an inserted document is too large") 16 | 17 | // Batches contains the necessary information to batch split an operation. This is only used for write 18 | // oeprations. 19 | type Batches struct { 20 | Identifier string 21 | Documents []bsoncore.Document 22 | Current []bsoncore.Document 23 | Ordered *bool 24 | } 25 | 26 | // Valid returns true if Batches contains both an identifier and the length of Documents is greater 27 | // than zero. 28 | func (b *Batches) Valid() bool { return b != nil && b.Identifier != "" && len(b.Documents) > 0 } 29 | 30 | // ClearBatch clears the Current batch. This must be called before AdvanceBatch will advance to the 31 | // next batch. 32 | func (b *Batches) ClearBatch() { b.Current = b.Current[:0] } 33 | 34 | // AdvanceBatch splits the next batch using maxCount and targetBatchSize. This method will do nothing if 35 | // the current batch has not been cleared. We do this so that when this is called during execute we 36 | // can call it without first needing to check if we already have a batch, which makes the code 37 | // simpler and makes retrying easier. 38 | func (b *Batches) AdvanceBatch(maxCount, targetBatchSize int) error { 39 | if len(b.Current) > 0 { 40 | return nil 41 | } 42 | 43 | if maxCount <= 0 { 44 | maxCount = 1 45 | } 46 | 47 | splitAfter := 0 48 | size := 0 49 | for i, doc := range b.Documents { 50 | if i == maxCount { 51 | break 52 | } 53 | if len(doc) > targetBatchSize { 54 | return ErrDocumentTooLarge 55 | } 56 | if size+len(doc) > targetBatchSize { 57 | break 58 | } 59 | 60 | size += len(doc) 61 | splitAfter++ 62 | } 63 | 64 | b.Current, b.Documents = b.Documents[:splitAfter], b.Documents[splitAfter:] 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/description.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description // import "go.mongodb.org/mongo-driver/x/mongo/driver/description" 8 | 9 | // Unknown is an unknown server or topology kind. 10 | const Unknown = 0 11 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/feature.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | import ( 10 | "fmt" 11 | ) 12 | 13 | // MaxStalenessSupported returns an error if the given server version 14 | // does not support max staleness. 15 | func MaxStalenessSupported(wireVersion *VersionRange) error { 16 | if wireVersion != nil && wireVersion.Max < 5 { 17 | return fmt.Errorf("max staleness is only supported for servers 3.4 or newer") 18 | } 19 | 20 | return nil 21 | } 22 | 23 | // ScramSHA1Supported returns an error if the given server version 24 | // does not support scram-sha-1. 25 | func ScramSHA1Supported(wireVersion *VersionRange) error { 26 | if wireVersion != nil && wireVersion.Max < 3 { 27 | return fmt.Errorf("SCRAM-SHA-1 is only supported for servers 3.0 or newer") 28 | } 29 | 30 | return nil 31 | } 32 | 33 | // SessionsSupported returns true of the given server version indicates that it supports sessions. 34 | func SessionsSupported(wireVersion *VersionRange) bool { 35 | return wireVersion != nil && wireVersion.Max >= 6 36 | } 37 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/server_kind.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | // ServerKind represents the type of a server. 10 | type ServerKind uint32 11 | 12 | // These constants are the possible types of servers. 13 | const ( 14 | Standalone ServerKind = 1 15 | RSMember ServerKind = 2 16 | RSPrimary ServerKind = 4 + RSMember 17 | RSSecondary ServerKind = 8 + RSMember 18 | RSArbiter ServerKind = 16 + RSMember 19 | RSGhost ServerKind = 32 + RSMember 20 | Mongos ServerKind = 256 21 | ) 22 | 23 | // String implements the fmt.Stringer interface. 24 | func (kind ServerKind) String() string { 25 | switch kind { 26 | case Standalone: 27 | return "Standalone" 28 | case RSMember: 29 | return "RSOther" 30 | case RSPrimary: 31 | return "RSPrimary" 32 | case RSSecondary: 33 | return "RSSecondary" 34 | case RSArbiter: 35 | return "RSArbiter" 36 | case RSGhost: 37 | return "RSGhost" 38 | case Mongos: 39 | return "Mongos" 40 | } 41 | 42 | return "Unknown" 43 | } 44 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/topology.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | import ( 10 | "go.mongodb.org/mongo-driver/x/mongo/driver/address" 11 | ) 12 | 13 | // Topology represents a description of a mongodb topology 14 | type Topology struct { 15 | Servers []Server 16 | Kind TopologyKind 17 | SessionTimeoutMinutes uint32 18 | } 19 | 20 | // Server returns the server for the given address. Returns false if the server 21 | // could not be found. 22 | func (t Topology) Server(addr address.Address) (Server, bool) { 23 | for _, server := range t.Servers { 24 | if server.Addr.String() == addr.String() { 25 | return server, true 26 | } 27 | } 28 | return Server{}, false 29 | } 30 | 31 | // TopologyDiff is the difference between two different topology descriptions. 32 | type TopologyDiff struct { 33 | Added []Server 34 | Removed []Server 35 | } 36 | 37 | // DiffTopology compares the two topology descriptions and returns the difference. 38 | func DiffTopology(old, new Topology) TopologyDiff { 39 | var diff TopologyDiff 40 | 41 | oldServers := make(map[string]bool) 42 | for _, s := range old.Servers { 43 | oldServers[s.Addr.String()] = true 44 | } 45 | 46 | for _, s := range new.Servers { 47 | addr := s.Addr.String() 48 | if oldServers[addr] { 49 | delete(oldServers, addr) 50 | } else { 51 | diff.Added = append(diff.Added, s) 52 | } 53 | } 54 | 55 | for _, s := range old.Servers { 56 | addr := s.Addr.String() 57 | if oldServers[addr] { 58 | diff.Removed = append(diff.Removed, s) 59 | } 60 | } 61 | 62 | return diff 63 | } 64 | 65 | // HostlistDiff is the difference between a topology and a host list. 66 | type HostlistDiff struct { 67 | Added []string 68 | Removed []string 69 | } 70 | 71 | // DiffHostlist compares the topology description and host list and returns the difference. 72 | func (t Topology) DiffHostlist(hostlist []string) HostlistDiff { 73 | var diff HostlistDiff 74 | 75 | oldServers := make(map[string]bool) 76 | for _, s := range t.Servers { 77 | oldServers[s.Addr.String()] = true 78 | } 79 | 80 | for _, addr := range hostlist { 81 | if oldServers[addr] { 82 | delete(oldServers, addr) 83 | } else { 84 | diff.Added = append(diff.Added, addr) 85 | } 86 | } 87 | 88 | for addr := range oldServers { 89 | diff.Removed = append(diff.Removed, addr) 90 | } 91 | 92 | return diff 93 | } 94 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/topology_kind.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | // TopologyKind represents a specific topology configuration. 10 | type TopologyKind uint32 11 | 12 | // These constants are the available topology configurations. 13 | const ( 14 | Single TopologyKind = 1 15 | ReplicaSet TopologyKind = 2 16 | ReplicaSetNoPrimary TopologyKind = 4 + ReplicaSet 17 | ReplicaSetWithPrimary TopologyKind = 8 + ReplicaSet 18 | Sharded TopologyKind = 256 19 | ) 20 | 21 | // String implements the fmt.Stringer interface. 22 | func (kind TopologyKind) String() string { 23 | switch kind { 24 | case Single: 25 | return "Single" 26 | case ReplicaSet: 27 | return "ReplicaSet" 28 | case ReplicaSetNoPrimary: 29 | return "ReplicaSetNoPrimary" 30 | case ReplicaSetWithPrimary: 31 | return "ReplicaSetWithPrimary" 32 | case Sharded: 33 | return "Sharded" 34 | } 35 | 36 | return "Unknown" 37 | } 38 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/version.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | import "strconv" 10 | 11 | // Version represents a software version. 12 | type Version struct { 13 | Desc string 14 | Parts []uint8 15 | } 16 | 17 | // AtLeast ensures that the version is at least as large as the "other" version. 18 | func (v Version) AtLeast(other ...uint8) bool { 19 | for i := range other { 20 | if i == len(v.Parts) { 21 | return false 22 | } 23 | if v.Parts[i] < other[i] { 24 | return false 25 | } 26 | } 27 | return true 28 | } 29 | 30 | // String provides the string represtation of the Version. 31 | func (v Version) String() string { 32 | if v.Desc == "" { 33 | var s string 34 | for i, p := range v.Parts { 35 | if i != 0 { 36 | s += "." 37 | } 38 | s += strconv.Itoa(int(p)) 39 | } 40 | return s 41 | } 42 | 43 | return v.Desc 44 | } 45 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/description/version_range.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package description 8 | 9 | import "fmt" 10 | 11 | // VersionRange represents a range of versions. 12 | type VersionRange struct { 13 | Min int32 14 | Max int32 15 | } 16 | 17 | // NewVersionRange creates a new VersionRange given a min and a max. 18 | func NewVersionRange(min, max int32) VersionRange { 19 | return VersionRange{Min: min, Max: max} 20 | } 21 | 22 | // Includes returns a bool indicating whether the supplied integer is included 23 | // in the range. 24 | func (vr VersionRange) Includes(v int32) bool { 25 | return v >= vr.Min && v <= vr.Max 26 | } 27 | 28 | // String implements the fmt.Stringer interface. 29 | func (vr VersionRange) String() string { 30 | return fmt.Sprintf("[%d, %d]", vr.Min, vr.Max) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/legacy.go: -------------------------------------------------------------------------------- 1 | package driver 2 | 3 | // LegacyOperationKind indicates if an operation is a legacy find, getMore, or killCursors. This is used 4 | // in Operation.Execute, which will create legacy OP_QUERY, OP_GET_MORE, or OP_KILL_CURSORS instead 5 | // of sending them as a command. 6 | type LegacyOperationKind uint 7 | 8 | // These constants represent the three different kinds of legacy operations. 9 | const ( 10 | LegacyNone LegacyOperationKind = iota 11 | LegacyFind 12 | LegacyGetMore 13 | LegacyKillCursors 14 | LegacyListCollections 15 | LegacyListIndexes 16 | ) 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/abort_transaction.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "AbortTransaction" 3 | documentation = "AbortTransaction performs an abortTransaction operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | 9 | [command] 10 | name = "abortTransaction" 11 | parameter = "database" 12 | 13 | [request.recoveryToken] 14 | type = "document" 15 | documentation = """ 16 | RecoveryToken sets the recovery token to use when committing or aborting a sharded transaction.\ 17 | """ 18 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/aggregate.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Aggregate" 3 | documentation = "Performs an aggregate operation" 4 | response.type = "batch cursor" 5 | 6 | [properties] 7 | enabled = ["read concern", "read preference", "write concern"] 8 | retryable = {mode = "once per command", type = "reads"} 9 | MinimumWriteConcernWireVersion = 5 10 | 11 | [command] 12 | name = "aggregate" 13 | parameter = "collection" 14 | database = true 15 | 16 | [request.pipeline] 17 | type = "array" 18 | constructor = true 19 | documentation = "Pipeline determines how data is transformed for an aggregation." 20 | 21 | [request.allowDiskUse] 22 | type = "boolean" 23 | documentation = "AllowDiskUse enables writing to temporary files. When true, aggregation stages can write to the dbPath/_tmp directory." 24 | 25 | [request.batchSize] 26 | type = "int32" 27 | documentation = "BatchSize specifies the number of documents to return in every batch." 28 | 29 | [request.bypassDocumentValidation] 30 | type = "boolean" 31 | documentation = "BypassDocumentValidation allows the write to opt-out of document level validation. This only applies when the $out stage is specified." 32 | 33 | [request.collation] 34 | type = "document" 35 | minWireVersionRequired = 5 36 | documentation = "Collation specifies a collation. This option is only valid for server versions 3.4 and above." 37 | 38 | [request.maxTimeMS] 39 | type = "int64" 40 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 41 | 42 | [request.comment] 43 | type = "string" 44 | documentation = "Comment specifies an arbitrary string to help trace the operation through the database profiler, currentOp, and logs." 45 | 46 | [request.hint] 47 | type = "value" 48 | documentation = "Hint specifies the index to use." 49 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/commit_transaction.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "CommitTransaction" 3 | documentation = "CommitTransaction attempts to commit a transaction." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | disabled = ["collection"] 8 | retryable = {mode = "once per command", type = "writes"} 9 | 10 | [command] 11 | name = "commitTransaction" 12 | parameter = "database" 13 | 14 | [request.recoveryToken] 15 | type = "document" 16 | documentation = """ 17 | RecoveryToken sets the recovery token to use when committing or aborting a sharded transaction.\ 18 | """ 19 | 20 | [request.maxTimeMS] 21 | type = "int64" 22 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 23 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/count.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Count" 3 | documentation = "Performs a count operation" 4 | 5 | [properties] 6 | enabled = ["read concern", "read preference"] 7 | retryable = {mode = "once per command", type = "reads"} 8 | 9 | [command] 10 | name = "count" 11 | parameter = "collection" 12 | 13 | [request.maxTimeMS] 14 | type = "int64" 15 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 16 | 17 | [request.query] 18 | type = "document" 19 | documentation = "Query determines what results are returned from find." 20 | 21 | [response] 22 | name = "CountResult" 23 | 24 | [response.field.n] 25 | type = "int64" 26 | documentation = "The number of documents found" 27 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/createIndexes.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "CreateIndexes" 3 | documentation = "CreateIndexes performs a createIndexes operation." 4 | 5 | [command] 6 | name = "createIndexes" 7 | parameter = "collection" 8 | 9 | [request.indexes] 10 | type = "array" 11 | constructor = true 12 | documentation = "An array containing index specification documents for the indexes being created." 13 | 14 | [request.maxTimeMS] 15 | type = "int64" 16 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 17 | 18 | [response] 19 | name = "CreateIndexesResult" 20 | 21 | [response.field.createdCollectionAutomatically] 22 | type = "boolean" 23 | documentation = "If the collection was created automatically." 24 | 25 | [response.field.indexesBefore] 26 | type = "int32" 27 | documentation = "The number of indexes existing before this command." 28 | 29 | [response.field.indexesAfter] 30 | type = "int32" 31 | documentation = "The number of indexes existing after this command." 32 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/delete.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Delete" 3 | documentation = "Delete performs a delete operation" 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | batches = "deletes" 9 | 10 | [command] 11 | name = "delete" 12 | parameter = "collection" 13 | 14 | [request.deletes] 15 | type = "document" 16 | slice = true 17 | constructor = true 18 | variadic = true 19 | required = true 20 | documentation = """ 21 | Deletes adds documents to this operation that will be used to determine what documents to delete when this operation 22 | is executed. These documents should have the form {q: , limit: , collation: }. The 23 | collation field is optional. If limit is 0, there will be no limit on the number of documents deleted.\ 24 | """ 25 | 26 | [request.ordered] 27 | type = "boolean" 28 | documentation = """ 29 | Ordered sets ordered. If true, when a write fails, the operation will return the error, when 30 | false write failures do not stop execution of the operation.\ 31 | """ 32 | 33 | [response] 34 | name = "DeleteResult" 35 | 36 | [response.field.n] 37 | type = "int32" 38 | documentation = "Number of documents successfully deleted." 39 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/distinct.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Distinct" 3 | documentation = "Distinct performs a distinct operation." 4 | 5 | [properties] 6 | enabled = ["read concern", "read preference"] 7 | retryable = {mode = "once per command", type = "reads"} 8 | 9 | [command] 10 | name = "distinct" 11 | parameter = "collection" 12 | 13 | [request.key] 14 | type = "string" 15 | constructor = true 16 | documentation = "Key specifies which field to return distinct values for." 17 | 18 | [request.query] 19 | type = "document" 20 | constructor = true 21 | documentation = "Query specifies which documents to return distinct values from." 22 | 23 | [request.maxTimeMS] 24 | type = "int64" 25 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 26 | 27 | [request.collation] 28 | type = "document" 29 | minWireVersionRequired = 5 30 | documentation = "Collation specifies a collation to be used." 31 | 32 | [response] 33 | name = "DistinctResult" 34 | 35 | [response.field.values] 36 | type = "value" 37 | documentation = "The distinct values for the field." -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_collection.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "DropCollection" 3 | documentation = "DropCollection performs a drop operation." 4 | 5 | [command] 6 | name = "drop" 7 | parameter = "collection" 8 | 9 | [properties] 10 | enabled = ["write concern"] 11 | 12 | [response] 13 | name = "DropCollectionResult" 14 | 15 | [response.field.ns] 16 | type = "string" 17 | documentation = "The namespace of the dropped collection." 18 | 19 | [response.field.nIndexesWas] 20 | type = "int32" 21 | documentation = "The number of indexes in the dropped collection." 22 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_database.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "DropDatabase" 3 | documentation = "DropDatabase performs a dropDatabase operation" 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | disabled = ["collection"] 8 | 9 | [command] 10 | name = "dropDatabase" 11 | parameter = "database" 12 | 13 | [response] 14 | name = "DropDatabaseResult" 15 | 16 | [response.field.dropped] 17 | type = "string" 18 | documentation = "The dropped database." -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/drop_indexes.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "DropIndexes" 3 | documentation = "DropIndexes performs an dropIndexes operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | 8 | [command] 9 | name = "dropIndexes" 10 | parameter = "collection" 11 | 12 | [request.index] 13 | type = "string" 14 | constructor = true 15 | documentation = """ 16 | Index specifies the name of the index to drop. If '*' is specified, all indexes will be dropped. 17 | """ 18 | 19 | [request.maxTimeMS] 20 | type = "int64" 21 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 22 | 23 | [response] 24 | name = "DropIndexesResult" 25 | 26 | [response.field.nIndexesWas] 27 | type = "int32" 28 | documentation = "Number of indexes that existed before the drop was executed." 29 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/end_sessions.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "EndSessions" 3 | documentation = "EndSessions performs an endSessions operation." 4 | 5 | [properties] 6 | disabled = ["collection"] 7 | 8 | [command] 9 | name = "endSessions" 10 | parameter = "sessionIDs" 11 | 12 | [request.sessionIDs] 13 | type = "array" 14 | documentation = "sessionIDs specify the sessions to be expired." 15 | skip = true 16 | constructor = true 17 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/find_and_modify.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "FindAndModify" 3 | documentation = "FindAndModify performs a findAndModify operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once", type = "writes"} 8 | 9 | [command] 10 | name = "findAndModify" 11 | parameter = "collection" 12 | 13 | [request.query] 14 | type = "document" 15 | constructor = true 16 | documentation = "Query specifies the selection criteria for the modification." 17 | 18 | [request.sort] 19 | type = "document" 20 | documentation = """ 21 | Sort determines which document the operation modifies if the query matches multiple documents.\ 22 | The first document matched by the sort order will be modified. 23 | """ 24 | 25 | [request.remove] 26 | type = "boolean" 27 | documentation = "Remove specifies that the matched document should be removed. Defaults to false." 28 | 29 | [request.update] 30 | type = "value" 31 | documentation = "Update specifies the update document to perform on the matched document." 32 | 33 | [request.newDocument] 34 | type = "boolean" 35 | documentation = "NewDocument specifies whether to return the modified document or the original. Defaults to false (return original)." 36 | 37 | [request.fields] 38 | type = "document" 39 | documentation = "Fields specifies a subset of fields to return." 40 | 41 | [request.upsert] 42 | type = "boolean" 43 | documentation = "Upsert specifies whether or not to create a new document if no documents match the query when doing an update. Defaults to false." 44 | 45 | [request.bypassDocumentValidation] 46 | type = "boolean" 47 | documentation = "BypassDocumentValidation specifies if document validation can be skipped when executing the operation." 48 | 49 | [request.maxTimeMS] 50 | type = "int64" 51 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the operation to run." 52 | 53 | [request.collation] 54 | type = "document" 55 | minWireVersionRequired = 5 56 | documentation = "Collation specifies a collation to be used." 57 | 58 | [request.arrayFilters] 59 | type = "array" 60 | minWireVersionRequired = 6 61 | documentation = "ArrayFilters specifies an array of filter documents that determines which array elements to modify for an update operation on an array field." 62 | 63 | [response] 64 | name = "FindAndModifyResult" 65 | 66 | [response.field.value] 67 | type = "document" 68 | documentation = "Either the old or modified document, depending on the value of the new parameter." 69 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/insert.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Insert" 3 | documentation = "Insert performs an insert operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | batches = "documents" 9 | 10 | [command] 11 | name = "insert" 12 | parameter = "collection" 13 | 14 | [request.documents] 15 | type = "document" 16 | slice = true 17 | constructor = true 18 | variadic = true 19 | required = true 20 | documentation = """ 21 | Documents adds documents to this operation that will be inserted when this operation is 22 | executed.\ 23 | """ 24 | 25 | [request.ordered] 26 | type = "boolean" 27 | documentation = """ 28 | Ordered sets ordered. If true, when a write fails, the operation will return the error, when 29 | false write failures do not stop execution of the operation.\ 30 | """ 31 | 32 | [request.bypassDocumentValidation] 33 | type = "boolean" 34 | minWireVersion = 4 35 | documentation = """ 36 | BypassDocumentValidation allows the operation to opt-out of document level validation. Valid 37 | for server versions >= 3.2. For servers < 3.2, this setting is ignored.\ 38 | """ 39 | 40 | [response] 41 | name = "InsertResult" 42 | 43 | [response.field.n] 44 | type = "int32" 45 | documentation = "Number of documents successfully inserted." 46 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/listDatabases.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "ListDatabases" 3 | documentation = "ListDatabases performs a listDatabases operation." 4 | 5 | [properties] 6 | enabled = ["read preference"] 7 | retryable = {mode = "once per command", type = "reads"} 8 | disabled = ["collection"] 9 | 10 | [command] 11 | name = "listDatabases" 12 | parameter = "database" 13 | 14 | [request.filter] 15 | type = "document" 16 | constructor = true 17 | documentation = "Filter determines what results are returned from listDatabases." 18 | 19 | 20 | [request.nameOnly] 21 | type = "boolean" 22 | documentation = "NameOnly specifies whether to only return database names." 23 | 24 | [response] 25 | name = "ListDatabasesResult" 26 | 27 | [response.field.totalSize] 28 | type = "int64" 29 | documentation = "The sum of the size of all the database files on disk in bytes." 30 | 31 | [response.field.databases] 32 | type = "value" 33 | documentation = "An array of documents, one document for each database" -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/list_collections.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "ListCollections" 3 | documentation = "ListCollections performs a listCollections operation." 4 | response.type = "list collections batch cursor" 5 | 6 | [properties] 7 | enabled = ["read preference"] 8 | disabled = ["collection"] 9 | retryable = {mode = "once per command", type = "reads"} 10 | legacy = "listCollections" 11 | 12 | [command] 13 | name = "listCollections" 14 | parameter = "database" 15 | 16 | [request.filter] 17 | type = "document" 18 | constructor = true 19 | documentation = "Filter determines what results are returned from listCollections." 20 | 21 | [request.nameOnly] 22 | type = "boolean" 23 | documentation = "NameOnly specifies whether to only return collection names." 24 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/list_indexes.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "ListIndexes" 3 | documentation = "ListIndexes performs a listIndexes operation." 4 | response.type = "batch cursor" 5 | 6 | [properties] 7 | legacy = "listIndexes" 8 | retryable = {mode = "once per command", type = "reads"} 9 | 10 | [command] 11 | name = "listIndexes" 12 | parameter = "collection" 13 | 14 | [request.batchSize] 15 | type = "int32" 16 | documentation = "BatchSize specifies the number of documents to return in every batch." 17 | 18 | [request.maxTimeMS] 19 | type = "int64" 20 | documentation = "MaxTimeMS specifies the maximum amount of time to allow the query to run." 21 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/operation.go: -------------------------------------------------------------------------------- 1 | package operation 2 | 3 | //go:generate operationgen insert.toml operation insert.go 4 | //go:generate operationgen find.toml operation find.go 5 | //go:generate operationgen list_collections.toml operation list_collections.go 6 | //go:generate operationgen createIndexes.toml operation createIndexes.go 7 | //go:generate operationgen drop_collection.toml operation drop_collection.go 8 | //go:generate operationgen distinct.toml operation distinct.go 9 | //go:generate operationgen delete.toml operation delete.go 10 | //go:generate operationgen drop_indexes.toml operation drop_indexes.go 11 | //go:generate operationgen drop_database.toml operation drop_database.go 12 | //go:generate operationgen commit_transaction.toml operation commit_transaction.go 13 | //go:generate operationgen abort_transaction.toml operation abort_transaction.go 14 | //go:generate operationgen count.toml operation count.go 15 | //go:generate operationgen end_sessions.toml operation end_sessions.go 16 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/operation/update.toml: -------------------------------------------------------------------------------- 1 | version = 0 2 | name = "Update" 3 | documentation = "Update performs an update operation." 4 | 5 | [properties] 6 | enabled = ["write concern"] 7 | retryable = {mode = "once per command", type = "writes"} 8 | batches = "updates" 9 | 10 | [command] 11 | name = "update" 12 | parameter = "collection" 13 | 14 | [request.updates] 15 | type = "document" 16 | slice = true 17 | constructor = true 18 | variadic = true 19 | required = true 20 | documentation = """ 21 | Updates specifies an array of update statements to perform when this operation is executed. 22 | Each update document must have the following structure: {q: , u: , multi: , collation: Optional, arrayFitlers: Optional}.\ 23 | """ 24 | 25 | [request.ordered] 26 | type = "boolean" 27 | documentation = """ 28 | Ordered sets ordered. If true, when a write fails, the operation will return the error, when 29 | false write failures do not stop execution of the operation.\ 30 | """ 31 | 32 | [request.bypassDocumentValidation] 33 | type = "boolean" 34 | minWireVersion = 4 35 | documentation = """ 36 | BypassDocumentValidation allows the operation to opt-out of document level validation. Valid 37 | for server versions >= 3.2. For servers < 3.2, this setting is ignored.\ 38 | """ 39 | 40 | [response] 41 | name = "UpdateResult" 42 | 43 | [response.field.n] 44 | type = "int32" 45 | documentation = "Number of documents matched." 46 | 47 | [response.field.nModified] 48 | type = "int32" 49 | documentation = "Number of documents modified." 50 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/cluster_clock.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package session 8 | 9 | import ( 10 | "sync" 11 | 12 | "go.mongodb.org/mongo-driver/bson" 13 | ) 14 | 15 | // ClusterClock represents a logical clock for keeping track of cluster time. 16 | type ClusterClock struct { 17 | clusterTime bson.Raw 18 | lock sync.Mutex 19 | } 20 | 21 | // GetClusterTime returns the cluster's current time. 22 | func (cc *ClusterClock) GetClusterTime() bson.Raw { 23 | var ct bson.Raw 24 | cc.lock.Lock() 25 | ct = cc.clusterTime 26 | cc.lock.Unlock() 27 | 28 | return ct 29 | } 30 | 31 | // AdvanceClusterTime updates the cluster's current time. 32 | func (cc *ClusterClock) AdvanceClusterTime(clusterTime bson.Raw) { 33 | cc.lock.Lock() 34 | cc.clusterTime = MaxClusterTime(cc.clusterTime, clusterTime) 35 | cc.lock.Unlock() 36 | } 37 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/options.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package session 8 | 9 | import ( 10 | "time" 11 | 12 | "go.mongodb.org/mongo-driver/mongo/readconcern" 13 | "go.mongodb.org/mongo-driver/mongo/readpref" 14 | "go.mongodb.org/mongo-driver/mongo/writeconcern" 15 | ) 16 | 17 | // ClientOptions represents all possible options for creating a client session. 18 | type ClientOptions struct { 19 | CausalConsistency *bool 20 | DefaultReadConcern *readconcern.ReadConcern 21 | DefaultWriteConcern *writeconcern.WriteConcern 22 | DefaultReadPreference *readpref.ReadPref 23 | DefaultMaxCommitTime *time.Duration 24 | } 25 | 26 | // TransactionOptions represents all possible options for starting a transaction in a session. 27 | type TransactionOptions struct { 28 | ReadConcern *readconcern.ReadConcern 29 | WriteConcern *writeconcern.WriteConcern 30 | ReadPreference *readpref.ReadPref 31 | MaxCommitTime *time.Duration 32 | } 33 | 34 | func mergeClientOptions(opts ...*ClientOptions) *ClientOptions { 35 | c := &ClientOptions{} 36 | for _, opt := range opts { 37 | if opt == nil { 38 | continue 39 | } 40 | if opt.CausalConsistency != nil { 41 | c.CausalConsistency = opt.CausalConsistency 42 | } 43 | if opt.DefaultReadConcern != nil { 44 | c.DefaultReadConcern = opt.DefaultReadConcern 45 | } 46 | if opt.DefaultReadPreference != nil { 47 | c.DefaultReadPreference = opt.DefaultReadPreference 48 | } 49 | if opt.DefaultWriteConcern != nil { 50 | c.DefaultWriteConcern = opt.DefaultWriteConcern 51 | } 52 | if opt.DefaultMaxCommitTime != nil { 53 | c.DefaultMaxCommitTime = opt.DefaultMaxCommitTime 54 | } 55 | } 56 | 57 | return c 58 | } 59 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/session/server_session.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package session 8 | 9 | import ( 10 | "time" 11 | 12 | "crypto/rand" 13 | 14 | "go.mongodb.org/mongo-driver/x/bsonx" 15 | "go.mongodb.org/mongo-driver/x/mongo/driver/uuid" 16 | ) 17 | 18 | var rander = rand.Reader 19 | 20 | // Server is an open session with the server. 21 | type Server struct { 22 | SessionID bsonx.Doc 23 | TxnNumber int64 24 | LastUsed time.Time 25 | Dirty bool 26 | } 27 | 28 | // returns whether or not a session has expired given a timeout in minutes 29 | // a session is considered expired if it has less than 1 minute left before becoming stale 30 | func (ss *Server) expired(timeoutMinutes uint32) bool { 31 | if timeoutMinutes <= 0 { 32 | return true 33 | } 34 | timeUnused := time.Since(ss.LastUsed).Minutes() 35 | return timeUnused > float64(timeoutMinutes-1) 36 | } 37 | 38 | // update the last used time for this session. 39 | // must be called whenever this server session is used to send a command to the server. 40 | func (ss *Server) updateUseTime() { 41 | ss.LastUsed = time.Now() 42 | } 43 | 44 | func newServerSession() (*Server, error) { 45 | id, err := uuid.New() 46 | if err != nil { 47 | return nil, err 48 | } 49 | 50 | idDoc := bsonx.Doc{{"id", bsonx.Binary(UUIDSubtype, id[:])}} 51 | 52 | return &Server{ 53 | SessionID: idDoc, 54 | LastUsed: time.Now(), 55 | }, nil 56 | } 57 | 58 | // IncrementTxnNumber increments the transaction number. 59 | func (ss *Server) IncrementTxnNumber() { 60 | ss.TxnNumber++ 61 | } 62 | 63 | // MarkDirty marks the session as dirty. 64 | func (ss *Server) MarkDirty() { 65 | ss.Dirty = true 66 | } 67 | 68 | // UUIDSubtype is the BSON binary subtype that a UUID should be encoded as 69 | const UUIDSubtype byte = 4 70 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/DESIGN.md: -------------------------------------------------------------------------------- 1 | # Topology Package Design 2 | This document outlines the design for this package. 3 | 4 | ## Topology 5 | The `Topology` type handles monitoring the state of a MongoDB deployment and selecting servers. 6 | Updating the description is handled by finite state machine which implements the server discovery 7 | and monitoring specification. A `Topology` can be connected and fully disconnected, which enables 8 | saving resources. The `Topology` type also handles server selection following the server selection 9 | specification. 10 | 11 | ## Server 12 | The `Server` type handles heartbeating a MongoDB server and holds a pool of connections. 13 | 14 | ## Connection 15 | Connections are handled by two main types and an auxiliary type. The two main types are `connection` 16 | and `Connection`. The first holds most of the logic required to actually read and write wire 17 | messages. Instances can be created with the `newConnection` method. Inside the `newConnection` 18 | method the auxiliary type, `initConnection` is used to perform the connection handshake. This is 19 | required because the `connection` type does not fully implement `driver.Connection` which is 20 | required during handshaking. The `Connection` type is what is actually returned to a consumer of the 21 | `topology` package. This type does implement the `driver.Connection` type, holds a reference to a 22 | `connection` instance, and exists mainly to prevent accidental continued usage of a connection after 23 | closing it. 24 | 25 | The connection implementations in this package are conduits for wire messages but they have no 26 | ability to encode, decode, or validate wire messages. That must be handled by consumers. 27 | 28 | ## Pool 29 | The `pool` type implements a connection pool. It handles caching idle connections and dialing 30 | new ones, but it does not track a maximum number of connections. That is the responsibility of a 31 | wrapping type, like `Server`. 32 | 33 | The `pool` type has no concept of closing, instead it has concepts of connecting and disconnecting. 34 | This allows a `Topology` to be disconnected,but keeping the memory around to be reconnected later. 35 | There is a `close` method, but this is used to close a connection. 36 | 37 | There are three methods related to getting and putting connections: `get`, `close`, and `put`. The 38 | `get` method will either retrieve a connection from the cache or it will dial a new `connection`. 39 | The `close` method will close the underlying socket of a `connection`. The `put` method will put a 40 | connection into the pool, placing it in the cahce if there is space, otherwise it will close it. 41 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection_legacy.go: -------------------------------------------------------------------------------- 1 | package topology 2 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/connection_legacy_command_metadata.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | import "time" 4 | 5 | // commandMetadata contains metadata about a command sent to the server. 6 | type commandMetadata struct { 7 | Name string 8 | Time time.Time 9 | Legacy bool 10 | FullCollectionName string 11 | } 12 | 13 | // createMetadata creates metadata for a command. 14 | func createMetadata(name string, legacy bool, fullCollName string) *commandMetadata { 15 | return &commandMetadata{ 16 | Name: name, 17 | Time: time.Now(), 18 | Legacy: legacy, 19 | FullCollectionName: fullCollName, 20 | } 21 | } 22 | 23 | // TimeDifference returns the difference between now and the time a command was sent in nanoseconds. 24 | func (cm *commandMetadata) TimeDifference() int64 { 25 | t := time.Now() 26 | duration := t.Sub(cm.Time) 27 | return duration.Nanoseconds() 28 | } 29 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/errors.go: -------------------------------------------------------------------------------- 1 | package topology 2 | 3 | import "fmt" 4 | 5 | // ConnectionError represents a connection error. 6 | type ConnectionError struct { 7 | ConnectionID string 8 | Wrapped error 9 | 10 | // init will be set to true if this error occured during connection initialization or 11 | // during a connection handshake. 12 | init bool 13 | message string 14 | } 15 | 16 | // Error implements the error interface. 17 | func (e ConnectionError) Error() string { 18 | if e.Wrapped != nil { 19 | return fmt.Sprintf("connection(%s) %s: %s", e.ConnectionID, e.message, e.Wrapped.Error()) 20 | } 21 | return fmt.Sprintf("connection(%s) %s", e.ConnectionID, e.message) 22 | } 23 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology_options_1_10.go: -------------------------------------------------------------------------------- 1 | // +build go1.10 2 | 3 | package topology 4 | 5 | import "crypto/x509" 6 | 7 | func x509CertSubject(cert *x509.Certificate) string { 8 | return cert.Subject.String() 9 | } 10 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/topology/topology_options_1_9.go: -------------------------------------------------------------------------------- 1 | // +build !go1.10 2 | 3 | package topology 4 | 5 | import ( 6 | "crypto/x509" 7 | ) 8 | 9 | // We don't support version less then 1.10, but Evergreen needs to be able to compile the driver 10 | // using version 1.8. 11 | func x509CertSubject(cert *x509.Certificate) string { 12 | return "" 13 | } 14 | -------------------------------------------------------------------------------- /vendor/go.mongodb.org/mongo-driver/x/mongo/driver/uuid/uuid.go: -------------------------------------------------------------------------------- 1 | // Copyright (C) MongoDB, Inc. 2017-present. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); you may 4 | // not use this file except in compliance with the License. You may obtain 5 | // a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | 7 | package uuid // import "go.mongodb.org/mongo-driver/x/mongo/driver/uuid" 8 | 9 | import ( 10 | "bytes" 11 | "crypto/rand" 12 | "io" 13 | ) 14 | 15 | // UUID represents a UUID. 16 | type UUID [16]byte 17 | 18 | var rander = rand.Reader 19 | 20 | // New generates a new uuid. 21 | func New() (UUID, error) { 22 | var uuid [16]byte 23 | 24 | _, err := io.ReadFull(rander, uuid[:]) 25 | if err != nil { 26 | return [16]byte{}, err 27 | } 28 | uuid[6] = (uuid[6] & 0x0f) | 0x40 // Version 4 29 | uuid[8] = (uuid[8] & 0x3f) | 0x80 // Variant is 10 30 | 31 | return uuid, nil 32 | } 33 | 34 | // Equal returns true if two UUIDs are equal. 35 | func Equal(a, b UUID) bool { 36 | return bytes.Equal([]byte(a[:]), []byte(b[:])) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at https://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at https://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/pbkdf2/pbkdf2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | /* 6 | Package pbkdf2 implements the key derivation function PBKDF2 as defined in RFC 7 | 2898 / PKCS #5 v2.0. 8 | 9 | A key derivation function is useful when encrypting data based on a password 10 | or any other not-fully-random data. It uses a pseudorandom function to derive 11 | a secure encryption key based on the password. 12 | 13 | While v2.0 of the standard defines only one pseudorandom function to use, 14 | HMAC-SHA1, the drafted v2.1 specification allows use of all five FIPS Approved 15 | Hash Functions SHA-1, SHA-224, SHA-256, SHA-384 and SHA-512 for HMAC. To 16 | choose, you can pass the `New` functions from the different SHA packages to 17 | pbkdf2.Key. 18 | */ 19 | package pbkdf2 // import "golang.org/x/crypto/pbkdf2" 20 | 21 | import ( 22 | "crypto/hmac" 23 | "hash" 24 | ) 25 | 26 | // Key derives a key from the password, salt and iteration count, returning a 27 | // []byte of length keylen that can be used as cryptographic key. The key is 28 | // derived based on the method described as PBKDF2 with the HMAC variant using 29 | // the supplied hash function. 30 | // 31 | // For example, to use a HMAC-SHA-1 based PBKDF2 key derivation function, you 32 | // can get a derived key for e.g. AES-256 (which needs a 32-byte key) by 33 | // doing: 34 | // 35 | // dk := pbkdf2.Key([]byte("some password"), salt, 4096, 32, sha1.New) 36 | // 37 | // Remember to get a good random salt. At least 8 bytes is recommended by the 38 | // RFC. 39 | // 40 | // Using a higher iteration count will increase the cost of an exhaustive 41 | // search but will also make derivation proportionally slower. 42 | func Key(password, salt []byte, iter, keyLen int, h func() hash.Hash) []byte { 43 | prf := hmac.New(h, password) 44 | hashLen := prf.Size() 45 | numBlocks := (keyLen + hashLen - 1) / hashLen 46 | 47 | var buf [4]byte 48 | dk := make([]byte, 0, numBlocks*hashLen) 49 | U := make([]byte, hashLen) 50 | for block := 1; block <= numBlocks; block++ { 51 | // N.B.: || means concatenation, ^ means XOR 52 | // for each block T_i = U_1 ^ U_2 ^ ... ^ U_iter 53 | // U_1 = PRF(password, salt || uint(i)) 54 | prf.Reset() 55 | prf.Write(salt) 56 | buf[0] = byte(block >> 24) 57 | buf[1] = byte(block >> 16) 58 | buf[2] = byte(block >> 8) 59 | buf[3] = byte(block) 60 | prf.Write(buf[:4]) 61 | dk = prf.Sum(dk) 62 | T := dk[len(dk)-hashLen:] 63 | copy(U, T) 64 | 65 | // U_n = PRF(password, U_(n-1)) 66 | for n := 2; n <= iter; n++ { 67 | prf.Reset() 68 | prf.Write(U) 69 | U = U[:0] 70 | U = prf.Sum(U) 71 | for x := range U { 72 | T[x] ^= U[x] 73 | } 74 | } 75 | } 76 | return dk[:keyLen] 77 | } 78 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sync/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/AUTHORS: -------------------------------------------------------------------------------- 1 | # This source code refers to The Go Authors for copyright purposes. 2 | # The master list of authors is in the main Go distribution, 3 | # visible at http://tip.golang.org/AUTHORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This source code was written by the Go contributors. 2 | # The master list of contributors is in the main Go distribution, 3 | # visible at http://tip.golang.org/CONTRIBUTORS. 4 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/internal/triegen/compact.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package triegen 6 | 7 | // This file defines Compacter and its implementations. 8 | 9 | import "io" 10 | 11 | // A Compacter generates an alternative, more space-efficient way to store a 12 | // trie value block. A trie value block holds all possible values for the last 13 | // byte of a UTF-8 encoded rune. Excluding ASCII characters, a trie value block 14 | // always has 64 values, as a UTF-8 encoding ends with a byte in [0x80, 0xC0). 15 | type Compacter interface { 16 | // Size returns whether the Compacter could encode the given block as well 17 | // as its size in case it can. len(v) is always 64. 18 | Size(v []uint64) (sz int, ok bool) 19 | 20 | // Store stores the block using the Compacter's compression method. 21 | // It returns a handle with which the block can be retrieved. 22 | // len(v) is always 64. 23 | Store(v []uint64) uint32 24 | 25 | // Print writes the data structures associated to the given store to w. 26 | Print(w io.Writer) error 27 | 28 | // Handler returns the name of a function that gets called during trie 29 | // lookup for blocks generated by the Compacter. The function should be of 30 | // the form func (n uint32, b byte) uint64, where n is the index returned by 31 | // the Compacter's Store method and b is the last byte of the UTF-8 32 | // encoding, where 0x80 <= b < 0xC0, for which to do the lookup in the 33 | // block. 34 | Handler() string 35 | } 36 | 37 | // simpleCompacter is the default Compacter used by builder. It implements a 38 | // normal trie block. 39 | type simpleCompacter builder 40 | 41 | func (b *simpleCompacter) Size([]uint64) (sz int, ok bool) { 42 | return blockSize * b.ValueSize, true 43 | } 44 | 45 | func (b *simpleCompacter) Store(v []uint64) uint32 { 46 | h := uint32(len(b.ValueBlocks) - blockOffset) 47 | b.ValueBlocks = append(b.ValueBlocks, v) 48 | return h 49 | } 50 | 51 | func (b *simpleCompacter) Print(io.Writer) error { 52 | // Structures are printed in print.go. 53 | return nil 54 | } 55 | 56 | func (b *simpleCompacter) Handler() string { 57 | panic("Handler should be special-cased for this Compacter") 58 | } 59 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/input.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | import "unicode/utf8" 8 | 9 | type input struct { 10 | str string 11 | bytes []byte 12 | } 13 | 14 | func inputBytes(str []byte) input { 15 | return input{bytes: str} 16 | } 17 | 18 | func inputString(str string) input { 19 | return input{str: str} 20 | } 21 | 22 | func (in *input) setBytes(str []byte) { 23 | in.str = "" 24 | in.bytes = str 25 | } 26 | 27 | func (in *input) setString(str string) { 28 | in.str = str 29 | in.bytes = nil 30 | } 31 | 32 | func (in *input) _byte(p int) byte { 33 | if in.bytes == nil { 34 | return in.str[p] 35 | } 36 | return in.bytes[p] 37 | } 38 | 39 | func (in *input) skipASCII(p, max int) int { 40 | if in.bytes == nil { 41 | for ; p < max && in.str[p] < utf8.RuneSelf; p++ { 42 | } 43 | } else { 44 | for ; p < max && in.bytes[p] < utf8.RuneSelf; p++ { 45 | } 46 | } 47 | return p 48 | } 49 | 50 | func (in *input) skipContinuationBytes(p int) int { 51 | if in.bytes == nil { 52 | for ; p < len(in.str) && !utf8.RuneStart(in.str[p]); p++ { 53 | } 54 | } else { 55 | for ; p < len(in.bytes) && !utf8.RuneStart(in.bytes[p]); p++ { 56 | } 57 | } 58 | return p 59 | } 60 | 61 | func (in *input) appendSlice(buf []byte, b, e int) []byte { 62 | if in.bytes != nil { 63 | return append(buf, in.bytes[b:e]...) 64 | } 65 | for i := b; i < e; i++ { 66 | buf = append(buf, in.str[i]) 67 | } 68 | return buf 69 | } 70 | 71 | func (in *input) copySlice(buf []byte, b, e int) int { 72 | if in.bytes == nil { 73 | return copy(buf, in.str[b:e]) 74 | } 75 | return copy(buf, in.bytes[b:e]) 76 | } 77 | 78 | func (in *input) charinfoNFC(p int) (uint16, int) { 79 | if in.bytes == nil { 80 | return nfcData.lookupString(in.str[p:]) 81 | } 82 | return nfcData.lookup(in.bytes[p:]) 83 | } 84 | 85 | func (in *input) charinfoNFKC(p int) (uint16, int) { 86 | if in.bytes == nil { 87 | return nfkcData.lookupString(in.str[p:]) 88 | } 89 | return nfkcData.lookup(in.bytes[p:]) 90 | } 91 | 92 | func (in *input) hangul(p int) (r rune) { 93 | var size int 94 | if in.bytes == nil { 95 | if !isHangulString(in.str[p:]) { 96 | return 0 97 | } 98 | r, size = utf8.DecodeRuneInString(in.str[p:]) 99 | } else { 100 | if !isHangul(in.bytes[p:]) { 101 | return 0 102 | } 103 | r, size = utf8.DecodeRune(in.bytes[p:]) 104 | } 105 | if size != hangulUTF8Size { 106 | return 0 107 | } 108 | return r 109 | } 110 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/transform.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | import ( 8 | "unicode/utf8" 9 | 10 | "golang.org/x/text/transform" 11 | ) 12 | 13 | // Reset implements the Reset method of the transform.Transformer interface. 14 | func (Form) Reset() {} 15 | 16 | // Transform implements the Transform method of the transform.Transformer 17 | // interface. It may need to write segments of up to MaxSegmentSize at once. 18 | // Users should either catch ErrShortDst and allow dst to grow or have dst be at 19 | // least of size MaxTransformChunkSize to be guaranteed of progress. 20 | func (f Form) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 21 | // Cap the maximum number of src bytes to check. 22 | b := src 23 | eof := atEOF 24 | if ns := len(dst); ns < len(b) { 25 | err = transform.ErrShortDst 26 | eof = false 27 | b = b[:ns] 28 | } 29 | i, ok := formTable[f].quickSpan(inputBytes(b), 0, len(b), eof) 30 | n := copy(dst, b[:i]) 31 | if !ok { 32 | nDst, nSrc, err = f.transform(dst[n:], src[n:], atEOF) 33 | return nDst + n, nSrc + n, err 34 | } 35 | 36 | if err == nil && n < len(src) && !atEOF { 37 | err = transform.ErrShortSrc 38 | } 39 | return n, n, err 40 | } 41 | 42 | func flushTransform(rb *reorderBuffer) bool { 43 | // Write out (must fully fit in dst, or else it is an ErrShortDst). 44 | if len(rb.out) < rb.nrune*utf8.UTFMax { 45 | return false 46 | } 47 | rb.out = rb.out[rb.flushCopy(rb.out):] 48 | return true 49 | } 50 | 51 | var errs = []error{nil, transform.ErrShortDst, transform.ErrShortSrc} 52 | 53 | // transform implements the transform.Transformer interface. It is only called 54 | // when quickSpan does not pass for a given string. 55 | func (f Form) transform(dst, src []byte, atEOF bool) (nDst, nSrc int, err error) { 56 | // TODO: get rid of reorderBuffer. See CL 23460044. 57 | rb := reorderBuffer{} 58 | rb.init(f, src) 59 | for { 60 | // Load segment into reorder buffer. 61 | rb.setFlusher(dst[nDst:], flushTransform) 62 | end := decomposeSegment(&rb, nSrc, atEOF) 63 | if end < 0 { 64 | return nDst, nSrc, errs[-end] 65 | } 66 | nDst = len(dst) - len(rb.out) 67 | nSrc = end 68 | 69 | // Next quickSpan. 70 | end = rb.nsrc 71 | eof := atEOF 72 | if n := nSrc + len(dst) - nDst; n < end { 73 | err = transform.ErrShortDst 74 | end = n 75 | eof = false 76 | } 77 | end, ok := rb.f.quickSpan(rb.src, nSrc, end, eof) 78 | n := copy(dst[nDst:], rb.src.bytes[nSrc:end]) 79 | nSrc += n 80 | nDst += n 81 | if ok { 82 | if err == nil && n < rb.nsrc && !atEOF { 83 | err = transform.ErrShortSrc 84 | } 85 | return nDst, nSrc, err 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/golang.org/x/text/unicode/norm/trie.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package norm 6 | 7 | type valueRange struct { 8 | value uint16 // header: value:stride 9 | lo, hi byte // header: lo:n 10 | } 11 | 12 | type sparseBlocks struct { 13 | values []valueRange 14 | offset []uint16 15 | } 16 | 17 | var nfcSparse = sparseBlocks{ 18 | values: nfcSparseValues[:], 19 | offset: nfcSparseOffset[:], 20 | } 21 | 22 | var nfkcSparse = sparseBlocks{ 23 | values: nfkcSparseValues[:], 24 | offset: nfkcSparseOffset[:], 25 | } 26 | 27 | var ( 28 | nfcData = newNfcTrie(0) 29 | nfkcData = newNfkcTrie(0) 30 | ) 31 | 32 | // lookupValue determines the type of block n and looks up the value for b. 33 | // For n < t.cutoff, the block is a simple lookup table. Otherwise, the block 34 | // is a list of ranges with an accompanying value. Given a matching range r, 35 | // the value for b is by r.value + (b - r.lo) * stride. 36 | func (t *sparseBlocks) lookup(n uint32, b byte) uint16 { 37 | offset := t.offset[n] 38 | header := t.values[offset] 39 | lo := offset + 1 40 | hi := lo + uint16(header.lo) 41 | for lo < hi { 42 | m := lo + (hi-lo)/2 43 | r := t.values[m] 44 | if r.lo <= b && b <= r.hi { 45 | return r.value + uint16(b-r.lo)*header.value 46 | } 47 | if b < r.lo { 48 | hi = m 49 | } else { 50 | lo = m + 1 51 | } 52 | } 53 | return 0 54 | } 55 | -------------------------------------------------------------------------------- /website/assets/css/images/overlay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/css/images/overlay.png -------------------------------------------------------------------------------- /website/assets/css/noscript.css: -------------------------------------------------------------------------------- 1 | /* 2 | Identity by HTML5 UP 3 | html5up.net | @ajlkn 4 | Free for personal and commercial use under the CCA 3.0 license (html5up.net/license) 5 | */ 6 | 7 | /* Basic */ 8 | 9 | body:after { 10 | display: none; 11 | } 12 | 13 | /* Main */ 14 | 15 | #main { 16 | -moz-transform: none !important; 17 | -webkit-transform: none !important; 18 | -ms-transform: none !important; 19 | transform: none !important; 20 | opacity: 1 !important; 21 | } -------------------------------------------------------------------------------- /website/assets/webfonts/fa-brands-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-brands-400.eot -------------------------------------------------------------------------------- /website/assets/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /website/assets/webfonts/fa-brands-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-brands-400.woff -------------------------------------------------------------------------------- /website/assets/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /website/assets/webfonts/fa-regular-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-regular-400.eot -------------------------------------------------------------------------------- /website/assets/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /website/assets/webfonts/fa-regular-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-regular-400.woff -------------------------------------------------------------------------------- /website/assets/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /website/assets/webfonts/fa-solid-900.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-solid-900.eot -------------------------------------------------------------------------------- /website/assets/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /website/assets/webfonts/fa-solid-900.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-solid-900.woff -------------------------------------------------------------------------------- /website/assets/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/assets/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /website/images/bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/someone-stole-my-name/gShort/55ae27ba1f2938f60e96334e02a0cc7b8b7d17e1/website/images/bg.jpg --------------------------------------------------------------------------------