diff --git a/glide.lock b/glide.lock index 97a5df95..385ea16e 100644 --- a/glide.lock +++ b/glide.lock @@ -1,10 +1,12 @@ -hash: 9065f050a8e87468098f6df070622f57a29d2de83efebb67363efa781f612080 -updated: 2016-11-10T21:20:31.679082589-05:00 +hash: 2c6dcc1de105586b60c0208475697a0e23904ef4c1a51a947670c8f747a0f388 +updated: 2016-11-11T18:51:11.117563-05:00 imports: - name: github.com/beorn7/perks version: 4c0e84591b9aa9e6dcfdf3e020114cd81f89d5f9 subpackages: - quantile +- name: github.com/boltdb/bolt + version: 583e8937c61f1af6513608ccc75c97b6abdf4ff9 - name: github.com/DavidHuie/gomigrate version: 4004e6142040f5d622e9d2be6e833a4652741571 - name: github.com/fullsailor/pkcs7 @@ -19,7 +21,7 @@ imports: - internal - redis - name: github.com/go-kit/kit - version: fa37eda80c7ca0329458495b0299f068f3f19d70 + version: 9f5c614cd1e70102f80b644edbc760805ebf16d5 vcs: git subpackages: - endpoint @@ -59,6 +61,12 @@ imports: version: 38c81b11544f31c2be14e0b3bcfa12f656fcc709 - name: github.com/micromdm/mdm version: 6e0586cca72594720a1c7c48214661a87c73bd17 +- name: github.com/micromdm/scep + version: 864b3e4b501f53b4897bdbde36e4960ba04f8bcf + subpackages: + - depot + - depot/bolt + - server - name: github.com/pkg/errors version: 645ef00459ed84a119197bfb8d8205042c6df63d - name: github.com/prometheus/client_golang @@ -91,12 +99,12 @@ imports: - name: github.com/satori/go.uuid version: b061729afc07e77a8aa4fad0a2fd840958f1942a - name: golang.org/x/crypto - version: bc89c496413265e715159bdc8478ee9a92fdc265 + version: a548aac93ed489257b9d959b40fe1e8c1e20778c subpackages: - pkcs12 - pkcs12/internal/rc2 - name: golang.org/x/net - version: 4d38db76854b199960801a1734443fd02870d7e1 + version: 07b51741c1d6423d4a6abab1c49940ec09cb1aaf subpackages: - context - context/ctxhttp diff --git a/glide.yaml b/glide.yaml index 364cce1e..a27dcf61 100644 --- a/glide.yaml +++ b/glide.yaml @@ -33,3 +33,11 @@ import: - payload - payload/badge - package: github.com/DavidHuie/gomigrate +- package: github.com/boltdb/bolt + version: 583e8937c61f1af6513608ccc75c97b6abdf4ff9 +- package: github.com/micromdm/scep + version: master + subpackages: + - server + - depot + - depot/bolt diff --git a/vendor/github.com/boltdb/bolt/.gitignore b/vendor/github.com/boltdb/bolt/.gitignore new file mode 100644 index 00000000..c7bd2b7a --- /dev/null +++ b/vendor/github.com/boltdb/bolt/.gitignore @@ -0,0 +1,4 @@ +*.prof +*.test +*.swp +/bin/ diff --git a/vendor/github.com/boltdb/bolt/LICENSE b/vendor/github.com/boltdb/bolt/LICENSE new file mode 100644 index 00000000..004e77fe --- /dev/null +++ b/vendor/github.com/boltdb/bolt/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Ben Johnson + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/boltdb/bolt/Makefile b/vendor/github.com/boltdb/bolt/Makefile new file mode 100644 index 00000000..e035e63a --- /dev/null +++ b/vendor/github.com/boltdb/bolt/Makefile @@ -0,0 +1,18 @@ +BRANCH=`git rev-parse --abbrev-ref HEAD` +COMMIT=`git rev-parse --short HEAD` +GOLDFLAGS="-X main.branch $(BRANCH) -X main.commit $(COMMIT)" + +default: build + +race: + @go test -v -race -test.run="TestSimulate_(100op|1000op)" + +# go get github.com/kisielk/errcheck +errcheck: + @errcheck -ignorepkg=bytes -ignore=os:Remove github.com/boltdb/bolt + +test: + @go test -v -cover . + @go test -v ./cmd/bolt + +.PHONY: fmt test diff --git a/vendor/github.com/boltdb/bolt/README.md b/vendor/github.com/boltdb/bolt/README.md new file mode 100644 index 00000000..8523e337 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/README.md @@ -0,0 +1,852 @@ +Bolt [![Coverage Status](https://coveralls.io/repos/boltdb/bolt/badge.svg?branch=master)](https://coveralls.io/r/boltdb/bolt?branch=master) [![GoDoc](https://godoc.org/github.com/boltdb/bolt?status.svg)](https://godoc.org/github.com/boltdb/bolt) ![Version](https://img.shields.io/badge/version-1.2.1-green.svg) +==== + +Bolt is a pure Go key/value store inspired by [Howard Chu's][hyc_symas] +[LMDB project][lmdb]. The goal of the project is to provide a simple, +fast, and reliable database for projects that don't require a full database +server such as Postgres or MySQL. + +Since Bolt is meant to be used as such a low-level piece of functionality, +simplicity is key. The API will be small and only focus on getting values +and setting values. That's it. + +[hyc_symas]: https://twitter.com/hyc_symas +[lmdb]: http://symas.com/mdb/ + +## Project Status + +Bolt is stable and the API is fixed. Full unit test coverage and randomized +black box testing are used to ensure database consistency and thread safety. +Bolt is currently in high-load production environments serving databases as +large as 1TB. Many companies such as Shopify and Heroku use Bolt-backed +services every day. + +## Table of Contents + +- [Getting Started](#getting-started) + - [Installing](#installing) + - [Opening a database](#opening-a-database) + - [Transactions](#transactions) + - [Read-write transactions](#read-write-transactions) + - [Read-only transactions](#read-only-transactions) + - [Batch read-write transactions](#batch-read-write-transactions) + - [Managing transactions manually](#managing-transactions-manually) + - [Using buckets](#using-buckets) + - [Using key/value pairs](#using-keyvalue-pairs) + - [Autoincrementing integer for the bucket](#autoincrementing-integer-for-the-bucket) + - [Iterating over keys](#iterating-over-keys) + - [Prefix scans](#prefix-scans) + - [Range scans](#range-scans) + - [ForEach()](#foreach) + - [Nested buckets](#nested-buckets) + - [Database backups](#database-backups) + - [Statistics](#statistics) + - [Read-Only Mode](#read-only-mode) + - [Mobile Use (iOS/Android)](#mobile-use-iosandroid) +- [Resources](#resources) +- [Comparison with other databases](#comparison-with-other-databases) + - [Postgres, MySQL, & other relational databases](#postgres-mysql--other-relational-databases) + - [LevelDB, RocksDB](#leveldb-rocksdb) + - [LMDB](#lmdb) +- [Caveats & Limitations](#caveats--limitations) +- [Reading the Source](#reading-the-source) +- [Other Projects Using Bolt](#other-projects-using-bolt) + +## Getting Started + +### Installing + +To start using Bolt, install Go and run `go get`: + +```sh +$ go get github.com/boltdb/bolt/... +``` + +This will retrieve the library and install the `bolt` command line utility into +your `$GOBIN` path. + + +### Opening a database + +The top-level object in Bolt is a `DB`. It is represented as a single file on +your disk and represents a consistent snapshot of your data. + +To open your database, simply use the `bolt.Open()` function: + +```go +package main + +import ( + "log" + + "github.com/boltdb/bolt" +) + +func main() { + // Open the my.db data file in your current directory. + // It will be created if it doesn't exist. + db, err := bolt.Open("my.db", 0600, nil) + if err != nil { + log.Fatal(err) + } + defer db.Close() + + ... +} +``` + +Please note that Bolt obtains a file lock on the data file so multiple processes +cannot open the same database at the same time. Opening an already open Bolt +database will cause it to hang until the other process closes it. To prevent +an indefinite wait you can pass a timeout option to the `Open()` function: + +```go +db, err := bolt.Open("my.db", 0600, &bolt.Options{Timeout: 1 * time.Second}) +``` + + +### Transactions + +Bolt allows only one read-write transaction at a time but allows as many +read-only transactions as you want at a time. Each transaction has a consistent +view of the data as it existed when the transaction started. + +Individual transactions and all objects created from them (e.g. buckets, keys) +are not thread safe. To work with data in multiple goroutines you must start +a transaction for each one or use locking to ensure only one goroutine accesses +a transaction at a time. Creating transaction from the `DB` is thread safe. + +Read-only transactions and read-write transactions should not depend on one +another and generally shouldn't be opened simultaneously in the same goroutine. +This can cause a deadlock as the read-write transaction needs to periodically +re-map the data file but it cannot do so while a read-only transaction is open. + + +#### Read-write transactions + +To start a read-write transaction, you can use the `DB.Update()` function: + +```go +err := db.Update(func(tx *bolt.Tx) error { + ... + return nil +}) +``` + +Inside the closure, you have a consistent view of the database. You commit the +transaction by returning `nil` at the end. You can also rollback the transaction +at any point by returning an error. All database operations are allowed inside +a read-write transaction. + +Always check the return error as it will report any disk failures that can cause +your transaction to not complete. If you return an error within your closure +it will be passed through. + + +#### Read-only transactions + +To start a read-only transaction, you can use the `DB.View()` function: + +```go +err := db.View(func(tx *bolt.Tx) error { + ... + return nil +}) +``` + +You also get a consistent view of the database within this closure, however, +no mutating operations are allowed within a read-only transaction. You can only +retrieve buckets, retrieve values, and copy the database within a read-only +transaction. + + +#### Batch read-write transactions + +Each `DB.Update()` waits for disk to commit the writes. This overhead +can be minimized by combining multiple updates with the `DB.Batch()` +function: + +```go +err := db.Batch(func(tx *bolt.Tx) error { + ... + return nil +}) +``` + +Concurrent Batch calls are opportunistically combined into larger +transactions. Batch is only useful when there are multiple goroutines +calling it. + +The trade-off is that `Batch` can call the given +function multiple times, if parts of the transaction fail. The +function must be idempotent and side effects must take effect only +after a successful return from `DB.Batch()`. + +For example: don't display messages from inside the function, instead +set variables in the enclosing scope: + +```go +var id uint64 +err := db.Batch(func(tx *bolt.Tx) error { + // Find last key in bucket, decode as bigendian uint64, increment + // by one, encode back to []byte, and add new key. + ... + id = newValue + return nil +}) +if err != nil { + return ... +} +fmt.Println("Allocated ID %d", id) +``` + + +#### Managing transactions manually + +The `DB.View()` and `DB.Update()` functions are wrappers around the `DB.Begin()` +function. These helper functions will start the transaction, execute a function, +and then safely close your transaction if an error is returned. This is the +recommended way to use Bolt transactions. + +However, sometimes you may want to manually start and end your transactions. +You can use the `Tx.Begin()` function directly but **please** be sure to close +the transaction. + +```go +// Start a writable transaction. +tx, err := db.Begin(true) +if err != nil { + return err +} +defer tx.Rollback() + +// Use the transaction... +_, err := tx.CreateBucket([]byte("MyBucket")) +if err != nil { + return err +} + +// Commit the transaction and check for error. +if err := tx.Commit(); err != nil { + return err +} +``` + +The first argument to `DB.Begin()` is a boolean stating if the transaction +should be writable. + + +### Using buckets + +Buckets are collections of key/value pairs within the database. All keys in a +bucket must be unique. You can create a bucket using the `DB.CreateBucket()` +function: + +```go +db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("MyBucket")) + if err != nil { + return fmt.Errorf("create bucket: %s", err) + } + return nil +}) +``` + +You can also create a bucket only if it doesn't exist by using the +`Tx.CreateBucketIfNotExists()` function. It's a common pattern to call this +function for all your top-level buckets after you open your database so you can +guarantee that they exist for future transactions. + +To delete a bucket, simply call the `Tx.DeleteBucket()` function. + + +### Using key/value pairs + +To save a key/value pair to a bucket, use the `Bucket.Put()` function: + +```go +db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("MyBucket")) + err := b.Put([]byte("answer"), []byte("42")) + return err +}) +``` + +This will set the value of the `"answer"` key to `"42"` in the `MyBucket` +bucket. To retrieve this value, we can use the `Bucket.Get()` function: + +```go +db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("MyBucket")) + v := b.Get([]byte("answer")) + fmt.Printf("The answer is: %s\n", v) + return nil +}) +``` + +The `Get()` function does not return an error because its operation is +guaranteed to work (unless there is some kind of system failure). If the key +exists then it will return its byte slice value. If it doesn't exist then it +will return `nil`. It's important to note that you can have a zero-length value +set to a key which is different than the key not existing. + +Use the `Bucket.Delete()` function to delete a key from the bucket. + +Please note that values returned from `Get()` are only valid while the +transaction is open. If you need to use a value outside of the transaction +then you must use `copy()` to copy it to another byte slice. + + +### Autoincrementing integer for the bucket +By using the `NextSequence()` function, you can let Bolt determine a sequence +which can be used as the unique identifier for your key/value pairs. See the +example below. + +```go +// CreateUser saves u to the store. The new user ID is set on u once the data is persisted. +func (s *Store) CreateUser(u *User) error { + return s.db.Update(func(tx *bolt.Tx) error { + // Retrieve the users bucket. + // This should be created when the DB is first opened. + b := tx.Bucket([]byte("users")) + + // Generate ID for the user. + // This returns an error only if the Tx is closed or not writeable. + // That can't happen in an Update() call so I ignore the error check. + id, _ := b.NextSequence() + u.ID = int(id) + + // Marshal user data into bytes. + buf, err := json.Marshal(u) + if err != nil { + return err + } + + // Persist bytes to users bucket. + return b.Put(itob(u.ID), buf) + }) +} + +// itob returns an 8-byte big endian representation of v. +func itob(v int) []byte { + b := make([]byte, 8) + binary.BigEndian.PutUint64(b, uint64(v)) + return b +} + +type User struct { + ID int + ... +} +``` + +### Iterating over keys + +Bolt stores its keys in byte-sorted order within a bucket. This makes sequential +iteration over these keys extremely fast. To iterate over keys we'll use a +`Cursor`: + +```go +db.View(func(tx *bolt.Tx) error { + // Assume bucket exists and has keys + b := tx.Bucket([]byte("MyBucket")) + + c := b.Cursor() + + for k, v := c.First(); k != nil; k, v = c.Next() { + fmt.Printf("key=%s, value=%s\n", k, v) + } + + return nil +}) +``` + +The cursor allows you to move to a specific point in the list of keys and move +forward or backward through the keys one at a time. + +The following functions are available on the cursor: + +``` +First() Move to the first key. +Last() Move to the last key. +Seek() Move to a specific key. +Next() Move to the next key. +Prev() Move to the previous key. +``` + +Each of those functions has a return signature of `(key []byte, value []byte)`. +When you have iterated to the end of the cursor then `Next()` will return a +`nil` key. You must seek to a position using `First()`, `Last()`, or `Seek()` +before calling `Next()` or `Prev()`. If you do not seek to a position then +these functions will return a `nil` key. + +During iteration, if the key is non-`nil` but the value is `nil`, that means +the key refers to a bucket rather than a value. Use `Bucket.Bucket()` to +access the sub-bucket. + + +#### Prefix scans + +To iterate over a key prefix, you can combine `Seek()` and `bytes.HasPrefix()`: + +```go +db.View(func(tx *bolt.Tx) error { + // Assume bucket exists and has keys + c := tx.Bucket([]byte("MyBucket")).Cursor() + + prefix := []byte("1234") + for k, v := c.Seek(prefix); bytes.HasPrefix(k, prefix); k, v = c.Next() { + fmt.Printf("key=%s, value=%s\n", k, v) + } + + return nil +}) +``` + +#### Range scans + +Another common use case is scanning over a range such as a time range. If you +use a sortable time encoding such as RFC3339 then you can query a specific +date range like this: + +```go +db.View(func(tx *bolt.Tx) error { + // Assume our events bucket exists and has RFC3339 encoded time keys. + c := tx.Bucket([]byte("Events")).Cursor() + + // Our time range spans the 90's decade. + min := []byte("1990-01-01T00:00:00Z") + max := []byte("2000-01-01T00:00:00Z") + + // Iterate over the 90's. + for k, v := c.Seek(min); k != nil && bytes.Compare(k, max) <= 0; k, v = c.Next() { + fmt.Printf("%s: %s\n", k, v) + } + + return nil +}) +``` + +Note that, while RFC3339 is sortable, the Golang implementation of RFC3339Nano does not use a fixed number of digits after the decimal point and is therefore not sortable. + + +#### ForEach() + +You can also use the function `ForEach()` if you know you'll be iterating over +all the keys in a bucket: + +```go +db.View(func(tx *bolt.Tx) error { + // Assume bucket exists and has keys + b := tx.Bucket([]byte("MyBucket")) + + b.ForEach(func(k, v []byte) error { + fmt.Printf("key=%s, value=%s\n", k, v) + return nil + }) + return nil +}) +``` + + +### Nested buckets + +You can also store a bucket in a key to create nested buckets. The API is the +same as the bucket management API on the `DB` object: + +```go +func (*Bucket) CreateBucket(key []byte) (*Bucket, error) +func (*Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error) +func (*Bucket) DeleteBucket(key []byte) error +``` + + +### Database backups + +Bolt is a single file so it's easy to backup. You can use the `Tx.WriteTo()` +function to write a consistent view of the database to a writer. If you call +this from a read-only transaction, it will perform a hot backup and not block +your other database reads and writes. + +By default, it will use a regular file handle which will utilize the operating +system's page cache. See the [`Tx`](https://godoc.org/github.com/boltdb/bolt#Tx) +documentation for information about optimizing for larger-than-RAM datasets. + +One common use case is to backup over HTTP so you can use tools like `cURL` to +do database backups: + +```go +func BackupHandleFunc(w http.ResponseWriter, req *http.Request) { + err := db.View(func(tx *bolt.Tx) error { + w.Header().Set("Content-Type", "application/octet-stream") + w.Header().Set("Content-Disposition", `attachment; filename="my.db"`) + w.Header().Set("Content-Length", strconv.Itoa(int(tx.Size()))) + _, err := tx.WriteTo(w) + return err + }) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + } +} +``` + +Then you can backup using this command: + +```sh +$ curl http://localhost/backup > my.db +``` + +Or you can open your browser to `http://localhost/backup` and it will download +automatically. + +If you want to backup to another file you can use the `Tx.CopyFile()` helper +function. + + +### Statistics + +The database keeps a running count of many of the internal operations it +performs so you can better understand what's going on. By grabbing a snapshot +of these stats at two points in time we can see what operations were performed +in that time range. + +For example, we could start a goroutine to log stats every 10 seconds: + +```go +go func() { + // Grab the initial stats. + prev := db.Stats() + + for { + // Wait for 10s. + time.Sleep(10 * time.Second) + + // Grab the current stats and diff them. + stats := db.Stats() + diff := stats.Sub(&prev) + + // Encode stats to JSON and print to STDERR. + json.NewEncoder(os.Stderr).Encode(diff) + + // Save stats for the next loop. + prev = stats + } +}() +``` + +It's also useful to pipe these stats to a service such as statsd for monitoring +or to provide an HTTP endpoint that will perform a fixed-length sample. + + +### Read-Only Mode + +Sometimes it is useful to create a shared, read-only Bolt database. To this, +set the `Options.ReadOnly` flag when opening your database. Read-only mode +uses a shared lock to allow multiple processes to read from the database but +it will block any processes from opening the database in read-write mode. + +```go +db, err := bolt.Open("my.db", 0666, &bolt.Options{ReadOnly: true}) +if err != nil { + log.Fatal(err) +} +``` + +### Mobile Use (iOS/Android) + +Bolt is able to run on mobile devices by leveraging the binding feature of the +[gomobile](https://github.com/golang/mobile) tool. Create a struct that will +contain your database logic and a reference to a `*bolt.DB` with a initializing +constructor that takes in a filepath where the database file will be stored. +Neither Android nor iOS require extra permissions or cleanup from using this method. + +```go +func NewBoltDB(filepath string) *BoltDB { + db, err := bolt.Open(filepath+"/demo.db", 0600, nil) + if err != nil { + log.Fatal(err) + } + + return &BoltDB{db} +} + +type BoltDB struct { + db *bolt.DB + ... +} + +func (b *BoltDB) Path() string { + return b.db.Path() +} + +func (b *BoltDB) Close() { + b.db.Close() +} +``` + +Database logic should be defined as methods on this wrapper struct. + +To initialize this struct from the native language (both platforms now sync +their local storage to the cloud. These snippets disable that functionality for the +database file): + +#### Android + +```java +String path; +if (android.os.Build.VERSION.SDK_INT >=android.os.Build.VERSION_CODES.LOLLIPOP){ + path = getNoBackupFilesDir().getAbsolutePath(); +} else{ + path = getFilesDir().getAbsolutePath(); +} +Boltmobiledemo.BoltDB boltDB = Boltmobiledemo.NewBoltDB(path) +``` + +#### iOS + +```objc +- (void)demo { + NSString* path = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, + NSUserDomainMask, + YES) objectAtIndex:0]; + GoBoltmobiledemoBoltDB * demo = GoBoltmobiledemoNewBoltDB(path); + [self addSkipBackupAttributeToItemAtPath:demo.path]; + //Some DB Logic would go here + [demo close]; +} + +- (BOOL)addSkipBackupAttributeToItemAtPath:(NSString *) filePathString +{ + NSURL* URL= [NSURL fileURLWithPath: filePathString]; + assert([[NSFileManager defaultManager] fileExistsAtPath: [URL path]]); + + NSError *error = nil; + BOOL success = [URL setResourceValue: [NSNumber numberWithBool: YES] + forKey: NSURLIsExcludedFromBackupKey error: &error]; + if(!success){ + NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error); + } + return success; +} + +``` + +## Resources + +For more information on getting started with Bolt, check out the following articles: + +* [Intro to BoltDB: Painless Performant Persistence](http://npf.io/2014/07/intro-to-boltdb-painless-performant-persistence/) by [Nate Finch](https://github.com/natefinch). +* [Bolt -- an embedded key/value database for Go](https://www.progville.com/go/bolt-embedded-db-golang/) by Progville + + +## Comparison with other databases + +### Postgres, MySQL, & other relational databases + +Relational databases structure data into rows and are only accessible through +the use of SQL. This approach provides flexibility in how you store and query +your data but also incurs overhead in parsing and planning SQL statements. Bolt +accesses all data by a byte slice key. This makes Bolt fast to read and write +data by key but provides no built-in support for joining values together. + +Most relational databases (with the exception of SQLite) are standalone servers +that run separately from your application. This gives your systems +flexibility to connect multiple application servers to a single database +server but also adds overhead in serializing and transporting data over the +network. Bolt runs as a library included in your application so all data access +has to go through your application's process. This brings data closer to your +application but limits multi-process access to the data. + + +### LevelDB, RocksDB + +LevelDB and its derivatives (RocksDB, HyperLevelDB) are similar to Bolt in that +they are libraries bundled into the application, however, their underlying +structure is a log-structured merge-tree (LSM tree). An LSM tree optimizes +random writes by using a write ahead log and multi-tiered, sorted files called +SSTables. Bolt uses a B+tree internally and only a single file. Both approaches +have trade-offs. + +If you require a high random write throughput (>10,000 w/sec) or you need to use +spinning disks then LevelDB could be a good choice. If your application is +read-heavy or does a lot of range scans then Bolt could be a good choice. + +One other important consideration is that LevelDB does not have transactions. +It supports batch writing of key/values pairs and it supports read snapshots +but it will not give you the ability to do a compare-and-swap operation safely. +Bolt supports fully serializable ACID transactions. + + +### LMDB + +Bolt was originally a port of LMDB so it is architecturally similar. Both use +a B+tree, have ACID semantics with fully serializable transactions, and support +lock-free MVCC using a single writer and multiple readers. + +The two projects have somewhat diverged. LMDB heavily focuses on raw performance +while Bolt has focused on simplicity and ease of use. For example, LMDB allows +several unsafe actions such as direct writes for the sake of performance. Bolt +opts to disallow actions which can leave the database in a corrupted state. The +only exception to this in Bolt is `DB.NoSync`. + +There are also a few differences in API. LMDB requires a maximum mmap size when +opening an `mdb_env` whereas Bolt will handle incremental mmap resizing +automatically. LMDB overloads the getter and setter functions with multiple +flags whereas Bolt splits these specialized cases into their own functions. + + +## Caveats & Limitations + +It's important to pick the right tool for the job and Bolt is no exception. +Here are a few things to note when evaluating and using Bolt: + +* Bolt is good for read intensive workloads. Sequential write performance is + also fast but random writes can be slow. You can use `DB.Batch()` or add a + write-ahead log to help mitigate this issue. + +* Bolt uses a B+tree internally so there can be a lot of random page access. + SSDs provide a significant performance boost over spinning disks. + +* Try to avoid long running read transactions. Bolt uses copy-on-write so + old pages cannot be reclaimed while an old transaction is using them. + +* Byte slices returned from Bolt are only valid during a transaction. Once the + transaction has been committed or rolled back then the memory they point to + can be reused by a new page or can be unmapped from virtual memory and you'll + see an `unexpected fault address` panic when accessing it. + +* Be careful when using `Bucket.FillPercent`. Setting a high fill percent for + buckets that have random inserts will cause your database to have very poor + page utilization. + +* Use larger buckets in general. Smaller buckets causes poor page utilization + once they become larger than the page size (typically 4KB). + +* Bulk loading a lot of random writes into a new bucket can be slow as the + page will not split until the transaction is committed. Randomly inserting + more than 100,000 key/value pairs into a single new bucket in a single + transaction is not advised. + +* Bolt uses a memory-mapped file so the underlying operating system handles the + caching of the data. Typically, the OS will cache as much of the file as it + can in memory and will release memory as needed to other processes. This means + that Bolt can show very high memory usage when working with large databases. + However, this is expected and the OS will release memory as needed. Bolt can + handle databases much larger than the available physical RAM, provided its + memory-map fits in the process virtual address space. It may be problematic + on 32-bits systems. + +* The data structures in the Bolt database are memory mapped so the data file + will be endian specific. This means that you cannot copy a Bolt file from a + little endian machine to a big endian machine and have it work. For most + users this is not a concern since most modern CPUs are little endian. + +* Because of the way pages are laid out on disk, Bolt cannot truncate data files + and return free pages back to the disk. Instead, Bolt maintains a free list + of unused pages within its data file. These free pages can be reused by later + transactions. This works well for many use cases as databases generally tend + to grow. However, it's important to note that deleting large chunks of data + will not allow you to reclaim that space on disk. + + For more information on page allocation, [see this comment][page-allocation]. + +[page-allocation]: https://github.com/boltdb/bolt/issues/308#issuecomment-74811638 + + +## Reading the Source + +Bolt is a relatively small code base (<3KLOC) for an embedded, serializable, +transactional key/value database so it can be a good starting point for people +interested in how databases work. + +The best places to start are the main entry points into Bolt: + +- `Open()` - Initializes the reference to the database. It's responsible for + creating the database if it doesn't exist, obtaining an exclusive lock on the + file, reading the meta pages, & memory-mapping the file. + +- `DB.Begin()` - Starts a read-only or read-write transaction depending on the + value of the `writable` argument. This requires briefly obtaining the "meta" + lock to keep track of open transactions. Only one read-write transaction can + exist at a time so the "rwlock" is acquired during the life of a read-write + transaction. + +- `Bucket.Put()` - Writes a key/value pair into a bucket. After validating the + arguments, a cursor is used to traverse the B+tree to the page and position + where they key & value will be written. Once the position is found, the bucket + materializes the underlying page and the page's parent pages into memory as + "nodes". These nodes are where mutations occur during read-write transactions. + These changes get flushed to disk during commit. + +- `Bucket.Get()` - Retrieves a key/value pair from a bucket. This uses a cursor + to move to the page & position of a key/value pair. During a read-only + transaction, the key and value data is returned as a direct reference to the + underlying mmap file so there's no allocation overhead. For read-write + transactions, this data may reference the mmap file or one of the in-memory + node values. + +- `Cursor` - This object is simply for traversing the B+tree of on-disk pages + or in-memory nodes. It can seek to a specific key, move to the first or last + value, or it can move forward or backward. The cursor handles the movement up + and down the B+tree transparently to the end user. + +- `Tx.Commit()` - Converts the in-memory dirty nodes and the list of free pages + into pages to be written to disk. Writing to disk then occurs in two phases. + First, the dirty pages are written to disk and an `fsync()` occurs. Second, a + new meta page with an incremented transaction ID is written and another + `fsync()` occurs. This two phase write ensures that partially written data + pages are ignored in the event of a crash since the meta page pointing to them + is never written. Partially written meta pages are invalidated because they + are written with a checksum. + +If you have additional notes that could be helpful for others, please submit +them via pull request. + + +## Other Projects Using Bolt + +Below is a list of public, open source projects that use Bolt: + +* [BoltDbWeb](https://github.com/evnix/boltdbweb) - A web based GUI for BoltDB files. +* [Operation Go: A Routine Mission](http://gocode.io) - An online programming game for Golang using Bolt for user accounts and a leaderboard. +* [Bazil](https://bazil.org/) - A file system that lets your data reside where it is most convenient for it to reside. +* [DVID](https://github.com/janelia-flyem/dvid) - Added Bolt as optional storage engine and testing it against Basho-tuned leveldb. +* [Skybox Analytics](https://github.com/skybox/skybox) - A standalone funnel analysis tool for web analytics. +* [Scuttlebutt](https://github.com/benbjohnson/scuttlebutt) - Uses Bolt to store and process all Twitter mentions of GitHub projects. +* [Wiki](https://github.com/peterhellberg/wiki) - A tiny wiki using Goji, BoltDB and Blackfriday. +* [ChainStore](https://github.com/pressly/chainstore) - Simple key-value interface to a variety of storage engines organized as a chain of operations. +* [MetricBase](https://github.com/msiebuhr/MetricBase) - Single-binary version of Graphite. +* [Gitchain](https://github.com/gitchain/gitchain) - Decentralized, peer-to-peer Git repositories aka "Git meets Bitcoin". +* [event-shuttle](https://github.com/sclasen/event-shuttle) - A Unix system service to collect and reliably deliver messages to Kafka. +* [ipxed](https://github.com/kelseyhightower/ipxed) - Web interface and api for ipxed. +* [BoltStore](https://github.com/yosssi/boltstore) - Session store using Bolt. +* [photosite/session](https://godoc.org/bitbucket.org/kardianos/photosite/session) - Sessions for a photo viewing site. +* [LedisDB](https://github.com/siddontang/ledisdb) - A high performance NoSQL, using Bolt as optional storage. +* [ipLocator](https://github.com/AndreasBriese/ipLocator) - A fast ip-geo-location-server using bolt with bloom filters. +* [cayley](https://github.com/google/cayley) - Cayley is an open-source graph database using Bolt as optional backend. +* [bleve](http://www.blevesearch.com/) - A pure Go search engine similar to ElasticSearch that uses Bolt as the default storage backend. +* [tentacool](https://github.com/optiflows/tentacool) - REST api server to manage system stuff (IP, DNS, Gateway...) on a linux server. +* [Seaweed File System](https://github.com/chrislusf/seaweedfs) - Highly scalable distributed key~file system with O(1) disk read. +* [InfluxDB](https://influxdata.com) - Scalable datastore for metrics, events, and real-time analytics. +* [Freehold](http://tshannon.bitbucket.org/freehold/) - An open, secure, and lightweight platform for your files and data. +* [Prometheus Annotation Server](https://github.com/oliver006/prom_annotation_server) - Annotation server for PromDash & Prometheus service monitoring system. +* [Consul](https://github.com/hashicorp/consul) - Consul is service discovery and configuration made easy. Distributed, highly available, and datacenter-aware. +* [Kala](https://github.com/ajvb/kala) - Kala is a modern job scheduler optimized to run on a single node. It is persistent, JSON over HTTP API, ISO 8601 duration notation, and dependent jobs. +* [drive](https://github.com/odeke-em/drive) - drive is an unofficial Google Drive command line client for \*NIX operating systems. +* [stow](https://github.com/djherbis/stow) - a persistence manager for objects + backed by boltdb. +* [buckets](https://github.com/joyrexus/buckets) - a bolt wrapper streamlining + simple tx and key scans. +* [mbuckets](https://github.com/abhigupta912/mbuckets) - A Bolt wrapper that allows easy operations on multi level (nested) buckets. +* [Request Baskets](https://github.com/darklynx/request-baskets) - A web service to collect arbitrary HTTP requests and inspect them via REST API or simple web UI, similar to [RequestBin](http://requestb.in/) service +* [Go Report Card](https://goreportcard.com/) - Go code quality report cards as a (free and open source) service. +* [Boltdb Boilerplate](https://github.com/bobintornado/boltdb-boilerplate) - Boilerplate wrapper around bolt aiming to make simple calls one-liners. +* [lru](https://github.com/crowdriff/lru) - Easy to use Bolt-backed Least-Recently-Used (LRU) read-through cache with chainable remote stores. +* [Storm](https://github.com/asdine/storm) - Simple and powerful ORM for BoltDB. +* [GoWebApp](https://github.com/josephspurrier/gowebapp) - A basic MVC web application in Go using BoltDB. +* [SimpleBolt](https://github.com/xyproto/simplebolt) - A simple way to use BoltDB. Deals mainly with strings. +* [Algernon](https://github.com/xyproto/algernon) - A HTTP/2 web server with built-in support for Lua. Uses BoltDB as the default database backend. +* [MuLiFS](https://github.com/dankomiocevic/mulifs) - Music Library Filesystem creates a filesystem to organise your music files. +* [GoShort](https://github.com/pankajkhairnar/goShort) - GoShort is a URL shortener written in Golang and BoltDB for persistent key/value storage and for routing it's using high performent HTTPRouter. + +If you are using Bolt in a project please send a pull request to add it to the list. diff --git a/vendor/github.com/boltdb/bolt/appveyor.yml b/vendor/github.com/boltdb/bolt/appveyor.yml new file mode 100644 index 00000000..6e26e941 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/appveyor.yml @@ -0,0 +1,18 @@ +version: "{build}" + +os: Windows Server 2012 R2 + +clone_folder: c:\gopath\src\github.com\boltdb\bolt + +environment: + GOPATH: c:\gopath + +install: + - echo %PATH% + - echo %GOPATH% + - go version + - go env + - go get -v -t ./... + +build_script: + - go test -v ./... diff --git a/vendor/github.com/boltdb/bolt/bolt_386.go b/vendor/github.com/boltdb/bolt/bolt_386.go new file mode 100644 index 00000000..e659bfb9 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_386.go @@ -0,0 +1,7 @@ +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0x7FFFFFFF // 2GB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0xFFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_amd64.go b/vendor/github.com/boltdb/bolt/bolt_amd64.go new file mode 100644 index 00000000..cca6b7eb --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_amd64.go @@ -0,0 +1,7 @@ +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0xFFFFFFFFFFFF // 256TB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0x7FFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_arm.go b/vendor/github.com/boltdb/bolt/bolt_arm.go new file mode 100644 index 00000000..e659bfb9 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_arm.go @@ -0,0 +1,7 @@ +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0x7FFFFFFF // 2GB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0xFFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_arm64.go b/vendor/github.com/boltdb/bolt/bolt_arm64.go new file mode 100644 index 00000000..6d230935 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_arm64.go @@ -0,0 +1,9 @@ +// +build arm64 + +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0xFFFFFFFFFFFF // 256TB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0x7FFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_linux.go b/vendor/github.com/boltdb/bolt/bolt_linux.go new file mode 100644 index 00000000..2b676661 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_linux.go @@ -0,0 +1,10 @@ +package bolt + +import ( + "syscall" +) + +// fdatasync flushes written data to a file descriptor. +func fdatasync(db *DB) error { + return syscall.Fdatasync(int(db.file.Fd())) +} diff --git a/vendor/github.com/boltdb/bolt/bolt_openbsd.go b/vendor/github.com/boltdb/bolt/bolt_openbsd.go new file mode 100644 index 00000000..7058c3d7 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_openbsd.go @@ -0,0 +1,27 @@ +package bolt + +import ( + "syscall" + "unsafe" +) + +const ( + msAsync = 1 << iota // perform asynchronous writes + msSync // perform synchronous writes + msInvalidate // invalidate cached data +) + +func msync(db *DB) error { + _, _, errno := syscall.Syscall(syscall.SYS_MSYNC, uintptr(unsafe.Pointer(db.data)), uintptr(db.datasz), msInvalidate) + if errno != 0 { + return errno + } + return nil +} + +func fdatasync(db *DB) error { + if db.data != nil { + return msync(db) + } + return db.file.Sync() +} diff --git a/vendor/github.com/boltdb/bolt/bolt_ppc.go b/vendor/github.com/boltdb/bolt/bolt_ppc.go new file mode 100644 index 00000000..645ddc3e --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_ppc.go @@ -0,0 +1,9 @@ +// +build ppc + +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0x7FFFFFFF // 2GB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0xFFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_ppc64.go b/vendor/github.com/boltdb/bolt/bolt_ppc64.go new file mode 100644 index 00000000..2dc6be02 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_ppc64.go @@ -0,0 +1,9 @@ +// +build ppc64 + +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0xFFFFFFFFFFFF // 256TB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0x7FFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_ppc64le.go b/vendor/github.com/boltdb/bolt/bolt_ppc64le.go new file mode 100644 index 00000000..8351e129 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_ppc64le.go @@ -0,0 +1,9 @@ +// +build ppc64le + +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0xFFFFFFFFFFFF // 256TB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0x7FFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_s390x.go b/vendor/github.com/boltdb/bolt/bolt_s390x.go new file mode 100644 index 00000000..f4dd26bb --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_s390x.go @@ -0,0 +1,9 @@ +// +build s390x + +package bolt + +// maxMapSize represents the largest mmap size supported by Bolt. +const maxMapSize = 0xFFFFFFFFFFFF // 256TB + +// maxAllocSize is the size used when creating array pointers. +const maxAllocSize = 0x7FFFFFFF diff --git a/vendor/github.com/boltdb/bolt/bolt_unix.go b/vendor/github.com/boltdb/bolt/bolt_unix.go new file mode 100644 index 00000000..cad62dda --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_unix.go @@ -0,0 +1,89 @@ +// +build !windows,!plan9,!solaris + +package bolt + +import ( + "fmt" + "os" + "syscall" + "time" + "unsafe" +) + +// flock acquires an advisory lock on a file descriptor. +func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { + var t time.Time + for { + // If we're beyond our timeout then return an error. + // This can only occur after we've attempted a flock once. + if t.IsZero() { + t = time.Now() + } else if timeout > 0 && time.Since(t) > timeout { + return ErrTimeout + } + flag := syscall.LOCK_SH + if exclusive { + flag = syscall.LOCK_EX + } + + // Otherwise attempt to obtain an exclusive lock. + err := syscall.Flock(int(db.file.Fd()), flag|syscall.LOCK_NB) + if err == nil { + return nil + } else if err != syscall.EWOULDBLOCK { + return err + } + + // Wait for a bit and try again. + time.Sleep(50 * time.Millisecond) + } +} + +// funlock releases an advisory lock on a file descriptor. +func funlock(db *DB) error { + return syscall.Flock(int(db.file.Fd()), syscall.LOCK_UN) +} + +// mmap memory maps a DB's data file. +func mmap(db *DB, sz int) error { + // Map the data file to memory. + b, err := syscall.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) + if err != nil { + return err + } + + // Advise the kernel that the mmap is accessed randomly. + if err := madvise(b, syscall.MADV_RANDOM); err != nil { + return fmt.Errorf("madvise: %s", err) + } + + // Save the original byte slice and convert to a byte array pointer. + db.dataref = b + db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0])) + db.datasz = sz + return nil +} + +// munmap unmaps a DB's data file from memory. +func munmap(db *DB) error { + // Ignore the unmap if we have no mapped data. + if db.dataref == nil { + return nil + } + + // Unmap using the original byte slice. + err := syscall.Munmap(db.dataref) + db.dataref = nil + db.data = nil + db.datasz = 0 + return err +} + +// NOTE: This function is copied from stdlib because it is not available on darwin. +func madvise(b []byte, advice int) (err error) { + _, _, e1 := syscall.Syscall(syscall.SYS_MADVISE, uintptr(unsafe.Pointer(&b[0])), uintptr(len(b)), uintptr(advice)) + if e1 != 0 { + err = e1 + } + return +} diff --git a/vendor/github.com/boltdb/bolt/bolt_unix_solaris.go b/vendor/github.com/boltdb/bolt/bolt_unix_solaris.go new file mode 100644 index 00000000..307bf2b3 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_unix_solaris.go @@ -0,0 +1,90 @@ +package bolt + +import ( + "fmt" + "os" + "syscall" + "time" + "unsafe" + + "golang.org/x/sys/unix" +) + +// flock acquires an advisory lock on a file descriptor. +func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { + var t time.Time + for { + // If we're beyond our timeout then return an error. + // This can only occur after we've attempted a flock once. + if t.IsZero() { + t = time.Now() + } else if timeout > 0 && time.Since(t) > timeout { + return ErrTimeout + } + var lock syscall.Flock_t + lock.Start = 0 + lock.Len = 0 + lock.Pid = 0 + lock.Whence = 0 + lock.Pid = 0 + if exclusive { + lock.Type = syscall.F_WRLCK + } else { + lock.Type = syscall.F_RDLCK + } + err := syscall.FcntlFlock(db.file.Fd(), syscall.F_SETLK, &lock) + if err == nil { + return nil + } else if err != syscall.EAGAIN { + return err + } + + // Wait for a bit and try again. + time.Sleep(50 * time.Millisecond) + } +} + +// funlock releases an advisory lock on a file descriptor. +func funlock(db *DB) error { + var lock syscall.Flock_t + lock.Start = 0 + lock.Len = 0 + lock.Type = syscall.F_UNLCK + lock.Whence = 0 + return syscall.FcntlFlock(uintptr(db.file.Fd()), syscall.F_SETLK, &lock) +} + +// mmap memory maps a DB's data file. +func mmap(db *DB, sz int) error { + // Map the data file to memory. + b, err := unix.Mmap(int(db.file.Fd()), 0, sz, syscall.PROT_READ, syscall.MAP_SHARED|db.MmapFlags) + if err != nil { + return err + } + + // Advise the kernel that the mmap is accessed randomly. + if err := unix.Madvise(b, syscall.MADV_RANDOM); err != nil { + return fmt.Errorf("madvise: %s", err) + } + + // Save the original byte slice and convert to a byte array pointer. + db.dataref = b + db.data = (*[maxMapSize]byte)(unsafe.Pointer(&b[0])) + db.datasz = sz + return nil +} + +// munmap unmaps a DB's data file from memory. +func munmap(db *DB) error { + // Ignore the unmap if we have no mapped data. + if db.dataref == nil { + return nil + } + + // Unmap using the original byte slice. + err := unix.Munmap(db.dataref) + db.dataref = nil + db.data = nil + db.datasz = 0 + return err +} diff --git a/vendor/github.com/boltdb/bolt/bolt_windows.go b/vendor/github.com/boltdb/bolt/bolt_windows.go new file mode 100644 index 00000000..d538e6af --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bolt_windows.go @@ -0,0 +1,144 @@ +package bolt + +import ( + "fmt" + "os" + "syscall" + "time" + "unsafe" +) + +// LockFileEx code derived from golang build filemutex_windows.go @ v1.5.1 +var ( + modkernel32 = syscall.NewLazyDLL("kernel32.dll") + procLockFileEx = modkernel32.NewProc("LockFileEx") + procUnlockFileEx = modkernel32.NewProc("UnlockFileEx") +) + +const ( + lockExt = ".lock" + + // see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365203(v=vs.85).aspx + flagLockExclusive = 2 + flagLockFailImmediately = 1 + + // see https://msdn.microsoft.com/en-us/library/windows/desktop/ms681382(v=vs.85).aspx + errLockViolation syscall.Errno = 0x21 +) + +func lockFileEx(h syscall.Handle, flags, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) { + r, _, err := procLockFileEx.Call(uintptr(h), uintptr(flags), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol))) + if r == 0 { + return err + } + return nil +} + +func unlockFileEx(h syscall.Handle, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) { + r, _, err := procUnlockFileEx.Call(uintptr(h), uintptr(reserved), uintptr(locklow), uintptr(lockhigh), uintptr(unsafe.Pointer(ol)), 0) + if r == 0 { + return err + } + return nil +} + +// fdatasync flushes written data to a file descriptor. +func fdatasync(db *DB) error { + return db.file.Sync() +} + +// flock acquires an advisory lock on a file descriptor. +func flock(db *DB, mode os.FileMode, exclusive bool, timeout time.Duration) error { + // Create a separate lock file on windows because a process + // cannot share an exclusive lock on the same file. This is + // needed during Tx.WriteTo(). + f, err := os.OpenFile(db.path+lockExt, os.O_CREATE, mode) + if err != nil { + return err + } + db.lockfile = f + + var t time.Time + for { + // If we're beyond our timeout then return an error. + // This can only occur after we've attempted a flock once. + if t.IsZero() { + t = time.Now() + } else if timeout > 0 && time.Since(t) > timeout { + return ErrTimeout + } + + var flag uint32 = flagLockFailImmediately + if exclusive { + flag |= flagLockExclusive + } + + err := lockFileEx(syscall.Handle(db.lockfile.Fd()), flag, 0, 1, 0, &syscall.Overlapped{}) + if err == nil { + return nil + } else if err != errLockViolation { + return err + } + + // Wait for a bit and try again. + time.Sleep(50 * time.Millisecond) + } +} + +// funlock releases an advisory lock on a file descriptor. +func funlock(db *DB) error { + err := unlockFileEx(syscall.Handle(db.lockfile.Fd()), 0, 1, 0, &syscall.Overlapped{}) + db.lockfile.Close() + os.Remove(db.path+lockExt) + return err +} + +// mmap memory maps a DB's data file. +// Based on: https://github.com/edsrzf/mmap-go +func mmap(db *DB, sz int) error { + if !db.readOnly { + // Truncate the database to the size of the mmap. + if err := db.file.Truncate(int64(sz)); err != nil { + return fmt.Errorf("truncate: %s", err) + } + } + + // Open a file mapping handle. + sizelo := uint32(sz >> 32) + sizehi := uint32(sz) & 0xffffffff + h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizelo, sizehi, nil) + if h == 0 { + return os.NewSyscallError("CreateFileMapping", errno) + } + + // Create the memory map. + addr, errno := syscall.MapViewOfFile(h, syscall.FILE_MAP_READ, 0, 0, uintptr(sz)) + if addr == 0 { + return os.NewSyscallError("MapViewOfFile", errno) + } + + // Close mapping handle. + if err := syscall.CloseHandle(syscall.Handle(h)); err != nil { + return os.NewSyscallError("CloseHandle", err) + } + + // Convert to a byte array. + db.data = ((*[maxMapSize]byte)(unsafe.Pointer(addr))) + db.datasz = sz + + return nil +} + +// munmap unmaps a pointer from a file. +// Based on: https://github.com/edsrzf/mmap-go +func munmap(db *DB) error { + if db.data == nil { + return nil + } + + addr := (uintptr)(unsafe.Pointer(&db.data[0])) + if err := syscall.UnmapViewOfFile(addr); err != nil { + return os.NewSyscallError("UnmapViewOfFile", err) + } + return nil +} diff --git a/vendor/github.com/boltdb/bolt/boltsync_unix.go b/vendor/github.com/boltdb/bolt/boltsync_unix.go new file mode 100644 index 00000000..f5044252 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/boltsync_unix.go @@ -0,0 +1,8 @@ +// +build !windows,!plan9,!linux,!openbsd + +package bolt + +// fdatasync flushes written data to a file descriptor. +func fdatasync(db *DB) error { + return db.file.Sync() +} diff --git a/vendor/github.com/boltdb/bolt/bucket.go b/vendor/github.com/boltdb/bolt/bucket.go new file mode 100644 index 00000000..d2f8c524 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bucket.go @@ -0,0 +1,748 @@ +package bolt + +import ( + "bytes" + "fmt" + "unsafe" +) + +const ( + // MaxKeySize is the maximum length of a key, in bytes. + MaxKeySize = 32768 + + // MaxValueSize is the maximum length of a value, in bytes. + MaxValueSize = (1 << 31) - 2 +) + +const ( + maxUint = ^uint(0) + minUint = 0 + maxInt = int(^uint(0) >> 1) + minInt = -maxInt - 1 +) + +const bucketHeaderSize = int(unsafe.Sizeof(bucket{})) + +const ( + minFillPercent = 0.1 + maxFillPercent = 1.0 +) + +// DefaultFillPercent is the percentage that split pages are filled. +// This value can be changed by setting Bucket.FillPercent. +const DefaultFillPercent = 0.5 + +// Bucket represents a collection of key/value pairs inside the database. +type Bucket struct { + *bucket + tx *Tx // the associated transaction + buckets map[string]*Bucket // subbucket cache + page *page // inline page reference + rootNode *node // materialized node for the root page. + nodes map[pgid]*node // node cache + + // Sets the threshold for filling nodes when they split. By default, + // the bucket will fill to 50% but it can be useful to increase this + // amount if you know that your write workloads are mostly append-only. + // + // This is non-persisted across transactions so it must be set in every Tx. + FillPercent float64 +} + +// bucket represents the on-file representation of a bucket. +// This is stored as the "value" of a bucket key. If the bucket is small enough, +// then its root page can be stored inline in the "value", after the bucket +// header. In the case of inline buckets, the "root" will be 0. +type bucket struct { + root pgid // page id of the bucket's root-level page + sequence uint64 // monotonically incrementing, used by NextSequence() +} + +// newBucket returns a new bucket associated with a transaction. +func newBucket(tx *Tx) Bucket { + var b = Bucket{tx: tx, FillPercent: DefaultFillPercent} + if tx.writable { + b.buckets = make(map[string]*Bucket) + b.nodes = make(map[pgid]*node) + } + return b +} + +// Tx returns the tx of the bucket. +func (b *Bucket) Tx() *Tx { + return b.tx +} + +// Root returns the root of the bucket. +func (b *Bucket) Root() pgid { + return b.root +} + +// Writable returns whether the bucket is writable. +func (b *Bucket) Writable() bool { + return b.tx.writable +} + +// Cursor creates a cursor associated with the bucket. +// The cursor is only valid as long as the transaction is open. +// Do not use a cursor after the transaction is closed. +func (b *Bucket) Cursor() *Cursor { + // Update transaction statistics. + b.tx.stats.CursorCount++ + + // Allocate and return a cursor. + return &Cursor{ + bucket: b, + stack: make([]elemRef, 0), + } +} + +// Bucket retrieves a nested bucket by name. +// Returns nil if the bucket does not exist. +// The bucket instance is only valid for the lifetime of the transaction. +func (b *Bucket) Bucket(name []byte) *Bucket { + if b.buckets != nil { + if child := b.buckets[string(name)]; child != nil { + return child + } + } + + // Move cursor to key. + c := b.Cursor() + k, v, flags := c.seek(name) + + // Return nil if the key doesn't exist or it is not a bucket. + if !bytes.Equal(name, k) || (flags&bucketLeafFlag) == 0 { + return nil + } + + // Otherwise create a bucket and cache it. + var child = b.openBucket(v) + if b.buckets != nil { + b.buckets[string(name)] = child + } + + return child +} + +// Helper method that re-interprets a sub-bucket value +// from a parent into a Bucket +func (b *Bucket) openBucket(value []byte) *Bucket { + var child = newBucket(b.tx) + + // If this is a writable transaction then we need to copy the bucket entry. + // Read-only transactions can point directly at the mmap entry. + if b.tx.writable { + child.bucket = &bucket{} + *child.bucket = *(*bucket)(unsafe.Pointer(&value[0])) + } else { + child.bucket = (*bucket)(unsafe.Pointer(&value[0])) + } + + // Save a reference to the inline page if the bucket is inline. + if child.root == 0 { + child.page = (*page)(unsafe.Pointer(&value[bucketHeaderSize])) + } + + return &child +} + +// CreateBucket creates a new bucket at the given key and returns the new bucket. +// Returns an error if the key already exists, if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. +func (b *Bucket) CreateBucket(key []byte) (*Bucket, error) { + if b.tx.db == nil { + return nil, ErrTxClosed + } else if !b.tx.writable { + return nil, ErrTxNotWritable + } else if len(key) == 0 { + return nil, ErrBucketNameRequired + } + + // Move cursor to correct position. + c := b.Cursor() + k, _, flags := c.seek(key) + + // Return an error if there is an existing key. + if bytes.Equal(key, k) { + if (flags & bucketLeafFlag) != 0 { + return nil, ErrBucketExists + } else { + return nil, ErrIncompatibleValue + } + } + + // Create empty, inline bucket. + var bucket = Bucket{ + bucket: &bucket{}, + rootNode: &node{isLeaf: true}, + FillPercent: DefaultFillPercent, + } + var value = bucket.write() + + // Insert into node. + key = cloneBytes(key) + c.node().put(key, key, value, 0, bucketLeafFlag) + + // Since subbuckets are not allowed on inline buckets, we need to + // dereference the inline page, if it exists. This will cause the bucket + // to be treated as a regular, non-inline bucket for the rest of the tx. + b.page = nil + + return b.Bucket(key), nil +} + +// CreateBucketIfNotExists creates a new bucket if it doesn't already exist and returns a reference to it. +// Returns an error if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. +func (b *Bucket) CreateBucketIfNotExists(key []byte) (*Bucket, error) { + child, err := b.CreateBucket(key) + if err == ErrBucketExists { + return b.Bucket(key), nil + } else if err != nil { + return nil, err + } + return child, nil +} + +// DeleteBucket deletes a bucket at the given key. +// Returns an error if the bucket does not exists, or if the key represents a non-bucket value. +func (b *Bucket) DeleteBucket(key []byte) error { + if b.tx.db == nil { + return ErrTxClosed + } else if !b.Writable() { + return ErrTxNotWritable + } + + // Move cursor to correct position. + c := b.Cursor() + k, _, flags := c.seek(key) + + // Return an error if bucket doesn't exist or is not a bucket. + if !bytes.Equal(key, k) { + return ErrBucketNotFound + } else if (flags & bucketLeafFlag) == 0 { + return ErrIncompatibleValue + } + + // Recursively delete all child buckets. + child := b.Bucket(key) + err := child.ForEach(func(k, v []byte) error { + if v == nil { + if err := child.DeleteBucket(k); err != nil { + return fmt.Errorf("delete bucket: %s", err) + } + } + return nil + }) + if err != nil { + return err + } + + // Remove cached copy. + delete(b.buckets, string(key)) + + // Release all bucket pages to freelist. + child.nodes = nil + child.rootNode = nil + child.free() + + // Delete the node if we have a matching key. + c.node().del(key) + + return nil +} + +// Get retrieves the value for a key in the bucket. +// Returns a nil value if the key does not exist or if the key is a nested bucket. +// The returned value is only valid for the life of the transaction. +func (b *Bucket) Get(key []byte) []byte { + k, v, flags := b.Cursor().seek(key) + + // Return nil if this is a bucket. + if (flags & bucketLeafFlag) != 0 { + return nil + } + + // If our target node isn't the same key as what's passed in then return nil. + if !bytes.Equal(key, k) { + return nil + } + return v +} + +// Put sets the value for a key in the bucket. +// If the key exist then its previous value will be overwritten. +// Supplied value must remain valid for the life of the transaction. +// Returns an error if the bucket was created from a read-only transaction, if the key is blank, if the key is too large, or if the value is too large. +func (b *Bucket) Put(key []byte, value []byte) error { + if b.tx.db == nil { + return ErrTxClosed + } else if !b.Writable() { + return ErrTxNotWritable + } else if len(key) == 0 { + return ErrKeyRequired + } else if len(key) > MaxKeySize { + return ErrKeyTooLarge + } else if int64(len(value)) > MaxValueSize { + return ErrValueTooLarge + } + + // Move cursor to correct position. + c := b.Cursor() + k, _, flags := c.seek(key) + + // Return an error if there is an existing key with a bucket value. + if bytes.Equal(key, k) && (flags&bucketLeafFlag) != 0 { + return ErrIncompatibleValue + } + + // Insert into node. + key = cloneBytes(key) + c.node().put(key, key, value, 0, 0) + + return nil +} + +// Delete removes a key from the bucket. +// If the key does not exist then nothing is done and a nil error is returned. +// Returns an error if the bucket was created from a read-only transaction. +func (b *Bucket) Delete(key []byte) error { + if b.tx.db == nil { + return ErrTxClosed + } else if !b.Writable() { + return ErrTxNotWritable + } + + // Move cursor to correct position. + c := b.Cursor() + _, _, flags := c.seek(key) + + // Return an error if there is already existing bucket value. + if (flags & bucketLeafFlag) != 0 { + return ErrIncompatibleValue + } + + // Delete the node if we have a matching key. + c.node().del(key) + + return nil +} + +// NextSequence returns an autoincrementing integer for the bucket. +func (b *Bucket) NextSequence() (uint64, error) { + if b.tx.db == nil { + return 0, ErrTxClosed + } else if !b.Writable() { + return 0, ErrTxNotWritable + } + + // Materialize the root node if it hasn't been already so that the + // bucket will be saved during commit. + if b.rootNode == nil { + _ = b.node(b.root, nil) + } + + // Increment and return the sequence. + b.bucket.sequence++ + return b.bucket.sequence, nil +} + +// ForEach executes a function for each key/value pair in a bucket. +// If the provided function returns an error then the iteration is stopped and +// the error is returned to the caller. The provided function must not modify +// the bucket; this will result in undefined behavior. +func (b *Bucket) ForEach(fn func(k, v []byte) error) error { + if b.tx.db == nil { + return ErrTxClosed + } + c := b.Cursor() + for k, v := c.First(); k != nil; k, v = c.Next() { + if err := fn(k, v); err != nil { + return err + } + } + return nil +} + +// Stat returns stats on a bucket. +func (b *Bucket) Stats() BucketStats { + var s, subStats BucketStats + pageSize := b.tx.db.pageSize + s.BucketN += 1 + if b.root == 0 { + s.InlineBucketN += 1 + } + b.forEachPage(func(p *page, depth int) { + if (p.flags & leafPageFlag) != 0 { + s.KeyN += int(p.count) + + // used totals the used bytes for the page + used := pageHeaderSize + + if p.count != 0 { + // If page has any elements, add all element headers. + used += leafPageElementSize * int(p.count-1) + + // Add all element key, value sizes. + // The computation takes advantage of the fact that the position + // of the last element's key/value equals to the total of the sizes + // of all previous elements' keys and values. + // It also includes the last element's header. + lastElement := p.leafPageElement(p.count - 1) + used += int(lastElement.pos + lastElement.ksize + lastElement.vsize) + } + + if b.root == 0 { + // For inlined bucket just update the inline stats + s.InlineBucketInuse += used + } else { + // For non-inlined bucket update all the leaf stats + s.LeafPageN++ + s.LeafInuse += used + s.LeafOverflowN += int(p.overflow) + + // Collect stats from sub-buckets. + // Do that by iterating over all element headers + // looking for the ones with the bucketLeafFlag. + for i := uint16(0); i < p.count; i++ { + e := p.leafPageElement(i) + if (e.flags & bucketLeafFlag) != 0 { + // For any bucket element, open the element value + // and recursively call Stats on the contained bucket. + subStats.Add(b.openBucket(e.value()).Stats()) + } + } + } + } else if (p.flags & branchPageFlag) != 0 { + s.BranchPageN++ + lastElement := p.branchPageElement(p.count - 1) + + // used totals the used bytes for the page + // Add header and all element headers. + used := pageHeaderSize + (branchPageElementSize * int(p.count-1)) + + // Add size of all keys and values. + // Again, use the fact that last element's position equals to + // the total of key, value sizes of all previous elements. + used += int(lastElement.pos + lastElement.ksize) + s.BranchInuse += used + s.BranchOverflowN += int(p.overflow) + } + + // Keep track of maximum page depth. + if depth+1 > s.Depth { + s.Depth = (depth + 1) + } + }) + + // Alloc stats can be computed from page counts and pageSize. + s.BranchAlloc = (s.BranchPageN + s.BranchOverflowN) * pageSize + s.LeafAlloc = (s.LeafPageN + s.LeafOverflowN) * pageSize + + // Add the max depth of sub-buckets to get total nested depth. + s.Depth += subStats.Depth + // Add the stats for all sub-buckets + s.Add(subStats) + return s +} + +// forEachPage iterates over every page in a bucket, including inline pages. +func (b *Bucket) forEachPage(fn func(*page, int)) { + // If we have an inline page then just use that. + if b.page != nil { + fn(b.page, 0) + return + } + + // Otherwise traverse the page hierarchy. + b.tx.forEachPage(b.root, 0, fn) +} + +// forEachPageNode iterates over every page (or node) in a bucket. +// This also includes inline pages. +func (b *Bucket) forEachPageNode(fn func(*page, *node, int)) { + // If we have an inline page or root node then just use that. + if b.page != nil { + fn(b.page, nil, 0) + return + } + b._forEachPageNode(b.root, 0, fn) +} + +func (b *Bucket) _forEachPageNode(pgid pgid, depth int, fn func(*page, *node, int)) { + var p, n = b.pageNode(pgid) + + // Execute function. + fn(p, n, depth) + + // Recursively loop over children. + if p != nil { + if (p.flags & branchPageFlag) != 0 { + for i := 0; i < int(p.count); i++ { + elem := p.branchPageElement(uint16(i)) + b._forEachPageNode(elem.pgid, depth+1, fn) + } + } + } else { + if !n.isLeaf { + for _, inode := range n.inodes { + b._forEachPageNode(inode.pgid, depth+1, fn) + } + } + } +} + +// spill writes all the nodes for this bucket to dirty pages. +func (b *Bucket) spill() error { + // Spill all child buckets first. + for name, child := range b.buckets { + // If the child bucket is small enough and it has no child buckets then + // write it inline into the parent bucket's page. Otherwise spill it + // like a normal bucket and make the parent value a pointer to the page. + var value []byte + if child.inlineable() { + child.free() + value = child.write() + } else { + if err := child.spill(); err != nil { + return err + } + + // Update the child bucket header in this bucket. + value = make([]byte, unsafe.Sizeof(bucket{})) + var bucket = (*bucket)(unsafe.Pointer(&value[0])) + *bucket = *child.bucket + } + + // Skip writing the bucket if there are no materialized nodes. + if child.rootNode == nil { + continue + } + + // Update parent node. + var c = b.Cursor() + k, _, flags := c.seek([]byte(name)) + if !bytes.Equal([]byte(name), k) { + panic(fmt.Sprintf("misplaced bucket header: %x -> %x", []byte(name), k)) + } + if flags&bucketLeafFlag == 0 { + panic(fmt.Sprintf("unexpected bucket header flag: %x", flags)) + } + c.node().put([]byte(name), []byte(name), value, 0, bucketLeafFlag) + } + + // Ignore if there's not a materialized root node. + if b.rootNode == nil { + return nil + } + + // Spill nodes. + if err := b.rootNode.spill(); err != nil { + return err + } + b.rootNode = b.rootNode.root() + + // Update the root node for this bucket. + if b.rootNode.pgid >= b.tx.meta.pgid { + panic(fmt.Sprintf("pgid (%d) above high water mark (%d)", b.rootNode.pgid, b.tx.meta.pgid)) + } + b.root = b.rootNode.pgid + + return nil +} + +// inlineable returns true if a bucket is small enough to be written inline +// and if it contains no subbuckets. Otherwise returns false. +func (b *Bucket) inlineable() bool { + var n = b.rootNode + + // Bucket must only contain a single leaf node. + if n == nil || !n.isLeaf { + return false + } + + // Bucket is not inlineable if it contains subbuckets or if it goes beyond + // our threshold for inline bucket size. + var size = pageHeaderSize + for _, inode := range n.inodes { + size += leafPageElementSize + len(inode.key) + len(inode.value) + + if inode.flags&bucketLeafFlag != 0 { + return false + } else if size > b.maxInlineBucketSize() { + return false + } + } + + return true +} + +// Returns the maximum total size of a bucket to make it a candidate for inlining. +func (b *Bucket) maxInlineBucketSize() int { + return b.tx.db.pageSize / 4 +} + +// write allocates and writes a bucket to a byte slice. +func (b *Bucket) write() []byte { + // Allocate the appropriate size. + var n = b.rootNode + var value = make([]byte, bucketHeaderSize+n.size()) + + // Write a bucket header. + var bucket = (*bucket)(unsafe.Pointer(&value[0])) + *bucket = *b.bucket + + // Convert byte slice to a fake page and write the root node. + var p = (*page)(unsafe.Pointer(&value[bucketHeaderSize])) + n.write(p) + + return value +} + +// rebalance attempts to balance all nodes. +func (b *Bucket) rebalance() { + for _, n := range b.nodes { + n.rebalance() + } + for _, child := range b.buckets { + child.rebalance() + } +} + +// node creates a node from a page and associates it with a given parent. +func (b *Bucket) node(pgid pgid, parent *node) *node { + _assert(b.nodes != nil, "nodes map expected") + + // Retrieve node if it's already been created. + if n := b.nodes[pgid]; n != nil { + return n + } + + // Otherwise create a node and cache it. + n := &node{bucket: b, parent: parent} + if parent == nil { + b.rootNode = n + } else { + parent.children = append(parent.children, n) + } + + // Use the inline page if this is an inline bucket. + var p = b.page + if p == nil { + p = b.tx.page(pgid) + } + + // Read the page into the node and cache it. + n.read(p) + b.nodes[pgid] = n + + // Update statistics. + b.tx.stats.NodeCount++ + + return n +} + +// free recursively frees all pages in the bucket. +func (b *Bucket) free() { + if b.root == 0 { + return + } + + var tx = b.tx + b.forEachPageNode(func(p *page, n *node, _ int) { + if p != nil { + tx.db.freelist.free(tx.meta.txid, p) + } else { + n.free() + } + }) + b.root = 0 +} + +// dereference removes all references to the old mmap. +func (b *Bucket) dereference() { + if b.rootNode != nil { + b.rootNode.root().dereference() + } + + for _, child := range b.buckets { + child.dereference() + } +} + +// pageNode returns the in-memory node, if it exists. +// Otherwise returns the underlying page. +func (b *Bucket) pageNode(id pgid) (*page, *node) { + // Inline buckets have a fake page embedded in their value so treat them + // differently. We'll return the rootNode (if available) or the fake page. + if b.root == 0 { + if id != 0 { + panic(fmt.Sprintf("inline bucket non-zero page access(2): %d != 0", id)) + } + if b.rootNode != nil { + return nil, b.rootNode + } + return b.page, nil + } + + // Check the node cache for non-inline buckets. + if b.nodes != nil { + if n := b.nodes[id]; n != nil { + return nil, n + } + } + + // Finally lookup the page from the transaction if no node is materialized. + return b.tx.page(id), nil +} + +// BucketStats records statistics about resources used by a bucket. +type BucketStats struct { + // Page count statistics. + BranchPageN int // number of logical branch pages + BranchOverflowN int // number of physical branch overflow pages + LeafPageN int // number of logical leaf pages + LeafOverflowN int // number of physical leaf overflow pages + + // Tree statistics. + KeyN int // number of keys/value pairs + Depth int // number of levels in B+tree + + // Page size utilization. + BranchAlloc int // bytes allocated for physical branch pages + BranchInuse int // bytes actually used for branch data + LeafAlloc int // bytes allocated for physical leaf pages + LeafInuse int // bytes actually used for leaf data + + // Bucket statistics + BucketN int // total number of buckets including the top bucket + InlineBucketN int // total number on inlined buckets + InlineBucketInuse int // bytes used for inlined buckets (also accounted for in LeafInuse) +} + +func (s *BucketStats) Add(other BucketStats) { + s.BranchPageN += other.BranchPageN + s.BranchOverflowN += other.BranchOverflowN + s.LeafPageN += other.LeafPageN + s.LeafOverflowN += other.LeafOverflowN + s.KeyN += other.KeyN + if s.Depth < other.Depth { + s.Depth = other.Depth + } + s.BranchAlloc += other.BranchAlloc + s.BranchInuse += other.BranchInuse + s.LeafAlloc += other.LeafAlloc + s.LeafInuse += other.LeafInuse + + s.BucketN += other.BucketN + s.InlineBucketN += other.InlineBucketN + s.InlineBucketInuse += other.InlineBucketInuse +} + +// cloneBytes returns a copy of a given slice. +func cloneBytes(v []byte) []byte { + var clone = make([]byte, len(v)) + copy(clone, v) + return clone +} diff --git a/vendor/github.com/boltdb/bolt/bucket_test.go b/vendor/github.com/boltdb/bolt/bucket_test.go new file mode 100644 index 00000000..528fec24 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/bucket_test.go @@ -0,0 +1,1867 @@ +package bolt_test + +import ( + "bytes" + "encoding/binary" + "errors" + "fmt" + "log" + "math/rand" + "os" + "strconv" + "strings" + "testing" + "testing/quick" + + "github.com/boltdb/bolt" +) + +// Ensure that a bucket that gets a non-existent key returns nil. +func TestBucket_Get_NonExistent(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if v := b.Get([]byte("foo")); v != nil { + t.Fatal("expected nil value") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can read a value that is not flushed yet. +func TestBucket_Get_FromNode(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if v := b.Get([]byte("foo")); !bytes.Equal(v, []byte("bar")) { + t.Fatalf("unexpected value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket retrieved via Get() returns a nil. +func TestBucket_Get_IncompatibleValue(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if _, err := tx.Bucket([]byte("widgets")).CreateBucket([]byte("foo")); err != nil { + t.Fatal(err) + } + + if tx.Bucket([]byte("widgets")).Get([]byte("foo")) != nil { + t.Fatal("expected nil value") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a slice returned from a bucket has a capacity equal to its length. +// This also allows slices to be appended to since it will require a realloc by Go. +// +// https://github.com/boltdb/bolt/issues/544 +func TestBucket_Get_Capacity(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + // Write key to a bucket. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("bucket")) + if err != nil { + return err + } + return b.Put([]byte("key"), []byte("val")) + }); err != nil { + t.Fatal(err) + } + + // Retrieve value and attempt to append to it. + if err := db.Update(func(tx *bolt.Tx) error { + k, v := tx.Bucket([]byte("bucket")).Cursor().First() + + // Verify capacity. + if len(k) != cap(k) { + t.Fatalf("unexpected key slice capacity: %d", cap(k)) + } else if len(v) != cap(v) { + t.Fatalf("unexpected value slice capacity: %d", cap(v)) + } + + // Ensure slice can be appended to without a segfault. + k = append(k, []byte("123")...) + v = append(v, []byte("123")...) + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can write a key/value. +func TestBucket_Put(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + + v := tx.Bucket([]byte("widgets")).Get([]byte("foo")) + if !bytes.Equal([]byte("bar"), v) { + t.Fatalf("unexpected value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can rewrite a key in the same transaction. +func TestBucket_Put_Repeat(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("baz")); err != nil { + t.Fatal(err) + } + + value := tx.Bucket([]byte("widgets")).Get([]byte("foo")) + if !bytes.Equal([]byte("baz"), value) { + t.Fatalf("unexpected value: %v", value) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can write a bunch of large values. +func TestBucket_Put_Large(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + count, factor := 100, 200 + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + for i := 1; i < count; i++ { + if err := b.Put([]byte(strings.Repeat("0", i*factor)), []byte(strings.Repeat("X", (count-i)*factor))); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for i := 1; i < count; i++ { + value := b.Get([]byte(strings.Repeat("0", i*factor))) + if !bytes.Equal(value, []byte(strings.Repeat("X", (count-i)*factor))) { + t.Fatalf("unexpected value: %v", value) + } + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a database can perform multiple large appends safely. +func TestDB_Put_VeryLarge(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + n, batchN := 400000, 200000 + ksize, vsize := 8, 500 + + db := MustOpenDB() + defer db.MustClose() + + for i := 0; i < n; i += batchN { + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucketIfNotExists([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + for j := 0; j < batchN; j++ { + k, v := make([]byte, ksize), make([]byte, vsize) + binary.BigEndian.PutUint32(k, uint32(i+j)) + if err := b.Put(k, v); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + } +} + +// Ensure that a setting a value on a key with a bucket value returns an error. +func TestBucket_Put_IncompatibleValue(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b0, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if _, err := tx.Bucket([]byte("widgets")).CreateBucket([]byte("foo")); err != nil { + t.Fatal(err) + } + if err := b0.Put([]byte("foo"), []byte("bar")); err != bolt.ErrIncompatibleValue { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a setting a value while the transaction is closed returns an error. +func TestBucket_Put_Closed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + + if err := b.Put([]byte("foo"), []byte("bar")); err != bolt.ErrTxClosed { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that setting a value on a read-only bucket returns an error. +func TestBucket_Put_ReadOnly(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + if err := b.Put([]byte("foo"), []byte("bar")); err != bolt.ErrTxNotWritable { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can delete an existing key. +func TestBucket_Delete(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if err := b.Delete([]byte("foo")); err != nil { + t.Fatal(err) + } + if v := b.Get([]byte("foo")); v != nil { + t.Fatalf("unexpected value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that deleting a large set of keys will work correctly. +func TestBucket_Delete_Large(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + for i := 0; i < 100; i++ { + if err := b.Put([]byte(strconv.Itoa(i)), []byte(strings.Repeat("*", 1024))); err != nil { + t.Fatal(err) + } + } + + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for i := 0; i < 100; i++ { + if err := b.Delete([]byte(strconv.Itoa(i))); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for i := 0; i < 100; i++ { + if v := b.Get([]byte(strconv.Itoa(i))); v != nil { + t.Fatalf("unexpected value: %v, i=%d", v, i) + } + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Deleting a very large list of keys will cause the freelist to use overflow. +func TestBucket_Delete_FreelistOverflow(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + db := MustOpenDB() + defer db.MustClose() + + k := make([]byte, 16) + for i := uint64(0); i < 10000; i++ { + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucketIfNotExists([]byte("0")) + if err != nil { + t.Fatalf("bucket error: %s", err) + } + + for j := uint64(0); j < 1000; j++ { + binary.BigEndian.PutUint64(k[:8], i) + binary.BigEndian.PutUint64(k[8:], j) + if err := b.Put(k, nil); err != nil { + t.Fatalf("put error: %s", err) + } + } + + return nil + }); err != nil { + t.Fatal(err) + } + } + + // Delete all of them in one large transaction + if err := db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("0")) + c := b.Cursor() + for k, _ := c.First(); k != nil; k, _ = c.Next() { + if err := c.Delete(); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that accessing and updating nested buckets is ok across transactions. +func TestBucket_Nested(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + // Create a widgets bucket. + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + // Create a widgets/foo bucket. + _, err = b.CreateBucket([]byte("foo")) + if err != nil { + t.Fatal(err) + } + + // Create a widgets/bar key. + if err := b.Put([]byte("bar"), []byte("0000")); err != nil { + t.Fatal(err) + } + + return nil + }); err != nil { + t.Fatal(err) + } + db.MustCheck() + + // Update widgets/bar. + if err := db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + if err := b.Put([]byte("bar"), []byte("xxxx")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + db.MustCheck() + + // Cause a split. + if err := db.Update(func(tx *bolt.Tx) error { + var b = tx.Bucket([]byte("widgets")) + for i := 0; i < 10000; i++ { + if err := b.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + db.MustCheck() + + // Insert into widgets/foo/baz. + if err := db.Update(func(tx *bolt.Tx) error { + var b = tx.Bucket([]byte("widgets")) + if err := b.Bucket([]byte("foo")).Put([]byte("baz"), []byte("yyyy")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + db.MustCheck() + + // Verify. + if err := db.View(func(tx *bolt.Tx) error { + var b = tx.Bucket([]byte("widgets")) + if v := b.Bucket([]byte("foo")).Get([]byte("baz")); !bytes.Equal(v, []byte("yyyy")) { + t.Fatalf("unexpected value: %v", v) + } + if v := b.Get([]byte("bar")); !bytes.Equal(v, []byte("xxxx")) { + t.Fatalf("unexpected value: %v", v) + } + for i := 0; i < 10000; i++ { + if v := b.Get([]byte(strconv.Itoa(i))); !bytes.Equal(v, []byte(strconv.Itoa(i))) { + t.Fatalf("unexpected value: %v", v) + } + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that deleting a bucket using Delete() returns an error. +func TestBucket_Delete_Bucket(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if _, err := b.CreateBucket([]byte("foo")); err != nil { + t.Fatal(err) + } + if err := b.Delete([]byte("foo")); err != bolt.ErrIncompatibleValue { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that deleting a key on a read-only bucket returns an error. +func TestBucket_Delete_ReadOnly(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + if err := tx.Bucket([]byte("widgets")).Delete([]byte("foo")); err != bolt.ErrTxNotWritable { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a deleting value while the transaction is closed returns an error. +func TestBucket_Delete_Closed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + if err := b.Delete([]byte("foo")); err != bolt.ErrTxClosed { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that deleting a bucket causes nested buckets to be deleted. +func TestBucket_DeleteBucket_Nested(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + widgets, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + foo, err := widgets.CreateBucket([]byte("foo")) + if err != nil { + t.Fatal(err) + } + + bar, err := foo.CreateBucket([]byte("bar")) + if err != nil { + t.Fatal(err) + } + if err := bar.Put([]byte("baz"), []byte("bat")); err != nil { + t.Fatal(err) + } + if err := tx.Bucket([]byte("widgets")).DeleteBucket([]byte("foo")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that deleting a bucket causes nested buckets to be deleted after they have been committed. +func TestBucket_DeleteBucket_Nested2(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + widgets, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + foo, err := widgets.CreateBucket([]byte("foo")) + if err != nil { + t.Fatal(err) + } + + bar, err := foo.CreateBucket([]byte("bar")) + if err != nil { + t.Fatal(err) + } + + if err := bar.Put([]byte("baz"), []byte("bat")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + widgets := tx.Bucket([]byte("widgets")) + if widgets == nil { + t.Fatal("expected widgets bucket") + } + + foo := widgets.Bucket([]byte("foo")) + if foo == nil { + t.Fatal("expected foo bucket") + } + + bar := foo.Bucket([]byte("bar")) + if bar == nil { + t.Fatal("expected bar bucket") + } + + if v := bar.Get([]byte("baz")); !bytes.Equal(v, []byte("bat")) { + t.Fatalf("unexpected value: %v", v) + } + if err := tx.DeleteBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + if tx.Bucket([]byte("widgets")) != nil { + t.Fatal("expected bucket to be deleted") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that deleting a child bucket with multiple pages causes all pages to get collected. +// NOTE: Consistency check in bolt_test.DB.Close() will panic if pages not freed properly. +func TestBucket_DeleteBucket_Large(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + widgets, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + foo, err := widgets.CreateBucket([]byte("foo")) + if err != nil { + t.Fatal(err) + } + + for i := 0; i < 1000; i++ { + if err := foo.Put([]byte(fmt.Sprintf("%d", i)), []byte(fmt.Sprintf("%0100d", i))); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + if err := tx.DeleteBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a simple value retrieved via Bucket() returns a nil. +func TestBucket_Bucket_IncompatibleValue(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + widgets, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if err := widgets.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if b := tx.Bucket([]byte("widgets")).Bucket([]byte("foo")); b != nil { + t.Fatal("expected nil bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that creating a bucket on an existing non-bucket key returns an error. +func TestBucket_CreateBucket_IncompatibleValue(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + widgets, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if err := widgets.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if _, err := widgets.CreateBucket([]byte("foo")); err != bolt.ErrIncompatibleValue { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that deleting a bucket on an existing non-bucket key returns an error. +func TestBucket_DeleteBucket_IncompatibleValue(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + widgets, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := widgets.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if err := tx.Bucket([]byte("widgets")).DeleteBucket([]byte("foo")); err != bolt.ErrIncompatibleValue { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can return an autoincrementing sequence. +func TestBucket_NextSequence(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + widgets, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + woojits, err := tx.CreateBucket([]byte("woojits")) + if err != nil { + t.Fatal(err) + } + + // Make sure sequence increments. + if seq, err := widgets.NextSequence(); err != nil { + t.Fatal(err) + } else if seq != 1 { + t.Fatalf("unexpecte sequence: %d", seq) + } + + if seq, err := widgets.NextSequence(); err != nil { + t.Fatal(err) + } else if seq != 2 { + t.Fatalf("unexpected sequence: %d", seq) + } + + // Buckets should be separate. + if seq, err := woojits.NextSequence(); err != nil { + t.Fatal(err) + } else if seq != 1 { + t.Fatalf("unexpected sequence: %d", 1) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket will persist an autoincrementing sequence even if its +// the only thing updated on the bucket. +// https://github.com/boltdb/bolt/issues/296 +func TestBucket_NextSequence_Persist(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.Bucket([]byte("widgets")).NextSequence(); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + seq, err := tx.Bucket([]byte("widgets")).NextSequence() + if err != nil { + t.Fatalf("unexpected error: %s", err) + } else if seq != 2 { + t.Fatalf("unexpected sequence: %d", seq) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that retrieving the next sequence on a read-only bucket returns an error. +func TestBucket_NextSequence_ReadOnly(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + _, err := tx.Bucket([]byte("widgets")).NextSequence() + if err != bolt.ErrTxNotWritable { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that retrieving the next sequence for a bucket on a closed database return an error. +func TestBucket_NextSequence_Closed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + if _, err := b.NextSequence(); err != bolt.ErrTxClosed { + t.Fatal(err) + } +} + +// Ensure a user can loop over all key/value pairs in a bucket. +func TestBucket_ForEach(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("0000")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte("0001")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("bar"), []byte("0002")); err != nil { + t.Fatal(err) + } + + var index int + if err := b.ForEach(func(k, v []byte) error { + switch index { + case 0: + if !bytes.Equal(k, []byte("bar")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte("0002")) { + t.Fatalf("unexpected value: %v", v) + } + case 1: + if !bytes.Equal(k, []byte("baz")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte("0001")) { + t.Fatalf("unexpected value: %v", v) + } + case 2: + if !bytes.Equal(k, []byte("foo")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte("0000")) { + t.Fatalf("unexpected value: %v", v) + } + } + index++ + return nil + }); err != nil { + t.Fatal(err) + } + + if index != 3 { + t.Fatalf("unexpected index: %d", index) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a database can stop iteration early. +func TestBucket_ForEach_ShortCircuit(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("bar"), []byte("0000")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte("0000")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("0000")); err != nil { + t.Fatal(err) + } + + var index int + if err := tx.Bucket([]byte("widgets")).ForEach(func(k, v []byte) error { + index++ + if bytes.Equal(k, []byte("baz")) { + return errors.New("marker") + } + return nil + }); err == nil || err.Error() != "marker" { + t.Fatalf("unexpected error: %s", err) + } + if index != 2 { + t.Fatalf("unexpected index: %d", index) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that looping over a bucket on a closed database returns an error. +func TestBucket_ForEach_Closed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + + if err := b.ForEach(func(k, v []byte) error { return nil }); err != bolt.ErrTxClosed { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that an error is returned when inserting with an empty key. +func TestBucket_Put_EmptyKey(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte(""), []byte("bar")); err != bolt.ErrKeyRequired { + t.Fatalf("unexpected error: %s", err) + } + if err := b.Put(nil, []byte("bar")); err != bolt.ErrKeyRequired { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that an error is returned when inserting with a key that's too large. +func TestBucket_Put_KeyTooLarge(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put(make([]byte, 32769), []byte("bar")); err != bolt.ErrKeyTooLarge { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that an error is returned when inserting a value that's too large. +func TestBucket_Put_ValueTooLarge(t *testing.T) { + // Skip this test on DroneCI because the machine is resource constrained. + if os.Getenv("DRONE") == "true" { + t.Skip("not enough RAM for test") + } + + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), make([]byte, bolt.MaxValueSize+1)); err != bolt.ErrValueTooLarge { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a bucket can calculate stats. +func TestBucket_Stats(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + // Add bucket with fewer keys but one big value. + bigKey := []byte("really-big-value") + for i := 0; i < 500; i++ { + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucketIfNotExists([]byte("woojits")) + if err != nil { + t.Fatal(err) + } + + if err := b.Put([]byte(fmt.Sprintf("%03d", i)), []byte(strconv.Itoa(i))); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + } + if err := db.Update(func(tx *bolt.Tx) error { + if err := tx.Bucket([]byte("woojits")).Put(bigKey, []byte(strings.Repeat("*", 10000))); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + db.MustCheck() + + if err := db.View(func(tx *bolt.Tx) error { + stats := tx.Bucket([]byte("woojits")).Stats() + if stats.BranchPageN != 1 { + t.Fatalf("unexpected BranchPageN: %d", stats.BranchPageN) + } else if stats.BranchOverflowN != 0 { + t.Fatalf("unexpected BranchOverflowN: %d", stats.BranchOverflowN) + } else if stats.LeafPageN != 7 { + t.Fatalf("unexpected LeafPageN: %d", stats.LeafPageN) + } else if stats.LeafOverflowN != 2 { + t.Fatalf("unexpected LeafOverflowN: %d", stats.LeafOverflowN) + } else if stats.KeyN != 501 { + t.Fatalf("unexpected KeyN: %d", stats.KeyN) + } else if stats.Depth != 2 { + t.Fatalf("unexpected Depth: %d", stats.Depth) + } + + branchInuse := 16 // branch page header + branchInuse += 7 * 16 // branch elements + branchInuse += 7 * 3 // branch keys (6 3-byte keys) + if stats.BranchInuse != branchInuse { + t.Fatalf("unexpected BranchInuse: %d", stats.BranchInuse) + } + + leafInuse := 7 * 16 // leaf page header + leafInuse += 501 * 16 // leaf elements + leafInuse += 500*3 + len(bigKey) // leaf keys + leafInuse += 1*10 + 2*90 + 3*400 + 10000 // leaf values + if stats.LeafInuse != leafInuse { + t.Fatalf("unexpected LeafInuse: %d", stats.LeafInuse) + } + + // Only check allocations for 4KB pages. + if os.Getpagesize() == 4096 { + if stats.BranchAlloc != 4096 { + t.Fatalf("unexpected BranchAlloc: %d", stats.BranchAlloc) + } else if stats.LeafAlloc != 36864 { + t.Fatalf("unexpected LeafAlloc: %d", stats.LeafAlloc) + } + } + + if stats.BucketN != 1 { + t.Fatalf("unexpected BucketN: %d", stats.BucketN) + } else if stats.InlineBucketN != 0 { + t.Fatalf("unexpected InlineBucketN: %d", stats.InlineBucketN) + } else if stats.InlineBucketInuse != 0 { + t.Fatalf("unexpected InlineBucketInuse: %d", stats.InlineBucketInuse) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a bucket with random insertion utilizes fill percentage correctly. +func TestBucket_Stats_RandomFill(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } else if os.Getpagesize() != 4096 { + t.Skip("invalid page size for test") + } + + db := MustOpenDB() + defer db.MustClose() + + // Add a set of values in random order. It will be the same random + // order so we can maintain consistency between test runs. + var count int + rand := rand.New(rand.NewSource(42)) + for _, i := range rand.Perm(1000) { + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucketIfNotExists([]byte("woojits")) + if err != nil { + t.Fatal(err) + } + b.FillPercent = 0.9 + for _, j := range rand.Perm(100) { + index := (j * 10000) + i + if err := b.Put([]byte(fmt.Sprintf("%d000000000000000", index)), []byte("0000000000")); err != nil { + t.Fatal(err) + } + count++ + } + return nil + }); err != nil { + t.Fatal(err) + } + } + + db.MustCheck() + + if err := db.View(func(tx *bolt.Tx) error { + stats := tx.Bucket([]byte("woojits")).Stats() + if stats.KeyN != 100000 { + t.Fatalf("unexpected KeyN: %d", stats.KeyN) + } + + if stats.BranchPageN != 98 { + t.Fatalf("unexpected BranchPageN: %d", stats.BranchPageN) + } else if stats.BranchOverflowN != 0 { + t.Fatalf("unexpected BranchOverflowN: %d", stats.BranchOverflowN) + } else if stats.BranchInuse != 130984 { + t.Fatalf("unexpected BranchInuse: %d", stats.BranchInuse) + } else if stats.BranchAlloc != 401408 { + t.Fatalf("unexpected BranchAlloc: %d", stats.BranchAlloc) + } + + if stats.LeafPageN != 3412 { + t.Fatalf("unexpected LeafPageN: %d", stats.LeafPageN) + } else if stats.LeafOverflowN != 0 { + t.Fatalf("unexpected LeafOverflowN: %d", stats.LeafOverflowN) + } else if stats.LeafInuse != 4742482 { + t.Fatalf("unexpected LeafInuse: %d", stats.LeafInuse) + } else if stats.LeafAlloc != 13975552 { + t.Fatalf("unexpected LeafAlloc: %d", stats.LeafAlloc) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a bucket can calculate stats. +func TestBucket_Stats_Small(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + // Add a bucket that fits on a single root leaf. + b, err := tx.CreateBucket([]byte("whozawhats")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + + return nil + }); err != nil { + t.Fatal(err) + } + + db.MustCheck() + + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("whozawhats")) + stats := b.Stats() + if stats.BranchPageN != 0 { + t.Fatalf("unexpected BranchPageN: %d", stats.BranchPageN) + } else if stats.BranchOverflowN != 0 { + t.Fatalf("unexpected BranchOverflowN: %d", stats.BranchOverflowN) + } else if stats.LeafPageN != 0 { + t.Fatalf("unexpected LeafPageN: %d", stats.LeafPageN) + } else if stats.LeafOverflowN != 0 { + t.Fatalf("unexpected LeafOverflowN: %d", stats.LeafOverflowN) + } else if stats.KeyN != 1 { + t.Fatalf("unexpected KeyN: %d", stats.KeyN) + } else if stats.Depth != 1 { + t.Fatalf("unexpected Depth: %d", stats.Depth) + } else if stats.BranchInuse != 0 { + t.Fatalf("unexpected BranchInuse: %d", stats.BranchInuse) + } else if stats.LeafInuse != 0 { + t.Fatalf("unexpected LeafInuse: %d", stats.LeafInuse) + } + + if os.Getpagesize() == 4096 { + if stats.BranchAlloc != 0 { + t.Fatalf("unexpected BranchAlloc: %d", stats.BranchAlloc) + } else if stats.LeafAlloc != 0 { + t.Fatalf("unexpected LeafAlloc: %d", stats.LeafAlloc) + } + } + + if stats.BucketN != 1 { + t.Fatalf("unexpected BucketN: %d", stats.BucketN) + } else if stats.InlineBucketN != 1 { + t.Fatalf("unexpected InlineBucketN: %d", stats.InlineBucketN) + } else if stats.InlineBucketInuse != 16+16+6 { + t.Fatalf("unexpected InlineBucketInuse: %d", stats.InlineBucketInuse) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +func TestBucket_Stats_EmptyBucket(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + // Add a bucket that fits on a single root leaf. + if _, err := tx.CreateBucket([]byte("whozawhats")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + db.MustCheck() + + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("whozawhats")) + stats := b.Stats() + if stats.BranchPageN != 0 { + t.Fatalf("unexpected BranchPageN: %d", stats.BranchPageN) + } else if stats.BranchOverflowN != 0 { + t.Fatalf("unexpected BranchOverflowN: %d", stats.BranchOverflowN) + } else if stats.LeafPageN != 0 { + t.Fatalf("unexpected LeafPageN: %d", stats.LeafPageN) + } else if stats.LeafOverflowN != 0 { + t.Fatalf("unexpected LeafOverflowN: %d", stats.LeafOverflowN) + } else if stats.KeyN != 0 { + t.Fatalf("unexpected KeyN: %d", stats.KeyN) + } else if stats.Depth != 1 { + t.Fatalf("unexpected Depth: %d", stats.Depth) + } else if stats.BranchInuse != 0 { + t.Fatalf("unexpected BranchInuse: %d", stats.BranchInuse) + } else if stats.LeafInuse != 0 { + t.Fatalf("unexpected LeafInuse: %d", stats.LeafInuse) + } + + if os.Getpagesize() == 4096 { + if stats.BranchAlloc != 0 { + t.Fatalf("unexpected BranchAlloc: %d", stats.BranchAlloc) + } else if stats.LeafAlloc != 0 { + t.Fatalf("unexpected LeafAlloc: %d", stats.LeafAlloc) + } + } + + if stats.BucketN != 1 { + t.Fatalf("unexpected BucketN: %d", stats.BucketN) + } else if stats.InlineBucketN != 1 { + t.Fatalf("unexpected InlineBucketN: %d", stats.InlineBucketN) + } else if stats.InlineBucketInuse != 16 { + t.Fatalf("unexpected InlineBucketInuse: %d", stats.InlineBucketInuse) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a bucket can calculate stats. +func TestBucket_Stats_Nested(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("foo")) + if err != nil { + t.Fatal(err) + } + for i := 0; i < 100; i++ { + if err := b.Put([]byte(fmt.Sprintf("%02d", i)), []byte(fmt.Sprintf("%02d", i))); err != nil { + t.Fatal(err) + } + } + + bar, err := b.CreateBucket([]byte("bar")) + if err != nil { + t.Fatal(err) + } + for i := 0; i < 10; i++ { + if err := bar.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))); err != nil { + t.Fatal(err) + } + } + + baz, err := bar.CreateBucket([]byte("baz")) + if err != nil { + t.Fatal(err) + } + for i := 0; i < 10; i++ { + if err := baz.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))); err != nil { + t.Fatal(err) + } + } + + return nil + }); err != nil { + t.Fatal(err) + } + + db.MustCheck() + + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("foo")) + stats := b.Stats() + if stats.BranchPageN != 0 { + t.Fatalf("unexpected BranchPageN: %d", stats.BranchPageN) + } else if stats.BranchOverflowN != 0 { + t.Fatalf("unexpected BranchOverflowN: %d", stats.BranchOverflowN) + } else if stats.LeafPageN != 2 { + t.Fatalf("unexpected LeafPageN: %d", stats.LeafPageN) + } else if stats.LeafOverflowN != 0 { + t.Fatalf("unexpected LeafOverflowN: %d", stats.LeafOverflowN) + } else if stats.KeyN != 122 { + t.Fatalf("unexpected KeyN: %d", stats.KeyN) + } else if stats.Depth != 3 { + t.Fatalf("unexpected Depth: %d", stats.Depth) + } else if stats.BranchInuse != 0 { + t.Fatalf("unexpected BranchInuse: %d", stats.BranchInuse) + } + + foo := 16 // foo (pghdr) + foo += 101 * 16 // foo leaf elements + foo += 100*2 + 100*2 // foo leaf key/values + foo += 3 + 16 // foo -> bar key/value + + bar := 16 // bar (pghdr) + bar += 11 * 16 // bar leaf elements + bar += 10 + 10 // bar leaf key/values + bar += 3 + 16 // bar -> baz key/value + + baz := 16 // baz (inline) (pghdr) + baz += 10 * 16 // baz leaf elements + baz += 10 + 10 // baz leaf key/values + + if stats.LeafInuse != foo+bar+baz { + t.Fatalf("unexpected LeafInuse: %d", stats.LeafInuse) + } + + if os.Getpagesize() == 4096 { + if stats.BranchAlloc != 0 { + t.Fatalf("unexpected BranchAlloc: %d", stats.BranchAlloc) + } else if stats.LeafAlloc != 8192 { + t.Fatalf("unexpected LeafAlloc: %d", stats.LeafAlloc) + } + } + + if stats.BucketN != 3 { + t.Fatalf("unexpected BucketN: %d", stats.BucketN) + } else if stats.InlineBucketN != 1 { + t.Fatalf("unexpected InlineBucketN: %d", stats.InlineBucketN) + } else if stats.InlineBucketInuse != baz { + t.Fatalf("unexpected InlineBucketInuse: %d", stats.InlineBucketInuse) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a large bucket can calculate stats. +func TestBucket_Stats_Large(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + db := MustOpenDB() + defer db.MustClose() + + var index int + for i := 0; i < 100; i++ { + // Add bucket with lots of keys. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucketIfNotExists([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + for i := 0; i < 1000; i++ { + if err := b.Put([]byte(strconv.Itoa(index)), []byte(strconv.Itoa(index))); err != nil { + t.Fatal(err) + } + index++ + } + return nil + }); err != nil { + t.Fatal(err) + } + } + + db.MustCheck() + + if err := db.View(func(tx *bolt.Tx) error { + stats := tx.Bucket([]byte("widgets")).Stats() + if stats.BranchPageN != 13 { + t.Fatalf("unexpected BranchPageN: %d", stats.BranchPageN) + } else if stats.BranchOverflowN != 0 { + t.Fatalf("unexpected BranchOverflowN: %d", stats.BranchOverflowN) + } else if stats.LeafPageN != 1196 { + t.Fatalf("unexpected LeafPageN: %d", stats.LeafPageN) + } else if stats.LeafOverflowN != 0 { + t.Fatalf("unexpected LeafOverflowN: %d", stats.LeafOverflowN) + } else if stats.KeyN != 100000 { + t.Fatalf("unexpected KeyN: %d", stats.KeyN) + } else if stats.Depth != 3 { + t.Fatalf("unexpected Depth: %d", stats.Depth) + } else if stats.BranchInuse != 25257 { + t.Fatalf("unexpected BranchInuse: %d", stats.BranchInuse) + } else if stats.LeafInuse != 2596916 { + t.Fatalf("unexpected LeafInuse: %d", stats.LeafInuse) + } + + if os.Getpagesize() == 4096 { + if stats.BranchAlloc != 53248 { + t.Fatalf("unexpected BranchAlloc: %d", stats.BranchAlloc) + } else if stats.LeafAlloc != 4898816 { + t.Fatalf("unexpected LeafAlloc: %d", stats.LeafAlloc) + } + } + + if stats.BucketN != 1 { + t.Fatalf("unexpected BucketN: %d", stats.BucketN) + } else if stats.InlineBucketN != 0 { + t.Fatalf("unexpected InlineBucketN: %d", stats.InlineBucketN) + } else if stats.InlineBucketInuse != 0 { + t.Fatalf("unexpected InlineBucketInuse: %d", stats.InlineBucketInuse) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can write random keys and values across multiple transactions. +func TestBucket_Put_Single(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + index := 0 + if err := quick.Check(func(items testdata) bool { + db := MustOpenDB() + defer db.MustClose() + + m := make(map[string][]byte) + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + for _, item := range items { + if err := db.Update(func(tx *bolt.Tx) error { + if err := tx.Bucket([]byte("widgets")).Put(item.Key, item.Value); err != nil { + panic("put error: " + err.Error()) + } + m[string(item.Key)] = item.Value + return nil + }); err != nil { + t.Fatal(err) + } + + // Verify all key/values so far. + if err := db.View(func(tx *bolt.Tx) error { + i := 0 + for k, v := range m { + value := tx.Bucket([]byte("widgets")).Get([]byte(k)) + if !bytes.Equal(value, v) { + t.Logf("value mismatch [run %d] (%d of %d):\nkey: %x\ngot: %x\nexp: %x", index, i, len(m), []byte(k), value, v) + db.CopyTempFile() + t.FailNow() + } + i++ + } + return nil + }); err != nil { + t.Fatal(err) + } + } + + index++ + return true + }, nil); err != nil { + t.Error(err) + } +} + +// Ensure that a transaction can insert multiple key/value pairs at once. +func TestBucket_Put_Multiple(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + if err := quick.Check(func(items testdata) bool { + db := MustOpenDB() + defer db.MustClose() + + // Bulk insert all values. + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for _, item := range items { + if err := b.Put(item.Key, item.Value); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Verify all items exist. + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for _, item := range items { + value := b.Get(item.Key) + if !bytes.Equal(item.Value, value) { + db.CopyTempFile() + t.Fatalf("exp=%x; got=%x", item.Value, value) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + return true + }, qconfig()); err != nil { + t.Error(err) + } +} + +// Ensure that a transaction can delete all key/value pairs and return to a single leaf page. +func TestBucket_Delete_Quick(t *testing.T) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + if err := quick.Check(func(items testdata) bool { + db := MustOpenDB() + defer db.MustClose() + + // Bulk insert all values. + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for _, item := range items { + if err := b.Put(item.Key, item.Value); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Remove items one at a time and check consistency. + for _, item := range items { + if err := db.Update(func(tx *bolt.Tx) error { + return tx.Bucket([]byte("widgets")).Delete(item.Key) + }); err != nil { + t.Fatal(err) + } + } + + // Anything before our deletion index should be nil. + if err := db.View(func(tx *bolt.Tx) error { + if err := tx.Bucket([]byte("widgets")).ForEach(func(k, v []byte) error { + t.Fatalf("bucket should be empty; found: %06x", trunc(k, 3)) + return nil + }); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + return true + }, qconfig()); err != nil { + t.Error(err) + } +} + +func ExampleBucket_Put() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Start a write transaction. + if err := db.Update(func(tx *bolt.Tx) error { + // Create a bucket. + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + return err + } + + // Set the value "bar" for the key "foo". + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + return err + } + return nil + }); err != nil { + log.Fatal(err) + } + + // Read value back in a different read-only transaction. + if err := db.View(func(tx *bolt.Tx) error { + value := tx.Bucket([]byte("widgets")).Get([]byte("foo")) + fmt.Printf("The value of 'foo' is: %s\n", value) + return nil + }); err != nil { + log.Fatal(err) + } + + // Close database to release file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // The value of 'foo' is: bar +} + +func ExampleBucket_Delete() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Start a write transaction. + if err := db.Update(func(tx *bolt.Tx) error { + // Create a bucket. + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + return err + } + + // Set the value "bar" for the key "foo". + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + return err + } + + // Retrieve the key back from the database and verify it. + value := b.Get([]byte("foo")) + fmt.Printf("The value of 'foo' was: %s\n", value) + + return nil + }); err != nil { + log.Fatal(err) + } + + // Delete the key in a different write transaction. + if err := db.Update(func(tx *bolt.Tx) error { + return tx.Bucket([]byte("widgets")).Delete([]byte("foo")) + }); err != nil { + log.Fatal(err) + } + + // Retrieve the key again. + if err := db.View(func(tx *bolt.Tx) error { + value := tx.Bucket([]byte("widgets")).Get([]byte("foo")) + if value == nil { + fmt.Printf("The value of 'foo' is now: nil\n") + } + return nil + }); err != nil { + log.Fatal(err) + } + + // Close database to release file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // The value of 'foo' was: bar + // The value of 'foo' is now: nil +} + +func ExampleBucket_ForEach() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Insert data into a bucket. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("animals")) + if err != nil { + return err + } + + if err := b.Put([]byte("dog"), []byte("fun")); err != nil { + return err + } + if err := b.Put([]byte("cat"), []byte("lame")); err != nil { + return err + } + if err := b.Put([]byte("liger"), []byte("awesome")); err != nil { + return err + } + + // Iterate over items in sorted key order. + if err := b.ForEach(func(k, v []byte) error { + fmt.Printf("A %s is %s.\n", k, v) + return nil + }); err != nil { + return err + } + + return nil + }); err != nil { + log.Fatal(err) + } + + // Close database to release file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // A cat is lame. + // A dog is fun. + // A liger is awesome. +} diff --git a/vendor/github.com/boltdb/bolt/cmd/bolt/main.go b/vendor/github.com/boltdb/bolt/cmd/bolt/main.go new file mode 100644 index 00000000..b96e6f73 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/cmd/bolt/main.go @@ -0,0 +1,1532 @@ +package main + +import ( + "bytes" + "encoding/binary" + "errors" + "flag" + "fmt" + "io" + "io/ioutil" + "math/rand" + "os" + "runtime" + "runtime/pprof" + "strconv" + "strings" + "time" + "unicode" + "unicode/utf8" + "unsafe" + + "github.com/boltdb/bolt" +) + +var ( + // ErrUsage is returned when a usage message was printed and the process + // should simply exit with an error. + ErrUsage = errors.New("usage") + + // ErrUnknownCommand is returned when a CLI command is not specified. + ErrUnknownCommand = errors.New("unknown command") + + // ErrPathRequired is returned when the path to a Bolt database is not specified. + ErrPathRequired = errors.New("path required") + + // ErrFileNotFound is returned when a Bolt database does not exist. + ErrFileNotFound = errors.New("file not found") + + // ErrInvalidValue is returned when a benchmark reads an unexpected value. + ErrInvalidValue = errors.New("invalid value") + + // ErrCorrupt is returned when a checking a data file finds errors. + ErrCorrupt = errors.New("invalid value") + + // ErrNonDivisibleBatchSize is returned when the batch size can't be evenly + // divided by the iteration count. + ErrNonDivisibleBatchSize = errors.New("number of iterations must be divisible by the batch size") + + // ErrPageIDRequired is returned when a required page id is not specified. + ErrPageIDRequired = errors.New("page id required") + + // ErrPageNotFound is returned when specifying a page above the high water mark. + ErrPageNotFound = errors.New("page not found") + + // ErrPageFreed is returned when reading a page that has already been freed. + ErrPageFreed = errors.New("page freed") +) + +// PageHeaderSize represents the size of the bolt.page header. +const PageHeaderSize = 16 + +func main() { + m := NewMain() + if err := m.Run(os.Args[1:]...); err == ErrUsage { + os.Exit(2) + } else if err != nil { + fmt.Println(err.Error()) + os.Exit(1) + } +} + +// Main represents the main program execution. +type Main struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// NewMain returns a new instance of Main connect to the standard input/output. +func NewMain() *Main { + return &Main{ + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + } +} + +// Run executes the program. +func (m *Main) Run(args ...string) error { + // Require a command at the beginning. + if len(args) == 0 || strings.HasPrefix(args[0], "-") { + fmt.Fprintln(m.Stderr, m.Usage()) + return ErrUsage + } + + // Execute command. + switch args[0] { + case "help": + fmt.Fprintln(m.Stderr, m.Usage()) + return ErrUsage + case "bench": + return newBenchCommand(m).Run(args[1:]...) + case "check": + return newCheckCommand(m).Run(args[1:]...) + case "dump": + return newDumpCommand(m).Run(args[1:]...) + case "info": + return newInfoCommand(m).Run(args[1:]...) + case "page": + return newPageCommand(m).Run(args[1:]...) + case "pages": + return newPagesCommand(m).Run(args[1:]...) + case "stats": + return newStatsCommand(m).Run(args[1:]...) + default: + return ErrUnknownCommand + } +} + +// Usage returns the help message. +func (m *Main) Usage() string { + return strings.TrimLeft(` +Bolt is a tool for inspecting bolt databases. + +Usage: + + bolt command [arguments] + +The commands are: + + bench run synthetic benchmark against bolt + check verifies integrity of bolt database + info print basic info + help print this screen + pages print list of pages with their types + stats iterate over all pages and generate usage stats + +Use "bolt [command] -h" for more information about a command. +`, "\n") +} + +// CheckCommand represents the "check" command execution. +type CheckCommand struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// NewCheckCommand returns a CheckCommand. +func newCheckCommand(m *Main) *CheckCommand { + return &CheckCommand{ + Stdin: m.Stdin, + Stdout: m.Stdout, + Stderr: m.Stderr, + } +} + +// Run executes the command. +func (cmd *CheckCommand) Run(args ...string) error { + // Parse flags. + fs := flag.NewFlagSet("", flag.ContinueOnError) + help := fs.Bool("h", false, "") + if err := fs.Parse(args); err != nil { + return err + } else if *help { + fmt.Fprintln(cmd.Stderr, cmd.Usage()) + return ErrUsage + } + + // Require database path. + path := fs.Arg(0) + if path == "" { + return ErrPathRequired + } else if _, err := os.Stat(path); os.IsNotExist(err) { + return ErrFileNotFound + } + + // Open database. + db, err := bolt.Open(path, 0666, nil) + if err != nil { + return err + } + defer db.Close() + + // Perform consistency check. + return db.View(func(tx *bolt.Tx) error { + var count int + ch := tx.Check() + loop: + for { + select { + case err, ok := <-ch: + if !ok { + break loop + } + fmt.Fprintln(cmd.Stdout, err) + count++ + } + } + + // Print summary of errors. + if count > 0 { + fmt.Fprintf(cmd.Stdout, "%d errors found\n", count) + return ErrCorrupt + } + + // Notify user that database is valid. + fmt.Fprintln(cmd.Stdout, "OK") + return nil + }) +} + +// Usage returns the help message. +func (cmd *CheckCommand) Usage() string { + return strings.TrimLeft(` +usage: bolt check PATH + +Check opens a database at PATH and runs an exhaustive check to verify that +all pages are accessible or are marked as freed. It also verifies that no +pages are double referenced. + +Verification errors will stream out as they are found and the process will +return after all pages have been checked. +`, "\n") +} + +// InfoCommand represents the "info" command execution. +type InfoCommand struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// NewInfoCommand returns a InfoCommand. +func newInfoCommand(m *Main) *InfoCommand { + return &InfoCommand{ + Stdin: m.Stdin, + Stdout: m.Stdout, + Stderr: m.Stderr, + } +} + +// Run executes the command. +func (cmd *InfoCommand) Run(args ...string) error { + // Parse flags. + fs := flag.NewFlagSet("", flag.ContinueOnError) + help := fs.Bool("h", false, "") + if err := fs.Parse(args); err != nil { + return err + } else if *help { + fmt.Fprintln(cmd.Stderr, cmd.Usage()) + return ErrUsage + } + + // Require database path. + path := fs.Arg(0) + if path == "" { + return ErrPathRequired + } else if _, err := os.Stat(path); os.IsNotExist(err) { + return ErrFileNotFound + } + + // Open the database. + db, err := bolt.Open(path, 0666, nil) + if err != nil { + return err + } + defer db.Close() + + // Print basic database info. + info := db.Info() + fmt.Fprintf(cmd.Stdout, "Page Size: %d\n", info.PageSize) + + return nil +} + +// Usage returns the help message. +func (cmd *InfoCommand) Usage() string { + return strings.TrimLeft(` +usage: bolt info PATH + +Info prints basic information about the Bolt database at PATH. +`, "\n") +} + +// DumpCommand represents the "dump" command execution. +type DumpCommand struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// newDumpCommand returns a DumpCommand. +func newDumpCommand(m *Main) *DumpCommand { + return &DumpCommand{ + Stdin: m.Stdin, + Stdout: m.Stdout, + Stderr: m.Stderr, + } +} + +// Run executes the command. +func (cmd *DumpCommand) Run(args ...string) error { + // Parse flags. + fs := flag.NewFlagSet("", flag.ContinueOnError) + help := fs.Bool("h", false, "") + if err := fs.Parse(args); err != nil { + return err + } else if *help { + fmt.Fprintln(cmd.Stderr, cmd.Usage()) + return ErrUsage + } + + // Require database path and page id. + path := fs.Arg(0) + if path == "" { + return ErrPathRequired + } else if _, err := os.Stat(path); os.IsNotExist(err) { + return ErrFileNotFound + } + + // Read page ids. + pageIDs, err := atois(fs.Args()[1:]) + if err != nil { + return err + } else if len(pageIDs) == 0 { + return ErrPageIDRequired + } + + // Open database to retrieve page size. + pageSize, err := ReadPageSize(path) + if err != nil { + return err + } + + // Open database file handler. + f, err := os.Open(path) + if err != nil { + return err + } + defer func() { _ = f.Close() }() + + // Print each page listed. + for i, pageID := range pageIDs { + // Print a separator. + if i > 0 { + fmt.Fprintln(cmd.Stdout, "===============================================") + } + + // Print page to stdout. + if err := cmd.PrintPage(cmd.Stdout, f, pageID, pageSize); err != nil { + return err + } + } + + return nil +} + +// PrintPage prints a given page as hexidecimal. +func (cmd *DumpCommand) PrintPage(w io.Writer, r io.ReaderAt, pageID int, pageSize int) error { + const bytesPerLineN = 16 + + // Read page into buffer. + buf := make([]byte, pageSize) + addr := pageID * pageSize + if n, err := r.ReadAt(buf, int64(addr)); err != nil { + return err + } else if n != pageSize { + return io.ErrUnexpectedEOF + } + + // Write out to writer in 16-byte lines. + var prev []byte + var skipped bool + for offset := 0; offset < pageSize; offset += bytesPerLineN { + // Retrieve current 16-byte line. + line := buf[offset : offset+bytesPerLineN] + isLastLine := (offset == (pageSize - bytesPerLineN)) + + // If it's the same as the previous line then print a skip. + if bytes.Equal(line, prev) && !isLastLine { + if !skipped { + fmt.Fprintf(w, "%07x *\n", addr+offset) + skipped = true + } + } else { + // Print line as hexadecimal in 2-byte groups. + fmt.Fprintf(w, "%07x %04x %04x %04x %04x %04x %04x %04x %04x\n", addr+offset, + line[0:2], line[2:4], line[4:6], line[6:8], + line[8:10], line[10:12], line[12:14], line[14:16], + ) + + skipped = false + } + + // Save the previous line. + prev = line + } + fmt.Fprint(w, "\n") + + return nil +} + +// Usage returns the help message. +func (cmd *DumpCommand) Usage() string { + return strings.TrimLeft(` +usage: bolt dump -page PAGEID PATH + +Dump prints a hexidecimal dump of a single page. +`, "\n") +} + +// PageCommand represents the "page" command execution. +type PageCommand struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// newPageCommand returns a PageCommand. +func newPageCommand(m *Main) *PageCommand { + return &PageCommand{ + Stdin: m.Stdin, + Stdout: m.Stdout, + Stderr: m.Stderr, + } +} + +// Run executes the command. +func (cmd *PageCommand) Run(args ...string) error { + // Parse flags. + fs := flag.NewFlagSet("", flag.ContinueOnError) + help := fs.Bool("h", false, "") + if err := fs.Parse(args); err != nil { + return err + } else if *help { + fmt.Fprintln(cmd.Stderr, cmd.Usage()) + return ErrUsage + } + + // Require database path and page id. + path := fs.Arg(0) + if path == "" { + return ErrPathRequired + } else if _, err := os.Stat(path); os.IsNotExist(err) { + return ErrFileNotFound + } + + // Read page ids. + pageIDs, err := atois(fs.Args()[1:]) + if err != nil { + return err + } else if len(pageIDs) == 0 { + return ErrPageIDRequired + } + + // Open database file handler. + f, err := os.Open(path) + if err != nil { + return err + } + defer func() { _ = f.Close() }() + + // Print each page listed. + for i, pageID := range pageIDs { + // Print a separator. + if i > 0 { + fmt.Fprintln(cmd.Stdout, "===============================================") + } + + // Retrieve page info and page size. + p, buf, err := ReadPage(path, pageID) + if err != nil { + return err + } + + // Print basic page info. + fmt.Fprintf(cmd.Stdout, "Page ID: %d\n", p.id) + fmt.Fprintf(cmd.Stdout, "Page Type: %s\n", p.Type()) + fmt.Fprintf(cmd.Stdout, "Total Size: %d bytes\n", len(buf)) + + // Print type-specific data. + switch p.Type() { + case "meta": + err = cmd.PrintMeta(cmd.Stdout, buf) + case "leaf": + err = cmd.PrintLeaf(cmd.Stdout, buf) + case "branch": + err = cmd.PrintBranch(cmd.Stdout, buf) + case "freelist": + err = cmd.PrintFreelist(cmd.Stdout, buf) + } + if err != nil { + return err + } + } + + return nil +} + +// PrintMeta prints the data from the meta page. +func (cmd *PageCommand) PrintMeta(w io.Writer, buf []byte) error { + m := (*meta)(unsafe.Pointer(&buf[PageHeaderSize])) + fmt.Fprintf(w, "Version: %d\n", m.version) + fmt.Fprintf(w, "Page Size: %d bytes\n", m.pageSize) + fmt.Fprintf(w, "Flags: %08x\n", m.flags) + fmt.Fprintf(w, "Root: \n", m.root.root) + fmt.Fprintf(w, "Freelist: \n", m.freelist) + fmt.Fprintf(w, "HWM: \n", m.pgid) + fmt.Fprintf(w, "Txn ID: %d\n", m.txid) + fmt.Fprintf(w, "Checksum: %016x\n", m.checksum) + fmt.Fprintf(w, "\n") + return nil +} + +// PrintLeaf prints the data for a leaf page. +func (cmd *PageCommand) PrintLeaf(w io.Writer, buf []byte) error { + p := (*page)(unsafe.Pointer(&buf[0])) + + // Print number of items. + fmt.Fprintf(w, "Item Count: %d\n", p.count) + fmt.Fprintf(w, "\n") + + // Print each key/value. + for i := uint16(0); i < p.count; i++ { + e := p.leafPageElement(i) + + // Format key as string. + var k string + if isPrintable(string(e.key())) { + k = fmt.Sprintf("%q", string(e.key())) + } else { + k = fmt.Sprintf("%x", string(e.key())) + } + + // Format value as string. + var v string + if (e.flags & uint32(bucketLeafFlag)) != 0 { + b := (*bucket)(unsafe.Pointer(&e.value()[0])) + v = fmt.Sprintf("", b.root, b.sequence) + } else if isPrintable(string(e.value())) { + k = fmt.Sprintf("%q", string(e.value())) + } else { + k = fmt.Sprintf("%x", string(e.value())) + } + + fmt.Fprintf(w, "%s: %s\n", k, v) + } + fmt.Fprintf(w, "\n") + return nil +} + +// PrintBranch prints the data for a leaf page. +func (cmd *PageCommand) PrintBranch(w io.Writer, buf []byte) error { + p := (*page)(unsafe.Pointer(&buf[0])) + + // Print number of items. + fmt.Fprintf(w, "Item Count: %d\n", p.count) + fmt.Fprintf(w, "\n") + + // Print each key/value. + for i := uint16(0); i < p.count; i++ { + e := p.branchPageElement(i) + + // Format key as string. + var k string + if isPrintable(string(e.key())) { + k = fmt.Sprintf("%q", string(e.key())) + } else { + k = fmt.Sprintf("%x", string(e.key())) + } + + fmt.Fprintf(w, "%s: \n", k, e.pgid) + } + fmt.Fprintf(w, "\n") + return nil +} + +// PrintFreelist prints the data for a freelist page. +func (cmd *PageCommand) PrintFreelist(w io.Writer, buf []byte) error { + p := (*page)(unsafe.Pointer(&buf[0])) + + // Print number of items. + fmt.Fprintf(w, "Item Count: %d\n", p.count) + fmt.Fprintf(w, "\n") + + // Print each page in the freelist. + ids := (*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)) + for i := uint16(0); i < p.count; i++ { + fmt.Fprintf(w, "%d\n", ids[i]) + } + fmt.Fprintf(w, "\n") + return nil +} + +// PrintPage prints a given page as hexidecimal. +func (cmd *PageCommand) PrintPage(w io.Writer, r io.ReaderAt, pageID int, pageSize int) error { + const bytesPerLineN = 16 + + // Read page into buffer. + buf := make([]byte, pageSize) + addr := pageID * pageSize + if n, err := r.ReadAt(buf, int64(addr)); err != nil { + return err + } else if n != pageSize { + return io.ErrUnexpectedEOF + } + + // Write out to writer in 16-byte lines. + var prev []byte + var skipped bool + for offset := 0; offset < pageSize; offset += bytesPerLineN { + // Retrieve current 16-byte line. + line := buf[offset : offset+bytesPerLineN] + isLastLine := (offset == (pageSize - bytesPerLineN)) + + // If it's the same as the previous line then print a skip. + if bytes.Equal(line, prev) && !isLastLine { + if !skipped { + fmt.Fprintf(w, "%07x *\n", addr+offset) + skipped = true + } + } else { + // Print line as hexadecimal in 2-byte groups. + fmt.Fprintf(w, "%07x %04x %04x %04x %04x %04x %04x %04x %04x\n", addr+offset, + line[0:2], line[2:4], line[4:6], line[6:8], + line[8:10], line[10:12], line[12:14], line[14:16], + ) + + skipped = false + } + + // Save the previous line. + prev = line + } + fmt.Fprint(w, "\n") + + return nil +} + +// Usage returns the help message. +func (cmd *PageCommand) Usage() string { + return strings.TrimLeft(` +usage: bolt page -page PATH pageid [pageid...] + +Page prints one or more pages in human readable format. +`, "\n") +} + +// PagesCommand represents the "pages" command execution. +type PagesCommand struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// NewPagesCommand returns a PagesCommand. +func newPagesCommand(m *Main) *PagesCommand { + return &PagesCommand{ + Stdin: m.Stdin, + Stdout: m.Stdout, + Stderr: m.Stderr, + } +} + +// Run executes the command. +func (cmd *PagesCommand) Run(args ...string) error { + // Parse flags. + fs := flag.NewFlagSet("", flag.ContinueOnError) + help := fs.Bool("h", false, "") + if err := fs.Parse(args); err != nil { + return err + } else if *help { + fmt.Fprintln(cmd.Stderr, cmd.Usage()) + return ErrUsage + } + + // Require database path. + path := fs.Arg(0) + if path == "" { + return ErrPathRequired + } else if _, err := os.Stat(path); os.IsNotExist(err) { + return ErrFileNotFound + } + + // Open database. + db, err := bolt.Open(path, 0666, nil) + if err != nil { + return err + } + defer func() { _ = db.Close() }() + + // Write header. + fmt.Fprintln(cmd.Stdout, "ID TYPE ITEMS OVRFLW") + fmt.Fprintln(cmd.Stdout, "======== ========== ====== ======") + + return db.Update(func(tx *bolt.Tx) error { + var id int + for { + p, err := tx.Page(id) + if err != nil { + return &PageError{ID: id, Err: err} + } else if p == nil { + break + } + + // Only display count and overflow if this is a non-free page. + var count, overflow string + if p.Type != "free" { + count = strconv.Itoa(p.Count) + if p.OverflowCount > 0 { + overflow = strconv.Itoa(p.OverflowCount) + } + } + + // Print table row. + fmt.Fprintf(cmd.Stdout, "%-8d %-10s %-6s %-6s\n", p.ID, p.Type, count, overflow) + + // Move to the next non-overflow page. + id += 1 + if p.Type != "free" { + id += p.OverflowCount + } + } + return nil + }) +} + +// Usage returns the help message. +func (cmd *PagesCommand) Usage() string { + return strings.TrimLeft(` +usage: bolt pages PATH + +Pages prints a table of pages with their type (meta, leaf, branch, freelist). +Leaf and branch pages will show a key count in the "items" column while the +freelist will show the number of free pages in the "items" column. + +The "overflow" column shows the number of blocks that the page spills over +into. Normally there is no overflow but large keys and values can cause +a single page to take up multiple blocks. +`, "\n") +} + +// StatsCommand represents the "stats" command execution. +type StatsCommand struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// NewStatsCommand returns a StatsCommand. +func newStatsCommand(m *Main) *StatsCommand { + return &StatsCommand{ + Stdin: m.Stdin, + Stdout: m.Stdout, + Stderr: m.Stderr, + } +} + +// Run executes the command. +func (cmd *StatsCommand) Run(args ...string) error { + // Parse flags. + fs := flag.NewFlagSet("", flag.ContinueOnError) + help := fs.Bool("h", false, "") + if err := fs.Parse(args); err != nil { + return err + } else if *help { + fmt.Fprintln(cmd.Stderr, cmd.Usage()) + return ErrUsage + } + + // Require database path. + path, prefix := fs.Arg(0), fs.Arg(1) + if path == "" { + return ErrPathRequired + } else if _, err := os.Stat(path); os.IsNotExist(err) { + return ErrFileNotFound + } + + // Open database. + db, err := bolt.Open(path, 0666, nil) + if err != nil { + return err + } + defer db.Close() + + return db.View(func(tx *bolt.Tx) error { + var s bolt.BucketStats + var count int + if err := tx.ForEach(func(name []byte, b *bolt.Bucket) error { + if bytes.HasPrefix(name, []byte(prefix)) { + s.Add(b.Stats()) + count += 1 + } + return nil + }); err != nil { + return err + } + + fmt.Fprintf(cmd.Stdout, "Aggregate statistics for %d buckets\n\n", count) + + fmt.Fprintln(cmd.Stdout, "Page count statistics") + fmt.Fprintf(cmd.Stdout, "\tNumber of logical branch pages: %d\n", s.BranchPageN) + fmt.Fprintf(cmd.Stdout, "\tNumber of physical branch overflow pages: %d\n", s.BranchOverflowN) + fmt.Fprintf(cmd.Stdout, "\tNumber of logical leaf pages: %d\n", s.LeafPageN) + fmt.Fprintf(cmd.Stdout, "\tNumber of physical leaf overflow pages: %d\n", s.LeafOverflowN) + + fmt.Fprintln(cmd.Stdout, "Tree statistics") + fmt.Fprintf(cmd.Stdout, "\tNumber of keys/value pairs: %d\n", s.KeyN) + fmt.Fprintf(cmd.Stdout, "\tNumber of levels in B+tree: %d\n", s.Depth) + + fmt.Fprintln(cmd.Stdout, "Page size utilization") + fmt.Fprintf(cmd.Stdout, "\tBytes allocated for physical branch pages: %d\n", s.BranchAlloc) + var percentage int + if s.BranchAlloc != 0 { + percentage = int(float32(s.BranchInuse) * 100.0 / float32(s.BranchAlloc)) + } + fmt.Fprintf(cmd.Stdout, "\tBytes actually used for branch data: %d (%d%%)\n", s.BranchInuse, percentage) + fmt.Fprintf(cmd.Stdout, "\tBytes allocated for physical leaf pages: %d\n", s.LeafAlloc) + percentage = 0 + if s.LeafAlloc != 0 { + percentage = int(float32(s.LeafInuse) * 100.0 / float32(s.LeafAlloc)) + } + fmt.Fprintf(cmd.Stdout, "\tBytes actually used for leaf data: %d (%d%%)\n", s.LeafInuse, percentage) + + fmt.Fprintln(cmd.Stdout, "Bucket statistics") + fmt.Fprintf(cmd.Stdout, "\tTotal number of buckets: %d\n", s.BucketN) + percentage = 0 + if s.BucketN != 0 { + percentage = int(float32(s.InlineBucketN) * 100.0 / float32(s.BucketN)) + } + fmt.Fprintf(cmd.Stdout, "\tTotal number on inlined buckets: %d (%d%%)\n", s.InlineBucketN, percentage) + percentage = 0 + if s.LeafInuse != 0 { + percentage = int(float32(s.InlineBucketInuse) * 100.0 / float32(s.LeafInuse)) + } + fmt.Fprintf(cmd.Stdout, "\tBytes used for inlined buckets: %d (%d%%)\n", s.InlineBucketInuse, percentage) + + return nil + }) +} + +// Usage returns the help message. +func (cmd *StatsCommand) Usage() string { + return strings.TrimLeft(` +usage: bolt stats PATH + +Stats performs an extensive search of the database to track every page +reference. It starts at the current meta page and recursively iterates +through every accessible bucket. + +The following errors can be reported: + + already freed + The page is referenced more than once in the freelist. + + unreachable unfreed + The page is not referenced by a bucket or in the freelist. + + reachable freed + The page is referenced by a bucket but is also in the freelist. + + out of bounds + A page is referenced that is above the high water mark. + + multiple references + A page is referenced by more than one other page. + + invalid type + The page type is not "meta", "leaf", "branch", or "freelist". + +No errors should occur in your database. However, if for some reason you +experience corruption, please submit a ticket to the Bolt project page: + + https://github.com/boltdb/bolt/issues +`, "\n") +} + +var benchBucketName = []byte("bench") + +// BenchCommand represents the "bench" command execution. +type BenchCommand struct { + Stdin io.Reader + Stdout io.Writer + Stderr io.Writer +} + +// NewBenchCommand returns a BenchCommand using the +func newBenchCommand(m *Main) *BenchCommand { + return &BenchCommand{ + Stdin: m.Stdin, + Stdout: m.Stdout, + Stderr: m.Stderr, + } +} + +// Run executes the "bench" command. +func (cmd *BenchCommand) Run(args ...string) error { + // Parse CLI arguments. + options, err := cmd.ParseFlags(args) + if err != nil { + return err + } + + // Remove path if "-work" is not set. Otherwise keep path. + if options.Work { + fmt.Fprintf(cmd.Stdout, "work: %s\n", options.Path) + } else { + defer os.Remove(options.Path) + } + + // Create database. + db, err := bolt.Open(options.Path, 0666, nil) + if err != nil { + return err + } + db.NoSync = options.NoSync + defer db.Close() + + // Write to the database. + var results BenchResults + if err := cmd.runWrites(db, options, &results); err != nil { + return fmt.Errorf("write: %v", err) + } + + // Read from the database. + if err := cmd.runReads(db, options, &results); err != nil { + return fmt.Errorf("bench: read: %s", err) + } + + // Print results. + fmt.Fprintf(os.Stderr, "# Write\t%v\t(%v/op)\t(%v op/sec)\n", results.WriteDuration, results.WriteOpDuration(), results.WriteOpsPerSecond()) + fmt.Fprintf(os.Stderr, "# Read\t%v\t(%v/op)\t(%v op/sec)\n", results.ReadDuration, results.ReadOpDuration(), results.ReadOpsPerSecond()) + fmt.Fprintln(os.Stderr, "") + return nil +} + +// ParseFlags parses the command line flags. +func (cmd *BenchCommand) ParseFlags(args []string) (*BenchOptions, error) { + var options BenchOptions + + // Parse flagset. + fs := flag.NewFlagSet("", flag.ContinueOnError) + fs.StringVar(&options.ProfileMode, "profile-mode", "rw", "") + fs.StringVar(&options.WriteMode, "write-mode", "seq", "") + fs.StringVar(&options.ReadMode, "read-mode", "seq", "") + fs.IntVar(&options.Iterations, "count", 1000, "") + fs.IntVar(&options.BatchSize, "batch-size", 0, "") + fs.IntVar(&options.KeySize, "key-size", 8, "") + fs.IntVar(&options.ValueSize, "value-size", 32, "") + fs.StringVar(&options.CPUProfile, "cpuprofile", "", "") + fs.StringVar(&options.MemProfile, "memprofile", "", "") + fs.StringVar(&options.BlockProfile, "blockprofile", "", "") + fs.Float64Var(&options.FillPercent, "fill-percent", bolt.DefaultFillPercent, "") + fs.BoolVar(&options.NoSync, "no-sync", false, "") + fs.BoolVar(&options.Work, "work", false, "") + fs.StringVar(&options.Path, "path", "", "") + fs.SetOutput(cmd.Stderr) + if err := fs.Parse(args); err != nil { + return nil, err + } + + // Set batch size to iteration size if not set. + // Require that batch size can be evenly divided by the iteration count. + if options.BatchSize == 0 { + options.BatchSize = options.Iterations + } else if options.Iterations%options.BatchSize != 0 { + return nil, ErrNonDivisibleBatchSize + } + + // Generate temp path if one is not passed in. + if options.Path == "" { + f, err := ioutil.TempFile("", "bolt-bench-") + if err != nil { + return nil, fmt.Errorf("temp file: %s", err) + } + f.Close() + os.Remove(f.Name()) + options.Path = f.Name() + } + + return &options, nil +} + +// Writes to the database. +func (cmd *BenchCommand) runWrites(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + // Start profiling for writes. + if options.ProfileMode == "rw" || options.ProfileMode == "w" { + cmd.startProfiling(options) + } + + t := time.Now() + + var err error + switch options.WriteMode { + case "seq": + err = cmd.runWritesSequential(db, options, results) + case "rnd": + err = cmd.runWritesRandom(db, options, results) + case "seq-nest": + err = cmd.runWritesSequentialNested(db, options, results) + case "rnd-nest": + err = cmd.runWritesRandomNested(db, options, results) + default: + return fmt.Errorf("invalid write mode: %s", options.WriteMode) + } + + // Save time to write. + results.WriteDuration = time.Since(t) + + // Stop profiling for writes only. + if options.ProfileMode == "w" { + cmd.stopProfiling() + } + + return err +} + +func (cmd *BenchCommand) runWritesSequential(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + var i = uint32(0) + return cmd.runWritesWithSource(db, options, results, func() uint32 { i++; return i }) +} + +func (cmd *BenchCommand) runWritesRandom(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + return cmd.runWritesWithSource(db, options, results, func() uint32 { return r.Uint32() }) +} + +func (cmd *BenchCommand) runWritesSequentialNested(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + var i = uint32(0) + return cmd.runWritesWithSource(db, options, results, func() uint32 { i++; return i }) +} + +func (cmd *BenchCommand) runWritesRandomNested(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + r := rand.New(rand.NewSource(time.Now().UnixNano())) + return cmd.runWritesWithSource(db, options, results, func() uint32 { return r.Uint32() }) +} + +func (cmd *BenchCommand) runWritesWithSource(db *bolt.DB, options *BenchOptions, results *BenchResults, keySource func() uint32) error { + results.WriteOps = options.Iterations + + for i := 0; i < options.Iterations; i += options.BatchSize { + if err := db.Update(func(tx *bolt.Tx) error { + b, _ := tx.CreateBucketIfNotExists(benchBucketName) + b.FillPercent = options.FillPercent + + for j := 0; j < options.BatchSize; j++ { + key := make([]byte, options.KeySize) + value := make([]byte, options.ValueSize) + + // Write key as uint32. + binary.BigEndian.PutUint32(key, keySource()) + + // Insert key/value. + if err := b.Put(key, value); err != nil { + return err + } + } + + return nil + }); err != nil { + return err + } + } + return nil +} + +func (cmd *BenchCommand) runWritesNestedWithSource(db *bolt.DB, options *BenchOptions, results *BenchResults, keySource func() uint32) error { + results.WriteOps = options.Iterations + + for i := 0; i < options.Iterations; i += options.BatchSize { + if err := db.Update(func(tx *bolt.Tx) error { + top, err := tx.CreateBucketIfNotExists(benchBucketName) + if err != nil { + return err + } + top.FillPercent = options.FillPercent + + // Create bucket key. + name := make([]byte, options.KeySize) + binary.BigEndian.PutUint32(name, keySource()) + + // Create bucket. + b, err := top.CreateBucketIfNotExists(name) + if err != nil { + return err + } + b.FillPercent = options.FillPercent + + for j := 0; j < options.BatchSize; j++ { + var key = make([]byte, options.KeySize) + var value = make([]byte, options.ValueSize) + + // Generate key as uint32. + binary.BigEndian.PutUint32(key, keySource()) + + // Insert value into subbucket. + if err := b.Put(key, value); err != nil { + return err + } + } + + return nil + }); err != nil { + return err + } + } + return nil +} + +// Reads from the database. +func (cmd *BenchCommand) runReads(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + // Start profiling for reads. + if options.ProfileMode == "r" { + cmd.startProfiling(options) + } + + t := time.Now() + + var err error + switch options.ReadMode { + case "seq": + switch options.WriteMode { + case "seq-nest", "rnd-nest": + err = cmd.runReadsSequentialNested(db, options, results) + default: + err = cmd.runReadsSequential(db, options, results) + } + default: + return fmt.Errorf("invalid read mode: %s", options.ReadMode) + } + + // Save read time. + results.ReadDuration = time.Since(t) + + // Stop profiling for reads. + if options.ProfileMode == "rw" || options.ProfileMode == "r" { + cmd.stopProfiling() + } + + return err +} + +func (cmd *BenchCommand) runReadsSequential(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + return db.View(func(tx *bolt.Tx) error { + t := time.Now() + + for { + var count int + + c := tx.Bucket(benchBucketName).Cursor() + for k, v := c.First(); k != nil; k, v = c.Next() { + if v == nil { + return errors.New("invalid value") + } + count++ + } + + if options.WriteMode == "seq" && count != options.Iterations { + return fmt.Errorf("read seq: iter mismatch: expected %d, got %d", options.Iterations, count) + } + + results.ReadOps += count + + // Make sure we do this for at least a second. + if time.Since(t) >= time.Second { + break + } + } + + return nil + }) +} + +func (cmd *BenchCommand) runReadsSequentialNested(db *bolt.DB, options *BenchOptions, results *BenchResults) error { + return db.View(func(tx *bolt.Tx) error { + t := time.Now() + + for { + var count int + var top = tx.Bucket(benchBucketName) + if err := top.ForEach(func(name, _ []byte) error { + c := top.Bucket(name).Cursor() + for k, v := c.First(); k != nil; k, v = c.Next() { + if v == nil { + return ErrInvalidValue + } + count++ + } + return nil + }); err != nil { + return err + } + + if options.WriteMode == "seq-nest" && count != options.Iterations { + return fmt.Errorf("read seq-nest: iter mismatch: expected %d, got %d", options.Iterations, count) + } + + results.ReadOps += count + + // Make sure we do this for at least a second. + if time.Since(t) >= time.Second { + break + } + } + + return nil + }) +} + +// File handlers for the various profiles. +var cpuprofile, memprofile, blockprofile *os.File + +// Starts all profiles set on the options. +func (cmd *BenchCommand) startProfiling(options *BenchOptions) { + var err error + + // Start CPU profiling. + if options.CPUProfile != "" { + cpuprofile, err = os.Create(options.CPUProfile) + if err != nil { + fmt.Fprintf(cmd.Stderr, "bench: could not create cpu profile %q: %v\n", options.CPUProfile, err) + os.Exit(1) + } + pprof.StartCPUProfile(cpuprofile) + } + + // Start memory profiling. + if options.MemProfile != "" { + memprofile, err = os.Create(options.MemProfile) + if err != nil { + fmt.Fprintf(cmd.Stderr, "bench: could not create memory profile %q: %v\n", options.MemProfile, err) + os.Exit(1) + } + runtime.MemProfileRate = 4096 + } + + // Start fatal profiling. + if options.BlockProfile != "" { + blockprofile, err = os.Create(options.BlockProfile) + if err != nil { + fmt.Fprintf(cmd.Stderr, "bench: could not create block profile %q: %v\n", options.BlockProfile, err) + os.Exit(1) + } + runtime.SetBlockProfileRate(1) + } +} + +// Stops all profiles. +func (cmd *BenchCommand) stopProfiling() { + if cpuprofile != nil { + pprof.StopCPUProfile() + cpuprofile.Close() + cpuprofile = nil + } + + if memprofile != nil { + pprof.Lookup("heap").WriteTo(memprofile, 0) + memprofile.Close() + memprofile = nil + } + + if blockprofile != nil { + pprof.Lookup("block").WriteTo(blockprofile, 0) + blockprofile.Close() + blockprofile = nil + runtime.SetBlockProfileRate(0) + } +} + +// BenchOptions represents the set of options that can be passed to "bolt bench". +type BenchOptions struct { + ProfileMode string + WriteMode string + ReadMode string + Iterations int + BatchSize int + KeySize int + ValueSize int + CPUProfile string + MemProfile string + BlockProfile string + StatsInterval time.Duration + FillPercent float64 + NoSync bool + Work bool + Path string +} + +// BenchResults represents the performance results of the benchmark. +type BenchResults struct { + WriteOps int + WriteDuration time.Duration + ReadOps int + ReadDuration time.Duration +} + +// Returns the duration for a single write operation. +func (r *BenchResults) WriteOpDuration() time.Duration { + if r.WriteOps == 0 { + return 0 + } + return r.WriteDuration / time.Duration(r.WriteOps) +} + +// Returns average number of write operations that can be performed per second. +func (r *BenchResults) WriteOpsPerSecond() int { + var op = r.WriteOpDuration() + if op == 0 { + return 0 + } + return int(time.Second) / int(op) +} + +// Returns the duration for a single read operation. +func (r *BenchResults) ReadOpDuration() time.Duration { + if r.ReadOps == 0 { + return 0 + } + return r.ReadDuration / time.Duration(r.ReadOps) +} + +// Returns average number of read operations that can be performed per second. +func (r *BenchResults) ReadOpsPerSecond() int { + var op = r.ReadOpDuration() + if op == 0 { + return 0 + } + return int(time.Second) / int(op) +} + +type PageError struct { + ID int + Err error +} + +func (e *PageError) Error() string { + return fmt.Sprintf("page error: id=%d, err=%s", e.ID, e.Err) +} + +// isPrintable returns true if the string is valid unicode and contains only printable runes. +func isPrintable(s string) bool { + if !utf8.ValidString(s) { + return false + } + for _, ch := range s { + if !unicode.IsPrint(ch) { + return false + } + } + return true +} + +// ReadPage reads page info & full page data from a path. +// This is not transactionally safe. +func ReadPage(path string, pageID int) (*page, []byte, error) { + // Find page size. + pageSize, err := ReadPageSize(path) + if err != nil { + return nil, nil, fmt.Errorf("read page size: %s", err) + } + + // Open database file. + f, err := os.Open(path) + if err != nil { + return nil, nil, err + } + defer f.Close() + + // Read one block into buffer. + buf := make([]byte, pageSize) + if n, err := f.ReadAt(buf, int64(pageID*pageSize)); err != nil { + return nil, nil, err + } else if n != len(buf) { + return nil, nil, io.ErrUnexpectedEOF + } + + // Determine total number of blocks. + p := (*page)(unsafe.Pointer(&buf[0])) + overflowN := p.overflow + + // Re-read entire page (with overflow) into buffer. + buf = make([]byte, (int(overflowN)+1)*pageSize) + if n, err := f.ReadAt(buf, int64(pageID*pageSize)); err != nil { + return nil, nil, err + } else if n != len(buf) { + return nil, nil, io.ErrUnexpectedEOF + } + p = (*page)(unsafe.Pointer(&buf[0])) + + return p, buf, nil +} + +// ReadPageSize reads page size a path. +// This is not transactionally safe. +func ReadPageSize(path string) (int, error) { + // Open database file. + f, err := os.Open(path) + if err != nil { + return 0, err + } + defer f.Close() + + // Read 4KB chunk. + buf := make([]byte, 4096) + if _, err := io.ReadFull(f, buf); err != nil { + return 0, err + } + + // Read page size from metadata. + m := (*meta)(unsafe.Pointer(&buf[PageHeaderSize])) + return int(m.pageSize), nil +} + +// atois parses a slice of strings into integers. +func atois(strs []string) ([]int, error) { + var a []int + for _, str := range strs { + i, err := strconv.Atoi(str) + if err != nil { + return nil, err + } + a = append(a, i) + } + return a, nil +} + +// DO NOT EDIT. Copied from the "bolt" package. +const maxAllocSize = 0xFFFFFFF + +// DO NOT EDIT. Copied from the "bolt" package. +const ( + branchPageFlag = 0x01 + leafPageFlag = 0x02 + metaPageFlag = 0x04 + freelistPageFlag = 0x10 +) + +// DO NOT EDIT. Copied from the "bolt" package. +const bucketLeafFlag = 0x01 + +// DO NOT EDIT. Copied from the "bolt" package. +type pgid uint64 + +// DO NOT EDIT. Copied from the "bolt" package. +type txid uint64 + +// DO NOT EDIT. Copied from the "bolt" package. +type meta struct { + magic uint32 + version uint32 + pageSize uint32 + flags uint32 + root bucket + freelist pgid + pgid pgid + txid txid + checksum uint64 +} + +// DO NOT EDIT. Copied from the "bolt" package. +type bucket struct { + root pgid + sequence uint64 +} + +// DO NOT EDIT. Copied from the "bolt" package. +type page struct { + id pgid + flags uint16 + count uint16 + overflow uint32 + ptr uintptr +} + +// DO NOT EDIT. Copied from the "bolt" package. +func (p *page) Type() string { + if (p.flags & branchPageFlag) != 0 { + return "branch" + } else if (p.flags & leafPageFlag) != 0 { + return "leaf" + } else if (p.flags & metaPageFlag) != 0 { + return "meta" + } else if (p.flags & freelistPageFlag) != 0 { + return "freelist" + } + return fmt.Sprintf("unknown<%02x>", p.flags) +} + +// DO NOT EDIT. Copied from the "bolt" package. +func (p *page) leafPageElement(index uint16) *leafPageElement { + n := &((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[index] + return n +} + +// DO NOT EDIT. Copied from the "bolt" package. +func (p *page) branchPageElement(index uint16) *branchPageElement { + return &((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[index] +} + +// DO NOT EDIT. Copied from the "bolt" package. +type branchPageElement struct { + pos uint32 + ksize uint32 + pgid pgid +} + +// DO NOT EDIT. Copied from the "bolt" package. +func (n *branchPageElement) key() []byte { + buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) + return buf[n.pos : n.pos+n.ksize] +} + +// DO NOT EDIT. Copied from the "bolt" package. +type leafPageElement struct { + flags uint32 + pos uint32 + ksize uint32 + vsize uint32 +} + +// DO NOT EDIT. Copied from the "bolt" package. +func (n *leafPageElement) key() []byte { + buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) + return buf[n.pos : n.pos+n.ksize] +} + +// DO NOT EDIT. Copied from the "bolt" package. +func (n *leafPageElement) value() []byte { + buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) + return buf[n.pos+n.ksize : n.pos+n.ksize+n.vsize] +} diff --git a/vendor/github.com/boltdb/bolt/cmd/bolt/main_test.go b/vendor/github.com/boltdb/bolt/cmd/bolt/main_test.go new file mode 100644 index 00000000..c378b790 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/cmd/bolt/main_test.go @@ -0,0 +1,185 @@ +package main_test + +import ( + "bytes" + "io/ioutil" + "os" + "strconv" + "testing" + + "github.com/boltdb/bolt" + "github.com/boltdb/bolt/cmd/bolt" +) + +// Ensure the "info" command can print information about a database. +func TestInfoCommand_Run(t *testing.T) { + db := MustOpen(0666, nil) + db.DB.Close() + defer db.Close() + + // Run the info command. + m := NewMain() + if err := m.Run("info", db.Path); err != nil { + t.Fatal(err) + } +} + +// Ensure the "stats" command executes correctly with an empty database. +func TestStatsCommand_Run_EmptyDatabase(t *testing.T) { + // Ignore + if os.Getpagesize() != 4096 { + t.Skip("system does not use 4KB page size") + } + + db := MustOpen(0666, nil) + defer db.Close() + db.DB.Close() + + // Generate expected result. + exp := "Aggregate statistics for 0 buckets\n\n" + + "Page count statistics\n" + + "\tNumber of logical branch pages: 0\n" + + "\tNumber of physical branch overflow pages: 0\n" + + "\tNumber of logical leaf pages: 0\n" + + "\tNumber of physical leaf overflow pages: 0\n" + + "Tree statistics\n" + + "\tNumber of keys/value pairs: 0\n" + + "\tNumber of levels in B+tree: 0\n" + + "Page size utilization\n" + + "\tBytes allocated for physical branch pages: 0\n" + + "\tBytes actually used for branch data: 0 (0%)\n" + + "\tBytes allocated for physical leaf pages: 0\n" + + "\tBytes actually used for leaf data: 0 (0%)\n" + + "Bucket statistics\n" + + "\tTotal number of buckets: 0\n" + + "\tTotal number on inlined buckets: 0 (0%)\n" + + "\tBytes used for inlined buckets: 0 (0%)\n" + + // Run the command. + m := NewMain() + if err := m.Run("stats", db.Path); err != nil { + t.Fatal(err) + } else if m.Stdout.String() != exp { + t.Fatalf("unexpected stdout:\n\n%s", m.Stdout.String()) + } +} + +// Ensure the "stats" command can execute correctly. +func TestStatsCommand_Run(t *testing.T) { + // Ignore + if os.Getpagesize() != 4096 { + t.Skip("system does not use 4KB page size") + } + + db := MustOpen(0666, nil) + defer db.Close() + + if err := db.Update(func(tx *bolt.Tx) error { + // Create "foo" bucket. + b, err := tx.CreateBucket([]byte("foo")) + if err != nil { + return err + } + for i := 0; i < 10; i++ { + if err := b.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))); err != nil { + return err + } + } + + // Create "bar" bucket. + b, err = tx.CreateBucket([]byte("bar")) + if err != nil { + return err + } + for i := 0; i < 100; i++ { + if err := b.Put([]byte(strconv.Itoa(i)), []byte(strconv.Itoa(i))); err != nil { + return err + } + } + + // Create "baz" bucket. + b, err = tx.CreateBucket([]byte("baz")) + if err != nil { + return err + } + if err := b.Put([]byte("key"), []byte("value")); err != nil { + return err + } + + return nil + }); err != nil { + t.Fatal(err) + } + db.DB.Close() + + // Generate expected result. + exp := "Aggregate statistics for 3 buckets\n\n" + + "Page count statistics\n" + + "\tNumber of logical branch pages: 0\n" + + "\tNumber of physical branch overflow pages: 0\n" + + "\tNumber of logical leaf pages: 1\n" + + "\tNumber of physical leaf overflow pages: 0\n" + + "Tree statistics\n" + + "\tNumber of keys/value pairs: 111\n" + + "\tNumber of levels in B+tree: 1\n" + + "Page size utilization\n" + + "\tBytes allocated for physical branch pages: 0\n" + + "\tBytes actually used for branch data: 0 (0%)\n" + + "\tBytes allocated for physical leaf pages: 4096\n" + + "\tBytes actually used for leaf data: 1996 (48%)\n" + + "Bucket statistics\n" + + "\tTotal number of buckets: 3\n" + + "\tTotal number on inlined buckets: 2 (66%)\n" + + "\tBytes used for inlined buckets: 236 (11%)\n" + + // Run the command. + m := NewMain() + if err := m.Run("stats", db.Path); err != nil { + t.Fatal(err) + } else if m.Stdout.String() != exp { + t.Fatalf("unexpected stdout:\n\n%s", m.Stdout.String()) + } +} + +// Main represents a test wrapper for main.Main that records output. +type Main struct { + *main.Main + Stdin bytes.Buffer + Stdout bytes.Buffer + Stderr bytes.Buffer +} + +// NewMain returns a new instance of Main. +func NewMain() *Main { + m := &Main{Main: main.NewMain()} + m.Main.Stdin = &m.Stdin + m.Main.Stdout = &m.Stdout + m.Main.Stderr = &m.Stderr + return m +} + +// MustOpen creates a Bolt database in a temporary location. +func MustOpen(mode os.FileMode, options *bolt.Options) *DB { + // Create temporary path. + f, _ := ioutil.TempFile("", "bolt-") + f.Close() + os.Remove(f.Name()) + + db, err := bolt.Open(f.Name(), mode, options) + if err != nil { + panic(err.Error()) + } + return &DB{DB: db, Path: f.Name()} +} + +// DB is a test wrapper for bolt.DB. +type DB struct { + *bolt.DB + Path string +} + +// Close closes and removes the database. +func (db *DB) Close() error { + defer os.Remove(db.Path) + return db.DB.Close() +} diff --git a/vendor/github.com/boltdb/bolt/cursor.go b/vendor/github.com/boltdb/bolt/cursor.go new file mode 100644 index 00000000..1be9f35e --- /dev/null +++ b/vendor/github.com/boltdb/bolt/cursor.go @@ -0,0 +1,400 @@ +package bolt + +import ( + "bytes" + "fmt" + "sort" +) + +// Cursor represents an iterator that can traverse over all key/value pairs in a bucket in sorted order. +// Cursors see nested buckets with value == nil. +// Cursors can be obtained from a transaction and are valid as long as the transaction is open. +// +// Keys and values returned from the cursor are only valid for the life of the transaction. +// +// Changing data while traversing with a cursor may cause it to be invalidated +// and return unexpected keys and/or values. You must reposition your cursor +// after mutating data. +type Cursor struct { + bucket *Bucket + stack []elemRef +} + +// Bucket returns the bucket that this cursor was created from. +func (c *Cursor) Bucket() *Bucket { + return c.bucket +} + +// First moves the cursor to the first item in the bucket and returns its key and value. +// If the bucket is empty then a nil key and value are returned. +// The returned key and value are only valid for the life of the transaction. +func (c *Cursor) First() (key []byte, value []byte) { + _assert(c.bucket.tx.db != nil, "tx closed") + c.stack = c.stack[:0] + p, n := c.bucket.pageNode(c.bucket.root) + c.stack = append(c.stack, elemRef{page: p, node: n, index: 0}) + c.first() + + // If we land on an empty page then move to the next value. + // https://github.com/boltdb/bolt/issues/450 + if c.stack[len(c.stack)-1].count() == 0 { + c.next() + } + + k, v, flags := c.keyValue() + if (flags & uint32(bucketLeafFlag)) != 0 { + return k, nil + } + return k, v + +} + +// Last moves the cursor to the last item in the bucket and returns its key and value. +// If the bucket is empty then a nil key and value are returned. +// The returned key and value are only valid for the life of the transaction. +func (c *Cursor) Last() (key []byte, value []byte) { + _assert(c.bucket.tx.db != nil, "tx closed") + c.stack = c.stack[:0] + p, n := c.bucket.pageNode(c.bucket.root) + ref := elemRef{page: p, node: n} + ref.index = ref.count() - 1 + c.stack = append(c.stack, ref) + c.last() + k, v, flags := c.keyValue() + if (flags & uint32(bucketLeafFlag)) != 0 { + return k, nil + } + return k, v +} + +// Next moves the cursor to the next item in the bucket and returns its key and value. +// If the cursor is at the end of the bucket then a nil key and value are returned. +// The returned key and value are only valid for the life of the transaction. +func (c *Cursor) Next() (key []byte, value []byte) { + _assert(c.bucket.tx.db != nil, "tx closed") + k, v, flags := c.next() + if (flags & uint32(bucketLeafFlag)) != 0 { + return k, nil + } + return k, v +} + +// Prev moves the cursor to the previous item in the bucket and returns its key and value. +// If the cursor is at the beginning of the bucket then a nil key and value are returned. +// The returned key and value are only valid for the life of the transaction. +func (c *Cursor) Prev() (key []byte, value []byte) { + _assert(c.bucket.tx.db != nil, "tx closed") + + // Attempt to move back one element until we're successful. + // Move up the stack as we hit the beginning of each page in our stack. + for i := len(c.stack) - 1; i >= 0; i-- { + elem := &c.stack[i] + if elem.index > 0 { + elem.index-- + break + } + c.stack = c.stack[:i] + } + + // If we've hit the end then return nil. + if len(c.stack) == 0 { + return nil, nil + } + + // Move down the stack to find the last element of the last leaf under this branch. + c.last() + k, v, flags := c.keyValue() + if (flags & uint32(bucketLeafFlag)) != 0 { + return k, nil + } + return k, v +} + +// Seek moves the cursor to a given key and returns it. +// If the key does not exist then the next key is used. If no keys +// follow, a nil key is returned. +// The returned key and value are only valid for the life of the transaction. +func (c *Cursor) Seek(seek []byte) (key []byte, value []byte) { + k, v, flags := c.seek(seek) + + // If we ended up after the last element of a page then move to the next one. + if ref := &c.stack[len(c.stack)-1]; ref.index >= ref.count() { + k, v, flags = c.next() + } + + if k == nil { + return nil, nil + } else if (flags & uint32(bucketLeafFlag)) != 0 { + return k, nil + } + return k, v +} + +// Delete removes the current key/value under the cursor from the bucket. +// Delete fails if current key/value is a bucket or if the transaction is not writable. +func (c *Cursor) Delete() error { + if c.bucket.tx.db == nil { + return ErrTxClosed + } else if !c.bucket.Writable() { + return ErrTxNotWritable + } + + key, _, flags := c.keyValue() + // Return an error if current value is a bucket. + if (flags & bucketLeafFlag) != 0 { + return ErrIncompatibleValue + } + c.node().del(key) + + return nil +} + +// seek moves the cursor to a given key and returns it. +// If the key does not exist then the next key is used. +func (c *Cursor) seek(seek []byte) (key []byte, value []byte, flags uint32) { + _assert(c.bucket.tx.db != nil, "tx closed") + + // Start from root page/node and traverse to correct page. + c.stack = c.stack[:0] + c.search(seek, c.bucket.root) + ref := &c.stack[len(c.stack)-1] + + // If the cursor is pointing to the end of page/node then return nil. + if ref.index >= ref.count() { + return nil, nil, 0 + } + + // If this is a bucket then return a nil value. + return c.keyValue() +} + +// first moves the cursor to the first leaf element under the last page in the stack. +func (c *Cursor) first() { + for { + // Exit when we hit a leaf page. + var ref = &c.stack[len(c.stack)-1] + if ref.isLeaf() { + break + } + + // Keep adding pages pointing to the first element to the stack. + var pgid pgid + if ref.node != nil { + pgid = ref.node.inodes[ref.index].pgid + } else { + pgid = ref.page.branchPageElement(uint16(ref.index)).pgid + } + p, n := c.bucket.pageNode(pgid) + c.stack = append(c.stack, elemRef{page: p, node: n, index: 0}) + } +} + +// last moves the cursor to the last leaf element under the last page in the stack. +func (c *Cursor) last() { + for { + // Exit when we hit a leaf page. + ref := &c.stack[len(c.stack)-1] + if ref.isLeaf() { + break + } + + // Keep adding pages pointing to the last element in the stack. + var pgid pgid + if ref.node != nil { + pgid = ref.node.inodes[ref.index].pgid + } else { + pgid = ref.page.branchPageElement(uint16(ref.index)).pgid + } + p, n := c.bucket.pageNode(pgid) + + var nextRef = elemRef{page: p, node: n} + nextRef.index = nextRef.count() - 1 + c.stack = append(c.stack, nextRef) + } +} + +// next moves to the next leaf element and returns the key and value. +// If the cursor is at the last leaf element then it stays there and returns nil. +func (c *Cursor) next() (key []byte, value []byte, flags uint32) { + for { + // Attempt to move over one element until we're successful. + // Move up the stack as we hit the end of each page in our stack. + var i int + for i = len(c.stack) - 1; i >= 0; i-- { + elem := &c.stack[i] + if elem.index < elem.count()-1 { + elem.index++ + break + } + } + + // If we've hit the root page then stop and return. This will leave the + // cursor on the last element of the last page. + if i == -1 { + return nil, nil, 0 + } + + // Otherwise start from where we left off in the stack and find the + // first element of the first leaf page. + c.stack = c.stack[:i+1] + c.first() + + // If this is an empty page then restart and move back up the stack. + // https://github.com/boltdb/bolt/issues/450 + if c.stack[len(c.stack)-1].count() == 0 { + continue + } + + return c.keyValue() + } +} + +// search recursively performs a binary search against a given page/node until it finds a given key. +func (c *Cursor) search(key []byte, pgid pgid) { + p, n := c.bucket.pageNode(pgid) + if p != nil && (p.flags&(branchPageFlag|leafPageFlag)) == 0 { + panic(fmt.Sprintf("invalid page type: %d: %x", p.id, p.flags)) + } + e := elemRef{page: p, node: n} + c.stack = append(c.stack, e) + + // If we're on a leaf page/node then find the specific node. + if e.isLeaf() { + c.nsearch(key) + return + } + + if n != nil { + c.searchNode(key, n) + return + } + c.searchPage(key, p) +} + +func (c *Cursor) searchNode(key []byte, n *node) { + var exact bool + index := sort.Search(len(n.inodes), func(i int) bool { + // TODO(benbjohnson): Optimize this range search. It's a bit hacky right now. + // sort.Search() finds the lowest index where f() != -1 but we need the highest index. + ret := bytes.Compare(n.inodes[i].key, key) + if ret == 0 { + exact = true + } + return ret != -1 + }) + if !exact && index > 0 { + index-- + } + c.stack[len(c.stack)-1].index = index + + // Recursively search to the next page. + c.search(key, n.inodes[index].pgid) +} + +func (c *Cursor) searchPage(key []byte, p *page) { + // Binary search for the correct range. + inodes := p.branchPageElements() + + var exact bool + index := sort.Search(int(p.count), func(i int) bool { + // TODO(benbjohnson): Optimize this range search. It's a bit hacky right now. + // sort.Search() finds the lowest index where f() != -1 but we need the highest index. + ret := bytes.Compare(inodes[i].key(), key) + if ret == 0 { + exact = true + } + return ret != -1 + }) + if !exact && index > 0 { + index-- + } + c.stack[len(c.stack)-1].index = index + + // Recursively search to the next page. + c.search(key, inodes[index].pgid) +} + +// nsearch searches the leaf node on the top of the stack for a key. +func (c *Cursor) nsearch(key []byte) { + e := &c.stack[len(c.stack)-1] + p, n := e.page, e.node + + // If we have a node then search its inodes. + if n != nil { + index := sort.Search(len(n.inodes), func(i int) bool { + return bytes.Compare(n.inodes[i].key, key) != -1 + }) + e.index = index + return + } + + // If we have a page then search its leaf elements. + inodes := p.leafPageElements() + index := sort.Search(int(p.count), func(i int) bool { + return bytes.Compare(inodes[i].key(), key) != -1 + }) + e.index = index +} + +// keyValue returns the key and value of the current leaf element. +func (c *Cursor) keyValue() ([]byte, []byte, uint32) { + ref := &c.stack[len(c.stack)-1] + if ref.count() == 0 || ref.index >= ref.count() { + return nil, nil, 0 + } + + // Retrieve value from node. + if ref.node != nil { + inode := &ref.node.inodes[ref.index] + return inode.key, inode.value, inode.flags + } + + // Or retrieve value from page. + elem := ref.page.leafPageElement(uint16(ref.index)) + return elem.key(), elem.value(), elem.flags +} + +// node returns the node that the cursor is currently positioned on. +func (c *Cursor) node() *node { + _assert(len(c.stack) > 0, "accessing a node with a zero-length cursor stack") + + // If the top of the stack is a leaf node then just return it. + if ref := &c.stack[len(c.stack)-1]; ref.node != nil && ref.isLeaf() { + return ref.node + } + + // Start from root and traverse down the hierarchy. + var n = c.stack[0].node + if n == nil { + n = c.bucket.node(c.stack[0].page.id, nil) + } + for _, ref := range c.stack[:len(c.stack)-1] { + _assert(!n.isLeaf, "expected branch node") + n = n.childAt(int(ref.index)) + } + _assert(n.isLeaf, "expected leaf node") + return n +} + +// elemRef represents a reference to an element on a given page/node. +type elemRef struct { + page *page + node *node + index int +} + +// isLeaf returns whether the ref is pointing at a leaf page/node. +func (r *elemRef) isLeaf() bool { + if r.node != nil { + return r.node.isLeaf + } + return (r.page.flags & leafPageFlag) != 0 +} + +// count returns the number of inodes or page elements. +func (r *elemRef) count() int { + if r.node != nil { + return len(r.node.inodes) + } + return int(r.page.count) +} diff --git a/vendor/github.com/boltdb/bolt/cursor_test.go b/vendor/github.com/boltdb/bolt/cursor_test.go new file mode 100644 index 00000000..562d60f9 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/cursor_test.go @@ -0,0 +1,817 @@ +package bolt_test + +import ( + "bytes" + "encoding/binary" + "fmt" + "log" + "os" + "reflect" + "sort" + "testing" + "testing/quick" + + "github.com/boltdb/bolt" +) + +// Ensure that a cursor can return a reference to the bucket that created it. +func TestCursor_Bucket(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if cb := b.Cursor().Bucket(); !reflect.DeepEqual(cb, b) { + t.Fatal("cursor bucket mismatch") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx cursor can seek to the appropriate keys. +func TestCursor_Seek(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("0001")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("bar"), []byte("0002")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte("0003")); err != nil { + t.Fatal(err) + } + + if _, err := b.CreateBucket([]byte("bkt")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + c := tx.Bucket([]byte("widgets")).Cursor() + + // Exact match should go to the key. + if k, v := c.Seek([]byte("bar")); !bytes.Equal(k, []byte("bar")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte("0002")) { + t.Fatalf("unexpected value: %v", v) + } + + // Inexact match should go to the next key. + if k, v := c.Seek([]byte("bas")); !bytes.Equal(k, []byte("baz")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte("0003")) { + t.Fatalf("unexpected value: %v", v) + } + + // Low key should go to the first key. + if k, v := c.Seek([]byte("")); !bytes.Equal(k, []byte("bar")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte("0002")) { + t.Fatalf("unexpected value: %v", v) + } + + // High key should return no key. + if k, v := c.Seek([]byte("zzz")); k != nil { + t.Fatalf("expected nil key: %v", k) + } else if v != nil { + t.Fatalf("expected nil value: %v", v) + } + + // Buckets should return their key but no value. + if k, v := c.Seek([]byte("bkt")); !bytes.Equal(k, []byte("bkt")) { + t.Fatalf("unexpected key: %v", k) + } else if v != nil { + t.Fatalf("expected nil value: %v", v) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +func TestCursor_Delete(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + const count = 1000 + + // Insert every other key between 0 and $count. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + for i := 0; i < count; i += 1 { + k := make([]byte, 8) + binary.BigEndian.PutUint64(k, uint64(i)) + if err := b.Put(k, make([]byte, 100)); err != nil { + t.Fatal(err) + } + } + if _, err := b.CreateBucket([]byte("sub")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + c := tx.Bucket([]byte("widgets")).Cursor() + bound := make([]byte, 8) + binary.BigEndian.PutUint64(bound, uint64(count/2)) + for key, _ := c.First(); bytes.Compare(key, bound) < 0; key, _ = c.Next() { + if err := c.Delete(); err != nil { + t.Fatal(err) + } + } + + c.Seek([]byte("sub")) + if err := c.Delete(); err != bolt.ErrIncompatibleValue { + t.Fatalf("unexpected error: %s", err) + } + + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + stats := tx.Bucket([]byte("widgets")).Stats() + if stats.KeyN != count/2+1 { + t.Fatalf("unexpected KeyN: %d", stats.KeyN) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx cursor can seek to the appropriate keys when there are a +// large number of keys. This test also checks that seek will always move +// forward to the next key. +// +// Related: https://github.com/boltdb/bolt/pull/187 +func TestCursor_Seek_Large(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var count = 10000 + + // Insert every other key between 0 and $count. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + for i := 0; i < count; i += 100 { + for j := i; j < i+100; j += 2 { + k := make([]byte, 8) + binary.BigEndian.PutUint64(k, uint64(j)) + if err := b.Put(k, make([]byte, 100)); err != nil { + t.Fatal(err) + } + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + c := tx.Bucket([]byte("widgets")).Cursor() + for i := 0; i < count; i++ { + seek := make([]byte, 8) + binary.BigEndian.PutUint64(seek, uint64(i)) + + k, _ := c.Seek(seek) + + // The last seek is beyond the end of the the range so + // it should return nil. + if i == count-1 { + if k != nil { + t.Fatal("expected nil key") + } + continue + } + + // Otherwise we should seek to the exact key or the next key. + num := binary.BigEndian.Uint64(k) + if i%2 == 0 { + if num != uint64(i) { + t.Fatalf("unexpected num: %d", num) + } + } else { + if num != uint64(i+1) { + t.Fatalf("unexpected num: %d", num) + } + } + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a cursor can iterate over an empty bucket without error. +func TestCursor_EmptyBucket(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + c := tx.Bucket([]byte("widgets")).Cursor() + k, v := c.First() + if k != nil { + t.Fatalf("unexpected key: %v", k) + } else if v != nil { + t.Fatalf("unexpected value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx cursor can reverse iterate over an empty bucket without error. +func TestCursor_EmptyBucketReverse(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + t.Fatal(err) + } + if err := db.View(func(tx *bolt.Tx) error { + c := tx.Bucket([]byte("widgets")).Cursor() + k, v := c.Last() + if k != nil { + t.Fatalf("unexpected key: %v", k) + } else if v != nil { + t.Fatalf("unexpected value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx cursor can iterate over a single root with a couple elements. +func TestCursor_Iterate_Leaf(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte{}); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte{0}); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("bar"), []byte{1}); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + tx, err := db.Begin(false) + if err != nil { + t.Fatal(err) + } + defer func() { _ = tx.Rollback() }() + + c := tx.Bucket([]byte("widgets")).Cursor() + + k, v := c.First() + if !bytes.Equal(k, []byte("bar")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte{1}) { + t.Fatalf("unexpected value: %v", v) + } + + k, v = c.Next() + if !bytes.Equal(k, []byte("baz")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte{}) { + t.Fatalf("unexpected value: %v", v) + } + + k, v = c.Next() + if !bytes.Equal(k, []byte("foo")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte{0}) { + t.Fatalf("unexpected value: %v", v) + } + + k, v = c.Next() + if k != nil { + t.Fatalf("expected nil key: %v", k) + } else if v != nil { + t.Fatalf("expected nil value: %v", v) + } + + k, v = c.Next() + if k != nil { + t.Fatalf("expected nil key: %v", k) + } else if v != nil { + t.Fatalf("expected nil value: %v", v) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx cursor can iterate in reverse over a single root with a couple elements. +func TestCursor_LeafRootReverse(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte{}); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte{0}); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("bar"), []byte{1}); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + tx, err := db.Begin(false) + if err != nil { + t.Fatal(err) + } + c := tx.Bucket([]byte("widgets")).Cursor() + + if k, v := c.Last(); !bytes.Equal(k, []byte("foo")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte{0}) { + t.Fatalf("unexpected value: %v", v) + } + + if k, v := c.Prev(); !bytes.Equal(k, []byte("baz")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte{}) { + t.Fatalf("unexpected value: %v", v) + } + + if k, v := c.Prev(); !bytes.Equal(k, []byte("bar")) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, []byte{1}) { + t.Fatalf("unexpected value: %v", v) + } + + if k, v := c.Prev(); k != nil { + t.Fatalf("expected nil key: %v", k) + } else if v != nil { + t.Fatalf("expected nil value: %v", v) + } + + if k, v := c.Prev(); k != nil { + t.Fatalf("expected nil key: %v", k) + } else if v != nil { + t.Fatalf("expected nil value: %v", v) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx cursor can restart from the beginning. +func TestCursor_Restart(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("bar"), []byte{}); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte{}); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + tx, err := db.Begin(false) + if err != nil { + t.Fatal(err) + } + c := tx.Bucket([]byte("widgets")).Cursor() + + if k, _ := c.First(); !bytes.Equal(k, []byte("bar")) { + t.Fatalf("unexpected key: %v", k) + } + if k, _ := c.Next(); !bytes.Equal(k, []byte("foo")) { + t.Fatalf("unexpected key: %v", k) + } + + if k, _ := c.First(); !bytes.Equal(k, []byte("bar")) { + t.Fatalf("unexpected key: %v", k) + } + if k, _ := c.Next(); !bytes.Equal(k, []byte("foo")) { + t.Fatalf("unexpected key: %v", k) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } +} + +// Ensure that a cursor can skip over empty pages that have been deleted. +func TestCursor_First_EmptyPages(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + // Create 1000 keys in the "widgets" bucket. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + for i := 0; i < 1000; i++ { + if err := b.Put(u64tob(uint64(i)), []byte{}); err != nil { + t.Fatal(err) + } + } + + return nil + }); err != nil { + t.Fatal(err) + } + + // Delete half the keys and then try to iterate. + if err := db.Update(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for i := 0; i < 600; i++ { + if err := b.Delete(u64tob(uint64(i))); err != nil { + t.Fatal(err) + } + } + + c := b.Cursor() + var n int + for k, _ := c.First(); k != nil; k, _ = c.Next() { + n++ + } + if n != 400 { + t.Fatalf("unexpected key count: %d", n) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx can iterate over all elements in a bucket. +func TestCursor_QuickCheck(t *testing.T) { + f := func(items testdata) bool { + db := MustOpenDB() + defer db.MustClose() + + // Bulk insert all values. + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + for _, item := range items { + if err := b.Put(item.Key, item.Value); err != nil { + t.Fatal(err) + } + } + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + + // Sort test data. + sort.Sort(items) + + // Iterate over all items and check consistency. + var index = 0 + tx, err = db.Begin(false) + if err != nil { + t.Fatal(err) + } + + c := tx.Bucket([]byte("widgets")).Cursor() + for k, v := c.First(); k != nil && index < len(items); k, v = c.Next() { + if !bytes.Equal(k, items[index].Key) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, items[index].Value) { + t.Fatalf("unexpected value: %v", v) + } + index++ + } + if len(items) != index { + t.Fatalf("unexpected item count: %v, expected %v", len(items), index) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + + return true + } + if err := quick.Check(f, qconfig()); err != nil { + t.Error(err) + } +} + +// Ensure that a transaction can iterate over all elements in a bucket in reverse. +func TestCursor_QuickCheck_Reverse(t *testing.T) { + f := func(items testdata) bool { + db := MustOpenDB() + defer db.MustClose() + + // Bulk insert all values. + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + for _, item := range items { + if err := b.Put(item.Key, item.Value); err != nil { + t.Fatal(err) + } + } + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + + // Sort test data. + sort.Sort(revtestdata(items)) + + // Iterate over all items and check consistency. + var index = 0 + tx, err = db.Begin(false) + if err != nil { + t.Fatal(err) + } + c := tx.Bucket([]byte("widgets")).Cursor() + for k, v := c.Last(); k != nil && index < len(items); k, v = c.Prev() { + if !bytes.Equal(k, items[index].Key) { + t.Fatalf("unexpected key: %v", k) + } else if !bytes.Equal(v, items[index].Value) { + t.Fatalf("unexpected value: %v", v) + } + index++ + } + if len(items) != index { + t.Fatalf("unexpected item count: %v, expected %v", len(items), index) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + + return true + } + if err := quick.Check(f, qconfig()); err != nil { + t.Error(err) + } +} + +// Ensure that a Tx cursor can iterate over subbuckets. +func TestCursor_QuickCheck_BucketsOnly(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if _, err := b.CreateBucket([]byte("foo")); err != nil { + t.Fatal(err) + } + if _, err := b.CreateBucket([]byte("bar")); err != nil { + t.Fatal(err) + } + if _, err := b.CreateBucket([]byte("baz")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + var names []string + c := tx.Bucket([]byte("widgets")).Cursor() + for k, v := c.First(); k != nil; k, v = c.Next() { + names = append(names, string(k)) + if v != nil { + t.Fatalf("unexpected value: %v", v) + } + } + if !reflect.DeepEqual(names, []string{"bar", "baz", "foo"}) { + t.Fatalf("unexpected names: %+v", names) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx cursor can reverse iterate over subbuckets. +func TestCursor_QuickCheck_BucketsOnly_Reverse(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if _, err := b.CreateBucket([]byte("foo")); err != nil { + t.Fatal(err) + } + if _, err := b.CreateBucket([]byte("bar")); err != nil { + t.Fatal(err) + } + if _, err := b.CreateBucket([]byte("baz")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + var names []string + c := tx.Bucket([]byte("widgets")).Cursor() + for k, v := c.Last(); k != nil; k, v = c.Prev() { + names = append(names, string(k)) + if v != nil { + t.Fatalf("unexpected value: %v", v) + } + } + if !reflect.DeepEqual(names, []string{"foo", "baz", "bar"}) { + t.Fatalf("unexpected names: %+v", names) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +func ExampleCursor() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Start a read-write transaction. + if err := db.Update(func(tx *bolt.Tx) error { + // Create a new bucket. + b, err := tx.CreateBucket([]byte("animals")) + if err != nil { + return err + } + + // Insert data into a bucket. + if err := b.Put([]byte("dog"), []byte("fun")); err != nil { + log.Fatal(err) + } + if err := b.Put([]byte("cat"), []byte("lame")); err != nil { + log.Fatal(err) + } + if err := b.Put([]byte("liger"), []byte("awesome")); err != nil { + log.Fatal(err) + } + + // Create a cursor for iteration. + c := b.Cursor() + + // Iterate over items in sorted key order. This starts from the + // first key/value pair and updates the k/v variables to the + // next key/value on each iteration. + // + // The loop finishes at the end of the cursor when a nil key is returned. + for k, v := c.First(); k != nil; k, v = c.Next() { + fmt.Printf("A %s is %s.\n", k, v) + } + + return nil + }); err != nil { + log.Fatal(err) + } + + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // A cat is lame. + // A dog is fun. + // A liger is awesome. +} + +func ExampleCursor_reverse() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Start a read-write transaction. + if err := db.Update(func(tx *bolt.Tx) error { + // Create a new bucket. + b, err := tx.CreateBucket([]byte("animals")) + if err != nil { + return err + } + + // Insert data into a bucket. + if err := b.Put([]byte("dog"), []byte("fun")); err != nil { + log.Fatal(err) + } + if err := b.Put([]byte("cat"), []byte("lame")); err != nil { + log.Fatal(err) + } + if err := b.Put([]byte("liger"), []byte("awesome")); err != nil { + log.Fatal(err) + } + + // Create a cursor for iteration. + c := b.Cursor() + + // Iterate over items in reverse sorted key order. This starts + // from the last key/value pair and updates the k/v variables to + // the previous key/value on each iteration. + // + // The loop finishes at the beginning of the cursor when a nil key + // is returned. + for k, v := c.Last(); k != nil; k, v = c.Prev() { + fmt.Printf("A %s is %s.\n", k, v) + } + + return nil + }); err != nil { + log.Fatal(err) + } + + // Close the database to release the file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // A liger is awesome. + // A dog is fun. + // A cat is lame. +} diff --git a/vendor/github.com/boltdb/bolt/db.go b/vendor/github.com/boltdb/bolt/db.go new file mode 100644 index 00000000..1223493c --- /dev/null +++ b/vendor/github.com/boltdb/bolt/db.go @@ -0,0 +1,1036 @@ +package bolt + +import ( + "errors" + "fmt" + "hash/fnv" + "log" + "os" + "runtime" + "runtime/debug" + "strings" + "sync" + "time" + "unsafe" +) + +// The largest step that can be taken when remapping the mmap. +const maxMmapStep = 1 << 30 // 1GB + +// The data file format version. +const version = 2 + +// Represents a marker value to indicate that a file is a Bolt DB. +const magic uint32 = 0xED0CDAED + +// IgnoreNoSync specifies whether the NoSync field of a DB is ignored when +// syncing changes to a file. This is required as some operating systems, +// such as OpenBSD, do not have a unified buffer cache (UBC) and writes +// must be synchronized using the msync(2) syscall. +const IgnoreNoSync = runtime.GOOS == "openbsd" + +// Default values if not set in a DB instance. +const ( + DefaultMaxBatchSize int = 1000 + DefaultMaxBatchDelay = 10 * time.Millisecond + DefaultAllocSize = 16 * 1024 * 1024 +) + +// default page size for db is set to the OS page size. +var defaultPageSize = os.Getpagesize() + +// DB represents a collection of buckets persisted to a file on disk. +// All data access is performed through transactions which can be obtained through the DB. +// All the functions on DB will return a ErrDatabaseNotOpen if accessed before Open() is called. +type DB struct { + // When enabled, the database will perform a Check() after every commit. + // A panic is issued if the database is in an inconsistent state. This + // flag has a large performance impact so it should only be used for + // debugging purposes. + StrictMode bool + + // Setting the NoSync flag will cause the database to skip fsync() + // calls after each commit. This can be useful when bulk loading data + // into a database and you can restart the bulk load in the event of + // a system failure or database corruption. Do not set this flag for + // normal use. + // + // If the package global IgnoreNoSync constant is true, this value is + // ignored. See the comment on that constant for more details. + // + // THIS IS UNSAFE. PLEASE USE WITH CAUTION. + NoSync bool + + // When true, skips the truncate call when growing the database. + // Setting this to true is only safe on non-ext3/ext4 systems. + // Skipping truncation avoids preallocation of hard drive space and + // bypasses a truncate() and fsync() syscall on remapping. + // + // https://github.com/boltdb/bolt/issues/284 + NoGrowSync bool + + // If you want to read the entire database fast, you can set MmapFlag to + // syscall.MAP_POPULATE on Linux 2.6.23+ for sequential read-ahead. + MmapFlags int + + // MaxBatchSize is the maximum size of a batch. Default value is + // copied from DefaultMaxBatchSize in Open. + // + // If <=0, disables batching. + // + // Do not change concurrently with calls to Batch. + MaxBatchSize int + + // MaxBatchDelay is the maximum delay before a batch starts. + // Default value is copied from DefaultMaxBatchDelay in Open. + // + // If <=0, effectively disables batching. + // + // Do not change concurrently with calls to Batch. + MaxBatchDelay time.Duration + + // AllocSize is the amount of space allocated when the database + // needs to create new pages. This is done to amortize the cost + // of truncate() and fsync() when growing the data file. + AllocSize int + + path string + file *os.File + lockfile *os.File // windows only + dataref []byte // mmap'ed readonly, write throws SEGV + data *[maxMapSize]byte + datasz int + filesz int // current on disk file size + meta0 *meta + meta1 *meta + pageSize int + opened bool + rwtx *Tx + txs []*Tx + freelist *freelist + stats Stats + + pagePool sync.Pool + + batchMu sync.Mutex + batch *batch + + rwlock sync.Mutex // Allows only one writer at a time. + metalock sync.Mutex // Protects meta page access. + mmaplock sync.RWMutex // Protects mmap access during remapping. + statlock sync.RWMutex // Protects stats access. + + ops struct { + writeAt func(b []byte, off int64) (n int, err error) + } + + // Read only mode. + // When true, Update() and Begin(true) return ErrDatabaseReadOnly immediately. + readOnly bool +} + +// Path returns the path to currently open database file. +func (db *DB) Path() string { + return db.path +} + +// GoString returns the Go string representation of the database. +func (db *DB) GoString() string { + return fmt.Sprintf("bolt.DB{path:%q}", db.path) +} + +// String returns the string representation of the database. +func (db *DB) String() string { + return fmt.Sprintf("DB<%q>", db.path) +} + +// Open creates and opens a database at the given path. +// If the file does not exist then it will be created automatically. +// Passing in nil options will cause Bolt to open the database with the default options. +func Open(path string, mode os.FileMode, options *Options) (*DB, error) { + var db = &DB{opened: true} + + // Set default options if no options are provided. + if options == nil { + options = DefaultOptions + } + db.NoGrowSync = options.NoGrowSync + db.MmapFlags = options.MmapFlags + + // Set default values for later DB operations. + db.MaxBatchSize = DefaultMaxBatchSize + db.MaxBatchDelay = DefaultMaxBatchDelay + db.AllocSize = DefaultAllocSize + + flag := os.O_RDWR + if options.ReadOnly { + flag = os.O_RDONLY + db.readOnly = true + } + + // Open data file and separate sync handler for metadata writes. + db.path = path + var err error + if db.file, err = os.OpenFile(db.path, flag|os.O_CREATE, mode); err != nil { + _ = db.close() + return nil, err + } + + // Lock file so that other processes using Bolt in read-write mode cannot + // use the database at the same time. This would cause corruption since + // the two processes would write meta pages and free pages separately. + // The database file is locked exclusively (only one process can grab the lock) + // if !options.ReadOnly. + // The database file is locked using the shared lock (more than one process may + // hold a lock at the same time) otherwise (options.ReadOnly is set). + if err := flock(db, mode, !db.readOnly, options.Timeout); err != nil { + _ = db.close() + return nil, err + } + + // Default values for test hooks + db.ops.writeAt = db.file.WriteAt + + // Initialize the database if it doesn't exist. + if info, err := db.file.Stat(); err != nil { + return nil, err + } else if info.Size() == 0 { + // Initialize new files with meta pages. + if err := db.init(); err != nil { + return nil, err + } + } else { + // Read the first meta page to determine the page size. + var buf [0x1000]byte + if _, err := db.file.ReadAt(buf[:], 0); err == nil { + m := db.pageInBuffer(buf[:], 0).meta() + if err := m.validate(); err != nil { + // If we can't read the page size, we can assume it's the same + // as the OS -- since that's how the page size was chosen in the + // first place. + // + // If the first page is invalid and this OS uses a different + // page size than what the database was created with then we + // are out of luck and cannot access the database. + db.pageSize = os.Getpagesize() + } else { + db.pageSize = int(m.pageSize) + } + } + } + + // Initialize page pool. + db.pagePool = sync.Pool{ + New: func() interface{} { + return make([]byte, db.pageSize) + }, + } + + // Memory map the data file. + if err := db.mmap(options.InitialMmapSize); err != nil { + _ = db.close() + return nil, err + } + + // Read in the freelist. + db.freelist = newFreelist() + db.freelist.read(db.page(db.meta().freelist)) + + // Mark the database as opened and return. + return db, nil +} + +// mmap opens the underlying memory-mapped file and initializes the meta references. +// minsz is the minimum size that the new mmap can be. +func (db *DB) mmap(minsz int) error { + db.mmaplock.Lock() + defer db.mmaplock.Unlock() + + info, err := db.file.Stat() + if err != nil { + return fmt.Errorf("mmap stat error: %s", err) + } else if int(info.Size()) < db.pageSize*2 { + return fmt.Errorf("file size too small") + } + + // Ensure the size is at least the minimum size. + var size = int(info.Size()) + if size < minsz { + size = minsz + } + size, err = db.mmapSize(size) + if err != nil { + return err + } + + // Dereference all mmap references before unmapping. + if db.rwtx != nil { + db.rwtx.root.dereference() + } + + // Unmap existing data before continuing. + if err := db.munmap(); err != nil { + return err + } + + // Memory-map the data file as a byte slice. + if err := mmap(db, size); err != nil { + return err + } + + // Save references to the meta pages. + db.meta0 = db.page(0).meta() + db.meta1 = db.page(1).meta() + + // Validate the meta pages. We only return an error if both meta pages fail + // validation, since meta0 failing validation means that it wasn't saved + // properly -- but we can recover using meta1. And vice-versa. + err0 := db.meta0.validate() + err1 := db.meta1.validate() + if err0 != nil && err1 != nil { + return err0 + } + + return nil +} + +// munmap unmaps the data file from memory. +func (db *DB) munmap() error { + if err := munmap(db); err != nil { + return fmt.Errorf("unmap error: " + err.Error()) + } + return nil +} + +// mmapSize determines the appropriate size for the mmap given the current size +// of the database. The minimum size is 32KB and doubles until it reaches 1GB. +// Returns an error if the new mmap size is greater than the max allowed. +func (db *DB) mmapSize(size int) (int, error) { + // Double the size from 32KB until 1GB. + for i := uint(15); i <= 30; i++ { + if size <= 1< maxMapSize { + return 0, fmt.Errorf("mmap too large") + } + + // If larger than 1GB then grow by 1GB at a time. + sz := int64(size) + if remainder := sz % int64(maxMmapStep); remainder > 0 { + sz += int64(maxMmapStep) - remainder + } + + // Ensure that the mmap size is a multiple of the page size. + // This should always be true since we're incrementing in MBs. + pageSize := int64(db.pageSize) + if (sz % pageSize) != 0 { + sz = ((sz / pageSize) + 1) * pageSize + } + + // If we've exceeded the max size then only grow up to the max size. + if sz > maxMapSize { + sz = maxMapSize + } + + return int(sz), nil +} + +// init creates a new database file and initializes its meta pages. +func (db *DB) init() error { + // Set the page size to the OS page size. + db.pageSize = os.Getpagesize() + + // Create two meta pages on a buffer. + buf := make([]byte, db.pageSize*4) + for i := 0; i < 2; i++ { + p := db.pageInBuffer(buf[:], pgid(i)) + p.id = pgid(i) + p.flags = metaPageFlag + + // Initialize the meta page. + m := p.meta() + m.magic = magic + m.version = version + m.pageSize = uint32(db.pageSize) + m.freelist = 2 + m.root = bucket{root: 3} + m.pgid = 4 + m.txid = txid(i) + m.checksum = m.sum64() + } + + // Write an empty freelist at page 3. + p := db.pageInBuffer(buf[:], pgid(2)) + p.id = pgid(2) + p.flags = freelistPageFlag + p.count = 0 + + // Write an empty leaf page at page 4. + p = db.pageInBuffer(buf[:], pgid(3)) + p.id = pgid(3) + p.flags = leafPageFlag + p.count = 0 + + // Write the buffer to our data file. + if _, err := db.ops.writeAt(buf, 0); err != nil { + return err + } + if err := fdatasync(db); err != nil { + return err + } + + return nil +} + +// Close releases all database resources. +// All transactions must be closed before closing the database. +func (db *DB) Close() error { + db.rwlock.Lock() + defer db.rwlock.Unlock() + + db.metalock.Lock() + defer db.metalock.Unlock() + + db.mmaplock.RLock() + defer db.mmaplock.RUnlock() + + return db.close() +} + +func (db *DB) close() error { + if !db.opened { + return nil + } + + db.opened = false + + db.freelist = nil + + // Clear ops. + db.ops.writeAt = nil + + // Close the mmap. + if err := db.munmap(); err != nil { + return err + } + + // Close file handles. + if db.file != nil { + // No need to unlock read-only file. + if !db.readOnly { + // Unlock the file. + if err := funlock(db); err != nil { + log.Printf("bolt.Close(): funlock error: %s", err) + } + } + + // Close the file descriptor. + if err := db.file.Close(); err != nil { + return fmt.Errorf("db file close: %s", err) + } + db.file = nil + } + + db.path = "" + return nil +} + +// Begin starts a new transaction. +// Multiple read-only transactions can be used concurrently but only one +// write transaction can be used at a time. Starting multiple write transactions +// will cause the calls to block and be serialized until the current write +// transaction finishes. +// +// Transactions should not be dependent on one another. Opening a read +// transaction and a write transaction in the same goroutine can cause the +// writer to deadlock because the database periodically needs to re-mmap itself +// as it grows and it cannot do that while a read transaction is open. +// +// If a long running read transaction (for example, a snapshot transaction) is +// needed, you might want to set DB.InitialMmapSize to a large enough value +// to avoid potential blocking of write transaction. +// +// IMPORTANT: You must close read-only transactions after you are finished or +// else the database will not reclaim old pages. +func (db *DB) Begin(writable bool) (*Tx, error) { + if writable { + return db.beginRWTx() + } + return db.beginTx() +} + +func (db *DB) beginTx() (*Tx, error) { + // Lock the meta pages while we initialize the transaction. We obtain + // the meta lock before the mmap lock because that's the order that the + // write transaction will obtain them. + db.metalock.Lock() + + // Obtain a read-only lock on the mmap. When the mmap is remapped it will + // obtain a write lock so all transactions must finish before it can be + // remapped. + db.mmaplock.RLock() + + // Exit if the database is not open yet. + if !db.opened { + db.mmaplock.RUnlock() + db.metalock.Unlock() + return nil, ErrDatabaseNotOpen + } + + // Create a transaction associated with the database. + t := &Tx{} + t.init(db) + + // Keep track of transaction until it closes. + db.txs = append(db.txs, t) + n := len(db.txs) + + // Unlock the meta pages. + db.metalock.Unlock() + + // Update the transaction stats. + db.statlock.Lock() + db.stats.TxN++ + db.stats.OpenTxN = n + db.statlock.Unlock() + + return t, nil +} + +func (db *DB) beginRWTx() (*Tx, error) { + // If the database was opened with Options.ReadOnly, return an error. + if db.readOnly { + return nil, ErrDatabaseReadOnly + } + + // Obtain writer lock. This is released by the transaction when it closes. + // This enforces only one writer transaction at a time. + db.rwlock.Lock() + + // Once we have the writer lock then we can lock the meta pages so that + // we can set up the transaction. + db.metalock.Lock() + defer db.metalock.Unlock() + + // Exit if the database is not open yet. + if !db.opened { + db.rwlock.Unlock() + return nil, ErrDatabaseNotOpen + } + + // Create a transaction associated with the database. + t := &Tx{writable: true} + t.init(db) + db.rwtx = t + + // Free any pages associated with closed read-only transactions. + var minid txid = 0xFFFFFFFFFFFFFFFF + for _, t := range db.txs { + if t.meta.txid < minid { + minid = t.meta.txid + } + } + if minid > 0 { + db.freelist.release(minid - 1) + } + + return t, nil +} + +// removeTx removes a transaction from the database. +func (db *DB) removeTx(tx *Tx) { + // Release the read lock on the mmap. + db.mmaplock.RUnlock() + + // Use the meta lock to restrict access to the DB object. + db.metalock.Lock() + + // Remove the transaction. + for i, t := range db.txs { + if t == tx { + db.txs = append(db.txs[:i], db.txs[i+1:]...) + break + } + } + n := len(db.txs) + + // Unlock the meta pages. + db.metalock.Unlock() + + // Merge statistics. + db.statlock.Lock() + db.stats.OpenTxN = n + db.stats.TxStats.add(&tx.stats) + db.statlock.Unlock() +} + +// Update executes a function within the context of a read-write managed transaction. +// If no error is returned from the function then the transaction is committed. +// If an error is returned then the entire transaction is rolled back. +// Any error that is returned from the function or returned from the commit is +// returned from the Update() method. +// +// Attempting to manually commit or rollback within the function will cause a panic. +func (db *DB) Update(fn func(*Tx) error) error { + t, err := db.Begin(true) + if err != nil { + return err + } + + // Make sure the transaction rolls back in the event of a panic. + defer func() { + if t.db != nil { + t.rollback() + } + }() + + // Mark as a managed tx so that the inner function cannot manually commit. + t.managed = true + + // If an error is returned from the function then rollback and return error. + err = fn(t) + t.managed = false + if err != nil { + _ = t.Rollback() + return err + } + + return t.Commit() +} + +// View executes a function within the context of a managed read-only transaction. +// Any error that is returned from the function is returned from the View() method. +// +// Attempting to manually rollback within the function will cause a panic. +func (db *DB) View(fn func(*Tx) error) error { + t, err := db.Begin(false) + if err != nil { + return err + } + + // Make sure the transaction rolls back in the event of a panic. + defer func() { + if t.db != nil { + t.rollback() + } + }() + + // Mark as a managed tx so that the inner function cannot manually rollback. + t.managed = true + + // If an error is returned from the function then pass it through. + err = fn(t) + t.managed = false + if err != nil { + _ = t.Rollback() + return err + } + + if err := t.Rollback(); err != nil { + return err + } + + return nil +} + +// Batch calls fn as part of a batch. It behaves similar to Update, +// except: +// +// 1. concurrent Batch calls can be combined into a single Bolt +// transaction. +// +// 2. the function passed to Batch may be called multiple times, +// regardless of whether it returns error or not. +// +// This means that Batch function side effects must be idempotent and +// take permanent effect only after a successful return is seen in +// caller. +// +// The maximum batch size and delay can be adjusted with DB.MaxBatchSize +// and DB.MaxBatchDelay, respectively. +// +// Batch is only useful when there are multiple goroutines calling it. +func (db *DB) Batch(fn func(*Tx) error) error { + errCh := make(chan error, 1) + + db.batchMu.Lock() + if (db.batch == nil) || (db.batch != nil && len(db.batch.calls) >= db.MaxBatchSize) { + // There is no existing batch, or the existing batch is full; start a new one. + db.batch = &batch{ + db: db, + } + db.batch.timer = time.AfterFunc(db.MaxBatchDelay, db.batch.trigger) + } + db.batch.calls = append(db.batch.calls, call{fn: fn, err: errCh}) + if len(db.batch.calls) >= db.MaxBatchSize { + // wake up batch, it's ready to run + go db.batch.trigger() + } + db.batchMu.Unlock() + + err := <-errCh + if err == trySolo { + err = db.Update(fn) + } + return err +} + +type call struct { + fn func(*Tx) error + err chan<- error +} + +type batch struct { + db *DB + timer *time.Timer + start sync.Once + calls []call +} + +// trigger runs the batch if it hasn't already been run. +func (b *batch) trigger() { + b.start.Do(b.run) +} + +// run performs the transactions in the batch and communicates results +// back to DB.Batch. +func (b *batch) run() { + b.db.batchMu.Lock() + b.timer.Stop() + // Make sure no new work is added to this batch, but don't break + // other batches. + if b.db.batch == b { + b.db.batch = nil + } + b.db.batchMu.Unlock() + +retry: + for len(b.calls) > 0 { + var failIdx = -1 + err := b.db.Update(func(tx *Tx) error { + for i, c := range b.calls { + if err := safelyCall(c.fn, tx); err != nil { + failIdx = i + return err + } + } + return nil + }) + + if failIdx >= 0 { + // take the failing transaction out of the batch. it's + // safe to shorten b.calls here because db.batch no longer + // points to us, and we hold the mutex anyway. + c := b.calls[failIdx] + b.calls[failIdx], b.calls = b.calls[len(b.calls)-1], b.calls[:len(b.calls)-1] + // tell the submitter re-run it solo, continue with the rest of the batch + c.err <- trySolo + continue retry + } + + // pass success, or bolt internal errors, to all callers + for _, c := range b.calls { + if c.err != nil { + c.err <- err + } + } + break retry + } +} + +// trySolo is a special sentinel error value used for signaling that a +// transaction function should be re-run. It should never be seen by +// callers. +var trySolo = errors.New("batch function returned an error and should be re-run solo") + +type panicked struct { + reason interface{} +} + +func (p panicked) Error() string { + if err, ok := p.reason.(error); ok { + return err.Error() + } + return fmt.Sprintf("panic: %v", p.reason) +} + +func safelyCall(fn func(*Tx) error, tx *Tx) (err error) { + defer func() { + if p := recover(); p != nil { + err = panicked{p} + } + }() + return fn(tx) +} + +// Sync executes fdatasync() against the database file handle. +// +// This is not necessary under normal operation, however, if you use NoSync +// then it allows you to force the database file to sync against the disk. +func (db *DB) Sync() error { return fdatasync(db) } + +// Stats retrieves ongoing performance stats for the database. +// This is only updated when a transaction closes. +func (db *DB) Stats() Stats { + db.statlock.RLock() + defer db.statlock.RUnlock() + return db.stats +} + +// This is for internal access to the raw data bytes from the C cursor, use +// carefully, or not at all. +func (db *DB) Info() *Info { + return &Info{uintptr(unsafe.Pointer(&db.data[0])), db.pageSize} +} + +// page retrieves a page reference from the mmap based on the current page size. +func (db *DB) page(id pgid) *page { + pos := id * pgid(db.pageSize) + return (*page)(unsafe.Pointer(&db.data[pos])) +} + +// pageInBuffer retrieves a page reference from a given byte array based on the current page size. +func (db *DB) pageInBuffer(b []byte, id pgid) *page { + return (*page)(unsafe.Pointer(&b[id*pgid(db.pageSize)])) +} + +// meta retrieves the current meta page reference. +func (db *DB) meta() *meta { + // We have to return the meta with the highest txid which doesn't fail + // validation. Otherwise, we can cause errors when in fact the database is + // in a consistent state. metaA is the one with the higher txid. + metaA := db.meta0 + metaB := db.meta1 + if db.meta1.txid > db.meta0.txid { + metaA = db.meta1 + metaB = db.meta0 + } + + // Use higher meta page if valid. Otherwise fallback to previous, if valid. + if err := metaA.validate(); err == nil { + return metaA + } else if err := metaB.validate(); err == nil { + return metaB + } + + // This should never be reached, because both meta1 and meta0 were validated + // on mmap() and we do fsync() on every write. + panic("bolt.DB.meta(): invalid meta pages") +} + +// allocate returns a contiguous block of memory starting at a given page. +func (db *DB) allocate(count int) (*page, error) { + // Allocate a temporary buffer for the page. + var buf []byte + if count == 1 { + buf = db.pagePool.Get().([]byte) + } else { + buf = make([]byte, count*db.pageSize) + } + p := (*page)(unsafe.Pointer(&buf[0])) + p.overflow = uint32(count - 1) + + // Use pages from the freelist if they are available. + if p.id = db.freelist.allocate(count); p.id != 0 { + return p, nil + } + + // Resize mmap() if we're at the end. + p.id = db.rwtx.meta.pgid + var minsz = int((p.id+pgid(count))+1) * db.pageSize + if minsz >= db.datasz { + if err := db.mmap(minsz); err != nil { + return nil, fmt.Errorf("mmap allocate error: %s", err) + } + } + + // Move the page id high water mark. + db.rwtx.meta.pgid += pgid(count) + + return p, nil +} + +// grow grows the size of the database to the given sz. +func (db *DB) grow(sz int) error { + // Ignore if the new size is less than available file size. + if sz <= db.filesz { + return nil + } + + // If the data is smaller than the alloc size then only allocate what's needed. + // Once it goes over the allocation size then allocate in chunks. + if db.datasz < db.AllocSize { + sz = db.datasz + } else { + sz += db.AllocSize + } + + // Truncate and fsync to ensure file size metadata is flushed. + // https://github.com/boltdb/bolt/issues/284 + if !db.NoGrowSync && !db.readOnly { + if runtime.GOOS != "windows" { + if err := db.file.Truncate(int64(sz)); err != nil { + return fmt.Errorf("file resize error: %s", err) + } + } + if err := db.file.Sync(); err != nil { + return fmt.Errorf("file sync error: %s", err) + } + } + + db.filesz = sz + return nil +} + +func (db *DB) IsReadOnly() bool { + return db.readOnly +} + +// Options represents the options that can be set when opening a database. +type Options struct { + // Timeout is the amount of time to wait to obtain a file lock. + // When set to zero it will wait indefinitely. This option is only + // available on Darwin and Linux. + Timeout time.Duration + + // Sets the DB.NoGrowSync flag before memory mapping the file. + NoGrowSync bool + + // Open database in read-only mode. Uses flock(..., LOCK_SH |LOCK_NB) to + // grab a shared lock (UNIX). + ReadOnly bool + + // Sets the DB.MmapFlags flag before memory mapping the file. + MmapFlags int + + // InitialMmapSize is the initial mmap size of the database + // in bytes. Read transactions won't block write transaction + // if the InitialMmapSize is large enough to hold database mmap + // size. (See DB.Begin for more information) + // + // If <=0, the initial map size is 0. + // If initialMmapSize is smaller than the previous database size, + // it takes no effect. + InitialMmapSize int +} + +// DefaultOptions represent the options used if nil options are passed into Open(). +// No timeout is used which will cause Bolt to wait indefinitely for a lock. +var DefaultOptions = &Options{ + Timeout: 0, + NoGrowSync: false, +} + +// Stats represents statistics about the database. +type Stats struct { + // Freelist stats + FreePageN int // total number of free pages on the freelist + PendingPageN int // total number of pending pages on the freelist + FreeAlloc int // total bytes allocated in free pages + FreelistInuse int // total bytes used by the freelist + + // Transaction stats + TxN int // total number of started read transactions + OpenTxN int // number of currently open read transactions + + TxStats TxStats // global, ongoing stats. +} + +// Sub calculates and returns the difference between two sets of database stats. +// This is useful when obtaining stats at two different points and time and +// you need the performance counters that occurred within that time span. +func (s *Stats) Sub(other *Stats) Stats { + if other == nil { + return *s + } + var diff Stats + diff.FreePageN = s.FreePageN + diff.PendingPageN = s.PendingPageN + diff.FreeAlloc = s.FreeAlloc + diff.FreelistInuse = s.FreelistInuse + diff.TxN = other.TxN - s.TxN + diff.TxStats = s.TxStats.Sub(&other.TxStats) + return diff +} + +func (s *Stats) add(other *Stats) { + s.TxStats.add(&other.TxStats) +} + +type Info struct { + Data uintptr + PageSize int +} + +type meta struct { + magic uint32 + version uint32 + pageSize uint32 + flags uint32 + root bucket + freelist pgid + pgid pgid + txid txid + checksum uint64 +} + +// validate checks the marker bytes and version of the meta page to ensure it matches this binary. +func (m *meta) validate() error { + if m.magic != magic { + return ErrInvalid + } else if m.version != version { + return ErrVersionMismatch + } else if m.checksum != 0 && m.checksum != m.sum64() { + return ErrChecksum + } + return nil +} + +// copy copies one meta object to another. +func (m *meta) copy(dest *meta) { + *dest = *m +} + +// write writes the meta onto a page. +func (m *meta) write(p *page) { + if m.root.root >= m.pgid { + panic(fmt.Sprintf("root bucket pgid (%d) above high water mark (%d)", m.root.root, m.pgid)) + } else if m.freelist >= m.pgid { + panic(fmt.Sprintf("freelist pgid (%d) above high water mark (%d)", m.freelist, m.pgid)) + } + + // Page id is either going to be 0 or 1 which we can determine by the transaction ID. + p.id = pgid(m.txid % 2) + p.flags |= metaPageFlag + + // Calculate the checksum. + m.checksum = m.sum64() + + m.copy(p.meta()) +} + +// generates the checksum for the meta. +func (m *meta) sum64() uint64 { + var h = fnv.New64a() + _, _ = h.Write((*[unsafe.Offsetof(meta{}.checksum)]byte)(unsafe.Pointer(m))[:]) + return h.Sum64() +} + +// _assert will panic with a given formatted message if the given condition is false. +func _assert(condition bool, msg string, v ...interface{}) { + if !condition { + panic(fmt.Sprintf("assertion failed: "+msg, v...)) + } +} + +func warn(v ...interface{}) { fmt.Fprintln(os.Stderr, v...) } +func warnf(msg string, v ...interface{}) { fmt.Fprintf(os.Stderr, msg+"\n", v...) } + +func printstack() { + stack := strings.Join(strings.Split(string(debug.Stack()), "\n")[2:], "\n") + fmt.Fprintln(os.Stderr, stack) +} diff --git a/vendor/github.com/boltdb/bolt/db_test.go b/vendor/github.com/boltdb/bolt/db_test.go new file mode 100644 index 00000000..74ff93a9 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/db_test.go @@ -0,0 +1,1706 @@ +package bolt_test + +import ( + "bytes" + "encoding/binary" + "errors" + "flag" + "fmt" + "hash/fnv" + "io/ioutil" + "log" + "os" + "path/filepath" + "regexp" + "runtime" + "sort" + "strings" + "sync" + "testing" + "time" + "unsafe" + + "github.com/boltdb/bolt" +) + +var statsFlag = flag.Bool("stats", false, "show performance stats") + +// version is the data file format version. +const version = 2 + +// magic is the marker value to indicate that a file is a Bolt DB. +const magic uint32 = 0xED0CDAED + +// pageSize is the size of one page in the data file. +const pageSize = 4096 + +// pageHeaderSize is the size of a page header. +const pageHeaderSize = 16 + +// meta represents a simplified version of a database meta page for testing. +type meta struct { + magic uint32 + version uint32 + _ uint32 + _ uint32 + _ [16]byte + _ uint64 + pgid uint64 + _ uint64 + checksum uint64 +} + +// Ensure that a database can be opened without error. +func TestOpen(t *testing.T) { + path := tempfile() + db, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } else if db == nil { + t.Fatal("expected db") + } + + if s := db.Path(); s != path { + t.Fatalf("unexpected path: %s", s) + } + + if err := db.Close(); err != nil { + t.Fatal(err) + } +} + +// Ensure that opening a database with a blank path returns an error. +func TestOpen_ErrPathRequired(t *testing.T) { + _, err := bolt.Open("", 0666, nil) + if err == nil { + t.Fatalf("expected error") + } +} + +// Ensure that opening a database with a bad path returns an error. +func TestOpen_ErrNotExists(t *testing.T) { + _, err := bolt.Open(filepath.Join(tempfile(), "bad-path"), 0666, nil) + if err == nil { + t.Fatal("expected error") + } +} + +// Ensure that opening a file that is not a Bolt database returns ErrInvalid. +func TestOpen_ErrInvalid(t *testing.T) { + path := tempfile() + + f, err := os.Create(path) + if err != nil { + t.Fatal(err) + } + if _, err := fmt.Fprintln(f, "this is not a bolt database"); err != nil { + t.Fatal(err) + } + if err := f.Close(); err != nil { + t.Fatal(err) + } + defer os.Remove(path) + + if _, err := bolt.Open(path, 0666, nil); err != bolt.ErrInvalid { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that opening a file with two invalid versions returns ErrVersionMismatch. +func TestOpen_ErrVersionMismatch(t *testing.T) { + if pageSize != os.Getpagesize() { + t.Skip("page size mismatch") + } + + // Create empty database. + db := MustOpenDB() + path := db.Path() + defer db.MustClose() + + // Close database. + if err := db.DB.Close(); err != nil { + t.Fatal(err) + } + + // Read data file. + buf, err := ioutil.ReadFile(path) + if err != nil { + t.Fatal(err) + } + + // Rewrite meta pages. + meta0 := (*meta)(unsafe.Pointer(&buf[pageHeaderSize])) + meta0.version++ + meta1 := (*meta)(unsafe.Pointer(&buf[pageSize+pageHeaderSize])) + meta1.version++ + if err := ioutil.WriteFile(path, buf, 0666); err != nil { + t.Fatal(err) + } + + // Reopen data file. + if _, err := bolt.Open(path, 0666, nil); err != bolt.ErrVersionMismatch { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that opening a file with two invalid checksums returns ErrChecksum. +func TestOpen_ErrChecksum(t *testing.T) { + if pageSize != os.Getpagesize() { + t.Skip("page size mismatch") + } + + // Create empty database. + db := MustOpenDB() + path := db.Path() + defer db.MustClose() + + // Close database. + if err := db.DB.Close(); err != nil { + t.Fatal(err) + } + + // Read data file. + buf, err := ioutil.ReadFile(path) + if err != nil { + t.Fatal(err) + } + + // Rewrite meta pages. + meta0 := (*meta)(unsafe.Pointer(&buf[pageHeaderSize])) + meta0.pgid++ + meta1 := (*meta)(unsafe.Pointer(&buf[pageSize+pageHeaderSize])) + meta1.pgid++ + if err := ioutil.WriteFile(path, buf, 0666); err != nil { + t.Fatal(err) + } + + // Reopen data file. + if _, err := bolt.Open(path, 0666, nil); err != bolt.ErrChecksum { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that opening an already open database file will timeout. +func TestOpen_Timeout(t *testing.T) { + if runtime.GOOS == "solaris" { + t.Skip("solaris fcntl locks don't support intra-process locking") + } + + path := tempfile() + + // Open a data file. + db0, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } else if db0 == nil { + t.Fatal("expected database") + } + + // Attempt to open the database again. + start := time.Now() + db1, err := bolt.Open(path, 0666, &bolt.Options{Timeout: 100 * time.Millisecond}) + if err != bolt.ErrTimeout { + t.Fatalf("unexpected timeout: %s", err) + } else if db1 != nil { + t.Fatal("unexpected database") + } else if time.Since(start) <= 100*time.Millisecond { + t.Fatal("expected to wait at least timeout duration") + } + + if err := db0.Close(); err != nil { + t.Fatal(err) + } +} + +// Ensure that opening an already open database file will wait until its closed. +func TestOpen_Wait(t *testing.T) { + if runtime.GOOS == "solaris" { + t.Skip("solaris fcntl locks don't support intra-process locking") + } + + path := tempfile() + + // Open a data file. + db0, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } + + // Close it in just a bit. + time.AfterFunc(100*time.Millisecond, func() { _ = db0.Close() }) + + // Attempt to open the database again. + start := time.Now() + db1, err := bolt.Open(path, 0666, &bolt.Options{Timeout: 200 * time.Millisecond}) + if err != nil { + t.Fatal(err) + } else if time.Since(start) <= 100*time.Millisecond { + t.Fatal("expected to wait at least timeout duration") + } + + if err := db1.Close(); err != nil { + t.Fatal(err) + } +} + +// Ensure that opening a database does not increase its size. +// https://github.com/boltdb/bolt/issues/291 +func TestOpen_Size(t *testing.T) { + // Open a data file. + db := MustOpenDB() + path := db.Path() + defer db.MustClose() + + pagesize := db.Info().PageSize + + // Insert until we get above the minimum 4MB size. + if err := db.Update(func(tx *bolt.Tx) error { + b, _ := tx.CreateBucketIfNotExists([]byte("data")) + for i := 0; i < 10000; i++ { + if err := b.Put([]byte(fmt.Sprintf("%04d", i)), make([]byte, 1000)); err != nil { + t.Fatal(err) + } + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Close database and grab the size. + if err := db.DB.Close(); err != nil { + t.Fatal(err) + } + sz := fileSize(path) + if sz == 0 { + t.Fatalf("unexpected new file size: %d", sz) + } + + // Reopen database, update, and check size again. + db0, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } + if err := db0.Update(func(tx *bolt.Tx) error { + if err := tx.Bucket([]byte("data")).Put([]byte{0}, []byte{0}); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + if err := db0.Close(); err != nil { + t.Fatal(err) + } + newSz := fileSize(path) + if newSz == 0 { + t.Fatalf("unexpected new file size: %d", newSz) + } + + // Compare the original size with the new size. + // db size might increase by a few page sizes due to the new small update. + if sz < newSz-5*int64(pagesize) { + t.Fatalf("unexpected file growth: %d => %d", sz, newSz) + } +} + +// Ensure that opening a database beyond the max step size does not increase its size. +// https://github.com/boltdb/bolt/issues/303 +func TestOpen_Size_Large(t *testing.T) { + if testing.Short() { + t.Skip("short mode") + } + + // Open a data file. + db := MustOpenDB() + path := db.Path() + defer db.MustClose() + + pagesize := db.Info().PageSize + + // Insert until we get above the minimum 4MB size. + var index uint64 + for i := 0; i < 10000; i++ { + if err := db.Update(func(tx *bolt.Tx) error { + b, _ := tx.CreateBucketIfNotExists([]byte("data")) + for j := 0; j < 1000; j++ { + if err := b.Put(u64tob(index), make([]byte, 50)); err != nil { + t.Fatal(err) + } + index++ + } + return nil + }); err != nil { + t.Fatal(err) + } + } + + // Close database and grab the size. + if err := db.DB.Close(); err != nil { + t.Fatal(err) + } + sz := fileSize(path) + if sz == 0 { + t.Fatalf("unexpected new file size: %d", sz) + } else if sz < (1 << 30) { + t.Fatalf("expected larger initial size: %d", sz) + } + + // Reopen database, update, and check size again. + db0, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } + if err := db0.Update(func(tx *bolt.Tx) error { + return tx.Bucket([]byte("data")).Put([]byte{0}, []byte{0}) + }); err != nil { + t.Fatal(err) + } + if err := db0.Close(); err != nil { + t.Fatal(err) + } + + newSz := fileSize(path) + if newSz == 0 { + t.Fatalf("unexpected new file size: %d", newSz) + } + + // Compare the original size with the new size. + // db size might increase by a few page sizes due to the new small update. + if sz < newSz-5*int64(pagesize) { + t.Fatalf("unexpected file growth: %d => %d", sz, newSz) + } +} + +// Ensure that a re-opened database is consistent. +func TestOpen_Check(t *testing.T) { + path := tempfile() + + db, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } + if err := db.View(func(tx *bolt.Tx) error { return <-tx.Check() }); err != nil { + t.Fatal(err) + } + if err := db.Close(); err != nil { + t.Fatal(err) + } + + db, err = bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } + if err := db.View(func(tx *bolt.Tx) error { return <-tx.Check() }); err != nil { + t.Fatal(err) + } + if err := db.Close(); err != nil { + t.Fatal(err) + } +} + +// Ensure that write errors to the meta file handler during initialization are returned. +func TestOpen_MetaInitWriteError(t *testing.T) { + t.Skip("pending") +} + +// Ensure that a database that is too small returns an error. +func TestOpen_FileTooSmall(t *testing.T) { + path := tempfile() + + db, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } + if err := db.Close(); err != nil { + t.Fatal(err) + } + + // corrupt the database + if err := os.Truncate(path, int64(os.Getpagesize())); err != nil { + t.Fatal(err) + } + + db, err = bolt.Open(path, 0666, nil) + if err == nil || err.Error() != "file size too small" { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that a database can be opened in read-only mode by multiple processes +// and that a database can not be opened in read-write mode and in read-only +// mode at the same time. +func TestOpen_ReadOnly(t *testing.T) { + if runtime.GOOS == "solaris" { + t.Skip("solaris fcntl locks don't support intra-process locking") + } + + bucket, key, value := []byte(`bucket`), []byte(`key`), []byte(`value`) + + path := tempfile() + + // Open in read-write mode. + db, err := bolt.Open(path, 0666, nil) + if err != nil { + t.Fatal(err) + } else if db.IsReadOnly() { + t.Fatal("db should not be in read only mode") + } + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket(bucket) + if err != nil { + return err + } + if err := b.Put(key, value); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + if err := db.Close(); err != nil { + t.Fatal(err) + } + + // Open in read-only mode. + db0, err := bolt.Open(path, 0666, &bolt.Options{ReadOnly: true}) + if err != nil { + t.Fatal(err) + } + + // Opening in read-write mode should return an error. + if _, err = bolt.Open(path, 0666, &bolt.Options{Timeout: time.Millisecond * 100}); err == nil { + t.Fatal("expected error") + } + + // And again (in read-only mode). + db1, err := bolt.Open(path, 0666, &bolt.Options{ReadOnly: true}) + if err != nil { + t.Fatal(err) + } + + // Verify both read-only databases are accessible. + for _, db := range []*bolt.DB{db0, db1} { + // Verify is is in read only mode indeed. + if !db.IsReadOnly() { + t.Fatal("expected read only mode") + } + + // Read-only databases should not allow updates. + if err := db.Update(func(*bolt.Tx) error { + panic(`should never get here`) + }); err != bolt.ErrDatabaseReadOnly { + t.Fatalf("unexpected error: %s", err) + } + + // Read-only databases should not allow beginning writable txns. + if _, err := db.Begin(true); err != bolt.ErrDatabaseReadOnly { + t.Fatalf("unexpected error: %s", err) + } + + // Verify the data. + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket(bucket) + if b == nil { + return fmt.Errorf("expected bucket `%s`", string(bucket)) + } + + got := string(b.Get(key)) + expected := string(value) + if got != expected { + return fmt.Errorf("expected `%s`, got `%s`", expected, got) + } + return nil + }); err != nil { + t.Fatal(err) + } + } + + if err := db0.Close(); err != nil { + t.Fatal(err) + } + if err := db1.Close(); err != nil { + t.Fatal(err) + } +} + +// TestDB_Open_InitialMmapSize tests if having InitialMmapSize large enough +// to hold data from concurrent write transaction resolves the issue that +// read transaction blocks the write transaction and causes deadlock. +// This is a very hacky test since the mmap size is not exposed. +func TestDB_Open_InitialMmapSize(t *testing.T) { + path := tempfile() + defer os.Remove(path) + + initMmapSize := 1 << 31 // 2GB + testWriteSize := 1 << 27 // 134MB + + db, err := bolt.Open(path, 0666, &bolt.Options{InitialMmapSize: initMmapSize}) + if err != nil { + t.Fatal(err) + } + + // create a long-running read transaction + // that never gets closed while writing + rtx, err := db.Begin(false) + if err != nil { + t.Fatal(err) + } + + // create a write transaction + wtx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + + b, err := wtx.CreateBucket([]byte("test")) + if err != nil { + t.Fatal(err) + } + + // and commit a large write + err = b.Put([]byte("foo"), make([]byte, testWriteSize)) + if err != nil { + t.Fatal(err) + } + + done := make(chan struct{}) + + go func() { + if err := wtx.Commit(); err != nil { + t.Fatal(err) + } + done <- struct{}{} + }() + + select { + case <-time.After(5 * time.Second): + t.Errorf("unexpected that the reader blocks writer") + case <-done: + } + + if err := rtx.Rollback(); err != nil { + t.Fatal(err) + } +} + +// Ensure that a database cannot open a transaction when it's not open. +func TestDB_Begin_ErrDatabaseNotOpen(t *testing.T) { + var db bolt.DB + if _, err := db.Begin(false); err != bolt.ErrDatabaseNotOpen { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that a read-write transaction can be retrieved. +func TestDB_BeginRW(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } else if tx == nil { + t.Fatal("expected tx") + } + + if tx.DB() != db.DB { + t.Fatal("unexpected tx database") + } else if !tx.Writable() { + t.Fatal("expected writable tx") + } + + if err := tx.Commit(); err != nil { + t.Fatal(err) + } +} + +// Ensure that opening a transaction while the DB is closed returns an error. +func TestDB_BeginRW_Closed(t *testing.T) { + var db bolt.DB + if _, err := db.Begin(true); err != bolt.ErrDatabaseNotOpen { + t.Fatalf("unexpected error: %s", err) + } +} + +func TestDB_Close_PendingTx_RW(t *testing.T) { testDB_Close_PendingTx(t, true) } +func TestDB_Close_PendingTx_RO(t *testing.T) { testDB_Close_PendingTx(t, false) } + +// Ensure that a database cannot close while transactions are open. +func testDB_Close_PendingTx(t *testing.T, writable bool) { + db := MustOpenDB() + defer db.MustClose() + + // Start transaction. + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + + // Open update in separate goroutine. + done := make(chan struct{}) + go func() { + if err := db.Close(); err != nil { + t.Fatal(err) + } + close(done) + }() + + // Ensure database hasn't closed. + time.Sleep(100 * time.Millisecond) + select { + case <-done: + t.Fatal("database closed too early") + default: + } + + // Commit transaction. + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + + // Ensure database closed now. + time.Sleep(100 * time.Millisecond) + select { + case <-done: + default: + t.Fatal("database did not close") + } +} + +// Ensure a database can provide a transactional block. +func TestDB_Update(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte("bat")); err != nil { + t.Fatal(err) + } + if err := b.Delete([]byte("foo")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + if v := b.Get([]byte("foo")); v != nil { + t.Fatalf("expected nil value, got: %v", v) + } + if v := b.Get([]byte("baz")); !bytes.Equal(v, []byte("bat")) { + t.Fatalf("unexpected value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a closed database returns an error while running a transaction block +func TestDB_Update_Closed(t *testing.T) { + var db bolt.DB + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != bolt.ErrDatabaseNotOpen { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure a panic occurs while trying to commit a managed transaction. +func TestDB_Update_ManualCommit(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var panicked bool + if err := db.Update(func(tx *bolt.Tx) error { + func() { + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + }() + return nil + }); err != nil { + t.Fatal(err) + } else if !panicked { + t.Fatal("expected panic") + } +} + +// Ensure a panic occurs while trying to rollback a managed transaction. +func TestDB_Update_ManualRollback(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var panicked bool + if err := db.Update(func(tx *bolt.Tx) error { + func() { + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + }() + return nil + }); err != nil { + t.Fatal(err) + } else if !panicked { + t.Fatal("expected panic") + } +} + +// Ensure a panic occurs while trying to commit a managed transaction. +func TestDB_View_ManualCommit(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var panicked bool + if err := db.View(func(tx *bolt.Tx) error { + func() { + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + }() + return nil + }); err != nil { + t.Fatal(err) + } else if !panicked { + t.Fatal("expected panic") + } +} + +// Ensure a panic occurs while trying to rollback a managed transaction. +func TestDB_View_ManualRollback(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var panicked bool + if err := db.View(func(tx *bolt.Tx) error { + func() { + defer func() { + if r := recover(); r != nil { + panicked = true + } + }() + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + }() + return nil + }); err != nil { + t.Fatal(err) + } else if !panicked { + t.Fatal("expected panic") + } +} + +// Ensure a write transaction that panics does not hold open locks. +func TestDB_Update_Panic(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + // Panic during update but recover. + func() { + defer func() { + if r := recover(); r != nil { + t.Log("recover: update", r) + } + }() + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + panic("omg") + }); err != nil { + t.Fatal(err) + } + }() + + // Verify we can update again. + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Verify that our change persisted. + if err := db.Update(func(tx *bolt.Tx) error { + if tx.Bucket([]byte("widgets")) == nil { + t.Fatal("expected bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure a database can return an error through a read-only transactional block. +func TestDB_View_Error(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.View(func(tx *bolt.Tx) error { + return errors.New("xxx") + }); err == nil || err.Error() != "xxx" { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure a read transaction that panics does not hold open locks. +func TestDB_View_Panic(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Panic during view transaction but recover. + func() { + defer func() { + if r := recover(); r != nil { + t.Log("recover: view", r) + } + }() + + if err := db.View(func(tx *bolt.Tx) error { + if tx.Bucket([]byte("widgets")) == nil { + t.Fatal("expected bucket") + } + panic("omg") + }); err != nil { + t.Fatal(err) + } + }() + + // Verify that we can still use read transactions. + if err := db.View(func(tx *bolt.Tx) error { + if tx.Bucket([]byte("widgets")) == nil { + t.Fatal("expected bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that DB stats can be returned. +func TestDB_Stats(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + t.Fatal(err) + } + + stats := db.Stats() + if stats.TxStats.PageCount != 2 { + t.Fatalf("unexpected TxStats.PageCount: %d", stats.TxStats.PageCount) + } else if stats.FreePageN != 0 { + t.Fatalf("unexpected FreePageN != 0: %d", stats.FreePageN) + } else if stats.PendingPageN != 2 { + t.Fatalf("unexpected PendingPageN != 2: %d", stats.PendingPageN) + } +} + +// Ensure that database pages are in expected order and type. +func TestDB_Consistency(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + t.Fatal(err) + } + + for i := 0; i < 10; i++ { + if err := db.Update(func(tx *bolt.Tx) error { + if err := tx.Bucket([]byte("widgets")).Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + } + + if err := db.Update(func(tx *bolt.Tx) error { + if p, _ := tx.Page(0); p == nil { + t.Fatal("expected page") + } else if p.Type != "meta" { + t.Fatalf("unexpected page type: %s", p.Type) + } + + if p, _ := tx.Page(1); p == nil { + t.Fatal("expected page") + } else if p.Type != "meta" { + t.Fatalf("unexpected page type: %s", p.Type) + } + + if p, _ := tx.Page(2); p == nil { + t.Fatal("expected page") + } else if p.Type != "free" { + t.Fatalf("unexpected page type: %s", p.Type) + } + + if p, _ := tx.Page(3); p == nil { + t.Fatal("expected page") + } else if p.Type != "free" { + t.Fatalf("unexpected page type: %s", p.Type) + } + + if p, _ := tx.Page(4); p == nil { + t.Fatal("expected page") + } else if p.Type != "leaf" { + t.Fatalf("unexpected page type: %s", p.Type) + } + + if p, _ := tx.Page(5); p == nil { + t.Fatal("expected page") + } else if p.Type != "freelist" { + t.Fatalf("unexpected page type: %s", p.Type) + } + + if p, _ := tx.Page(6); p != nil { + t.Fatal("unexpected page") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that DB stats can be subtracted from one another. +func TestDBStats_Sub(t *testing.T) { + var a, b bolt.Stats + a.TxStats.PageCount = 3 + a.FreePageN = 4 + b.TxStats.PageCount = 10 + b.FreePageN = 14 + diff := b.Sub(&a) + if diff.TxStats.PageCount != 7 { + t.Fatalf("unexpected TxStats.PageCount: %d", diff.TxStats.PageCount) + } + + // free page stats are copied from the receiver and not subtracted + if diff.FreePageN != 14 { + t.Fatalf("unexpected FreePageN: %d", diff.FreePageN) + } +} + +// Ensure two functions can perform updates in a single batch. +func TestDB_Batch(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Iterate over multiple updates in separate goroutines. + n := 2 + ch := make(chan error) + for i := 0; i < n; i++ { + go func(i int) { + ch <- db.Batch(func(tx *bolt.Tx) error { + return tx.Bucket([]byte("widgets")).Put(u64tob(uint64(i)), []byte{}) + }) + }(i) + } + + // Check all responses to make sure there's no error. + for i := 0; i < n; i++ { + if err := <-ch; err != nil { + t.Fatal(err) + } + } + + // Ensure data is correct. + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for i := 0; i < n; i++ { + if v := b.Get(u64tob(uint64(i))); v == nil { + t.Errorf("key not found: %d", i) + } + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +func TestDB_Batch_Panic(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var sentinel int + var bork = &sentinel + var problem interface{} + var err error + + // Execute a function inside a batch that panics. + func() { + defer func() { + if p := recover(); p != nil { + problem = p + } + }() + err = db.Batch(func(tx *bolt.Tx) error { + panic(bork) + }) + }() + + // Verify there is no error. + if g, e := err, error(nil); g != e { + t.Fatalf("wrong error: %v != %v", g, e) + } + // Verify the panic was captured. + if g, e := problem, bork; g != e { + t.Fatalf("wrong error: %v != %v", g, e) + } +} + +func TestDB_BatchFull(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + t.Fatal(err) + } + + const size = 3 + // buffered so we never leak goroutines + ch := make(chan error, size) + put := func(i int) { + ch <- db.Batch(func(tx *bolt.Tx) error { + return tx.Bucket([]byte("widgets")).Put(u64tob(uint64(i)), []byte{}) + }) + } + + db.MaxBatchSize = size + // high enough to never trigger here + db.MaxBatchDelay = 1 * time.Hour + + go put(1) + go put(2) + + // Give the batch a chance to exhibit bugs. + time.Sleep(10 * time.Millisecond) + + // not triggered yet + select { + case <-ch: + t.Fatalf("batch triggered too early") + default: + } + + go put(3) + + // Check all responses to make sure there's no error. + for i := 0; i < size; i++ { + if err := <-ch; err != nil { + t.Fatal(err) + } + } + + // Ensure data is correct. + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for i := 1; i <= size; i++ { + if v := b.Get(u64tob(uint64(i))); v == nil { + t.Errorf("key not found: %d", i) + } + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +func TestDB_BatchTime(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + t.Fatal(err) + } + + const size = 1 + // buffered so we never leak goroutines + ch := make(chan error, size) + put := func(i int) { + ch <- db.Batch(func(tx *bolt.Tx) error { + return tx.Bucket([]byte("widgets")).Put(u64tob(uint64(i)), []byte{}) + }) + } + + db.MaxBatchSize = 1000 + db.MaxBatchDelay = 0 + + go put(1) + + // Batch must trigger by time alone. + + // Check all responses to make sure there's no error. + for i := 0; i < size; i++ { + if err := <-ch; err != nil { + t.Fatal(err) + } + } + + // Ensure data is correct. + if err := db.View(func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("widgets")) + for i := 1; i <= size; i++ { + if v := b.Get(u64tob(uint64(i))); v == nil { + t.Errorf("key not found: %d", i) + } + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +func ExampleDB_Update() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Execute several commands within a read-write transaction. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + return err + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + return err + } + return nil + }); err != nil { + log.Fatal(err) + } + + // Read the value back from a separate read-only transaction. + if err := db.View(func(tx *bolt.Tx) error { + value := tx.Bucket([]byte("widgets")).Get([]byte("foo")) + fmt.Printf("The value of 'foo' is: %s\n", value) + return nil + }); err != nil { + log.Fatal(err) + } + + // Close database to release the file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // The value of 'foo' is: bar +} + +func ExampleDB_View() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Insert data into a bucket. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("people")) + if err != nil { + return err + } + if err := b.Put([]byte("john"), []byte("doe")); err != nil { + return err + } + if err := b.Put([]byte("susy"), []byte("que")); err != nil { + return err + } + return nil + }); err != nil { + log.Fatal(err) + } + + // Access data from within a read-only transactional block. + if err := db.View(func(tx *bolt.Tx) error { + v := tx.Bucket([]byte("people")).Get([]byte("john")) + fmt.Printf("John's last name is %s.\n", v) + return nil + }); err != nil { + log.Fatal(err) + } + + // Close database to release the file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // John's last name is doe. +} + +func ExampleDB_Begin_ReadOnly() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Create a bucket using a read-write transaction. + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + log.Fatal(err) + } + + // Create several keys in a transaction. + tx, err := db.Begin(true) + if err != nil { + log.Fatal(err) + } + b := tx.Bucket([]byte("widgets")) + if err := b.Put([]byte("john"), []byte("blue")); err != nil { + log.Fatal(err) + } + if err := b.Put([]byte("abby"), []byte("red")); err != nil { + log.Fatal(err) + } + if err := b.Put([]byte("zephyr"), []byte("purple")); err != nil { + log.Fatal(err) + } + if err := tx.Commit(); err != nil { + log.Fatal(err) + } + + // Iterate over the values in sorted key order. + tx, err = db.Begin(false) + if err != nil { + log.Fatal(err) + } + c := tx.Bucket([]byte("widgets")).Cursor() + for k, v := c.First(); k != nil; k, v = c.Next() { + fmt.Printf("%s likes %s\n", k, v) + } + + if err := tx.Rollback(); err != nil { + log.Fatal(err) + } + + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // abby likes red + // john likes blue + // zephyr likes purple +} + +func BenchmarkDBBatchAutomatic(b *testing.B) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("bench")) + return err + }); err != nil { + b.Fatal(err) + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + start := make(chan struct{}) + var wg sync.WaitGroup + + for round := 0; round < 1000; round++ { + wg.Add(1) + + go func(id uint32) { + defer wg.Done() + <-start + + h := fnv.New32a() + buf := make([]byte, 4) + binary.LittleEndian.PutUint32(buf, id) + _, _ = h.Write(buf[:]) + k := h.Sum(nil) + insert := func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("bench")) + return b.Put(k, []byte("filler")) + } + if err := db.Batch(insert); err != nil { + b.Error(err) + return + } + }(uint32(round)) + } + close(start) + wg.Wait() + } + + b.StopTimer() + validateBatchBench(b, db) +} + +func BenchmarkDBBatchSingle(b *testing.B) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("bench")) + return err + }); err != nil { + b.Fatal(err) + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + start := make(chan struct{}) + var wg sync.WaitGroup + + for round := 0; round < 1000; round++ { + wg.Add(1) + go func(id uint32) { + defer wg.Done() + <-start + + h := fnv.New32a() + buf := make([]byte, 4) + binary.LittleEndian.PutUint32(buf, id) + _, _ = h.Write(buf[:]) + k := h.Sum(nil) + insert := func(tx *bolt.Tx) error { + b := tx.Bucket([]byte("bench")) + return b.Put(k, []byte("filler")) + } + if err := db.Update(insert); err != nil { + b.Error(err) + return + } + }(uint32(round)) + } + close(start) + wg.Wait() + } + + b.StopTimer() + validateBatchBench(b, db) +} + +func BenchmarkDBBatchManual10x100(b *testing.B) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("bench")) + return err + }); err != nil { + b.Fatal(err) + } + + b.ResetTimer() + for i := 0; i < b.N; i++ { + start := make(chan struct{}) + var wg sync.WaitGroup + + for major := 0; major < 10; major++ { + wg.Add(1) + go func(id uint32) { + defer wg.Done() + <-start + + insert100 := func(tx *bolt.Tx) error { + h := fnv.New32a() + buf := make([]byte, 4) + for minor := uint32(0); minor < 100; minor++ { + binary.LittleEndian.PutUint32(buf, uint32(id*100+minor)) + h.Reset() + _, _ = h.Write(buf[:]) + k := h.Sum(nil) + b := tx.Bucket([]byte("bench")) + if err := b.Put(k, []byte("filler")); err != nil { + return err + } + } + return nil + } + if err := db.Update(insert100); err != nil { + b.Fatal(err) + } + }(uint32(major)) + } + close(start) + wg.Wait() + } + + b.StopTimer() + validateBatchBench(b, db) +} + +func validateBatchBench(b *testing.B, db *DB) { + var rollback = errors.New("sentinel error to cause rollback") + validate := func(tx *bolt.Tx) error { + bucket := tx.Bucket([]byte("bench")) + h := fnv.New32a() + buf := make([]byte, 4) + for id := uint32(0); id < 1000; id++ { + binary.LittleEndian.PutUint32(buf, id) + h.Reset() + _, _ = h.Write(buf[:]) + k := h.Sum(nil) + v := bucket.Get(k) + if v == nil { + b.Errorf("not found id=%d key=%x", id, k) + continue + } + if g, e := v, []byte("filler"); !bytes.Equal(g, e) { + b.Errorf("bad value for id=%d key=%x: %s != %q", id, k, g, e) + } + if err := bucket.Delete(k); err != nil { + return err + } + } + // should be empty now + c := bucket.Cursor() + for k, v := c.First(); k != nil; k, v = c.Next() { + b.Errorf("unexpected key: %x = %q", k, v) + } + return rollback + } + if err := db.Update(validate); err != nil && err != rollback { + b.Error(err) + } +} + +// DB is a test wrapper for bolt.DB. +type DB struct { + *bolt.DB +} + +// MustOpenDB returns a new, open DB at a temporary location. +func MustOpenDB() *DB { + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + panic(err) + } + return &DB{db} +} + +// Close closes the database and deletes the underlying file. +func (db *DB) Close() error { + // Log statistics. + if *statsFlag { + db.PrintStats() + } + + // Check database consistency after every test. + db.MustCheck() + + // Close database and remove file. + defer os.Remove(db.Path()) + return db.DB.Close() +} + +// MustClose closes the database and deletes the underlying file. Panic on error. +func (db *DB) MustClose() { + if err := db.Close(); err != nil { + panic(err) + } +} + +// PrintStats prints the database stats +func (db *DB) PrintStats() { + var stats = db.Stats() + fmt.Printf("[db] %-20s %-20s %-20s\n", + fmt.Sprintf("pg(%d/%d)", stats.TxStats.PageCount, stats.TxStats.PageAlloc), + fmt.Sprintf("cur(%d)", stats.TxStats.CursorCount), + fmt.Sprintf("node(%d/%d)", stats.TxStats.NodeCount, stats.TxStats.NodeDeref), + ) + fmt.Printf(" %-20s %-20s %-20s\n", + fmt.Sprintf("rebal(%d/%v)", stats.TxStats.Rebalance, truncDuration(stats.TxStats.RebalanceTime)), + fmt.Sprintf("spill(%d/%v)", stats.TxStats.Spill, truncDuration(stats.TxStats.SpillTime)), + fmt.Sprintf("w(%d/%v)", stats.TxStats.Write, truncDuration(stats.TxStats.WriteTime)), + ) +} + +// MustCheck runs a consistency check on the database and panics if any errors are found. +func (db *DB) MustCheck() { + if err := db.Update(func(tx *bolt.Tx) error { + // Collect all the errors. + var errors []error + for err := range tx.Check() { + errors = append(errors, err) + if len(errors) > 10 { + break + } + } + + // If errors occurred, copy the DB and print the errors. + if len(errors) > 0 { + var path = tempfile() + if err := tx.CopyFile(path, 0600); err != nil { + panic(err) + } + + // Print errors. + fmt.Print("\n\n") + fmt.Printf("consistency check failed (%d errors)\n", len(errors)) + for _, err := range errors { + fmt.Println(err) + } + fmt.Println("") + fmt.Println("db saved to:") + fmt.Println(path) + fmt.Print("\n\n") + os.Exit(-1) + } + + return nil + }); err != nil && err != bolt.ErrDatabaseNotOpen { + panic(err) + } +} + +// CopyTempFile copies a database to a temporary file. +func (db *DB) CopyTempFile() { + path := tempfile() + if err := db.View(func(tx *bolt.Tx) error { + return tx.CopyFile(path, 0600) + }); err != nil { + panic(err) + } + fmt.Println("db copied to: ", path) +} + +// tempfile returns a temporary file path. +func tempfile() string { + f, err := ioutil.TempFile("", "bolt-") + if err != nil { + panic(err) + } + if err := f.Close(); err != nil { + panic(err) + } + if err := os.Remove(f.Name()); err != nil { + panic(err) + } + return f.Name() +} + +// mustContainKeys checks that a bucket contains a given set of keys. +func mustContainKeys(b *bolt.Bucket, m map[string]string) { + found := make(map[string]string) + if err := b.ForEach(func(k, _ []byte) error { + found[string(k)] = "" + return nil + }); err != nil { + panic(err) + } + + // Check for keys found in bucket that shouldn't be there. + var keys []string + for k, _ := range found { + if _, ok := m[string(k)]; !ok { + keys = append(keys, k) + } + } + if len(keys) > 0 { + sort.Strings(keys) + panic(fmt.Sprintf("keys found(%d): %s", len(keys), strings.Join(keys, ","))) + } + + // Check for keys not found in bucket that should be there. + for k, _ := range m { + if _, ok := found[string(k)]; !ok { + keys = append(keys, k) + } + } + if len(keys) > 0 { + sort.Strings(keys) + panic(fmt.Sprintf("keys not found(%d): %s", len(keys), strings.Join(keys, ","))) + } +} + +func trunc(b []byte, length int) []byte { + if length < len(b) { + return b[:length] + } + return b +} + +func truncDuration(d time.Duration) string { + return regexp.MustCompile(`^(\d+)(\.\d+)`).ReplaceAllString(d.String(), "$1") +} + +func fileSize(path string) int64 { + fi, err := os.Stat(path) + if err != nil { + return 0 + } + return fi.Size() +} + +func warn(v ...interface{}) { fmt.Fprintln(os.Stderr, v...) } +func warnf(msg string, v ...interface{}) { fmt.Fprintf(os.Stderr, msg+"\n", v...) } + +// u64tob converts a uint64 into an 8-byte slice. +func u64tob(v uint64) []byte { + b := make([]byte, 8) + binary.BigEndian.PutUint64(b, v) + return b +} + +// btou64 converts an 8-byte slice into an uint64. +func btou64(b []byte) uint64 { return binary.BigEndian.Uint64(b) } diff --git a/vendor/github.com/boltdb/bolt/doc.go b/vendor/github.com/boltdb/bolt/doc.go new file mode 100644 index 00000000..cc937845 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/doc.go @@ -0,0 +1,44 @@ +/* +Package bolt implements a low-level key/value store in pure Go. It supports +fully serializable transactions, ACID semantics, and lock-free MVCC with +multiple readers and a single writer. Bolt can be used for projects that +want a simple data store without the need to add large dependencies such as +Postgres or MySQL. + +Bolt is a single-level, zero-copy, B+tree data store. This means that Bolt is +optimized for fast read access and does not require recovery in the event of a +system crash. Transactions which have not finished committing will simply be +rolled back in the event of a crash. + +The design of Bolt is based on Howard Chu's LMDB database project. + +Bolt currently works on Windows, Mac OS X, and Linux. + + +Basics + +There are only a few types in Bolt: DB, Bucket, Tx, and Cursor. The DB is +a collection of buckets and is represented by a single file on disk. A bucket is +a collection of unique keys that are associated with values. + +Transactions provide either read-only or read-write access to the database. +Read-only transactions can retrieve key/value pairs and can use Cursors to +iterate over the dataset sequentially. Read-write transactions can create and +delete buckets and can insert and remove keys. Only one read-write transaction +is allowed at a time. + + +Caveats + +The database uses a read-only, memory-mapped data file to ensure that +applications cannot corrupt the database, however, this means that keys and +values returned from Bolt cannot be changed. Writing to a read-only byte slice +will cause Go to panic. + +Keys and values retrieved from the database are only valid for the life of +the transaction. When used outside the transaction, these byte slices can +point to different data or can point to invalid memory which will cause a panic. + + +*/ +package bolt diff --git a/vendor/github.com/boltdb/bolt/errors.go b/vendor/github.com/boltdb/bolt/errors.go new file mode 100644 index 00000000..a3620a3e --- /dev/null +++ b/vendor/github.com/boltdb/bolt/errors.go @@ -0,0 +1,71 @@ +package bolt + +import "errors" + +// These errors can be returned when opening or calling methods on a DB. +var ( + // ErrDatabaseNotOpen is returned when a DB instance is accessed before it + // is opened or after it is closed. + ErrDatabaseNotOpen = errors.New("database not open") + + // ErrDatabaseOpen is returned when opening a database that is + // already open. + ErrDatabaseOpen = errors.New("database already open") + + // ErrInvalid is returned when both meta pages on a database are invalid. + // This typically occurs when a file is not a bolt database. + ErrInvalid = errors.New("invalid database") + + // ErrVersionMismatch is returned when the data file was created with a + // different version of Bolt. + ErrVersionMismatch = errors.New("version mismatch") + + // ErrChecksum is returned when either meta page checksum does not match. + ErrChecksum = errors.New("checksum error") + + // ErrTimeout is returned when a database cannot obtain an exclusive lock + // on the data file after the timeout passed to Open(). + ErrTimeout = errors.New("timeout") +) + +// These errors can occur when beginning or committing a Tx. +var ( + // ErrTxNotWritable is returned when performing a write operation on a + // read-only transaction. + ErrTxNotWritable = errors.New("tx not writable") + + // ErrTxClosed is returned when committing or rolling back a transaction + // that has already been committed or rolled back. + ErrTxClosed = errors.New("tx closed") + + // ErrDatabaseReadOnly is returned when a mutating transaction is started on a + // read-only database. + ErrDatabaseReadOnly = errors.New("database is in read-only mode") +) + +// These errors can occur when putting or deleting a value or a bucket. +var ( + // ErrBucketNotFound is returned when trying to access a bucket that has + // not been created yet. + ErrBucketNotFound = errors.New("bucket not found") + + // ErrBucketExists is returned when creating a bucket that already exists. + ErrBucketExists = errors.New("bucket already exists") + + // ErrBucketNameRequired is returned when creating a bucket with a blank name. + ErrBucketNameRequired = errors.New("bucket name required") + + // ErrKeyRequired is returned when inserting a zero-length key. + ErrKeyRequired = errors.New("key required") + + // ErrKeyTooLarge is returned when inserting a key that is larger than MaxKeySize. + ErrKeyTooLarge = errors.New("key too large") + + // ErrValueTooLarge is returned when inserting a value that is larger than MaxValueSize. + ErrValueTooLarge = errors.New("value too large") + + // ErrIncompatibleValue is returned when trying create or delete a bucket + // on an existing non-bucket key or when trying to create or delete a + // non-bucket key on an existing bucket key. + ErrIncompatibleValue = errors.New("incompatible value") +) diff --git a/vendor/github.com/boltdb/bolt/freelist.go b/vendor/github.com/boltdb/bolt/freelist.go new file mode 100644 index 00000000..1b7ba91b --- /dev/null +++ b/vendor/github.com/boltdb/bolt/freelist.go @@ -0,0 +1,248 @@ +package bolt + +import ( + "fmt" + "sort" + "unsafe" +) + +// freelist represents a list of all pages that are available for allocation. +// It also tracks pages that have been freed but are still in use by open transactions. +type freelist struct { + ids []pgid // all free and available free page ids. + pending map[txid][]pgid // mapping of soon-to-be free page ids by tx. + cache map[pgid]bool // fast lookup of all free and pending page ids. +} + +// newFreelist returns an empty, initialized freelist. +func newFreelist() *freelist { + return &freelist{ + pending: make(map[txid][]pgid), + cache: make(map[pgid]bool), + } +} + +// size returns the size of the page after serialization. +func (f *freelist) size() int { + return pageHeaderSize + (int(unsafe.Sizeof(pgid(0))) * f.count()) +} + +// count returns count of pages on the freelist +func (f *freelist) count() int { + return f.free_count() + f.pending_count() +} + +// free_count returns count of free pages +func (f *freelist) free_count() int { + return len(f.ids) +} + +// pending_count returns count of pending pages +func (f *freelist) pending_count() int { + var count int + for _, list := range f.pending { + count += len(list) + } + return count +} + +// all returns a list of all free ids and all pending ids in one sorted list. +func (f *freelist) all() []pgid { + m := make(pgids, 0) + + for _, list := range f.pending { + m = append(m, list...) + } + + sort.Sort(m) + return pgids(f.ids).merge(m) +} + +// allocate returns the starting page id of a contiguous list of pages of a given size. +// If a contiguous block cannot be found then 0 is returned. +func (f *freelist) allocate(n int) pgid { + if len(f.ids) == 0 { + return 0 + } + + var initial, previd pgid + for i, id := range f.ids { + if id <= 1 { + panic(fmt.Sprintf("invalid page allocation: %d", id)) + } + + // Reset initial page if this is not contiguous. + if previd == 0 || id-previd != 1 { + initial = id + } + + // If we found a contiguous block then remove it and return it. + if (id-initial)+1 == pgid(n) { + // If we're allocating off the beginning then take the fast path + // and just adjust the existing slice. This will use extra memory + // temporarily but the append() in free() will realloc the slice + // as is necessary. + if (i + 1) == n { + f.ids = f.ids[i+1:] + } else { + copy(f.ids[i-n+1:], f.ids[i+1:]) + f.ids = f.ids[:len(f.ids)-n] + } + + // Remove from the free cache. + for i := pgid(0); i < pgid(n); i++ { + delete(f.cache, initial+i) + } + + return initial + } + + previd = id + } + return 0 +} + +// free releases a page and its overflow for a given transaction id. +// If the page is already free then a panic will occur. +func (f *freelist) free(txid txid, p *page) { + if p.id <= 1 { + panic(fmt.Sprintf("cannot free page 0 or 1: %d", p.id)) + } + + // Free page and all its overflow pages. + var ids = f.pending[txid] + for id := p.id; id <= p.id+pgid(p.overflow); id++ { + // Verify that page is not already free. + if f.cache[id] { + panic(fmt.Sprintf("page %d already freed", id)) + } + + // Add to the freelist and cache. + ids = append(ids, id) + f.cache[id] = true + } + f.pending[txid] = ids +} + +// release moves all page ids for a transaction id (or older) to the freelist. +func (f *freelist) release(txid txid) { + m := make(pgids, 0) + for tid, ids := range f.pending { + if tid <= txid { + // Move transaction's pending pages to the available freelist. + // Don't remove from the cache since the page is still free. + m = append(m, ids...) + delete(f.pending, tid) + } + } + sort.Sort(m) + f.ids = pgids(f.ids).merge(m) +} + +// rollback removes the pages from a given pending tx. +func (f *freelist) rollback(txid txid) { + // Remove page ids from cache. + for _, id := range f.pending[txid] { + delete(f.cache, id) + } + + // Remove pages from pending list. + delete(f.pending, txid) +} + +// freed returns whether a given page is in the free list. +func (f *freelist) freed(pgid pgid) bool { + return f.cache[pgid] +} + +// read initializes the freelist from a freelist page. +func (f *freelist) read(p *page) { + // If the page.count is at the max uint16 value (64k) then it's considered + // an overflow and the size of the freelist is stored as the first element. + idx, count := 0, int(p.count) + if count == 0xFFFF { + idx = 1 + count = int(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[0]) + } + + // Copy the list of page ids from the freelist. + if count == 0 { + f.ids = nil + } else { + ids := ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[idx:count] + f.ids = make([]pgid, len(ids)) + copy(f.ids, ids) + + // Make sure they're sorted. + sort.Sort(pgids(f.ids)) + } + + // Rebuild the page cache. + f.reindex() +} + +// write writes the page ids onto a freelist page. All free and pending ids are +// saved to disk since in the event of a program crash, all pending ids will +// become free. +func (f *freelist) write(p *page) error { + // Combine the old free pgids and pgids waiting on an open transaction. + ids := f.all() + + // Update the header flag. + p.flags |= freelistPageFlag + + // The page.count can only hold up to 64k elements so if we overflow that + // number then we handle it by putting the size in the first element. + if len(ids) == 0 { + p.count = uint16(len(ids)) + } else if len(ids) < 0xFFFF { + p.count = uint16(len(ids)) + copy(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[:], ids) + } else { + p.count = 0xFFFF + ((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[0] = pgid(len(ids)) + copy(((*[maxAllocSize]pgid)(unsafe.Pointer(&p.ptr)))[1:], ids) + } + + return nil +} + +// reload reads the freelist from a page and filters out pending items. +func (f *freelist) reload(p *page) { + f.read(p) + + // Build a cache of only pending pages. + pcache := make(map[pgid]bool) + for _, pendingIDs := range f.pending { + for _, pendingID := range pendingIDs { + pcache[pendingID] = true + } + } + + // Check each page in the freelist and build a new available freelist + // with any pages not in the pending lists. + var a []pgid + for _, id := range f.ids { + if !pcache[id] { + a = append(a, id) + } + } + f.ids = a + + // Once the available list is rebuilt then rebuild the free cache so that + // it includes the available and pending free pages. + f.reindex() +} + +// reindex rebuilds the free cache based on available and pending free lists. +func (f *freelist) reindex() { + f.cache = make(map[pgid]bool) + for _, id := range f.ids { + f.cache[id] = true + } + for _, pendingIDs := range f.pending { + for _, pendingID := range pendingIDs { + f.cache[pendingID] = true + } + } +} diff --git a/vendor/github.com/boltdb/bolt/freelist_test.go b/vendor/github.com/boltdb/bolt/freelist_test.go new file mode 100644 index 00000000..4e9b3a8d --- /dev/null +++ b/vendor/github.com/boltdb/bolt/freelist_test.go @@ -0,0 +1,158 @@ +package bolt + +import ( + "math/rand" + "reflect" + "sort" + "testing" + "unsafe" +) + +// Ensure that a page is added to a transaction's freelist. +func TestFreelist_free(t *testing.T) { + f := newFreelist() + f.free(100, &page{id: 12}) + if !reflect.DeepEqual([]pgid{12}, f.pending[100]) { + t.Fatalf("exp=%v; got=%v", []pgid{12}, f.pending[100]) + } +} + +// Ensure that a page and its overflow is added to a transaction's freelist. +func TestFreelist_free_overflow(t *testing.T) { + f := newFreelist() + f.free(100, &page{id: 12, overflow: 3}) + if exp := []pgid{12, 13, 14, 15}; !reflect.DeepEqual(exp, f.pending[100]) { + t.Fatalf("exp=%v; got=%v", exp, f.pending[100]) + } +} + +// Ensure that a transaction's free pages can be released. +func TestFreelist_release(t *testing.T) { + f := newFreelist() + f.free(100, &page{id: 12, overflow: 1}) + f.free(100, &page{id: 9}) + f.free(102, &page{id: 39}) + f.release(100) + f.release(101) + if exp := []pgid{9, 12, 13}; !reflect.DeepEqual(exp, f.ids) { + t.Fatalf("exp=%v; got=%v", exp, f.ids) + } + + f.release(102) + if exp := []pgid{9, 12, 13, 39}; !reflect.DeepEqual(exp, f.ids) { + t.Fatalf("exp=%v; got=%v", exp, f.ids) + } +} + +// Ensure that a freelist can find contiguous blocks of pages. +func TestFreelist_allocate(t *testing.T) { + f := &freelist{ids: []pgid{3, 4, 5, 6, 7, 9, 12, 13, 18}} + if id := int(f.allocate(3)); id != 3 { + t.Fatalf("exp=3; got=%v", id) + } + if id := int(f.allocate(1)); id != 6 { + t.Fatalf("exp=6; got=%v", id) + } + if id := int(f.allocate(3)); id != 0 { + t.Fatalf("exp=0; got=%v", id) + } + if id := int(f.allocate(2)); id != 12 { + t.Fatalf("exp=12; got=%v", id) + } + if id := int(f.allocate(1)); id != 7 { + t.Fatalf("exp=7; got=%v", id) + } + if id := int(f.allocate(0)); id != 0 { + t.Fatalf("exp=0; got=%v", id) + } + if id := int(f.allocate(0)); id != 0 { + t.Fatalf("exp=0; got=%v", id) + } + if exp := []pgid{9, 18}; !reflect.DeepEqual(exp, f.ids) { + t.Fatalf("exp=%v; got=%v", exp, f.ids) + } + + if id := int(f.allocate(1)); id != 9 { + t.Fatalf("exp=9; got=%v", id) + } + if id := int(f.allocate(1)); id != 18 { + t.Fatalf("exp=18; got=%v", id) + } + if id := int(f.allocate(1)); id != 0 { + t.Fatalf("exp=0; got=%v", id) + } + if exp := []pgid{}; !reflect.DeepEqual(exp, f.ids) { + t.Fatalf("exp=%v; got=%v", exp, f.ids) + } +} + +// Ensure that a freelist can deserialize from a freelist page. +func TestFreelist_read(t *testing.T) { + // Create a page. + var buf [4096]byte + page := (*page)(unsafe.Pointer(&buf[0])) + page.flags = freelistPageFlag + page.count = 2 + + // Insert 2 page ids. + ids := (*[3]pgid)(unsafe.Pointer(&page.ptr)) + ids[0] = 23 + ids[1] = 50 + + // Deserialize page into a freelist. + f := newFreelist() + f.read(page) + + // Ensure that there are two page ids in the freelist. + if exp := []pgid{23, 50}; !reflect.DeepEqual(exp, f.ids) { + t.Fatalf("exp=%v; got=%v", exp, f.ids) + } +} + +// Ensure that a freelist can serialize into a freelist page. +func TestFreelist_write(t *testing.T) { + // Create a freelist and write it to a page. + var buf [4096]byte + f := &freelist{ids: []pgid{12, 39}, pending: make(map[txid][]pgid)} + f.pending[100] = []pgid{28, 11} + f.pending[101] = []pgid{3} + p := (*page)(unsafe.Pointer(&buf[0])) + if err := f.write(p); err != nil { + t.Fatal(err) + } + + // Read the page back out. + f2 := newFreelist() + f2.read(p) + + // Ensure that the freelist is correct. + // All pages should be present and in reverse order. + if exp := []pgid{3, 11, 12, 28, 39}; !reflect.DeepEqual(exp, f2.ids) { + t.Fatalf("exp=%v; got=%v", exp, f2.ids) + } +} + +func Benchmark_FreelistRelease10K(b *testing.B) { benchmark_FreelistRelease(b, 10000) } +func Benchmark_FreelistRelease100K(b *testing.B) { benchmark_FreelistRelease(b, 100000) } +func Benchmark_FreelistRelease1000K(b *testing.B) { benchmark_FreelistRelease(b, 1000000) } +func Benchmark_FreelistRelease10000K(b *testing.B) { benchmark_FreelistRelease(b, 10000000) } + +func benchmark_FreelistRelease(b *testing.B, size int) { + ids := randomPgids(size) + pending := randomPgids(len(ids) / 400) + b.ResetTimer() + for i := 0; i < b.N; i++ { + f := &freelist{ids: ids, pending: map[txid][]pgid{1: pending}} + f.release(1) + } +} + +func randomPgids(n int) []pgid { + rand.Seed(42) + pgids := make(pgids, n) + for i := range pgids { + pgids[i] = pgid(rand.Int63()) + } + sort.Sort(pgids) + return pgids +} diff --git a/vendor/github.com/boltdb/bolt/node.go b/vendor/github.com/boltdb/bolt/node.go new file mode 100644 index 00000000..159318b2 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/node.go @@ -0,0 +1,604 @@ +package bolt + +import ( + "bytes" + "fmt" + "sort" + "unsafe" +) + +// node represents an in-memory, deserialized page. +type node struct { + bucket *Bucket + isLeaf bool + unbalanced bool + spilled bool + key []byte + pgid pgid + parent *node + children nodes + inodes inodes +} + +// root returns the top-level node this node is attached to. +func (n *node) root() *node { + if n.parent == nil { + return n + } + return n.parent.root() +} + +// minKeys returns the minimum number of inodes this node should have. +func (n *node) minKeys() int { + if n.isLeaf { + return 1 + } + return 2 +} + +// size returns the size of the node after serialization. +func (n *node) size() int { + sz, elsz := pageHeaderSize, n.pageElementSize() + for i := 0; i < len(n.inodes); i++ { + item := &n.inodes[i] + sz += elsz + len(item.key) + len(item.value) + } + return sz +} + +// sizeLessThan returns true if the node is less than a given size. +// This is an optimization to avoid calculating a large node when we only need +// to know if it fits inside a certain page size. +func (n *node) sizeLessThan(v int) bool { + sz, elsz := pageHeaderSize, n.pageElementSize() + for i := 0; i < len(n.inodes); i++ { + item := &n.inodes[i] + sz += elsz + len(item.key) + len(item.value) + if sz >= v { + return false + } + } + return true +} + +// pageElementSize returns the size of each page element based on the type of node. +func (n *node) pageElementSize() int { + if n.isLeaf { + return leafPageElementSize + } + return branchPageElementSize +} + +// childAt returns the child node at a given index. +func (n *node) childAt(index int) *node { + if n.isLeaf { + panic(fmt.Sprintf("invalid childAt(%d) on a leaf node", index)) + } + return n.bucket.node(n.inodes[index].pgid, n) +} + +// childIndex returns the index of a given child node. +func (n *node) childIndex(child *node) int { + index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, child.key) != -1 }) + return index +} + +// numChildren returns the number of children. +func (n *node) numChildren() int { + return len(n.inodes) +} + +// nextSibling returns the next node with the same parent. +func (n *node) nextSibling() *node { + if n.parent == nil { + return nil + } + index := n.parent.childIndex(n) + if index >= n.parent.numChildren()-1 { + return nil + } + return n.parent.childAt(index + 1) +} + +// prevSibling returns the previous node with the same parent. +func (n *node) prevSibling() *node { + if n.parent == nil { + return nil + } + index := n.parent.childIndex(n) + if index == 0 { + return nil + } + return n.parent.childAt(index - 1) +} + +// put inserts a key/value. +func (n *node) put(oldKey, newKey, value []byte, pgid pgid, flags uint32) { + if pgid >= n.bucket.tx.meta.pgid { + panic(fmt.Sprintf("pgid (%d) above high water mark (%d)", pgid, n.bucket.tx.meta.pgid)) + } else if len(oldKey) <= 0 { + panic("put: zero-length old key") + } else if len(newKey) <= 0 { + panic("put: zero-length new key") + } + + // Find insertion index. + index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, oldKey) != -1 }) + + // Add capacity and shift nodes if we don't have an exact match and need to insert. + exact := (len(n.inodes) > 0 && index < len(n.inodes) && bytes.Equal(n.inodes[index].key, oldKey)) + if !exact { + n.inodes = append(n.inodes, inode{}) + copy(n.inodes[index+1:], n.inodes[index:]) + } + + inode := &n.inodes[index] + inode.flags = flags + inode.key = newKey + inode.value = value + inode.pgid = pgid + _assert(len(inode.key) > 0, "put: zero-length inode key") +} + +// del removes a key from the node. +func (n *node) del(key []byte) { + // Find index of key. + index := sort.Search(len(n.inodes), func(i int) bool { return bytes.Compare(n.inodes[i].key, key) != -1 }) + + // Exit if the key isn't found. + if index >= len(n.inodes) || !bytes.Equal(n.inodes[index].key, key) { + return + } + + // Delete inode from the node. + n.inodes = append(n.inodes[:index], n.inodes[index+1:]...) + + // Mark the node as needing rebalancing. + n.unbalanced = true +} + +// read initializes the node from a page. +func (n *node) read(p *page) { + n.pgid = p.id + n.isLeaf = ((p.flags & leafPageFlag) != 0) + n.inodes = make(inodes, int(p.count)) + + for i := 0; i < int(p.count); i++ { + inode := &n.inodes[i] + if n.isLeaf { + elem := p.leafPageElement(uint16(i)) + inode.flags = elem.flags + inode.key = elem.key() + inode.value = elem.value() + } else { + elem := p.branchPageElement(uint16(i)) + inode.pgid = elem.pgid + inode.key = elem.key() + } + _assert(len(inode.key) > 0, "read: zero-length inode key") + } + + // Save first key so we can find the node in the parent when we spill. + if len(n.inodes) > 0 { + n.key = n.inodes[0].key + _assert(len(n.key) > 0, "read: zero-length node key") + } else { + n.key = nil + } +} + +// write writes the items onto one or more pages. +func (n *node) write(p *page) { + // Initialize page. + if n.isLeaf { + p.flags |= leafPageFlag + } else { + p.flags |= branchPageFlag + } + + if len(n.inodes) >= 0xFFFF { + panic(fmt.Sprintf("inode overflow: %d (pgid=%d)", len(n.inodes), p.id)) + } + p.count = uint16(len(n.inodes)) + + // Stop here if there are no items to write. + if p.count == 0 { + return + } + + // Loop over each item and write it to the page. + b := (*[maxAllocSize]byte)(unsafe.Pointer(&p.ptr))[n.pageElementSize()*len(n.inodes):] + for i, item := range n.inodes { + _assert(len(item.key) > 0, "write: zero-length inode key") + + // Write the page element. + if n.isLeaf { + elem := p.leafPageElement(uint16(i)) + elem.pos = uint32(uintptr(unsafe.Pointer(&b[0])) - uintptr(unsafe.Pointer(elem))) + elem.flags = item.flags + elem.ksize = uint32(len(item.key)) + elem.vsize = uint32(len(item.value)) + } else { + elem := p.branchPageElement(uint16(i)) + elem.pos = uint32(uintptr(unsafe.Pointer(&b[0])) - uintptr(unsafe.Pointer(elem))) + elem.ksize = uint32(len(item.key)) + elem.pgid = item.pgid + _assert(elem.pgid != p.id, "write: circular dependency occurred") + } + + // If the length of key+value is larger than the max allocation size + // then we need to reallocate the byte array pointer. + // + // See: https://github.com/boltdb/bolt/pull/335 + klen, vlen := len(item.key), len(item.value) + if len(b) < klen+vlen { + b = (*[maxAllocSize]byte)(unsafe.Pointer(&b[0]))[:] + } + + // Write data for the element to the end of the page. + copy(b[0:], item.key) + b = b[klen:] + copy(b[0:], item.value) + b = b[vlen:] + } + + // DEBUG ONLY: n.dump() +} + +// split breaks up a node into multiple smaller nodes, if appropriate. +// This should only be called from the spill() function. +func (n *node) split(pageSize int) []*node { + var nodes []*node + + node := n + for { + // Split node into two. + a, b := node.splitTwo(pageSize) + nodes = append(nodes, a) + + // If we can't split then exit the loop. + if b == nil { + break + } + + // Set node to b so it gets split on the next iteration. + node = b + } + + return nodes +} + +// splitTwo breaks up a node into two smaller nodes, if appropriate. +// This should only be called from the split() function. +func (n *node) splitTwo(pageSize int) (*node, *node) { + // Ignore the split if the page doesn't have at least enough nodes for + // two pages or if the nodes can fit in a single page. + if len(n.inodes) <= (minKeysPerPage*2) || n.sizeLessThan(pageSize) { + return n, nil + } + + // Determine the threshold before starting a new node. + var fillPercent = n.bucket.FillPercent + if fillPercent < minFillPercent { + fillPercent = minFillPercent + } else if fillPercent > maxFillPercent { + fillPercent = maxFillPercent + } + threshold := int(float64(pageSize) * fillPercent) + + // Determine split position and sizes of the two pages. + splitIndex, _ := n.splitIndex(threshold) + + // Split node into two separate nodes. + // If there's no parent then we'll need to create one. + if n.parent == nil { + n.parent = &node{bucket: n.bucket, children: []*node{n}} + } + + // Create a new node and add it to the parent. + next := &node{bucket: n.bucket, isLeaf: n.isLeaf, parent: n.parent} + n.parent.children = append(n.parent.children, next) + + // Split inodes across two nodes. + next.inodes = n.inodes[splitIndex:] + n.inodes = n.inodes[:splitIndex] + + // Update the statistics. + n.bucket.tx.stats.Split++ + + return n, next +} + +// splitIndex finds the position where a page will fill a given threshold. +// It returns the index as well as the size of the first page. +// This is only be called from split(). +func (n *node) splitIndex(threshold int) (index, sz int) { + sz = pageHeaderSize + + // Loop until we only have the minimum number of keys required for the second page. + for i := 0; i < len(n.inodes)-minKeysPerPage; i++ { + index = i + inode := n.inodes[i] + elsize := n.pageElementSize() + len(inode.key) + len(inode.value) + + // If we have at least the minimum number of keys and adding another + // node would put us over the threshold then exit and return. + if i >= minKeysPerPage && sz+elsize > threshold { + break + } + + // Add the element size to the total size. + sz += elsize + } + + return +} + +// spill writes the nodes to dirty pages and splits nodes as it goes. +// Returns an error if dirty pages cannot be allocated. +func (n *node) spill() error { + var tx = n.bucket.tx + if n.spilled { + return nil + } + + // Spill child nodes first. Child nodes can materialize sibling nodes in + // the case of split-merge so we cannot use a range loop. We have to check + // the children size on every loop iteration. + sort.Sort(n.children) + for i := 0; i < len(n.children); i++ { + if err := n.children[i].spill(); err != nil { + return err + } + } + + // We no longer need the child list because it's only used for spill tracking. + n.children = nil + + // Split nodes into appropriate sizes. The first node will always be n. + var nodes = n.split(tx.db.pageSize) + for _, node := range nodes { + // Add node's page to the freelist if it's not new. + if node.pgid > 0 { + tx.db.freelist.free(tx.meta.txid, tx.page(node.pgid)) + node.pgid = 0 + } + + // Allocate contiguous space for the node. + p, err := tx.allocate((node.size() / tx.db.pageSize) + 1) + if err != nil { + return err + } + + // Write the node. + if p.id >= tx.meta.pgid { + panic(fmt.Sprintf("pgid (%d) above high water mark (%d)", p.id, tx.meta.pgid)) + } + node.pgid = p.id + node.write(p) + node.spilled = true + + // Insert into parent inodes. + if node.parent != nil { + var key = node.key + if key == nil { + key = node.inodes[0].key + } + + node.parent.put(key, node.inodes[0].key, nil, node.pgid, 0) + node.key = node.inodes[0].key + _assert(len(node.key) > 0, "spill: zero-length node key") + } + + // Update the statistics. + tx.stats.Spill++ + } + + // If the root node split and created a new root then we need to spill that + // as well. We'll clear out the children to make sure it doesn't try to respill. + if n.parent != nil && n.parent.pgid == 0 { + n.children = nil + return n.parent.spill() + } + + return nil +} + +// rebalance attempts to combine the node with sibling nodes if the node fill +// size is below a threshold or if there are not enough keys. +func (n *node) rebalance() { + if !n.unbalanced { + return + } + n.unbalanced = false + + // Update statistics. + n.bucket.tx.stats.Rebalance++ + + // Ignore if node is above threshold (25%) and has enough keys. + var threshold = n.bucket.tx.db.pageSize / 4 + if n.size() > threshold && len(n.inodes) > n.minKeys() { + return + } + + // Root node has special handling. + if n.parent == nil { + // If root node is a branch and only has one node then collapse it. + if !n.isLeaf && len(n.inodes) == 1 { + // Move root's child up. + child := n.bucket.node(n.inodes[0].pgid, n) + n.isLeaf = child.isLeaf + n.inodes = child.inodes[:] + n.children = child.children + + // Reparent all child nodes being moved. + for _, inode := range n.inodes { + if child, ok := n.bucket.nodes[inode.pgid]; ok { + child.parent = n + } + } + + // Remove old child. + child.parent = nil + delete(n.bucket.nodes, child.pgid) + child.free() + } + + return + } + + // If node has no keys then just remove it. + if n.numChildren() == 0 { + n.parent.del(n.key) + n.parent.removeChild(n) + delete(n.bucket.nodes, n.pgid) + n.free() + n.parent.rebalance() + return + } + + _assert(n.parent.numChildren() > 1, "parent must have at least 2 children") + + // Destination node is right sibling if idx == 0, otherwise left sibling. + var target *node + var useNextSibling = (n.parent.childIndex(n) == 0) + if useNextSibling { + target = n.nextSibling() + } else { + target = n.prevSibling() + } + + // If both this node and the target node are too small then merge them. + if useNextSibling { + // Reparent all child nodes being moved. + for _, inode := range target.inodes { + if child, ok := n.bucket.nodes[inode.pgid]; ok { + child.parent.removeChild(child) + child.parent = n + child.parent.children = append(child.parent.children, child) + } + } + + // Copy over inodes from target and remove target. + n.inodes = append(n.inodes, target.inodes...) + n.parent.del(target.key) + n.parent.removeChild(target) + delete(n.bucket.nodes, target.pgid) + target.free() + } else { + // Reparent all child nodes being moved. + for _, inode := range n.inodes { + if child, ok := n.bucket.nodes[inode.pgid]; ok { + child.parent.removeChild(child) + child.parent = target + child.parent.children = append(child.parent.children, child) + } + } + + // Copy over inodes to target and remove node. + target.inodes = append(target.inodes, n.inodes...) + n.parent.del(n.key) + n.parent.removeChild(n) + delete(n.bucket.nodes, n.pgid) + n.free() + } + + // Either this node or the target node was deleted from the parent so rebalance it. + n.parent.rebalance() +} + +// removes a node from the list of in-memory children. +// This does not affect the inodes. +func (n *node) removeChild(target *node) { + for i, child := range n.children { + if child == target { + n.children = append(n.children[:i], n.children[i+1:]...) + return + } + } +} + +// dereference causes the node to copy all its inode key/value references to heap memory. +// This is required when the mmap is reallocated so inodes are not pointing to stale data. +func (n *node) dereference() { + if n.key != nil { + key := make([]byte, len(n.key)) + copy(key, n.key) + n.key = key + _assert(n.pgid == 0 || len(n.key) > 0, "dereference: zero-length node key on existing node") + } + + for i := range n.inodes { + inode := &n.inodes[i] + + key := make([]byte, len(inode.key)) + copy(key, inode.key) + inode.key = key + _assert(len(inode.key) > 0, "dereference: zero-length inode key") + + value := make([]byte, len(inode.value)) + copy(value, inode.value) + inode.value = value + } + + // Recursively dereference children. + for _, child := range n.children { + child.dereference() + } + + // Update statistics. + n.bucket.tx.stats.NodeDeref++ +} + +// free adds the node's underlying page to the freelist. +func (n *node) free() { + if n.pgid != 0 { + n.bucket.tx.db.freelist.free(n.bucket.tx.meta.txid, n.bucket.tx.page(n.pgid)) + n.pgid = 0 + } +} + +// dump writes the contents of the node to STDERR for debugging purposes. +/* +func (n *node) dump() { + // Write node header. + var typ = "branch" + if n.isLeaf { + typ = "leaf" + } + warnf("[NODE %d {type=%s count=%d}]", n.pgid, typ, len(n.inodes)) + + // Write out abbreviated version of each item. + for _, item := range n.inodes { + if n.isLeaf { + if item.flags&bucketLeafFlag != 0 { + bucket := (*bucket)(unsafe.Pointer(&item.value[0])) + warnf("+L %08x -> (bucket root=%d)", trunc(item.key, 4), bucket.root) + } else { + warnf("+L %08x -> %08x", trunc(item.key, 4), trunc(item.value, 4)) + } + } else { + warnf("+B %08x -> pgid=%d", trunc(item.key, 4), item.pgid) + } + } + warn("") +} +*/ + +type nodes []*node + +func (s nodes) Len() int { return len(s) } +func (s nodes) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s nodes) Less(i, j int) bool { return bytes.Compare(s[i].inodes[0].key, s[j].inodes[0].key) == -1 } + +// inode represents an internal node inside of a node. +// It can be used to point to elements in a page or point +// to an element which hasn't been added to a page yet. +type inode struct { + flags uint32 + pgid pgid + key []byte + value []byte +} + +type inodes []inode diff --git a/vendor/github.com/boltdb/bolt/node_test.go b/vendor/github.com/boltdb/bolt/node_test.go new file mode 100644 index 00000000..fa5d10f9 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/node_test.go @@ -0,0 +1,156 @@ +package bolt + +import ( + "testing" + "unsafe" +) + +// Ensure that a node can insert a key/value. +func TestNode_put(t *testing.T) { + n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{meta: &meta{pgid: 1}}}} + n.put([]byte("baz"), []byte("baz"), []byte("2"), 0, 0) + n.put([]byte("foo"), []byte("foo"), []byte("0"), 0, 0) + n.put([]byte("bar"), []byte("bar"), []byte("1"), 0, 0) + n.put([]byte("foo"), []byte("foo"), []byte("3"), 0, leafPageFlag) + + if len(n.inodes) != 3 { + t.Fatalf("exp=3; got=%d", len(n.inodes)) + } + if k, v := n.inodes[0].key, n.inodes[0].value; string(k) != "bar" || string(v) != "1" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } + if k, v := n.inodes[1].key, n.inodes[1].value; string(k) != "baz" || string(v) != "2" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } + if k, v := n.inodes[2].key, n.inodes[2].value; string(k) != "foo" || string(v) != "3" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } + if n.inodes[2].flags != uint32(leafPageFlag) { + t.Fatalf("not a leaf: %d", n.inodes[2].flags) + } +} + +// Ensure that a node can deserialize from a leaf page. +func TestNode_read_LeafPage(t *testing.T) { + // Create a page. + var buf [4096]byte + page := (*page)(unsafe.Pointer(&buf[0])) + page.flags = leafPageFlag + page.count = 2 + + // Insert 2 elements at the beginning. sizeof(leafPageElement) == 16 + nodes := (*[3]leafPageElement)(unsafe.Pointer(&page.ptr)) + nodes[0] = leafPageElement{flags: 0, pos: 32, ksize: 3, vsize: 4} // pos = sizeof(leafPageElement) * 2 + nodes[1] = leafPageElement{flags: 0, pos: 23, ksize: 10, vsize: 3} // pos = sizeof(leafPageElement) + 3 + 4 + + // Write data for the nodes at the end. + data := (*[4096]byte)(unsafe.Pointer(&nodes[2])) + copy(data[:], []byte("barfooz")) + copy(data[7:], []byte("helloworldbye")) + + // Deserialize page into a leaf. + n := &node{} + n.read(page) + + // Check that there are two inodes with correct data. + if !n.isLeaf { + t.Fatal("expected leaf") + } + if len(n.inodes) != 2 { + t.Fatalf("exp=2; got=%d", len(n.inodes)) + } + if k, v := n.inodes[0].key, n.inodes[0].value; string(k) != "bar" || string(v) != "fooz" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } + if k, v := n.inodes[1].key, n.inodes[1].value; string(k) != "helloworld" || string(v) != "bye" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } +} + +// Ensure that a node can serialize into a leaf page. +func TestNode_write_LeafPage(t *testing.T) { + // Create a node. + n := &node{isLeaf: true, inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}} + n.put([]byte("susy"), []byte("susy"), []byte("que"), 0, 0) + n.put([]byte("ricki"), []byte("ricki"), []byte("lake"), 0, 0) + n.put([]byte("john"), []byte("john"), []byte("johnson"), 0, 0) + + // Write it to a page. + var buf [4096]byte + p := (*page)(unsafe.Pointer(&buf[0])) + n.write(p) + + // Read the page back in. + n2 := &node{} + n2.read(p) + + // Check that the two pages are the same. + if len(n2.inodes) != 3 { + t.Fatalf("exp=3; got=%d", len(n2.inodes)) + } + if k, v := n2.inodes[0].key, n2.inodes[0].value; string(k) != "john" || string(v) != "johnson" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } + if k, v := n2.inodes[1].key, n2.inodes[1].value; string(k) != "ricki" || string(v) != "lake" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } + if k, v := n2.inodes[2].key, n2.inodes[2].value; string(k) != "susy" || string(v) != "que" { + t.Fatalf("exp=; got=<%s,%s>", k, v) + } +} + +// Ensure that a node can split into appropriate subgroups. +func TestNode_split(t *testing.T) { + // Create a node. + n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}} + n.put([]byte("00000001"), []byte("00000001"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000002"), []byte("00000002"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000003"), []byte("00000003"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000004"), []byte("00000004"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000005"), []byte("00000005"), []byte("0123456701234567"), 0, 0) + + // Split between 2 & 3. + n.split(100) + + var parent = n.parent + if len(parent.children) != 2 { + t.Fatalf("exp=2; got=%d", len(parent.children)) + } + if len(parent.children[0].inodes) != 2 { + t.Fatalf("exp=2; got=%d", len(parent.children[0].inodes)) + } + if len(parent.children[1].inodes) != 3 { + t.Fatalf("exp=3; got=%d", len(parent.children[1].inodes)) + } +} + +// Ensure that a page with the minimum number of inodes just returns a single node. +func TestNode_split_MinKeys(t *testing.T) { + // Create a node. + n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}} + n.put([]byte("00000001"), []byte("00000001"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000002"), []byte("00000002"), []byte("0123456701234567"), 0, 0) + + // Split. + n.split(20) + if n.parent != nil { + t.Fatalf("expected nil parent") + } +} + +// Ensure that a node that has keys that all fit on a page just returns one leaf. +func TestNode_split_SinglePage(t *testing.T) { + // Create a node. + n := &node{inodes: make(inodes, 0), bucket: &Bucket{tx: &Tx{db: &DB{}, meta: &meta{pgid: 1}}}} + n.put([]byte("00000001"), []byte("00000001"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000002"), []byte("00000002"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000003"), []byte("00000003"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000004"), []byte("00000004"), []byte("0123456701234567"), 0, 0) + n.put([]byte("00000005"), []byte("00000005"), []byte("0123456701234567"), 0, 0) + + // Split. + n.split(4096) + if n.parent != nil { + t.Fatalf("expected nil parent") + } +} diff --git a/vendor/github.com/boltdb/bolt/page.go b/vendor/github.com/boltdb/bolt/page.go new file mode 100644 index 00000000..7651a6bf --- /dev/null +++ b/vendor/github.com/boltdb/bolt/page.go @@ -0,0 +1,178 @@ +package bolt + +import ( + "fmt" + "os" + "sort" + "unsafe" +) + +const pageHeaderSize = int(unsafe.Offsetof(((*page)(nil)).ptr)) + +const minKeysPerPage = 2 + +const branchPageElementSize = int(unsafe.Sizeof(branchPageElement{})) +const leafPageElementSize = int(unsafe.Sizeof(leafPageElement{})) + +const ( + branchPageFlag = 0x01 + leafPageFlag = 0x02 + metaPageFlag = 0x04 + freelistPageFlag = 0x10 +) + +const ( + bucketLeafFlag = 0x01 +) + +type pgid uint64 + +type page struct { + id pgid + flags uint16 + count uint16 + overflow uint32 + ptr uintptr +} + +// typ returns a human readable page type string used for debugging. +func (p *page) typ() string { + if (p.flags & branchPageFlag) != 0 { + return "branch" + } else if (p.flags & leafPageFlag) != 0 { + return "leaf" + } else if (p.flags & metaPageFlag) != 0 { + return "meta" + } else if (p.flags & freelistPageFlag) != 0 { + return "freelist" + } + return fmt.Sprintf("unknown<%02x>", p.flags) +} + +// meta returns a pointer to the metadata section of the page. +func (p *page) meta() *meta { + return (*meta)(unsafe.Pointer(&p.ptr)) +} + +// leafPageElement retrieves the leaf node by index +func (p *page) leafPageElement(index uint16) *leafPageElement { + n := &((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[index] + return n +} + +// leafPageElements retrieves a list of leaf nodes. +func (p *page) leafPageElements() []leafPageElement { + if p.count == 0 { + return nil + } + return ((*[0x7FFFFFF]leafPageElement)(unsafe.Pointer(&p.ptr)))[:] +} + +// branchPageElement retrieves the branch node by index +func (p *page) branchPageElement(index uint16) *branchPageElement { + return &((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[index] +} + +// branchPageElements retrieves a list of branch nodes. +func (p *page) branchPageElements() []branchPageElement { + if p.count == 0 { + return nil + } + return ((*[0x7FFFFFF]branchPageElement)(unsafe.Pointer(&p.ptr)))[:] +} + +// dump writes n bytes of the page to STDERR as hex output. +func (p *page) hexdump(n int) { + buf := (*[maxAllocSize]byte)(unsafe.Pointer(p))[:n] + fmt.Fprintf(os.Stderr, "%x\n", buf) +} + +type pages []*page + +func (s pages) Len() int { return len(s) } +func (s pages) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s pages) Less(i, j int) bool { return s[i].id < s[j].id } + +// branchPageElement represents a node on a branch page. +type branchPageElement struct { + pos uint32 + ksize uint32 + pgid pgid +} + +// key returns a byte slice of the node key. +func (n *branchPageElement) key() []byte { + buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) + return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos]))[:n.ksize] +} + +// leafPageElement represents a node on a leaf page. +type leafPageElement struct { + flags uint32 + pos uint32 + ksize uint32 + vsize uint32 +} + +// key returns a byte slice of the node key. +func (n *leafPageElement) key() []byte { + buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) + return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos]))[:n.ksize:n.ksize] +} + +// value returns a byte slice of the node value. +func (n *leafPageElement) value() []byte { + buf := (*[maxAllocSize]byte)(unsafe.Pointer(n)) + return (*[maxAllocSize]byte)(unsafe.Pointer(&buf[n.pos+n.ksize]))[:n.vsize:n.vsize] +} + +// PageInfo represents human readable information about a page. +type PageInfo struct { + ID int + Type string + Count int + OverflowCount int +} + +type pgids []pgid + +func (s pgids) Len() int { return len(s) } +func (s pgids) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +func (s pgids) Less(i, j int) bool { return s[i] < s[j] } + +// merge returns the sorted union of a and b. +func (a pgids) merge(b pgids) pgids { + // Return the opposite slice if one is nil. + if len(a) == 0 { + return b + } else if len(b) == 0 { + return a + } + + // Create a list to hold all elements from both lists. + merged := make(pgids, 0, len(a)+len(b)) + + // Assign lead to the slice with a lower starting value, follow to the higher value. + lead, follow := a, b + if b[0] < a[0] { + lead, follow = b, a + } + + // Continue while there are elements in the lead. + for len(lead) > 0 { + // Merge largest prefix of lead that is ahead of follow[0]. + n := sort.Search(len(lead), func(i int) bool { return lead[i] > follow[0] }) + merged = append(merged, lead[:n]...) + if n >= len(lead) { + break + } + + // Swap lead and follow. + lead, follow = follow, lead[n:] + } + + // Append what's left in follow. + merged = append(merged, follow...) + + return merged +} diff --git a/vendor/github.com/boltdb/bolt/page_test.go b/vendor/github.com/boltdb/bolt/page_test.go new file mode 100644 index 00000000..59f4a30e --- /dev/null +++ b/vendor/github.com/boltdb/bolt/page_test.go @@ -0,0 +1,72 @@ +package bolt + +import ( + "reflect" + "sort" + "testing" + "testing/quick" +) + +// Ensure that the page type can be returned in human readable format. +func TestPage_typ(t *testing.T) { + if typ := (&page{flags: branchPageFlag}).typ(); typ != "branch" { + t.Fatalf("exp=branch; got=%v", typ) + } + if typ := (&page{flags: leafPageFlag}).typ(); typ != "leaf" { + t.Fatalf("exp=leaf; got=%v", typ) + } + if typ := (&page{flags: metaPageFlag}).typ(); typ != "meta" { + t.Fatalf("exp=meta; got=%v", typ) + } + if typ := (&page{flags: freelistPageFlag}).typ(); typ != "freelist" { + t.Fatalf("exp=freelist; got=%v", typ) + } + if typ := (&page{flags: 20000}).typ(); typ != "unknown<4e20>" { + t.Fatalf("exp=unknown<4e20>; got=%v", typ) + } +} + +// Ensure that the hexdump debugging function doesn't blow up. +func TestPage_dump(t *testing.T) { + (&page{id: 256}).hexdump(16) +} + +func TestPgids_merge(t *testing.T) { + a := pgids{4, 5, 6, 10, 11, 12, 13, 27} + b := pgids{1, 3, 8, 9, 25, 30} + c := a.merge(b) + if !reflect.DeepEqual(c, pgids{1, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 25, 27, 30}) { + t.Errorf("mismatch: %v", c) + } + + a = pgids{4, 5, 6, 10, 11, 12, 13, 27, 35, 36} + b = pgids{8, 9, 25, 30} + c = a.merge(b) + if !reflect.DeepEqual(c, pgids{4, 5, 6, 8, 9, 10, 11, 12, 13, 25, 27, 30, 35, 36}) { + t.Errorf("mismatch: %v", c) + } +} + +func TestPgids_merge_quick(t *testing.T) { + if err := quick.Check(func(a, b pgids) bool { + // Sort incoming lists. + sort.Sort(a) + sort.Sort(b) + + // Merge the two lists together. + got := a.merge(b) + + // The expected value should be the two lists combined and sorted. + exp := append(a, b...) + sort.Sort(exp) + + if !reflect.DeepEqual(exp, got) { + t.Errorf("\nexp=%+v\ngot=%+v\n", exp, got) + return false + } + + return true + }, nil); err != nil { + t.Fatal(err) + } +} diff --git a/vendor/github.com/boltdb/bolt/quick_test.go b/vendor/github.com/boltdb/bolt/quick_test.go new file mode 100644 index 00000000..4da58177 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/quick_test.go @@ -0,0 +1,79 @@ +package bolt_test + +import ( + "bytes" + "flag" + "fmt" + "math/rand" + "os" + "reflect" + "testing/quick" + "time" +) + +// testing/quick defaults to 5 iterations and a random seed. +// You can override these settings from the command line: +// +// -quick.count The number of iterations to perform. +// -quick.seed The seed to use for randomizing. +// -quick.maxitems The maximum number of items to insert into a DB. +// -quick.maxksize The maximum size of a key. +// -quick.maxvsize The maximum size of a value. +// + +var qcount, qseed, qmaxitems, qmaxksize, qmaxvsize int + +func init() { + flag.IntVar(&qcount, "quick.count", 5, "") + flag.IntVar(&qseed, "quick.seed", int(time.Now().UnixNano())%100000, "") + flag.IntVar(&qmaxitems, "quick.maxitems", 1000, "") + flag.IntVar(&qmaxksize, "quick.maxksize", 1024, "") + flag.IntVar(&qmaxvsize, "quick.maxvsize", 1024, "") + flag.Parse() + fmt.Fprintln(os.Stderr, "seed:", qseed) + fmt.Fprintf(os.Stderr, "quick settings: count=%v, items=%v, ksize=%v, vsize=%v\n", qcount, qmaxitems, qmaxksize, qmaxvsize) +} + +func qconfig() *quick.Config { + return &quick.Config{ + MaxCount: qcount, + Rand: rand.New(rand.NewSource(int64(qseed))), + } +} + +type testdata []testdataitem + +func (t testdata) Len() int { return len(t) } +func (t testdata) Swap(i, j int) { t[i], t[j] = t[j], t[i] } +func (t testdata) Less(i, j int) bool { return bytes.Compare(t[i].Key, t[j].Key) == -1 } + +func (t testdata) Generate(rand *rand.Rand, size int) reflect.Value { + n := rand.Intn(qmaxitems-1) + 1 + items := make(testdata, n) + for i := 0; i < n; i++ { + item := &items[i] + item.Key = randByteSlice(rand, 1, qmaxksize) + item.Value = randByteSlice(rand, 0, qmaxvsize) + } + return reflect.ValueOf(items) +} + +type revtestdata []testdataitem + +func (t revtestdata) Len() int { return len(t) } +func (t revtestdata) Swap(i, j int) { t[i], t[j] = t[j], t[i] } +func (t revtestdata) Less(i, j int) bool { return bytes.Compare(t[i].Key, t[j].Key) == 1 } + +type testdataitem struct { + Key []byte + Value []byte +} + +func randByteSlice(rand *rand.Rand, minSize, maxSize int) []byte { + n := rand.Intn(maxSize-minSize) + minSize + b := make([]byte, n) + for i := 0; i < n; i++ { + b[i] = byte(rand.Intn(255)) + } + return b +} diff --git a/vendor/github.com/boltdb/bolt/simulation_test.go b/vendor/github.com/boltdb/bolt/simulation_test.go new file mode 100644 index 00000000..38310165 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/simulation_test.go @@ -0,0 +1,329 @@ +package bolt_test + +import ( + "bytes" + "fmt" + "math/rand" + "sync" + "testing" + + "github.com/boltdb/bolt" +) + +func TestSimulate_1op_1p(t *testing.T) { testSimulate(t, 1, 1) } +func TestSimulate_10op_1p(t *testing.T) { testSimulate(t, 10, 1) } +func TestSimulate_100op_1p(t *testing.T) { testSimulate(t, 100, 1) } +func TestSimulate_1000op_1p(t *testing.T) { testSimulate(t, 1000, 1) } +func TestSimulate_10000op_1p(t *testing.T) { testSimulate(t, 10000, 1) } + +func TestSimulate_10op_10p(t *testing.T) { testSimulate(t, 10, 10) } +func TestSimulate_100op_10p(t *testing.T) { testSimulate(t, 100, 10) } +func TestSimulate_1000op_10p(t *testing.T) { testSimulate(t, 1000, 10) } +func TestSimulate_10000op_10p(t *testing.T) { testSimulate(t, 10000, 10) } + +func TestSimulate_100op_100p(t *testing.T) { testSimulate(t, 100, 100) } +func TestSimulate_1000op_100p(t *testing.T) { testSimulate(t, 1000, 100) } +func TestSimulate_10000op_100p(t *testing.T) { testSimulate(t, 10000, 100) } + +func TestSimulate_10000op_1000p(t *testing.T) { testSimulate(t, 10000, 1000) } + +// Randomly generate operations on a given database with multiple clients to ensure consistency and thread safety. +func testSimulate(t *testing.T, threadCount, parallelism int) { + if testing.Short() { + t.Skip("skipping test in short mode.") + } + + rand.Seed(int64(qseed)) + + // A list of operations that readers and writers can perform. + var readerHandlers = []simulateHandler{simulateGetHandler} + var writerHandlers = []simulateHandler{simulateGetHandler, simulatePutHandler} + + var versions = make(map[int]*QuickDB) + versions[1] = NewQuickDB() + + db := MustOpenDB() + defer db.MustClose() + + var mutex sync.Mutex + + // Run n threads in parallel, each with their own operation. + var wg sync.WaitGroup + var threads = make(chan bool, parallelism) + var i int + for { + threads <- true + wg.Add(1) + writable := ((rand.Int() % 100) < 20) // 20% writers + + // Choose an operation to execute. + var handler simulateHandler + if writable { + handler = writerHandlers[rand.Intn(len(writerHandlers))] + } else { + handler = readerHandlers[rand.Intn(len(readerHandlers))] + } + + // Execute a thread for the given operation. + go func(writable bool, handler simulateHandler) { + defer wg.Done() + + // Start transaction. + tx, err := db.Begin(writable) + if err != nil { + t.Fatal("tx begin: ", err) + } + + // Obtain current state of the dataset. + mutex.Lock() + var qdb = versions[tx.ID()] + if writable { + qdb = versions[tx.ID()-1].Copy() + } + mutex.Unlock() + + // Make sure we commit/rollback the tx at the end and update the state. + if writable { + defer func() { + mutex.Lock() + versions[tx.ID()] = qdb + mutex.Unlock() + + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + }() + } else { + defer func() { _ = tx.Rollback() }() + } + + // Ignore operation if we don't have data yet. + if qdb == nil { + return + } + + // Execute handler. + handler(tx, qdb) + + // Release a thread back to the scheduling loop. + <-threads + }(writable, handler) + + i++ + if i > threadCount { + break + } + } + + // Wait until all threads are done. + wg.Wait() +} + +type simulateHandler func(tx *bolt.Tx, qdb *QuickDB) + +// Retrieves a key from the database and verifies that it is what is expected. +func simulateGetHandler(tx *bolt.Tx, qdb *QuickDB) { + // Randomly retrieve an existing exist. + keys := qdb.Rand() + if len(keys) == 0 { + return + } + + // Retrieve root bucket. + b := tx.Bucket(keys[0]) + if b == nil { + panic(fmt.Sprintf("bucket[0] expected: %08x\n", trunc(keys[0], 4))) + } + + // Drill into nested buckets. + for _, key := range keys[1 : len(keys)-1] { + b = b.Bucket(key) + if b == nil { + panic(fmt.Sprintf("bucket[n] expected: %v -> %v\n", keys, key)) + } + } + + // Verify key/value on the final bucket. + expected := qdb.Get(keys) + actual := b.Get(keys[len(keys)-1]) + if !bytes.Equal(actual, expected) { + fmt.Println("=== EXPECTED ===") + fmt.Println(expected) + fmt.Println("=== ACTUAL ===") + fmt.Println(actual) + fmt.Println("=== END ===") + panic("value mismatch") + } +} + +// Inserts a key into the database. +func simulatePutHandler(tx *bolt.Tx, qdb *QuickDB) { + var err error + keys, value := randKeys(), randValue() + + // Retrieve root bucket. + b := tx.Bucket(keys[0]) + if b == nil { + b, err = tx.CreateBucket(keys[0]) + if err != nil { + panic("create bucket: " + err.Error()) + } + } + + // Create nested buckets, if necessary. + for _, key := range keys[1 : len(keys)-1] { + child := b.Bucket(key) + if child != nil { + b = child + } else { + b, err = b.CreateBucket(key) + if err != nil { + panic("create bucket: " + err.Error()) + } + } + } + + // Insert into database. + if err := b.Put(keys[len(keys)-1], value); err != nil { + panic("put: " + err.Error()) + } + + // Insert into in-memory database. + qdb.Put(keys, value) +} + +// QuickDB is an in-memory database that replicates the functionality of the +// Bolt DB type except that it is entirely in-memory. It is meant for testing +// that the Bolt database is consistent. +type QuickDB struct { + sync.RWMutex + m map[string]interface{} +} + +// NewQuickDB returns an instance of QuickDB. +func NewQuickDB() *QuickDB { + return &QuickDB{m: make(map[string]interface{})} +} + +// Get retrieves the value at a key path. +func (db *QuickDB) Get(keys [][]byte) []byte { + db.RLock() + defer db.RUnlock() + + m := db.m + for _, key := range keys[:len(keys)-1] { + value := m[string(key)] + if value == nil { + return nil + } + switch value := value.(type) { + case map[string]interface{}: + m = value + case []byte: + return nil + } + } + + // Only return if it's a simple value. + if value, ok := m[string(keys[len(keys)-1])].([]byte); ok { + return value + } + return nil +} + +// Put inserts a value into a key path. +func (db *QuickDB) Put(keys [][]byte, value []byte) { + db.Lock() + defer db.Unlock() + + // Build buckets all the way down the key path. + m := db.m + for _, key := range keys[:len(keys)-1] { + if _, ok := m[string(key)].([]byte); ok { + return // Keypath intersects with a simple value. Do nothing. + } + + if m[string(key)] == nil { + m[string(key)] = make(map[string]interface{}) + } + m = m[string(key)].(map[string]interface{}) + } + + // Insert value into the last key. + m[string(keys[len(keys)-1])] = value +} + +// Rand returns a random key path that points to a simple value. +func (db *QuickDB) Rand() [][]byte { + db.RLock() + defer db.RUnlock() + if len(db.m) == 0 { + return nil + } + var keys [][]byte + db.rand(db.m, &keys) + return keys +} + +func (db *QuickDB) rand(m map[string]interface{}, keys *[][]byte) { + i, index := 0, rand.Intn(len(m)) + for k, v := range m { + if i == index { + *keys = append(*keys, []byte(k)) + if v, ok := v.(map[string]interface{}); ok { + db.rand(v, keys) + } + return + } + i++ + } + panic("quickdb rand: out-of-range") +} + +// Copy copies the entire database. +func (db *QuickDB) Copy() *QuickDB { + db.RLock() + defer db.RUnlock() + return &QuickDB{m: db.copy(db.m)} +} + +func (db *QuickDB) copy(m map[string]interface{}) map[string]interface{} { + clone := make(map[string]interface{}, len(m)) + for k, v := range m { + switch v := v.(type) { + case map[string]interface{}: + clone[k] = db.copy(v) + default: + clone[k] = v + } + } + return clone +} + +func randKey() []byte { + var min, max = 1, 1024 + n := rand.Intn(max-min) + min + b := make([]byte, n) + for i := 0; i < n; i++ { + b[i] = byte(rand.Intn(255)) + } + return b +} + +func randKeys() [][]byte { + var keys [][]byte + var count = rand.Intn(2) + 2 + for i := 0; i < count; i++ { + keys = append(keys, randKey()) + } + return keys +} + +func randValue() []byte { + n := rand.Intn(8192) + b := make([]byte, n) + for i := 0; i < n; i++ { + b[i] = byte(rand.Intn(255)) + } + return b +} diff --git a/vendor/github.com/boltdb/bolt/tx.go b/vendor/github.com/boltdb/bolt/tx.go new file mode 100644 index 00000000..1cfb4cde --- /dev/null +++ b/vendor/github.com/boltdb/bolt/tx.go @@ -0,0 +1,682 @@ +package bolt + +import ( + "fmt" + "io" + "os" + "sort" + "strings" + "time" + "unsafe" +) + +// txid represents the internal transaction identifier. +type txid uint64 + +// Tx represents a read-only or read/write transaction on the database. +// Read-only transactions can be used for retrieving values for keys and creating cursors. +// Read/write transactions can create and remove buckets and create and remove keys. +// +// IMPORTANT: You must commit or rollback transactions when you are done with +// them. Pages can not be reclaimed by the writer until no more transactions +// are using them. A long running read transaction can cause the database to +// quickly grow. +type Tx struct { + writable bool + managed bool + db *DB + meta *meta + root Bucket + pages map[pgid]*page + stats TxStats + commitHandlers []func() + + // WriteFlag specifies the flag for write-related methods like WriteTo(). + // Tx opens the database file with the specified flag to copy the data. + // + // By default, the flag is unset, which works well for mostly in-memory + // workloads. For databases that are much larger than available RAM, + // set the flag to syscall.O_DIRECT to avoid trashing the page cache. + WriteFlag int +} + +// init initializes the transaction. +func (tx *Tx) init(db *DB) { + tx.db = db + tx.pages = nil + + // Copy the meta page since it can be changed by the writer. + tx.meta = &meta{} + db.meta().copy(tx.meta) + + // Copy over the root bucket. + tx.root = newBucket(tx) + tx.root.bucket = &bucket{} + *tx.root.bucket = tx.meta.root + + // Increment the transaction id and add a page cache for writable transactions. + if tx.writable { + tx.pages = make(map[pgid]*page) + tx.meta.txid += txid(1) + } +} + +// ID returns the transaction id. +func (tx *Tx) ID() int { + return int(tx.meta.txid) +} + +// DB returns a reference to the database that created the transaction. +func (tx *Tx) DB() *DB { + return tx.db +} + +// Size returns current database size in bytes as seen by this transaction. +func (tx *Tx) Size() int64 { + return int64(tx.meta.pgid) * int64(tx.db.pageSize) +} + +// Writable returns whether the transaction can perform write operations. +func (tx *Tx) Writable() bool { + return tx.writable +} + +// Cursor creates a cursor associated with the root bucket. +// All items in the cursor will return a nil value because all root bucket keys point to buckets. +// The cursor is only valid as long as the transaction is open. +// Do not use a cursor after the transaction is closed. +func (tx *Tx) Cursor() *Cursor { + return tx.root.Cursor() +} + +// Stats retrieves a copy of the current transaction statistics. +func (tx *Tx) Stats() TxStats { + return tx.stats +} + +// Bucket retrieves a bucket by name. +// Returns nil if the bucket does not exist. +// The bucket instance is only valid for the lifetime of the transaction. +func (tx *Tx) Bucket(name []byte) *Bucket { + return tx.root.Bucket(name) +} + +// CreateBucket creates a new bucket. +// Returns an error if the bucket already exists, if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. +func (tx *Tx) CreateBucket(name []byte) (*Bucket, error) { + return tx.root.CreateBucket(name) +} + +// CreateBucketIfNotExists creates a new bucket if it doesn't already exist. +// Returns an error if the bucket name is blank, or if the bucket name is too long. +// The bucket instance is only valid for the lifetime of the transaction. +func (tx *Tx) CreateBucketIfNotExists(name []byte) (*Bucket, error) { + return tx.root.CreateBucketIfNotExists(name) +} + +// DeleteBucket deletes a bucket. +// Returns an error if the bucket cannot be found or if the key represents a non-bucket value. +func (tx *Tx) DeleteBucket(name []byte) error { + return tx.root.DeleteBucket(name) +} + +// ForEach executes a function for each bucket in the root. +// If the provided function returns an error then the iteration is stopped and +// the error is returned to the caller. +func (tx *Tx) ForEach(fn func(name []byte, b *Bucket) error) error { + return tx.root.ForEach(func(k, v []byte) error { + if err := fn(k, tx.root.Bucket(k)); err != nil { + return err + } + return nil + }) +} + +// OnCommit adds a handler function to be executed after the transaction successfully commits. +func (tx *Tx) OnCommit(fn func()) { + tx.commitHandlers = append(tx.commitHandlers, fn) +} + +// Commit writes all changes to disk and updates the meta page. +// Returns an error if a disk write error occurs, or if Commit is +// called on a read-only transaction. +func (tx *Tx) Commit() error { + _assert(!tx.managed, "managed tx commit not allowed") + if tx.db == nil { + return ErrTxClosed + } else if !tx.writable { + return ErrTxNotWritable + } + + // TODO(benbjohnson): Use vectorized I/O to write out dirty pages. + + // Rebalance nodes which have had deletions. + var startTime = time.Now() + tx.root.rebalance() + if tx.stats.Rebalance > 0 { + tx.stats.RebalanceTime += time.Since(startTime) + } + + // spill data onto dirty pages. + startTime = time.Now() + if err := tx.root.spill(); err != nil { + tx.rollback() + return err + } + tx.stats.SpillTime += time.Since(startTime) + + // Free the old root bucket. + tx.meta.root.root = tx.root.root + + opgid := tx.meta.pgid + + // Free the freelist and allocate new pages for it. This will overestimate + // the size of the freelist but not underestimate the size (which would be bad). + tx.db.freelist.free(tx.meta.txid, tx.db.page(tx.meta.freelist)) + p, err := tx.allocate((tx.db.freelist.size() / tx.db.pageSize) + 1) + if err != nil { + tx.rollback() + return err + } + if err := tx.db.freelist.write(p); err != nil { + tx.rollback() + return err + } + tx.meta.freelist = p.id + + // If the high water mark has moved up then attempt to grow the database. + if tx.meta.pgid > opgid { + if err := tx.db.grow(int(tx.meta.pgid+1) * tx.db.pageSize); err != nil { + tx.rollback() + return err + } + } + + // Write dirty pages to disk. + startTime = time.Now() + if err := tx.write(); err != nil { + tx.rollback() + return err + } + + // If strict mode is enabled then perform a consistency check. + // Only the first consistency error is reported in the panic. + if tx.db.StrictMode { + ch := tx.Check() + var errs []string + for { + err, ok := <-ch + if !ok { + break + } + errs = append(errs, err.Error()) + } + if len(errs) > 0 { + panic("check fail: " + strings.Join(errs, "\n")) + } + } + + // Write meta to disk. + if err := tx.writeMeta(); err != nil { + tx.rollback() + return err + } + tx.stats.WriteTime += time.Since(startTime) + + // Finalize the transaction. + tx.close() + + // Execute commit handlers now that the locks have been removed. + for _, fn := range tx.commitHandlers { + fn() + } + + return nil +} + +// Rollback closes the transaction and ignores all previous updates. Read-only +// transactions must be rolled back and not committed. +func (tx *Tx) Rollback() error { + _assert(!tx.managed, "managed tx rollback not allowed") + if tx.db == nil { + return ErrTxClosed + } + tx.rollback() + return nil +} + +func (tx *Tx) rollback() { + if tx.db == nil { + return + } + if tx.writable { + tx.db.freelist.rollback(tx.meta.txid) + tx.db.freelist.reload(tx.db.page(tx.db.meta().freelist)) + } + tx.close() +} + +func (tx *Tx) close() { + if tx.db == nil { + return + } + if tx.writable { + // Grab freelist stats. + var freelistFreeN = tx.db.freelist.free_count() + var freelistPendingN = tx.db.freelist.pending_count() + var freelistAlloc = tx.db.freelist.size() + + // Remove transaction ref & writer lock. + tx.db.rwtx = nil + tx.db.rwlock.Unlock() + + // Merge statistics. + tx.db.statlock.Lock() + tx.db.stats.FreePageN = freelistFreeN + tx.db.stats.PendingPageN = freelistPendingN + tx.db.stats.FreeAlloc = (freelistFreeN + freelistPendingN) * tx.db.pageSize + tx.db.stats.FreelistInuse = freelistAlloc + tx.db.stats.TxStats.add(&tx.stats) + tx.db.statlock.Unlock() + } else { + tx.db.removeTx(tx) + } + + // Clear all references. + tx.db = nil + tx.meta = nil + tx.root = Bucket{tx: tx} + tx.pages = nil +} + +// Copy writes the entire database to a writer. +// This function exists for backwards compatibility. Use WriteTo() instead. +func (tx *Tx) Copy(w io.Writer) error { + _, err := tx.WriteTo(w) + return err +} + +// WriteTo writes the entire database to a writer. +// If err == nil then exactly tx.Size() bytes will be written into the writer. +func (tx *Tx) WriteTo(w io.Writer) (n int64, err error) { + // Attempt to open reader with WriteFlag + f, err := os.OpenFile(tx.db.path, os.O_RDONLY|tx.WriteFlag, 0) + if err != nil { + return 0, err + } + defer func() { _ = f.Close() }() + + // Generate a meta page. We use the same page data for both meta pages. + buf := make([]byte, tx.db.pageSize) + page := (*page)(unsafe.Pointer(&buf[0])) + page.flags = metaPageFlag + *page.meta() = *tx.meta + + // Write meta 0. + page.id = 0 + page.meta().checksum = page.meta().sum64() + nn, err := w.Write(buf) + n += int64(nn) + if err != nil { + return n, fmt.Errorf("meta 0 copy: %s", err) + } + + // Write meta 1 with a lower transaction id. + page.id = 1 + page.meta().txid -= 1 + page.meta().checksum = page.meta().sum64() + nn, err = w.Write(buf) + n += int64(nn) + if err != nil { + return n, fmt.Errorf("meta 1 copy: %s", err) + } + + // Move past the meta pages in the file. + if _, err := f.Seek(int64(tx.db.pageSize*2), os.SEEK_SET); err != nil { + return n, fmt.Errorf("seek: %s", err) + } + + // Copy data pages. + wn, err := io.CopyN(w, f, tx.Size()-int64(tx.db.pageSize*2)) + n += wn + if err != nil { + return n, err + } + + return n, f.Close() +} + +// CopyFile copies the entire database to file at the given path. +// A reader transaction is maintained during the copy so it is safe to continue +// using the database while a copy is in progress. +func (tx *Tx) CopyFile(path string, mode os.FileMode) error { + f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, mode) + if err != nil { + return err + } + + err = tx.Copy(f) + if err != nil { + _ = f.Close() + return err + } + return f.Close() +} + +// Check performs several consistency checks on the database for this transaction. +// An error is returned if any inconsistency is found. +// +// It can be safely run concurrently on a writable transaction. However, this +// incurs a high cost for large databases and databases with a lot of subbuckets +// because of caching. This overhead can be removed if running on a read-only +// transaction, however, it is not safe to execute other writer transactions at +// the same time. +func (tx *Tx) Check() <-chan error { + ch := make(chan error) + go tx.check(ch) + return ch +} + +func (tx *Tx) check(ch chan error) { + // Check if any pages are double freed. + freed := make(map[pgid]bool) + for _, id := range tx.db.freelist.all() { + if freed[id] { + ch <- fmt.Errorf("page %d: already freed", id) + } + freed[id] = true + } + + // Track every reachable page. + reachable := make(map[pgid]*page) + reachable[0] = tx.page(0) // meta0 + reachable[1] = tx.page(1) // meta1 + for i := uint32(0); i <= tx.page(tx.meta.freelist).overflow; i++ { + reachable[tx.meta.freelist+pgid(i)] = tx.page(tx.meta.freelist) + } + + // Recursively check buckets. + tx.checkBucket(&tx.root, reachable, freed, ch) + + // Ensure all pages below high water mark are either reachable or freed. + for i := pgid(0); i < tx.meta.pgid; i++ { + _, isReachable := reachable[i] + if !isReachable && !freed[i] { + ch <- fmt.Errorf("page %d: unreachable unfreed", int(i)) + } + } + + // Close the channel to signal completion. + close(ch) +} + +func (tx *Tx) checkBucket(b *Bucket, reachable map[pgid]*page, freed map[pgid]bool, ch chan error) { + // Ignore inline buckets. + if b.root == 0 { + return + } + + // Check every page used by this bucket. + b.tx.forEachPage(b.root, 0, func(p *page, _ int) { + if p.id > tx.meta.pgid { + ch <- fmt.Errorf("page %d: out of bounds: %d", int(p.id), int(b.tx.meta.pgid)) + } + + // Ensure each page is only referenced once. + for i := pgid(0); i <= pgid(p.overflow); i++ { + var id = p.id + i + if _, ok := reachable[id]; ok { + ch <- fmt.Errorf("page %d: multiple references", int(id)) + } + reachable[id] = p + } + + // We should only encounter un-freed leaf and branch pages. + if freed[p.id] { + ch <- fmt.Errorf("page %d: reachable freed", int(p.id)) + } else if (p.flags&branchPageFlag) == 0 && (p.flags&leafPageFlag) == 0 { + ch <- fmt.Errorf("page %d: invalid type: %s", int(p.id), p.typ()) + } + }) + + // Check each bucket within this bucket. + _ = b.ForEach(func(k, v []byte) error { + if child := b.Bucket(k); child != nil { + tx.checkBucket(child, reachable, freed, ch) + } + return nil + }) +} + +// allocate returns a contiguous block of memory starting at a given page. +func (tx *Tx) allocate(count int) (*page, error) { + p, err := tx.db.allocate(count) + if err != nil { + return nil, err + } + + // Save to our page cache. + tx.pages[p.id] = p + + // Update statistics. + tx.stats.PageCount++ + tx.stats.PageAlloc += count * tx.db.pageSize + + return p, nil +} + +// write writes any dirty pages to disk. +func (tx *Tx) write() error { + // Sort pages by id. + pages := make(pages, 0, len(tx.pages)) + for _, p := range tx.pages { + pages = append(pages, p) + } + // Clear out page cache early. + tx.pages = make(map[pgid]*page) + sort.Sort(pages) + + // Write pages to disk in order. + for _, p := range pages { + size := (int(p.overflow) + 1) * tx.db.pageSize + offset := int64(p.id) * int64(tx.db.pageSize) + + // Write out page in "max allocation" sized chunks. + ptr := (*[maxAllocSize]byte)(unsafe.Pointer(p)) + for { + // Limit our write to our max allocation size. + sz := size + if sz > maxAllocSize-1 { + sz = maxAllocSize - 1 + } + + // Write chunk to disk. + buf := ptr[:sz] + if _, err := tx.db.ops.writeAt(buf, offset); err != nil { + return err + } + + // Update statistics. + tx.stats.Write++ + + // Exit inner for loop if we've written all the chunks. + size -= sz + if size == 0 { + break + } + + // Otherwise move offset forward and move pointer to next chunk. + offset += int64(sz) + ptr = (*[maxAllocSize]byte)(unsafe.Pointer(&ptr[sz])) + } + } + + // Ignore file sync if flag is set on DB. + if !tx.db.NoSync || IgnoreNoSync { + if err := fdatasync(tx.db); err != nil { + return err + } + } + + // Put small pages back to page pool. + for _, p := range pages { + // Ignore page sizes over 1 page. + // These are allocated using make() instead of the page pool. + if int(p.overflow) != 0 { + continue + } + + buf := (*[maxAllocSize]byte)(unsafe.Pointer(p))[:tx.db.pageSize] + + // See https://go.googlesource.com/go/+/f03c9202c43e0abb130669852082117ca50aa9b1 + for i := range buf { + buf[i] = 0 + } + tx.db.pagePool.Put(buf) + } + + return nil +} + +// writeMeta writes the meta to the disk. +func (tx *Tx) writeMeta() error { + // Create a temporary buffer for the meta page. + buf := make([]byte, tx.db.pageSize) + p := tx.db.pageInBuffer(buf, 0) + tx.meta.write(p) + + // Write the meta page to file. + if _, err := tx.db.ops.writeAt(buf, int64(p.id)*int64(tx.db.pageSize)); err != nil { + return err + } + if !tx.db.NoSync || IgnoreNoSync { + if err := fdatasync(tx.db); err != nil { + return err + } + } + + // Update statistics. + tx.stats.Write++ + + return nil +} + +// page returns a reference to the page with a given id. +// If page has been written to then a temporary buffered page is returned. +func (tx *Tx) page(id pgid) *page { + // Check the dirty pages first. + if tx.pages != nil { + if p, ok := tx.pages[id]; ok { + return p + } + } + + // Otherwise return directly from the mmap. + return tx.db.page(id) +} + +// forEachPage iterates over every page within a given page and executes a function. +func (tx *Tx) forEachPage(pgid pgid, depth int, fn func(*page, int)) { + p := tx.page(pgid) + + // Execute function. + fn(p, depth) + + // Recursively loop over children. + if (p.flags & branchPageFlag) != 0 { + for i := 0; i < int(p.count); i++ { + elem := p.branchPageElement(uint16(i)) + tx.forEachPage(elem.pgid, depth+1, fn) + } + } +} + +// Page returns page information for a given page number. +// This is only safe for concurrent use when used by a writable transaction. +func (tx *Tx) Page(id int) (*PageInfo, error) { + if tx.db == nil { + return nil, ErrTxClosed + } else if pgid(id) >= tx.meta.pgid { + return nil, nil + } + + // Build the page info. + p := tx.db.page(pgid(id)) + info := &PageInfo{ + ID: id, + Count: int(p.count), + OverflowCount: int(p.overflow), + } + + // Determine the type (or if it's free). + if tx.db.freelist.freed(pgid(id)) { + info.Type = "free" + } else { + info.Type = p.typ() + } + + return info, nil +} + +// TxStats represents statistics about the actions performed by the transaction. +type TxStats struct { + // Page statistics. + PageCount int // number of page allocations + PageAlloc int // total bytes allocated + + // Cursor statistics. + CursorCount int // number of cursors created + + // Node statistics + NodeCount int // number of node allocations + NodeDeref int // number of node dereferences + + // Rebalance statistics. + Rebalance int // number of node rebalances + RebalanceTime time.Duration // total time spent rebalancing + + // Split/Spill statistics. + Split int // number of nodes split + Spill int // number of nodes spilled + SpillTime time.Duration // total time spent spilling + + // Write statistics. + Write int // number of writes performed + WriteTime time.Duration // total time spent writing to disk +} + +func (s *TxStats) add(other *TxStats) { + s.PageCount += other.PageCount + s.PageAlloc += other.PageAlloc + s.CursorCount += other.CursorCount + s.NodeCount += other.NodeCount + s.NodeDeref += other.NodeDeref + s.Rebalance += other.Rebalance + s.RebalanceTime += other.RebalanceTime + s.Split += other.Split + s.Spill += other.Spill + s.SpillTime += other.SpillTime + s.Write += other.Write + s.WriteTime += other.WriteTime +} + +// Sub calculates and returns the difference between two sets of transaction stats. +// This is useful when obtaining stats at two different points and time and +// you need the performance counters that occurred within that time span. +func (s *TxStats) Sub(other *TxStats) TxStats { + var diff TxStats + diff.PageCount = s.PageCount - other.PageCount + diff.PageAlloc = s.PageAlloc - other.PageAlloc + diff.CursorCount = s.CursorCount - other.CursorCount + diff.NodeCount = s.NodeCount - other.NodeCount + diff.NodeDeref = s.NodeDeref - other.NodeDeref + diff.Rebalance = s.Rebalance - other.Rebalance + diff.RebalanceTime = s.RebalanceTime - other.RebalanceTime + diff.Split = s.Split - other.Split + diff.Spill = s.Spill - other.Spill + diff.SpillTime = s.SpillTime - other.SpillTime + diff.Write = s.Write - other.Write + diff.WriteTime = s.WriteTime - other.WriteTime + return diff +} diff --git a/vendor/github.com/boltdb/bolt/tx_test.go b/vendor/github.com/boltdb/bolt/tx_test.go new file mode 100644 index 00000000..2201e792 --- /dev/null +++ b/vendor/github.com/boltdb/bolt/tx_test.go @@ -0,0 +1,716 @@ +package bolt_test + +import ( + "bytes" + "errors" + "fmt" + "log" + "os" + "testing" + + "github.com/boltdb/bolt" +) + +// Ensure that committing a closed transaction returns an error. +func TestTx_Commit_ErrTxClosed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + + if _, err := tx.CreateBucket([]byte("foo")); err != nil { + t.Fatal(err) + } + + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + + if err := tx.Commit(); err != bolt.ErrTxClosed { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that rolling back a closed transaction returns an error. +func TestTx_Rollback_ErrTxClosed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + + if err := tx.Rollback(); err != nil { + t.Fatal(err) + } + if err := tx.Rollback(); err != bolt.ErrTxClosed { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that committing a read-only transaction returns an error. +func TestTx_Commit_ErrTxNotWritable(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + tx, err := db.Begin(false) + if err != nil { + t.Fatal(err) + } + if err := tx.Commit(); err != bolt.ErrTxNotWritable { + t.Fatal(err) + } +} + +// Ensure that a transaction can retrieve a cursor on the root bucket. +func TestTx_Cursor(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + + if _, err := tx.CreateBucket([]byte("woojits")); err != nil { + t.Fatal(err) + } + + c := tx.Cursor() + if k, v := c.First(); !bytes.Equal(k, []byte("widgets")) { + t.Fatalf("unexpected key: %v", k) + } else if v != nil { + t.Fatalf("unexpected value: %v", v) + } + + if k, v := c.Next(); !bytes.Equal(k, []byte("woojits")) { + t.Fatalf("unexpected key: %v", k) + } else if v != nil { + t.Fatalf("unexpected value: %v", v) + } + + if k, v := c.Next(); k != nil { + t.Fatalf("unexpected key: %v", k) + } else if v != nil { + t.Fatalf("unexpected value: %v", k) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that creating a bucket with a read-only transaction returns an error. +func TestTx_CreateBucket_ErrTxNotWritable(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.View(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("foo")) + if err != bolt.ErrTxNotWritable { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that creating a bucket on a closed transaction returns an error. +func TestTx_CreateBucket_ErrTxClosed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + + if _, err := tx.CreateBucket([]byte("foo")); err != bolt.ErrTxClosed { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that a Tx can retrieve a bucket. +func TestTx_Bucket(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + if tx.Bucket([]byte("widgets")) == nil { + t.Fatal("expected bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a Tx retrieving a non-existent key returns nil. +func TestTx_Get_NotFound(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if b.Get([]byte("no_such_key")) != nil { + t.Fatal("expected nil value") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can be created and retrieved. +func TestTx_CreateBucket(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + // Create a bucket. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } else if b == nil { + t.Fatal("expected bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Read the bucket through a separate transaction. + if err := db.View(func(tx *bolt.Tx) error { + if tx.Bucket([]byte("widgets")) == nil { + t.Fatal("expected bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can be created if it doesn't already exist. +func TestTx_CreateBucketIfNotExists(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + // Create bucket. + if b, err := tx.CreateBucketIfNotExists([]byte("widgets")); err != nil { + t.Fatal(err) + } else if b == nil { + t.Fatal("expected bucket") + } + + // Create bucket again. + if b, err := tx.CreateBucketIfNotExists([]byte("widgets")); err != nil { + t.Fatal(err) + } else if b == nil { + t.Fatal("expected bucket") + } + + return nil + }); err != nil { + t.Fatal(err) + } + + // Read the bucket through a separate transaction. + if err := db.View(func(tx *bolt.Tx) error { + if tx.Bucket([]byte("widgets")) == nil { + t.Fatal("expected bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure transaction returns an error if creating an unnamed bucket. +func TestTx_CreateBucketIfNotExists_ErrBucketNameRequired(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucketIfNotExists([]byte{}); err != bolt.ErrBucketNameRequired { + t.Fatalf("unexpected error: %s", err) + } + + if _, err := tx.CreateBucketIfNotExists(nil); err != bolt.ErrBucketNameRequired { + t.Fatalf("unexpected error: %s", err) + } + + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket cannot be created twice. +func TestTx_CreateBucket_ErrBucketExists(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + // Create a bucket. + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Create the same bucket again. + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket([]byte("widgets")); err != bolt.ErrBucketExists { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket is created with a non-blank name. +func TestTx_CreateBucket_ErrBucketNameRequired(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + if _, err := tx.CreateBucket(nil); err != bolt.ErrBucketNameRequired { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that a bucket can be deleted. +func TestTx_DeleteBucket(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + // Create a bucket and add a value. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + // Delete the bucket and make sure we can't get the value. + if err := db.Update(func(tx *bolt.Tx) error { + if err := tx.DeleteBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + if tx.Bucket([]byte("widgets")) != nil { + t.Fatal("unexpected bucket") + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.Update(func(tx *bolt.Tx) error { + // Create the bucket again and make sure there's not a phantom value. + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if v := b.Get([]byte("foo")); v != nil { + t.Fatalf("unexpected phantom value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that deleting a bucket on a closed transaction returns an error. +func TestTx_DeleteBucket_ErrTxClosed(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + tx, err := db.Begin(true) + if err != nil { + t.Fatal(err) + } + if err := tx.Commit(); err != nil { + t.Fatal(err) + } + if err := tx.DeleteBucket([]byte("foo")); err != bolt.ErrTxClosed { + t.Fatalf("unexpected error: %s", err) + } +} + +// Ensure that deleting a bucket with a read-only transaction returns an error. +func TestTx_DeleteBucket_ReadOnly(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.View(func(tx *bolt.Tx) error { + if err := tx.DeleteBucket([]byte("foo")); err != bolt.ErrTxNotWritable { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that nothing happens when deleting a bucket that doesn't exist. +func TestTx_DeleteBucket_NotFound(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + if err := tx.DeleteBucket([]byte("widgets")); err != bolt.ErrBucketNotFound { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that no error is returned when a tx.ForEach function does not return +// an error. +func TestTx_ForEach_NoError(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + + if err := tx.ForEach(func(name []byte, b *bolt.Bucket) error { + return nil + }); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that an error is returned when a tx.ForEach function returns an error. +func TestTx_ForEach_WithError(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + + marker := errors.New("marker") + if err := tx.ForEach(func(name []byte, b *bolt.Bucket) error { + return marker + }); err != marker { + t.Fatalf("unexpected error: %s", err) + } + return nil + }); err != nil { + t.Fatal(err) + } +} + +// Ensure that Tx commit handlers are called after a transaction successfully commits. +func TestTx_OnCommit(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var x int + if err := db.Update(func(tx *bolt.Tx) error { + tx.OnCommit(func() { x += 1 }) + tx.OnCommit(func() { x += 2 }) + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } else if x != 3 { + t.Fatalf("unexpected x: %d", x) + } +} + +// Ensure that Tx commit handlers are NOT called after a transaction rolls back. +func TestTx_OnCommit_Rollback(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + var x int + if err := db.Update(func(tx *bolt.Tx) error { + tx.OnCommit(func() { x += 1 }) + tx.OnCommit(func() { x += 2 }) + if _, err := tx.CreateBucket([]byte("widgets")); err != nil { + t.Fatal(err) + } + return errors.New("rollback this commit") + }); err == nil || err.Error() != "rollback this commit" { + t.Fatalf("unexpected error: %s", err) + } else if x != 0 { + t.Fatalf("unexpected x: %d", x) + } +} + +// Ensure that the database can be copied to a file path. +func TestTx_CopyFile(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + + path := tempfile() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte("bat")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + return tx.CopyFile(path, 0600) + }); err != nil { + t.Fatal(err) + } + + db2, err := bolt.Open(path, 0600, nil) + if err != nil { + t.Fatal(err) + } + + if err := db2.View(func(tx *bolt.Tx) error { + if v := tx.Bucket([]byte("widgets")).Get([]byte("foo")); !bytes.Equal(v, []byte("bar")) { + t.Fatalf("unexpected value: %v", v) + } + if v := tx.Bucket([]byte("widgets")).Get([]byte("baz")); !bytes.Equal(v, []byte("bat")) { + t.Fatalf("unexpected value: %v", v) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db2.Close(); err != nil { + t.Fatal(err) + } +} + +type failWriterError struct{} + +func (failWriterError) Error() string { + return "error injected for tests" +} + +type failWriter struct { + // fail after this many bytes + After int +} + +func (f *failWriter) Write(p []byte) (n int, err error) { + n = len(p) + if n > f.After { + n = f.After + err = failWriterError{} + } + f.After -= n + return n, err +} + +// Ensure that Copy handles write errors right. +func TestTx_CopyFile_Error_Meta(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte("bat")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + return tx.Copy(&failWriter{}) + }); err == nil || err.Error() != "meta 0 copy: error injected for tests" { + t.Fatalf("unexpected error: %v", err) + } +} + +// Ensure that Copy handles write errors right. +func TestTx_CopyFile_Error_Normal(t *testing.T) { + db := MustOpenDB() + defer db.MustClose() + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + t.Fatal(err) + } + if err := b.Put([]byte("baz"), []byte("bat")); err != nil { + t.Fatal(err) + } + return nil + }); err != nil { + t.Fatal(err) + } + + if err := db.View(func(tx *bolt.Tx) error { + return tx.Copy(&failWriter{3 * db.Info().PageSize}) + }); err == nil || err.Error() != "error injected for tests" { + t.Fatalf("unexpected error: %v", err) + } +} + +func ExampleTx_Rollback() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Create a bucket. + if err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucket([]byte("widgets")) + return err + }); err != nil { + log.Fatal(err) + } + + // Set a value for a key. + if err := db.Update(func(tx *bolt.Tx) error { + return tx.Bucket([]byte("widgets")).Put([]byte("foo"), []byte("bar")) + }); err != nil { + log.Fatal(err) + } + + // Update the key but rollback the transaction so it never saves. + tx, err := db.Begin(true) + if err != nil { + log.Fatal(err) + } + b := tx.Bucket([]byte("widgets")) + if err := b.Put([]byte("foo"), []byte("baz")); err != nil { + log.Fatal(err) + } + if err := tx.Rollback(); err != nil { + log.Fatal(err) + } + + // Ensure that our original value is still set. + if err := db.View(func(tx *bolt.Tx) error { + value := tx.Bucket([]byte("widgets")).Get([]byte("foo")) + fmt.Printf("The value for 'foo' is still: %s\n", value) + return nil + }); err != nil { + log.Fatal(err) + } + + // Close database to release file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // The value for 'foo' is still: bar +} + +func ExampleTx_CopyFile() { + // Open the database. + db, err := bolt.Open(tempfile(), 0666, nil) + if err != nil { + log.Fatal(err) + } + defer os.Remove(db.Path()) + + // Create a bucket and a key. + if err := db.Update(func(tx *bolt.Tx) error { + b, err := tx.CreateBucket([]byte("widgets")) + if err != nil { + return err + } + if err := b.Put([]byte("foo"), []byte("bar")); err != nil { + return err + } + return nil + }); err != nil { + log.Fatal(err) + } + + // Copy the database to another file. + toFile := tempfile() + if err := db.View(func(tx *bolt.Tx) error { + return tx.CopyFile(toFile, 0666) + }); err != nil { + log.Fatal(err) + } + defer os.Remove(toFile) + + // Open the cloned database. + db2, err := bolt.Open(toFile, 0666, nil) + if err != nil { + log.Fatal(err) + } + + // Ensure that the key exists in the copy. + if err := db2.View(func(tx *bolt.Tx) error { + value := tx.Bucket([]byte("widgets")).Get([]byte("foo")) + fmt.Printf("The value for 'foo' in the clone is: %s\n", value) + return nil + }); err != nil { + log.Fatal(err) + } + + // Close database to release file lock. + if err := db.Close(); err != nil { + log.Fatal(err) + } + + if err := db2.Close(); err != nil { + log.Fatal(err) + } + + // Output: + // The value for 'foo' in the clone is: bar +} diff --git a/vendor/github.com/go-kit/kit/ROADMAP.md b/vendor/github.com/go-kit/kit/ROADMAP.md index 900568c2..5c462aa2 100644 --- a/vendor/github.com/go-kit/kit/ROADMAP.md +++ b/vendor/github.com/go-kit/kit/ROADMAP.md @@ -7,9 +7,8 @@ maintainers. Suggest new ideas, enhancements, and features using the standard ## Prioritized -1. package metrics refactor (#313, #263, #300) -2. kitgen code generation (#308, #70) -3. package pubsub (#298, #295) +1. kitgen code generation (#308, #70) +1. package pubsub (#298, #295) ## Unprioritized diff --git a/vendor/github.com/go-kit/kit/auth/jwt/README.md b/vendor/github.com/go-kit/kit/auth/jwt/README.md new file mode 100644 index 00000000..bec4f674 --- /dev/null +++ b/vendor/github.com/go-kit/kit/auth/jwt/README.md @@ -0,0 +1,122 @@ +# package auth/jwt + +`package auth/jwt` provides a set of interfaces for service authorization +through [JSON Web Tokens](https://jwt.io/). + +## Usage + +NewParser takes a key function and an expected signing method and returns an +`endpoint.Middleware`. The middleware will parse a token passed into the +context via the `jwt.JWTTokenContextKey`. If the token is valid, any claims +will be added to the context via the `jwt.JWTClaimsContextKey`. + +```go +import ( + stdjwt "github.com/dgrijalva/jwt-go" + + "github.com/go-kit/kit/auth/jwt" + "github.com/go-kit/kit/endpoint" +) + +func main() { + var exampleEndpoint endpoint.Endpoint + { + kf := func(token *stdjwt.Token) (interface{}, error) { return []byte("SigningString"), nil } + exampleEndpoint = MakeExampleEndpoint(service) + exampleEndpoint = jwt.NewParser(kf, stdjwt.SigningMethodHS256)(exampleEndpoint) + } +} +``` + +NewSigner takes a JWT key ID header, the signing key, signing method, and a +claims object. It returns an `endpoint.Middleware`. The middleware will build +the token string and add it to the context via the `jwt.JWTTokenContextKey`. + +```go +import ( + stdjwt "github.com/dgrijalva/jwt-go" + + "github.com/go-kit/kit/auth/jwt" + "github.com/go-kit/kit/endpoint" +) + +func main() { + var exampleEndpoint endpoint.Endpoint + { + exampleEndpoint = grpctransport.NewClient(...).Endpoint() + exampleEndpoint = jwt.NewSigner( + "kid-header", + []byte("SigningString"), + stdjwt.SigningMethodHS256, + jwt.Claims{}, + )(exampleEndpoint) + } +} +``` + +In order for the parser and the signer to work, the authorization headers need +to be passed between the request and the context. `ToHTTPContext()`, +`FromHTTPContext()`, `ToGRPCContext()`, and `FromGRPCContext()` are given as +helpers to do this. These functions implement the correlating transport's +RequestFunc interface and can be passed as ClientBefore or ServerBefore +options. + +Example of use in a client: + +```go +import ( + stdjwt "github.com/dgrijalva/jwt-go" + + grpctransport "github.com/go-kit/kit/transport/grpc" + "github.com/go-kit/kit/auth/jwt" + "github.com/go-kit/kit/endpoint" +) + +func main() { + + options := []httptransport.ClientOption{} + var exampleEndpoint endpoint.Endpoint + { + exampleEndpoint = grpctransport.NewClient(..., grpctransport.ClientBefore(jwt.FromGRPCContext())).Endpoint() + exampleEndpoint = jwt.NewSigner( + "kid-header", + []byte("SigningString"), + stdjwt.SigningMethodHS256, + jwt.Claims{}, + )(exampleEndpoint) + } +} +``` + +Example of use in a server: + +```go +import ( + "golang.org/x/net/context" + + "github.com/go-kit/kit/auth/jwt" + "github.com/go-kit/kit/log" + grpctransport "github.com/go-kit/kit/transport/grpc" +) + +func MakeGRPCServer(ctx context.Context, endpoints Endpoints, logger log.Logger) pb.ExampleServer { + options := []grpctransport.ServerOption{grpctransport.ServerErrorLogger(logger)} + + return &grpcServer{ + createUser: grpctransport.NewServer( + ctx, + endpoints.CreateUserEndpoint, + DecodeGRPCCreateUserRequest, + EncodeGRPCCreateUserResponse, + append(options, grpctransport.ServerBefore(jwt.ToGRPCContext()))..., + ), + getUser: grpctransport.NewServer( + ctx, + endpoints.GetUserEndpoint, + DecodeGRPCGetUserRequest, + EncodeGRPCGetUserResponse, + options..., + ), + } +} +``` diff --git a/vendor/github.com/go-kit/kit/auth/jwt/middleware.go b/vendor/github.com/go-kit/kit/auth/jwt/middleware.go new file mode 100644 index 00000000..8b5f826c --- /dev/null +++ b/vendor/github.com/go-kit/kit/auth/jwt/middleware.go @@ -0,0 +1,122 @@ +package jwt + +import ( + "errors" + + jwt "github.com/dgrijalva/jwt-go" + "golang.org/x/net/context" + + "github.com/go-kit/kit/endpoint" +) + +type contextKey string + +const ( + // JWTTokenContextKey holds the key used to store a JWT Token in the + // context. + JWTTokenContextKey contextKey = "JWTToken" + // JWTClaimsContxtKey holds the key used to store the JWT Claims in the + // context. + JWTClaimsContextKey contextKey = "JWTClaims" +) + +var ( + // ErrTokenContextMissing denotes a token was not passed into the parsing + // middleware's context. + ErrTokenContextMissing = errors.New("token up for parsing was not passed through the context") + // ErrTokenInvalid denotes a token was not able to be validated. + ErrTokenInvalid = errors.New("JWT Token was invalid") + // ErrTokenExpired denotes a token's expire header (exp) has since passed. + ErrTokenExpired = errors.New("JWT Token is expired") + // ErrTokenMalformed denotes a token was not formatted as a JWT token. + ErrTokenMalformed = errors.New("JWT Token is malformed") + // ErrTokenNotActive denotes a token's not before header (nbf) is in the + // future. + ErrTokenNotActive = errors.New("token is not valid yet") + // ErrUncesptedSigningMethod denotes a token was signed with an unexpected + // signing method. + ErrUnexpectedSigningMethod = errors.New("unexpected signing method") +) + +type Claims map[string]interface{} + +// NewSigner creates a new JWT token generating middleware, specifying key ID, +// signing string, signing method and the claims you would like it to contain. +// Tokens are signed with a Key ID header (kid) which is useful for determining +// the key to use for parsing. Particularly useful for clients. +func NewSigner(kid string, key []byte, method jwt.SigningMethod, claims Claims) endpoint.Middleware { + return func(next endpoint.Endpoint) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + token := jwt.NewWithClaims(method, jwt.MapClaims(claims)) + token.Header["kid"] = kid + + // Sign and get the complete encoded token as a string using the secret + tokenString, err := token.SignedString(key) + if err != nil { + return nil, err + } + ctx = context.WithValue(ctx, JWTTokenContextKey, tokenString) + + return next(ctx, request) + } + } +} + +// NewParser creates a new JWT token parsing middleware, specifying a +// jwt.Keyfunc interface and the signing method. NewParser adds the resulting +// claims to endpoint context or returns error on invalid token. Particularly +// useful for servers. +func NewParser(keyFunc jwt.Keyfunc, method jwt.SigningMethod) endpoint.Middleware { + return func(next endpoint.Endpoint) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (response interface{}, err error) { + // tokenString is stored in the context from the transport handlers. + tokenString, ok := ctx.Value(JWTTokenContextKey).(string) + if !ok { + return nil, ErrTokenContextMissing + } + + // Parse takes the token string and a function for looking up the + // key. The latter is especially useful if you use multiple keys + // for your application. The standard is to use 'kid' in the head + // of the token to identify which key to use, but the parsed token + // (head and claims) is provided to the callback, providing + // flexibility. + token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) { + // Don't forget to validate the alg is what you expect: + if token.Method != method { + return nil, ErrUnexpectedSigningMethod + } + + return keyFunc(token) + }) + if err != nil { + if e, ok := err.(*jwt.ValidationError); ok && e.Inner != nil { + if e.Errors&jwt.ValidationErrorMalformed != 0 { + // Token is malformed + return nil, ErrTokenMalformed + } else if e.Errors&jwt.ValidationErrorExpired != 0 { + // Token is expired + return nil, ErrTokenExpired + } else if e.Errors&jwt.ValidationErrorNotValidYet != 0 { + // Token is not active yet + return nil, ErrTokenNotActive + } + + return nil, e.Inner + } + + return nil, err + } + + if !token.Valid { + return nil, ErrTokenInvalid + } + + if claims, ok := token.Claims.(jwt.MapClaims); ok { + ctx = context.WithValue(ctx, JWTClaimsContextKey, Claims(claims)) + } + + return next(ctx, request) + } + } +} diff --git a/vendor/github.com/go-kit/kit/auth/jwt/middleware_test.go b/vendor/github.com/go-kit/kit/auth/jwt/middleware_test.go new file mode 100644 index 00000000..46bae688 --- /dev/null +++ b/vendor/github.com/go-kit/kit/auth/jwt/middleware_test.go @@ -0,0 +1,106 @@ +package jwt + +import ( + "testing" + + jwt "github.com/dgrijalva/jwt-go" + + "golang.org/x/net/context" +) + +var ( + kid = "kid" + key = []byte("test_signing_key") + method = jwt.SigningMethodHS256 + invalidMethod = jwt.SigningMethodRS256 + claims = Claims{"user": "go-kit"} + // Signed tokens generated at https://jwt.io/ + signedKey = "eyJhbGciOiJIUzI1NiIsImtpZCI6ImtpZCIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoiZ28ta2l0In0.14M2VmYyApdSlV_LZ88ajjwuaLeIFplB8JpyNy0A19E" + invalidKey = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.e30.vKVCKto-Wn6rgz3vBdaZaCBGfCBDTXOENSo_X2Gq7qA" +) + +func TestSigner(t *testing.T) { + e := func(ctx context.Context, i interface{}) (interface{}, error) { return ctx, nil } + + signer := NewSigner(kid, key, method, claims)(e) + ctx, err := signer(context.Background(), struct{}{}) + if err != nil { + t.Fatalf("Signer returned error: %s", err) + } + + token, ok := ctx.(context.Context).Value(JWTTokenContextKey).(string) + if !ok { + t.Fatal("Token did not exist in context") + } + + if token != signedKey { + t.Fatalf("JWT tokens did not match: expecting %s got %s", signedKey, token) + } +} + +func TestJWTParser(t *testing.T) { + e := func(ctx context.Context, i interface{}) (interface{}, error) { return ctx, nil } + + keys := func(token *jwt.Token) (interface{}, error) { + return key, nil + } + + parser := NewParser(keys, method)(e) + + // No Token is passed into the parser + _, err := parser(context.Background(), struct{}{}) + if err == nil { + t.Error("Parser should have returned an error") + } + + if err != ErrTokenContextMissing { + t.Errorf("unexpected error returned, expected: %s got: %s", ErrTokenContextMissing, err) + } + + // Invalid Token is passed into the parser + ctx := context.WithValue(context.Background(), JWTTokenContextKey, invalidKey) + _, err = parser(ctx, struct{}{}) + if err == nil { + t.Error("Parser should have returned an error") + } + + // Invalid Method is used in the parser + badParser := NewParser(keys, invalidMethod)(e) + ctx = context.WithValue(context.Background(), JWTTokenContextKey, signedKey) + _, err = badParser(ctx, struct{}{}) + if err == nil { + t.Error("Parser should have returned an error") + } + + if err != ErrUnexpectedSigningMethod { + t.Errorf("unexpected error returned, expected: %s got: %s", ErrUnexpectedSigningMethod, err) + } + + // Invalid key is used in the parser + invalidKeys := func(token *jwt.Token) (interface{}, error) { + return []byte("bad"), nil + } + + badParser = NewParser(invalidKeys, method)(e) + ctx = context.WithValue(context.Background(), JWTTokenContextKey, signedKey) + _, err = badParser(ctx, struct{}{}) + if err == nil { + t.Error("Parser should have returned an error") + } + + // Correct token is passed into the parser + ctx = context.WithValue(context.Background(), JWTTokenContextKey, signedKey) + ctx1, err := parser(ctx, struct{}{}) + if err != nil { + t.Fatalf("Parser returned error: %s", err) + } + + cl, ok := ctx1.(context.Context).Value(JWTClaimsContextKey).(Claims) + if !ok { + t.Fatal("Claims were not passed into context correctly") + } + + if cl["user"] != claims["user"] { + t.Fatalf("JWT Claims.user did not match: expecting %s got %s", claims["user"], cl["user"]) + } +} diff --git a/vendor/github.com/go-kit/kit/auth/jwt/transport.go b/vendor/github.com/go-kit/kit/auth/jwt/transport.go new file mode 100644 index 00000000..f4ab4d81 --- /dev/null +++ b/vendor/github.com/go-kit/kit/auth/jwt/transport.go @@ -0,0 +1,89 @@ +package jwt + +import ( + "fmt" + stdhttp "net/http" + "strings" + + "golang.org/x/net/context" + "google.golang.org/grpc/metadata" + + "github.com/go-kit/kit/transport/grpc" + "github.com/go-kit/kit/transport/http" +) + +const ( + bearer string = "bearer" + bearerFormat string = "Bearer %s" +) + +// ToHTTPContext moves JWT token from request header to context. Particularly +// useful for servers. +func ToHTTPContext() http.RequestFunc { + return func(ctx context.Context, r *stdhttp.Request) context.Context { + token, ok := extractTokenFromAuthHeader(r.Header.Get("Authorization")) + if !ok { + return ctx + } + + return context.WithValue(ctx, JWTTokenContextKey, token) + } +} + +// FromHTTPContext moves JWT token from context to request header. Particularly +// useful for clients. +func FromHTTPContext() http.RequestFunc { + return func(ctx context.Context, r *stdhttp.Request) context.Context { + token, ok := ctx.Value(JWTTokenContextKey).(string) + if ok { + r.Header.Add("Authorization", generateAuthHeaderFromToken(token)) + } + return ctx + } +} + +// ToGRPCContext moves JWT token from grpc metadata to context. Particularly +// userful for servers. +func ToGRPCContext() grpc.RequestFunc { + return func(ctx context.Context, md *metadata.MD) context.Context { + // capital "Key" is illegal in HTTP/2. + authHeader, ok := (*md)["authorization"] + if !ok { + return ctx + } + + token, ok := extractTokenFromAuthHeader(authHeader[0]) + if ok { + ctx = context.WithValue(ctx, JWTTokenContextKey, token) + } + + return ctx + } +} + +// FromGRPCContext moves JWT token from context to grpc metadata. Particularly +// useful for clients. +func FromGRPCContext() grpc.RequestFunc { + return func(ctx context.Context, md *metadata.MD) context.Context { + token, ok := ctx.Value(JWTTokenContextKey).(string) + if ok { + // capital "Key" is illegal in HTTP/2. + (*md)["authorization"] = []string{generateAuthHeaderFromToken(token)} + } + + return ctx + } +} + +func extractTokenFromAuthHeader(val string) (token string, ok bool) { + authHeaderParts := strings.Split(val, " ") + if len(authHeaderParts) != 2 || strings.ToLower(authHeaderParts[0]) != bearer { + return "", false + } + + return authHeaderParts[1], true +} + +func generateAuthHeaderFromToken(token string) string { + return fmt.Sprintf(bearerFormat, token) +} diff --git a/vendor/github.com/go-kit/kit/auth/jwt/transport_test.go b/vendor/github.com/go-kit/kit/auth/jwt/transport_test.go new file mode 100644 index 00000000..829d87f4 --- /dev/null +++ b/vendor/github.com/go-kit/kit/auth/jwt/transport_test.go @@ -0,0 +1,126 @@ +package jwt + +import ( + "fmt" + "net/http" + "testing" + + "google.golang.org/grpc/metadata" + + "golang.org/x/net/context" +) + +func TestToHTTPContext(t *testing.T) { + reqFunc := ToHTTPContext() + + // When the header doesn't exist + ctx := reqFunc(context.Background(), &http.Request{}) + + if ctx.Value(JWTTokenContextKey) != nil { + t.Error("Context shouldn't contain the encoded JWT") + } + + // Authorization header value has invalid format + header := http.Header{} + header.Set("Authorization", "no expected auth header format value") + ctx = reqFunc(context.Background(), &http.Request{Header: header}) + + if ctx.Value(JWTTokenContextKey) != nil { + t.Error("Context shouldn't contain the encoded JWT") + } + + // Authorization header is correct + header.Set("Authorization", generateAuthHeaderFromToken(signedKey)) + ctx = reqFunc(context.Background(), &http.Request{Header: header}) + + token := ctx.Value(JWTTokenContextKey).(string) + if token != signedKey { + t.Errorf("Context doesn't contain the expected encoded token value; expected: %s, got: %s", signedKey, token) + } +} + +func TestFromHTTPContext(t *testing.T) { + reqFunc := FromHTTPContext() + + // No JWT Token is passed in the context + ctx := context.Background() + r := http.Request{} + reqFunc(ctx, &r) + + token := r.Header.Get("Authorization") + if token != "" { + t.Error("authorization key should not exist in metadata") + } + + // Correct JWT Token is passed in the context + ctx = context.WithValue(context.Background(), JWTTokenContextKey, signedKey) + r = http.Request{Header: http.Header{}} + reqFunc(ctx, &r) + + token = r.Header.Get("Authorization") + expected := generateAuthHeaderFromToken(signedKey) + + if token != expected { + t.Errorf("Authorization header does not contain the expected JWT token; expected %s, got %s", expected, token) + } +} + +func TestToGRPCContext(t *testing.T) { + md := metadata.MD{} + reqFunc := ToGRPCContext() + + // No Authorization header is passed + ctx := reqFunc(context.Background(), &md) + token := ctx.Value(JWTTokenContextKey) + if token != nil { + t.Error("Context should not contain a JWT Token") + } + + // Invalid Authorization header is passed + md["authorization"] = []string{fmt.Sprintf("%s", signedKey)} + ctx = reqFunc(context.Background(), &md) + token = ctx.Value(JWTTokenContextKey) + if token != nil { + t.Error("Context should not contain a JWT Token") + } + + // Authorization header is correct + md["authorization"] = []string{fmt.Sprintf("Bearer %s", signedKey)} + ctx = reqFunc(context.Background(), &md) + token, ok := ctx.Value(JWTTokenContextKey).(string) + if !ok { + t.Fatal("JWT Token not passed to context correctly") + } + + if token != signedKey { + t.Errorf("JWT tokens did not match: expecting %s got %s", signedKey, token) + } +} + +func TestFromGRPCContext(t *testing.T) { + reqFunc := FromGRPCContext() + + // No JWT Token is passed in the context + ctx := context.Background() + md := metadata.MD{} + reqFunc(ctx, &md) + + _, ok := md["authorization"] + if ok { + t.Error("authorization key should not exist in metadata") + } + + // Correct JWT Token is passed in the context + ctx = context.WithValue(context.Background(), JWTTokenContextKey, signedKey) + md = metadata.MD{} + reqFunc(ctx, &md) + + token, ok := md["authorization"] + if !ok { + t.Fatal("JWT Token not passed to metadata correctly") + } + + if token[0] != generateAuthHeaderFromToken(signedKey) { + t.Errorf("JWT tokens did not match: expecting %s got %s", signedKey, token[0]) + } +} diff --git a/vendor/github.com/go-kit/kit/circuitbreaker/util_test.go b/vendor/github.com/go-kit/kit/circuitbreaker/util_test.go index 0039b6db..b5c0391b 100644 --- a/vendor/github.com/go-kit/kit/circuitbreaker/util_test.go +++ b/vendor/github.com/go-kit/kit/circuitbreaker/util_test.go @@ -40,7 +40,7 @@ func testFailingEndpoint( // Switch the endpoint to start throwing errors. m.err = errors.New("tragedy+disaster") - m.thru = 0 + m.through = 0 // The first several should be allowed through and yield our error. for i := 0; shouldPass(i); i++ { @@ -49,7 +49,7 @@ func testFailingEndpoint( } time.Sleep(requestDelay) } - thru := m.thru + through := m.through // But the rest should be blocked by an open circuit. for i := 0; i < 10; i++ { @@ -60,17 +60,17 @@ func testFailingEndpoint( } // Make sure none of those got through. - if want, have := thru, m.thru; want != have { + if want, have := through, m.through; want != have { t.Errorf("%s: want %d, have %d", caller, want, have) } } type mock struct { - thru int + through int err error } func (m *mock) endpoint(context.Context, interface{}) (interface{}, error) { - m.thru++ + m.through++ return struct{}{}, m.err } diff --git a/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go b/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go index 0e8cff5c..a685eef0 100644 --- a/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go +++ b/vendor/github.com/go-kit/kit/examples/addsvc/pb/addsvc.pb.go @@ -93,7 +93,7 @@ var _ grpc.ClientConn // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion3 +const _ = grpc.SupportPackageIsVersion4 // Client API for Add service @@ -193,13 +193,13 @@ var _Add_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: fileDescriptor0, + Metadata: "addsvc.proto", } func init() { proto.RegisterFile("addsvc.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 188 bytes of a gzipped FileDescriptorProto + // 189 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xe2, 0xe2, 0x49, 0x4c, 0x49, 0x29, 0x2e, 0x4b, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2a, 0x48, 0x52, 0xd2, 0xe0, 0xe2, 0x0a, 0x2e, 0xcd, 0x0d, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0xe2, 0xe1, 0x62, 0x4c, 0x94, @@ -208,8 +208,8 @@ var fileDescriptor0 = []byte{ 0x00, 0x17, 0x73, 0x6a, 0x51, 0x11, 0x58, 0x25, 0x67, 0x10, 0x88, 0xa9, 0xa4, 0xcd, 0xc5, 0xeb, 0x9c, 0x9f, 0x97, 0x9c, 0x58, 0x82, 0x61, 0x30, 0x27, 0x8a, 0xc1, 0x9c, 0x20, 0x83, 0x75, 0xb9, 0xb8, 0x61, 0x8a, 0x51, 0xcc, 0xe6, 0xc4, 0x6a, 0xb6, 0x51, 0x0c, 0x17, 0xb3, 0x63, 0x4a, 0x8a, - 0x90, 0x2a, 0x17, 0x33, 0xd0, 0x39, 0x42, 0x7c, 0x7a, 0x05, 0x49, 0x7a, 0x08, 0x1f, 0x48, 0xf1, - 0xc0, 0xf9, 0x40, 0xb3, 0x94, 0x18, 0x84, 0xf4, 0xb8, 0xd8, 0x20, 0x86, 0x0b, 0x09, 0x82, 0x64, - 0x50, 0x5c, 0x25, 0xc5, 0x8f, 0x2c, 0x04, 0x56, 0x9f, 0xc4, 0x06, 0x0e, 0x1a, 0x63, 0x40, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xdc, 0x37, 0x81, 0x99, 0x2a, 0x01, 0x00, 0x00, + 0x90, 0x2a, 0x17, 0x73, 0x70, 0x69, 0xae, 0x10, 0x9f, 0x5e, 0x41, 0x92, 0x1e, 0xc2, 0x07, 0x52, + 0x3c, 0x70, 0x7e, 0x41, 0x4e, 0xa5, 0x12, 0x83, 0x90, 0x1e, 0x17, 0x1b, 0xc4, 0x70, 0x21, 0x41, + 0x90, 0x0c, 0x8a, 0xab, 0xa4, 0xf8, 0x91, 0x85, 0xc0, 0xea, 0x93, 0xd8, 0xc0, 0x41, 0x63, 0x0c, + 0x08, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x37, 0x81, 0x99, 0x2a, 0x01, 0x00, 0x00, } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/README.md b/vendor/github.com/go-kit/kit/examples/shipping/README.md index cbcc4df9..1a9a14ee 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/README.md +++ b/vendor/github.com/go-kit/kit/examples/shipping/README.md @@ -16,7 +16,7 @@ The application consists of three application services, `booking`, `handling` an There are also a few pure domain packages that contain some intricate business-logic. They provide domain objects and services that are used by each application service to provide interesting use-cases for the user. -`repository` contains in-memory implementations for the repositories found in the domain packages. +`inmem` contains in-memory implementations for the repositories found in the domain packages. The `routing` package provides a _domain service_ that is used to query an external application for possible routes. diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go index b9864d2c..fe74955b 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/booking/endpoint.go @@ -6,6 +6,7 @@ import ( "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" + "github.com/go-kit/kit/examples/shipping/cargo" "github.com/go-kit/kit/examples/shipping/location" ) diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go index 85317964..b9b03b91 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/booking/instrumenting.go @@ -16,21 +16,21 @@ type instrumentingService struct { } // NewInstrumentingService returns an instance of an instrumenting Service. -func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.Histogram, s Service) Service { +func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service { return &instrumentingService{ - requestCount: requestCount, - requestLatency: requestLatency, + requestCount: counter, + requestLatency: latency, Service: s, } } -func (s *instrumentingService) BookNewCargo(origin, destination location.UNLocode, arrivalDeadline time.Time) (cargo.TrackingID, error) { +func (s *instrumentingService) BookNewCargo(origin, destination location.UNLocode, deadline time.Time) (cargo.TrackingID, error) { defer func(begin time.Time) { s.requestCount.With("method", "book").Add(1) s.requestLatency.With("method", "book").Observe(time.Since(begin).Seconds()) }(time.Now()) - return s.Service.BookNewCargo(origin, destination, arrivalDeadline) + return s.Service.BookNewCargo(origin, destination, deadline) } func (s *instrumentingService) LoadCargo(id cargo.TrackingID) (c Cargo, err error) { diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go index 3a04576d..931d4307 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/booking/logging.go @@ -3,9 +3,10 @@ package booking import ( "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/examples/shipping/cargo" "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/log" ) type loggingService struct { @@ -18,18 +19,18 @@ func NewLoggingService(logger log.Logger, s Service) Service { return &loggingService{logger, s} } -func (s *loggingService) BookNewCargo(origin location.UNLocode, destination location.UNLocode, arrivalDeadline time.Time) (id cargo.TrackingID, err error) { +func (s *loggingService) BookNewCargo(origin location.UNLocode, destination location.UNLocode, deadline time.Time) (id cargo.TrackingID, err error) { defer func(begin time.Time) { s.logger.Log( "method", "book", "origin", origin, "destination", destination, - "arrival_deadline", arrivalDeadline, + "arrival_deadline", deadline, "took", time.Since(begin), "err", err, ) }(time.Now()) - return s.Service.BookNewCargo(origin, destination, arrivalDeadline) + return s.Service.BookNewCargo(origin, destination, deadline) } func (s *loggingService) LoadCargo(id cargo.TrackingID) (c Cargo, err error) { diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/service.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/service.go index 47605f88..8689a5a5 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/service.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/booking/service.go @@ -18,21 +18,21 @@ var ErrInvalidArgument = errors.New("invalid argument") type Service interface { // BookNewCargo registers a new cargo in the tracking system, not yet // routed. - BookNewCargo(origin location.UNLocode, destination location.UNLocode, arrivalDeadline time.Time) (cargo.TrackingID, error) + BookNewCargo(origin location.UNLocode, destination location.UNLocode, deadline time.Time) (cargo.TrackingID, error) // LoadCargo returns a read model of a cargo. - LoadCargo(trackingID cargo.TrackingID) (Cargo, error) + LoadCargo(id cargo.TrackingID) (Cargo, error) // RequestPossibleRoutesForCargo requests a list of itineraries describing // possible routes for this cargo. - RequestPossibleRoutesForCargo(trackingID cargo.TrackingID) []cargo.Itinerary + RequestPossibleRoutesForCargo(id cargo.TrackingID) []cargo.Itinerary // AssignCargoToRoute assigns a cargo to the route specified by the // itinerary. - AssignCargoToRoute(trackingID cargo.TrackingID, itinerary cargo.Itinerary) error + AssignCargoToRoute(id cargo.TrackingID, itinerary cargo.Itinerary) error // ChangeDestination changes the destination of a cargo. - ChangeDestination(trackingID cargo.TrackingID, unLocode location.UNLocode) error + ChangeDestination(id cargo.TrackingID, destination location.UNLocode) error // Cargos returns a list of all cargos that have been booked. Cargos() []Cargo @@ -42,10 +42,10 @@ type Service interface { } type service struct { - cargoRepository cargo.Repository - locationRepository location.Repository - routingService routing.Service - handlingEventRepository cargo.HandlingEventRepository + cargos cargo.Repository + locations location.Repository + handlingEvents cargo.HandlingEventRepository + routingService routing.Service } func (s *service) AssignCargoToRoute(id cargo.TrackingID, itinerary cargo.Itinerary) error { @@ -53,22 +53,18 @@ func (s *service) AssignCargoToRoute(id cargo.TrackingID, itinerary cargo.Itiner return ErrInvalidArgument } - c, err := s.cargoRepository.Find(id) + c, err := s.cargos.Find(id) if err != nil { return err } c.AssignToRoute(itinerary) - if err := s.cargoRepository.Store(c); err != nil { - return err - } - - return nil + return s.cargos.Store(c) } -func (s *service) BookNewCargo(origin, destination location.UNLocode, arrivalDeadline time.Time) (cargo.TrackingID, error) { - if origin == "" || destination == "" || arrivalDeadline.IsZero() { +func (s *service) BookNewCargo(origin, destination location.UNLocode, deadline time.Time) (cargo.TrackingID, error) { + if origin == "" || destination == "" || deadline.IsZero() { return "", ErrInvalidArgument } @@ -76,29 +72,29 @@ func (s *service) BookNewCargo(origin, destination location.UNLocode, arrivalDea rs := cargo.RouteSpecification{ Origin: origin, Destination: destination, - ArrivalDeadline: arrivalDeadline, + ArrivalDeadline: deadline, } c := cargo.New(id, rs) - if err := s.cargoRepository.Store(c); err != nil { + if err := s.cargos.Store(c); err != nil { return "", err } return c.TrackingID, nil } -func (s *service) LoadCargo(trackingID cargo.TrackingID) (Cargo, error) { - if trackingID == "" { +func (s *service) LoadCargo(id cargo.TrackingID) (Cargo, error) { + if id == "" { return Cargo{}, ErrInvalidArgument } - c, err := s.cargoRepository.Find(trackingID) + c, err := s.cargos.Find(id) if err != nil { return Cargo{}, err } - return assemble(c, s.handlingEventRepository), nil + return assemble(c, s.handlingEvents), nil } func (s *service) ChangeDestination(id cargo.TrackingID, destination location.UNLocode) error { @@ -106,12 +102,12 @@ func (s *service) ChangeDestination(id cargo.TrackingID, destination location.UN return ErrInvalidArgument } - c, err := s.cargoRepository.Find(id) + c, err := s.cargos.Find(id) if err != nil { return err } - l, err := s.locationRepository.Find(destination) + l, err := s.locations.Find(destination) if err != nil { return err } @@ -122,7 +118,7 @@ func (s *service) ChangeDestination(id cargo.TrackingID, destination location.UN ArrivalDeadline: c.RouteSpecification.ArrivalDeadline, }) - if err := s.cargoRepository.Store(c); err != nil { + if err := s.cargos.Store(c); err != nil { return err } @@ -134,7 +130,7 @@ func (s *service) RequestPossibleRoutesForCargo(id cargo.TrackingID) []cargo.Iti return nil } - c, err := s.cargoRepository.Find(id) + c, err := s.cargos.Find(id) if err != nil { return []cargo.Itinerary{} } @@ -144,15 +140,15 @@ func (s *service) RequestPossibleRoutesForCargo(id cargo.TrackingID) []cargo.Iti func (s *service) Cargos() []Cargo { var result []Cargo - for _, c := range s.cargoRepository.FindAll() { - result = append(result, assemble(c, s.handlingEventRepository)) + for _, c := range s.cargos.FindAll() { + result = append(result, assemble(c, s.handlingEvents)) } return result } func (s *service) Locations() []Location { var result []Location - for _, v := range s.locationRepository.FindAll() { + for _, v := range s.locations.FindAll() { result = append(result, Location{ UNLocode: string(v.UNLocode), Name: v.Name, @@ -162,12 +158,12 @@ func (s *service) Locations() []Location { } // NewService creates a booking service with necessary dependencies. -func NewService(cr cargo.Repository, lr location.Repository, her cargo.HandlingEventRepository, rs routing.Service) Service { +func NewService(cargos cargo.Repository, locations location.Repository, events cargo.HandlingEventRepository, rs routing.Service) Service { return &service{ - cargoRepository: cr, - locationRepository: lr, - handlingEventRepository: her, - routingService: rs, + cargos: cargos, + locations: locations, + handlingEvents: events, + routingService: rs, } } @@ -188,7 +184,7 @@ type Cargo struct { TrackingID string `json:"tracking_id"` } -func assemble(c *cargo.Cargo, her cargo.HandlingEventRepository) Cargo { +func assemble(c *cargo.Cargo, events cargo.HandlingEventRepository) Cargo { return Cargo{ TrackingID: string(c.TrackingID), Origin: string(c.Origin), diff --git a/vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go b/vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go index 7cf59944..e4457737 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/booking/transport.go @@ -9,10 +9,11 @@ import ( "github.com/gorilla/mux" "golang.org/x/net/context" - "github.com/go-kit/kit/examples/shipping/cargo" - "github.com/go-kit/kit/examples/shipping/location" kitlog "github.com/go-kit/kit/log" kithttp "github.com/go-kit/kit/transport/http" + + "github.com/go-kit/kit/examples/shipping/cargo" + "github.com/go-kit/kit/examples/shipping/location" ) // MakeHandler returns a handler for the booking service. @@ -81,7 +82,6 @@ func MakeHandler(ctx context.Context, bs Service, logger kitlog.Logger) http.Han r.Handle("/booking/v1/cargos/{id}/assign_to_route", assignToRouteHandler).Methods("POST") r.Handle("/booking/v1/cargos/{id}/change_destination", changeDestinationHandler).Methods("POST") r.Handle("/booking/v1/locations", listLocationsHandler).Methods("GET") - r.Handle("/booking/v1/docs", http.StripPrefix("/booking/v1/docs", http.FileServer(http.Dir("booking/docs")))) return r } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go b/vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go index d4bb5f43..a9440f51 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/cargo/cargo.go @@ -57,7 +57,7 @@ func New(id TrackingID, rs RouteSpecification) *Cargo { // Repository provides access a cargo store. type Repository interface { Store(cargo *Cargo) error - Find(trackingID TrackingID) (*Cargo, error) + Find(id TrackingID) (*Cargo, error) FindAll() []*Cargo } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go b/vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go index 5f77bc4f..bec8509f 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/cargo/handling.go @@ -92,10 +92,10 @@ type HandlingEventFactory struct { } // CreateHandlingEvent creates a validated handling event. -func (f *HandlingEventFactory) CreateHandlingEvent(registrationTime time.Time, completionTime time.Time, trackingID TrackingID, +func (f *HandlingEventFactory) CreateHandlingEvent(registered time.Time, completed time.Time, id TrackingID, voyageNumber voyage.Number, unLocode location.UNLocode, eventType HandlingEventType) (HandlingEvent, error) { - if _, err := f.CargoRepository.Find(trackingID); err != nil { + if _, err := f.CargoRepository.Find(id); err != nil { return HandlingEvent{}, err } @@ -111,7 +111,7 @@ func (f *HandlingEventFactory) CreateHandlingEvent(registrationTime time.Time, c } return HandlingEvent{ - TrackingID: trackingID, + TrackingID: id, Activity: HandlingActivity{ Type: eventType, Location: unLocode, diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go index e10bddae..0ee3f222 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/handling/endpoint.go @@ -6,6 +6,7 @@ import ( "golang.org/x/net/context" "github.com/go-kit/kit/endpoint" + "github.com/go-kit/kit/examples/shipping/cargo" "github.com/go-kit/kit/examples/shipping/location" "github.com/go-kit/kit/examples/shipping/voyage" diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go index 065eca63..fecce04e 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/handling/instrumenting.go @@ -17,15 +17,15 @@ type instrumentingService struct { } // NewInstrumentingService returns an instance of an instrumenting Service. -func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.Histogram, s Service) Service { +func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service { return &instrumentingService{ - requestCount: requestCount, - requestLatency: requestLatency, + requestCount: counter, + requestLatency: latency, Service: s, } } -func (s *instrumentingService) RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyage voyage.Number, +func (s *instrumentingService) RegisterHandlingEvent(completed time.Time, id cargo.TrackingID, voyageNumber voyage.Number, loc location.UNLocode, eventType cargo.HandlingEventType) error { defer func(begin time.Time) { @@ -33,5 +33,5 @@ func (s *instrumentingService) RegisterHandlingEvent(completionTime time.Time, t s.requestLatency.With("method", "register_incident").Observe(time.Since(begin).Seconds()) }(time.Now()) - return s.Service.RegisterHandlingEvent(completionTime, trackingID, voyage, loc, eventType) + return s.Service.RegisterHandlingEvent(completed, id, voyageNumber, loc, eventType) } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go index 26457acd..84722fb4 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/handling/logging.go @@ -3,10 +3,11 @@ package handling import ( "time" + "github.com/go-kit/kit/log" + "github.com/go-kit/kit/examples/shipping/cargo" "github.com/go-kit/kit/examples/shipping/location" "github.com/go-kit/kit/examples/shipping/voyage" - "github.com/go-kit/kit/log" ) type loggingService struct { @@ -19,19 +20,19 @@ func NewLoggingService(logger log.Logger, s Service) Service { return &loggingService{logger, s} } -func (s *loggingService) RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyageNumber voyage.Number, +func (s *loggingService) RegisterHandlingEvent(completed time.Time, id cargo.TrackingID, voyageNumber voyage.Number, unLocode location.UNLocode, eventType cargo.HandlingEventType) (err error) { defer func(begin time.Time) { s.logger.Log( "method", "register_incident", - "tracking_id", trackingID, + "tracking_id", id, "location", unLocode, "voyage", voyageNumber, "event_type", eventType, - "completion_time", completionTime, + "completion_time", completed, "took", time.Since(begin), "err", err, ) }(time.Now()) - return s.Service.RegisterHandlingEvent(completionTime, trackingID, voyageNumber, unLocode, eventType) + return s.Service.RegisterHandlingEvent(completed, id, voyageNumber, unLocode, eventType) } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/service.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/service.go index f548f4c8..83d503a2 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/service.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/handling/service.go @@ -24,7 +24,7 @@ type EventHandler interface { type Service interface { // RegisterHandlingEvent registers a handling event in the system, and // notifies interested parties that a cargo has been handled. - RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyageNumber voyage.Number, + RegisterHandlingEvent(completed time.Time, id cargo.TrackingID, voyageNumber voyage.Number, unLocode location.UNLocode, eventType cargo.HandlingEventType) error } @@ -34,13 +34,13 @@ type service struct { handlingEventHandler EventHandler } -func (s *service) RegisterHandlingEvent(completionTime time.Time, trackingID cargo.TrackingID, voyage voyage.Number, +func (s *service) RegisterHandlingEvent(completed time.Time, id cargo.TrackingID, voyageNumber voyage.Number, loc location.UNLocode, eventType cargo.HandlingEventType) error { - if completionTime.IsZero() || trackingID == "" || loc == "" || eventType == cargo.NotHandled { + if completed.IsZero() || id == "" || loc == "" || eventType == cargo.NotHandled { return ErrInvalidArgument } - e, err := s.handlingEventFactory.CreateHandlingEvent(time.Now(), completionTime, trackingID, voyage, loc, eventType) + e, err := s.handlingEventFactory.CreateHandlingEvent(time.Now(), completed, id, voyageNumber, loc, eventType) if err != nil { return err } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go b/vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go index 1777ad61..e5d2c444 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/handling/transport.go @@ -8,11 +8,12 @@ import ( "github.com/gorilla/mux" "golang.org/x/net/context" + kitlog "github.com/go-kit/kit/log" + kithttp "github.com/go-kit/kit/transport/http" + "github.com/go-kit/kit/examples/shipping/cargo" "github.com/go-kit/kit/examples/shipping/location" "github.com/go-kit/kit/examples/shipping/voyage" - kitlog "github.com/go-kit/kit/log" - kithttp "github.com/go-kit/kit/transport/http" ) // MakeHandler returns a handler for the handling service. diff --git a/vendor/github.com/go-kit/kit/examples/shipping/repository/repositories.go b/vendor/github.com/go-kit/kit/examples/shipping/inmem/inmem.go similarity index 67% rename from vendor/github.com/go-kit/kit/examples/shipping/repository/repositories.go rename to vendor/github.com/go-kit/kit/examples/shipping/inmem/inmem.go index 714d0a8f..f941b7eb 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/repository/repositories.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/inmem/inmem.go @@ -1,5 +1,5 @@ -// Package repository provides implementations of all the domain repositories. -package repository +// Package inmem provides in-memory implementations of all the domain repositories. +package inmem import ( "sync" @@ -21,10 +21,10 @@ func (r *cargoRepository) Store(c *cargo.Cargo) error { return nil } -func (r *cargoRepository) Find(trackingID cargo.TrackingID) (*cargo.Cargo, error) { +func (r *cargoRepository) Find(id cargo.TrackingID) (*cargo.Cargo, error) { r.mtx.RLock() defer r.mtx.RUnlock() - if val, ok := r.cargos[trackingID]; ok { + if val, ok := r.cargos[id]; ok { return val, nil } return nil, cargo.ErrUnknown @@ -40,36 +40,36 @@ func (r *cargoRepository) FindAll() []*cargo.Cargo { return c } -// NewCargo returns a new instance of a in-memory cargo repository. -func NewCargo() cargo.Repository { +// NewCargoRepository returns a new instance of a in-memory cargo repository. +func NewCargoRepository() cargo.Repository { return &cargoRepository{ cargos: make(map[cargo.TrackingID]*cargo.Cargo), } } type locationRepository struct { - locations map[location.UNLocode]location.Location + locations map[location.UNLocode]*location.Location } -func (r *locationRepository) Find(locode location.UNLocode) (location.Location, error) { +func (r *locationRepository) Find(locode location.UNLocode) (*location.Location, error) { if l, ok := r.locations[locode]; ok { return l, nil } - return location.Location{}, location.ErrUnknown + return nil, location.ErrUnknown } -func (r *locationRepository) FindAll() []location.Location { - l := make([]location.Location, 0, len(r.locations)) +func (r *locationRepository) FindAll() []*location.Location { + l := make([]*location.Location, 0, len(r.locations)) for _, val := range r.locations { l = append(l, val) } return l } -// NewLocation returns a new instance of a in-memory location repository. -func NewLocation() location.Repository { +// NewLocationRepository returns a new instance of a in-memory location repository. +func NewLocationRepository() location.Repository { r := &locationRepository{ - locations: make(map[location.UNLocode]location.Location), + locations: make(map[location.UNLocode]*location.Location), } r.locations[location.SESTO] = location.Stockholm @@ -94,8 +94,8 @@ func (r *voyageRepository) Find(voyageNumber voyage.Number) (*voyage.Voyage, err return nil, voyage.ErrUnknown } -// NewVoyage returns a new instance of a in-memory voyage repository. -func NewVoyage() voyage.Repository { +// NewVoyageRepository returns a new instance of a in-memory voyage repository. +func NewVoyageRepository() voyage.Repository { r := &voyageRepository{ voyages: make(map[voyage.Number]*voyage.Voyage), } @@ -128,14 +128,14 @@ func (r *handlingEventRepository) Store(e cargo.HandlingEvent) { r.events[e.TrackingID] = append(r.events[e.TrackingID], e) } -func (r *handlingEventRepository) QueryHandlingHistory(trackingID cargo.TrackingID) cargo.HandlingHistory { +func (r *handlingEventRepository) QueryHandlingHistory(id cargo.TrackingID) cargo.HandlingHistory { r.mtx.RLock() defer r.mtx.RUnlock() - return cargo.HandlingHistory{HandlingEvents: r.events[trackingID]} + return cargo.HandlingHistory{HandlingEvents: r.events[id]} } -// NewHandlingEvent returns a new instance of a in-memory handling event repository. -func NewHandlingEvent() cargo.HandlingEventRepository { +// NewHandlingEventRepository returns a new instance of a in-memory handling event repository. +func NewHandlingEventRepository() cargo.HandlingEventRepository { return &handlingEventRepository{ events: make(map[cargo.TrackingID][]cargo.HandlingEvent), } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go b/vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go index a3f7147f..91cceb0d 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/inspection/inspection.go @@ -14,38 +14,38 @@ type Service interface { // InspectCargo inspects cargo and send relevant notifications to // interested parties, for example if a cargo has been misdirected, or // unloaded at the final destination. - InspectCargo(trackingID cargo.TrackingID) + InspectCargo(id cargo.TrackingID) } type service struct { - cargoRepository cargo.Repository - handlingEventRepository cargo.HandlingEventRepository - cargoEventHandler EventHandler + cargos cargo.Repository + events cargo.HandlingEventRepository + handler EventHandler } // TODO: Should be transactional -func (s *service) InspectCargo(trackingID cargo.TrackingID) { - c, err := s.cargoRepository.Find(trackingID) +func (s *service) InspectCargo(id cargo.TrackingID) { + c, err := s.cargos.Find(id) if err != nil { return } - h := s.handlingEventRepository.QueryHandlingHistory(trackingID) + h := s.events.QueryHandlingHistory(id) c.DeriveDeliveryProgress(h) if c.Delivery.IsMisdirected { - s.cargoEventHandler.CargoWasMisdirected(c) + s.handler.CargoWasMisdirected(c) } if c.Delivery.IsUnloadedAtDestination { - s.cargoEventHandler.CargoHasArrived(c) + s.handler.CargoHasArrived(c) } - s.cargoRepository.Store(c) + s.cargos.Store(c) } // NewService creates a inspection service with necessary dependencies. -func NewService(cargoRepository cargo.Repository, handlingEventRepository cargo.HandlingEventRepository, eventHandler EventHandler) Service { - return &service{cargoRepository, handlingEventRepository, eventHandler} +func NewService(cargos cargo.Repository, events cargo.HandlingEventRepository, handler EventHandler) Service { + return &service{cargos, events, handler} } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/location/location.go b/vendor/github.com/go-kit/kit/examples/shipping/location/location.go index 51293803..4a9d2f9f 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/location/location.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/location/location.go @@ -22,6 +22,6 @@ var ErrUnknown = errors.New("unknown location") // Repository provides access a location store. type Repository interface { - Find(locode UNLocode) (Location, error) - FindAll() []Location + Find(locode UNLocode) (*Location, error) + FindAll() []*Location } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go b/vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go index de0d4c10..7fd34efa 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/location/sample_locations.go @@ -15,13 +15,13 @@ var ( // Sample locations. var ( - Stockholm = Location{SESTO, "Stockholm"} - Melbourne = Location{AUMEL, "Melbourne"} - Hongkong = Location{CNHKG, "Hongkong"} - NewYork = Location{USNYC, "New York"} - Chicago = Location{USCHI, "Chicago"} - Tokyo = Location{JNTKO, "Tokyo"} - Hamburg = Location{DEHAM, "Hamburg"} - Rotterdam = Location{NLRTM, "Rotterdam"} - Helsinki = Location{FIHEL, "Helsinki"} + Stockholm = &Location{SESTO, "Stockholm"} + Melbourne = &Location{AUMEL, "Melbourne"} + Hongkong = &Location{CNHKG, "Hongkong"} + NewYork = &Location{USNYC, "New York"} + Chicago = &Location{USCHI, "Chicago"} + Tokyo = &Location{JNTKO, "Tokyo"} + Hamburg = &Location{DEHAM, "Hamburg"} + Rotterdam = &Location{NLRTM, "Rotterdam"} + Helsinki = &Location{FIHEL, "Helsinki"} ) diff --git a/vendor/github.com/go-kit/kit/examples/shipping/main.go b/vendor/github.com/go-kit/kit/examples/shipping/main.go index 3800cf14..4fbcd94b 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/main.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/main.go @@ -19,9 +19,9 @@ import ( "github.com/go-kit/kit/examples/shipping/booking" "github.com/go-kit/kit/examples/shipping/cargo" "github.com/go-kit/kit/examples/shipping/handling" + "github.com/go-kit/kit/examples/shipping/inmem" "github.com/go-kit/kit/examples/shipping/inspection" "github.com/go-kit/kit/examples/shipping/location" - "github.com/go-kit/kit/examples/shipping/repository" "github.com/go-kit/kit/examples/shipping/routing" "github.com/go-kit/kit/examples/shipping/tracking" ) @@ -50,10 +50,10 @@ func main() { logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) var ( - cargos = repository.NewCargo() - locations = repository.NewLocation() - voyages = repository.NewVoyage() - handlingEvents = repository.NewHandlingEvent() + cargos = inmem.NewCargoRepository() + locations = inmem.NewLocationRepository() + voyages = inmem.NewVoyageRepository() + handlingEvents = inmem.NewHandlingEventRepository() ) // Configure some questionable dependencies. @@ -74,7 +74,7 @@ func main() { fieldKeys := []string{"method"} var rs routing.Service - rs = routing.NewProxyingMiddleware(*routingServiceURL, ctx)(rs) + rs = routing.NewProxyingMiddleware(ctx, *routingServiceURL)(rs) var bs booking.Service bs = booking.NewService(cargos, locations, handlingEvents, rs) @@ -186,14 +186,18 @@ func storeTestData(r cargo.Repository) { Destination: location.SESTO, ArrivalDeadline: time.Now().AddDate(0, 0, 7), }) - _ = r.Store(test1) + if err := r.Store(test1); err != nil { + panic(err) + } test2 := cargo.New("ABC123", cargo.RouteSpecification{ Origin: location.SESTO, Destination: location.CNHKG, ArrivalDeadline: time.Now().AddDate(0, 0, 14), }) - _ = r.Store(test2) + if err := r.Store(test2); err != nil { + panic(err) + } } type serializedLogger struct { diff --git a/vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go b/vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go index 3051cafb..a53f265b 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/routing/proxying.go @@ -10,10 +10,11 @@ import ( "github.com/go-kit/kit/circuitbreaker" "github.com/go-kit/kit/endpoint" + kithttp "github.com/go-kit/kit/transport/http" + "github.com/go-kit/kit/examples/shipping/cargo" "github.com/go-kit/kit/examples/shipping/location" "github.com/go-kit/kit/examples/shipping/voyage" - kithttp "github.com/go-kit/kit/transport/http" ) type proxyService struct { @@ -56,7 +57,7 @@ func (s proxyService) FetchRoutesForSpecification(rs cargo.RouteSpecification) [ type ServiceMiddleware func(Service) Service // NewProxyingMiddleware returns a new instance of a proxying middleware. -func NewProxyingMiddleware(proxyURL string, ctx context.Context) ServiceMiddleware { +func NewProxyingMiddleware(ctx context.Context, proxyURL string) ServiceMiddleware { return func(next Service) Service { var e endpoint.Endpoint e = makeFetchRoutesEndpoint(ctx, proxyURL) diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go index c2016d21..f5dc018b 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/tracking/instrumenting.go @@ -13,10 +13,10 @@ type instrumentingService struct { } // NewInstrumentingService returns an instance of an instrumenting Service. -func NewInstrumentingService(requestCount metrics.Counter, requestLatency metrics.Histogram, s Service) Service { +func NewInstrumentingService(counter metrics.Counter, latency metrics.Histogram, s Service) Service { return &instrumentingService{ - requestCount: requestCount, - requestLatency: requestLatency, + requestCount: counter, + requestLatency: latency, Service: s, } } diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go index d5b92733..b0e360b2 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/tracking/service.go @@ -37,10 +37,10 @@ func (s *service) Track(id string) (Cargo, error) { } // NewService returns a new instance of the default Service. -func NewService(cargos cargo.Repository, handlingEvents cargo.HandlingEventRepository) Service { +func NewService(cargos cargo.Repository, events cargo.HandlingEventRepository) Service { return &service{ cargos: cargos, - handlingEvents: handlingEvents, + handlingEvents: events, } } @@ -71,7 +71,7 @@ type Event struct { Expected bool `json:"expected"` } -func assemble(c *cargo.Cargo, her cargo.HandlingEventRepository) Cargo { +func assemble(c *cargo.Cargo, events cargo.HandlingEventRepository) Cargo { return Cargo{ TrackingID: string(c.TrackingID), Origin: string(c.Origin), @@ -80,7 +80,7 @@ func assemble(c *cargo.Cargo, her cargo.HandlingEventRepository) Cargo { NextExpectedActivity: nextExpectedActivity(c), ArrivalDeadline: c.RouteSpecification.ArrivalDeadline, StatusText: assembleStatusText(c), - Events: assembleEvents(c, her), + Events: assembleEvents(c, events), } } @@ -129,8 +129,8 @@ func assembleStatusText(c *cargo.Cargo) string { } } -func assembleEvents(c *cargo.Cargo, r cargo.HandlingEventRepository) []Event { - h := r.QueryHandlingHistory(c.TrackingID) +func assembleEvents(c *cargo.Cargo, handlingEvents cargo.HandlingEventRepository) []Event { + h := handlingEvents.QueryHandlingHistory(c.TrackingID) var events []Event for _, e := range h.HandlingEvents { diff --git a/vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go b/vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go index 9cac1ecb..3cdb9b1d 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/tracking/transport.go @@ -8,9 +8,10 @@ import ( "github.com/gorilla/mux" "golang.org/x/net/context" - "github.com/go-kit/kit/examples/shipping/cargo" kitlog "github.com/go-kit/kit/log" kithttp "github.com/go-kit/kit/transport/http" + + "github.com/go-kit/kit/examples/shipping/cargo" ) // MakeHandler returns a handler for the tracking service. diff --git a/vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go b/vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go index 51b7a05e..751f5885 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/voyage/sample_voyages.go @@ -6,25 +6,25 @@ import "github.com/go-kit/kit/examples/shipping/location" var ( V100 = New("V100", Schedule{ []CarrierMovement{ - {DepartureLocation: location.Hongkong, ArrivalLocation: location.Tokyo}, - {DepartureLocation: location.Tokyo, ArrivalLocation: location.NewYork}, + {DepartureLocation: location.CNHKG, ArrivalLocation: location.JNTKO}, + {DepartureLocation: location.JNTKO, ArrivalLocation: location.USNYC}, }, }) V300 = New("V300", Schedule{ []CarrierMovement{ - {DepartureLocation: location.Tokyo, ArrivalLocation: location.Rotterdam}, - {DepartureLocation: location.Rotterdam, ArrivalLocation: location.Hamburg}, - {DepartureLocation: location.Hamburg, ArrivalLocation: location.Melbourne}, - {DepartureLocation: location.Melbourne, ArrivalLocation: location.Tokyo}, + {DepartureLocation: location.JNTKO, ArrivalLocation: location.NLRTM}, + {DepartureLocation: location.NLRTM, ArrivalLocation: location.DEHAM}, + {DepartureLocation: location.DEHAM, ArrivalLocation: location.AUMEL}, + {DepartureLocation: location.AUMEL, ArrivalLocation: location.JNTKO}, }, }) V400 = New("V400", Schedule{ []CarrierMovement{ - {DepartureLocation: location.Hamburg, ArrivalLocation: location.Stockholm}, - {DepartureLocation: location.Stockholm, ArrivalLocation: location.Helsinki}, - {DepartureLocation: location.Helsinki, ArrivalLocation: location.Hamburg}, + {DepartureLocation: location.DEHAM, ArrivalLocation: location.SESTO}, + {DepartureLocation: location.SESTO, ArrivalLocation: location.FIHEL}, + {DepartureLocation: location.FIHEL, ArrivalLocation: location.DEHAM}, }, }) ) diff --git a/vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go b/vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go index 57a70b09..37366af4 100644 --- a/vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go +++ b/vendor/github.com/go-kit/kit/examples/shipping/voyage/voyage.go @@ -29,8 +29,8 @@ type Schedule struct { // CarrierMovement is a vessel voyage from one location to another. type CarrierMovement struct { - DepartureLocation location.Location - ArrivalLocation location.Location + DepartureLocation location.UNLocode + ArrivalLocation location.UNLocode DepartureTime time.Time ArrivalTime time.Time } diff --git a/vendor/github.com/go-kit/kit/log/README.md b/vendor/github.com/go-kit/kit/log/README.md index 70e70a6a..2763f7f1 100644 --- a/vendor/github.com/go-kit/kit/log/README.md +++ b/vendor/github.com/go-kit/kit/log/README.md @@ -68,7 +68,7 @@ import ( ) func main() { - logger := kitlog.NewJSONLogger(log.NewSyncWriter(os.Stdout)) + logger := kitlog.NewJSONLogger(kitlog.NewSyncWriter(os.Stdout)) stdlog.SetOutput(kitlog.NewStdlibAdapter(logger)) stdlog.Print("I sure like pie") } diff --git a/vendor/github.com/go-kit/kit/metrics/doc.go b/vendor/github.com/go-kit/kit/metrics/doc.go index fa303376..0318ed8a 100644 --- a/vendor/github.com/go-kit/kit/metrics/doc.go +++ b/vendor/github.com/go-kit/kit/metrics/doc.go @@ -55,5 +55,6 @@ // influx n custom custom custom // prometheus n native native native // circonus 1 native native native +// pcp 1 native native native // package metrics diff --git a/vendor/github.com/go-kit/kit/metrics/expvar/expvar.go b/vendor/github.com/go-kit/kit/metrics/expvar/expvar.go index a76c9f03..dcb5d622 100644 --- a/vendor/github.com/go-kit/kit/metrics/expvar/expvar.go +++ b/vendor/github.com/go-kit/kit/metrics/expvar/expvar.go @@ -30,7 +30,7 @@ func (c *Counter) With(labelValues ...string) metrics.Counter { return c } // Add implements Counter. func (c *Counter) Add(delta float64) { c.f.Add(delta) } -// Gauge implements the gauge metric wtih an expvar float. +// Gauge implements the gauge metric with an expvar float. // Label values are not supported. type Gauge struct { f *expvar.Float diff --git a/vendor/github.com/go-kit/kit/metrics/influx/example_test.go b/vendor/github.com/go-kit/kit/metrics/influx/example_test.go new file mode 100644 index 00000000..1a5105ca --- /dev/null +++ b/vendor/github.com/go-kit/kit/metrics/influx/example_test.go @@ -0,0 +1,104 @@ +package influx + +import ( + "fmt" + "regexp" + + influxdb "github.com/influxdata/influxdb/client/v2" + + "github.com/go-kit/kit/log" +) + +func ExampleCounter() { + in := New(map[string]string{"a": "b"}, influxdb.BatchPointsConfig{}, log.NewNopLogger()) + counter := in.NewCounter("influx_counter") + counter.Add(10) + counter.With("error", "true").Add(1) + counter.With("error", "false").Add(2) + counter.Add(50) + + client := &bufWriter{} + in.WriteTo(client) + + expectedLines := []string{ + `(influx_counter,a=b count=60) [0-9]{19}`, + `(influx_counter,a=b,error=true count=1) [0-9]{19}`, + `(influx_counter,a=b,error=false count=2) [0-9]{19}`, + } + + if err := extractAndPrintMessage(expectedLines, client.buf.String()); err != nil { + fmt.Println(err.Error()) + } + + // Output: + // influx_counter,a=b count=60 + // influx_counter,a=b,error=true count=1 + // influx_counter,a=b,error=false count=2 +} + +func ExampleGauge() { + in := New(map[string]string{"a": "b"}, influxdb.BatchPointsConfig{}, log.NewNopLogger()) + gauge := in.NewGauge("influx_gauge") + gauge.Set(10) + gauge.With("error", "true").Set(2) + gauge.With("error", "true").Set(1) + gauge.With("error", "false").Set(2) + gauge.Set(50) + + client := &bufWriter{} + in.WriteTo(client) + + expectedLines := []string{ + `(influx_gauge,a=b value=50) [0-9]{19}`, + `(influx_gauge,a=b,error=true value=1) [0-9]{19}`, + `(influx_gauge,a=b,error=false value=2) [0-9]{19}`, + } + + if err := extractAndPrintMessage(expectedLines, client.buf.String()); err != nil { + fmt.Println(err.Error()) + } + + // Output: + // influx_gauge,a=b value=50 + // influx_gauge,a=b,error=true value=1 + // influx_gauge,a=b,error=false value=2 +} + +func ExampleHistogram() { + in := New(map[string]string{"foo": "alpha"}, influxdb.BatchPointsConfig{}, log.NewNopLogger()) + histogram := in.NewHistogram("influx_histogram") + histogram.Observe(float64(10)) + histogram.With("error", "true").Observe(float64(1)) + histogram.With("error", "false").Observe(float64(2)) + histogram.Observe(float64(50)) + + client := &bufWriter{} + in.WriteTo(client) + + expectedLines := []string{ + `(influx_histogram,foo=alpha p50=10,p90=50,p95=50,p99=50) [0-9]{19}`, + `(influx_histogram,error=true,foo=alpha p50=1,p90=1,p95=1,p99=1) [0-9]{19}`, + `(influx_histogram,error=false,foo=alpha p50=2,p90=2,p95=2,p99=2) [0-9]{19}`, + } + + if err := extractAndPrintMessage(expectedLines, client.buf.String()); err != nil { + fmt.Println(err.Error()) + } + + // Output: + // influx_histogram,foo=alpha p50=10,p90=50,p95=50,p99=50 + // influx_histogram,error=true,foo=alpha p50=1,p90=1,p95=1,p99=1 + // influx_histogram,error=false,foo=alpha p50=2,p90=2,p95=2,p99=2 +} + +func extractAndPrintMessage(expected []string, msg string) error { + for _, pattern := range expected { + re := regexp.MustCompile(pattern) + match := re.FindStringSubmatch(msg) + if len(match) != 2 { + return fmt.Errorf("Pattern not found! {%s} [%s]: %v\n", pattern, msg, match) + } + fmt.Println(match[1]) + } + return nil +} diff --git a/vendor/github.com/go-kit/kit/metrics/influx/influx.go b/vendor/github.com/go-kit/kit/metrics/influx/influx.go index 1d2ae7ab..0c555e11 100644 --- a/vendor/github.com/go-kit/kit/metrics/influx/influx.go +++ b/vendor/github.com/go-kit/kit/metrics/influx/influx.go @@ -10,6 +10,7 @@ import ( "github.com/go-kit/kit/log" "github.com/go-kit/kit/metrics" + "github.com/go-kit/kit/metrics/generic" "github.com/go-kit/kit/metrics/internal/lv" ) @@ -20,14 +21,13 @@ import ( // one data point per flush, with a "count" field that reflects all adds since // the last flush. Gauges are modeled as a timeseries with one data point per // flush, with a "value" field that reflects the current state of the gauge. -// Histograms are modeled as a timeseries with one data point per observation, -// with a "value" field that reflects each observation; use e.g. the HISTOGRAM -// aggregate function to compute histograms. +// Histograms are modeled as a timeseries with one data point per combination of tags, +// with a set of quantile fields that reflects the p50, p90, p95 & p99. // -// Influx tags are immutable, attached to the Influx object, and given to each -// metric at construction. Influx fields are mapped to Go kit label values, and -// may be mutated via With functions. Actual metric values are provided as -// fields with specific names depending on the metric. +// Influx tags are attached to the Influx object, can be given to each +// metric at construction and can be updated anytime via With function. Influx fields +// are mapped to Go kit label values directly by this collector. Actual metric +// values are provided as fields with specific names depending on the metric. // // All observations are collected in memory locally, and flushed on demand. type Influx struct { @@ -108,10 +108,10 @@ func (in *Influx) WriteTo(w BatchPointsWriter) (err error) { now := time.Now() in.counters.Reset().Walk(func(name string, lvs lv.LabelValues, values []float64) bool { - fields := fieldsFrom(lvs) - fields["count"] = sum(values) + tags := mergeTags(in.tags, lvs) var p *influxdb.Point - p, err = influxdb.NewPoint(name, in.tags, fields, now) + fields := map[string]interface{}{"count": sum(values)} + p, err = influxdb.NewPoint(name, tags, fields, now) if err != nil { return false } @@ -123,10 +123,10 @@ func (in *Influx) WriteTo(w BatchPointsWriter) (err error) { } in.gauges.Reset().Walk(func(name string, lvs lv.LabelValues, values []float64) bool { - fields := fieldsFrom(lvs) - fields["value"] = last(values) + tags := mergeTags(in.tags, lvs) var p *influxdb.Point - p, err = influxdb.NewPoint(name, in.tags, fields, now) + fields := map[string]interface{}{"value": last(values)} + p, err = influxdb.NewPoint(name, tags, fields, now) if err != nil { return false } @@ -138,16 +138,23 @@ func (in *Influx) WriteTo(w BatchPointsWriter) (err error) { } in.histograms.Reset().Walk(func(name string, lvs lv.LabelValues, values []float64) bool { - fields := fieldsFrom(lvs) - ps := make([]*influxdb.Point, len(values)) - for i, v := range values { - fields["value"] = v // overwrite each time - ps[i], err = influxdb.NewPoint(name, in.tags, fields, now) - if err != nil { - return false - } + histogram := generic.NewHistogram(name, 50) + tags := mergeTags(in.tags, lvs) + var p *influxdb.Point + for _, v := range values { + histogram.Observe(v) } - bp.AddPoints(ps) + fields := map[string]interface{}{ + "p50": histogram.Quantile(0.50), + "p90": histogram.Quantile(0.90), + "p95": histogram.Quantile(0.95), + "p99": histogram.Quantile(0.99), + } + p, err = influxdb.NewPoint(name, tags, fields, now) + if err != nil { + return false + } + bp.AddPoint(p) return true }) if err != nil { @@ -157,15 +164,14 @@ func (in *Influx) WriteTo(w BatchPointsWriter) (err error) { return w.Write(bp) } -func fieldsFrom(labelValues []string) map[string]interface{} { +func mergeTags(tags map[string]string, labelValues []string) map[string]string { if len(labelValues)%2 != 0 { - panic("fieldsFrom received a labelValues with an odd number of strings") + panic("mergeTags received a labelValues with an odd number of strings") } - fields := make(map[string]interface{}, len(labelValues)/2) for i := 0; i < len(labelValues); i += 2 { - fields[labelValues[i]] = labelValues[i+1] + tags[labelValues[i]] = labelValues[i+1] } - return fields + return tags } func sum(a []float64) float64 { diff --git a/vendor/github.com/go-kit/kit/metrics/influx/influx_test.go b/vendor/github.com/go-kit/kit/metrics/influx/influx_test.go index 32fb92af..b5d3df4e 100644 --- a/vendor/github.com/go-kit/kit/metrics/influx/influx_test.go +++ b/vendor/github.com/go-kit/kit/metrics/influx/influx_test.go @@ -11,7 +11,6 @@ import ( influxdb "github.com/influxdata/influxdb/client/v2" "github.com/go-kit/kit/log" - "github.com/go-kit/kit/metrics/generic" "github.com/go-kit/kit/metrics/teststat" ) @@ -49,18 +48,20 @@ func TestGauge(t *testing.T) { func TestHistogram(t *testing.T) { in := New(map[string]string{"foo": "alpha"}, influxdb.BatchPointsConfig{}, log.NewNopLogger()) - re := regexp.MustCompile(`influx_histogram,foo=alpha bar="beta",value=([0-9\.]+) [0-9]+`) + re := regexp.MustCompile(`influx_histogram,bar=beta,foo=alpha p50=([0-9\.]+),p90=([0-9\.]+),p95=([0-9\.]+),p99=([0-9\.]+) [0-9]+`) histogram := in.NewHistogram("influx_histogram").With("bar", "beta") quantiles := func() (float64, float64, float64, float64) { w := &bufWriter{} in.WriteTo(w) - h := generic.NewHistogram("h", 50) - matches := re.FindAllStringSubmatch(w.buf.String(), -1) - for _, match := range matches { - f, _ := strconv.ParseFloat(match[1], 64) - h.Observe(f) + match := re.FindStringSubmatch(w.buf.String()) + if len(match) != 5 { + t.Errorf("These are not the quantiles you're looking for: %v\n", match) } - return h.Quantile(0.50), h.Quantile(0.90), h.Quantile(0.95), h.Quantile(0.99) + var result [4]float64 + for i, q := range match[1:] { + result[i], _ = strconv.ParseFloat(q, 64) + } + return result[0], result[1], result[2], result[3] } if err := teststat.TestHistogram(histogram, quantiles, 0.01); err != nil { t.Fatal(err) diff --git a/vendor/github.com/go-kit/kit/metrics/pcp/pcp.go b/vendor/github.com/go-kit/kit/metrics/pcp/pcp.go new file mode 100644 index 00000000..a8887a06 --- /dev/null +++ b/vendor/github.com/go-kit/kit/metrics/pcp/pcp.go @@ -0,0 +1,125 @@ +package pcp + +import ( + "github.com/performancecopilot/speed" + + "github.com/go-kit/kit/metrics" +) + +// Reporter encapsulates a speed client. +type Reporter struct { + c *speed.PCPClient +} + +// NewReporter creates a new Reporter instance. The first parameter is the +// application name and is used to create the speed client. Hence it should be a +// valid speed parameter name and should not contain spaces or the path +// separator for your operating system. +func NewReporter(appname string) (*Reporter, error) { + c, err := speed.NewPCPClient(appname) + if err != nil { + return nil, err + } + + return &Reporter{c}, nil +} + +// Start starts the underlying speed client so it can start reporting registered +// metrics to your PCP installation. +func (r *Reporter) Start() { r.c.MustStart() } + +// Stop stops the underlying speed client so it can stop reporting registered +// metrics to your PCP installation. +func (r *Reporter) Stop() { r.c.MustStop() } + +// Counter implements metrics.Counter via a single dimensional speed.Counter. +type Counter struct { + c speed.Counter +} + +// NewCounter creates a new Counter. This requires a name parameter and can +// optionally take a couple of description strings, that are used to create the +// underlying speed.Counter and are reported by PCP. +func (r *Reporter) NewCounter(name string, desc ...string) (*Counter, error) { + c, err := speed.NewPCPCounter(0, name, desc...) + if err != nil { + return nil, err + } + + r.c.MustRegister(c) + return &Counter{c}, nil +} + +// With is a no-op. +func (c *Counter) With(labelValues ...string) metrics.Counter { return c } + +// Add increments Counter. speed.Counters only take int64, so delta is converted +// to int64 before observation. +func (c *Counter) Add(delta float64) { c.c.Inc(int64(delta)) } + +// Gauge implements metrics.Gauge via a single dimensional speed.Gauge. +type Gauge struct { + g speed.Gauge +} + +// NewGauge creates a new Gauge. This requires a name parameter and can +// optionally take a couple of description strings, that are used to create the +// underlying speed.Gauge and are reported by PCP. +func (r *Reporter) NewGauge(name string, desc ...string) (*Gauge, error) { + g, err := speed.NewPCPGauge(0, name, desc...) + if err != nil { + return nil, err + } + + r.c.MustRegister(g) + return &Gauge{g}, nil +} + +// With is a no-op. +func (g *Gauge) With(labelValues ...string) metrics.Gauge { return g } + +// Set sets the value of the gauge. +func (g *Gauge) Set(value float64) { g.g.Set(value) } + +// Add adds a value to the gauge. +func (g *Gauge) Add(value float64) { g.g.Inc(value) } + +// Histogram wraps a speed Histogram. +type Histogram struct { + h speed.Histogram +} + +// NewHistogram creates a new Histogram. The minimum observeable value is 0. The +// maximum observeable value is 3600000000 (3.6e9). +// +// The required parameters are a metric name, the minimum and maximum observable +// values, and a metric unit for the units of the observed values. +// +// Optionally, it can also take a couple of description strings. +func (r *Reporter) NewHistogram(name string, min, max int64, unit speed.MetricUnit, desc ...string) (*Histogram, error) { + h, err := speed.NewPCPHistogram(name, min, max, 5, unit, desc...) + if err != nil { + return nil, err + } + + r.c.MustRegister(h) + return &Histogram{h}, nil +} + +// With is a no-op. +func (h *Histogram) With(labelValues ...string) metrics.Histogram { return h } + +// Observe observes a value. +// +// This converts float64 value to int64 before observation, as the Histogram in +// speed is backed using codahale/hdrhistogram, which only observes int64 +// values. Additionally, the value is interpreted in the metric unit used to +// construct the histogram. +func (h *Histogram) Observe(value float64) { h.h.MustRecord(int64(value)) } + +// Mean returns the mean of the values observed so far by the Histogram. +func (h *Histogram) Mean() float64 { return h.h.Mean() } + +// Percentile returns a percentile value for the given percentile +// between 0 and 100 for all values observed by the histogram. +func (h *Histogram) Percentile(p float64) int64 { return h.h.Percentile(p) } diff --git a/vendor/github.com/go-kit/kit/metrics/pcp/pcp_test.go b/vendor/github.com/go-kit/kit/metrics/pcp/pcp_test.go new file mode 100644 index 00000000..ce847a10 --- /dev/null +++ b/vendor/github.com/go-kit/kit/metrics/pcp/pcp_test.go @@ -0,0 +1,72 @@ +package pcp + +import ( + "testing" + + "github.com/performancecopilot/speed" + + "github.com/go-kit/kit/metrics/teststat" +) + +func TestCounter(t *testing.T) { + r, err := NewReporter("test_counter") + if err != nil { + t.Fatal(err) + } + + counter, err := r.NewCounter("speed_counter") + if err != nil { + t.Fatal(err) + } + + counter = counter.With("label values", "not supported").(*Counter) + + value := func() float64 { f := counter.c.Val(); return float64(f) } + if err := teststat.TestCounter(counter, value); err != nil { + t.Fatal(err) + } +} + +func TestGauge(t *testing.T) { + r, err := NewReporter("test_gauge") + if err != nil { + t.Fatal(err) + } + + gauge, err := r.NewGauge("speed_gauge") + if err != nil { + t.Fatal(err) + } + + gauge = gauge.With("label values", "not supported").(*Gauge) + + value := func() float64 { f := gauge.g.Val(); return f } + if err := teststat.TestGauge(gauge, value); err != nil { + t.Fatal(err) + } +} + +func TestHistogram(t *testing.T) { + r, err := NewReporter("test_histogram") + if err != nil { + t.Fatal(err) + } + + histogram, err := r.NewHistogram("speed_histogram", 0, 3600000000, speed.OneUnit) + if err != nil { + t.Fatal(err) + } + + histogram = histogram.With("label values", "not supported").(*Histogram) + + quantiles := func() (float64, float64, float64, float64) { + p50 := float64(histogram.Percentile(50)) + p90 := float64(histogram.Percentile(90)) + p95 := float64(histogram.Percentile(95)) + p99 := float64(histogram.Percentile(99)) + return p50, p90, p95, p99 + } + if err := teststat.TestHistogram(histogram, quantiles, 0.01); err != nil { + t.Fatal(err) + } +} diff --git a/vendor/github.com/go-kit/kit/metrics/teststat/teststat.go b/vendor/github.com/go-kit/kit/metrics/teststat/teststat.go index 8ebfeb27..991f5c06 100644 --- a/vendor/github.com/go-kit/kit/metrics/teststat/teststat.go +++ b/vendor/github.com/go-kit/kit/metrics/teststat/teststat.go @@ -81,8 +81,13 @@ func TestHistogram(histogram metrics.Histogram, quantiles func() (p50, p90, p95, } var ( + // Count is the number of observations. Count = 12345 - Mean = 500 + + // Mean is the center of the normal distribution of observations. + Mean = 500 + + // Stdev of the normal distribution of observations. Stdev = 25 ) diff --git a/vendor/github.com/go-kit/kit/sd/etcd/integration_test.go b/vendor/github.com/go-kit/kit/sd/etcd/integration_test.go index e65840d7..e0fb3a7a 100644 --- a/vendor/github.com/go-kit/kit/sd/etcd/integration_test.go +++ b/vendor/github.com/go-kit/kit/sd/etcd/integration_test.go @@ -101,7 +101,7 @@ func TestIntegration(t *testing.T) { } // Verify test data no longer exists in etcd. - entries, err = client.GetEntries(key) + _, err = client.GetEntries(key) if err == nil { t.Fatalf("GetEntries(%q): expected error, got none", key) } diff --git a/vendor/github.com/go-kit/kit/sd/lb/retry.go b/vendor/github.com/go-kit/kit/sd/lb/retry.go index a933eeb0..1214a669 100644 --- a/vendor/github.com/go-kit/kit/sd/lb/retry.go +++ b/vendor/github.com/go-kit/kit/sd/lb/retry.go @@ -10,24 +10,76 @@ import ( "github.com/go-kit/kit/endpoint" ) +// RetryError is an error wrapper that is used by the retry mechanism. All +// errors returned by the retry mechanism via its endpoint will be RetryErrors. +type RetryError struct { + RawErrors []error // all errors encountered from endpoints directly + Final error // the final, terminating error +} + +func (e RetryError) Error() string { + var suffix string + if len(e.RawErrors) > 1 { + a := make([]string, len(e.RawErrors)-1) + for i := 0; i < len(e.RawErrors)-1; i++ { // last one is Final + a[i] = e.RawErrors[i].Error() + } + suffix = fmt.Sprintf(" (previously: %s)", strings.Join(a, "; ")) + } + return fmt.Sprintf("%v%s", e.Final, suffix) +} + +// Callback is a function that is given the current attempt count and the error +// received from the underlying endpoint. It should return whether the Retry +// function should continue trying to get a working endpoint, and a custom error +// if desired. The error message may be nil, but a true/false is always +// expected. In all cases, if the replacement error is supplied, the received +// error will be replaced in the calling context. +type Callback func(n int, received error) (keepTrying bool, replacement error) + // Retry wraps a service load balancer and returns an endpoint oriented load -// balancer for the specified service method. -// Requests to the endpoint will be automatically load balanced via the load -// balancer. Requests that return errors will be retried until they succeed, -// up to max times, or until the timeout is elapsed, whichever comes first. +// balancer for the specified service method. Requests to the endpoint will be +// automatically load balanced via the load balancer. Requests that return +// errors will be retried until they succeed, up to max times, or until the +// timeout is elapsed, whichever comes first. func Retry(max int, timeout time.Duration, b Balancer) endpoint.Endpoint { + return RetryWithCallback(timeout, b, maxRetries(max)) +} + +func maxRetries(max int) Callback { + return func(n int, err error) (keepTrying bool, replacement error) { + return n < max, nil + } +} + +func alwaysRetry(int, error) (keepTrying bool, replacement error) { + return true, nil +} + +// RetryWithCallback wraps a service load balancer and returns an endpoint +// oriented load balancer for the specified service method. Requests to the +// endpoint will be automatically load balanced via the load balancer. Requests +// that return errors will be retried until they succeed, up to max times, until +// the callback returns false, or until the timeout is elapsed, whichever comes +// first. +func RetryWithCallback(timeout time.Duration, b Balancer, cb Callback) endpoint.Endpoint { + if cb == nil { + cb = alwaysRetry + } if b == nil { panic("nil Balancer") } + return func(ctx context.Context, request interface{}) (response interface{}, err error) { var ( newctx, cancel = context.WithTimeout(ctx, timeout) responses = make(chan interface{}, 1) errs = make(chan error, 1) - a = []string{} + final RetryError ) defer cancel() - for i := 1; i <= max; i++ { + + for i := 1; ; i++ { go func() { e, err := b.Endpoint() if err != nil { @@ -45,13 +97,22 @@ func Retry(max int, timeout time.Duration, b Balancer) endpoint.Endpoint { select { case <-newctx.Done(): return nil, newctx.Err() + case response := <-responses: return response, nil + case err := <-errs: - a = append(a, err.Error()) + final.RawErrors = append(final.RawErrors, err) + keepTrying, replacement := cb(i, err) + if replacement != nil { + err = replacement + } + if !keepTrying { + final.Final = err + return nil, final + } continue } } - return nil, fmt.Errorf("retry attempts exceeded (%s)", strings.Join(a, "; ")) } } diff --git a/vendor/github.com/go-kit/kit/sd/lb/retry_test.go b/vendor/github.com/go-kit/kit/sd/lb/retry_test.go index 07b1afdb..238198a6 100644 --- a/vendor/github.com/go-kit/kit/sd/lb/retry_test.go +++ b/vendor/github.com/go-kit/kit/sd/lb/retry_test.go @@ -9,14 +9,14 @@ import ( "github.com/go-kit/kit/endpoint" "github.com/go-kit/kit/sd" - loadbalancer "github.com/go-kit/kit/sd/lb" + "github.com/go-kit/kit/sd/lb" ) func TestRetryMaxTotalFail(t *testing.T) { var ( endpoints = sd.FixedSubscriber{} // no endpoints - lb = loadbalancer.NewRoundRobin(endpoints) - retry = loadbalancer.Retry(999, time.Second, lb) // lots of retries + rr = lb.NewRoundRobin(endpoints) + retry = lb.Retry(999, time.Second, rr) // lots of retries ctx = context.Background() ) if _, err := retry(ctx, struct{}{}); err == nil { @@ -37,11 +37,11 @@ func TestRetryMaxPartialFail(t *testing.T) { 2: endpoints[2], } retries = len(endpoints) - 1 // not quite enough retries - lb = loadbalancer.NewRoundRobin(subscriber) + rr = lb.NewRoundRobin(subscriber) ctx = context.Background() ) - if _, err := loadbalancer.Retry(retries, time.Second, lb)(ctx, struct{}{}); err == nil { - t.Errorf("expected error, got none") + if _, err := lb.Retry(retries, time.Second, rr)(ctx, struct{}{}); err == nil { + t.Errorf("expected error two, got none") } } @@ -58,10 +58,10 @@ func TestRetryMaxSuccess(t *testing.T) { 2: endpoints[2], } retries = len(endpoints) // exactly enough retries - lb = loadbalancer.NewRoundRobin(subscriber) + rr = lb.NewRoundRobin(subscriber) ctx = context.Background() ) - if _, err := loadbalancer.Retry(retries, time.Second, lb)(ctx, struct{}{}); err != nil { + if _, err := lb.Retry(retries, time.Second, rr)(ctx, struct{}{}); err != nil { t.Error(err) } } @@ -71,7 +71,7 @@ func TestRetryTimeout(t *testing.T) { step = make(chan struct{}) e = func(context.Context, interface{}) (interface{}, error) { <-step; return struct{}{}, nil } timeout = time.Millisecond - retry = loadbalancer.Retry(999, timeout, loadbalancer.NewRoundRobin(sd.FixedSubscriber{0: e})) + retry = lb.Retry(999, timeout, lb.NewRoundRobin(sd.FixedSubscriber{0: e})) errs = make(chan error, 1) invoke = func() { _, err := retry(context.Background(), struct{}{}); errs <- err } ) @@ -88,3 +88,55 @@ func TestRetryTimeout(t *testing.T) { t.Errorf("wanted %v, got none", context.DeadlineExceeded) } } + +func TestAbortEarlyCustomMessage(t *testing.T) { + var ( + myErr = errors.New("aborting early") + cb = func(int, error) (bool, error) { return false, myErr } + endpoints = sd.FixedSubscriber{} // no endpoints + rr = lb.NewRoundRobin(endpoints) + retry = lb.RetryWithCallback(time.Second, rr, cb) // lots of retries + ctx = context.Background() + ) + _, err := retry(ctx, struct{}{}) + if want, have := myErr, err.(lb.RetryError).Final; want != have { + t.Errorf("want %v, have %v", want, have) + } +} + +func TestErrorPassedUnchangedToCallback(t *testing.T) { + var ( + myErr = errors.New("my custom error") + cb = func(_ int, err error) (bool, error) { + if want, have := myErr, err; want != have { + t.Errorf("want %v, have %v", want, have) + } + return false, nil + } + endpoint = func(ctx context.Context, request interface{}) (interface{}, error) { + return nil, myErr + } + endpoints = sd.FixedSubscriber{endpoint} // no endpoints + rr = lb.NewRoundRobin(endpoints) + retry = lb.RetryWithCallback(time.Second, rr, cb) // lots of retries + ctx = context.Background() + ) + _, err := retry(ctx, struct{}{}) + if want, have := myErr, err.(lb.RetryError).Final; want != have { + t.Errorf("want %v, have %v", want, have) + } +} + +func TestHandleNilCallback(t *testing.T) { + var ( + subscriber = sd.FixedSubscriber{ + func(context.Context, interface{}) (interface{}, error) { return struct{}{}, nil /* OK */ }, + } + rr = lb.NewRoundRobin(subscriber) + ctx = context.Background() + ) + retry := lb.RetryWithCallback(time.Second, rr, nil) + if _, err := retry(ctx, struct{}{}); err != nil { + t.Error(err) + } +} diff --git a/vendor/github.com/go-kit/kit/tracing/opentracing/grpc_test.go b/vendor/github.com/go-kit/kit/tracing/opentracing/grpc_test.go index 4f4d1c8a..657817a9 100644 --- a/vendor/github.com/go-kit/kit/tracing/opentracing/grpc_test.go +++ b/vendor/github.com/go-kit/kit/tracing/opentracing/grpc_test.go @@ -30,7 +30,7 @@ func TestTraceGRPCRequestRoundtrip(t *testing.T) { // The Span should not have changed. afterSpan := opentracing.SpanFromContext(afterCtx) if beforeSpan != afterSpan { - t.Errorf("Should not swap in a new span") + t.Error("Should not swap in a new span") } // No spans should have finished yet. diff --git a/vendor/github.com/go-kit/kit/tracing/opentracing/http.go b/vendor/github.com/go-kit/kit/tracing/opentracing/http.go index 742d8309..9c608f6e 100644 --- a/vendor/github.com/go-kit/kit/tracing/opentracing/http.go +++ b/vendor/github.com/go-kit/kit/tracing/opentracing/http.go @@ -21,7 +21,8 @@ func ToHTTPRequest(tracer opentracing.Tracer, logger log.Logger) kithttp.Request // Try to find a Span in the Context. if span := opentracing.SpanFromContext(ctx); span != nil { // Add standard OpenTracing tags. - ext.HTTPMethod.Set(span, req.URL.RequestURI()) + ext.HTTPMethod.Set(span, req.Method) + ext.HTTPUrl.Set(span, req.URL.String()) host, portString, err := net.SplitHostPort(req.URL.Host) if err == nil { ext.PeerHostname.Set(span, host) @@ -61,7 +62,10 @@ func FromHTTPRequest(tracer opentracing.Tracer, operationName string, logger log if err != nil && err != opentracing.ErrSpanContextNotFound { logger.Log("err", err) } + span = tracer.StartSpan(operationName, ext.RPCServerOption(wireContext)) + ext.HTTPMethod.Set(span, req.Method) + ext.HTTPUrl.Set(span, req.URL.String()) return opentracing.ContextWithSpan(ctx, span) } } diff --git a/vendor/github.com/go-kit/kit/tracing/opentracing/http_test.go b/vendor/github.com/go-kit/kit/tracing/opentracing/http_test.go index c08e5af9..359cba4c 100644 --- a/vendor/github.com/go-kit/kit/tracing/opentracing/http_test.go +++ b/vendor/github.com/go-kit/kit/tracing/opentracing/http_test.go @@ -2,9 +2,11 @@ package opentracing_test import ( "net/http" + "reflect" "testing" "github.com/opentracing/opentracing-go" + "github.com/opentracing/opentracing-go/ext" "github.com/opentracing/opentracing-go/mocktracer" "golang.org/x/net/context" @@ -23,14 +25,14 @@ func TestTraceHTTPRequestRoundtrip(t *testing.T) { beforeCtx := opentracing.ContextWithSpan(context.Background(), beforeSpan) toHTTPFunc := kitot.ToHTTPRequest(tracer, logger) - req, _ := http.NewRequest("GET", "http://test.biz/url", nil) + req, _ := http.NewRequest("GET", "http://test.biz/path", nil) // Call the RequestFunc. afterCtx := toHTTPFunc(beforeCtx, req) // The Span should not have changed. afterSpan := opentracing.SpanFromContext(afterCtx) if beforeSpan != afterSpan { - t.Errorf("Should not swap in a new span") + t.Error("Should not swap in a new span") } // No spans should have finished yet. @@ -62,3 +64,46 @@ func TestTraceHTTPRequestRoundtrip(t *testing.T) { t.Errorf("Want %q, have %q", want, have) } } + +func TestToHTTPRequestTags(t *testing.T) { + tracer := mocktracer.New() + span := tracer.StartSpan("to_inject").(*mocktracer.MockSpan) + defer span.Finish() + ctx := opentracing.ContextWithSpan(context.Background(), span) + req, _ := http.NewRequest("GET", "http://test.biz/path", nil) + + kitot.ToHTTPRequest(tracer, log.NewNopLogger())(ctx, req) + + expectedTags := map[string]interface{}{ + string(ext.HTTPMethod): "GET", + string(ext.HTTPUrl): "http://test.biz/path", + string(ext.PeerHostname): "test.biz", + } + if !reflect.DeepEqual(expectedTags, span.Tags()) { + t.Errorf("Want %q, have %q", expectedTags, span.Tags()) + } +} + +func TestFromHTTPRequestTags(t *testing.T) { + tracer := mocktracer.New() + parentSpan := tracer.StartSpan("to_extract").(*mocktracer.MockSpan) + defer parentSpan.Finish() + req, _ := http.NewRequest("GET", "http://test.biz/path", nil) + tracer.Inject(parentSpan.Context(), opentracing.TextMap, opentracing.HTTPHeadersCarrier(req.Header)) + + ctx := kitot.FromHTTPRequest(tracer, "op", log.NewNopLogger())(context.Background(), req) + opentracing.SpanFromContext(ctx).Finish() + + childSpan := tracer.FinishedSpans()[0] + expectedTags := map[string]interface{}{ + string(ext.HTTPMethod): "GET", + string(ext.HTTPUrl): "http://test.biz/path", + string(ext.SpanKind): ext.SpanKindRPCServerEnum, + } + if !reflect.DeepEqual(expectedTags, childSpan.Tags()) { + t.Errorf("Want %q, have %q", expectedTags, childSpan.Tags()) + } + if want, have := "op", childSpan.OperationName; want != have { + t.Errorf("Want %q, have %q", want, have) + } +} diff --git a/vendor/github.com/go-kit/kit/transport/http/err_test.go b/vendor/github.com/go-kit/kit/transport/http/err_test.go index 75a1838a..b0dd6f7b 100644 --- a/vendor/github.com/go-kit/kit/transport/http/err_test.go +++ b/vendor/github.com/go-kit/kit/transport/http/err_test.go @@ -47,7 +47,7 @@ func TestClientEndpointEncodeError(t *testing.T) { } } -func ExampleErrOutput() { +func ExampleErrorOutput() { sampleErr := errors.New("oh no, an error") err := httptransport.Error{Domain: httptransport.DomainDo, Err: sampleErr} fmt.Println(err) diff --git a/vendor/github.com/go-kit/kit/util/conn/manager_test.go b/vendor/github.com/go-kit/kit/util/conn/manager_test.go index 86bddbca..5e41b31b 100644 --- a/vendor/github.com/go-kit/kit/util/conn/manager_test.go +++ b/vendor/github.com/go-kit/kit/util/conn/manager_test.go @@ -26,7 +26,7 @@ func TestManager(t *testing.T) { t.Fatal("nil conn") } - // Write and check it went thru. + // Write and check it went through. if _, err := conn.Write([]byte{1, 2, 3}); err != nil { t.Fatal(err) } @@ -55,7 +55,7 @@ func TestManager(t *testing.T) { t.Fatal("conn remained nil") } - // Write and check it went thru. + // Write and check it went through. if _, err := conn.Write([]byte{4, 5}); err != nil { t.Fatal(err) } diff --git a/vendor/github.com/micromdm/scep/.gitignore b/vendor/github.com/micromdm/scep/.gitignore new file mode 100644 index 00000000..aa6018ae --- /dev/null +++ b/vendor/github.com/micromdm/scep/.gitignore @@ -0,0 +1,5 @@ +.DS_Store +cmd/scepserver/scepserver +cmd/scepclient/scepclient +build/ +vendor/ diff --git a/vendor/github.com/micromdm/scep/Dockerfile b/vendor/github.com/micromdm/scep/Dockerfile new file mode 100644 index 00000000..0aefb280 --- /dev/null +++ b/vendor/github.com/micromdm/scep/Dockerfile @@ -0,0 +1,9 @@ +FROM alpine:3.3 + +ENV SCEP_VERSION=0.1.0.0 +RUN apk --no-cache add curl && \ + curl -L https://github.com/micromdm/scep/releases/download/${SCEP_VERSION}/scep-linux-amd64 -o /scep && \ + chmod a+x /scep && \ + apk del curl + +CMD ["/scep"] diff --git a/vendor/github.com/micromdm/scep/LICENSE b/vendor/github.com/micromdm/scep/LICENSE new file mode 100644 index 00000000..9ad85793 --- /dev/null +++ b/vendor/github.com/micromdm/scep/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2016 Victor Vrantchan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/micromdm/scep/README.md b/vendor/github.com/micromdm/scep/README.md new file mode 100644 index 00000000..0c8e4f23 --- /dev/null +++ b/vendor/github.com/micromdm/scep/README.md @@ -0,0 +1,151 @@ +`scep` is a Simple Certificate Enrollment Protocol server and client + +# Installation +A binary release is available on the releases page. + +# Example +minimal example for both server and client +``` +# create a new CA +scepserver ca -init +# start server +scepserver -depot depot -port 2016 -challenge=secret + +# in a separate terminal window, run a client +# note, if the client.key doesn't exist, the client will create a new rsa private key. Must be in PEM format. +scepclient -private-key client.key -server-url=http://scep.groob.io:2016 -challenge=secret +``` +# Server Usage + +The default flags configure and run the scep server. +depot must be the path to a folder with `ca.pem` and `ca.key` files. + +If you don't already have a CA to use, you can create one using the `scep ca` subcommand. + +``` +Usage of ./cmd/scepserver/scepserver: + -challenge string + enforce a challenge password + -depot string + path to ca folder (default "depot") + -port string + port to listen on (default "8080") + -version + prints version information +``` + +`scep ca -init` to create a new CA and private key. + +``` +Usage of ./cmd/scepserver/scepserver ca: + -country string + country for CA cert (default "US") + -depot string + path to ca folder (default "depot") + -init + create a new CA + -key-password string + password to store rsa key + -keySize int + rsa key size (default 4096) + -organization string + organization for CA cert (default "scep-ca") + -years int + default CA years (default 10) +``` + +# Client Usage + +``` +Usage of scepclient: + -certificate string + certificate path, if there is no key, scepclient will create one + -challenge string + enforce a challenge password + -cn string + common name for certificate (default "scepclient") + -country string + country code in certificate (default "US") + -keySize int + rsa key size (default 2048) + -organization string + organization for cert (default "scep-client") + -private-key string + private key path, if there is no key, scepclient will create one + -server-url string + SCEP server url + -version + prints version information +``` + +# Docker +``` +docker pull micromdm/scep +# create CA +docker run -it --rm -v /path/to/ca/folder:/depot micromdm/scep ./scep ca -init + +# run +docker run -it --rm -v /path/to/ca/folder:/depot -p 8080:8080 micromdm/scep +``` + +# SCEP library + +``` +go get github.com/micromdm/scep/scep +``` + +For detailed usage, see [godoc](https://godoc.org/github.com/micromdm/scep/scep) + +Example: +``` +// read a request body containing SCEP message +body, err := ioutil.ReadAll(r.Body) +if err != nil { + // handle err +} + +// parse the SCEP message +msg, err := scep.ParsePKIMessage(body) +if err != nil { + // handle err +} + +// do something with msg +fmt.Println(msg.MessageType) + +// extract encrypted pkiEnvelope +err := msg.DecryptPKIEnvelope(CAcert, CAkey) +if err != nil { + // handle err +} + +// use the csr from decrypted PKCRS request +csr := msg.CSRReqMessage.CSR + +// create cert template +tmpl := &x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: csr.Subject, + NotBefore: time.Now().Add(-600).UTC(), + NotAfter: time.Now().AddDate(1, 0, 0).UTC(), + SubjectKeyId: id, + ExtKeyUsage: []x509.ExtKeyUsage{ + x509.ExtKeyUsageAny, + x509.ExtKeyUsageClientAuth, + }, +} + +// create a CertRep message from the original +certRep, err := msg.SignCSR(CAcert, CAkey, tmlp) +if err != nil { + // handle err +} + +// send response back +// w is a http.ResponseWriter +w.Write(certRep.Raw) +``` + +# Server library + +You can import the scep endpoint into another Go project. For an example take a look at `cmd/scep/main.go` diff --git a/vendor/github.com/micromdm/scep/client/scep.go b/vendor/github.com/micromdm/scep/client/scep.go new file mode 100644 index 00000000..3ccc7556 --- /dev/null +++ b/vendor/github.com/micromdm/scep/client/scep.go @@ -0,0 +1,100 @@ +package scepclient + +import ( + "bytes" + "errors" + "net/http" + "net/url" + + "github.com/go-kit/kit/endpoint" + httptransport "github.com/go-kit/kit/transport/http" + "github.com/micromdm/scep/server" + "golang.org/x/net/context" +) + +// Client implements the SCEP service and extra methods +type Client interface { + scepserver.Service + Supports(string) bool +} +type client struct { + getRemote endpoint.Endpoint + postRemote endpoint.Endpoint + capabilities []byte +} + +func (c *client) Supports(cap string) bool { + if len(c.capabilities) == 0 { + ctx := context.Background() + // try to retrieve caps + c.GetCACaps(ctx) + } + return bytes.Contains(c.capabilities, []byte(cap)) +} + +// NewClient returns a SCEP service that's backed by the provided Endpoint +func NewClient(baseURL string) Client { + scepURL, _ := url.Parse(baseURL) + httpc := http.DefaultClient + return &client{ + getRemote: httptransport.NewClient( + "GET", + scepURL, + scepserver.EncodeSCEPRequest, + scepserver.DecodeSCEPResponse, + httptransport.SetClient(httpc), + ).Endpoint(), + postRemote: httptransport.NewClient( + "POST", + scepURL, + scepserver.EncodeSCEPRequest, + scepserver.DecodeSCEPResponse, + httptransport.SetClient(httpc), + ).Endpoint(), + } +} + +func (c *client) GetCACaps(ctx context.Context) ([]byte, error) { + request := scepserver.SCEPRequest{ + Operation: "GetCACaps", + } + reply, err := c.getRemote(ctx, request) + if err != nil { + return nil, err + } + r := reply.(scepserver.SCEPResponse) + c.capabilities = r.Data + return r.Data, nil +} + +func (c *client) GetCACert(ctx context.Context) ([]byte, int, error) { + request := scepserver.SCEPRequest{ + Operation: "GetCACert", + } + reply, err := c.getRemote(ctx, request) + if err != nil { + return nil, 0, err + } + r := reply.(scepserver.SCEPResponse) + return r.Data, r.CACertNum, nil +} + +func (c *client) PKIOperation(ctx context.Context, data []byte) ([]byte, error) { + request := scepserver.SCEPRequest{ + Operation: "PKIOperation", + Message: data, + } + if c.Supports("POSTPKIOperation") { + reply, err := c.postRemote(ctx, request) + if err != nil { + return nil, err + } + r := reply.(scepserver.SCEPResponse) + return r.Data, nil + } + return nil, errors.New("no POSTPKIOperation support") +} + +func (c *client) GetNextCACert(ctx context.Context) ([]byte, error) { + panic("not implemented") +} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/cert.go b/vendor/github.com/micromdm/scep/cmd/scepclient/cert.go new file mode 100644 index 00000000..f4ae94d8 --- /dev/null +++ b/vendor/github.com/micromdm/scep/cmd/scepclient/cert.go @@ -0,0 +1,100 @@ +package main + +import ( + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "errors" + "fmt" + "io/ioutil" + "math/big" + "os" + "time" +) + +const ( + certificatePEMBlockType = "CERTIFICATE" +) + +func pemCert(derBytes []byte) []byte { + pemBlock := &pem.Block{ + Type: certificatePEMBlockType, + Headers: nil, + Bytes: derBytes, + } + out := pem.EncodeToMemory(pemBlock) + return out +} + +func loadOrSign(path string, priv *rsa.PrivateKey, csr *x509.CertificateRequest) (*x509.Certificate, error) { + file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) + if err != nil { + if os.IsExist(err) { + return loadPEMCertFromFile(path) + } + return nil, err + } + defer file.Close() + self, err := selfSign(priv, csr) + if err != nil { + return nil, err + } + pemBlock := &pem.Block{ + Type: certificatePEMBlockType, + Headers: nil, + Bytes: self.Raw, + } + if err = pem.Encode(file, pemBlock); err != nil { + return nil, err + } + return self, nil +} + +func selfSign(priv *rsa.PrivateKey, csr *x509.CertificateRequest) (*x509.Certificate, error) { + serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128) + serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) + if err != nil { + return nil, fmt.Errorf("failed to generate serial number: %s", err) + } + + notBefore := time.Now() + notAfter := notBefore.Add(time.Hour * 1) + template := x509.Certificate{ + SerialNumber: serialNumber, + Subject: pkix.Name{ + CommonName: "SCEP SIGNER", + Organization: csr.Subject.Organization, + }, + NotBefore: notBefore, + NotAfter: notAfter, + + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}, + BasicConstraintsValid: true, + } + + derBytes, err := x509.CreateCertificate(rand.Reader, &template, &template, &priv.PublicKey, priv) + if err != nil { + return nil, err + } + return x509.ParseCertificate(derBytes) +} + +func loadPEMCertFromFile(path string) (*x509.Certificate, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != certificatePEMBlockType { + return nil, errors.New("unmatched type or headers") + } + + return x509.ParseCertificate(pemBlock.Bytes) +} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/csr.go b/vendor/github.com/micromdm/scep/cmd/scepclient/csr.go new file mode 100644 index 00000000..1d0188bb --- /dev/null +++ b/vendor/github.com/micromdm/scep/cmd/scepclient/csr.go @@ -0,0 +1,99 @@ +package main + +import ( + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "errors" + "io/ioutil" + "os" +) + +const ( + csrPEMBlockType = "CERTIFICATE REQUEST" +) + +type csrOptions struct { + cn, org, country, ou, locality, province, challenge string + key *rsa.PrivateKey +} + +func loadOrMakeCSR(path string, opts *csrOptions) (*x509.CertificateRequest, error) { + file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) + if err != nil { + if os.IsExist(err) { + return loadCSRfromFile(path) + } + return nil, err + } + defer file.Close() + + csrBytes, err := newCSR(opts.key, opts.ou, opts.locality, opts.province, opts.country, opts.cn, opts.org) + if err != nil { + return nil, err + } + pemBlock := &pem.Block{ + Type: csrPEMBlockType, + Headers: nil, + Bytes: csrBytes, + } + if err := pem.Encode(file, pemBlock); err != nil { + return nil, err + } + return x509.ParseCertificateRequest(csrBytes) +} + +// create a CSR using the same parameters as Keychain Access would produce +func newCSR(priv *rsa.PrivateKey, ou string, locality string, province string, country string, cname, org string) ([]byte, error) { + subj := pkix.Name{ + CommonName: cname, + } + if len(org) > 0 { + subj.Organization = []string{org} + } + if len(ou) > 0 { + subj.OrganizationalUnit = []string{ou} + } + if len(province) > 0 { + subj.Province = []string{province} + } + if len(locality) > 0 { + subj.Locality = []string{locality} + } + if len(country) > 0 { + subj.Country = []string{country} + } + template := &x509.CertificateRequest{ + Subject: subj, + } + return x509.CreateCertificateRequest(rand.Reader, template, priv) +} + +// convert DER to PEM format +func pemCSR(derBytes []byte) []byte { + pemBlock := &pem.Block{ + Type: csrPEMBlockType, + Headers: nil, + Bytes: derBytes, + } + out := pem.EncodeToMemory(pemBlock) + return out +} + +// load PEM encoded CSR from file +func loadCSRfromFile(path string) (*x509.CertificateRequest, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("cannot find the next PEM formatted block") + } + if pemBlock.Type != csrPEMBlockType || len(pemBlock.Headers) != 0 { + return nil, errors.New("unmatched type or headers") + } + return x509.ParseCertificateRequest(pemBlock.Bytes) +} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/key.go b/vendor/github.com/micromdm/scep/cmd/scepclient/key.go new file mode 100644 index 00000000..b21c0b19 --- /dev/null +++ b/vendor/github.com/micromdm/scep/cmd/scepclient/key.go @@ -0,0 +1,70 @@ +package main + +import ( + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "encoding/pem" + "errors" + "io/ioutil" + "os" +) + +const ( + rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" +) + +// create a new RSA private key +func newRSAKey(bits int) (*rsa.PrivateKey, error) { + private, err := rsa.GenerateKey(rand.Reader, bits) + if err != nil { + return nil, err + } + return private, nil +} + +// load key if it exists or create a new one +func loadOrMakeKey(path string, rsaBits int) (*rsa.PrivateKey, error) { + file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0666) + if err != nil { + if os.IsExist(err) { + return loadKeyFromFile(path) + } + return nil, err + } + defer file.Close() + + // write key + priv, err := newRSAKey(rsaBits) + if err != nil { + return nil, err + } + privBytes := x509.MarshalPKCS1PrivateKey(priv) + pemBlock := &pem.Block{ + Type: rsaPrivateKeyPEMBlockType, + Headers: nil, + Bytes: privBytes, + } + if err = pem.Encode(file, pemBlock); err != nil { + return nil, err + } + return priv, nil +} + +// load a PEM private key from disk +func loadKeyFromFile(path string) (*rsa.PrivateKey, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != rsaPrivateKeyPEMBlockType { + return nil, errors.New("unmatched type or headers") + } + + return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) +} diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/release.sh b/vendor/github.com/micromdm/scep/cmd/scepclient/release.sh new file mode 100755 index 00000000..b9954f67 --- /dev/null +++ b/vendor/github.com/micromdm/scep/cmd/scepclient/release.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +VERSION="0.3.0.0" +NAME=scepclient +OUTPUT=../../build + +echo "Building $NAME version $VERSION" + +mkdir -p ${OUTPUT} + +build() { + echo -n "=> $1-$2: " + GOOS=$1 GOARCH=$2 go build -o ${OUTPUT}/$NAME-$1-$2 -ldflags "-X main.version=$VERSION -X main.gitHash=`git rev-parse HEAD`" ./*.go + du -h ${OUTPUT}/${NAME}-$1-$2 +} + +build "darwin" "amd64" +build "linux" "amd64" diff --git a/vendor/github.com/micromdm/scep/cmd/scepclient/scepclient.go b/vendor/github.com/micromdm/scep/cmd/scepclient/scepclient.go new file mode 100644 index 00000000..21160e7d --- /dev/null +++ b/vendor/github.com/micromdm/scep/cmd/scepclient/scepclient.go @@ -0,0 +1,256 @@ +package main + +import ( + "crypto/x509" + "errors" + "flag" + "fmt" + "github.com/micromdm/scep/client" + "github.com/micromdm/scep/scep" + "golang.org/x/net/context" + "io/ioutil" + "net/url" + "os" + "path/filepath" + "strings" + "unicode" +) + +// version info +var ( + version = "unreleased" + gitHash = "unknown" +) + +type runCfg struct { + dir string + csrPath string + keyPath string + keyBits int + selfSignPath string + certPath string + cn string + org string + ou string + locality string + province string + country string + challenge string + serverURL string +} + +func isAsciiPrintableTo(s string) int { + count := 0 + for _, r := range s { + count = count + 1 + if r > unicode.MaxLatin1 || !unicode.IsPrint(r) { + return count - 1 + } + } + return count - 1 +} + +func run(cfg runCfg) error { + key, err := loadOrMakeKey(cfg.keyPath, cfg.keyBits) + if err != nil { + return err + } + + opts := &csrOptions{ + cn: cfg.cn, + org: cfg.org, + country: strings.ToUpper(cfg.country), + ou: cfg.ou, + locality: cfg.locality, + province: cfg.province, + challenge: cfg.challenge, + key: key, + } + + csr, err := loadOrMakeCSR(cfg.csrPath, opts) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + var self *x509.Certificate + cert, err := loadPEMCertFromFile(cfg.certPath) + if err != nil { + if !os.IsNotExist(err) { + return err + } + s, err := loadOrSign(cfg.selfSignPath, key, csr) + if err != nil { + return err + } + self = s + } + + ctx := context.Background() + var client scepclient.Client + { + client = scepclient.NewClient(cfg.serverURL) + } + + resp, certNum, err := client.GetCACert(ctx) + if err != nil { + return err + } + var certs []*x509.Certificate + { + if certNum > 1 { + certs, err = scep.CACerts(resp) + if err != nil { + return err + } + if len(certs) < 1 { + return fmt.Errorf("no certificates returned") + } + } else { + certs, err = x509.ParseCertificates(resp) + if err != nil { + return err + } + } + } + + var signerCert *x509.Certificate + { + if cert != nil { + signerCert = cert + } else { + signerCert = self + } + } + + var msgType scep.MessageType + { + // TODO validate CA and set UpdateReq if needed + if cert != nil { + msgType = scep.RenewalReq + } else { + msgType = scep.PKCSReq + } + } + + tmpl := &scep.PKIMessage{ + MessageType: msgType, + Recipients: certs, + SignerKey: key, + SignerCert: signerCert, + } + + if cfg.challenge != "" && msgType == scep.PKCSReq { + tmpl.CSRReqMessage = &scep.CSRReqMessage{ + ChallengePassword: cfg.challenge, + } + } + + msg, err := scep.NewCSRRequest(csr, tmpl) + if err != nil { + return err + } + + respBytes, err := client.PKIOperation(ctx, msg.Raw) + if err != nil { + return fmt.Errorf("Server reply : " + string(respBytes[0:isAsciiPrintableTo(string(respBytes))])) + } + + respMsg, err := scep.ParsePKIMessage(respBytes) + if err != nil { + return fmt.Errorf("Server reply : " + string(respBytes[0:isAsciiPrintableTo(string(respBytes))])) + } + + if err := respMsg.DecryptPKIEnvelope(signerCert, key); err != nil { + fmt.Println("Server error : " + string(respBytes[0:isAsciiPrintableTo(string(respBytes))])) + os.Exit(1) + } + + respCert := respMsg.CertRepMessage.Certificate + if err := ioutil.WriteFile(cfg.certPath, pemCert(respCert.Raw), 0666); err != nil { + return err + } + + // remove self signer if used + if self != nil { + if err := os.Remove(cfg.selfSignPath); err != nil { + return err + } + } + + return nil +} + +func validateFlags(keyPath, serverURL string) error { + if keyPath == "" { + return errors.New("must specify private key path") + } + if serverURL == "" { + return errors.New("must specify server-url flag parameter") + } + _, err := url.Parse(serverURL) + if err != nil { + return fmt.Errorf("invalid server-url flag parameter %s", err) + } + return nil +} + +func main() { + // flags + var ( + flVersion = flag.Bool("version", false, "prints version information") + flServerURL = flag.String("server-url", "", "SCEP server url") + flChallengePassword = flag.String("challenge", "", "enforce a challenge password") + flPKeyPath = flag.String("private-key", "", "private key path, if there is no key, scepclient will create one") + flCertPath = flag.String("certificate", "", "certificate path, if there is no key, scepclient will create one") + flKeySize = flag.Int("keySize", 2048, "rsa key size") + flOrg = flag.String("organization", "scep-client", "organization for cert") + flCName = flag.String("cn", "scepclient", "common name for certificate") + flOU = flag.String("ou", "MDM", "organizational unit for certificate") + flLoc = flag.String("locality", "", "locality for certificate") + flProvince = flag.String("province", "", "province for certificate") + flCountry = flag.String("country", "US", "country code in certificate") + ) + flag.Parse() + + // print version information + if *flVersion { + fmt.Printf("scepclient - %v\n", version) + fmt.Printf("git revision - %v\n", gitHash) + os.Exit(0) + } + + if err := validateFlags(*flPKeyPath, *flServerURL); err != nil { + fmt.Println(err) + os.Exit(1) + } + + dir := filepath.Dir(*flPKeyPath) + csrPath := dir + "/csr.pem" + selfSignPath := dir + "/self.pem" + if *flCertPath == "" { + *flCertPath = dir + "/client.pem" + } + + cfg := runCfg{ + dir: dir, + csrPath: csrPath, + keyPath: *flPKeyPath, + keyBits: *flKeySize, + selfSignPath: selfSignPath, + certPath: *flCertPath, + cn: *flCName, + org: *flOrg, + country: *flCountry, + locality: *flLoc, + ou: *flOU, + province: *flProvince, + challenge: *flChallengePassword, + serverURL: *flServerURL, + } + + if err := run(cfg); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/vendor/github.com/micromdm/scep/cmd/scepserver/release.sh b/vendor/github.com/micromdm/scep/cmd/scepserver/release.sh new file mode 100755 index 00000000..64d85902 --- /dev/null +++ b/vendor/github.com/micromdm/scep/cmd/scepserver/release.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +VERSION="0.3.0.0" +NAME=scepserver +OUTPUT=../../build + +echo "Building $NAME version $VERSION" + +mkdir -p ${OUTPUT} + +build() { + echo -n "=> $1-$2: " + GOOS=$1 GOARCH=$2 go build -o ${OUTPUT}/$NAME-$1-$2 -ldflags "-X main.version=$VERSION -X main.gitHash=`git rev-parse HEAD`" ./*.go + du -h ${OUTPUT}/${NAME}-$1-$2 +} + +build "darwin" "amd64" +build "linux" "amd64" diff --git a/vendor/github.com/micromdm/scep/cmd/scepserver/scepserver.go b/vendor/github.com/micromdm/scep/cmd/scepserver/scepserver.go new file mode 100644 index 00000000..f26c62ac --- /dev/null +++ b/vendor/github.com/micromdm/scep/cmd/scepserver/scepserver.go @@ -0,0 +1,331 @@ +package main + +import ( + "crypto" + "crypto/rand" + "crypto/rsa" + "crypto/sha1" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/pem" + "errors" + "flag" + "fmt" + "math/big" + "net/http" + "os" + "os/signal" + "strconv" + "syscall" + "time" + + "github.com/go-kit/kit/log" + "github.com/micromdm/scep/depot" + "github.com/micromdm/scep/depot/file" + "github.com/micromdm/scep/server" + "golang.org/x/net/context" +) + +// version info +var ( + version = "unreleased" + gitHash = "unknown" +) + +func main() { + var caCMD = flag.NewFlagSet("ca", flag.ExitOnError) + { + if len(os.Args) >= 2 { + if os.Args[1] == "ca" { + status := caMain(caCMD) + os.Exit(status) + } + } + } + + //main flags + var ( + flVersion = flag.Bool("version", false, "prints version information") + flPort = flag.String("port", envString("SCEP_HTTP_LISTEN_PORT", "8080"), "port to listen on") + flDepotPath = flag.String("depot", envString("SCEP_FILE_DEPOT", "depot"), "path to ca folder") + // TODO : how to submit non string passwords? + flCAPass = flag.String("capass", envString("SCEP_CA_PASS", ""), "passwd for the ca.key") + flClDuration = flag.String("crtvalid", envString("SCEP_CERT_VALID", "365"), "validity for new client certificates in days") + flClAllowRenewal = flag.String("allowrenew", envString("SCEP_CERT_RENEW", "14"), "do not allow renewal until n days before expiry, set to 0 to always allow") + flChallengePassword = flag.String("challenge", envString("SCEP_CHALLENGE_PASSWORD", ""), "enforce a challenge password") + ) + flag.Usage = func() { + flag.PrintDefaults() + + fmt.Println("usage: scep [] []") + fmt.Println(" ca create/manage a CA") + fmt.Println("type --help to see usage for each subcommand") + } + flag.Parse() + + // print version information + if *flVersion { + fmt.Printf("scep - %v\n", version) + fmt.Printf("git revision - %v\n", gitHash) + os.Exit(0) + } + port := ":" + *flPort + ctx := context.Background() + + var logger log.Logger + { + logger = log.NewLogfmtLogger(os.Stderr) + logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC) + logger = log.NewContext(logger).With("caller", log.DefaultCaller) + } + + var err error + var depot depot.Depot // cert storage + { + depot, err = file.NewFileDepot(*flDepotPath) + if err != nil { + logger.Log("err", err) + os.Exit(1) + } + } + allowRenewal, err := strconv.Atoi(*flClAllowRenewal) + if err != nil { + logger.Log("No valid number for allowed renewal time : ", err) + os.Exit(1) + } + clientValidity, err := strconv.Atoi(*flClDuration) + if err != nil { + logger.Log("No valid number for client cert validity : ", err) + os.Exit(1) + } + var svc scepserver.Service // scep service + { + svcOptions := []scepserver.ServiceOption{ + scepserver.ChallengePassword(*flChallengePassword), + scepserver.CAKeyPassword([]byte(*flCAPass)), + scepserver.ClientValidity(clientValidity), + scepserver.AllowRenewal(allowRenewal), + } + svc, err = scepserver.NewService(depot, svcOptions...) + if err != nil { + logger.Log("err", err) + os.Exit(1) + } + svc = scepserver.NewLoggingService(log.NewContext(logger).With("component", "service"), svc) + } + + var h http.Handler // http handler + { + h = scepserver.ServiceHandler(ctx, svc, log.NewContext(logger).With("component", "http")) + } + + // start http server + errs := make(chan error, 2) + go func() { + logger.Log("transport", "http", "address", port, "msg", "listening") + errs <- http.ListenAndServe(port, h) + }() + go func() { + c := make(chan os.Signal) + signal.Notify(c, syscall.SIGINT) + errs <- fmt.Errorf("%s", <-c) + }() + + logger.Log("terminated", <-errs) +} + +func caMain(cmd *flag.FlagSet) int { + var ( + flDepotPath = cmd.String("depot", "depot", "path to ca folder") + flInit = cmd.Bool("init", false, "create a new CA") + flYears = cmd.Int("years", 10, "default CA years") + flKeySize = cmd.Int("keySize", 4096, "rsa key size") + flOrg = cmd.String("organization", "scep-ca", "organization for CA cert") + flPassword = cmd.String("key-password", "", "password to store rsa key") + flCountry = cmd.String("country", "US", "country for CA cert") + ) + cmd.Parse(os.Args[2:]) + if *flInit { + fmt.Println("Initializing new CA") + key, err := createKey(*flKeySize, []byte(*flPassword), *flDepotPath) + if err != nil { + fmt.Println(err) + return 1 + } + if err := createCertificateAuthority(key, *flYears, *flOrg, *flCountry, *flDepotPath); err != nil { + fmt.Println(err) + return 1 + } + } + + return 0 +} + +// create a key, save it to depot and return it for further usage. +func createKey(bits int, password []byte, depot string) (*rsa.PrivateKey, error) { + // create depot folder if missing + if err := os.MkdirAll(depot, 0755); err != nil { + return nil, err + } + name := depot + "/" + "ca.key" + file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0400) + if err != nil { + return nil, err + } + defer file.Close() + + // create RSA key and save as PEM file + key, err := rsa.GenerateKey(rand.Reader, bits) + if err != nil { + return nil, err + } + privPEMBlock, err := x509.EncryptPEMBlock( + rand.Reader, + rsaPrivateKeyPEMBlockType, + x509.MarshalPKCS1PrivateKey(key), + password, + x509.PEMCipher3DES, + ) + if err != nil { + return nil, err + } + if err := pem.Encode(file, privPEMBlock); err != nil { + os.Remove(name) + return nil, err + } + + return key, nil +} + +func createCertificateAuthority(key *rsa.PrivateKey, years int, organization string, country string, depot string) error { + var ( + authPkixName = pkix.Name{ + Country: nil, + Organization: nil, + OrganizationalUnit: []string{"SCEP CA"}, + Locality: nil, + Province: nil, + StreetAddress: nil, + PostalCode: nil, + SerialNumber: "", + CommonName: "", + } + // Build CA based on RFC5280 + authTemplate = x509.Certificate{ + SerialNumber: big.NewInt(1), + Subject: authPkixName, + // NotBefore is set to be 10min earlier to fix gap on time difference in cluster + NotBefore: time.Now().Add(-600).UTC(), + NotAfter: time.Time{}, + // Used for certificate signing only + KeyUsage: x509.KeyUsageCertSign, + + ExtKeyUsage: nil, + UnknownExtKeyUsage: nil, + + // activate CA + BasicConstraintsValid: true, + IsCA: true, + // Not allow any non-self-issued intermediate CA + MaxPathLen: 0, + + // 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey + // (excluding the tag, length, and number of unused bits) + // **SHOULD** be filled in later + SubjectKeyId: nil, + + // Subject Alternative Name + DNSNames: nil, + + PermittedDNSDomainsCritical: false, + PermittedDNSDomains: nil, + } + ) + + subjectKeyID, err := generateSubjectKeyID(&key.PublicKey) + if err != nil { + return err + } + authTemplate.SubjectKeyId = subjectKeyID + authTemplate.NotAfter = time.Now().AddDate(years, 0, 0).UTC() + authTemplate.Subject.Country = []string{country} + authTemplate.Subject.Organization = []string{organization} + crtBytes, err := x509.CreateCertificate(rand.Reader, &authTemplate, &authTemplate, &key.PublicKey, key) + if err != nil { + return err + } + + name := depot + "/" + "ca.pem" + file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0400) + if err != nil { + return err + } + defer file.Close() + + if _, err := file.Write(pemCert(crtBytes)); err != nil { + file.Close() + os.Remove(name) + return err + } + + return nil +} + +const ( + rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" + certificatePEMBlockType = "CERTIFICATE" +) + +// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. +type rsaPublicKey struct { + N *big.Int + E int +} + +// GenerateSubjectKeyID generates SubjectKeyId used in Certificate +// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey +func generateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { + var pubBytes []byte + var err error + switch pub := pub.(type) { + case *rsa.PublicKey: + pubBytes, err = asn1.Marshal(rsaPublicKey{ + N: pub.N, + E: pub.E, + }) + if err != nil { + return nil, err + } + default: + return nil, errors.New("only RSA public key is supported") + } + + hash := sha1.Sum(pubBytes) + + return hash[:], nil +} + +func pemCert(derBytes []byte) []byte { + pemBlock := &pem.Block{ + Type: certificatePEMBlockType, + Headers: nil, + Bytes: derBytes, + } + out := pem.EncodeToMemory(pemBlock) + return out +} + +func envString(key, def string) string { + if env := os.Getenv(key); env != "" { + return env + } + return def +} + +func envBool(key string) bool { + if env := os.Getenv(key); env == "true" { + return true + } + return false +} diff --git a/vendor/github.com/micromdm/scep/depot/bolt/depot.go b/vendor/github.com/micromdm/scep/depot/bolt/depot.go new file mode 100644 index 00000000..dd0190a3 --- /dev/null +++ b/vendor/github.com/micromdm/scep/depot/bolt/depot.go @@ -0,0 +1,161 @@ +package bolt + +import ( + "crypto/rsa" + "crypto/x509" + "fmt" + "math/big" + + "github.com/boltdb/bolt" +) + +// Depot implements a SCEP certifiacte store using boltdb. +// https://github.com/boltdb/bolt +type Depot struct { + *bolt.DB +} + +const certBucket = "scep_certificates" + +// NewBoltDepot creates a depot.Depot backed by BoltDB. +func NewBoltDepot(db *bolt.DB) (*Depot, error) { + err := db.Update(func(tx *bolt.Tx) error { + _, err := tx.CreateBucketIfNotExists([]byte(certBucket)) + if err != nil { + return fmt.Errorf("create bucket: %s", err) + } + return nil + }) + if err != nil { + return nil, err + } + return &Depot{db}, nil +} + +func (db *Depot) CA(pass []byte) ([]*x509.Certificate, *rsa.PrivateKey, error) { + chain := []*x509.Certificate{} + var key *rsa.PrivateKey + err := db.View(func(tx *bolt.Tx) error { + bucket := tx.Bucket([]byte(certBucket)) + if bucket == nil { + return fmt.Errorf("bucket %q not found!", certBucket) + } + // get ca_certificate + caCert := bucket.Get([]byte("ca_certificate")) + if caCert == nil { + return fmt.Errorf("no ca_certificate in bucket") + } + cert, err := x509.ParseCertificate(caCert) + if err != nil { + return err + } + chain = append(chain, cert) + + // get ca_key + caKey := bucket.Get([]byte("ca_key")) + if caKey == nil { + return fmt.Errorf("no ca_key in bucket") + } + key, err = x509.ParsePKCS1PrivateKey(caKey) + if err != nil { + return err + } + return nil + }) + if err != nil { + return nil, nil, err + } + return chain, key, err +} + +func (db *Depot) Put(cn string, crt *x509.Certificate) error { + if crt == nil || crt.Raw == nil { + return fmt.Errorf("%q does not specify a valid certificate for storage", cn) + } + serial, err := db.Serial() + if err != nil { + return err + } + err = db.Update(func(tx *bolt.Tx) error { + bucket := tx.Bucket([]byte(certBucket)) + if bucket == nil { + return fmt.Errorf("bucket %q not found!", certBucket) + } + name := cn + "." + serial.String() + return bucket.Put([]byte(name), crt.Raw) + }) + if err != nil { + return err + } + return db.incrementSerial(serial) +} + +func (db *Depot) Serial() (*big.Int, error) { + s := big.NewInt(2) + if !db.hasKey([]byte("serial")) { + if err := db.writeSerial(s); err != nil { + return nil, err + } + return s, nil + } + err := db.View(func(tx *bolt.Tx) error { + bucket := tx.Bucket([]byte(certBucket)) + if bucket == nil { + return fmt.Errorf("bucket %q not found!", certBucket) + } + k := bucket.Get([]byte("serial")) + if k == nil { + return fmt.Errorf("key %q not found", "serial") + } + s = s.SetBytes(k) + return nil + }) + if err != nil { + return nil, err + } + return s, nil +} + +func (db *Depot) writeSerial(s *big.Int) error { + err := db.Update(func(tx *bolt.Tx) error { + bucket := tx.Bucket([]byte(certBucket)) + if bucket == nil { + return fmt.Errorf("bucket %q not found!", certBucket) + } + return bucket.Put([]byte("serial"), []byte(s.Bytes())) + }) + return err +} + +func (db *Depot) hasKey(name []byte) bool { + var present bool + db.View(func(tx *bolt.Tx) error { + bucket := tx.Bucket([]byte(certBucket)) + if bucket == nil { + return fmt.Errorf("bucket %q not found!", certBucket) + } + k := bucket.Get([]byte("serial")) + if k != nil { + present = true + } + return nil + }) + return present +} + +func (db *Depot) incrementSerial(s *big.Int) error { + serial := s.Add(s, big.NewInt(1)) + err := db.Update(func(tx *bolt.Tx) error { + bucket := tx.Bucket([]byte(certBucket)) + if bucket == nil { + return fmt.Errorf("bucket %q not found!", certBucket) + } + return bucket.Put([]byte("serial"), []byte(serial.Bytes())) + }) + return err +} + +func (db *Depot) HasCN(cn string, allowTime int, cert *x509.Certificate, revokeOldCertificate bool) error { + // FIXME: not implemented. + return nil +} diff --git a/vendor/github.com/micromdm/scep/depot/bolt/depot_test.go b/vendor/github.com/micromdm/scep/depot/bolt/depot_test.go new file mode 100644 index 00000000..4e3b6fef --- /dev/null +++ b/vendor/github.com/micromdm/scep/depot/bolt/depot_test.go @@ -0,0 +1,108 @@ +package bolt + +import ( + "io/ioutil" + "math/big" + "os" + "reflect" + "testing" + + "github.com/boltdb/bolt" +) + +// createDepot creates a Bolt database in a temporary location. +func createDB(mode os.FileMode, options *bolt.Options) *Depot { + // Create temporary path. + f, _ := ioutil.TempFile("", "bolt-") + f.Close() + os.Remove(f.Name()) + + db, err := bolt.Open(f.Name(), mode, options) + if err != nil { + panic(err.Error()) + } + d, err := NewBoltDepot(db) + if err != nil { + panic(err.Error()) + } + return d +} + +func TestDepot_Serial(t *testing.T) { + db := createDB(0666, nil) + tests := []struct { + name string + want *big.Int + wantErr bool + }{ + { + name: "two is the default value.", + want: big.NewInt(2), + }, + } + for _, tt := range tests { + got, err := db.Serial() + if (err != nil) != tt.wantErr { + t.Errorf("%q. Depot.Serial() error = %v, wantErr %v", tt.name, err, tt.wantErr) + continue + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("%q. Depot.Serial() = %v, want %v", tt.name, got, tt.want) + } + } +} + +func TestDepot_writeSerial(t *testing.T) { + db := createDB(0666, nil) + type args struct { + s *big.Int + } + tests := []struct { + name string + args *big.Int + wantErr bool + }{ + { + args: big.NewInt(5), + }, + { + args: big.NewInt(3), + }, + } + for _, tt := range tests { + if err := db.writeSerial(tt.args); (err != nil) != tt.wantErr { + t.Errorf("%q. Depot.writeSerial() error = %v, wantErr %v", tt.name, err, tt.wantErr) + } + } +} + +func TestDepot_incrementSerial(t *testing.T) { + db := createDB(0666, nil) + type args struct { + s *big.Int + } + tests := []struct { + name string + args *big.Int + want *big.Int + wantErr bool + }{ + { + args: big.NewInt(2), + want: big.NewInt(3), + }, + { + args: big.NewInt(3), + want: big.NewInt(4), + }, + } + for _, tt := range tests { + if err := db.incrementSerial(tt.args); (err != nil) != tt.wantErr { + t.Errorf("%q. Depot.incrementSerial() error = %v, wantErr %v", tt.name, err, tt.wantErr) + } + got, _ := db.Serial() + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("%q. Depot.Serial() = %v, want %v", tt.name, got, tt.want) + } + } +} diff --git a/vendor/github.com/micromdm/scep/depot/depot.go b/vendor/github.com/micromdm/scep/depot/depot.go new file mode 100644 index 00000000..3b1b0ce0 --- /dev/null +++ b/vendor/github.com/micromdm/scep/depot/depot.go @@ -0,0 +1,15 @@ +package depot + +import ( + "crypto/rsa" + "crypto/x509" + "math/big" +) + +// Depot is a repository for managing certificates +type Depot interface { + CA(pass []byte) ([]*x509.Certificate, *rsa.PrivateKey, error) + Put(name string, crt *x509.Certificate) error + Serial() (*big.Int, error) + HasCN(cn string, allowTime int, cert *x509.Certificate, revokeOldCertificate bool) error +} diff --git a/vendor/github.com/micromdm/scep/depot/file/depot.go b/vendor/github.com/micromdm/scep/depot/file/depot.go new file mode 100644 index 00000000..7fb6d494 --- /dev/null +++ b/vendor/github.com/micromdm/scep/depot/file/depot.go @@ -0,0 +1,400 @@ +package file + +import ( + "bufio" + "bytes" + "crypto/rsa" + "crypto/x509" + "encoding/pem" + "errors" + "fmt" + "io" + "io/ioutil" + "math/big" + "os" + "path/filepath" + "strconv" + "strings" + "time" +) + +// NewFileDepot returns a new cert depot. +func NewFileDepot(path string) (*fileDepot, error) { + f, err := os.OpenFile(fmt.Sprintf("%s/index.txt", path), + os.O_RDONLY|os.O_CREATE, 0666) + if err != nil { + return nil, err + } + defer f.Close() + return &fileDepot{dirPath: path}, nil +} + +type fileDepot struct { + dirPath string +} + +func (d *fileDepot) CA(pass []byte) ([]*x509.Certificate, *rsa.PrivateKey, error) { + caPEM, err := d.getFile("ca.pem") + if err != nil { + return nil, nil, err + } + cert, err := loadCert(caPEM.Data) + if err != nil { + return nil, nil, err + } + keyPEM, err := d.getFile("ca.key") + if err != nil { + return nil, nil, err + } + key, err := loadKey(keyPEM.Data, pass) + if err != nil { + return nil, nil, err + } + return []*x509.Certificate{cert}, key, nil +} + +// file permissions +const ( + certPerm = 0444 + serialPerm = 0400 + dbPerm = 0600 +) + +// Put adds a certificate to the depot +func (d *fileDepot) Put(cn string, crt *x509.Certificate) error { + if crt == nil { + return errors.New("crt is nil") + } + if crt.Raw == nil { + return errors.New("data is nil") + } + data := crt.Raw + + if err := os.MkdirAll(d.dirPath, 0755); err != nil { + return err + } + + serial, err := d.Serial() + if err != nil { + return err + } + + name := d.path(cn) + "." + serial.String() + ".pem" + file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, certPerm) + if err != nil { + return err + } + defer file.Close() + + if _, err := file.Write(pemCert(data)); err != nil { + os.Remove(name) + return err + } + if err := d.writeDB(cn, serial, cn+"."+serial.String()+".pem", crt); err != nil { + // TODO : remove certificate in case of writeDB problems + return err + } + + if err := d.incrementSerial(serial); err != nil { + return err + } + + return nil +} + +func (d *fileDepot) Serial() (*big.Int, error) { + name := d.path("serial") + s := big.NewInt(2) + if err := d.check("serial"); err != nil { + // assuming it doesnt exist, create + if err := d.writeSerial(s); err != nil { + return nil, err + } + return s, nil + } + file, err := os.Open(name) + if err != nil { + return nil, err + } + defer file.Close() + r := bufio.NewReader(file) + data, err := r.ReadString('\r') + if err != nil && err != io.EOF { + return nil, err + } + data = strings.TrimSuffix(data, "\r") + data = strings.TrimSuffix(data, "\n") + serial, ok := s.SetString(data, 16) + if !ok { + return nil, errors.New("could not convert " + string(data) + " to serial number") + } + return serial, nil +} + +func makeOpenSSLTime(t time.Time) string { + y := (int(t.Year()) % 100) + validDate := fmt.Sprintf("%02d%02d%02d%02d%02d%02dZ", y, t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second()) + return validDate +} + +func makeDn(cert *x509.Certificate) string { + var dn bytes.Buffer + + if len(cert.Subject.Country) > 0 && len(cert.Subject.Country[0]) > 0 { + dn.WriteString("/C=" + cert.Subject.Country[0]) + } + if len(cert.Subject.Province) > 0 && len(cert.Subject.Province[0]) > 0 { + dn.WriteString("/ST=" + cert.Subject.Province[0]) + } + if len(cert.Subject.Locality) > 0 && len(cert.Subject.Locality[0]) > 0 { + dn.WriteString("/L=" + cert.Subject.Locality[0]) + } + if len(cert.Subject.Organization) > 0 && len(cert.Subject.Organization[0]) > 0 { + dn.WriteString("/O=" + cert.Subject.Organization[0]) + } + if len(cert.Subject.OrganizationalUnit) > 0 && len(cert.Subject.OrganizationalUnit[0]) > 0 { + dn.WriteString("/OU=" + cert.Subject.OrganizationalUnit[0]) + } + if len(cert.Subject.CommonName) > 0 { + dn.WriteString("/CN=" + cert.Subject.CommonName) + } + if len(cert.EmailAddresses) > 0 { + dn.WriteString("/emailAddress=" + cert.EmailAddresses[0]) + } + return dn.String() +} + +// Determine if the cadb already has a valid certificate with the same name +func (d *fileDepot) HasCN(cn string, allowTime int, cert *x509.Certificate, revokeOldCertificate bool) error { + + var addDB bytes.Buffer + var candidates map[string]string + candidates = make(map[string]string) + + dn := makeDn(cert) + + if err := os.MkdirAll(d.dirPath, 0755); err != nil { + return err + } + + name := d.path("index.txt") + file, err := os.Open(name) + if err != nil { + return err + } + defer file.Close() + + // Loop over index.txt, determine if a certificate is valid and can be revoked + // revoke certificate in DB if requested + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := scanner.Text() + if strings.HasSuffix(line, dn) { + // Removing revoked certificate from candidates, if any + if strings.HasPrefix(line, "R\t") { + entries := strings.Split(line, "\t") + serial := strings.ToUpper(entries[3]) + candidates[serial] = line + delete(candidates, serial) + addDB.WriteString(line + "\n") + // Test & add certificate candidates, if any + } else if strings.HasPrefix(line, "V\t") { + issueDate, err := strconv.Atoi(strings.Replace(strings.Split(line, "\t")[1], "Z", "", 1)) + if err != nil { + return errors.New("Could not get expiry date from ca db") + } + minimalRenewDate, err := strconv.Atoi(strings.Replace(makeOpenSSLTime(time.Now().AddDate(0, 0, allowTime).UTC()), "Z", "", 1)) + if err != nil { + return errors.New("Could not calculate expiry date") + } + entries := strings.Split(line, "\t") + serial := strings.ToUpper(entries[3]) + + // all non renewable certificates + if minimalRenewDate < issueDate && allowTime > 0 { + candidates[serial] = "no" + } else { + candidates[serial] = line + } + } + } else { + addDB.WriteString(line + "\n") + } + } + file.Close() + for key, value := range candidates { + if value == "no" { + return errors.New("DN " + dn + " already exists") + } + if revokeOldCertificate { + fmt.Println("Revoking certificate with serial " + key + " from DB. Recreation of CRL needed.") + entries := strings.Split(value, "\t") + addDB.WriteString("R\t" + entries[1] + "\t" + makeOpenSSLTime(time.Now()) + "\t" + strings.ToUpper(entries[3]) + "\t" + entries[4] + "\t" + entries[5] + "\n") + } + } + if err := scanner.Err(); err != nil { + return err + } + if revokeOldCertificate { + file, err := os.OpenFile(name, os.O_CREATE|os.O_RDWR, dbPerm) + if err != nil { + return err + } + if _, err := file.Write(addDB.Bytes()); err != nil { + return err + } + } + return nil +} + +func (d *fileDepot) writeDB(cn string, serial *big.Int, filename string, cert *x509.Certificate) error { + + var dbEntry bytes.Buffer + + // Revoke old certificate + if err := d.HasCN(cn, 0, cert, true); err != nil { + return err + } + if err := os.MkdirAll(d.dirPath, 0755); err != nil { + return err + } + name := d.path("index.txt") + + file, err := os.OpenFile(name, os.O_CREATE|os.O_RDWR|os.O_APPEND, dbPerm) + if err != nil { + return fmt.Errorf("could not append to "+name+" : %q\n", err.Error()) + } + defer file.Close() + + // Format of the caDB, see http://pki-tutorial.readthedocs.io/en/latest/cadb.html + // STATUSFLAG EXPIRATIONDATE REVOCATIONDATE(or emtpy) SERIAL_IN_HEX CERTFILENAME_OR_'unknown' Certificate_DN + + serialHex := strings.ToUpper(fmt.Sprintf("%x", cert.SerialNumber)) + + validDate := makeOpenSSLTime(cert.NotAfter) + + dn := makeDn(cert) + + // Valid + dbEntry.WriteString("V\t") + // Valid till + dbEntry.WriteString(validDate + "\t") + // Empty (not revoked) + dbEntry.WriteString("\t") + // Serial in Hex + dbEntry.WriteString(serialHex + "\t") + // Certificate file name + dbEntry.WriteString(filename + "\t") + // Certificate DN + dbEntry.WriteString(dn) + dbEntry.WriteString("\n") + + if _, err := file.Write(dbEntry.Bytes()); err != nil { + return err + } + return nil +} + +func (d *fileDepot) writeSerial(serial *big.Int) error { + if err := os.MkdirAll(d.dirPath, 0755); err != nil { + return err + } + name := d.path("serial") + os.Remove(name) + + file, err := os.OpenFile(name, os.O_WRONLY|os.O_CREATE|os.O_EXCL, serialPerm) + if err != nil { + return err + } + defer file.Close() + + if _, err := file.WriteString(fmt.Sprintf("%x\n", serial.Bytes())); err != nil { + os.Remove(name) + return err + } + return nil +} + +// read serial and increment +func (d *fileDepot) incrementSerial(s *big.Int) error { + serial := s.Add(s, big.NewInt(1)) + if err := d.writeSerial(serial); err != nil { + return err + } + return nil +} + +type file struct { + Info os.FileInfo + Data []byte +} + +func (d *fileDepot) check(path string) error { + name := d.path(path) + _, err := os.Stat(name) + if err != nil { + return err + } + return nil +} + +func (d *fileDepot) getFile(path string) (*file, error) { + if err := d.check(path); err != nil { + return nil, err + } + fi, err := os.Stat(d.path(path)) + if err != nil { + return nil, err + } + b, err := ioutil.ReadFile(d.path(path)) + return &file{fi, b}, err +} + +func (d *fileDepot) path(name string) string { + return filepath.Join(d.dirPath, name) +} + +const ( + rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" + certificatePEMBlockType = "CERTIFICATE" +) + +// load an encrypted private key from disk +func loadKey(data []byte, password []byte) (*rsa.PrivateKey, error) { + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != rsaPrivateKeyPEMBlockType { + return nil, errors.New("unmatched type or headers") + } + + b, err := x509.DecryptPEMBlock(pemBlock, password) + if err != nil { + return nil, err + } + return x509.ParsePKCS1PrivateKey(b) +} + +// load an encrypted private key from disk +func loadCert(data []byte) (*x509.Certificate, error) { + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != certificatePEMBlockType { + return nil, errors.New("unmatched type or headers") + } + + return x509.ParseCertificate(pemBlock.Bytes) +} + +func pemCert(derBytes []byte) []byte { + pemBlock := &pem.Block{ + Type: certificatePEMBlockType, + Headers: nil, + Bytes: derBytes, + } + out := pem.EncodeToMemory(pemBlock) + return out +} diff --git a/vendor/github.com/micromdm/scep/glide.lock b/vendor/github.com/micromdm/scep/glide.lock new file mode 100644 index 00000000..4c6ab5b6 --- /dev/null +++ b/vendor/github.com/micromdm/scep/glide.lock @@ -0,0 +1,21 @@ +hash: 16f973415fd1764dbff6c7a52c94861f25145139a5752c5180f8756f6391028d +updated: 2016-11-11T09:56:01.599837376-05:00 +imports: +- name: github.com/go-kit/kit + version: 6fb874ce59bb45b2f60ee3d289829db02142ecc6 + subpackages: + - endpoint + - log + - transport/http +- name: github.com/go-logfmt/logfmt + version: d4327190ff838312623b09bfeb50d7c93c8d9c1d +- name: github.com/go-stack/stack + version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82 +- name: github.com/kr/logfmt + version: b84e30acd515aadc4b783ad4ff83aff3299bdfe0 +- name: golang.org/x/net + version: 07b51741c1d6423d4a6abab1c49940ec09cb1aaf + subpackages: + - context + - context/ctxhttp +testImports: [] diff --git a/vendor/github.com/micromdm/scep/glide.yaml b/vendor/github.com/micromdm/scep/glide.yaml new file mode 100644 index 00000000..82343c96 --- /dev/null +++ b/vendor/github.com/micromdm/scep/glide.yaml @@ -0,0 +1,11 @@ +package: github.com/micromdm/scep +import: +- package: github.com/go-kit/kit + version: ^0.2.0 + subpackages: + - endpoint + - log + - transport/http +- package: golang.org/x/net + subpackages: + - context diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/.gitignore b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/.gitignore new file mode 100644 index 00000000..daf913b1 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/LICENSE b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/LICENSE new file mode 100644 index 00000000..75f32090 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/LICENSE @@ -0,0 +1,22 @@ +The MIT License (MIT) + +Copyright (c) 2015 Andrew Smith + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/README.md b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/README.md new file mode 100644 index 00000000..32f21593 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/README.md @@ -0,0 +1,10 @@ +# pkcs7 + +Original at https://github.com/fullsailor/pkcs7 +This package is internal to the scep repo and is meant to be replaced with the upstream version at a later time. + +[![GoDoc](https://godoc.org/github.com/fullsailor/pkcs7?status.svg)](https://godoc.org/github.com/fullsailor/pkcs7) + +pkcs7 implements parsing and creating signed and enveloped messages. + +- Documentation on [GoDoc](http://godoc.org/github.com/fullsailor/pkcs7) diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber.go new file mode 100644 index 00000000..45924baf --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber.go @@ -0,0 +1,228 @@ +package pkcs7 + +import ( + "bytes" + "errors" +) + +var encodeIndent = 0 + +type asn1Object interface { + EncodeTo(writer *bytes.Buffer) error +} + +type asn1Structured struct { + tagBytes []byte + content []asn1Object +} + +func (s asn1Structured) EncodeTo(out *bytes.Buffer) error { + //fmt.Printf("%s--> tag: % X\n", strings.Repeat("| ", encodeIndent), s.tagBytes) + encodeIndent++ + inner := new(bytes.Buffer) + for _, obj := range s.content { + err := obj.EncodeTo(inner) + if err != nil { + return err + } + } + encodeIndent-- + out.Write(s.tagBytes) + encodeLength(out, inner.Len()) + out.Write(inner.Bytes()) + return nil +} + +type asn1Primitive struct { + tagBytes []byte + length int + content []byte +} + +func (p asn1Primitive) EncodeTo(out *bytes.Buffer) error { + _, err := out.Write(p.tagBytes) + if err != nil { + return err + } + if err = encodeLength(out, p.length); err != nil { + return err + } + //fmt.Printf("%s--> tag: % X length: %d\n", strings.Repeat("| ", encodeIndent), p.tagBytes, p.length) + //fmt.Printf("%s--> content length: %d\n", strings.Repeat("| ", encodeIndent), len(p.content)) + out.Write(p.content) + + return nil +} + +func ber2der(ber []byte) ([]byte, error) { + if len(ber) == 0 { + return nil, errors.New("ber2der: input ber is empty") + } + //fmt.Printf("--> ber2der: Transcoding %d bytes\n", len(ber)) + out := new(bytes.Buffer) + + obj, _, err := readObject(ber, 0) + if err != nil { + return nil, err + } + obj.EncodeTo(out) + + // if offset < len(ber) { + // return nil, fmt.Errorf("ber2der: Content longer than expected. Got %d, expected %d", offset, len(ber)) + //} + + return out.Bytes(), nil +} + +// encodes lengths that are longer than 127 into string of bytes +func marshalLongLength(out *bytes.Buffer, i int) (err error) { + n := lengthLength(i) + + for ; n > 0; n-- { + err = out.WriteByte(byte(i >> uint((n-1)*8))) + if err != nil { + return + } + } + + return nil +} + +// computes the byte length of an encoded length value +func lengthLength(i int) (numBytes int) { + numBytes = 1 + for i > 255 { + numBytes++ + i >>= 8 + } + return +} + +// encodes the length in DER format +// If the length fits in 7 bits, the value is encoded directly. +// +// Otherwise, the number of bytes to encode the length is first determined. +// This number is likely to be 4 or less for a 32bit length. This number is +// added to 0x80. The length is encoded in big endian encoding follow after +// +// Examples: +// length | byte 1 | bytes n +// 0 | 0x00 | - +// 120 | 0x78 | - +// 200 | 0x81 | 0xC8 +// 500 | 0x82 | 0x01 0xF4 +// +func encodeLength(out *bytes.Buffer, length int) (err error) { + if length >= 128 { + l := lengthLength(length) + err = out.WriteByte(0x80 | byte(l)) + if err != nil { + return + } + err = marshalLongLength(out, length) + if err != nil { + return + } + } else { + err = out.WriteByte(byte(length)) + if err != nil { + return + } + } + return +} + +func readObject(ber []byte, offset int) (asn1Object, int, error) { + //fmt.Printf("\n====> Starting readObject at offset: %d\n\n", offset) + tagStart := offset + b := ber[offset] + offset++ + tag := b & 0x1F // last 5 bits + if tag == 0x1F { + tag = 0 + for ber[offset] >= 0x80 { + tag = tag*128 + ber[offset] - 0x80 + offset++ + } + tag = tag*128 + ber[offset] - 0x80 + offset++ + } + tagEnd := offset + + kind := b & 0x20 + /* + if kind == 0 { + fmt.Print("--> Primitive\n") + } else { + fmt.Print("--> Constructed\n") + } + */ + // read length + var length int + l := ber[offset] + offset++ + hack := 0 + if l > 0x80 { + numberOfBytes := (int)(l & 0x7F) + if numberOfBytes > 4 { // int is only guaranteed to be 32bit + return nil, 0, errors.New("ber2der: BER tag length too long") + } + if numberOfBytes == 4 && (int)(ber[offset]) > 0x7F { + return nil, 0, errors.New("ber2der: BER tag length is negative") + } + if 0x0 == (int)(ber[offset]) { + return nil, 0, errors.New("ber2der: BER tag length has leading zero") + } + //fmt.Printf("--> (compute length) indicator byte: %x\n", l) + //fmt.Printf("--> (compute length) length bytes: % X\n", ber[offset:offset+numberOfBytes]) + for i := 0; i < numberOfBytes; i++ { + length = length*256 + (int)(ber[offset]) + offset++ + } + } else if l == 0x80 { + // find length by searching content + markerIndex := bytes.LastIndex(ber[offset:], []byte{0x0, 0x0}) + if markerIndex == -1 { + return nil, 0, errors.New("ber2der: Invalid BER format") + } + length = markerIndex + hack = 2 + //fmt.Printf("--> (compute length) marker found at offset: %d\n", markerIndex+offset) + } else { + length = (int)(l) + } + + //fmt.Printf("--> length : %d\n", length) + contentEnd := offset + length + if contentEnd > len(ber) { + return nil, 0, errors.New("ber2der: BER tag length is more than available data") + } + //fmt.Printf("--> content start : %d\n", offset) + //fmt.Printf("--> content end : %d\n", contentEnd) + //fmt.Printf("--> content : % X\n", ber[offset:contentEnd]) + var obj asn1Object + if kind == 0 { + obj = asn1Primitive{ + tagBytes: ber[tagStart:tagEnd], + length: length, + content: ber[offset:contentEnd], + } + } else { + var subObjects []asn1Object + for offset < contentEnd { + var subObj asn1Object + var err error + subObj, offset, err = readObject(ber[:contentEnd], offset) + if err != nil { + return nil, 0, err + } + subObjects = append(subObjects, subObj) + } + obj = asn1Structured{ + tagBytes: ber[tagStart:tagEnd], + content: subObjects, + } + } + + return obj, contentEnd + hack, nil +} diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber_test.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber_test.go new file mode 100644 index 00000000..32dc88a4 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/ber_test.go @@ -0,0 +1,61 @@ +package pkcs7 + +import ( + "bytes" + "encoding/asn1" + "strings" + "testing" +) + +func TestBer2Der(t *testing.T) { + // indefinite length fixture + ber := []byte{0x30, 0x80, 0x02, 0x01, 0x01, 0x00, 0x00} + expected := []byte{0x30, 0x03, 0x02, 0x01, 0x01} + der, err := ber2der(ber) + if err != nil { + t.Fatalf("ber2der failed with error: %v", err) + } + if bytes.Compare(der, expected) != 0 { + t.Errorf("ber2der result did not match.\n\tExpected: % X\n\tActual: % X", expected, der) + } + + if der2, err := ber2der(der); err != nil { + t.Errorf("ber2der on DER bytes failed with error: %v", err) + } else { + if !bytes.Equal(der, der2) { + t.Error("ber2der is not idempotent") + } + } + var thing struct { + Number int + } + rest, err := asn1.Unmarshal(der, &thing) + if err != nil { + t.Errorf("Cannot parse resulting DER because: %v", err) + } else if len(rest) > 0 { + t.Errorf("Resulting DER has trailing data: % X", rest) + } +} + +func TestBer2Der_Negatives(t *testing.T) { + fixtures := []struct { + Input []byte + ErrorContains string + }{ + {[]byte{0x30, 0x85}, "length too long"}, + {[]byte{0x30, 0x84, 0x80, 0x0, 0x0, 0x0}, "length is negative"}, + {[]byte{0x30, 0x82, 0x0, 0x1}, "length has leading zero"}, + {[]byte{0x30, 0x80, 0x1, 0x2}, "Invalid BER format"}, + {[]byte{0x30, 0x03, 0x01, 0x02}, "length is more than available data"}, + } + + for _, fixture := range fixtures { + _, err := ber2der(fixture.Input) + if err == nil { + t.Errorf("No error thrown. Expected: %s", fixture.ErrorContains) + } + if !strings.Contains(err.Error(), fixture.ErrorContains) { + t.Errorf("Unexpected error thrown.\n\tExpected: /%s/\n\tActual: %s", fixture.ErrorContains, err.Error()) + } + } +} diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7.go new file mode 100644 index 00000000..82024d29 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7.go @@ -0,0 +1,788 @@ +// Package pkcs7 implements parsing and generation of some PKCS#7 structures. +package pkcs7 + +import ( + "bytes" + "crypto" + "crypto/aes" + "crypto/cipher" + "crypto/des" + "crypto/hmac" + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "errors" + "fmt" + "math/big" + "sort" + "time" + + _ "crypto/sha1" // for crypto.SHA1 +) + +// PKCS7 Represents a PKCS7 structure +type PKCS7 struct { + Content []byte + Certificates []*x509.Certificate + CRLs []pkix.CertificateList + Signers []signerInfo + raw interface{} +} + +type contentInfo struct { + ContentType asn1.ObjectIdentifier + Content asn1.RawValue `asn1:"explicit,optional,tag:0"` +} + +// ErrUnsupportedContentType is returned when a PKCS7 content is not supported. +// Currently only Data (1.2.840.113549.1.7.1), Signed Data (1.2.840.113549.1.7.2), +// and Enveloped Data are supported (1.2.840.113549.1.7.3) +var ErrUnsupportedContentType = errors.New("pkcs7: cannot parse data: unimplemented content type") + +type unsignedData []byte + +var ( + oidData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 1} + oidSignedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 2} + oidEnvelopedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 3} + oidSignedAndEnvelopedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 4} + oidDigestedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 5} + oidEncryptedData = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 7, 6} + oidAttributeContentType = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 3} + oidAttributeMessageDigest = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 4} + oidAttributeSigningTime = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 5} +) + +type signedData struct { + Version int `asn1:"default:1"` + DigestAlgorithmIdentifiers []pkix.AlgorithmIdentifier `asn1:"set"` + ContentInfo contentInfo + Certificates rawCertificates `asn1:"optional,tag:0"` + CRLs []pkix.CertificateList `asn1:"optional,tag:1"` + SignerInfos []signerInfo `asn1:"set"` +} + +type rawCertificates struct { + Raw asn1.RawContent +} + +type envelopedData struct { + Version int + RecipientInfos []recipientInfo `asn1:"set"` + EncryptedContentInfo encryptedContentInfo +} + +type recipientInfo struct { + Version int + IssuerAndSerialNumber issuerAndSerial + KeyEncryptionAlgorithm pkix.AlgorithmIdentifier + EncryptedKey []byte +} + +type encryptedContentInfo struct { + ContentType asn1.ObjectIdentifier + ContentEncryptionAlgorithm pkix.AlgorithmIdentifier + EncryptedContent asn1.RawValue `asn1:"tag:0,optional,explicit"` +} + +type attribute struct { + Type asn1.ObjectIdentifier + Value asn1.RawValue `asn1:"set"` +} + +type issuerAndSerial struct { + IssuerName asn1.RawValue + SerialNumber *big.Int +} + +// MessageDigestMismatchError is returned when the signer data digest does not +// match the computed digest for the contained content +type MessageDigestMismatchError struct { + ExpectedDigest []byte + ActualDigest []byte +} + +func (err *MessageDigestMismatchError) Error() string { + return fmt.Sprintf("pkcs7: Message digest mismatch\n\tExpected: %X\n\tActual : %X", err.ExpectedDigest, err.ActualDigest) +} + +type signerInfo struct { + Version int `asn1:"default:1"` + IssuerAndSerialNumber issuerAndSerial + DigestAlgorithm pkix.AlgorithmIdentifier + AuthenticatedAttributes []attribute `asn1:"optional,tag:0"` + DigestEncryptionAlgorithm pkix.AlgorithmIdentifier + EncryptedDigest []byte + UnauthenticatedAttributes []attribute `asn1:"optional,tag:1"` +} + +// Parse decodes a DER encoded PKCS7 package +func Parse(data []byte) (p7 *PKCS7, err error) { + if len(data) == 0 { + return nil, errors.New("pkcs7: input data is empty") + } + var info contentInfo + der, err := ber2der(data) + if err != nil { + return nil, err + } + rest, err := asn1.Unmarshal(der, &info) + if len(rest) > 0 { + err = asn1.SyntaxError{Msg: "trailing data"} + return + } + if err != nil { + return + } + + // fmt.Printf("--> Content Type: %s", info.ContentType) + switch { + case info.ContentType.Equal(oidSignedData): + return parseSignedData(info.Content.Bytes) + case info.ContentType.Equal(oidEnvelopedData): + return parseEnvelopedData(info.Content.Bytes) + } + return nil, ErrUnsupportedContentType +} + +func parseSignedData(data []byte) (*PKCS7, error) { + var sd signedData + asn1.Unmarshal(data, &sd) + certs, err := sd.Certificates.Parse() + if err != nil { + return nil, err + } + // fmt.Printf("--> Signed Data Version %d\n", sd.Version) + + var compound asn1.RawValue + var content unsignedData + + // The Content.Bytes maybe empty on PKI responses. + if len(sd.ContentInfo.Content.Bytes) > 0 { + if _, err := asn1.Unmarshal(sd.ContentInfo.Content.Bytes, &compound); err != nil { + return nil, err + } + } + // Compound octet string + if compound.IsCompound { + if _, err = asn1.Unmarshal(compound.Bytes, &content); err != nil { + return nil, err + } + } else { + // assuming this is tag 04 + content = compound.Bytes + } + return &PKCS7{ + Content: content, + Certificates: certs, + CRLs: sd.CRLs, + Signers: sd.SignerInfos, + raw: sd}, nil +} + +func (raw rawCertificates) Parse() ([]*x509.Certificate, error) { + if len(raw.Raw) == 0 { + return nil, nil + } + + var val asn1.RawValue + if _, err := asn1.Unmarshal(raw.Raw, &val); err != nil { + return nil, err + } + + return x509.ParseCertificates(val.Bytes) +} + +func parseEnvelopedData(data []byte) (*PKCS7, error) { + var ed envelopedData + if _, err := asn1.Unmarshal(data, &ed); err != nil { + return nil, err + } + return &PKCS7{ + raw: ed, + }, nil +} + +// Verify checks the signatures of a PKCS7 object +// WARNING: Verify does not check signing time or verify certificate chains at +// this time. +func (p7 *PKCS7) Verify() (err error) { + if len(p7.Signers) == 0 { + return errors.New("pkcs7: Message has no signers") + } + for _, signer := range p7.Signers { + if err := verifySignature(p7, signer); err != nil { + return err + } + } + return nil +} + +func verifySignature(p7 *PKCS7, signer signerInfo) error { + if len(signer.AuthenticatedAttributes) > 0 { + // TODO(fullsailor): First check the content type match + var digest []byte + err := unmarshalAttribute(signer.AuthenticatedAttributes, oidAttributeMessageDigest, &digest) + if err != nil { + return err + } + hash, err := getHashForOID(signer.DigestAlgorithm.Algorithm) + if err != nil { + return err + } + h := hash.New() + h.Write(p7.Content) + computed := h.Sum(nil) + if !hmac.Equal(digest, computed) { + return &MessageDigestMismatchError{ + ExpectedDigest: digest, + ActualDigest: computed, + } + } + } + cert := getCertFromCertsByIssuerAndSerial(p7.Certificates, signer.IssuerAndSerialNumber) + if cert == nil { + return errors.New("pkcs7: No certificate for signer") + } + // TODO(fullsailor): Optionally verify certificate chain + // TODO(fullsailor): Optionally verify signingTime against certificate NotAfter/NotBefore + encodedAttributes, err := marshalAttributes(signer.AuthenticatedAttributes) + if err != nil { + return err + } + algo := x509.SHA1WithRSA + return cert.CheckSignature(algo, encodedAttributes, signer.EncryptedDigest) +} + +func marshalAttributes(attrs []attribute) ([]byte, error) { + encodedAttributes, err := asn1.Marshal(struct { + A []attribute `asn1:"set"` + }{A: attrs}) + if err != nil { + return nil, err + } + + // Remove the leading sequence octets + var raw asn1.RawValue + asn1.Unmarshal(encodedAttributes, &raw) + return raw.Bytes, nil +} + +var ( + oidDigestAlgorithmSHA1 = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 26} + oidEncryptionAlgorithmRSA = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 1, 1} +) + +func getCertFromCertsByIssuerAndSerial(certs []*x509.Certificate, ias issuerAndSerial) *x509.Certificate { + for _, cert := range certs { + if isCertMatchForIssuerAndSerial(cert, ias) { + return cert + } + } + return nil +} + +func getHashForOID(oid asn1.ObjectIdentifier) (crypto.Hash, error) { + switch { + case oid.Equal(oidDigestAlgorithmSHA1): + return crypto.SHA1, nil + } + return crypto.Hash(0), ErrUnsupportedAlgorithm +} + +// GetOnlySigner returns an x509.Certificate for the first signer of the signed +// data payload. If there are more or less than one signer, nil is returned +func (p7 *PKCS7) GetOnlySigner() *x509.Certificate { + if len(p7.Signers) != 1 { + return nil + } + signer := p7.Signers[0] + return getCertFromCertsByIssuerAndSerial(p7.Certificates, signer.IssuerAndSerialNumber) +} + +// ErrUnsupportedAlgorithm tells you when our quick dev assumptions have failed +var ErrUnsupportedAlgorithm = errors.New("pkcs7: cannot decrypt data: only RSA, DES, DES-EDE3 and AES-256-CBC supported") + +// ErrNotEncryptedContent is returned when attempting to Decrypt data that is not encrypted data +var ErrNotEncryptedContent = errors.New("pkcs7: content data is a decryptable data type") + +// Decrypt decrypts encrypted content info for recipient cert and private key +func (p7 *PKCS7) Decrypt(cert *x509.Certificate, pk crypto.PrivateKey) ([]byte, error) { + data, ok := p7.raw.(envelopedData) + if !ok { + return nil, ErrNotEncryptedContent + } + recipient := selectRecipientForCertificate(data.RecipientInfos, cert) + if recipient.EncryptedKey == nil { + return nil, errors.New("pkcs7: no enveloped recipient for provided certificate") + } + if priv := pk.(*rsa.PrivateKey); priv != nil { + var contentKey []byte + contentKey, err := rsa.DecryptPKCS1v15(rand.Reader, priv, recipient.EncryptedKey) + if err != nil { + return nil, err + } + return data.EncryptedContentInfo.decrypt(contentKey) + } + fmt.Printf("Unsupported Private Key: %v\n", pk) + return nil, ErrUnsupportedAlgorithm +} + +var oidEncryptionAlgorithmDESCBC = asn1.ObjectIdentifier{1, 3, 14, 3, 2, 7} +var oidEncryptionAlgorithmDESEDE3CBC = asn1.ObjectIdentifier{1, 2, 840, 113549, 3, 7} +var oidEncryptionAlgorithmAES256CBC = asn1.ObjectIdentifier{2, 16, 840, 1, 101, 3, 4, 1, 42} + +func (eci encryptedContentInfo) decrypt(key []byte) ([]byte, error) { + alg := eci.ContentEncryptionAlgorithm.Algorithm + if !alg.Equal(oidEncryptionAlgorithmDESCBC) && !alg.Equal(oidEncryptionAlgorithmDESEDE3CBC) && !alg.Equal(oidEncryptionAlgorithmAES256CBC) { + fmt.Printf("Unsupported Content Encryption Algorithm: %s\n", alg) + return nil, ErrUnsupportedAlgorithm + } + + // EncryptedContent can either be constructed of multple OCTET STRINGs + // or _be_ a tagged OCTET STRING + var cyphertext []byte + if eci.EncryptedContent.IsCompound { + // Complex case to concat all of the children OCTET STRINGs + var buf bytes.Buffer + cypherbytes := eci.EncryptedContent.Bytes + for { + var part []byte + cypherbytes, _ = asn1.Unmarshal(cypherbytes, &part) + buf.Write(part) + if cypherbytes == nil { + break + } + } + cyphertext = buf.Bytes() + } else { + // Simple case, the bytes _are_ the cyphertext + cyphertext = eci.EncryptedContent.Bytes + } + + var block cipher.Block + var err error + + switch { + case alg.Equal(oidEncryptionAlgorithmDESCBC): + block, err = des.NewCipher(key) + case alg.Equal(oidEncryptionAlgorithmDESEDE3CBC): + block, err = des.NewTripleDESCipher(key) + case alg.Equal(oidEncryptionAlgorithmAES256CBC): + block, err = aes.NewCipher(key) + } + if err != nil { + return nil, err + } + + iv := eci.ContentEncryptionAlgorithm.Parameters.Bytes + if len(iv) != block.BlockSize() { + return nil, errors.New("pkcs7: encryption algorithm parameters are malformed") + } + mode := cipher.NewCBCDecrypter(block, iv) + plaintext := make([]byte, len(cyphertext)) + mode.CryptBlocks(plaintext, cyphertext) + if plaintext, err = unpad(plaintext, mode.BlockSize()); err != nil { + return nil, err + } + return plaintext, nil +} + +func selectRecipientForCertificate(recipients []recipientInfo, cert *x509.Certificate) recipientInfo { + for _, recp := range recipients { + if isCertMatchForIssuerAndSerial(cert, recp.IssuerAndSerialNumber) { + return recp + } + } + return recipientInfo{} +} + +func isCertMatchForIssuerAndSerial(cert *x509.Certificate, ias issuerAndSerial) bool { + return cert.SerialNumber.Cmp(ias.SerialNumber) == 0 && bytes.Compare(cert.RawIssuer, ias.IssuerName.FullBytes) == 0 +} + +func pad(data []byte, blocklen int) ([]byte, error) { + if blocklen < 1 { + return nil, fmt.Errorf("invalid blocklen %d", blocklen) + } + padlen := blocklen - (len(data) % blocklen) + if padlen == 0 { + padlen = blocklen + } + pad := bytes.Repeat([]byte{byte(padlen)}, padlen) + return append(data, pad...), nil +} + +func unpad(data []byte, blocklen int) ([]byte, error) { + if blocklen < 1 { + return nil, fmt.Errorf("invalid blocklen %d", blocklen) + } + if len(data)%blocklen != 0 || len(data) == 0 { + return nil, fmt.Errorf("invalid data len %d", len(data)) + } + + // the last byte is the length of padding + padlen := int(data[len(data)-1]) + + // check padding integrity, all bytes should be the same + pad := data[len(data)-padlen:] + for _, padbyte := range pad { + if padbyte != byte(padlen) { + return nil, errors.New("invalid padding") + } + } + + return data[:len(data)-padlen], nil +} + +func unmarshalAttribute(attrs []attribute, attributeType asn1.ObjectIdentifier, out interface{}) error { + for _, attr := range attrs { + if attr.Type.Equal(attributeType) { + _, err := asn1.Unmarshal(attr.Value.Bytes, out) + return err + } + } + return errors.New("pkcs7: attribute type not in attributes") +} + +// UnmarshalSignedAttribute decodes a single attribute from the signer info +func (p7 *PKCS7) UnmarshalSignedAttribute(attributeType asn1.ObjectIdentifier, out interface{}) error { + sd, ok := p7.raw.(signedData) + if !ok { + return errors.New("pkcs7: payload is not signedData content") + } + if len(sd.SignerInfos) < 1 { + return errors.New("pkcs7: payload has no signers") + } + attributes := sd.SignerInfos[0].AuthenticatedAttributes + return unmarshalAttribute(attributes, attributeType, out) +} + +// SignedData is an opaque data structure for creating signed data payloads +type SignedData struct { + sd signedData + certs []*x509.Certificate + messageDigest []byte +} + +// Attribute represents a key value pair attribute. Value must be marshalable byte +// `encoding/asn1` +type Attribute struct { + Type asn1.ObjectIdentifier + Value interface{} +} + +// SignerInfoConfig are optional values to include when adding a signer +type SignerInfoConfig struct { + ExtraSignedAttributes []Attribute +} + +// NewSignedData initializes a SignedData with content +func NewSignedData(data []byte) (*SignedData, error) { + content, err := asn1.Marshal(data) + if err != nil { + return nil, err + } + ci := contentInfo{ + ContentType: oidData, + Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: content, IsCompound: true}, + } + digAlg := pkix.AlgorithmIdentifier{ + Algorithm: oidDigestAlgorithmSHA1, + } + h := crypto.SHA1.New() + h.Write(data) + md := h.Sum(nil) + sd := signedData{ + ContentInfo: ci, + Version: 1, + DigestAlgorithmIdentifiers: []pkix.AlgorithmIdentifier{digAlg}, + } + return &SignedData{sd: sd, messageDigest: md}, nil +} + +type attributes struct { + types []asn1.ObjectIdentifier + values []interface{} +} + +// Add adds the attribute, maintaining insertion order +func (attrs *attributes) Add(attrType asn1.ObjectIdentifier, value interface{}) { + attrs.types = append(attrs.types, attrType) + attrs.values = append(attrs.values, value) +} + +type sortableAttribute struct { + SortKey []byte + Attribute attribute +} + +type attributeSet []sortableAttribute + +func (sa attributeSet) Len() int { + return len(sa) +} + +func (sa attributeSet) Less(i, j int) bool { + return bytes.Compare(sa[i].SortKey, sa[j].SortKey) < 0 +} + +func (sa attributeSet) Swap(i, j int) { + sa[i], sa[j] = sa[j], sa[i] +} + +func (sa attributeSet) Attributes() []attribute { + attrs := make([]attribute, len(sa)) + for i, attr := range sa { + attrs[i] = attr.Attribute + } + return attrs +} + +func (attrs *attributes) ForMarshaling() ([]attribute, error) { + sortables := make(attributeSet, len(attrs.types)) + for i := range sortables { + attrType := attrs.types[i] + attrValue := attrs.values[i] + asn1Value, err := asn1.Marshal(attrValue) + if err != nil { + return nil, err + } + attr := attribute{ + Type: attrType, + Value: asn1.RawValue{Tag: 17, IsCompound: true, Bytes: asn1Value}, // 17 == SET tag + } + encoded, err := asn1.Marshal(attr) + if err != nil { + return nil, err + } + sortables[i] = sortableAttribute{ + SortKey: encoded, + Attribute: attr, + } + } + sort.Sort(sortables) + return sortables.Attributes(), nil +} + +// AddSigner signs attributes about the content and adds certificate to payload +func (sd *SignedData) AddSigner(cert *x509.Certificate, pkey crypto.PrivateKey, config SignerInfoConfig) error { + attrs := &attributes{} + attrs.Add(oidAttributeContentType, sd.sd.ContentInfo.ContentType) + attrs.Add(oidAttributeMessageDigest, sd.messageDigest) + attrs.Add(oidAttributeSigningTime, time.Now()) + for _, attr := range config.ExtraSignedAttributes { + attrs.Add(attr.Type, attr.Value) + } + finalAttrs, err := attrs.ForMarshaling() + if err != nil { + return err + } + signature, err := signAttributes(finalAttrs, pkey, crypto.SHA1) + if err != nil { + return err + } + + ias, err := cert2issuerAndSerial(cert) + if err != nil { + return err + } + + signer := signerInfo{ + AuthenticatedAttributes: finalAttrs, + DigestAlgorithm: pkix.AlgorithmIdentifier{Algorithm: oidDigestAlgorithmSHA1}, + DigestEncryptionAlgorithm: pkix.AlgorithmIdentifier{Algorithm: oidEncryptionAlgorithmRSA}, + IssuerAndSerialNumber: ias, + EncryptedDigest: signature, + Version: 1, + } + // create signature of signed attributes + sd.certs = append(sd.certs, cert) + sd.sd.SignerInfos = append(sd.sd.SignerInfos, signer) + return nil +} + +// AddCertificate adds the certificate to the payload. Useful for parent certificates +func (sd *SignedData) AddCertificate(cert *x509.Certificate) { + sd.certs = append(sd.certs, cert) +} + +// Finish marshals the content and its signers +func (sd *SignedData) Finish() ([]byte, error) { + sd.sd.Certificates = marshalCertificates(sd.certs) + inner, err := asn1.Marshal(sd.sd) + if err != nil { + return nil, err + } + outer := contentInfo{ + ContentType: oidSignedData, + Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: inner, IsCompound: true}, + } + return asn1.Marshal(outer) +} + +func cert2issuerAndSerial(cert *x509.Certificate) (issuerAndSerial, error) { + var ias issuerAndSerial + // The issuer RDNSequence has to match exactly the sequence in the certificate + // We cannot use cert.Issuer.ToRDNSequence() here since it mangles the sequence + ias.IssuerName = asn1.RawValue{FullBytes: cert.RawIssuer} + ias.SerialNumber = cert.SerialNumber + + return ias, nil +} + +// signs the DER encoded form of the attributes with the private key +func signAttributes(attrs []attribute, pkey crypto.PrivateKey, hash crypto.Hash) ([]byte, error) { + attrBytes, err := marshalAttributes(attrs) + if err != nil { + return nil, err + } + h := hash.New() + h.Write(attrBytes) + hashed := h.Sum(nil) + switch priv := pkey.(type) { + case *rsa.PrivateKey: + return rsa.SignPKCS1v15(rand.Reader, priv, crypto.SHA1, hashed) + } + return nil, ErrUnsupportedAlgorithm +} + +// concats and wraps the certificates in the RawValue structure +func marshalCertificates(certs []*x509.Certificate) rawCertificates { + var buf bytes.Buffer + for _, cert := range certs { + buf.Write(cert.Raw) + } + rawCerts, _ := marshalCertificateBytes(buf.Bytes()) + return rawCerts +} + +// Even though, the tag & length are stripped out during marshalling the +// RawContent, we have to encode it into the RawContent. If its missing, +// then `asn1.Marshal()` will strip out the certificate wrapper instead. +func marshalCertificateBytes(certs []byte) (rawCertificates, error) { + var val = asn1.RawValue{Bytes: certs, Class: 2, Tag: 0, IsCompound: true} + b, err := asn1.Marshal(val) + if err != nil { + return rawCertificates{}, err + } + return rawCertificates{Raw: b}, nil +} + +// DegenerateCertificate creates a signed data structure containing only the +// provided certificate or certificate chain. +func DegenerateCertificate(cert []byte) ([]byte, error) { + rawCert, err := marshalCertificateBytes(cert) + if err != nil { + return nil, err + } + emptyContent := contentInfo{ContentType: oidData} + sd := signedData{ + Version: 1, + ContentInfo: emptyContent, + Certificates: rawCert, + CRLs: []pkix.CertificateList{}, + } + content, err := asn1.Marshal(sd) + if err != nil { + return nil, err + } + signedContent := contentInfo{ + ContentType: oidSignedData, + Content: asn1.RawValue{Class: 2, Tag: 0, Bytes: content, IsCompound: true}, + } + return asn1.Marshal(signedContent) +} + +// Encrypt creates and returns an envelope data PKCS7 structure with encrypted +// recipient keys for each recipient public key +// TODO(fullsailor): Add support for encrypting content with other algorithms +func Encrypt(content []byte, recipients []*x509.Certificate) ([]byte, error) { + + // Create DES key & CBC IV + key := make([]byte, 8) + iv := make([]byte, des.BlockSize) + _, err := rand.Read(key) + if err != nil { + return nil, err + } + _, err = rand.Read(iv) + if err != nil { + return nil, err + } + + // Encrypt padded content + block, err := des.NewCipher(key) + if err != nil { + return nil, err + } + mode := cipher.NewCBCEncrypter(block, iv) + plaintext, err := pad(content, mode.BlockSize()) + cyphertext := make([]byte, len(plaintext)) + mode.CryptBlocks(cyphertext, plaintext) + + // Prepare ASN.1 Encrypted Content Info + eci := encryptedContentInfo{ + ContentType: oidData, + ContentEncryptionAlgorithm: pkix.AlgorithmIdentifier{ + Algorithm: oidEncryptionAlgorithmDESCBC, + Parameters: asn1.RawValue{Tag: 4, Bytes: iv}, + }, + EncryptedContent: marshalEncryptedContent(cyphertext), + } + + // Prepare each recipient's encrypted cipher key + recipientInfos := make([]recipientInfo, len(recipients)) + for i, recipient := range recipients { + encrypted, err := encryptKey(key, recipient) + if err != nil { + return nil, err + } + ias, err := cert2issuerAndSerial(recipient) + if err != nil { + return nil, err + } + info := recipientInfo{ + Version: 0, + IssuerAndSerialNumber: ias, + KeyEncryptionAlgorithm: pkix.AlgorithmIdentifier{ + Algorithm: oidEncryptionAlgorithmRSA, + }, + EncryptedKey: encrypted, + } + recipientInfos[i] = info + } + + // Prepare envelope content + envelope := envelopedData{ + EncryptedContentInfo: eci, + Version: 0, + RecipientInfos: recipientInfos, + } + innerContent, err := asn1.Marshal(envelope) + if err != nil { + return nil, err + } + + // Prepare outer payload structure + wrapper := contentInfo{ + ContentType: oidEnvelopedData, + Content: asn1.RawValue{Class: 2, Tag: 0, IsCompound: true, Bytes: innerContent}, + } + + return asn1.Marshal(wrapper) +} + +func marshalEncryptedContent(content []byte) asn1.RawValue { + asn1Content, _ := asn1.Marshal(content) + return asn1.RawValue{Tag: 0, Class: 2, Bytes: asn1Content, IsCompound: true} +} + +func encryptKey(key []byte, recipient *x509.Certificate) ([]byte, error) { + if pub := recipient.PublicKey.(*rsa.PublicKey); pub != nil { + return rsa.EncryptPKCS1v15(rand.Reader, pub, key) + } + return nil, ErrUnsupportedAlgorithm +} diff --git a/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7_test.go b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7_test.go new file mode 100644 index 00000000..c66f8fe7 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/internal/pkcs7/pkcs7_test.go @@ -0,0 +1,439 @@ +package pkcs7 + +import ( + "bytes" + "crypto" + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/pem" + "fmt" + "io" + "io/ioutil" + "math/big" + "os" + "os/exec" + "testing" + "time" +) + +func TestVerify(t *testing.T) { + fixture := UnmarshalTestFixture(SignedTestFixture) + p7, err := Parse(fixture.Input) + if err != nil { + t.Errorf("Parse encountered unexpected error: %v", err) + } + + if err := p7.Verify(); err != nil { + t.Errorf("Verify failed with error: %v", err) + } + expected := []byte("We the People") + if bytes.Compare(p7.Content, expected) != 0 { + t.Errorf("Signed content does not match.\n\tExpected:%s\n\tActual:%s", expected, p7.Content) + + } +} + +func TestVerifyEC2(t *testing.T) { + fixture := UnmarshalTestFixture(EC2IdentityDocumentFixture) + p7, err := Parse(fixture.Input) + if err != nil { + t.Errorf("Parse encountered unexpected error: %v", err) + } + p7.Certificates = []*x509.Certificate{fixture.Certificate} + if err := p7.Verify(); err != nil { + t.Errorf("Verify failed with error: %v", err) + } +} + +func TestDecrypt(t *testing.T) { + fixture := UnmarshalTestFixture(EncryptedTestFixture) + p7, err := Parse(fixture.Input) + if err != nil { + t.Fatal(err) + } + content, err := p7.Decrypt(fixture.Certificate, fixture.PrivateKey) + if err != nil { + t.Errorf("Cannot Decrypt with error: %v", err) + } + expected := []byte("This is a test") + if bytes.Compare(content, expected) != 0 { + t.Errorf("Decrypted result does not match.\n\tExpected:%s\n\tActual:%s", expected, content) + } +} + +func TestDegenerateCertificate(t *testing.T) { + cert, err := createTestCertificate() + if err != nil { + t.Fatal(err) + } + deg, err := DegenerateCertificate(cert.Certificate.Raw) + if err != nil { + t.Fatal(err) + } + testOpenSSLParse(t, deg) + + fmt.Printf("=== BEGIN DEGENERATE CERT ===\n% X\n=== END DEGENERATE CERT ===\n", deg) +} + +// writes the cert to a temporary file and tests that openssl can read it. +func testOpenSSLParse(t *testing.T, certBytes []byte) { + tmpCertFile, err := ioutil.TempFile("", "testCertificate") + if err != nil { + t.Fatal(err) + } + defer os.Remove(tmpCertFile.Name()) // clean up + + if _, err := tmpCertFile.Write(certBytes); err != nil { + t.Fatal(err) + } + + opensslCMD := exec.Command("openssl", "pkcs7", "-inform", "der", "-in", tmpCertFile.Name()) + _, err = opensslCMD.Output() + if err != nil { + t.Fatal(err) + } + + if err := tmpCertFile.Close(); err != nil { + t.Fatal(err) + } + +} + +func TestSign(t *testing.T) { + cert, err := createTestCertificate() + if err != nil { + t.Fatal(err) + } + content := []byte("Hello World") + toBeSigned, err := NewSignedData(content) + if err != nil { + t.Fatalf("Cannot initialize signed data: %s", err) + } + if err := toBeSigned.AddSigner(cert.Certificate, cert.PrivateKey, SignerInfoConfig{}); err != nil { + t.Fatalf("Cannot add signer: %s", err) + } + signed, err := toBeSigned.Finish() + if err != nil { + t.Fatalf("Cannot finish signing data: %s", err) + } + fmt.Printf("=== BEGIN SIGNED RESULT ===\n% X\n=== END SIGNED RESULT ===\n", signed) + + p7, err := Parse(signed) + if err != nil { + t.Fatalf("Cannot parse our signed data: %s", err) + } + if bytes.Compare(content, p7.Content) != 0 { + t.Errorf("Our content was not in the parsed data:\n\tExpected: %s\n\tActual: %s", content, p7.Content) + } + if err := p7.Verify(); err != nil { + t.Errorf("Cannot verify our signed data: %s", err) + } +} + +func TestEncrypt(t *testing.T) { + plaintext := []byte("Hello Secret World!") + cert, err := createTestCertificate() + if err != nil { + t.Fatal(err) + } + encrypted, err := Encrypt(plaintext, []*x509.Certificate{cert.Certificate}) + if err != nil { + t.Fatal(err) + } + p7, err := Parse(encrypted) + if err != nil { + t.Fatalf("cannot Parse encrypted result: %s", err) + } + result, err := p7.Decrypt(cert.Certificate, cert.PrivateKey) + if err != nil { + t.Fatalf("cannot Decrypt encrypted result: %s", err) + } + if bytes.Compare(plaintext, result) != 0 { + t.Errorf("encrypted data does not match plaintext:\n\tExpected: %s\n\tActual: %s", plaintext, result) + } +} + +func TestUnmarshalSignedAttribute(t *testing.T) { + cert, err := createTestCertificate() + if err != nil { + t.Fatal(err) + } + content := []byte("Hello World") + toBeSigned, err := NewSignedData(content) + if err != nil { + t.Fatalf("Cannot initialize signed data: %s", err) + } + oidTest := asn1.ObjectIdentifier{2, 3, 4, 5, 6, 7} + testValue := "TestValue" + if err := toBeSigned.AddSigner(cert.Certificate, cert.PrivateKey, SignerInfoConfig{ + ExtraSignedAttributes: []Attribute{Attribute{Type: oidTest, Value: testValue}}, + }); err != nil { + t.Fatalf("Cannot add signer: %s", err) + } + signed, err := toBeSigned.Finish() + if err != nil { + t.Fatalf("Cannot finish signing data: %s", err) + } + p7, err := Parse(signed) + var actual string + err = p7.UnmarshalSignedAttribute(oidTest, &actual) + if err != nil { + t.Fatalf("Cannot unmarshal test value: %s", err) + } + if testValue != actual { + t.Errorf("Attribute does not match test value\n\tExpected: %s\n\tActual: %s", testValue, actual) + } +} + +func TestPad(t *testing.T) { + tests := []struct { + Original []byte + Expected []byte + BlockSize int + }{ + {[]byte{0x1, 0x2, 0x3, 0x10}, []byte{0x1, 0x2, 0x3, 0x10, 0x4, 0x4, 0x4, 0x4}, 8}, + {[]byte{0x1, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0}, []byte{0x1, 0x2, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8, 0x8}, 8}, + } + for _, test := range tests { + padded, err := pad(test.Original, test.BlockSize) + if err != nil { + t.Errorf("pad encountered error: %s", err) + continue + } + if bytes.Compare(test.Expected, padded) != 0 { + t.Errorf("pad results mismatch:\n\tExpected: %X\n\tActual: %X", test.Expected, padded) + } + } +} + +type certKeyPair struct { + Certificate *x509.Certificate + PrivateKey *rsa.PrivateKey +} + +func createTestCertificate() (certKeyPair, error) { + signer, err := createTestCertificateByIssuer("Eddard Stark", nil) + if err != nil { + return certKeyPair{}, err + } + pair, err := createTestCertificateByIssuer("Jon Snow", signer) + if err != nil { + return certKeyPair{}, err + } + return *pair, nil +} + +func createTestCertificateByIssuer(name string, issuer *certKeyPair) (*certKeyPair, error) { + + priv, err := rsa.GenerateKey(rand.Reader, 1024) + if err != nil { + return nil, err + } + serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 32) + serialNumber, err := rand.Int(rand.Reader, serialNumberLimit) + if err != nil { + return nil, err + } + + template := x509.Certificate{ + SerialNumber: serialNumber, + SignatureAlgorithm: x509.SHA256WithRSA, + Subject: pkix.Name{ + CommonName: name, + Organization: []string{"Acme Co"}, + }, + NotBefore: time.Now(), + NotAfter: time.Now().AddDate(1, 0, 0), + KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature, + } + var issuerCert *x509.Certificate + var issuerKey crypto.PrivateKey + if issuer != nil { + issuerCert = issuer.Certificate + issuerKey = issuer.PrivateKey + } else { + issuerCert = &template + issuerKey = priv + } + cert, err := x509.CreateCertificate(rand.Reader, &template, issuerCert, priv.Public(), issuerKey) + if err != nil { + return nil, err + } + leaf, err := x509.ParseCertificate(cert) + if err != nil { + return nil, err + } + return &certKeyPair{ + Certificate: leaf, + PrivateKey: priv, + }, nil +} + +type TestFixture struct { + Input []byte + Certificate *x509.Certificate + PrivateKey *rsa.PrivateKey +} + +func UnmarshalTestFixture(testPEMBlock string) TestFixture { + var result TestFixture + var derBlock *pem.Block + var pemBlock = []byte(testPEMBlock) + for { + derBlock, pemBlock = pem.Decode(pemBlock) + if derBlock == nil { + break + } + switch derBlock.Type { + case "PKCS7": + result.Input = derBlock.Bytes + case "CERTIFICATE": + result.Certificate, _ = x509.ParseCertificate(derBlock.Bytes) + case "PRIVATE KEY": + result.PrivateKey, _ = x509.ParsePKCS1PrivateKey(derBlock.Bytes) + } + } + + return result +} + +func MarshalTestFixture(t TestFixture, w io.Writer) { + if t.Input != nil { + pem.Encode(w, &pem.Block{Type: "PKCS7", Bytes: t.Input}) + } + if t.Certificate != nil { + pem.Encode(w, &pem.Block{Type: "CERTIFICATE", Bytes: t.Certificate.Raw}) + } + if t.PrivateKey != nil { + pem.Encode(w, &pem.Block{Type: "PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(t.PrivateKey)}) + } +} + +var SignedTestFixture = ` +-----BEGIN PKCS7----- +MIIDVgYJKoZIhvcNAQcCoIIDRzCCA0MCAQExCTAHBgUrDgMCGjAcBgkqhkiG9w0B +BwGgDwQNV2UgdGhlIFBlb3BsZaCCAdkwggHVMIIBQKADAgECAgRpuDctMAsGCSqG +SIb3DQEBCzApMRAwDgYDVQQKEwdBY21lIENvMRUwEwYDVQQDEwxFZGRhcmQgU3Rh +cmswHhcNMTUwNTA2MDQyNDQ4WhcNMTYwNTA2MDQyNDQ4WjAlMRAwDgYDVQQKEwdB +Y21lIENvMREwDwYDVQQDEwhKb24gU25vdzCBnzANBgkqhkiG9w0BAQEFAAOBjQAw +gYkCgYEAqr+tTF4mZP5rMwlXp1y+crRtFpuLXF1zvBZiYMfIvAHwo1ta8E1IcyEP +J1jIiKMcwbzeo6kAmZzIJRCTezq9jwXUsKbQTvcfOH9HmjUmXBRWFXZYoQs/OaaF +a45deHmwEeMQkuSWEtYiVKKZXtJOtflKIT3MryJEDiiItMkdybUCAwEAAaMSMBAw +DgYDVR0PAQH/BAQDAgCgMAsGCSqGSIb3DQEBCwOBgQDK1EweZWRL+f7Z+J0kVzY8 +zXptcBaV4Lf5wGZJLJVUgp33bpLNpT3yadS++XQJ+cvtW3wADQzBSTMduyOF8Zf+ +L7TjjrQ2+F2HbNbKUhBQKudxTfv9dJHdKbD+ngCCdQJYkIy2YexsoNG0C8nQkggy +axZd/J69xDVx6pui3Sj8sDGCATYwggEyAgEBMDEwKTEQMA4GA1UEChMHQWNtZSBD +bzEVMBMGA1UEAxMMRWRkYXJkIFN0YXJrAgRpuDctMAcGBSsOAwIaoGEwGAYJKoZI +hvcNAQkDMQsGCSqGSIb3DQEHATAgBgkqhkiG9w0BCQUxExcRMTUwNTA2MDAyNDQ4 +LTA0MDAwIwYJKoZIhvcNAQkEMRYEFG9D7gcTh9zfKiYNJ1lgB0yTh4sZMAsGCSqG +SIb3DQEBAQSBgFF3sGDU9PtXty/QMtpcFa35vvIOqmWQAIZt93XAskQOnBq4OloX +iL9Ct7t1m4pzjRm0o9nDkbaSLZe7HKASHdCqijroScGlI8M+alJ8drHSFv6ZIjnM +FIwIf0B2Lko6nh9/6mUXq7tbbIHa3Gd1JUVire/QFFtmgRXMbXYk8SIS +-----END PKCS7----- +-----BEGIN CERTIFICATE----- +MIIB1TCCAUCgAwIBAgIEabg3LTALBgkqhkiG9w0BAQswKTEQMA4GA1UEChMHQWNt +ZSBDbzEVMBMGA1UEAxMMRWRkYXJkIFN0YXJrMB4XDTE1MDUwNjA0MjQ0OFoXDTE2 +MDUwNjA0MjQ0OFowJTEQMA4GA1UEChMHQWNtZSBDbzERMA8GA1UEAxMISm9uIFNu +b3cwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKq/rUxeJmT+azMJV6dcvnK0 +bRabi1xdc7wWYmDHyLwB8KNbWvBNSHMhDydYyIijHMG83qOpAJmcyCUQk3s6vY8F +1LCm0E73Hzh/R5o1JlwUVhV2WKELPzmmhWuOXXh5sBHjEJLklhLWIlSimV7STrX5 +SiE9zK8iRA4oiLTJHcm1AgMBAAGjEjAQMA4GA1UdDwEB/wQEAwIAoDALBgkqhkiG +9w0BAQsDgYEAytRMHmVkS/n+2fidJFc2PM16bXAWleC3+cBmSSyVVIKd926SzaU9 +8mnUvvl0CfnL7Vt8AA0MwUkzHbsjhfGX/i+04460Nvhdh2zWylIQUCrncU37/XSR +3Smw/p4AgnUCWJCMtmHsbKDRtAvJ0JIIMmsWXfyevcQ1ceqbot0o/LA= +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIICXgIBAAKBgQCqv61MXiZk/mszCVenXL5ytG0Wm4tcXXO8FmJgx8i8AfCjW1rw +TUhzIQ8nWMiIoxzBvN6jqQCZnMglEJN7Or2PBdSwptBO9x84f0eaNSZcFFYVdlih +Cz85poVrjl14ebAR4xCS5JYS1iJUople0k61+UohPcyvIkQOKIi0yR3JtQIDAQAB +AoGBAIPLCR9N+IKxodq11lNXEaUFwMHXc1zqwP8no+2hpz3+nVfplqqubEJ4/PJY +5AgbJoIfnxVhyBXJXu7E+aD/OPneKZrgp58YvHKgGvvPyJg2gpC/1Fh0vQB0HNpI +1ZzIZUl8ZTUtVgtnCBUOh5JGI4bFokAqrT//Uvcfd+idgxqBAkEA1ZbP/Kseld14 +qbWmgmU5GCVxsZRxgR1j4lG3UVjH36KXMtRTm1atAam1uw3OEGa6Y3ANjpU52FaB +Hep5rkk4FQJBAMynMo1L1uiN5GP+KYLEF5kKRxK+FLjXR0ywnMh+gpGcZDcOae+J ++t1gLoWBIESH/Xt639T7smuSfrZSA9V0EyECQA8cvZiWDvLxmaEAXkipmtGPjKzQ +4PsOtkuEFqFl07aKDYKmLUg3aMROWrJidqsIabWxbvQgsNgSvs38EiH3wkUCQQCg +ndxb7piVXb9RBwm3OoU2tE1BlXMX+sVXmAkEhd2dwDsaxrI3sHf1xGXem5AimQRF +JBOFyaCnMotGNioSHY5hAkEAxyXcNixQ2RpLXJTQZtwnbk0XDcbgB+fBgXnv/4f3 +BCvcu85DqJeJyQv44Oe1qsXEX9BfcQIOVaoep35RPlKi9g== +-----END PRIVATE KEY-----` + +// Content is "This is a test" +var EncryptedTestFixture = ` +-----BEGIN PKCS7----- +MIIBFwYJKoZIhvcNAQcDoIIBCDCCAQQCAQAxgcowgccCAQAwMjApMRAwDgYDVQQK +EwdBY21lIENvMRUwEwYDVQQDEwxFZGRhcmQgU3RhcmsCBQDL+CvWMAsGCSqGSIb3 +DQEBAQSBgKyP/5WlRTZD3dWMrLOX6QRNDrXEkQjhmToRwFZdY3LgUh25ZU0S/q4G +dHPV21Fv9lQD+q7l3vfeHw8M6Z1PKi9sHMVfxAkQpvaI96DTIT3YHtuLC1w3geCO +8eFWTq2qS4WChSuS/yhYosjA1kTkE0eLnVZcGw0z/WVuEZznkdyIMDIGCSqGSIb3 +DQEHATARBgUrDgMCBwQImpKsUyMPpQigEgQQRcWWrCRXqpD5Njs0GkJl+g== +-----END PKCS7----- +-----BEGIN CERTIFICATE----- +MIIB1jCCAUGgAwIBAgIFAMv4K9YwCwYJKoZIhvcNAQELMCkxEDAOBgNVBAoTB0Fj +bWUgQ28xFTATBgNVBAMTDEVkZGFyZCBTdGFyazAeFw0xNTA1MDYwMzU2NDBaFw0x +NjA1MDYwMzU2NDBaMCUxEDAOBgNVBAoTB0FjbWUgQ28xETAPBgNVBAMTCEpvbiBT +bm93MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDK6NU0R0eiCYVquU4RcjKc +LzGfx0aa1lMr2TnLQUSeLFZHFxsyyMXXuMPig3HK4A7SGFHupO+/1H/sL4xpH5zg +8+Zg2r8xnnney7abxcuv0uATWSIeKlNnb1ZO1BAxFnESc3GtyOCr2dUwZHX5mRVP ++Zxp2ni5qHNraf3wE2VPIQIDAQABoxIwEDAOBgNVHQ8BAf8EBAMCAKAwCwYJKoZI +hvcNAQELA4GBAIr2F7wsqmEU/J/kLyrCgEVXgaV/sKZq4pPNnzS0tBYk8fkV3V18 +sBJyHKRLL/wFZASvzDcVGCplXyMdAOCyfd8jO3F9Ac/xdlz10RrHJT75hNu3a7/n +9KNwKhfN4A1CQv2x372oGjRhCW5bHNCWx4PIVeNzCyq/KZhyY9sxHE6f +-----END CERTIFICATE----- +-----BEGIN PRIVATE KEY----- +MIICXgIBAAKBgQDK6NU0R0eiCYVquU4RcjKcLzGfx0aa1lMr2TnLQUSeLFZHFxsy +yMXXuMPig3HK4A7SGFHupO+/1H/sL4xpH5zg8+Zg2r8xnnney7abxcuv0uATWSIe +KlNnb1ZO1BAxFnESc3GtyOCr2dUwZHX5mRVP+Zxp2ni5qHNraf3wE2VPIQIDAQAB +AoGBALyvnSt7KUquDen7nXQtvJBudnf9KFPt//OjkdHHxNZNpoF/JCSqfQeoYkeu +MdAVYNLQGMiRifzZz4dDhA9xfUAuy7lcGQcMCxEQ1dwwuFaYkawbS0Tvy2PFlq2d +H5/HeDXU4EDJ3BZg0eYj2Bnkt1sJI35UKQSxblQ0MY2q0uFBAkEA5MMOogkgUx1C +67S1tFqMUSM8D0mZB0O5vOJZC5Gtt2Urju6vywge2ArExWRXlM2qGl8afFy2SgSv +Xk5eybcEiQJBAOMRwwbEoW5NYHuFFbSJyWll4n71CYuWuQOCzehDPyTb80WFZGLV +i91kFIjeERyq88eDE5xVB3ZuRiXqaShO/9kCQQCKOEkpInaDgZSjskZvuJ47kByD +6CYsO4GIXQMMeHML8ncFH7bb6AYq5ybJVb2NTU7QLFJmfeYuhvIm+xdOreRxAkEA +o5FC5Jg2FUfFzZSDmyZ6IONUsdF/i78KDV5nRv1R+hI6/oRlWNCtTNBv/lvBBd6b +dseUE9QoaQZsn5lpILEvmQJAZ0B+Or1rAYjnbjnUhdVZoy9kC4Zov+4UH3N/BtSy +KJRWUR0wTWfZBPZ5hAYZjTBEAFULaYCXlQKsODSp0M1aQA== +-----END PRIVATE KEY-----` + +var EC2IdentityDocumentFixture = ` +-----BEGIN PKCS7----- +MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAaCA +JIAEggGmewogICJwcml2YXRlSXAiIDogIjE3Mi4zMC4wLjI1MiIsCiAgImRldnBh +eVByb2R1Y3RDb2RlcyIgOiBudWxsLAogICJhdmFpbGFiaWxpdHlab25lIiA6ICJ1 +cy1lYXN0LTFhIiwKICAidmVyc2lvbiIgOiAiMjAxMC0wOC0zMSIsCiAgImluc3Rh +bmNlSWQiIDogImktZjc5ZmU1NmMiLAogICJiaWxsaW5nUHJvZHVjdHMiIDogbnVs +bCwKICAiaW5zdGFuY2VUeXBlIiA6ICJ0Mi5taWNybyIsCiAgImFjY291bnRJZCIg +OiAiMTIxNjU5MDE0MzM0IiwKICAiaW1hZ2VJZCIgOiAiYW1pLWZjZTNjNjk2IiwK +ICAicGVuZGluZ1RpbWUiIDogIjIwMTYtMDQtMDhUMDM6MDE6MzhaIiwKICAiYXJj +aGl0ZWN0dXJlIiA6ICJ4ODZfNjQiLAogICJrZXJuZWxJZCIgOiBudWxsLAogICJy +YW1kaXNrSWQiIDogbnVsbCwKICAicmVnaW9uIiA6ICJ1cy1lYXN0LTEiCn0AAAAA +AAAxggEYMIIBFAIBATBpMFwxCzAJBgNVBAYTAlVTMRkwFwYDVQQIExBXYXNoaW5n +dG9uIFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYDVQQKExdBbWF6b24gV2Vi +IFNlcnZpY2VzIExMQwIJAJa6SNnlXhpnMAkGBSsOAwIaBQCgXTAYBgkqhkiG9w0B +CQMxCwYJKoZIhvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0xNjA0MDgwMzAxNDRaMCMG +CSqGSIb3DQEJBDEWBBTuUc28eBXmImAautC+wOjqcFCBVjAJBgcqhkjOOAQDBC8w +LQIVAKA54NxGHWWCz5InboDmY/GHs33nAhQ6O/ZI86NwjA9Vz3RNMUJrUPU5tAAA +AAAAAA== +-----END PKCS7----- +-----BEGIN CERTIFICATE----- +MIIC7TCCAq0CCQCWukjZ5V4aZzAJBgcqhkjOOAQDMFwxCzAJBgNVBAYTAlVTMRkw +FwYDVQQIExBXYXNoaW5ndG9uIFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYD +VQQKExdBbWF6b24gV2ViIFNlcnZpY2VzIExMQzAeFw0xMjAxMDUxMjU2MTJaFw0z +ODAxMDUxMjU2MTJaMFwxCzAJBgNVBAYTAlVTMRkwFwYDVQQIExBXYXNoaW5ndG9u +IFN0YXRlMRAwDgYDVQQHEwdTZWF0dGxlMSAwHgYDVQQKExdBbWF6b24gV2ViIFNl +cnZpY2VzIExMQzCCAbcwggEsBgcqhkjOOAQBMIIBHwKBgQCjkvcS2bb1VQ4yt/5e +ih5OO6kK/n1Lzllr7D8ZwtQP8fOEpp5E2ng+D6Ud1Z1gYipr58Kj3nssSNpI6bX3 +VyIQzK7wLclnd/YozqNNmgIyZecN7EglK9ITHJLP+x8FtUpt3QbyYXJdmVMegN6P +hviYt5JH/nYl4hh3Pa1HJdskgQIVALVJ3ER11+Ko4tP6nwvHwh6+ERYRAoGBAI1j +k+tkqMVHuAFcvAGKocTgsjJem6/5qomzJuKDmbJNu9Qxw3rAotXau8Qe+MBcJl/U +hhy1KHVpCGl9fueQ2s6IL0CaO/buycU1CiYQk40KNHCcHfNiZbdlx1E9rpUp7bnF +lRa2v1ntMX3caRVDdbtPEWmdxSCYsYFDk4mZrOLBA4GEAAKBgEbmeve5f8LIE/Gf +MNmP9CM5eovQOGx5ho8WqD+aTebs+k2tn92BBPqeZqpWRa5P/+jrdKml1qx4llHW +MXrs3IgIb6+hUIB+S8dz8/mmO0bpr76RoZVCXYab2CZedFut7qc3WUH9+EUAH5mw +vSeDCOUMYQR7R9LINYwouHIziqQYMAkGByqGSM44BAMDLwAwLAIUWXBlk40xTwSw +7HX32MxXYruse9ACFBNGmdX2ZBrVNGrN9N2f6ROk0k9K +-----END CERTIFICATE-----` diff --git a/vendor/github.com/micromdm/scep/scep/scep.go b/vendor/github.com/micromdm/scep/scep/scep.go new file mode 100644 index 00000000..b726928a --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/scep.go @@ -0,0 +1,621 @@ +// Package scep provides common functionality for encoding and decoding +// Simple Certificate Enrolment Protocol pki messages as defined by +// https://tools.ietf.org/html/draft-gutmann-scep-02 +package scep + +import ( + "bytes" + "crypto" + "crypto/rand" + "crypto/rsa" + "crypto/sha1" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/base64" + "errors" + "math/big" + + "github.com/micromdm/scep/scep/internal/pkcs7" +) + +// errors +var ( + errNotImplemented = errors.New("not implemented") + errUnknownMessageType = errors.New("unknown messageType") +) + +// The MessageType attribute specifies the type of operation performed +// by the transaction. This attribute MUST be included in all PKI +// messages. +// +// The following message types are defined: +type MessageType string + +// Undefined message types are treated as an error. +const ( + CertRep MessageType = "3" + RenewalReq = "17" + UpdateReq = "18" + PKCSReq = "19" + CertPoll = "20" + GetCert = "21" + GetCRL = "22" +) + +// PKIStatus is a SCEP pkiStatus attribute which holds transaction status information. +// All SCEP responses MUST include a pkiStatus. +// +// The following pkiStatuses are defined: +type PKIStatus string + +// Undefined pkiStatus attributes are treated as an error +const ( + SUCCESS PKIStatus = "0" + FAILURE = "2" + PENDING = "3" +) + +// FailInfo is a SCEP failInfo attribute +// +// The FailInfo attribute MUST contain one of the following failure +// reasons: +type FailInfo string + +// +const ( + BadAlg FailInfo = "0" + BadMessageCheck = "1" + BadRequest = "2" + BadTime = "3" + BadCertID = "4" +) + +// SenderNonce is a random 16 byte number. +// A sender must include the senderNonce in each transaction to a recipient. +type SenderNonce []byte + +// The RecipientNonce MUST be copied from the SenderNonce +// and included in the reply. +type RecipientNonce []byte + +// The TransactionID is a text +// string generated by the client when starting a transaction. The +// client MUST generate a unique string as the transaction identifier, +// which MUST be used for all PKI messages exchanged for a given +// enrolment, encoded as a PrintableString. +type TransactionID string + +// SCEP OIDs +var ( + oidSCEPmessageType = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 2} + oidSCEPpkiStatus = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 3} + oidSCEPfailInfo = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 4} + oidSCEPsenderNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 5} + oidSCEPrecipientNonce = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 6} + oidSCEPtransactionID = asn1.ObjectIdentifier{2, 16, 840, 1, 113733, 1, 9, 7} + oidChallengePassword = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 7} +) + +// PKIMessage defines the possible SCEP message types +type PKIMessage struct { + TransactionID + MessageType + SenderNonce + *CertRepMessage + *CSRReqMessage + + // DER Encoded PKIMessage + Raw []byte + + // parsed + p7 *pkcs7.PKCS7 + + // decrypted enveloped content + pkiEnvelope []byte + + // Used to sign message + Recipients []*x509.Certificate + + // Signer info + SignerKey *rsa.PrivateKey + SignerCert *x509.Certificate +} + +// CertRepMessage is a type of PKIMessage +type CertRepMessage struct { + PKIStatus + RecipientNonce + FailInfo + + Certificate *x509.Certificate + + degenerate []byte +} + +// CSRReqMessage can be of the type PKCSReq/RenewalReq/UpdateReq +// and includes a PKCS#10 CSR request. +// The content of this message is protected +// by the recipient public key(example CA) +type CSRReqMessage struct { + // PKCS#10 Certificate request inside the envelope + CSR *x509.CertificateRequest + + ChallengePassword string +} + +// ParsePKIMessage unmarshals a PKCS#7 signed data into a PKI message struct +func ParsePKIMessage(data []byte) (*PKIMessage, error) { + // parse PKCS#7 signed data + p7, err := pkcs7.Parse(data) + if err != nil { + return nil, err + } + + var tID TransactionID + if err := p7.UnmarshalSignedAttribute(oidSCEPtransactionID, &tID); err != nil { + return nil, err + } + + var msgType MessageType + if err := p7.UnmarshalSignedAttribute(oidSCEPmessageType, &msgType); err != nil { + return nil, err + } + + msg := &PKIMessage{ + TransactionID: tID, + MessageType: msgType, + Raw: data, + p7: p7, + } + + if err := msg.parseMessageType(); err != nil { + return nil, err + } + + return msg, nil +} + +func (msg *PKIMessage) parseMessageType() error { + switch msg.MessageType { + case CertRep: + var status PKIStatus + if err := msg.p7.UnmarshalSignedAttribute(oidSCEPpkiStatus, &status); err != nil { + return err + } + var rn RecipientNonce + if err := msg.p7.UnmarshalSignedAttribute(oidSCEPrecipientNonce, &rn); err != nil { + return err + } + if len(rn) == 0 { + return errors.New("scep pkiMessage must include recipientNonce attribute") + } + cr := &CertRepMessage{ + PKIStatus: status, + RecipientNonce: rn, + } + switch status { + case SUCCESS: + break + case FAILURE: + var fi FailInfo + if err := msg.p7.UnmarshalSignedAttribute(oidSCEPfailInfo, &fi); err != nil { + return err + } + if fi == "" { + return errors.New("scep pkiStatus FAILURE must have a failInfo attribute") + } + cr.FailInfo = fi + case PENDING: + return errNotImplemented + default: + return errors.New("unknown scep pkiStatus") + } + msg.CertRepMessage = cr + return nil + case PKCSReq, UpdateReq, RenewalReq: + var sn SenderNonce + if err := msg.p7.UnmarshalSignedAttribute(oidSCEPsenderNonce, &sn); err != nil { + return err + } + if len(sn) == 0 { + return errors.New("scep pkiMessage must include senderNonce attribute") + } + msg.SenderNonce = sn + return nil + case GetCRL, GetCert, CertPoll: + return errNotImplemented + default: + return errUnknownMessageType + } +} + +type publicKeyInfo struct { + Raw asn1.RawContent + Algorithm pkix.AlgorithmIdentifier + PublicKey asn1.BitString +} + +type tbsCertificateRequest struct { + Raw asn1.RawContent + Version int + Subject asn1.RawValue + PublicKey publicKeyInfo + RawAttributes []asn1.RawValue `asn1:"tag:0"` +} + +type certificateRequest struct { + Raw asn1.RawContent + TBSCSR tbsCertificateRequest + SignatureAlgorithm pkix.AlgorithmIdentifier + SignatureValue asn1.BitString +} + +// stdlib ignores the challengePassword attribute in csr +func parseChallengePassword(asn1Data []byte) (string, error) { + type attribute struct { + ID asn1.ObjectIdentifier + Value asn1.RawValue `asn1:"set"` + } + var csr certificateRequest + rest, err := asn1.Unmarshal(asn1Data, &csr) + if err != nil { + return "", err + } else if len(rest) != 0 { + err = asn1.SyntaxError{Msg: "trailing data"} + return "", err + } + + var password string + for _, rawAttr := range csr.TBSCSR.RawAttributes { + var attr attribute + _, err := asn1.Unmarshal(rawAttr.FullBytes, &attr) + if err != nil { + return "", err + } + if attr.ID.Equal(oidChallengePassword) { + _, err := asn1.Unmarshal(attr.Value.Bytes, &password) + if err != nil { + return "", err + } + } + } + + return password, nil +} + +// AddChallenge adds a challenge password to the CSR +func addChallenge(csr *x509.CertificateRequest, challenge string) ([]byte, error) { + // unmarshal csr + var req certificateRequest + rest, err := asn1.Unmarshal(csr.Raw, &req) + if err != nil { + return nil, err + } else if len(rest) != 0 { + err = asn1.SyntaxError{Msg: "trailing data"} + return nil, err + } + + passwordAttribute := pkix.AttributeTypeAndValue{ + Type: oidChallengePassword, + Value: []byte(challenge), + } + b, err := asn1.Marshal(passwordAttribute) + + var rawAttribute asn1.RawValue + rest, err = asn1.Unmarshal(b, &rawAttribute) + if err != nil { + return nil, err + } else if len(rest) != 0 { + err = asn1.SyntaxError{Msg: "trailing data"} + return nil, err + } + + // append attribute + req.TBSCSR.RawAttributes = append(req.TBSCSR.RawAttributes, rawAttribute) + + // recreate request + tbsCSR := tbsCertificateRequest{ + Version: 0, + Subject: req.TBSCSR.Subject, + PublicKey: req.TBSCSR.PublicKey, + RawAttributes: req.TBSCSR.RawAttributes, + } + + tbsCSRContents, err := asn1.Marshal(tbsCSR) + if err != nil { + return nil, err + } + tbsCSR.Raw = tbsCSRContents + + // marshal csr with challenge password + csrBytes, err := asn1.Marshal(certificateRequest{ + TBSCSR: tbsCSR, + SignatureAlgorithm: req.SignatureAlgorithm, + SignatureValue: req.SignatureValue, + }) + if err != nil { + return nil, err + } + + return csrBytes, nil +} + +// DecryptPKIEnvelope decrypts the pkcs envelopedData inside the SCEP PKIMessage +func (msg *PKIMessage) DecryptPKIEnvelope(cert *x509.Certificate, key *rsa.PrivateKey) error { + p7, err := pkcs7.Parse(msg.p7.Content) + if err != nil { + return err + } + msg.pkiEnvelope, err = p7.Decrypt(cert, key) + if err != nil { + return err + } + + switch msg.MessageType { + case CertRep: + certs, err := CACerts(msg.pkiEnvelope) + if err != nil { + return err + } + msg.CertRepMessage.Certificate = certs[0] + return nil + case PKCSReq, UpdateReq, RenewalReq: + csr, err := x509.ParseCertificateRequest(msg.pkiEnvelope) + if err != nil { + return err + } + // check for challengePassword + cp, err := parseChallengePassword(msg.pkiEnvelope) + if err != nil { + return err + } + msg.CSRReqMessage = &CSRReqMessage{ + CSR: csr, + ChallengePassword: cp, + } + return nil + case GetCRL, GetCert, CertPoll: + return errNotImplemented + default: + return errUnknownMessageType + } +} + +// SignCSR creates an x509.Certificate based on a template and Cert Authority credentials +// returns a new PKIMessage with CertRep data +func (msg *PKIMessage) SignCSR(crtAuth *x509.Certificate, keyAuth *rsa.PrivateKey, template *x509.Certificate) (*PKIMessage, error) { + // check if CSRReqMessage has already been decrypted + if msg.CSRReqMessage.CSR == nil { + if err := msg.DecryptPKIEnvelope(crtAuth, keyAuth); err != nil { + return nil, err + } + } + // sign the CSR creating a DER encoded cert + crtBytes, err := x509.CreateCertificate(rand.Reader, template, crtAuth, msg.CSRReqMessage.CSR.PublicKey, keyAuth) + if err != nil { + return nil, err + } + // parse the certificate + crt, err := x509.ParseCertificate(crtBytes) + if err != nil { + return nil, err + } + + // create a degenerate cert structure + deg, err := DegenerateCertificates([]*x509.Certificate{crt}) + if err != nil { + return nil, err + } + + // encrypt degenerate data using the original messages recipients + e7, err := pkcs7.Encrypt(deg, msg.p7.Certificates) + if err != nil { + return nil, err + } + + // PKIMessageAttributes to be signed + config := pkcs7.SignerInfoConfig{ + ExtraSignedAttributes: []pkcs7.Attribute{ + pkcs7.Attribute{ + Type: oidSCEPtransactionID, + Value: msg.TransactionID, + }, + pkcs7.Attribute{ + Type: oidSCEPpkiStatus, + Value: SUCCESS, + }, + pkcs7.Attribute{ + Type: oidSCEPmessageType, + Value: CertRep, + }, + pkcs7.Attribute{ + Type: oidSCEPrecipientNonce, + Value: msg.SenderNonce, + }, + }, + } + + signedData, err := pkcs7.NewSignedData(e7) + if err != nil { + return nil, err + } + // add the certificate into the signed data type + // this cert must be added before the signedData because the recipient will expect it + // as the first certificate in the array + signedData.AddCertificate(crt) + // sign the attributes + if err := signedData.AddSigner(crtAuth, keyAuth, config); err != nil { + return nil, err + } + + certRepBytes, err := signedData.Finish() + if err != nil { + return nil, err + } + + cr := &CertRepMessage{ + PKIStatus: SUCCESS, + RecipientNonce: RecipientNonce(msg.SenderNonce), + Certificate: crt, + degenerate: deg, + } + + // create a CertRep message from the original + crepMsg := &PKIMessage{ + Raw: certRepBytes, + TransactionID: msg.TransactionID, + MessageType: CertRep, + CertRepMessage: cr, + } + + return crepMsg, nil +} + +// DegenerateCertificates creates degenerate certificates pkcs#7 type +func DegenerateCertificates(certs []*x509.Certificate) ([]byte, error) { + var buf bytes.Buffer + for _, cert := range certs { + buf.Write(cert.Raw) + } + degenerate, err := pkcs7.DegenerateCertificate(buf.Bytes()) + if err != nil { + return nil, err + } + return degenerate, nil +} + +// CACerts extract CA Certificate or chain from pkcs7 degenerate signed data +func CACerts(data []byte) ([]*x509.Certificate, error) { + p7, err := pkcs7.Parse(data) + if err != nil { + return nil, err + } + return p7.Certificates, nil +} + +// NewCSRRequest creates a scep PKI PKCSReq/UpdateReq message +func NewCSRRequest(csr *x509.CertificateRequest, tmpl *PKIMessage) (*PKIMessage, error) { + csrBytes := csr.Raw + if tmpl.CSRReqMessage != nil { + if tmpl.ChallengePassword != "" { + b, err := addChallenge(csr, tmpl.ChallengePassword) + if err != nil { + return nil, err + } + csrBytes = b + } + } + e7, err := pkcs7.Encrypt(csrBytes, tmpl.Recipients) + if err != nil { + return nil, err + } + + signedData, err := pkcs7.NewSignedData(e7) + if err != nil { + return nil, err + } + + // create transaction ID from public key hash + tID, err := newTransactionID(csr.PublicKey) + if err != nil { + return nil, err + } + + sn, err := newNonce() + if err != nil { + return nil, err + } + + // PKIMessageAttributes to be signed + config := pkcs7.SignerInfoConfig{ + ExtraSignedAttributes: []pkcs7.Attribute{ + pkcs7.Attribute{ + Type: oidSCEPtransactionID, + Value: tID, + }, + pkcs7.Attribute{ + Type: oidSCEPmessageType, + Value: tmpl.MessageType, + }, + pkcs7.Attribute{ + Type: oidSCEPsenderNonce, + Value: sn, + }, + }, + } + + // sign attributes + if err := signedData.AddSigner(tmpl.SignerCert, tmpl.SignerKey, config); err != nil { + return nil, err + } + + rawPKIMessage, err := signedData.Finish() + if err != nil { + return nil, err + } + + cr := &CSRReqMessage{ + CSR: csr, + } + + newMsg := &PKIMessage{ + Raw: rawPKIMessage, + MessageType: tmpl.MessageType, + TransactionID: tID, + SenderNonce: sn, + CSRReqMessage: cr, + } + + return newMsg, nil +} + +func newNonce() (SenderNonce, error) { + size := 16 + b := make([]byte, size) + _, err := rand.Read(b) + if err != nil { + return SenderNonce{}, err + } + return SenderNonce(b), nil +} + +// use public key to create a deterministric transactionID +func newTransactionID(key crypto.PublicKey) (TransactionID, error) { + id, err := generateSubjectKeyID(key) + if err != nil { + return "", err + } + + encHash := base64.StdEncoding.EncodeToString(id) + return TransactionID(encHash), nil +} + +// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. +type rsaPublicKey struct { + N *big.Int + E int +} + +// GenerateSubjectKeyID generates SubjectKeyId used in Certificate +// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey +func generateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { + var pubBytes []byte + var err error + switch pub := pub.(type) { + case *rsa.PublicKey: + pubBytes, err = asn1.Marshal(rsaPublicKey{ + N: pub.N, + E: pub.E, + }) + if err != nil { + return nil, err + } + default: + return nil, errors.New("only RSA public key is supported") + } + + hash := sha1.Sum(pubBytes) + + return hash[:], nil +} diff --git a/vendor/github.com/micromdm/scep/scep/scep_test.go b/vendor/github.com/micromdm/scep/scep/scep_test.go new file mode 100644 index 00000000..d67452dc --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/scep_test.go @@ -0,0 +1,266 @@ +package scep_test + +import ( + "crypto" + "crypto/rand" + "crypto/rsa" + "crypto/sha1" + "crypto/x509" + "crypto/x509/pkix" + "encoding/asn1" + "encoding/pem" + "errors" + "io/ioutil" + "math/big" + "testing" + "time" + + "github.com/micromdm/scep/scep" +) + +func testParsePKIMessage(t *testing.T, data []byte) *scep.PKIMessage { + msg, err := scep.ParsePKIMessage(data) + if err != nil { + t.Fatal(err) + } + if msg.TransactionID == "" { + t.Errorf("expected TransactionID attribute") + } + if msg.MessageType == "" { + t.Errorf("expected MessageType attribute") + } + switch msg.MessageType { + case scep.CertRep: + if len(msg.RecipientNonce) == 0 { + t.Errorf("expected RecipientNonce attribute") + } + case scep.PKCSReq, scep.UpdateReq, scep.RenewalReq: + if len(msg.SenderNonce) == 0 { + t.Errorf("expected SenderNonce attribute") + } + } + return msg +} + +func TestDecryptPKIEnvelopeCSR(t *testing.T) { + pkcsReq := loadTestFile(t, "testdata/PKCSReq.der") + msg := testParsePKIMessage(t, pkcsReq) + cacert, cakey := loadCACredentials(t) + err := msg.DecryptPKIEnvelope(cacert, cakey) + if err != nil { + t.Fatal(err) + } + if msg.CSRReqMessage.CSR == nil { + t.Errorf("expected non-nil CSR field") + } +} + +func TestDecryptPKIEnvelopeCert(t *testing.T) { + certRep := loadTestFile(t, "testdata/CertRep.der") + testParsePKIMessage(t, certRep) + // clientcert, clientkey := loadClientCredentials(t) + // err = msg.DecryptPKIEnvelope(clientcert, clientkey) + // if err != nil { + // t.Fatal(err) + // } +} + +func TestSignCSR(t *testing.T) { + pkcsReq := loadTestFile(t, "testdata/PKCSReq.der") + msg := testParsePKIMessage(t, pkcsReq) + cacert, cakey := loadCACredentials(t) + err := msg.DecryptPKIEnvelope(cacert, cakey) + if err != nil { + t.Fatal(err) + } + csr := msg.CSRReqMessage.CSR + id, err := GenerateSubjectKeyID(csr.PublicKey) + if err != nil { + t.Fatal(err) + } + tmpl := &x509.Certificate{ + SerialNumber: big.NewInt(4), + Subject: csr.Subject, + NotBefore: time.Now().Add(-600).UTC(), + NotAfter: time.Now().AddDate(1, 0, 0).UTC(), + SubjectKeyId: id, + ExtKeyUsage: []x509.ExtKeyUsage{ + x509.ExtKeyUsageAny, + x509.ExtKeyUsageClientAuth, + }, + } + certRep, err := msg.SignCSR(cacert, cakey, tmpl) + if err != nil { + t.Fatal(err) + } + testParsePKIMessage(t, certRep.Raw) +} + +func TestNewCSRRequest(t *testing.T) { + key, err := newRSAKey(2048) + if err != nil { + t.Fatal(err) + } + derBytes, err := newCSR(key, "john.doe@example.com", "US", "com.apple.scep.2379B935-294B-4AF1-A213-9BD44A2C6688") + if err != nil { + t.Fatal(err) + } + csr, err := x509.ParseCertificateRequest(derBytes) + if err != nil { + t.Fatal(err) + } + clientcert, clientkey := loadClientCredentials(t) + cacert, cakey := loadCACredentials(t) + tmpl := &scep.PKIMessage{ + MessageType: scep.PKCSReq, + Recipients: []*x509.Certificate{cacert}, + SignerCert: clientcert, + SignerKey: clientkey, + } + + pkcsreq, err := scep.NewCSRRequest(csr, tmpl) + if err != nil { + t.Fatal(err) + } + msg := testParsePKIMessage(t, pkcsreq.Raw) + err = msg.DecryptPKIEnvelope(cacert, cakey) + if err != nil { + t.Fatal(err) + } +} + +// create a new RSA private key +func newRSAKey(bits int) (*rsa.PrivateKey, error) { + private, err := rsa.GenerateKey(rand.Reader, bits) + if err != nil { + return nil, err + } + return private, nil +} + +// create a CSR using the same parameters as Keychain Access would produce +func newCSR(priv *rsa.PrivateKey, email, country, cname string) ([]byte, error) { + subj := pkix.Name{ + Country: []string{country}, + CommonName: cname, + ExtraNames: []pkix.AttributeTypeAndValue{pkix.AttributeTypeAndValue{ + Type: []int{1, 2, 840, 113549, 1, 9, 1}, + Value: email, + }}, + } + template := &x509.CertificateRequest{ + Subject: subj, + } + return x509.CreateCertificateRequest(rand.Reader, template, priv) +} + +func loadTestFile(t *testing.T, path string) []byte { + data, err := ioutil.ReadFile(path) + if err != nil { + t.Fatal(err) + } + return data +} + +func loadCACredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { + cert, err := loadCertFromFile("testdata/testca/ca.crt") + if err != nil { + t.Fatal(err) + } + key, err := loadKeyFromFile("testdata/testca/ca.key") + if err != nil { + t.Fatal(err) + } + return cert, key +} + +func loadClientCredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { + cert, err := loadCertFromFile("testdata/testclient/client.pem") + if err != nil { + t.Fatal(err) + } + key, err := loadKeyFromFile("testdata/testclient/client.key") + if err != nil { + t.Fatal(err) + } + return cert, key +} + +const ( + rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" + certificatePEMBlockType = "CERTIFICATE" +) + +func loadCertFromFile(path string) (*x509.Certificate, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != certificatePEMBlockType { + return nil, errors.New("unmatched type or headers") + } + return x509.ParseCertificate(pemBlock.Bytes) +} + +// load an encrypted private key from disk +func loadKeyFromFile(path string) (*rsa.PrivateKey, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != rsaPrivateKeyPEMBlockType { + return nil, errors.New("unmatched type or headers") + } + + // testca key has a password + if len(pemBlock.Headers) > 0 { + password := []byte("") + b, err := x509.DecryptPEMBlock(pemBlock, password) + if err != nil { + return nil, err + } + return x509.ParsePKCS1PrivateKey(b) + } + + return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) + +} + +// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. +type rsaPublicKey struct { + N *big.Int + E int +} + +// GenerateSubjectKeyID generates SubjectKeyId used in Certificate +// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey +func GenerateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { + var pubBytes []byte + var err error + switch pub := pub.(type) { + case *rsa.PublicKey: + pubBytes, err = asn1.Marshal(rsaPublicKey{ + N: pub.N, + E: pub.E, + }) + if err != nil { + return nil, err + } + default: + return nil, errors.New("only RSA public key is supported") + } + + hash := sha1.Sum(pubBytes) + + return hash[:], nil +} diff --git a/vendor/github.com/micromdm/scep/scep/testdata/CertRep.der b/vendor/github.com/micromdm/scep/scep/testdata/CertRep.der new file mode 100755 index 00000000..16ebc2be Binary files /dev/null and b/vendor/github.com/micromdm/scep/scep/testdata/CertRep.der differ diff --git a/vendor/github.com/micromdm/scep/scep/testdata/PKCSReq.der b/vendor/github.com/micromdm/scep/scep/testdata/PKCSReq.der new file mode 100755 index 00000000..71938c06 Binary files /dev/null and b/vendor/github.com/micromdm/scep/scep/testdata/PKCSReq.der differ diff --git a/vendor/github.com/micromdm/scep/scep/testdata/testca/ca.crt.info b/vendor/github.com/micromdm/scep/scep/testdata/testca/ca.crt.info new file mode 100644 index 00000000..d8263ee9 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/testdata/testca/ca.crt.info @@ -0,0 +1 @@ +2 \ No newline at end of file diff --git a/vendor/github.com/micromdm/scep/scep/testdata/testca/ca.pem b/vendor/github.com/micromdm/scep/scep/testdata/testca/ca.pem new file mode 100644 index 00000000..037b296c --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/testdata/testca/ca.pem @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFODCCAyCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAtMQwwCgYDVQQGEwNVU0Ex +EDAOBgNVBAoTB2V0Y2QtY2ExCzAJBgNVBAsTAkNBMB4XDTE2MDUyOTEzNDcwNVoX +DTI2MDUyOTEzNDcwOFowLTEMMAoGA1UEBhMDVVNBMRAwDgYDVQQKEwdldGNkLWNh +MQswCQYDVQQLEwJDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALEG +S866Uf79znmx8+BakJ17tox8VYem0NZzPc2jF4RVWXfT481Yz9jdsjZubMCFuJiI +JzpMBT7RzXvZvuzMzZEe77Tb0mM+83t5kVwWWuxkEz7HQn0tWxuLR7NGaAi5MH53 +pcSGRNH8RgC7WdhyQ/3HwNGWObe0wQT69tfz1pHDSvNR9v7DS9KIiGsMc+dcqayz +n3YQuwEV8nD1KGenxEFjFh0NsP5FKrzDrsvzdFOWLJ3jedfDCSQSe0y33syZIYAQ +wS2/b+io6GMWDQemcirN9QiI1NGkcN9zioPRuYPxkaxGNa0O+3cTgA8egTFMigvI +4ZFsmERfZkJM4sBMK1uUmxXKb87nA1zooPvPk1KGQChXBEnrkHPbkP1VO+yYOS4m +t9LDweGVS6GoC5vjqQgymOHecaNfKpBnU6t7fP/aEZUF+6mxRKofolR/hTknkVNc +q2nrXEJpz8J73Iq8rkL0rNAEu1h83npPAoUgdFhwHzlq9ShRbz+ZQTxdAv5MOVs+ +6F9qcmbv/6C4xc1N1xH2NAJ8aFZTxsw4ny43hi7DgyRh1LJxcb2Bp7JMaD56CMSA +0zJqxIiV5kGUwbmrBjXMyvjYzx/0qI3j3bZl3p8BjZgyjkvOP0nArP3bby5mEUYx +i7+YgPm8dfGIzPh19I4oFReszOJl+JrdLnbf45efAgMBAAGjYzBhMA4GA1UdDwEB +/wQEAwICBDAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBT6XD/PBaV7GbFEnxOm +3OJ3deamkzAfBgNVHSMEGDAWgBT6XD/PBaV7GbFEnxOm3OJ3deamkzANBgkqhkiG +9w0BAQsFAAOCAgEAC6yBHrRElZ7ovDrqjVBf8fLG+nINETPJ/kPTlTNtvqClLaeE +NKPH6JVp0/uusoKmqvE0LxyBEdP7waHQVq2XnfYggDCNjAUFxdv7OKAwlBjJ0JGs +5RsJ9DEehyLecnDDDhte92M2xUcfMet1BmuizLDDKaUU17sI1g/UNE+c7hViZA2J +e+wezVOUZqCY0pICsm4ar8JBY/pfUZ+1J00AZJtXuVWqK5GYGkrLZ7ZjNzzDF0cY +UmJxki5rj11XpCCQOZjVB+Pp3t7YpUOey1EC+1fKKrdS40zaRS3VVgh+Guavs5HV +egBzKDQUuRrZDbodJSv28RYlVbFTmkl3hGGNE0l2v0L2XHasZHoBkDZzz9nLuiI8 +ZdhWS+fn7dbswN9WzzB+dPzKS1WkTj5RXL/luI/7+fYNQyvIJYdnNCegyi2C2yTD +a/vmFJkBU+uLHWsW9a8R5Ca7A91ltJobTJE3uwxdXuZMTrmlWKsEbhqHCqO7d0j8 +IgYGxDo9ysfA4AOiNDxlp7lXxV/JFOsuGXNdFKcDFykLZ5u21X9ho9fptWJDP9JN +NNOXjC0Jv2UGZrHze6IqyL5JqxOGpK22PQIwpZwExwijUom+LH5VEXK1zpXzwC93 +WXWVtGOW4yEqv0VTn7vafIeM5GBTJ44ggpkp4RpFWoBMZcAFj8gE/9AUaHo= +-----END CERTIFICATE----- diff --git a/vendor/github.com/micromdm/scep/scep/testdata/testca/sceptest.mobileconfig b/vendor/github.com/micromdm/scep/scep/testdata/testca/sceptest.mobileconfig new file mode 100644 index 00000000..8ee4942f --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/testdata/testca/sceptest.mobileconfig @@ -0,0 +1,115 @@ + + + + + PayloadContent + + + PayloadContent + + Key Type + RSA + Keysize + 1024 + Retries + 3 + RetryDelay + 10 + URL + http://localhost:9001/scep + + PayloadDescription + Configures SCEP settings + PayloadDisplayName + SCEP + PayloadIdentifier + com.apple.security.scep.063D7953-1338-4BF0-8F99-913382996224 + PayloadType + com.apple.security.scep + PayloadUUID + 063D7953-1338-4BF0-8F99-913382996224 + PayloadVersion + 1 + + + PayloadCertificateFileName + ca.crt + PayloadContent + + LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUZPRENDQXlD + Z0F3SUJBZ0lCQVRBTkJna3Foa2lHOXcwQkFRc0ZBREF0TVF3d0Nn + WURWUVFHRXdOVlUwRXgKRURBT0JnTlZCQW9UQjJWMFkyUXRZMkV4 + Q3pBSkJnTlZCQXNUQWtOQk1CNFhEVEUyTURVeU9URXpORGN3TlZv + WApEVEkyTURVeU9URXpORGN3T0Zvd0xURU1NQW9HQTFVRUJoTURW + Vk5CTVJBd0RnWURWUVFLRXdkbGRHTmtMV05oCk1Rc3dDUVlEVlFR + TEV3SkRRVENDQWlJd0RRWUpLb1pJaHZjTkFRRUJCUUFEZ2dJUEFE + Q0NBZ29DZ2dJQkFMRUcKUzg2NlVmNzl6bm14OCtCYWtKMTd0b3g4 + VlllbTBOWnpQYzJqRjRSVldYZlQ0ODFZejlqZHNqWnViTUNGdUpp + SQpKenBNQlQ3UnpYdlp2dXpNelpFZTc3VGIwbU0rODN0NWtWd1dX + dXhrRXo3SFFuMHRXeHVMUjdOR2FBaTVNSDUzCnBjU0dSTkg4UmdD + N1dkaHlRLzNId05HV09iZTB3UVQ2OXRmejFwSERTdk5SOXY3RFM5 + S0lpR3NNYytkY3FheXoKbjNZUXV3RVY4bkQxS0dlbnhFRmpGaDBO + c1A1RktyekRyc3Z6ZEZPV0xKM2plZGZEQ1NRU2UweTMzc3laSVlB + UQp3UzIvYitpbzZHTVdEUWVtY2lyTjlRaUkxTkdrY045emlvUFJ1 + WVB4a2F4R05hME8rM2NUZ0E4ZWdURk1pZ3ZJCjRaRnNtRVJmWmtK + TTRzQk1LMXVVbXhYS2I4N25BMXpvb1B2UGsxS0dRQ2hYQkVucmtI + UGJrUDFWTyt5WU9TNG0KdDlMRHdlR1ZTNkdvQzV2anFRZ3ltT0hl + Y2FOZktwQm5VNnQ3ZlAvYUVaVUYrNm14UktvZm9sUi9oVGtua1ZO + YwpxMm5yWEVKcHo4SjczSXE4cmtMMHJOQUV1MWg4M25wUEFvVWdk + Rmh3SHpscTlTaFJieitaUVR4ZEF2NU1PVnMrCjZGOXFjbWJ2LzZD + NHhjMU4xeEgyTkFKOGFGWlR4c3c0bnk0M2hpN0RneVJoMUxKeGNi + MkJwN0pNYUQ1NkNNU0EKMHpKcXhJaVY1a0dVd2JtckJqWE15dmpZ + engvMHFJM2ozYlpsM3A4QmpaZ3lqa3ZPUDBuQXJQM2JieTVtRVVZ + eAppNytZZ1BtOGRmR0l6UGgxOUk0b0ZSZXN6T0psK0pyZExuYmY0 + NWVmQWdNQkFBR2pZekJoTUE0R0ExVWREd0VCCi93UUVBd0lDQkRB + UEJnTlZIUk1CQWY4RUJUQURBUUgvTUIwR0ExVWREZ1FXQkJUNlhE + L1BCYVY3R2JGRW54T20KM09KM2RlYW1rekFmQmdOVkhTTUVHREFX + Z0JUNlhEL1BCYVY3R2JGRW54T20zT0ozZGVhbWt6QU5CZ2txaGtp + Rwo5dzBCQVFzRkFBT0NBZ0VBQzZ5QkhyUkVsWjdvdkRycWpWQmY4 + ZkxHK25JTkVUUEova1BUbFROdHZxQ2xMYWVFCk5LUEg2SlZwMC91 + dXNvS21xdkUwTHh5QkVkUDd3YUhRVnEyWG5mWWdnRENOakFVRnhk + djdPS0F3bEJqSjBKR3MKNVJzSjlERWVoeUxlY25ERERodGU5Mk0y + eFVjZk1ldDFCbXVpekxEREthVVUxN3NJMWcvVU5FK2M3aFZpWkEy + SgplK3dlelZPVVpxQ1kwcElDc200YXI4SkJZL3BmVVorMUowMEFa + SnRYdVZXcUs1R1lHa3JMWjdaak56ekRGMGNZClVtSnhraTVyajEx + WHBDQ1FPWmpWQitQcDN0N1lwVU9leTFFQysxZktLcmRTNDB6YVJT + M1ZWZ2grR3VhdnM1SFYKZWdCektEUVV1UnJaRGJvZEpTdjI4Ulls + VmJGVG1rbDNoR0dORTBsMnYwTDJYSGFzWkhvQmtEWnp6OW5MdWlJ + OApaZGhXUytmbjdkYnN3TjlXenpCK2RQektTMVdrVGo1UlhML2x1 + SS83K2ZZTlF5dklKWWRuTkNlZ3lpMkMyeVRECmEvdm1GSmtCVSt1 + TEhXc1c5YThSNUNhN0E5MWx0Sm9iVEpFM3V3eGRYdVpNVHJtbFdL + c0ViaHFIQ3FPN2QwajgKSWdZR3hEbzl5c2ZBNEFPaU5EeGxwN2xY + eFYvSkZPc3VHWE5kRktjREZ5a0xaNXUyMVg5aG85ZnB0V0pEUDlK + TgpOTk9YakMwSnYyVUdackh6ZTZJcXlMNUpxeE9HcEsyMlBRSXdw + WndFeHdpalVvbStMSDVWRVhLMXpwWHp3QzkzCldYV1Z0R09XNHlF + cXYwVlRuN3ZhZkllTTVHQlRKNDRnZ3BrcDRScEZXb0JNWmNBRmo4 + Z0UvOUFVYUhvPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + + PayloadDescription + Configures certificate settings. + PayloadDisplayName + ca.crt + PayloadIdentifier + com.apple.security.root.2E5B325F-84CA-4914-844F-703F9C4B11CE + PayloadType + com.apple.security.root + PayloadUUID + 2E5B325F-84CA-4914-844F-703F9C4B11CE + PayloadVersion + 1 + + + PayloadDisplayName + scept + PayloadIdentifier + vvrantchmbp.local.A795EFE8-60CA-47DA-92F3-FE2E435D800F + PayloadRemovalDisallowed + + PayloadType + Configuration + PayloadUUID + 7F0CF6ED-09FF-490E-AD53-89ACB920CD37 + PayloadVersion + 1 + + diff --git a/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.pem b/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.pem new file mode 100644 index 00000000..ca003130 --- /dev/null +++ b/vendor/github.com/micromdm/scep/scep/testdata/testclient/client.pem @@ -0,0 +1,28 @@ +Bag Attributes + friendlyName: com.apple.security.scep.063D7953-1338-4BF0-8F99-913382996224 + localKeyID: A1 30 90 76 1A 30 F6 66 64 F8 5D 37 43 3D 20 65 E1 11 2B A1 +subject=/CN=com.apple.security.scep.063D7953-1338-4BF0-8F99-913382996224 +issuer=/C=USA/O=etcd-ca/OU=CA +-----BEGIN CERTIFICATE----- +MIIDyDCCAbCgAwIBAgIBBDANBgkqhkiG9w0BAQsFADAtMQwwCgYDVQQGEwNVU0Ex +EDAOBgNVBAoTB2V0Y2QtY2ExCzAJBgNVBAsTAkNBMB4XDTE2MDUzMTExMzAxNFoX +DTE3MDUzMTExMzAxNFowRzFFMEMGA1UEAxM8Y29tLmFwcGxlLnNlY3VyaXR5LnNj +ZXAuMDYzRDc5NTMtMTMzOC00QkYwLThGOTktOTEzMzgyOTk2MjI0MIGfMA0GCSqG +SIb3DQEBAQUAA4GNADCBiQKBgQDT9YGr0H8dpozAEi5l2XkWyKy2JD3yEybI9A1Z +DXcK/78UPQ+C4tBb6BTRJWDWoZFlFcHUGbZWXbySPw6ggBsLl4feF1A+hjtCjlZs +RF4mnfctixkrdP+UGl37UunsW63mn8uM6oM+7elhB2zRscZrZPBDKZx1V+Et+BFr +X49xNwIDAQABo10wWzAZBgNVHSUEEjAQBgRVHSUABggrBgEFBQcDAjAdBgNVHQ4E +FgQUoTCQdhow9mZk+F03Qz0gZeERK6EwHwYDVR0jBBgwFoAU+lw/zwWlexmxRJ8T +ptzid3XmppMwDQYJKoZIhvcNAQELBQADggIBACWTrU5VMLd+kVu/2AxJMbCmCFd/ +DJNvCuGqCE4v3As11CUdD5iiypj6bWfqJ4fRhT8N+mMj2CGyUUCh2f3HCGitNWht +F6WJDjlDeoFAklrs7i/nGHfNMVEewkoZ0YEv+B4ShPujj26+8Rwc3zmkj7Xy3G2j +p9pEv5IU3TEjlGdlzsRLqMVkh/Y/qbMfKHS35OQOqk+n7OGp5IgE2qp2BhvNXW/9 ++x+OTNnSjoQWivqKAuw9Wjway5b++Gi0DSSqn+fhhlJFa1UE5USDPx7OePeTctpF +nCeNi1HspTcKfTzWHBH+A47+f8uUU2akhbZ50ve9rvXO+PEt0McjiJctH39g/gsm +eUbO4jll+3X77/y8Fd4nBqj6+EbIus6xg5J2kkp2goDk7Mjr9NMEqgAYCKfAtqKW +rXBELcmgE4scJ85xXdh9mB8OlUuh+YShifpOlB3b24VQSbPny5aLHivIBqRQAYKw +cuh0DTIOx3MefQR2W3+rc0f5Q92ntT24k2jD4QXl7BfWsGr6fF5dJE26QJANOgQH +T1qnfIlaEirJxV+Z/E+NKN1wFQNUjgSM4GYpAOtOJPCAH6HbCTa3Mjp2/TkZBAoK +wPNcmfPhLCnQNFGYmAQP2u3naPdFZHyAhnMsRJxCh5UVcD/bOfk0DevEOimCYgki +WrNcgABYGlAaBpo7 +-----END CERTIFICATE----- diff --git a/vendor/github.com/micromdm/scep/server/endpoint.go b/vendor/github.com/micromdm/scep/server/endpoint.go new file mode 100644 index 00000000..6278a713 --- /dev/null +++ b/vendor/github.com/micromdm/scep/server/endpoint.go @@ -0,0 +1,17 @@ +package scepserver + +// SCEPRequest is a SCEP server request. +type SCEPRequest struct { + Operation string + Message []byte + Err error // request error +} + +// SCEPResponse is a SCEP server response. +// Business errors will be encoded as a CertRep message +// with pkiStatus FAILURE and a failInfo attribute. +type SCEPResponse struct { + CACertNum int //chain + Data []byte + Err error // response error +} diff --git a/vendor/github.com/micromdm/scep/server/service.go b/vendor/github.com/micromdm/scep/server/service.go new file mode 100644 index 00000000..8f094c00 --- /dev/null +++ b/vendor/github.com/micromdm/scep/server/service.go @@ -0,0 +1,240 @@ +package scepserver + +import ( + "crypto" + "crypto/rsa" + "crypto/sha1" + "crypto/x509" + "encoding/asn1" + "errors" + "math/big" + "time" + + "github.com/micromdm/scep/depot" + "github.com/micromdm/scep/scep" + "golang.org/x/net/context" +) + +// Service is the interface for all supported SCEP server operations. +type Service interface { + // GetCACaps returns a list of options + // which are supported by the server. + GetCACaps(ctx context.Context) ([]byte, error) + + // GetCACert returns CA certificate or + // a CA certificate chain with intermediates + // in a PKCS#7 Degenerate Certificates format + GetCACert(ctx context.Context) ([]byte, int, error) + + // PKIOperation handles incoming SCEP messages such as PKCSReq and + // sends back a CertRep PKIMessag. + PKIOperation(ctx context.Context, msg []byte) ([]byte, error) + + // GetNextCACert returns a replacement certificate or certificate chain + // when the old one expires. The response format is a PKCS#7 Degenerate + // Certificates type. + GetNextCACert(ctx context.Context) ([]byte, error) +} + +type service struct { + depot depot.Depot + ca []*x509.Certificate // CA cert or chain + caKey *rsa.PrivateKey + caKeyPassword []byte + csrTemplate *x509.Certificate + challengePassword string + allowRenewal int // days before expiry, 0 to disable + clientValidity int // client cert validity in days +} + +func (svc service) GetCACaps(ctx context.Context) ([]byte, error) { + defaultCaps := []byte(`POSTPKIOperation`) + return defaultCaps, nil +} + +func (svc service) GetCACert(ctx context.Context) ([]byte, int, error) { + if len(svc.ca) == 0 { + return nil, 0, errors.New("missing CA Cert") + } + if len(svc.ca) == 1 { + return svc.ca[0].Raw, 1, nil + } + data, err := scep.DegenerateCertificates(svc.ca) + return data, len(svc.ca), err +} + +func (svc service) PKIOperation(ctx context.Context, data []byte) ([]byte, error) { + msg, err := scep.ParsePKIMessage(data) + if err != nil { + // handle err + return nil, err + } + ca := svc.ca[0] + if err := msg.DecryptPKIEnvelope(svc.ca[0], svc.caKey); err != nil { + return nil, err + } + + // validate challenge passwords + if msg.MessageType == scep.PKCSReq { + if !svc.challengePasswordMatch(msg.CSRReqMessage.ChallengePassword) { + // handle err + return nil, errors.New("scep challenge password does not match") + } + } + + csr := msg.CSRReqMessage.CSR + id, err := generateSubjectKeyID(csr.PublicKey) + if err != nil { + return nil, err + } + + serial, err := svc.depot.Serial() + if err != nil { + return nil, err + } + + duration := svc.clientValidity + + // create cert template + tmpl := &x509.Certificate{ + SerialNumber: serial, + Subject: csr.Subject, + NotBefore: time.Now().Add(-600).UTC(), + NotAfter: time.Now().AddDate(0, 0, duration).UTC(), + SubjectKeyId: id, + KeyUsage: x509.KeyUsageDigitalSignature, + ExtKeyUsage: []x509.ExtKeyUsage{ + x509.ExtKeyUsageClientAuth, + }, + } + + certRep, err := msg.SignCSR(ca, svc.caKey, tmpl) + if err != nil { + return nil, err + } + + crt := certRep.CertRepMessage.Certificate + name := certName(crt) + + // Test if this certificate is already in the CADB, revoke if needed + // revocation is done if the validity of the existing certificate is + // less than allowRenewal (14 days by default) + err = svc.depot.HasCN(name, svc.allowRenewal, crt, false) + if err != nil { + return nil, err + } + + if err := svc.depot.Put(name, crt); err != nil { + return nil, err + } + + return certRep.Raw, nil + +} + +func certName(crt *x509.Certificate) string { + if crt.Subject.CommonName != "" { + return crt.Subject.CommonName + } + return string(crt.Signature) +} + +func (svc service) GetNextCACert(ctx context.Context) ([]byte, error) { + panic("not implemented") +} + +func (svc service) challengePasswordMatch(pw string) bool { + if svc.challengePassword == "" { + // empty password, don't validate + return true + } + if svc.challengePassword == pw { + return true + } + return false +} + +// ServiceOption is a server configuration option +type ServiceOption func(*service) error + +// ChallengePassword is an optional argument to NewService +// which allows setting a preshared key for SCEP. +func ChallengePassword(pw string) ServiceOption { + return func(s *service) error { + s.challengePassword = pw + return nil + } +} + +// CAKeyPassword is an optional argument to NewService for +// specifying the CA private key password. +func CAKeyPassword(pw []byte) ServiceOption { + return func(s *service) error { + s.caKeyPassword = pw + return nil + } +} + +// allowRenewal sets the days before expiry which we are allowed to renew (optional) +func AllowRenewal(duration int) ServiceOption { + return func(s *service) error { + s.allowRenewal = duration + return nil + } +} + +// ClientValidity sets the validity of signed client certs in days (optional parameter) +func ClientValidity(duration int) ServiceOption { + return func(s *service) error { + s.clientValidity = duration + return nil + } +} + +// NewService creates a new scep service +func NewService(depot depot.Depot, opts ...ServiceOption) (Service, error) { + s := &service{ + depot: depot, + } + for _, opt := range opts { + if err := opt(s); err != nil { + return nil, err + } + } + + var err error + s.ca, s.caKey, err = depot.CA(s.caKeyPassword) + if err != nil { + return nil, err + } + return s, nil +} + +// rsaPublicKey reflects the ASN.1 structure of a PKCS#1 public key. +type rsaPublicKey struct { + N *big.Int + E int +} + +// GenerateSubjectKeyID generates SubjectKeyId used in Certificate +// ID is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey +func generateSubjectKeyID(pub crypto.PublicKey) ([]byte, error) { + var pubBytes []byte + var err error + switch pub := pub.(type) { + case *rsa.PublicKey: + pubBytes, err = asn1.Marshal(rsaPublicKey{ + N: pub.N, + E: pub.E, + }) + if err != nil { + return nil, err + } + default: + return nil, errors.New("only RSA public key is supported") + } + + hash := sha1.Sum(pubBytes) + + return hash[:], nil +} diff --git a/vendor/github.com/micromdm/scep/server/service_logging.go b/vendor/github.com/micromdm/scep/server/service_logging.go new file mode 100644 index 00000000..3c4a1e8d --- /dev/null +++ b/vendor/github.com/micromdm/scep/server/service_logging.go @@ -0,0 +1,54 @@ +package scepserver + +import ( + "time" + + "github.com/go-kit/kit/log" + "golang.org/x/net/context" +) + +type loggingService struct { + logger log.Logger + Service +} + +// NewLoggingService creates adds logging to the SCEP service +func NewLoggingService(logger log.Logger, s Service) Service { + return &loggingService{logger, s} +} + +func (mw loggingService) GetCACaps(ctx context.Context) (caps []byte, err error) { + defer func(begin time.Time) { + _ = mw.logger.Log( + "method", "GetCACaps", + "err", err, + "took", time.Since(begin), + ) + }(time.Now()) + caps, err = mw.Service.GetCACaps(ctx) + return +} + +func (mw loggingService) GetCACert(ctx context.Context) (cert []byte, certNum int, err error) { + defer func(begin time.Time) { + _ = mw.logger.Log( + "method", "GetCACert", + "err", err, + "took", time.Since(begin), + ) + }(time.Now()) + cert, certNum, err = mw.Service.GetCACert(ctx) + return +} + +func (mw loggingService) PKIOperation(ctx context.Context, data []byte) (certRep []byte, err error) { + defer func(begin time.Time) { + _ = mw.logger.Log( + "method", "PKIOperation", + "err", err, + "took", time.Since(begin), + ) + }(time.Now()) + certRep, err = mw.Service.PKIOperation(ctx, data) + return +} diff --git a/vendor/github.com/micromdm/scep/server/transport.go b/vendor/github.com/micromdm/scep/server/transport.go new file mode 100644 index 00000000..a2fb6648 --- /dev/null +++ b/vendor/github.com/micromdm/scep/server/transport.go @@ -0,0 +1,181 @@ +package scepserver + +import ( + "bytes" + "errors" + "fmt" + "io/ioutil" + "net/http" + + "github.com/go-kit/kit/endpoint" + kitlog "github.com/go-kit/kit/log" + kithttp "github.com/go-kit/kit/transport/http" + "golang.org/x/net/context" +) + +// ServiceHandler is an HTTP Handler for a SCEP endpoint. +func ServiceHandler(ctx context.Context, svc Service, logger kitlog.Logger) http.Handler { + opts := []kithttp.ServerOption{ + kithttp.ServerErrorLogger(logger), + kithttp.ServerBefore(updateContext), + } + + scepHandler := kithttp.NewServer( + ctx, + makeSCEPEndpoint(svc), + decodeSCEPRequest, + encodeSCEPResponse, + opts..., + ) + + mux := http.NewServeMux() + mux.Handle("/scep", scepHandler) + return mux +} + +func updateContext(ctx context.Context, r *http.Request) context.Context { + q := r.URL.Query() + if _, ok := q["operation"]; ok { + ctx = context.WithValue(ctx, "operation", q.Get("operation")) + } + return ctx +} + +// EncodeSCEPRequest encodes a SCEP http request +func EncodeSCEPRequest(ctx context.Context, r *http.Request, request interface{}) error { + req := request.(SCEPRequest) + params := r.URL.Query() + params.Set("operation", req.Operation) + switch r.Method { + case "GET": + if len(req.Message) > 0 { + return errors.New("only POSTPKIOperation supported") + } + case "POST": + var buf bytes.Buffer + _, err := buf.Write(req.Message) + if err != nil { + return err + } + r.Body = ioutil.NopCloser(&buf) + default: + return errors.New("method not supported") + } + r.URL.RawQuery = params.Encode() + return nil +} + +// DecodeSCEPRequest decodes an HTTP request to the SCEP server +// extracting the Operation and Message. +func decodeSCEPRequest(ctx context.Context, r *http.Request) (interface{}, error) { + msg, err := message(r) + if err != nil { + return nil, err + } + + request := SCEPRequest{ + Message: msg, + } + + return request, nil +} + +// extract message from request +func message(r *http.Request) ([]byte, error) { + switch r.Method { + case "GET": + var msg string + q := r.URL.Query() + if _, ok := q["message"]; ok { + msg = q.Get("message") + } + return []byte(msg), nil + case "POST": + return ioutil.ReadAll(r.Body) + default: + return nil, errors.New("method not supported") + } +} + +// EncodeSCEPResponse writes a SCEP response back to the SCEP client. +func encodeSCEPResponse(ctx context.Context, w http.ResponseWriter, response interface{}) error { + resp := response.(SCEPResponse) + if resp.Err != nil { + fmt.Println(resp.Err) + return resp.Err + } + w.Header().Set("Content-Type", contentHeader(ctx, resp.CACertNum)) + w.Write(resp.Data) + return nil +} + +// DecodeSCEPResponse decodes a SCEP response +func DecodeSCEPResponse(ctx context.Context, r *http.Response) (interface{}, error) { + data, err := ioutil.ReadAll(r.Body) + if err != nil { + return nil, err + } + resp := SCEPResponse{ + Data: data, + } + header := r.Header.Get("Content-Type") + if header == certChainHeader { + // TODO decode the response instead of just passing []byte around + // 0 or 1 + resp.CACertNum = 2 + } + return resp, nil +} + +const ( + certChainHeader = "application/x-x509-ca-ra-cert" + leafHeader = "application/x-x509-ca-cert" + pkiOpHeader = "application/x-pki-message" +) + +func contentHeader(ctx context.Context, certNum int) string { + op := ctx.Value("operation") + switch op { + case "GetCACert": + if certNum > 1 { + return certChainHeader + } + return leafHeader + case "PKIOperation": + return pkiOpHeader + default: + return "text/plain" + } +} + +func makeSCEPEndpoint(svc Service) endpoint.Endpoint { + return func(ctx context.Context, request interface{}) (interface{}, error) { + op := ctx.Value("operation") + if op == nil { + return SCEPResponse{Err: errors.New("unknown operation")}, nil + } + req := request.(SCEPRequest) + switch op { + case "GetCACaps": + caps, err := svc.GetCACaps(ctx) + if err != nil { + return SCEPResponse{Err: err}, nil + } + return SCEPResponse{Data: caps}, nil + case "GetCACert": + cert, certNum, err := svc.GetCACert(ctx) + if err != nil { + return SCEPResponse{Err: err, CACertNum: certNum}, nil + } + return SCEPResponse{Data: cert}, nil + case "PKIOperation": + resp, err := svc.PKIOperation(ctx, req.Message) + if err != nil { + return SCEPResponse{Err: err}, nil + } + return SCEPResponse{Data: resp}, nil + default: + return nil, errors.New("operation not implemented") + } + } +} diff --git a/vendor/github.com/micromdm/scep/server/transport_test.go b/vendor/github.com/micromdm/scep/server/transport_test.go new file mode 100644 index 00000000..03a85cef --- /dev/null +++ b/vendor/github.com/micromdm/scep/server/transport_test.go @@ -0,0 +1,177 @@ +package scepserver_test + +import ( + "bytes" + "crypto/rand" + "crypto/rsa" + "crypto/x509" + "crypto/x509/pkix" + "encoding/pem" + "errors" + "io/ioutil" + "net/http" + "net/http/httptest" + "testing" + + kitlog "github.com/go-kit/kit/log" + "golang.org/x/net/context" + + "github.com/micromdm/scep/server" +) + +func TestCACaps(t *testing.T) { + server, _ := newServer(t) + defer server.Close() + url := server.URL + "/scep?operation=GetCACaps" + resp, err := http.Get(url) + if err != nil { + t.Fatal(err) + } + if resp.StatusCode != http.StatusOK { + t.Error("expected", http.StatusOK, "got", resp.StatusCode) + } +} + +func TestPKIOperation(t *testing.T) { + server, _ := newServer(t) + defer server.Close() + pkcsreq := loadTestFile(t, "../scep/testdata/PKCSReq.der") + body := bytes.NewReader(pkcsreq) + url := server.URL + "/scep?operation=PKIOperation" + resp, err := http.Post(url, "", body) + if err != nil { + t.Fatal(err) + } + if resp.StatusCode != http.StatusOK { + t.Error("expected", http.StatusOK, "got", resp.StatusCode) + } +} + +func newServer(t *testing.T, opts ...scepserver.ServiceOption) (*httptest.Server, scepserver.Service) { + var err error + var depot scepserver.Depot // cert storage + { + depot, err = scepserver.NewFileDepot("../scep/testdata/testca") + if err != nil { + t.Fatal(err) + } + } + var svc scepserver.Service // scep service + { + svc, err = scepserver.NewService(depot, opts...) + if err != nil { + t.Fatal(err) + } + } + ctx := context.Background() + logger := kitlog.NewNopLogger() + handler := scepserver.ServiceHandler(ctx, svc, logger) + server := httptest.NewServer(handler) + return server, svc +} + +/* helpers */ +const ( + rsaPrivateKeyPEMBlockType = "RSA PRIVATE KEY" + certificatePEMBlockType = "CERTIFICATE" +) + +func loadTestFile(t *testing.T, path string) []byte { + data, err := ioutil.ReadFile(path) + if err != nil { + t.Fatal(err) + } + return data +} + +// create a new RSA private key +func newRSAKey(bits int) (*rsa.PrivateKey, error) { + private, err := rsa.GenerateKey(rand.Reader, bits) + if err != nil { + return nil, err + } + return private, nil +} + +// create a CSR using the same parameters as Keychain Access would produce +func newCSR(priv *rsa.PrivateKey, email, country, cname string) ([]byte, error) { + subj := pkix.Name{ + Country: []string{country}, + CommonName: cname, + ExtraNames: []pkix.AttributeTypeAndValue{pkix.AttributeTypeAndValue{ + Type: []int{1, 2, 840, 113549, 1, 9, 1}, + Value: email, + }}, + } + template := &x509.CertificateRequest{ + Subject: subj, + } + return x509.CreateCertificateRequest(rand.Reader, template, priv) +} +func loadCACredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { + cert, err := loadCertFromFile("../scep/testdata/testca/ca.crt") + if err != nil { + t.Fatal(err) + } + key, err := loadKeyFromFile("../scep/testdata/testca/ca.key") + if err != nil { + t.Fatal(err) + } + return cert, key +} + +func loadClientCredentials(t *testing.T) (*x509.Certificate, *rsa.PrivateKey) { + cert, err := loadCertFromFile("../scep/testdata/testclient/client.pem") + if err != nil { + t.Fatal(err) + } + key, err := loadKeyFromFile("../scep/testdata/testclient/client.key") + if err != nil { + t.Fatal(err) + } + return cert, key +} + +func loadCertFromFile(path string) (*x509.Certificate, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != certificatePEMBlockType { + return nil, errors.New("unmatched type or headers") + } + return x509.ParseCertificate(pemBlock.Bytes) +} + +// load an encrypted private key from disk +func loadKeyFromFile(path string) (*rsa.PrivateKey, error) { + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + + pemBlock, _ := pem.Decode(data) + if pemBlock == nil { + return nil, errors.New("PEM decode failed") + } + if pemBlock.Type != rsaPrivateKeyPEMBlockType { + return nil, errors.New("unmatched type or headers") + } + + // testca key has a password + if len(pemBlock.Headers) > 0 { + password := []byte("") + b, err := x509.DecryptPEMBlock(pemBlock, password) + if err != nil { + return nil, err + } + return x509.ParsePKCS1PrivateKey(b) + } + + return x509.ParsePKCS1PrivateKey(pemBlock.Bytes) +} diff --git a/vendor/golang.org/x/crypto/acme/internal/acme/acme.go b/vendor/golang.org/x/crypto/acme/internal/acme/acme.go index a41b6ba5..eb60ba5d 100644 --- a/vendor/golang.org/x/crypto/acme/internal/acme/acme.go +++ b/vendor/golang.org/x/crypto/acme/internal/acme/acme.go @@ -2,20 +2,29 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package acme provides an ACME client implementation. -// See https://ietf-wg-acme.github.io/acme/ for details. +// Package acme provides an implementation of the +// Automatic Certificate Management Environment (ACME) spec. +// See https://tools.ietf.org/html/draft-ietf-acme-acme-02 for details. // // This package is a work in progress and makes no API stability promises. package acme import ( "bytes" + "crypto" + "crypto/rand" "crypto/rsa" + "crypto/sha256" + "crypto/tls" + "crypto/x509" "encoding/base64" + "encoding/hex" "encoding/json" + "encoding/pem" "errors" "fmt" "io/ioutil" + "math/big" "net/http" "strconv" "strings" @@ -39,13 +48,14 @@ const LetsEncryptURL = "https://acme-v01.api.letsencrypt.org/directory" // client := &Client{Key: key} // type Client struct { + // Key is the account key used to register with a CA and sign requests. + // Key.Public() must return a *rsa.PublicKey or *ecdsa.PublicKey. + Key crypto.Signer + // HTTPClient optionally specifies an HTTP client to use // instead of http.DefaultClient. HTTPClient *http.Client - // Key is the account key used to register with a CA and sign requests. - Key *rsa.PrivateKey - // DirectoryURL points to the CA directory endpoint. // If empty, LetsEncryptURL is used. // Mutating this value after a successful call of Client's Discover method @@ -185,18 +195,18 @@ func (c *Client) FetchCert(ctx context.Context, url string, bundle bool) ([][]by } } -// AcceptTOS always returns true to indicate the acceptance of a CA Terms of Service +// AcceptTOS always returns true to indicate the acceptance of a CA's Terms of Service // during account registration. See Register method of Client for more details. -func AcceptTOS(string) bool { return true } +func AcceptTOS(tosURL string) bool { return true } // Register creates a new account registration by following the "new-reg" flow. // It returns registered account. The a argument is not modified. // -// The registration may require the caller to agree to the CA Terms of Service (TOS). +// The registration may require the caller to agree to the CA's Terms of Service (TOS). // If so, and the account has not indicated the acceptance of the terms (see Account for details), // Register calls prompt with a TOS URL provided by the CA. Prompt should report // whether the caller agrees to the terms. To always accept the terms, the caller can use AcceptTOS. -func (c *Client) Register(a *Account, prompt func(tos string) bool) (*Account, error) { +func (c *Client) Register(a *Account, prompt func(tosURL string) bool) (*Account, error) { if _, err := c.Discover(); err != nil { return nil, err } @@ -219,14 +229,24 @@ func (c *Client) Register(a *Account, prompt func(tos string) bool) (*Account, e // GetReg retrieves an existing registration. // The url argument is an Account URI. func (c *Client) GetReg(url string) (*Account, error) { - a := &Account{URI: url} - return c.doReg(url, "reg", a) + a, err := c.doReg(url, "reg", nil) + if err != nil { + return nil, err + } + a.URI = url + return a, nil } // UpdateReg updates an existing registration. // It returns an updated account copy. The provided account is not modified. func (c *Client) UpdateReg(a *Account) (*Account, error) { - return c.doReg(a.URI, "reg", a) + uri := a.URI + a, err := c.doReg(uri, "reg", a) + if err != nil { + return nil, err + } + a.URI = uri + return a, nil } // Authorize performs the initial step in an authorization flow. @@ -259,10 +279,10 @@ func (c *Client) Authorize(domain string) (*Authorization, error) { var v wireAuthz if err := json.NewDecoder(res.Body).Decode(&v); err != nil { - return nil, fmt.Errorf("Decode: %v", err) + return nil, fmt.Errorf("acme: invalid response: %v", err) } if v.Status != StatusPending { - return nil, fmt.Errorf("Unexpected status: %s", v.Status) + return nil, fmt.Errorf("acme: unexpected status: %s", v.Status) } return v.authorization(res.Header.Get("Location")), nil } @@ -281,7 +301,7 @@ func (c *Client) GetAuthz(url string) (*Authorization, error) { } var v wireAuthz if err := json.NewDecoder(res.Body).Decode(&v); err != nil { - return nil, fmt.Errorf("Decode: %v", err) + return nil, fmt.Errorf("acme: invalid response: %v", err) } return v.authorization(url), nil } @@ -300,7 +320,7 @@ func (c *Client) GetChallenge(url string) (*Challenge, error) { } v := wireChallenge{URI: url} if err := json.NewDecoder(res.Body).Decode(&v); err != nil { - return nil, fmt.Errorf("Decode: %v", err) + return nil, fmt.Errorf("acme: invalid response: %v", err) } return v.challenge(), nil } @@ -310,6 +330,11 @@ func (c *Client) GetChallenge(url string) (*Challenge, error) { // // The server will then perform the validation asynchronously. func (c *Client) Accept(chal *Challenge) (*Challenge, error) { + auth, err := keyAuth(c.Key.Public(), chal.Token) + if err != nil { + return nil, err + } + req := struct { Resource string `json:"resource"` Type string `json:"type"` @@ -317,7 +342,7 @@ func (c *Client) Accept(chal *Challenge) (*Challenge, error) { }{ Resource: "challenge", Type: chal.Type, - Auth: keyAuth(&c.Key.PublicKey, chal.Token), + Auth: auth, } res, err := c.postJWS(chal.URI, req) if err != nil { @@ -332,7 +357,7 @@ func (c *Client) Accept(chal *Challenge) (*Challenge, error) { var v wireChallenge if err := json.NewDecoder(res.Body).Decode(&v); err != nil { - return nil, fmt.Errorf("Decode: %v", err) + return nil, fmt.Errorf("acme: invalid response: %v", err) } return v.challenge(), nil } @@ -346,10 +371,72 @@ func (c *Client) HTTP01Handler(token string) http.Handler { return } w.Header().Set("content-type", "text/plain") - w.Write([]byte(keyAuth(&c.Key.PublicKey, token))) + auth, err := keyAuth(c.Key.Public(), token) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + w.Write([]byte(auth)) }) } +// TLSSNI01ChallengeCert creates a certificate for TLS-SNI-01 challenge response. +// Servers can present the certificate to validate the challenge and prove control +// over a domain name. +// +// The implementation is incomplete in that the returned value is a single certificate, +// computed only for Z0 of the key authorization. ACME CAs are expected to update +// their implementations to use the newer version, TLS-SNI-02. +// For more details on TLS-SNI-01 see https://tools.ietf.org/html/draft-ietf-acme-acme-01#section-7.3. +// +// The token argument is a Challenge.Token value. +// +// The returned certificate is valid for the next 24 hours and must be presented only when +// the server name of the client hello matches exactly the returned name value. +func (c *Client) TLSSNI01ChallengeCert(token string) (cert tls.Certificate, name string, err error) { + ka, err := keyAuth(c.Key.Public(), token) + if err != nil { + return tls.Certificate{}, "", err + } + b := sha256.Sum256([]byte(ka)) + h := hex.EncodeToString(b[:]) + name = fmt.Sprintf("%s.%s.acme.invalid", h[:32], h[32:]) + cert, err = tlsChallengeCert(name) + if err != nil { + return tls.Certificate{}, "", err + } + return cert, name, nil +} + +// TLSSNI02ChallengeCert creates a certificate for TLS-SNI-02 challenge response. +// Servers can present the certificate to validate the challenge and prove control +// over a domain name. For more details on TLS-SNI-02 see +// https://tools.ietf.org/html/draft-ietf-acme-acme-03#section-7.3. +// +// The token argument is a Challenge.Token value. +// +// The returned certificate is valid for the next 24 hours and must be presented only when +// the server name in the client hello matches exactly the returned name value. +func (c *Client) TLSSNI02ChallengeCert(token string) (cert tls.Certificate, name string, err error) { + b := sha256.Sum256([]byte(token)) + h := hex.EncodeToString(b[:]) + sanA := fmt.Sprintf("%s.%s.token.acme.invalid", h[:32], h[32:]) + + ka, err := keyAuth(c.Key.Public(), token) + if err != nil { + return tls.Certificate{}, "", err + } + b = sha256.Sum256([]byte(ka)) + h = hex.EncodeToString(b[:]) + sanB := fmt.Sprintf("%s.%s.ka.acme.invalid", h[:32], h[32:]) + + cert, err = tlsChallengeCert(sanA, sanB) + if err != nil { + return tls.Certificate{}, "", err + } + return cert, sanA, nil +} + func (c *Client) httpClient() *http.Client { if c.HTTPClient != nil { return c.HTTPClient @@ -413,7 +500,7 @@ func (c *Client) doReg(url string, typ string, acct *Account) (*Account, error) Certificates string } if err := json.NewDecoder(res.Body).Decode(&v); err != nil { - return nil, fmt.Errorf("Decode: %v", err) + return nil, fmt.Errorf("acme: invalid response: %v", err) } return &Account{ URI: res.Header.Get("Location"), @@ -429,7 +516,7 @@ func (c *Client) doReg(url string, typ string, acct *Account) (*Account, error) func responseCert(client *http.Client, res *http.Response, bundle bool) ([][]byte, error) { b, err := ioutil.ReadAll(res.Body) if err != nil { - return nil, fmt.Errorf("ReadAll: %v", err) + return nil, fmt.Errorf("acme: response stream: %v", err) } cert := [][]byte{b} if !bundle { @@ -439,7 +526,7 @@ func responseCert(client *http.Client, res *http.Response, bundle bool) ([][]byt // append ca cert up := linkHeader(res.Header, "up") if up == "" { - return nil, errors.New("rel=up link not found") + return nil, errors.New("acme: rel=up link not found") } res, err = client.Get(up) if err != nil { @@ -493,7 +580,7 @@ func fetchNonce(client *http.Client, url string) (string, error) { defer resp.Body.Close() enc := resp.Header.Get("replay-nonce") if enc == "" { - return "", errors.New("nonce not found") + return "", errors.New("acme: nonce not found") } return enc, nil } @@ -526,8 +613,40 @@ func retryAfter(v string) (time.Duration, error) { } // keyAuth generates a key authorization string for a given token. -func keyAuth(pub *rsa.PublicKey, token string) string { - return fmt.Sprintf("%s.%s", token, JWKThumbprint(pub)) +func keyAuth(pub crypto.PublicKey, token string) (string, error) { + th, err := JWKThumbprint(pub) + if err != nil { + return "", err + } + return fmt.Sprintf("%s.%s", token, th), nil +} + +// tlsChallengeCert creates a temporary certificate for TLS-SNI challenges +// with the given SANs. +func tlsChallengeCert(san ...string) (tls.Certificate, error) { + key, err := rsa.GenerateKey(rand.Reader, 2048) + if err != nil { + return tls.Certificate{}, err + } + t := x509.Certificate{ + SerialNumber: big.NewInt(1), + NotBefore: time.Now(), + NotAfter: time.Now().Add(24 * time.Hour), + BasicConstraintsValid: true, + KeyUsage: x509.KeyUsageKeyEncipherment, + DNSNames: san, + } + der, err := x509.CreateCertificate(rand.Reader, &t, &t, &key.PublicKey, key) + return tls.Certificate{ + Certificate: [][]byte{der}, + PrivateKey: key, + }, nil +} + +// encodePEM returns b encoded as PEM with block of type typ. +func encodePEM(typ string, b []byte) []byte { + pb := &pem.Block{Type: typ, Bytes: b} + return pem.EncodeToMemory(pb) } // timeNow is useful for testing for fixed current time. diff --git a/vendor/golang.org/x/crypto/acme/internal/acme/acme_test.go b/vendor/golang.org/x/crypto/acme/internal/acme/acme_test.go index eae8f66c..bb7dd1f7 100644 --- a/vendor/golang.org/x/crypto/acme/internal/acme/acme_test.go +++ b/vendor/golang.org/x/crypto/acme/internal/acme/acme_test.go @@ -16,6 +16,7 @@ import ( "net/http" "net/http/httptest" "reflect" + "sort" "strings" "testing" "time" @@ -204,6 +205,9 @@ func TestUpdateReg(t *testing.T) { if a.CurrentTerms != terms { t.Errorf("a.CurrentTerms = %q; want %q", a.CurrentTerms, terms) } + if a.URI != ts.URL { + t.Errorf("a.URI = %q; want %q", a.URI, ts.URL) + } } func TestGetReg(t *testing.T) { @@ -265,6 +269,9 @@ func TestGetReg(t *testing.T) { if a.CurrentTerms != newTerms { t.Errorf("a.CurrentTerms = %q; want %q", a.CurrentTerms, newTerms) } + if a.URI != ts.URL { + t.Errorf("a.URI = %q; want %q", a.URI, ts.URL) + } } func TestAuthorize(t *testing.T) { @@ -766,3 +773,64 @@ func TestErrorResponse(t *testing.T) { t.Errorf("v.Header = %+v; want %+v", v.Header, res.Header) } } + +func TestTLSSNI01ChallengeCert(t *testing.T) { + const ( + token = "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA" + // echo -n | shasum -a 256 + san = "b6ddc3df57802969e2e0b88eb548d4be.febc5bd6cf3690eb526081b5d10deda4.acme.invalid" + ) + + client := &Client{Key: testKey} + tlscert, name, err := client.TLSSNI01ChallengeCert(token) + if err != nil { + t.Fatal(err) + } + + if n := len(tlscert.Certificate); n != 1 { + t.Fatalf("len(tlscert.Certificate) = %d; want 1", n) + } + cert, err := x509.ParseCertificate(tlscert.Certificate[0]) + if err != nil { + t.Fatal(err) + } + if len(cert.DNSNames) != 1 || cert.DNSNames[0] != san { + t.Fatalf("cert.DNSNames = %v; want %q", cert.DNSNames, san) + } + if cert.DNSNames[0] != name { + t.Errorf("cert.DNSNames[0] != name: %q vs %q", cert.DNSNames[0], name) + } +} + +func TestTLSSNI02ChallengeCert(t *testing.T) { + const ( + token = "evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA" + // echo -n evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA | shasum -a 256 + sanA = "7ea0aaa69214e71e02cebb18bb867736.09b730209baabf60e43d4999979ff139.token.acme.invalid" + // echo -n | shasum -a 256 + sanB = "b6ddc3df57802969e2e0b88eb548d4be.febc5bd6cf3690eb526081b5d10deda4.ka.acme.invalid" + ) + + client := &Client{Key: testKey} + tlscert, name, err := client.TLSSNI02ChallengeCert(token) + if err != nil { + t.Fatal(err) + } + + if n := len(tlscert.Certificate); n != 1 { + t.Fatalf("len(tlscert.Certificate) = %d; want 1", n) + } + cert, err := x509.ParseCertificate(tlscert.Certificate[0]) + if err != nil { + t.Fatal(err) + } + names := []string{sanA, sanB} + if !reflect.DeepEqual(cert.DNSNames, names) { + t.Fatalf("cert.DNSNames = %v;\nwant %v", cert.DNSNames, names) + } + sort.Strings(cert.DNSNames) + i := sort.SearchStrings(cert.DNSNames, name) + if i >= len(cert.DNSNames) || cert.DNSNames[i] != name { + t.Errorf("%v doesn't have %q", cert.DNSNames, name) + } +} diff --git a/vendor/golang.org/x/crypto/acme/internal/acme/jws.go b/vendor/golang.org/x/crypto/acme/internal/acme/jws.go index c2775297..d8bb769d 100644 --- a/vendor/golang.org/x/crypto/acme/internal/acme/jws.go +++ b/vendor/golang.org/x/crypto/acme/internal/acme/jws.go @@ -6,6 +6,7 @@ package acme import ( "crypto" + "crypto/ecdsa" "crypto/rand" "crypto/rsa" "crypto/sha256" @@ -18,8 +19,11 @@ import ( // jwsEncodeJSON signs claimset using provided key and a nonce. // The result is serialized in JSON format. // See https://tools.ietf.org/html/rfc7515#section-7. -func jwsEncodeJSON(claimset interface{}, key *rsa.PrivateKey, nonce string) ([]byte, error) { - jwk := jwkEncode(&key.PublicKey) +func jwsEncodeJSON(claimset interface{}, key crypto.Signer, nonce string) ([]byte, error) { + jwk, err := jwkEncode(key.Public()) + if err != nil { + return nil, err + } phead := fmt.Sprintf(`{"alg":"RS256","jwk":%s,"nonce":%q}`, jwk, nonce) phead = base64.RawURLEncoding.EncodeToString([]byte(phead)) cs, err := json.Marshal(claimset) @@ -29,7 +33,7 @@ func jwsEncodeJSON(claimset interface{}, key *rsa.PrivateKey, nonce string) ([]b payload := base64.RawURLEncoding.EncodeToString(cs) h := sha256.New() h.Write([]byte(phead + "." + payload)) - sig, err := rsa.SignPKCS1v15(rand.Reader, key, crypto.SHA256, h.Sum(nil)) + sig, err := key.Sign(rand.Reader, h.Sum(nil), crypto.SHA256) if err != nil { return nil, err } @@ -45,23 +49,54 @@ func jwsEncodeJSON(claimset interface{}, key *rsa.PrivateKey, nonce string) ([]b return json.Marshal(&enc) } -// jwkEncode encodes public part of an RSA key into a JWK. +// jwkEncode encodes public part of an RSA or ECDSA key into a JWK. // The result is also suitable for creating a JWK thumbprint. -func jwkEncode(pub *rsa.PublicKey) string { - n := pub.N - e := big.NewInt(int64(pub.E)) - // fields order is important - // see https://tools.ietf.org/html/rfc7638#section-3.3 for details - return fmt.Sprintf(`{"e":"%s","kty":"RSA","n":"%s"}`, - base64.RawURLEncoding.EncodeToString(e.Bytes()), - base64.RawURLEncoding.EncodeToString(n.Bytes()), - ) +// https://tools.ietf.org/html/rfc7517 +func jwkEncode(pub crypto.PublicKey) (string, error) { + switch pub := pub.(type) { + case *rsa.PublicKey: + // https://tools.ietf.org/html/rfc7518#section-6.3.1 + n := pub.N + e := big.NewInt(int64(pub.E)) + // Field order is important. + // See https://tools.ietf.org/html/rfc7638#section-3.3 for details. + return fmt.Sprintf(`{"e":"%s","kty":"RSA","n":"%s"}`, + base64.RawURLEncoding.EncodeToString(e.Bytes()), + base64.RawURLEncoding.EncodeToString(n.Bytes()), + ), nil + case *ecdsa.PublicKey: + // https://tools.ietf.org/html/rfc7518#section-6.2.1 + p := pub.Curve.Params() + n := p.BitSize / 8 + if p.BitSize%8 != 0 { + n++ + } + x := pub.X.Bytes() + if n > len(x) { + x = append(make([]byte, n-len(x)), x...) + } + y := pub.Y.Bytes() + if n > len(y) { + y = append(make([]byte, n-len(y)), y...) + } + // Field order is important. + // See https://tools.ietf.org/html/rfc7638#section-3.3 for details. + return fmt.Sprintf(`{"crv":"%s","kty":"EC","x":"%s","y":"%s"}`, + p.Name, + base64.RawURLEncoding.EncodeToString(x), + base64.RawURLEncoding.EncodeToString(y), + ), nil + } + return "", ErrUnsupportedKey } // JWKThumbprint creates a JWK thumbprint out of pub // as specified in https://tools.ietf.org/html/rfc7638. -func JWKThumbprint(pub *rsa.PublicKey) string { - jwk := jwkEncode(pub) +func JWKThumbprint(pub crypto.PublicKey) (string, error) { + jwk, err := jwkEncode(pub) + if err != nil { + return "", err + } b := sha256.Sum256([]byte(jwk)) - return base64.RawURLEncoding.EncodeToString(b[:]) + return base64.RawURLEncoding.EncodeToString(b[:]), nil } diff --git a/vendor/golang.org/x/crypto/acme/internal/acme/jws_test.go b/vendor/golang.org/x/crypto/acme/internal/acme/jws_test.go index 7afd9507..4f7e6ecd 100644 --- a/vendor/golang.org/x/crypto/acme/internal/acme/jws_test.go +++ b/vendor/golang.org/x/crypto/acme/internal/acme/jws_test.go @@ -5,6 +5,8 @@ package acme import ( + "crypto/ecdsa" + "crypto/elliptic" "crypto/rsa" "crypto/x509" "encoding/base64" @@ -108,7 +110,7 @@ func TestJWSEncodeJSON(t *testing.T) { } } -func TestJWKThumbprint(t *testing.T) { +func TestJWKThumbprintRSA(t *testing.T) { // Key example from RFC 7638 const base64N = "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAt" + "VT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn6" + @@ -119,21 +121,68 @@ func TestJWKThumbprint(t *testing.T) { const base64E = "AQAB" const expected = "NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs" - bytes, err := base64.RawURLEncoding.DecodeString(base64N) + b, err := base64.RawURLEncoding.DecodeString(base64N) if err != nil { t.Fatalf("Error parsing example key N: %v", err) } - n := new(big.Int).SetBytes(bytes) + n := new(big.Int).SetBytes(b) - bytes, err = base64.RawURLEncoding.DecodeString(base64E) + b, err = base64.RawURLEncoding.DecodeString(base64E) if err != nil { t.Fatalf("Error parsing example key E: %v", err) } - e := new(big.Int).SetBytes(bytes) + e := new(big.Int).SetBytes(b) pub := &rsa.PublicKey{N: n, E: int(e.Uint64())} - th := JWKThumbprint(pub) + th, err := JWKThumbprint(pub) + if err != nil { + t.Error(err) + } if th != expected { - t.Errorf("th = %q; want %q", th, expected) + t.Errorf("thumbprint = %q; want %q", th, expected) + } +} + +func TestJWKThumbprintEC(t *testing.T) { + // Key example from RFC 7520 + // expected was computed with + // echo -n '{"crv":"P-521","kty":"EC","x":"","y":""}' | \ + // openssl dgst -binary -sha256 | \ + // base64 | \ + // tr -d '=' | tr '/+' '_-' + const ( + base64X = "AHKZLLOsCOzz5cY97ewNUajB957y-C-U88c3v13nmGZx6sYl_oJXu9A5RkT" + + "KqjqvjyekWF-7ytDyRXYgCF5cj0Kt" + base64Y = "AdymlHvOiLxXkEhayXQnNCvDX4h9htZaCJN34kfmC6pV5OhQHiraVySsUda" + + "QkAgDPrwQrJmbnX9cwlGfP-HqHZR1" + expected = "dHri3SADZkrush5HU_50AoRhcKFryN-PI6jPBtPL55M" + ) + + b, err := base64.RawURLEncoding.DecodeString(base64X) + if err != nil { + t.Fatalf("Error parsing example key X: %v", err) + } + x := new(big.Int).SetBytes(b) + + b, err = base64.RawURLEncoding.DecodeString(base64Y) + if err != nil { + t.Fatalf("Error parsing example key Y: %v", err) + } + y := new(big.Int).SetBytes(b) + + pub := &ecdsa.PublicKey{Curve: elliptic.P521(), X: x, Y: y} + th, err := JWKThumbprint(pub) + if err != nil { + t.Error(err) + } + if th != expected { + t.Errorf("thumbprint = %q; want %q", th, expected) + } +} + +func TestJWKThumbprintErrUnsupportedKey(t *testing.T) { + _, err := JWKThumbprint(struct{}{}) + if err != ErrUnsupportedKey { + t.Errorf("err = %q; want %q", err, ErrUnsupportedKey) } } diff --git a/vendor/golang.org/x/crypto/acme/internal/acme/types.go b/vendor/golang.org/x/crypto/acme/internal/acme/types.go index 702be796..fb17ed55 100644 --- a/vendor/golang.org/x/crypto/acme/internal/acme/types.go +++ b/vendor/golang.org/x/crypto/acme/internal/acme/types.go @@ -1,6 +1,7 @@ package acme import ( + "errors" "fmt" "net/http" ) @@ -15,6 +16,27 @@ const ( StatusRevoked = "revoked" ) +// ErrUnsupportedKey is returned when an unsupported key type is encountered. +var ErrUnsupportedKey = errors.New("acme: unknown key type; only RSA and ECDSA are supported") + +// Error is an ACME error, defined in Problem Details for HTTP APIs doc +// http://tools.ietf.org/html/draft-ietf-appsawg-http-problem. +type Error struct { + // StatusCode is The HTTP status code generated by the origin server. + StatusCode int + // ProblemType is a URI reference that identifies the problem type, + // typically in a "urn:acme:error:xxx" form. + ProblemType string + // Detail is a human-readable explanation specific to this occurrence of the problem. + Detail string + // Header is the original server error response headers. + Header http.Header +} + +func (e *Error) Error() string { + return fmt.Sprintf("%d %s: %s", e.StatusCode, e.ProblemType, e.Detail) +} + // Account is a user account. It is associated with a private key. type Account struct { // URI is the account unique ID, which is also a URL used to retrieve @@ -117,24 +139,6 @@ type AuthzID struct { Value string // The identifier itself, e.g. "example.org". } -// Error is an ACME error, defined in Problem Details for HTTP APIs doc -// http://tools.ietf.org/html/draft-ietf-appsawg-http-problem. -type Error struct { - // StatusCode is The HTTP status code generated by the origin server. - StatusCode int - // ProblemType is a URI reference that identifies the problem type, - // typically in a "urn:acme:error:xxx" form. - ProblemType string - // Detail is a human-readable explanation specific to this occurrence of the problem. - Detail string - // Header is the original server error response headers. - Header http.Header -} - -func (e *Error) Error() string { - return fmt.Sprintf("%d %s: %s", e.StatusCode, e.ProblemType, e.Detail) -} - // wireAuthz is ACME JSON representation of Authorization objects. type wireAuthz struct { Status string diff --git a/vendor/golang.org/x/net/http2/client_conn_pool.go b/vendor/golang.org/x/net/http2/client_conn_pool.go index cb34cc2d..b1394125 100644 --- a/vendor/golang.org/x/net/http2/client_conn_pool.go +++ b/vendor/golang.org/x/net/http2/client_conn_pool.go @@ -55,11 +55,11 @@ const ( func (p *clientConnPool) getClientConn(req *http.Request, addr string, dialOnMiss bool) (*ClientConn, error) { if isConnectionCloseRequest(req) && dialOnMiss { // It gets its own connection. - cc, err := p.t.dialClientConn(addr) + const singleUse = true + cc, err := p.t.dialClientConn(addr, singleUse) if err != nil { return nil, err } - cc.singleUse = true return cc, nil } p.mu.Lock() @@ -104,7 +104,8 @@ func (p *clientConnPool) getStartDialLocked(addr string) *dialCall { // run in its own goroutine. func (c *dialCall) dial(addr string) { - c.res, c.err = c.p.t.dialClientConn(addr) + const singleUse = false // shared conn + c.res, c.err = c.p.t.dialClientConn(addr, singleUse) close(c.done) c.p.mu.Lock() diff --git a/vendor/golang.org/x/net/http2/errors.go b/vendor/golang.org/x/net/http2/errors.go index 71a4e290..20fd7626 100644 --- a/vendor/golang.org/x/net/http2/errors.go +++ b/vendor/golang.org/x/net/http2/errors.go @@ -64,9 +64,17 @@ func (e ConnectionError) Error() string { return fmt.Sprintf("connection error: type StreamError struct { StreamID uint32 Code ErrCode + Cause error // optional additional detail +} + +func streamError(id uint32, code ErrCode) StreamError { + return StreamError{StreamID: id, Code: code} } func (e StreamError) Error() string { + if e.Cause != nil { + return fmt.Sprintf("stream error: stream ID %d; %v; %v", e.StreamID, e.Code, e.Cause) + } return fmt.Sprintf("stream error: stream ID %d; %v", e.StreamID, e.Code) } diff --git a/vendor/golang.org/x/net/http2/frame.go b/vendor/golang.org/x/net/http2/frame.go index 981d407a..c9b09bb6 100644 --- a/vendor/golang.org/x/net/http2/frame.go +++ b/vendor/golang.org/x/net/http2/frame.go @@ -594,6 +594,7 @@ func parseDataFrame(fh FrameHeader, payload []byte) (Frame, error) { var ( errStreamID = errors.New("invalid stream ID") errDepStreamID = errors.New("invalid dependent stream ID") + errPadLength = errors.New("pad length too large") ) func validStreamIDOrZero(streamID uint32) bool { @@ -607,18 +608,40 @@ func validStreamID(streamID uint32) bool { // WriteData writes a DATA frame. // // It will perform exactly one Write to the underlying Writer. -// It is the caller's responsibility to not call other Write methods concurrently. +// It is the caller's responsibility not to violate the maximum frame size +// and to not call other Write methods concurrently. func (f *Framer) WriteData(streamID uint32, endStream bool, data []byte) error { - // TODO: ignoring padding for now. will add when somebody cares. + return f.WriteDataPadded(streamID, endStream, data, nil) +} + +// WriteData writes a DATA frame with optional padding. +// +// If pad is nil, the padding bit is not sent. +// The length of pad must not exceed 255 bytes. +// +// It will perform exactly one Write to the underlying Writer. +// It is the caller's responsibility not to violate the maximum frame size +// and to not call other Write methods concurrently. +func (f *Framer) WriteDataPadded(streamID uint32, endStream bool, data, pad []byte) error { if !validStreamID(streamID) && !f.AllowIllegalWrites { return errStreamID } + if len(pad) > 255 { + return errPadLength + } var flags Flags if endStream { flags |= FlagDataEndStream } + if pad != nil { + flags |= FlagDataPadded + } f.startWrite(FrameData, flags, streamID) + if pad != nil { + f.wbuf = append(f.wbuf, byte(len(pad))) + } f.wbuf = append(f.wbuf, data...) + f.wbuf = append(f.wbuf, pad...) return f.endWrite() } @@ -840,7 +863,7 @@ func parseWindowUpdateFrame(fh FrameHeader, p []byte) (Frame, error) { if fh.StreamID == 0 { return nil, ConnectionError(ErrCodeProtocol) } - return nil, StreamError{fh.StreamID, ErrCodeProtocol} + return nil, streamError(fh.StreamID, ErrCodeProtocol) } return &WindowUpdateFrame{ FrameHeader: fh, @@ -921,7 +944,7 @@ func parseHeadersFrame(fh FrameHeader, p []byte) (_ Frame, err error) { } } if len(p)-int(padLength) <= 0 { - return nil, StreamError{fh.StreamID, ErrCodeProtocol} + return nil, streamError(fh.StreamID, ErrCodeProtocol) } hf.headerFragBuf = p[:len(p)-int(padLength)] return hf, nil @@ -1396,6 +1419,9 @@ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) { hdec.SetEmitEnabled(true) hdec.SetMaxStringLength(fr.maxHeaderStringLen()) hdec.SetEmitFunc(func(hf hpack.HeaderField) { + if VerboseLogs && logFrameReads { + log.Printf("http2: decoded hpack field %+v", hf) + } if !httplex.ValidHeaderFieldValue(hf.Value) { invalid = headerFieldValueError(hf.Value) } @@ -1454,11 +1480,17 @@ func (fr *Framer) readMetaFrame(hf *HeadersFrame) (*MetaHeadersFrame, error) { } if invalid != nil { fr.errDetail = invalid - return nil, StreamError{mh.StreamID, ErrCodeProtocol} + if VerboseLogs { + log.Printf("http2: invalid header: %v", invalid) + } + return nil, StreamError{mh.StreamID, ErrCodeProtocol, invalid} } if err := mh.checkPseudos(); err != nil { fr.errDetail = err - return nil, StreamError{mh.StreamID, ErrCodeProtocol} + if VerboseLogs { + log.Printf("http2: invalid pseudo headers: %v", err) + } + return nil, StreamError{mh.StreamID, ErrCodeProtocol, err} } return mh, nil } diff --git a/vendor/golang.org/x/net/http2/frame_test.go b/vendor/golang.org/x/net/http2/frame_test.go index 9bd24afd..7b1933d9 100644 --- a/vendor/golang.org/x/net/http2/frame_test.go +++ b/vendor/golang.org/x/net/http2/frame_test.go @@ -100,6 +100,77 @@ func TestWriteData(t *testing.T) { } } +func TestWriteDataPadded(t *testing.T) { + tests := [...]struct { + streamID uint32 + endStream bool + data []byte + pad []byte + wantHeader FrameHeader + }{ + // Unpadded: + 0: { + streamID: 1, + endStream: true, + data: []byte("foo"), + pad: nil, + wantHeader: FrameHeader{ + Type: FrameData, + Flags: FlagDataEndStream, + Length: 3, + StreamID: 1, + }, + }, + + // Padded bit set, but no padding: + 1: { + streamID: 1, + endStream: true, + data: []byte("foo"), + pad: []byte{}, + wantHeader: FrameHeader{ + Type: FrameData, + Flags: FlagDataEndStream | FlagDataPadded, + Length: 4, + StreamID: 1, + }, + }, + + // Padded bit set, with padding: + 2: { + streamID: 1, + endStream: false, + data: []byte("foo"), + pad: []byte("bar"), + wantHeader: FrameHeader{ + Type: FrameData, + Flags: FlagDataPadded, + Length: 7, + StreamID: 1, + }, + }, + } + for i, tt := range tests { + fr, _ := testFramer() + fr.WriteDataPadded(tt.streamID, tt.endStream, tt.data, tt.pad) + f, err := fr.ReadFrame() + if err != nil { + t.Errorf("%d. ReadFrame: %v", i, err) + continue + } + got := f.Header() + tt.wantHeader.valid = true + if got != tt.wantHeader { + t.Errorf("%d. read %+v; want %+v", i, got, tt.wantHeader) + continue + } + df := f.(*DataFrame) + if !bytes.Equal(df.Data(), tt.data) { + t.Errorf("%d. got %q; want %q", i, df.Data(), tt.data) + } + } +} + func TestWriteHeaders(t *testing.T) { tests := []struct { name string @@ -921,7 +992,7 @@ func TestMetaFrameHeader(t *testing.T) { ":path", "/", // bogus )) }, - want: StreamError{1, ErrCodeProtocol}, + want: streamError(1, ErrCodeProtocol), wantErrReason: "pseudo header field after regular", }, 7: { @@ -932,7 +1003,7 @@ func TestMetaFrameHeader(t *testing.T) { "foo", "bar", )) }, - want: StreamError{1, ErrCodeProtocol}, + want: streamError(1, ErrCodeProtocol), wantErrReason: "invalid pseudo-header \":unknown\"", }, 8: { @@ -943,7 +1014,7 @@ func TestMetaFrameHeader(t *testing.T) { ":status", "100", )) }, - want: StreamError{1, ErrCodeProtocol}, + want: streamError(1, ErrCodeProtocol), wantErrReason: "mix of request and response pseudo headers", }, 9: { @@ -954,7 +1025,7 @@ func TestMetaFrameHeader(t *testing.T) { ":method", "POST", )) }, - want: StreamError{1, ErrCodeProtocol}, + want: streamError(1, ErrCodeProtocol), wantErrReason: "duplicate pseudo-header \":method\"", }, 10: { @@ -965,13 +1036,13 @@ func TestMetaFrameHeader(t *testing.T) { 11: { name: "invalid_field_name", w: func(f *Framer) { write(f, encodeHeaderRaw(t, "CapitalBad", "x")) }, - want: StreamError{1, ErrCodeProtocol}, + want: streamError(1, ErrCodeProtocol), wantErrReason: "invalid header field name \"CapitalBad\"", }, 12: { name: "invalid_field_value", w: func(f *Framer) { write(f, encodeHeaderRaw(t, "key", "bad_null\x00")) }, - want: StreamError{1, ErrCodeProtocol}, + want: streamError(1, ErrCodeProtocol), wantErrReason: "invalid header field value \"bad_null\\x00\"", }, } @@ -992,6 +1063,13 @@ func TestMetaFrameHeader(t *testing.T) { got, err = f.ReadFrame() if err != nil { got = err + + // Ignore the StreamError.Cause field, if it matches the wantErrReason. + // The test table above predates the Cause field. + if se, ok := err.(StreamError); ok && se.Cause != nil && se.Cause.Error() == tt.wantErrReason { + se.Cause = nil + got = se + } } if !reflect.DeepEqual(got, tt.want) { if mhg, ok := got.(*MetaHeadersFrame); ok { diff --git a/vendor/golang.org/x/net/http2/http2.go b/vendor/golang.org/x/net/http2/http2.go index 0173aed6..f06e87b3 100644 --- a/vendor/golang.org/x/net/http2/http2.go +++ b/vendor/golang.org/x/net/http2/http2.go @@ -13,7 +13,8 @@ // See https://http2.github.io/ for more information on HTTP/2. // // See https://http2.golang.org/ for a test server running this code. -package http2 +// +package http2 // import "golang.org/x/net/http2" import ( "bufio" diff --git a/vendor/golang.org/x/net/http2/http2_test.go b/vendor/golang.org/x/net/http2/http2_test.go index 549ff5e4..22c2ace8 100644 --- a/vendor/golang.org/x/net/http2/http2_test.go +++ b/vendor/golang.org/x/net/http2/http2_test.go @@ -28,7 +28,7 @@ func condSkipFailingTest(t *testing.T) { func init() { DebugGoroutines = true - flag.BoolVar(&VerboseLogs, "verboseh2", false, "Verbose HTTP/2 debug logging") + flag.BoolVar(&VerboseLogs, "verboseh2", VerboseLogs, "Verbose HTTP/2 debug logging") } func TestSettingString(t *testing.T) { diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index f368738f..8206fa79 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -922,7 +922,7 @@ func (sc *serverConn) wroteFrame(res frameWriteResult) { // state here anyway, after telling the peer // we're hanging up on them. st.state = stateHalfClosedLocal // won't last long, but necessary for closeStream via resetStream - errCancel := StreamError{st.id, ErrCodeCancel} + errCancel := streamError(st.id, ErrCodeCancel) sc.resetStream(errCancel) case stateHalfClosedRemote: sc.closeStream(st, errHandlerComplete) @@ -1133,7 +1133,7 @@ func (sc *serverConn) processWindowUpdate(f *WindowUpdateFrame) error { return nil } if !st.flow.add(int32(f.Increment)) { - return StreamError{f.StreamID, ErrCodeFlowControl} + return streamError(f.StreamID, ErrCodeFlowControl) } default: // connection-level flow control if !sc.flow.add(int32(f.Increment)) { @@ -1159,7 +1159,7 @@ func (sc *serverConn) processResetStream(f *RSTStreamFrame) error { if st != nil { st.gotReset = true st.cancelCtx() - sc.closeStream(st, StreamError{f.StreamID, f.ErrCode}) + sc.closeStream(st, streamError(f.StreamID, f.ErrCode)) } return nil } @@ -1176,6 +1176,10 @@ func (sc *serverConn) closeStream(st *stream, err error) { } delete(sc.streams, st.id) if p := st.body; p != nil { + // Return any buffered unread bytes worth of conn-level flow control. + // See golang.org/issue/16481 + sc.sendWindowUpdate(nil, p.Len()) + p.CloseWithError(err) } st.cw.Close() // signals Handler's CloseNotifier, unblocks writes, etc @@ -1277,6 +1281,8 @@ func (sc *serverConn) processSettingInitialWindowSize(val uint32) error { func (sc *serverConn) processData(f *DataFrame) error { sc.serveG.check() + data := f.Data() + // "If a DATA frame is received whose stream is not in "open" // or "half closed (local)" state, the recipient MUST respond // with a stream error (Section 5.4.2) of type STREAM_CLOSED." @@ -1288,32 +1294,55 @@ func (sc *serverConn) processData(f *DataFrame) error { // the http.Handler returned, so it's done reading & // done writing). Try to stop the client from sending // more DATA. - return StreamError{id, ErrCodeStreamClosed} + + // But still enforce their connection-level flow control, + // and return any flow control bytes since we're not going + // to consume them. + if sc.inflow.available() < int32(f.Length) { + return streamError(id, ErrCodeFlowControl) + } + // Deduct the flow control from inflow, since we're + // going to immediately add it back in + // sendWindowUpdate, which also schedules sending the + // frames. + sc.inflow.take(int32(f.Length)) + sc.sendWindowUpdate(nil, int(f.Length)) // conn-level + + return streamError(id, ErrCodeStreamClosed) } if st.body == nil { panic("internal error: should have a body in this state") } - data := f.Data() // Sender sending more than they'd declared? if st.declBodyBytes != -1 && st.bodyBytes+int64(len(data)) > st.declBodyBytes { st.body.CloseWithError(fmt.Errorf("sender tried to send more than declared Content-Length of %d bytes", st.declBodyBytes)) - return StreamError{id, ErrCodeStreamClosed} + return streamError(id, ErrCodeStreamClosed) } - if len(data) > 0 { + if f.Length > 0 { // Check whether the client has flow control quota. - if int(st.inflow.available()) < len(data) { - return StreamError{id, ErrCodeFlowControl} + if st.inflow.available() < int32(f.Length) { + return streamError(id, ErrCodeFlowControl) } - st.inflow.take(int32(len(data))) - wrote, err := st.body.Write(data) - if err != nil { - return StreamError{id, ErrCodeStreamClosed} + st.inflow.take(int32(f.Length)) + + if len(data) > 0 { + wrote, err := st.body.Write(data) + if err != nil { + return streamError(id, ErrCodeStreamClosed) + } + if wrote != len(data) { + panic("internal error: bad Writer") + } + st.bodyBytes += int64(len(data)) } - if wrote != len(data) { - panic("internal error: bad Writer") + + // Return any padded flow control now, since we won't + // refund it later on body reads. + if pad := int32(f.Length) - int32(len(data)); pad > 0 { + sc.sendWindowUpdate32(nil, pad) + sc.sendWindowUpdate32(st, pad) } - st.bodyBytes += int64(len(data)) } if f.StreamEnded() { st.endStream() @@ -1417,14 +1446,14 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error { // REFUSED_STREAM." if sc.unackedSettings == 0 { // They should know better. - return StreamError{st.id, ErrCodeProtocol} + return streamError(st.id, ErrCodeProtocol) } // Assume it's a network race, where they just haven't // received our last SETTINGS update. But actually // this can't happen yet, because we don't yet provide // a way for users to adjust server parameters at // runtime. - return StreamError{st.id, ErrCodeRefusedStream} + return streamError(st.id, ErrCodeRefusedStream) } rw, req, err := sc.newWriterAndRequest(st, f) @@ -1458,11 +1487,11 @@ func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { } st.gotTrailerHeader = true if !f.StreamEnded() { - return StreamError{st.id, ErrCodeProtocol} + return streamError(st.id, ErrCodeProtocol) } if len(f.PseudoFields()) > 0 { - return StreamError{st.id, ErrCodeProtocol} + return streamError(st.id, ErrCodeProtocol) } if st.trailer != nil { for _, hf := range f.RegularFields() { @@ -1471,7 +1500,7 @@ func (st *stream) processTrailerHeaders(f *MetaHeadersFrame) error { // TODO: send more details to the peer somehow. But http2 has // no way to send debug data at a stream level. Discuss with // HTTP folk. - return StreamError{st.id, ErrCodeProtocol} + return streamError(st.id, ErrCodeProtocol) } st.trailer[key] = append(st.trailer[key], hf.Value) } @@ -1532,7 +1561,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res isConnect := method == "CONNECT" if isConnect { if path != "" || scheme != "" || authority == "" { - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} + return nil, nil, streamError(f.StreamID, ErrCodeProtocol) } } else if method == "" || path == "" || (scheme != "https" && scheme != "http") { @@ -1546,13 +1575,13 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res // "All HTTP/2 requests MUST include exactly one valid // value for the :method, :scheme, and :path // pseudo-header fields" - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} + return nil, nil, streamError(f.StreamID, ErrCodeProtocol) } bodyOpen := !f.StreamEnded() if method == "HEAD" && bodyOpen { // HEAD requests can't have bodies - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} + return nil, nil, streamError(f.StreamID, ErrCodeProtocol) } var tlsState *tls.ConnectionState // nil if not scheme https @@ -1610,7 +1639,7 @@ func (sc *serverConn) newWriterAndRequest(st *stream, f *MetaHeadersFrame) (*res var err error url_, err = url.ParseRequestURI(path) if err != nil { - return nil, nil, StreamError{f.StreamID, ErrCodeProtocol} + return nil, nil, streamError(f.StreamID, ErrCodeProtocol) } requestURI = path } diff --git a/vendor/golang.org/x/net/http2/server_test.go b/vendor/golang.org/x/net/http2/server_test.go index a45905f3..ecacf84c 100644 --- a/vendor/golang.org/x/net/http2/server_test.go +++ b/vendor/golang.org/x/net/http2/server_test.go @@ -55,11 +55,6 @@ type serverTester struct { // writing headers: headerBuf bytes.Buffer hpackEnc *hpack.Encoder - - // reading frames: - frc chan Frame - frErrc chan error - readTimer *time.Timer } func init() { @@ -117,8 +112,6 @@ func newServerTester(t testing.TB, handler http.HandlerFunc, opts ...interface{} t: t, ts: ts, logBuf: logBuf, - frc: make(chan Frame, 1), - frErrc: make(chan error, 1), } st.hpackEnc = hpack.NewEncoder(&st.headerBuf) st.hpackDec = hpack.NewDecoder(initialHeaderTableSize, st.onHeaderField) @@ -359,32 +352,39 @@ func (st *serverTester) writeData(streamID uint32, endStream bool, data []byte) } } -func (st *serverTester) readFrame() (Frame, error) { +func (st *serverTester) writeDataPadded(streamID uint32, endStream bool, data, pad []byte) { + if err := st.fr.WriteDataPadded(streamID, endStream, data, pad); err != nil { + st.t.Fatalf("Error writing DATA: %v", err) + } +} + +func readFrameTimeout(fr *Framer, wait time.Duration) (Frame, error) { + ch := make(chan interface{}, 1) go func() { - fr, err := st.fr.ReadFrame() + fr, err := fr.ReadFrame() if err != nil { - st.frErrc <- err + ch <- err } else { - st.frc <- fr + ch <- fr } }() - t := st.readTimer - if t == nil { - t = time.NewTimer(2 * time.Second) - st.readTimer = t - } - t.Reset(2 * time.Second) - defer t.Stop() + t := time.NewTimer(wait) select { - case f := <-st.frc: - return f, nil - case err := <-st.frErrc: - return nil, err + case v := <-ch: + t.Stop() + if fr, ok := v.(Frame); ok { + return fr, nil + } + return nil, v.(error) case <-t.C: return nil, errors.New("timeout waiting for frame") } } +func (st *serverTester) readFrame() (Frame, error) { + return readFrameTimeout(st.fr, 2*time.Second) +} + func (st *serverTester) wantHeaders() *HeadersFrame { f, err := st.readFrame() if err != nil { @@ -1083,6 +1083,40 @@ func TestServer_Handler_Sends_WindowUpdate(t *testing.T) { st.wantWindowUpdate(0, 3) // no more stream-level, since END_STREAM } +// the version of the TestServer_Handler_Sends_WindowUpdate with padding. +// See golang.org/issue/16556 +func TestServer_Handler_Sends_WindowUpdate_Padding(t *testing.T) { + puppet := newHandlerPuppet() + st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { + puppet.act(w, r) + }) + defer st.Close() + defer puppet.done() + + st.greet() + + st.writeHeaders(HeadersFrameParam{ + StreamID: 1, + BlockFragment: st.encodeHeader(":method", "POST"), + EndStream: false, + EndHeaders: true, + }) + st.writeDataPadded(1, false, []byte("abcdef"), []byte("1234")) + + // Expect to immediately get our 5 bytes of padding back for + // both the connection and stream (4 bytes of padding + 1 byte of length) + st.wantWindowUpdate(0, 5) + st.wantWindowUpdate(1, 5) + + puppet.do(readBodyHandler(t, "abc")) + st.wantWindowUpdate(0, 3) + st.wantWindowUpdate(1, 3) + + puppet.do(readBodyHandler(t, "def")) + st.wantWindowUpdate(0, 3) + st.wantWindowUpdate(1, 3) +} + func TestServer_Send_GoAway_After_Bogus_WindowUpdate(t *testing.T) { st := newServerTester(t, nil) defer st.Close() @@ -2167,6 +2201,9 @@ func TestServer_NoCrash_HandlerClose_Then_ClientClose(t *testing.T) { // it did before. st.writeData(1, true, []byte("foo")) + // Get our flow control bytes back, since the handler didn't get them. + st.wantWindowUpdate(0, uint32(len("foo"))) + // Sent after a peer sends data anyway (admittedly the // previous RST_STREAM might've still been in-flight), // but they'll get the more friendly 'cancel' code @@ -3301,3 +3338,43 @@ func TestExpect100ContinueAfterHandlerWrites(t *testing.T) { t.Fatalf("second msg = %q; want %q", buf, msg2) } } + +type funcReader func([]byte) (n int, err error) + +func (f funcReader) Read(p []byte) (n int, err error) { return f(p) } + +// golang.org/issue/16481 -- return flow control when streams close with unread data. +// (The Server version of the bug. See also TestUnreadFlowControlReturned_Transport) +func TestUnreadFlowControlReturned_Server(t *testing.T) { + unblock := make(chan bool, 1) + defer close(unblock) + + st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) { + // Don't read the 16KB request body. Wait until the client's + // done sending it and then return. This should cause the Server + // to then return those 16KB of flow control to the client. + <-unblock + }, optOnlyServer) + defer st.Close() + + tr := &Transport{TLSClientConfig: tlsConfigInsecure} + defer tr.CloseIdleConnections() + + // This previously hung on the 4th iteration. + for i := 0; i < 6; i++ { + body := io.MultiReader( + io.LimitReader(neverEnding('A'), 16<<10), + funcReader(func([]byte) (n int, err error) { + unblock <- true + return 0, io.EOF + }), + ) + req, _ := http.NewRequest("POST", st.ts.URL, body) + res, err := tr.RoundTrip(req) + if err != nil { + t.Fatal(err) + } + res.Body.Close() + } + +} diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 2b1f3a44..3cefc22a 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -16,6 +16,7 @@ import ( "io" "io/ioutil" "log" + "math" "net" "net/http" "sort" @@ -148,27 +149,28 @@ type ClientConn struct { readerDone chan struct{} // closed on error readerErr error // set before readerDone is closed - mu sync.Mutex // guards following - cond *sync.Cond // hold mu; broadcast on flow/closed changes - flow flow // our conn-level flow control quota (cs.flow is per stream) - inflow flow // peer's conn-level flow control - closed bool - goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received - goAwayDebug string // goAway frame's debug data, retained as a string - streams map[uint32]*clientStream // client-initiated - nextStreamID uint32 - bw *bufio.Writer - br *bufio.Reader - fr *Framer - lastActive time.Time - - // Settings from peer: + mu sync.Mutex // guards following + cond *sync.Cond // hold mu; broadcast on flow/closed changes + flow flow // our conn-level flow control quota (cs.flow is per stream) + inflow flow // peer's conn-level flow control + closed bool + wantSettingsAck bool // we sent a SETTINGS frame and haven't heard back + goAway *GoAwayFrame // if non-nil, the GoAwayFrame we received + goAwayDebug string // goAway frame's debug data, retained as a string + streams map[uint32]*clientStream // client-initiated + nextStreamID uint32 + bw *bufio.Writer + br *bufio.Reader + fr *Framer + lastActive time.Time + // Settings from peer: (also guarded by mu) maxFrameSize uint32 maxConcurrentStreams uint32 initialWindowSize uint32 - hbuf bytes.Buffer // HPACK encoder writes into this - henc *hpack.Encoder - freeBuf [][]byte + + hbuf bytes.Buffer // HPACK encoder writes into this + henc *hpack.Encoder + freeBuf [][]byte wmu sync.Mutex // held while writing; acquire AFTER mu if holding both werr error // first write error that has occurred @@ -339,7 +341,7 @@ func shouldRetryRequest(req *http.Request, err error) bool { return err == errClientConnUnusable } -func (t *Transport) dialClientConn(addr string) (*ClientConn, error) { +func (t *Transport) dialClientConn(addr string, singleUse bool) (*ClientConn, error) { host, _, err := net.SplitHostPort(addr) if err != nil { return nil, err @@ -348,7 +350,7 @@ func (t *Transport) dialClientConn(addr string) (*ClientConn, error) { if err != nil { return nil, err } - return t.NewClientConn(tconn) + return t.newClientConn(tconn, singleUse) } func (t *Transport) newTLSConfig(host string) *tls.Config { @@ -409,14 +411,10 @@ func (t *Transport) expectContinueTimeout() time.Duration { } func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { - if VerboseLogs { - t.vlogf("http2: Transport creating client conn to %v", c.RemoteAddr()) - } - if _, err := c.Write(clientPreface); err != nil { - t.vlogf("client preface write error: %v", err) - return nil, err - } + return t.newClientConn(c, false) +} +func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, error) { cc := &ClientConn{ t: t, tconn: c, @@ -426,7 +424,13 @@ func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { initialWindowSize: 65535, // spec default maxConcurrentStreams: 1000, // "infinite", per spec. 1000 seems good enough. streams: make(map[uint32]*clientStream), + singleUse: singleUse, + wantSettingsAck: true, } + if VerboseLogs { + t.vlogf("http2: Transport creating client conn %p to %v", cc, c.RemoteAddr()) + } + cc.cond = sync.NewCond(&cc.mu) cc.flow.add(int32(initialWindowSize)) @@ -454,6 +458,8 @@ func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { if max := t.maxHeaderListSize(); max != 0 { initialSettings = append(initialSettings, Setting{ID: SettingMaxHeaderListSize, Val: max}) } + + cc.bw.Write(clientPreface) cc.fr.WriteSettings(initialSettings...) cc.fr.WriteWindowUpdate(0, transportDefaultConnFlow) cc.inflow.add(transportDefaultConnFlow + initialWindowSize) @@ -462,33 +468,6 @@ func (t *Transport) NewClientConn(c net.Conn) (*ClientConn, error) { return nil, cc.werr } - // Read the obligatory SETTINGS frame - f, err := cc.fr.ReadFrame() - if err != nil { - return nil, err - } - sf, ok := f.(*SettingsFrame) - if !ok { - return nil, fmt.Errorf("expected settings frame, got: %T", f) - } - cc.fr.WriteSettingsAck() - cc.bw.Flush() - - sf.ForeachSetting(func(s Setting) error { - switch s.ID { - case SettingMaxFrameSize: - cc.maxFrameSize = s.Val - case SettingMaxConcurrentStreams: - cc.maxConcurrentStreams = s.Val - case SettingInitialWindowSize: - cc.initialWindowSize = s.Val - default: - // TODO(bradfitz): handle more; at least SETTINGS_HEADER_TABLE_SIZE? - t.vlogf("Unhandled Setting: %v", s) - } - return nil - }) - go cc.readLoop() return cc, nil } @@ -521,7 +500,7 @@ func (cc *ClientConn) canTakeNewRequestLocked() bool { } return cc.goAway == nil && !cc.closed && int64(len(cc.streams)+1) < int64(cc.maxConcurrentStreams) && - cc.nextStreamID < 2147483647 + cc.nextStreamID < math.MaxInt32 } func (cc *ClientConn) closeIfIdle() { @@ -531,9 +510,13 @@ func (cc *ClientConn) closeIfIdle() { return } cc.closed = true + nextID := cc.nextStreamID // TODO: do clients send GOAWAY too? maybe? Just Close: cc.mu.Unlock() + if VerboseLogs { + cc.vlogf("http2: Transport closing idle conn %p (forSingleUse=%v, maxStream=%v)", cc, cc.singleUse, nextID-2) + } cc.tconn.Close() } @@ -931,28 +914,26 @@ func (cs *clientStream) writeRequestBody(body io.Reader, bodyCloser io.Closer) ( } } - cc.wmu.Lock() - if !sentEnd { - var trls []byte - if hasTrailers { - cc.mu.Lock() - trls = cc.encodeTrailers(req) - cc.mu.Unlock() - } + var trls []byte + if !sentEnd && hasTrailers { + cc.mu.Lock() + defer cc.mu.Unlock() + trls = cc.encodeTrailers(req) + } - // Avoid forgetting to send an END_STREAM if the encoded - // trailers are 0 bytes. Both results produce and END_STREAM. - if len(trls) > 0 { - err = cc.writeHeaders(cs.ID, true, trls) - } else { - err = cc.fr.WriteData(cs.ID, true, nil) - } + cc.wmu.Lock() + defer cc.wmu.Unlock() + + // Avoid forgetting to send an END_STREAM if the encoded + // trailers are 0 bytes. Both results produce and END_STREAM. + if len(trls) > 0 { + err = cc.writeHeaders(cs.ID, true, trls) + } else { + err = cc.fr.WriteData(cs.ID, true, nil) } if ferr := cc.bw.Flush(); ferr != nil && err == nil { err = ferr } - cc.wmu.Unlock() - return err } @@ -1198,6 +1179,14 @@ func (e GoAwayError) Error() string { e.LastStreamID, e.ErrCode, e.DebugData) } +func isEOFOrNetReadError(err error) bool { + if err == io.EOF { + return true + } + ne, ok := err.(*net.OpError) + return ok && ne.Op == "read" +} + func (rl *clientConnReadLoop) cleanup() { cc := rl.cc defer cc.tconn.Close() @@ -1209,16 +1198,14 @@ func (rl *clientConnReadLoop) cleanup() { // gotten a response yet. err := cc.readerErr cc.mu.Lock() - if err == io.EOF { - if cc.goAway != nil { - err = GoAwayError{ - LastStreamID: cc.goAway.LastStreamID, - ErrCode: cc.goAway.ErrCode, - DebugData: cc.goAwayDebug, - } - } else { - err = io.ErrUnexpectedEOF + if cc.goAway != nil && isEOFOrNetReadError(err) { + err = GoAwayError{ + LastStreamID: cc.goAway.LastStreamID, + ErrCode: cc.goAway.ErrCode, + DebugData: cc.goAwayDebug, } + } else if err == io.EOF { + err = io.ErrUnexpectedEOF } for _, cs := range rl.activeRes { cs.bufPipe.CloseWithError(err) @@ -1238,15 +1225,20 @@ func (rl *clientConnReadLoop) cleanup() { func (rl *clientConnReadLoop) run() error { cc := rl.cc rl.closeWhenIdle = cc.t.disableKeepAlives() || cc.singleUse - gotReply := false // ever saw a reply + gotReply := false // ever saw a HEADERS reply + gotSettings := false for { f, err := cc.fr.ReadFrame() if err != nil { - cc.vlogf("Transport readFrame error: (%T) %v", err, err) + cc.vlogf("http2: Transport readFrame error on conn %p: (%T) %v", cc, err, err) } if se, ok := err.(StreamError); ok { if cs := cc.streamByID(se.StreamID, true /*ended; remove it*/); cs != nil { - rl.endStreamError(cs, cc.fr.errDetail) + cs.cc.writeStreamReset(cs.ID, se.Code, err) + if se.Cause == nil { + se.Cause = cc.fr.errDetail + } + rl.endStreamError(cs, se) } continue } else if err != nil { @@ -1255,6 +1247,13 @@ func (rl *clientConnReadLoop) run() error { if VerboseLogs { cc.vlogf("http2: Transport received %s", summarizeFrame(f)) } + if !gotSettings { + if _, ok := f.(*SettingsFrame); !ok { + cc.logf("protocol error: received %T before a SETTINGS frame", f) + return ConnectionError(ErrCodeProtocol) + } + gotSettings = true + } maybeIdle := false // whether frame might transition us to idle switch f := f.(type) { @@ -1283,6 +1282,9 @@ func (rl *clientConnReadLoop) run() error { cc.logf("Transport: unhandled response frame type %T", f) } if err != nil { + if VerboseLogs { + cc.vlogf("http2: Transport conn %p received error from processing frame %v: %v", cc, summarizeFrame(f), err) + } return err } if rl.closeWhenIdle && gotReply && maybeIdle && len(rl.activeRes) == 0 { @@ -1532,10 +1534,27 @@ var errClosedResponseBody = errors.New("http2: response body closed") func (b transportResponseBody) Close() error { cs := b.cs - if cs.bufPipe.Err() != io.EOF { - // TODO: write test for this - cs.cc.writeStreamReset(cs.ID, ErrCodeCancel, nil) + cc := cs.cc + + serverSentStreamEnd := cs.bufPipe.Err() == io.EOF + unread := cs.bufPipe.Len() + + if unread > 0 || !serverSentStreamEnd { + cc.mu.Lock() + cc.wmu.Lock() + if !serverSentStreamEnd { + cc.fr.WriteRSTStream(cs.ID, ErrCodeCancel) + } + // Return connection-level flow control. + if unread > 0 { + cc.inflow.add(int32(unread)) + cc.fr.WriteWindowUpdate(0, uint32(unread)) + } + cc.bw.Flush() + cc.wmu.Unlock() + cc.mu.Unlock() } + cs.bufPipe.BreakWithError(errClosedResponseBody) return nil } @@ -1543,6 +1562,7 @@ func (b transportResponseBody) Close() error { func (rl *clientConnReadLoop) processData(f *DataFrame) error { cc := rl.cc cs := cc.streamByID(f.StreamID, f.StreamEnded()) + data := f.Data() if cs == nil { cc.mu.Lock() neverSent := cc.nextStreamID @@ -1556,10 +1576,22 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { // TODO: be stricter here? only silently ignore things which // we canceled, but not things which were closed normally // by the peer? Tough without accumulating too much state. + + // But at least return their flow control: + if f.Length > 0 { + cc.mu.Lock() + cc.inflow.add(int32(f.Length)) + cc.mu.Unlock() + + cc.wmu.Lock() + cc.fr.WriteWindowUpdate(0, uint32(f.Length)) + cc.bw.Flush() + cc.wmu.Unlock() + } return nil } - if data := f.Data(); len(data) > 0 { - if cs.bufPipe.b == nil { + if f.Length > 0 { + if len(data) > 0 && cs.bufPipe.b == nil { // Data frame after it's already closed? cc.logf("http2: Transport received DATA frame for closed stream; closing connection") return ConnectionError(ErrCodeProtocol) @@ -1567,17 +1599,30 @@ func (rl *clientConnReadLoop) processData(f *DataFrame) error { // Check connection-level flow control. cc.mu.Lock() - if cs.inflow.available() >= int32(len(data)) { - cs.inflow.take(int32(len(data))) + if cs.inflow.available() >= int32(f.Length) { + cs.inflow.take(int32(f.Length)) } else { cc.mu.Unlock() return ConnectionError(ErrCodeFlowControl) } + // Return any padded flow control now, since we won't + // refund it later on body reads. + if pad := int32(f.Length) - int32(len(data)); pad > 0 { + cs.inflow.add(pad) + cc.inflow.add(pad) + cc.wmu.Lock() + cc.fr.WriteWindowUpdate(0, uint32(pad)) + cc.fr.WriteWindowUpdate(cs.ID, uint32(pad)) + cc.bw.Flush() + cc.wmu.Unlock() + } cc.mu.Unlock() - if _, err := cs.bufPipe.Write(data); err != nil { - rl.endStreamError(cs, err) - return err + if len(data) > 0 { + if _, err := cs.bufPipe.Write(data); err != nil { + rl.endStreamError(cs, err) + return err + } } } @@ -1606,6 +1651,11 @@ func (rl *clientConnReadLoop) endStreamError(cs *clientStream, err error) { if isConnectionCloseRequest(cs.req) { rl.closeWhenIdle = true } + + select { + case cs.resc <- resAndError{err: err}: + default: + } } func (cs *clientStream) copyTrailers() { @@ -1633,18 +1683,39 @@ func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { cc := rl.cc cc.mu.Lock() defer cc.mu.Unlock() - return f.ForeachSetting(func(s Setting) error { + + if f.IsAck() { + if cc.wantSettingsAck { + cc.wantSettingsAck = false + return nil + } + return ConnectionError(ErrCodeProtocol) + } + + err := f.ForeachSetting(func(s Setting) error { switch s.ID { case SettingMaxFrameSize: cc.maxFrameSize = s.Val case SettingMaxConcurrentStreams: cc.maxConcurrentStreams = s.Val case SettingInitialWindowSize: - // TODO: error if this is too large. + // Values above the maximum flow-control + // window size of 2^31-1 MUST be treated as a + // connection error (Section 5.4.1) of type + // FLOW_CONTROL_ERROR. + if s.Val > math.MaxInt32 { + return ConnectionError(ErrCodeFlowControl) + } - // TODO: adjust flow control of still-open + // Adjust flow control of currently-open // frames by the difference of the old initial // window size and this one. + delta := int32(s.Val) - int32(cc.initialWindowSize) + for _, cs := range cc.streams { + cs.flow.add(delta) + } + cc.cond.Broadcast() + cc.initialWindowSize = s.Val default: // TODO(bradfitz): handle more settings? SETTINGS_HEADER_TABLE_SIZE probably. @@ -1652,6 +1723,16 @@ func (rl *clientConnReadLoop) processSettings(f *SettingsFrame) error { } return nil }) + if err != nil { + return err + } + + cc.wmu.Lock() + defer cc.wmu.Unlock() + + cc.fr.WriteSettingsAck() + cc.bw.Flush() + return cc.werr } func (rl *clientConnReadLoop) processWindowUpdate(f *WindowUpdateFrame) error { @@ -1688,7 +1769,7 @@ func (rl *clientConnReadLoop) processResetStream(f *RSTStreamFrame) error { // which closes this, so there // isn't a race. default: - err := StreamError{cs.ID, f.ErrCode} + err := streamError(cs.ID, f.ErrCode) cs.resetErr = err close(cs.peerReset) cs.bufPipe.CloseWithError(err) @@ -1725,8 +1806,10 @@ func (rl *clientConnReadLoop) processPushPromise(f *PushPromiseFrame) error { } func (cc *ClientConn) writeStreamReset(streamID uint32, code ErrCode, err error) { - // TODO: do something with err? send it as a debug frame to the peer? - // But that's only in GOAWAY. Invent a new frame type? Is there one already? + // TODO: map err to more interesting error codes, once the + // HTTP community comes up with some. But currently for + // RST_STREAM there's no equivalent to GOAWAY frame's debug + // data, and the error codes are all pretty vague ("cancel"). cc.wmu.Lock() cc.fr.WriteRSTStream(streamID, code) cc.bw.Flush() diff --git a/vendor/golang.org/x/net/http2/transport_test.go b/vendor/golang.org/x/net/http2/transport_test.go index 58877148..9ab4149f 100644 --- a/vendor/golang.org/x/net/http2/transport_test.go +++ b/vendor/golang.org/x/net/http2/transport_test.go @@ -652,6 +652,19 @@ func (ct *clientTester) greet() { } } +func (ct *clientTester) readNonSettingsFrame() (Frame, error) { + for { + f, err := ct.fr.ReadFrame() + if err != nil { + return nil, err + } + if _, ok := f.(*SettingsFrame); ok { + continue + } + return f, nil + } +} + func (ct *clientTester) cleanup() { ct.tr.CloseIdleConnections() } @@ -686,6 +699,28 @@ func (ct *clientTester) start(which string, errc chan<- error, fn func() error) }() } +func (ct *clientTester) readFrame() (Frame, error) { + return readFrameTimeout(ct.fr, 2*time.Second) +} + +func (ct *clientTester) firstHeaders() (*HeadersFrame, error) { + for { + f, err := ct.readFrame() + if err != nil { + return nil, fmt.Errorf("ReadFrame while waiting for Headers: %v", err) + } + switch f.(type) { + case *WindowUpdateFrame, *SettingsFrame: + continue + } + hf, ok := f.(*HeadersFrame) + if !ok { + return nil, fmt.Errorf("Got %T; want HeadersFrame", f) + } + return hf, nil + } +} + type countingReader struct { n *int64 } @@ -703,8 +738,12 @@ func TestTransportReqBodyAfterResponse_403(t *testing.T) { testTransportReqBodyA func testTransportReqBodyAfterResponse(t *testing.T, status int) { const bodySize = 10 << 20 + clientDone := make(chan struct{}) ct := newClientTester(t) ct.client = func() error { + defer ct.cc.(*net.TCPConn).CloseWrite() + defer close(clientDone) + var n int64 // atomic req, err := http.NewRequest("PUT", "https://dummy.tld/", io.LimitReader(countingReader{&n}, bodySize)) if err != nil { @@ -745,7 +784,15 @@ func testTransportReqBodyAfterResponse(t *testing.T, status int) { for { f, err := ct.fr.ReadFrame() if err != nil { - return err + select { + case <-clientDone: + // If the client's done, it + // will have reported any + // errors on its side. + return nil + default: + return err + } } //println(fmt.Sprintf("server got frame: %v", f)) switch f := f.(type) { @@ -784,7 +831,6 @@ func testTransportReqBodyAfterResponse(t *testing.T, status int) { if err := ct.fr.WriteData(f.StreamID, true, nil); err != nil { return err } - return nil } default: return fmt.Errorf("Unexpected client frame %v", f) @@ -1200,8 +1246,9 @@ func testInvalidTrailer(t *testing.T, trailers headerType, wantErr error, writeT return fmt.Errorf("status code = %v; want 200", res.StatusCode) } slurp, err := ioutil.ReadAll(res.Body) - if err != wantErr { - return fmt.Errorf("res.Body ReadAll error = %q, %#v; want %T of %#v", slurp, err, wantErr, wantErr) + se, ok := err.(StreamError) + if !ok || se.Cause != wantErr { + return fmt.Errorf("res.Body ReadAll error = %q, %#v; want StreamError with cause %T, %#v", slurp, err, wantErr, wantErr) } if len(slurp) > 0 { return fmt.Errorf("body = %q; want nothing", slurp) @@ -2090,10 +2137,293 @@ func testTransportUsesGoAwayDebugError(t *testing.T, failMidBody bool) { // the interesting parts of both. ct.fr.WriteGoAway(5, ErrCodeNo, []byte(goAwayDebugData)) ct.fr.WriteGoAway(5, goAwayErrCode, nil) - ct.sc.Close() + ct.sc.(*net.TCPConn).CloseWrite() <-clientDone return nil } } ct.run() } + +// See golang.org/issue/16481 +func TestTransportReturnsUnusedFlowControl(t *testing.T) { + ct := newClientTester(t) + + clientClosed := make(chan bool, 1) + serverWroteBody := make(chan bool, 1) + + ct.client = func() error { + req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) + res, err := ct.tr.RoundTrip(req) + if err != nil { + return err + } + <-serverWroteBody + + if n, err := res.Body.Read(make([]byte, 1)); err != nil || n != 1 { + return fmt.Errorf("body read = %v, %v; want 1, nil", n, err) + } + res.Body.Close() // leaving 4999 bytes unread + clientClosed <- true + + return nil + } + ct.server = func() error { + ct.greet() + + var hf *HeadersFrame + for { + f, err := ct.fr.ReadFrame() + if err != nil { + return fmt.Errorf("ReadFrame while waiting for Headers: %v", err) + } + switch f.(type) { + case *WindowUpdateFrame, *SettingsFrame: + continue + } + var ok bool + hf, ok = f.(*HeadersFrame) + if !ok { + return fmt.Errorf("Got %T; want HeadersFrame", f) + } + break + } + + var buf bytes.Buffer + enc := hpack.NewEncoder(&buf) + enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) + enc.WriteField(hpack.HeaderField{Name: "content-length", Value: "5000"}) + ct.fr.WriteHeaders(HeadersFrameParam{ + StreamID: hf.StreamID, + EndHeaders: true, + EndStream: false, + BlockFragment: buf.Bytes(), + }) + ct.fr.WriteData(hf.StreamID, false, make([]byte, 5000)) // without ending stream + serverWroteBody <- true + + <-clientClosed + + waitingFor := "RSTStreamFrame" + for { + f, err := ct.fr.ReadFrame() + if err != nil { + return fmt.Errorf("ReadFrame while waiting for %s: %v", waitingFor, err) + } + if _, ok := f.(*SettingsFrame); ok { + continue + } + switch waitingFor { + case "RSTStreamFrame": + if rf, ok := f.(*RSTStreamFrame); !ok || rf.ErrCode != ErrCodeCancel { + return fmt.Errorf("Expected a WindowUpdateFrame with code cancel; got %v", summarizeFrame(f)) + } + waitingFor = "WindowUpdateFrame" + case "WindowUpdateFrame": + if wuf, ok := f.(*WindowUpdateFrame); !ok || wuf.Increment != 4999 { + return fmt.Errorf("Expected WindowUpdateFrame for 4999 bytes; got %v", summarizeFrame(f)) + } + return nil + } + } + } + ct.run() +} + +// Issue 16612: adjust flow control on open streams when transport +// receives SETTINGS with INITIAL_WINDOW_SIZE from server. +func TestTransportAdjustsFlowControl(t *testing.T) { + ct := newClientTester(t) + clientDone := make(chan struct{}) + + const bodySize = 1 << 20 + + ct.client = func() error { + defer ct.cc.(*net.TCPConn).CloseWrite() + defer close(clientDone) + + req, _ := http.NewRequest("POST", "https://dummy.tld/", struct{ io.Reader }{io.LimitReader(neverEnding('A'), bodySize)}) + res, err := ct.tr.RoundTrip(req) + if err != nil { + return err + } + res.Body.Close() + return nil + } + ct.server = func() error { + _, err := io.ReadFull(ct.sc, make([]byte, len(ClientPreface))) + if err != nil { + return fmt.Errorf("reading client preface: %v", err) + } + + var gotBytes int64 + var sentSettings bool + for { + f, err := ct.fr.ReadFrame() + if err != nil { + select { + case <-clientDone: + return nil + default: + return fmt.Errorf("ReadFrame while waiting for Headers: %v", err) + } + } + switch f := f.(type) { + case *DataFrame: + gotBytes += int64(len(f.Data())) + // After we've got half the client's + // initial flow control window's worth + // of request body data, give it just + // enough flow control to finish. + if gotBytes >= initialWindowSize/2 && !sentSettings { + sentSettings = true + + ct.fr.WriteSettings(Setting{ID: SettingInitialWindowSize, Val: bodySize}) + ct.fr.WriteWindowUpdate(0, bodySize) + ct.fr.WriteSettingsAck() + } + + if f.StreamEnded() { + var buf bytes.Buffer + enc := hpack.NewEncoder(&buf) + enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) + ct.fr.WriteHeaders(HeadersFrameParam{ + StreamID: f.StreamID, + EndHeaders: true, + EndStream: true, + BlockFragment: buf.Bytes(), + }) + } + } + } + } + ct.run() +} + +// See golang.org/issue/16556 +func TestTransportReturnsDataPaddingFlowControl(t *testing.T) { + ct := newClientTester(t) + + unblockClient := make(chan bool, 1) + + ct.client = func() error { + req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) + res, err := ct.tr.RoundTrip(req) + if err != nil { + return err + } + defer res.Body.Close() + <-unblockClient + return nil + } + ct.server = func() error { + ct.greet() + + var hf *HeadersFrame + for { + f, err := ct.fr.ReadFrame() + if err != nil { + return fmt.Errorf("ReadFrame while waiting for Headers: %v", err) + } + switch f.(type) { + case *WindowUpdateFrame, *SettingsFrame: + continue + } + var ok bool + hf, ok = f.(*HeadersFrame) + if !ok { + return fmt.Errorf("Got %T; want HeadersFrame", f) + } + break + } + + var buf bytes.Buffer + enc := hpack.NewEncoder(&buf) + enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) + enc.WriteField(hpack.HeaderField{Name: "content-length", Value: "5000"}) + ct.fr.WriteHeaders(HeadersFrameParam{ + StreamID: hf.StreamID, + EndHeaders: true, + EndStream: false, + BlockFragment: buf.Bytes(), + }) + pad := []byte("12345") + ct.fr.WriteDataPadded(hf.StreamID, false, make([]byte, 5000), pad) // without ending stream + + f, err := ct.readNonSettingsFrame() + if err != nil { + return fmt.Errorf("ReadFrame while waiting for first WindowUpdateFrame: %v", err) + } + wantBack := uint32(len(pad)) + 1 // one byte for the length of the padding + if wuf, ok := f.(*WindowUpdateFrame); !ok || wuf.Increment != wantBack || wuf.StreamID != 0 { + return fmt.Errorf("Expected conn WindowUpdateFrame for %d bytes; got %v", wantBack, summarizeFrame(f)) + } + + f, err = ct.readNonSettingsFrame() + if err != nil { + return fmt.Errorf("ReadFrame while waiting for second WindowUpdateFrame: %v", err) + } + if wuf, ok := f.(*WindowUpdateFrame); !ok || wuf.Increment != wantBack || wuf.StreamID == 0 { + return fmt.Errorf("Expected stream WindowUpdateFrame for %d bytes; got %v", wantBack, summarizeFrame(f)) + } + unblockClient <- true + return nil + } + ct.run() +} + +// golang.org/issue/16572 -- RoundTrip shouldn't hang when it gets a +// StreamError as a result of the response HEADERS +func TestTransportReturnsErrorOnBadResponseHeaders(t *testing.T) { + ct := newClientTester(t) + + ct.client = func() error { + req, _ := http.NewRequest("GET", "https://dummy.tld/", nil) + res, err := ct.tr.RoundTrip(req) + if err == nil { + res.Body.Close() + return errors.New("unexpected successful GET") + } + want := StreamError{1, ErrCodeProtocol, headerFieldNameError(" content-type")} + if !reflect.DeepEqual(want, err) { + t.Errorf("RoundTrip error = %#v; want %#v", err, want) + } + return nil + } + ct.server = func() error { + ct.greet() + + hf, err := ct.firstHeaders() + if err != nil { + return err + } + + var buf bytes.Buffer + enc := hpack.NewEncoder(&buf) + enc.WriteField(hpack.HeaderField{Name: ":status", Value: "200"}) + enc.WriteField(hpack.HeaderField{Name: " content-type", Value: "bogus"}) // bogus spaces + ct.fr.WriteHeaders(HeadersFrameParam{ + StreamID: hf.StreamID, + EndHeaders: true, + EndStream: false, + BlockFragment: buf.Bytes(), + }) + + for { + fr, err := ct.readFrame() + if err != nil { + return fmt.Errorf("error waiting for RST_STREAM from client: %v", err) + } + if _, ok := fr.(*SettingsFrame); ok { + continue + } + if rst, ok := fr.(*RSTStreamFrame); !ok || rst.StreamID != 1 || rst.ErrCode != ErrCodeProtocol { + t.Errorf("Frame = %v; want RST_STREAM for stream 1 with ErrCodeProtocol", summarizeFrame(fr)) + } + break + } + + return nil + } + ct.run() +} diff --git a/vendor/golang.org/x/net/publicsuffix/table.go b/vendor/golang.org/x/net/publicsuffix/table.go index 00fa1ef5..dfe67ebe 100644 --- a/vendor/golang.org/x/net/publicsuffix/table.go +++ b/vendor/golang.org/x/net/publicsuffix/table.go @@ -2,7 +2,7 @@ package publicsuffix -const version = "publicsuffix.org's public_suffix_list.dat, git revision fb4a6bce72a86feaf6c38f0a43cd05baf97a9258 (2016-07-07T00:50:50Z)" +const version = "publicsuffix.org's public_suffix_list.dat, git revision 533b016049473e520193e70156e4b54dc1f19568 (2016-08-05T11:21:15Z)" const ( nodesBitsChildren = 9 @@ -26,441 +26,442 @@ const ( const numTLD = 1552 // Text is the combined text of all labels. -const text = "biellaakesvuemieleccebieszczadygeyachimataipeigersundrangedalivo" + - "rnoddabievatmallorcafederationikonantanangerbifukagawalmartatesh" + - "inanomachintaijinfolldalomzansimagicasadelamonedatsunanjoetsuwan" + - "ouchikujogaszkoladbrokesamsclubindalorenskogliwicebihorologyusui" + - "sserveexchangebikedagestangeorgeorgiabilbaogakievenesamsunglobal" + - "ashovhachinohedmarkhangelskatowicebillustrationinohekinannestadr" + +const text = "biellaakesvuemieleccebieszczadygeyachimataipeigersundnpaleomutas" + + "hinainfolldalottebievatmallorcafederationinohekinannestadrangeda" + + "lottokonamegatakatorintuitateshinanomachintaijinuyamanouchikuhok" + + "uryugasakitashiobarabifukagawalmartateyamabihorologyusuisserveex" + + "changebikedagestangebilbaogakievenesandvikcoromantovalle-d-aosta" + + "thellexusdecorativeartsanfranciscofreakunemurorangeiseiyoichirop" + + "racticaseihichisobetsuitairabillustrationinomiyakonojoshkar-olaw" + + "abiobirdartcenterprisesakikonaircraftraeumtgeradealstahaugesundr" + "ivelandrobaknoluoktainaikawachinaganoharamcoalaheadjudaicable-mo" + - "dembetsukuintuitateyamabiomutashinainuyamanouchikuhokuryugasakit" + - "ashiobarabirdartcenterprisesakikonaircraftraeumtgeradealstahauge" + - "sundunloppacificaseihichisobetsuitairabirkenesoddtangenovaravenn" + - "agatorockartuzyuudmurtiabirthplacebjarkoyuzawabjerkreimdbalatino" + - "rdkappgafanpachigasakidsmynasperschlesisches3-sa-east-1bjugniezn" + - "ordre-landunsandvikcoromantovalle-d-aostatoilotenkawablockbuster" + - "nidupontariobloombergbauernrtatsunobloxcmsanfranciscofreakunemur" + - "orangeiseiyoichiropracticasertaishinomakikuchikuseikarugaulardal" + - "ottebluedaplierneuesangobmoattachmentsanjotattoolsztynsettlersan" + - "naninomiyakonojoshkar-olayangroupaleobmsannohelplfinancialottoko" + - "namegatakatorinvestmentsanokatsushikabeeldengeluidurbanamexhibit" + - "ionirasakis-a-candidatebmweirbnpparibaselburglobodoes-itverranza" + - "nquannefrankfurtaxihuanishiazais-a-catererbomloansantabarbarabon" + - "durhamburglogowfarmsteadvrcambridgestonewspaperbonnishigotsukiso" + - "fukushimaritimodenakanojohanamakinoharabookingloppenzaogashimada" + - "chicagoboatsantacruzsantafedextraspace-to-rentalstomakomaibarabo" + - "otsanukis-a-celticsfanishiharaboschaefflerdalouvreitgoryuzhno-sa" + - "khalinskatsuyamaseratis-a-chefarsundvrdnsfor-better-thandabostik" + - "aufenishiizunazukis-a-conservativefsncfdwgmbhartiffanybostonakij" + - "insekikogentingminakamichiharabotanicalgardenishikatakazakis-a-c" + - "padoval-daostavalleybotanicgardenishikatsuragithubusercontentjel" + - "dsundyndns-ipalermomasvuotnakatombetsupplybotanybouncemerckautok" + - "einobounty-fullensakerrypropertiesaotomeloyalistockholmestrandyn" + - "dns-mailowiczest-le-patrondheimperiaboutiquebecngmodellingmxfini" + - "tybozentsujiiebradescorporationishikawazukanazawabrandywinevalle" + - "ybrasiliabresciabrindisibenikebristolgapartmentsapodhalewismille" + - "rbritishcolumbialowiezaganishimerabroadcastleclercasinore-og-uvd" + - "alucaniabroadwaybroke-itjmaxxxjaworznobrokerbronnoysundyndns-off" + - "ice-on-the-webcampobassociatesapporobrothermesaverdeatnuorogersv" + - "palmspringsakerbrumunddaluccapitalonewhollandyndns-picsaratovall" + - "eaostavernishinomiyashironobrunelblagdenesnaaseralingenkainanaej" + - "rietisalatinabenoboribetsucksardegnamsosnowiecateringebudejjuedi" + - "schesapeakebayernurembergrimstadyndns-remotegildeskalmykiabrusse" + - "lsardiniabruxellesarlucernebryanskjervoyagebryneustarhubalestran" + - "dabergamoarekemrbuskerudinewhampshirechtrainingripebuzenishinoom" + - "otegotvalled-aostavropolitiendabuzzgorzeleccolognewmexicoldwarmi" + - "amiastaplesarpsborgriwataraidyndns-servercellikes-piedmontblanco" + - "meeresarufutsunomiyawakasaikaitakoenigrondarbwhalingrongabzhitom" + - "irkutskleppamperedchefashionishinoshimatta-varjjatjometlifeinsur" + - "ancecomputerhistoryofscience-fictioncomsecuritytacticsavonamssko" + - "ganeis-a-designerimarumorimachidacondoshichinohealthcareersaxoco" + - "nferenceconstructionconsuladoharuhrconsultanthropologyconsulting" + - "volluzerncontactoyosatoyokawacontemporaryarteducationalchikugojo" + - "medio-campidano-mediocampidanomediocontractorskenconventureshino" + - "desashibetsuikimobetsuliguriacookingchannelveruminamibosogndalvi" + - "vano-frankivskfhappoumuenchencoolkuszgradcooperaunitemasekhabaro" + - "vskhakassiacopenhagencyclopedichernihivanovosibirskydivingrosset" + - "ouchijiwadeloittevadsoccertificationissandnessjoenissayokoshibah" + - "ikariwanumataketomisatomobellevuelosangelesjaguarchitecturealtyc" + - "hyattorneyagawalbrzycharternopilawalesundyndns-wikinderoycorsica" + - "hcesuolocalhistorybnikahokutoeiheijis-a-doctoraycorvettenrightat" + - "homegoodsbschokoladencosenzakopanerairguardcostumedizinhistorisc" + - "hescholarshipschoolcouchpotatofrieschulezajskharkivgucciprianiig" + - "ataiwanairforcertmgretachikawakuyabukicks-assedichernivtsiciliac" + - "ouncilcouponschwarzgwangjuifminamidaitomangotembaixadacourseschw" + - "eizippodlasiellakasamatsudovre-eikercq-acranbrookuwanalyticscien" + - "cecentersciencehistorycreditcardcreditunioncremonashorokanaiecre" + - "wildlifedjejuegoshikiminokamoenairlinedre-eikercricketrzyncrimea" + - "crotonewportlligatewaycrownprovidercrscientistor-elvdalcruisescj" + - "ohnsoncryptonomichigangwoncuisinellahppiacenzamamibuilderscotlan" + - "dculturalcentertainmentoyotaris-a-financialadvisor-aurdalcuneocu" + - "pcakecxn--1ctwolominamatambovalledaostamayukis-a-geekgalaxycymru" + - "ovatoyotomiyazakis-a-greencyonabarussiacyouthdfcbankzjcbnlfieldf" + - "iguerestaurantoyotsukaidownloadfilateliafilminamiechizenfinalfin" + - "ancefineartscrappinguovdageaidnulsandoyfinlandfinnoyfirebaseappa" + - "raglidingushikamifuranoshiroomurafirenzefirestonextdirectoyouraf" + - "irmdaleirfjordfishingolffanserveftparisor-fronfitjarqhachiojiyah" + - "ikobeatservegame-serverisignfitnessettlementoystre-slidrettozawa" + - "fjalerflesbergxn--1lqs71dflickragerotikamakurazakinkobayashiksha" + - "cknetnedalflightservehalflifestyleflirumannortonsbergzlgfloginto" + - "gurafloraflorencefloridafloristanohatakaharulvikhmelnitskiyamasf" + - "jordenfloromskoguchikuzenflowerservehttparliamentozsdeflsmidthru" + - "heredstonexus-east-1flynnhubalsfjordishakotankarumaifarmerseinew" + - "yorkshirecreationaturbruksgymnaturhistorisches3-us-gov-west-1fnd" + - "foodnetworkshoppingfor-ourfor-someetranbyfor-theaterforexrothach" + - "irogatakamoriokamikitayamatotakadaforgotdnservehumourforli-cesen" + - "a-forlicesenaforlikescandyndns-at-workinggrouparmaforsaleirvikhm" + - "elnytskyivalleeaosteigenforsandasuoloftrani-andria-barletta-tran" + - "i-andriafortmissoulan-udefenseljordfortworthadanotaireserveirche" + - "rnovtsykkylvenetogakushimotoganewjerseyforuminamifuranofosneserv" + - "eminecraftraniandriabarlettatraniandriafotaruis-a-gurunzenfoxfor" + - "degreefreeboxostrowiechiryukyuragifudaigodoesntexistanbullensvan" + - "guardyndns-workisboringroundhandlingroznyfreemasonryfreiburgfrei" + - "ghtcmwilliamhillfreseniuscountryestateofdelawaredumbrellajollame" + - "ricanexpressexyzparocherkasyzrankoshigayaltaikis-a-hard-workerfr" + - "ibourgfriuli-v-giuliafriuli-ve-giuliafriuli-vegiuliafriuli-venez" + - "ia-giuliafriuli-veneziagiuliafriuli-vgiuliafriuliv-giuliafriuliv" + - "e-giuliafriulivegiuliafriulivenezia-giuliafriuliveneziagiuliafri" + - "ulivgiuliafrlfroganservemp3utilitiesquarezzoologicalvinklein-add" + - "rammenuernbergdyniabcn-north-1kappleaseating-organicbcg12000emma" + - "fanconagawakayamadridvagsoyericsson-aptibleangaviikadenaamesjevu" + - "emielno-ip6frognfrolandfrom-akrehamnfrom-alfrom-arfrom-azwinbalt" + - "imore-og-romsdalimitedunetbankasaokamisatokamachippubetsubetsuga" + - "ruconnectarumizusawaukraanghkebinagisochildrensgardenasushiobara" + - "bruzzoologyeongbuk-uralsk12from-capetownnews-stagingfrom-collect" + - "ionfrom-ctranoyfrom-dchitachinakagawassamukawataricohdavvenjarga" + - "usdalukowhoswhokksundynnsasayamafrom-dell-ogliastrakhanawatchese" + - "rvep2parservepicservequakefrom-flanderservesarcasmatartanddesign" + - "from-gafrom-higashiagatsumagoirminamiiselectransportrapaniimimat" + - "akatsukis-a-hunterfrom-iafrom-idfrom-ilfrom-incheonfrom-kservice" + - "settsurfastlyfrom-kyotobetsumidatlantichitosetogitsuldaluroyfrom" + - "-lanbibaidarfrom-mansionsevastopolefrom-mdfrom-megurorostrowwlkp" + - "mgfrom-microsoftbankhvanylvenicefrom-mnfrom-mochizukirafrom-msev" + - "enassisicilyfrom-mtnfrom-nchloefrom-ndfrom-nefrom-nhktravelchann" + - "elfrom-njcpartis-a-knightravelersinsurancefrom-nminamiizukamiton" + - "dabayashiogamagoriziafrom-nvaolbia-tempio-olbiatempioolbialystok" + - "kemerovodkagoshimaizurubtsovskjakdnepropetrovskiervaapsteiermark" + - "labudhabikinokawabarthadselfipartnersewindmillfrom-nyfrom-ohkura" + - "from-oketohmanxn--1qqw23afrom-orfrom-paderbornfrom-pratohnoshooo" + - "shikamaishimofusartsfranziskanerdpolicefrom-rivnefrom-schoenbrun" + - "nfrom-sdnipropetrovskypescaravantaafrom-tnfrom-txn--2m4a15efrom-" + - "utazuerichardlillehammerfest-mon-blogueurovisionfrom-vaksdalfrom" + - "-vtrdfrom-wafrom-wielunnerfrom-wvareserveblogspotrentino-a-adige" + - "from-wyfrosinonefrostalowa-wolawafroyahabaghdadultrentino-aadige" + - "fstcgroupartshangrilangevagrarboretumbriamallamagentositelefonic" + - "aaarborteaches-yogasawaracingroks-theatreefujiiderafujikawaguchi" + - "konefujiminohtawaramotoineppugliafujinomiyadafujiokayamaoris-a-l" + - "andscaperugiafujisatoshonairportland-4-salernogatagajobojis-a-la" + - "wyerfujisawafujishiroishidakabiratoridellogliastraderfujitsuruga" + - "shimamateramodalenfujixeroxn--30rr7yfujiyoshidafukayabeardubaidu" + - "ckdnsdojoburgfukuchiyamadafukudominichocolatelevisionissedalutsk" + - "azimierz-dolnyfukuis-a-liberalfukumitsubishigakirkenesharis-a-li" + - "bertarianfukuokazakirovogradoyfukuroishikarikaturindalfukusakiry" + - "uohaebaruminamimakis-a-linux-useranishiaritabashikaoizumizakitau" + - "rayasudafukuyamagatakahashimamakisarazurewebsiteshikagamiishibuk" + - "awafunabashiriuchinadafunagatakahatakaishimoichinosekigaharafuna" + - "hashikamiamakusatsumasendaisennangonohejis-a-llamarylandfundacio" + - "fuoiskujukuriyamarburgfuosskoczowindowsharpartyfurnitureggio-cal" + - "abriafurubiraquarellebesbyglandfurudonostiafurukawairtelecityeat" + - "shawaiijimarugame-hostingfusodegaurafussaikishiwadafutabayamaguc" + - "hinomigawafutboldlygoingnowhere-for-moregontrailroadfuttsurugimi" + - "namiminowafvgfyis-a-musicianfylkesbiblackfridayfyresdalhannovarg" + - "gatrentino-alto-adigehanyuzenhapmirhareidsbergenharstadharvestce" + - "lebrationhasamarahasaminami-alpssells-itrentino-altoadigehashban" + - "ghasudahasura-appassagenshimokitayamahasvikmshimonitayanagivestb" + - "ytomaritimekeepinghatogayahoohatoyamazakitahatakanabeautydalhats" + - "ukaichikaiseis-a-painteractivegarsheis-a-patsfanhattfjelldalhaya" + - "shimamotobuildinghazuminobusellsyourhomeipassenger-associationhb" + - "oehringerikehelsinkitahiroshimarriottrentino-s-tirollagrigentomo" + - "logyhembygdsforbundhemneshimonosekikawahemsedalhepforgeherokussl" + - "dheroyhgtvaroyhigashichichibungotakadatinghigashihiroshimanehiga" + - "shiizumozakitakamiizumisanofidelityumenhigashikagawahigashikagur" + - "asoedahigashikawakitaaikitakatakanezawahigashikurumeiwamarshalls" + - "tatebankokonoehigashimatsushimarinehigashimatsuyamakitaakitadait" + - "oigawahigashimurayamalatvuopmidoris-a-personaltrainerhigashinaru" + - "sembokukitakyushuaiahigashinehigashiomihachimanchesterhigashiosa" + - "kasayamamotorcycleshimosuwalkis-a-photographerokuappaviancarboni" + - "a-iglesias-carboniaiglesiascarboniahigashishirakawamatakaokamiko" + - "aniikappulawyhigashisumiyoshikawaminamiaikitamidsundhigashitsuno" + - "tteroyhigashiurausukitamotosumitakaginankokubunjis-a-playerhigas" + - "hiyamatokoriyamanakakogawahigashiyodogawahigashiyoshinogaris-a-r" + - "epublicancerresearchaeologicaliforniahiraizumisatohobby-sitehira" + - "katashinagawahiranairtraffichonanbugattipschmidtre-gauldaluxuryh" + - "irarahiratsukagawahirayaitakarazukamiminershimotsukehistorichous" + - "eshimotsumahitachiomiyaginowaniihamatamakawajimarcheapfizerhitac" + - "hiotagooglecodespotrentino-stirolhitoyoshimifunehitradinghjartda" + - "lhjelmelandholeckobierzyceholidayhomelinuxn--32vp30hagebostadhom" + - "esecuritymaceratakasagopocznosegawahomesecuritypccwinnershinichi" + - "nanhomesenseminehomeunixn--3bst00minamiogunicomcastresistancehon" + - "dahonefosshinjournalismailillesandefjordhoneywellhongorgehonjyoi" + - "takasakitanakagusukumoduminamisanrikubetsupplieshinjukumanohorni" + - "ndalhorseoulminamitanehortendofinternetrentino-sud-tirolhotelesh" + - "inkamigotoyohashimototalhotmailhoyangerhoylandetroitskolobrzeger" + - "sundhumanitieshinshinotsurgeonshalloffamemergencyberlevagangavii" + - "kanonjis-a-rockstarachowicehurdalhurumajis-a-socialistmeindianap" + - "olis-a-bloggerhyllestadhyogoris-a-soxfanhyugawarahyundaiwafunehz" + - "choseirouterjgorajlchoyodobashichikashukujitawarajlljmpgfoggiajn" + - "jelenia-gorajoyokaichibahcavuotnagaraholtaleniwaizumiotsukumiyam" + - "azonawsadodgemologicallyngenvironmentalconservationjpmorganjpnch" + - "ristmasakikugawatchandclockazojprshioyamemorialjuniperjurkristia" + - "nsundkrodsheradkrokstadelvaldaostarostwodzislawioshirakofuelkrym" + - "inamiyamashirokawanabelgorodeokumatorinokumejimassa-carrara-mass" + - "acarraramassabunkyonanaoshimageandsoundandvisionkumenanyokkaichi" + - "rurgiens-dentistes-en-francekunisakis-an-anarchistoricalsocietyk" + - "unitachiarailwaykunitomigusukumamotoyamasoykunneppupharmacyshira" + - "nukaniepcekunstsammlungkunstunddesignkuokgrouphiladelphiaareadmy" + - "blogsitekureisenkurgankurobelaudibleborkdalvdalaskanittedallasal" + - "leasingleshiraois-an-artisteinkjerusalembroiderykurogimilitaryku" + - "roisoftwarendalenugkuromatsunais-an-engineeringkurotakikawasakis" + - "-an-entertainerkurskomitamamurakushirogawakustanais-bykusuperspo" + - "rtrentinoaadigekutchanelkutnokuzbassnillfjordkuzumakis-certified" + - "ekakudamatsuekvafjordkvalsundkvamfamberkeleykvanangenkvinesdalkv" + - "innheradkviteseidskogkvitsoykwpspiegelkyowariasahikawamitourismo" + - "lanciamitoyoakemiuramiyazustkarasjokommunemiyotamanomjondalenmlb" + - "fanmonmouthaibarakisosakitagawamonstermonticellombardiamondshira" + - "okanmakiwakunigamihamadamontrealestatefarmequipmentrentinoalto-a" + - "digemonza-brianzaporizhzheguris-into-animelbournemonza-e-della-b" + - "rianzaporizhzhiamonzabrianzapposhiratakahagivingmonzaebrianzapto" + - "kuyamatsunomonzaedellabrianzaramoparachutingmordoviajessheiminan" + - "omoriyamatsusakahoginozawaonsenmoriyoshiokamitsuemormoneymoroyam" + - "atsushigemortgagemoscowitdkomonomoseushistorymosjoenmoskeneshish" + - "ikuis-into-carshintomikasaharamosshisognemosvikomorotsukamisunag" + - "awamoviemovistargardmtpchromedicaltanissettaitogliattiresaskatch" + - "ewanggouvicenzamtranakatsugawamuenstermugithubcloudusercontentre" + - "ntinoaltoadigemuikamogawamukochikushinonsenergymulhouservebeermu" + - "ltichoicemunakatanemuncieszynmuosattemuphilatelymurmanskomvuxn--" + - "3ds443gmurotorcraftrentinos-tirolmusashimurayamatsuuramusashinoh" + - "aramuseetrentinostirolmuseumverenigingmutsuzawamutuellevangermyd" + - "robofagemydshisuifuettertdasnetzmyeffectrentinosud-tirolmyfritzm" + - "yftphilipsymykolaivbarcelonagasakijobserverdalimoliserniaurskog-" + - "holandroverhalla-speziaeroportalabamagasakishimabarackmaze12myme" + - "diapchryslermyokohamamatsudamypepsonyoursidedyn-o-saurecipesaro-" + - "urbino-pesarourbinopesaromalvikongsbergmypetshitaramamyphotoshib" + - "ahccavuotnagareyamakeupowiathletajimabariakepnord-odalpharmacien" + - "snasaarlandmypsxn--3e0b707emysecuritycamerakermyshopblockshizuku" + - "ishimogosenmytis-a-bookkeepermincommbankommunalforbundmyvnchungb" + - "ukazunopictureshizuokannamiharupiemontepilotshoujis-into-cartoon" + - "shinyoshitomiokaneyamaxunusualpersonpimientakinouepinkongsvinger" + - "pioneerpippupiszpittsburghofauskedsmokorsetagayasells-for-ufcfan" + - "piwatepizzapkoninjamisonplanetariuminnesotaketakayamatsumaebashi" + - "modateplantationplantshowaplatformintelligenceplaystationplazapl" + - "chungnamdalseidfjordynv6plombardyndns-blogdnsiskinkyknethnologyp" + - "lumbingovtrentinosued-tirolplusterpmnpodzonepohlpointtomskonskow" + - "olancashireggioemiliaromagnakasatsunais-a-techietis-a-studentalp" + - "oivronpokerpokrovskonsulatrobeepilepsydneypolkowicepoltavalle-ao" + - "stathellexusdecorativeartshowtimeteorapphotographysiopomorzeszow" + - "ithgoogleapisa-hockeynutrentinosuedtirolpordenonepornporsangerpo" + - "rsanguideltajimicrolightingporsgrunnanpoznanpraxis-a-bruinsfanpr" + - "dpreservationpresidioprgmrprimelhusgardenprincipeprivatizehealth" + - "insuranceprochowiceproductionshriramlidlugolekagaminogiessenebak" + - "keshibechambagriculturennebudapest-a-la-masionthewifiat-band-cam" + - "paniaprofbsbxn--1lqs03nprogressivegaskimitsubatamicadaquesienapl" + - "esigdalprojectrentoyonakagyokutoyakokamishihoronobeokaminoyamats" + - "uris-into-gamessinashikitchenpromombetsupportrevisohughesilkonyv" + - "elolpropertyprotectionprudentialpruszkowithyoutubeneventodayprze" + - "worskogptzpvtroandinosaurlandesimbirskooris-a-therapistoiapwchur" + - "chaseljeepostfoldnavyatkakamigaharapzqldqponqslgbtrogstadquicksy" + - "tesimple-urlqvchuvashiaspreadbettingspydebergsrlsrtromsojavald-a" + - "ostarnbergsrvdonskoseis-an-accountantshinshirostoragestordalstor" + - "enburgstorfjordstpetersburgstreamsterdamnserverbaniastudiostudyn" + - "dns-homeftpaccesslingstuff-4-salestufftoread-booksneslupskopervi" + - "komatsushimashikestuttgartrusteesurnadalsurreysusakis-not-certif" + - "iedogawarabikomaezakirunorthwesternmutualsusonosuzakanrasuzukanu" + - "mazurysuzukis-saveducatorahimeshimakanegasakindleikangersvalbard" + - "udinkakegawasveiosvelvikosherbrookegawasvizzeraswedenswidnicargo" + - "daddyndns-at-homednshomebuiltrvenneslaskerrylogisticsmolenskoryo" + - "lasiteswiebodzindianmarketingswiftcoveronaritakurashikis-slickom" + - "aganeswinoujscienceandhistoryswisshikis-uberleetrentino-sued-tir" + - "olvestnesokndalvestre-slidreamhostersolarssonvestre-totennishiaw" + - "akuravestvagoyvevelstadvibo-valentiavibovalentiavideovillaskoyab" + - "earalvahkihokumakogengerdalipayufuchukotkafjordvinnicarriervinny" + - "tsiavipsinaappiagetmyiphoenixn--3oq18vl8pn36avirginiavirtualvirt" + - "ueeldomeindustriesteambulancevirtuelvisakatakkoelnvistaprinterna" + - "tionalfirearmsologneviterboltrysiljan-mayenvivoldavladikavkazanv" + - "ladimirvladivostokaizukarasuyamazoevlogoipictetrentinosudtirolvo" + - "lkenkunderseaportulansnoasaitamatsukuris-leetrentino-sudtirolvol" + - "kswagentsolundbeckosaigawavologdanskoshunantokigawavolvolgogradv" + - "olyngdalvoronezhytomyrvossevangenvotevotingvotoyonezawavrnworse-" + - "thangglidingwowiwatsukiyonowtversaillesokanoyakagewritesthisblog" + - "sytewroclawloclawekostromahachijorpelandwtcirclegnicagliaridagaw" + - "alterwtfbx-oslodingenwuozuwwworldwzmiuwajimaxn--4gq48lf9jeonname" + - "rikawauexn--4it168dxn--4it797kotohiradomainsurehabmerxn--4pvxsol" + - "utionsirdalxn--54b7fta0cciticatholicheltenham-radio-openair-traf" + - "fic-controlleyxn--55qw42gxn--55qx5dxn--5js045dxn--5rtp49civilavi" + - "ationisshingugexn--5rtq34kotouraxn--5su34j936bgsgxn--5tzm5gxn--6" + - "btw5axn--6frz82gxn--6orx2rxn--6qq986b3xlxn--7t0a264civilisationi" + - "yodogawaxn--80adxhksomaxn--80ao21axn--80aqecdr1axn--80asehdbarcl" + - "aycardstvedestrandiskstationatuurwetenschappenaumburgladelmenhor" + - "stalbans3-us-west-1xn--80aswgxn--80audnedalnxn--8ltr62kouhokutam" + - "akizunokunimilanoxn--8pvr4uxn--8y0a063axn--90a3academyactivedire" + - "ctoryazannakadomari-elasticbeanstalkounosunndalxn--90aishobaraom" + - "origuchiharagusabaerobaticketsaritsynologyeongnamegawakeisenbahn" + - "xn--90azhair-surveillancexn--9dbhblg6dietcimmobilienxn--9dbq2axn" + - "--9et52uxn--9krt00axn--andy-iraxn--aroport-byanagawaxn--asky-ira" + - "xn--aurskog-hland-jnbarclays3-us-west-2xn--avery-yuasakegawaxn--" + - "b-5gaxn--b4w605ferdxn--bck1b9a5dre4civilizationrwiiheyaizuwakama" + - "tsubushikusakadogawaxn--bdddj-mrabdxn--bearalvhki-y4axn--berlevg" + - "-jxaxn--bhcavuotna-s4axn--bhccavuotna-k7axn--bidr-5nachikatsuura" + - "xn--bievt-0qa2xn--bjarky-fyanaizuxn--bjddar-ptaobaokinawashirosa" + - "tobishimaintenancexn--blt-elaborxn--bmlo-graingerxn--bod-2naroyx" + - "n--brnny-wuaccident-investigationjukudoyamagadancebetsukubabia-g" + - "oracleaningatlantabusebastopologyeonggiehtavuoatnadexeterimo-i-r" + - "anagahamaroygardendoftheinternetflixilovecollegefantasyleaguerns" + - "eyxn--brnnysund-m8accident-preventionlineat-urlxn--brum-voagatun" + - "esnzxn--btsfjord-9zaxn--c1avgxn--c2br7gxn--c3s14misasaguris-gone" + - "xn--cck2b3barefootballangenoamishirasatochigiftsakuragawaustevol" + - "lavangenativeamericanantiques3-eu-central-1xn--cg4bkis-very-bada" + - "ddjamalborkangerxn--ciqpnxn--clchc0ea0b2g2a9gcdn77-sslattumisawa" + - "xn--comunicaes-v6a2oxn--correios-e-telecomunicaes-ghc29axn--czr6" + - "94bargainstitutelekommunikationaustdalindasiaustinnaturalhistory" + - "museumcentereportarnobrzegyptianaturalsciencesnaturelles3-eu-wes" + - "t-1xn--czrs0tunkoshimizumakiyosumydissentrentinoa-adigexn--czru2" + - "dxn--czrw28barreauctionaval-d-aosta-valleyonagoyaustraliaisondri" + - "odejaneirochestereviewskrakowebhoppdalaziobihirosakikamijimattel" + - "edatabaseballooningjesdalillyokosukareliancebinorilskariyakumold" + - "evennodessagaeroclubmedecincinnationwidealerhcloudcontrolledds3-" + - "external-1xn--d1acj3barrel-of-knowledgeologyonaguniversityoriika" + - "shibatakashimarylhurstjordalshalsenavigationavuotnakayamatsuzaki" + - "bigawaustrheimatunduhrennesoyokotebizenakamuratakahamaniwakurate" + - "xasdaburyatiaarpagefrontappagespeedmobilizerobiraetnagaivuotnaga" + - "okakyotambabydgoszczecinemailavagiske164xn--d1alfaromeoxn--d1atu" + - "rystykarasjohkamiokaminokawanishiaizubangexn--d5qv7z876civilwarm" + - "anagementkmaxxn--11b4c3dyroyrvikinguitarsassaris-a-democratmpana" + - "sonichelyabinskodjeffersonishiokoppegardyndns-weberlincolnishito" + - "sashimizunaminamiashigaraxn--davvenjrga-y4axn--djrs72d6uyxn--djt" + - "y4kouyamashikis-an-actorxn--dnna-grajewolterskluwerxn--drbak-wua" + - "xn--dyry-iraxn--e1a4claimsatxn--1ck2e1balsanagochihayaakasakawah" + - "araumalopolskanlandiscoveryokamikawanehonbetsurutaharaugustowada" + - "egubs3-ap-southeast-2xn--eckvdtc9dxn--efvn9somnarashinoxn--efvy8" + - "8hakatanotogawaxn--ehqz56nxn--elqq16hakodatexn--estv75gxn--eveni" + - "-0qa01gaxn--f6qx53axn--fct429kouzushimashikokuchuoxn--fhbeiarnxn" + - "--finny-yuaxn--fiq228c5hsooxn--fiq64barrell-of-knowledgeometre-e" + - "xperts-comptablesakuraibmditchyouripalaceu-1xn--fiqs8sopotromsak" + - "akinokiaxn--fiqz9sor-odalxn--fjord-lraxn--fjq720axn--fl-ziaxn--f" + - "lor-jraxn--flw351exn--fpcrj9c3dxn--frde-grandrapidsor-varangerxn" + - "--frna-woaraisaijosoyrovigorlicexn--frya-hraxn--fzc2c9e2clickddi" + - "elddanuorrikuzentakatajirissagamiharaxn--fzys8d69uvgmailxn--g2xx" + - "48clinichernigovernmentjxn--0trq7p7nnishiwakis-a-cubicle-slavell" + - "inowruzhgorodoyxn--gckr3f0fbxostrolekaluganskharkovallee-aostero" + - "yxn--gecrj9cliniquenoharaxn--ggaviika-8ya47hakonexn--gildeskl-g0" + - "axn--givuotna-8yandexn--3pxu8kosugexn--gjvik-wuaxn--gk3at1exn--g" + - "ls-elacaixaxn--gmq050is-very-evillagexn--gmqw5axn--h-2failxn--h1" + - "aeghakubankmpspacekitagatakasugais-a-nascarfanxn--h2brj9clintono" + - "shoesaudaxn--hbmer-xqaxn--hcesuolo-7ya35bashkiriauthordalandroid" + - "gcanonoichinomiyakehimejibestadigitalimanowarudagroks-thisamitsu" + - "kembuchikumagayagawakkanaibetsubamericanfamilydscloudappspotager" + - "epairbusantiquest-a-la-maisondre-landebusinessebyklefrakkestaddn" + - "skingjerdrumckinseyekaterinburgjerstadotsuruokamchatkameokameyam" + - "ashinatsukigatakamatsukawabogadocscbggfareastcoastaldefence-burg" + - "jemnes3-ap-northeast-1xn--hery-iraxn--hgebostad-g3axn--hmmrfeast" + - "a-s4acctuscanyxn--hnefoss-q1axn--hobl-iraxn--holtlen-hxaxn--hpmi" + - "r-xqaxn--hxt814exn--hyanger-q1axn--hylandet-54axn--i1b6b1a6a2exn" + - "--imr513nxn--indery-fyaotsurgutsiracusaitoshimaxn--io0a7is-very-" + - "goodhandsonxn--j1aefermobilyxn--j1amhakuis-a-nurservebbshellaspe" + - "ziaxn--j6w193gxn--jlq61u9w7basilicataniautomotivecodynaliascoli-" + - "picenoipirangamvikarlsoyokozemersongdalenviknakaniikawatanaguram" + - "usementargets-itargi234xn--jlster-byaroslavlaanderenxn--jrpeland" + - "-54axn--jvr189misconfusedxn--k7yn95exn--karmy-yuaxn--kbrq7oxn--k" + - "crx77d1x4axn--kfjord-iuaxn--klbu-woaxn--klt787dxn--kltp7dxn--klt" + - "x9axn--klty5xn--42c2d9axn--koluokta-7ya57hakusandiegoodyearthaga" + - "khanamigawaxn--kprw13dxn--kpry57dxn--kpu716ferraraxn--kput3is-ve" + - "ry-nicexn--krager-gyasakaiminatoyonoxn--kranghke-b0axn--krdshera" + - "d-m8axn--krehamn-dxaxn--krjohka-hwab49jetztrentino-suedtirolxn--" + - "ksnes-uuaxn--kvfjord-nxaxn--kvitsy-fyasugis-very-sweetpepperxn--" + - "kvnangen-k0axn--l-1fairwindsorfoldxn--l1accentureklamborghiniiza" + - "xn--laheadju-7yasuokaratexn--langevg-jxaxn--lcvr32dxn--ldingen-q" + - "1axn--leagaviika-52basketballfinanzgorautoscanadaejeonbukarmoyom" + - "itanobninskarpaczeladz-1xn--lesund-huaxn--lgbbat1ad8jevnakershus" + - "cultureggiocalabriaxn--lgrd-poacoachampionshiphoptobamagazinebra" + - "skaunjargallupinbatochiokinoshimalselvendrellindesnesakyotanabel" + - "lunordlandivtasvuodnaharimamurogawawegroweibolzanordreisa-geekas" + - "hiharaveroykenglandiscountysvardolls3-external-2xn--lhppi-xqaxn-" + - "-linds-pramericanartushuissier-justicexn--lns-qlanxessorreisahay" + - "akawakamiichikawamisatottoris-lostre-toteneis-a-teacherkassymant" + - "echnologyxn--loabt-0qaxn--lrdal-sraxn--lrenskog-54axn--lt-liaclo" + - "thingujolsterxn--lten-granexn--lury-iraxn--mely-iraxn--merker-ku" + - "axn--mgb2ddesortlandxn--mgb9awbferrarittogoldpoint2thisayamanash" + - "iibadajozorahkkeravjudygarlandxn--mgba3a3ejtuvalle-daostavangerx" + - "n--mgba3a4f16axn--mgba3a4franamizuholdingsmileksvikozagawaxn--mg" + - "ba7c0bbn0axn--mgbaakc7dvferreroticapebretonamiasakuchinotsuchiur" + - "akawarszawashingtondclkhersonxn--mgbaam7a8haldenxn--mgbab2bdxn--" + - "mgbai9a5eva00batsfjordivttasvuotnakaiwamizawavocatanzaroweddingj" + - "ovikaruizawasnesoddenmarkets3-ap-northeast-2xn--mgbai9azgqp6jewe" + - "lryxn--mgbayh7gpaduaxn--mgbb9fbpobanazawaxn--mgbbh1a71exn--mgbc0" + - "a9azcgxn--mgbca7dzdoxn--mgberp4a5d4a87gxn--mgberp4a5d4arxn--mgbi" + - "4ecexposedxn--mgbpl2fhskozakis-an-actresshintokushimaxn--mgbqly7" + - "c0a67fbcloudfrontdoorxn--mgbqly7cvafredrikstadtvsorumisakis-foun" + - "dationxn--mgbt3dhdxn--mgbtf8flatangerxn--mgbtx2bauhausposts-and-" + - "telecommunicationsupdatelemarkashiwaravoues3-fips-us-gov-west-1x" + - "n--mgbx4cd0abbottuxfamilyxn--mix082fetsundxn--mix891fgunmarnarda" + - "lxn--mjndalen-64axn--mk0axinfinitis-with-thebandoomdnsaliascolip" + - "icenord-aurdalceshiojirishirifujiedaxn--mk1bu44cloudfunctionsauh" + - "eradxn--mkru45isleofmandalxn--mlatvuopmi-s4axn--mli-tlapyatigors" + - "kpnxn--mlselv-iuaxn--moreke-juaxn--mori-qsakuhokkaidontexisteing" + - "eekppspbananarepublicartierxn--mosjen-eyatominamiawajikissmarter" + - "thanyouslivinghistoryxn--mot-tlaquilancasterxn--mre-og-romsdal-q" + - "qbbcartoonartdecoffeedbackashiwazakiyokawaraxastronomycdn77-secu" + - "rebungoonord-frontierepbodyndns-freebox-oskolegokasells-for-less" + - "3-ap-southeast-1xn--msy-ula0halsaintlouis-a-anarchistoireggio-em" + - "ilia-romagnakanotoddenxn--mtta-vrjjat-k7afamilycompanycntoyookan" + - "zakiwienxn--muost-0qaxn--mxtq1mishimatsumotofukexn--ngbc5azdxn--" + - "ngbe9e0axn--ngbrxn--45brj9circus-2xn--nit225krasnodarxn--nmesjev" + - "uemie-tcbajddarchaeologyxn--nnx388axn--nodexn--nqv7fs00emaxn--nr" + - "y-yla5gxn--ntso0iqx3axn--ntsq17gxn--nttery-byaeservecounterstrik" + - "exn--nvuotna-hwaxn--nyqy26axn--o1achattanooganorfolkebiblegalloc" + - "us-1xn--o3cw4hammarfeastafricamagichofunatorientexpressaseboknow" + - "sitalluxembourgrpanamaxn--od0algxn--od0aq3bbtatamotorsalangenayo" + - "roceanographicsalondonetskasukabedzin-the-bandaioiraseeklogesura" + - "nceoceanographiqueu-2xn--ogbpf8flekkefjordxn--oppegrd-ixaxn--ost" + - "ery-fyatsukaratsuginamikatagamihoboleslawiecolonialwilliamsburgu" + - "lenxn--osyro-wuaxn--p1acfhvalerxn--p1aiwchoshibuyachiyodavvesiid" + - "azaifuefukihaborokunohealth-carereformitakeharaxn--pbt977colorad" + - "oplateaudioxn--pgbs0dhlxn--porsgu-sta26fidonnakamagayachtscrappe" + - "r-sitexn--pssu33lxn--pssy2uxn--q9jyb4columbusheyxn--qcka1pmcdona" + - "ldsouthcarolinazawaxn--qqqt11missilelxn--qxamurskiptveterinairea" + - "ltorlandxn--rady-iraxn--rdal-poaxn--rde-ularvikrasnoyarskomforba" + - "mblebtimnetz-2xn--rdy-0nabarixn--rennesy-v1axn--rhkkervju-01afla" + - "kstadaokagakibichuoxn--rholt-mragowoodsidexn--rhqv96gxn--rht27zx" + - "n--rht3dxn--rht61exn--risa-5narusawaxn--risr-iraxn--rland-uuaxn-" + - "-rlingen-mxaxn--rmskog-byatsushiroxn--rny31hamurakamigoriginshim" + - "okawaxn--rovu88bbvacationswatch-and-clockerxn--rros-granvindafjo" + - "rdxn--rskog-uuaxn--rst-0narutokyotangotpantheonsitextileitungsen" + - "xn--rsta-francaiseharaxn--ryken-vuaxn--ryrvik-byawaraxn--s-1fait" + - "heguardianxn--s9brj9communitysnesavannahgaxn--sandnessjen-ogbizh" + - "evskredirectmeldalxn--sandy-yuaxn--seral-lraxn--ses554gxn--sgne-" + - "gratangenxn--skierv-utazaskvolloabathsbcomobaraxn--skjervy-v1axn" + - "--skjk-soaxn--sknit-yqaxn--sknland-fxaxn--slat-5narviikananporov" + - "noxn--slt-elabourxn--smla-hraxn--smna-gratis-a-bulls-fanxn--snas" + - "e-nraxn--sndre-land-0cbremangerxn--snes-poaxn--snsa-roaxn--sr-au" + - "rdal-l8axn--sr-fron-q1axn--sr-odal-q1axn--sr-varanger-ggbentleyu" + - "kuhashimojiinetatarstanflfanfshostrodawaraxn--srfold-byawatahama" + - "xn--srreisa-q1axn--srum-grazxn--stfold-9xaxn--stjrdal-s1axn--stj" + - "rdalshalsen-sqbeppubolognagasukeverbankasumigaurawa-mazowszexbox" + - "enapponazure-mobilevje-og-hornnesaltdalinkasuyakutiaxn--stre-tot" + - "en-zcbsouthwestfalenxn--t60b56axn--tckweatherchannelxn--tiq49xqy" + - "jewishartgalleryxn--tjme-hraxn--tn0agrinet-freaksowaxn--tnsberg-" + - "q1axn--tor131oxn--trany-yuaxn--trgstad-r1axn--trna-woaxn--troms-" + - "zuaxn--tysvr-vraxn--uc0atversicherungxn--uc0ay4axn--uist22hangou" + - "tsystemscloudcontrolappasadenaklodzkodairaxn--uisz3gxn--unjrga-r" + - "tarantourspjelkavikosakaerodromegalsacechirealminamiuonumasudaxn" + - "--unup4yxn--uuwu58axn--vads-jraxn--vard-jraxn--vegrshei-c0axn--v" + - "ermgensberater-ctberndiyurihonjournalistjohnhlfanhsalvadordaliba" + - "baikaliszczytnorddalinzaiitatebayashijonawatexn--vermgensberatun" + - "g-pwbeskidynathomedepotenzachpomorskienikiiyamanobeauxartsandcra" + - "ftsalzburglassassinationalheritagematsubarakawagoexn--vestvgy-ix" + - "a6oxn--vg-yiabbvieeexn--vgan-qoaxn--vgsy-qoa0jfkomakiyosatokashi" + - "kiyosemitexn--vgu402comparemarkerryhotelsaves-the-whalessandria-" + - "trani-barletta-andriatranibarlettaandriaxn--vhquvestfoldxn--vler" + - "-qoaxn--vre-eiker-k8axn--vrggt-xqadxn--vry-yla5gxn--vuq861bestbu" + - "yshousesamegawaxn--w4r85el8fhu5dnraxn--w4rs40lxn--wcvs22dxn--wgb" + - "h1compute-1xn--wgbl6axn--xhq521betainaboxfusejnynysafetysfjordnp" + - "alanakhodkanagawaxn--xkc2al3hye2axn--xkc2dl3a5ee0hannanmokuizumo" + - "dernxn--y9a3aquariumisugitokorozawaxn--yer-znarvikristiansandcat" + - "shirahamatonbetsurgeryxn--yfro4i67oxn--ygarden-p1axn--ygbi2ammxn" + - "--45q11citadeliveryggeelvinckchristiansburgruexn--ystre-slidre-u" + - "jbieidsvollipetskaszubyusuharaxn--zbx025dxn--zf0ao64axn--zf0avxn" + - "--4gbriminingxn--zfr164bielawallonieruchomoscienceandindustrynik" + - "koebenhavnikolaeventsamnangerxperiaxz" + "dembetsukuinvestmentsangobirkenesoddtangenovarabirthplacebjarkoy" + + "uulsandoyuzawabjerkreimdbalatinorddalimitediscountysnes3-sa-east" + + "-1bjugnieznordlandrudmurtiablockbusternidunloppacificasertaishin" + + "omakikuchikuseikarugausdalouvreitatsunobloombergbauernrtattoolsz" + + "tynsettlersanjotaxihuanirasakis-a-candidatebloxcmsannanishiazais" + + "-a-catererbluedaplierneuesannohelplfinancialowiczest-le-patrondh" + + "eimperiabmoattachmentsanokasuyakutiabmsantabarbarabmweirbnpparib" + + "aselburgloppenzaogashimadachicagoboatsantacruzsantafedextraspace" + + "-to-rentalstomakomaibarabomloanswatch-and-clockerbondunsanukis-a" + + "-celticsfanishigotsukisofukushimaritimodenakanotoddenishiharabon" + + "nishiizunazukis-a-chefarmsteadupontariobookingmbhartiffanyuzhno-" + + "sakhalinskaszubybootsaotomeloyalistjordalshalsenishikatakazakis-" + + "a-conservativefsncfdurbanamexhibitionishikatsuragithubuserconten" + + "tgoryboschaefflerdalucaniabostikatowicebostonakijinsekikogenting" + + "minakamichiharabotanicalgardenishikawazukanazawabotanicgardenish" + + "imerabotanybouncemerckatsushikabeeldengeluidurhamburgmodellingmx" + + "finitybounty-fullensakerrypropertiesapodhalewismillerboutiquebec" + + "ngrimstadvrcambridgestonewspaperbozentsujiiebradescorporationish" + + "inomiyashironobrandywinevalleybrasiliabresciabrindisibenikebrist" + + "olgapartmentsapporobritishcolumbialowiezaganishinoomotegotvallea" + + "ostatoiluccapitalonewhollandvrdnsfor-better-thandabroadcastlecle" + + "rcasinore-og-uvdalucernebroadwaybroke-itjeldsundwgripebrokerbron" + + "noysundyndns-ipalermomasvuotnakatombetsupplybrothermesaverdeatnu" + + "orogersvpalmspringsakerbrowsersafetymarketsaratovalled-aostavang" + + "erbrumunddalukowfarsundyndns-mailuroybrunelblagdenesnaaseralinge" + + "nkainanaejrietisalatinabenoboribetsucksardegnamsosnowiecateringe" + + "budejjuedischesapeakebayernurembergriwataraidyndns-office-on-the" + + "-webcampobassociatesardiniabrusselsarlutskatsuyamaseratis-a-cpad" + + "oval-daostavalleybruxellesarpsborgrondarbryanskleppamperedchefas" + + "hionishinoshimatta-varjjatjmaxxxjaworznobryneustarhubalestrandab" + + "ergamoarekemreviewskrakoweddingladelmenhorstackspacekitagatajimi" + + "crolightinglassassinationalheritagematsubarakawagoeu-1buskerudin" + + "ewhampshirebungoonordreisa-geekaufenishiokoppegardyndns-picsaruf" + + "utsunomiyawakasaikaitakoenigrongabuzenishitosashimizunaminamiash" + + "igarabuzzgorzeleccolognewmexicoldwarmiamiastalowa-wolahppiacenza" + + "kopanerairguardyndns-remotegildeskalmykiabwhalingrossetouchijiwa" + + "deloittevadsoccertificationishiwakis-a-cubicle-slavellinowruzhgo" + + "rodoybzhitomirkutskodjeepostfoldnavyatkakegawalterconferencecons" + + "tructionconsuladoharuhrconsultanthropologyconsultingvollcontacto" + + "yookanzakiwiencontemporaryarteducationalchikugojomedio-campidano" + + "-mediocampidanomediocontractorskenconventureshinodesashibetsuiki" + + "mobetsuliguriacookingchannelveruminamibosogndalcoolkuszgradcoope" + + "raunitemasekfhappoumuenchencopenhagencyclopedichernihivanovosibi" + + "rskypescaravantaacorsicahcesuolocalhistorybnikahokutoeiheijis-a-" + + "doctoraycorvettenrightathomegoodsbschokoladencosenzamamibuilders" + + "cholarshipschoolcostumedizinhistorischeschulezajskhabarovskhakas" + + "siacouchpotatofrieschwarzgwangjuifminamidaitomangotembaixadacoun" + + "cilcouponschweizippodlasiellakasamatsudovre-eikercoursesciencece" + + "ntersciencehistorycq-acranbrookuwanalyticscientistockholmestrand" + + "creditcardcreditunioncremonashorokanaiecrewiiheyaizuwakamatsubus" + + "hikusakadogawacricketrzyncrimeacrotonewportlligatewaycrownprovid" + + "ercrscjohnsoncruisescotlandcryptonomichigangwoncuisinellajollame" + + "ricanexpressexyzjcbnlculturalcentertainmentoyosatoyokawacuneocup" + + "cakecxn--1ctwolominamatamayukis-a-financialadvisor-aurdalcymruov" + + "atoyotaris-a-geekgalaxycyonabarussiacyouthdfcbankzlguovdageaidnu" + + "lvikharkivgucciprianiigataiwanairforcertmgretachikawakuyabukicks" + + "-assedichernivtsiciliafieldfiguerestaurantoyotomiyazakis-a-green" + + "filateliafilminamiechizenfinalfinancefineartserveftparaglidingzp" + + "arisor-fronfinlandfinnoyfirebaseapparliamentoyotsukaidownloadfir" + + "enzefirestonextdirectoyourafirmdaleirfjordfishingolffanservegame" + + "-serverisignfitjarqhachiojiyahikobeatservehalflifestylefitnesset" + + "tlementoystre-slidrettozawafjalerflesbergflickragerotikamakuraza" + + "kiraflightservehttparmaflirumannortonsbergflogintogurafloraflore" + + "ncefloridafloristanohatakahashimamakirkeneservehumourfloromskogu" + + "chikuzenflowerserveirchernovtsykkylvenetogakushimotoganewjerseyf" + + "lsmidthruheredstonexus-east-1flynnhubalsfjordiscoveryokamikawane" + + "honbetsurutaharaurskog-holandroverhalla-speziaetnagaivuotnagaoka" + + "kyotambabydgoszczecinemailavagiske164fndfoodnetworkshoppingfor-o" + + "urfor-someetozsdefor-theaterforexrothachirogatakanabeautydalforg" + + "otdnserveminecraftranbyforli-cesena-forlicesenaforlikescandyndns" + + "-at-workinggrouparocherkasyzrankoshigayaltaikis-a-guruslivinghis" + + "toryforsaleirvikhersonforsandasuoloftrani-andria-barletta-trani-" + + "andriafortmissoulan-udefenseljordfortworthadanotaireservemp3util" + + "itiesquarezzoologicalvinklein-addrammenuernbergdyniabogadocscbgg" + + "fareastcoastaldefence-burgjemnes3-ap-northeast-1kappleaseating-o" + + "rganicbcg12000emmafanconagawakayamadridvagsoyericsson-aptibleang" + + "aviikadenaamesjevuemielno-ip6foruminamifuranofosneservep2parserv" + + "epicservequakefotaruis-a-hard-workerfoxfordegreefreeboxostrowiec" + + "hiryukyuragifudaigodoesntexistanbullensvanguardyndns-servercelli" + + "kes-piedmontblancomeeresasayamafreemasonryfreiburgfreightcmwildl" + + "ifedjejuegoshikiminokamoenairlinedre-eikerfreseniuscountryestate" + + "ofdelawaredumbrellanbibaidarfribourgfriuli-v-giuliafriuli-ve-giu" + + "liafriuli-vegiuliafriuli-venezia-giuliafriuli-veneziagiuliafriul" + + "i-vgiuliafriuliv-giuliafriulive-giuliafriulivegiuliafriulivenezi" + + "a-giuliafriuliveneziagiuliafriulivgiuliafrlfroganservesarcasmata" + + "rtanddesignfrognfrolandfrom-akrehamnfrom-alfrom-arfrom-azwilliam" + + "hillfrom-capetownnews-stagingfrom-collectionfrom-ctraniandriabar" + + "lettatraniandriafrom-dchitachinakagawatchandclockautokeinofrom-d" + + "ell-ogliastrakhanawawinbaltimore-og-romsdalindasiaustevollaziobi" + + "ragroks-thisamitsukembuchikumagayagawakkanaibetsubamericanfamily" + + "dscloudcontrolledekafjorddnskingjerdrumckinseyekaterinburgjersta" + + "dotsuruokamchatkameokameyamashinatsukigatakamoriokamikitayamatot" + + "akadabruzzoologyeongbuk-uralsk12from-flanderservicesettsurfastly" + + "from-gafrom-higashiagatsumagoirminamiiselectranoyfrom-iafrom-idf" + + "rom-ilfrom-incheonfrom-ksevastopolefrom-kyotobetsumidatlantichit" + + "osetogitsuldaluxembourgrpanamafrom-lancashireggio-calabriafrom-m" + + "ansionsevenassisicilyfrom-mdfrom-megurorostrowwlkpmgfrom-microso" + + "ftbankhmelnitskiyamasfjordenfrom-mnfrom-mochizukirovogradoyfrom-" + + "msewindmillfrom-mtnfrom-nchloefrom-ndfrom-nefrom-nhktransportrap" + + "aniimimatakatsukis-a-hunterfrom-njcpartis-a-knightravelchannelfr" + + "om-nminamiizukamitondabayashiogamagoriziafrom-nvallee-aosteroyfr" + + "om-nyfrom-ohkurafrom-oketohmanxn--1qqw23afrom-orfrom-paderbornfr" + + "om-pratohnoshoooshikamaishimofusartsfranziskanerdpolicefrom-rivn" + + "efrom-schoenbrunnfrom-sdnipropetrovskhmelnytskyivalleeaosteigenf" + + "rom-tnfrom-txn--2m4a15efrom-utazuerichardlillehammerfest-mon-blo" + + "gueurovisionfrom-vaksdalfrom-vtravelersinsurancefrom-wafrom-wiel" + + "unnerfrom-wvanylvenicefrom-wyfrosinonefrostalbanshangrilangevagr" + + "arboretumbriamallamagentositelefonicaaarborteaches-yogasawaracin" + + "groks-theatreefroyahabaghdadultrdfstavropolitiendafujiiderafujik" + + "awaguchikonefujiminohtawaramotoineppugliafujinomiyadafujiokayama" + + "oris-a-landscaperugiafujisatoshonairportland-4-salernogatagajobo" + + "jis-a-lawyerfujisawafujishiroishidakabiratoridellogliastraderfuj" + + "itsurugashimamateramodalenfujixeroxn--30rr7yfujiyoshidafukayabea" + + "rdubaiduckdnsdojoburgfukuchiyamadafukudominichocolatelevisioniss" + + "andnessjoenissayokoshibahikariwanumataketomisatomobellevuelosang" + + "elesjaguarchitecturealtychyattorneyagawalbrzycharternopilawalesu" + + "ndyndns-weberlincolnissedaluxuryfukuis-a-liberalfukumitsubishiga" + + "kiryuohadselfipartnersharis-a-libertarianfukuokazakisarazurewebs" + + "iteshikagamiishibukawafukuroishikarikaturindalfukusakishiwadafuk" + + "uyamagatakahatakaishimoichinosekigaharafunabashiriuchinadafunaga" + + "takamatsukawafunahashikamiamakusatsumasendaisennangonohejis-a-li" + + "nux-useranishiaritabashikaoizumizakitaurayasudafundaciofuoiskuju" + + "kuriyamarburgfuosskoczowindowsharpartshawaiijimarumorimachidafur" + + "nitureggio-emilia-romagnakanojohanamakinoharafurubiraquarellebes" + + "byglandfurudonostiafurukawairtelecityeatshellaspeziafusodegauraf" + + "ussaintlouis-a-anarchistoireggiocalabriafutabayamaguchinomigawaf" + + "utboldlygoingnowhere-for-moregontrailroadfuttsurugiminamimakis-a" + + "-llamarylhurstcgroupartyfvgfyis-a-musicianfylkesbiblackfridayfyr" + + "esdalhannovareserveblogspotrentino-a-adigehanyuzenhapmirhareidsb" + + "ergenharstadharvestcelebrationhasamarahasaminami-alpssells-itren" + + "tino-aadigehashbanghasudahasura-appasadenaklodzkodairahasviklabu" + + "dhabikinokawabarthagakhanamigawahatogayahoohatoyamazakitahatakan" + + "ezawahatsukaichikaiseis-a-painteractivegarsheis-a-patsfanhattfje" + + "lldalhayashimamotobuildinghazuminobusellsyourhomeipassagenshimon" + + "itayanagitlaborhboehringerikehelsinkitahiroshimarriottrentino-al" + + "to-adigehembygdsforbundhemneshimonosekikawahemsedalhepforgeherok" + + "ussldheroyhgtvarggatrentino-altoadigehigashichichibungotakadatin" + + "ghigashihiroshimanehigashiizumozakitakamiizumisanofidelitysvardo" + + "llshimosuwalkis-a-personaltrainerhigashikagawahigashikagurasoeda" + + "higashikawakitaaikitakatakaokamikoaniikappulawyhigashikurumeiwam" + + "arshallstatebankmpspbamblebtimnetz-2higashimatsushimarinehigashi" + + "matsuyamakitaakitadaitoigawahigashimurayamalatvuopmidoris-a-phot" + + "ographerokuappassenger-associationhigashinarusembokukitakyushuai" + + "ahigashinehigashiomihachimanchesterhigashiosakasayamamotorcycles" + + "himotsukehigashishirakawamatakarazukamiminershimotsumahigashisum" + + "iyoshikawaminamiaikitamidsundhigashitsunotteroyhigashiurausukita" + + "motosumitakaginankokubunjis-a-playerhigashiyamatokoriyamanakakog" + + "awahigashiyodogawahigashiyoshinogaris-a-republicancerresearchaeo" + + "logicaliforniahiraizumisatohobby-sitehirakatashinagawahiranairtr" + + "affichonanbugattipschmidtre-gauldalvivano-frankivskazimierz-doln" + + "yhirarahiratsukagawahirayaitakasagooglecodespotrentino-s-tirolla" + + "grigentomologyhistorichouseshinichinanhitachiomiyaginowaniihamat" + + "amakawajimarcheapaviancarbonia-iglesias-carboniaiglesiascarbonia" + + "hitachiotagopocznosegawahitoyoshimifunehitradinghjartdalhjelmela" + + "ndholeckobierzyceholidayhomelinuxn--32vp30hagebostadhomesecurity" + + "maceratakasakitanakagusukumoduminamiogunicomcastresistancehomese" + + "curitypccwinnershinjournalismailillesandefjordhomesenseminehomeu" + + "nixn--3bst00minamisanrikubetsupplieshinjukumanohondahonefosshink" + + "amigotoyohashimototalhoneywellhongorgehonjyoitakashimarugame-hos" + + "tinghornindalhorseoulminamitanehortendofinternetrentino-stirolho" + + "teleshinshinotsurgeonshalloffamemergencyberlevagangaviikanonjis-" + + "a-rockstarachowicehotmailhoyangerhoylandetroitskmshinshirohumani" + + "tieshintokushimahurdalhurumajis-a-socialistmeindianapolis-a-blog" + + "gerhyllestadhyogoris-a-soxfanhyugawarahyundaiwafunehzchoseiroute" + + "rjgorajlchoyodobashichikashukujitawarajlljmpgfoggiajnjelenia-gor" + + "ajoyokaichibahcavuotnagaraumakeupowiathletajimabariakepnord-fron" + + "tierjpmorganjpnchristmasakikugawatchesaskatchewanggouvicenzajprs" + + "hirahamatonbetsurgeryjuniperjurkristiansundkrodsheradkrokstadelv" + + "aldaostarnbergkryminamiyamashirokawanabelgorodeokumatorinokumeji" + + "massa-carrara-massacarraramassabunkyonanaoshimageandsoundandvisi" + + "onkumenanyokkaichirurgiens-dentistes-en-francekunisakis-an-anarc" + + "historicalsocietyumenkunitachiarailwaykunitomigusukumamotoyamaso" + + "ykunneppupharmacyshiraois-an-artisteinkjerusalembroiderykunstsam" + + "mlungkunstunddesignkuokgrouphiladelphiaareadmyblogsitekureisenku" + + "rgankurobelaudibleborkdalvdalaskanittedallasalleasingleshiraokan" + + "makiwakunigamihamadakurogimilitarykuroisoftwarendalenugkuromatsu" + + "nais-an-engineeringkurotakikawasakis-an-entertainerkurskomitamam" + + "urakushirogawakustanais-bykusupersportrentino-suedtirolkutchanel" + + "kutnokuzbassnillfjordkuzumakis-certifiedogawarabikomaezakirunort" + + "hwesternmutualkvafjordkvalsundkvamfamberkeleykvanangenkvinesdalk" + + "vinnheradkviteseidskogkvitsoykwpspjelkavikommunalforbundkyowaria" + + "sahikawamitourismolanciamitoyoakemiuramiyazumiyotamanomjondalenm" + + "lbfanmonmouthaibarakisosakitagawamonstermonticellombardiamondshi" + + "ratakahagivestbytomaritimekeepingmontrealestatefarmequipmentrent" + + "inoa-adigemonza-brianzaporizhzheguris-into-animelbournemonza-e-d" + + "ella-brianzaporizhzhiamonzabrianzapposhishikuis-into-carshiojiri" + + "shirifujiedamonzaebrianzaptokuyamatsunomonzaedellabrianzaramopar" + + "achutingmordoviajessheiminanomoriyamatsusakahoginozawaonsenmoriy" + + "oshiokamitsuemormoneymoroyamatsushigemortgagemoscowioshisognemos" + + "eushistorymosjoenmoskeneshisuifuettertdasnetzmosshitaramamosviko" + + "monomoviemovistargardmtpchromedicaltanissettaitogliattiresassari" + + "s-a-democratjxn--0trq7p7nniyodogawamtranakatsugawamuenstermugith" + + "ubcloudusercontentrentinoaadigemuikamogawamukochikushinonsenergy" + + "mulhouservebeermultichoicemunakatanemuncieszynmuosattemuphilatel" + + "ymurmanskomorotsukamisunagawamurotorcraftrentinoalto-adigemusash" + + "imurayamatsuuramusashinoharamuseetrentinoaltoadigemuseumverenigi" + + "ngmutsuzawamutuellevangermydissentrentinos-tirolmydrobofagemydsh" + + "izukuishimogosenmyeffectrentinostirolmyfritzmyftphilipsymykolaiv" + + "aroymymediapchryslermyokohamamatsudamypepsonyoursidedyn-o-saurec" + + "ipesaro-urbino-pesarourbinopesaromalvikomvuxn--3ds443gmypetshizu" + + "okannamiharumyphotoshibahccavuotnagareyamalopolskanlandmypsxn--3" + + "e0b707emysecuritycamerakermyshopblockshoujis-into-cartoonshioyam" + + "emorialmytis-a-bookkeepermincommbankommunemyvnchungbukazopicture" + + "showapiemontepilotshowtimeteorapphotographysiopimientakinouepink" + + "ongsbergpioneerpippupiszpittsburghofauskedsmokorsetagayasells-fo" + + "r-unzenpiwatepizzapkongsvingerplanetariuminnesotaketakayamatsuma" + + "ebashimodateplantationplantshriramlidlugolekagoshimaintenancepla" + + "tformintelligenceplaystationplazaplchungnamdalseidfjordyndns-wik" + + "inderoyplombardyndns-blogdnsiskinkyknethnologyplumbingovtrentino" + + "sudtirolplusterpmnpodzonepohlpointtomskoninjamisonpoivronpokerpo" + + "krovskonskowolayangroupharmacienshirakofuelpolkowicepoltavalle-a" + + "ostarostwodzislawitdkonsulatrobeepilepsydneypomorzeszowithgoogle" + + "apisa-hockeynutrentinosued-tirolpordenonepornporsangerporsanguid" + + "eltajirikuzentakatakahamamurogawaporsgrunnanpoznanpraxis-a-bruin" + + "sfanprdpreservationpresidioprgmrprimelhusgardenprincipeprivatize" + + "healthinsuranceprochowiceproductionsienaplesigdalprofbsbxn--1lqs" + + "03nprogressivegaskimitsubatamicadaquesilkonyvelolprojectrentinos" + + "uedtirolpromombetsupportrentoyonakagyokutoyakokamishihoronobeoka" + + "minoyamatsuris-into-gamessinashikitchenpropertyprotectionprudent" + + "ialpruszkowithyoutubeneventodayprzeworskogptzpvtrevisohughesimbi" + + "rskooris-a-therapistoiapwchurchaseljeffersonrwhoswhokksundyndns-" + + "workisboringruepzqldqponqslgbtroandinosaurlandesimple-urlquicksy" + + "tesirdalqvchuvashiasrlsrtromsakatakkoelnsrvbarcelonagasukeu-2sto" + + "ragestordalstorenburgstorfjordstpetersburgstreamsterdamnserverba" + + "niastudiostudyndns-homeftpaccesslupskopervikomatsushimashikestuf" + + "f-4-salestufftoread-booksnesmolenskoryolasitestuttgartromsojaval" + + "d-aostaplesnoasaitoshimasurnadalsurreysusakis-lostre-toteneis-a-" + + "teacherkassymantechnologysusonosuzakanrasuzukanumazurysuzukis-no" + + "t-certifieducatorahimeshimakanegasakindleikangersvalbardudinkaku" + + "damatsuesveiosvelvikosakaerodromegalsacechirealminamiuonumasudas" + + "vizzeraswedenswidnicargodaddyndns-at-homednshomebuiltrusteeswieb" + + "odzindianmarketingswiftcoveronaritakurashikis-savedunetbankokono" + + "eswinoujscienceandhistoryswisshikis-slickolobrzegersundtuxfamily" + + "vestnesolognevestre-slidreamhostersolundbeckosaigawavestre-toten" + + "nishiawakuravestvagoyvevelstadvibo-valentiavibovalentiavideovill" + + "askoyabearalvahkihokumakogengerdalipayufuchukotkagaminogiesseneb" + + "akkeshibechambagriculturennebudapest-a-la-masionthewifiat-band-c" + + "ampaniavinnicarriervinnytsiavipsinaappiagetmyiphoenixn--3oq18vl8" + + "pn36avirginiavirtualvirtueeldomeindustriesteambulancevirtuelvisa" + + "kegawavistaprinternationalfirearmsolutionslingviterboltrvdonskos" + + "eis-an-accountantshintomikasaharavivoldavladikavkazanvladimirvla" + + "divostokaizukarasuyamazoevlogoipictetrentinosud-tirolvolkenkunde" + + "rseaportrysiljan-mayenvolkswagentsomavologdanskoshimizumakiyosum" + + "ycdn77-securechtrainingvolvolgogradvolyngdalvoronezhytomyrvossev" + + "angenvotevotingvotoyonezawavrnworse-thangglidingwowiwatsukiyonow" + + "tvenneslaskerrylogisticsokndalwritesthisblogsytewroclawloclaweko" + + "shunantokigawawtcircus-2wtfbx-oslodingenwuozuwwworldwzmiuwajimax" + + "n--4gq48lf9jeonnamerikawauexn--4it168dxn--4it797kosugexn--4pvxso" + + "mnarashinoxn--54b7fta0ccivilaviationxn--55qw42gxn--55qx5dxn--5js" + + "045dxn--5rtp49civilisationxn--5rtq34kotohiradomainsurehabmerxn--" + + "5su34j936bgsgxn--5tzm5gxn--6btw5axn--6frz82gxn--6orx2rxn--6qq986" + + "b3xlxn--7t0a264civilizationxn--80adxhksooxn--80ao21axn--80aqecdr" + + "1axn--80asehdbarclaycardstvedestrandishakotankarumaifarmerseinew" + + "yorkshirecreationatuurwetenschappenaumburgliwicevents3-us-west-1" + + "xn--80aswgxn--80audnedalnxn--8ltr62kotouraxn--8pvr4uxn--8y0a063a" + + "xn--90a3academyactivedirectoryazannakadomari-elasticbeanstalkouh" + + "okutamakizunokunimilanoxn--90aishobaraomoriguchiharahkkeravjudyg" + + "arlandxn--90azhair-surveillancexn--9dbhblg6dietcimmobilienxn--9d" + + "bq2axn--9et52uxn--9krt00axn--andy-iraxn--aroport-byanagawaxn--as" + + "ky-iraxn--aurskog-hland-jnbarclays3-us-west-2xn--avery-yuasakuho" + + "kkaidontexisteingeekounosunndalxn--b-5gaxn--b4w605ferdxn--bck1b9" + + "a5dre4civilwarmanagementkmaxxn--1ck2e1balsanagochihayaakasakawah" + + "aravennagasakijobserverdalimoliserniaukraanghkebinorilskariyakum" + + "oldev-myqnapcloudcontrolappagefrontappagespeedmobilizerobihirosa" + + "kikamijimatteledatabaseballooningjesdalavangenativeamericanantiq" + + "ues3-eu-central-1xn--bdddj-mrabdxn--bearalvhki-y4axn--berlevg-jx" + + "axn--bhcavuotna-s4axn--bhccavuotna-k7axn--bidr-5nachikatsuuraxn-" + + "-bievt-0qa2xn--bjarky-fyanaizuxn--bjddar-ptamboversaillesolarsso" + + "nxn--blt-elabourxn--bmlo-graingerxn--bod-2naroyxn--brnny-wuaccid" + + "ent-investigationjukudoyamagadancebetsukubabia-goracleaningatlan" + + "tabusebastopologyeonggiehtavuoatnadexeterimo-i-ranagahamaroygard" + + "endoftheinternetflixilovecollegefantasyleaguernseyxn--brnnysund-" + + "m8accident-preventionlineat-urlxn--brum-voagatulansnzxn--btsfjor" + + "d-9zaxn--c1avgxn--c2br7gxn--c3s14misasaguris-gonexn--cck2b3baref" + + "ootballangenoamishirasatochigiftsakuraibestadiskstationaustdalin" + + "desnesakyotanabellunordkappgafanpachigasakidsmynasperschlesische" + + "salangenaval-d-aosta-valleyonagoyaustinnaturalhistorymuseumcente" + + "repbodyndns-freebox-oskolegokasells-for-less3-eu-west-1xn--cg4bk" + + "is-uberleetrentino-sudtirolxn--ciqpnxn--clchc0ea0b2g2a9gcdn77-ss" + + "lattumisawaxn--comunicaes-v6a2oxn--correios-e-telecomunicaes-ghc" + + "29axn--czr694bargainstitutelekommunikationavigationavuotnakayama" + + "tsuzakibigawaustraliaisondriodejaneirochestereportargets-itargiv" + + "ingjovikarlsoyokosukareliancebizenakamuratakaharuconnectarnobrze" + + "gyptianaturalsciencesnaturelles3-external-1xn--czrs0tunesokanoya" + + "kagexn--czru2dxn--czrw28barreauctionayoroceanographicsalondonets" + + "kasaokamisatokamachippubetsubetsugarufcfanflfanfshostrodawaraust" + + "rheimatunduhrennesoyokotehimeji234xn--d1acj3barrel-of-knowledgeo" + + "logyonaguniversityoriikashibatakasugaibmditchyouripalaceverbanka" + + "shiharauthordalandroidigitalillyokozemersongdalenviknakaniikawat" + + "anaguramusementarantours3-ap-northeast-2xn--d1alfaromeoxn--d1atu" + + "nkosherbrookegawaxn--d5qv7z876claimsauheradynv6xn--davvenjrga-y4" + + "axn--djrs72d6uyxn--djty4kouyamashikis-an-actorxn--dnna-grajewolt" + + "erskluwerxn--drbak-wuaxn--dyry-iraxn--e1a4clickddielddanuorrissa" + + "gamiharaxn--eckvdtc9dxn--efvn9sopotrogstadxn--efvy88hakatanotoga" + + "waxn--ehqz56nxn--elqq16hakodatexn--estv75gxn--eveni-0qa01gaxn--f" + + "6qx53axn--fct429kouzushimashikokuchuoxn--fhbeiarnxn--finny-yuaxn" + + "--fiq228c5hsor-odalxn--fiq64barrell-of-knowledgeometre-experts-c" + + "omptablesaltdalinkashiwarautomotivecodynaliascoli-picenoipiranga" + + "mvikarmoyomitanobninskarpaczeladz-1xn--fiqs8sor-varangerxn--fiqz" + + "9sorfoldxn--fjord-lraxn--fjq720axn--fl-ziaxn--flor-jraxn--flw351" + + "exn--fpcrj9c3dxn--frde-grandrapidsorreisahayakawakamiichikawamis" + + "atottoris-leetrentino-sud-tirolxn--frna-woaraisaijosoyrovigorlic" + + "exn--frya-hraxn--fzc2c9e2clinichelyabinskydivingroundhandlingroz" + + "nyxn--fzys8d69uvgmailxn--g2xx48cliniquenoharaxn--gckr3f0fbxostro" + + "lekaluganskharkovalledaostavernxn--gecrj9clintonoshoesavannahgax" + + "n--ggaviika-8ya47hakonexn--gildeskl-g0axn--givuotna-8yandexn--3p" + + "xu8kostromahachijorpelandxn--gjvik-wuaxn--gk3at1exn--gls-elacaix" + + "axn--gmq050is-very-badaddjamalborkangerxn--gmqw5axn--h-2failxn--" + + "h1aeghakubankhvaolbia-tempio-olbiatempioolbialystokkemerovodkaka" + + "migaharagusaarlandxn--h2brj9clothingujolsterxn--hbmer-xqaxn--hce" + + "suolo-7ya35bashkiriautoscanadaejeonbukaruizawasnesoddenmarkhange" + + "lskjervoyagemologicallyngenglandds3-ap-southeast-1xn--hery-iraxn" + + "--hgebostad-g3axn--hmmrfeasta-s4accturystykarasjohkamiokaminokaw" + + "anishiaizubangexn--hnefoss-q1axn--hobl-iraxn--holtlen-hxaxn--hpm" + + "ir-xqaxn--hxt814exn--hyanger-q1axn--hylandet-54axn--i1b6b1a6a2ex" + + "n--imr513nxn--indery-fyaotsurgutsiracusakakinokiaxn--io0a7is-ver" + + "y-evillagexn--j1aefermobilyxn--j1amhakuis-a-nascarfanxn--j6w193g" + + "xn--jlq61u9w7basilicataniaveroykeniwaizumiotsukumiyamazonawsabae" + + "robaticketsaritsynologyeongnamegawakeisenbahnaturbruksgymnaturhi" + + "storisches3-external-2xn--jlster-byaroslavlaanderenxn--jrpeland-" + + "54axn--jvr189misconfusedxn--k7yn95exn--karmy-yuaxn--kbrq7oxn--kc" + + "rx77d1x4axn--kfjord-iuaxn--klbu-woaxn--klt787dxn--kltp7dxn--kltx" + + "9axn--klty5xn--42c2d9axn--koluokta-7ya57hakusandiegoodyearthaeba" + + "ruminamiminowaxn--kprw13dxn--kpry57dxn--kpu716ferraraxn--kput3is" + + "-very-goodhandsonxn--krager-gyasakaiminatoyonoxn--kranghke-b0axn" + + "--krdsherad-m8axn--krehamn-dxaxn--krjohka-hwab49jetztrentino-sue" + + "d-tirolxn--ksnes-uuaxn--kvfjord-nxaxn--kvitsy-fyasugis-very-nice" + + "xn--kvnangen-k0axn--l-1fairwindsortlandxn--l1accentureklamborghi" + + "niizaxn--laheadju-7yasuokaratexn--langevg-jxaxn--lcvr32dxn--ldin" + + "gen-q1axn--leagaviika-52basketballfinanzgoravocatanzarowebhoppda" + + "limanowarudastronomyasustor-elvdalpha-myqnapcloudappspotagerepai" + + "rbusantiquest-a-la-maisondre-landebusinessebyklefrakkestadgcanon" + + "oichinomiyakebinagisochildrensgardenasushiobaraeroportalabamagas" + + "akishimabarackmaze12xn--lesund-huaxn--lgbbat1ad8jevnakershuscult" + + "ureggioemiliaromagnakasatsunais-a-techietis-a-studentalxn--lgrd-" + + "poacoachampionshiphoptobamagazinebraskaunjargallupinbatochiokino" + + "shimalselvendrellinzaiinetarumizusawavoues3-fips-us-gov-west-1xn" + + "--lhppi-xqaxn--linds-pramericanartuscanyxn--lns-qlanxessorumisak" + + "is-foundationxn--loabt-0qaxn--lrdal-sraxn--lrenskog-54axn--lt-li" + + "acntmpanasonichernigovernmentjometlifeinsurancexn--lten-granexn-" + + "-lury-iraxn--mely-iraxn--merker-kuaxn--mgb2ddesouthcarolinazawax" + + "n--mgb9awbferrarittogoldpoint2thisayamanashiibadajozoraholtalenv" + + "ironmentalconservationxn--mgba3a3ejtushuissier-justicexn--mgba3a" + + "4f16axn--mgba3a4franamizuholdingsmileksvikozagawaxn--mgba7c0bbn0" + + "axn--mgbaakc7dvferreroticapebretonamiasakuchinotsuchiurakawassam" + + "ukawataricohdatsunanjoetsuwanouchikujogaszkoladbrokescrapper-sit" + + "exn--mgbaam7a8haldenxn--mgbab2bdxn--mgbai9a5eva00batsfjordivtasv" + + "uodnaharimaniwakuratexascolipicenord-aurdalcesalvadordalibabaika" + + "liszczytnord-odalipetskashiwazakiyokawaraxaugustowadaegubs3-ap-s" + + "outheast-2xn--mgbai9azgqp6jewelryxn--mgbayh7gpaduaxn--mgbb9fbpob" + + "anazawaxn--mgbbh1a71exn--mgbc0a9azcgxn--mgbca7dzdoxn--mgberp4a5d" + + "4a87gxn--mgberp4a5d4arxn--mgbi4ecexposedxn--mgbpl2fhskozakis-an-" + + "actresshinyoshitomiokaneyamaxunusualpersonxn--mgbqly7c0a67fbcolo" + + "nialwilliamsburgulenxn--mgbqly7cvafredrikstadtvsouthwestfalenxn-" + + "-mgbt3dhdxn--mgbtf8flatangerxn--mgbtx2bauhausposts-and-telecommu" + + "nicationsnasadodgeorgeorgiaxn--mgbx4cd0abbottuvalle-daostaticirc" + + "legnicagliaridagawarszawashingtondclkazunoxn--mix082fetsundxn--m" + + "ix891fgushikamifuranoshiroomuraxn--mjndalen-64axn--mk0axinfiniti" + + "s-very-sweetpepperxn--mk1bu44coloradoplateaudioxn--mkru45is-with" + + "-thebandoomdnsaliasdaburyatiaarpfizerxn--mlatvuopmi-s4axn--mli-t" + + "lapyatigorskpnxn--mlselv-iuaxn--moreke-juaxn--mori-qsakuragawaxn" + + "--mosjen-eyatominamiawajikisleofmandalxn--mot-tlaquilancasterxn-" + + "-mre-og-romsdal-qqbbcartoonartdecoffeedbackplaneappalanakhodkana" + + "gawaxn--msy-ula0halsaitamatsukuris-a-nurservebbshimokawaxn--mtta" + + "-vrjjat-k7afamilycompanycolumbusheyxn--muost-0qaxn--mxtq1mishima" + + "tsumotofukexn--ngbc5azdxn--ngbe9e0axn--ngbrxn--45brj9citadeliver" + + "yggeelvinckchristiansburguitarsatxn--11b4c3dynnsaudaxn--nit225kp" + + "pspiegelxn--nmesjevuemie-tcbajddarchaeologyxn--nnx388axn--nodexn" + + "--nqv7fs00emaxn--nry-yla5gxn--ntso0iqx3axn--ntsq17gxn--nttery-by" + + "aeservecounterstrikexn--nvuotna-hwaxn--nyqy26axn--o1achattanooga" + + "norfolkebiblegallocus-1xn--o3cw4hammarfeastafricamagichofunatori" + + "entexpressaseboknowsitalluzernisshingugexn--od0algxn--od0aq3bbta" + + "tamotorsalzburglobalashovhachinohedmarkasukabedzin-the-bandaioir" + + "aseeklogesuranceoceanographiquevje-og-hornnesamegawaxn--ogbpf8fl" + + "ekkefjordxn--oppegrd-ixaxn--ostery-fyatsukaratsuginamikatagamiho" + + "boleslawiecommunitysfjordyroyrvikingunmarnardalxn--osyro-wuaxn--" + + "p1acfhvalerxn--p1aissmarterthanyoustkarasjokomaganexn--pbt977com" + + "obaraxn--pgbs0dhlxn--porsgu-sta26fidonnakamagayachtscrappingxn--" + + "1lqs71dxn--pssu33lxn--pssy2uxn--q9jyb4comparemarkerryhotelsaves-" + + "the-whalessandria-trani-barletta-andriatranibarlettaandriaxn--qc" + + "ka1pmcdonaldsowaxn--qqqt11missilelxn--qxamurskiptveterinairealto" + + "rlandxn--rady-iraxn--rdal-poaxn--rde-ularvikrasnodarxn--rdy-0nab" + + "ariwchoshibuyachiyodavvesiidazaifuefukihaborokunohealth-carerefo" + + "rmitakeharaxn--rennesy-v1axn--rhkkervju-01aflakstadaokagakibichu" + + "oxn--rholt-mragowoodsidexn--rhqv96gxn--rht27zxn--rht3dxn--rht61e" + + "xn--risa-5narusawaxn--risr-iraxn--rland-uuaxn--rlingen-mxaxn--rm" + + "skog-byatsushiroxn--rny31hamurakamigoriginshimokitayamaxn--rovu8" + + "8bbvacationsupdatelemarkasumigaurawa-mazowszexboxenapponazure-mo" + + "bilexn--rros-granvindafjordxn--rskog-uuaxn--rst-0narutokyotangot" + + "pantheonsitextileitungsenxn--rsta-francaiseharaxn--ryken-vuaxn--" + + "ryrvik-byawaraxn--s-1faitheguardianxn--s9brj9compute-1xn--sandne" + + "ssjen-ogbizhevskrasnoyarskomforbananarepublicartierhcloudfunctio" + + "ns3-us-gov-west-1xn--sandy-yuaxn--seral-lraxn--ses554gxn--sgne-g" + + "ratangenxn--skierv-utazaskvolloabathsbcomputerhistoryofscience-f" + + "ictionxn--skjervy-v1axn--skjk-soaxn--sknit-yqaxn--sknland-fxaxn-" + + "-slat-5narviikananporovnoxn--slt-elabbvieeexn--smla-hraxn--smna-" + + "gratis-a-bulls-fanxn--snase-nraxn--sndre-land-0cbremangerxn--sne" + + "s-poaxn--snsa-roaxn--sr-aurdal-l8axn--sr-fron-q1axn--sr-odal-q1a" + + "xn--sr-varanger-ggbentleyukuhashimojiitatebayashijonawatexn--srf" + + "old-byawatahamaxn--srreisa-q1axn--srum-grazxn--stfold-9xaxn--stj" + + "rdal-s1axn--stjrdalshalsen-sqbeppubolognagatorockartuzyurihonjou" + + "rnalistjohnhlfanhsamnangerxn--stre-toten-zcbspreadbettingxn--t60" + + "b56axn--tckweatherchannelxn--tiq49xqyjewishartgalleryxn--tjme-hr" + + "axn--tn0agrinet-freakspydebergxn--tnsberg-q1axn--tor131oxn--tran" + + "y-yuaxn--trgstad-r1axn--trna-woaxn--troms-zuaxn--tysvr-vraxn--uc" + + "0atversicherungxn--uc0ay4axn--uist22hangoutsystemscloudfrontdoor" + + "xn--uisz3gxn--unjrga-rtaobaokinawashirosatobishimaizurubtsovskja" + + "kdnepropetrovskiervaapsteiermarkredirectmeldalxn--unup4yxn--uuwu" + + "58axn--vads-jraxn--vard-jraxn--vegrshei-c0axn--vermgensberater-c" + + "tberndivttasvuotnakaiwamizawaxn--vermgensberatung-pwbeskidynatho" + + "medepotenzachpomorskienikiiyamanobeauxartsandcraftsamsclubindali" + + "vornoddaxn--vestvgy-ixa6oxn--vg-yiabcn-north-1xn--vgan-qoaxn--vg" + + "sy-qoa0jfkomakiyosatokashikiyosemitexn--vgu402comsecuritytactics" + + "avonamsskoganeis-a-designerimarylandxn--vhquvestfoldxn--vler-qoa" + + "xn--vre-eiker-k8axn--vrggt-xqadxn--vry-yla5gxn--vuq861bestbuysho" + + "usesamsunglobodoes-itverranzanquannefrankfurtatarstanikkoebenhav" + + "nikolaevennodessaikinkobayashikshacknetnedalomzansimagicasadelam" + + "onedavvenjargaulardalorenskoglogowegroweibolzanordre-landiyusuha" + + "raxn--w4r85el8fhu5dnraxn--w4rs40lxn--wcvs22dxn--wgbh1condoshichi" + + "nohealthcareersaxoxn--wgbl6axn--xhq521betainaboxfusejnynysagaero" + + "clubmedecincinnationwidealerxn--xkc2al3hye2axn--xkc2dl3a5ee0hann" + + "anmokuizumodernxn--y9a3aquariumisugitokorozawaxn--yer-znarvikris" + + "tiansandcatshiranukaniepcexn--yfro4i67oxn--ygarden-p1axn--ygbi2a" + + "mmxn--45q11citicatholicheltenham-radio-openair-traffic-controlle" + + "yxn--ystre-slidre-ujbieidsvollotenkawaxn--zbx025dxn--zf0ao64axn-" + + "-zf0avxn--4gbriminingxn--zfr164bielawallonieruchomoscienceandind" + + "ustrynikonantanangerxperiaxz" // nodes is the list of nodes. Each node is represented as a uint32, which // encodes the node's children, wildcard bit and node type (as an index into @@ -480,8055 +481,8068 @@ const text = "biellaakesvuemieleccebieszczadygeyachimataipeigersundrangedalivo" // [15 bits] text index // [ 6 bits] text length var nodes = [...]uint32{ - 0x27a003, - 0x328304, - 0x272406, - 0x36e2c3, - 0x36e2c6, - 0x3a6306, - 0x260483, - 0x206e44, - 0x345647, - 0x272048, + 0x274903, + 0x370704, + 0x28c306, + 0x36c9c3, + 0x36c9c6, + 0x3948c6, + 0x3a4883, + 0x208e44, + 0x252cc7, + 0x28bf48, 0x1a00882, - 0x30abc7, - 0x355a09, - 0x2eb6ca, - 0x2eb6cb, - 0x22f803, - 0x28f606, - 0x232a05, + 0x308207, + 0x350b49, + 0x2f91ca, + 0x2f91cb, + 0x232343, + 0x28d846, + 0x231645, 0x1e00702, - 0x215f44, - 0x236483, - 0x278b45, - 0x2208ac2, - 0x330fc3, - 0x26cf584, - 0x328c05, - 0x2a014c2, - 0x378a0e, - 0x24d0c3, - 0x37e606, - 0x37e60b, - 0x2e01c42, - 0x350f47, - 0x235446, + 0x2105c4, + 0x22d243, + 0x275685, + 0x2207982, + 0x33d083, + 0x26ee604, + 0x24bb45, + 0x2a01782, + 0x37528e, + 0x2470c3, + 0x37bac6, + 0x37bacb, + 0x2e03642, + 0x28c487, + 0x233846, 0x3200a42, - 0x258943, - 0x258944, - 0x343086, - 0x23c1c8, - 0x287c86, - 0x2717c4, - 0x3600ec2, - 0x329b89, - 0x3a2ec7, - 0x2f7646, - 0x357689, - 0x295f08, - 0x2af504, - 0x3a0846, - 0x216b86, - 0x3a02a82, - 0x25af4f, - 0x34280e, - 0x211dc4, - 0x2bc7c5, - 0x2e4bc5, - 0x2ec7c9, - 0x23ecc9, - 0x340e47, - 0x212fc6, - 0x212f03, - 0x3e04a42, - 0x270703, - 0x22098a, - 0x20b0c3, - 0x2607c5, - 0x287302, - 0x287309, - 0x4201e02, - 0x208184, - 0x206986, - 0x237bc5, - 0x34ea44, - 0x4a86a04, - 0x201e03, - 0x231a44, - 0x4e02902, - 0x328044, - 0x31ea44, - 0x22350a, + 0x2573c3, + 0x2573c4, + 0x353f86, + 0x240788, + 0x285686, + 0x39ffc4, + 0x3600dc2, + 0x32ab89, + 0x364d87, + 0x2f4806, + 0x3527c9, + 0x295108, + 0x3404c4, + 0x2ee886, + 0x211206, + 0x3a02202, + 0x23cf4f, + 0x262c8e, + 0x215644, + 0x2bc805, + 0x2e16c5, + 0x2e8b89, + 0x239849, + 0x3293c7, + 0x3a8706, + 0x230103, + 0x3e04602, + 0x33d3c3, + 0x21c0ca, + 0x21c343, + 0x253c45, + 0x284d02, + 0x284d09, + 0x4203442, + 0x203444, + 0x208986, + 0x27c205, + 0x349a04, + 0x4a837c4, + 0x203803, + 0x230684, + 0x4e00f82, + 0x370444, + 0x261b84, + 0x22428a, 0x52009c2, - 0x2d2687, - 0x238088, - 0x5a08f02, - 0x321407, - 0x2b7744, - 0x2b7747, - 0x385185, - 0x36ccc7, - 0x340c06, - 0x21cec4, - 0x357985, - 0x299d07, - 0x6a01cc2, - 0x2af103, - 0x213402, - 0x375ac3, - 0x6e136c2, - 0x283905, - 0x7204a02, - 0x329244, - 0x27eec5, - 0x211d07, - 0x3731ce, - 0x2e3e04, - 0x245c04, - 0x208143, - 0x2ce4c9, - 0x307ecb, - 0x30f508, - 0x31a288, - 0x31e088, - 0x323148, - 0x3574ca, - 0x36cbc7, - 0x2272c6, - 0x769ed02, - 0x375043, - 0x37fa83, - 0x38d3c4, - 0x260d03, - 0x2604c3, - 0x1711602, - 0x7a070c2, - 0x24a0c5, - 0x28ecc6, - 0x2c9e84, - 0x396e07, - 0x32cc06, - 0x341644, - 0x3a9e87, - 0x2070c3, - 0x7ebefc2, - 0x8305b42, - 0x8619ac2, - 0x219ac6, + 0x2ae907, + 0x27c6c8, + 0x5a07dc2, + 0x325747, + 0x2b72c4, + 0x2b72c7, + 0x36fa85, + 0x36ba87, + 0x329186, + 0x260c44, + 0x33f4c5, + 0x2a1447, + 0x6a036c2, + 0x346e43, + 0x20d402, + 0x365a03, + 0x6e0dec2, + 0x27edc5, + 0x7203402, + 0x24c184, + 0x27a0c5, + 0x215587, + 0x3907ce, + 0x2f5e84, + 0x23fb44, + 0x203403, + 0x2e7ac9, + 0x30534b, + 0x30c688, + 0x31aec8, + 0x321348, + 0x3114c8, + 0x35260a, + 0x36b987, + 0x223546, + 0x769d742, + 0x373483, + 0x37cf03, + 0x38c044, + 0x254183, + 0x3a48c3, + 0x1712542, + 0x7a06442, + 0x245845, + 0x24dcc6, + 0x2ca2c4, + 0x397487, + 0x27d286, + 0x31b9c4, + 0x3a7d87, + 0x206443, + 0x7ebf042, + 0x8252f42, + 0x8613bc2, + 0x213bc6, 0x8a00002, - 0x37dd45, - 0x312b43, - 0x204384, - 0x2db0c4, - 0x2db0c5, - 0x2075c3, - 0x8f27883, - 0x920a882, - 0x28a905, - 0x28a90b, - 0x22be86, - 0x20cd4b, - 0x276844, - 0x20d309, - 0x20f104, - 0x960f602, - 0x210943, - 0x2125c3, - 0x1612742, - 0x245dc3, - 0x21274a, - 0x9a12bc2, - 0x2161c5, - 0x290fca, - 0x2cd084, - 0x213a83, - 0x213f44, - 0x2159c3, - 0x2159c4, - 0x2159c7, - 0x216f85, - 0x217785, - 0x218e86, - 0x219d86, - 0x21a783, - 0x21e908, - 0x258283, - 0x9e03482, - 0x21f388, - 0x21474b, - 0x222208, - 0x222986, - 0x223907, - 0x227e88, - 0xa63a242, - 0xaa715c2, - 0x2e3688, - 0x29f847, - 0x242c85, - 0x242c88, - 0x343988, - 0x383b83, - 0x22a7c4, - 0x38d402, - 0xae2cb02, - 0xb2519c2, - 0xba2ce42, - 0x22ce43, - 0xbe01482, - 0x206e03, - 0x201484, - 0x21a903, - 0x2af4c4, - 0x25fc4b, - 0x214683, - 0x2d3946, - 0x223384, - 0x29e18e, - 0x341045, - 0x265808, - 0x2246c7, - 0x2246ca, - 0x22fd03, - 0x275647, - 0x308085, - 0x22fd04, - 0x22fd06, - 0x22fd07, - 0x2c62c4, - 0x373507, - 0x2028c4, - 0x2093c4, - 0x2093c6, - 0x2dc104, - 0x221c46, - 0x2138c3, - 0x226b48, - 0x303708, - 0x245bc3, - 0x245d83, - 0x395544, - 0x39b103, - 0xc200482, - 0xc707ac2, - 0x2004c3, - 0x208406, - 0x381043, - 0x228584, - 0xca19942, - 0x2d7f03, - 0x219943, - 0x21b682, - 0xce008c2, - 0x2bb486, - 0x233907, - 0x2e9005, - 0x344c04, - 0x2a1c45, - 0x2021c7, - 0x26e685, - 0x2aff89, - 0x2c75c6, - 0x2d0108, - 0x2e8f06, - 0xd2092c2, - 0x23bd88, - 0x300a86, - 0x20dc05, - 0x3af1c7, - 0x303604, - 0x303605, - 0x287e44, - 0x287e48, - 0xd60a1c2, - 0xda036c2, - 0x32f506, - 0x3160c8, - 0x338e05, - 0x33a086, - 0x33c2c8, - 0x35ff48, - 0xdec8b85, - 0x2036c4, - 0x324407, - 0xe20d9c2, - 0xe61eb82, - 0xfa06a82, - 0x3597c5, - 0x2a22c5, - 0x3753c6, - 0x317a47, - 0x22aac7, - 0x1022bf83, - 0x2a5b07, - 0x2d4808, - 0x390509, - 0x378bc7, - 0x3a7507, - 0x22e108, - 0x22e906, - 0x22f846, - 0x23020c, - 0x230d8a, - 0x231247, - 0x2328cb, - 0x233747, - 0x23374e, - 0x234744, - 0x234a44, - 0x238e47, - 0x25a647, - 0x23d186, - 0x23d187, - 0x23dd87, - 0x13208942, - 0x23f586, - 0x23f58a, - 0x23f80b, - 0x240bc7, - 0x241585, - 0x2418c3, - 0x241dc6, - 0x241dc7, - 0x23ee83, - 0x1362ea42, - 0x24268a, - 0x13b56b42, - 0x13ea4c42, - 0x14244142, - 0x14635542, - 0x244ec5, - 0x2459c4, - 0x14e00682, - 0x3280c5, - 0x278b03, - 0x315b45, - 0x2124c4, - 0x293906, - 0x202bc6, - 0x28ab03, - 0x3654c4, - 0x324ec3, - 0x15201582, - 0x208d04, - 0x324986, - 0x208d05, - 0x258006, - 0x3af2c8, - 0x21ecc4, - 0x236248, - 0x2e01c5, - 0x32bcc8, - 0x2dce46, - 0x2b4247, - 0x22f244, - 0x22f246, - 0x323fc3, - 0x385503, - 0x2bfd08, - 0x30d944, - 0x341787, - 0x248cc6, - 0x30af09, - 0x35c488, - 0x330488, - 0x24f8c4, - 0x3a2543, - 0x206c82, - 0x1560b042, - 0x15a05382, - 0x3abf43, - 0x15e12c42, - 0x345784, - 0x2af205, - 0x29d8c3, - 0x2306c4, - 0x302947, - 0x344943, - 0x2465c8, - 0x205f85, - 0x308144, - 0x36bb43, - 0x27ee45, - 0x27ef84, - 0x2090c6, - 0x20c244, - 0x20d086, - 0x211c46, - 0x261504, - 0x2199c3, - 0x162b1a02, - 0x350e05, - 0x223cc3, - 0x16600442, - 0x2bbf85, - 0x231b03, - 0x231b09, - 0x16a04142, - 0x172110c2, - 0x329605, - 0x21cd46, - 0x34c707, - 0x2c9a46, - 0x2b9908, - 0x2b990b, - 0x20844b, - 0x2e9205, - 0x2d07c5, - 0x2c0a89, - 0x1600bc2, - 0x2616c8, - 0x20cf84, - 0x17a00202, - 0x25f883, - 0x1825a806, - 0x380ec8, - 0x18602e42, - 0x226088, - 0x18a08b02, - 0x27698a, - 0x228bc3, - 0x3b23c6, - 0x3997c8, - 0x204188, - 0x334fc6, - 0x36a0c7, - 0x25b147, - 0x21670a, - 0x2cd104, - 0x33ed84, - 0x3554c9, - 0x38ff05, - 0x342a06, - 0x20b203, - 0x249604, - 0x2143c4, - 0x24fd07, - 0x22d547, - 0x26b1c4, - 0x216645, - 0x375488, - 0x3617c7, - 0x364607, - 0x18e09342, - 0x2e3cc4, - 0x2946c8, - 0x3859c4, - 0x246a04, - 0x246e05, - 0x246f47, - 0x210c49, - 0x247d04, - 0x248a09, - 0x248fc8, - 0x249384, - 0x249387, - 0x249b83, - 0x24a707, - 0x1649242, - 0x17a6b82, - 0x24b646, - 0x24c287, - 0x24c884, - 0x24d607, - 0x24e647, - 0x24ed88, - 0x24f503, - 0x23d6c2, - 0x202442, - 0x251003, - 0x251004, - 0x25100b, - 0x31a388, - 0x257f44, - 0x251d05, - 0x253c87, - 0x2569c5, - 0x36bf0a, - 0x257e83, - 0x1920db02, - 0x258184, - 0x25a409, - 0x25f283, - 0x25f347, - 0x36b309, - 0x376348, - 0x208a03, - 0x27dd47, - 0x27e489, - 0x2840c3, - 0x285e04, - 0x286bc9, - 0x289286, - 0x28a343, - 0x201c82, - 0x244d43, - 0x39c247, - 0x37de85, - 0x35a206, - 0x24a304, - 0x2e6285, - 0x220943, - 0x21a9c6, - 0x20d502, - 0x390ec4, - 0x225902, - 0x2daa43, - 0x196007c2, - 0x247643, - 0x21a204, - 0x21a207, - 0x204686, - 0x24cdc2, - 0x19a53a02, - 0x3af4c4, - 0x19e39ec2, - 0x1a202842, - 0x31aac4, - 0x31aac5, - 0x28de45, - 0x2c2a86, - 0x1a603ac2, - 0x308d05, - 0x3a5245, - 0x29a0c3, - 0x204e86, - 0x212b05, - 0x219a42, - 0x339cc5, - 0x219a44, - 0x21ec03, - 0x21ee43, - 0x1aa0be82, - 0x2f1f87, - 0x361a44, - 0x361a49, - 0x249504, - 0x23a103, - 0x34a009, - 0x350cc8, - 0x2a2144, - 0x2a2146, - 0x2a4543, - 0x214dc3, - 0x22a0c4, - 0x250cc3, - 0x1aee0682, - 0x301c42, - 0x1b210702, - 0x314a48, - 0x3801c8, - 0x394986, - 0x245545, - 0x229b85, - 0x210705, - 0x224242, - 0x1b6931c2, - 0x1633602, - 0x390088, - 0x23bcc5, - 0x3052c4, - 0x2e0105, - 0x32b887, - 0x257c84, - 0x23d4c2, - 0x1ba03e82, - 0x30d204, - 0x2140c7, - 0x39ee87, - 0x36cc84, - 0x290f83, - 0x245b04, - 0x245b08, - 0x22fb86, - 0x22fb8a, - 0x210b04, - 0x291308, - 0x24f004, - 0x223a06, - 0x293184, - 0x359ac6, - 0x341dc9, - 0x266587, - 0x235903, - 0x1be10442, - 0x26ecc3, - 0x20f802, - 0x1c217e82, - 0x2df3c6, - 0x363888, - 0x2a3687, - 0x3a4389, - 0x23a009, - 0x2a3f45, - 0x2a50c9, - 0x2a5f45, - 0x2a6a09, - 0x2a8105, - 0x288484, - 0x288487, - 0x2998c3, - 0x2a8e07, - 0x3a78c6, - 0x2a9607, - 0x2a0f05, - 0x2ab543, - 0x1c630842, - 0x392904, - 0x1ca29982, - 0x25a043, - 0x1ce134c2, - 0x2e6cc6, - 0x238005, - 0x2acc47, - 0x335583, - 0x260c84, - 0x203bc3, - 0x2e33c3, - 0x1d20b542, - 0x1da00042, - 0x3a6404, - 0x23d683, - 0x397285, - 0x2aafc5, - 0x1de04982, - 0x1e600942, - 0x27e086, - 0x20ad44, - 0x30da84, - 0x30da8a, - 0x1ee02002, - 0x2f920a, - 0x36f688, - 0x1f2023c4, - 0x215ac3, - 0x24bc43, - 0x31e1c9, - 0x22dec9, - 0x302a46, - 0x1f602243, - 0x2d9885, - 0x2f9e4d, - 0x207286, - 0x21134b, - 0x1fa016c2, - 0x34c188, - 0x1fe1ea02, - 0x20208282, - 0x370545, - 0x20603fc2, - 0x269947, - 0x2a6507, - 0x21db43, - 0x258c48, - 0x20a07382, - 0x282f04, - 0x212d83, - 0x34bb85, - 0x383983, - 0x237ac6, - 0x2eae04, - 0x245d43, - 0x26f203, - 0x20e0abc2, - 0x2e9184, - 0x353985, - 0x367f07, - 0x27bbc3, - 0x2ad443, - 0x2adc43, - 0x1622602, - 0x2add03, - 0x2adf83, - 0x21202dc2, - 0x2ce884, - 0x27f1c6, - 0x20fa03, - 0x2ae303, - 0x216afcc2, - 0x2afcc8, - 0x2b0784, - 0x2402c6, - 0x2b0bc7, - 0x218fc6, - 0x338f04, - 0x2f2001c2, - 0x3a778b, - 0x2f29ce, - 0x21d4cf, - 0x234343, - 0x2fa44d02, - 0x1605482, - 0x2fe04b42, - 0x227dc3, - 0x233343, - 0x238c46, - 0x2f0ac6, - 0x2e6587, - 0x379084, - 0x3028da82, - 0x306062c2, - 0x2f9b45, - 0x2ee007, - 0x2f15c6, - 0x30a6cf82, - 0x26cf84, - 0x372003, - 0x30e0ac82, - 0x352e03, - 0x3910c4, - 0x2b6949, - 0x16bd702, - 0x31235c82, - 0x2dac86, - 0x26b485, - 0x31645cc2, - 0x31a00102, - 0x33e107, - 0x2033c9, - 0x355c8b, - 0x25af05, - 0x3748c9, - 0x2be006, - 0x22bec7, - 0x2060c4, - 0x2cf089, - 0x35dbc7, - 0x2b7ec7, - 0x20ae83, - 0x20ae86, - 0x2dd5c7, - 0x2387c3, - 0x27cf86, - 0x31e049c2, - 0x32231d82, - 0x21bfc3, - 0x260885, - 0x221ac7, - 0x343c86, - 0x37de05, - 0x376b04, - 0x2de1c5, - 0x2e9b84, - 0x32600f02, - 0x321d87, - 0x2e2904, - 0x22ddc4, - 0x22ddcd, - 0x24c649, - 0x2e04c8, - 0x22bb04, - 0x323605, - 0x2633c7, - 0x2ceb44, - 0x32ccc7, - 0x35ab05, - 0x32b9a984, - 0x2ce185, - 0x25df44, - 0x374206, - 0x317845, - 0x32e34802, - 0x213b44, - 0x213b45, - 0x38d946, - 0x37df45, - 0x2548c4, - 0x2e7043, - 0x380406, - 0x20efc5, - 0x210e45, - 0x317944, - 0x210b83, - 0x210b8c, - 0x33289bc2, - 0x33605602, - 0x33a17382, - 0x39a883, - 0x39a884, - 0x33e03702, - 0x2fd288, - 0x35a2c5, - 0x37f144, - 0x29fe46, - 0x34233a82, - 0x3461ca02, - 0x34a00982, - 0x2b5dc5, - 0x2613c6, - 0x24fc44, - 0x3435c6, + 0x37b205, + 0x313a83, + 0x204184, + 0x2d9c84, + 0x2d9c85, + 0x207043, + 0x8f23743, + 0x9209e42, + 0x288c85, + 0x288c8b, + 0x258306, + 0x20b6cb, + 0x271f44, + 0x20c9c9, + 0x20e284, + 0x960f202, + 0x20f903, + 0x20fc83, + 0x160fe02, + 0x23d483, + 0x20fe0a, + 0x9a10842, + 0x210845, + 0x28f40a, + 0x2cdd44, + 0x211603, + 0x211c44, + 0x2139c3, + 0x2139c4, + 0x2139c7, + 0x214405, + 0x216145, + 0x216686, + 0x2169c6, + 0x2173c3, + 0x219d48, + 0x256d03, + 0x9e1a382, + 0x21ab08, + 0x21a38b, + 0x21e608, + 0x21ed86, + 0x21fb07, + 0x2246c8, + 0xa635842, + 0xaa95682, + 0x2f5708, + 0x29e287, + 0x235e05, + 0x235e08, + 0x354888, + 0x387283, + 0x22b144, + 0x38c082, + 0xae2ca42, + 0xb214382, + 0xba2e142, + 0x22e143, + 0xbe01742, + 0x208e03, + 0x201744, + 0x217543, + 0x340484, + 0x25248b, + 0x21a2c3, 0x2d2446, - 0x207a03, - 0x34f2afca, - 0x23d9c5, - 0x2f3506, - 0x2f3509, - 0x367547, - 0x291748, - 0x295dc9, - 0x218388, - 0x322e86, - 0x23db83, - 0x35206a42, - 0x386e83, - 0x386e89, - 0x3442c8, - 0x3560ad82, - 0x35a0f842, - 0x232003, - 0x2cff85, - 0x251804, - 0x2c1a09, - 0x2aa9c4, - 0x2b09c8, - 0x20f843, - 0x2600c4, - 0x329d03, - 0x22dd07, - 0x35e3c442, - 0x25a2c2, - 0x22af85, - 0x26d1c9, - 0x220ec3, - 0x27f804, - 0x2d9844, - 0x263443, - 0x28088a, - 0x3636f542, - 0x36613b02, - 0x2bef43, - 0x3721c3, - 0x1660082, - 0x260f43, - 0x36a50702, - 0x3891c4, - 0x36e02ac2, - 0x3730db04, - 0x34a586, - 0x27e2c4, - 0x2406c3, - 0x284a83, - 0x21c443, - 0x23fb86, - 0x2c4d05, - 0x2bf7c7, - 0x22bd89, - 0x2c37c5, - 0x2c4c46, - 0x2c5248, - 0x2c5446, - 0x256604, - 0x29920b, - 0x2c70c3, - 0x2c70c5, - 0x2c7208, - 0x21e782, - 0x33e402, - 0x37629382, - 0x37a03642, - 0x2632c3, - 0x37e08b82, - 0x26e443, - 0x2c7504, - 0x2c83c3, - 0x38607682, - 0x2c9f8b, - 0x38acc586, - 0x2ef8c6, - 0x2ccbc8, - 0x38ecae42, - 0x39212602, - 0x3961ee82, - 0x39a0b602, - 0x39e02642, - 0x20264b, - 0x3a201842, - 0x2262c3, - 0x316c05, - 0x321ac6, - 0x3a611004, - 0x20b687, - 0x32478a, - 0x31ec86, - 0x2e9444, - 0x262ec3, - 0x3b20dbc2, - 0x202b42, - 0x2570c3, - 0x3b64c083, - 0x2635c7, - 0x317747, - 0x3ca51107, - 0x228b87, - 0x214983, - 0x2248ca, - 0x214984, - 0x248bc4, - 0x248bca, - 0x24f205, - 0x3ce02402, - 0x24e143, - 0x3d200dc2, - 0x20f543, - 0x26ec83, - 0x3da01742, - 0x2a5a84, - 0x220684, - 0x201745, - 0x2d8385, - 0x2368c6, - 0x236c46, - 0x3de09142, - 0x3e201042, - 0x3360c5, - 0x2ef5d2, - 0x24ca86, - 0x226a03, - 0x33b046, - 0x2ff645, - 0x160b282, - 0x4660d682, - 0x2efd43, - 0x310b83, - 0x2dbcc3, - 0x46a07902, - 0x378d03, - 0x46e12f42, - 0x2a3443, - 0x2ce8c8, - 0x222f43, - 0x222f46, - 0x313c87, - 0x210586, - 0x21058b, - 0x2e9387, - 0x392704, - 0x47602102, - 0x3a0745, - 0x202b03, - 0x22cd43, - 0x3188c3, - 0x3188c6, - 0x2d088a, - 0x273f43, - 0x235304, - 0x316006, - 0x20e006, - 0x47a04703, - 0x260b47, - 0x37ea8d, - 0x38cd87, - 0x298f45, - 0x246406, - 0x20f003, - 0x492050c3, - 0x49609242, - 0x3283c4, - 0x22d28c, - 0x32bf09, - 0x23a787, - 0x249885, - 0x268144, - 0x272748, - 0x279205, - 0x286a85, - 0x28d409, - 0x2f7703, - 0x2f7704, - 0x2a4bc4, - 0x49a00ac2, - 0x265883, - 0x49e92c42, - 0x2a1d46, - 0x160b142, - 0x4a299882, - 0x2b5cc8, - 0x2ce0c7, - 0x299885, - 0x2de9cb, - 0x2d1dc6, - 0x2debc6, - 0x2f8346, - 0x224cc4, - 0x2fba46, - 0x2d51c8, - 0x232243, - 0x247403, - 0x247404, - 0x2d6c84, - 0x2d7007, - 0x2d8185, - 0x4a6d82c2, - 0x4aa0a742, - 0x20a745, - 0x29cd44, - 0x2d9b8b, - 0x2dafc8, - 0x2db6c4, - 0x26cfc2, - 0x4b2aff02, - 0x2aff03, - 0x2dbb04, - 0x2dd185, - 0x22a547, - 0x2dfc44, - 0x2e9244, - 0x4b608582, - 0x35d1c9, - 0x2e0b05, - 0x25b1c5, - 0x2e1685, - 0x4ba1d603, - 0x2e24c4, - 0x2e24cb, - 0x2e4144, - 0x2e45cb, - 0x2e6745, - 0x21d60a, - 0x2e7108, - 0x2e730a, - 0x2e7583, - 0x2e758a, - 0x4be297c2, - 0x4c242242, - 0x263c83, - 0x4c6e8e82, - 0x2e8e83, - 0x4caea942, - 0x4cf132c2, - 0x2e9a04, - 0x21ea46, - 0x343305, - 0x2ea303, - 0x27a5c6, - 0x22b644, - 0x4d203942, - 0x2b6e84, - 0x2c070a, - 0x387f47, - 0x237e46, - 0x2d0d47, - 0x22d3c3, - 0x24f088, - 0x25ab8b, - 0x302b45, - 0x2b7285, - 0x2b7286, - 0x217c04, - 0x323908, - 0x203943, - 0x216a84, - 0x216a87, - 0x342fc6, - 0x31f2c6, - 0x29dfca, - 0x246104, - 0x24610a, - 0x322406, - 0x322407, - 0x251d87, - 0x276184, - 0x276189, - 0x266c05, - 0x239e4b, - 0x279443, - 0x20d243, - 0x229bc3, - 0x384904, - 0x4d6034c2, - 0x25b486, - 0x2ab2c5, - 0x2b2645, - 0x223e46, - 0x248684, - 0x4da00c02, - 0x223f44, - 0x4de0ed42, - 0x2307c4, - 0x225703, - 0x4e301102, - 0x308803, - 0x258606, - 0x4e602942, - 0x2d30c8, - 0x3abc84, - 0x3abc86, - 0x31abc6, - 0x253d44, - 0x380385, - 0x2035c8, - 0x204d07, - 0x20c307, - 0x20c30f, - 0x2945c6, - 0x220bc3, - 0x220bc4, - 0x228444, - 0x233083, - 0x223b44, - 0x22fe84, - 0x4ea2b382, - 0x28a843, - 0x23a203, - 0x4ee03682, - 0x253503, - 0x345843, - 0x21780a, - 0x29fa47, - 0x23b08c, - 0x23b346, - 0x23b886, - 0x23d307, - 0x22e547, - 0x241f49, - 0x21f4c4, - 0x242e44, - 0x4f24ecc2, - 0x4f604042, - 0x260944, - 0x375f06, - 0x22e9c8, - 0x380d04, - 0x269986, - 0x2c9a05, - 0x26ae48, - 0x208643, - 0x26df45, - 0x272903, - 0x25b2c3, - 0x25b2c4, - 0x2744c3, - 0x4fa50642, - 0x4fe01f82, - 0x279309, - 0x286985, - 0x288004, - 0x34adc5, - 0x213604, - 0x24be47, - 0x340005, - 0x2512c4, - 0x2512c8, - 0x2d5b06, - 0x2d9544, - 0x2de648, - 0x2e2747, - 0x50202742, - 0x2e6e04, - 0x2e63c4, - 0x2b80c7, - 0x50679d44, - 0x236b42, - 0x50a03a02, - 0x24ddc3, - 0x2dab84, - 0x235c43, - 0x2754c5, - 0x50e4acc2, - 0x2ed405, - 0x20b5c2, - 0x373e45, - 0x363a45, - 0x512198c2, + 0x224104, + 0x29cbce, + 0x354ec5, + 0x25f248, + 0x21d287, + 0x21d28a, + 0x2341c3, + 0x2341c7, + 0x305505, + 0x387e04, + 0x3ac206, + 0x3ac207, + 0x2c2d44, + 0x390b07, + 0x3a9dc4, + 0x206144, + 0x206146, + 0x268984, + 0x21e046, + 0x20e0c3, + 0x222dc8, + 0x3b03c8, + 0x23fb03, + 0x23d443, + 0x395bc4, + 0x39aa83, + 0xc200482, + 0xc6fc042, + 0x2004c3, + 0x2072c6, + 0x37e383, + 0x21e4c4, + 0xca15442, + 0x326983, + 0x215443, + 0x217d82, + 0xce008c2, + 0x2bae86, + 0x232547, + 0x2e5745, + 0x2642c4, + 0x2a1305, + 0x202987, + 0x26b645, + 0x2af3c9, + 0x2c7606, + 0x2cf308, + 0x2e5646, + 0xd205742, + 0x240348, + 0x36cf06, + 0x205745, + 0x376d47, + 0x3b02c4, + 0x3b02c5, + 0x285844, + 0x285848, + 0xd60b782, + 0xda11a82, + 0x32b786, + 0x316cc8, + 0x32da85, + 0x337646, + 0x3387c8, + 0x33e708, + 0xde63085, + 0x3a3d84, + 0x3ad007, + 0xe20dbc2, + 0xe619fc2, + 0xfa04a82, + 0x3580c5, + 0x29f9c5, + 0x373806, + 0x318647, + 0x22b447, + 0x10258403, + 0x2a4a47, + 0x2d3708, + 0x380289, + 0x375447, + 0x383987, + 0x392988, + 0x3a5b86, + 0x3abd46, + 0x22ef0c, + 0x22fa8a, + 0x22fe07, + 0x23150b, + 0x232387, + 0x23238e, + 0x232bc4, + 0x232ec4, + 0x234447, + 0x259cc7, + 0x2380c6, + 0x2380c7, + 0x238c47, + 0x13207802, + 0x23a006, + 0x23a00a, + 0x23a28b, + 0x23b387, + 0x23bd45, + 0x23c083, + 0x23c346, + 0x23c347, + 0x239a03, + 0x1362d9c2, + 0x23cbca, + 0x13b51c82, + 0x13ea5202, + 0x1423e102, + 0x14633942, + 0x23ee45, + 0x23f904, + 0x14e00682, + 0x3704c5, + 0x275643, + 0x316745, + 0x20d9c4, + 0x291ec6, + 0x362306, + 0x288e83, + 0x36d844, + 0x3407c3, + 0x15201842, + 0x207bc4, + 0x3ad586, + 0x207bc5, + 0x256a86, + 0x376e48, + 0x218dc4, + 0x22d008, + 0x2ddfc5, + 0x2c8108, + 0x357c46, + 0x2b36c7, + 0x25e144, + 0x25e146, + 0x310083, + 0x382383, + 0x2bfd88, + 0x30aac4, + 0x329547, + 0x2443c6, + 0x308549, + 0x20aa88, + 0x24ab08, + 0x3058c4, + 0x3aae03, + 0x208c82, + 0x156b0a82, + 0x15a0b502, + 0x200d03, + 0x15e0a182, + 0x252e04, + 0x36c345, + 0x23b203, + 0x22f3c4, + 0x302b07, + 0x264003, + 0x243d48, + 0x207f85, + 0x3055c4, + 0x36ab03, + 0x27a045, + 0x27a184, + 0x20ba06, + 0x211d04, + 0x213746, + 0x2154c6, + 0x254984, + 0x21ebc3, + 0x1628bb42, + 0x34bdc5, + 0x21fec3, + 0x16600442, + 0x2633c5, + 0x230743, + 0x230749, + 0x16a03f42, + 0x17202282, + 0x24c545, + 0x218406, + 0x329907, + 0x2c9e86, + 0x2b9208, + 0x2b920b, + 0x20730b, + 0x22e5c5, + 0x2cf9c5, + 0x2c0cc9, + 0x1600bc2, + 0x254b48, + 0x20b904, + 0x17a00202, + 0x2520c3, + 0x18259e86, + 0x37e208, + 0x18606482, + 0x222308, + 0x18a079c2, + 0x27208a, + 0x226b03, + 0x306bc6, + 0x328dc8, + 0x203f88, + 0x331dc6, + 0x368847, + 0x23d147, + 0x210d8a, + 0x2cddc4, + 0x33ce04, + 0x3505c9, + 0x38f545, + 0x262e86, + 0x212203, + 0x244d04, + 0x213544, + 0x305d07, + 0x225f47, + 0x265e84, + 0x210cc5, + 0x3738c8, + 0x35e287, + 0x3613c7, + 0x18e0bc82, + 0x2f5d44, + 0x292c88, + 0x382844, + 0x242244, + 0x242645, + 0x242787, + 0x20e8c9, + 0x243604, + 0x244109, + 0x2446c8, + 0x244a84, + 0x244a87, + 0x245303, + 0x245dc7, + 0x1644942, + 0x17a5202, + 0x246a46, + 0x247107, + 0x2475c4, + 0x248287, + 0x249207, + 0x249fc8, + 0x24a743, + 0x237842, + 0x201182, + 0x24ca03, + 0x24ca04, + 0x24ca0b, + 0x31afc8, + 0x2569c4, + 0x24d705, + 0x250107, + 0x255745, + 0x35b0ca, + 0x256903, + 0x19205642, + 0x256c04, + 0x259a89, + 0x25da03, + 0x25dac7, + 0x39edc9, + 0x2aef08, + 0x2078c3, + 0x278f47, + 0x279689, + 0x2809c3, + 0x282bc4, + 0x283f49, + 0x286fc6, + 0x2886c3, + 0x2022c2, + 0x23f443, + 0x39bb87, + 0x37b345, + 0x358b06, + 0x244f04, + 0x2e3505, + 0x21c083, + 0x217606, + 0x20cbc2, + 0x3901c4, + 0x221b82, + 0x2d9603, + 0x196007c2, + 0x23fe43, + 0x216e44, + 0x216e47, + 0x36c406, + 0x246a02, + 0x19a4f282, + 0x377044, + 0x19e28142, + 0x1a215c02, + 0x31b704, + 0x31b705, + 0x2c0205, + 0x322f46, + 0x1a6101c2, + 0x227785, + 0x228285, + 0x29f903, + 0x37d386, + 0x3a8245, + 0x213b42, + 0x338405, + 0x213b44, + 0x218d03, + 0x218f43, + 0x1aa0b142, + 0x2ef587, + 0x35e504, + 0x35e509, + 0x244c04, + 0x229383, + 0x34d189, + 0x34bc88, + 0x29f844, + 0x29f846, + 0x2a2283, + 0x2123c3, + 0x21cdc4, + 0x2d9d43, + 0x1aed51c2, + 0x300102, + 0x1b21a042, + 0x315648, + 0x325b88, + 0x395006, + 0x241ec5, + 0x21ec45, + 0x24f2c5, + 0x220442, + 0x1b6912c2, + 0x162c282, + 0x38f6c8, + 0x240285, + 0x37c904, + 0x2ddf05, + 0x377607, + 0x24fc84, + 0x237642, + 0x1ba03c82, + 0x30a384, + 0x218b87, + 0x39e907, + 0x36ba44, + 0x28f3c3, + 0x23fa44, + 0x23fa48, + 0x2e0006, + 0x3ac08a, + 0x20e784, + 0x28f748, + 0x24a244, + 0x21fc06, + 0x291284, + 0x3583c6, + 0x262249, + 0x2605c7, + 0x233d03, + 0x1be06dc2, + 0x26bc83, + 0x20f402, + 0x1c213f02, + 0x2dd186, + 0x360648, + 0x2a3447, + 0x3a2f89, + 0x235609, + 0x2a3d05, + 0x2a5b89, + 0x2a6bc5, + 0x2a7549, + 0x2a8345, + 0x2a7f44, + 0x2a7f47, + 0x296f43, + 0x2a8f87, + 0x383d46, + 0x2aa487, + 0x2a0585, + 0x2aa303, + 0x1c62f542, + 0x3928c4, + 0x1ca28182, + 0x258dc3, + 0x1ce0d4c2, + 0x2e4d86, + 0x27c645, + 0x2ac987, + 0x328943, + 0x254104, + 0x216903, + 0x2f5443, + 0x1d20b9c2, + 0x1da00042, + 0x3949c4, + 0x237803, + 0x359545, + 0x2a9d85, + 0x1de04542, + 0x1e600942, + 0x279286, + 0x20a544, + 0x30ac04, + 0x30ac0a, + 0x1ee01042, + 0x2f780a, + 0x36ee08, + 0x1f201104, + 0x213ac3, + 0x252583, + 0x321489, + 0x2729c9, + 0x302c06, + 0x1f602503, + 0x2d8145, + 0x2f834d, + 0x202506, + 0x20928b, + 0x1fa01982, + 0x332e08, + 0x1fe19e42, + 0x20205f02, + 0x2c2f45, + 0x20603dc2, + 0x266947, + 0x2a5687, + 0x214803, + 0x2576c8, + 0x20a02602, + 0x2828c4, + 0x3a84c3, + 0x332805, + 0x387083, + 0x27c106, + 0x2eaec4, + 0x23d403, + 0x26c843, + 0x20e0a3c2, + 0x22e544, + 0x34ec05, + 0x366687, + 0x276dc3, + 0x2ad183, + 0x2ad983, + 0x1626682, + 0x2ada43, + 0x2adcc3, + 0x21206d02, + 0x30f384, + 0x27a3c6, + 0x20d343, + 0x2ae043, + 0x216af102, + 0x2af108, + 0x2aff04, + 0x259186, + 0x2b0547, + 0x229786, + 0x32db84, + 0x2f2001c2, + 0x383c0b, + 0x2fe28e, + 0x21954f, + 0x2332c3, + 0x2fa3f402, + 0x1614082, + 0x2fe01b82, + 0x22c983, + 0x231f83, + 0x2d8fc6, + 0x2ed8c6, + 0x2e3807, + 0x230204, + 0x302953c2, + 0x306082c2, + 0x2e78c5, + 0x2e9ac7, + 0x32b046, + 0x30a69c02, + 0x269c04, + 0x3712c3, + 0x30e0a482, + 0x34e083, + 0x3a07c4, + 0x2b64c9, + 0x16bd742, + 0x31234082, + 0x2d9846, + 0x267a05, + 0x3163fc02, + 0x31a00102, + 0x33be87, + 0x362b09, + 0x350dcb, + 0x23cf05, + 0x372d09, + 0x2be486, + 0x258347, + 0x31e080c4, + 0x24b649, + 0x35ac47, + 0x2b7a47, + 0x20a683, + 0x20a686, + 0x2dc647, + 0x206f43, + 0x278186, + 0x32604582, + 0x32a2fdc2, + 0x21ea83, + 0x253d05, + 0x21dec7, + 0x354b86, + 0x37b2c5, + 0x31e604, + 0x205105, + 0x2e6684, + 0x32e0a902, + 0x322487, + 0x2d7884, + 0x245b84, + 0x35c88d, + 0x245b89, + 0x2280c8, + 0x24ec84, + 0x3296c5, + 0x20a907, + 0x30f644, + 0x27d347, + 0x31bf45, + 0x33332384, + 0x2cecc5, + 0x25c6c4, + 0x24fdc6, + 0x318445, + 0x33632c82, + 0x2116c4, + 0x2116c5, + 0x211ac6, + 0x37b405, + 0x250844, + 0x2e1b83, + 0x325dc6, + 0x201305, + 0x202005, + 0x318544, + 0x20e803, + 0x20e80c, + 0x33a87902, + 0x33e07c82, + 0x342120c2, + 0x332283, + 0x332284, + 0x346067c2, + 0x2f2908, + 0x358bc5, + 0x268344, + 0x27d686, + 0x34a326c2, + 0x34e1fa82, + 0x35200982, + 0x2b5345, + 0x254846, + 0x305c44, + 0x3544c6, + 0x2ae6c6, + 0x202cc3, + 0x3570e38a, + 0x237b45, + 0x220906, + 0x2f0249, + 0x220907, + 0x28fb88, + 0x294fc9, + 0x224c08, + 0x311206, + 0x237d03, + 0x35a08a42, + 0x385103, + 0x385109, + 0x263988, + 0x35e0a582, + 0x36202242, + 0x230c43, + 0x2cf185, + 0x24d204, + 0x2c1b89, + 0x2a9784, + 0x2d2fc8, + 0x209403, + 0x252904, + 0x264443, + 0x35c7c7, + 0x36640a02, + 0x25efc2, + 0x22b905, + 0x269e49, + 0x219bc3, + 0x27aa04, + 0x2d8104, + 0x20a983, + 0x27dd0a, + 0x36b6ecc2, + 0x36e11682, + 0x2befc3, + 0x371483, + 0x16528c2, + 0x2543c3, + 0x37253702, + 0x295744, + 0x37608f82, + 0x37b0ac84, + 0x345546, + 0x2794c4, + 0x259583, + 0x280543, + 0x21f4c3, + 0x23a606, + 0x2c5405, + 0x2bf847, + 0x258209, + 0x2c3ec5, + 0x2c5346, + 0x2c5948, + 0x2c5b46, + 0x249c04, + 0x298d4b, + 0x2c7103, + 0x2c7105, + 0x2c7248, + 0x20f082, + 0x33c182, + 0x37e272c2, + 0x3820dc02, + 0x261983, + 0x38607a42, + 0x26b403, + 0x2c7544, + 0x2c88c3, + 0x38e00ec2, + 0x2ca3cb, + 0x392ccc86, + 0x2bc206, + 0x2cd2c8, + 0x396ccdc2, + 0x39a0fcc2, + 0x39e18f82, + 0x3a22c902, + 0x3a7a9b42, + 0x3a9b4b, + 0x3aa01082, + 0x222543, + 0x317805, + 0x31d706, + 0x3ae021c4, + 0x31cbc7, + 0x3ad38a, + 0x31d9c6, + 0x22e804, + 0x261583, + 0x3ba05702, + 0x201cc2, + 0x24e2c3, + 0x3be49943, + 0x2f0d07, + 0x318347, + 0x3d24cb07, + 0x226ac7, + 0x21a5c3, + 0x21d48a, + 0x21a5c4, + 0x2442c4, + 0x2442ca, + 0x24a445, + 0x3d601142, + 0x2491c3, + 0x3da01ec2, + 0x209583, + 0x26bc43, + 0x3e201a02, + 0x2a49c4, + 0x21bdc4, + 0x3b3145, + 0x2daa05, + 0x27af06, + 0x27b286, + 0x3e60ba82, + 0x3ea01a82, + 0x344b05, + 0x2bbf12, + 0x2477c6, + 0x222c83, + 0x22ddc6, + 0x2fdf45, + 0x1600d42, + 0x46e0cd42, + 0x2ec943, + 0x2e5ac3, + 0x2da803, + 0x47202bc2, + 0x375583, + 0x47610342, + 0x2070c3, + 0x30f3c8, + 0x223cc3, + 0x223cc6, + 0x39f6c7, + 0x2db306, + 0x2db30b, + 0x22e747, + 0x3926c4, + 0x47e00e82, + 0x2ee785, + 0x21a583, + 0x22a743, + 0x3194c3, + 0x3194c6, + 0x2cfa8a, + 0x26f343, + 0x233704, + 0x316c06, + 0x205b46, + 0x482257c3, + 0x253fc7, + 0x37bf4d, + 0x38b907, + 0x298a85, + 0x243b86, + 0x201343, + 0x49b7d5c3, + 0x49e00d82, + 0x310684, + 0x225c8c, + 0x35c149, + 0x22c087, + 0x242fc5, + 0x255e44, + 0x27e388, + 0x283845, + 0x2884c5, + 0x28ec89, + 0x2f48c3, + 0x2f48c4, + 0x2a5184, + 0x4a200ac2, + 0x25f2c3, + 0x4a690d42, + 0x3707c6, + 0x16adac2, + 0x4aa96f02, + 0x2b5248, + 0x2cec07, + 0x296f05, + 0x2d480b, + 0x2d1386, + 0x2d4a06, + 0x2f6946, + 0x229e04, + 0x2fa7c6, + 0x2d3e48, + 0x230e83, + 0x24cdc3, + 0x24cdc4, + 0x2d4f04, + 0x2d5207, + 0x2d6345, + 0x4aed6482, + 0x4b209d02, + 0x209d05, + 0x29b784, + 0x2d844b, + 0x2d9b88, + 0x2da204, + 0x269c42, + 0x4baaed82, + 0x2af343, + 0x2da644, + 0x2dae45, + 0x275a07, + 0x2dda44, + 0x22e604, + 0x4be05fc2, + 0x35a549, + 0x2dec85, + 0x23d1c5, + 0x2df805, + 0x4c219683, + 0x2e0644, + 0x2e064b, + 0x2e0c44, + 0x2e10cb, + 0x2e2205, + 0x21968a, + 0x2e39c8, + 0x2e3bca, + 0x2e3e43, + 0x2e3e4a, + 0x4c625702, + 0x4ca3c782, + 0x29ca83, + 0x4cee55c2, + 0x2e55c3, + 0x4d371082, + 0x4d714202, + 0x2e6504, + 0x219e86, + 0x354205, + 0x2e7203, + 0x274ec6, + 0x223a44, + 0x4da058c2, + 0x2b6a04, + 0x2c094a, + 0x385e87, + 0x27c486, + 0x2cff47, + 0x225dc3, + 0x24a2c8, + 0x25a20b, + 0x302d05, + 0x2b6e05, + 0x2b6e06, + 0x20c744, + 0x323548, + 0x211103, + 0x211104, + 0x211107, + 0x353ec6, + 0x322b06, + 0x29ca0a, + 0x241804, + 0x24180a, + 0x227306, + 0x227307, + 0x24d787, + 0x271884, + 0x271889, + 0x3621c5, + 0x23544b, + 0x273d43, + 0x213903, + 0x21ec83, + 0x388004, + 0x4de03b82, + 0x24f446, + 0x2aa085, + 0x2b1ac5, + 0x220046, + 0x36e604, + 0x4e200c02, + 0x220144, + 0x4e60b482, + 0x22f4c4, + 0x221983, + 0x4eae5b02, + 0x306543, + 0x257086, + 0x4ee03182, + 0x33e288, + 0x220784, + 0x220786, + 0x31b806, + 0x2501c4, + 0x325d45, + 0x3a3c88, + 0x3a80c7, + 0x2048c7, + 0x2048cf, + 0x292b86, + 0x2198c3, 0x2198c4, - 0x51609642, - 0x236506, - 0x2abb46, - 0x26d308, - 0x2b90c8, - 0x2e6c44, - 0x2f5905, - 0x302f49, - 0x34c804, - 0x2d0844, - 0x261603, - 0x216845, - 0x2bd7c7, - 0x277b44, - 0x2ea5cd, - 0x2eab42, - 0x2eab43, - 0x2eac03, - 0x51a04582, - 0x38a045, - 0x22b107, - 0x228c44, - 0x228c47, - 0x295fc9, - 0x2c0849, - 0x20c987, - 0x279043, - 0x279048, - 0x21db89, - 0x2ebb87, - 0x2ebf05, - 0x2ec6c6, - 0x2ecd06, - 0x2ece85, - 0x24c745, - 0x51e00c42, - 0x226605, - 0x2bae0a, - 0x2a7a08, - 0x21c906, - 0x2e6987, - 0x26b104, - 0x3ae3c7, - 0x2f0186, - 0x52200242, - 0x38d646, - 0x2f374a, - 0x2f4745, - 0x526d3382, - 0x52a56142, - 0x2dd906, - 0x35ee88, - 0x39f047, - 0x52e00602, - 0x213d03, - 0x200a06, - 0x30b804, - 0x313b46, - 0x34d186, - 0x37fb0a, - 0x397385, - 0x20fa86, - 0x2133c3, - 0x2133c4, - 0x2083c2, - 0x300a43, - 0x53248c82, - 0x2c5603, - 0x2f9484, - 0x2dca84, - 0x35efca, - 0x2468c3, - 0x287d48, - 0x279dca, - 0x234cc7, - 0x2f5d86, - 0x2363c4, - 0x28fcc2, - 0x208bc2, - 0x5360a6c2, - 0x245ac3, - 0x251b47, - 0x27a887, - 0x38ffcb, - 0x328284, - 0x30c5c7, - 0x22a646, - 0x219bc7, - 0x29f984, - 0x2c7d05, - 0x291bc5, - 0x53a1bf02, - 0x2225c6, - 0x33a583, - 0x2be6c2, - 0x32b206, - 0x53e0fe42, - 0x542012c2, - 0x2012c5, - 0x5461c642, - 0x54a05702, - 0x2e7dc5, - 0x38e705, - 0x20fb45, - 0x26c743, - 0x239ac5, - 0x2d1e87, - 0x2a94c5, - 0x3a0145, - 0x265904, - 0x243586, - 0x24aac4, - 0x54e05a02, - 0x27dbc5, - 0x2a2c87, - 0x2299c8, - 0x26ed46, - 0x26ed4d, - 0x26f609, - 0x26f612, - 0x2ee645, - 0x2f2703, - 0x55a0f042, - 0x2e7b84, - 0x207303, - 0x318f45, - 0x35d4c5, - 0x55e12dc2, - 0x36bb83, - 0x56244302, - 0x566cd782, - 0x56a13082, - 0x33f185, - 0x331083, - 0x264048, - 0x56e07e02, - 0x57201bc2, - 0x2a5a46, - 0x325c0a, - 0x20d803, - 0x239103, - 0x2edd83, - 0x57e03f02, - 0x66207942, - 0x66a0a302, - 0x201242, - 0x38d449, - 0x2bcb44, - 0x258f48, - 0x66eea342, - 0x67204102, - 0x2e4805, - 0x232d08, - 0x24a508, - 0x39e64c, - 0x239cc3, - 0x23bc82, - 0x6760c402, - 0x2c3c46, - 0x2f6c05, - 0x326903, - 0x32b746, - 0x2f6d46, - 0x235d83, - 0x2f8103, - 0x2f8b46, - 0x2f9904, - 0x276a86, - 0x2c7285, - 0x2f9c8a, - 0x233f84, - 0x2faac4, - 0x34da8a, - 0x67a74b82, - 0x271185, - 0x2fcf4a, - 0x2fdcc5, - 0x2fe844, - 0x2fe946, - 0x2feac4, - 0x228946, - 0x67e00282, - 0x237786, - 0x238845, - 0x201d07, - 0x300fc6, - 0x23d504, - 0x2c8047, - 0x32af06, - 0x267e05, - 0x267e07, - 0x39b987, - 0x39b98e, - 0x2232c6, - 0x32cb85, - 0x283a47, - 0x2f1c03, - 0x366e07, - 0x35ba05, - 0x212644, - 0x214382, - 0x267207, - 0x379104, - 0x238bc4, - 0x25a14b, - 0x21fdc3, - 0x286807, - 0x21fdc4, - 0x2a4c87, - 0x22ac83, - 0x32e98d, - 0x38a888, - 0x2511c4, - 0x2511c5, - 0x301705, - 0x2ff303, - 0x68214a02, - 0x300a03, - 0x301143, - 0x399f04, - 0x27e585, - 0x21eec7, - 0x213446, - 0x36f643, - 0x32b34b, - 0x32f70b, - 0x27338b, - 0x27e68a, - 0x2a55cb, - 0x2caf0b, - 0x2d33cc, - 0x2f8711, - 0x33d50a, - 0x35030b, - 0x37a40b, - 0x3aef8a, - 0x3b0f8a, - 0x301b0d, - 0x3032ce, - 0x30438b, - 0x30464a, - 0x305811, - 0x305c4a, - 0x30614b, - 0x30668e, - 0x30720c, - 0x3075cb, - 0x30788e, - 0x307c0c, - 0x3094ca, - 0x30a6cc, - 0x6870a9ca, - 0x30bbc9, - 0x30dd0a, - 0x30df8a, - 0x30e20b, - 0x31014e, - 0x3104d1, - 0x319509, - 0x31974a, - 0x31a00b, - 0x31baca, - 0x31c656, - 0x31de0b, - 0x3200ca, - 0x320dca, - 0x32528b, - 0x329a09, - 0x32f309, - 0x33154d, - 0x331dcb, - 0x332b0b, - 0x3334cb, - 0x333c89, - 0x3342ce, - 0x3346ca, - 0x335b0a, - 0x33620a, - 0x33698b, - 0x3371cb, - 0x33748d, - 0x338b0d, - 0x339950, - 0x339e0b, - 0x33b3cc, - 0x33c04b, - 0x33dc0b, - 0x33fb8b, - 0x34814b, - 0x348bcf, - 0x348f8b, - 0x349bca, - 0x34a2c9, - 0x34a709, - 0x34b0cb, - 0x34b38e, - 0x34e10b, - 0x34eecf, - 0x3512cb, - 0x35158b, - 0x35184b, - 0x351c8a, - 0x355889, - 0x35898f, - 0x36104c, - 0x36150c, - 0x36278e, - 0x362fcf, - 0x36338e, - 0x363e90, - 0x36428f, - 0x36574e, - 0x365c0c, - 0x365f12, - 0x367b11, - 0x3680ce, - 0x36850e, - 0x368a4e, - 0x368dcf, - 0x36918e, - 0x369513, - 0x3699d1, - 0x369e0e, - 0x36a28c, - 0x36ad53, - 0x36b550, - 0x36c18c, - 0x36c48c, - 0x36c94b, - 0x36dfce, - 0x36e64b, - 0x36ea8b, - 0x37090c, - 0x37954a, - 0x379c0c, - 0x379f0c, - 0x37a209, - 0x37b60b, - 0x37b8c8, - 0x37bac9, - 0x37bacf, - 0x37d40b, - 0x37e10a, - 0x38154c, - 0x383409, - 0x3837c8, - 0x384bcb, - 0x3852cb, - 0x38644a, - 0x3866cb, - 0x386c0c, - 0x387948, - 0x38aa8b, - 0x38d14b, - 0x39028b, - 0x391b0b, - 0x39b50b, - 0x39b7c9, - 0x39bd0d, - 0x3a0f8a, - 0x3a1ed7, - 0x3a3b58, - 0x3a8a09, - 0x3a9c0b, - 0x3aa3d4, - 0x3aa8cb, - 0x3aae4a, - 0x3ab2ca, - 0x3ab54b, - 0x3ac450, - 0x3ac851, - 0x3ad10a, - 0x3ae58d, - 0x3aec8d, - 0x3b134b, - 0x3b2746, - 0x2226c3, - 0x68a5b343, - 0x385d06, - 0x28e605, - 0x2d6487, - 0x33d3c6, - 0x1627342, - 0x2ad589, - 0x27a3c4, - 0x2d0348, - 0x245a03, - 0x2e7ac7, - 0x22eb82, - 0x2acc83, - 0x68e006c2, - 0x2c2686, - 0x2c36c4, - 0x328a44, - 0x23e083, - 0x23e085, - 0x696cd7c2, - 0x2dba04, - 0x2760c7, - 0x1662e02, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x2020c3, - 0x200882, - 0x77a48, - 0x206a82, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x20b803, - 0x3152d6, - 0x318493, - 0x30c449, - 0x324308, - 0x3a05c9, - 0x2fd0c6, - 0x30d250, - 0x303e13, - 0x208888, - 0x2407c7, - 0x27c647, - 0x29f48a, - 0x2f9509, - 0x34cf89, - 0x290ccb, - 0x340c06, - 0x32324a, - 0x222986, - 0x279fc3, - 0x2f1ec5, - 0x226b48, - 0x2365cd, - 0x35988c, - 0x238507, - 0x304e0d, - 0x2036c4, - 0x22ff8a, - 0x2308ca, - 0x230d8a, - 0x304107, - 0x23cfc7, - 0x23ff44, - 0x22f246, - 0x340fc4, - 0x2f0448, - 0x2aaa09, - 0x2b9906, - 0x2b9908, - 0x24328d, + 0x224884, + 0x228383, + 0x21fd44, + 0x3ac384, + 0x4f225742, + 0x288bc3, + 0x235803, + 0x4f6057c2, + 0x234183, + 0x252ec3, + 0x2161ca, + 0x29e487, + 0x235fcc, + 0x236286, + 0x2369c6, + 0x237487, + 0x238dc7, + 0x23c109, + 0x21ac44, + 0x23c4c4, + 0x4fa05202, + 0x4fe03e42, + 0x253dc4, + 0x2fc1c6, + 0x2a3e08, + 0x37e044, + 0x266986, + 0x2c9e45, + 0x265b08, + 0x207503, + 0x269185, + 0x26b043, + 0x23d2c3, + 0x23d2c4, + 0x26f8c3, + 0x502de902, + 0x50600fc2, + 0x273c09, + 0x283745, + 0x283944, + 0x285a05, + 0x20de04, + 0x3a96c7, + 0x339c45, + 0x24ccc4, + 0x24ccc8, + 0x2d2946, + 0x2d4004, + 0x2d4488, + 0x2d76c7, + 0x50a1b842, + 0x2e1944, + 0x228444, + 0x2b7c47, + 0x50e74644, + 0x255342, + 0x51214202, + 0x2636c3, + 0x2636c4, + 0x234043, + 0x234045, + 0x5162dbc2, + 0x2f8a45, + 0x219b82, + 0x381505, + 0x360805, + 0x51a0acc2, + 0x2153c4, + 0x51e063c2, + 0x22d2c6, + 0x2ab886, + 0x269f88, + 0x2b89c8, + 0x2e4d04, + 0x314e05, + 0x2f8849, + 0x329a04, + 0x2cfa44, + 0x254a83, + 0x52210ec5, + 0x378047, + 0x2895c4, + 0x39ab0d, + 0x2e74c2, + 0x2e74c3, + 0x2e7583, + 0x52601d42, + 0x388bc5, + 0x2eb107, + 0x226b84, + 0x226b87, + 0x2951c9, 0x2c0a89, - 0x204188, - 0x25b147, - 0x20150a, - 0x24c286, - 0x259f07, - 0x2b1e04, - 0x248087, - 0x33a34a, - 0x25958e, - 0x210705, - 0x2ff04b, - 0x2f2509, - 0x22dec9, - 0x2a6347, - 0x3a278a, - 0x2b8007, - 0x2f2b09, - 0x359d48, - 0x3141cb, - 0x2cff85, - 0x2e038a, - 0x21ec49, - 0x32688a, - 0x2c384b, - 0x247f8b, - 0x290a55, - 0x2d59c5, - 0x25b1c5, - 0x2e24ca, - 0x2501ca, - 0x376507, - 0x220283, - 0x29e308, - 0x2cb24a, - 0x3abc86, - 0x241949, - 0x26ae48, - 0x2d9544, - 0x235c49, - 0x2b90c8, - 0x2dcd87, - 0x27dbc6, - 0x2a2c87, - 0x297b87, - 0x23f985, - 0x25388c, - 0x2511c5, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x206a82, - 0x22bf83, - 0x24c083, - 0x2020c3, - 0x204703, - 0x22bf83, - 0x24c083, - 0x222f43, - 0x204703, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x77a48, - 0x206a82, - 0x200e42, - 0x230fc2, - 0x207382, - 0x203202, - 0x2d3cc2, - 0x462bf83, - 0x231b03, - 0x20f583, - 0x250cc3, - 0x202243, - 0x220ec3, - 0x24c083, - 0x204703, - 0x232dc3, - 0x77a48, - 0x329904, - 0x25fe87, - 0x262203, - 0x3395c4, - 0x22ea83, - 0x286c03, - 0x250cc3, + 0x21d047, + 0x253143, + 0x288308, + 0x239c09, + 0x2e7f47, + 0x2e82c5, + 0x2e8a86, + 0x2e90c6, + 0x2e9245, + 0x245c85, + 0x52a00c42, + 0x222885, + 0x2ba70a, + 0x2a6708, + 0x21f986, + 0x2e2447, + 0x265dc4, + 0x2b0387, + 0x2ecd86, + 0x52e00242, + 0x2117c6, + 0x2f048a, + 0x2f1645, + 0x532d1e82, + 0x53649742, + 0x2dc986, + 0x2ec288, + 0x39eac7, + 0x53a00602, + 0x20fa43, + 0x200a06, + 0x308e44, + 0x39f586, + 0x322c46, + 0x37cf8a, + 0x3a8b05, + 0x20cdc6, + 0x20d3c3, + 0x20d3c4, + 0x207282, + 0x2ff3c3, + 0x53e44382, + 0x2dc483, + 0x2f7a84, + 0x2ec3c4, + 0x2ec3ca, + 0x242103, + 0x285748, + 0x2746ca, + 0x233147, + 0x2f2f46, + 0x22d184, + 0x22e6c2, + 0x207a82, + 0x54205002, + 0x23fa03, + 0x24d547, + 0x275187, + 0x38f60b, + 0x370684, + 0x347107, + 0x275b06, + 0x213cc7, + 0x29e3c4, + 0x2c7d45, + 0x29fe45, + 0x54614882, + 0x226646, + 0x2c82c3, + 0x22e942, + 0x30e5c6, + 0x54a0d182, + 0x54e01582, + 0x201585, + 0x5521f6c2, + 0x556020c2, + 0x2e4685, + 0x38dd45, + 0x20ce85, + 0x267743, + 0x2350c5, + 0x2d1447, + 0x2a7405, + 0x32a4c5, + 0x25f344, + 0x23f046, + 0x246184, + 0x55a06882, + 0x278dc5, + 0x2a2a47, + 0x2fc3c8, + 0x26cc46, + 0x26cc4d, + 0x272789, + 0x272792, + 0x2efd05, + 0x2f8d83, + 0x56601382, + 0x2e4444, + 0x202583, + 0x324d05, + 0x35f8c5, + 0x56a1ce42, + 0x36ab43, + 0x56e3e2c2, + 0x57295802, + 0x5760d502, + 0x33d205, + 0x365dc3, + 0x323c08, + 0x57a030c2, + 0x57e035c2, + 0x2a4986, + 0x32820a, + 0x20c903, + 0x234703, + 0x2e9843, + 0x58a03d02, + 0x66e02c02, + 0x6760a242, + 0x201502, + 0x38c0c9, + 0x2bcb84, + 0x2579c8, + 0x67ae7242, + 0x67e03f02, + 0x2e1305, + 0x231948, + 0x245108, + 0x39e0cc, + 0x2352c3, + 0x240242, + 0x682049c2, + 0x2c4346, + 0x2f3dc5, + 0x321ac3, + 0x380786, + 0x2f3f06, + 0x24fe43, + 0x2f6703, + 0x2f7146, + 0x2f7f04, + 0x272186, + 0x2c72c5, + 0x2f818a, + 0x29e8c4, + 0x2f9844, + 0x348a4a, + 0x6866ff82, + 0x33de45, + 0x2fb58a, + 0x2fc5c5, + 0x2fd144, + 0x2fd246, + 0x2fd3c4, + 0x340186, + 0x68a00282, + 0x27bdc6, + 0x27ce85, + 0x203707, + 0x22eb06, + 0x237684, + 0x2afb87, + 0x30e2c6, + 0x211805, + 0x2af7c7, + 0x39b2c7, + 0x39b2ce, + 0x224046, + 0x27d205, + 0x27ef07, + 0x227603, + 0x227607, + 0x3aa985, + 0x20fd04, + 0x2213c2, + 0x2e5b47, + 0x230284, + 0x2d8f44, + 0x25ee4b, + 0x21b503, + 0x2835c7, + 0x21b504, + 0x2a5247, + 0x22b603, + 0x32cf0d, + 0x389408, + 0x24cbc4, + 0x24cbc5, + 0x2ffbc5, + 0x2fdc03, + 0x68e1a642, + 0x2ff383, + 0x2ff603, + 0x38cb44, + 0x279785, + 0x218fc7, + 0x20d446, + 0x36edc3, + 0x37784b, + 0x30e70b, + 0x26e78b, + 0x27988a, + 0x2a608b, + 0x2d0acb, + 0x2d1ecc, + 0x2f6d11, + 0x33ae8a, + 0x34b2cb, + 0x376acb, + 0x3b008a, + 0x3b218a, + 0x2fffcd, + 0x30128e, + 0x30190b, + 0x301bca, + 0x302f11, + 0x30334a, + 0x30384b, + 0x303d8e, + 0x3046cc, + 0x304a4b, + 0x304d0e, + 0x30508c, + 0x30700a, + 0x307d0c, + 0x6930800a, + 0x3095c9, + 0x30ae8a, + 0x30b10a, + 0x30b38b, + 0x30da0e, + 0x30dd91, + 0x31a149, + 0x31a38a, + 0x31ac4b, + 0x31edca, + 0x31f916, + 0x3210cb, + 0x324aca, + 0x32510a, + 0x32788b, + 0x32aa09, + 0x32d889, + 0x32e20d, + 0x32ea8b, + 0x32f7cb, + 0x33018b, + 0x330949, + 0x330f8e, + 0x3314ca, + 0x3338ca, + 0x333e0a, + 0x33454b, + 0x334d8b, + 0x33504d, + 0x33734d, + 0x338090, + 0x33854b, + 0x338b4c, + 0x3397cb, + 0x33b98b, + 0x33e48b, + 0x34318b, + 0x343c0f, + 0x343fcb, + 0x344c4a, + 0x345289, + 0x3456c9, + 0x345d4b, + 0x34600e, + 0x3490cb, + 0x349e8f, + 0x34c38b, + 0x34c64b, + 0x34c90b, + 0x34cd4a, + 0x3509c9, + 0x35688f, + 0x35d8cc, + 0x35dfcc, + 0x35f58e, + 0x35fd8f, + 0x36014e, + 0x360c50, + 0x36104f, + 0x36304e, + 0x36350c, + 0x363812, + 0x366291, + 0x36684e, + 0x366c8e, + 0x3671ce, + 0x36754f, + 0x36790e, + 0x367c93, + 0x368151, + 0x36858e, + 0x368a0c, + 0x369a93, + 0x36a510, + 0x36af4c, + 0x36b24c, + 0x36b70b, + 0x36c6ce, + 0x36da8b, + 0x36decb, + 0x36f48c, + 0x375c0a, + 0x3762cc, + 0x3765cc, + 0x3768c9, + 0x378acb, + 0x378d88, + 0x378f89, + 0x378f8f, + 0x37a8cb, + 0x37b5ca, + 0x37ed0c, + 0x380f09, + 0x3812c8, + 0x381ccb, + 0x38214b, + 0x38348a, + 0x38370b, + 0x384e8c, + 0x385888, + 0x38960b, + 0x38bdcb, + 0x38f8cb, + 0x391acb, + 0x39ae4b, + 0x39b109, + 0x39b64d, + 0x3a0b8a, + 0x3a1ad7, + 0x3a2758, + 0x3a6909, + 0x3a7b0b, + 0x3ab094, + 0x3ab58b, + 0x3abb0a, + 0x3ac48a, + 0x3ac70b, + 0x3ad710, + 0x3adb11, + 0x3ae3ca, + 0x3af68d, + 0x3afd8d, + 0x3b254b, + 0x3b3506, + 0x226743, + 0x6963d343, + 0x382b86, + 0x28c985, + 0x369607, + 0x33ad46, + 0x16235c2, + 0x2ad2c9, + 0x274cc4, + 0x2cf548, + 0x23f943, + 0x2e4387, + 0x239942, + 0x2ac9c3, + 0x69a006c2, + 0x2c2806, + 0x2c3dc4, + 0x310d04, + 0x2383c3, + 0x2383c5, + 0x6a2c6b02, + 0x2da544, + 0x2717c7, + 0x165ee02, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x202883, 0x200882, - 0x127883, - 0x5606a82, - 0x230fc2, - 0x23c4, - 0x200fc2, - 0xe1c44, - 0x77a48, - 0x20e503, - 0x2cd683, - 0x5e2bf83, - 0x22ff84, - 0x6231b03, - 0x6650cc3, - 0x20b542, - 0x2023c4, - 0x24c083, - 0x2f1d03, - 0x2018c2, - 0x204703, - 0x21f0c2, - 0x2e9943, - 0x202942, - 0x207703, - 0x26af03, - 0x201d02, - 0x77a48, - 0x20e503, - 0x2f1d03, - 0x2018c2, - 0x2e9943, - 0x202942, - 0x207703, - 0x26af03, - 0x201d02, - 0x2e9943, - 0x202942, - 0x207703, - 0x26af03, - 0x201d02, - 0x22bf83, - 0x327883, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x202243, - 0x220ec3, - 0x211004, - 0x24c083, - 0x204703, - 0x209202, - 0x21d603, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x327883, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x24c083, - 0x204703, - 0x2ebf05, - 0x212dc2, + 0x894c8, + 0x204a82, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x2161c3, + 0x315ed6, + 0x319093, + 0x346f89, + 0x3acf08, + 0x2ee609, + 0x2fb706, + 0x30a3d0, + 0x3b0ad3, + 0x207748, + 0x259687, + 0x277847, + 0x29deca, + 0x2f7b09, + 0x32a189, + 0x2975cb, + 0x329186, + 0x3115ca, + 0x21ed86, + 0x2748c3, + 0x2ef4c5, + 0x222dc8, + 0x22d38d, + 0x35818c, + 0x27cb47, + 0x3015cd, + 0x3a3d84, + 0x22ec8a, + 0x22f5ca, + 0x22fa8a, + 0x2631c7, + 0x237f07, + 0x23a9c4, + 0x25e146, + 0x354e44, + 0x2ed248, + 0x2a97c9, + 0x2b9206, + 0x2b9208, + 0x23d78d, + 0x2c0cc9, + 0x203f88, + 0x23d147, + 0x2017ca, + 0x247106, + 0x258c87, + 0x2db9c4, + 0x242dc7, + 0x35c4ca, + 0x337bce, + 0x24f2c5, + 0x2fd94b, + 0x2efb09, + 0x2729c9, + 0x2a54c7, + 0x399f4a, + 0x2b7b87, + 0x2fe3c9, + 0x358648, + 0x2d7c8b, + 0x2cf185, + 0x227f8a, + 0x218d49, + 0x321a4a, + 0x2c3f4b, + 0x242ccb, + 0x297355, + 0x2d4345, + 0x23d1c5, + 0x2e064a, + 0x3061ca, + 0x31e007, + 0x21b9c3, + 0x29cd48, + 0x2cb7ca, + 0x220786, + 0x239a49, + 0x265b08, + 0x2d4004, + 0x3379c9, + 0x2b89c8, + 0x357b87, + 0x278dc6, + 0x2a2a47, + 0x293687, + 0x23a405, + 0x24f10c, + 0x24cbc5, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x204a82, + 0x258403, + 0x249943, + 0x202883, + 0x2257c3, + 0x258403, + 0x249943, + 0x223cc3, + 0x2257c3, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x894c8, + 0x204a82, + 0x201802, + 0x22fcc2, + 0x202602, + 0x203c42, + 0x2954c2, + 0x4658403, + 0x230743, + 0x2095c3, + 0x2d9d43, + 0x202503, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x231a03, + 0x894c8, + 0x24c844, + 0x2526c7, + 0x255683, + 0x2c2f44, + 0x232283, + 0x283f83, + 0x2d9d43, 0x200882, - 0x77a48, - 0x250cc3, - 0x260e41, - 0x20bd81, - 0x260e01, - 0x20bb01, - 0x275d81, - 0x275e41, - 0x262281, - 0x24b581, - 0x2f8901, - 0x301dc1, + 0x123743, + 0x5604a82, + 0x22fcc2, + 0x1104, + 0x2016c2, + 0xdfdc4, + 0x894c8, + 0x206043, + 0x2c69c3, + 0x5e58403, + 0x22ec84, + 0x6230743, + 0x66d9d43, + 0x20b9c2, + 0x201104, + 0x249943, + 0x211783, + 0x202542, + 0x2257c3, + 0x21a842, + 0x2e6443, + 0x203182, + 0x200f43, + 0x265bc3, + 0x203702, + 0x894c8, + 0x206043, + 0x211783, + 0x202542, + 0x2e6443, + 0x203182, + 0x200f43, + 0x265bc3, + 0x203702, + 0x2e6443, + 0x203182, + 0x200f43, + 0x265bc3, + 0x203702, + 0x258403, + 0x323743, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x202503, + 0x219bc3, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x20bb42, + 0x219683, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x323743, + 0x204a82, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x249943, + 0x2257c3, + 0x2e82c5, + 0x21ce42, + 0x200882, + 0x894c8, + 0x2d9d43, + 0x2542c1, + 0x20b041, + 0x254281, + 0x20adc1, + 0x24c901, + 0x271541, + 0x24c8c1, + 0x279a81, + 0x2f6f01, + 0x300281, 0x200141, 0x200001, - 0x77a48, + 0x894c8, 0x200481, 0x200741, 0x200081, - 0x201501, + 0x201181, 0x2007c1, 0x200901, 0x200041, - 0x202381, + 0x202b41, 0x2001c1, 0x2000c1, 0x200341, 0x200cc1, - 0x200fc1, + 0x200e81, 0x200ac1, - 0x213041, + 0x219e81, 0x200c01, 0x200241, 0x200a01, 0x2002c1, 0x200281, - 0x201d01, - 0x2041c1, + 0x203701, + 0x203fc1, 0x200781, 0x200641, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x200fc2, - 0x204703, - 0x142b87, - 0x1c106, - 0x18a4a, - 0x89808, - 0x51688, - 0x51a47, - 0x60f46, - 0xcdfc5, - 0x62145, - 0x72606, - 0x122706, - 0x223504, - 0x3212c7, - 0x77a48, - 0x2c8144, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x250cc3, - 0x202243, - 0x220ec3, - 0x24c083, - 0x204703, - 0x212dc2, - 0x2b6f03, - 0x214583, - 0x279643, - 0x202a82, - 0x249c83, - 0x201e03, - 0x2056c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x204a82, + 0x258403, + 0x230743, + 0x2016c2, + 0x2257c3, + 0x63007, + 0x1f186, + 0x1d84a, + 0x87548, + 0x4d088, + 0x4d447, + 0x543c6, + 0xceb05, + 0x555c5, + 0x7e246, + 0x152dc6, + 0x224284, + 0x325607, + 0x894c8, + 0x2afc84, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2095c3, + 0x2d9d43, + 0x202503, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x21ce42, + 0x2b6a83, + 0x21a1c3, + 0x262043, + 0x202202, + 0x245403, + 0x203803, + 0x202403, 0x200001, - 0x2075c3, - 0x276844, - 0x3355c3, - 0x30da43, - 0x21eb83, - 0x378d83, - 0xa22bf83, - 0x234a44, - 0x21eb43, - 0x22e0c3, - 0x231b03, - 0x231843, - 0x211a83, - 0x2a2383, - 0x30d9c3, - 0x226083, - 0x2143c3, - 0x24ce04, - 0x23d6c2, - 0x250f43, - 0x2579c3, - 0x279003, - 0x260d83, - 0x345903, - 0x250cc3, - 0x2e87c3, - 0x2037c3, - 0x2023c3, - 0x249283, - 0x35d7c3, - 0x300b83, - 0x387883, + 0x207043, + 0x271f44, + 0x328983, + 0x30abc3, + 0x219fc3, + 0x35c043, + 0xa258403, + 0x232ec4, + 0x219f83, + 0x205283, + 0x230743, + 0x230483, + 0x218903, + 0x29fa83, + 0x30ab43, + 0x222303, + 0x213543, + 0x247a84, + 0x237842, + 0x24c943, + 0x256383, + 0x275843, + 0x254203, + 0x252f83, + 0x2d9d43, + 0x2e4f03, + 0x21bbc3, + 0x201103, + 0x2148c3, + 0x35fbc3, + 0x318703, + 0x3857c3, 0x200983, - 0x232003, - 0x220ec3, - 0x21e782, - 0x28a503, - 0x24c083, - 0x16020c3, - 0x255bc3, - 0x232943, - 0x212c03, - 0x204703, - 0x20b103, - 0x21d603, - 0x23b303, - 0x2f8183, - 0x2e9b03, - 0x303b85, - 0x2298c3, - 0x2e9b43, - 0x2eb283, - 0x2133c4, - 0x25a903, - 0x32be83, - 0x277083, - 0x232dc3, - 0x212dc2, - 0x239cc3, - 0x2fb8c4, - 0x238bc4, - 0x24cd43, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x206a82, - 0x204703, - 0xb62bf83, - 0x250cc3, - 0x220ec3, - 0x20dd02, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x6c2, - 0x201142, - 0x223342, - 0x77a48, - 0x6a82, - 0x2338c2, - 0x207082, - 0x23eac2, - 0x202402, - 0x209142, - 0x62145, - 0x202702, - 0x2018c2, - 0x207902, - 0x201702, - 0x200ac2, - 0x386d02, - 0x203a02, - 0x227d82, - 0x117c0d, - 0xed209, - 0x4a30b, - 0xd1d48, - 0x472c9, - 0x250cc3, - 0x77a48, - 0x77a48, - 0x52946, - 0x200882, - 0x223504, - 0x206a82, - 0x22bf83, - 0x200e42, - 0x231b03, - 0x20f582, - 0x2c8144, - 0x202243, - 0x20ad82, - 0x24c083, - 0x200fc2, - 0x204703, - 0x25b1c6, - 0x30e7cf, - 0x701683, - 0x77a48, - 0x206a82, - 0x20f583, - 0x250cc3, - 0x220ec3, - 0x1479b8b, - 0x206a82, - 0x22bf83, - 0x250cc3, - 0x24c083, - 0x200882, - 0x206b82, - 0x20a882, - 0xea2bf83, - 0x23e902, - 0x231b03, - 0x249242, - 0x225902, - 0x250cc3, - 0x224242, - 0x24b342, - 0x24cd02, - 0x204242, - 0x28cf02, - 0x205302, - 0x200902, - 0x210442, - 0x20b882, - 0x217e82, - 0x2ad442, - 0x23ba82, - 0x312042, - 0x24dcc2, - 0x220ec3, - 0x202ac2, - 0x24c083, - 0x243482, - 0x273342, - 0x204703, - 0x249d02, - 0x203682, - 0x24ecc2, - 0x201f82, - 0x2198c2, - 0x2d3382, - 0x21bf02, - 0x244302, - 0x222742, - 0x30464a, - 0x349bca, - 0x37f58a, - 0x3b28c2, - 0x20b642, - 0x245d02, - 0xeeaef89, - 0xf26050a, - 0xf42e107, - 0xbac2, - 0x6050a, - 0x247204, - 0xfe2bf83, - 0x231b03, - 0x248fc4, - 0x250cc3, - 0x2023c4, - 0x202243, - 0x220ec3, - 0x24c083, - 0x2020c3, - 0x204703, - 0x2298c3, - 0x2232c3, - 0x77a48, - 0x1460ec4, - 0x60745, - 0x5f68a, - 0x10a642, - 0x17e606, - 0x106aef89, - 0x142d47, - 0x1e02, - 0x1ab7ca, - 0xda987, - 0x77a48, - 0xfff08, - 0xd8c7, - 0x1181d10b, - 0x3482, - 0x1a0947, - 0xdc0a, - 0x19f20f, - 0x124b4f, - 0x1eb82, - 0x6a82, - 0xa22c8, - 0xec94a, - 0x143f48, - 0x1582, - 0x13564b, - 0x16fcc8, - 0x7f087, - 0xdaa8a, - 0x58a4b, - 0x172cc9, - 0x16fbc7, - 0xf564c, - 0xb587, - 0xd0b0a, - 0x14bcc8, - 0xf20ce, - 0x5360e, - 0xda7cb, - 0x17664b, - 0xecf4b, - 0x1c109, - 0x1df4b, - 0x22d8d, - 0x24b0b, - 0x277cd, - 0x2b70d, - 0x12c9ca, - 0x38a0b, - 0x5910b, - 0x67505, - 0x10b510, - 0x14338f, - 0xe37cf, - 0x1e34d, - 0x76650, - 0x8b02, - 0x11f24008, - 0x142a08, - 0x122e4205, - 0x47d0b, - 0x4f508, - 0x17680a, - 0x58189, - 0x625c7, - 0x62907, - 0x62ac7, - 0x656c7, - 0x660c7, - 0x663c7, - 0x67807, - 0x68687, - 0x69007, - 0x691c7, - 0x6a487, - 0x6a647, - 0x6a807, - 0x6a9c7, - 0x6acc7, - 0x6b347, - 0x6c307, - 0x6c8c7, - 0x6d087, - 0x6d807, - 0x6d9c7, - 0x6ddc7, - 0x6e307, - 0x6e507, - 0x6e7c7, - 0x6e987, - 0x6eb47, - 0x6f087, - 0x6fa87, - 0x70547, - 0x72d47, - 0x73007, - 0x73647, - 0x73807, - 0x73b87, - 0x749c7, - 0x74c47, - 0x75047, - 0x758c7, - 0x75a87, - 0x75ec7, - 0x76c07, - 0x76f07, - 0x77147, - 0x77307, - 0x77687, - 0x78007, - 0xd502, - 0x44c4a, - 0xf8407, - 0x124c8a0b, - 0x14c8a16, - 0x1bb11, - 0xdf0ca, - 0xa214a, - 0x52946, - 0x18e90b, - 0x10702, - 0x184551, - 0x99ac9, - 0x92dc9, - 0x10442, - 0x9ec8a, - 0xa3849, - 0xa3f4f, - 0xa48ce, - 0xa5408, - 0x134c2, - 0x799c9, - 0x1779ce, - 0xac08c, - 0xd438f, - 0x194a8e, - 0x1378c, - 0x18549, - 0x19451, - 0x1ae88, - 0x13ab12, - 0x12bb8d, - 0x2f10d, - 0x398cb, - 0x43755, - 0x44b09, - 0x4540a, - 0x57b49, - 0x5bb90, - 0x6a1cb, - 0x7be8f, - 0x7ce4b, - 0x8048c, - 0x80e50, - 0x85a0a, - 0x8a3cd, - 0x13f80e, - 0x14aa0a, - 0x8f30c, - 0x97854, - 0x99751, - 0x9cc0b, - 0x9de8f, - 0xab18d, - 0xaba0e, - 0xdcc4c, - 0x15eacc, - 0xdc94b, - 0xe8a4e, - 0xeb550, - 0x12e34b, - 0x16a70d, - 0xb48cf, - 0xb83cc, - 0xb978e, - 0xb9f91, - 0xbbd0c, - 0x119e47, - 0xc174d, - 0xc60cc, - 0xd5c50, - 0xe608d, - 0xfc987, - 0xeecd0, - 0xf3d88, - 0xf494b, - 0x16f84f, - 0x15bd88, - 0xdf2cd, - 0x173dd0, - 0xafec3, - 0xac82, - 0x2bb09, - 0x5340a, - 0xfb906, - 0x128de7c9, - 0x11e03, - 0x10ad11, - 0xccf47, - 0xd36d0, - 0xd3b8c, - 0xd4d85, - 0x1189c8, - 0x19c9ca, - 0x1976c7, - 0x1042, - 0x6184a, - 0xe3b09, - 0x34aca, - 0x19ef8f, - 0x4160b, - 0x1283cc, - 0x128692, - 0xadd85, - 0x161b4a, - 0x12ee1545, - 0x1132c3, - 0x186d02, - 0xe9e4a, - 0xcfc88, - 0x124ac7, - 0x34c2, - 0xed42, - 0x2942, - 0x1a7a10, - 0x4042, - 0x2e9cf, - 0x72606, - 0x176c8e, - 0xd7c0b, - 0x14ac08, - 0xc9d49, - 0x17cbd2, - 0x404d, - 0x496c8, - 0x4a1c9, - 0x4c40d, - 0x4e7c9, - 0x52a8b, - 0x55d88, - 0x5f4c8, - 0x67f88, - 0x68209, - 0x6840a, - 0x6898c, - 0xea08a, - 0xf81c7, - 0x1684d, - 0xed84b, - 0x7a1cc, - 0x65910, - 0x1bc2, - 0xd65cd, - 0x3f02, - 0x7942, - 0xf810a, - 0xdefca, - 0xe79cb, - 0x592cc, - 0xffc8e, - 0x199fcd, - 0xf2f88, - 0x6c2, - 0x10b6778e, - 0x10c2e107, - 0x111ab089, - 0x129c3, - 0x1171b7cc, - 0xbac2, - 0x146151, - 0x1676d1, - 0x176fd1, - 0x131111, - 0x11b70f, - 0x11fdcc, - 0x124f4d, - 0x15c8cd, - 0x16da95, - 0xbacc, - 0x50b50, - 0x1091cc, - 0x10f6cc, - 0x4f2c9, - 0xbac2, - 0x14620e, - 0x16778e, - 0x17708e, - 0x1311ce, - 0x11b7cc, - 0x11fe89, - 0xbb89, - 0x50c0d, - 0x109289, - 0x10f789, - 0x158543, - 0x1892c3, - 0xbac2, - 0xd2d05, - 0x1ab7c4, - 0x135a04, - 0x181444, - 0x17e004, - 0x17a784, - 0x142d44, - 0x1424703, - 0x1416703, - 0xf2b84, - 0x8b02, - 0x199fc3, - 0x200882, - 0x206a82, - 0x200e42, - 0x209342, - 0x20f582, - 0x200fc2, - 0x202942, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c3, - 0x24c083, - 0x204703, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x24c083, - 0x204703, - 0x39f83, - 0x250cc3, - 0x200882, - 0x327883, - 0x14a2bf83, - 0x380d87, - 0x250cc3, - 0x39a883, - 0x211004, - 0x24c083, - 0x204703, - 0x24e9ca, - 0x25b1c5, - 0x21d603, - 0x2012c2, - 0x77a48, - 0x77a48, - 0x6a82, - 0x110842, - 0x1a0a85, - 0x77a48, - 0x2bf83, - 0xf2447, - 0xcd44f, - 0xfb984, - 0x172e4a, - 0xabcc7, - 0x18908a, - 0x18ed8a, - 0xfb906, - 0x8a4d, - 0x127883, - 0x77a48, - 0x6a82, - 0x48fc4, - 0x86d83, - 0xebf05, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x201e03, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x292f83, - 0x2232c3, - 0x201e03, - 0x223504, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22a543, - 0x22bf83, - 0x231b03, - 0x210c43, - 0x20f583, - 0x250cc3, - 0x2023c4, - 0x265603, - 0x232003, - 0x220ec3, - 0x24c083, - 0x204703, - 0x21d603, - 0x200a43, - 0x16e2bf83, - 0x231b03, - 0x245e83, - 0x250cc3, - 0x2805c3, - 0x232003, - 0x204703, - 0x208583, - 0x325ec4, - 0x77a48, - 0x1762bf83, - 0x231b03, - 0x2a54c3, - 0x250cc3, - 0x220ec3, - 0x211004, - 0x24c083, - 0x204703, - 0x220303, - 0x77a48, - 0x17e2bf83, - 0x231b03, - 0x20f583, - 0x2020c3, - 0x204703, - 0x77a48, - 0x142e107, - 0x327883, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x211004, - 0x24c083, - 0x204703, - 0x175d04, - 0x340dc5, - 0x77a48, - 0x742, - 0x33303, - 0x2cf588, - 0x23ca87, - 0x223504, - 0x366b06, - 0x36d946, - 0x77a48, - 0x23bd43, - 0x2e31c9, - 0x2b3f55, - 0xb3f5f, - 0x22bf83, - 0x334fd2, - 0x1011c6, - 0x13b685, - 0x17680a, - 0x58189, - 0x334d8f, - 0x2c8144, - 0x23c485, - 0x35d590, - 0x324507, - 0x2020c3, - 0x255bc8, - 0x2d2d8a, - 0x241204, - 0x2e0f83, - 0x25b1c6, - 0x2012c2, - 0x387d0b, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x2e8283, - 0x206a82, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x39a883, - 0x206f83, - 0x204703, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x24c083, - 0x204703, - 0x200882, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x223504, - 0x22bf83, - 0x231b03, - 0x30db04, - 0x24c083, - 0x204703, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x2037c3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2614c3, - 0x6ab03, - 0x19a883, - 0x24c083, - 0x204703, - 0x30464a, - 0x31c409, - 0x33e2cb, - 0x33e94a, - 0x349bca, - 0x356a0b, - 0x36f44a, - 0x37954a, - 0x37f58a, - 0x37f80b, - 0x39c709, - 0x39e40a, - 0x39e94b, - 0x3aab8b, - 0x3b0d4a, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x220ec3, - 0x24c083, - 0x204703, - 0x77a48, - 0x22bf83, - 0x2625c4, - 0x219242, - 0x211004, - 0x278b45, - 0x201e03, - 0x223504, - 0x22bf83, - 0x234a44, - 0x231b03, - 0x248fc4, - 0x2c8144, - 0x2023c4, - 0x232003, - 0x24c083, - 0x204703, - 0x297985, - 0x22a543, - 0x21d603, - 0x25ad03, - 0x2512c4, - 0x260e04, - 0x279645, - 0x77a48, + 0x230c43, + 0x219bc3, + 0x20f082, + 0x288883, + 0x249943, + 0x1602883, + 0x212b43, + 0x231583, + 0x22e043, + 0x2257c3, + 0x31c643, + 0x219683, + 0x236243, + 0x2f6783, + 0x2e6603, + 0x3b0845, + 0x244443, + 0x2e6643, + 0x2e7a03, + 0x20d3c4, + 0x259f83, + 0x35c0c3, + 0x275783, + 0x231a03, + 0x21ce42, + 0x2352c3, 0x2fa644, - 0x221c46, - 0x287e44, - 0x206a82, - 0x364707, - 0x24b847, - 0x246a04, - 0x2569c5, - 0x2e6285, - 0x2a8e05, - 0x2023c4, - 0x316208, - 0x2031c6, - 0x2e6ec8, - 0x23e385, - 0x2cff85, - 0x214984, - 0x204703, - 0x2e1c44, - 0x355bc6, - 0x25b2c3, - 0x2512c4, - 0x269bc5, - 0x233504, - 0x399e44, - 0x2012c2, - 0x24ec06, - 0x392506, - 0x2f6c05, + 0x2d8f44, + 0x23fc43, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x204a82, + 0x2257c3, + 0xb658403, + 0x2d9d43, + 0x219bc3, + 0x205842, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x6c2, + 0x2034c2, + 0x2240c2, + 0x894c8, + 0x4a82, + 0x232502, + 0x209082, + 0x239642, + 0x201142, + 0x20ba82, + 0x555c5, + 0x20d082, + 0x202542, + 0x202bc2, + 0x2019c2, + 0x200ac2, + 0x384f82, + 0x214202, + 0x22c942, + 0x11880d, + 0xe95c9, + 0x44f0b, + 0xd1308, + 0x182cc9, + 0x2d9d43, + 0x894c8, + 0x894c8, + 0x4dfc6, 0x200882, - 0x327883, - 0x1d606a82, - 0x233004, - 0x20f582, - 0x220ec3, - 0x20b602, - 0x24c083, + 0x224284, + 0x204a82, + 0x258403, + 0x201802, + 0x230743, + 0x2095c2, + 0x2afc84, + 0x202503, + 0x20a582, + 0x249943, + 0x2016c2, + 0x2257c3, + 0x23d1c6, + 0x30b94f, + 0x6ffb43, + 0x894c8, + 0x204a82, + 0x2095c3, + 0x2d9d43, + 0x219bc3, + 0x147448b, + 0x204a82, + 0x258403, + 0x2d9d43, + 0x249943, + 0x200882, + 0x207d42, + 0x209e42, + 0xea58403, + 0x239482, + 0x230743, + 0x244942, + 0x221b82, + 0x2d9d43, + 0x220442, + 0x301b82, + 0x242f42, + 0x204042, + 0x28b382, + 0x201b02, + 0x200902, + 0x206dc2, + 0x26b682, + 0x213f02, + 0x2ad182, + 0x236bc2, + 0x2c8302, + 0x255582, + 0x219bc3, + 0x208f82, + 0x249943, + 0x23d982, + 0x26e742, + 0x2257c3, + 0x245482, + 0x2057c2, + 0x205202, 0x200fc2, - 0x20b803, - 0x2232c3, - 0x77a48, - 0x77a48, - 0x250cc3, + 0x20acc2, + 0x2d1e82, + 0x214882, + 0x23e2c2, + 0x2267c2, + 0x301bca, + 0x344c4a, + 0x37ca0a, + 0x3b3682, + 0x20d042, + 0x23d3c2, + 0xef46cc9, + 0xf3a490a, + 0xf58fb47, + 0xad82, + 0x1a490a, + 0x2054c4, + 0xfe58403, + 0x230743, + 0x2446c4, + 0x2d9d43, + 0x201104, + 0x202503, + 0x219bc3, + 0x249943, + 0x202883, + 0x2257c3, + 0x244443, + 0x224043, + 0x894c8, + 0x1454344, + 0x53bc5, + 0x51eca, + 0x107c82, + 0x17bac6, + 0x153811, + 0x10746cc9, + 0x153c47, + 0x3442, + 0x1ac98a, + 0xd9547, + 0x894c8, + 0xfea08, + 0xdac7, + 0x1181918b, + 0x1a382, + 0xee987, + 0x574a, + 0x11030f, + 0x6308f, + 0x19fc2, + 0x4a82, + 0x9f9c8, + 0xe8d0a, + 0x63608, + 0x1842, + 0x11008f, + 0x128a0b, + 0x1702c8, + 0x7a287, + 0xd964a, + 0x574cb, + 0x10d109, + 0x1701c7, + 0xf25cc, + 0x11cac7, + 0xcfd0a, + 0x132948, + 0xef6ce, + 0x4ee8e, + 0xd938b, + 0x11e14b, + 0xe930b, + 0x1f189, + 0x2158b, + 0x23b0d, + 0x29c4b, + 0x2c38d, + 0x57b8d, + 0x7d04a, + 0xd8d8b, + 0xe5e4b, + 0x177ac5, + 0x108b50, + 0x15428f, + 0xf584f, + 0xec4d, + 0x71d50, + 0x79c2, + 0x11fa9188, + 0x62e88, + 0x122e0d05, + 0x4360b, + 0x4a748, + 0x11e30a, + 0x56c09, + 0x5e5c7, + 0x5e907, + 0x5eac7, + 0x5f107, + 0x5fb07, + 0x60407, + 0x60e87, + 0x65807, + 0x66007, + 0x661c7, + 0x66c47, + 0x66e07, + 0x66fc7, + 0x67187, + 0x67487, + 0x678c7, + 0x68e87, + 0x69547, + 0x69d07, + 0x6a707, + 0x6a8c7, + 0x6aec7, + 0x6b2c7, + 0x6b4c7, + 0x6b787, + 0x6b947, + 0x6bb07, + 0x6c6c7, + 0x6cf87, + 0x6da47, + 0x6e147, + 0x6e407, + 0x6ea47, + 0x6ec07, + 0x6ef87, + 0x6fdc7, + 0x70047, + 0x70447, + 0x70fc7, + 0x71187, + 0x715c7, + 0x72307, + 0x72607, + 0x72c07, + 0x72dc7, + 0x73147, + 0x73587, + 0xcbc2, + 0x3f34a, + 0xf6a07, + 0x124c8f0b, + 0x14c8f16, + 0x15c11, + 0xdce8a, + 0x9f84a, + 0x4dfc6, + 0x18df4b, + 0x1a042, + 0x187c51, + 0x97149, + 0x90ec9, + 0x6dc2, + 0x9d6ca, + 0xa3609, + 0xa3d0f, + 0xa4e8e, + 0xa5ec8, + 0xd4c2, + 0x742c9, + 0x8628e, + 0xabdcc, + 0xd328f, + 0x19510e, + 0xdf8c, + 0x13349, + 0x14f51, + 0x24dc8, + 0x2d892, + 0xc7fcd, + 0x1a638d, + 0x34ecb, + 0x3e755, + 0x3f209, + 0x41d8a, + 0x4fb49, + 0x56510, + 0x6c40b, + 0x7708f, + 0x7804b, + 0x7d90c, + 0x7e650, + 0x87f0a, + 0x8874d, + 0x1459ce, + 0x17480a, + 0x8d54c, + 0x93354, + 0x96dd1, + 0x9b64b, + 0x9c8cf, + 0xa9f4d, + 0xab74e, + 0x157a4c, + 0xebecc, + 0x15774b, + 0xe518e, + 0xf9050, + 0x12c8cb, + 0x168e8d, + 0xb3d4f, + 0xb55cc, + 0xb908e, + 0xb9891, + 0xbb70c, + 0x11aa87, + 0xc18cd, + 0xc2b4c, + 0xd2a90, + 0xe330d, + 0x1361c7, + 0xeced0, + 0xf1848, + 0x11f00b, + 0x16fe4f, + 0x295c8, + 0xdd08d, + 0x181490, + 0xaf303, + 0xa482, + 0x57f89, + 0x4ec8a, + 0xfa686, + 0x128d4609, + 0x15683, + 0x108351, + 0x153489, + 0xcdc07, + 0x11018b, + 0xd21d0, + 0xd268c, + 0xd3a85, + 0x1195c8, + 0x19c30a, + 0x126b87, + 0x1a82, + 0x54cca, + 0xf5b89, + 0x32f4a, + 0x19ea0f, + 0x3bdcb, + 0x11068c, + 0x110952, + 0xadac5, + 0x15e60a, + 0x12edf6c5, + 0x114203, + 0x184f82, + 0xe6e4a, + 0x156288, + 0x190c87, + 0x3b82, + 0xb482, + 0x3182, + 0x183e90, + 0x3e42, + 0x1a5c4f, + 0x7e246, + 0x11e78e, + 0xd5e0b, + 0x174a08, + 0xca189, + 0x17a092, + 0x3e4d, + 0x42b08, + 0x44dc9, + 0x4594d, + 0x47289, + 0x48a8b, + 0x49388, + 0x51d08, + 0x55c88, + 0x55f09, + 0x5610a, + 0x5dc4c, + 0xe6bca, + 0xf67c7, + 0x10ecd, + 0xea20b, + 0x74acc, + 0x5f350, + 0x35c2, + 0x16974d, + 0x3d02, + 0x2c02, + 0xf670a, + 0xdcd8a, + 0xe428b, + 0xe600c, + 0xfe78e, + 0x18cc0d, + 0xea948, + 0x6c2, + 0x10b2a68e, + 0x10d8fb47, + 0x1118fb49, + 0x10083, + 0x1171214c, + 0xad82, + 0x537d1, + 0x12a5d1, + 0x140851, + 0x165e51, + 0x11208f, + 0x11eacc, + 0x12478d, + 0x14824d, + 0x159a55, + 0xad8c, + 0x191050, + 0x106d0c, + 0x10c84c, + 0x4a509, + 0xad82, + 0x5388e, + 0x12a68e, + 0x14090e, + 0x165f0e, + 0x11214c, + 0x11eb89, + 0xae49, + 0x159c4d, + 0x106dc9, + 0x10c909, + 0x133803, + 0x95843, + 0xad82, + 0x153805, + 0x1ac984, + 0x28c84, + 0xe7e44, + 0x17b4c4, + 0xff504, + 0x153c44, + 0x141d2c3, + 0x1410d83, + 0xfe444, + 0x79c2, + 0x18cc03, 0x200882, - 0x1e206a82, - 0x250cc3, - 0x26a783, - 0x265603, - 0x31d184, - 0x24c083, - 0x204703, - 0x77a48, + 0x204a82, + 0x201802, + 0x20bc82, + 0x2095c2, + 0x2016c2, + 0x203182, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201103, + 0x249943, + 0x2257c3, + 0x894c8, + 0x258403, + 0x230743, + 0x249943, + 0x2257c3, + 0x4fc3, + 0x2d9d43, 0x200882, - 0x1ea06a82, - 0x22bf83, - 0x24c083, - 0x204703, - 0x20f042, - 0x212dc2, - 0x39a883, - 0x2d9f83, + 0x323743, + 0x14a58403, + 0x37e0c7, + 0x2d9d43, + 0x332283, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x24388a, + 0x23d1c5, + 0x219683, + 0x201582, + 0x894c8, + 0x894c8, + 0x4a82, + 0x10e102, + 0xeeac5, + 0x894c8, + 0x58403, + 0xefa47, + 0xc678f, + 0xfa704, + 0x10d28a, + 0xaba07, + 0x9560a, + 0x18e3ca, + 0xfa686, + 0x790d, + 0x123743, + 0x894c8, + 0x4a82, + 0x446c4, + 0x68ac3, + 0xe82c5, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x203803, + 0x258403, + 0x230743, + 0x2095c3, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x291083, + 0x224043, + 0x203803, + 0x224284, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x22f903, + 0x258403, + 0x230743, + 0x20e8c3, + 0x2095c3, + 0x2d9d43, + 0x201104, + 0x265743, + 0x230c43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x219683, + 0x200a43, + 0x16e58403, + 0x230743, + 0x241583, + 0x2d9d43, + 0x27da43, + 0x230c43, + 0x2257c3, + 0x207443, + 0x3284c4, + 0x894c8, + 0x17658403, + 0x230743, + 0x2a5f83, + 0x2d9d43, + 0x219bc3, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x21ba43, + 0x894c8, + 0x17e58403, + 0x230743, + 0x2095c3, + 0x202883, + 0x2257c3, + 0x894c8, + 0x158fb47, + 0x323743, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x2021c4, + 0x249943, + 0x2257c3, + 0xfbfc4, + 0x329345, + 0x894c8, + 0x742, + 0x31f43, + 0x355b88, + 0x241047, + 0x224284, + 0x352ac6, + 0x359906, + 0x894c8, + 0x240303, + 0x2f5249, + 0x2b33d5, + 0xb33df, + 0x258403, + 0x331dd2, + 0xff686, + 0x138e05, + 0x11e30a, + 0x56c09, + 0x331b8f, + 0x2afc84, + 0x240a45, + 0x35f990, + 0x3ad107, + 0x202883, + 0x251b48, + 0x2db58a, + 0x23b9c4, + 0x2df103, + 0x23d1c6, + 0x201582, + 0x385c4b, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x2e4b43, + 0x204a82, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x332283, + 0x208f83, + 0x2257c3, + 0x204a82, + 0x258403, + 0x230743, + 0x249943, + 0x2257c3, 0x200882, - 0x77a48, - 0x206a82, - 0x231b03, - 0x248fc4, - 0x209d03, - 0x250cc3, - 0x2037c3, - 0x220ec3, - 0x24c083, - 0x21a883, - 0x204703, - 0x220283, - 0x125513, - 0x134914, - 0x145c6, - 0x1c106, - 0x514c7, - 0x7a709, - 0x141c0a, - 0x896cd, - 0x11790c, - 0x17ef0a, - 0x62145, - 0x16d408, - 0x72606, - 0x122706, - 0x208b02, - 0x1ab987, - 0x22bf83, - 0xd0a85, - 0x1bb06, - 0x8d1ca, - 0xacf83, - 0x7a6c5, - 0xd003, - 0x18e9cc, - 0x1ade48, - 0x13f348, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x224284, + 0x258403, + 0x230743, + 0x30ac84, + 0x249943, + 0x2257c3, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2095c3, + 0x21bbc3, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x204a82, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x254943, + 0x672c3, + 0x132283, + 0x249943, + 0x2257c3, + 0x301bca, + 0x31f6c9, + 0x33c04b, + 0x33c9ca, + 0x344c4a, + 0x351b4b, + 0x36ebca, + 0x375c0a, + 0x37ca0a, + 0x37cc8b, + 0x39c049, + 0x39de8a, + 0x39e3cb, + 0x3ab84b, + 0x3b1f4a, + 0x258403, + 0x230743, + 0x2095c3, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x894c8, + 0x258403, + 0x25e5c4, + 0x213142, + 0x2021c4, + 0x275685, + 0x203803, + 0x224284, + 0x258403, + 0x232ec4, + 0x230743, + 0x2446c4, + 0x2afc84, + 0x201104, + 0x230c43, + 0x249943, + 0x2257c3, + 0x293485, + 0x22f903, + 0x219683, + 0x25a383, + 0x24ccc4, + 0x254284, + 0x273f45, + 0x894c8, + 0x2f8cc4, + 0x21e046, + 0x285844, + 0x204a82, + 0x3614c7, + 0x246c47, + 0x242244, + 0x255745, + 0x2e3505, + 0x2a8f85, + 0x201104, + 0x316e08, + 0x362906, + 0x2e1a08, + 0x2386c5, + 0x2cf185, + 0x21a5c4, + 0x2257c3, + 0x2dfdc4, + 0x350d06, + 0x23d2c3, + 0x24ccc4, + 0x26be05, + 0x232144, + 0x38ca84, + 0x201582, + 0x24d2c6, + 0x3924c6, + 0x2f3dc5, 0x200882, - 0x206a82, - 0x250cc3, - 0x20b542, - 0x24c083, - 0x204703, - 0x20b803, - 0x362fcf, - 0x36338e, - 0x77a48, - 0x22bf83, - 0x43f87, - 0x231b03, - 0x250cc3, - 0x202243, - 0x24c083, - 0x204703, - 0x21fc03, - 0x264fc7, + 0x323743, + 0x1d604a82, + 0x231c44, + 0x2095c2, + 0x219bc3, + 0x22c902, + 0x249943, + 0x2016c2, + 0x2161c3, + 0x224043, + 0x894c8, + 0x894c8, + 0x2d9d43, + 0x200882, + 0x1e204a82, + 0x2d9d43, + 0x266f43, + 0x265743, + 0x320444, + 0x249943, + 0x2257c3, + 0x894c8, + 0x200882, + 0x1ea04a82, + 0x258403, + 0x249943, + 0x2257c3, + 0x201382, + 0x21ce42, + 0x332283, + 0x2d8843, + 0x200882, + 0x894c8, + 0x204a82, + 0x230743, + 0x2446c4, + 0x2099c3, + 0x2d9d43, + 0x21bbc3, + 0x219bc3, + 0x249943, + 0x2174c3, + 0x2257c3, + 0x21b9c3, + 0x127b13, + 0x131714, + 0x1a206, + 0x1f186, + 0x4cec7, + 0x75009, + 0x6208a, + 0x8740d, + 0x11850c, + 0x17c3ca, + 0x555c5, + 0x18c288, + 0x7e246, + 0x152dc6, + 0x2079c2, + 0x1739cc, + 0x1acb47, + 0x205d1, + 0x258403, + 0xcfc85, + 0xb444, + 0x15c06, + 0x8f1c6, + 0x8b64a, + 0xaccc3, + 0x74fc5, + 0xb983, + 0x18e00c, + 0x1af108, + 0x27bc8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x200882, + 0x204a82, + 0x2d9d43, + 0x20b9c2, + 0x249943, + 0x2257c3, + 0x2161c3, + 0x35fd8f, + 0x36014e, + 0x894c8, + 0x258403, + 0x3df47, + 0x230743, + 0x2d9d43, + 0x202503, + 0x249943, + 0x2257c3, + 0x21b943, + 0x265107, + 0x203642, + 0x29ffc9, + 0x200dc2, + 0x38418b, + 0x28ff8a, + 0x291709, 0x201c42, - 0x291d49, - 0x200ec2, - 0x3a7d0b, - 0x28b2ca, - 0x28cc09, - 0x200d82, - 0x261046, - 0x254b15, - 0x3a7e55, - 0x257393, - 0x3a83d3, - 0x204a42, - 0x20c905, - 0x32178c, - 0x21b24b, - 0x2543c5, - 0x20b0c2, - 0x287302, - 0x3747c6, - 0x201e02, - 0x25f986, - 0x34be4d, - 0x36fe4c, - 0x30b584, + 0x2544c6, + 0x250a95, + 0x3842d5, + 0x25fdd3, + 0x384853, + 0x204602, + 0x204ec5, + 0x31d3cc, + 0x22518b, + 0x26dd85, + 0x20e3c2, + 0x284d02, + 0x372c06, + 0x203442, + 0x2521c6, + 0x332acd, + 0x36458c, + 0x308bc4, 0x2009c2, - 0x209ec2, - 0x33aec8, - 0x204a02, - 0x32f986, - 0x2d2944, - 0x254cd5, - 0x257513, - 0x212903, - 0x34b6ca, - 0x35af47, - 0x2e7c09, - 0x229087, - 0x305b42, + 0x21fd82, + 0x22dc48, + 0x203402, + 0x30e986, + 0x2aebc4, + 0x250c55, + 0x25ff53, + 0x20ffc3, + 0x34634a, + 0x31c387, + 0x2e44c9, + 0x226fc7, + 0x252f42, 0x200002, 0x200006, - 0x206e82, - 0x77a48, - 0x212742, - 0x212bc2, - 0x3994c7, - 0x35bac7, - 0x21f085, - 0x203482, - 0x220247, - 0x220408, - 0x23a242, - 0x2715c2, - 0x22ce42, - 0x201482, - 0x300cc8, - 0x21a903, - 0x286f48, - 0x2c77cd, - 0x214683, - 0x2e3f48, - 0x23218f, - 0x23254e, - 0x22338a, - 0x299e51, - 0x29a2d0, - 0x2b2d0d, - 0x2b304c, - 0x20e607, - 0x34b847, - 0x366bc9, - 0x245bc2, + 0x208e82, + 0x894c8, + 0x20fe02, + 0x210842, + 0x399887, + 0x3aaa47, + 0x21a805, + 0x21a382, + 0x21b987, + 0x21bb48, + 0x235842, + 0x295682, + 0x22e142, + 0x201742, + 0x36d148, + 0x217543, + 0x268c88, + 0x2c780d, + 0x21a2c3, + 0x2f5fc8, + 0x230dcf, + 0x23118e, + 0x22410a, + 0x2a1591, + 0x2a1a10, + 0x2b218d, + 0x2b24cc, + 0x20bd07, + 0x3464c7, + 0x352b89, + 0x23d442, 0x2004c2, - 0x252ecc, - 0x2531cb, + 0x24e74c, + 0x24ea4b, 0x2008c2, - 0x2dcb06, - 0x2092c2, - 0x2036c2, - 0x21eb82, - 0x206a82, - 0x3929c4, + 0x357906, + 0x205742, + 0x211a82, + 0x219fc2, + 0x204a82, + 0x381f44, + 0x235b47, + 0x207802, 0x23a547, - 0x208942, - 0x23fac7, - 0x241007, - 0x217442, - 0x20e542, - 0x243e45, + 0x23b7c7, + 0x212182, + 0x206082, + 0x23de05, 0x200682, - 0x26794e, - 0x27d94d, - 0x231b03, - 0x377f8e, - 0x2dc3cd, - 0x229343, - 0x203982, - 0x209f44, - 0x245b82, - 0x201502, - 0x34a4c5, - 0x351ac7, - 0x36ed02, - 0x209342, - 0x248847, - 0x24d248, - 0x23d6c2, - 0x2ade06, - 0x252d4c, - 0x25308b, - 0x20db02, - 0x25c18f, - 0x25c550, - 0x25c94f, - 0x25cd15, - 0x25d254, - 0x25d74e, - 0x25dace, - 0x25de4f, - 0x25e20e, - 0x25e594, - 0x25ea93, - 0x25ef4d, - 0x2781c9, - 0x28a283, + 0x260fce, + 0x278b4d, + 0x230743, + 0x2842ce, + 0x3571cd, + 0x227283, + 0x204802, + 0x281b44, + 0x23fac2, + 0x2017c2, + 0x345485, + 0x34cb87, + 0x36e142, + 0x20bc82, + 0x243f47, + 0x247ec8, + 0x237842, + 0x2adb46, + 0x24e5cc, + 0x24e90b, + 0x205642, + 0x25a90f, + 0x25acd0, + 0x25b0cf, + 0x25b495, + 0x25b9d4, + 0x25bece, + 0x25c24e, + 0x25c5cf, + 0x25c98e, + 0x25cd14, + 0x25d213, + 0x25d6cd, + 0x273749, + 0x288603, 0x2007c2, - 0x31a605, - 0x209d06, - 0x20f582, - 0x270387, - 0x250cc3, - 0x210702, - 0x235e48, - 0x29a091, - 0x29a4d0, + 0x31b245, + 0x2099c6, + 0x2095c2, + 0x26d887, + 0x2d9d43, + 0x21a042, + 0x22cc08, + 0x2a17d1, + 0x2a1c10, 0x200942, - 0x21e747, - 0x203fc2, - 0x2cec87, - 0x20ac82, - 0x2cf389, - 0x374787, - 0x34aec8, - 0x2261c6, - 0x2d9e83, - 0x322945, - 0x231d82, + 0x20f047, + 0x203dc2, + 0x30f787, + 0x20a482, + 0x24b949, + 0x372bc7, + 0x285b08, + 0x222446, + 0x261e43, + 0x261e45, + 0x22fdc2, 0x200402, 0x200405, - 0x22aa05, - 0x200f02, - 0x233583, - 0x233587, - 0x200f07, - 0x2013c2, - 0x301344, - 0x2025c3, - 0x2bfb89, - 0x2da648, - 0x217382, - 0x203702, - 0x222047, - 0x224605, - 0x2a4248, - 0x20c5c7, - 0x201dc3, - 0x2a1b86, - 0x2b2b8d, - 0x2b2f0c, - 0x27e146, - 0x207082, - 0x206a42, - 0x20f842, - 0x23200f, - 0x23240e, - 0x2e6307, + 0x22b385, + 0x20a902, + 0x2280c3, + 0x2321c7, + 0x3a3f87, + 0x201302, + 0x2ff804, + 0x23e383, + 0x2bfc09, + 0x2d9208, + 0x2120c2, + 0x2067c2, + 0x2164c7, + 0x21d1c5, + 0x2a4008, + 0x204b87, + 0x2037c3, + 0x2a1246, + 0x2b200d, + 0x2b238c, + 0x279346, + 0x209082, + 0x208a42, + 0x202242, + 0x230c4f, + 0x23104e, + 0x2e3587, 0x200342, - 0x30a2c5, - 0x30a2c6, - 0x250702, - 0x202ac2, - 0x215346, - 0x291f83, - 0x2cebc6, - 0x2c1105, - 0x2c110d, - 0x2c1c55, - 0x2c240c, - 0x2c2c0d, - 0x2c32d2, - 0x203642, - 0x208b82, - 0x201842, - 0x2e4f06, - 0x2abf46, - 0x201042, - 0x209d86, - 0x207902, - 0x223d85, - 0x203202, - 0x267a89, - 0x27074c, - 0x270a8b, - 0x200fc2, - 0x24d688, - 0x20cb42, - 0x209242, - 0x21b006, - 0x3683c5, - 0x21c307, - 0x253b45, - 0x299cc5, - 0x244002, - 0x322882, + 0x309445, + 0x309446, + 0x253702, + 0x208f82, + 0x212946, + 0x2a0203, + 0x30f6c6, + 0x2c1285, + 0x2c128d, + 0x2c1dd5, + 0x2c258c, + 0x2c330d, + 0x2c39d2, + 0x20dc02, + 0x207a42, + 0x201082, + 0x2e0986, + 0x2abc86, + 0x201a82, + 0x209a46, + 0x202bc2, + 0x21ff85, + 0x203c42, + 0x261109, + 0x33d40c, + 0x33d74b, + 0x2016c2, + 0x248308, + 0x201342, + 0x200d82, + 0x224f46, + 0x366b45, + 0x21f387, + 0x247485, + 0x2a1405, + 0x23dfc2, + 0x352f42, 0x200ac2, - 0x27c187, - 0x2d0e4d, - 0x2d11cc, - 0x275587, - 0x20b142, - 0x224742, - 0x242988, - 0x22bc88, - 0x2d57c8, - 0x2df284, - 0x2e8cc7, - 0x2db883, - 0x2aff02, - 0x20d102, - 0x2dfa09, - 0x3a4507, - 0x208582, - 0x273cc5, - 0x242242, - 0x22e1c2, - 0x27b6c3, - 0x27b6c6, - 0x2e8282, - 0x2e98c2, - 0x200d42, - 0x30c286, - 0x209e87, - 0x201442, - 0x203942, - 0x286d8f, - 0x377dcd, - 0x35914e, - 0x2dc24c, - 0x204742, + 0x277387, + 0x2d004d, + 0x2d03cc, + 0x234107, + 0x2adac2, + 0x21d302, + 0x22be08, + 0x258108, + 0x2d4148, + 0x2dd044, + 0x2e5407, + 0x2da3c3, + 0x2aed82, + 0x2137c2, + 0x2dd809, + 0x3a3107, 0x205fc2, - 0x226005, - 0x3b1146, - 0x214442, - 0x201002, - 0x2034c2, - 0x20c544, - 0x2c7644, - 0x338546, - 0x202942, - 0x27c9c7, - 0x224d83, - 0x226708, - 0x228048, - 0x32ba07, - 0x22ed46, - 0x202742, - 0x238f03, - 0x23ce07, - 0x26e186, - 0x2e4e45, - 0x3497c8, - 0x209642, - 0x321e87, - 0x20b702, - 0x2eab42, - 0x204002, - 0x2df7c9, + 0x26f0c5, + 0x23c782, + 0x2768c2, + 0x2768c3, + 0x2768c6, + 0x2e4b42, + 0x2e63c2, + 0x2018c2, + 0x33e186, + 0x30f047, + 0x201702, + 0x2058c2, + 0x268acf, + 0x28410d, + 0x28668e, + 0x35704c, + 0x20cb82, + 0x2024c2, + 0x222285, + 0x3b2346, + 0x2135c2, + 0x20b942, + 0x203b82, + 0x204b04, + 0x2c7684, + 0x336d86, + 0x203182, + 0x277bc7, + 0x220a83, + 0x222988, + 0x2244c8, + 0x2c7e47, + 0x3a5fc6, + 0x21b842, + 0x234503, + 0x2413c7, + 0x2693c6, + 0x2e08c5, + 0x344808, + 0x2063c2, + 0x322587, + 0x210ec2, + 0x2e74c2, + 0x203e02, + 0x2bab89, 0x200242, 0x200a02, - 0x275803, - 0x3a0007, - 0x201f02, - 0x2708cc, - 0x270bcb, - 0x27e1c6, - 0x20cf45, - 0x21c642, - 0x205702, - 0x2b2886, - 0x26ba43, - 0x357a07, - 0x249842, - 0x205a02, - 0x254995, - 0x3a8015, - 0x257253, - 0x3a8553, - 0x269cc7, - 0x277c08, - 0x277c10, - 0x278c4f, - 0x28b093, - 0x28c9d2, - 0x291910, - 0x2a248f, - 0x2a8992, - 0x2fcb11, - 0x2f4bd3, - 0x353a92, - 0x320a0f, - 0x2bb04e, - 0x2c0c92, - 0x2c8f51, - 0x2cb48f, - 0x2cc20e, - 0x2cd9d1, - 0x2fbb90, - 0x2db252, - 0x2df5d1, - 0x2e5346, - 0x2e6b07, - 0x2f9347, - 0x202c42, - 0x281b85, - 0x3471c7, - 0x212dc2, - 0x206d02, - 0x229585, - 0x2212c3, - 0x2798c6, - 0x2d100d, - 0x2d134c, - 0x201242, - 0x32160b, - 0x21b10a, - 0x2eae8a, - 0x2b1649, - 0x2dde0b, - 0x20c70d, - 0x362b4c, - 0x224f0a, - 0x22a18c, - 0x24470b, - 0x33bc8c, - 0x25424b, - 0x2706c3, - 0x277806, - 0x2ce482, - 0x2ea342, - 0x221f83, - 0x204102, - 0x204c03, - 0x2562c6, - 0x25cec7, - 0x26d686, - 0x2ecb08, - 0x22b988, - 0x2f3906, - 0x20c402, - 0x2f65cd, - 0x2f690c, - 0x2c8207, - 0x2fa507, - 0x214602, - 0x2342c2, - 0x23cd82, - 0x266dc2, - 0x206a82, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x211004, - 0x24c083, - 0x204703, - 0x20b803, + 0x234383, + 0x32a387, + 0x2013c2, + 0x33d58c, + 0x33d88b, + 0x2793c6, + 0x20b8c5, + 0x21f6c2, + 0x2020c2, + 0x2b1d06, + 0x22aa83, + 0x33f547, + 0x242c82, + 0x206882, + 0x250915, + 0x384495, + 0x25fc93, + 0x3849d3, + 0x26bf07, + 0x289688, + 0x289690, + 0x28af0f, + 0x28fd53, + 0x2914d2, + 0x29fb90, + 0x2a8bcf, + 0x336352, + 0x31f291, + 0x34ed13, + 0x2ba952, + 0x2c0ecf, + 0x2c944e, + 0x2cba12, + 0x2cc851, + 0x2cd84f, + 0x2ce5ce, + 0x2fa911, + 0x2d9e10, + 0x2dd392, + 0x2e1dd1, + 0x2e25c6, + 0x2e4bc7, + 0x2f7947, + 0x205542, + 0x27f985, + 0x35a847, + 0x21ce42, + 0x208d02, + 0x228f05, + 0x21c743, + 0x2741c6, + 0x2d020d, + 0x2d054c, + 0x201502, + 0x31d24b, + 0x22504a, + 0x2eaf4a, + 0x2b0fc9, + 0x2dbe4b, + 0x204ccd, + 0x36cb8c, + 0x21ce8a, + 0x220c0c, + 0x33940b, + 0x26dbcc, + 0x270c0b, + 0x33d383, + 0x289286, + 0x2e7a82, + 0x2e7242, + 0x21e383, + 0x203f02, + 0x2047c3, + 0x2498c6, + 0x25b647, + 0x273406, + 0x2e8ec8, + 0x257e08, + 0x2f0646, + 0x2049c2, + 0x2f378d, + 0x2f3acc, + 0x2afd47, + 0x2f8b87, + 0x20c702, + 0x236e02, + 0x241342, + 0x32bd42, + 0x204a82, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x2161c3, 0x200882, 0x200702, - 0x21a8f085, - 0x21e07f05, - 0x2230bf46, - 0x77a48, - 0x226ae4c5, - 0x206a82, - 0x200e42, - 0x22b41485, - 0x22e80385, - 0x23281247, - 0x23615009, - 0x23a58804, - 0x20f582, - 0x210702, - 0x23f6ed45, - 0x24291589, - 0x24772b48, - 0x24aac5c5, - 0x24ebf307, - 0x2521f7c8, - 0x256d8045, - 0x25a01c06, - 0x25e71249, - 0x263ac248, - 0x266b9dc8, - 0x26a981ca, - 0x26e4a044, - 0x272c96c5, - 0x276b5708, - 0x27a6b485, - 0x21a982, + 0x21a8d2c5, + 0x21e031c5, + 0x22309946, + 0x894c8, + 0x226ae205, + 0x204a82, + 0x201802, + 0x22b27605, + 0x22e7d805, + 0x2327ea47, + 0x23612609, + 0x23a57284, + 0x2095c2, + 0x21a042, + 0x23f808c5, + 0x2428f9c9, + 0x2470cf88, + 0x24aac305, + 0x24ebf387, + 0x25217788, + 0x256d6205, + 0x25a03606, + 0x25ed7ac9, + 0x26373f08, + 0x266b96c8, + 0x26a97d0a, + 0x26e457c4, + 0x272c9b05, + 0x276b4c88, + 0x27a67a05, + 0x2175c2, 0x27e00343, - 0x282a14c6, - 0x28645248, - 0x28a067c6, - 0x28ece688, - 0x29321ac6, - 0x29731b84, - 0x202b42, - 0x29a3bf07, - 0x29ea6f84, - 0x2a27bc47, - 0x2a713c87, - 0x200fc2, - 0x2aa98f45, - 0x2af24244, - 0x2b2fc647, - 0x2b623747, - 0x2ba85546, - 0x2be5b885, - 0x2c293d47, - 0x2c6d5388, - 0x2cb1a987, - 0x2cf6ab09, - 0x2d38e705, - 0x2d75e547, - 0x2da8e7c6, - 0x2de61248, - 0x33a60d, - 0x244189, - 0x2e430b, - 0x24b38b, - 0x275c0b, - 0x2a3a4b, - 0x30220b, - 0x3024cb, - 0x302d49, - 0x3048cb, - 0x304b8b, - 0x3053cb, - 0x305eca, - 0x30640a, - 0x306a0c, - 0x309b0b, - 0x30a44a, - 0x3199ca, - 0x32aa8e, - 0x32dace, - 0x32de4a, - 0x33188a, - 0x3323cb, - 0x33268b, - 0x33320b, - 0x34e64b, - 0x34ec4a, - 0x34f90b, - 0x34fbca, - 0x34fe4a, - 0x3500ca, - 0x37110b, - 0x37a88b, - 0x37c1ce, - 0x37c54b, - 0x38618b, - 0x3874cb, - 0x38ad4a, - 0x38afc9, - 0x38b20a, - 0x38c88a, - 0x39d0cb, - 0x39ec0b, - 0x39fa8a, - 0x3a120b, - 0x3a728b, - 0x3b078b, - 0x2e283308, - 0x2e688e49, - 0x2eb61e09, - 0x2eed0348, - 0x3382c5, - 0x207503, - 0x202d44, - 0x3996c5, - 0x258546, - 0x266545, - 0x288644, - 0x270288, - 0x218d45, - 0x290444, - 0x205c87, - 0x29c18a, - 0x3411ca, - 0x387307, - 0x2078c7, - 0x2f47c7, - 0x327dc7, - 0x2b6085, - 0x323d06, - 0x33f687, - 0x26dcc4, - 0x320686, - 0x3a6bc6, - 0x2017c5, - 0x24fa04, - 0x2c0406, - 0x29b587, - 0x32c646, - 0x305107, - 0x27f203, - 0x24e386, - 0x230705, - 0x281347, - 0x2bda0a, - 0x235f44, - 0x21b888, - 0x2eb949, - 0x2d1b07, - 0x330c06, - 0x327b88, - 0x314009, - 0x2396c4, - 0x3619c4, - 0x2fb3c5, - 0x210f08, - 0x2be207, - 0x2a9209, - 0x231548, - 0x2feb46, - 0x243586, - 0x2965c8, - 0x3739c6, - 0x207f05, - 0x285606, - 0x27c348, - 0x231f06, - 0x251f0b, - 0x2343c6, - 0x297d4d, - 0x3a26c5, - 0x2a6e46, - 0x2065c5, - 0x29ae89, - 0x32a347, - 0x3825c8, - 0x2d5046, - 0x296cc9, - 0x3a0486, - 0x2bd985, - 0x237446, - 0x2a8406, - 0x2c47c9, - 0x2394c6, - 0x248547, - 0x2d9045, - 0x203203, - 0x252085, - 0x298007, - 0x327706, - 0x3a25c9, - 0x30bf46, - 0x285846, - 0x205149, - 0x285009, - 0x29f347, - 0x322b08, - 0x28dc89, - 0x281808, - 0x31ce86, - 0x2cc985, - 0x30b24a, - 0x2858c6, - 0x380c06, - 0x2a1685, - 0x3843c8, - 0x2109c7, - 0x22f98a, - 0x249406, - 0x2f9a85, - 0x330e86, - 0x263ec7, - 0x330ac7, - 0x2ef245, - 0x2bdb45, - 0x29f6c6, - 0x2ad006, - 0x383a06, - 0x333b84, - 0x2840c9, - 0x289d06, - 0x35104a, - 0x21a588, - 0x35e248, - 0x3411ca, - 0x3a3505, - 0x29b4c5, - 0x385b88, - 0x2c9448, - 0x36d747, - 0x211206, - 0x312e08, - 0x2e4947, - 0x2837c8, - 0x36a5c6, - 0x286148, - 0x2b3406, - 0x23e507, - 0x297706, - 0x2c0406, - 0x233bca, - 0x392a46, - 0x2cc989, - 0x2ae7c6, - 0x2d224a, - 0x331b89, - 0x2f3a06, - 0x37ac04, - 0x31a6cd, - 0x2890c7, - 0x3157c6, - 0x2b9c85, - 0x3a0505, - 0x31abc6, - 0x274209, - 0x2b1c47, - 0x27d406, - 0x2cd2c6, - 0x2886c9, - 0x2bf4c4, - 0x22c784, - 0x2073c8, - 0x256686, - 0x273d88, - 0x2373c8, - 0x282fc7, - 0x200849, - 0x383c07, - 0x2ae38a, - 0x236d8f, - 0x2463ca, - 0x225e05, - 0x27c585, - 0x21ac05, - 0x2d2887, - 0x20e243, - 0x322d08, - 0x2f7206, - 0x2f7309, - 0x2b0106, - 0x2c3107, - 0x296a89, - 0x3824c8, - 0x2a1747, - 0x3015c3, - 0x338345, - 0x20e1c5, - 0x3339cb, - 0x26b544, - 0x2d5f04, - 0x27af06, - 0x301947, - 0x397d8a, - 0x246c47, - 0x239747, - 0x280385, - 0x2043c5, - 0x2181c9, - 0x2c0406, - 0x246acd, - 0x359c85, - 0x302803, - 0x2102c3, - 0x30c385, - 0x352545, - 0x327b88, - 0x27de47, - 0x22c506, - 0x29cf86, - 0x229cc5, - 0x231dc7, - 0x207b47, - 0x203087, - 0x2c974a, - 0x24e448, - 0x333b84, - 0x383fc7, - 0x27f347, - 0x332046, - 0x269307, - 0x2b2288, - 0x361d08, - 0x26fd46, - 0x3450c8, - 0x239544, - 0x33f686, - 0x39aa46, - 0x375986, - 0x30cd86, - 0x22ef84, - 0x327e86, - 0x2b8c06, - 0x295b86, - 0x233bc6, - 0x210186, - 0x2aeec6, - 0x22c408, - 0x320508, - 0x2ca248, - 0x266748, - 0x385b06, - 0x213585, - 0x27cb06, - 0x2ac645, - 0x38a187, - 0x231605, - 0x215a43, - 0x207645, - 0x22cd44, - 0x2102c5, - 0x21d8c3, - 0x2fd4c7, - 0x319c88, - 0x3051c6, - 0x2d600d, - 0x27c546, - 0x295045, - 0x2bc283, - 0x2b50c9, - 0x2bf646, - 0x295646, - 0x29ec04, - 0x246347, - 0x233246, - 0x384205, - 0x233b83, - 0x203f04, - 0x27f506, - 0x2b0944, - 0x30eb08, - 0x396f89, - 0x32a849, - 0x29ea0a, - 0x310d8d, - 0x32fe07, - 0x380a86, - 0x2124c4, - 0x215009, - 0x2877c8, - 0x288cc6, - 0x267d06, - 0x269307, - 0x2c2806, - 0x225546, - 0x3a3606, - 0x313d0a, - 0x21f7c8, - 0x33aa05, - 0x282d09, - 0x283cca, - 0x2d6388, - 0x29abc8, - 0x2955c8, - 0x207f4c, - 0x2e8945, - 0x29d208, - 0x30a1c6, - 0x2d5646, - 0x379787, - 0x246b45, - 0x285785, - 0x32a709, - 0x214c87, - 0x2b2745, - 0x229f87, - 0x2102c3, - 0x2beb45, - 0x3aa1c8, - 0x2d4047, - 0x29aa89, - 0x2d9545, - 0x3074c4, - 0x2a0288, - 0x20e747, - 0x2a1908, - 0x34cdc8, - 0x35e9c5, - 0x23c806, - 0x252586, - 0x2e5e89, - 0x313687, - 0x2aca46, - 0x20b247, - 0x215403, - 0x258804, - 0x29c8c5, - 0x2589c4, - 0x360104, - 0x283587, - 0x209507, - 0x22f744, - 0x29a8d0, - 0x326fc7, - 0x2043c5, - 0x2e95cc, - 0x2b6084, - 0x2c6588, - 0x23e409, - 0x302086, - 0x33f488, - 0x240544, - 0x240548, - 0x384946, - 0x32d148, - 0x29c5c6, - 0x2c84cb, - 0x204a85, - 0x2c4308, - 0x21a084, - 0x284c8a, - 0x29aa89, - 0x2e0286, - 0x2d8b48, - 0x257a45, - 0x2fdac4, - 0x2c6486, - 0x202f48, - 0x283308, - 0x349546, - 0x37ff84, - 0x30b1c6, - 0x383c87, - 0x27bb47, - 0x26930f, - 0x208607, - 0x2f3ac7, - 0x2d5505, - 0x2efcc5, - 0x29f009, - 0x272346, - 0x281f05, - 0x285307, - 0x2d8e08, - 0x295c85, - 0x297706, - 0x21a3c8, - 0x2067ca, - 0x215448, - 0x3acd07, - 0x2371c6, - 0x282cc6, - 0x20e003, - 0x20fa43, - 0x283e89, - 0x28db09, - 0x2c6386, - 0x2d9545, - 0x2a7008, - 0x2d8b48, - 0x2ba5c8, - 0x3a368b, - 0x2d6247, - 0x2ff489, - 0x269588, - 0x33c444, - 0x2c48c8, - 0x28c489, - 0x2acd45, - 0x2d2787, - 0x2f7805, - 0x283208, - 0x28ef0b, - 0x293a90, - 0x2a6c45, - 0x219fcc, - 0x22c6c5, - 0x207203, - 0x2a7d46, - 0x2b7204, - 0x3397c6, - 0x29b587, - 0x215444, - 0x2422c8, - 0x322bcd, - 0x2d8a05, - 0x298f84, - 0x218404, - 0x282789, - 0x2a4e08, - 0x30bdc7, - 0x3849c8, - 0x284188, - 0x27d705, - 0x342607, - 0x27d687, - 0x2e2f87, - 0x2bdb49, - 0x2330c9, - 0x23fc46, - 0x2b3246, - 0x269546, - 0x26c105, - 0x3b0044, - 0x201b06, - 0x203c86, - 0x27d748, - 0x263b8b, - 0x26b987, - 0x2124c4, - 0x315c46, - 0x207047, - 0x2aeac5, - 0x316dc5, - 0x20f484, - 0x233046, - 0x201b88, - 0x215009, - 0x248446, - 0x287148, - 0x3842c6, - 0x332908, - 0x3ae14c, - 0x27d5c6, - 0x294d0d, - 0x29518b, - 0x248605, - 0x207c87, - 0x2395c6, - 0x330988, - 0x23fcc9, - 0x2e5ac8, - 0x2043c5, - 0x2f0807, - 0x281908, - 0x366909, - 0x23c0c6, - 0x24834a, - 0x330708, - 0x2e590b, - 0x2c6dcc, - 0x240648, - 0x27ec46, - 0x342008, - 0x208747, - 0x233349, - 0x29148d, - 0x29ba46, - 0x3a6cc8, - 0x3203c9, - 0x2b5ac8, - 0x286248, - 0x2b94cc, - 0x2ba7c7, - 0x2bb3c7, - 0x2bd985, - 0x2ee287, - 0x2d8cc8, - 0x2c6506, - 0x256acc, - 0x2e6808, - 0x2c5808, - 0x266a06, - 0x20df47, - 0x23fe44, - 0x266748, - 0x2dc68c, - 0x21c68c, - 0x225e85, - 0x393e07, - 0x37ff06, - 0x20dec6, - 0x29b048, - 0x3a4984, - 0x32c64b, - 0x2263cb, - 0x2371c6, - 0x322a47, - 0x328b05, - 0x273145, - 0x32c786, - 0x257a05, - 0x26b505, - 0x379a47, - 0x27b509, - 0x2344c4, - 0x3621c5, + 0x282a0b86, + 0x28641bc8, + 0x28a087c6, + 0x28f0f188, + 0x2931d706, + 0x29701044, + 0x201cc2, + 0x29a404c7, + 0x29ea7ac4, + 0x2a276e47, + 0x2a79f6c7, + 0x2016c2, + 0x2aa98a85, + 0x2af2df84, + 0x2b3744c7, + 0x2b61c307, + 0x2ba81986, + 0x2be2af85, + 0x2c292307, + 0x2c6d0ec8, + 0x2cb1b5c7, + 0x2ceab1c9, + 0x2d38dd45, + 0x2d736047, + 0x2da8cb46, + 0x2de546c8, + 0x2c834d, + 0x23e149, + 0x2e0e0b, + 0x382f0b, + 0x27130b, + 0x2a380b, + 0x3006cb, + 0x30098b, + 0x300d89, + 0x301e4b, + 0x30210b, + 0x30268b, + 0x3035ca, + 0x303b0a, + 0x30410c, + 0x30764b, + 0x307a8a, + 0x31a60a, + 0x32b44e, + 0x32c04e, + 0x32c3ca, + 0x32e54a, + 0x32f08b, + 0x32f34b, + 0x32fecb, + 0x34960b, + 0x349c0a, + 0x34a8cb, + 0x34ab8a, + 0x34ae0a, + 0x34b08a, + 0x36fbcb, + 0x377d0b, + 0x37968e, + 0x379a0b, + 0x3831cb, + 0x38540b, + 0x3898ca, + 0x389b49, + 0x389d8a, + 0x38b40a, + 0x39cb4b, + 0x39e68b, + 0x39f00a, + 0x3a0e0b, + 0x3a590b, + 0x3b198b, + 0x2e280048, + 0x2e686b89, + 0x2eb5e8c9, + 0x2eecf548, + 0x336b05, + 0x202c83, + 0x20d2c4, + 0x2e7d45, + 0x256fc6, + 0x260585, + 0x285d04, + 0x26d788, + 0x21db45, + 0x28e684, + 0x201b07, + 0x29abca, + 0x35504a, + 0x35de07, + 0x202b87, + 0x2f16c7, + 0x364307, + 0x3af485, + 0x30fdc6, + 0x3287c7, + 0x247004, + 0x2fbe46, + 0x3a5246, + 0x3b31c5, + 0x305a04, + 0x2b8306, + 0x299fc7, + 0x2298c6, + 0x37c747, + 0x27a403, + 0x248f46, + 0x22f405, + 0x27eb47, + 0x2bde8a, + 0x22cd04, + 0x215988, + 0x2aac49, + 0x2c6c07, + 0x24b286, + 0x2de448, + 0x39fa49, + 0x234cc4, + 0x35e484, + 0x2fa145, + 0x2020c8, + 0x2be687, + 0x2a7149, + 0x23dc08, + 0x2fd446, + 0x23f046, + 0x295b48, + 0x372286, + 0x2031c5, + 0x281a46, + 0x277548, + 0x230b46, + 0x24d90b, + 0x233346, + 0x29788d, + 0x399e85, + 0x2a7986, + 0x2085c5, + 0x294709, + 0x341c87, + 0x37fd88, + 0x36d906, + 0x296249, + 0x2ee4c6, + 0x2bde05, + 0x27ba86, + 0x2a8646, + 0x2c4ec9, + 0x234ac6, + 0x36e4c7, 0x2d71c5, - 0x25b748, - 0x376005, - 0x2a7849, - 0x370587, - 0x37058b, - 0x2d1546, - 0x22c149, - 0x24f948, - 0x280d45, - 0x2e3088, - 0x233108, - 0x211807, - 0x282b87, - 0x283609, - 0x320447, - 0x38cf09, - 0x2aa34c, - 0x36aa08, - 0x2b5ec9, - 0x2b8247, - 0x284249, - 0x209647, - 0x2c6ec8, - 0x25ba85, - 0x33f606, - 0x2b9cc8, - 0x2d6a88, - 0x283b89, - 0x26b547, - 0x273205, - 0x216c49, - 0x28e046, - 0x28e7c4, - 0x2e5786, - 0x2450c8, - 0x248e07, - 0x263d88, - 0x345189, - 0x364f87, - 0x29c346, - 0x207d44, - 0x2076c9, - 0x342488, - 0x2668c7, - 0x323e06, - 0x20e286, - 0x380b84, - 0x326186, - 0x210243, - 0x2cf889, - 0x204a46, - 0x2a4485, - 0x29cf86, - 0x2a1a45, - 0x281d88, - 0x240387, - 0x35b546, - 0x3414c6, - 0x35e248, - 0x29f187, - 0x29ba85, - 0x29d488, - 0x38cc48, - 0x330708, - 0x22c585, - 0x33f686, - 0x32a609, - 0x252404, - 0x373acb, - 0x22524b, - 0x33a909, - 0x2102c3, - 0x2546c5, - 0x20ff46, - 0x267608, - 0x236d04, - 0x3051c6, - 0x2c9889, - 0x2c6845, - 0x379986, - 0x20e746, - 0x211184, - 0x2a064a, - 0x2a43c8, - 0x2d6a86, - 0x329185, - 0x20d707, - 0x378e07, - 0x23c804, - 0x225487, - 0x2315c4, - 0x2315c6, - 0x21a503, - 0x2bdb45, - 0x36fb05, - 0x20eac8, - 0x258905, - 0x27d309, - 0x266587, - 0x26658b, - 0x2a12cc, - 0x2a1eca, - 0x2bf307, - 0x202003, - 0x2e6408, - 0x22c745, - 0x295d05, - 0x338404, - 0x2c6dc6, - 0x23e406, - 0x3261c7, - 0x39998b, - 0x22ef84, - 0x382744, - 0x26fec4, - 0x2c4046, - 0x215444, - 0x211008, - 0x338205, - 0x29d545, - 0x2ba507, - 0x207d89, - 0x352545, - 0x31abca, - 0x2d8f49, - 0x2a104a, - 0x313e49, - 0x39cc04, - 0x2cd385, - 0x2c2908, - 0x2fc70b, - 0x2fb3c5, - 0x237546, - 0x214904, - 0x27d846, - 0x364e09, - 0x315d07, - 0x30c108, - 0x311106, - 0x383c07, - 0x283308, - 0x38fbc6, - 0x244a44, - 0x3636c7, - 0x34a905, - 0x350a47, - 0x201c04, - 0x239546, - 0x21fa48, - 0x295348, - 0x2ee007, - 0x378288, - 0x2b34c5, - 0x210104, - 0x3410c8, - 0x3321c4, - 0x211805, - 0x2efe04, - 0x2e4a47, - 0x289dc7, - 0x284388, - 0x2a1a86, - 0x258885, - 0x27d108, - 0x215648, - 0x29e949, - 0x225546, - 0x22fa08, - 0x284b0a, - 0x2aeb48, - 0x2d8045, - 0x27cd06, - 0x2740c8, - 0x2f08ca, - 0x24fb47, - 0x287bc5, - 0x294288, - 0x2ad9c4, - 0x384446, - 0x2bbb48, - 0x210186, - 0x264308, - 0x252247, - 0x205b86, - 0x37ac04, - 0x37e907, - 0x2fd904, - 0x364dc7, - 0x33924d, - 0x288b05, - 0x2d3e4b, - 0x29c6c6, - 0x24d788, - 0x242284, - 0x278906, - 0x27f506, - 0x342347, - 0x2949cd, - 0x2ab007, - 0x302748, - 0x24c9c5, - 0x288248, - 0x2be186, - 0x2b3548, - 0x217086, - 0x3448c7, - 0x345349, - 0x33ff07, - 0x288f88, - 0x276005, - 0x21f108, - 0x20de05, - 0x242b45, - 0x35a545, - 0x226103, - 0x285684, - 0x282d05, - 0x271249, - 0x2ffa06, - 0x2b2388, - 0x24bc05, - 0x32e087, - 0x24ba0a, - 0x3798c9, - 0x2a830a, - 0x2ca2c8, - 0x229dcc, - 0x28538d, - 0x334603, - 0x264208, - 0x203ec5, - 0x206586, - 0x382346, - 0x2d7b45, - 0x20b349, - 0x264745, - 0x27d108, - 0x255ac6, - 0x33cac6, - 0x2a0149, - 0x38f3c7, - 0x28f1c6, - 0x24b988, - 0x375888, - 0x2d0547, - 0x32d2ce, - 0x2be3c5, - 0x366805, - 0x210088, - 0x3978c7, - 0x20ca82, - 0x2b9044, - 0x3396ca, - 0x266988, - 0x207146, - 0x296bc8, - 0x252586, - 0x323708, - 0x2aca48, - 0x242b04, - 0x333805, - 0x687e44, - 0x687e44, - 0x687e44, - 0x204b03, - 0x20e106, - 0x27d5c6, - 0x29bd0c, - 0x205243, - 0x283cc6, - 0x21a4c4, - 0x2bf5c8, - 0x2c96c5, - 0x3397c6, - 0x2b5808, - 0x2cb1c6, - 0x35b4c6, - 0x327988, - 0x29c947, - 0x32ce49, - 0x306f8a, - 0x264944, - 0x231605, - 0x2a91c5, - 0x214e06, - 0x32fe46, - 0x2a7406, - 0x2eeb86, - 0x32cf84, - 0x32cf8b, - 0x2313c4, - 0x20d785, - 0x2ab905, - 0x283086, - 0x3b0588, - 0x285247, - 0x30bec4, - 0x259b83, - 0x2ad4c5, - 0x2e5647, - 0x2a2849, - 0x28514b, - 0x3261c7, - 0x20e9c7, - 0x2b5708, - 0x32e1c7, - 0x2a2a86, - 0x244448, - 0x2a584b, - 0x399606, - 0x217549, - 0x2a59c5, - 0x3015c3, - 0x379986, - 0x252148, - 0x214ec3, - 0x21cf03, - 0x283306, - 0x252586, - 0x38c60a, - 0x27ec85, - 0x27f34b, - 0x29cecb, - 0x2417c3, - 0x21fe03, - 0x2ae304, - 0x344d07, - 0x240644, - 0x207f44, - 0x30a044, - 0x2aee48, - 0x3290c8, - 0x35ad89, - 0x38e788, - 0x271407, - 0x233bc6, - 0x2b1fcf, - 0x2be506, - 0x2c9644, - 0x328f0a, - 0x2e5547, - 0x201846, - 0x28e809, - 0x35ad05, - 0x20ec05, - 0x35ae46, - 0x21f243, - 0x2ada09, - 0x21f946, - 0x344f49, - 0x397d86, - 0x2bdb45, - 0x226285, - 0x208603, - 0x344e48, - 0x3a5ac7, - 0x2f7204, - 0x2bf448, - 0x2c0184, - 0x2c5686, - 0x2a7d46, - 0x23ec06, - 0x2c41c9, - 0x295c85, - 0x2c0406, - 0x2697c9, - 0x3ad4c6, - 0x2aeec6, - 0x3895c6, - 0x215105, - 0x2efe06, - 0x3448c4, - 0x25ba85, - 0x2b9cc4, - 0x309f46, - 0x359c44, - 0x202c43, - 0x287885, - 0x232e08, - 0x22b547, - 0x2b3dc9, - 0x287ac8, - 0x296391, - 0x20e7ca, - 0x237107, - 0x2bc046, - 0x21a4c4, - 0x2b9dc8, - 0x22f488, - 0x29654a, - 0x2a760d, - 0x237446, - 0x327a86, - 0x37e9c6, - 0x2ef0c7, - 0x302805, - 0x261107, - 0x2bf505, - 0x3706c4, - 0x2a5286, - 0x326007, - 0x2ad70d, - 0x274007, - 0x270188, - 0x27d409, - 0x27cc06, - 0x23c045, - 0x21d904, - 0x2451c6, - 0x23c706, - 0x266b06, - 0x299108, - 0x215d03, - 0x210603, - 0x323ac5, - 0x376b86, - 0x2aca05, - 0x311308, - 0x29b74a, - 0x2ce804, - 0x2bf5c8, - 0x2955c8, - 0x282ec7, - 0x24bcc9, - 0x2b5408, - 0x215087, - 0x269ec6, - 0x21018a, - 0x245248, - 0x2c6c09, - 0x2a4ec8, - 0x221649, - 0x2e5bc7, - 0x349945, - 0x361f86, - 0x2c6388, - 0x24d908, - 0x28eb48, - 0x21acc8, - 0x20d785, - 0x200884, - 0x3a57c8, - 0x201944, - 0x313c44, - 0x2bdb45, - 0x290487, - 0x207b49, - 0x342147, - 0x2051c5, - 0x27b106, - 0x33f0c6, - 0x206944, - 0x2a0486, - 0x383f44, - 0x288146, - 0x3a4a46, - 0x219206, - 0x2043c5, - 0x3111c7, - 0x202003, - 0x3670c9, - 0x35e048, - 0x214f04, - 0x214f0d, - 0x295448, - 0x2f3f48, - 0x2c6b86, - 0x345449, - 0x3798c9, - 0x364b05, - 0x29b84a, - 0x28224a, - 0x289f8c, - 0x28a106, - 0x27b9c6, - 0x2bea86, - 0x26db09, - 0x2067c6, - 0x261146, - 0x264806, - 0x266748, - 0x215446, - 0x2c450b, - 0x290605, - 0x29d545, - 0x27bc45, - 0x202106, - 0x210143, - 0x23eb86, - 0x273f87, - 0x2b9c85, - 0x243645, - 0x3a0505, - 0x335f46, - 0x31abc4, - 0x372a46, - 0x299489, - 0x201f8c, - 0x370408, - 0x202ec4, - 0x2efbc6, - 0x29c7c6, - 0x252148, - 0x2d8b48, - 0x201e89, - 0x20d707, - 0x2563c9, - 0x24cf86, - 0x22cf44, - 0x20f184, - 0x288bc4, - 0x283308, - 0x20798a, - 0x3524c6, - 0x356387, - 0x236087, - 0x22c245, - 0x2a9184, - 0x28c446, - 0x302846, - 0x233303, - 0x35de87, - 0x34ccc8, - 0x364c4a, - 0x2cbb88, - 0x2ce688, - 0x359c85, - 0x248705, - 0x26ba85, - 0x22c606, - 0x37ed86, - 0x209445, - 0x2cfac9, - 0x2a8f8c, - 0x26bb47, - 0x2965c8, - 0x257d45, - 0x687e44, - 0x247884, - 0x2d4184, - 0x2c1606, - 0x29da4e, - 0x20ec87, - 0x2edfc5, - 0x25238c, - 0x2c0047, - 0x325f87, - 0x35bf49, - 0x21b949, - 0x287bc5, - 0x35e048, - 0x32a609, - 0x2f2ec5, - 0x2b9bc8, - 0x2c4ac6, - 0x341346, - 0x331b84, - 0x2a46c8, - 0x249e83, - 0x342c84, - 0x2ad545, - 0x335407, - 0x20f4c5, - 0x2849c9, - 0x28d60d, - 0x2a6246, - 0x32c004, - 0x211188, - 0x27b34a, - 0x20cb87, - 0x239d85, - 0x206d03, - 0x29d08e, - 0x25258c, - 0x2fb707, - 0x29dc07, - 0x201c43, - 0x206805, - 0x2d4185, - 0x296f88, - 0x2940c9, - 0x202dc6, - 0x240644, - 0x237046, - 0x37564b, - 0x3a0b8c, - 0x341ec7, - 0x2c9385, - 0x38cb48, - 0x2d0305, - 0x328f07, - 0x23bf07, - 0x249e85, - 0x210143, - 0x2af184, - 0x20f945, - 0x2ad0c5, - 0x2ad0c6, - 0x2927c8, - 0x326007, - 0x382646, - 0x206486, - 0x35a486, - 0x263a09, - 0x342707, - 0x202c46, - 0x3a0d06, - 0x249f46, - 0x2a6f45, - 0x20aa06, - 0x399385, - 0x376088, - 0x2936cb, - 0x28c246, - 0x2360c4, - 0x2f0689, - 0x266584, - 0x2c4a48, - 0x2961c7, - 0x286144, - 0x2b4708, - 0x2bad84, - 0x2a6f84, - 0x2889c5, - 0x2d8a46, - 0x2aed87, - 0x2643c3, - 0x29c405, - 0x2f7784, - 0x366846, - 0x364b88, - 0x327885, - 0x28ff09, - 0x216e45, - 0x2e2b48, - 0x263747, - 0x38a2c8, - 0x2b3c07, - 0x2f3b89, - 0x327d06, - 0x36bd06, - 0x264804, - 0x269e05, - 0x2f5e4c, - 0x27bc47, - 0x27c447, - 0x235f48, - 0x2a6246, - 0x273ec4, - 0x2ead84, - 0x283489, - 0x2beb86, - 0x218247, - 0x30cd04, - 0x2ffb06, - 0x325b85, - 0x2a15c7, - 0x2c4486, - 0x248209, - 0x282087, - 0x269307, - 0x29ffc6, - 0x310c85, - 0x280a08, - 0x21f7c8, - 0x23d906, - 0x3278c5, - 0x261c86, - 0x205d03, - 0x296e09, - 0x2a718e, - 0x2b2a08, - 0x2c0288, - 0x23d70b, - 0x290146, - 0x321ac4, - 0x284f84, - 0x2a728a, - 0x219ec7, - 0x202d05, - 0x217549, - 0x2b8cc5, - 0x313c87, - 0x301e84, - 0x397107, - 0x2372c8, - 0x2d1bc6, - 0x3a6e49, - 0x2b550a, - 0x219e46, - 0x294f86, - 0x2ab885, - 0x37cb05, - 0x357f47, - 0x2456c8, - 0x325ac8, - 0x242b06, - 0x226305, - 0x32fbce, - 0x333b84, - 0x23d885, - 0x27aa89, - 0x272148, - 0x3acc46, - 0x298d8c, - 0x29b350, - 0x29d68f, - 0x29ef08, - 0x2bf307, - 0x2043c5, - 0x282d05, - 0x2aec09, - 0x294489, - 0x30b2c6, - 0x2fb447, - 0x393d85, - 0x36d749, - 0x3320c6, - 0x20660d, - 0x288a89, - 0x207f44, - 0x2b2788, - 0x3a5889, - 0x352686, - 0x27b205, - 0x36bd06, - 0x30bfc9, - 0x2381c8, - 0x213585, - 0x284c04, - 0x298f4b, - 0x352545, - 0x267686, - 0x2856c6, - 0x26b006, - 0x3a388b, - 0x290009, - 0x209785, - 0x38a087, - 0x20e746, - 0x339506, - 0x284888, - 0x269fc9, - 0x26ff4c, - 0x2e5448, - 0x352786, - 0x349543, - 0x2d2986, - 0x2829c5, - 0x27f688, - 0x225d06, - 0x2a1808, - 0x246cc5, - 0x215185, - 0x2a0848, - 0x378f47, - 0x382287, - 0x3261c7, - 0x33f488, - 0x28e9c8, - 0x24de06, - 0x309d87, - 0x2586c7, - 0x28288a, - 0x24ce83, - 0x202106, - 0x203005, - 0x324244, - 0x27d409, - 0x2f3b04, - 0x22b5c4, - 0x29c644, - 0x29dc0b, - 0x3a5a07, - 0x32fe05, - 0x293548, - 0x27b106, - 0x27b108, - 0x27ebc6, - 0x28adc5, - 0x28b545, - 0x28d046, - 0x28e488, - 0x28e748, - 0x27d5c6, - 0x29338f, - 0x2968d0, - 0x3a26c5, - 0x202003, - 0x24c905, - 0x2ff3c8, - 0x294389, - 0x330708, - 0x263888, - 0x380648, - 0x3a5ac7, - 0x27adc9, - 0x2a1a08, - 0x2b0684, - 0x29c4c8, - 0x25b809, - 0x30b8c7, - 0x298144, - 0x342208, - 0x310f8a, - 0x2c3ec6, - 0x237446, - 0x225409, - 0x29b587, - 0x2c4e48, - 0x209fc8, - 0x30cb88, - 0x355ec5, - 0x37da85, - 0x29d545, - 0x2d4145, - 0x2f1807, - 0x210145, - 0x2b9c85, - 0x212ec6, - 0x330647, - 0x2fc647, - 0x311286, - 0x2ca805, - 0x267686, - 0x240405, - 0x2bfec8, - 0x2ff984, - 0x3ad546, - 0x2e7dc4, - 0x2fdac8, - 0x3ad64a, - 0x27de4c, - 0x399b85, - 0x2ef186, - 0x270106, - 0x34c5c6, - 0x2ff5c4, - 0x325e45, - 0x27ea07, - 0x29b609, - 0x2a2947, - 0x687e44, - 0x687e44, - 0x30bd45, - 0x229144, - 0x29874a, - 0x27af86, - 0x2e5884, - 0x2017c5, - 0x2eb445, - 0x302744, - 0x285307, - 0x216dc7, - 0x2c4048, - 0x317048, - 0x213589, - 0x3321c8, - 0x29890b, - 0x214e04, - 0x361905, - 0x281f85, - 0x326149, - 0x269fc9, - 0x2f0588, - 0x2313c8, - 0x283084, - 0x29c805, - 0x207503, - 0x214dc5, - 0x2c0486, - 0x293f0c, - 0x21f846, - 0x240446, - 0x2940c5, - 0x335fc8, - 0x3a0e06, - 0x2bc1c6, - 0x237446, - 0x22d6cc, - 0x266cc4, - 0x35a5ca, - 0x3ace08, - 0x293d47, - 0x244946, - 0x202e87, - 0x2e0845, - 0x323e06, - 0x354906, - 0x382147, - 0x22b604, - 0x2e4b45, - 0x27aa84, - 0x370747, - 0x27acc8, - 0x27b84a, - 0x281787, - 0x23da87, - 0x2bf287, - 0x2d0449, - 0x293f0a, - 0x22cf03, - 0x22b505, - 0x219243, - 0x30a089, - 0x2f1108, - 0x2d5507, - 0x330809, - 0x21f8c6, - 0x2b0208, - 0x2fd445, - 0x21574a, - 0x326dc9, - 0x26fc09, - 0x379787, - 0x22f589, - 0x219108, - 0x2eff86, - 0x2ef348, - 0x215e47, - 0x320447, - 0x2d8f47, - 0x2d5388, - 0x2efa46, - 0x310d45, - 0x27ea07, - 0x294a88, - 0x35a404, - 0x350f04, - 0x28f0c7, - 0x2acdc7, - 0x32a48a, - 0x2eff06, - 0x2fb58a, - 0x2b8f87, - 0x333947, - 0x242c04, - 0x38cfc4, - 0x227a06, - 0x264d04, - 0x264d0c, - 0x3b1f45, - 0x21ab09, - 0x2e2cc4, - 0x302805, - 0x27b2c8, - 0x28e805, - 0x31abc6, - 0x2115c4, - 0x2a0a8a, - 0x2b0846, - 0x29574a, - 0x31a987, - 0x263ec5, - 0x21f245, - 0x22c28a, - 0x2a0585, - 0x29ea06, - 0x201944, - 0x2ae486, - 0x358005, - 0x225dc6, - 0x2ee00c, - 0x2c4fca, - 0x269ec4, - 0x233bc6, - 0x29b587, - 0x2c8984, - 0x266748, - 0x38e606, - 0x32fa49, - 0x2c5ec9, - 0x36ab09, - 0x373c86, - 0x215f46, - 0x2ef487, - 0x2cfa08, - 0x215d49, - 0x3a5a07, - 0x2b3346, - 0x383c87, - 0x37e885, - 0x333b84, - 0x2ef047, - 0x2f7805, - 0x288905, - 0x300687, - 0x249d48, - 0x38cac6, - 0x2959cd, - 0x29718f, - 0x29cecd, - 0x205204, - 0x232f06, - 0x2cbec8, - 0x2647c5, - 0x282a48, - 0x2116ca, - 0x207f44, - 0x3a7006, - 0x39f8c7, - 0x22ef87, - 0x29ca09, - 0x2ef305, - 0x302744, - 0x33374a, - 0x2b4fc9, - 0x22f687, - 0x26cbc6, - 0x352686, - 0x29c746, - 0x363786, - 0x2cb84f, - 0x2cbd89, - 0x215446, - 0x22f386, - 0x27a409, - 0x309e87, - 0x21d943, - 0x22d846, - 0x20fa43, - 0x2d7a08, - 0x383ac7, - 0x29f109, - 0x2a7bc8, - 0x3823c8, - 0x26b686, - 0x23c549, - 0x2c7a85, - 0x244944, - 0x349a07, - 0x26db85, - 0x205204, - 0x32fec8, - 0x21a184, - 0x305647, - 0x319c06, - 0x29f785, - 0x2a4ec8, - 0x35254b, - 0x35e547, - 0x22c506, - 0x2be584, - 0x321a46, - 0x2bdb45, - 0x2f7805, - 0x280789, - 0x284f09, - 0x2a2a04, - 0x3204c5, - 0x233c05, - 0x2155c6, - 0x35e148, - 0x2b7586, - 0x34cb0b, - 0x301f0a, - 0x2fda05, - 0x28b5c6, - 0x2f6f05, - 0x209845, - 0x29ad47, - 0x2073c8, - 0x2563c4, - 0x364a06, - 0x28e7c6, - 0x2192c7, - 0x301584, - 0x27f506, - 0x300e05, - 0x300e09, - 0x216144, - 0x2a9309, - 0x27d5c6, - 0x2ba888, - 0x233c05, - 0x236185, - 0x225dc6, - 0x26fe49, - 0x21b949, - 0x2404c6, - 0x272248, - 0x252488, - 0x2f6ec4, - 0x363c84, - 0x363c88, - 0x3158c8, - 0x2564c9, - 0x2c0406, - 0x237446, - 0x312ccd, - 0x3051c6, - 0x3ae009, - 0x2022c5, - 0x35ae46, - 0x261248, - 0x30fc45, - 0x258704, - 0x2bdb45, - 0x284588, - 0x298509, - 0x27ab44, - 0x239546, - 0x2e5d0a, - 0x2d6388, - 0x32a609, - 0x35b64a, - 0x330786, - 0x297348, - 0x328cc5, - 0x326c48, - 0x2b3d05, - 0x21f789, - 0x368809, - 0x202e02, - 0x2a59c5, - 0x272e86, - 0x27d507, - 0x324245, - 0x2f9986, - 0x30fd08, - 0x2a6246, - 0x2c27c9, - 0x27c546, - 0x284708, - 0x2a8645, - 0x24ae86, - 0x3449c8, - 0x283308, - 0x3a4ac8, - 0x2febc8, - 0x20aa04, - 0x22a783, - 0x2c2a04, - 0x236fc6, - 0x37e8c4, - 0x2c01c7, - 0x2bc0c9, - 0x2bdd85, - 0x209fc6, - 0x22d846, - 0x29260b, - 0x2fd946, - 0x316406, - 0x2c2f88, - 0x243586, - 0x263cc3, - 0x20a383, - 0x333b84, - 0x22f905, - 0x384107, - 0x27acc8, - 0x27accf, - 0x27e90b, - 0x35df48, - 0x2395c6, - 0x35e24e, - 0x225dc3, - 0x2b1d84, - 0x2fd8c5, - 0x33d746, - 0x28c54b, - 0x290546, - 0x21a449, - 0x29f785, - 0x38b708, - 0x212088, - 0x21b80c, - 0x29dc46, - 0x214e06, - 0x2d9545, - 0x288d48, - 0x27de45, - 0x33c448, - 0x29d30a, - 0x361e09, - 0x687e44, - 0x2f606a82, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x327883, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x24c083, - 0x204703, - 0x223503, - 0x223504, - 0x22bf83, - 0x234a44, - 0x231b03, - 0x2c8144, - 0x250cc3, - 0x324507, - 0x220ec3, - 0x2020c3, - 0x255bc8, - 0x204703, - 0x2d2d8b, - 0x2e0f83, - 0x25b1c6, - 0x2012c2, - 0x387d0b, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x204703, - 0x29dfc3, - 0x205a03, - 0x200882, - 0x77a48, - 0x343145, - 0x2d4e88, - 0x2da008, - 0x206a82, - 0x330f85, - 0x357bc7, - 0x200202, - 0x2424c7, - 0x20f582, - 0x23d4c7, - 0x265249, - 0x3167c8, - 0x30ca09, - 0x3345c2, - 0x26ab07, - 0x240244, - 0x357c87, - 0x301e07, - 0x244d02, - 0x220ec3, - 0x203642, - 0x202b42, - 0x200fc2, - 0x200ac2, - 0x203942, - 0x203682, - 0x2a81c5, - 0x2477c5, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x481, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x202243, - 0x24c083, - 0x204703, - 0x20b743, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0xa9c2, - 0x77a48, - 0x45684, - 0xd0705, - 0x200882, - 0x2bb844, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x37f383, - 0x2a8e05, - 0x202243, - 0x39a883, - 0x24c083, - 0x20f543, - 0x204703, - 0x20b803, - 0x223583, - 0x2232c3, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x206a82, - 0x204703, - 0x77a48, - 0x250cc3, - 0x77a48, - 0x2cd683, - 0x22bf83, - 0x22ff84, - 0x231b03, - 0x250cc3, - 0x20b542, - 0x220ec3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x20b542, - 0x232003, - 0x24c083, - 0x204703, - 0x2d9f83, - 0x20b803, - 0x200882, - 0x206a82, - 0x250cc3, - 0x24c083, - 0x204703, - 0x25b1c5, - 0xad186, - 0x223504, - 0x2012c2, - 0x77a48, - 0x200882, - 0x20048, - 0x206a82, - 0xf206, - 0x143f44, - 0x10844b, - 0x18986, - 0x142b87, - 0x231b03, - 0x250cc3, - 0x159b85, - 0x14d4c4, - 0x24dd43, - 0x4ce47, - 0xcd204, - 0x24c083, - 0x14c104, - 0x204703, - 0x2e1c44, - 0x10c888, - 0x122706, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x2020c3, - 0x204703, - 0x2e0f83, - 0x2012c2, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c3, - 0x211004, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x2c8144, - 0x250cc3, - 0x24c083, - 0x204703, - 0x25b1c6, - 0x231b03, - 0x250cc3, - 0x178d03, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x142b87, - 0x77a48, - 0x250cc3, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x3822bf83, - 0x231b03, - 0x24c083, - 0x204703, - 0x77a48, - 0x200882, - 0x206a82, - 0x22bf83, - 0x250cc3, - 0x24c083, - 0x200fc2, - 0x204703, - 0x30abc7, - 0x2e330b, - 0x208883, - 0x23a8c8, - 0x2cf787, - 0x2b7b46, - 0x2bc885, - 0x2f9509, - 0x25af48, - 0x31b349, - 0x31b350, - 0x35d24b, - 0x2ec7c9, - 0x206103, - 0x2130c9, - 0x230a86, - 0x230a8c, - 0x31b548, - 0x3ad308, - 0x279709, - 0x29e40e, - 0x37b34b, - 0x237bcc, - 0x201e03, - 0x268d0c, - 0x208349, - 0x375287, - 0x231a4c, - 0x39c18a, - 0x247204, - 0x3a4d8d, - 0x268bc8, - 0x3a52cd, - 0x26e086, - 0x290ccb, - 0x375b49, - 0x3162c7, - 0x31eb06, - 0x321c09, - 0x34b9ca, - 0x304f48, - 0x2e0b84, - 0x362087, - 0x278a07, - 0x30cf04, - 0x228dc4, - 0x262f09, - 0x2ce4c9, - 0x323148, - 0x212905, - 0x392845, - 0x20d546, - 0x3a4c49, - 0x21194d, - 0x237648, - 0x20d447, - 0x2bc908, - 0x32cc06, - 0x3a2444, - 0x37dd45, - 0x204946, - 0x205884, - 0x208247, - 0x20a60a, - 0x214bc4, - 0x219d86, - 0x21a789, - 0x21a78f, - 0x21b50d, - 0x21ca86, - 0x21fc50, - 0x220046, - 0x220787, - 0x221047, - 0x22104f, - 0x221889, - 0x2256c6, - 0x227e87, - 0x227e88, - 0x228249, - 0x290248, - 0x2d7547, - 0x20ce83, - 0x386a86, - 0x2e4c88, - 0x29e6ca, - 0x214689, - 0x212383, - 0x357ac6, - 0x36484a, - 0x2f7d07, - 0x3750ca, - 0x2028ce, - 0x2219c6, - 0x2a5bc7, - 0x217306, - 0x208406, - 0x37d88b, - 0x3038ca, - 0x22704d, - 0x216007, - 0x264988, - 0x264989, - 0x26498f, - 0x20e34c, - 0x27f909, - 0x3af74e, - 0x32460a, - 0x329546, - 0x37a686, - 0x306ccc, - 0x3108cc, - 0x32adc8, - 0x33fe07, - 0x2b0585, - 0x206a84, - 0x345b4e, - 0x34bc44, - 0x22adc7, - 0x265e4a, - 0x382ad4, - 0x384e4f, - 0x221208, - 0x386948, - 0x36d10d, - 0x36d10e, - 0x390509, - 0x22e108, - 0x22e10f, - 0x23174c, - 0x23174f, - 0x232c47, - 0x2352ca, - 0x21f50b, - 0x239c08, - 0x23aac7, - 0x25a64d, - 0x35c546, - 0x3a4f46, - 0x23ea09, - 0x250248, - 0x243048, - 0x24304e, - 0x2e3407, - 0x2aabc5, - 0x244ec5, - 0x200e84, - 0x2b7e06, - 0x323048, - 0x25ff83, - 0x2de30e, - 0x25aa08, - 0x308dcb, - 0x367487, - 0x3a4485, - 0x22f246, - 0x2a9b47, - 0x2e8448, - 0x330489, - 0x35c7c5, - 0x2878c8, - 0x214006, - 0x37e50a, - 0x345a49, - 0x231b09, - 0x231b0b, - 0x31f608, - 0x30cdc9, - 0x2129c6, - 0x35a8ca, - 0x2b898a, - 0x2354cc, - 0x35c307, - 0x291e8a, - 0x2af68b, - 0x2af699, - 0x2dd788, - 0x25b245, - 0x25a806, - 0x2dad89, - 0x316cc6, - 0x211e4a, - 0x342a06, - 0x2143c4, - 0x2c098d, - 0x24fd07, - 0x2143c9, - 0x245e85, - 0x245fc8, - 0x2467c9, - 0x246a04, - 0x247107, - 0x247108, - 0x2479c7, - 0x2687c8, - 0x24d447, - 0x23c285, - 0x25520c, - 0x2558c9, - 0x36bf0a, - 0x38f249, - 0x2131c9, - 0x27450c, - 0x259a4b, - 0x259d08, - 0x25bf88, - 0x25f344, - 0x285e08, - 0x286bc9, - 0x39c247, - 0x21a9c6, - 0x2413c7, - 0x3af509, - 0x2af2cb, - 0x325947, - 0x204787, - 0x2e2d47, - 0x3a5244, - 0x3a5245, - 0x2a6d05, - 0x337a0b, - 0x398604, - 0x317e88, - 0x2aa7ca, - 0x2140c7, - 0x34a107, - 0x28bdd2, - 0x288046, - 0x22fb86, - 0x32728e, - 0x34ae06, - 0x291308, - 0x29210f, - 0x3a5688, - 0x377c48, - 0x2b4b8a, - 0x2b4b91, - 0x2a0d0e, - 0x23adca, - 0x23adcc, - 0x22e307, - 0x22e310, - 0x203d08, - 0x2a0f05, - 0x2aa10a, - 0x2058cc, - 0x2b368d, - 0x2abe06, - 0x2abe07, - 0x2abe0c, - 0x2f338c, - 0x2d988c, - 0x28f4cb, - 0x287284, - 0x225584, - 0x371389, - 0x2d8447, - 0x32c449, - 0x2b87c9, - 0x367f07, - 0x39c006, - 0x39c009, - 0x3a6b43, - 0x2a634a, - 0x206cc7, - 0x3624cb, - 0x226eca, - 0x23d604, - 0x3564c6, - 0x281a09, - 0x20b504, - 0x3b200a, - 0x2f9b45, - 0x2b6285, - 0x2b628d, - 0x2b65ce, - 0x3146c5, - 0x3942c6, - 0x25adc7, - 0x2dc04a, - 0x2e8646, - 0x2fc484, - 0x2f5987, - 0x220d8b, - 0x32ccc7, - 0x3a34c4, - 0x374206, - 0x37420d, - 0x23918c, - 0x380406, - 0x23784a, - 0x217b06, - 0x21da08, - 0x228507, - 0x37f14a, - 0x2310c6, - 0x215f03, - 0x2613c6, - 0x201308, - 0x298b0a, - 0x26c447, - 0x26c448, - 0x2732c4, - 0x2863c7, - 0x28e0c8, - 0x2151c8, - 0x285c08, - 0x32630a, - 0x2cff85, - 0x2c76c7, - 0x23ac13, - 0x22c006, - 0x2b09c8, - 0x223ac9, - 0x242388, - 0x26b70b, - 0x2b8d88, - 0x220ec4, - 0x2a0946, - 0x3b11c6, - 0x2d8889, - 0x387747, - 0x255308, - 0x3acf86, - 0x21c444, - 0x2c4d05, - 0x2bf0c8, - 0x2bf98a, - 0x2c0608, - 0x2c5446, - 0x29920a, - 0x234548, - 0x2c8788, - 0x2c9bc8, - 0x2ca4c6, - 0x2cc0c6, - 0x31f00c, - 0x2cc590, - 0x28a505, - 0x2f9f88, - 0x2f9f90, - 0x3a5490, - 0x31b1ce, - 0x31ec8e, - 0x31ec94, - 0x31f7cf, - 0x31fb86, - 0x250751, - 0x3086d3, - 0x308b48, - 0x321585, - 0x359ec8, - 0x20f3c5, - 0x22964c, - 0x256789, - 0x22ac09, - 0x241147, - 0x214989, - 0x24ff47, - 0x2b6106, - 0x37db47, - 0x2605c5, - 0x310b83, - 0x260149, - 0x227409, - 0x378d03, - 0x3abb84, - 0x38004d, - 0x3810cf, - 0x3005c5, - 0x3188c6, - 0x20d147, - 0x303d07, - 0x289946, - 0x28994b, - 0x2a2085, - 0x257ec6, - 0x209247, - 0x273949, - 0x3358c6, - 0x210805, - 0x22400b, - 0x37f406, - 0x249885, - 0x39f588, - 0x2b5cc8, - 0x2b6b4c, - 0x2b6b50, - 0x2ca9c9, - 0x2f8587, - 0x2de9cb, - 0x2d59c6, - 0x2d740a, - 0x2d860b, - 0x2d918a, - 0x2d9406, - 0x2d9e45, - 0x2cf686, - 0x27c708, - 0x24120a, - 0x36cd9c, - 0x2e104c, - 0x2e1348, - 0x25b1c5, - 0x2e51c7, - 0x29e046, - 0x399445, - 0x21ea46, - 0x289b08, - 0x2b5247, - 0x29e308, - 0x2a5cca, - 0x321f8c, - 0x322209, - 0x20a147, - 0x20c544, - 0x245846, - 0x3777ca, - 0x2b88c5, - 0x3a2c8c, - 0x3a5088, - 0x350b48, - 0x20da4c, - 0x213c4c, - 0x2162c9, - 0x216507, - 0x2c7e0c, - 0x32f644, - 0x39080a, - 0x20b80c, - 0x274d8b, - 0x23a28b, - 0x23b346, - 0x23df07, - 0x22e547, - 0x22e54f, - 0x2f4311, - 0x3b1ad2, - 0x23eecd, - 0x23eece, - 0x23f20e, - 0x31f988, - 0x31f992, - 0x242e48, - 0x2fc287, - 0x24a88a, - 0x20fd88, - 0x34adc5, - 0x2f164a, - 0x220587, - 0x2e6e04, - 0x24ddc3, - 0x376a45, - 0x2b4e07, - 0x2fa347, - 0x2b388e, - 0x38708d, - 0x39b189, - 0x216845, - 0x2ea903, - 0x25f8c6, - 0x36ba85, - 0x309008, - 0x2eb049, - 0x25a845, - 0x25a84f, - 0x2d9c87, - 0x2f9445, - 0x271d8a, - 0x3a2986, - 0x21db89, - 0x2ec3cc, - 0x2ee449, - 0x203f46, - 0x2aa5cc, - 0x2eea06, - 0x2f19c8, - 0x2f1bc6, - 0x2dd906, - 0x24fa84, - 0x25a083, - 0x35efca, - 0x31e391, - 0x27faca, - 0x327f85, - 0x38ec47, - 0x251b47, - 0x28e1c4, - 0x28e1cb, - 0x316648, + 0x204643, + 0x24da85, + 0x297b47, + 0x3274c6, + 0x399d89, + 0x309946, + 0x281c86, + 0x37d649, + 0x281449, + 0x29dd87, + 0x310e88, + 0x28f009, + 0x27f608, + 0x320146, + 0x2cd085, + 0x30888a, + 0x281d06, + 0x37df46, + 0x2a0d45, + 0x387ac8, + 0x20e647, + 0x3abe8a, + 0x244b06, + 0x2e7805, + 0x365bc6, + 0x326787, + 0x24b147, + 0x2bbb85, + 0x2bdfc5, + 0x29e106, + 0x2acd46, + 0x387106, + 0x330844, + 0x2809c9, + 0x287a46, + 0x28c58a, + 0x2171c8, + 0x335d48, + 0x35504a, + 0x359445, + 0x299f05, + 0x382a08, + 0x2c9888, + 0x332447, + 0x2023c6, + 0x313d48, + 0x2e1447, + 0x27ec88, + 0x368d46, + 0x282f08, 0x2b2886, - 0x235fc5, - 0x265904, - 0x269ac9, - 0x27a984, - 0x3041c7, - 0x2ee645, - 0x2ee647, - 0x3274c5, - 0x2a8283, - 0x2fc148, - 0x325c0a, - 0x2643c3, - 0x34318a, - 0x274386, - 0x25a5cf, - 0x358f89, - 0x2de290, - 0x2e1848, - 0x2c5909, - 0x298347, - 0x37418f, - 0x330bc4, - 0x2c81c4, - 0x21b386, - 0x275746, - 0x2ff74a, - 0x32b746, - 0x33e787, - 0x2f8b48, - 0x2f8d47, - 0x2f9747, - 0x34da8a, - 0x2fbf8b, - 0x238845, - 0x3b1708, - 0x22aec3, - 0x36524c, - 0x38d68f, - 0x2b038d, - 0x2ef707, - 0x39b2c9, - 0x22cb47, - 0x240008, - 0x382ccc, - 0x272988, - 0x2511c8, - 0x30d64e, - 0x31d014, - 0x31d524, - 0x33ee8a, - 0x35d98b, - 0x250004, - 0x250009, - 0x3a7088, - 0x245a05, - 0x25fa8a, - 0x265107, - 0x2cf584, - 0x327883, - 0x22bf83, - 0x234a44, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x202243, - 0x220ec3, - 0x2cc586, - 0x211004, - 0x24c083, - 0x204703, - 0x21d603, + 0x238847, + 0x296c86, + 0x2b8306, + 0x23280a, + 0x381fc6, + 0x2cd089, + 0x2ae506, + 0x2d180a, + 0x301049, + 0x2f0746, + 0x386bc4, + 0x31b30d, + 0x286e07, + 0x3163c6, + 0x2b9585, + 0x2ee545, + 0x31b806, + 0x26f609, + 0x2db807, + 0x278606, + 0x2c6606, + 0x285d89, + 0x2bf544, + 0x22a504, + 0x203888, + 0x249c86, + 0x26f188, + 0x27ba08, + 0x282987, + 0x200849, + 0x387307, + 0x2ae0ca, + 0x27b3cf, + 0x243b4a, + 0x222085, + 0x277785, + 0x214cc5, + 0x2aeb07, + 0x205d83, + 0x311088, + 0x2f43c6, + 0x2f44c9, + 0x2af546, + 0x2c3807, + 0x296009, + 0x37fc88, + 0x2a0e07, + 0x2ffa83, + 0x336b85, + 0x205d05, + 0x33068b, + 0x267ac4, + 0x2d2d44, + 0x276106, + 0x2ffe07, + 0x39814a, + 0x242487, + 0x234d47, + 0x27d805, + 0x2041c5, + 0x224a49, + 0x2b8306, + 0x24230d, + 0x358585, + 0x3029c3, + 0x206c43, + 0x346ec5, + 0x34d7c5, + 0x2de448, + 0x279047, + 0x22a286, + 0x29b9c6, + 0x22a845, + 0x230a07, + 0x202e07, + 0x3627c7, + 0x2c9b8a, + 0x249008, + 0x330844, + 0x3876c7, + 0x27a547, + 0x32ed06, + 0x266307, + 0x2b1708, + 0x35e7c8, + 0x26d246, + 0x264788, + 0x234b44, + 0x3287c6, + 0x20f646, + 0x3658c6, + 0x3478c6, + 0x29bf44, + 0x3643c6, + 0x2b8506, + 0x294d86, + 0x22adc6, + 0x206b06, + 0x2b1546, + 0x22a188, + 0x2fbcc8, + 0x2ca688, + 0x260788, + 0x382986, + 0x20dd85, + 0x277d06, + 0x2ac385, + 0x388d07, + 0x23dcc5, + 0x213a43, + 0x200e85, + 0x22a744, + 0x206c45, + 0x212b83, + 0x2f2b47, + 0x31a8c8, + 0x37c806, + 0x36918d, + 0x277746, + 0x293ec5, + 0x2bab83, + 0x2b4649, + 0x2bf6c6, + 0x2944c6, + 0x29d644, + 0x243ac7, + 0x231e86, + 0x387905, + 0x2327c3, + 0x203d04, + 0x27a706, + 0x2d2f44, + 0x30bc88, + 0x397609, + 0x342189, + 0x29d44a, + 0x23ac0d, + 0x30ee07, + 0x37ddc6, + 0x20d9c4, + 0x212609, + 0x2851c8, + 0x286a06, + 0x261386, + 0x266307, + 0x2bff86, + 0x21b206, + 0x397906, + 0x39f74a, + 0x217788, + 0x22d785, + 0x2826c9, + 0x27f18a, + 0x369508, + 0x299548, + 0x294448, + 0x20320c, + 0x2e5085, + 0x29bc48, + 0x309346, + 0x2d1186, + 0x375e47, + 0x242385, + 0x281bc5, + 0x342049, + 0x212287, + 0x2b1bc5, + 0x21cc87, + 0x206c43, + 0x2bebc5, + 0x37eb08, + 0x2ce187, + 0x299409, + 0x2d4005, + 0x2fb844, + 0x29f308, + 0x20be47, + 0x2a0fc8, + 0x329fc8, + 0x2ebdc5, + 0x240dc6, + 0x264e46, + 0x2e3109, + 0x3145c7, + 0x2ac786, + 0x31c787, + 0x212a03, + 0x257284, + 0x29b305, + 0x257444, + 0x33e8c4, + 0x248687, + 0x206287, + 0x2787c4, + 0x299250, + 0x322187, + 0x2041c5, + 0x33df0c, + 0x2b77c4, + 0x2f9648, + 0x238749, + 0x300546, + 0x227d08, + 0x259404, + 0x259408, + 0x388046, + 0x22ac48, + 0x29b006, + 0x2c89cb, + 0x204645, + 0x2c4a08, + 0x216cc4, + 0x28074a, + 0x299409, + 0x227e86, + 0x2d6cc8, + 0x256405, + 0x2ff184, + 0x2f9546, + 0x362688, + 0x280048, + 0x344586, + 0x325944, + 0x308806, + 0x387387, + 0x276d47, + 0x26630f, + 0x2074c7, + 0x2f0807, + 0x2d1045, + 0x2ec8c5, + 0x29da49, + 0x28c246, + 0x27e005, + 0x281747, + 0x2d6f88, + 0x294e85, + 0x296c86, + 0x217008, + 0x2087ca, + 0x2845c8, + 0x3adfc7, + 0x27b806, + 0x282686, + 0x205303, + 0x20d383, + 0x27f349, + 0x28ee89, + 0x2ab0c6, + 0x2d4005, + 0x2a4188, + 0x2d6cc8, + 0x2b9ec8, + 0x39798b, + 0x3693c7, + 0x2fdd89, + 0x266588, + 0x338944, + 0x2c4fc8, + 0x28a9c9, + 0x2aca85, + 0x2aea07, + 0x2f49c5, + 0x27ff48, + 0x28d14b, + 0x292050, + 0x2a7785, + 0x216c0c, + 0x22a445, + 0x209203, + 0x2a6a46, + 0x2b6d84, + 0x32e086, + 0x299fc7, + 0x212a44, + 0x23c808, + 0x310f4d, + 0x2d6b85, + 0x23b104, + 0x221dc4, + 0x282149, + 0x2a06c8, + 0x3097c7, + 0x3880c8, + 0x280a88, + 0x278905, + 0x262a87, + 0x278887, + 0x2f5007, + 0x2bdfc9, + 0x231d09, + 0x23a6c6, + 0x2b26c6, + 0x266546, + 0x25a505, + 0x3b1504, + 0x203506, + 0x203a86, + 0x278948, + 0x32644b, + 0x267f07, + 0x20d9c4, + 0x316846, + 0x209047, + 0x346805, + 0x3179c5, + 0x204884, + 0x231c86, + 0x203588, + 0x212609, + 0x2559c6, + 0x284b48, + 0x3879c6, + 0x32f5c8, + 0x2b010c, + 0x2787c6, + 0x293b8d, + 0x29400b, + 0x36e585, + 0x202f47, + 0x234bc6, + 0x24b008, + 0x23a749, + 0x2e2d48, + 0x2041c5, + 0x2ed607, + 0x27f708, + 0x3a2509, + 0x240686, + 0x36e2ca, + 0x24ad88, + 0x2e2b8b, + 0x2cb44c, + 0x259508, + 0x279e46, + 0x262488, + 0x207607, + 0x231f89, + 0x28f8cd, + 0x29a486, + 0x3a5348, + 0x2fbb89, + 0x2b5048, + 0x283008, + 0x2b8dcc, + 0x2ba0c7, + 0x2badc7, + 0x2bde05, + 0x2e9d47, + 0x2d6e48, + 0x2f95c6, + 0x25584c, + 0x2e22c8, + 0x2c5f48, + 0x361fc6, + 0x205a87, + 0x23a8c4, + 0x260788, + 0x35748c, + 0x21f70c, + 0x222105, + 0x3943c7, + 0x3258c6, + 0x205a06, + 0x2948c8, + 0x3a3584, + 0x2298cb, + 0x22264b, + 0x27b806, + 0x310dc7, + 0x261f45, + 0x26e545, + 0x229a06, + 0x2563c5, + 0x267a85, + 0x376107, + 0x276709, + 0x233444, + 0x35ec85, + 0x2d53c5, + 0x24f708, + 0x229245, + 0x2a6549, + 0x2c2f87, + 0x2c2f8b, + 0x2d0746, + 0x229ec9, + 0x305948, + 0x27e545, + 0x2f5108, + 0x231d48, + 0x218687, + 0x282547, + 0x248709, + 0x22ab87, + 0x374bc9, + 0x2a910c, + 0x2ab0c8, + 0x3af2c9, + 0x2b5447, + 0x280b49, + 0x2063c7, + 0x2cb548, + 0x24fa45, + 0x328746, + 0x2b95c8, + 0x2d4d08, + 0x27f049, + 0x267ac7, + 0x26e605, + 0x2112c9, + 0x2c0406, + 0x28cb44, + 0x2e2a06, + 0x241a48, + 0x244507, + 0x326648, + 0x264849, + 0x361d47, + 0x29ad86, + 0x203004, + 0x200f09, + 0x262908, + 0x361e87, + 0x30fec6, + 0x205dc6, + 0x37dec4, + 0x2a7b86, + 0x206bc3, + 0x355e89, + 0x204606, + 0x29f785, + 0x29b9c6, + 0x2a1105, + 0x27fb88, + 0x259247, + 0x364146, + 0x327646, + 0x335d48, + 0x29dbc7, + 0x29a4c5, + 0x29bec8, + 0x38b7c8, + 0x24ad88, + 0x22a305, + 0x3287c6, + 0x341f49, + 0x264cc4, + 0x37238b, + 0x21af0b, + 0x22d689, + 0x206c43, + 0x250645, + 0x20dc46, + 0x2585c8, + 0x27b344, + 0x37c806, + 0x2c9cc9, + 0x2c5d45, + 0x376046, + 0x20be46, + 0x202344, + 0x2996ca, + 0x29f6c8, + 0x2d4d06, + 0x24c0c5, + 0x20c807, + 0x22ff87, + 0x240dc4, + 0x21b147, + 0x23dc84, + 0x23dc86, + 0x217143, + 0x2bdfc5, + 0x370105, + 0x20c1c8, + 0x257385, + 0x278509, + 0x2605c7, + 0x2605cb, + 0x2a098c, + 0x2a200a, + 0x2bf387, + 0x201043, + 0x2e3688, + 0x22a4c5, + 0x294f05, + 0x336c44, + 0x2cb446, + 0x238746, + 0x2a7bc7, + 0x38c5cb, + 0x29bf44, + 0x37ff04, + 0x26d3c4, + 0x2c4746, + 0x212a44, + 0x2021c8, + 0x336a45, + 0x23b245, + 0x2b9e07, + 0x203049, + 0x34d7c5, + 0x371d0a, + 0x2d70c9, + 0x299b0a, + 0x39f889, + 0x385304, + 0x2c66c5, + 0x2c0088, + 0x37458b, + 0x2fa145, + 0x27bb86, + 0x21a544, + 0x278a46, + 0x361bc9, + 0x316907, + 0x309b08, + 0x23af86, + 0x387307, + 0x280048, + 0x38f206, + 0x23e684, + 0x360487, + 0x3458c5, + 0x34ba07, + 0x203604, + 0x234b46, + 0x217a08, + 0x2941c8, + 0x2e9ac7, + 0x212a48, + 0x2b2945, + 0x206a84, + 0x354f48, + 0x212b44, + 0x214c45, + 0x2eca04, + 0x2e1547, + 0x287b07, + 0x280c88, + 0x2a1146, + 0x257305, + 0x278308, + 0x2847c8, + 0x29d389, + 0x21b206, + 0x3abf08, + 0x2805ca, + 0x346888, + 0x2d6205, + 0x277f06, + 0x26f4c8, + 0x2ed6ca, + 0x305b47, + 0x2855c5, + 0x292848, + 0x2ad704, + 0x387b46, + 0x2bb548, + 0x206b06, + 0x359748, + 0x264b07, + 0x201a06, + 0x386bc4, + 0x37bdc7, + 0x2fefc4, + 0x361b87, + 0x2de18d, + 0x22d705, + 0x2cdf8b, + 0x29b106, + 0x248408, + 0x23c7c4, + 0x275446, + 0x27a706, + 0x2627c7, + 0x29384d, + 0x2a9dc7, + 0x302908, + 0x247705, + 0x2a7d08, + 0x2be606, + 0x2b29c8, + 0x211dc6, + 0x263f87, + 0x281009, + 0x339b47, + 0x286cc8, + 0x271705, + 0x21a888, + 0x205945, + 0x235cc5, + 0x358e45, + 0x222383, + 0x281ac4, + 0x2826c5, + 0x2d7ac9, + 0x324e86, + 0x2b1808, + 0x3a9485, + 0x32c607, + 0x246e0a, + 0x375f89, + 0x2a854a, + 0x2ca708, + 0x21cacc, + 0x2817cd, + 0x304983, + 0x359648, + 0x203cc5, + 0x208586, + 0x37fb06, + 0x2d5d45, + 0x31c889, + 0x355305, + 0x278308, + 0x251a46, + 0x33a446, + 0x29f1c9, + 0x38ea07, + 0x28d406, + 0x246d88, + 0x3657c8, + 0x2cf747, + 0x22adce, + 0x2be845, + 0x3a2405, + 0x206a08, + 0x326d87, + 0x205e02, + 0x2b8944, + 0x32df8a, + 0x361f48, + 0x209146, + 0x296148, + 0x264e46, + 0x323348, + 0x2ac788, + 0x235c84, + 0x3304c5, + 0x685844, + 0x685844, + 0x685844, + 0x2031c3, + 0x205c46, + 0x2787c6, + 0x29a74c, + 0x201a43, + 0x27f186, + 0x217104, + 0x2bf648, + 0x2c9b05, + 0x32e086, + 0x2b4d88, + 0x2cb746, + 0x3640c6, + 0x323848, + 0x29b387, + 0x22a949, + 0x2c864a, + 0x26aa44, + 0x23dcc5, + 0x2a7105, + 0x212406, + 0x30ee46, + 0x2a4586, + 0x2eb986, + 0x22aa84, + 0x22aa8b, + 0x22ff84, + 0x20c885, + 0x2ab645, + 0x282a46, + 0x3aae88, + 0x281687, + 0x3098c4, + 0x258903, + 0x2ad205, + 0x2e28c7, + 0x2a2609, + 0x28158b, + 0x2a7bc7, + 0x20c0c7, + 0x2b4c88, + 0x32c747, + 0x2a2846, + 0x23e408, + 0x2a478b, + 0x2e7c86, + 0x212d09, + 0x2a4905, + 0x2ffa83, + 0x376046, + 0x264a08, + 0x211e83, + 0x234c83, + 0x280046, + 0x264e46, + 0x38b18a, + 0x279e85, + 0x27a54b, + 0x29b90b, + 0x23bf83, + 0x21b543, + 0x2ae044, + 0x2643c7, + 0x259504, + 0x203204, + 0x3091c4, + 0x346b88, + 0x24c008, + 0x31c1c9, + 0x38ddc8, + 0x39fc07, + 0x22adc6, + 0x2b144f, + 0x2be986, + 0x2c9a84, + 0x24be4a, + 0x2e27c7, + 0x3b3246, + 0x28cb89, + 0x31c145, + 0x20c305, + 0x31c286, + 0x21a9c3, + 0x2ad749, + 0x217906, + 0x264609, + 0x398146, + 0x2bdfc5, + 0x222505, + 0x205cc3, + 0x264508, + 0x228b07, + 0x2f43c4, + 0x2bf4c8, + 0x2b8084, + 0x2c6f86, + 0x2a6a46, + 0x239786, + 0x2c48c9, + 0x294e85, + 0x2b8306, + 0x2667c9, + 0x3ae786, + 0x2b1546, + 0x386f46, + 0x2104c5, + 0x2eca06, + 0x263f84, + 0x24fa45, + 0x2b95c4, + 0x3090c6, + 0x358544, + 0x2064c3, + 0x285285, + 0x231a48, + 0x223947, + 0x2b3249, + 0x2854c8, + 0x295911, + 0x20beca, + 0x27b747, + 0x2edf06, + 0x217104, + 0x2b96c8, + 0x283b88, + 0x295aca, + 0x2a630d, + 0x27ba86, + 0x323946, + 0x37be86, + 0x2bba07, + 0x3029c5, + 0x254587, + 0x2bf585, + 0x2c30c4, + 0x2a5d46, + 0x328607, + 0x2ad44d, + 0x26f407, + 0x26d688, + 0x278609, + 0x277e06, + 0x240605, + 0x2145c4, + 0x241b46, + 0x240cc6, + 0x3620c6, + 0x298c48, + 0x210383, + 0x24f943, + 0x30fb85, + 0x31e686, + 0x2ac745, + 0x23b188, + 0x29a18a, + 0x30f304, + 0x2bf648, + 0x294448, + 0x282887, + 0x3a9549, + 0x2b4988, + 0x212687, + 0x26c106, + 0x206b0a, + 0x241bc8, + 0x2cb289, + 0x2a0788, + 0x217f09, + 0x2e2e47, + 0x2eb385, + 0x35ea46, + 0x2f9448, + 0x323a48, + 0x24db48, + 0x214d88, + 0x20c885, + 0x200884, + 0x228808, + 0x2bcbc4, + 0x39f684, + 0x2bdfc5, + 0x28e6c7, + 0x202e09, + 0x2625c7, + 0x280605, + 0x276306, + 0x33d146, + 0x208944, + 0x29f506, + 0x387644, + 0x283a86, + 0x3a3646, + 0x213106, + 0x2041c5, + 0x23b047, + 0x201043, + 0x33f949, + 0x335b48, + 0x212504, + 0x21250d, + 0x2942c8, + 0x381ac8, + 0x2cb206, + 0x281109, + 0x375f89, + 0x3618c5, + 0x29a28a, + 0x287cca, + 0x34c08c, + 0x34c206, + 0x276bc6, + 0x2beb06, + 0x26aa09, + 0x2087c6, + 0x2545c6, + 0x3553c6, + 0x260788, + 0x212a46, + 0x2c4c0b, + 0x28e845, + 0x23b245, + 0x276e45, + 0x2028c6, + 0x206ac3, + 0x239706, + 0x26f387, + 0x2b9585, + 0x23f105, + 0x2ee545, + 0x344986, + 0x30ce84, + 0x30ce86, + 0x293089, + 0x20274c, + 0x2c2e08, + 0x2931c4, + 0x2ec7c6, + 0x29b206, + 0x264a08, + 0x2d6cc8, + 0x202649, + 0x20c807, + 0x2499c9, + 0x247c06, + 0x22e244, + 0x20e304, + 0x27fe44, + 0x280048, + 0x202c4a, + 0x34d746, + 0x3514c7, + 0x22ce47, + 0x229fc5, + 0x2a70c4, + 0x28a986, + 0x302a06, + 0x231f43, + 0x335987, + 0x329ec8, + 0x361a0a, + 0x2cc1c8, + 0x30f188, + 0x358585, + 0x36e685, + 0x268005, + 0x22a386, + 0x37c246, + 0x2061c5, + 0x3560c9, + 0x2a6ecc, + 0x2680c7, + 0x295b48, + 0x2d6085, + 0x685844, + 0x20a104, + 0x2ce2c4, + 0x2c1786, + 0x29c48e, + 0x20c387, + 0x2bbc05, + 0x264c4c, + 0x2b7f47, + 0x328587, + 0x328f89, + 0x215a49, + 0x2855c5, + 0x335b48, + 0x341f49, + 0x2ea885, + 0x2b94c8, + 0x2c51c6, + 0x3551c6, + 0x301044, + 0x2a2408, + 0x245603, + 0x353b84, + 0x2ad285, + 0x31b807, + 0x209505, + 0x280489, + 0x38ba8d, + 0x2a53c6, + 0x35c244, + 0x202348, + 0x27654a, + 0x3b17c7, + 0x235385, + 0x208d03, + 0x29bace, + 0x264e4c, + 0x2fa487, + 0x29c647, + 0x203643, + 0x208805, + 0x2ce2c5, + 0x296508, + 0x292689, + 0x362506, + 0x259504, + 0x27b686, + 0x36558b, + 0x2eebcc, + 0x262347, + 0x2c97c5, + 0x38b6c8, + 0x2cf505, + 0x24be47, + 0x2404c7, + 0x245605, + 0x206ac3, + 0x36c2c4, + 0x20d285, + 0x2ace05, + 0x2ace06, + 0x2908c8, + 0x328607, + 0x37fe06, + 0x208486, + 0x358d86, + 0x3262c9, + 0x262b87, + 0x362386, + 0x2eed46, + 0x2456c6, + 0x2a7a85, + 0x20a206, + 0x399745, + 0x2292c8, + 0x291c8b, + 0x28a786, + 0x22ce84, + 0x2ed489, + 0x2605c4, + 0x2c5148, + 0x2f0e87, + 0x282f04, + 0x2b3b88, + 0x2ba684, + 0x2a7ac4, + 0x3a93c5, + 0x2d6bc6, + 0x346ac7, + 0x23b0c3, + 0x29ae45, + 0x2f4944, + 0x3a2446, + 0x361948, + 0x323745, + 0x28e149, + 0x2114c5, + 0x2f4bc8, + 0x326007, + 0x388e48, + 0x2b3087, + 0x2f08c9, + 0x364246, + 0x35aec6, + 0x28f144, + 0x26c045, + 0x2f300c, + 0x276e47, + 0x277647, + 0x22cd08, + 0x2a53c6, + 0x26f2c4, + 0x2eae44, + 0x248589, + 0x2bec06, + 0x224ac7, + 0x347844, + 0x324f86, + 0x328185, + 0x2a0c87, + 0x2c4b86, + 0x36e189, + 0x34bec7, + 0x266307, + 0x29f046, + 0x23ab05, + 0x27de88, + 0x217788, + 0x237a86, + 0x323785, + 0x255106, + 0x201b83, + 0x296389, + 0x2a430e, + 0x2b1e88, + 0x2b8188, + 0x23788b, + 0x28e386, + 0x30eac4, + 0x2813c4, + 0x2a440a, + 0x216b07, + 0x362445, + 0x212d09, + 0x2b85c5, + 0x39f6c7, + 0x300344, + 0x397787, + 0x27b908, + 0x2c6cc6, + 0x3a54c9, + 0x2b4a8a, + 0x216a86, + 0x293e06, + 0x2ab5c5, + 0x379fc5, + 0x333207, + 0x23f608, + 0x3280c8, + 0x235c86, + 0x222585, + 0x30ebce, + 0x330844, + 0x237a05, + 0x275c89, + 0x28c048, + 0x3adf06, + 0x2988cc, + 0x299d90, + 0x29c0cf, + 0x29d948, + 0x2bf387, + 0x2041c5, + 0x2826c5, + 0x346949, + 0x292a49, + 0x308906, + 0x2fa1c7, + 0x394345, + 0x332449, + 0x32ed86, + 0x20860d, + 0x27fd09, + 0x203204, + 0x2b1c08, + 0x2288c9, + 0x34d906, + 0x276405, + 0x35aec6, + 0x3099c9, + 0x27c808, + 0x20dd85, + 0x2806c4, + 0x298a8b, + 0x34d7c5, + 0x258646, + 0x281b06, + 0x265cc6, + 0x397b8b, + 0x28e249, + 0x206505, + 0x388c07, + 0x20be46, + 0x2de086, + 0x280348, + 0x26c209, + 0x26d44c, + 0x2e26c8, + 0x34da06, + 0x344583, + 0x2aec06, + 0x282385, + 0x27a888, + 0x221f86, + 0x2a0ec8, + 0x242505, + 0x212785, + 0x2998c8, + 0x2300c7, + 0x37fa47, + 0x2a7bc7, + 0x227d08, + 0x28cd48, + 0x26a386, + 0x308f07, + 0x257147, + 0x28224a, + 0x247b03, + 0x2028c6, + 0x202d85, + 0x32df84, + 0x278609, + 0x2f0844, + 0x2239c4, + 0x29b084, + 0x29c64b, + 0x228a47, + 0x30ee05, + 0x291b08, + 0x276306, + 0x276308, + 0x279dc6, + 0x289145, + 0x289a85, + 0x28b4c6, + 0x28c808, + 0x28cac8, + 0x2787c6, + 0x29194f, + 0x295e50, + 0x399e85, + 0x201043, + 0x247645, + 0x2fdcc8, + 0x292949, + 0x24ad88, + 0x326148, + 0x37d988, + 0x228b07, + 0x275fc9, + 0x2a10c8, + 0x2d3d44, + 0x29af08, + 0x24f7c9, + 0x30d4c7, + 0x297c84, + 0x262688, + 0x23ae0a, + 0x2c45c6, + 0x27ba86, + 0x21b0c9, + 0x299fc7, + 0x2c5548, + 0x3999c8, + 0x3476c8, + 0x351005, + 0x37af45, + 0x23b245, + 0x2ce285, + 0x32b287, + 0x206ac5, + 0x2b9585, + 0x3a8606, + 0x24acc7, + 0x3744c7, + 0x23b106, + 0x2cac45, + 0x258646, + 0x2592c5, + 0x2b7dc8, + 0x324e04, + 0x3ae806, + 0x2e4684, + 0x2ff188, + 0x3ae90a, + 0x27904c, + 0x38c7c5, + 0x2bbac6, + 0x26d606, + 0x3297c6, + 0x2fdec4, + 0x328445, + 0x279c07, + 0x29a049, + 0x2a2707, + 0x685844, + 0x685844, + 0x309745, + 0x227084, + 0x29828a, + 0x276186, + 0x2e2b04, + 0x3b31c5, + 0x2f8f45, + 0x302904, + 0x281747, + 0x211447, + 0x2c4748, + 0x317c48, + 0x20dd89, + 0x32ee88, + 0x29844b, + 0x212404, + 0x35e3c5, + 0x27e085, + 0x2a7b49, + 0x26c209, + 0x2ed388, + 0x23da88, + 0x282a44, + 0x29b245, + 0x202c83, + 0x2123c5, + 0x2b8386, + 0x2924cc, + 0x217806, + 0x259306, + 0x292685, + 0x344a08, + 0x2eee46, + 0x2ee086, + 0x27ba86, + 0x2260cc, + 0x362284, + 0x358eca, + 0x3ae0c8, + 0x292307, + 0x23e586, + 0x3625c7, + 0x2de9c5, + 0x30fec6, + 0x34fbc6, + 0x37f907, + 0x223a04, + 0x2e1645, + 0x275c84, + 0x2c3147, + 0x275ec8, + 0x276a4a, + 0x27f587, + 0x237c07, + 0x2bf307, + 0x2cf649, + 0x2924ca, + 0x22aa43, + 0x223905, + 0x213143, + 0x309209, + 0x22e988, + 0x2d1047, + 0x24ae89, + 0x217886, + 0x2af648, + 0x2f2ac5, + 0x2848ca, + 0x321f89, + 0x26d109, + 0x375e47, + 0x283c89, + 0x213008, + 0x2ecb86, + 0x2bbc88, + 0x2104c7, + 0x22ab87, + 0x2d70c7, + 0x2d0ec8, + 0x2ec646, + 0x23abc5, + 0x279c07, + 0x293908, + 0x358d04, + 0x28c444, + 0x28d307, + 0x2acb07, + 0x341dca, + 0x2ecb06, + 0x2fa30a, + 0x2b8887, + 0x330607, + 0x235d84, + 0x374c84, + 0x22c5c6, + 0x3558c4, + 0x3558cc, + 0x3a8d05, + 0x214bc9, + 0x2f4d44, + 0x3029c5, + 0x2764c8, + 0x28cb85, + 0x31b806, + 0x20f544, + 0x298fca, + 0x2d2e46, + 0x28ceca, + 0x31b5c7, + 0x2c8ac5, + 0x21a9c5, + 0x22a00a, + 0x29f605, + 0x29d446, + 0x2bcbc4, + 0x2ae1c6, + 0x3332c5, + 0x222046, + 0x2e9acc, + 0x2c56ca, + 0x26c104, + 0x22adc6, + 0x299fc7, + 0x2c8e84, + 0x260788, + 0x38dc46, + 0x30ea49, + 0x2c2949, + 0x2ab1c9, + 0x372546, + 0x2105c6, + 0x2bbdc7, + 0x356008, + 0x2103c9, + 0x228a47, + 0x2b27c6, + 0x387387, + 0x37bd45, + 0x330844, + 0x2bb987, + 0x2f49c5, + 0x285fc5, + 0x33b2c7, + 0x2454c8, + 0x38b646, + 0x294bcd, + 0x29670f, + 0x29b90d, + 0x20bf44, + 0x231b46, + 0x2cc508, + 0x355385, + 0x282408, + 0x21854a, + 0x203204, + 0x3a5686, + 0x28bbc7, + 0x3a6207, + 0x29b449, + 0x2bbc45, + 0x302904, + 0x33040a, + 0x2b4549, + 0x283d87, + 0x269846, + 0x34d906, + 0x29b186, + 0x360546, + 0x2cbe8f, + 0x2cc3c9, + 0x212a46, + 0x3a6606, + 0x274d09, + 0x309007, + 0x214603, + 0x226246, + 0x20d383, + 0x2d5c08, + 0x3871c7, + 0x29db49, + 0x2a68c8, + 0x37fb88, + 0x267c06, + 0x240b09, + 0x2c7ac5, + 0x23e584, + 0x2eb447, + 0x26aa85, + 0x20bf44, + 0x30eec8, + 0x216dc4, + 0x3078c7, + 0x31a846, + 0x29e1c5, + 0x2a0788, + 0x34d7cb, + 0x336047, + 0x22a286, + 0x2bea04, + 0x31d686, + 0x2bdfc5, + 0x2f49c5, + 0x27dc09, + 0x281349, + 0x22abc4, + 0x22ac05, + 0x22ae05, + 0x284746, + 0x335c48, + 0x2b7106, + 0x329d0b, + 0x3003ca, + 0x2ff0c5, + 0x289b06, + 0x2f40c5, + 0x2065c5, + 0x2945c7, + 0x203888, + 0x2499c4, + 0x3617c6, + 0x28cb46, + 0x2131c7, + 0x2ffa44, + 0x27a706, + 0x36d285, + 0x36d289, + 0x2107c4, + 0x2a7249, + 0x2787c6, + 0x2ba188, + 0x22ae05, + 0x22cf45, + 0x222046, + 0x26d349, + 0x215a49, + 0x259386, + 0x28c148, + 0x264d48, + 0x2f4084, + 0x360a44, + 0x360a48, + 0x3164c8, + 0x249ac9, + 0x2b8306, + 0x27ba86, + 0x313c0d, + 0x37c806, + 0x2affc9, + 0x202a85, + 0x31c286, + 0x2546c8, + 0x30cdc5, + 0x257184, + 0x2bdfc5, + 0x280e88, + 0x298049, + 0x275d44, + 0x234b46, + 0x2e2f8a, + 0x369508, + 0x341f49, + 0x2de5ca, + 0x24ae06, + 0x2968c8, + 0x24bc05, + 0x321e08, + 0x2b3185, + 0x217749, + 0x366f89, + 0x228c42, + 0x2a4905, + 0x26e286, + 0x278707, + 0x3ace45, + 0x2e7706, + 0x2f7f88, + 0x2a53c6, + 0x2bff49, + 0x277746, + 0x2801c8, + 0x2a8885, + 0x246546, + 0x264088, + 0x280048, + 0x3a36c8, + 0x2fd4c8, + 0x20a204, + 0x22a803, + 0x2c0184, + 0x27b606, + 0x37bd84, + 0x2b80c7, + 0x2edf89, + 0x2be205, + 0x3999c6, + 0x226246, + 0x29070b, + 0x2ff006, + 0x317006, + 0x2c3688, + 0x23f046, + 0x2a6603, + 0x209fc3, + 0x330844, + 0x3abe05, + 0x387807, + 0x275ec8, + 0x275ecf, + 0x279b0b, + 0x335a48, + 0x234bc6, + 0x335d4e, + 0x222043, + 0x2db944, + 0x2fef85, + 0x300c06, + 0x28aa8b, + 0x28e786, + 0x217089, + 0x29e1c5, + 0x38a288, + 0x20d588, + 0x21590c, + 0x29c686, + 0x212406, + 0x2d4005, + 0x286a88, + 0x24b145, + 0x338948, + 0x29bd4a, + 0x35e8c9, + 0x685844, + 0x2f604a82, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x323743, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x249943, + 0x2257c3, + 0x224283, + 0x224284, + 0x258403, + 0x232ec4, + 0x230743, + 0x2afc84, + 0x2d9d43, + 0x3ad107, + 0x219bc3, + 0x202883, + 0x251b48, + 0x2257c3, + 0x2db58b, + 0x2df103, + 0x23d1c6, + 0x201582, + 0x385c4b, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x2257c3, + 0x29ca03, + 0x206883, 0x200882, - 0x327883, - 0x206a82, - 0x22bf83, - 0x234a44, - 0x231b03, - 0x250cc3, - 0x202243, - 0x2cc586, - 0x24c083, - 0x204703, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x24c083, - 0x204703, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x211004, - 0x24c083, - 0x204703, - 0x722f48, - 0x201482, + 0x894c8, + 0x354045, + 0x2d3b88, + 0x2d88c8, + 0x204a82, + 0x365cc5, + 0x33f707, + 0x200202, + 0x23ca07, + 0x2095c2, + 0x237647, + 0x265389, + 0x3173c8, + 0x347549, + 0x331282, + 0x2672c7, + 0x259104, + 0x33f7c7, + 0x3002c7, + 0x23f402, + 0x219bc3, + 0x20dc02, + 0x201cc2, + 0x2016c2, + 0x200ac2, + 0x2058c2, + 0x2057c2, + 0x2a8405, + 0x20a045, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x481, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x202503, + 0x249943, + 0x2257c3, + 0x20f0c3, + 0x3216cdc6, + 0x110083, + 0x7efc5, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x204a82, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x9f82, + 0x894c8, + 0x3f5c4, + 0xcf905, + 0x200882, + 0x2bb244, + 0x258403, + 0x230743, + 0x2d9d43, + 0x268583, + 0x2a8f85, + 0x202503, + 0x332283, + 0x249943, + 0x209583, + 0x2257c3, + 0x2161c3, + 0x224303, + 0x224043, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x204a82, + 0x2257c3, + 0x894c8, + 0x2d9d43, + 0x894c8, + 0x2c69c3, + 0x258403, + 0x22ec84, + 0x230743, + 0x2d9d43, + 0x20b9c2, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x20b9c2, + 0x230c43, + 0x249943, + 0x2257c3, + 0x2d8843, + 0x2161c3, + 0x200882, + 0x204a82, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x23d1c5, + 0xacec6, + 0x224284, + 0x201582, + 0x894c8, + 0x200882, + 0x1b788, + 0x204a82, + 0xe386, + 0x63604, + 0x11bb0b, + 0x1d786, + 0x63007, + 0x230743, + 0x2d9d43, + 0x158485, + 0x127784, + 0x262383, + 0x47ac7, + 0xcdec4, + 0x249943, + 0x132d84, + 0x2257c3, + 0x2dfdc4, + 0x1473c8, + 0x152dc6, + 0x204a82, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x202883, + 0x2257c3, + 0x2df103, + 0x201582, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201103, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2afc84, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x23d1c6, + 0x230743, + 0x2d9d43, + 0x175583, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x63007, + 0x894c8, + 0x2d9d43, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x38a58403, + 0x230743, + 0x249943, + 0x2257c3, + 0x894c8, + 0x200882, + 0x204a82, + 0x258403, + 0x2d9d43, + 0x249943, + 0x2016c2, + 0x2257c3, + 0x308207, + 0x2f538b, + 0x206603, + 0x22c1c8, + 0x355d87, + 0x2b76c6, + 0x2bc8c5, + 0x2f7b09, + 0x23cf48, + 0x311cc9, + 0x311cd0, + 0x35a5cb, + 0x2e8b89, + 0x204903, + 0x3a8809, + 0x22f786, + 0x22f78c, + 0x311ec8, + 0x3ae5c8, + 0x274009, + 0x29ce4e, + 0x37880b, + 0x27c20c, + 0x203803, + 0x25dfcc, + 0x207209, + 0x3736c7, + 0x23068c, + 0x39baca, + 0x2054c4, + 0x3a398d, + 0x25de88, + 0x22830d, + 0x2692c6, + 0x2975cb, + 0x3532c9, + 0x316ec7, + 0x31d846, + 0x322309, + 0x33264a, + 0x301708, + 0x2ded04, + 0x35eb47, + 0x275547, + 0x347a44, + 0x226d04, + 0x2615c9, + 0x2e7ac9, + 0x3114c8, + 0x20ffc5, + 0x392805, + 0x20cc06, + 0x3a3849, + 0x2187cd, + 0x27bc88, + 0x20cb07, + 0x2bc948, + 0x27d286, + 0x3a2044, + 0x37b205, + 0x204506, + 0x206704, + 0x207107, + 0x209bca, + 0x212f44, + 0x2169c6, + 0x2173c9, + 0x2173cf, + 0x217c0d, + 0x218146, + 0x21b390, + 0x21b786, + 0x21bec7, + 0x21c4c7, + 0x21c4cf, + 0x21dc89, + 0x221946, + 0x2246c7, + 0x2246c8, + 0x225449, + 0x28e488, + 0x2d5747, + 0x20b803, + 0x375746, + 0x2e1788, + 0x29d10a, + 0x21a2c9, + 0x20d883, + 0x33f606, + 0x36160a, + 0x2f6307, + 0x37350a, + 0x3a9dce, + 0x21ddc6, + 0x2a4b07, + 0x212046, + 0x2072c6, + 0x37ad4b, + 0x3b058a, + 0x2232cd, + 0x210687, + 0x355548, + 0x355549, + 0x35554f, + 0x205e8c, + 0x27ab09, + 0x3772ce, + 0x3ad20a, + 0x24c486, + 0x2ff406, + 0x30238c, + 0x3043cc, + 0x30e188, + 0x339a47, + 0x211a85, + 0x208a84, + 0x2531ce, + 0x3328c4, + 0x22b747, + 0x25f88a, + 0x369f14, + 0x36f74f, + 0x21c688, + 0x375608, + 0x36becd, + 0x36bece, + 0x380289, + 0x392988, + 0x39298f, + 0x23038c, + 0x23038f, + 0x231887, + 0x2336ca, + 0x21ac8b, + 0x235208, + 0x236407, + 0x259ccd, + 0x20ab46, + 0x3a3b46, + 0x239589, + 0x306248, + 0x23d548, + 0x23d54e, + 0x2f5487, + 0x2a9985, + 0x23ee45, + 0x20a884, + 0x2b7986, + 0x3113c8, + 0x2527c3, + 0x20524e, + 0x25a088, + 0x22784b, + 0x33fd07, + 0x3a3085, + 0x25e146, + 0x2aa9c7, + 0x2e6888, + 0x24ab09, + 0x292f85, + 0x2852c8, + 0x218ac6, + 0x37b9ca, + 0x2530c9, + 0x230749, + 0x23074b, + 0x323fc8, + 0x347909, + 0x210086, + 0x3591ca, + 0x2b5b8a, + 0x2338cc, + 0x340647, + 0x2a010a, + 0x35ef4b, + 0x35ef59, + 0x2dc808, + 0x23d245, + 0x259e86, + 0x2d9949, + 0x3178c6, + 0x2156ca, + 0x262e86, + 0x213544, + 0x2c0bcd, + 0x305d07, + 0x213549, + 0x241585, + 0x2416c8, + 0x242009, + 0x242244, + 0x242947, + 0x242948, + 0x2432c7, + 0x265948, + 0x2480c7, + 0x240845, + 0x25118c, + 0x251849, + 0x35b0ca, + 0x38e889, + 0x3a8909, + 0x26f90c, + 0x2587cb, + 0x258a88, + 0x25a708, + 0x25dac4, + 0x282bc8, + 0x283f49, + 0x39bb87, + 0x217606, + 0x23bb87, + 0x377089, + 0x34028b, + 0x327f47, + 0x36c507, + 0x2f4dc7, + 0x228284, + 0x228285, + 0x2a7845, + 0x3355cb, + 0x3989c4, + 0x318a88, + 0x2a958a, + 0x218b87, + 0x34d287, + 0x28a312, + 0x283986, + 0x2e0006, + 0x32704e, + 0x285a46, + 0x28f748, + 0x29020f, + 0x2286c8, + 0x286508, + 0x2b400a, + 0x2b4011, + 0x2a038e, + 0x23670a, + 0x23670c, + 0x2348c7, + 0x392b90, + 0x203b08, + 0x2a0585, + 0x2aae8a, + 0x20674c, + 0x2b2b0d, + 0x2abb46, + 0x2abb47, + 0x2abb4c, + 0x2f00cc, + 0x2d814c, + 0x28d70b, + 0x284c84, + 0x21b244, + 0x372689, + 0x2daac7, + 0x2e58c9, + 0x2b59c9, + 0x366687, + 0x39b946, + 0x39b949, + 0x3a51c3, + 0x2a54ca, + 0x208cc7, + 0x309ecb, + 0x22314a, + 0x237784, + 0x351606, + 0x27f809, + 0x31ca44, + 0x3a8dca, + 0x2e78c5, + 0x2b5e05, + 0x2b5e0d, + 0x2b614e, + 0x28f285, + 0x315286, + 0x23cdc7, + 0x2688ca, + 0x2e6a86, + 0x319bc4, + 0x314e87, + 0x219a8b, + 0x27d347, + 0x359404, + 0x24fdc6, + 0x24fdcd, + 0x23478c, + 0x325dc6, + 0x27be8a, + 0x20c646, + 0x2146c8, + 0x21e447, + 0x26834a, + 0x37c606, + 0x210583, + 0x254846, + 0x2015c8, + 0x29864a, + 0x268fc7, + 0x268fc8, + 0x26e6c4, + 0x283187, + 0x2c0488, + 0x2127c8, + 0x3a6708, + 0x28810a, + 0x2cf185, + 0x2c7707, + 0x236553, + 0x258486, + 0x2d2fc8, + 0x21fcc9, + 0x23c8c8, + 0x267c8b, + 0x2b8688, + 0x219bc4, + 0x2999c6, + 0x3b23c6, + 0x2d6a09, + 0x385687, + 0x251288, + 0x3ae246, + 0x21f4c4, + 0x2c5405, + 0x2bf148, + 0x2bfa0a, + 0x2c0848, + 0x2c5b46, + 0x298d4a, + 0x2334c8, + 0x2c8c88, + 0x2ca008, + 0x2ca906, + 0x2cc706, + 0x31dd4c, + 0x2ccc90, + 0x288885, + 0x2284c8, + 0x2f8490, + 0x2284d0, + 0x311b4e, + 0x31d9ce, + 0x31d9d4, + 0x32418f, + 0x324546, + 0x347e51, + 0x306413, + 0x306888, + 0x31d1c5, + 0x3587c8, + 0x20e545, + 0x228fcc, + 0x249d89, + 0x22b589, + 0x23b907, + 0x21a5c9, + 0x305f47, + 0x3af506, + 0x37b007, + 0x253945, + 0x2e5ac3, + 0x252989, + 0x223689, + 0x375583, + 0x3acd44, + 0x325a0d, + 0x37e40f, + 0x33b205, + 0x3194c6, + 0x213807, + 0x3b09c7, + 0x287686, + 0x28768b, + 0x2a21c5, + 0x256946, + 0x20bb87, + 0x26ed49, + 0x328c86, + 0x200d85, + 0x22020b, + 0x268606, + 0x242fc5, + 0x28b888, + 0x2b5248, + 0x2b66cc, + 0x2b66d0, + 0x2cae09, + 0x2f6b87, + 0x2d480b, + 0x2d4346, + 0x2d560a, + 0x2d678b, + 0x2d730a, + 0x2d7586, + 0x2d8705, + 0x355c86, + 0x277908, + 0x23b9ca, + 0x36bb5c, + 0x2df1cc, + 0x2df4c8, + 0x23d1c5, + 0x2e1c47, + 0x29ca86, + 0x399805, + 0x219e86, + 0x287848, + 0x2b47c7, + 0x29cd48, + 0x2a4c0a, + 0x32268c, + 0x322909, + 0x399b47, + 0x204b04, + 0x23f786, + 0x28608a, + 0x2b5ac5, + 0x364b4c, + 0x37d1c8, + 0x34bb08, + 0x20558c, + 0x20f98c, + 0x210949, + 0x210b87, + 0x2af94c, + 0x377784, + 0x339d4a, + 0x31cd4c, + 0x27018b, + 0x23588b, + 0x236286, + 0x238247, + 0x238dc7, + 0x392dcf, + 0x2f1211, + 0x3b2cd2, + 0x238dcd, + 0x238dce, + 0x23910e, + 0x324348, + 0x324352, + 0x23c4c8, + 0x2fb047, + 0x245f4a, + 0x20d0c8, + 0x285a05, + 0x32b0ca, + 0x21bcc7, + 0x2e1944, + 0x2636c3, + 0x31e545, + 0x2b4287, + 0x2f2187, + 0x2b2d0e, + 0x35db8d, + 0x36abc9, + 0x210ec5, + 0x39c543, + 0x252106, + 0x36aa45, + 0x273a48, + 0x2b1149, + 0x259ec5, + 0x259ecf, + 0x2d8547, + 0x2f7a45, + 0x3a058a, + 0x39a146, + 0x239c09, + 0x2e878c, + 0x2eab49, + 0x203d46, + 0x2a938c, + 0x2eb806, + 0x2eefc8, + 0x2ef1c6, + 0x2dc986, + 0x305a84, + 0x258e03, + 0x2ec3ca, + 0x321651, + 0x27acca, + 0x3644c5, + 0x38e287, + 0x24d547, + 0x2c0584, + 0x2c058b, + 0x317248, + 0x2b1d06, + 0x22cd85, + 0x25f344, + 0x26bd09, + 0x275284, + 0x3b0e87, + 0x2efd05, + 0x2efd07, + 0x327285, + 0x2a84c3, + 0x2faf08, + 0x32820a, + 0x23b0c3, + 0x35408a, + 0x26f786, + 0x259c4f, + 0x356e89, + 0x2051d0, + 0x2df9c8, + 0x2c6049, + 0x297e87, + 0x24fd4f, + 0x24b244, + 0x2afd04, + 0x21b606, + 0x2342c6, + 0x314bca, + 0x380786, + 0x3450c7, + 0x2f7148, + 0x2f7347, + 0x2f7d47, + 0x348a4a, + 0x2fad4b, + 0x27ce85, + 0x3b2908, + 0x22b843, + 0x36d5cc, + 0x21180f, + 0x26090d, + 0x2bc047, + 0x36ad09, + 0x22ca87, + 0x258ec8, + 0x36a10c, + 0x26b0c8, + 0x24cbc8, + 0x30a7ce, + 0x3202d4, + 0x3207e4, + 0x33cf0a, + 0x35aa0b, + 0x306004, + 0x306009, + 0x3a5708, + 0x23f945, + 0x2522ca, + 0x265247, + 0x2ee604, + 0x323743, + 0x258403, + 0x232ec4, + 0x230743, + 0x2d9d43, + 0x201104, + 0x202503, + 0x219bc3, + 0x2ccc86, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x219683, + 0x200882, + 0x323743, + 0x204a82, + 0x258403, + 0x232ec4, + 0x230743, + 0x2d9d43, + 0x202503, + 0x2ccc86, + 0x249943, + 0x2257c3, + 0x894c8, + 0x258403, + 0x230743, + 0x2095c3, + 0x249943, + 0x2257c3, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x7112c8, + 0x201742, 0x200482, - 0x206a82, - 0x22bf83, - 0x200d02, - 0x202002, - 0x2023c4, - 0x30db04, - 0x21ee82, - 0x211004, - 0x200fc2, - 0x204703, - 0x21d603, - 0x23b346, - 0x212dc2, - 0x203f02, - 0x214a02, - 0x3aa23a03, - 0x3ae095c3, - 0x52886, - 0x52886, - 0x223504, - 0xe3d4c, - 0x19a1cc, - 0x8390d, - 0xda987, - 0x1cc08, - 0x22408, - 0x1a9f8a, - 0x3bb1cb45, - 0x11cb49, - 0x142c08, - 0x16b1ca, - 0x170bce, - 0x144218b, - 0x143f44, - 0x16fcc8, - 0x7f087, - 0x12c47, - 0x172cc9, - 0xb587, - 0x14bcc8, - 0x1a4249, - 0xda4c5, - 0x6098e, - 0xa868d, - 0x142a08, - 0x3be6b1c6, - 0x62c87, - 0x65d07, - 0x6bf07, - 0x72b87, - 0xd502, - 0x14d247, - 0x103a8c, - 0xed107, - 0x90906, - 0xa3849, - 0xa5408, - 0x134c2, - 0x2002, - 0x1808cb, - 0x18549, - 0x44b09, - 0x15bd88, - 0xafcc2, - 0x3c909, - 0x120809, - 0xcd808, - 0xcde07, - 0xcff09, - 0xd32c5, - 0xd36d0, - 0x1a2ac6, - 0x62145, - 0x22f4d, - 0xb146, - 0xdb947, - 0xe1c58, - 0xcfc88, - 0x19110a, - 0x185e4d, - 0x4042, - 0x72606, - 0x8c808, - 0x14ac08, - 0x77909, - 0x496c8, - 0x56f0e, - 0xe9f85, - 0x4ef08, - 0x1bc2, - 0x122706, + 0x204a82, + 0x258403, + 0x201e02, + 0x201042, + 0x201104, + 0x30ac84, + 0x218f82, + 0x2021c4, + 0x2016c2, + 0x2257c3, + 0x219683, + 0x236286, + 0x21ce42, + 0x203d02, + 0x21a642, + 0x3b21fc03, + 0x3b606343, + 0x4df06, + 0x4df06, + 0x224284, + 0xf5dcc, + 0x18ce0c, + 0x7edcd, + 0xd9547, + 0x182c8, + 0x1e808, + 0x1a7e8a, + 0x3c2fc045, + 0x11fe09, + 0x153b08, + 0x19ec8a, + 0x190d0e, + 0x143c6cb, + 0x63604, + 0x1702c8, + 0x7a287, + 0x1a8387, + 0x10d109, + 0x11cac7, + 0x132948, + 0x1a2e49, + 0x12ba85, + 0x53e0e, + 0xa88cd, + 0x62e88, + 0x3c665e86, + 0x5ec87, + 0x5f747, + 0x68787, + 0x6df87, + 0xcbc2, + 0x122d07, + 0x1b074c, + 0xe94c7, + 0x8eb46, + 0xa3609, + 0xa5ec8, + 0xd4c2, + 0x1042, + 0x17dc0b, + 0x13349, + 0x3f209, + 0x295c8, + 0xaf102, + 0x40ec9, + 0xcd649, + 0xce408, + 0xce947, + 0xcf109, + 0xd1dc5, + 0xd21d0, + 0x19a286, + 0x555c5, + 0x23ccd, + 0x11c686, + 0xda487, + 0xdfdd8, + 0x156288, + 0x1a080a, + 0x162d0d, + 0x3e42, + 0x7e246, + 0x8ad48, + 0x174a08, + 0x89389, + 0x42b08, + 0x4e10e, + 0xe6f85, + 0x4a148, + 0x35c2, + 0x152dc6, 0x6c2, 0xc01, - 0x3c2e24c4, - 0x3c692f43, + 0x3cae0644, + 0x3ce91043, 0x141, - 0x4e86, + 0x17d386, 0x141, 0x1, - 0x4e86, - 0x1570305, - 0x247204, - 0x22bf83, - 0x248fc4, - 0x2023c4, - 0x24c083, - 0x223985, - 0x20b743, - 0x2298c3, - 0x2ebf05, - 0x2232c3, - 0x3d62bf83, - 0x231b03, - 0x250cc3, + 0x17d386, + 0x1564a45, + 0x2054c4, + 0x258403, + 0x2446c4, + 0x201104, + 0x249943, + 0x21fb85, + 0x20f0c3, + 0x244443, + 0x2e82c5, + 0x224043, + 0x3de58403, + 0x230743, + 0x2d9d43, 0x200041, - 0x220ec3, - 0x30db04, - 0x211004, - 0x24c083, - 0x204703, - 0x20b803, - 0x77a48, + 0x219bc3, + 0x30ac84, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x2161c3, + 0x894c8, 0x200882, - 0x327883, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x202002, - 0x2023c4, - 0x202243, - 0x220ec3, - 0x24c083, - 0x2020c3, - 0x204703, - 0x2232c3, - 0x77a48, - 0x38d402, - 0x6a82, - 0xf8f0e, - 0x3e600142, - 0x27a048, - 0x225f46, - 0x2bc3c6, - 0x2258c7, - 0x3ea06b82, - 0x3ef58e08, - 0x20628a, - 0x262708, - 0x200ec2, - 0x206b09, - 0x238887, - 0x21a946, - 0x208d89, - 0x25ba04, - 0x2b7a46, - 0x2e2884, - 0x27b484, - 0x254709, - 0x343886, - 0x247885, - 0x20eec5, - 0x3a7607, - 0x2b9207, - 0x36ee44, - 0x225b06, - 0x2f2945, - 0x2e48c5, - 0x2f6e45, - 0x392607, - 0x3672c5, - 0x3098c9, - 0x2644c5, - 0x2d0cc4, - 0x2e8587, - 0x2cee0e, - 0x31ae09, - 0x327149, - 0x35c146, - 0x31bf08, - 0x2ae58b, - 0x2d1fcc, - 0x26c186, - 0x37b207, - 0x20ae05, - 0x228dca, - 0x31a489, - 0x24f6c9, - 0x388f86, - 0x2f0f05, - 0x282145, - 0x366349, - 0x2f6fcb, - 0x27ed46, - 0x333e06, - 0x20d444, - 0x28ba86, - 0x2aac48, - 0x201186, - 0x203786, - 0x209988, - 0x20a887, - 0x20ab89, - 0x20bdc5, - 0x77a48, - 0x212bc4, - 0x37ee84, - 0x213a85, - 0x395589, - 0x222b07, - 0x222b0b, - 0x2243ca, - 0x228ac5, - 0x3f20ce82, - 0x226d87, - 0x3f629408, - 0x287607, - 0x343bc5, - 0x238f8a, - 0x6a82, - 0x266d4b, - 0x383dca, - 0x223c86, - 0x3a4483, - 0x338f8d, - 0x35b24c, - 0x36654d, - 0x385a45, - 0x23e645, - 0x25ffc7, - 0x200d09, - 0x206186, - 0x32b5c5, - 0x2a9f08, - 0x28b983, - 0x2da308, - 0x28b988, - 0x2bd387, - 0x3b00c8, + 0x323743, + 0x204a82, + 0x258403, + 0x230743, + 0x2095c3, + 0x201042, + 0x201104, + 0x202503, + 0x219bc3, + 0x249943, + 0x202883, + 0x2257c3, + 0x224043, + 0x894c8, + 0x38c082, + 0x4a82, + 0xf750e, + 0x3ee00142, + 0x274948, + 0x2221c6, + 0x2634c6, + 0x221b47, + 0x3f207d42, + 0x3f756d08, + 0x20828a, + 0x25e708, + 0x200dc2, + 0x208b09, + 0x27cec7, + 0x217586, + 0x207c49, + 0x24f9c4, + 0x2b75c6, + 0x2d7804, + 0x276684, + 0x250689, + 0x354786, + 0x20a105, + 0x380a85, + 0x383a87, + 0x2b8b07, + 0x3809c4, + 0x221d86, + 0x2fe205, + 0x2e13c5, + 0x2f4005, + 0x3925c7, + 0x33fb45, + 0x307409, + 0x30f905, + 0x2cfec4, + 0x2e69c7, + 0x24b3ce, + 0x261c49, + 0x326f09, + 0x346646, + 0x33c4c8, + 0x2ae2cb, + 0x2d158c, + 0x25a586, + 0x3786c7, + 0x20a605, + 0x226d0a, + 0x31b0c9, + 0x24a909, + 0x295506, + 0x2edd05, + 0x34bf85, + 0x363c49, + 0x2f418b, + 0x279f46, + 0x330ac6, + 0x20cb04, + 0x289fc6, + 0x2a9a08, + 0x201446, + 0x3a3e46, + 0x209648, + 0x209e47, + 0x20a389, + 0x20b085, + 0x894c8, + 0x3a8304, + 0x37c344, + 0x211605, + 0x395c09, + 0x21ef07, + 0x21ef0b, + 0x22108a, + 0x226a05, + 0x3fa0b802, + 0x223007, + 0x3fe28d88, + 0x285007, + 0x354ac5, + 0x23458a, + 0x4a82, + 0x3aa0cb, + 0x3874ca, + 0x21fe86, + 0x3a3083, + 0x32dc0d, + 0x363e4c, + 0x3a214d, + 0x3828c5, + 0x238985, + 0x252807, + 0x201e09, + 0x208186, + 0x380605, + 0x2f1bc8, + 0x289ec3, + 0x2d8bc8, + 0x289ec8, + 0x2bd3c7, + 0x3b1588, 0x200b09, - 0x233a47, - 0x2e2e87, - 0x2f74c8, - 0x24c0c4, - 0x24c0c7, - 0x26df88, - 0x204bc6, - 0x39a48f, - 0x218747, - 0x2d76c6, - 0x240185, - 0x36e8c3, - 0x36e8c7, - 0x36a503, - 0x247b86, - 0x249b86, - 0x24b006, - 0x28fd05, - 0x2687c3, - 0x389f48, - 0x36c709, - 0x3817cb, - 0x24b188, - 0x24d105, - 0x24e185, - 0x3fa3d6c2, - 0x37dc09, - 0x202447, - 0x257f45, - 0x254607, - 0x256dc6, - 0x363645, - 0x36b8cb, - 0x259d04, - 0x2622c5, - 0x262407, - 0x278406, - 0x278845, - 0x286007, - 0x286587, - 0x274344, - 0x28a70a, - 0x28abc8, - 0x328d49, - 0x3a0805, - 0x34c306, - 0x2aae0a, - 0x20edc6, - 0x266f87, - 0x31694d, - 0x227b09, - 0x329805, - 0x345fc7, - 0x344108, - 0x344788, - 0x323487, - 0x366f86, - 0x215b47, - 0x249503, - 0x337a04, - 0x360585, - 0x38dd07, - 0x392009, - 0x227608, - 0x22ccc5, - 0x3afa84, - 0x382f85, - 0x2474cd, - 0x204242, - 0x302bc6, - 0x272546, - 0x2a3cca, - 0x365a86, - 0x377705, - 0x317145, - 0x317147, - 0x37e34c, - 0x27648a, - 0x28b746, - 0x206945, - 0x28b8c6, - 0x28bc07, - 0x28d946, - 0x28fc0c, - 0x208ec9, - 0x3fe05307, - 0x2924c5, - 0x2924c6, - 0x2929c8, - 0x2b1285, - 0x2a2c05, - 0x2a2e48, - 0x2a304a, - 0x4020b882, - 0x4060f802, - 0x3827c5, - 0x2d7643, - 0x267348, - 0x21dcc3, - 0x2a32c4, - 0x21dccb, - 0x2ae948, - 0x2a6088, - 0x40b40cc9, - 0x2a7ec9, - 0x2a8586, - 0x2a97c8, - 0x2a99c9, - 0x2ab6c6, - 0x2ab845, - 0x383646, - 0x2ac389, - 0x341607, - 0x24ad46, - 0x238c87, - 0x206007, - 0x23bc44, - 0x40efa889, - 0x2c3d08, - 0x358d08, - 0x360187, - 0x2bed46, - 0x3007c9, - 0x2f7a07, - 0x32a14a, - 0x2be708, - 0x34c447, - 0x357e06, - 0x21ce8a, - 0x280b88, - 0x271fc5, - 0x22d185, - 0x2be8c7, - 0x2d1789, - 0x2d6d4b, - 0x2ede48, - 0x264549, - 0x24b747, - 0x3adc4c, - 0x2b0e4c, - 0x2b114a, - 0x2b13cc, - 0x2bc348, - 0x2bc548, - 0x2bc744, - 0x2bcb09, - 0x2bcd49, - 0x2bcf8a, - 0x2bd209, - 0x2bd547, + 0x232687, + 0x2f4f07, + 0x2f4688, + 0x3a9944, + 0x3a9947, + 0x2691c8, + 0x204786, + 0x37e78f, + 0x221407, + 0x2d58c6, + 0x259045, + 0x220803, + 0x36dd07, + 0x368c83, + 0x243486, + 0x245306, + 0x2466c6, + 0x28df45, + 0x265943, + 0x388ac8, + 0x36b4c9, + 0x37ef8b, + 0x246848, + 0x247d85, + 0x248d45, + 0x40237842, + 0x37b0c9, + 0x201187, + 0x2569c5, + 0x250587, + 0x255b46, + 0x360405, + 0x36a88b, + 0x258a84, + 0x25e2c5, + 0x25e407, + 0x273986, + 0x275385, + 0x282dc7, + 0x283347, + 0x26f744, + 0x288a8a, + 0x288f48, + 0x24bc89, + 0x2ee845, + 0x332f86, + 0x2a9bca, + 0x3aa306, + 0x20c4c7, + 0x31754d, + 0x22c6c9, + 0x24c745, + 0x253647, + 0x2637c8, + 0x263e48, + 0x311807, + 0x323086, + 0x2101c7, + 0x244c03, + 0x3355c4, + 0x35ce05, + 0x38d347, + 0x391fc9, + 0x21a048, + 0x22a6c5, + 0x2e62c4, + 0x36a3c5, + 0x23fccd, + 0x204042, + 0x302d86, + 0x27e186, + 0x2a3a8a, + 0x363386, + 0x374405, + 0x317d45, + 0x317d47, + 0x37b80c, + 0x271b8a, + 0x289c86, + 0x208945, + 0x289e06, + 0x28a147, + 0x28bd86, + 0x28de4c, + 0x207d89, + 0x4077d807, + 0x2905c5, + 0x2905c6, + 0x290ac8, + 0x2b0c05, + 0x2a29c5, + 0x2a2c08, + 0x2a2e0a, + 0x40a6b682, + 0x40e0f402, + 0x37ff85, + 0x2d5843, + 0x2e5c88, + 0x21d543, + 0x2a3084, + 0x239d4b, + 0x35edc8, + 0x2a6d08, + 0x41329249, + 0x2a8109, + 0x2a87c6, + 0x2aa648, + 0x2aa849, + 0x2ab406, + 0x2ab585, + 0x381146, + 0x2ac0c9, + 0x31b987, + 0x246406, + 0x2d9007, + 0x208007, + 0x240204, + 0x416fb349, + 0x2c4408, + 0x356c08, + 0x33e947, + 0x2bedc6, + 0x33b409, + 0x263487, + 0x341a8a, + 0x381908, + 0x3231c7, + 0x3330c6, + 0x260c0a, + 0x2488c8, + 0x28bec5, + 0x225b85, + 0x2d38c7, + 0x2d4fc9, + 0x2d64cb, + 0x2e9908, + 0x30f989, + 0x246b47, + 0x3aef0c, + 0x2b07cc, + 0x2b0aca, + 0x2b0d4c, + 0x2bc388, + 0x2bc588, + 0x2bc784, + 0x2bcb49, + 0x2bcd89, + 0x2bcfca, + 0x2bd249, + 0x2bd587, 0x20010c, - 0x242886, - 0x2794c8, - 0x20ee86, - 0x388a46, - 0x329707, - 0x31b008, - 0x261a4b, - 0x2874c7, - 0x2f0bc9, - 0x249149, - 0x253dc7, - 0x2e2ac4, - 0x363b07, - 0x34c986, - 0x2179c6, - 0x237a05, - 0x2ccd48, - 0x20f2c4, - 0x20f2c6, - 0x27634b, - 0x2a6649, - 0x31e946, - 0x35ab09, - 0x392786, - 0x301348, - 0x2025c3, - 0x209185, - 0x2038c9, - 0x20cb05, - 0x2fd284, - 0x277506, - 0x26bdc5, - 0x2db706, - 0x2fe047, - 0x2af586, - 0x2974cb, - 0x35a7c7, - 0x2d1646, - 0x371506, - 0x3a76c6, - 0x36ee09, - 0x24df0a, - 0x2b5985, - 0x22d94d, - 0x2a3146, - 0x391306, - 0x2e1746, - 0x21d985, - 0x2d39c7, - 0x29bb47, - 0x29fb0e, - 0x220ec3, - 0x2bed09, - 0x316e89, - 0x2291c7, - 0x27e2c7, - 0x2a7505, - 0x323f05, - 0x4126304f, - 0x2c5b47, - 0x2c5d08, - 0x2c6784, - 0x2c6a46, - 0x41629382, - 0x2ca746, - 0x2cc586, - 0x261d8e, - 0x2da14a, - 0x226886, - 0x22ee4a, - 0x205d89, - 0x314e85, - 0x393c08, - 0x3adb06, - 0x31e788, - 0x326ac8, - 0x24090b, - 0x2259c5, - 0x367348, - 0x209acc, - 0x343a87, - 0x24a7c6, - 0x27fd08, - 0x2b7cc8, - 0x41a09142, - 0x3700cb, - 0x376209, - 0x2d2b49, - 0x3a3347, - 0x20af88, - 0x41f5b088, - 0x20bfcb, - 0x35bc09, - 0x221d4d, - 0x378388, - 0x29bf88, - 0x422018c2, - 0x201084, - 0x4260dd02, - 0x2edbc6, - 0x42a02482, - 0x21c48a, - 0x322806, - 0x32c808, - 0x31c208, - 0x2b7946, - 0x388086, - 0x2e8046, - 0x308f85, - 0x23a584, - 0x42f012c4, - 0x338446, - 0x33be87, - 0x432e9287, - 0x35e7cb, - 0x2cf1c9, - 0x23e68a, - 0x261644, - 0x317288, - 0x24ab0d, - 0x2dfd49, - 0x2dff88, - 0x2e06c9, - 0x2e1c44, - 0x208c84, - 0x281645, - 0x36228b, - 0x2ae8c6, - 0x338285, - 0x343d49, - 0x225bc8, - 0x29f3c4, - 0x228f49, - 0x330045, - 0x2b9248, - 0x2e3547, - 0x327548, - 0x281c06, - 0x226c47, - 0x2910c9, - 0x224189, - 0x249905, - 0x339605, - 0x436284c2, - 0x2e8344, - 0x33b285, - 0x291c46, - 0x335e85, - 0x24e247, - 0x26ccc5, - 0x26cd44, - 0x35c206, - 0x32b647, - 0x244f86, - 0x3af445, - 0x37fd48, - 0x226145, - 0x39a807, - 0x3b2509, - 0x2a678a, - 0x236987, - 0x23698c, - 0x247846, - 0x22b289, - 0x340105, - 0x370f08, - 0x212983, - 0x212985, - 0x2e90c5, - 0x255707, - 0x43a17482, - 0x23e287, - 0x2e5046, - 0x2fa7c6, - 0x303146, - 0x2b7c06, - 0x3302c8, - 0x35a005, - 0x2d7787, - 0x2d778d, - 0x24ddc3, - 0x3a4885, - 0x271b47, - 0x387bc8, - 0x271705, - 0x228808, - 0x32c346, - 0x31cd07, - 0x2bdf45, - 0x225a46, - 0x2d3005, - 0x2bb8ca, - 0x2fc546, - 0x233dc7, - 0x2c6905, - 0x2f5207, - 0x2f5904, - 0x2fd206, - 0x331ac5, - 0x34368b, - 0x34c809, - 0x243bca, - 0x249988, - 0x336448, - 0x337c8c, - 0x3556c7, - 0x35dd48, - 0x361308, - 0x36bc05, - 0x3a024a, - 0x2ea909, - 0x43e04582, - 0x204586, - 0x20c984, - 0x2de009, - 0x362d89, - 0x2250c7, - 0x254447, - 0x2b8649, - 0x326508, - 0x32650f, - 0x270f06, - 0x241b0b, - 0x2ebd45, - 0x2ebd47, - 0x2ec189, - 0x21de06, - 0x228ec7, - 0x3b1e45, - 0x2305c4, - 0x26bc86, + 0x22bd06, + 0x273dc8, + 0x3aa3c6, + 0x386986, + 0x24c647, + 0x311988, + 0x254ecb, + 0x284ec7, + 0x2ed9c9, + 0x244849, + 0x250247, + 0x2d7a44, + 0x3608c7, + 0x329b86, + 0x216386, + 0x27c045, + 0x2cd448, + 0x20e444, + 0x20e446, + 0x271a4b, + 0x2a57c9, + 0x261a86, + 0x31bf49, + 0x392746, + 0x2ff808, + 0x23e383, + 0x20bac5, + 0x3aa509, + 0x3b1745, + 0x2f2904, + 0x272fc6, + 0x221805, + 0x2da246, + 0x2fc947, + 0x340546, + 0x296a4b, + 0x3590c7, + 0x2d0846, + 0x372806, + 0x383b46, + 0x380989, + 0x26a48a, + 0x2b4f05, + 0x22634d, + 0x2a2f06, + 0x3a0a06, + 0x2df8c6, + 0x214645, + 0x2d24c7, + 0x29a587, + 0x29e54e, + 0x219bc3, + 0x2bed89, + 0x317a89, + 0x227107, + 0x2794c7, + 0x2a4685, + 0x30ffc5, + 0x41a6170f, + 0x2c6287, + 0x2c6448, + 0x2c6b44, + 0x2c6e46, + 0x41e272c2, + 0x2cab86, + 0x2ccc86, + 0x25520e, + 0x2d8a0a, + 0x222b06, + 0x3a60ca, + 0x201c09, + 0x315a85, + 0x3941c8, + 0x3aedc6, + 0x31bd88, + 0x321c88, + 0x2597cb, + 0x221c45, + 0x33fbc8, + 0x20978c, + 0x354987, + 0x245e86, + 0x27d4c8, + 0x2b7848, + 0x4220ba82, + 0x36480b, + 0x2aedc9, + 0x365209, + 0x20a787, + 0x31c4c8, + 0x4260b288, + 0x3aab8b, + 0x229449, + 0x21e14d, + 0x212b48, + 0x29a9c8, + 0x42a02542, + 0x3a4104, + 0x42e05842, + 0x2ea586, + 0x432011c2, + 0x21f50a, + 0x352ec6, + 0x229a88, + 0x33c7c8, + 0x2b74c6, + 0x385fc6, + 0x2e4906, + 0x227a05, + 0x235b84, + 0x436ff784, + 0x336c86, + 0x26ddc7, + 0x43a2e647, + 0x2ebbcb, + 0x24b789, + 0x2389ca, + 0x254ac4, + 0x317e88, + 0x2461cd, + 0x2ddb49, + 0x2ddd88, + 0x2de849, + 0x2dfdc4, + 0x207b44, + 0x26ad85, + 0x309c8b, + 0x35ed46, + 0x336ac5, + 0x354c49, + 0x221e48, + 0x29de04, + 0x226e89, + 0x2ae605, + 0x2b8b48, + 0x2f55c7, + 0x327308, + 0x27fa06, + 0x222ec7, + 0x28f509, + 0x220389, + 0x243045, + 0x32dec5, + 0x43e24902, + 0x2e6784, + 0x22e005, + 0x29fec6, + 0x2e7645, + 0x248e07, + 0x269945, + 0x2699c4, + 0x346706, + 0x380687, + 0x23ef06, + 0x376fc5, + 0x31d008, + 0x2223c5, + 0x332207, + 0x39a449, + 0x2a590a, + 0x27afc7, + 0x27afcc, + 0x20a0c6, + 0x225649, + 0x377bc5, + 0x32b8c8, + 0x210043, + 0x210045, + 0x2e5805, + 0x251687, + 0x442121c2, + 0x2385c7, + 0x2e0ac6, + 0x2fb286, + 0x2e7086, + 0x2b7786, + 0x2d1bc8, + 0x358905, + 0x2d5987, + 0x2d598d, + 0x2636c3, + 0x3a3485, + 0x3a0347, + 0x385b08, + 0x39ff05, + 0x340048, + 0x22e446, + 0x31ffc7, + 0x2be3c5, + 0x221cc6, + 0x36c205, + 0x2bb2ca, + 0x2eb286, + 0x232a07, + 0x2c5e05, + 0x2fe5c7, + 0x314e04, + 0x2f2886, + 0x300f85, + 0x35458b, + 0x329a09, + 0x23ebca, + 0x2430c8, + 0x3312c8, + 0x333b0c, + 0x334047, + 0x335848, + 0x3507c8, + 0x35adc5, + 0x2bd80a, + 0x39c549, + 0x44601d42, + 0x204386, + 0x204f44, + 0x204f49, + 0x220e49, + 0x339607, + 0x270e07, + 0x2b5849, + 0x214848, + 0x21484f, + 0x33dbc6, + 0x3535cb, + 0x2e8105, + 0x2e8107, + 0x2e8549, + 0x226e06, + 0x226e07, + 0x3b3045, + 0x22f2c4, + 0x268206, 0x200c44, - 0x30ba07, - 0x2ee808, - 0x442f0e08, - 0x2f1305, - 0x2f1447, - 0x256149, - 0x201904, - 0x201908, - 0x4476d588, - 0x28e1c4, - 0x230f08, - 0x31ebc4, - 0x21bf09, - 0x22dc45, - 0x44a012c2, - 0x270f45, - 0x220885, - 0x24cb48, - 0x232a87, - 0x44e05a02, - 0x2c8405, - 0x2518c6, - 0x266246, - 0x2e8308, - 0x2e9c48, - 0x335e46, - 0x2eac86, - 0x21e589, - 0x2fa706, - 0x3081cb, - 0x28edc5, - 0x20fcc6, - 0x3abd88, - 0x3906c6, - 0x35c646, - 0x21d30a, - 0x258dca, - 0x24dac5, - 0x35a0c7, - 0x349746, - 0x45201242, - 0x271c87, - 0x236445, - 0x2aad84, - 0x2aad85, - 0x261546, - 0x276d47, - 0x20c705, - 0x258f44, - 0x26d548, + 0x30d607, + 0x2eb608, + 0x44aedc08, + 0x2ee205, + 0x2ee347, + 0x249749, + 0x2a4384, + 0x3b3308, + 0x44f8c408, + 0x2c0584, + 0x22fc08, + 0x31d904, + 0x21e9c9, 0x35c705, - 0x28af07, - 0x293245, - 0x219805, - 0x24a284, - 0x28f709, - 0x2f2788, - 0x2cea06, - 0x212e06, - 0x28dec6, - 0x457a8c08, - 0x2f5087, - 0x2f53cd, - 0x2f5b4c, - 0x2f6149, - 0x2f6389, - 0x45b54382, - 0x3a6903, - 0x20c403, - 0x34ca45, - 0x38de0a, - 0x318e06, - 0x2fab45, - 0x2fe584, - 0x2fe58b, - 0x30e4cc, - 0x30ed0c, - 0x30f015, - 0x30f9cd, - 0x31150f, - 0x3118d2, - 0x311d4f, - 0x312112, - 0x312593, - 0x312a4d, - 0x31300d, - 0x31338e, - 0x31384e, - 0x31448c, - 0x31480c, - 0x314c4b, - 0x314fce, - 0x318092, - 0x318bcc, - 0x319110, - 0x32d652, - 0x32e60c, - 0x32eccd, - 0x32f00c, - 0x332dd1, - 0x333f8d, - 0x33664d, - 0x336c4a, - 0x336ecc, - 0x3377cc, - 0x337f8c, - 0x33880c, - 0x33c653, - 0x33cc50, - 0x33d050, - 0x33d8cd, - 0x33decc, - 0x33ebc9, - 0x34024d, - 0x340593, - 0x346891, - 0x346cd3, - 0x34738f, - 0x34774c, - 0x347a4f, - 0x347e0d, - 0x34840f, - 0x3487d0, - 0x34924e, - 0x34d5ce, - 0x34dd10, - 0x34e90d, - 0x34f28e, - 0x34f60c, - 0x3505d3, - 0x3521ce, - 0x352910, - 0x352d11, - 0x35314f, - 0x353513, - 0x353f0d, - 0x35424f, - 0x35460e, - 0x354f10, - 0x355309, - 0x356010, - 0x35664f, - 0x356ccf, - 0x357092, - 0x35860e, - 0x3594cd, - 0x35cc0d, - 0x35cf4d, - 0x35f24d, - 0x35f58d, - 0x35f8d0, - 0x35fccb, - 0x36034c, - 0x3606cc, - 0x3609cc, - 0x360cce, - 0x36f050, - 0x371692, - 0x371b0b, - 0x3720ce, - 0x37244e, - 0x3736ce, - 0x37454b, - 0x45f74b16, - 0x37740d, - 0x378594, - 0x37920d, - 0x37ad55, - 0x37be8d, - 0x37c80f, - 0x37d04f, - 0x381a8f, - 0x381e4e, - 0x3830cd, - 0x3855d1, - 0x38820c, - 0x38850c, - 0x38880b, - 0x38938c, - 0x38974f, - 0x389b12, - 0x38a4cd, - 0x38b48c, - 0x38b90c, - 0x38bc0d, - 0x38bf4f, - 0x38c30e, - 0x38dacc, - 0x38e08d, - 0x38e3cb, - 0x38f00c, - 0x38f58d, - 0x38f8ce, - 0x38fd49, - 0x390a93, - 0x39148d, - 0x3917cd, - 0x391dcc, - 0x39224e, - 0x392bcf, - 0x392f8c, - 0x39328d, - 0x3935cf, - 0x39398c, - 0x39408c, - 0x39444c, - 0x39474c, - 0x394e0d, - 0x395152, - 0x3957cc, - 0x395acc, - 0x395dd1, - 0x39620f, - 0x3965cf, - 0x396993, - 0x397a8e, - 0x39800f, - 0x3983cc, - 0x4639870e, - 0x398a8f, - 0x398e56, - 0x39ad12, - 0x39c40c, - 0x39cd0f, - 0x39d38d, - 0x39d6cf, - 0x39da8c, - 0x39dd8d, - 0x39e0cd, - 0x39fd0e, - 0x3a14cc, - 0x3a17cc, - 0x3a1ad0, - 0x3a5c91, - 0x3a60cb, - 0x3a650c, - 0x3a680e, - 0x3a9111, - 0x3a954e, - 0x3a98cd, - 0x3ad8cb, - 0x3ae8cf, - 0x3afb94, - 0x224242, - 0x224242, - 0x204c83, - 0x224242, - 0x204c83, - 0x224242, - 0x20c942, - 0x383685, - 0x3a8e0c, - 0x224242, - 0x224242, - 0x20c942, - 0x224242, - 0x293045, - 0x2a6785, - 0x224242, - 0x224242, - 0x212bc2, - 0x293045, - 0x30ff09, - 0x34658c, - 0x224242, - 0x224242, - 0x224242, - 0x224242, - 0x383685, - 0x224242, - 0x224242, - 0x224242, - 0x224242, - 0x212bc2, - 0x30ff09, - 0x224242, - 0x224242, - 0x224242, - 0x2a6785, - 0x224242, - 0x2a6785, - 0x34658c, - 0x3a8e0c, - 0x327883, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x24c083, - 0x204703, - 0x4fdc8, - 0x57044, - 0x4bf48, + 0x45201582, + 0x33dc05, + 0x21bfc5, + 0x247888, + 0x2316c7, + 0x45606882, + 0x2c8905, + 0x24e446, + 0x266ac6, + 0x2e6748, + 0x32e888, + 0x2e7606, + 0x2ead46, + 0x20ee89, + 0x2fb1c6, + 0x30564b, + 0x24ddc5, + 0x20d006, + 0x380448, + 0x20ac46, + 0x292e06, + 0x21938a, + 0x25784a, + 0x23ffc5, + 0x3589c7, + 0x344786, + 0x45a01502, + 0x3a0487, + 0x22d205, + 0x2a9b44, + 0x2a9b45, + 0x2549c6, + 0x272447, + 0x204cc5, + 0x220f04, + 0x2732c8, + 0x292ec5, + 0x291347, + 0x2cefc5, + 0x215305, + 0x244e84, + 0x28d949, + 0x2fe048, + 0x30f506, + 0x3a8546, + 0x2c0286, + 0x45fa6b08, + 0x2f2007, + 0x2f234d, + 0x2f2d0c, + 0x2f3309, + 0x2f3549, + 0x4634f642, + 0x3a4f83, + 0x2049c3, + 0x329c45, + 0x38d44a, + 0x319a06, + 0x2f98c5, + 0x2fce84, + 0x2fce8b, + 0x30b64c, + 0x30be8c, + 0x30c195, + 0x30cb4d, + 0x31244f, + 0x312812, + 0x312c8f, + 0x313052, + 0x3134d3, + 0x31398d, + 0x313f4d, + 0x3142ce, + 0x31478e, + 0x31504c, + 0x31540c, + 0x31584b, + 0x315bce, + 0x318c92, + 0x3197cc, + 0x319d50, + 0x32bbd2, + 0x32cb8c, + 0x32d24d, + 0x32d58c, + 0x32fa91, + 0x330c4d, + 0x33420d, + 0x33480a, + 0x334a8c, + 0x33538c, + 0x3367cc, + 0x33704c, + 0x339fd3, + 0x33a5d0, + 0x33a9d0, + 0x33b64d, + 0x33bc4c, + 0x33cc49, + 0x33eb0d, + 0x33ee53, + 0x340f91, + 0x3413d3, + 0x3423cf, + 0x34278c, + 0x342a8f, + 0x342e4d, + 0x34344f, + 0x343810, + 0x34428e, + 0x34858e, + 0x348cd0, + 0x3498cd, + 0x34a24e, + 0x34a5cc, + 0x34b593, + 0x34d44e, + 0x34db90, + 0x34df91, + 0x34e3cf, + 0x34e793, + 0x34f1cd, + 0x34f50f, + 0x34f8ce, + 0x350010, + 0x350409, + 0x351150, + 0x35178f, + 0x351e0f, + 0x3521d2, + 0x35650e, + 0x357dcd, + 0x359f8d, + 0x35a2cd, + 0x35b34d, + 0x35b68d, + 0x35b9d0, + 0x35bdcb, + 0x35cbcc, + 0x35cf4c, + 0x35d24c, + 0x35d54e, + 0x36e7d0, + 0x370952, + 0x370dcb, + 0x37138e, + 0x37170e, + 0x371f8e, + 0x37298b, + 0x46772f56, + 0x37410d, + 0x374e14, + 0x3758cd, + 0x378215, + 0x37934d, + 0x379ccf, + 0x37a50f, + 0x37f24f, + 0x37f60e, + 0x380bcd, + 0x382451, + 0x38614c, + 0x38644c, + 0x38674b, + 0x386d0c, + 0x3882cf, + 0x388692, + 0x38904d, + 0x38a00c, + 0x38a48c, + 0x38a78d, + 0x38aacf, + 0x38ae8e, + 0x38d10c, + 0x38d6cd, + 0x38da0b, + 0x38e64c, + 0x38ebcd, + 0x38ef0e, + 0x38f389, + 0x38fd93, + 0x39144d, + 0x39178d, + 0x391d8c, + 0x39220e, + 0x39318f, + 0x39354c, + 0x39384d, + 0x393b8f, + 0x393f4c, + 0x39464c, + 0x394acc, + 0x394dcc, + 0x39548d, + 0x3957d2, + 0x395e4c, + 0x39614c, + 0x396451, + 0x39688f, + 0x396c4f, + 0x397013, + 0x397e4e, + 0x3983cf, + 0x39878c, + 0x46b98ace, + 0x398e4f, + 0x399216, + 0x39a692, + 0x39bd4c, + 0x39c78f, + 0x39ce0d, + 0x39d14f, + 0x39d50c, + 0x39d80d, + 0x39db4d, + 0x39f28e, + 0x3a10cc, + 0x3a13cc, + 0x3a16d0, + 0x3a4211, + 0x3a464b, + 0x3a4b8c, + 0x3a4e8e, + 0x3a7011, + 0x3a744e, + 0x3a77cd, + 0x3aeb8b, + 0x3af9cf, + 0x3b1054, + 0x220442, + 0x220442, + 0x201cc3, + 0x220442, + 0x201cc3, + 0x220442, + 0x204f02, + 0x381185, + 0x3a6d0c, + 0x220442, + 0x220442, + 0x204f02, + 0x220442, + 0x291145, + 0x2a5905, + 0x220442, + 0x220442, + 0x210842, + 0x291145, + 0x30d7c9, + 0x340c8c, + 0x220442, + 0x220442, + 0x220442, + 0x220442, + 0x381185, + 0x220442, + 0x220442, + 0x220442, + 0x220442, + 0x210842, + 0x30d7c9, + 0x220442, + 0x220442, + 0x220442, + 0x2a5905, + 0x220442, + 0x2a5905, + 0x340c8c, + 0x3a6d0c, + 0x323743, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x249943, + 0x2257c3, + 0x105dc8, + 0x4e244, + 0x1a97c8, 0x200882, - 0x47206a82, - 0x240bc3, - 0x244c44, - 0x209d03, - 0x2db184, - 0x22fb86, - 0x203b43, - 0x379084, - 0x27bd85, - 0x220ec3, - 0x24c083, - 0x204703, - 0x24e9ca, - 0x23b346, - 0x3727cc, - 0x77a48, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x232003, - 0x2cc586, - 0x24c083, - 0x204703, - 0x21d603, - 0x8ac2, - 0xda987, - 0xb7008, - 0xf60e, - 0x89352, - 0x6e0b, - 0x47f1cb45, - 0x48375d8c, - 0x3c347, - 0x117a4a, - 0x3b4d0, - 0x16fcc8, - 0x7f087, - 0x58a4b, - 0x172cc9, - 0x16fbc7, - 0xb587, - 0x7ef87, - 0x188c6, - 0x14bcc8, - 0x4881c106, - 0xa868d, - 0x117410, - 0x48c08b02, - 0x142a08, - 0x6ca87, - 0x88349, - 0x52946, - 0x92bc8, - 0x10442, - 0x9ec8a, - 0xf2347, - 0xed107, - 0xa3849, - 0xa5408, - 0x159b85, - 0xe0c0e, - 0x1224e, - 0x171cf, - 0x18549, - 0x44b09, - 0x6f38b, - 0x8248f, - 0x8f90c, - 0xac74b, - 0x16be48, - 0x15e6c7, - 0xf02c8, - 0x11bd0b, - 0x13e54c, - 0x149e0c, - 0x151ecc, - 0x154a4d, - 0x15bd88, - 0x3c909, - 0x14e38b, - 0xbef46, - 0xcdfc5, - 0xd36d0, - 0x197586, - 0x62145, - 0xd6908, - 0xdb947, - 0xdcfc7, - 0x142e47, - 0xeda0a, - 0xb6e8a, - 0x72606, - 0x906cd, - 0x14ac08, - 0x496c8, - 0x4a1c9, - 0xed54c, - 0x154c4b, - 0x120304, - 0x16e409, - 0xd7e86, - 0x3f02, - 0x122706, + 0x47a04a82, + 0x23b383, + 0x2296c4, + 0x2099c3, + 0x2d9d44, + 0x2e0006, + 0x230243, + 0x230204, + 0x276f85, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x24388a, + 0x236286, + 0x371a8c, + 0x894c8, + 0x204a82, + 0x258403, + 0x230743, + 0x2d9d43, + 0x230c43, + 0x2ccc86, + 0x249943, + 0x2257c3, + 0x219683, + 0x7982, + 0xd9547, + 0xb6b88, + 0xf20e, + 0x87092, + 0x8e0b, + 0x486fc045, + 0x48afc04c, + 0x40907, + 0x11864a, + 0x370d0, + 0x1702c8, + 0x7a287, + 0x574cb, + 0x10d109, + 0x1701c7, + 0x11cac7, + 0x7a187, + 0x1d6c6, + 0x132948, + 0x4901f186, + 0xa88cd, + 0x118010, + 0x494079c2, + 0x62e88, + 0x69707, + 0xa7e09, + 0x4dfc6, + 0x90cc8, + 0x6dc2, + 0x9d6ca, + 0xef947, + 0xe94c7, + 0xa3609, + 0xa5ec8, + 0x158485, + 0xded8e, + 0xd74e, + 0x11f0f, + 0x13349, + 0x3f209, + 0x6c9cb, + 0x81e4f, + 0x8db4c, + 0xac48b, + 0x15b008, + 0xebac7, + 0xf0ac8, + 0x13c2cb, + 0x144e8c, + 0x14cf8c, + 0x14fd0c, + 0x16efcd, + 0x295c8, + 0x40ec9, + 0x14934b, + 0xbefc6, + 0xceb05, + 0xd21d0, + 0x126a46, + 0x555c5, + 0xd4b88, + 0xda487, + 0xdac87, + 0x153d47, + 0xea3ca, + 0xb6a0a, + 0x7e246, + 0x8e90d, + 0x174a08, + 0x42b08, + 0x44dc9, + 0xe9f0c, + 0x16f1cb, + 0x12af84, + 0xf1dc9, + 0x126906, + 0x3d02, + 0x152dc6, 0x6c2, - 0xc2ec5, + 0xc35c5, 0x481, - 0xb7c3, - 0x4878cd86, - 0x92f43, - 0xf582, - 0x3a004, - 0xec2, - 0x23504, - 0x9c2, - 0x8f02, - 0x70c2, - 0x105b42, - 0x1482, - 0x107ac2, - 0x8c2, - 0x1eb82, - 0x35542, - 0x682, - 0x1582, - 0xb042, - 0x31b03, - 0x4142, - 0x202, - 0x9342, - 0xdb02, - 0x10702, - 0x30842, - 0x134c2, - 0x42, - 0x4982, - 0x2002, - 0x2243, - 0x3fc2, - 0x7382, - 0xafcc2, - 0xac82, - 0x17382, - 0x3702, - 0x33a82, - 0x6a42, - 0xf842, - 0x16f542, - 0x8b82, - 0xb602, - 0x4c083, + 0x35f83, + 0x48f8b906, + 0x91043, + 0x95c2, + 0x35604, 0xdc2, - 0x9142, + 0x24284, + 0x9c2, + 0x7dc2, + 0x6442, + 0x52f42, + 0x1742, + 0xfc042, + 0x8c2, + 0x19fc2, + 0x33942, + 0x682, + 0x1842, + 0xb0a82, + 0x30743, + 0x3f42, + 0x202, + 0xbc82, + 0x5642, + 0x1a042, + 0x2f542, + 0xd4c2, + 0x42, + 0x4542, 0x1042, - 0x12f42, - 0x49885, - 0xa742, - 0x42242, - 0x3e943, - 0x34c2, - 0xed42, - 0x4042, - 0x2742, - 0x3a02, - 0x5a02, - 0x1bc2, - 0x3f02, - 0x74747, - 0x213f03, + 0x2503, + 0x3dc2, + 0x2602, + 0xaf102, + 0xa482, + 0x120c2, + 0x67c2, + 0x326c2, + 0x8a42, + 0x2242, + 0x16ecc2, + 0x7a42, + 0x2c902, + 0x49943, + 0x1ec2, + 0xba82, + 0x1a82, + 0x10342, + 0x42fc5, + 0x9d02, + 0x3c782, + 0x394c3, + 0x3b82, + 0xb482, + 0x3e42, + 0x1b842, + 0x14202, + 0x6882, + 0x35c2, + 0x3d02, + 0x6fb47, + 0x2115c3, 0x200882, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x215ac3, - 0x232003, - 0x24c083, - 0x2020c3, - 0x204703, - 0x292f83, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x220ec3, - 0x24c083, - 0x2020c3, - 0x204703, - 0x22bf83, - 0x231b03, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, + 0x258403, + 0x230743, + 0x2095c3, + 0x213ac3, + 0x230c43, + 0x249943, + 0x202883, + 0x2257c3, + 0x291083, + 0x894c8, + 0x258403, + 0x230743, + 0x2095c3, + 0x219bc3, + 0x249943, + 0x202883, + 0x2257c3, + 0x258403, + 0x230743, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, 0x200041, - 0x220ec3, - 0x24c083, - 0x20f543, - 0x204703, - 0x327883, - 0x22bf83, - 0x231b03, - 0x2aa943, - 0x20f583, - 0x376b83, - 0x285843, - 0x2a4543, - 0x240383, - 0x250cc3, - 0x2023c4, - 0x24c083, - 0x204703, - 0x2232c3, - 0x341bc4, - 0x22b683, - 0x1e03, - 0x201283, - 0x330d48, - 0x21cec4, - 0x315e4a, - 0x3807c6, - 0xdd704, - 0x3a4107, - 0x22134a, - 0x270dc9, - 0x3b15c7, + 0x219bc3, + 0x249943, + 0x209583, + 0x2257c3, + 0x323743, + 0x258403, + 0x230743, + 0x262e83, + 0x2095c3, + 0x31e683, + 0x281c83, + 0x2a2283, + 0x24c2c3, + 0x2d9d43, + 0x201104, + 0x249943, + 0x2257c3, + 0x224043, + 0x262044, + 0x223a83, + 0x3803, + 0x201543, + 0x365a88, + 0x260c44, + 0x316a4a, + 0x37db06, + 0xdc784, + 0x3a2d07, + 0x21c7ca, + 0x33da89, + 0x3b27c7, 0x20054a, - 0x327883, - 0x38284b, - 0x3292c9, - 0x28dfc5, - 0x2ca587, - 0x6a82, - 0x22bf83, - 0x3583c7, - 0x21e2c5, - 0x2e2989, - 0x231b03, - 0x2257c6, - 0x2b1e83, - 0xe50c3, - 0xfd786, - 0x60346, - 0x3ac7, - 0x214246, - 0x21a385, - 0x20be87, - 0x338647, - 0x4ae50cc3, - 0x32e847, - 0x363a03, - 0x238785, - 0x2023c4, - 0x222788, - 0x2ae00c, - 0x2ad305, - 0x3a30c6, - 0x358287, - 0x20a207, - 0x3b0407, - 0x205688, - 0x27ffcf, - 0x2d2a85, - 0x240cc7, - 0x39f787, - 0x2a340a, - 0x2a9d49, - 0x2d8305, - 0x2dbe4a, - 0x1225c6, - 0x2bb605, - 0x371d44, - 0x2b7886, - 0x300b87, - 0x23b987, - 0x341908, - 0x2025c5, - 0x21e1c6, - 0x203705, - 0x267105, - 0x21e104, - 0x31c107, - 0x33010a, - 0x399d08, - 0x2f0006, - 0x32003, - 0x2cff85, - 0x22b046, + 0x323743, + 0x38000b, + 0x24c209, + 0x2c0385, + 0x2ca9c7, + 0x4a82, + 0x258403, + 0x333687, + 0x20ebc5, + 0x2d7909, + 0x230743, + 0x221a46, + 0x2baf83, + 0xe0b43, + 0xfba46, + 0x52b86, + 0x106a47, + 0x3aa706, + 0x216fc5, + 0x20b147, + 0x336e87, + 0x4b6d9d43, + 0x32cdc7, + 0x3607c3, + 0x27cdc5, + 0x201104, + 0x226808, + 0x2add4c, + 0x2ad045, + 0x364f86, + 0x333547, + 0x399c07, + 0x214247, + 0x2167c8, + 0x29ec8f, + 0x2aed05, + 0x23b487, + 0x28ba87, + 0x2a31ca, + 0x2f1a09, + 0x2da985, + 0x2db14a, + 0x274c6, + 0x2bb005, + 0x371004, + 0x2b7406, + 0x36d007, + 0x236ac7, + 0x353008, + 0x3a9ac5, + 0x20eac6, + 0x3a3dc5, + 0x2212c5, + 0x221744, + 0x33c6c7, + 0x2d1a0a, + 0x38c948, + 0x2ecc06, + 0x30c43, + 0x2cf185, + 0x22b9c6, 0x200346, - 0x262046, - 0x220ec3, - 0x38a747, - 0x39f705, - 0x24c083, - 0x3b184d, - 0x2020c3, - 0x341a08, - 0x3abc04, - 0x278705, - 0x2a3306, - 0x2347c6, - 0x20fbc7, - 0x2a4587, - 0x26c785, - 0x204703, - 0x3977c7, - 0x33b749, - 0x258349, - 0x26cd8a, - 0x244002, - 0x238744, - 0x2d7304, - 0x220c47, - 0x23e148, - 0x2dda89, - 0x3a4749, - 0x2ded47, - 0x2d2586, - 0xe0986, - 0x2e1c44, - 0x2e224a, - 0x2e7808, - 0x2e7f09, - 0x29b1c6, - 0x3028c5, - 0x399bc8, - 0x2c070a, - 0x25ad03, - 0x239406, - 0x2dee47, - 0x2115c5, - 0x3abac5, - 0x25b2c3, - 0x2512c4, - 0x22d145, - 0x286687, - 0x2f28c5, - 0x2edd06, - 0x135d45, - 0x226943, - 0x226949, - 0x2784cc, - 0x2ab3cc, - 0x2c7308, - 0x2995c7, - 0x2f1d48, - 0x2f318a, - 0x2f414b, - 0x329408, - 0x3a31c8, - 0x2032c6, - 0x34d3c5, - 0x31f40a, - 0x217cc5, - 0x2012c2, - 0x2bde07, - 0x26ed46, - 0x355b45, - 0x329f89, - 0x237f45, - 0x2be645, - 0x238349, - 0x22aec6, - 0x3650c8, - 0x35b843, - 0x35b8c6, - 0x277446, - 0x300285, - 0x300289, - 0x2b1989, - 0x244347, - 0x100104, - 0x300107, - 0x3a4649, - 0x221545, - 0x3a688, - 0x366d05, - 0x357885, - 0x22a889, - 0x20b0c2, - 0x22b484, - 0x202882, - 0x203fc2, - 0x33f285, - 0x2dd488, - 0x373085, - 0x2bd703, - 0x2bd705, - 0x2ca943, - 0x212602, - 0x269704, - 0x2344c3, - 0x209242, - 0x35a344, - 0x2d8003, - 0x20d102, - 0x2bd783, - 0x28c784, - 0x2b5c43, - 0x23d444, - 0x202942, - 0x275183, - 0x203a03, - 0x209642, - 0x2eab42, - 0x2b17c9, - 0x207e02, - 0x289ec4, - 0x208b42, - 0x399a44, - 0x2d2544, - 0x2e69c4, - 0x203f02, - 0x202f02, - 0x216483, - 0x2e3c43, - 0x310c04, - 0x262e44, - 0x2b1b84, - 0x2c5584, - 0x2ff383, - 0x2af143, - 0x322544, - 0x301544, - 0x301846, - 0x25b3c2, - 0x206a82, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, + 0x2554c6, + 0x219bc3, + 0x3892c7, + 0x28ba05, + 0x249943, + 0x3b2a4d, + 0x202883, + 0x353108, + 0x3acdc4, + 0x206f05, + 0x2a30c6, + 0x232c46, + 0x20cf07, + 0x2a22c7, + 0x267785, + 0x2257c3, + 0x326c87, + 0x338ec9, + 0x256dc9, + 0x269a0a, + 0x23dfc2, + 0x27cd84, + 0x2d5504, + 0x219947, + 0x238488, + 0x2dbac9, + 0x3a3349, + 0x2dcb07, + 0x2ae806, + 0xdeb06, + 0x2dfdc4, + 0x2e03ca, + 0x2e40c8, + 0x2e47c9, + 0x294a46, + 0x302a85, + 0x38c808, + 0x2c094a, + 0x25a383, + 0x234a06, + 0x2dcc07, + 0x20f545, + 0x3acc85, + 0x23d2c3, + 0x24ccc4, + 0x225b45, + 0x283447, + 0x2fe185, + 0x2e97c6, + 0x12e785, + 0x222bc3, + 0x222bc9, + 0x22ba8c, + 0x2aa18c, + 0x2c7348, + 0x2931c7, + 0x2ef348, + 0x2efeca, + 0x2f104b, + 0x24c348, + 0x365088, + 0x362a06, + 0x322e85, + 0x323dca, + 0x216005, + 0x201582, + 0x2be287, + 0x26cc46, + 0x350c85, + 0x3418c9, + 0x27c585, + 0x381845, + 0x27c989, + 0x22b846, + 0x36d448, + 0x261483, + 0x3aa846, + 0x272f06, + 0x2fed85, + 0x2fed89, + 0x2dc209, + 0x23e307, + 0xfec04, + 0x2fec07, + 0x3a3249, + 0x21c9c5, + 0x2bf88, + 0x352cc5, + 0x3529c5, + 0x22b209, + 0x20e3c2, + 0x223884, + 0x205e42, + 0x203dc2, + 0x2953c5, + 0x2dc508, + 0x377f85, + 0x2bd743, + 0x2bd745, + 0x2cad83, + 0x20fcc2, + 0x266704, + 0x233443, + 0x200d82, + 0x358c44, + 0x2d61c3, + 0x2137c2, + 0x295443, + 0x28acc4, + 0x2b51c3, + 0x2375c4, + 0x203182, + 0x270583, + 0x22e443, + 0x2063c2, + 0x2e74c2, + 0x2dc049, + 0x2030c2, + 0x287c04, + 0x207a02, + 0x38c684, + 0x2ae7c4, + 0x2e2484, + 0x203d02, + 0x2397c2, + 0x210b03, + 0x2f04c3, + 0x23aa84, + 0x261504, + 0x2c5c84, + 0x2dc404, + 0x2fdc83, + 0x346e83, + 0x227444, + 0x2ffa04, + 0x2ffd06, + 0x242f82, + 0x204a82, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, 0x200882, - 0x327883, - 0x22bf83, - 0x231b03, - 0x204543, - 0x250cc3, - 0x2023c4, - 0x2b1a84, - 0x211004, - 0x24c083, - 0x204703, - 0x21d603, - 0x2e4144, - 0x27a003, - 0x2b3003, - 0x347104, - 0x366b06, - 0x208143, - 0x21afc3, - 0x211a83, - 0x2b0d83, - 0x2387c3, - 0x232003, - 0x2298c5, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x2da603, - 0x22e9c3, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x202243, - 0x24c083, - 0x232704, - 0x204703, - 0x29e044, - 0x2b7685, - 0x206a82, - 0x200e42, - 0x20f582, - 0x202b42, - 0x200fc2, - 0x22bf83, - 0x234a44, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x211004, - 0x24c083, - 0x204703, - 0x20b803, - 0x223504, - 0x77a48, - 0x22bf83, - 0x2020c3, - 0x247204, - 0x77a48, - 0x22bf83, - 0x248fc4, - 0x2023c4, - 0x2020c3, - 0x2018c2, - 0x204703, - 0x2298c3, - 0x2ebf05, - 0x2012c2, - 0x301683, + 0x323743, + 0x258403, + 0x230743, + 0x201d03, + 0x2d9d43, + 0x201104, + 0x2dc304, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x219683, + 0x2e0c44, + 0x274903, + 0x2b2483, + 0x341804, + 0x352ac6, + 0x203403, + 0x224f03, + 0x218903, + 0x2b0703, + 0x206f43, + 0x230c43, + 0x2fc2c5, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x2d91c3, + 0x2a3e03, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x202503, + 0x249943, + 0x231344, + 0x2257c3, + 0x29ca84, + 0x2b7205, + 0x204a82, + 0x201802, + 0x2095c2, + 0x201cc2, + 0x2016c2, + 0x258403, + 0x232ec4, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x2161c3, + 0x224284, + 0x894c8, + 0x258403, + 0x202883, + 0x2054c4, + 0x894c8, + 0x258403, + 0x2446c4, + 0x201104, + 0x202883, + 0x202542, + 0x2257c3, + 0x244443, + 0x2e82c5, + 0x201582, + 0x2ffb43, 0x200882, - 0x77a48, - 0x206a82, - 0x231b03, - 0x250cc3, - 0x202002, - 0x204703, + 0x894c8, + 0x204a82, + 0x230743, + 0x2d9d43, + 0x201042, + 0x2257c3, 0x200882, 0x200707, - 0x25ba05, - 0x2ba684, - 0x387ac6, - 0x20540b, - 0x267b89, - 0x3a3006, - 0x340a09, - 0x2b2508, - 0x208243, - 0x77a48, - 0x2286c7, - 0x328148, - 0x345883, - 0x3038c4, - 0x32c10b, - 0x266545, - 0x2f7888, - 0x2ea389, - 0x25a0c3, - 0x22bf83, - 0x204488, - 0x2f0fc7, - 0x345e86, - 0x231b03, - 0x345987, - 0x250cc3, - 0x2598c6, - 0x202243, - 0x22d007, - 0x235947, - 0x390f47, - 0x31c085, - 0x20a8c3, - 0x21038b, - 0x265448, - 0x227c88, - 0x33b906, - 0x344b49, - 0x323887, - 0x2fae85, - 0x3af704, - 0x271008, - 0x234e4a, - 0x235089, - 0x26d4c3, - 0x281485, - 0x28da83, - 0x22c806, - 0x2ba4c4, - 0x300488, - 0x388b8b, - 0x33f145, - 0x2b7406, - 0x2ba3c5, - 0x2baa88, - 0x2bb747, - 0x3b0287, - 0x315a47, - 0x2151c4, - 0x30b3c7, - 0x296746, - 0x220ec3, - 0x2c3b08, - 0x24e2c3, - 0x2cac08, - 0x2d42c5, - 0x3ac0c8, - 0x231d07, - 0x24c083, - 0x245c83, - 0x28ae44, - 0x323b87, - 0x209d83, - 0x235a0b, - 0x2039c3, - 0x24e284, - 0x2ebf88, - 0x204703, - 0x2f2f05, - 0x376a05, - 0x3abfc6, - 0x215c45, - 0x2d4684, - 0x209202, - 0x2e81c3, - 0x371dca, - 0x3a24c3, - 0x271549, - 0x30b0c6, - 0x217f88, - 0x28c2c6, - 0x224d87, - 0x2e8788, - 0x2f2d08, - 0x319043, - 0x373143, - 0x22a3c9, - 0x2f61c3, - 0x349646, - 0x25b686, - 0x2445c6, - 0x397389, - 0x2ffd44, - 0x216c43, - 0x2dbd45, - 0x30c709, - 0x22d103, - 0x2fc404, - 0x362ac4, - 0x212dc4, - 0x294846, - 0x20a403, - 0x20a408, - 0x255448, - 0x2eb306, - 0x2fac8b, - 0x2fafc8, - 0x2fb1cb, - 0x2fdd89, - 0x2fd687, - 0x2fe208, - 0x2fedc3, - 0x2e94c6, - 0x39ab47, - 0x297445, - 0x34d8c9, - 0x34448d, - 0x217dd1, - 0x234905, + 0x24f9c5, + 0x2b9f84, + 0x385a06, + 0x33fe0b, + 0x261209, + 0x364ec6, + 0x33f2c9, + 0x2b1988, + 0x207103, + 0x894c8, + 0x225a07, + 0x370548, + 0x252f03, + 0x337784, + 0x33778b, + 0x260585, + 0x2f4a48, + 0x2e7289, + 0x258e43, + 0x258403, + 0x204288, + 0x2eddc7, + 0x253506, + 0x230743, + 0x253007, + 0x2d9d43, + 0x337f06, + 0x202503, + 0x22e307, + 0x233d47, + 0x390247, + 0x33c645, + 0x209e83, + 0x206d0b, + 0x265588, + 0x22c848, + 0x339086, + 0x264209, + 0x3234c7, + 0x2f9c05, + 0x377284, + 0x33dcc8, + 0x236c4a, + 0x236e89, + 0x33d303, + 0x26abc5, + 0x2aabc3, + 0x22a586, + 0x2b9dc4, + 0x33b0c8, + 0x3903cb, + 0x33d1c5, + 0x2b6f86, + 0x2b9cc5, + 0x2ba388, + 0x2bb147, + 0x365407, + 0x316647, + 0x2127c4, + 0x308a07, + 0x295cc6, + 0x219bc3, + 0x2c4208, + 0x248e83, + 0x2cb048, + 0x2d31c5, + 0x373d88, + 0x230947, + 0x249943, + 0x23fbc3, + 0x2891c4, + 0x30fc47, + 0x209a43, + 0x233e0b, + 0x2141c3, + 0x248e44, + 0x2e8348, + 0x2257c3, + 0x2ea8c5, + 0x31e505, + 0x373c86, + 0x2102c5, + 0x2d3584, + 0x20bb42, + 0x2e4a83, + 0x37108a, + 0x3a20c3, + 0x39fd49, + 0x308706, + 0x214008, + 0x28a806, + 0x220a87, + 0x2e4ec8, + 0x2ea6c8, + 0x319c83, + 0x295483, + 0x275889, + 0x2f3383, + 0x344686, + 0x24f646, + 0x314a86, + 0x3a8b09, + 0x2eaac4, + 0x2112c3, + 0x2da885, + 0x347249, + 0x2249c3, + 0x319b44, + 0x36cb04, + 0x39e084, + 0x2b43c6, + 0x20b4c3, + 0x20b4c8, + 0x2513c8, + 0x2f8e06, + 0x2f9a0b, + 0x2f9d48, + 0x2f9f4b, + 0x2fc689, + 0x2fb947, + 0x2fcb08, + 0x2fd6c3, + 0x22e886, + 0x20f747, + 0x2969c5, + 0x348889, + 0x263b4d, + 0x213e51, + 0x232d85, 0x200882, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x2c8144, - 0x250cc3, - 0x202243, - 0x220ec3, - 0x24c083, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x232003, - 0x24c083, - 0x204703, - 0x263c83, - 0x20b803, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x232003, - 0x24c083, - 0x204703, - 0x212dc2, + 0x204a82, + 0x258403, + 0x230743, + 0x2afc84, + 0x2d9d43, + 0x202503, + 0x219bc3, + 0x249943, + 0x258403, + 0x230743, + 0x2d9d43, + 0x230c43, + 0x249943, + 0x2257c3, + 0x29ca83, + 0x2161c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x230c43, + 0x249943, + 0x2257c3, + 0x21ce42, 0x200141, 0x200882, 0x200001, - 0x311602, - 0x77a48, - 0x21fc45, + 0x312542, + 0x894c8, + 0x21b385, 0x200481, - 0x2bf83, + 0x58403, 0x200741, 0x200081, - 0x201501, - 0x234382, - 0x36a504, - 0x383603, + 0x201181, + 0x233302, + 0x368c84, + 0x381103, 0x2007c1, 0x200901, 0x200041, 0x2001c1, - 0x388e07, - 0x2d49cf, - 0x2cadc6, + 0x390647, + 0x2bda4f, + 0x2d0986, 0x2000c1, - 0x26c046, + 0x25a446, 0x200341, 0x200cc1, - 0x25040e, - 0x200fc1, - 0x204703, + 0x347b0e, + 0x200e81, + 0x2257c3, 0x200ac1, - 0x26f285, - 0x209202, - 0x25b1c5, + 0x26c8c5, + 0x20bb42, + 0x23d1c5, 0x200c01, 0x200241, 0x200a01, - 0x2012c2, + 0x201582, 0x2002c1, - 0x201d01, - 0x2041c1, + 0x203701, + 0x203fc1, 0x200781, 0x200641, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x20b743, - 0x22bf83, - 0x250cc3, - 0x8ce48, - 0x220ec3, - 0x24c083, - 0x204703, - 0x14d9688, - 0x77a48, - 0x45684, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x24c083, - 0x204703, - 0x201e03, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x2c8144, - 0x204703, - 0x297985, - 0x325c04, - 0x22bf83, - 0x24c083, - 0x204703, - 0x206a82, - 0x22bf83, - 0x230509, - 0x231b03, - 0x23db49, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x2e1a48, - 0x21d847, - 0x2ebf05, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x20f0c3, + 0x258403, + 0x2d9d43, + 0x8b2c8, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x14d7f48, + 0x894c8, + 0x3f5c4, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x249943, + 0x2257c3, + 0x203803, + 0x894c8, + 0x258403, + 0x230743, + 0x2afc84, + 0x2257c3, + 0x293485, + 0x328204, + 0x258403, + 0x249943, + 0x2257c3, + 0x27a8a, + 0x204a82, + 0x258403, + 0x22f209, + 0x230743, + 0x237cc9, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x2dfbc8, + 0x214507, + 0x2e82c5, 0x200707, - 0x20540b, - 0x204f48, - 0x340a09, - 0x2286c7, - 0x204488, - 0x2598c6, - 0x235947, - 0x227c88, - 0x33b906, - 0x323887, - 0x235089, - 0x37ab09, - 0x2b7406, - 0x2b9385, - 0x2c3b08, - 0x24e2c3, - 0x2cac08, - 0x231d07, - 0x209d83, - 0x358107, - 0x215c45, - 0x2dd2c8, - 0x264905, - 0x373143, - 0x2c7b49, - 0x2a9bc7, - 0x2fc404, - 0x362ac4, - 0x2fac8b, - 0x2fafc8, - 0x2fd687, - 0x22bf83, - 0x231b03, - 0x20f583, - 0x204703, - 0x22d3c3, - 0x250cc3, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, + 0x33fe0b, + 0x37d448, + 0x33f2c9, + 0x225a07, + 0x204288, + 0x337f06, + 0x233d47, + 0x22c848, + 0x339086, + 0x3234c7, + 0x236e89, + 0x386ac9, + 0x2b6f86, + 0x2b8c85, + 0x2c4208, + 0x248e83, + 0x2cb048, + 0x230947, + 0x209a43, + 0x3333c7, + 0x2102c5, + 0x2daf88, + 0x3554c5, + 0x295483, + 0x2c7b89, + 0x2aaa47, + 0x319b44, + 0x36cb04, + 0x2f9a0b, + 0x2f9d48, + 0x2fb947, + 0x258403, + 0x230743, + 0x2095c3, + 0x2257c3, + 0x225dc3, + 0x2d9d43, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, 0x200882, - 0x206a82, - 0x204703, - 0x77a48, + 0x204a82, + 0x2257c3, + 0x894c8, 0x200882, - 0x206a82, - 0x20f582, - 0x202002, + 0x204a82, + 0x2095c2, + 0x201042, 0x200342, - 0x24c083, - 0x200fc2, + 0x249943, + 0x2016c2, 0x200882, - 0x327883, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x20f582, - 0x250cc3, - 0x202243, - 0x220ec3, - 0x211004, - 0x24c083, - 0x21a883, - 0x204703, - 0x2ffd44, - 0x2232c3, - 0x250cc3, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x2020c3, - 0x204703, - 0x39c8c7, - 0x22bf83, - 0x2555c7, - 0x263506, - 0x203983, - 0x210c43, - 0x250cc3, - 0x2037c3, - 0x2023c4, - 0x377844, - 0x2d4746, - 0x250403, - 0x24c083, - 0x204703, - 0x297985, - 0x20d644, - 0x317f43, - 0x2273c3, - 0x2bde07, - 0x2e34c5, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x209ec2, - 0x34ad43, - 0x237643, - 0x327883, - 0x5522bf83, + 0x323743, + 0x204a82, + 0x258403, + 0x230743, + 0x2095c2, + 0x2d9d43, + 0x202503, + 0x219bc3, + 0x2021c4, + 0x249943, + 0x2174c3, + 0x2257c3, + 0x2eaac4, + 0x224043, + 0x2d9d43, + 0x204a82, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x202883, + 0x2257c3, + 0x39c207, + 0x258403, + 0x251547, + 0x2f0c46, + 0x219443, + 0x20e8c3, + 0x2d9d43, + 0x21bbc3, + 0x201104, + 0x286104, + 0x2d3646, + 0x2284c3, + 0x249943, + 0x2257c3, + 0x293485, + 0x20cd04, + 0x318b43, + 0x223643, + 0x2be287, + 0x2f5545, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x21fd82, + 0x374b43, + 0x27bc83, + 0x323743, + 0x55e58403, + 0x201e02, + 0x230743, + 0x2099c3, + 0x2d9d43, + 0x201104, + 0x265743, + 0x2aed03, + 0x219bc3, + 0x2021c4, + 0x56205702, + 0x249943, + 0x2257c3, + 0x22f903, + 0x242103, + 0x21ce42, + 0x224043, + 0x894c8, + 0x2d9d43, + 0x2ee604, + 0x323743, + 0x204a82, + 0x258403, + 0x232ec4, + 0x230743, + 0x2d9d43, + 0x201104, + 0x202503, + 0x30f384, + 0x30ac84, + 0x2ccc86, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x219683, + 0x26cc46, + 0x1d94b, + 0x1f186, + 0x23e8a, + 0xfd78a, + 0x894c8, + 0x3a3d84, + 0x258403, + 0x323704, + 0x230743, + 0x244f04, + 0x2d9d43, + 0x254943, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x32538b, + 0x39de8a, + 0x3b1c4c, + 0x200882, + 0x204a82, + 0x2095c2, + 0x2a8f85, + 0x201104, + 0x202242, + 0x219bc3, + 0x30ac84, + 0x201cc2, + 0x2016c2, + 0x2057c2, + 0x21ce42, + 0x123743, + 0x2ec0c9, + 0x24f4c8, + 0x35c349, + 0x233b89, + 0x2411ca, + 0x24954a, + 0x20b782, + 0x219fc2, + 0x4a82, + 0x258403, + 0x207802, + 0x23b646, + 0x351c82, 0x200d02, - 0x231b03, - 0x209d03, - 0x250cc3, - 0x2023c4, - 0x265603, - 0x2d2a83, - 0x220ec3, - 0x211004, - 0x5560dbc2, - 0x24c083, - 0x204703, - 0x22a543, - 0x2468c3, - 0x212dc2, - 0x2232c3, - 0x77a48, - 0x250cc3, - 0x2cf584, - 0x327883, - 0x206a82, - 0x22bf83, - 0x234a44, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x202243, - 0x2ce884, - 0x30db04, - 0x2cc586, - 0x211004, - 0x24c083, - 0x204703, - 0x21d603, - 0x26ed46, - 0x18b4b, - 0x1c106, - 0x2310a, - 0xfee8a, - 0x77a48, - 0x2036c4, - 0x22bf83, - 0x327844, - 0x231b03, - 0x24a304, - 0x250cc3, - 0x2614c3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x32104b, - 0x39e40a, - 0x3b0a4c, + 0x3a004e, + 0x2705ce, + 0x27a987, + 0x325e87, + 0x26fc02, + 0x230743, + 0x2d9d43, + 0x203542, + 0x201042, + 0x29e90f, + 0x214082, + 0x2400c7, + 0x339287, + 0x2503c7, + 0x26a14c, + 0x27090c, + 0x204704, + 0x26abca, + 0x2953c2, + 0x20a482, + 0x2b1384, + 0x222942, + 0x2bc382, + 0x270b44, + 0x2175c2, + 0x2120c2, + 0x339107, + 0x224945, + 0x2326c2, + 0x29e884, + 0x36ecc2, + 0x2cee08, + 0x249943, + 0x3a9008, + 0x208fc2, + 0x231c05, + 0x3a92c6, + 0x2257c3, + 0x209d02, + 0x2dbd07, + 0xbb42, + 0x26ff05, + 0x394505, + 0x203ec2, + 0x225742, + 0x31710a, + 0x26760a, + 0x219b82, + 0x2fbf44, + 0x2013c2, + 0x27cc48, + 0x20a242, + 0x22dec8, + 0x2f61c7, + 0x2f64c9, + 0x26ff82, + 0x2fc8c5, + 0x24f985, + 0x2c154b, + 0x2c228c, + 0x22e188, + 0x2fcc88, + 0x242f82, + 0x20cfc2, 0x200882, - 0x206a82, - 0x20f582, - 0x2a8e05, - 0x2023c4, - 0x20f842, - 0x220ec3, - 0x30db04, - 0x202b42, - 0x200fc2, - 0x203682, - 0x212dc2, - 0x127883, - 0x35ecc9, - 0x25b508, - 0x33a1c9, - 0x235789, - 0x23cc0a, - 0x255f4a, - 0x20a1c2, - 0x21eb82, - 0x6a82, - 0x22bf83, - 0x208942, - 0x240e86, - 0x356b42, - 0x218982, - 0x27184e, - 0x2751ce, - 0x27f787, - 0x3804c7, - 0x274802, - 0x231b03, - 0x250cc3, - 0x201b42, - 0x202002, - 0x233fcf, - 0x205482, - 0x23bb07, - 0x33bb07, - 0x365587, - 0x24dbcc, - 0x253f4c, - 0x204b44, - 0x28148a, - 0x28da82, - 0x20ac82, - 0x2b1f04, - 0x2266c2, - 0x2bc342, - 0x254184, - 0x21a982, - 0x217382, - 0x33b987, - 0x27fec5, - 0x233a82, - 0x233f44, - 0x36f542, - 0x2ce2c8, - 0x24c083, - 0x3b2248, - 0x201082, - 0x232fc5, - 0x324146, - 0x204703, - 0x20a742, - 0x2ddcc7, - 0x9202, - 0x274b05, - 0x393f45, - 0x2040c2, - 0x22b382, - 0x31650a, - 0x26c60a, - 0x20b5c2, - 0x320784, - 0x201f02, - 0x238608, - 0x20a302, - 0x33b148, - 0x2f7bc7, - 0x2f7ec9, - 0x274b82, - 0x2fdfc5, - 0x25b9c5, - 0x2c13cb, - 0x2c210c, - 0x22ce88, - 0x2fe388, - 0x25b3c2, - 0x20fc82, + 0x894c8, + 0x204a82, + 0x258403, + 0x2095c2, + 0x201cc2, + 0x2016c2, + 0x2257c3, + 0x2057c2, 0x200882, - 0x77a48, - 0x206a82, - 0x22bf83, - 0x20f582, - 0x202b42, - 0x200fc2, - 0x204703, - 0x203682, + 0x58204a82, + 0x586d9d43, + 0x332283, + 0x202242, + 0x249943, + 0x39a3c3, + 0x2257c3, + 0x2d8843, + 0x26fc46, + 0x16161c3, + 0x894c8, + 0x555c5, + 0x65b07, + 0x58e00182, + 0x59200dc2, + 0x59603442, + 0x59a00f82, + 0x59e0dec2, + 0x5a201742, + 0x5a604a82, + 0x5aa06082, + 0x5ae1dd82, + 0x5b201842, + 0x2705c3, + 0xb444, + 0x2017c3, + 0x5b616342, + 0x5ba022c2, + 0x44c07, + 0x5be2c282, + 0x5c200902, + 0x5c60b642, + 0x5ca0b9c2, + 0x5ce04542, + 0x5d201042, + 0xba545, + 0x222383, + 0x31ca44, + 0x5d622942, + 0x5da34082, + 0x5de00102, + 0x77a0b, + 0x5e200982, + 0x5ea0a582, + 0x5ee02242, + 0x5f200342, + 0x5f653702, + 0x5fa08f82, + 0x5fe0dc02, + 0x60207a42, + 0x60605702, + 0x60a00cc2, + 0x60e01cc2, + 0x61227982, + 0x6160d302, + 0x61a3d982, + 0x132d84, + 0x319c43, + 0x61e092c2, + 0x62213e02, + 0x62601ac2, + 0x62a02102, + 0x62e016c2, + 0x63200d82, + 0xda747, + 0x63605fc2, + 0x63a024c2, + 0x63e057c2, + 0x64205202, + 0xe9f0c, + 0x6461f6c2, + 0x64a712c2, + 0x64e00f02, + 0x65201502, + 0x656049c2, + 0x65a41342, + 0x65e03702, + 0x6620eb42, + 0x66673282, + 0x66a736c2, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x5e665743, + 0x27da43, + 0x2fc344, + 0x24f3c6, + 0x2e4b43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x265743, + 0x27da43, + 0x200482, + 0x200482, + 0x265743, + 0x27da43, + 0x67258403, + 0x230743, + 0x365d83, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x894c8, + 0x204a82, + 0x258403, + 0x249943, + 0x2257c3, + 0x258403, + 0x230743, + 0x2d9d43, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x2054c4, + 0x204a82, + 0x258403, + 0x356443, + 0x230743, + 0x2446c4, + 0x2095c3, + 0x2d9d43, + 0x201104, + 0x202503, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x244443, + 0x2e82c5, + 0x27c343, + 0x224043, + 0x204a82, + 0x258403, + 0x265743, + 0x249943, + 0x2257c3, 0x200882, - 0x57606a82, - 0x57a50cc3, - 0x39a883, - 0x20f842, - 0x24c083, - 0x3a2c03, - 0x204703, - 0x2d9f83, - 0x274846, - 0x160b803, - 0x77a48, - 0x62145, - 0x6ae47, - 0x58200182, - 0x58600ec2, - 0x58a01e02, - 0x58e02902, - 0x592136c2, - 0x59601482, - 0x59a06a82, - 0x59e0e542, - 0x5a221982, - 0x5a601582, - 0x2751c3, - 0x201503, - 0x5aa17982, - 0x5ae01c82, - 0x49507, - 0x5b233602, - 0x5b600902, - 0x5ba048c2, - 0x5be0b542, - 0x5c204982, - 0x5c602002, - 0xbac45, - 0x226103, - 0x20b504, - 0x5ca266c2, - 0x5ce35c82, - 0x5d200102, - 0x7c80b, - 0x5d600982, - 0x5de0ad82, - 0x5e20f842, - 0x5e600342, - 0x5ea50702, - 0x5ee02ac2, - 0x5f203642, - 0x5f608b82, - 0x5fa0dbc2, - 0x5fe00cc2, - 0x60202b42, - 0x606353c2, - 0x60a02d82, - 0x60e43482, - 0x14c104, - 0x2d2fc3, - 0x61211382, - 0x61619d02, - 0x61a052c2, - 0x61e03502, - 0x62200fc2, - 0x62609242, - 0xdbc07, - 0x62a08582, - 0x62e05fc2, - 0x63203682, - 0x6364ecc2, - 0xed54c, - 0x63a1c642, - 0x63e75bc2, - 0x642076c2, - 0x64601242, - 0x64a0c402, - 0x64e3cd82, - 0x65201d02, - 0x65603b82, - 0x65a777c2, - 0x65e4ffc2, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x5da65603, - 0x2805c3, - 0x229944, - 0x25b406, - 0x2e8283, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x265603, - 0x2805c3, - 0x200482, - 0x200482, - 0x265603, - 0x2805c3, - 0x6662bf83, - 0x231b03, - 0x331043, - 0x220ec3, - 0x24c083, - 0x204703, - 0x77a48, - 0x206a82, - 0x22bf83, - 0x24c083, - 0x204703, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x220ec3, - 0x24c083, - 0x204703, - 0x247204, - 0x206a82, - 0x22bf83, - 0x2cfe43, - 0x231b03, - 0x248fc4, - 0x20f583, - 0x250cc3, - 0x2023c4, - 0x202243, - 0x220ec3, - 0x24c083, - 0x204703, - 0x2298c3, - 0x2ebf05, - 0x237d03, - 0x2232c3, - 0x206a82, - 0x22bf83, - 0x265603, - 0x24c083, - 0x204703, + 0x323743, + 0x894c8, + 0x258403, + 0x230743, + 0x2d9d43, + 0x2e0006, + 0x201104, + 0x202503, + 0x2021c4, + 0x249943, + 0x2257c3, + 0x219683, + 0x258403, + 0x230743, + 0x249943, + 0x2257c3, + 0x258403, + 0x1f186, + 0x230743, + 0x2d9d43, + 0xd0d86, + 0x249943, + 0x2257c3, + 0x307288, + 0x30a189, + 0x31a149, + 0x32adc8, + 0x37ab88, + 0x37ab89, + 0x33305, 0x200882, - 0x327883, - 0x77a48, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x22fb86, - 0x2023c4, - 0x202243, - 0x211004, - 0x24c083, - 0x204703, - 0x21d603, - 0x22bf83, - 0x231b03, - 0x24c083, - 0x204703, - 0x22bf83, - 0x1c106, - 0x231b03, - 0x250cc3, - 0xd19c6, - 0x24c083, - 0x204703, - 0x309748, - 0x30d009, - 0x319509, - 0x329dc8, - 0x37d6c8, - 0x37d6c9, - 0x34385, + 0x2f5385, + 0x22eb43, + 0x69e04a82, + 0x230743, + 0x2d9d43, + 0x225847, + 0x206f43, + 0x219bc3, + 0x249943, + 0x209583, + 0x20dd83, + 0x202883, + 0x2257c3, + 0x236286, + 0x201582, + 0x224043, + 0x894c8, 0x200882, - 0x2e3305, - 0x22fc03, - 0x69206a82, - 0x231b03, - 0x250cc3, - 0x22c947, - 0x2387c3, - 0x220ec3, - 0x24c083, - 0x20f543, - 0x213583, - 0x2020c3, - 0x204703, - 0x23b346, - 0x2012c2, - 0x2232c3, - 0x77a48, - 0x200882, - 0x327883, - 0x206a82, - 0x22bf83, - 0x231b03, - 0x250cc3, - 0x2023c4, - 0x220ec3, - 0x24c083, - 0x204703, - 0x20b803, + 0x323743, + 0x204a82, + 0x258403, + 0x230743, + 0x2d9d43, + 0x201104, + 0x219bc3, + 0x249943, + 0x2257c3, + 0x2161c3, } // children is the list of nodes' children, the parent's wildcard bit and the @@ -8606,368 +8620,371 @@ var children = [...]uint32{ 0x1ff07fb, 0x20247fc, 0x2028809, - 0x244880a, - 0x22498912, - 0x2249c926, - 0x24c4927, - 0x24cc931, - 0x224d0933, - 0x24d8934, - 0x224e8936, - 0x224ec93a, - 0x24f893b, - 0x24fc93e, - 0x2250093f, - 0x251c940, - 0x2534947, - 0x253894d, - 0x254894e, - 0x2550952, - 0x22584954, - 0x2588961, - 0x2598962, - 0x25c4966, - 0x25dc971, - 0x25f0977, - 0x261897c, - 0x2638986, - 0x266898e, - 0x269099a, - 0x26949a4, - 0x26b89a5, - 0x26bc9ae, - 0x26d09af, - 0x26d49b4, - 0x26d89b5, - 0x26f89b6, - 0x26fc9be, - 0x270c9bf, - 0x27809c3, - 0x279c9e0, - 0x27a89e7, - 0x27bc9ea, - 0x27d49ef, - 0x27e89f5, - 0x28009fa, - 0x2818a00, - 0x2830a06, - 0x284ca0c, - 0x2864a13, - 0x28c4a19, - 0x28dca31, - 0x28f0a37, - 0x2934a3c, - 0x29b4a4d, - 0x29e0a6d, - 0x29e4a78, - 0x29eca79, - 0x2a0ca7b, - 0x2a10a83, - 0x2a2ca84, - 0x2a34a8b, - 0x2a68a8d, - 0x2aa0a9a, - 0x2aa4aa8, - 0x2ad0aa9, - 0x2ae8ab4, - 0x2b0caba, - 0x2b2cac3, - 0x30f0acb, - 0x30fcc3c, - 0x311cc3f, - 0x32d8c47, - 0x33a8cb6, - 0x3418cea, - 0x3470d06, - 0x3558d1c, - 0x35b0d56, - 0x35ecd6c, - 0x36e8d7b, - 0x37b4dba, - 0x384cded, - 0x38dce13, - 0x3940e37, - 0x3b78e50, - 0x3c30ede, - 0x3cfcf0c, - 0x3d48f3f, - 0x3dd0f52, - 0x3e0cf74, - 0x3e5cf83, - 0x3ed4f97, - 0x63ed8fb5, - 0x63edcfb6, - 0x63ee0fb7, - 0x3f5cfb8, - 0x3fc0fd7, - 0x403cff0, - 0x40b500f, - 0x413502d, - 0x41a104d, - 0x42cd068, - 0x43250b3, - 0x643290c9, - 0x43c10ca, - 0x44490f0, - 0x4495112, - 0x44fd125, - 0x45a513f, - 0x466d169, - 0x46d519b, - 0x47e91b5, - 0x647ed1fa, - 0x647f11fb, - 0x484d1fc, - 0x48a9213, - 0x493922a, - 0x49b524e, - 0x49f926d, - 0x4add27e, - 0x4b112b7, - 0x4b712c4, - 0x4be52dc, - 0x4c6d2f9, - 0x4cad31b, - 0x4d1d32b, - 0x64d21347, - 0x64d25348, - 0x24d29349, - 0x4d4134a, - 0x4d5d350, - 0x4da1357, - 0x4db1368, - 0x4dc936c, - 0x4e41372, - 0x4e55390, - 0x4e6d395, - 0x4e9139b, - 0x4ea53a4, - 0x4ec13a9, - 0x4ec53b0, - 0x4ecd3b1, - 0x4f093b3, - 0x4f1d3c2, - 0x4f253c7, - 0x4f2d3c9, - 0x4f313cb, - 0x4f553cc, - 0x4f793d5, - 0x4f913de, - 0x4f953e4, - 0x4f9d3e5, - 0x4fa13e7, - 0x4ff53e8, - 0x50193fd, - 0x5039406, - 0x505540e, - 0x5065415, - 0x5079419, - 0x507d41e, - 0x508541f, - 0x5099421, - 0x50a9426, - 0x50ad42a, - 0x50c942b, - 0x5959432, - 0x5991656, - 0x59bd664, - 0x59d566f, - 0x59f5675, - 0x659f967d, - 0x5a3d67e, - 0x5a4568f, - 0x25a49691, - 0x25a4d692, - 0x5a51693, - 0x5b71694, - 0x25b756dc, - 0x25b7d6dd, - 0x25b856df, - 0x25b916e1, - 0x5b956e4, - 0x5bbd6e5, - 0x5be56ef, - 0x5be96f9, - 0x25c216fa, - 0x5c31708, - 0x678970c, - 0x678d9e2, - 0x67919e3, - 0x267959e4, - 0x67999e5, - 0x2679d9e6, - 0x67a19e7, - 0x267ad9e8, - 0x67b19eb, - 0x67b59ec, - 0x267b99ed, + 0x245880a, + 0x224a8916, + 0x224ac92a, + 0x24d492b, + 0x24dc935, + 0x224e0937, + 0x24e8938, + 0x224f893a, + 0x224fc93e, + 0x250893f, + 0x250c942, + 0x22510943, + 0x252c944, + 0x254494b, + 0x2548951, + 0x2558952, + 0x2560956, + 0x22594958, + 0x2598965, + 0x25a8966, + 0x25d496a, + 0x25ec975, + 0x260097b, + 0x2628980, + 0x264898a, + 0x2678992, + 0x26a099e, + 0x26a49a8, + 0x26c89a9, + 0x26cc9b2, + 0x26e09b3, + 0x26e49b8, + 0x26e89b9, + 0x27089ba, + 0x270c9c2, + 0x271c9c3, + 0x27909c7, + 0x27ac9e4, + 0x27b89eb, + 0x27cc9ee, + 0x27e49f3, + 0x27f89f9, + 0x28109fe, + 0x2828a04, + 0x2840a0a, + 0x285ca10, + 0x2874a17, + 0x28d4a1d, + 0x28eca35, + 0x2900a3b, + 0x2944a40, + 0x29c4a51, + 0x29f0a71, + 0x29f4a7c, + 0x29fca7d, + 0x2a1ca7f, + 0x2a20a87, + 0x2a3ca88, + 0x2a44a8f, + 0x2a78a91, + 0x2ab0a9e, + 0x2ab4aac, + 0x2af0aad, + 0x2b08abc, + 0x2b2cac2, + 0x2b4cacb, + 0x3110ad3, + 0x311cc44, + 0x313cc47, + 0x32f8c4f, + 0x33c8cbe, + 0x3438cf2, + 0x3490d0e, + 0x3578d24, + 0x35d0d5e, + 0x360cd74, + 0x3708d83, + 0x37d4dc2, + 0x386cdf5, + 0x38fce1b, + 0x3960e3f, + 0x3b98e58, + 0x3c50ee6, + 0x3d1cf14, + 0x3d68f47, + 0x3df0f5a, + 0x3e2cf7c, + 0x3e7cf8b, + 0x3ef4f9f, + 0x63ef8fbd, + 0x63efcfbe, + 0x63f00fbf, + 0x3f7cfc0, + 0x3fe0fdf, + 0x405cff8, + 0x40d5017, + 0x4155035, + 0x41c1055, + 0x42ed070, + 0x43450bb, + 0x643490d1, + 0x43e10d2, + 0x44690f8, + 0x44b511a, + 0x451d12d, + 0x45c5147, + 0x468d171, + 0x46f51a3, + 0x48091bd, + 0x6480d202, + 0x64811203, + 0x486d204, + 0x48c921b, + 0x4959232, + 0x49d5256, + 0x4a19275, + 0x4afd286, + 0x4b312bf, + 0x4b912cc, + 0x4c052e4, + 0x4c8d301, + 0x4ccd323, + 0x4d3d333, + 0x64d4134f, + 0x64d45350, + 0x24d49351, + 0x4d61352, + 0x4d7d358, + 0x4dc135f, + 0x4dd1370, + 0x4de9374, + 0x4e6137a, + 0x4e75398, + 0x4e8d39d, + 0x4eb13a3, + 0x4eb53ac, + 0x4ebd3ad, + 0x4ed13af, + 0x4eed3b4, + 0x4ef13bb, + 0x4ef93bc, + 0x4f353be, + 0x4f493cd, + 0x4f513d2, + 0x4f593d4, + 0x4f5d3d6, + 0x4f813d7, + 0x4fa53e0, + 0x4fbd3e9, + 0x4fc13ef, + 0x4fc93f0, + 0x4fcd3f2, + 0x50213f3, + 0x5045408, + 0x5065411, + 0x5081419, + 0x5091420, + 0x50a5424, + 0x50a9429, + 0x50b142a, + 0x50c542c, + 0x50d5431, + 0x50d9435, + 0x50f5436, + 0x598543d, + 0x59bd661, + 0x59e966f, + 0x5a0167a, + 0x5a21680, + 0x65a25688, + 0x5a69689, + 0x5a7169a, + 0x25a7569c, + 0x25a7969d, + 0x5a7d69e, + 0x5b9d69f, + 0x25ba16e7, + 0x25ba96e8, + 0x25bb16ea, + 0x25bbd6ec, + 0x5bc16ef, + 0x5be96f0, + 0x5c116fa, + 0x5c15704, + 0x25c4d705, + 0x5c5d713, + 0x67b5717, + 0x67b99ed, 0x67bd9ee, - 0x267c59ef, - 0x67c99f1, + 0x267c19ef, + 0x67c59f0, + 0x267c99f1, 0x67cd9f2, - 0x267dd9f3, + 0x267d99f3, + 0x67dd9f6, 0x67e19f7, - 0x67e59f8, + 0x267e59f8, 0x67e99f9, - 0x67ed9fa, - 0x267f19fb, + 0x267f19fa, 0x67f59fc, 0x67f99fd, - 0x67fd9fe, - 0x68019ff, - 0x26809a00, + 0x268099fe, 0x680da02, 0x6811a03, 0x6815a04, - 0x26819a05, - 0x681da06, - 0x26825a07, - 0x26829a09, - 0x6845a0a, - 0x6851a11, - 0x6891a14, - 0x6895a24, - 0x68b9a25, - 0x69fda2e, - 0x26a05a7f, - 0x26a09a81, - 0x26a0da82, - 0x6a15a83, - 0x6af1a85, - 0x6af5abc, - 0x6b21abd, - 0x6b41ac8, - 0x6b4dad0, + 0x6819a05, + 0x2681da06, + 0x6821a07, + 0x6825a08, + 0x6829a09, + 0x682da0a, + 0x26835a0b, + 0x6839a0d, + 0x683da0e, + 0x6841a0f, + 0x26845a10, + 0x6849a11, + 0x26851a12, + 0x26855a14, + 0x6871a15, + 0x687da1c, + 0x68bda1f, + 0x68c1a2f, + 0x68e5a30, + 0x6a29a39, + 0x26a31a8a, + 0x26a35a8c, + 0x26a39a8d, + 0x6a41a8e, + 0x6b1da90, + 0x6b21ac7, + 0x6b4dac8, 0x6b6dad3, - 0x6ba5adb, - 0x6e3dae9, - 0x6ef9b8f, - 0x6f0dbbe, - 0x6f41bc3, - 0x6f6dbd0, - 0x6f89bdb, - 0x6fadbe2, - 0x6fc5beb, - 0x6fe1bf1, - 0x7005bf8, - 0x7015c01, - 0x7045c05, - 0x7061c11, - 0x726dc18, - 0x7291c9b, - 0x72b1ca4, - 0x72c5cac, - 0x72d9cb1, - 0x72f9cb6, - 0x739dcbe, - 0x73b9ce7, - 0x73d5cee, - 0x73d9cf5, - 0x73ddcf6, - 0x73e1cf7, - 0x73f5cf8, - 0x7415cfd, - 0x7421d05, - 0x7451d08, - 0x74d1d14, - 0x74e5d34, - 0x74e9d39, - 0x7501d3a, - 0x750dd40, - 0x7511d43, - 0x752dd44, - 0x7569d4b, - 0x756dd5a, - 0x758dd5b, - 0x75ddd63, - 0x75f5d77, - 0x7649d7d, - 0x764dd92, - 0x7651d93, - 0x7695d94, - 0x76a5da5, - 0x76ddda9, - 0x770ddb7, - 0x7849dc3, - 0x786de12, - 0x7899e1b, - 0x78a1e26, - 0x78a5e28, - 0x79ade29, - 0x79b9e6b, - 0x79c5e6e, - 0x79d1e71, - 0x79dde74, - 0x79e9e77, - 0x79f5e7a, - 0x7a01e7d, - 0x7a0de80, - 0x7a19e83, - 0x7a25e86, - 0x7a31e89, - 0x7a3de8c, - 0x7a49e8f, - 0x7a51e92, - 0x7a5de94, - 0x7a69e97, - 0x7a75e9a, - 0x7a81e9d, - 0x7a8dea0, - 0x7a99ea3, - 0x7aa5ea6, - 0x7ab1ea9, - 0x7abdeac, - 0x7ac9eaf, - 0x7ad5eb2, - 0x7ae1eb5, - 0x7aedeb8, - 0x7af9ebb, - 0x7b05ebe, - 0x7b11ec1, - 0x7b1dec4, - 0x7b25ec7, - 0x7b31ec9, - 0x7b3decc, - 0x7b49ecf, - 0x7b55ed2, - 0x7b61ed5, - 0x7b6ded8, - 0x7b79edb, - 0x7b85ede, - 0x7b91ee1, - 0x7b9dee4, - 0x7ba9ee7, - 0x7bb5eea, - 0x7bc1eed, - 0x7bc9ef0, - 0x7bd5ef2, - 0x7be1ef5, - 0x7bedef8, - 0x7bf9efb, - 0x7c05efe, - 0x7c11f01, - 0x7c1df04, - 0x7c29f07, - 0x7c2df0a, + 0x6b79adb, + 0x6b99ade, + 0x6bd1ae6, + 0x6e69af4, + 0x6f25b9a, + 0x6f39bc9, + 0x6f6dbce, + 0x6f99bdb, + 0x6fb5be6, + 0x6fd9bed, + 0x6ff1bf6, + 0x700dbfc, + 0x7031c03, + 0x7041c0c, + 0x7071c10, + 0x708dc1c, + 0x7299c23, + 0x72bdca6, + 0x72ddcaf, + 0x72f1cb7, + 0x7305cbc, + 0x7325cc1, + 0x73c9cc9, + 0x73e5cf2, + 0x7401cf9, + 0x7405d00, + 0x7409d01, + 0x740dd02, + 0x7421d03, + 0x7441d08, + 0x744dd10, + 0x7451d13, + 0x7481d14, + 0x7501d20, + 0x7515d40, + 0x7519d45, + 0x7531d46, + 0x753dd4c, + 0x7541d4f, + 0x755dd50, + 0x7599d57, + 0x759dd66, + 0x75bdd67, + 0x760dd6f, + 0x7625d83, + 0x7679d89, + 0x767dd9e, + 0x7681d9f, + 0x76c5da0, + 0x76d5db1, + 0x770ddb5, + 0x773ddc3, + 0x7879dcf, + 0x789de1e, + 0x78c9e27, + 0x78d1e32, + 0x78d5e34, + 0x79e1e35, + 0x79ede78, + 0x79f9e7b, + 0x7a05e7e, + 0x7a11e81, + 0x7a1de84, + 0x7a29e87, + 0x7a35e8a, + 0x7a41e8d, + 0x7a4de90, + 0x7a59e93, + 0x7a65e96, + 0x7a71e99, + 0x7a7de9c, + 0x7a85e9f, + 0x7a91ea1, + 0x7a9dea4, + 0x7aa9ea7, + 0x7ab5eaa, + 0x7ac1ead, + 0x7acdeb0, + 0x7ad9eb3, + 0x7ae5eb6, + 0x7af1eb9, + 0x7afdebc, + 0x7b09ebf, + 0x7b15ec2, + 0x7b21ec5, + 0x7b2dec8, + 0x7b39ecb, + 0x7b45ece, + 0x7b51ed1, + 0x7b59ed4, + 0x7b65ed6, + 0x7b71ed9, + 0x7b7dedc, + 0x7b89edf, + 0x7b95ee2, + 0x7ba1ee5, + 0x7badee8, + 0x7bb9eeb, + 0x7bc5eee, + 0x7bd1ef1, + 0x7bddef4, + 0x7be9ef7, + 0x7bf5efa, + 0x7bfdefd, + 0x7c09eff, + 0x7c15f02, + 0x7c21f05, + 0x7c2df08, 0x7c39f0b, - 0x7c51f0e, - 0x7c55f14, - 0x7c65f15, - 0x7c7df19, - 0x7cc1f1f, - 0x7cd5f30, - 0x7d09f35, - 0x7d19f42, - 0x7d35f46, - 0x7d4df4d, - 0x7d51f53, - 0x27d95f54, - 0x7d99f65, - 0x7dc5f66, + 0x7c45f0e, + 0x7c51f11, + 0x7c5df14, + 0x7c61f17, + 0x7c6df18, + 0x7c85f1b, + 0x7c89f21, + 0x7c99f22, + 0x7cb1f26, + 0x7cf5f2c, + 0x7d09f3d, + 0x7d3df42, + 0x7d4df4f, + 0x7d69f53, + 0x7d81f5a, + 0x7d85f60, + 0x27dc9f61, + 0x7dcdf72, + 0x7df9f73, } -// max children 421 (capacity 511) -// max text offset 27811 (capacity 32767) +// max children 424 (capacity 511) +// max text offset 27866 (capacity 32767) // max text length 36 (capacity 63) -// max hi 8049 (capacity 16383) -// max lo 8038 (capacity 16383) +// max hi 8062 (capacity 16383) +// max lo 8051 (capacity 16383) diff --git a/vendor/golang.org/x/net/publicsuffix/table_test.go b/vendor/golang.org/x/net/publicsuffix/table_test.go index 2c974762..9e921e71 100644 --- a/vendor/golang.org/x/net/publicsuffix/table_test.go +++ b/vendor/golang.org/x/net/publicsuffix/table_test.go @@ -7296,10 +7296,10 @@ var rules = [...]string{ "us-gov-west-1.compute.amazonaws.com", "us-west-1.compute.amazonaws.com", "us-west-2.compute.amazonaws.com", - "us-east-1.amazonaws.com", "compute-1.amazonaws.com", "z-1.compute-1.amazonaws.com", "z-2.compute-1.amazonaws.com", + "us-east-1.amazonaws.com", "compute.amazonaws.com.cn", "cn-north-1.compute.amazonaws.com.cn", "elasticbeanstalk.com", @@ -7322,13 +7322,16 @@ var rules = [...]string{ "s3.cn-north-1.amazonaws.com.cn", "s3.eu-central-1.amazonaws.com", "on-aptible.com", - "potager.org", - "poivron.org", - "sweetpepper.org", "pimienta.org", + "poivron.org", + "potager.org", + "sweetpepper.org", + "myasustor.com", "myfritz.net", + "backplaneapp.io", "betainabox.com", "boxfuse.io", + "browsersafetymark.io", "mycd.eu", "ae.org", "ar.com", @@ -7394,6 +7397,8 @@ var rules = [...]string{ "dnshome.de", "dreamhosters.com", "mydrobo.com", + "drud.io", + "drud.us", "duckdns.org", "dy.fi", "tunk.org", @@ -7761,6 +7766,7 @@ var rules = [...]string{ "*.ext.githubcloud.com", "gist.githubcloud.com", "*.githubcloudusercontent.com", + "gitlab.io", "ro.com", "goip.de", "*.0emm.com", @@ -7973,6 +7979,9 @@ var rules = [...]string{ "priv.at", "chirurgiens-dentistes-en-france.fr", "qa2.com", + "dev-myqnapcloud.com", + "alpha-myqnapcloud.com", + "myqnapcloud.com", "rackmaze.com", "rackmaze.net", "rhcloud.com", @@ -7990,7 +7999,11 @@ var rules = [...]string{ "bounty-full.com", "alpha.bounty-full.com", "beta.bounty-full.com", + "static.land", + "dev.static.land", + "sites.static.land", "spacekit.io", + "stackspace.space", "diskstation.me", "dscloud.biz", "dscloud.me", @@ -10086,6 +10099,7 @@ var nodeLabels = [...]string{ "3utilities", "4u", "africa", + "alpha-myqnapcloud", "amazonaws", "appspot", "ar", @@ -10106,6 +10120,7 @@ var nodeLabels = [...]string{ "damnserver", "ddnsking", "de", + "dev-myqnapcloud", "ditchyourip", "dnsalias", "dnsdojo", @@ -10280,7 +10295,9 @@ var nodeLabels = [...]string{ "meteorapp", "mex", "myactivedirectory", + "myasustor", "mydrobo", + "myqnapcloud", "mysecuritycamera", "myshopblocks", "myvnc", @@ -10752,10 +10769,14 @@ var nodeLabels = [...]string{ "selfip", "webhop", "eu", + "backplaneapp", "boxfuse", + "browsersafetymark", "com", "dedyn", + "drud", "github", + "gitlab", "hasura-app", "hzc", "ngrok", @@ -13051,6 +13072,9 @@ var nodeLabels = [...]string{ "net", "org", "per", + "static", + "dev", + "sites", "com", "edu", "gov", @@ -15455,6 +15479,7 @@ var nodeLabels = [...]string{ "com", "net", "org", + "stackspace", "co", "com", "consulado", @@ -15755,6 +15780,7 @@ var nodeLabels = [...]string{ "dc", "de", "dni", + "drud", "fed", "fl", "ga",